Added UI Grid
This commit is contained in:
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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 {
|
||||
|
Reference in New Issue
Block a user