Skip to content

Commit 2372322

Browse files
committed
tweak functions for gui builder tooltip and text
1 parent 725af51 commit 2372322

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

sources/include/cage-core/hashString.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace cage
1010
{
1111
CAGE_FORCE_INLINE constexpr explicit HashString(const char *str) : value(hashRawString(str) | ((uint32)1 << 31)) {}
1212

13-
CAGE_FORCE_INLINE constexpr explicit HashString(const StringPointer &str) : value(hashRawString(str) | ((uint32)1 << 31)) {}
13+
CAGE_FORCE_INLINE constexpr explicit HashString(StringPointer str) : value(hashRawString(str) | ((uint32)1 << 31)) {}
1414

1515
template<uint32 N>
1616
CAGE_FORCE_INLINE constexpr explicit HashString(const detail::StringBase<N> &str) : value(hashBuffer(str) | ((uint32)1 << 31))

sources/include/cage-engine/guiBuilder.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,17 @@ namespace cage
4646
BuilderItem update(Delegate<void(Entity *)> u);
4747

4848
BuilderItem tooltip(const GuiTooltipComponent &t);
49-
template<StringLiteral Text, uint32 TextId = 0>
49+
template<StringLiteral Text>
5050
BuilderItem tooltip(uint64 delay = GuiTooltipComponent().delay)
5151
{
52-
(*this)->template value<GuiTooltipComponent>().tooltip = detail::guiTooltipText<Text, TextId>();
52+
(*this)->template value<GuiTooltipComponent>().tooltip = detail::guiTooltipText<Text>();
53+
(*this)->template value<GuiTooltipComponent>().delay = delay;
54+
return *this;
55+
}
56+
template<uint32 TextId>
57+
BuilderItem tooltip(uint64 delay = GuiTooltipComponent().delay)
58+
{
59+
(*this)->template value<GuiTooltipComponent>().tooltip = detail::guiTooltipText<TextId>();
5360
(*this)->template value<GuiTooltipComponent>().delay = delay;
5461
return *this;
5562
}

sources/include/cage-engine/guiComponents.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,10 +305,17 @@ namespace cage
305305
CAGE_ENGINE_API void guiDestroyChildrenRecursively(Entity *e);
306306
CAGE_ENGINE_API void guiDestroyEntityRecursively(Entity *e);
307307

308-
template<StringLiteral Text, uint32 TextId = 0>
308+
template<StringLiteral Text>
309309
GuiTooltipComponent::TooltipCallback guiTooltipText()
310310
{
311-
static constexpr GuiTextComponent txt{ Text.value, TextId };
311+
static constexpr GuiTextComponent txt{ Text.value, 0 };
312+
return privat::guiTooltipText(&txt);
313+
}
314+
315+
template<uint32 TextId>
316+
GuiTooltipComponent::TooltipCallback guiTooltipText()
317+
{
318+
static constexpr GuiTextComponent txt{ "", TextId };
312319
return privat::guiTooltipText(&txt);
313320
}
314321
}

sources/libengine/gui/tooltips.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ namespace cage
274274
GuiTooltipComponent::TooltipCallback guiTooltipText(const GuiTextComponent *txt)
275275
{
276276
GuiTooltipComponent::TooltipCallback tt;
277-
tt.bind<const GuiTextComponent *, &guiTooltipTextImpl>(txt);
277+
tt.bind<const GuiTextComponent *, guiTooltipTextImpl>(txt);
278278
return tt;
279279
}
280280
}

0 commit comments

Comments
 (0)