TachyonUI 1.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;
24 static constexpr float kTimerSlackSeconds = 0.01f;
25
27 void BeginFrame(ID currentHoveredID, ID currentFocusedID, float elapsedTimeSecs,
28 bool hasMouseMove, bool hasMousePress, bool hasKeyboard, bool hasScroll, bool menuIsOpen,
29 bool buttonHeld = false);
30
32 ID GetActiveTargetID() const { return m_activeTargetID; }
35 void SetTargetAncestors(std::vector<ID> ancestors) { m_targetAncestors = std::move(ancestors); }
36
41 bool ShouldShow(ID targetID);
42
44 void EndFrame();
45
47 bool IsVisible() const { return m_isVisible; }
49 bool IsReady() const { return m_isReady; }
50
53 float NextChangeTime() const;
54
55 private:
56 ID m_activeTargetID = ID::Invalid();
57 std::vector<ID> m_targetAncestors;
58 ID m_prevFocusedID = ID::Invalid();
59 float m_targetStartTime = 0.0f;
60 float m_currentTime = 0.0f;
61 bool m_isReady = false;
62 bool m_isVisible = false;
63 bool m_declaredThisFrame = false;
64 bool m_triggeredByFocus = false;
65 bool m_suppressHover = false;
66 bool m_pressedLastFrame = false;
67 float m_lastVisibleTime = -1.0e9f;
68 ID m_lingerID = ID::Invalid();
69 float m_lingerUntil = 0.0f;
70 bool m_activeAsked = false;
71 bool m_activeAskedLast = false;
72 void Dismiss(ID currentFocusedID, bool hasMouseMove);
73 };
74
76} // 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:47
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:35
float hideSeconds
a tooltip stays this long after its target is left
Definition gui_tooltip_manager.h:21
float NextChangeTime() const
The frame time the tooltip next changes at by itself: the hovered element's delay running out,...
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
bool IsReady() const
True once the active target's wait is over: its tooltip shows when its target asks.
Definition gui_tooltip_manager.h:49
ID GetActiveTargetID() const
The element the tooltip is for: the hovered one, or the focused one after a Tab.
Definition gui_tooltip_manager.h:32
static constexpr float kTimerSlackSeconds
The wait counts as over this close to its end: about half a refresh period, what a frame clock snappe...
Definition gui_tooltip_manager.h:24
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