Skip to content

Commit

Permalink
combo box tooltips
Browse files Browse the repository at this point in the history
  • Loading branch information
malytomas committed Nov 6, 2023
1 parent e821df1 commit a14c914
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions sources/gui/widgets/comboBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

using namespace cage;

void tooltipCallback(uint32 index, const GuiTooltipConfig &cfg)
{
cfg.placement = TooltipPlacementEnum::InvokerCorner;
auto g = newGuiBuilder(cfg.tooltip);
auto _ = g->panel();
g->label().text(Stringizer() + "option " + index);
}

class GuiTestImpl : public GuiTestClass
{
void initialize() override
Expand Down Expand Up @@ -51,13 +59,15 @@ class GuiTestImpl : public GuiTestClass
p.order = index++;
e->value<GuiComboBoxComponent>().selected = 2;
e->value<GuiTextComponent>().value = "select one:";
e->value<GuiTooltipComponent>().tooltip = detail::guiTooltipText<"select one">();
for (uint32 i = 0; i < 4; i++)
{
Entity *o = ents->createUnique();
GuiParentComponent &p = o->value<GuiParentComponent>();
p.parent = e->name();
p.order = index++;
o->value<GuiTextComponent>().value = Stringizer() + "option " + i;
o->value<GuiTooltipComponent>().tooltip.bind<uint32, &tooltipCallback>(i);
}
}
{ // disabled combo
Expand All @@ -69,13 +79,15 @@ class GuiTestImpl : public GuiTestClass
e->value<GuiComboBoxComponent>();
e->value<GuiWidgetStateComponent>().disabled = true;
e->value<GuiTextComponent>().value = "select one:";
e->value<GuiTooltipComponent>().tooltip = detail::guiTooltipText<"select one">();
for (uint32 i = 0; i < 4; i++)
{
Entity *o = ents->createUnique();
GuiParentComponent &p = o->value<GuiParentComponent>();
p.parent = e->name();
p.order = index++;
o->value<GuiTextComponent>().value = Stringizer() + "option " + i;
o->value<GuiTooltipComponent>().tooltip.bind<uint32, &tooltipCallback>(i);
}
}
{ // disabled items
Expand All @@ -86,6 +98,7 @@ class GuiTestImpl : public GuiTestClass
p.order = index++;
e->value<GuiComboBoxComponent>();
e->value<GuiTextComponent>().value = "select one:";
e->value<GuiTooltipComponent>().tooltip = detail::guiTooltipText<"select one">();
for (uint32 i = 0; i < 4; i++)
{
Entity *o = ents->createUnique();
Expand All @@ -95,6 +108,7 @@ class GuiTestImpl : public GuiTestClass
o->value<GuiTextComponent>().value = Stringizer() + "option " + i;
if (i == 2)
o->value<GuiWidgetStateComponent>().disabled = true;
o->value<GuiTooltipComponent>().tooltip.bind<uint32, &tooltipCallback>(i);
}
}
}
Expand Down

0 comments on commit a14c914

Please sign in to comment.