TachyonUI 1.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>
12#include <gui_core/style/gui_style_text.h> // IconID
13
14// Plain state holders for several controls (no frame callbacks or logic).
15
16namespace tachyon
17{
20
24 {
25 public:
27 bool isActive = false;
30 bool firstFrame = false;
31 std::string* editBuffer = nullptr;
32
34 void Start(tachyon::ID id, std::string* buffer, std::string_view text)
35 {
36 targetID = id; isActive = true; firstFrame = true;
37 editBuffer = buffer; *buffer = text;
38 }
39
40 void Cancel()
41 {
42 targetID = tachyon::ID::Invalid(); isActive = false; firstFrame = false; editBuffer = nullptr;
43 }
44 };
45
49 {
50 public:
54 {
55 m_widths.Touch(id);
56 const int* width = m_widths.Find(id);
57 return width ? *width : 0;
58 }
59
61 RecentIDMap<int>& Widths() { return m_widths; }
62
64 void EndFrame() { m_widths.EndFrame(); }
65
66 private:
67 RecentIDMap<int> m_widths;
68 };
69
79
82 {
83 bool hasTarget = false;
86 std::chrono::steady_clock::time_point lastTime{};
87 };
88
91 {
92 public:
93 DockTabDragInfo& Info() { return m_info; }
94 DockDropZoneAnim& DropZoneAnim() { return m_dropZoneAnim; }
95
96 private:
97 DockTabDragInfo m_info{};
98 DockDropZoneAnim m_dropZoneAnim{};
99 };
100
101 struct ToolbarDockState;
102
115
120 {
121 public:
123 const tachyon::IntRect* FindTriggerRect(tachyon::ID id) const { return m_triggerRects.Find(id); }
125 const tachyon::IntRect* FindWindowRect(tachyon::ID id) const { return m_windowRects.Find(id); }
126
128 RecentIDMap<tachyon::IntRect>& TriggerRects() { return m_triggerRects; }
129 RecentIDMap<tachyon::IntRect>& WindowRects() { return m_windowRects; }
130
132 void EndFrame() { m_triggerRects.EndFrame(); m_windowRects.EndFrame(); }
133
134 size_t Size() const { return m_triggerRects.Size() + m_windowRects.Size(); }
135
136 private:
137 RecentIDMap<tachyon::IntRect> m_triggerRects;
138 RecentIDMap<tachyon::IntRect> m_windowRects;
139 };
140
141}
Dock tab drag state: the dragged tab and the drop-zone overlay animation.
Definition gui_subsystem_state.h:91
DockDropZoneAnim & DropZoneAnim()
Definition gui_subsystem_state.h:94
DockTabDragInfo & Info()
Definition gui_subsystem_state.h:93
Last frame's screen rects of menu triggers and popups, written by AddPostLayout callbacks.
Definition gui_subsystem_state.h:120
const tachyon::IntRect * FindTriggerRect(tachyon::ID id) const
Last frame's rect of menu trigger id; nullptr if absent.
Definition gui_subsystem_state.h:123
void EndFrame()
Once per frame: the rects of menus no longer built go after a while.
Definition gui_subsystem_state.h:132
RecentIDMap< tachyon::IntRect > & WindowRects()
Definition gui_subsystem_state.h:129
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:125
size_t Size() const
Definition gui_subsystem_state.h:134
RecentIDMap< tachyon::IntRect > & TriggerRects()
For the AddPostLayout lambdas to write into.
Definition gui_subsystem_state.h:128
Per-ID state kept between frames for the elements still built: an entry not written for kKeepFrames f...
Definition gui_recent_id_map.h:25
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:24
void Cancel()
Ends the rename without touching the buffer.
Definition gui_subsystem_state.h:40
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:30
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:34
tachyon::ID targetID
the row being renamed
Definition gui_subsystem_state.h:26
bool isActive
Definition gui_subsystem_state.h:27
std::string * editBuffer
the caller's buffer the field edits
Definition gui_subsystem_state.h:31
Slider track widths written by the sliders' custom draws and read next frame (keyboard step sizes,...
Definition gui_subsystem_state.h:49
int GetWidth(tachyon::ID id)
0 until the slider has drawn once.
Definition gui_subsystem_state.h:53
RecentIDMap< int > & Widths()
For the custom-draw lambdas to write into.
Definition gui_subsystem_state.h:61
void EndFrame()
Once per frame: the widths of sliders no longer shown go after a while.
Definition gui_subsystem_state.h:64
A floating toolbar window dragged by its thumb; one drag at a time.
Definition gui_subsystem_state.h:106
Gesture< IntRect > press
the thumb's press, a drag from the start; the window before it, put back by Escape
Definition gui_subsystem_state.h:108
int2 currentMousePos
screen pixels
Definition gui_subsystem_state.h:110
ToolbarDockState * sourceDockState
Definition gui_subsystem_state.h:111
ID windowID
Definition gui_subsystem_state.h:109
bool Active() const
Definition gui_subsystem_state.h:113
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:82
IntRect currentRect
interpolated rect, the one drawn
Definition gui_subsystem_state.h:84
std::chrono::steady_clock::time_point lastTime
Definition gui_subsystem_state.h:86
IntRect targetRect
destination rect
Definition gui_subsystem_state.h:85
bool hasTarget
the previous frame showed the overlay
Definition gui_subsystem_state.h:83
Set when a dock tab drag starts, so any target leaf can emit a phantom tab during construction.
Definition gui_subsystem_state.h:73
int tabWidth
the dragged tab's width at drag start, pixels
Definition gui_subsystem_state.h:77
tachyon::ID panelID
Definition gui_subsystem_state.h:74
std::string title
Definition gui_subsystem_state.h:75
IconID icon
Definition gui_subsystem_state.h:76
One press that may become a drag, with what every control does around it: the focus and the capture o...
Definition gui_gesture.h:60
bool IsHeld() const noexcept
Definition gui_gesture.h:64
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:406
Per-instance state for one toolbar dock.
Definition controls_toolbar_dock.h:41
Integer 2D vector.
Definition gui_base_types.h:18