TachyonUI 0.1.0
High-performance UI for building tools.
Loading...
Searching...
No Matches
gui_state_manager.h
Go to the documentation of this file.
1#pragma once
2
3#include <gui_core/gui_id.h>
4
6
8
10
15
17
18#include <functional>
19
20namespace tachyon
21{
24
25 class IDManager;
26
30 {
36
39 std::function<ID(ID window, int2 pos, ID& disabled)> hitTest;
41 std::function<bool(ID window, int2 pos, ID& target)> textDragTarget;
42 };
43
52
65 {
66 InteractionState m_interaction;
67 DragDropState m_drag;
68 ConstructionScopes m_construction;
69 TextEditorFocusState m_textEditorFocus;
70 LabelBinding m_labels;
71 CursorState m_cursor;
72 ScrollManagement m_scrolling;
73
74 ElementDataStore m_elementDataStore;
75
77 bool m_modified = false;
78
81 ID m_interactionWindowID = ID::Invalid();
82
83 public:
84 // -----------------------------------------------------------------
85 // Sub-state accessors
86 // -----------------------------------------------------------------
87 InteractionState& Interaction() { return m_interaction; }
88 const InteractionState& Interaction() const { return m_interaction; }
89
90 DragDropState& Drag() { return m_drag; }
91 const DragDropState& Drag() const { return m_drag; }
92
93 ConstructionScopes& Construction() { return m_construction; }
94 const ConstructionScopes& Construction() const { return m_construction; }
95
96 TextEditorFocusState& TextEditorFocus() { return m_textEditorFocus; }
97 const TextEditorFocusState& TextEditorFocus() const { return m_textEditorFocus; }
98
99 LabelBinding& Labels() { return m_labels; }
100 const LabelBinding& Labels() const { return m_labels; }
101
102 CursorState& Cursor() { return m_cursor; }
103 const CursorState& Cursor() const { return m_cursor; }
104
105 ScrollManagement& GetScrollManagement() { return m_scrolling; }
106 const ScrollManagement& GetScrollManagement() const { return m_scrolling; }
107
108 ElementDataStore& GetElementDataStore() { return m_elementDataStore; }
109 const ElementDataStore& GetElementDataStore() const { return m_elementDataStore; }
110
111 // -----------------------------------------------------------------
112 // Cross-cutting state
113 // -----------------------------------------------------------------
116 void ClearModifiedFlag() { m_modified = false; }
117 bool IsModified() const { return m_modified; }
118 void SetModified(bool v) { m_modified = v; }
120
124
129 FrameHover EndFrame(const FrameInput& input, IDManager& idManager);
130 };
131
132}
Construction-time Push/Pop nesting read by GUIStateManager::GetCurrentState.
Definition gui_state_atomic_values.h:50
The mouse cursor requested this frame.
Definition gui_state_atomic_values.h:20
Drag-and-drop state, owned by GUIStateManager.
Definition gui_drag_drop_state.h:39
Per-element typed state keyed by ID, kept across frames (drag start, double-click timing).
Definition gui_element_data_store.h:23
Owns the per-frame state objects and runs their BeginFrame / EndFrame in order.
Definition gui_state_manager.h:65
const CursorState & Cursor() const
Definition gui_state_manager.h:103
ElementDataStore & GetElementDataStore()
Definition gui_state_manager.h:108
bool IsModified() const
Whether transient state changed this frame.
Definition gui_state_manager.h:117
FrameHover EndFrame(const FrameInput &input, IDManager &idManager)
Resolves the active window, the window and element under the pointer and the hovered element from inp...
bool BeginFrame()
Resets the per-frame state; call before construction. Always true.
const LabelBinding & Labels() const
Definition gui_state_manager.h:100
void ClearModifiedFlag()
Whether transient state changed this frame.
Definition gui_state_manager.h:116
const TextEditorFocusState & TextEditorFocus() const
Definition gui_state_manager.h:97
InteractionState & Interaction()
Definition gui_state_manager.h:87
DragDropState & Drag()
Definition gui_state_manager.h:90
ElementState GetCurrentState(ID id) const
The state of id (hovered, focused, disabled, ...) from Interaction, Construction and Labels.
void SetModified(bool v)
Whether transient state changed this frame.
Definition gui_state_manager.h:118
const ConstructionScopes & Construction() const
Definition gui_state_manager.h:94
const ScrollManagement & GetScrollManagement() const
Definition gui_state_manager.h:106
TextEditorFocusState & TextEditorFocus()
Definition gui_state_manager.h:96
ScrollManagement & GetScrollManagement()
Definition gui_state_manager.h:105
ConstructionScopes & Construction()
Definition gui_state_manager.h:93
CursorState & Cursor()
Definition gui_state_manager.h:102
const InteractionState & Interaction() const
Definition gui_state_manager.h:88
LabelBinding & Labels()
Definition gui_state_manager.h:99
const DragDropState & Drag() const
Definition gui_state_manager.h:91
const ElementDataStore & GetElementDataStore() const
Definition gui_state_manager.h:109
Makes element IDs: per-frame dynamic / ranged IDs (hashed from the call site or a hint and the parent...
Definition gui_id_manager.h:27
The hovered, active, focused and captured elements, the active window, the one-shot click,...
Definition gui_interaction_state.h:17
Links labels to the controls they describe during construction; owned by GUIStateManager.
Definition gui_label_binding.h:25
Scroll containers' offsets (pixels), kept across frames by ID behind handles.
Definition gui_scroll_management.h:33
The focused text editor, plus the one as of the last Commit, to detect changes.
Definition gui_state_atomic_values.h:32
MouseButtons
Mouse buttons, combined with |.
Definition gui_input_enums.h:38
@ None
Definition gui_input_enums.h:39
ElementState
Interaction state bits of an element; they pick the Style::states variant it draws with.
Definition gui_style.h:42
Definition gui_logging.h:24
Where the frame's input goes, from GUIStateManager::EndFrame.
Definition gui_state_manager.h:46
ID hoverID
what counts as hovered: capture, active element, drop target
Definition gui_state_manager.h:48
ID disabledID
a disabled element under the cursor: tooltips only
Definition gui_state_manager.h:50
ID overID
the element under the cursor
Definition gui_state_manager.h:47
ID hoverWindowID
the window the pointer input belongs to
Definition gui_state_manager.h:49
What the window layer reports at the end of a frame's construction; GUIStateManager::EndFrame turns i...
Definition gui_state_manager.h:30
ID modalWindowID
top modal window, which blocks the others
Definition gui_state_manager.h:32
std::function< ID(ID window, int2 pos, ID &disabled)> hitTest
The element at pos in window, or Invalid; disabled gets the disabled element there,...
Definition gui_state_manager.h:39
ID activeWindowID
the OS's active window; Invalid without focus
Definition gui_state_manager.h:31
int2 mousePos
screen pixels
Definition gui_state_manager.h:34
std::function< bool(ID window, int2 pos, ID &target)> textDragTarget
While text is dragged: the text drop target at pos in window. Optional.
Definition gui_state_manager.h:41
MouseButtons mouseButtons
Definition gui_state_manager.h:35
ID windowUnderMouse
Definition gui_state_manager.h:33
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
Integer 2D vector.
Definition gui_base_types.h:19