Grid Progress
This commit is contained in:
		@@ -11,6 +11,7 @@ target_sources(${DAWN_TARGET_NAME}
 | 
			
		||||
    UILabel.cpp
 | 
			
		||||
    UIImage.cpp
 | 
			
		||||
    UIBorder.cpp
 | 
			
		||||
    UIGrid.cpp
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
add_subdirectory(menu)
 | 
			
		||||
@@ -4,6 +4,7 @@
 | 
			
		||||
// https://opensource.org/licenses/MIT
 | 
			
		||||
 | 
			
		||||
#include "UIComponent.hpp"
 | 
			
		||||
#include "UIGrid.hpp"
 | 
			
		||||
 | 
			
		||||
using namespace Dawn;
 | 
			
		||||
 | 
			
		||||
@@ -32,11 +33,22 @@ void UIComponent::updateAlignment() {
 | 
			
		||||
  auto dimensional = this->getParentDimensional();
 | 
			
		||||
  auto translate = this->transform->getLocalPosition();
 | 
			
		||||
 | 
			
		||||
  float_t parentWidth, parentHeight, parentX, parentY;
 | 
			
		||||
  auto dimensionalAsGrid = dynamic_cast<UIGrid*>(dimensional);
 | 
			
		||||
  if(dimensionalAsGrid != nullptr) {
 | 
			
		||||
    std::cout << "TEST" << std::endl;
 | 
			
		||||
  } else {
 | 
			
		||||
    parentWidth = dimensional->getWidth();
 | 
			
		||||
    parentHeight = dimensional->getHeight();
 | 
			
		||||
    parentX = 0;
 | 
			
		||||
    parentY = 0;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  UIComponent::calculateDimensions(
 | 
			
		||||
    this->alignX,
 | 
			
		||||
    &translate.x,
 | 
			
		||||
    &this->width,
 | 
			
		||||
    dimensional->getWidth(),
 | 
			
		||||
    parentWidth,
 | 
			
		||||
    this->getContentWidth(),
 | 
			
		||||
    glm::vec2(align[0], align[2])
 | 
			
		||||
  );
 | 
			
		||||
@@ -44,10 +56,13 @@ void UIComponent::updateAlignment() {
 | 
			
		||||
    this->alignY,
 | 
			
		||||
    &translate.y,
 | 
			
		||||
    &this->height,
 | 
			
		||||
    dimensional->getHeight(),
 | 
			
		||||
    parentHeight,
 | 
			
		||||
    this->getContentHeight(),
 | 
			
		||||
    glm::vec2(align[1], align[3])
 | 
			
		||||
  );
 | 
			
		||||
  
 | 
			
		||||
  translate.x += parentX;
 | 
			
		||||
  translate.y += parentY;
 | 
			
		||||
 | 
			
		||||
  this->transform->setLocalPosition(translate);
 | 
			
		||||
  this->alignmentNeedsUpdating = false;
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										30
									
								
								src/dawn/scene/components/ui/UIGrid.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								src/dawn/scene/components/ui/UIGrid.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,30 @@
 | 
			
		||||
// Copyright (c) 2023 Dominic Masters
 | 
			
		||||
// 
 | 
			
		||||
// This software is released under the MIT License.
 | 
			
		||||
// https://opensource.org/licenses/MIT
 | 
			
		||||
 | 
			
		||||
#include "UIGrid.hpp"
 | 
			
		||||
 | 
			
		||||
using namespace Dawn;
 | 
			
		||||
 | 
			
		||||
UIGrid::UIGrid(SceneItem *item) :
 | 
			
		||||
  SceneItemComponent(item)
 | 
			
		||||
{
 | 
			
		||||
  
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
float_t UIGrid::getWidth() {
 | 
			
		||||
  return 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
float_t UIGrid::getHeight() {
 | 
			
		||||
  return 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
float_t UIGrid::getContentWidth() {
 | 
			
		||||
  return 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
float_t UIGrid::getContentHeight() {
 | 
			
		||||
  return 1;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										22
									
								
								src/dawn/scene/components/ui/UIGrid.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								src/dawn/scene/components/ui/UIGrid.hpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,22 @@
 | 
			
		||||
// Copyright (c) 2023 Dominic Masters
 | 
			
		||||
// 
 | 
			
		||||
// This software is released under the MIT License.
 | 
			
		||||
// https://opensource.org/licenses/MIT
 | 
			
		||||
 | 
			
		||||
#pragma once
 | 
			
		||||
#include "scene/SceneItemComponent.hpp"
 | 
			
		||||
#include "UICanvas.hpp"
 | 
			
		||||
 | 
			
		||||
namespace Dawn {
 | 
			
		||||
  class UIGrid :
 | 
			
		||||
    public SceneItemComponent,
 | 
			
		||||
    public UIComponentDimensional
 | 
			
		||||
  {
 | 
			
		||||
    public:
 | 
			
		||||
      UIGrid(SceneItem *item);
 | 
			
		||||
      float_t getWidth() override;
 | 
			
		||||
      float_t getHeight() override;
 | 
			
		||||
      float_t getContentWidth() override;
 | 
			
		||||
      float_t getContentHeight() override;
 | 
			
		||||
  };
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user