TachyonUI 0.1.0
High-performance UI for building tools.
Loading...
Searching...
No Matches
gui_subsystem_state.h
Go to the documentation of this file.
1#pragma once
2
3#include <chrono>
4#include <string>
5#include <string_view>
6#include <unordered_map>
7
8#include <gui_core/gui_id.h>
11#include <gui_core/text/gui_text_system.h> // IconID
12
13// Plain state holders for several controls (no frame callbacks or logic).
14
15namespace tachyon
16{
19
23 {
24 public:
26 bool isActive = false;
29 bool firstFrame = false;
30 std::string* editBuffer = nullptr;
31
33 void Start(tachyon::ID id, std::string* buffer, std::string_view text)
34 {
35 targetID = id; isActive = true; firstFrame = true;
36 editBuffer = buffer; *buffer = text;
37 }
38
39 void Cancel()
40 {
41 targetID = tachyon::ID::Invalid(); isActive = false; firstFrame = false; editBuffer = nullptr;
42 }
43 };
44
48 {
49 public:
51 int GetWidth(tachyon::ID id) const
52 {
53 auto it = m_widths.find(id);
54 return (it != m_widths.end()) ? it->second : 0;
55 }
56
58 std::unordered_map<tachyon::ID, int>& Widths() { return m_widths; }
59
60 private:
61 std::unordered_map<tachyon::ID, int> m_widths;
62 };
63
73
76 {
77 bool hasTarget = false;
80 std::chrono::steady_clock::time_point lastTime{};
81 };
82
85 {
86 public:
87 DockTabDragInfo& Info() { return m_info; }
88 DockDropZoneAnim& DropZoneAnim() { return m_dropZoneAnim; }
89
90 private:
91 DockTabDragInfo m_info{};
92 DockDropZoneAnim m_dropZoneAnim{};
93 };
94
95 struct ToolbarDockState;
96
110
115 {
116 public:
119 {
120 auto it = m_triggerRects.find(id);
121 return (it == m_triggerRects.end()) ? nullptr : &it->second;
122 }
123
125 {
126 auto it = m_windowRects.find(id);
127 return (it == m_windowRects.end()) ? nullptr : &it->second;
128 }
129
131 std::unordered_map<tachyon::ID, tachyon::IntRect>& TriggerRects() { return m_triggerRects; }
132 std::unordered_map<tachyon::ID, tachyon::IntRect>& WindowRects() { return m_windowRects; }
133
134 private:
135 std::unordered_map<tachyon::ID, tachyon::IntRect> m_triggerRects;
136 std::unordered_map<tachyon::ID, tachyon::IntRect> m_windowRects;
137 };
138
139}
Dock tab drag state: the dragged tab and the drop-zone overlay animation.
Definition gui_subsystem_state.h:85
DockDropZoneAnim & DropZoneAnim()
Definition gui_subsystem_state.h:88
DockTabDragInfo & Info()
Definition gui_subsystem_state.h:87
Last frame's screen rects of menu triggers and popups, written by AddPostLayout callbacks.
Definition gui_subsystem_state.h:115
const tachyon::IntRect * FindTriggerRect(tachyon::ID id) const
Last frame's rect of menu trigger id; nullptr if absent.
Definition gui_subsystem_state.h:118
std::unordered_map< tachyon::ID, tachyon::IntRect > & WindowRects()
Definition gui_subsystem_state.h:132
const tachyon::IntRect * FindWindowRect(tachyon::ID id) const
Last frame's rect of menu popup window id; nullptr if absent.
Definition gui_subsystem_state.h:124
std::unordered_map< tachyon::ID, tachyon::IntRect > & TriggerRects()
For the AddPostLayout lambdas to write into.
Definition gui_subsystem_state.h:131
In-place rename of a tree / list / grid row (F2, Ctrl+Shift+Click or a slow re-click); the target row...
Definition gui_subsystem_state.h:23
void Cancel()
Ends the rename without touching the buffer.
Definition gui_subsystem_state.h:39
bool firstFrame
Set on the frame the rename starts, when a commit left over from an earlier edit must not end it; cle...
Definition gui_subsystem_state.h:29
void Start(tachyon::ID id, std::string *buffer, std::string_view text)
Starts renaming row id: buffer is set to text and edited in place.
Definition gui_subsystem_state.h:33
tachyon::ID targetID
the row being renamed
Definition gui_subsystem_state.h:25
bool isActive
Definition gui_subsystem_state.h:26
std::string * editBuffer
the caller's buffer the field edits
Definition gui_subsystem_state.h:30
Slider track widths written by the sliders' custom draws and read next frame (keyboard step sizes,...
Definition gui_subsystem_state.h:48
int GetWidth(tachyon::ID id) const
0 until the slider has drawn once.
Definition gui_subsystem_state.h:51
std::unordered_map< tachyon::ID, int > & Widths()
For the custom-draw lambdas to write into.
Definition gui_subsystem_state.h:58
A floating toolbar window dragged by its thumb; one drag at a time.
Definition gui_subsystem_state.h:100
int2 currentMousePos
screen pixels
Definition gui_subsystem_state.h:104
ToolbarDockState * sourceDockState
Definition gui_subsystem_state.h:106
IntRect startRect
the window before the drag; put back by Escape
Definition gui_subsystem_state.h:105
ID windowID
Definition gui_subsystem_state.h:103
PointerDrag drag
the thumb's press, a drag from the start
Definition gui_subsystem_state.h:102
bool Active() const
Definition gui_subsystem_state.h:108
IconID
Handle for an icon registered with ITextSystem::RegisterIconFromSVG / RegisterIconFromSVGFile.
Definition gui_style_text.h:15
@ Invalid
Definition gui_style_text.h:15
Definition gui_logging.h:24
The drop-zone overlay shown while a dock tab is dragged; it slides between zones.
Definition gui_subsystem_state.h:76
IntRect currentRect
interpolated rect, the one drawn
Definition gui_subsystem_state.h:78
std::chrono::steady_clock::time_point lastTime
Definition gui_subsystem_state.h:80
IntRect targetRect
destination rect
Definition gui_subsystem_state.h:79
bool hasTarget
the previous frame showed the overlay
Definition gui_subsystem_state.h:77
Set when a dock tab drag starts, so any target leaf can emit a phantom tab during construction.
Definition gui_subsystem_state.h:67
int tabWidth
the dragged tab's width at drag start, pixels
Definition gui_subsystem_state.h:71
tachyon::ID panelID
Definition gui_subsystem_state.h:68
std::string title
Definition gui_subsystem_state.h:69
IconID icon
Definition gui_subsystem_state.h:70
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
Definition gui_base_types.h:407
One press on an element that may become a drag.
Definition gui_pointer_drag.h:41
ID id
the element pressed; Invalid when there is no press
Definition gui_pointer_drag.h:42
Per-instance state for one toolbar dock.
Definition controls_toolbar_dock.h:39
Integer 2D vector.
Definition gui_base_types.h:19