Added UI Grid

This commit is contained in:
2023-01-24 21:06:51 -08:00
parent dd83f2cefa
commit 774ab04ade
7 changed files with 254 additions and 114 deletions

View File

@ -32,7 +32,7 @@ void TestUIScene::stage() {
this->canvas = UICanvas::create(this);
// auto text = man->get<TextureAsset>("texture_test");
// auto border = this->canvas->addElement<UIBorder>();
// auto border = this->canvas->addElement<UIBorder>();
// border->texture = &text->texture;
// border->setBorderSize(glm::vec2(4, 4));
// border->setTransform(
@ -42,13 +42,19 @@ void TestUIScene::stage() {
// );
auto assetFont = man->get<TrueTypeAsset>("truetype_alice");
auto label = this->canvas->addElement<UILabel>();
label->setFont(&assetFont->font);
label->setText("test.1");
label->setFontSize(24);
label->setTransform(
UI_COMPONENT_ALIGN_STRETCH, UI_COMPONENT_ALIGN_STRETCH,
glm::vec4(0, 0, 0, 0),
0.0f
);
auto grid = this->canvas->addElement<UIGrid>();
grid->setTransform(UI_COMPONENT_ALIGN_STRETCH, UI_COMPONENT_ALIGN_STRETCH, glm::vec4(0, 0, 0, 0), 0);
grid->setGridSize(4, 4, 8, 8);
for(int32_t x = 0; x < grid->getColumns(); x++) {
for(int32_t y = 0; y < grid->getRows(); y++) {
auto label = this->canvas->addElement<UILabel>();
label->setFont(&assetFont->font);
label->setText("test.1");
label->setFontSize(24);
grid->addToGrid(label, x, y);
}
}
}

View File

@ -9,6 +9,8 @@
#include "scene/components/ui/UICanvas.hpp"
#include "ui/UILabel.hpp"
#include "ui/UIBorder.hpp"
#include "ui/UIGrid.hpp"
#include "ui/UISprite.hpp"
#include "prefabs/SimpleSpinningCubePrefab.hpp"
namespace Dawn {