Skip to content

Commit

Permalink
gui skin index; gui accent
Browse files Browse the repository at this point in the history
  • Loading branch information
malytomas committed Nov 24, 2024
1 parent 36a14a1 commit 24a6625
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 32 deletions.
2 changes: 1 addition & 1 deletion sources/gui/exportSkinTemplate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class GuiTestImpl : public GuiTestClass
public:
void initialize() override
{
detail::guiSkinTemplateExport(engineGuiManager()->skin(0), 2048)->exportFile("guiSkinTemplate.png");
detail::guiSkinTemplateExport(engineGuiManager()->skin(GuiSkinDefault), 2048)->exportFile("guiSkinTemplate.png");
engineStop();
}
};
Expand Down
6 changes: 1 addition & 5 deletions sources/gui/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,7 @@ namespace GuiTestClassNS
{
try
{
// log to console
Holder<Logger> log1 = newLogger();
log1->format.bind<logFormatConsole>();
log1->output.bind<logOutputStdOut>();

initializeConsoleLogger();
initializeEngine();

// events
Expand Down
23 changes: 22 additions & 1 deletion sources/gui/guiBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class GuiTestImpl : public GuiTestClass
bool switchSkin(input::GuiValue in)
{
EntityManager *ents = engineGuiEntities();
ents->get(3)->value<GuiWidgetStateComponent>().skinIndex = in.entity->value<GuiComboBoxComponent>().selected;
ents->get(3)->value<GuiWidgetStateComponent>().skin = GuiSkinIndex(in.entity->value<GuiComboBoxComponent>().selected);
return true;
}

Expand Down Expand Up @@ -102,6 +102,27 @@ class GuiTestImpl : public GuiTestClass

g->label().text("updated label");
g->label().text("").update([&](Entity *e) { e->value<GuiTextComponent>().value = Stringizer() + updatedIndex++; });

g->label().text("red accent");
{
auto _ = g->row();
for (Real a = 0.1; a < 0.51; a += 0.1)
g->button().text(Stringizer() + a).accent(Vec4(1, 0, 0, a));
}

g->label().text("green accent");
{
auto _ = g->row();
for (Real a = 0.1; a < 0.51; a += 0.1)
g->button().text(Stringizer() + a).accent(Vec4(0, 1, 0, a));
}

g->label().text("blue accent");
{
auto _ = g->row();
for (Real a = 0.1; a < 0.51; a += 0.1)
g->button().text(Stringizer() + a).accent(Vec4(0, 0, 1, a));
}
}
}
};
Expand Down
16 changes: 8 additions & 8 deletions sources/gui/layouts/line.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class GuiTestImpl : public GuiTestClass
{
for (uint32 i = 0; i < count; i++)
{
auto _1 = g->panel().text(Stringizer() + i).skin(3);
auto _1 = g->panel().text(Stringizer() + i).skin(GuiSkinTooltips);
auto _2 = g->column();
const uint32 cnt = randomRange(0, 3);
for (uint32 j = 0; j < cnt; j++)
Expand Down Expand Up @@ -264,8 +264,8 @@ class GuiTestImpl : public GuiTestClass
{
auto _1 = g->panel().text(Stringizer() + w).size(Vec2(w, Real::Nan()));
auto _2 = g->leftRowStretchRight();
g->panel().skin(3).text("fixed left");
g->panel().skin(3).text("flexible right");
g->panel().skin(GuiSkinTooltips).text("fixed left");
g->panel().skin(GuiSkinTooltips).text("flexible right");
}
}
{
Expand All @@ -275,8 +275,8 @@ class GuiTestImpl : public GuiTestClass
{
auto _1 = g->panel().text(Stringizer() + w).size(Vec2(w, Real::Nan()));
auto _2 = g->centerRowStretchBoth();
g->panel().skin(3).text("flexible left");
g->panel().skin(3).text("flexible right");
g->panel().skin(GuiSkinTooltips).text("flexible left");
g->panel().skin(GuiSkinTooltips).text("flexible right");
}
}
{
Expand All @@ -286,8 +286,8 @@ class GuiTestImpl : public GuiTestClass
{
auto _1 = g->panel().text(Stringizer() + w).size(Vec2(w, Real::Nan()));
auto _2 = g->rightRowStretchLeft();
g->panel().skin(3).text("flexible left");
g->panel().skin(3).text("fixed right");
g->panel().skin(GuiSkinTooltips).text("flexible left");
g->panel().skin(GuiSkinTooltips).text("fixed right");
}
}
}
Expand All @@ -304,7 +304,7 @@ class GuiTestImpl : public GuiTestClass
auto _1 = g->panel().text(Stringizer() + cnt);
auto _2 = g->leftRowStretchRight();
{
auto _ = g->panel().skin(3).text("fixed left");
auto _ = g->panel().skin(GuiSkinTooltips).text("fixed left");
g->label().text("hej");
}
generate(g, cnt);
Expand Down
2 changes: 1 addition & 1 deletion sources/gui/layouts/split.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class GuiTestImpl : public GuiTestClass
{
for (uint32 i = 0; i < count; i++)
{
auto _1 = g->panel().text(Stringizer() + i).skin(3);
auto _1 = g->panel().text(Stringizer() + i).skin(GuiSkinTooltips);
auto _2 = g->column();
const uint32 cnt = randomRange(0, 3);
for (uint32 j = 0; j < cnt; j++)
Expand Down
2 changes: 1 addition & 1 deletion sources/gui/mixture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class GuiTestImpl : public GuiTestClass
bool switchSkin(input::GuiValue in)
{
EntityManager *ents = engineGuiEntities();
ents->get(3)->value<GuiWidgetStateComponent>().skinIndex = in.entity->value<GuiComboBoxComponent>().selected;
ents->get(3)->value<GuiWidgetStateComponent>().skin = GuiSkinIndex(in.entity->value<GuiComboBoxComponent>().selected);
return true;
}

Expand Down
28 changes: 14 additions & 14 deletions sources/gui/skins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ class GuiTestImpl : public GuiTestClass
for (uint32 i = 0; i < 4; i++)
a4[i] = (steeper(Rads(t) + Rads::Full() * Real(i) / 4) * 0.5 + 0.5) * 20;

const auto &generate = [&](uint32 styleIndex)
const auto &generate = [&](GuiSkinIndex style)
{
GuiSkinConfig skin = detail::guiSkinGenerate(styleIndex);
GuiSkinConfig skin = detail::guiSkinGenerate(style);
switch (animateOption)
{
case 0: // margins
Expand Down Expand Up @@ -76,12 +76,12 @@ class GuiTestImpl : public GuiTestClass
return skin;
};

engineGuiManager()->skin(0) = generate(0);
engineGuiManager()->skin(1) = generate(1);
engineGuiManager()->skin(2) = generate(2);
engineGuiManager()->skin(3) = generate(3);
engineGuiManager()->skin(4) = generate(0);
engineGuiManager()->skin(4).textureName = HashString("cage-tests/gui/skin.png");
engineGuiManager()->skin(GuiSkinDefault) = generate(GuiSkinDefault);
engineGuiManager()->skin(GuiSkinLarge) = generate(GuiSkinLarge);
engineGuiManager()->skin(GuiSkinCompact) = generate(GuiSkinCompact);
engineGuiManager()->skin(GuiSkinTooltips) = generate(GuiSkinTooltips);
engineGuiManager()->skin(GuiSkinIndex(4)) = generate(GuiSkinDefault);
engineGuiManager()->skin(GuiSkinIndex(4)).textureName = HashString("cage-tests/gui/skin.png");
}

void initializeEngine() override
Expand Down Expand Up @@ -174,7 +174,7 @@ class GuiTestImpl : public GuiTestClass
p.order = index++;
e->value<GuiInputComponent>();
e->value<GuiTextComponent>().value = "large input box";
e->value<GuiWidgetStateComponent>().skinIndex = 1;
e->value<GuiWidgetStateComponent>().skin = GuiSkinLarge;
}
{ // compact input box
Entity *e = ents->createUnique();
Expand All @@ -183,7 +183,7 @@ class GuiTestImpl : public GuiTestClass
p.order = index++;
e->value<GuiInputComponent>();
e->value<GuiTextComponent>().value = "compact input box";
e->value<GuiWidgetStateComponent>().skinIndex = 2;
e->value<GuiWidgetStateComponent>().skin = GuiSkinCompact;
}
{ // checkbox
Entity *e = ents->createUnique();
Expand Down Expand Up @@ -329,10 +329,10 @@ class GuiTestImpl : public GuiTestClass
initializeSide(6, "compact skin");
initializeSide(7, "tooltips skin");
initializeSide(8, "default skin - texture template");
ents->get(5)->value<GuiWidgetStateComponent>().skinIndex = 1;
ents->get(6)->value<GuiWidgetStateComponent>().skinIndex = 2;
ents->get(7)->value<GuiWidgetStateComponent>().skinIndex = 3;
ents->get(8)->value<GuiWidgetStateComponent>().skinIndex = 4;
ents->get(5)->value<GuiWidgetStateComponent>().skin = GuiSkinLarge;
ents->get(6)->value<GuiWidgetStateComponent>().skin = GuiSkinCompact;
ents->get(7)->value<GuiWidgetStateComponent>().skin = GuiSkinTooltips;
ents->get(8)->value<GuiWidgetStateComponent>().skin = GuiSkinIndex(4);
}
};

Expand Down

0 comments on commit 24a6625

Please sign in to comment.