TachyonUI 0.1.0
High-performance UI for building tools.
Loading...
Searching...
No Matches
gui_tooltip_manager.h
Go to the documentation of this file.
1#pragma once
2
3#include <gui_core/gui_id.h>
4
5#include <vector>
6
7namespace tachyon
8{
11
17 {
18 public:
19 float delaySeconds = 0.5f;
20 float warmSeconds = 0.5f;
21 float hideSeconds = 0.1f;
22
24 void BeginFrame(ID currentHoveredID, ID currentFocusedID, float elapsedTimeSecs,
25 bool hasMouseMove, bool hasMousePress, bool hasKeyboard, bool hasScroll, bool menuIsOpen,
26 bool buttonHeld = false);
27
29 ID GetActiveTargetID() const { return m_activeTargetID; }
32 void SetTargetAncestors(std::vector<ID> ancestors) { m_targetAncestors = std::move(ancestors); }
33
38 bool ShouldShow(ID targetID);
39
41 void EndFrame();
42
44 bool IsVisible() const { return m_isVisible; }
45
46 private:
47 ID m_activeTargetID = ID::Invalid();
48 std::vector<ID> m_targetAncestors;
49 ID m_prevFocusedID = ID::Invalid();
50 float m_targetStartTime = 0.0f;
51 float m_currentTime = 0.0f;
52 bool m_isReady = false;
53 bool m_isVisible = false;
54 bool m_declaredThisFrame = false;
55 bool m_triggeredByFocus = false;
56 bool m_suppressHover = false;
57 bool m_pressedLastFrame = false;
58 float m_lastVisibleTime = -1.0e9f;
59 ID m_lingerID = ID::Invalid();
60 float m_lingerUntil = 0.0f;
61 bool m_activeAsked = false;
62 bool m_activeAskedLast = false;
63 void Dismiss(ID currentFocusedID, bool hasMouseMove);
64 };
65
67} // namespace tachyon
Decides which element's tooltip shows: the hovered one after a delay, or at once for focus moved by t...
Definition gui_tooltip_manager.h:17
bool ShouldShow(ID targetID)
True when the tooltip for targetID should be shown this frame: it is the active target or one around ...
bool IsVisible() const
True while a tooltip is shown.
Definition gui_tooltip_manager.h:44
void SetTargetAncestors(std::vector< ID > ancestors)
The elements that take the active target's states (PropagatesDescendantState); a tooltip on any of th...
Definition gui_tooltip_manager.h:32
float hideSeconds
a tooltip stays this long after its target is left
Definition gui_tooltip_manager.h:21
void EndFrame()
Call after OnGUI. Hides the tooltip if nothing declared it this frame.
float delaySeconds
hover time before a tooltip shows
Definition gui_tooltip_manager.h:19
ID GetActiveTargetID() const
The element the tooltip is for: the hovered one, or the focused one after a Tab.
Definition gui_tooltip_manager.h:29
void BeginFrame(ID currentHoveredID, ID currentFocusedID, float elapsedTimeSecs, bool hasMouseMove, bool hasMousePress, bool hasKeyboard, bool hasScroll, bool menuIsOpen, bool buttonHeld=false)
Updates the target from this frame's hover, focus and input; call before OnGUI.
float warmSeconds
after a tooltip was shown, the next shows at once for this long
Definition gui_tooltip_manager.h:20
Definition gui_logging.h:24
A 64-bit element ID whose bit layout depends on its IDMode.
Definition gui_id.h:23
static constexpr ID Invalid()
The "no element" ID (all bits zero); also the default for optional ID parameters.
Definition gui_id.h:66