diff --git a/src/dawn/ui/UIGrid.cpp b/src/dawn/ui/UIGrid.cpp index 164a75b4..651ef076 100644 --- a/src/dawn/ui/UIGrid.cpp +++ b/src/dawn/ui/UIGrid.cpp @@ -47,7 +47,7 @@ void UIGrid::alignChild(UIComponent *child, struct UIGridPosition pos) { // Alignment float_t x, y, sizeX, sizeY; UIComponent::calculateDimensions( - UI_COMPONENT_ALIGN_MIDDLE, + pos.alignX, &x, &sizeX, this->sizeCol, @@ -55,7 +55,7 @@ void UIGrid::alignChild(UIComponent *child, struct UIGridPosition pos) { glm::vec2(0, 0) ); UIComponent::calculateDimensions( - UI_COMPONENT_ALIGN_MIDDLE, + pos.alignY, &y, &sizeY, this->sizeRow, @@ -83,13 +83,19 @@ void UIGrid::setGridSize( this->updatePositions(); } -void UIGrid::addToGrid(UIComponent *ui, int32_t x, int32_t y) { +void UIGrid::addToGrid( + UIComponent *ui, + int32_t x, int32_t y, + enum UIComponentAlign alignX, enum UIComponentAlign alignY +) { assertTrue(x >= 0 && x < this->columns); assertTrue(y >= 0 && y < this->rows); this->addChild(ui); struct UIGridPosition pos; pos.x = x; pos.y = y; + pos.alignX = alignX; + pos.alignY = alignY; this->gridChildren[ui] = pos; this->alignChild(ui, pos); } diff --git a/src/dawn/ui/UIGrid.hpp b/src/dawn/ui/UIGrid.hpp index b02deaf4..93476b9e 100644 --- a/src/dawn/ui/UIGrid.hpp +++ b/src/dawn/ui/UIGrid.hpp @@ -11,8 +11,8 @@ namespace Dawn { struct UIGridPosition { int32_t x; int32_t y; - UIComponentAlign alignX; - UIComponentAlign alignY; + enum UIComponentAlign alignX; + enum UIComponentAlign alignY; }; @@ -63,8 +63,14 @@ namespace Dawn { * @param component Component to add to the grid. * @param column Column Position. * @param row Row Position. + * @param alignX X alignment of the component within the cell. + * @param alignY Y alignment of the component within the cell. */ - void addToGrid(UIComponent *component, int32_t column, int32_t row); + void addToGrid( + UIComponent *ui, + int32_t x, int32_t y, + enum UIComponentAlign alignX, enum UIComponentAlign alignY + ); int32_t getRows(); int32_t getColumns(); diff --git a/src/dawnpokergame/scenes/TestUIScene.cpp b/src/dawnpokergame/scenes/TestUIScene.cpp index 1a5bf486..e9919de2 100644 --- a/src/dawnpokergame/scenes/TestUIScene.cpp +++ b/src/dawnpokergame/scenes/TestUIScene.cpp @@ -53,8 +53,7 @@ void TestUIScene::stage() { label->setFont(&assetFont->font); label->setText("test.1"); label->setFontSize(24); - - grid->addToGrid(label, x, y); + grid->addToGrid(label, x, y, UI_COMPONENT_ALIGN_END, UI_COMPONENT_ALIGN_END); } } } \ No newline at end of file