TachyonUI 0.1.0
High-performance UI for building tools.
Loading...
Searching...
No Matches
gui_application.h
Go to the documentation of this file.
1#pragma once
2
3#include <chrono>
4#include <cstdint>
5#include <memory>
6#include <optional>
7#include <unordered_map>
8#include <unordered_set>
9#include <variant>
10#include <vector>
11#include <cassert>
12#include <source_location>
13#include <span>
14#include <functional>
15#include <initializer_list>
16#include <limits>
17#include <string>
18#include <utility>
19
23
28
33
37
43
45
47
49
52
54
56
67#include <gui_core/gui_result.h>
68
75
83
84namespace tachyon
85{
88
93 void VERIFY(RegistryResult result);
94
96 void VERIFY(AddWindowResult result);
100
101
102 // ---- MessageDialog: a modal question (GUIApplication::MessageDialog) ----
104 enum class MessageIcon : uint8_t { Warning, Quit, Question, Info, Error };
106 enum class MessageButtonKind : uint8_t { Secondary, Primary, Danger };
107
110 {
113 std::string_view label;
115 bool alignLeft = false;
116 };
117
121 {
122 std::string_view name;
123 std::string_view meta;
125 bool* checked = nullptr;
126 };
127
130 {
132 std::string_view title;
133 std::string_view message;
134 std::span<const MessageButton> buttons;
136 int cancelButton = -1;
137 std::span<const MessageDialogItem> items;
138 bool* dontAskAgain = nullptr;
139 std::string_view details;
140 };
141
142 // Outside GUIApplication: GCC can't use a nested struct's member initializers in a
143 // default argument of the class being defined.
147 {
148 bool loadStyles = true;
149 bool commandShortcuts = true;
154 std::string_view fallbackFonts {};
155 };
156
185 {
186 public:
188 std::unique_ptr<InputManager> inputManager;
190 std::unique_ptr<LayoutEngine> layoutEngine;
192 std::unique_ptr<OSWindowManager> windowManager;
194 std::unique_ptr<TextAtlasManager> textAtlasManager;
195 std::unique_ptr<IClipboard> clipboard;
196
203
214
219
220 private:
223 FramePipeline m_frame{};
224
225 std::unique_ptr<SliderFieldTrackSubsystem> m_sliderFieldTrack;
226 std::unique_ptr<MenuRectsSubsystem> m_menuRects;
227 std::unique_ptr<LabelGroupSubsystem> m_labelGroup;
228 std::unique_ptr<ButtonGroupSubsystem> m_buttonGroup;
229 std::unique_ptr<ColorPickerSubsystem> m_colorPickerSub;
230 std::unique_ptr<GradientEditorSubsystem> m_gradientEditorSub;
231 std::unique_ptr<RenameSubsystem> m_renameSub;
232 std::unique_ptr<ReorderableSubsystem> m_reorderable;
233 std::unique_ptr<DockTabDragSubsystem> m_dockTabDragSub;
234 ToolbarWindowDragSubsystem m_toolbarWindowDrag{};
235 std::unique_ptr<UICacheManager> m_uiCache;
236
237 public:
240
245
250
253
256
260
264
265
267 bool applicationQuit = false;
269 std::chrono::steady_clock::time_point m_frameStart{};
271 float frameTime = 0.0f;
273 float frameBuildTime = 0.0f;
274
276 struct FrameTimingSample { float buildMs = 0.0f; float totalMs = 0.0f; };
277 static constexpr int kFrameHistoryCount = 240;
278
280 void GetFrameTimingHistory(std::span<FrameTimingSample> out) const;
281
283
284
287
291 void CreatePanel(std::unordered_map<tachyon::ID, tachyon::Panel>& panels, ID id, std::string title, tachyon::IconID icon,
292 std::function<void()> onPanelGUI,
293 std::string panelType = {},
294 std::function<void()> onEnable = {},
295 std::function<void()> onDisable = {});
296
298 tachyon::ID CreatePanel(std::unordered_map<tachyon::ID, tachyon::Panel>& panels, std::string title, tachyon::IconID icon,
299 std::function<void()> onPanelGUI,
300 std::string panelType = {},
301 std::function<void()> onEnable = {},
302 std::function<void()> onDisable = {})
303 {
304 ID id = idManager.CreateStaticID();
305 CreatePanel(panels, id, std::move(title), icon, std::move(onPanelGUI),
306 std::move(panelType), std::move(onEnable), std::move(onDisable));
307 return id;
308 }
309
310
315
317 void EmitFloatingToolbarWindows(std::vector<struct FloatingToolbarItem>& floatingItems,
318 const struct FloatingToolbarOptions* options = nullptr);
319
323
326
332 void EmitFloatingDockWindows(const DocumentSet& documents);
335 bool FloatPanel(DockingLayout& layout, ID panelID, int2 screenPos);
336
338 void CloseFloatingDockWindow(size_t index);
339
341 void CloseDockedPanel(DockingLayout& layout, DockNode& leaf, int tabIndex);
342
345 Document& CreateDocument(DocumentSet& set, std::string name, std::string extension, std::string kind,
346 tachyon::IconID icon);
352 void CloseDocument(DocumentSet& set, int index);
353
355 static void TransferPanel(tachyon::ID panelID, tachyon::DockNode* sourceNode,
356 DockingLayout* sourceLayout,
357 DockingLayout* targetLayout);
358
360
363
364 virtual ~GUIApplication() = default;
365
368
371 virtual Result<void> Initialize(const InitializeOptions& options = {});
374 virtual void Cleanup();
375
378
381 virtual void OnStylesReloaded() {}
382
385 void RequestReloadTheme(std::string_view themePath, float fontScale);
387 const Result<void>& ThemeReloadResult() const { return m_themeReload; }
388 const std::string& GetThemePath() const { return m_themePath; }
389
394 void SetResourceRoot(std::string_view root) { m_resourceRoot = std::string(root); }
395 const std::string& GetResourceRoot() const { return m_resourceRoot; }
396
398
401
408 void InjectMouseButton(ID windowID, int2 pos, MouseButtons button, bool down, KeyModifier mods = KeyModifier::None);
410 void InjectMouseScroll(ID windowID, int2 pos, float2 offset, KeyModifier mods = KeyModifier::None);
412 void InjectMouseLeave(ID windowID);
414 void InjectFocus(ID windowID, bool focused);
416 void InjectKey(ID windowID, KeyCode key, KeyAction action, KeyModifier mods = KeyModifier::None);
418 void InjectText(ID windowID, std::string_view utf8);
419
422 Result<void> ReadWindowPixels(ID windowID, std::span<uint8_t> bgra);
423
425
428
433 void SetGraphicsBackend(std::unique_ptr<GraphicsContext> backend) { m_graphicsBackend = std::move(backend); }
434
438 void SetWindowBackend(std::unique_ptr<IWindowBackend> backend) { m_osWindowBackend = std::move(backend); }
441 void SetClipboard(std::unique_ptr<IClipboard> clipboardImpl) { clipboard = std::move(clipboardImpl); }
442
446 void SetAllocationHooks(const AllocationHooks& hooks) { m_allocationHooks = hooks; }
447
452 void SetStyleFiles(std::span<const std::string_view> files);
453 float GetGlobalFontScale() const { return m_globalFontScale; }
454
457 void SetUIScale(float scale);
458 float GetUIScale() const { return m_uiScale; }
459
463 void SetReducedMotion(std::optional<bool> reduced);
465 bool IsThemeCrossfading() const { return !m_crossfades.empty(); }
468
470
473
475 virtual void OnGUI() = 0;
476
480
494
496
499
500 // ---- Event handler factories ----
501 //
502 // Event handlers run at END OF FRAME (input dispatch), not during OnGUI. Captures must
503 // outlive the frame: user-owned pointers, GUIApplication members and copies are fine;
504 // transient construction state (m_treeState, ...) and OnGUI stack locals are not.
505 //
509 tachyon::EventHandler MakeButtonHandler(std::function<void()> onClick);
512
516 tachyon::ElementRef RegisterElement(tachyon::Element&& element, std::string_view text, LayoutOverride&& constraints);
517
518
521 bool TakeEscapeFor(ID popupWindowID, ID triggerID);
522
526 tachyon::ElementRef RegisterControl(tachyon::Element&& element, std::string_view text, LayoutOverride&& constraints);
528 tachyon::ElementRef RegisterControl(tachyon::Element&& element, std::function<TextID(tachyon::Element& element)> createTextID, LayoutOverride&& constraints);
529
534 bool reserveIcon, IconID icon, std::string_view text,
535 std::string_view trailing, StyleRef trailingStyle,
536 LayoutOverride&& constraints, bool destructive = false);
539 bool MenuItemImpl(ID id, const GUIContent& content, std::string_view shortcut,
540 std::function<void()> onClick, StyleRef style, bool destructive, LayoutOverride&& constraints);
542 void ShowContentTooltip(ID id, const GUIContent& content) { if (!content.tooltip.empty()) SetTooltip(id, content.tooltip); }
543
549
551
554
559 bool Button(ID id, const GUIContent& content, std::function<void()> onClick, StyleRef style, LayoutOverride&& constraints = {});
561 inline bool Button(ID id, const GUIContent& content, std::function<void()> onClick, LayoutOverride&& constraints = {}) { return Button(id, content, std::move(onClick), theme.controls->button, std::move(constraints)); }
563 inline bool Button( const GUIContent& content, std::function<void()> onClick, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return Button(idManager.AllocateDynamicID(site), content, std::move(onClick), style, std::move(constraints)); }
565 inline bool Button( const GUIContent& content, std::function<void()> onClick, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return Button(idManager.AllocateDynamicID(site), content, std::move(onClick), theme.controls->button, std::move(constraints)); }
566
568 bool CommandButton(CommandID command, StyleRef style, LayoutOverride&& constraints = {});
570 inline bool CommandButton(CommandID command, LayoutOverride&& constraints = {}) { return CommandButton(command, theme.controls->button, std::move(constraints)); }
571
573 bool Checkbox(ID id, bool value, std::string_view text, std::function<void(bool)> onToggle, StyleRef style, LayoutOverride&& constraints = {});
575 inline bool Checkbox(ID id, bool value, std::string_view text, std::function<void(bool)> onToggle, LayoutOverride&& constraints = {}) { return Checkbox(id, value, text, std::move(onToggle), theme.checkboxStyleRef, std::move(constraints)); }
577 inline bool Checkbox( bool value, std::string_view text, std::function<void(bool)> onToggle, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return Checkbox(idManager.AllocateDynamicID(site), value, text, std::move(onToggle), style, std::move(constraints)); }
579 inline bool Checkbox( bool value, std::string_view text, std::function<void(bool)> onToggle, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return Checkbox(idManager.AllocateDynamicID(site), value, text, std::move(onToggle), theme.checkboxStyleRef, std::move(constraints)); }
581 inline bool Checkbox(ID id, bool& value, std::string_view text, StyleRef style, LayoutOverride&& constraints = {}) { return Checkbox(id, value, text, [&value](bool newValue){ value = newValue; }, style, std::move(constraints)); }
583 inline bool Checkbox(ID id, bool& value, std::string_view text = {}, LayoutOverride&& constraints = {}) { return Checkbox(id, value, text, [&value](bool newValue){ value = newValue; }, theme.checkboxStyleRef, std::move(constraints)); }
585 inline bool Checkbox( bool& value, std::string_view text, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return Checkbox(idManager.AllocateDynamicID(site), value, text, [&value](bool newValue){ value = newValue; }, style, std::move(constraints)); }
587 inline bool Checkbox( bool& value, std::string_view text = {}, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return Checkbox(idManager.AllocateDynamicID(site), value, text, [&value](bool newValue){ value = newValue; }, theme.checkboxStyleRef, std::move(constraints)); }
588
590 bool Switch(ID id, bool value, std::string_view text, std::function<void(bool)> onToggle, StyleRef style, LayoutOverride&& constraints = {});
592 inline bool Switch(ID id, bool value, std::string_view text, std::function<void(bool)> onToggle, LayoutOverride&& constraints = {}) { return Switch(id, value, text, std::move(onToggle), theme.switchStyleRef, std::move(constraints)); }
594 inline bool Switch( bool value, std::string_view text, std::function<void(bool)> onToggle, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return Switch(idManager.AllocateDynamicID(site), value, text, std::move(onToggle), style, std::move(constraints)); }
596 inline bool Switch( bool value, std::string_view text, std::function<void(bool)> onToggle, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return Switch(idManager.AllocateDynamicID(site), value, text, std::move(onToggle), theme.switchStyleRef, std::move(constraints)); }
598 inline bool Switch(ID id, bool& value, std::string_view text, StyleRef style, LayoutOverride&& constraints = {}) { return Switch(id, value, text, [&value](bool newValue){ value = newValue; }, style, std::move(constraints)); }
600 inline bool Switch(ID id, bool& value, std::string_view text = {}, LayoutOverride&& constraints = {}) { return Switch(id, value, text, [&value](bool newValue){ value = newValue; }, theme.switchStyleRef, std::move(constraints)); }
602 inline bool Switch( bool& value, std::string_view text, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return Switch(idManager.AllocateDynamicID(site), value, text, [&value](bool newValue){ value = newValue; }, style, std::move(constraints)); }
604 inline bool Switch( bool& value, std::string_view text = {}, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return Switch(idManager.AllocateDynamicID(site), value, text, [&value](bool newValue){ value = newValue; }, theme.switchStyleRef, std::move(constraints)); }
605
607 bool Toggle(ID id, bool value, const GUIContent& content, std::function<void(bool)> onToggle, StyleRef style, LayoutOverride&& constraints = {});
609 inline bool Toggle(ID id, bool value, const GUIContent& content, std::function<void(bool)> onToggle, LayoutOverride&& constraints = {}) { return Toggle(id, value, content, std::move(onToggle), theme.controls->toggle, std::move(constraints)); }
611 inline bool Toggle( bool value, const GUIContent& content, std::function<void(bool)> onToggle, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return Toggle(idManager.AllocateDynamicID(site), value, content, std::move(onToggle), style, std::move(constraints)); }
613 inline bool Toggle( bool value, const GUIContent& content, std::function<void(bool)> onToggle, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return Toggle(idManager.AllocateDynamicID(site), value, content, std::move(onToggle), theme.controls->toggle, std::move(constraints)); }
615 inline bool Toggle(ID id, bool& value, const GUIContent& content, StyleRef style, LayoutOverride&& constraints = {}) { return Toggle(id, value, content, [&value](bool newValue){ value = newValue; }, style, std::move(constraints)); }
617 inline bool Toggle(ID id, bool& value, const GUIContent& content, LayoutOverride&& constraints = {}) { return Toggle(id, value, content, [&value](bool newValue){ value = newValue; }, theme.controls->toggle, std::move(constraints)); }
619 inline bool Toggle( bool& value, const GUIContent& content, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return Toggle(idManager.AllocateDynamicID(site), value, content, [&value](bool newValue){ value = newValue; }, style, std::move(constraints)); }
621 inline bool Toggle( bool& value, const GUIContent& content, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return Toggle(idManager.AllocateDynamicID(site), value, content, [&value](bool newValue){ value = newValue; }, theme.controls->toggle, std::move(constraints)); }
622
624
627
630 bool BeginMenu(ID id, std::string_view text, StyleRef buttonStyle, StyleRef menuStyle, StyleRef itemStyle, LayoutOverride&& constraints = {});
632 inline bool BeginMenu(ID id, std::string_view text, LayoutOverride&& constraints = {}) { return BeginMenu(id, text, theme.controls->menuTrigger, theme.menuStyleRef, theme.menuItemRowStyleRef, std::move(constraints)); }
634 inline bool BeginMenu( std::string_view text, StyleRef buttonStyle, StyleRef menuStyle, StyleRef itemStyle, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return BeginMenu(idManager.AllocateDynamicID(site), text, buttonStyle, menuStyle, itemStyle, std::move(constraints)); }
636 inline bool BeginMenu( std::string_view text, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return BeginMenu(idManager.AllocateDynamicID(site), text, theme.controls->menuTrigger, theme.menuStyleRef, theme.menuItemRowStyleRef, std::move(constraints)); }
641 bool Dropdown(ID id, int& selected, std::span<const std::string_view> options, StyleRef style, LayoutOverride&& constraints = {});
643 inline bool Dropdown(ID id, int& selected, std::span<const std::string_view> options, LayoutOverride&& constraints = {}) { return Dropdown(id, selected, options, theme.controls->menuTrigger, std::move(constraints)); }
645 inline bool Dropdown( int& selected, std::span<const std::string_view> options, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return Dropdown(idManager.AllocateDynamicID(site), selected, options, style, std::move(constraints)); }
647 inline bool Dropdown( int& selected, std::span<const std::string_view> options, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return Dropdown(idManager.AllocateDynamicID(site), selected, options, theme.controls->menuTrigger, std::move(constraints)); }
649 inline bool Dropdown(ID id, int& selected, std::initializer_list<std::string_view> options, LayoutOverride&& constraints = {}) { return Dropdown(id, selected, std::span<const std::string_view>(options.begin(), options.size()), theme.controls->menuTrigger, std::move(constraints)); }
651 inline bool Dropdown( int& selected, std::initializer_list<std::string_view> options, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return Dropdown(idManager.AllocateDynamicID(site), selected, std::span<const std::string_view>(options.begin(), options.size()), theme.controls->menuTrigger, std::move(constraints)); }
653 inline bool Dropdown(ID id, int& selected, std::initializer_list<std::string_view> options, StyleRef style, LayoutOverride&& constraints = {}) { return Dropdown(id, selected, std::span<const std::string_view>(options.begin(), options.size()), style, std::move(constraints)); }
655 inline bool Dropdown( int& selected, std::initializer_list<std::string_view> options, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return Dropdown(idManager.AllocateDynamicID(site), selected, std::span<const std::string_view>(options.begin(), options.size()), style, std::move(constraints)); }
657 void MenuHeader(std::string_view text);
661 int MessageDialog(ID id, const MessageDialogDesc& desc, StyleRef style);
663 inline int MessageDialog(ID id, const MessageDialogDesc& desc) { return MessageDialog(id, desc, theme.messageBoxStyleRef); }
665 inline int MessageDialog( const MessageDialogDesc& desc, StyleRef style, std::source_location site = std::source_location::current()) { return MessageDialog(idManager.AllocateDynamicID(site), desc, style); }
667 inline int MessageDialog( const MessageDialogDesc& desc, std::source_location site = std::source_location::current()) { return MessageDialog(idManager.AllocateDynamicID(site), desc, theme.messageBoxStyleRef); }
668
680 void Toasts();
683 void Banner(ID id, Severity severity, const GUIContent& message, std::span<const BannerAction> actions = {},
684 LayoutOverride&& constraints = {});
686 inline void Banner(Severity severity, const GUIContent& message, std::span<const BannerAction> actions = {},
687 LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current())
688 { Banner(idManager.AllocateDynamicID(site), severity, message, actions, std::move(constraints)); }
689
692 bool CloseRequested(ID windowID);
693
698
700 bool MenuItem(ID id, const GUIContent& content, std::string_view shortcut, std::function<void()> onClick, StyleRef style, LayoutOverride&& constraints = {});
702 inline bool MenuItem(ID id, const GUIContent& content, std::function<void()> onClick = nullptr, LayoutOverride&& constraints = {}) { return MenuItem(id, content, std::string_view{}, std::move(onClick), theme.menuItemRowStyleRef, std::move(constraints)); }
704 inline bool MenuItem( const GUIContent& content, std::function<void()> onClick = nullptr, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return MenuItem(idManager.AllocateDynamicID(site), content, std::string_view{}, std::move(onClick), theme.menuItemRowStyleRef, std::move(constraints)); }
706 inline bool MenuItem(ID id, const GUIContent& content, std::string_view shortcut, std::function<void()> onClick, LayoutOverride&& constraints = {}) { return MenuItem(id, content, shortcut, std::move(onClick), theme.menuItemRowStyleRef, std::move(constraints)); }
708 inline bool MenuItem( const GUIContent& content, std::string_view shortcut, std::function<void()> onClick, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return MenuItem(idManager.AllocateDynamicID(site), content, shortcut, std::move(onClick), theme.menuItemRowStyleRef, std::move(constraints)); }
710 inline bool MenuItem( const GUIContent& content, std::string_view shortcut, std::function<void()> onClick, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return MenuItem(idManager.AllocateDynamicID(site), content, shortcut, std::move(onClick), style, std::move(constraints)); }
712 inline bool MenuItem(ID id, const GUIContent& content, std::function<void()> onClick, StyleRef style, LayoutOverride&& constraints = {}) { return MenuItem(id, content, std::string_view{}, std::move(onClick), style, std::move(constraints)); }
714 inline bool MenuItem( const GUIContent& content, std::function<void()> onClick, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return MenuItem(idManager.AllocateDynamicID(site), content, std::string_view{}, std::move(onClick), style, std::move(constraints)); }
715
717 bool MenuItem(CommandID command);
719 bool DestructiveMenuItem(ID id, const GUIContent& content, std::string_view shortcut, std::function<void()> onClick, StyleRef style, LayoutOverride&& constraints = {});
721 inline bool DestructiveMenuItem(ID id, const GUIContent& content, std::string_view shortcut, std::function<void()> onClick, LayoutOverride&& constraints = {}) { return DestructiveMenuItem(id, content, shortcut, std::move(onClick), theme.menuItemRowStyleRef, std::move(constraints)); }
723 inline bool DestructiveMenuItem( const GUIContent& content, std::string_view shortcut, std::function<void()> onClick, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return DestructiveMenuItem(idManager.AllocateDynamicID(site), content, shortcut, std::move(onClick), style, std::move(constraints)); }
725 inline bool DestructiveMenuItem( const GUIContent& content, std::string_view shortcut, std::function<void()> onClick, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return DestructiveMenuItem(idManager.AllocateDynamicID(site), content, shortcut, std::move(onClick), theme.menuItemRowStyleRef, std::move(constraints)); }
727 inline bool DestructiveMenuItem(ID id, const GUIContent& content, std::function<void()> onClick, StyleRef style, LayoutOverride&& constraints = {}) { return DestructiveMenuItem(id, content, std::string_view{}, std::move(onClick), style, std::move(constraints)); }
729 inline bool DestructiveMenuItem(ID id, const GUIContent& content, std::function<void()> onClick, LayoutOverride&& constraints = {}) { return DestructiveMenuItem(id, content, std::string_view{}, std::move(onClick), theme.menuItemRowStyleRef, std::move(constraints)); }
731 inline bool DestructiveMenuItem( const GUIContent& content, std::function<void()> onClick, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return DestructiveMenuItem(idManager.AllocateDynamicID(site), content, std::string_view{}, std::move(onClick), style, std::move(constraints)); }
733 inline bool DestructiveMenuItem( const GUIContent& content, std::function<void()> onClick, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return DestructiveMenuItem(idManager.AllocateDynamicID(site), content, std::string_view{}, std::move(onClick), theme.menuItemRowStyleRef, std::move(constraints)); }
735 void EndMenu();
736
739 bool BeginMenuBar(ID id, StyleRef style, LayoutOverride&& constraints = {});
741 inline bool BeginMenuBar(ID id, LayoutOverride&& constraints = {}) { return BeginMenuBar(id, theme.menuBarStyleRef, std::move(constraints)); }
743 inline bool BeginMenuBar( LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return BeginMenuBar(idManager.AllocateDynamicID(site), theme.menuBarStyleRef, std::move(constraints)); }
745 inline bool BeginMenuBar( StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return BeginMenuBar(idManager.AllocateDynamicID(site), style, std::move(constraints)); }
748
750
753
754 // ---- Title bar: a menu bar the window is dragged by ----
755 // Whatever in it isn't a control is the caption: dragging it moves the window and a
756 // double-click maximizes it. In a window with ElementFlags::WindowCustomTitleBar,
757 // EndTitleBar adds the minimize, maximize / restore and close buttons.
761 bool BeginTitleBar(ID id, StyleRef style, LayoutOverride&& constraints = {});
763 inline bool BeginTitleBar(ID id, LayoutOverride&& constraints = {}) { return BeginTitleBar(id, theme.titleBarStyleRef, std::move(constraints)); }
765 inline bool BeginTitleBar( LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return BeginTitleBar(idManager.AllocateDynamicID(site), theme.titleBarStyleRef, std::move(constraints)); }
767 inline bool BeginTitleBar( StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return BeginTitleBar(idManager.AllocateDynamicID(site), style, std::move(constraints)); }
770
772 WindowHitArea TitleBarHitTest(ID windowID, int2 screenPos) const;
773
776
778 void SetTooltip(ID targetID, std::string_view text);
780 void SetTooltip(ID targetID, IconID icon, std::string_view text);
782 inline void SetTooltip(std::string_view text) { SetTooltip(elementStorage.GetLastItemID(), text); }
784 inline void SetTooltip(IconID icon, std::string_view text) { SetTooltip(elementStorage.GetLastItemID(), icon, text); }
786 void SetTooltip(ID targetID, std::string_view text, std::string_view shortcut);
788 void SetTooltip(ID targetID, IconID icon, std::string_view text, std::string_view shortcut);
790 inline void SetTooltip(std::string_view text, std::string_view shortcut) { SetTooltip(elementStorage.GetLastItemID(), text, shortcut); }
793 void SetTooltip(ID targetID, const PropertyHelp& help);
795 inline void SetTooltip(const PropertyHelp& help) { SetTooltip(elementStorage.GetLastItemID(), help); }
798 void SetErrorTooltip(ID targetID, std::string_view message);
800 inline void SetErrorTooltip(std::string_view message) { SetErrorTooltip(elementStorage.GetLastItemID(), message); }
803 void SetDisabledTooltip(ID targetID, std::string_view text, std::string_view reason);
805 inline void SetDisabledTooltip(std::string_view text, std::string_view reason) { SetDisabledTooltip(elementStorage.GetLastItemID(), text, reason); }
806
809 bool BeginTooltip(ID targetID);
814
819 bool BeginContextMenu(ID targetID);
826 void OpenContextMenu(ID targetID, int2 screenPos);
827
829
832
835 bool BeginLabelGroup(ID id, CssPx defaultWidth = 120, CssPx minWidth = 40, CssPx maxWidth = 500, bool resizable = true);
837 inline bool BeginLabelGroup(CssPx defaultWidth = 120, CssPx minWidth = 40, CssPx maxWidth = 500, bool resizable = true, std::source_location site = std::source_location::current()) { return BeginLabelGroup(idManager.AllocateDynamicID(site), defaultWidth, minWidth, maxWidth, resizable); }
840
843 bool BeginButtonGroup(LayoutOverride&& constraints = {});
847 bool BeginToggleGroup(LayoutOverride&& constraints = {});
850
854
857 bool BeginArea(ID id, StyleRef style, LayoutOverride&& constraints = {});
859 inline bool BeginArea(ID id, LayoutOverride&& constraints = {}) { return BeginArea(id, theme.collectionStyleRef, std::move(constraints)); }
861 inline bool BeginArea( StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return BeginArea(idManager.AllocateDynamicID(site), style, std::move(constraints)); }
863 inline bool BeginArea( LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return BeginArea(idManager.AllocateDynamicID(site), theme.collectionStyleRef, std::move(constraints)); }
865 void EndArea();
866
873 bool BeginCached(ID id, StyleRef style, uint64_t signature = 0, LayoutOverride&& constraints = {});
875 inline bool BeginCached(ID id, uint64_t signature = 0, LayoutOverride&& constraints = {}) { return BeginCached(id, theme.collectionStyleRef, signature, std::move(constraints)); }
877 void EndCached();
879 void Invalidate(ID id);
880
882 void SetDrawCacheEnabled(bool enabled) { if (m_uiCache) m_uiCache->SetDrawCacheEnabled(enabled); }
883
885 void InvalidatePanel(ID panelId);
886
888 bool BeginHorizontal(ID id, StyleRef style, LayoutOverride&& constraints = {});
890 inline bool BeginHorizontal(ID id, LayoutOverride&& constraints = {}) { return BeginHorizontal(id, theme.emptyHorzStyleRef, std::move(constraints)); }
892 inline bool BeginHorizontal( StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return BeginHorizontal(idManager.AllocateDynamicID(site), style, std::move(constraints)); }
894 inline bool BeginHorizontal( LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return BeginHorizontal(idManager.AllocateDynamicID(site), theme.emptyHorzStyleRef, std::move(constraints)); }
897
899 bool BeginHorizontalWrap(ID id, StyleRef style, LayoutOverride&& constraints = {});
901 inline bool BeginHorizontalWrap(ID id, LayoutOverride&& constraints = {}) { return BeginHorizontalWrap(id, theme.emptyHorzWrapStyleRef, std::move(constraints)); }
903 inline bool BeginHorizontalWrap( StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return BeginHorizontalWrap(idManager.AllocateDynamicID(site), style, std::move(constraints)); }
905 inline bool BeginHorizontalWrap( LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return BeginHorizontalWrap(idManager.AllocateDynamicID(site), theme.emptyHorzWrapStyleRef, std::move(constraints)); }
908
910 bool BeginVertical(ID id, StyleRef style, LayoutOverride&& constraints = {});
912 inline bool BeginVertical(ID id, LayoutOverride&& constraints = {}) { return BeginVertical(id, theme.emptyVertStyleRef, std::move(constraints)); }
914 inline bool BeginVertical( StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return BeginVertical(idManager.AllocateDynamicID(site), style, std::move(constraints)); }
916 inline bool BeginVertical( LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return BeginVertical(idManager.AllocateDynamicID(site), theme.emptyVertStyleRef, std::move(constraints)); }
919
921 bool BeginVerticalWrap(ID id, StyleRef style, LayoutOverride&& constraints = {});
923 inline bool BeginVerticalWrap(ID id, LayoutOverride&& constraints = {}) { return BeginVerticalWrap(id, theme.emptyVertWrapStyleRef, std::move(constraints)); }
925 inline bool BeginVerticalWrap( StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return BeginVerticalWrap(idManager.AllocateDynamicID(site), style, std::move(constraints)); }
927 inline bool BeginVerticalWrap( LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return BeginVerticalWrap(idManager.AllocateDynamicID(site), theme.emptyVertWrapStyleRef, std::move(constraints)); }
930
933 bool BeginToolbar(bool horizontal = true);
936
938
941
942 // ---- Scrollbars ----
943 // Call from INSIDE the scrollable container `containerID`: the bar overlays
944 // its border box, unaffected by its scroll offset. Paints nothing without
945 // overflow, so it can always be emitted.
948 void VerticalScrollbar (ID scrollBarID, ID containerID);
950 void VerticalScrollbar (ID containerID) { (void)idManager.PushParent(containerID); const ID barID = idManager.AllocateDynamicID("vertical_scrollbar"); (void)idManager.PopParent(); VerticalScrollbar(barID, containerID); }
952 void HorizontalScrollbar(ID scrollBarID, ID containerID);
954 void HorizontalScrollbar(ID containerID) { (void)idManager.PushParent(containerID); const ID barID = idManager.AllocateDynamicID("horizontal_scrollbar"); (void)idManager.PopParent(); HorizontalScrollbar(barID, containerID); }
955
958 void ScrollbarOverlay(ID containerID,
959 int2 lastInnerSize = int2{0, 0},
960 ID vertScrollBarID = ID::Invalid(),
961 ID horzScrollBarID = ID::Invalid(),
962 bool emitVert = true,
963 bool emitHorz = true);
964
966
969
970 // ---- Reorderable Group: drag-to-reorder container ----
971 // onReorder(fromIndex, toIndex) fires on drop. isWrapped allows multi-line layout.
972 // onDragOut(index, screenPos): an item was released outside the group.
973 // dragVisualizer(index, screenPos): each frame while dragging outside the group,
974 // typically to draw a ghost window; suppresses the in-place cross-axis offset.
977 bool BeginReorderableGroup(ID id, ReorderDirection direction, bool isWrapped, std::function<void(int fromIndex, int toIndex)> onReorder, StyleRef style, LayoutOverride&& constraints = {}, std::function<void(int, tachyon::int2)> onDragOut = nullptr, std::function<void(int, tachyon::int2)> dragVisualizer = nullptr);
979 inline bool BeginReorderableGroup(ID id, ReorderDirection direction, std::function<void(int fromIndex, int toIndex)> onReorder, StyleRef style, LayoutOverride&& constraints = {})
980 { return BeginReorderableGroup(id, direction, false, std::move(onReorder), style, std::move(constraints)); }
981
982 inline bool BeginReorderableGroup(ID id, ReorderDirection direction, std::function<void(int fromIndex, int toIndex)> onReorder, LayoutOverride&& constraints = {})
983 { return BeginReorderableGroup(id, direction, false, std::move(onReorder), ReorderableGroupStyle(direction, false), std::move(constraints)); }
984
985 inline bool BeginReorderableGroup(ID id, ReorderDirection direction, bool isWrapped, std::function<void(int fromIndex, int toIndex)> onReorder, LayoutOverride&& constraints = {})
986 { return BeginReorderableGroup(id, direction, isWrapped, std::move(onReorder), ReorderableGroupStyle(direction, isWrapped), std::move(constraints)); }
987
988 inline bool BeginReorderableGroup(ReorderDirection direction, bool isWrapped, std::function<void(int fromIndex, int toIndex)> onReorder, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current())
989 { return BeginReorderableGroup(idManager.AllocateDynamicID(site), direction, isWrapped, std::move(onReorder), style, std::move(constraints)); }
990
991 inline bool BeginReorderableGroup(ReorderDirection direction, bool isWrapped, std::function<void(int fromIndex, int toIndex)> onReorder, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current())
992 { return BeginReorderableGroup(idManager.AllocateDynamicID(site), direction, isWrapped, std::move(onReorder), ReorderableGroupStyle(direction, isWrapped), std::move(constraints)); }
993
994 inline bool BeginReorderableGroup(ReorderDirection direction, std::function<void(int fromIndex, int toIndex)> onReorder, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current())
995 { return BeginReorderableGroup(idManager.AllocateDynamicID(site), direction, false, std::move(onReorder), style, std::move(constraints)); }
996
997 inline bool BeginReorderableGroup(ReorderDirection direction, std::function<void(int fromIndex, int toIndex)> onReorder, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current())
998 { return BeginReorderableGroup(idManager.AllocateDynamicID(site), direction, false, std::move(onReorder), ReorderableGroupStyle(direction, false), std::move(constraints)); }
999
1006
1008
1010 bool BeginReorderableItem(ID id, StyleRef style, LayoutOverride&& constraints = {});
1012 inline bool BeginReorderableItem(ID id, LayoutOverride&& constraints = {}) { return BeginReorderableItem(id, theme.reorderableItemStyleRef, std::move(constraints)); }
1014 inline bool BeginReorderableItem(StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return BeginReorderableItem(idManager.AllocateDynamicID(site), style, std::move(constraints)); }
1016 inline bool BeginReorderableItem(LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return BeginReorderableItem(idManager.AllocateDynamicID(site), theme.reorderableItemStyleRef, std::move(constraints)); }
1019
1022
1024
1027
1028 // ---- ListView: scrollable list with selectable items ----
1031 bool BeginListView(ID id, int* selectedIndex, int itemCount, ItemDragDropConfig* dragDrop, StyleRef style, LayoutOverride&& constraints = {});
1033 inline bool BeginListView(ID id, int* selectedIndex, int itemCount, StyleRef style, LayoutOverride&& constraints = {}) { return BeginListView(id, selectedIndex, itemCount, nullptr, style, std::move(constraints)); }
1035 inline bool BeginListView(ID id, int* selectedIndex, int itemCount, LayoutOverride&& constraints = {}) { return BeginListView(id, selectedIndex, itemCount, nullptr, theme.listViewStyleRef, std::move(constraints)); }
1037 inline bool BeginListView( int* selectedIndex, int itemCount, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return BeginListView(idManager.AllocateDynamicID(site), selectedIndex, itemCount, nullptr, theme.listViewStyleRef, std::move(constraints)); }
1039 inline bool BeginListView(ID id, int* selectedIndex, int itemCount, ItemDragDropConfig* dragDrop, LayoutOverride&& constraints = {}) { return BeginListView(id, selectedIndex, itemCount, dragDrop, theme.listViewStyleRef, std::move(constraints)); }
1041 inline bool BeginListView( int* selectedIndex, int itemCount, ItemDragDropConfig* dragDrop, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return BeginListView(idManager.AllocateDynamicID(site), selectedIndex, itemCount, dragDrop, theme.listViewStyleRef, std::move(constraints)); }
1043 inline bool BeginListView( int* selectedIndex, int itemCount, ItemDragDropConfig* dragDrop, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return BeginListView(idManager.AllocateDynamicID(site), selectedIndex, itemCount, dragDrop, style, std::move(constraints)); }
1045 inline bool BeginListView( int* selectedIndex, int itemCount, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return BeginListView(idManager.AllocateDynamicID(site), selectedIndex, itemCount, nullptr, style, std::move(constraints)); }
1048
1052
1054 bool ListItem(ID id, const GUIContent& content, StyleRef style, LayoutOverride&& constraints = {});
1056 inline bool ListItem(ID id, const GUIContent& content, LayoutOverride&& constraints = {}) { return ListItem(id, content, theme.listItemStyleRef, std::move(constraints)); }
1058 inline bool ListItem( const GUIContent& content, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return ListItem(idManager.AllocateDynamicID(site), content, theme.listItemStyleRef, std::move(constraints)); }
1060 inline bool ListItem( const GUIContent& content, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return ListItem(idManager.AllocateDynamicID(site), content, style, std::move(constraints)); }
1061
1062
1065 static void RebuildTreeViewIndex(std::vector<TreeViewRow>& rows);
1066
1068 static void WalkTreeViewVisibility(const std::vector<TreeViewRow>& rows,
1069 std::vector<int>& visibleIdx);
1070
1074 std::vector<TreeViewRow>& rows,
1075 std::vector<int>& visibleIdx,
1076 TableState& state,
1077 StyleRef style = {},
1078 LayoutOverride&& constraints = {},
1079 std::string_view header = {});
1081 inline void VirtualTreeView(std::vector<TreeViewRow>& rows, std::vector<int>& visibleIdx, TableState& state,
1082 StyleRef style = {}, LayoutOverride&& constraints = {}, std::string_view header = {},
1083 std::source_location site = std::source_location::current())
1084 { VirtualTreeView(idManager.AllocateDynamicID(site), rows, visibleIdx, state, style, std::move(constraints), header); }
1085
1087 ID TreeDropTargetRow() const { return m_treeDropState.targetRowID; }
1088
1091 bool IsFileDragging() const { return inputManager && inputManager->GetFileDrag() != nullptr; }
1095 ID FileDragTargetID() const { return m_fileDragTargetID; }
1098 void SetFileDropHandler(std::function<void(const FileDrop&)> handler) { m_fileDropHandler = std::move(handler); }
1099
1114
1116
1119
1120 // ---- GridView: 2D icon grid (like file explorer) ----
1124 bool BeginGridView(ID id, int* selectedIndex, StyleRef style, MultiSelectState* multiSelect = nullptr, ItemDragDropConfig* dragDrop = nullptr, LayoutOverride&& constraints = {});
1126 inline bool BeginGridView(ID id, int* selectedIndex = nullptr, MultiSelectState* multiSelect = nullptr, ItemDragDropConfig* dragDrop = nullptr, LayoutOverride&& constraints = {}) { return BeginGridView(id, selectedIndex, theme.gridViewStyleRef, multiSelect, dragDrop, std::move(constraints)); }
1128 inline bool BeginGridView(int* selectedIndex, StyleRef style, MultiSelectState* multiSelect = nullptr, ItemDragDropConfig* dragDrop = nullptr, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return BeginGridView(idManager.AllocateDynamicID(site), selectedIndex, style, multiSelect, dragDrop, std::move(constraints)); }
1130 inline bool BeginGridView(int* selectedIndex, MultiSelectState* multiSelect = nullptr, ItemDragDropConfig* dragDrop = nullptr, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return BeginGridView(idManager.AllocateDynamicID(site), selectedIndex, theme.gridViewStyleRef, multiSelect, dragDrop, std::move(constraints)); }
1133
1136 bool GridViewItem(ID id, const GUIContent& content,
1138 std::string* renameBuffer = nullptr,
1139 StyleRef itemStyle = {},
1140 LayoutOverride&& constraints = {});
1142 inline bool GridViewItem(ID id, const GUIContent& content, LayoutOverride&& constraints)
1143 { return GridViewItem(id, content, tachyon::ElementState::None, nullptr, {}, std::move(constraints)); }
1144
1145 inline bool GridViewItem(const GUIContent& content, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current())
1146 { return GridViewItem(idManager.AllocateDynamicID(site), content, tachyon::ElementState::None, nullptr, {}, std::move(constraints)); }
1147
1148 inline bool GridViewItem(ID id, const GUIContent& content, StyleRef style, LayoutOverride&& constraints = {})
1149 { return GridViewItem(id, content, tachyon::ElementState::None, nullptr, style, std::move(constraints)); }
1150
1151 inline bool GridViewItem(const GUIContent& content, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current())
1152 { return GridViewItem(idManager.AllocateDynamicID(site), content, tachyon::ElementState::None, nullptr, style, std::move(constraints)); }
1153
1156 bool IsRenaming() const { return m_renameSub && m_renameSub->isActive; }
1157
1158
1163 int itemCount, int2 cellSize,
1164 const std::function<void(int index, ID itemID)>& generateItem,
1165 int* selectedIndex = nullptr,
1166 MultiSelectState* multiSelect = nullptr,
1167 ItemDragDropConfig* dragDrop = nullptr,
1168 StyleRef scrollStyle = {},
1169 StyleRef rowStyle = {},
1170 LayoutOverride&& constraints = {});
1172 inline void VirtualGridView(GridViewVirtualState& vstate, int itemCount, int2 cellSize,
1173 const std::function<void(int index, ID itemID)>& generateItem,
1174 int* selectedIndex = nullptr, MultiSelectState* multiSelect = nullptr,
1175 ItemDragDropConfig* dragDrop = nullptr, StyleRef scrollStyle = {}, StyleRef rowStyle = {},
1176 LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current())
1177 { VirtualGridView(idManager.AllocateDynamicID(site), vstate, itemCount, cellSize, generateItem, selectedIndex, multiSelect, dragDrop, scrollStyle, rowStyle, std::move(constraints)); }
1178
1180
1183
1184 // ---- Table: row x column data grid ----
1189 bool BeginTable(ID id, VirtualTableColumn* columns, size_t columnCount,
1190 TableState& state, StyleRef style,
1191 LayoutOverride&& constraints = {});
1193 inline bool BeginTable(ID id, VirtualTableColumn* columns, size_t columnCount,
1194 TableState& state, LayoutOverride&& constraints = {})
1195 { return BeginTable(id, columns, columnCount, state, theme.tableStyleRef, std::move(constraints)); }
1196
1197 template <size_t N>
1198 inline bool BeginTable(ID id, VirtualTableColumn (&columns)[N], TableState& state,
1199 StyleRef style, LayoutOverride&& constraints = {})
1200 { return BeginTable(id, columns, N, state, style, std::move(constraints)); }
1201
1202 template <size_t N>
1203 inline bool BeginTable(ID id, VirtualTableColumn (&columns)[N], TableState& state,
1204 LayoutOverride&& constraints = {})
1205 { return BeginTable(id, columns, N, state, theme.tableStyleRef, std::move(constraints)); }
1206
1207 inline bool BeginTable(VirtualTableColumn* columns, size_t columnCount, TableState& state, StyleRef style,
1208 LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current())
1209 { return BeginTable(idManager.AllocateDynamicID(site), columns, columnCount, state, style, std::move(constraints)); }
1210
1211 inline bool BeginTable(VirtualTableColumn* columns, size_t columnCount, TableState& state,
1212 LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current())
1213 { return BeginTable(idManager.AllocateDynamicID(site), columns, columnCount, state, theme.tableStyleRef, std::move(constraints)); }
1214
1215 template <size_t N>
1216 inline bool BeginTable(VirtualTableColumn (&columns)[N], TableState& state, StyleRef style,
1217 LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current())
1218 { return BeginTable(idManager.AllocateDynamicID(site), columns, N, state, style, std::move(constraints)); }
1219
1220 template <size_t N>
1221 inline bool BeginTable(VirtualTableColumn (&columns)[N], TableState& state,
1222 LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current())
1223 { return BeginTable(idManager.AllocateDynamicID(site), columns, N, state, theme.tableStyleRef, std::move(constraints)); }
1224
1225 void EndTable();
1226
1228 bool BeginRow();
1230 void EndRow();
1231
1233 void Cell(std::string_view text);
1234
1237 void Cell(std::function<void()> emit);
1238
1251 void TreeCell(std::string_view text, int depth, bool* isOpen,
1252 IconID icon = IconID::Invalid,
1253 uint32_t ancestorLineMask = 0,
1254 bool isLastSibling = true,
1255 std::string* renameBuffer = nullptr,
1256 bool reserveExpander = true);
1257
1266 void VirtualTable(ID id, TableState& state,
1267 std::span<VirtualTableColumn> columns,
1268 int totalRowCount,
1269 CssPx rowHeight = 0,
1270 StyleRef style = {},
1271 LayoutOverride&& constraints = {});
1273 inline void VirtualTable(TableState& state, std::span<VirtualTableColumn> columns, int totalRowCount,
1274 CssPx rowHeight = 0, StyleRef style = {}, LayoutOverride&& constraints = {},
1275 std::source_location site = std::source_location::current())
1276 { VirtualTable(idManager.AllocateDynamicID(site), state, columns, totalRowCount, rowHeight, style, std::move(constraints)); }
1277
1279
1282
1283 // ---- Breadcrumb ----
1286 bool Breadcrumb(ID id, std::span<const std::string> segments, std::function<void(int)> onSelect, StyleRef style, LayoutOverride&& constraints = {});
1288 inline bool Breadcrumb(ID id, std::span<const std::string> segments, std::function<void(int)> onSelect, LayoutOverride&& constraints = {}) { return Breadcrumb(id, segments, std::move(onSelect), theme.breadcrumbStyleRef, std::move(constraints)); }
1290 inline bool Breadcrumb( std::span<const std::string> segments, std::function<void(int)> onSelect, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return Breadcrumb(idManager.AllocateDynamicID(site), segments, std::move(onSelect), theme.breadcrumbStyleRef, std::move(constraints)); }
1292 inline bool Breadcrumb( std::span<const std::string> segments, std::function<void(int)> onSelect, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return Breadcrumb(idManager.AllocateDynamicID(site), segments, std::move(onSelect), style, std::move(constraints)); }
1293
1295
1298
1299 // ---- Status bar ----
1302 bool BeginStatusBar(ID id, StyleRef style, LayoutOverride&& constraints = {});
1304 inline bool BeginStatusBar(ID id, LayoutOverride&& constraints = {}) { return BeginStatusBar(id, theme.statusBarStyleRef, std::move(constraints)); }
1306 inline bool BeginStatusBar( LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return BeginStatusBar(idManager.AllocateDynamicID(site), theme.statusBarStyleRef, std::move(constraints)); }
1308 inline bool BeginStatusBar( StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return BeginStatusBar(idManager.AllocateDynamicID(site), style, std::move(constraints)); }
1312 void StatusText(ID id, std::string_view text, StyleRef style, LayoutOverride&& constraints = {});
1314 inline void StatusText(ID id, std::string_view text, LayoutOverride&& constraints = {}) { StatusText(id, text, theme.statusTextStyleRef, std::move(constraints)); }
1316 inline void StatusText( std::string_view text, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { StatusText(idManager.AllocateDynamicID(site), text, style, std::move(constraints)); }
1318 inline void StatusText( std::string_view text, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { StatusText(idManager.AllocateDynamicID(site), text, theme.statusTextStyleRef, std::move(constraints)); }
1319
1321
1324
1325 // ---- Command search ----
1329 bool CommandSearch(ID id, CommandSearchState& state, StyleRef style, LayoutOverride&& constraints = {});
1331 inline bool CommandSearch(ID id, CommandSearchState& state, LayoutOverride&& constraints = {}) { return CommandSearch(id, state, theme.commandSearchStyleRef, std::move(constraints)); }
1333 inline bool CommandSearch( CommandSearchState& state, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return CommandSearch(idManager.AllocateDynamicID(site), state, style, std::move(constraints)); }
1335 inline bool CommandSearch( CommandSearchState& state, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return CommandSearch(idManager.AllocateDynamicID(site), state, theme.commandSearchStyleRef, std::move(constraints)); }
1337 static void FocusCommandSearch(CommandSearchState& state) { state.focusRequested = true; }
1338
1340
1343
1344 // ---- Node view: self-contained graph editor ----
1345 // All state lives in `view`, so several views can coexist.
1348
1351 void NodeText(std::string_view text);
1352
1354
1357
1358 // ---- TabBar: reorderable tabs ----
1365 bool BeginTabBar(ID id, int* selectedIndex,
1366 std::function<void(int, int)> onReorder,
1367 std::function<void(int)> onClose = nullptr,
1368 std::function<void(int, tachyon::int2)> onDragOut = nullptr,
1369 std::function<void(int, tachyon::int2)> dragVisualizer = nullptr,
1370 StyleRef style = {},
1371 LayoutOverride&& constraints = {},
1372 TabBarLayout* layout = nullptr,
1373 const TabBarOptions& options = {});
1375 inline bool BeginTabBar(int* selectedIndex,
1376 std::function<void(int, int)> onReorder,
1377 std::function<void(int)> onClose = nullptr,
1378 std::function<void(int, tachyon::int2)> onDragOut = nullptr,
1379 std::function<void(int, tachyon::int2)> dragVisualizer = nullptr,
1380 StyleRef style = {},
1381 LayoutOverride&& constraints = {}, TabBarLayout* layout = nullptr,
1382 std::source_location site = std::source_location::current())
1383 { return BeginTabBar(idManager.AllocateDynamicID(site), selectedIndex, std::move(onReorder), std::move(onClose), std::move(onDragOut), std::move(dragVisualizer), style, std::move(constraints), layout); }
1384
1386
1388 bool Tab(ID id, const GUIContent& content, StyleRef style, LayoutOverride&& constraints = {});
1392 bool BeginTab(ID id, const GUIContent& content, StyleRef style, StyleRef contentStyle,
1393 LayoutOverride&& constraints = {});
1395 void EndTab();
1397 inline bool Tab(ID id, const GUIContent& content, LayoutOverride&& constraints = {}) { return Tab(id, content, theme.tabStyleRef, std::move(constraints)); }
1399 inline bool Tab( const GUIContent& content, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return Tab(idManager.AllocateDynamicID(site), content, theme.tabStyleRef, std::move(constraints)); }
1401 inline bool Tab( const GUIContent& content, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return Tab(idManager.AllocateDynamicID(site), content, style, std::move(constraints)); }
1402
1404
1407
1408 // ---- DockingContainer ----
1411 bool BeginDockingContainer(ID id, DockingLayout* layout, StyleRef style, LayoutOverride&& constraints = {});
1413 inline bool BeginDockingContainer(ID id, DockingLayout* layout, LayoutOverride&& constraints = {})
1414 { return BeginDockingContainer(id, layout, theme.dockContainerStyleRef, std::move(constraints)); }
1415
1416 inline bool BeginDockingContainer(DockingLayout* layout, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current())
1417 { return BeginDockingContainer(idManager.AllocateDynamicID(site), layout, style, std::move(constraints)); }
1418
1419 inline bool BeginDockingContainer(DockingLayout* layout, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current())
1420 { return BeginDockingContainer(idManager.AllocateDynamicID(site), layout, theme.dockContainerStyleRef, std::move(constraints)); }
1421
1423
1428 void Documents(ID id, DocumentSet& set, LayoutOverride&& constraints = {});
1429
1431
1434
1436 bool Field(ID id, bool& value, std::string_view text, StyleRef style, LayoutOverride&& constraints = {});
1438 inline bool Field( bool& value, std::string_view text, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return Field(idManager.AllocateDynamicID(site), value, text, style, std::move(constraints)); }
1440 inline bool Field(ID id, bool& value, std::string_view text, LayoutOverride&& constraints = {}) { return Field(id, value, text, theme.controls->toggle, std::move(constraints)); }
1442 inline bool Field( bool& value, std::string_view text, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return Field(idManager.AllocateDynamicID(site), value, text, theme.controls->toggle, std::move(constraints)); }
1443
1446 bool Field(ID id, std::string& value, TextEditBehavior textEditBehavior, StyleRef style, LayoutOverride&& constraints = {});
1448 inline bool Field( std::string& value, TextEditBehavior textEditBehavior, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return Field(idManager.AllocateDynamicID(site), value, textEditBehavior, style, std::move(constraints)); }
1450 inline bool Field(ID id, std::string& value, StyleRef style, LayoutOverride&& constraints = {}) { return Field(id, value, TextEditBehavior::ContinuousUpdate, style, std::move(constraints)); }
1452 inline bool Field( std::string& value, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return Field(idManager.AllocateDynamicID(site), value, TextEditBehavior::ContinuousUpdate, style, std::move(constraints)); }
1454 inline bool Field(ID id, std::string& value, TextEditBehavior textEditBehavior, LayoutOverride&& constraints = {}) { return Field(id, value, textEditBehavior, theme.controls->textbox, std::move(constraints)); }
1456 inline bool Field( std::string& value, TextEditBehavior textEditBehavior, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return Field(idManager.AllocateDynamicID(site), value, textEditBehavior, theme.controls->textbox, std::move(constraints)); }
1458 inline bool Field(ID id, std::string& value, LayoutOverride&& constraints = {}) { return Field(id, value, TextEditBehavior::ContinuousUpdate, theme.controls->textbox, std::move(constraints)); }
1460 inline bool Field( std::string& value, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return Field(idManager.AllocateDynamicID(site), value, TextEditBehavior::ContinuousUpdate, theme.controls->textbox, std::move(constraints)); }
1461
1463 inline bool SearchField(ID id, std::string& value, IconID icon, TextEditBehavior textEditBehavior, StyleRef style, LayoutOverride&& constraints = {}) { return SearchField(id, value, icon, textEditBehavior, style, std::move(constraints), nullptr); }
1465 inline bool SearchField(ID id, std::string& value, IconID icon, TextEditBehavior textEditBehavior = TextEditBehavior::ContinuousUpdate, LayoutOverride&& constraints = {}) { return SearchField(id, value, icon, textEditBehavior, theme.searchTextboxStyleRef, std::move(constraints)); }
1467 inline bool SearchField( std::string& value, IconID icon, TextEditBehavior textEditBehavior, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return SearchField(idManager.AllocateDynamicID(site), value, icon, textEditBehavior, style, std::move(constraints)); }
1469 inline bool SearchField( std::string& value, IconID icon, TextEditBehavior textEditBehavior = TextEditBehavior::ContinuousUpdate, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return SearchField(idManager.AllocateDynamicID(site), value, icon, textEditBehavior, theme.searchTextboxStyleRef, std::move(constraints)); }
1470
1476 bool AutocompleteField(ID id, std::string& value, std::span<const std::string_view> suggestions, StyleRef style, LayoutOverride&& constraints = {});
1478 inline bool AutocompleteField(ID id, std::string& value, std::span<const std::string_view> suggestions, LayoutOverride&& constraints = {}) { return AutocompleteField(id, value, suggestions, theme.controls->textbox, std::move(constraints)); }
1480 inline bool AutocompleteField( std::string& value, std::span<const std::string_view> suggestions, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return AutocompleteField(idManager.AllocateDynamicID(site), value, suggestions, style, std::move(constraints)); }
1482 inline bool AutocompleteField( std::string& value, std::span<const std::string_view> suggestions, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return AutocompleteField(idManager.AllocateDynamicID(site), value, suggestions, theme.controls->textbox, std::move(constraints)); }
1483
1484
1485
1486
1490 template<typename T, typename ComponentT = typename TypeDimensions<T>::ComponentType>
1491 inline bool Field(ID id, T& value, TextEditBehavior textEditBehavior, StyleRef style, NumericFieldConfig<ComponentT> config = {}, LayoutOverride&& constraints = {})
1492 {
1494 {
1495 RegisterControl(tachyon::Element { .id = id, .styleRef = style, .flags = ElementFlags::DoNotMeasureText },
1496 [this](tachyon::Element& element) { return textSystem->RegisterText(element.id, "\xe2\x80\x94", element.styleRef, element.state); },
1497 std::move(constraints));
1499 return false;
1500 }
1501
1502 if constexpr (TypeDimensions<T>::dimensions == 1)
1503 {
1504 // Inside a node row, fill the body after the label so the node stays grid-aligned.
1505 if (nodeRowFieldMinWidth > 0 && !constraints.HasFixedWidth())
1506 constraints.FlexGrow(1).MinWidth(Pixels{ nodeRowFieldMinWidth });
1507 bool modified = false;
1508 RegisterControl(tachyon::Element { .id = id, .eventHandler = ReportingChanges(guiStateManager, &value, MakeNumericalBoxHandler(guiStateManager, value, config)),
1509 .styleRef = style, .flags = ElementFlags::DoNotMeasureText },
1510 [this, &modified, &value, textEditBehavior, config](tachyon::Element& element) {
1511 const TextID textID = textSystem->RegisterEditableNumber(element.id, value, textEditBehavior, element.styleRef, element.state, modified, config);
1512 if constexpr (std::is_floating_point_v<T>)
1513 if (std::isnan(value))
1514 textSystem->SetTextColor(textID, theme.nanTextColor); // NaN reads as a warning
1515 return textID;
1516 },
1517 std::move(constraints));
1518 // A label drag writes the value from the handler: reported the frame after.
1519 modified = modified || guiStateManager.Interaction().HasBeenClicked(id);
1520 guiStateManager.SetModified(modified);
1521 return modified;
1522 } else
1523 {
1524 bool modified = false;
1525 // Width 0 + flex-grow: the group fills remaining space after the label.
1526 constraints.Width(0);
1527 // Takes its components' states, so a tooltip or context menu on it covers them.
1528 RegisterElement(tachyon::Element{ .id = id, .eventHandler = ReportingChanges(guiStateManager, &value, MakeMultiDimDragHandler<T>(guiStateManager, value, config)),
1529 .styleRef = theme.fieldElementGroupStyleRef,
1530 .flags = ElementFlags::PropagatesDescendantState }, std::move(constraints));
1532 {
1533 // Each component: a colored axis label (drag it to change the value) attached
1534 // to the component's field. A caller's own style replaces the attached field.
1535 const StyleRef componentStyle = (style == theme.controls->number || style == theme.controls->textbox) ? theme.vectorComponentStyleRef : style;
1536 for (int i = 0; i < TypeDimensions<T>::dimensions; i++)
1537 {
1538 DragLabel(TypeDimensions<T>::names[i], theme.axisLabelStyleRefs[i % 4],
1539 LayoutOverride::FixedWidth(Pixels{ theme.axisLabelWidth }).KeepWithNext()); // wraps with its field
1540 modified = Field(TypeDimensions<T>::GetComponent(value, i), textEditBehavior, componentStyle, config, LayoutOverride::Auto()
1541 .MinWidth(40)) || modified;
1542 }
1543 }
1545 modified = modified || guiStateManager.Interaction().HasBeenClicked(id);
1546 guiStateManager.SetModified(modified);
1547 return modified;
1548 }
1549 }
1550
1551 template<typename T, typename ComponentT = typename TypeDimensions<T>::ComponentType>
1552 inline bool Field(ID id, T& value, TextEditBehavior textEditBehavior, NumericFieldConfig<ComponentT> config, LayoutOverride&& constraints = {}) { return Field<T>(id, value, textEditBehavior, theme.controls->number, config, std::move(constraints)); }
1554 template<typename T, typename ComponentT = typename TypeDimensions<T>::ComponentType>
1555 inline bool Field(ID id, T& value, TextEditBehavior textEditBehavior, LayoutOverride&& constraints = {}) { return Field<T>(id, value, textEditBehavior, theme.controls->number, {}, std::move(constraints)); }
1557 template<typename T, typename ComponentT = typename TypeDimensions<T>::ComponentType>
1558 inline bool Field(ID id, T& value, LayoutOverride&& constraints = {}) { return Field<T>(id, value, TextEditBehavior::ContinuousUpdate, theme.controls->number, {}, std::move(constraints)); }
1560 template<typename T, typename ComponentT = typename TypeDimensions<T>::ComponentType>
1561 inline bool Field(ID id, T& value, StyleRef style, NumericFieldConfig<ComponentT> config, LayoutOverride&& constraints = {}) { return Field<T>(id, value, TextEditBehavior::ContinuousUpdate, style, config, std::move(constraints)); }
1563 template<typename T, typename ComponentT = typename TypeDimensions<T>::ComponentType>
1564 inline bool Field(ID id, T& value, StyleRef style, LayoutOverride&& constraints = {}) { return Field<T>(id, value, TextEditBehavior::ContinuousUpdate, style, {}, std::move(constraints)); }
1566 template<typename T, typename ComponentT = typename TypeDimensions<T>::ComponentType>
1567 inline bool Field(ID id, T& value, NumericFieldConfig<ComponentT> config, LayoutOverride&& constraints = {}) { return Field<T>(id, value, TextEditBehavior::ContinuousUpdate, theme.controls->number, config, std::move(constraints)); }
1569 template<typename T, typename ComponentT = typename TypeDimensions<T>::ComponentType>
1570 inline bool Field(T& value, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return Field<T>(idManager.AllocateDynamicID(site), value, TextEditBehavior::ContinuousUpdate, style, {}, std::move(constraints)); }
1572 template<typename T, typename ComponentT = typename TypeDimensions<T>::ComponentType>
1573 inline bool Field( T& value, TextEditBehavior textEditBehavior, StyleRef style, NumericFieldConfig<ComponentT> config, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return Field<T>(idManager.AllocateDynamicID(site), value, textEditBehavior, style, config, std::move(constraints)); }
1575 template<typename T, typename ComponentT = typename TypeDimensions<T>::ComponentType>
1576 inline bool Field(T& value, StyleRef style, NumericFieldConfig<ComponentT> config, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return Field<T>(idManager.AllocateDynamicID(site), value, TextEditBehavior::ContinuousUpdate, style, config, std::move(constraints)); }
1578 template<typename T, typename ComponentT = typename TypeDimensions<T>::ComponentType>
1579 inline bool Field( T& value, TextEditBehavior textEditBehavior, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return Field<T>(idManager.AllocateDynamicID(site), value, textEditBehavior, style, {}, std::move(constraints)); }
1581 template<typename T, typename ComponentT = typename TypeDimensions<T>::ComponentType>
1582 inline bool Field( T& value, TextEditBehavior textEditBehavior, NumericFieldConfig<ComponentT> config, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return Field<T>(idManager.AllocateDynamicID(site), value, textEditBehavior, theme.controls->number, config, std::move(constraints)); }
1584 template<typename T, typename ComponentT = typename TypeDimensions<T>::ComponentType>
1585 inline bool Field(T& value, NumericFieldConfig<ComponentT> config, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return Field<T>(idManager.AllocateDynamicID(site), value, TextEditBehavior::ContinuousUpdate, theme.controls->number, config, std::move(constraints)); }
1587 template<typename T, typename ComponentT = typename TypeDimensions<T>::ComponentType>
1588 inline bool Field( T& value, TextEditBehavior textEditBehavior, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return Field<T>(idManager.AllocateDynamicID(site), value, textEditBehavior, theme.controls->number, {}, std::move(constraints)); }
1591 template<typename T, typename ComponentT = typename TypeDimensions<T>::ComponentType>
1592 inline bool Field( T& value, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return Field<T>(idManager.AllocateDynamicID(site), value, TextEditBehavior::ContinuousUpdate, theme.controls->number, {}, std::move(constraints)); }
1593
1594
1596 template<typename T>
1597 static constexpr std::string_view TypeTag()
1598 {
1599 if constexpr (std::is_same_v<T, float>) return "f32";
1600 else if constexpr (std::is_same_v<T, double>) return "f64";
1601 else if constexpr (std::is_same_v<T, int8_t>) return "i8";
1602 else if constexpr (std::is_same_v<T, int16_t>) return "i16";
1603 else if constexpr (std::is_same_v<T, int32_t>) return "i32";
1604 else if constexpr (std::is_same_v<T, int64_t>) return "i64";
1605 else if constexpr (std::is_same_v<T, uint8_t>) return "u8";
1606 else if constexpr (std::is_same_v<T, uint16_t>) return "u16";
1607 else if constexpr (std::is_same_v<T, uint32_t>) return "u32";
1608 else if constexpr (std::is_same_v<T, uint64_t>) return "u64";
1609 else if constexpr (std::is_same_v<T, std::string>) return "string";
1610 else return {};
1611 }
1612
1614 template<typename T>
1615 bool TypedField(ID id, T& value, LayoutOverride&& constraints = {}) { return TypedField(id, value, theme.typedFieldStyleRef, std::move(constraints)); }
1617 template<typename T>
1618 bool TypedField(ID id, T& value, StyleRef style, LayoutOverride&& constraints = {})
1619 {
1620 // The box's and the type's IDs under the field's own, so they don't depend on what came before.
1621 [[maybe_unused]] const bool pushed = idManager.PushParent(id);
1622 const ID boxID = idManager.AllocateDynamicID("typed_field");
1623 const ID typeID = idManager.AllocateDynamicID("typed_field_type");
1624 if (pushed) (void)idManager.PopParent();
1625 BeginFieldBox(boxID, style, std::move(constraints));
1626 const bool changed = Field(id, value, TextEditBehavior::ContinuousUpdate, theme.typedFieldInputStyleRef, {},
1629 EndFieldBox();
1630 return changed;
1631 }
1632
1633 template<typename T>
1634 bool TypedField(T& value, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return TypedField(idManager.AllocateDynamicID(site), value, std::move(constraints)); }
1636 template<typename T>
1637 bool TypedField(T& value, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return TypedField(idManager.AllocateDynamicID(site), value, style, std::move(constraints)); }
1638
1642 template<typename T>
1643 void Field(ID id, std::vector<T>& items, StyleRef style, LayoutOverride&& constraints = {})
1644 {
1645 if (BeginArea(id, style, std::move(constraints)))
1646 {
1647 // Everything inside under the list's own ID.
1648 [[maybe_unused]] const bool pushed = idManager.PushParent(id);
1649 auto onReorder = [&items](int from, int to)
1650 {
1651 if (from < 0 || from >= (int)items.size()) return;
1652 if (to < 0 || to >= (int)items.size()) return;
1653 T moved = std::move(items[from]);
1654 items.erase(items.begin() + from);
1655 items.insert(items.begin() + to, std::move(moved));
1656 };
1657
1658 if (BeginReorderableGroup(idManager.AllocateDynamicID("list_rows"), ReorderDirection::Vertical, std::move(onReorder),
1660 {
1661 for (int i = 0; i < (int)items.size(); i++)
1662 {
1663 BeginReorderableItem(idManager.AllocateDynamicID("list_row"), theme.collectionRowStyleRef,
1665 {
1667 Text(idManager.AllocateDynamicID("list_index"), std::to_string(i), theme.collectionIndexStyleRef);
1668 if constexpr (std::is_arithmetic_v<T>)
1670 else
1671 Field(items[i], tachyon::LayoutOverride{}.FlexGrow(1));
1672 Button(theme.tabCloseIcon, [&items, i]() { items.erase(items.begin() + i); },
1673 theme.collectionRemoveStyleRef, tachyon::LayoutOverride{}.NoGrow());
1674 }
1676 }
1678 }
1679 Button(idManager.AllocateDynamicID("list_add"), "+ Add item", [&items]() { items.push_back({}); },
1681 if (pushed) (void)idManager.PopParent();
1682 EndArea();
1683 }
1684 }
1685
1686 template<typename T>
1687 void Field(ID id, std::vector<T>& items, LayoutOverride&& constraints = {}) { Field(id, items, theme.collectionAreaStyleRef, std::move(constraints)); }
1689 template<typename T>
1690 void Field(std::vector<T>& items, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { Field(idManager.AllocateDynamicID(site), items, style, std::move(constraints)); }
1692 template<typename T>
1693 void Field(std::vector<T>& items, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { Field(idManager.AllocateDynamicID(site), items, theme.collectionAreaStyleRef, std::move(constraints)); }
1694
1697 template<typename V>
1698 void Field(ID id, std::vector<std::pair<std::string, V>>& items, StyleRef style, LayoutOverride&& constraints = {})
1699 {
1700 if (BeginArea(id, style, std::move(constraints)))
1701 {
1702 // Everything inside under the dictionary's own ID.
1703 [[maybe_unused]] const bool pushed = idManager.PushParent(id);
1704 CollectionHeader(TypeTag<V>());
1705 for (int i = 0; i < (int)items.size(); i++)
1706 {
1707 BeginHorizontal(idManager.AllocateDynamicID("dictionary_row"), theme.collectionEntryStyleRef, tachyon::LayoutOverride{}.NoShrink());
1708 Field(items[i].first, tachyon::LayoutOverride{}.FlexGrow(1));
1710 Button(theme.tabCloseIcon, [&items, i]() { items.erase(items.begin() + i); },
1712 EndHorizontal();
1713 }
1714 Button(idManager.AllocateDynamicID("dictionary_add"), "+ Add entry",
1715 [&items]() { items.push_back({ std::string{}, V{} }); }, theme.collectionAddEntryStyleRef);
1716 if (pushed) (void)idManager.PopParent();
1717 EndArea();
1718 }
1719 }
1720
1721 template<typename V>
1722 void Field(ID id, std::vector<std::pair<std::string, V>>& items, LayoutOverride&& constraints = {}) { Field(id, items, theme.collectionAreaStyleRef, std::move(constraints)); }
1724 template<typename V>
1725 void Field(std::vector<std::pair<std::string, V>>& items, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { Field(idManager.AllocateDynamicID(site), items, style, std::move(constraints)); }
1727 template<typename V>
1728 void Field(std::vector<std::pair<std::string, V>>& items, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { Field(idManager.AllocateDynamicID(site), items, theme.collectionAreaStyleRef, std::move(constraints)); }
1729
1732 template<typename V>
1733 void Field(ID id, std::unordered_map<std::string, V>& items, StyleRef style, LayoutOverride&& constraints = {})
1734 {
1735 if (BeginArea(id, style, std::move(constraints)))
1736 {
1737 // Everything inside under the dictionary's own ID.
1738 [[maybe_unused]] const bool pushed = idManager.PushParent(id);
1739 CollectionHeader(TypeTag<V>());
1740 // Map keys are const: edit a copy, committed on Enter/blur, and re-key
1741 // after the loop (renaming onto an existing key is ignored).
1742 std::string renameFrom, renameTo;
1743 bool rename = false;
1744 for (auto& pair : items)
1745 {
1746 BeginHorizontal(idManager.AllocateDynamicID("dictionary_row"), theme.collectionEntryStyleRef, tachyon::LayoutOverride{}.NoShrink());
1747 std::string key = pair.first;
1748 if (Field(key, TextEditBehavior::None, tachyon::LayoutOverride{}.FlexGrow(1)) && key != pair.first)
1749 {
1750 renameFrom = pair.first;
1751 renameTo = key;
1752 rename = true;
1753 }
1754 Field(pair.second, TextEditBehavior::ContinuousUpdate, theme.collectionValueStyleRef, tachyon::LayoutOverride{}.FlexGrow(1));
1755 Button(theme.tabCloseIcon, [&items, k = pair.first]() { items.erase(k); },
1757 EndHorizontal();
1758 }
1759 if (rename && !items.contains(renameTo))
1760 {
1761 auto node = items.extract(renameFrom);
1762 node.key() = renameTo;
1763 items.insert(std::move(node));
1764 }
1765 Button(idManager.AllocateDynamicID("dictionary_add"), "+ Add entry",
1766 [&items]() { items.emplace(std::string{}, V{}); }, theme.collectionAddEntryStyleRef);
1767 if (pushed) (void)idManager.PopParent();
1768 EndArea();
1769 }
1770 }
1771
1772 template<typename V>
1773 void Field(ID id, std::unordered_map<std::string, V>& items, LayoutOverride&& constraints = {}) { Field(id, items, theme.collectionAreaStyleRef, std::move(constraints)); }
1775 template<typename V>
1776 void Field(std::unordered_map<std::string, V>& items, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { Field(idManager.AllocateDynamicID(site), items, style, std::move(constraints)); }
1778 template<typename V>
1779 void Field(std::unordered_map<std::string, V>& items, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { Field(idManager.AllocateDynamicID(site), items, theme.collectionAreaStyleRef, std::move(constraints)); }
1780
1782 void CollectionHeader(std::string_view valueType);
1783
1785
1786
1789
1790 // ---- ColorField: swatch + color picker popup ----
1793 bool ColorField(ID id, tachyon::color4f& value, bool allowHDR, StyleRef style, LayoutOverride&& constraints = {});
1795 inline bool ColorField(ID id, tachyon::color4f& value, bool allowHDR = false, LayoutOverride&& constraints = {}) { return ColorField(id, value, allowHDR, theme.colorFieldStyleRef, std::move(constraints)); }
1797 inline bool ColorField( tachyon::color4f& value, bool allowHDR, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return ColorField(idManager.AllocateDynamicID(site), value, allowHDR, style, std::move(constraints)); }
1799 inline bool ColorField( tachyon::color4f& value, bool allowHDR = false, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return ColorField(idManager.AllocateDynamicID(site), value, allowHDR, theme.colorFieldStyleRef, std::move(constraints)); }
1801 bool ColorField(ID id, tachyon::color4b& value, StyleRef style, LayoutOverride&& constraints = {});
1803 inline bool ColorField(ID id, tachyon::color4b& value, LayoutOverride&& constraints = {}) { return ColorField(id, value, theme.colorFieldStyleRef, std::move(constraints)); }
1805 inline bool ColorField( tachyon::color4b& value, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return ColorField(idManager.AllocateDynamicID(site), value, style, std::move(constraints)); }
1807 inline bool ColorField( tachyon::color4b& value, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return ColorField(idManager.AllocateDynamicID(site), value, theme.colorFieldStyleRef, std::move(constraints)); }
1808
1809 // ---- GradientField: gradient swatch + editor popup ----
1811 bool GradientField(ID id, tachyon::Gradient& value, StyleRef style, LayoutOverride&& constraints = {});
1813 inline bool GradientField(ID id, tachyon::Gradient& value, LayoutOverride&& constraints = {}) { return GradientField(id, value, theme.gradientSwatchStyleRef, std::move(constraints)); }
1815 inline bool GradientField( tachyon::Gradient& value, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return GradientField(idManager.AllocateDynamicID(site), value, style, std::move(constraints)); }
1817 inline bool GradientField( tachyon::Gradient& value, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return GradientField(idManager.AllocateDynamicID(site), value, theme.gradientSwatchStyleRef, std::move(constraints)); }
1818
1820
1823
1824 // ---- SliderField: DragLabel + horizontal slider track + numeric textbox ----
1827 bool SliderField(ID id, float& value, float minVal, float maxVal,
1828 std::string_view text, StyleRef style, LayoutOverride&& constraints = {});
1830 inline bool SliderField(ID id, float& value, float minVal, float maxVal,
1831 std::string_view text, LayoutOverride&& constraints = {}) { return SliderField(id, value, minVal, maxVal, text, theme.sliderFieldTrackStyleRef, std::move(constraints)); }
1832
1833 inline bool SliderField(float& value, float minVal, float maxVal,
1834 std::string_view text, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return SliderField(idManager.AllocateDynamicID(site), value, minVal, maxVal, text, style, std::move(constraints)); }
1835
1836 inline bool SliderField(float& value, float minVal, float maxVal,
1837 std::string_view text, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return SliderField(idManager.AllocateDynamicID(site), value, minVal, maxVal, text, theme.sliderFieldTrackStyleRef, std::move(constraints)); }
1838
1840 bool SliderField(ID id, int& value, int minVal, int maxVal,
1841 std::string_view text, StyleRef style, LayoutOverride&& constraints = {});
1843 inline bool SliderField(ID id, int& value, int minVal, int maxVal,
1844 std::string_view text, LayoutOverride&& constraints = {}) { return SliderField(id, value, minVal, maxVal, text, theme.sliderFieldTrackStyleRef, std::move(constraints)); }
1845
1846 inline bool SliderField(int& value, int minVal, int maxVal,
1847 std::string_view text, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return SliderField(idManager.AllocateDynamicID(site), value, minVal, maxVal, text, style, std::move(constraints)); }
1848
1849 inline bool SliderField(int& value, int minVal, int maxVal,
1850 std::string_view text, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return SliderField(idManager.AllocateDynamicID(site), value, minVal, maxVal, text, theme.sliderFieldTrackStyleRef, std::move(constraints)); }
1851
1853 bool Slider(ID id, int& value, int minVal, int maxVal, StyleRef style, LayoutOverride&& constraints = {});
1855 inline bool Slider(ID id, int& value, int minVal, int maxVal, LayoutOverride&& constraints = {}) { return Slider(id, value, minVal, maxVal, theme.sliderStyleRef, std::move(constraints)); }
1857 inline bool Slider(int& value, int minVal, int maxVal, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return Slider(idManager.AllocateDynamicID(site), value, minVal, maxVal, style, std::move(constraints)); }
1859 inline bool Slider(int& value, int minVal, int maxVal, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return Slider(idManager.AllocateDynamicID(site), value, minVal, maxVal, theme.sliderStyleRef, std::move(constraints)); }
1860
1861
1862
1864
1867
1870 void DragLabel(ID id, std::string_view text, StyleRef style, LayoutOverride&& constraints = {});
1872 inline void DragLabel(ID id, std::string_view text, LayoutOverride&& constraints = {}) { DragLabel(id, text, theme.dragLabelStyleRef, std::move(constraints)); }
1874 inline void DragLabel( std::string_view text, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { DragLabel(idManager.AllocateDynamicID(site), text, style, std::move(constraints)); }
1876 inline void DragLabel( std::string_view text, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { DragLabel(idManager.AllocateDynamicID(site), text, theme.dragLabelStyleRef, std::move(constraints)); }
1877
1880 void Label(ID id, std::string_view text, StyleRef style, LayoutOverride&& constraints = {});
1883 void Label(ID id, std::string_view text, std::string_view caption, StyleRef style, LayoutOverride&& constraints = {});
1885 inline void Label(ID id, std::string_view text, std::string_view caption, LayoutOverride&& constraints = {}) { Label(id, text, caption, theme.groupLabelTopStyleRef, std::move(constraints)); }
1887 inline void Label( std::string_view text, std::string_view caption, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { Label(idManager.AllocateDynamicID(site), text, caption, style, std::move(constraints)); }
1889 inline void Label( std::string_view text, std::string_view caption, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { Label(idManager.AllocateDynamicID(site), text, caption, theme.groupLabelTopStyleRef, std::move(constraints)); }
1891 inline void Label(ID id, std::string_view text, LayoutOverride&& constraints = {}) { Label(id, text, theme.labelStyleRef, std::move(constraints)); }
1893 inline void Label( std::string_view text, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { Label(idManager.AllocateDynamicID(site), text, style, std::move(constraints)); }
1895 inline void Label( std::string_view text, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { Label(idManager.AllocateDynamicID(site), text, theme.labelStyleRef, std::move(constraints)); }
1896
1898 void Text(ID id, std::string_view text, StyleRef style, LayoutOverride&& constraints = {});
1900 inline void Text(ID id, std::string_view text, LayoutOverride&& constraints = {}) { Text(id, text, theme.staticTextStyleRef, std::move(constraints)); }
1902 inline void Text( std::string_view text, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { Text(idManager.AllocateDynamicID(site), text, style, std::move(constraints)); }
1904 inline void Text( std::string_view text, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { Text(idManager.AllocateDynamicID(site), text, theme.staticTextStyleRef, std::move(constraints)); }
1905
1908 void SelectableText(ID id, const std::span<ContentRun>& runs,
1909 std::function<void(intptr_t contentId)> onLinkActivate,
1910 StyleRef style, LayoutOverride&& constraints = {});
1912 inline void SelectableText(ID id, const std::span<ContentRun>& runs, StyleRef style, LayoutOverride&& constraints = {})
1913 { SelectableText(id, runs, {}, style, std::move(constraints)); }
1914
1915 inline void SelectableText(ID id, const std::span<ContentRun>& runs, LayoutOverride&& constraints = {})
1916 { SelectableText(id, runs, {}, theme.staticTextStyleRef, std::move(constraints)); }
1917
1918 inline void SelectableText(const std::span<ContentRun>& runs, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current())
1919 { SelectableText(idManager.AllocateDynamicID(site), runs, {}, style, std::move(constraints)); }
1920
1921 inline void SelectableText(const std::span<ContentRun>& runs, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current())
1922 { SelectableText(idManager.AllocateDynamicID(site), runs, {}, theme.staticTextStyleRef, std::move(constraints)); }
1923
1925 void Image(ID id, ImageIndex image, StyleRef style, LayoutOverride&& constraints = {});
1927 inline void Image(ID id, ImageIndex image, LayoutOverride&& constraints = {}) { Image(id, image, theme.imageStyleRef, std::move(constraints)); }
1929 inline void Image( ImageIndex image, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { Image(idManager.AllocateDynamicID(site), image, style, std::move(constraints)); }
1931 inline void Image( ImageIndex image, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { Image(idManager.AllocateDynamicID(site), image, theme.imageStyleRef, std::move(constraints)); }
1932
1935 void Image(ID id, ImageIndex image, uint2 sourceSize, StyleRef style, LayoutOverride&& constraints = {});
1937 inline void Image(ID id, ImageIndex image, uint2 sourceSize, LayoutOverride&& constraints = {}) { Image(id, image, sourceSize, theme.imageStyleRef, std::move(constraints)); }
1939 inline void Image( ImageIndex image, uint2 sourceSize, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { Image(idManager.AllocateDynamicID(site), image, sourceSize, style, std::move(constraints)); }
1941 inline void Image( ImageIndex image, uint2 sourceSize, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { Image(idManager.AllocateDynamicID(site), image, sourceSize, theme.imageStyleRef, std::move(constraints)); }
1942
1944
1947
1950 bool BeginGhostWindow(ID windowLayoutID, int2 position)
1951 {
1952 return BeginGhostWindow(windowLayoutID, position, int2{ styleManager.Px(28), styleManager.Px(28) });
1953 }
1954
1956 bool BeginGhostWindow(ID windowLayoutID, int2 position, int2 size, StyleRef styleRef)
1957 {
1958 if (windowManager->GetWindowState(windowLayoutID) == WindowState::Closing)
1959 {
1960 m_windowOpen.push_back(false); // its EndGhostWindow is still called
1961 return false;
1962 }
1963
1964 LayoutOverride constraints = LayoutOverride::FixedSize(size).Position(position.x, position.y);
1965
1967 return BeginWindow(windowLayoutID, styleRef, std::move(constraints), elementFlags);
1968 }
1969
1971 bool BeginGhostWindow(ID windowLayoutID, int2 position, int2 size)
1972 {
1973 return BeginGhostWindow(windowLayoutID, position, size, theme.ghostWindowStyleRef);
1974 }
1975
1977 bool BeginGhostWindow(ID windowLayoutID, int2 position, StyleRef styleRef)
1978 {
1979 if (windowManager->GetWindowState(windowLayoutID) == WindowState::Closing)
1980 {
1981 m_windowOpen.push_back(false); // its EndGhostWindow is still called
1982 return false;
1983 }
1984 LayoutOverride constraints = LayoutOverride{}.Position(position.x, position.y);
1986 return BeginWindow(windowLayoutID, styleRef, std::move(constraints), elementFlags);
1987 }
1988
1992 {
1993 const int32_t o = m_cursorSize > 0 ? (m_cursorSize * 14 + 16) / 32 : styleManager.Px(14);
1994 return int2{ o, o };
1995 }
1996
1997 bool BeginCursorGhostWindow(ID windowLayoutID, int2 cursorPos)
1998 {
1999 return BeginGhostWindow(windowLayoutID, cursorPos + CursorGhostOffset());
2000 }
2001
2002 bool BeginCursorGhostWindow(ID windowLayoutID, int2 cursorPos, int2 size, StyleRef styleRef)
2003 {
2004 return BeginGhostWindow(windowLayoutID, cursorPos + CursorGhostOffset(), size, styleRef);
2005 }
2006
2007 bool BeginCursorGhostWindow(ID windowLayoutID, int2 cursorPos, int2 size)
2008 {
2009 return BeginGhostWindow(windowLayoutID, cursorPos + CursorGhostOffset(), size);
2010 }
2011
2012 bool BeginCursorGhostWindow(ID windowLayoutID, int2 cursorPos, StyleRef styleRef)
2013 {
2014 return BeginGhostWindow(windowLayoutID, cursorPos + CursorGhostOffset(), styleRef);
2015 }
2016
2018 void AddGhostIcon(IconID icon, std::source_location site = std::source_location::current())
2019 {
2020 auto dragGhostIconID = idManager.AllocateDynamicID(site);
2021 tachyon::Element ghostIcon
2022 {
2023 .id = dragGhostIconID,
2024 .textID = TextID::Invalid,
2025 .iconID = icon,
2026 .styleRef = theme.ghostIconStyleRef,
2027 };
2028
2029 auto ghostIconRes = elementStorage.Add(std::move(ghostIcon),
2031 VERIFY(ghostIconRes.status);
2032 VERIFY(windowRegistry.Add(ghostIconRes.ref));
2033 }
2034
2037 {
2038 EndWindow();
2039 }
2040
2042
2045
2047 bool BeginWindow(ID windowLayoutID, std::string_view title, ElementFlags flags = ElementFlags::WindowUserControlled | ElementFlags::WindowIsCentered, int monitorIndex = -1)
2048 {
2049 return BeginWindow(windowLayoutID, title, theme.windowStyleRef, LayoutOverride{}, flags, monitorIndex);
2050 }
2051
2053 bool BeginWindow(ID windowLayoutID, std::string_view title, StyleRef styleRef, ElementFlags flags = ElementFlags::WindowUserControlled | ElementFlags::WindowIsCentered, int monitorIndex = -1)
2054 {
2055 return BeginWindow(windowLayoutID, title, styleRef, LayoutOverride{}, flags, monitorIndex);
2056 }
2057
2059 bool BeginWindow(ID windowLayoutID, std::string_view title, LayoutOverride&& constraints, ElementFlags flags = ElementFlags::WindowUserControlled | ElementFlags::WindowIsCentered, int monitorIndex = -1)
2060 {
2061 return BeginWindow(windowLayoutID, title, theme.windowStyleRef, std::move(constraints), flags, monitorIndex);
2062 }
2063
2064
2067 {
2068 return BeginWindow(windowLayoutID, theme.windowStyleRef, LayoutOverride{}, flags, monitorIndex);
2069 }
2070
2072 bool BeginWindow(ID windowLayoutID, StyleRef styleRef, ElementFlags flags = ElementFlags::WindowUserControlled | ElementFlags::WindowIsCentered, int monitorIndex = -1)
2073 {
2074 return BeginWindow(windowLayoutID, styleRef, LayoutOverride{}, flags, monitorIndex);
2075 }
2076
2078 bool BeginWindow(ID windowLayoutID, LayoutOverride&& constraints, ElementFlags flags = ElementFlags::WindowUserControlled | ElementFlags::WindowIsCentered, int monitorIndex = -1)
2079 {
2080 return BeginWindow(windowLayoutID, theme.windowStyleRef, std::move(constraints), flags, monitorIndex);
2081 }
2082
2084 bool BeginWindow(ID windowLayoutID, StyleRef styleRef, LayoutOverride&& constraints, ElementFlags flags = ElementFlags::WindowUserControlled | ElementFlags::WindowIsCentered, int monitorIndex = -1)
2085 {
2086 return BeginWindow(windowLayoutID, "", styleRef, std::move(constraints), flags, monitorIndex);
2087 }
2088
2089
2094 bool BeginWindow(ID windowLayoutID, std::string_view title, StyleRef styleRef, LayoutOverride&& constraints, ElementFlags flags = ElementFlags::WindowUserControlled | ElementFlags::WindowIsCentered, int monitorIndex = -1)
2095 {
2096 const bool open = OpenWindow(windowLayoutID, title, styleRef, std::move(constraints), flags, monitorIndex);
2097 m_windowOpen.push_back(open);
2098 return open;
2099 }
2100
2102 bool OpenWindow(ID windowLayoutID, std::string_view title, StyleRef styleRef, LayoutOverride&& constraints, ElementFlags flags, int monitorIndex)
2103 {
2104 if (windowLayoutID == ID::Invalid())
2105 {
2106 ReportMisuse("GUIApplication: BeginWindow with an invalid ID (not shown)");
2107 return false;
2108 }
2109
2110 // Closed by the user since last frame.
2111 if (windowManager->GetWindowState(windowLayoutID) == WindowState::Closing
2112 || windowManager->WasUserClosed(windowLayoutID))
2113 {
2114 return false;
2115 }
2116 if (!m_restoredWindows.empty())
2117 ApplyRestoredWindow(windowLayoutID, constraints, flags);
2118
2119 if (monitorIndex == -1)
2120 {
2121 if (constraints.x.type == PositionType::Fixed &&
2122 constraints.y.type == PositionType::Fixed)
2123 {
2124 monitorIndex = windowManager->GetMonitorIndexAt(tachyon::int2{ .x = constraints.x.near, .y = constraints.y.near });
2125 } else
2126 monitorIndex = windowManager->GetPrimaryMonitorIndex();
2127 }
2128
2129 Element windowElement
2130 {
2131 .id = windowLayoutID,
2132 .textID = (title.size() == 0) ? TextID::Invalid : textSystem->RegisterText(windowLayoutID, title, styleRef, tachyon::ElementState::None),
2133 .styleRef = styleRef,
2134 .monitorIndex = (int16_t)monitorIndex,
2135 .flags = ElementFlags::IsWindow | flags
2136 };
2137
2138 auto addResult = elementStorage.Add(std::move(windowElement),
2139 std::move(constraints));
2140 VERIFY(addResult.status);
2141 windowRegistry.BeginWindowScope(windowLayoutID, addResult.ref);
2143
2144 tabChainManager.BeginWindow(windowLayoutID);
2145 [[maybe_unused]] bool pushed = idManager.PushParent(windowLayoutID);
2146 assert(pushed); // windows are top-level, so this can't fail
2147
2148 m_windowIdScopeStack.push_back(pushed);
2149 activeWindowID = windowLayoutID;
2150 return true;
2151 }
2152
2155 {
2156 if (m_windowOpen.empty())
2157 {
2158 ReportMisuse("GUIApplication: EndWindow without BeginWindow (ignored)");
2159 return;
2160 }
2161 const bool open = m_windowOpen.back();
2162 m_windowOpen.pop_back();
2163 if (open)
2164 CloseWindow();
2165 }
2166
2168
2173 template<void (GUIApplication::*EndFn)()>
2174 class [[nodiscard]] Scope
2175 {
2176 public:
2178 Scope(GUIApplication& app, bool open) : m_app(&app), m_open(open) {}
2179 Scope(Scope&& other) noexcept : m_app(std::exchange(other.m_app, nullptr)), m_open(other.m_open) {}
2180 Scope(const Scope&) = delete;
2181 Scope& operator=(const Scope&) = delete;
2182 Scope& operator=(Scope&&) = delete;
2183 ~Scope() { End(); }
2184
2186 void End()
2187 {
2188 if (GUIApplication* app = std::exchange(m_app, nullptr))
2189 (app->*EndFn)();
2190 }
2191 explicit operator bool() const { return m_open; }
2192
2193 private:
2194 GUIApplication* m_app;
2195 bool m_open;
2196 };
2197
2201 template<class... A> auto Window(A&&... a) { return Scope<&GUIApplication::EndWindow>(*this, BeginWindow(std::forward<A>(a)...)); }
2202 template<class... A> auto GhostWindow(A&&... a) { return Scope<&GUIApplication::EndGhostWindow>(*this, BeginGhostWindow(std::forward<A>(a)...)); }
2203 template<class... A> auto CursorGhostWindow(A&&... a){ return Scope<&GUIApplication::EndGhostWindow>(*this, BeginCursorGhostWindow(std::forward<A>(a)...)); }
2204 template<class... A> auto Menu(A&&... a) { return Scope<&GUIApplication::EndMenu>(*this, BeginMenu(std::forward<A>(a)...)); }
2205 template<class... A> auto MenuBar(A&&... a) { return Scope<&GUIApplication::EndMenuBar>(*this, BeginMenuBar(std::forward<A>(a)...)); }
2206 template<class... A> auto ContextMenu(A&&... a) { return Scope<&GUIApplication::EndContextMenu>(*this, BeginContextMenu(std::forward<A>(a)...)); }
2207 template<class... A> auto Tooltip(A&&... a) { return Scope<&GUIApplication::EndTooltip>(*this, BeginTooltip(std::forward<A>(a)...)); }
2208 template<class... A> auto Cached(A&&... a) { return Scope<&GUIApplication::EndCached>(*this, BeginCached(std::forward<A>(a)...)); }
2209 template<class... A> auto Horizontal(A&&... a) { return Scope<&GUIApplication::EndHorizontal>(*this, BeginHorizontal(std::forward<A>(a)...)); }
2210 template<class... A> auto Vertical(A&&... a) { return Scope<&GUIApplication::EndVertical>(*this, BeginVertical(std::forward<A>(a)...)); }
2211 template<class... A> auto HorizontalWrap(A&&... a) { return Scope<&GUIApplication::EndHorizontalWrap>(*this, BeginHorizontalWrap(std::forward<A>(a)...)); }
2212 template<class... A> auto VerticalWrap(A&&... a) { return Scope<&GUIApplication::EndVerticalWrap>(*this, BeginVerticalWrap(std::forward<A>(a)...)); }
2213 template<class... A> auto Area(A&&... a) { return Scope<&GUIApplication::EndArea>(*this, BeginArea(std::forward<A>(a)...)); }
2214 template<class... A> auto LabelGroup(A&&... a) { return Scope<&GUIApplication::EndLabelGroup>(*this, BeginLabelGroup(std::forward<A>(a)...)); }
2215 template<class... A> auto ButtonGroup(A&&... a) { return Scope<&GUIApplication::EndButtonGroup>(*this, BeginButtonGroup(std::forward<A>(a)...)); }
2216 template<class... A> auto ToggleGroup(A&&... a) { return Scope<&GUIApplication::EndToggleGroup>(*this, BeginToggleGroup(std::forward<A>(a)...)); }
2217 template<class... A> auto Table(A&&... a) { return Scope<&GUIApplication::EndTable>(*this, BeginTable(std::forward<A>(a)...)); }
2218 template<class... A> auto Row(A&&... a) { return Scope<&GUIApplication::EndRow>(*this, BeginRow(std::forward<A>(a)...)); }
2219 template<class... A> auto ListView(A&&... a) { return Scope<&GUIApplication::EndListView>(*this, BeginListView(std::forward<A>(a)...)); }
2220 template<class... A> auto GridView(A&&... a) { return Scope<&GUIApplication::EndGridView>(*this, BeginGridView(std::forward<A>(a)...)); }
2221 template<class... A> auto TabBar(A&&... a) { return Scope<&GUIApplication::EndTabBar>(*this, BeginTabBar(std::forward<A>(a)...)); }
2222 template<class... A> auto Toolbar(A&&... a) { return Scope<&GUIApplication::EndToolbar>(*this, BeginToolbar(std::forward<A>(a)...)); }
2223 template<class... A> auto StatusBar(A&&... a) { return Scope<&GUIApplication::EndStatusBar>(*this, BeginStatusBar(std::forward<A>(a)...)); }
2224 template<class... A> auto TitleBar(A&&... a) { return Scope<&GUIApplication::EndTitleBar>(*this, BeginTitleBar(std::forward<A>(a)...)); }
2225 template<class... A> auto ReorderableGroup(A&&... a) { return Scope<&GUIApplication::EndReorderableGroup>(*this, BeginReorderableGroup(std::forward<A>(a)...)); }
2226 template<class... A> auto ReorderableItem(A&&... a) { return Scope<&GUIApplication::EndReorderableItem>(*this, BeginReorderableItem(std::forward<A>(a)...)); }
2227 template<class... A> auto Disabled(A&&... a) { return Scope<&GUIApplication::EndDisabled>(*this, BeginDisabled(std::forward<A>(a)...)); }
2228 template<class... A> auto Invalid(A&&... a) { return Scope<&GUIApplication::EndInvalid>(*this, BeginInvalid(std::forward<A>(a)...)); }
2229 template<class... A> auto Selected(A&&... a) { return Scope<&GUIApplication::EndSelected>(*this, BeginSelected(std::forward<A>(a)...)); }
2230 template<class... A> auto Indeterminate(A&&... a) { return Scope<&GUIApplication::EndIndeterminate>(*this, BeginIndeterminate(std::forward<A>(a)...)); }
2231 template<class... A> auto DockingContainer(A&&... a) { return Scope<&GUIApplication::EndDockingContainer>(*this, BeginDockingContainer(std::forward<A>(a)...)); }
2232 template<class... A> auto DockingFrame(A&&... a) { return Scope<&GUIApplication::EndDockingFrame>(*this, BeginDockingFrame(std::forward<A>(a)...)); }
2234
2237
2240 {
2242 if (!m_windowIdScopeStack.empty() && m_windowIdScopeStack.back())
2243 (void)idManager.PopParent();
2244 if (!m_windowIdScopeStack.empty())
2245 m_windowIdScopeStack.pop_back();
2248 activeWindowID = ID::Invalid();
2250 }
2251
2253 void AddBox(ID id, int2 size, StyleRef styleRef, TextID textID = TextID::Invalid)
2254 {
2255 Element boxElement {};
2256 boxElement.id = id;
2257 boxElement.flags = ElementFlags::None;
2258 boxElement.styleRef = styleRef;
2259 boxElement.textID = textID;
2260 boxElement.state = guiStateManager.GetCurrentState(id);
2261
2262 auto childB1 = elementStorage.Add(std::move(boxElement), LayoutOverride::FixedSize(size));
2263 VERIFY(childB1.status);
2264 VERIFY(windowRegistry.Add(childB1.ref));
2265 }
2266
2268 void AddBox(int2 size, StyleRef styleRef, TextID textID = TextID::Invalid, std::source_location site = std::source_location::current())
2269 {
2270 AddBox(idManager.AllocateDynamicID(site), size, styleRef, textID);
2271 }
2272
2274 void AddBox(ID id, int2 size, StyleRef styleRef, std::string_view text)
2275 {
2277 auto childB1 = elementStorage.Add(Element
2278 {
2279 .id = id,
2280 .textID = textSystem->RegisterText(id, text, styleRef, state),
2281 .styleRef = styleRef,
2282 .flags = ElementFlags::None,
2283 .state = state
2284 },
2286 VERIFY(childB1.status);
2287 VERIFY(windowRegistry.Add(childB1.ref));
2288 }
2289
2291 void AddBox(ID id, int2 size, StyleRef styleRef, IconID iconID, std::string_view text)
2292 {
2294 auto childB1 = elementStorage.Add(Element
2295 {
2296 .id = id,
2297 .textID = textSystem->RegisterText(id, iconID, text, styleRef, state),
2298 .styleRef = styleRef,
2299 .flags = ElementFlags::None,
2300 .state = state
2301 },
2303 VERIFY(childB1.status);
2304 VERIFY(windowRegistry.Add(childB1.ref));
2305 }
2306
2308 void AddBox(ID id, StyleRef styleRef, IconID iconID, std::string_view text)
2309 {
2311 auto childB1 = elementStorage.Add(Element
2312 {
2313 .id = id,
2314 .textID = textSystem->RegisterText(id, iconID, text, styleRef, state),
2315 .styleRef = styleRef,
2316 .flags = ElementFlags::None,
2317 .state = state
2318 });
2319 VERIFY(childB1.status);
2320 VERIFY(windowRegistry.Add(childB1.ref));
2321 }
2322
2324 void AddBox(StyleRef styleRef, std::string_view text, std::source_location site = std::source_location::current())
2325 {
2326 AddBox(idManager.AllocateDynamicID(site), styleRef, IconID::Invalid, text);
2327 }
2328
2330 void AddBox(int2 size, StyleRef styleRef, std::string_view text, std::source_location site = std::source_location::current())
2331 {
2332 AddBox(idManager.AllocateDynamicID(site), size, styleRef, text);
2333 }
2334
2336
2339
2340 // ------------------------------------------------------------------
2341 // Settings panel
2342 // ------------------------------------------------------------------
2343 // Two-pane settings panel: a page tree, a sizer, and the selected page's content.
2344 // Owns only selection and tree width; page state belongs to the application.
2347 {
2349 struct Page
2350 {
2354 std::string name;
2356 std::function<void()> render;
2357 };
2358
2360 std::vector<Page> pages;
2365
2368 {
2369 std::vector<TreeViewRow> rows;
2370 std::vector<int> visibleIdx;
2372 } internal;
2373
2375 tachyon::ID AddPage(tachyon::ID id, std::string_view name,
2376 std::function<void()> render)
2377 {
2378 pages.push_back({ id, std::string(name), std::move(render) });
2380 return id;
2381 }
2382 };
2383
2386
2388
2405
2407 void PersistWindow(std::string key, ID windowID);
2409 void PersistDocking(std::string key, DockingLayout& layout);
2411 void PersistTable(std::string key, TableState& state, std::span<VirtualTableColumn> columns);
2413 void PersistToolbars(std::string key, std::span<std::vector<ToolbarItem>, kToolbarSideCount> sides);
2415 void PersistValue(std::string key, bool& value);
2417 void PersistValue(std::string key, int& value);
2419 void PersistValue(std::string key, float& value);
2421 void PersistValue(std::string key, std::string& value);
2425 void PersistDocuments(std::string key, std::function<std::vector<DocumentWindowRef>()> windows);
2429 void PersistShortcuts(std::string key, CommandManager& commands);
2433 std::vector<SavedDocumentWindow> TakeSavedDocuments(std::string_view key);
2436 bool RestoreDocumentLayout(Document& document, const SavedDocument& saved);
2439 void RestoreWindowPlace(ID windowID, const SavedDocumentWindow& saved);
2441 std::string SaveUIState() const;
2444 Result<void> RestoreUIState(std::string_view json);
2445
2447
2448 private:
2452
2454 std::vector<ID> m_cacheRecordStack;
2455
2457 bool m_keyboardPending = false;
2458 bool m_tabPending = false;
2459 uint64_t m_inputFlagsFrame = 0;
2460 void RefreshCachedInputFlags();
2461
2463 void NoteSwatchClaim(ID swatchID);
2465 std::string PendingLabelText() const;
2467 struct ColorSwatchLook SwatchLook() const;
2468
2470 std::unordered_map<tachyon::ID, tachyon::ID> m_panelContentIDs;
2471
2473 std::vector<const ControlStyles*> controlStylesStack;
2474
2475 ID tooltipWindowID { ID::Invalid() };
2476 ID contextMenuWindowID { ID::Invalid() };
2477 ID contextMenuTargetID { ID::Invalid() };
2478 std::optional<int2> contextMenuScreenPos;
2479 bool m_contextMenuClaimed = false;
2480 ID tabDragGhostWindowID{ ID::Invalid() };
2481
2482 FrameTimingSample frameTimingHistory[kFrameHistoryCount] = {};
2483 int frameTimingHead = 0;
2484
2486 ColumnDragState m_columnDrag{};
2487 TreeDropState m_treeDropState{};
2488
2489 // ---- ListView ID->index map (shared by every list view; cleared once per frame) ----
2490 // Filled by ListItem when dragDrop is on; valid in end-of-frame handlers via FindListItemIndex().
2491 std::unordered_map<tachyon::ID, int> m_listItemIndexByID;
2492
2493
2496 TreeViewState m_treeState{};
2497 GridViewState m_gridViewState;
2498
2500 std::unordered_map<tachyon::ID, GridItemRenameInfo> m_gridItemRenameByID;
2501
2502
2504 std::optional<TableEmit> m_tableEmit;
2506 std::vector<std::optional<TableEmit>> m_outerTableEmits;
2507
2508 int CurrentCellCol() const
2509 {
2510 const int c = m_tableEmit->currentCol;
2511 assert(c < int(m_tableEmit->columnCount));
2512 return c;
2513 }
2514
2515 TabBarState m_tabBarState;
2516 TabState m_tabState;
2517
2519 void EnableVisiblePanels(DockingLayout& layout);
2520
2523 DockingConstructionState m_dockingState;
2524
2527 std::vector<DockingLayout*> m_dockingLayoutsThisFrame{};
2528
2530 std::vector<struct ToolbarDockState*> m_toolbarDocksThisFrame{};
2531
2533 void SyncDockingScrollOffsets();
2534
2536 void SyncToolbarDockRects();
2537
2539 tachyon::DockNode* FindDockLeafTabBarCachedAtScreenPos(tachyon::int2 screenPos);
2540
2541 std::vector<std::unique_ptr<FloatingDockWindow>> m_floatingDockWindows;
2542
2544 void EmitFloatingDockWindowsOf(const DocumentSet* documents);
2545
2548 std::vector<DocumentSet*> m_documentSetsThisFrame{};
2550 bool ActivateDocumentOf(const DockingLayout* layout);
2552 struct ShownToast
2553 {
2554 ToastID handle = 0;
2555 ToastDesc desc;
2556 ID id = ID::Invalid();
2557 float shownAt = 0.0f;
2558 float leftAt = -1.0f;
2559 float shownFor = 0.0f;
2560 };
2561 std::vector<ShownToast> m_toasts;
2562 ToastID m_nextToast = 0;
2563 float m_toastsTime = -1.0f;
2564 bool m_toastsExpanded = false;
2565 ID m_toastStackID = ID::Invalid();
2566 bool m_toastsBuilt = false;
2567
2568 DocumentDrag m_documentDrag;
2569 std::vector<IntRect> m_documentBarRects;
2570 std::optional<DocumentMove> m_documentMove;
2572 void ApplyDocumentMove();
2574 void SyncDocumentRects();
2576 DocumentSet* FindDocumentBarAt(tachyon::int2 screenPos);
2577
2579 void RegisterFrameHooks(); // per-frame stage hooks; Initialize (and test harnesses) call it
2580 void RegisterFrameBalanceChecks();
2582 static void ReportMisuse(const char* message);
2584 bool OpenMenu(ID menuID, std::string_view text, StyleRef buttonStyle, StyleRef menuStyle, StyleRef itemStyle, LayoutOverride&& constraints);
2585 void CloseMenu();
2588 enum class TooltipBox : uint8_t { Plain, Lines, Help, Error };
2589 bool OpenTooltip(ID targetID, TooltipBox box = TooltipBox::Plain);
2591 void ShowPinTooltip(const NodeView& view, ID socketID, PropertyEndpoint pin, bool isOutput);
2593 void CloseTooltip();
2595 struct CutShortText
2596 {
2597 ID id = ID::Invalid();
2598 ID windowID = ID::Invalid();
2599 int2 windowPos{};
2600 int2 at{};
2601 int32_t width = 0;
2602 int32_t height = 0;
2603 bool textOnly = false;
2604 int16_t monitorIndex = -1;
2605 };
2609 CutShortText FindCutShortText(int2 mousePos) const;
2612 void ShowCutShortText();
2613 CutShortText m_cutShort{};
2614 bool OpenContextMenuWindow(ID targetID);
2615 bool OpenCached(ID id, StyleRef style, uint64_t signature, LayoutOverride&& constraints);
2616 static void ReportInvalidControlID(ID id);
2618 void RegisterTabStop(ID id);
2620 bool SearchField(ID id, std::string& value, IconID icon, TextEditBehavior textEditBehavior, StyleRef style, LayoutOverride&& constraints, ID* outFieldID);
2623 void BeginFieldBox(ID id, StyleRef style, LayoutOverride&& constraints);
2624 void EndFieldBox();
2625
2628 void ApplyPendingStyleReload();
2629
2632 void UpdateMouseCursor(ID hoverID, ID hoverWindowID, int2 mousePosition);
2633
2634 void OnRender(float elapsedTimeSecs);
2637 void FireStateTransitions(float elapsedTimeSecs);
2640 struct TransitionsSeen
2641 {
2642 std::vector<ID> hover;
2643 std::vector<ID> focused;
2644 ID active = ID::Invalid();
2645 };
2646 TransitionsSeen m_transitionsSeen;
2648 void RenderBoxShadows(IntRect rectLayout, IntRect clipRectScreen, const TransitionState& ts, bool ring);
2650 void RenderShadowLayer(IntRect rectLayout, IntRect clipRectScreen, const VisualShadow& s, float radius);
2652 void RenderInvalidHalo(IntRect rectLayout, IntRect clipRectScreen, const TransitionState& ts, float grown);
2655 void RenderInvalidBorder(IntRect rectLayout, IntRect clipRectScreen, const TransitionState& ts, IntRect snappedPx);
2659 IntRect OpaqueInterior(IntRect rectLayout, const TransitionState& ts) const;
2660 void OnFrame();
2661 Result<void> RecoverDevice();
2662
2664 std::string m_resourceRoot;
2665 std::unique_ptr<IWindowBackend> m_osWindowBackend;
2666 ImageWindowBackend* m_imageWindows { nullptr };
2667 MouseButtons m_injectedButtons { MouseButtons::None };
2668 int2 InjectedScreenPos(ID windowID, int2 pos);
2669 AllocationHooks m_allocationHooks;
2670 std::unique_ptr<GraphicsContext> m_graphicsBackend;
2671 MouseButtons m_lastPhysicalButtons { MouseButtons::None };
2672 std::string ResourcePath(std::string_view path) const; // relative paths resolve against m_resourceRoot
2673 std::string m_themePath { "themes/dark.css" };
2674 bool m_initialized = false;
2675 bool m_inFrame = false;
2676 Result<void> m_themeReload {};
2677
2679 struct PersistedWindow { std::string key; ID target; };
2680 struct PersistedDock { std::string key; DockingLayout* target; };
2681 struct PersistedTable { struct Target { TableState* state; std::span<VirtualTableColumn> columns; }; std::string key; Target target; };
2682 struct PersistedToolbars { std::string key; std::span<std::vector<ToolbarItem>, kToolbarSideCount> target; };
2683 struct PersistedValue { using Target = std::variant<bool*, int*, float*, std::string*>; std::string key; Target target; };
2684 struct PersistedDocuments { std::string key; std::function<std::vector<DocumentWindowRef>()> target; };
2685 struct PersistedShortcuts { std::string key; CommandManager* target; };
2686 struct RestoredWindow
2687 {
2688 IntRect rect {};
2689 IntRect monitor {};
2690 WindowMode mode = WindowMode::Normal;
2691 bool hasMonitor = false;
2692 bool hasPosition = false;
2693 bool rectDone = false;
2694 };
2695 std::vector<PersistedWindow> m_persistWindows;
2696 std::vector<PersistedDock> m_persistDocks;
2697 std::vector<PersistedTable> m_persistTables;
2698 std::vector<PersistedToolbars> m_persistToolbars;
2699 std::vector<PersistedValue> m_persistValues;
2700 std::vector<PersistedDocuments> m_persistDocuments;
2701 std::vector<PersistedShortcuts> m_persistShortcuts;
2703 std::unordered_map<std::string, std::vector<SavedDocumentWindow>> m_savedDocuments;
2704 std::unordered_map<ID, RestoredWindow> m_restoredWindows;
2705 void ApplyRestoredWindow(ID windowID, LayoutOverride& constraints, ElementFlags& flags);
2707 void PlaceOnSavedMonitor(RestoredWindow& restored) const;
2708 int32_t m_cursorSize = 0;
2711 std::vector<bool> m_windowOpen, m_menuOpen, m_tooltipOpen, m_cachedOpen;
2714 std::vector<ConstructionScopes> m_tooltipScopes;
2716 std::string m_loadedThemePath;
2717 float m_loadedFontScale { 1.0f };
2718 std::vector<std::string> m_styleFiles { "styles.css" };
2719 float m_globalFontScale { 1.0f };
2720 float m_uiScale { 1.0f };
2721 std::optional<bool> m_reducedMotion;
2722
2725 struct ThemeCrossfade
2726 {
2727 ID window = ID::Invalid();
2728 tachyon::Image* image = nullptr;
2729 ImageIndex index = ImageIndex::Invalid;
2730 };
2731 static constexpr float kThemeCrossfadeSecs = 0.2f;
2732 std::vector<ThemeCrossfade> m_crossfades;
2733 float m_crossfadeStart = 0.0f;
2734 VisualBoxStyleIndex m_crossfadeStyle = VisualBoxStyleIndex::Invalid;
2736 void CaptureThemeCrossfade();
2738 void EndThemeCrossfade();
2739 float m_displayScale { 1.0f };
2740 FrameClock m_frameClock;
2741 bool m_themeReloadPending { false };
2742
2743 tachyon::ElementRef RegisterElementInternal(tachyon::Element&& element, LayoutOverride&& constraints, bool updateState = true);
2744
2747 void InvalidateCachedScopesForInput(ID overID);
2749 static std::vector<ID> CollectPropagatedAncestors(const ElementStorage& storage, ID leafID);
2753 void NoteTargetAncestors(int2 mousePos);
2755 ID TooltipHoverID() const
2756 {
2757 const ID hovered = guiStateManager.Interaction().GetHoveredID();
2758 return hovered != ID::Invalid() ? hovered : guiStateManager.Interaction().GetHoveredDisabledID();
2759 }
2761 void InvalidateCachedScopesAbove(ID id);
2764 void RebuildCachedScopesAbove(ID id) { m_cacheRebuildRequests.push_back(id); }
2765 std::vector<ID> m_cacheRebuildRequests;
2766
2768 void NotePanelContentID(ID panelId, ID contentID) { m_panelContentIDs[panelId] = contentID; }
2769
2771 TextAlign nodeRowTextAlign = TextAlign::Start;
2772
2775 int32_t nodeRowFieldMinWidth = 0;
2776
2777 bool BeginDockingFrame();
2778 void EndDockingFrame();
2779
2780 ID activeWindowID { ID::Invalid() };
2781 std::vector<bool> m_windowIdScopeStack;
2782
2784 void EmitNodeViewOverlays(NodeView& view, ID canvasID);
2785
2787 struct TitleBarInfo { ID barID = ID::Invalid(); ID maximizeID = ID::Invalid(); std::vector<ID> captions; };
2788 std::unordered_map<ID, TitleBarInfo> m_titleBars;
2789 std::vector<ID> m_titleBarStack;
2790 std::vector<ID> m_titleBarCaptions;
2791 std::unordered_set<ID> m_closeRequests;
2795 struct SuggestionRow { IconID icon = IconID::Invalid; std::string_view text; std::string_view trailing; };
2796 static constexpr int kMaxSuggestions = 12;
2797 void SuggestionPopup(ID windowID, ID anchorID, std::span<const SuggestionRow> rows, int current,
2798 bool reserveIcon, int32_t minWidth, std::function<void(int)> onPick);
2800 struct AutocompleteState
2801 {
2802 ID listWindowID = ID::Invalid();
2803 int current = -1;
2804 bool dismissed = false;
2805 bool picked = false;
2806 int32_t width = 0;
2807 };
2808 std::unordered_map<ID, AutocompleteState> m_autocomplete;
2809
2812 struct PressOutsideWatch { ID inside[2]; std::function<void()> onPressOutside; };
2813 std::vector<PressOutsideWatch> m_pressOutsideWatches;
2814 void CloseOnPressOutside(ID inside, ID alsoInside, std::function<void()> onPressOutside)
2815 { m_pressOutsideWatches.push_back({ { inside, alsoInside }, std::move(onPressOutside) }); }
2816 void RunPressOutsideWatches();
2820 void DispatchFileDrops(const FrameInput& input);
2822 ID OfferFileDrop(EventType type, ID overID, int2 screenPos, const FileDrop* drop);
2823 ID m_fileDragTargetID = ID::Invalid();
2824 std::vector<FileDrop> m_heldFileDrops;
2825 std::function<void(const FileDrop&)> m_fileDropHandler;
2826 std::vector<TextStyle> m_mnemonicStyles;
2828 struct ScrimFade { float amount = 0.0f; bool wanted = false; VisualColorStyleIndex color = VisualColorStyleIndex::Invalid; };
2829 std::unordered_map<ID, ScrimFade> m_scrims;
2830 float m_scrimTime = -1.0f;
2831 void DrawScrims(float now);
2833 struct PendingAfterDraw { uint32_t endIdx; ElementRef owner; };
2834 std::vector<PendingAfterDraw> m_pendingAfterDraws;
2836 void TitleBarCaption(ID id) { m_titleBarCaptions.push_back(id); }
2837 void DockFloatingWindow(FloatingDockWindow& fw);
2838
2840 void EmitColorPicker(tachyon::color4f& outColor, bool allowHDR);
2841 void EmitGradientEditor(tachyon::Gradient& outGradient);
2842
2845 void EmitColumnSizers(TableEmit& emit, int colStart, int colEnd,
2846 bool skipDragged = false);
2848 void EmitColumnSeparators(TableEmit& emit, int colStart, int colEnd);
2850 void EmitColumnBackgrounds(TableEmit& emit, int colStart, int colEnd);
2851
2853 void UpdateTableFollowTail(TableState& state, int32_t viewportH, int32_t contentH);
2854 void ScrollTableSectionsToBottom(TableState& state);
2856 void EmitTableSectionSeparator();
2857
2859 tachyon::LayoutOverride ApplyColumnDragOffsetX(tachyon::LayoutOverride lo,
2860 const TableEmit& emit, int c) const
2861 {
2862 if (emit.dragActive)
2863 lo = std::move(lo).PositionX(tachyon::PositionConstraintAxis::Relative(emit.columns[c].internal.dragOffsetX));
2864 return lo;
2865 }
2867 void MirrorTableScroll(TableState* state);
2870 void EmitTableHeaderCell(TableEmit& emit, tachyon::ID tableID, int c, int16_t gridCol,
2871 bool isStretchTrack, int sectionMin, int sectionMax,
2872 int effectiveSortCol, IconID sortIcon);
2874 void EmitTableHeaderSection(TableEmit& emit, tachyon::ID tableID,
2875 int colStart, int colEnd, bool lastColIsStretch,
2876 int effectiveSortCol, IconID sortIcon);
2879 GridTrack ComputeSectionColumnTrack(const TableEmit& emit, int c, int colEnd,
2880 bool isMiddle, bool fitContent = false) const;
2883 void OpenTableBodySection(TableEmit& emit, tachyon::ID sectionID, tachyon::StyleRef sectionStyle,
2884 tachyon::LayoutOverride&& layout, bool sampleViewport);
2887 void CloseTableBodySection(TableEmit& emit,
2888 tachyon::ID sectionBodyID, bool emitVerticalScrollbar,
2889 bool suppressHorzScrollbar = false);
2891 void EmitVirtualBodyRows(TableEmit& emit,
2892 int colStart, int colEnd,
2893 int totalRowCount, int32_t actualRowHeight,
2894 int firstVisible, int lastVisible,
2895 tachyon::ID rowsRangeID,
2896 bool isLastSection);
2897
2900 void EmitDraggedColumnOnTop(TableEmit& emit, tachyon::ID tableID,
2901 int colStart, int colEnd,
2902 int firstVisible, int lastVisible,
2903 tachyon::ID rowsRangeID,
2904 bool lastColIsStretch,
2905 int effectiveSortCol, IconID sortIcon);
2907 void EmitDirectCellText(const VirtualTableColumn& column, TableEmit& emit,
2908 tachyon::ID cellID, tachyon::ElementState cellState, tachyon::ElementFlags cellFlags,
2909 tachyon::StyleRef cellStyleRef, tachyon::EventHandler cellHandler,
2910 tachyon::TextID textID,
2911 int colIdx, int colStart, int16_t gridRow);
2912 void EmitDirectCellCustom(const VirtualTableColumn& column, TableEmit& emit,
2913 tachyon::ID cellID, tachyon::ElementState cellState, tachyon::ElementFlags cellFlags,
2914 tachyon::StyleRef cellStyleRef, tachyon::EventHandler cellHandler,
2915 bool cellSelected,
2916 std::function<void()> emit_fn,
2917 int colIdx, int colStart, int16_t gridRow);
2918 void EmitDirectCellTree(const VirtualTableColumn& column, TableEmit& emit,
2919 tachyon::ID cellID, tachyon::ElementState cellState, tachyon::ElementFlags cellFlags,
2920 tachyon::StyleRef cellStyleRef, tachyon::EventHandler cellHandler,
2921 bool cellSelected,
2922 tachyon::TextID textID,
2923 int treeDepth, bool* treeIsOpen, IconID treeIcon,
2924 uint32_t treeAncestorMask, bool treeIsLastSibling,
2925 std::string* treeRenameBuffer, bool treeRenameActive,
2926 tachyon::ID treeBodyID, bool reserveExpander,
2927 int colIdx, int colStart, int16_t gridRow);
2929 void EmitDirectRowBackdrop(tachyon::ID rowID, int16_t gridRow,
2930 int colStart, int colEnd,
2931 tachyon::ElementState backdropState,
2932 tachyon::ElementFlags backdropFlags,
2933 tachyon::StyleRef rowStyle,
2934 tachyon::EventHandler backdropHandler,
2935 TableState* tableState,
2936 bool isLastSection);
2938 void EmitDirectRowSpacer(int16_t gridRow,
2939 int colStart, int colEnd, int32_t height);
2942 tachyon::EventHandler BuildRowBackdropHandler(TableState* state,
2943 tachyon::ID containerID);
2945 tachyon::EventHandler BuildTableContainerHandler(TableState* state,
2946 tachyon::ID containerID);
2947
2949 bool IsTreeItemSelected(tachyon::ID id, int itemIndex) const;
2950 tachyon::TextID TreeItemRegisterText(tachyon::ID id, std::string_view text, IconID icon, StyleRef style, tachyon::ElementState state);
2951 void TreeItemRowCustomDraw(const tachyon::ElementRef& rowRef, bool hasArrow, tachyon::ID rowID);
2952 tachyon::EventHandler MakeTreeRowDragDropHandler(tachyon::ID rowID, bool rowHasChildren, ItemDragDropConfig* dd, bool* isOpen = nullptr);
2953 bool TreeItemRenameCheck(tachyon::ID bodyID, std::string* renameBuffer, StyleRef textStyle);
2954
2955 struct TreeClickState { tachyon::ID lastClickID = tachyon::ID::Invalid(); int64_t lastClickTimeNanos = 0; };
2956
2957 };
2958
2960} // namespace tachyon
Registry of commands: named actions with an optional icon and an optional shortcut key,...
Definition gui_command_manager.h:58
void PopDisabled()
Definition gui_state_atomic_values.h:58
void PopSelected()
Definition gui_state_atomic_values.h:61
void PushIndeterminate()
Definition gui_state_atomic_values.h:66
void PopIndeterminate()
Definition gui_state_atomic_values.h:67
void PushDisabled()
Definition gui_state_atomic_values.h:57
void PushInvalid()
Definition gui_state_atomic_values.h:63
bool IsIndeterminate() const
Definition gui_state_atomic_values.h:71
void PopInvalid()
Definition gui_state_atomic_values.h:64
void PushSelected()
Definition gui_state_atomic_values.h:60
The frame's element tree.
Definition gui_element_storage.h:100
ID GetLastItemID() const
The element last added at the level being built, its children done: after a control with parts,...
Definition gui_element_storage.h:188
AddResult Add(Element &&element, LayoutOverride &&constraints={})
Adds element after the previous one at the current nesting level.
ElementStorageResult BeginChildren()
Begins adding children to the last added element; elements without BeginChildren are leaves.
ElementStorageResult EndChildren()
Closes the innermost BeginChildren. Fails outside construction or without one open.
Stage callbacks run in registration order (no priorities): if A must run before B,...
Definition gui_frame_pipeline.h:74
A container's scope: its End runs when the scope leaves (or at End()).
Definition gui_application.h:2175
Scope & operator=(const Scope &)=delete
Scope(Scope &&other) noexcept
Definition gui_application.h:2179
~Scope()
Definition gui_application.h:2183
void End()
Ends the container now instead of when the scope leaves.
Definition gui_application.h:2186
Scope(GUIApplication &app, bool open)
Made by the scope functions below.
Definition gui_application.h:2178
Scope(const Scope &)=delete
Scope & operator=(Scope &&)=delete
The application: owns the windows, the systems and the frame loop.
Definition gui_application.h:185
void SelectableText(const std::span< ContentRun > &runs, StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID (the same every frame).
Definition gui_application.h:1918
tachyon::ElementRef RegisterElement(tachyon::Element &&element, std::string_view text, LayoutOverride &&constraints)
As above, with text registered as its text.
bool BeginTable(ID id, VirtualTableColumn(&columns)[N], TableState &state, StyleRef style, LayoutOverride &&constraints={})
As above, for a C array of columns.
Definition gui_application.h:1198
int MessageDialog(ID id, const MessageDialogDesc &desc, StyleRef style)
A modal question with verb buttons, centered.
void InjectFocus(ID windowID, bool focused)
Gives the window keyboard focus, or takes it away.
bool Field(bool &value, std::string_view text, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID, in the theme's toggle style.
Definition gui_application.h:1442
bool Switch(bool value, std::string_view text, std::function< void(bool)> onToggle, StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:594
InputHandlerBroadcaster inputBroadcaster
Sends each platform input event to the input manager and the text system.
Definition gui_application.h:255
bool BeginTitleBar(StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID, in style.
Definition gui_application.h:767
void Documents(ID id, DocumentSet &set, LayoutOverride &&constraints={})
The document bar of set, under the title bar, and below it the active document's panels,...
bool BeginTabBar(ID id, int *selectedIndex, std::function< void(int, int)> onReorder, std::function< void(int)> onClose=nullptr, std::function< void(int, tachyon::int2)> onDragOut=nullptr, std::function< void(int, tachyon::int2)> dragVisualizer=nullptr, StyleRef style={}, LayoutOverride &&constraints={}, TabBarLayout *layout=nullptr, const TabBarOptions &options={})
Opens a tab bar of Tabs.
void EndInvalid()
Closes BeginInvalid.
Definition gui_application.h:1113
void DragLabel(std::string_view text, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID, in the theme's drag label style.
Definition gui_application.h:1876
void Field(std::vector< T > &items, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID, in the theme's collection style.
Definition gui_application.h:1693
bool BeginListView(int *selectedIndex, int itemCount, ItemDragDropConfig *dragDrop, StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID, in style.
Definition gui_application.h:1043
auto Horizontal(A &&... a)
Definition gui_application.h:2209
friend class GUIApplicationInternals
GUIApplicationInternals (gui_application_internal.h) re-exposes these to the library's own code and t...
Definition gui_application.h:2451
void Image(ID id, ImageIndex image, uint2 sourceSize, StyleRef style, LayoutOverride &&constraints={})
Aspect-preserving: sizes the element to the largest sourceSize-aspect rect that fits the constraints.
bool ColorField(ID id, tachyon::color4b &value, StyleRef style, LayoutOverride &&constraints={})
As above, for an 8-bit color.
void EndReorderableGroup()
Closes BeginReorderableGroup.
bool BeginInvalid()
Controls emitted in between show that their value isn't accepted: the theme's error border (–error) a...
Definition gui_application.h:1111
bool BeginGridView(int *selectedIndex, StyleRef style, MultiSelectState *multiSelect=nullptr, ItemDragDropConfig *dragDrop=nullptr, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID, in style.
Definition gui_application.h:1128
void SetTooltip(std::string_view text, std::string_view shortcut)
As above, for the last control.
Definition gui_application.h:790
bool Slider(ID id, int &value, int minVal, int maxVal, LayoutOverride &&constraints={})
As above, in the theme's slider style.
Definition gui_application.h:1855
bool BeginTitleBar(LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:765
auto ReorderableItem(A &&... a)
Definition gui_application.h:2226
bool BeginDockingContainer(ID id, DockingLayout *layout, LayoutOverride &&constraints={})
As above, in the theme's dock style.
Definition gui_application.h:1413
void Cell(std::string_view text)
Cells auto-advance to the next column.
bool BeginReorderableItem(StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:1014
bool Field(T &value, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As the first, with the call site as the ID and the default config, updating continuously,...
Definition gui_application.h:1592
void Image(ImageIndex image, uint2 sourceSize, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID, in the theme's image style.
Definition gui_application.h:1941
bool Tab(ID id, const GUIContent &content, StyleRef style, LayoutOverride &&constraints={})
One tab of the tab bar; a click selects it. True when clicked.
void SetErrorTooltip(std::string_view message)
As above, for the last control.
Definition gui_application.h:800
bool CommandButton(CommandID command, StyleRef style, LayoutOverride &&constraints={})
Icon button for a command; the tooltip shows its name and shortcut, e.g. "Undo (Ctrl+Z)".
Result< void > Run()
Loops over the frame calls below until the app quits; an error when the GPU device was lost and could...
void EndIndeterminate()
Closes BeginIndeterminate.
Definition gui_application.h:548
void EndArea()
Closes BeginArea.
auto Table(A &&... a)
Definition gui_application.h:2217
bool BeginListView(ID id, int *selectedIndex, int itemCount, StyleRef style, LayoutOverride &&constraints={})
As above, without drag and drop.
Definition gui_application.h:1033
const std::string & GetThemePath() const
See GUIApplicationInitializeOptions.
Definition gui_application.h:388
bool Tab(const GUIContent &content, StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID, in style.
Definition gui_application.h:1401
bool BeginWindow(ID windowLayoutID, std::string_view title, StyleRef styleRef, LayoutOverride &&constraints, ElementFlags flags=ElementFlags::WindowUserControlled|ElementFlags::WindowIsCentered, int monitorIndex=-1)
An OS window, made the first time its ID is seen; build its content while this returns true.
Definition gui_application.h:2094
bool Field(T &value, TextEditBehavior textEditBehavior, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As the first, with the call site as the ID and the default config, in the theme's number style.
Definition gui_application.h:1588
void Label(ID id, std::string_view text, LayoutOverride &&constraints={})
As the first, in the theme's label style.
Definition gui_application.h:1891
bool TypedField(ID id, T &value, StyleRef style, LayoutOverride &&constraints={})
As above; style is the box's around the number and its type.
Definition gui_application.h:1618
virtual Result< void > Initialize(const InitializeOptions &options={})
Creates the backends not set before, the window manager, the text system and the subsystems,...
bool SliderField(int &value, int minVal, int maxVal, std::string_view text, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID, in the theme's slider field style.
Definition gui_application.h:1849
void SelectableText(const std::span< ContentRun > &runs, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID, in the theme's text style.
Definition gui_application.h:1921
bool GradientField(tachyon::Gradient &value, StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:1815
bool TypedField(T &value, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:1634
void SetUIScale(float scale)
Extra UI zoom on top of the main window's display scale (1 follows the OS).
void SetTooltip(ID targetID, IconID icon, std::string_view text)
As above, with an icon before the text.
bool Checkbox(ID id, bool &value, std::string_view text, StyleRef style, LayoutOverride &&constraints={})
Checks and unchecks value itself.
Definition gui_application.h:581
void AddBox(ID id, int2 size, StyleRef styleRef, std::string_view text)
As above, with text.
Definition gui_application.h:2274
bool BeginListView(ID id, int *selectedIndex, int itemCount, ItemDragDropConfig *dragDrop, StyleRef style, LayoutOverride &&constraints={})
Opens a list view of ListItems.
int MessageDialog(const MessageDialogDesc &desc, std::source_location site=std::source_location::current())
As above, with the call site as the ID, in the theme's message box style.
Definition gui_application.h:667
auto ContextMenu(A &&... a)
Definition gui_application.h:2206
bool BeginToolbar(bool horizontal=true)
Toolbar scope: a wrap container that swaps theme.controls to the toolbar styles, so default-style wid...
void Field(ID id, std::vector< std::pair< std::string, V > > &items, StyleRef style, LayoutOverride &&constraints={})
A key-value list (std::string keys, V values): a Key / Value header with the types,...
Definition gui_application.h:1698
std::unique_ptr< LayoutEngine > layoutEngine
Lays out the elements each frame. Created by Initialize.
Definition gui_application.h:190
std::unique_ptr< TextAtlasManager > textAtlasManager
The glyph atlas. Created by Initialize.
Definition gui_application.h:194
bool Checkbox(ID id, bool value, std::string_view text, std::function< void(bool)> onToggle, StyleRef style, LayoutOverride &&constraints={})
A checkbox (a box, checked with a tick) and its label; a click calls onToggle with the new value.
bool BeginMenu(std::string_view text, StyleRef buttonStyle, StyleRef menuStyle, StyleRef itemStyle, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:634
StyleRef ReorderableGroupStyle(ReorderDirection direction, bool isWrapped) const
The theme's reorderable group style for a direction and wrapping.
Definition gui_application.h:1000
bool BeginTooltip(ID targetID)
A tooltip with any content on targetID: build it while this returns true.
void MenuFilter()
A filter field for a big menu, first in it: it takes the keyboard when the menu opens,...
bool BeginMenu(ID id, std::string_view text, LayoutOverride &&constraints={})
As above, in the theme's menu styles.
Definition gui_application.h:632
static void TransferPanel(tachyon::ID panelID, tachyon::DockNode *sourceNode, DockingLayout *sourceLayout, DockingLayout *targetLayout)
Moves a panel from sourceNode/sourceLayout to targetLayout, fixing up selectedTab.
void StatusText(std::string_view text, StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:1316
bool TypedField(ID id, T &value, LayoutOverride &&constraints={})
A number field with its type after the value, e.g. "0.5 f32".
Definition gui_application.h:1615
bool BeginVerticalWrap(ID id, LayoutOverride &&constraints={})
As above, in the theme's plain style.
Definition gui_application.h:923
void Field(std::unordered_map< std::string, V > &items, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID, in the theme's collection style.
Definition gui_application.h:1779
bool Field(ID id, T &value, StyleRef style, LayoutOverride &&constraints={})
As the first, updating continuously, with the default config.
Definition gui_application.h:1564
void EndGhostWindow()
Closes BeginGhostWindow or BeginCursorGhostWindow.
Definition gui_application.h:2036
TransitionManager transitionManager
In-progress visual state transitions, per element.
Definition gui_application.h:211
bool MenuItem(ID id, const GUIContent &content, std::function< void()> onClick, StyleRef style, LayoutOverride &&constraints={})
Without a shortcut, in style.
Definition gui_application.h:712
void InjectMouseLeave(ID windowID)
The pointer left the window.
auto VerticalWrap(A &&... a)
Definition gui_application.h:2212
void EndReorderableItem()
Closes BeginReorderableItem.
void VirtualTreeView(std::vector< TreeViewRow > &rows, std::vector< int > &visibleIdx, TableState &state, StyleRef style={}, LayoutOverride &&constraints={}, std::string_view header={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:1081
bool Dropdown(int &selected, std::initializer_list< std::string_view > options, StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID, in style.
Definition gui_application.h:655
void EmitFloatingDockWindows(const DocumentSet &documents)
With documents in several main windows: in each, after its Documents, the windows of the panels torn ...
void Text(ID id, std::string_view text, StyleRef style, LayoutOverride &&constraints={})
Static text.
bool Toggle(ID id, bool &value, const GUIContent &content, StyleRef style, LayoutOverride &&constraints={})
Toggles value itself.
Definition gui_application.h:615
void EndVerticalWrap()
Closes BeginVerticalWrap.
void ScrollbarOverlay(ID containerID, int2 lastInnerSize=int2{0, 0}, ID vertScrollBarID=ID::Invalid(), ID horzScrollBarID=ID::Invalid(), bool emitVert=true, bool emitHorz=true)
Both bars plus a corner cap; each hides itself without overflow.
auto ReorderableGroup(A &&... a)
Definition gui_application.h:2225
tachyon::ID CreatePanel(std::unordered_map< tachyon::ID, tachyon::Panel > &panels, std::string title, tachyon::IconID icon, std::function< void()> onPanelGUI, std::string panelType={}, std::function< void()> onEnable={}, std::function< void()> onDisable={})
As above, with a new static ID, which it returns.
Definition gui_application.h:298
GUITheme theme
The loaded theme: the style refs, icons and metrics the controls use; theme.GetStyle finds a CSS clas...
Definition gui_application.h:263
bool UpdateFrame()
One frame, for a host with its own main loop:
void HorizontalScrollbar(ID containerID)
As above, with an ID derived from the container's.
Definition gui_application.h:954
MenuManager menuManager
The open menus and the menu bar's triggers.
Definition gui_application.h:216
bool Field(T &value, NumericFieldConfig< ComponentT > config, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As the first, with the call site as the ID, updating continuously, in the theme's number style.
Definition gui_application.h:1585
auto ListView(A &&... a)
Definition gui_application.h:2219
void EndTabBar()
Closes BeginTabBar.
void EmitFloatingDockWindows()
Call from OnGUI after the main docking container. Empty windows are closed.
bool IsFileDragging() const
Whether files or text from another application are dragged over one of the app's windows.
Definition gui_application.h:1091
StyleManager styleManager
The registered styles; Px converts CSS pixels to pixels at the UI scale.
Definition gui_application.h:244
bool Breadcrumb(ID id, std::span< const std::string > segments, std::function< void(int)> onSelect, LayoutOverride &&constraints={})
As above, in the theme's breadcrumb style.
Definition gui_application.h:1288
bool BeginCursorGhostWindow(ID windowLayoutID, int2 cursorPos, StyleRef styleRef)
As above, with a style, sized to its content.
Definition gui_application.h:2012
void AddBox(int2 size, StyleRef styleRef, std::string_view text, std::source_location site=std::source_location::current())
A fixed-size box with text, with the call site as the ID.
Definition gui_application.h:2330
static void FocusCommandSearch(CommandSearchState &state)
Puts the keyboard in the search next frame; bind it to a command such as Ctrl+K.
Definition gui_application.h:1337
bool SliderField(ID id, float &value, float minVal, float maxVal, std::string_view text, LayoutOverride &&constraints={})
As above, in the theme's slider field style.
Definition gui_application.h:1830
void Label(ID id, std::string_view text, StyleRef style, LayoutOverride &&constraints={})
A label for the control after it: a click focuses that control.
bool AutocompleteField(ID id, std::string &value, std::span< const std::string_view > suggestions, StyleRef style, LayoutOverride &&constraints={})
A text field that lists, under itself while it has the keyboard and holds text, the suggestions that ...
void EndGridView()
Closes BeginGridView.
bool DestructiveMenuItem(ID id, const GUIContent &content, std::function< void()> onClick, LayoutOverride &&constraints={})
Without a shortcut, in the theme's item style.
Definition gui_application.h:729
void Image(ImageIndex image, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID, in the theme's image style.
Definition gui_application.h:1931
void PersistShortcuts(std::string key, CommandManager &commands)
Keeps the shortcuts that aren't the ones their commands were registered with, matching commands by mo...
bool GridViewItem(ID id, const GUIContent &content, tachyon::ElementState extraState=tachyon::ElementState::None, std::string *renameBuffer=nullptr, StyleRef itemStyle={}, LayoutOverride &&constraints={})
renameBuffer (optional) enables in-place rename: F2, Ctrl+Shift+Click or a slow re-click opens an edi...
bool BeginTable(ID id, VirtualTableColumn(&columns)[N], TableState &state, LayoutOverride &&constraints={})
As above, for a C array of columns, in the theme's table style.
Definition gui_application.h:1203
static void RebuildTreeViewIndex(std::vector< TreeViewRow > &rows)
Recomputes skipCount / ancestorLineMask / isLastSibling from row depths.
auto DockingContainer(A &&... a)
Definition gui_application.h:2231
void EndWindow()
Closes BeginWindow; called whether or not it returned true.
Definition gui_application.h:2154
void CollectionHeader(std::string_view valueType)
A dictionary's header row: "Key string", "Value <type>".
GUIStateManager guiStateManager
Per-element interaction state (hover, focus, clicks) and the construction stacks (disabled,...
Definition gui_application.h:209
void PersistTable(std::string key, TableState &state, std::span< VirtualTableColumn > columns)
Keeps the table's column widths and order, matching columns by header.
bool Switch(bool &value, std::string_view text={}, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID, in the theme's switch style.
Definition gui_application.h:604
void Text(std::string_view text, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID, in the theme's text style.
Definition gui_application.h:1904
Result< void > RestoreUIState(std::string_view json)
Applies JSON text from SaveUIState.
bool BeginMenu(ID id, std::string_view text, StyleRef buttonStyle, StyleRef menuStyle, StyleRef itemStyle, LayoutOverride &&constraints={})
A menu: a trigger button (in a menu bar or on its own), or a submenu item inside another menu.
void TreeCell(std::string_view text, int depth, bool *isOpen, IconID icon=IconID::Invalid, uint32_t ancestorLineMask=0, bool isLastSibling=true, std::string *renameBuffer=nullptr, bool reserveExpander=true)
Tree-style first column: [indent][arrow or spacer][optional icon][text].
bool ColorField(tachyon::color4f &value, bool allowHDR, StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:1797
bool Button(const GUIContent &content, std::function< void()> onClick, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID, in the theme's button style.
Definition gui_application.h:565
auto CursorGhostWindow(A &&... a)
Definition gui_application.h:2203
bool BeginReorderableGroup(ReorderDirection direction, std::function< void(int fromIndex, int toIndex)> onReorder, StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, not wrapped, with the call site as the ID.
Definition gui_application.h:994
void EndLabelGroup()
Closes BeginLabelGroup.
bool SliderField(ID id, int &value, int minVal, int maxVal, std::string_view text, StyleRef style, LayoutOverride &&constraints={})
Integer variant: snaps to whole numbers.
static void WalkTreeViewVisibility(const std::vector< TreeViewRow > &rows, std::vector< int > &visibleIdx)
Writes the flat indices of visible rows (honoring isOpen) to visibleIdx.
CommandManager commandManager
Commands, their shortcuts and the undo history.
Definition gui_application.h:252
bool BeginLabelGroup(CssPx defaultWidth=120, CssPx minWidth=40, CssPx maxWidth=500, bool resizable=true, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:837
bool Breadcrumb(std::span< const std::string > segments, std::function< void(int)> onSelect, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:1290
void VirtualTable(TableState &state, std::span< VirtualTableColumn > columns, int totalRowCount, CssPx rowHeight=0, StyleRef style={}, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:1273
bool Field(ID id, T &value, NumericFieldConfig< ComponentT > config, LayoutOverride &&constraints={})
As the first, updating continuously, in the theme's number style.
Definition gui_application.h:1567
void GetFrameTimingHistory(std::span< FrameTimingSample > out) const
Copies the ring chronologically (oldest first) into out.
void EndContextMenu()
Closes BeginContextMenu; called whether or not it returned true.
bool AutocompleteField(std::string &value, std::span< const std::string_view > suggestions, StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:1480
void AddBox(StyleRef styleRef, std::string_view text, std::source_location site=std::source_location::current())
A box with text, sized to its content, with the call site as the ID.
Definition gui_application.h:2324
bool Slider(ID id, int &value, int minVal, int maxVal, StyleRef style, LayoutOverride &&constraints={})
Groove + knob without value text; drag-only, integer-valued.
bool BeginReorderableGroup(ReorderDirection direction, std::function< void(int fromIndex, int toIndex)> onReorder, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, not wrapped, with the call site as the ID, in the theme's style for the direction.
Definition gui_application.h:997
void CreatePanel(std::unordered_map< tachyon::ID, tachyon::Panel > &panels, ID id, std::string title, tachyon::IconID icon, std::function< void()> onPanelGUI, std::string panelType={}, std::function< void()> onEnable={}, std::function< void()> onDisable={})
Adds a panel to panels (usually a DockingLayout's).
Document & CreateDocument(DocumentSet &set, std::string name, std::string extension, std::string kind, tachyon::IconID icon)
Adds a document at the end of set, with new static IDs and an empty layout, which the caller fills (C...
void SetWindowBackend(std::unique_ptr< IWindowBackend > backend)
The OS windows and their input; Initialize wraps it to add render-to-image windows.
Definition gui_application.h:438
bool DestructiveMenuItem(const GUIContent &content, std::string_view shortcut, std::function< void()> onClick, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID, in the theme's item style.
Definition gui_application.h:725
float GetUIScale() const
The graphics backend Initialize uses; without one it creates a vulkan::VulkanGraphicsContext.
Definition gui_application.h:458
void InjectMouseMove(ID windowID, int2 pos, KeyModifier mods=KeyModifier::None)
Input for render-to-image windows (WindowFlags::RenderToImage), which get none from the OS.
bool Field(bool &value, std::string_view text, StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:1438
void SetClipboard(std::unique_ptr< IClipboard > clipboardImpl)
Copy and paste for text fields.
Definition gui_application.h:441
bool BeginWindow(ID windowLayoutID, std::string_view title, ElementFlags flags=ElementFlags::WindowUserControlled|ElementFlags::WindowIsCentered, int monitorIndex=-1)
As the full BeginWindow below, in the theme's window style.
Definition gui_application.h:2047
bool CommandSearch(CommandSearchState &state, StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:1333
void InvalidatePanel(ID panelId)
Invalidates a docked panel's cached content by panel id. Safe from event handlers.
bool Dropdown(int &selected, std::initializer_list< std::string_view > options, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:651
void RequestReloadTheme(std::string_view themePath, float fontScale)
Deferred to the start of the next frame; safe from event handlers.
bool BeginGhostWindow(ID windowLayoutID, int2 position, int2 size, StyleRef styleRef)
position is the top-left in screen space; for drag previews use BeginCursorGhostWindow.
Definition gui_application.h:1956
bool BeginLabelGroup(ID id, CssPx defaultWidth=120, CssPx minWidth=40, CssPx maxWidth=500, bool resizable=true)
Label group: Labels/DragLabels inside share one width, resizable by dragging any label's right edge.
bool BeginHorizontal(ID id, LayoutOverride &&constraints={})
As above, in the theme's plain style.
Definition gui_application.h:890
bool BeginTable(VirtualTableColumn *columns, size_t columnCount, TableState &state, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID, in the theme's table style.
Definition gui_application.h:1211
WindowRegistry windowRegistry
The elements of each window, filled as the windows are built.
Definition gui_application.h:249
void EmitDragHandle()
Non-interactive drag handle for use inside BeginReorderableItem; clicks reach the item.
void EndHorizontalWrap()
Closes BeginHorizontalWrap.
float GetGlobalFontScale() const
The graphics backend Initialize uses; without one it creates a vulkan::VulkanGraphicsContext.
Definition gui_application.h:453
bool CommandSearch(ID id, CommandSearchState &state, LayoutOverride &&constraints={})
As above, in the theme's command search style.
Definition gui_application.h:1331
bool Toggle(ID id, bool &value, const GUIContent &content, LayoutOverride &&constraints={})
As above, in the theme's toggle style.
Definition gui_application.h:617
bool SliderField(ID id, int &value, int minVal, int maxVal, std::string_view text, LayoutOverride &&constraints={})
As above, in the theme's slider field style.
Definition gui_application.h:1843
auto TabBar(A &&... a)
Definition gui_application.h:2221
bool Toggle(ID id, bool value, const GUIContent &content, std::function< void(bool)> onToggle, LayoutOverride &&constraints={})
As above, in the theme's toggle style.
Definition gui_application.h:609
auto Tooltip(A &&... a)
Definition gui_application.h:2207
bool MenuItem(const GUIContent &content, std::string_view shortcut, std::function< void()> onClick, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:708
bool BeginMenuBar(ID id, StyleRef style, LayoutOverride &&constraints={})
Menu bar: place BeginMenu triggers inside.
void SetDrawCacheEnabled(bool enabled)
Enables the retained-render cache (on by default). When off, every scope rebuilds.
Definition gui_application.h:882
bool BeginTable(ID id, VirtualTableColumn *columns, size_t columnCount, TableState &state, StyleRef style, LayoutOverride &&constraints={})
Opens a table.
auto TitleBar(A &&... a)
Definition gui_application.h:2224
bool BeginButtonGroup(LayoutOverride &&constraints={})
Button / toggle group: Buttons / Field(bool) inside are restyled with .first-/.mid-/....
bool Field(std::string &value, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:1460
bool BeginReorderableGroup(ID id, ReorderDirection direction, std::function< void(int fromIndex, int toIndex)> onReorder, LayoutOverride &&constraints={})
As above, not wrapped, in the theme's style for the direction.
Definition gui_application.h:982
bool BeginListView(ID id, int *selectedIndex, int itemCount, LayoutOverride &&constraints={})
As above, without drag and drop, in the theme's list style.
Definition gui_application.h:1035
bool Dropdown(int &selected, std::span< const std::string_view > options, StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:645
bool Button(const GUIContent &content, std::function< void()> onClick, StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:563
bool CommandSearch(CommandSearchState &state, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID, in the theme's command search style.
Definition gui_application.h:1335
void InjectKey(ID windowID, KeyCode key, KeyAction action, KeyModifier mods=KeyModifier::None)
A key event; typed text goes through InjectText.
auto DockingFrame(A &&... a)
Definition gui_application.h:2232
void EndDisabled()
Closes BeginDisabled.
Definition gui_application.h:1107
std::chrono::steady_clock::time_point m_frameStart
Internal: when the current frame started (set by UpdateFrame).
Definition gui_application.h:269
int FindListItemIndex(tachyon::ID id) const
A list item's index by ID, for end-of-frame handlers; -1 if unknown.
bool Button(ID id, const GUIContent &content, std::function< void()> onClick, StyleRef style, LayoutOverride &&constraints={})
Controls take (id, icon, text, ..., style, constraints), each part optional.
bool FloatPanel(DockingLayout &layout, ID panelID, int2 screenPos)
Moves a docked panel into its own window at a screen position, as tearing its tab off does; the windo...
bool Dropdown(ID id, int &selected, std::span< const std::string_view > options, LayoutOverride &&constraints={})
As above, in the theme's dropdown style.
Definition gui_application.h:643
void EndMenuBar()
Closes BeginMenuBar.
bool BeginTable(ID id, VirtualTableColumn *columns, size_t columnCount, TableState &state, LayoutOverride &&constraints={})
As above, in the theme's table style.
Definition gui_application.h:1193
float frameTime
The last frame's duration in seconds, including any vsync wait.
Definition gui_application.h:271
bool GridViewItem(const GUIContent &content, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:1145
bool SearchField(std::string &value, IconID icon, TextEditBehavior textEditBehavior=TextEditBehavior::ContinuousUpdate, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID, in the theme's search style.
Definition gui_application.h:1469
void AddGhostIcon(IconID icon, std::source_location site=std::source_location::current())
An icon in the open ghost window, 28 x 28 CSS px.
Definition gui_application.h:2018
bool Field(ID id, std::string &value, TextEditBehavior textEditBehavior, StyleRef style, LayoutOverride &&constraints={})
A text field editing value; true when it changed.
bool ListItem(ID id, const GUIContent &content, LayoutOverride &&constraints={})
As above, in the theme's item style.
Definition gui_application.h:1056
void EmitFloatingToolbarWindows(std::vector< struct FloatingToolbarItem > &floatingItems, const struct FloatingToolbarOptions *options=nullptr)
One OS window per floating toolbar. Closed windows are erased and their IDs released.
ElementStorage elementStorage
This frame's element tree.
Definition gui_application.h:247
bool ColorField(tachyon::color4b &value, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID, in the theme's color field style.
Definition gui_application.h:1807
bool MenuItem(const GUIContent &content, std::function< void()> onClick=nullptr, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:704
void Banner(Severity severity, const GUIContent &message, std::span< const BannerAction > actions={}, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:686
bool Field(T &value, TextEditBehavior textEditBehavior, StyleRef style, NumericFieldConfig< ComponentT > config, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As the first, with the call site as the ID.
Definition gui_application.h:1573
GraphicsContext * graphicsContext
the backend from SetGraphicsBackend
Definition gui_application.h:200
bool Field(ID id, bool &value, std::string_view text, StyleRef style, LayoutOverride &&constraints={})
A bool as a Toggle labelled text.
bool SliderField(ID id, float &value, float minVal, float maxVal, std::string_view text, StyleRef style, LayoutOverride &&constraints={})
A label, a slider track and a number field for value in [minVal, maxVal]; true when it changed.
void Label(ID id, std::string_view text, std::string_view caption, StyleRef style, LayoutOverride &&constraints={})
A label over a field taller than a row (a list): at the top, with a caption under it such as "3 items...
bool BeginDockingContainer(DockingLayout *layout, StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:1416
bool Field(std::string &value, TextEditBehavior textEditBehavior, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:1456
tachyon::EventHandler MakeLabelHandler()
A label's handler: a click focuses the control the label belongs to.
bool Switch(ID id, bool &value, std::string_view text, StyleRef style, LayoutOverride &&constraints={})
Switches value itself.
Definition gui_application.h:598
bool BeginMenuBar(LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:743
void CloseDocument(DocumentSet &set, int index)
Closes set's document at index for good: its panels are disabled and destroyed, its torn-off panel wi...
tachyon::EventHandler MakeButtonHandler(std::function< void()> onClick)
A handler that calls onClick on click.
auto StatusBar(A &&... a)
Definition gui_application.h:2223
void VerticalScrollbar(ID scrollBarID, ID containerID)
A vertical scrollbar for containerID, called from inside it: it overlays the container's border box a...
bool BeginTab(ID id, const GUIContent &content, StyleRef style, StyleRef contentStyle, LayoutOverride &&constraints={})
A tab with more in it: its icon and text in contentStyle (the theme's when invalid),...
void StatusText(ID id, std::string_view text, StyleRef style, LayoutOverride &&constraints={})
A text in the status bar.
bool SliderField(float &value, float minVal, float maxVal, std::string_view text, StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:1833
void EndTitleBar()
Closes BeginTitleBar, adding the window buttons in a custom-title-bar window.
WindowHitArea TitleBarHitTest(ID windowID, int2 screenPos) const
What the OS should do with a screen point of a window with a custom title bar.
void HorizontalScrollbar(ID scrollBarID, ID containerID)
As VerticalScrollbar, horizontal.
bool BeginHorizontalWrap(ID id, StyleRef style, LayoutOverride &&constraints={})
A horizontal container whose children wrap onto further lines.
bool Switch(ID id, bool value, std::string_view text, std::function< void(bool)> onToggle, StyleRef style, LayoutOverride &&constraints={})
An on/off switch (track and knob) with an optional label after it, e.g. "On".
bool GradientField(ID id, tachyon::Gradient &value, LayoutOverride &&constraints={})
As above, in the theme's gradient swatch style.
Definition gui_application.h:1813
bool BeginWindow(ID windowLayoutID, StyleRef styleRef, ElementFlags flags=ElementFlags::WindowUserControlled|ElementFlags::WindowIsCentered, int monitorIndex=-1)
As the full BeginWindow below, without a title.
Definition gui_application.h:2072
DockDropResult FindDockDropTargetAtScreenPos(tachyon::int2 screenPos)
Hit-tests leaf content areas; falls back to tab bars with zone=Center.
bool ColorField(ID id, tachyon::color4f &value, bool allowHDR, StyleRef style, LayoutOverride &&constraints={})
A color swatch that opens a color picker; true when the color changed.
bool Dropdown(ID id, int &selected, std::span< const std::string_view > options, StyleRef style, LayoutOverride &&constraints={})
A dropdown: a field showing options[selected] that opens the list of options under itself.
ID TreeDropTargetRow() const
The tree row a drag is over (drives the drop indicator), or Invalid.
Definition gui_application.h:1087
auto ToggleGroup(A &&... a)
Definition gui_application.h:2216
void SetDisabledTooltip(std::string_view text, std::string_view reason)
As above, for the last control.
Definition gui_application.h:805
void Field(ID id, std::vector< T > &items, StyleRef style, LayoutOverride &&constraints={})
A reorderable list: each row a grip, its index, the field (numbers with their type) and a remove butt...
Definition gui_application.h:1643
bool Field(ID id, T &value, StyleRef style, NumericFieldConfig< ComponentT > config, LayoutOverride &&constraints={})
As the first, updating continuously.
Definition gui_application.h:1561
void PersistValue(std::string key, bool &value)
Keeps an app value.
void RenderSettingsPanel(SettingsPanelState &state)
Renders into the current container; the caller provides the outer panel.
bool Field(T &value, StyleRef style, NumericFieldConfig< ComponentT > config, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As the first, with the call site as the ID, updating continuously.
Definition gui_application.h:1576
bool Switch(bool value, std::string_view text, std::function< void(bool)> onToggle, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID, in the theme's switch style.
Definition gui_application.h:596
std::vector< SavedDocumentWindow > TakeSavedDocuments(std::string_view key)
The main windows of documents RestoreUIState read for key, in the order they were listed; empty when ...
auto GhostWindow(A &&... a)
Definition gui_application.h:2202
bool ColorField(tachyon::color4f &value, bool allowHDR=false, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID, in the theme's color field style.
Definition gui_application.h:1799
bool BeginWindow(ID windowLayoutID, std::string_view title, StyleRef styleRef, ElementFlags flags=ElementFlags::WindowUserControlled|ElementFlags::WindowIsCentered, int monitorIndex=-1)
As the full BeginWindow below.
Definition gui_application.h:2053
bool BeginWindow(ID windowLayoutID, StyleRef styleRef, LayoutOverride &&constraints, ElementFlags flags=ElementFlags::WindowUserControlled|ElementFlags::WindowIsCentered, int monitorIndex=-1)
As the full BeginWindow below, without a title.
Definition gui_application.h:2084
bool Switch(bool &value, std::string_view text, StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:602
bool Field(ID id, T &value, TextEditBehavior textEditBehavior, NumericFieldConfig< ComponentT > config, LayoutOverride &&constraints={})
As above, in the theme's number style.
Definition gui_application.h:1552
void DismissToast(ToastID toast)
Takes a toast away, as its close button does.
auto Selected(A &&... a)
Definition gui_application.h:2229
bool Dropdown(ID id, int &selected, std::initializer_list< std::string_view > options, StyleRef style, LayoutOverride &&constraints={})
As above, in style.
Definition gui_application.h:653
bool BeginTitleBar(ID id, StyleRef style, LayoutOverride &&constraints={})
A menu bar the window is dragged by: what in it isn't a control is the caption (drag to move,...
bool BeginDockingContainer(DockingLayout *layout, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID, in the theme's dock style.
Definition gui_application.h:1419
const std::string & GetResourceRoot() const
See GUIApplicationInitializeOptions.
Definition gui_application.h:395
static constexpr int kFrameHistoryCount
~4s @ 60fps
Definition gui_application.h:277
bool BeginTabBar(int *selectedIndex, std::function< void(int, int)> onReorder, std::function< void(int)> onClose=nullptr, std::function< void(int, tachyon::int2)> onDragOut=nullptr, std::function< void(int, tachyon::int2)> dragVisualizer=nullptr, StyleRef style={}, LayoutOverride &&constraints={}, TabBarLayout *layout=nullptr, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:1375
bool ListItem(ID id, const GUIContent &content, StyleRef style, LayoutOverride &&constraints={})
One item of a list view, drawn selected when it is the selected index. True when clicked.
void Field(ID id, std::vector< T > &items, LayoutOverride &&constraints={})
As above, in the theme's collection style.
Definition gui_application.h:1687
void SetTooltip(std::string_view text)
As above, on the control just drawn (its outer element, shown over all its parts).
Definition gui_application.h:782
virtual ~GUIApplication()=default
See GUIApplicationInitializeOptions.
bool BeginVerticalWrap(ID id, StyleRef style, LayoutOverride &&constraints={})
A vertical container whose children wrap onto further columns.
void CloseFloatingDockWindow(size_t index)
Closes the window for good: its panels are disabled and destroyed.
Result< void > RecordFrame()
See UpdateFrame.
void EndStatusBar()
Closes BeginStatusBar.
void Image(ID id, ImageIndex image, LayoutOverride &&constraints={})
As above, in the theme's image style.
Definition gui_application.h:1927
IWindowBackend * windowBackend
SetWindowBackend's windows plus render-to-image windows.
Definition gui_application.h:199
void SetTooltip(IconID icon, std::string_view text)
As above, with an icon, on the control just drawn.
Definition gui_application.h:784
bool Toggle(ID id, bool value, const GUIContent &content, std::function< void(bool)> onToggle, StyleRef style, LayoutOverride &&constraints={})
A button that shows pressed while value is on; a click calls onToggle with the new value.
bool BeginHorizontalWrap(ID id, LayoutOverride &&constraints={})
As above, in the theme's plain style.
Definition gui_application.h:901
bool BeginArea(ID id, LayoutOverride &&constraints={})
As above, in the theme's area style.
Definition gui_application.h:859
bool MenuItem(const GUIContent &content, std::function< void()> onClick, StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
Without a shortcut, with the call site as the ID, in style.
Definition gui_application.h:714
void SetTooltip(ID targetID, std::string_view text, std::string_view shortcut)
As above, with the keyboard shortcut that does the same in a chip after the text.
void SetAllocationHooks(const AllocationHooks &hooks)
Host memory functions for what can be routed: Vulkan objects, VMA, vk-bootstrap and SDL (only when th...
Definition gui_application.h:446
bool Field(ID id, std::string &value, StyleRef style, LayoutOverride &&constraints={})
As above, updating continuously.
Definition gui_application.h:1450
bool BeginStatusBar(ID id, LayoutOverride &&constraints={})
As above, in the theme's status bar style.
Definition gui_application.h:1304
void EndTooltip()
Closes BeginTooltip; called whether or not it returned true.
void Field(ID id, std::vector< std::pair< std::string, V > > &items, LayoutOverride &&constraints={})
As above, in the theme's collection style.
Definition gui_application.h:1722
auto Cached(A &&... a)
Definition gui_application.h:2208
bool Field(ID id, T &value, TextEditBehavior textEditBehavior, LayoutOverride &&constraints={})
As above, with the default config.
Definition gui_application.h:1555
bool BeginStatusBar(LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:1306
void Field(std::vector< std::pair< std::string, V > > &items, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID, in the theme's collection style.
Definition gui_application.h:1728
tachyon::ElementRef RegisterElement(tachyon::Element &&element, LayoutOverride &&constraints)
Adds an element, with its interaction state, to the current window; for custom elements.
void Cell(std::function< void()> emit)
Custom-content cell: emit runs inside the cell during EndTable, so its captures must live until then.
bool SearchField(std::string &value, IconID icon, TextEditBehavior textEditBehavior, StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:1467
bool BeginMenuBar(ID id, LayoutOverride &&constraints={})
As above, in the theme's menu bar style.
Definition gui_application.h:741
void RenderNodeView(NodeView &view)
Builds view (canvas, nodes, wires and overlays) in the current container.
bool BeginHorizontal(StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:892
bool Checkbox(bool value, std::string_view text, std::function< void(bool)> onToggle, StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:577
bool BeginReorderableGroup(ReorderDirection direction, bool isWrapped, std::function< void(int fromIndex, int toIndex)> onReorder, StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:988
bool MenuItem(ID id, const GUIContent &content, std::string_view shortcut, std::function< void()> onClick, StyleRef style, LayoutOverride &&constraints={})
Optional icon, label, optional shortcut. The icon column is reserved if any sibling has an icon.
void DragLabel(ID id, std::string_view text, StyleRef style, LayoutOverride &&constraints={})
A label whose horizontal drag changes the value of the field after it; a click focuses that field and...
auto HorizontalWrap(A &&... a)
Definition gui_application.h:2211
void Field(std::vector< T > &items, StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:1690
bool Field(std::string &value, TextEditBehavior textEditBehavior, StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:1448
GradientManager gradientManager
GPU pages for the gradients styles use.
Definition gui_application.h:242
void SelectableText(ID id, const std::span< ContentRun > &runs, std::function< void(intptr_t contentId)> onLinkActivate, StyleRef style, LayoutOverride &&constraints={})
Read-only rich text with links, mouse selection and Ctrl+C.
bool CommandSearch(ID id, CommandSearchState &state, StyleRef style, LayoutOverride &&constraints={})
Finds and runs commandManager's commands: focused, it lists those whose description contains the quer...
bool BeginDockingContainer(ID id, DockingLayout *layout, StyleRef style, LayoutOverride &&constraints={})
Builds layout's docked panels (each one's onPanelGUI) in a container, enabling the visible panels fir...
void SetDisabledTooltip(ID targetID, std::string_view text, std::string_view reason)
A text tooltip that, while targetID is disabled, also says why, on a second, muted line.
void PersistValue(std::string key, float &value)
As above, for a float.
auto Invalid(A &&... a)
Definition gui_application.h:2228
bool BeginHorizontal(LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID, in the theme's plain style.
Definition gui_application.h:894
void DragLabel(ID id, std::string_view text, LayoutOverride &&constraints={})
As above, in the theme's drag label style.
Definition gui_application.h:1872
bool BeginDisabled()
Controls emitted in between are disabled: drawn dimmed, and they take no input.
Definition gui_application.h:1105
void Toasts()
The toasts, in the current window's bottom-right corner over what's built before; call it last in the...
bool BeginArea(LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID, in the theme's area style.
Definition gui_application.h:863
bool BeginTooltip()
As above, on the control just drawn.
Definition gui_application.h:811
int MessageDialog(const MessageDialogDesc &desc, StyleRef style, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:665
void ShowContentTooltip(ID id, const GUIContent &content)
The content's tooltip, if it has one, on the control id.
Definition gui_application.h:542
IDManager idManager
Element IDs: static ones (CreateStaticID), call-site ones (AllocateDynamicID) and parent scopes (Push...
Definition gui_application.h:206
bool Checkbox(bool value, std::string_view text, std::function< void(bool)> onToggle, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID, in the theme's checkbox style.
Definition gui_application.h:579
bool TypedField(T &value, StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID and a style for the box.
Definition gui_application.h:1637
bool BeginHorizontal(ID id, StyleRef style, LayoutOverride &&constraints={})
Undecorated flex containers; the Wrap variants wrap onto further lines/columns.
void SelectableText(ID id, const std::span< ContentRun > &runs, StyleRef style, LayoutOverride &&constraints={})
As above, without link handling.
Definition gui_application.h:1912
bool OpenWindow(ID windowLayoutID, std::string_view title, StyleRef styleRef, LayoutOverride &&constraints, ElementFlags flags, int monitorIndex)
Internal: the body of BeginWindow; call BeginWindow.
Definition gui_application.h:2102
void EndDockingContainer()
Closes BeginDockingContainer.
void Field(ID id, std::unordered_map< std::string, V > &items, StyleRef style, LayoutOverride &&constraints={})
Key-value list over an unordered_map.
Definition gui_application.h:1733
bool DestructiveMenuItem(const GUIContent &content, std::function< void()> onClick, StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
Without a shortcut, with the call site as the ID, in style.
Definition gui_application.h:731
bool Field(ID id, bool &value, std::string_view text, LayoutOverride &&constraints={})
As above, in the theme's toggle style.
Definition gui_application.h:1440
bool BeginReorderableGroup(ID id, ReorderDirection direction, std::function< void(int fromIndex, int toIndex)> onReorder, StyleRef style, LayoutOverride &&constraints={})
As above, not wrapped.
Definition gui_application.h:979
bool Slider(int &value, int minVal, int maxVal, StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:1857
OnGuiFunc onGui
Runs a frame from inside the OS's modal resize loop, so windows repaint while resized.
Definition gui_application.h:259
bool BeginVertical(ID id, LayoutOverride &&constraints={})
As above, in the theme's plain style.
Definition gui_application.h:912
bool applicationQuit
Set to true to end Run (UpdateFrame then returns false).
Definition gui_application.h:267
void PersistValue(std::string key, std::string &value)
As above, for a string.
bool Field(ID id, T &value, LayoutOverride &&constraints={})
As above, updating continuously.
Definition gui_application.h:1558
tachyon::ElementRef MenuItemRow(ID id, tachyon::EventHandler handler, StyleRef rowStyle, bool reserveIcon, IconID icon, std::string_view text, std::string_view trailing, StyleRef trailingStyle, LayoutOverride &&constraints, bool destructive=false)
A menu row: an icon slot, the label and a trailing text (a shortcut or a submenu arrow).
void RestoreWindowPlace(ID windowID, const SavedDocumentWindow &saved)
Puts a window where saved was when it's next declared, as PersistWindow does (on its monitor,...
bool GridViewItem(const GUIContent &content, StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
Without rename, with the call site as the ID, in style.
Definition gui_application.h:1151
void SetReducedMotion(std::optional< bool > reduced)
Reduced motion: changes of state show at once instead of blending.
bool BeginSelected()
Items emitted in between render as selected.
Definition gui_application.h:1101
void SetResourceRoot(std::string_view root)
The folder the resources load from: compiled shaders, default fonts and relative theme paths.
Definition gui_application.h:394
bool BeginStatusBar(ID id, StyleRef style, LayoutOverride &&constraints={})
A strip of short status texts, usually along a window's bottom edge.
ITextSystem * textSystem
Shapes, measures and edits text. Created by Initialize.
Definition gui_application.h:198
bool MenuItem(CommandID command)
Menu item for a command: icon, label, shortcut and callback come from the command.
void SetTooltip(ID targetID, IconID icon, std::string_view text, std::string_view shortcut)
As above, with an icon.
bool BeginTable(VirtualTableColumn(&columns)[N], TableState &state, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, for a C array of columns, with the call site as the ID, in the theme's table style.
Definition gui_application.h:1221
bool Toggle(bool value, const GUIContent &content, std::function< void(bool)> onToggle, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID, in the theme's toggle style.
Definition gui_application.h:613
bool BeginGridView(ID id, int *selectedIndex, StyleRef style, MultiSelectState *multiSelect=nullptr, ItemDragDropConfig *dragDrop=nullptr, LayoutOverride &&constraints={})
Opens a grid view of GridViewItems.
GUIRenderer * guiRenderer
The graphics backend's renderer.
Definition gui_application.h:202
bool Switch(ID id, bool value, std::string_view text, std::function< void(bool)> onToggle, LayoutOverride &&constraints={})
As above, in the theme's switch style.
Definition gui_application.h:592
ToastID ShowToast(ToastDesc desc)
Shows a toast in the corner of the window that builds Toasts.
bool Breadcrumb(ID id, std::span< const std::string > segments, std::function< void(int)> onSelect, StyleRef style, LayoutOverride &&constraints={})
A path such as Graphs > Terrain material: segments separated by chevrons, the last one current.
auto Row(A &&... a)
Definition gui_application.h:2218
void SetTooltip(ID targetID, const PropertyHelp &help)
A property's help on targetID, in a larger tooltip: its title, description and footer.
bool BeginArea(ID id, StyleRef style, LayoutOverride &&constraints={})
A container drawn in style, for grouping content; it scrolls when bounded and its style has overflow:...
bool BeginVerticalWrap(LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID, in the theme's plain style.
Definition gui_application.h:927
void Field(std::unordered_map< std::string, V > &items, StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:1776
bool CommandButton(CommandID command, LayoutOverride &&constraints={})
As above, in the theme's button style.
Definition gui_application.h:570
void EndTab()
Closes BeginTab.
void SetErrorTooltip(ID targetID, std::string_view message)
Why a value isn't accepted, in a tooltip on the popup surface with an error border (and arrow).
void Label(std::string_view text, std::string_view caption, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID, in the theme's top label style.
Definition gui_application.h:1889
void EndMenu()
Closes BeginMenu; called whether or not it returned true.
bool TakeEscapeFor(ID popupWindowID, ID triggerID)
While building a popup's trigger: true, and the key taken, when Escape was pressed this frame with th...
float frameBuildTime
CPU work per frame, excluding the vsync stall in present.
Definition gui_application.h:273
auto Window(A &&... a)
Definition gui_application.h:2201
const Result< void > & ThemeReloadResult() const
How the last reload went; on an error the previous theme stays.
Definition gui_application.h:387
static constexpr std::string_view TypeTag()
A number's type as a short tag: f32, f64, i8 ... u64 (empty for other types).
Definition gui_application.h:1597
bool DestructiveMenuItem(ID id, const GUIContent &content, std::function< void()> onClick, StyleRef style, LayoutOverride &&constraints={})
Without a shortcut, in style.
Definition gui_application.h:727
bool DestructiveMenuItem(ID id, const GUIContent &content, std::string_view shortcut, std::function< void()> onClick, LayoutOverride &&constraints={})
As above, in the theme's item style.
Definition gui_application.h:721
auto Menu(A &&... a)
Definition gui_application.h:2204
bool BeginToggleGroup(LayoutOverride &&constraints={})
The same for Toggles and Field(bool).
void AddBox(ID id, StyleRef styleRef, IconID iconID, std::string_view text)
As above, sized to its content.
Definition gui_application.h:2308
void Label(std::string_view text, std::string_view caption, StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:1887
void Field(std::vector< std::pair< std::string, V > > &items, StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:1725
tachyon::EventHandler MakeToggleHandler(bool &toggle)
A handler that flips toggle on click.
void InjectText(ID windowID, std::string_view utf8)
Typed text, one character event per codepoint.
void OpenContextMenu(ID targetID, int2 screenPos)
Opens targetID's context menu at a screen point, e.g.
void Image(ImageIndex image, StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:1929
bool BeginArea(StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:861
bool BeginGhostWindow(ID windowLayoutID, int2 position, StyleRef styleRef)
Sized to its content.
Definition gui_application.h:1977
bool BeginVertical(ID id, StyleRef style, LayoutOverride &&constraints={})
A vertical container.
bool SliderField(int &value, int minVal, int maxVal, std::string_view text, StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:1846
bool GridViewItem(ID id, const GUIContent &content, StyleRef style, LayoutOverride &&constraints={})
Without rename, in style.
Definition gui_application.h:1148
void CloseDockedPanel(DockingLayout &layout, DockNode &leaf, int tabIndex)
Closes the panel at tabIndex of a docked leaf, as the tab's Close action does.
bool Checkbox(bool &value, std::string_view text={}, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID, in the theme's checkbox style.
Definition gui_application.h:587
bool Dropdown(int &selected, std::span< const std::string_view > options, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID, in the theme's dropdown style.
Definition gui_application.h:647
bool IsReducedMotion() const
Whether changes of state show at once now.
Definition gui_application.h:467
auto Vertical(A &&... a)
Definition gui_application.h:2210
bool BeginTable(VirtualTableColumn *columns, size_t columnCount, TableState &state, StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:1207
bool SearchField(ID id, std::string &value, IconID icon, TextEditBehavior textEditBehavior, StyleRef style, LayoutOverride &&constraints={})
A Field with a leading icon inside its border; style is the border's.
Definition gui_application.h:1463
void Label(std::string_view text, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As the first, with the call site as the ID, in the theme's label style.
Definition gui_application.h:1895
bool BeginReorderableGroup(ID id, ReorderDirection direction, bool isWrapped, std::function< void(int fromIndex, int toIndex)> onReorder, LayoutOverride &&constraints={})
As above, in the theme's style for the direction and wrapping.
Definition gui_application.h:985
bool ColorField(tachyon::color4b &value, StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:1805
bool Checkbox(bool &value, std::string_view text, StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:585
bool BeginGhostWindow(ID windowLayoutID, int2 position)
A ghost window: caption-less and transparent, e.g.
Definition gui_application.h:1950
bool SearchField(ID id, std::string &value, IconID icon, TextEditBehavior textEditBehavior=TextEditBehavior::ContinuousUpdate, LayoutOverride &&constraints={})
As above, in the theme's search style.
Definition gui_application.h:1465
void EndListView()
Closes BeginListView.
void Text(ID id, std::string_view text, LayoutOverride &&constraints={})
As above, in the theme's text style.
Definition gui_application.h:1900
bool Dropdown(ID id, int &selected, std::initializer_list< std::string_view > options, LayoutOverride &&constraints={})
With the options written in place: Dropdown(quality, { "Low", "Medium", "High" }).
Definition gui_application.h:649
bool BeginVertical(LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID, in the theme's plain style.
Definition gui_application.h:916
bool BeginCursorGhostWindow(ID windowLayoutID, int2 cursorPos, int2 size, StyleRef styleRef)
As above, with a size and style.
Definition gui_application.h:2002
bool Checkbox(ID id, bool &value, std::string_view text={}, LayoutOverride &&constraints={})
As above, in the theme's checkbox style.
Definition gui_application.h:583
bool BeginWindow(ID windowLayoutID, ElementFlags flags=ElementFlags::WindowUserControlled|ElementFlags::WindowIsCentered, int monitorIndex=-1)
As the full BeginWindow below, without a title, in the theme's window style.
Definition gui_application.h:2066
bool DestructiveMenuItem(const GUIContent &content, std::string_view shortcut, std::function< void()> onClick, StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:723
void Image(ID id, ImageIndex image, uint2 sourceSize, LayoutOverride &&constraints={})
As above, in the theme's image style.
Definition gui_application.h:1937
void InjectMouseScroll(ID windowID, int2 pos, float2 offset, KeyModifier mods=KeyModifier::None)
A wheel scroll by offset at pos.
bool BeginCached(ID id, uint64_t signature=0, LayoutOverride &&constraints={})
As above, in the theme's area style.
Definition gui_application.h:875
bool BeginCached(ID id, StyleRef style, uint64_t signature=0, LayoutOverride &&constraints={})
A container (like BeginArea) whose drawing is kept: while nothing changed it returns false,...
void MenuSeparator()
Divider inside a menu or context menu.
bool BeginWindow(ID windowLayoutID, std::string_view title, LayoutOverride &&constraints, ElementFlags flags=ElementFlags::WindowUserControlled|ElementFlags::WindowIsCentered, int monitorIndex=-1)
As the full BeginWindow below, in the theme's window style.
Definition gui_application.h:2059
auto Area(A &&... a)
Definition gui_application.h:2213
bool BeginHorizontalWrap(LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID, in the theme's plain style.
Definition gui_application.h:905
bool BeginGridView(ID id, int *selectedIndex=nullptr, MultiSelectState *multiSelect=nullptr, ItemDragDropConfig *dragDrop=nullptr, LayoutOverride &&constraints={})
As above, in the theme's grid style.
Definition gui_application.h:1126
std::unique_ptr< OSWindowManager > windowManager
The OS windows and their render contexts. Created by Initialize.
Definition gui_application.h:192
void Invalidate(ID id)
Rebuilds id's cached scope, and those around it, next frame. Safe from event handlers.
bool BeginGhostWindow(ID windowLayoutID, int2 position, int2 size)
As above, in the theme's ghost window style.
Definition gui_application.h:1971
bool AutocompleteField(ID id, std::string &value, std::span< const std::string_view > suggestions, LayoutOverride &&constraints={})
As above, in the theme's textbox style.
Definition gui_application.h:1478
bool Toggle(bool value, const GUIContent &content, std::function< void(bool)> onToggle, StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:611
void SetTooltip(const PropertyHelp &help)
As above, for the last control.
Definition gui_application.h:795
void PersistValue(std::string key, int &value)
As above, for an int.
DockLeafResult FindDockLeafAtScreenPos(tachyon::int2 screenPos)
Dock leaf whose tab bar contains screenPos, plus its owning layout (needed by TransferPanel for cross...
bool BeginWindow(ID windowLayoutID, LayoutOverride &&constraints, ElementFlags flags=ElementFlags::WindowUserControlled|ElementFlags::WindowIsCentered, int monitorIndex=-1)
As the full BeginWindow below, without a title, in the theme's window style.
Definition gui_application.h:2078
void Banner(ID id, Severity severity, const GUIContent &message, std::span< const BannerAction > actions={}, LayoutOverride &&constraints={})
A banner across the top of a panel: the message (message.icon, else the severity's) on the severity's...
void PersistDocking(std::string key, DockingLayout &layout)
Keeps the layout's dock tree; panels are matched by type, else by title.
void Label(std::string_view text, StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As the first, with the call site as the ID.
Definition gui_application.h:1893
bool BeginCursorGhostWindow(ID windowLayoutID, int2 cursorPos, int2 size)
As above, with a size.
Definition gui_application.h:2007
tachyon::ElementRef RegisterControl(tachyon::Element &&element, LayoutOverride &&constraints)
As RegisterElement, for a control: it joins the Tab order and needs a valid ID.
void SetFileDropHandler(std::function< void(const FileDrop &)> handler)
Gets the drops no element took (none returned true to EventType::FileDrop): the application's own,...
Definition gui_application.h:1098
bool BeginReorderableItem(ID id, StyleRef style, LayoutOverride &&constraints={})
One draggable item of a reorderable group; any content goes inside.
GUIApplicationInitializeOptions InitializeOptions
See GUIApplicationInitializeOptions.
Definition gui_application.h:367
auto MenuBar(A &&... a)
Definition gui_application.h:2205
bool Tab(ID id, const GUIContent &content, LayoutOverride &&constraints={})
As above, in the theme's tab style.
Definition gui_application.h:1397
bool IsRenaming() const
Whether an inline rename editor (a grid item's, a tree row's) is open; an app that sorts by name re-s...
Definition gui_application.h:1156
bool Field(T &value, TextEditBehavior textEditBehavior, StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As the first, with the call site as the ID and the default config.
Definition gui_application.h:1579
bool MenuItem(ID id, const GUIContent &content, std::function< void()> onClick=nullptr, LayoutOverride &&constraints={})
As above, without a shortcut, in the theme's item style.
Definition gui_application.h:702
void EndButtonGroup()
Closes BeginButtonGroup.
ID FileDragTargetID() const
The element that takes that drag where it is now: the first from the one under the pointer up whose h...
Definition gui_application.h:1095
bool BeginListView(ID id, int *selectedIndex, int itemCount, ItemDragDropConfig *dragDrop, LayoutOverride &&constraints={})
As above, with drag and drop, in the theme's list style.
Definition gui_application.h:1039
void VirtualGridView(GridViewVirtualState &vstate, int itemCount, int2 cellSize, const std::function< void(int index, ID itemID)> &generateItem, int *selectedIndex=nullptr, MultiSelectState *multiSelect=nullptr, ItemDragDropConfig *dragDrop=nullptr, StyleRef scrollStyle={}, StyleRef rowStyle={}, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:1172
void EndToggleGroup()
Closes BeginToggleGroup.
void PresentFrame()
See UpdateFrame.
bool BeginReorderableItem(ID id, LayoutOverride &&constraints={})
As above, in the theme's item style.
Definition gui_application.h:1012
virtual void OnGUI()=0
Builds the UI; called each frame.
void Text(std::string_view text, StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:1902
bool BeginTitleBar(ID id, LayoutOverride &&constraints={})
As above, in the theme's title bar style.
Definition gui_application.h:763
bool Field(T &value, TextEditBehavior textEditBehavior, NumericFieldConfig< ComponentT > config, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As the first, with the call site as the ID, in the theme's number style.
Definition gui_application.h:1582
auto LabelGroup(A &&... a)
Definition gui_application.h:2214
bool BeginListView(int *selectedIndex, int itemCount, StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, without drag and drop, with the call site as the ID, in style.
Definition gui_application.h:1045
bool BeginHorizontalWrap(StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:903
std::string SaveUIState() const
The named state as JSON text.
void PersistDocuments(std::string key, std::function< std::vector< DocumentWindowRef >()> windows)
Keeps the documents of each main window that windows lists when the state is saved: their names,...
TabChainManager tabChainManager
The Tab-key focus order, rebuilt each frame.
Definition gui_application.h:213
void EndTable()
Builds the recorded rows as a VirtualTable.
int MessageDialog(ID id, const MessageDialogDesc &desc)
As above, in the theme's message box style.
Definition gui_application.h:663
bool ColorField(ID id, tachyon::color4b &value, LayoutOverride &&constraints={})
As above, in the theme's color field style.
Definition gui_application.h:1803
bool Slider(int &value, int minVal, int maxVal, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID, in the theme's slider style.
Definition gui_application.h:1859
bool Breadcrumb(std::span< const std::string > segments, std::function< void(int)> onSelect, StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID, in style.
Definition gui_application.h:1292
auto ButtonGroup(A &&... a)
Definition gui_application.h:2215
void Field(ID id, std::unordered_map< std::string, V > &items, LayoutOverride &&constraints={})
As above, in the theme's collection style.
Definition gui_application.h:1773
auto Disabled(A &&... a)
Definition gui_application.h:2227
void VirtualTable(ID id, TableState &state, std::span< VirtualTableColumn > columns, int totalRowCount, CssPx rowHeight=0, StyleRef style={}, LayoutOverride &&constraints={})
Virtual-scrolled table: emits only the visible rows, under one ranged ID.
void StatusText(std::string_view text, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID, in the theme's status text style.
Definition gui_application.h:1318
bool DestructiveMenuItem(ID id, const GUIContent &content, std::string_view shortcut, std::function< void()> onClick, StyleRef style, LayoutOverride &&constraints={})
An item that destroys something (Delete, Discard), in the error color.
bool CloseRequested(ID windowID)
Whether the user asked to close a window flagged WindowConfirmClose (its close button,...
Result< void > InitializeStyles()
Loads the current theme at the current font scale; an error when it can't be opened.
TooltipManager tooltipManager
When a tooltip shows (delaySeconds) and for which element.
Definition gui_application.h:218
void PersistToolbars(std::string key, std::span< std::vector< ToolbarItem >, kToolbarSideCount > sides)
Keeps each side's toolbar items, by debugName.
bool MenuItem(const GUIContent &content, std::string_view shortcut, std::function< void()> onClick, StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
With a shortcut, the call site as the ID and style.
Definition gui_application.h:710
void PersistWindow(std::string key, ID windowID)
Keeps the window's position, size and mode.
bool BeginContextMenu(ID targetID)
Context menu: opens at the pointer on a right-click on the target element, or below it on Shift+F10 o...
bool AutocompleteField(std::string &value, std::span< const std::string_view > suggestions, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID, in the theme's textbox style.
Definition gui_application.h:1482
void CloseWindow()
Internal: the body of EndWindow for an open window; call EndWindow.
Definition gui_application.h:2239
bool SliderField(float &value, float minVal, float maxVal, std::string_view text, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID, in the theme's slider field style.
Definition gui_application.h:1836
void AddBox(ID id, int2 size, StyleRef styleRef, TextID textID=TextID::Invalid)
A plain box of a fixed size in pixels, in a style; textID is optional.
Definition gui_application.h:2253
void DragLabel(std::string_view text, StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:1874
virtual void OnStylesReloaded()
Called after every successful theme/font reload (and by subclasses at startup) to re-register styles/...
Definition gui_application.h:381
bool GradientField(tachyon::Gradient &value, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID, in the theme's gradient swatch style.
Definition gui_application.h:1817
void EndHorizontal()
Closes BeginHorizontal.
bool Button(ID id, const GUIContent &content, std::function< void()> onClick, LayoutOverride &&constraints={})
As above, in the theme's button style.
Definition gui_application.h:561
std::unique_ptr< IClipboard > clipboard
from SetClipboard
Definition gui_application.h:195
void SelectableText(ID id, const std::span< ContentRun > &runs, LayoutOverride &&constraints={})
As above, in the theme's text style.
Definition gui_application.h:1915
bool Field(ID id, std::string &value, TextEditBehavior textEditBehavior, LayoutOverride &&constraints={})
As the first, in the theme's text box style.
Definition gui_application.h:1454
auto GridView(A &&... a)
Definition gui_application.h:2220
void Label(ID id, std::string_view text, std::string_view caption, LayoutOverride &&constraints={})
As above, in the theme's top label style.
Definition gui_application.h:1885
bool IsThemeCrossfading() const
True while a theme switch is crossfading (the old look fading out over the new).
Definition gui_application.h:465
ToastDesc * FindToast(ToastID toast)
A shown toast's description, to change (its progress, its body); null once it's gone.
bool ListItem(const GUIContent &content, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:1058
bool ColorField(ID id, tachyon::color4f &value, bool allowHDR=false, LayoutOverride &&constraints={})
As above, in the theme's color field style.
Definition gui_application.h:1795
void AddBox(ID id, int2 size, StyleRef styleRef, IconID iconID, std::string_view text)
As above, with an icon and text.
Definition gui_application.h:2291
bool GradientField(ID id, tachyon::Gradient &value, StyleRef style, LayoutOverride &&constraints={})
A gradient swatch that opens a gradient editor; true when the gradient changed.
bool BeginReorderableGroup(ReorderDirection direction, bool isWrapped, std::function< void(int fromIndex, int toIndex)> onReorder, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID, in the theme's style for the direction and wrapping.
Definition gui_application.h:991
bool ListItem(const GUIContent &content, StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID, in style.
Definition gui_application.h:1060
bool Toggle(bool &value, const GUIContent &content, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID, in the theme's toggle style.
Definition gui_application.h:621
bool Field(ID id, T &value, TextEditBehavior textEditBehavior, StyleRef style, NumericFieldConfig< ComponentT > config={}, LayoutOverride &&constraints={})
A number field; for a vector type (TypeDimensions), a field per component, each after a colored axis ...
Definition gui_application.h:1491
bool BeginReorderableGroup(ID id, ReorderDirection direction, bool isWrapped, std::function< void(int fromIndex, int toIndex)> onReorder, StyleRef style, LayoutOverride &&constraints={}, std::function< void(int, tachyon::int2)> onDragOut=nullptr, std::function< void(int, tachyon::int2)> dragVisualizer=nullptr)
A container of BeginReorderableItem scopes the user reorders by dragging.
void NodeText(std::string_view text)
Text property body aligned by the row's sockets: left => left, right => right, both => centre.
void EndSelected()
Closes BeginSelected.
Definition gui_application.h:1103
bool BeginIndeterminate()
Value fields emitted in between show a dash for mixed values (e.g.
Definition gui_application.h:546
int2 CursorGhostOffset() const
Where a ghost sits from the cursor, clear of the OS cursor: 14 px for a 32 px cursor,...
Definition gui_application.h:1991
void EndRow()
Ends the row.
bool MenuItemImpl(ID id, const GUIContent &content, std::string_view shortcut, std::function< void()> onClick, StyleRef style, bool destructive, LayoutOverride &&constraints)
SearchField, also giving the ID of its text field (to focus it).
bool BeginListView(int *selectedIndex, int itemCount, ItemDragDropConfig *dragDrop, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:1041
bool BeginReorderableItem(LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID, in the theme's item style.
Definition gui_application.h:1016
bool RestoreDocumentLayout(Document &document, const SavedDocument &saved)
Lays a document's panels out as saved: panels by type, else title; ones the saved tree doesn't have g...
bool BeginListView(int *selectedIndex, int itemCount, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:1037
bool BeginGridView(int *selectedIndex, MultiSelectState *multiSelect=nullptr, ItemDragDropConfig *dragDrop=nullptr, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID, in the theme's grid style.
Definition gui_application.h:1130
void EndCached()
Closes BeginCached; called whether or not it returned true.
bool Tab(const GUIContent &content, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:1399
bool BeginMenuBar(StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID, in style.
Definition gui_application.h:745
bool BeginStatusBar(StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID, in style.
Definition gui_application.h:1308
void DisableAllPanels(DockingLayout &layout)
Panel lifecycle.
Result< void > ReadWindowPixels(ID windowID, std::span< uint8_t > bgra)
The last rendered frame of a render-to-image window: BGRA8, tightly packed rows, bgra holding width x...
void SetGraphicsBackend(std::unique_ptr< GraphicsContext > backend)
The graphics backend Initialize uses; without one it creates a vulkan::VulkanGraphicsContext.
Definition gui_application.h:433
void Image(ID id, ImageIndex image, StyleRef style, LayoutOverride &&constraints={})
Draws image (from graphicsContext->RegisterImage) stretched over the element's box.
bool MenuItem(ID id, const GUIContent &content, std::string_view shortcut, std::function< void()> onClick, LayoutOverride &&constraints={})
With a shortcut; onClick is required so MenuItem(text, nullptr) stays unambiguous.
Definition gui_application.h:706
bool Field(T &value, StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As the first, with the call site as the ID, updating continuously, with the default config.
Definition gui_application.h:1570
auto Toolbar(A &&... a)
Definition gui_application.h:2222
bool Field(ID id, std::string &value, LayoutOverride &&constraints={})
As the first, updating continuously, in the theme's text box style.
Definition gui_application.h:1458
bool Switch(ID id, bool &value, std::string_view text={}, LayoutOverride &&constraints={})
As above, in the theme's switch style.
Definition gui_application.h:600
void InjectMouseButton(ID windowID, int2 pos, MouseButtons button, bool down, KeyModifier mods=KeyModifier::None)
A button press (down) or release at pos.
void VerticalScrollbar(ID containerID)
As above, with an ID derived from the container's.
Definition gui_application.h:950
bool Toggle(bool &value, const GUIContent &content, StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:619
bool BeginMenu(std::string_view text, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID, in the theme's menu styles.
Definition gui_application.h:636
void EndToolbar()
Closes BeginToolbar.
bool Field(std::string &value, StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:1452
void VirtualTreeView(ID id, std::vector< TreeViewRow > &rows, std::vector< int > &visibleIdx, TableState &state, StyleRef style={}, LayoutOverride &&constraints={}, std::string_view header={})
Single-column virtualized tree view (a VirtualTable with one TreeCell column).
virtual void Cleanup()
Releases what Initialize created, including the backends set before it.
bool BeginContextMenu()
As above, on the control just drawn.
Definition gui_application.h:821
void Image(ImageIndex image, uint2 sourceSize, StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:1939
tachyon::ElementRef RegisterControl(tachyon::Element &&element, std::string_view text, LayoutOverride &&constraints)
As above, with text registered as its text.
bool DestructiveMenuItem(const GUIContent &content, std::function< void()> onClick, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
Without a shortcut, with the call site as the ID, in the theme's item style.
Definition gui_application.h:733
bool GridViewItem(ID id, const GUIContent &content, LayoutOverride &&constraints)
As above, without rename.
Definition gui_application.h:1142
tachyon::ElementRef RegisterControl(tachyon::Element &&element, std::function< TextID(tachyon::Element &element)> createTextID, LayoutOverride &&constraints)
As above; createTextID registers the text, given the element with its current state.
bool BeginCursorGhostWindow(ID windowLayoutID, int2 cursorPos)
A ghost window at the cursor, offset by CursorGhostOffset; 28 x 28 CSS px.
Definition gui_application.h:1997
bool BeginTable(VirtualTableColumn(&columns)[N], TableState &state, StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, for a C array of columns, with the call site as the ID.
Definition gui_application.h:1216
bool Checkbox(ID id, bool value, std::string_view text, std::function< void(bool)> onToggle, LayoutOverride &&constraints={})
As above, in the theme's checkbox style.
Definition gui_application.h:575
void MenuHeader(std::string_view text)
A section's name between items, e.g. "View", lined up with the labels.
void SetStyleFiles(std::span< const std::string_view > files)
The CSS rule files loaded after the palette, in order; relative paths are next to the palette file.
void EndVertical()
Closes BeginVertical.
void StatusText(ID id, std::string_view text, LayoutOverride &&constraints={})
As above, in the theme's status text style.
Definition gui_application.h:1314
auto Indeterminate(A &&... a)
Definition gui_application.h:2230
void VirtualGridView(ID id, GridViewVirtualState &vstate, int itemCount, int2 cellSize, const std::function< void(int index, ID itemID)> &generateItem, int *selectedIndex=nullptr, MultiSelectState *multiSelect=nullptr, ItemDragDropConfig *dragDrop=nullptr, StyleRef scrollStyle={}, StyleRef rowStyle={}, LayoutOverride &&constraints={})
generateItem(index, itemID) must emit exactly one cell, typically GridViewItem(itemID,...
bool BeginVerticalWrap(StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:925
void SetTooltip(ID targetID, std::string_view text)
A text tooltip on targetID, shown when the pointer rests on it.
bool BeginRow()
Starts a row; its Cells fill the columns in order.
bool BeginVertical(StyleRef style, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:914
void AddBox(int2 size, StyleRef styleRef, TextID textID=TextID::Invalid, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:2268
std::unique_ptr< InputManager > inputManager
Routes input events to the elements; also holds global handlers. Created by Initialize.
Definition gui_application.h:188
Definition gui_renderer.h:43
Owns the per-frame state objects and runs their BeginFrame / EndFrame in order.
Definition gui_state_manager.h:65
ElementDataStore & GetElementDataStore()
Definition gui_state_manager.h:108
InteractionState & Interaction()
Definition gui_state_manager.h:87
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
ConstructionScopes & Construction()
Definition gui_state_manager.h:93
LabelBinding & Labels()
Definition gui_state_manager.h:99
The library's styles, icons and theme metrics, the defaults the controls draw with.
Definition gui_theme.h:46
StyleRef emptyVertWrapStyleRef
vertical flex, wrap
Definition gui_theme.h:55
StyleRef imageStyleRef
default box for the Image() element
Definition gui_theme.h:82
StyleRef collectionAreaStyleRef
card-like well behind the list & dictionary Field() helpers
Definition gui_theme.h:318
StyleRef collectionRowStyleRef
list field: a row
Definition gui_theme.h:323
StyleRef tableStyleRef
Table: the table.
Definition gui_theme.h:225
StyleRef titleBarStyleRef
a window's own title bar (BeginTitleBar)
Definition gui_theme.h:344
StyleRef checkboxStyleRef
Checkbox: the control.
Definition gui_theme.h:166
StyleRef gradientSwatchStyleRef
GradientField: the swatch.
Definition gui_theme.h:194
StyleRef vectorComponentStyleRef
a vector component's field
Definition gui_theme.h:282
StyleRef staticTextStyleRef
plain non-interactive text
Definition gui_theme.h:81
StyleRef collectionIndexStyleRef
list field: a row's index
Definition gui_theme.h:324
StyleRef switchStyleRef
Switch: the control (track + label).
Definition gui_theme.h:117
StyleRef gridViewStyleRef
BeginGridView's default.
Definition gui_theme.h:400
StyleRef vertReorderableGroupStyleRef
Definition gui_theme.h:389
StyleRef typedFieldTypeStyleRef
TypedField: the type tag.
Definition gui_theme.h:321
StyleRef sliderFieldTrackStyleRef
SliderField: the track holding the parts below.
Definition gui_theme.h:107
StyleRef vertReorderableGroupWrapStyleRef
Definition gui_theme.h:391
StyleRef dockContainerStyleRef
a docking container
Definition gui_theme.h:482
StyleRef windowStyleRef
BeginWindow's default.
Definition gui_theme.h:307
StyleRef groupLabelTopStyleRef
Label with a caption: the container.
Definition gui_theme.h:334
StyleRef ghostIconStyleRef
the icon in a drag ghost
Definition gui_theme.h:79
StyleRef emptyHorzStyleRef
horizontal flex, no wrap; groups elements without drawing anything
Definition gui_theme.h:52
StyleRef collectionEntryStyleRef
dictionary: a row
Definition gui_theme.h:328
StyleRef menuStyleRef
a menu's window
Definition gui_theme.h:339
StyleRef emptyHorzWrapStyleRef
horizontal flex, wrap
Definition gui_theme.h:53
StyleRef collectionAddEntryStyleRef
dictionary: Add entry
Definition gui_theme.h:327
IconID tabCloseIcon
a tab's close button
Definition gui_theme.h:504
StyleRef collectionValueStyleRef
dictionary: a value
Definition gui_theme.h:329
StyleRef colorFieldStyleRef
ColorField: swatch, hex and alpha in a row.
Definition gui_theme.h:132
StyleRef listItemStyleRef
ListItem's default.
Definition gui_theme.h:394
StyleRef menuItemRowStyleRef
interactive row: icon slot + label + trailing shortcut/arrow
Definition gui_theme.h:354
StyleRef listViewStyleRef
BeginListView's default.
Definition gui_theme.h:393
const ControlStyles * controls
the bundle in use
Definition gui_theme.h:50
StyleRef collectionListStyleRef
list field: the rows
Definition gui_theme.h:322
StyleRef commandSearchStyleRef
Definition gui_theme.h:288
StyleRef statusBarStyleRef
BeginStatusBar's default.
Definition gui_theme.h:283
StyleRef typedFieldStyleRef
TypedField: the box.
Definition gui_theme.h:319
StyleRef menuBarStyleRef
horizontal strip at the top of the main window
Definition gui_theme.h:342
StyleRef tabStyleRef
the "+N" button after the tabs that fit
Definition gui_theme.h:430
StyleRef fieldElementGroupStyleRef
Built in code: an undecorated, growing, wrapping flex row (a multi-value drag field).
Definition gui_theme.h:57
StyleRef breadcrumbStyleRef
the breadcrumb path bar
Definition gui_theme.h:274
StyleRef ghostWindowStyleRef
BeginGhostWindow's default: the window following a drag.
Definition gui_theme.h:78
StyleRef collectionAddStyleRef
list field: Add item
Definition gui_theme.h:326
StyleRef horzReorderableGroupStyleRef
Definition gui_theme.h:388
StyleRef messageBoxStyleRef
MessageDialog: the window.
Definition gui_theme.h:150
StyleRef typedFieldInputStyleRef
TypedField: the value.
Definition gui_theme.h:320
tachyon::VisualColorStyleIndex nanTextColor
a number field's NaN
Definition gui_theme.h:540
StyleRef labelStyleRef
Label()'s default.
Definition gui_theme.h:83
StyleRef searchTextboxStyleRef
Definition gui_theme.h:416
StyleRef reorderableItemStyleRef
Definition gui_theme.h:387
StyleRef collectionRemoveStyleRef
list / dictionary: remove
Definition gui_theme.h:325
StyleRef emptyVertStyleRef
vertical flex, no wrap
Definition gui_theme.h:54
StyleRef sliderStyleRef
Slider: a groove and knob, no value text.
Definition gui_theme.h:113
StyleRef statusTextStyleRef
text in the status bar
Definition gui_theme.h:284
StyleRef axisLabelStyleRefs[4]
vector fields: the label of each component (X, Y, Z, W)
Definition gui_theme.h:278
StyleRef dragLabelStyleRef
DragLabel()'s default.
Definition gui_theme.h:86
StyleRef collectionStyleRef
BeginArea / BeginCached default.
Definition gui_theme.h:382
StyleRef horzReorderableGroupWrapStyleRef
Definition gui_theme.h:390
The atlas that the colors of color styles are baked into: pages of 2D textures, one row per gradient,...
Definition gui_gradient_manager.h:64
A graphics backend: the device, the window contexts that render the GUI's windows,...
Definition gui_graphics_context.h:60
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
bool PopParent()
Pops the last PushParent. Never pops the root; false on underflow or outside a frame.
bool PushParent(ID parent_id)
Makes parent_id the parent: dynamic and ranged IDs created under it inherit its hash.
ID CreateStaticID()
A persistent ID tracked by slot and generation; release it with ReleaseStaticID.
Text and icon registration, measurement, rendering and editing.
Definition gui_text_system.h:178
virtual void SetTextColor(TextID textId, VisualColorStyleIndex color)=0
Draw a registered text in color instead of its style's text color, until it is registered again (call...
TextID RegisterEditableNumber(ID elementId, T &value, TextEditBehavior behavior, StyleRef styleIndex, ElementState state, bool &wasModified, NumericFieldConfig< T > config={})
Registers an editable number, clamped to config's [minVal, maxVal] after an edit.
Definition gui_text_system.h:285
virtual TextID RegisterText(ID elementId, IconID iconId, std::string_view text, StyleRef styleIndex, ElementState state)=0
Registers static text, with an optional icon, for elementId.
Makes and manages the OS windows and delivers their input; GUIApplication::SetWindowBackend sets one,...
Definition gui_window_backend.h:105
An image made by GraphicsContext::CreateImage; the backend defines its contents.
Definition gui_image.h:40
Sends every platform input event to all handlers (e.g.
Definition gui_input_handler_broadcaster.h:18
ID GetHoveredID() const
Definition gui_interaction_state.h:57
bool HasBeenClicked(ID id) const
Definition gui_interaction_state.h:84
ID GetHoveredDisabledID() const
The disabled element under the cursor when nothing is hovered: it takes no input, but shows its toolt...
Definition gui_interaction_state.h:60
void ClearPendingLabel()
Definition gui_label_binding.h:32
State of the open menus (menu bar dropdowns, context menus, submenus) and their mouse and keyboard be...
Definition gui_menu_manager.h:29
A value, or the Error saying why there is none.
Definition gui_result.h:36
Bakes serializable Styles into deduplicated runtime layout/visual styles; a StyleRef holds indices in...
Definition gui_style_manager.h:39
int32_t Px(int32_t cssPx) const noexcept
A size given in code (CSS px) at the UI scale: whole pixels, and a non-zero size stays at least 1.
Definition gui_style_manager.h:77
Tracks the next/prev tab targets around the focused element, rebuilt each frame during construction a...
Definition gui_tab_chain_manager.h:18
void BeginWindow(ID windowID)
Starts collecting windowID's tab targets until EndWindow; only the active window builds a chain.
Definition gui_tab_chain_manager.h:47
void EndWindow()
Ends the window begun by BeginWindow; its chain wraps around.
Definition gui_tab_chain_manager.h:84
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
Tracks in-progress visual state transitions per element ID.
Definition gui_transition_manager.h:43
bool IsReducedMotion() const
Definition gui_transition_manager.h:103
Per-window lists of ElementRefs in addition (render) order, driven during ElementStorage construction...
Definition gui_window_registry.h:33
RegistryResult BeginWindowScope(ID id, const ElementRef &ref)
Registers a window element just added to the ElementStorage and opens its scope: following Adds go to...
Definition gui_window_registry.h:149
RegistryResult Add(const ElementRef &ref)
Adds a non-window element to the innermost window scope's render list.
Definition gui_window_registry.h:178
RegistryResult EndWindowScope()
Closes the innermost window scope; NoActiveWindow when none is open.
Definition gui_window_registry.h:293
void VERIFY(ElementStorageResult result)
Checks the result of an element-storage call (e.g.
MessageIcon
The icon beside a MessageDialog's text.
Definition gui_application.h:104
EventHandler MakeNumericalBoxHandler(GUIStateManager &guiStateManager, T &value, NumericFieldConfig< T > config={})
Numeric field handler: a left click focuses it for typing, and LabelDrag* events from its label drag ...
Definition gui_default_handlers.h:207
MessageButtonKind
How a MessageButton is styled: Primary for the main choice, Danger for a destructive one.
Definition gui_application.h:106
EventHandler ReportingChanges(GUIStateManager &guiStateManager, T *value, EventHandler inner)
Wraps a handler that writes *value: it runs during input, after the control's call returned,...
Definition gui_default_handlers.h:191
EventHandler MakeMultiDimDragHandler(GUIStateManager &guiStateManager, T &value, NumericFieldConfig< typename TypeDimensions< T >::ComponentType > config={})
Applies LabelDrag* events to all components (multi-dimensional Field groups).
Definition gui_default_handlers.h:271
@ Quit
Definition gui_application.h:104
@ Question
Definition gui_application.h:104
@ Primary
Definition gui_application.h:106
@ Secondary
Definition gui_application.h:106
@ Danger
Definition gui_application.h:106
TabBarLayout
How a tab bar lays out tabs that don't fit on one row.
Definition gui_dock_node.h:56
constexpr int kToolbarSideCount
number of ToolbarSide values
Definition controls_toolbar_dock.h:33
ReorderDirection
Main axis of a reorderable group.
Definition gui_reorderable_subsystem.h:18
Severity
How serious a notification is: its icon and color.
Definition gui_notification_types.h:21
uint32_t ToastID
A toast shown by ShowToast; 0 is none.
Definition gui_notification_types.h:41
@ Vertical
Definition gui_reorderable_subsystem.h:18
@ Horizontal
Definition gui_reorderable_subsystem.h:18
void ReportMisuse(LogCategory category, const char *message)
API misuse (an unbalanced Begin/End, a call outside its frame, ...) is reported, not fatal: the calle...
@ Error
Definition gui_logging.h:28
ElementStorageResult
Outcome of an ElementStorage call.
Definition gui_element_storage.h:43
ElementFlags
What an element is and how it behaves, combined with |.
Definition gui_element_flags.h:18
@ DoNotMeasureText
Definition gui_element_flags.h:26
@ WindowNoCaption
Definition gui_element_flags.h:33
@ WindowIsCentered
Definition gui_element_flags.h:34
@ None
Definition gui_element_flags.h:19
@ WindowUserControlled
Definition gui_element_flags.h:32
@ PropagatesDescendantState
Hover/Focused when any descendant is.
Definition gui_element_flags.h:45
@ IsWindow
Definition gui_element_flags.h:28
@ WindowIsTransparent
Definition gui_element_flags.h:35
ImageIndex
Index of an image in the graphics context's image set, as the shaders sample it.
Definition gui_image.h:37
KeyCode
Keys by what the keyboard layout makes them, not by position.
Definition gui_input_enums.h:106
KeyAction
A keyboard event: a key down or up, or a typed character (KeyChar).
Definition gui_input_enums.h:50
std::function< bool(ElementEvent &&input)> EventHandler
Element-level input handler used by the immediate-mode dispatcher; returns true when it consumed the ...
Definition gui_input_handler_func.h:35
KeyModifier
Modifier keys held, combined with |.
Definition gui_input_enums.h:26
MouseButtons
Mouse buttons, combined with |.
Definition gui_input_enums.h:38
@ Help
Definition gui_input_enums.h:288
@ Question
Definition gui_input_enums.h:144
@ None
Definition gui_input_enums.h:27
@ Text
dropped: text, in data
Definition gui_input_enums.h:69
VisualColorStyleIndex
Index into StyleManager's color style pool; Invalid (0) draws nothing (transparent).
Definition gui_style.h:33
TextID
Handle for text registered with the text system (ITextSystem::RegisterText and friends).
Definition gui_style_text.h:13
IconID
Handle for an icon registered with ITextSystem::RegisterIconFromSVG / RegisterIconFromSVGFile.
Definition gui_style_text.h:15
VisualBoxStyleIndex
Index into StyleManager's visual box style pool; Invalid (0) = none.
Definition gui_style_ref.h:17
TextAlign
Alignment of text in its box (CSS: text-align, -tachyon-vertical-text-align).
Definition gui_style_text.h:68
ElementState
Interaction state bits of an element; they pick the Style::states variant it draws with.
Definition gui_style.h:42
@ Fixed
out of flow in overlay space; doesn't scroll with the parent
Definition gui_style.h:219
@ Invalid
Definition gui_style_text.h:13
@ Invalid
Definition gui_style_text.h:15
@ None
Definition gui_style.h:43
TextEditBehavior
Definition gui_text_system.h:99
@ None
Definition gui_text_system.h:100
@ ContinuousUpdate
update the text on every keystroke, not only on commit
Definition gui_text_system.h:101
std::function< void()> OnGuiFunc
Definition gui_base_types.h:14
RequestCloseResult
Outcome of an OSWindowManager close request; negative values are failures.
Definition gui_os_window_manager.h:41
WindowMode
A window's state (IWindowBackend::SetWindowMode). Any window can go fullscreen.
Definition gui_window_backend.h:60
RegistryResult
Outcome of a WindowRegistry call.
Definition gui_window_registry.h:18
WindowHitArea
What a point of a window with a custom title bar (WindowFlags::CustomTitleBar) is to the OS.
Definition gui_window_backend.h:52
AddWindowResult
Outcome of OSWindowManager::GetOrCreateWindow; negative values are failures.
Definition gui_os_window_manager.h:29
@ Closing
close requested (this frame) or already closed
Definition gui_os_window_manager.h:54
Definition gui_logging.h:24
Memory functions a host gives the library, for the allocations that can be routed: Vulkan objects,...
Definition gui_allocation_hooks.h:15
Handle to a registered command, stable for the manager's lifetime.
Definition gui_command_manager.h:32
State of a CommandSearch box; user-owned, keep it alive across frames.
Definition gui_widget_state_types.h:31
bool focusRequested
set by FocusCommandSearch, taken next frame
Definition gui_widget_state_types.h:37
StyleRef textbox
.textbox / .toolbar-textbox
Definition gui_theme.h:30
StyleRef menuTrigger
.menu-trigger / .toolbar-menu-trigger
Definition gui_theme.h:32
StyleRef toggle
.toggle / .toolbar-toggle
Definition gui_theme.h:29
StyleRef number
numeric fields: the textbox in the monospace font
Definition gui_theme.h:31
StyleRef button
.button / .toolbar-button
Definition gui_theme.h:28
A size in CSS px.
Definition gui_units.h:18
Result of FindDockDropTargetAtScreenPos: the drop target and its layout.
Definition gui_docking_types.h:152
Result of FindDockLeafAtScreenPos: the leaf and its layout, both null on a miss.
Definition gui_docking_types.h:146
Docking tree node: a leaf with panel tabs, or a split with two children where splitSize applies to th...
Definition gui_dock_node.h:64
A docking area: the split/tab tree and the panels its leaves refer to by ID.
Definition gui_docking_types.h:125
The documents one main window shows, in tab order, and which one is active.
Definition gui_docking_types.h:201
A document: a level, prefab, material graph, ... with its own panels.
Definition gui_docking_types.h:174
An element's slot in ElementStorage: its depth and index within that depth.
Definition gui_element.h:127
Definition gui_element.h:33
ElementState state
Definition gui_element.h:45
TextID textID
Definition gui_element.h:39
ElementFlags flags
Definition gui_element.h:44
ID id
Definition gui_element.h:34
StyleRef styleRef
Definition gui_element.h:42
A failure: its category and a human-readable message.
Definition gui_result.h:26
Files or text dropped from another application.
Definition gui_input_state.h:70
Enables dragging a floating toolbar back onto a dock side; both fields are required,...
Definition controls_toolbar_dock.h:110
What GUIApplication::Initialize sets up besides the core systems.
Definition gui_application.h:147
bool closeMenusOnWindowMove
open menus close when a window moves or resizes
Definition gui_application.h:151
bool loadStyles
load the theme (InitializeStyles)
Definition gui_application.h:148
std::string_view fallbackFonts
The optional fallback fonts (Noto: other scripts, emoji, symbols), relative to the resource root,...
Definition gui_application.h:154
bool repaintWhileResizing
onGui = OnFrame, unless onGui is already set
Definition gui_application.h:150
bool commandShortcuts
route keys to commandManager's shortcuts
Definition gui_application.h:149
Rolling per-frame timing history in ms, recorded only while profiling is enabled.
Definition gui_application.h:276
float buildMs
Definition gui_application.h:276
float totalMs
Definition gui_application.h:276
Definition gui_application.h:2681
std::span< VirtualTableColumn > columns
Definition gui_application.h:2681
TableState * state
Definition gui_application.h:2681
Tree-view backing state, rebuilt per frame; not part of the API.
Definition gui_application.h:2368
std::vector< TreeViewRow > rows
Definition gui_application.h:2369
std::vector< int > visibleIdx
Definition gui_application.h:2370
TableState tableState
Definition gui_application.h:2371
A page: a stable ID, its name in the tree, and render, which builds its content.
Definition gui_application.h:2350
std::function< void()> render
Builds the page's content while it is selected.
Definition gui_application.h:2356
std::string name
Shown in the page tree.
Definition gui_application.h:2354
tachyon::ID id
Stable across frames.
Definition gui_application.h:2352
What RenderSettingsPanel shows: its pages, the selected one and the tree width.
Definition gui_application.h:2347
CssPx treeWidth
The page tree's width; its sizer changes it.
Definition gui_application.h:2364
tachyon::ID AddPage(tachyon::ID id, std::string_view name, std::function< void()> render)
id must be stable. The first page added is selected initially.
Definition gui_application.h:2375
std::vector< Page > pages
Added with AddPage.
Definition gui_application.h:2360
tachyon::ID selectedID
The page shown; a click in the tree changes it.
Definition gui_application.h:2362
What a control shows: a text, an icon or both, and an optional tooltip.
Definition gui_content.h:22
std::string_view tooltip
shown on hover when not empty
Definition gui_content.h:25
Up to kMaxStops color stops plus an angle and interpolation color space.
Definition gui_style_gradient.h:91
User-owned, persistent state of a virtualized GridView; keep it alive across frames.
Definition gui_tree_grid_types.h:90
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
Drag & drop setup for item-based views (tree, list, grid): items drag a payload and accept drops of t...
Definition gui_widget_state_types.h:55
Per-element overrides of style layout properties.
Definition gui_constraints.h:150
constexpr bool HasFixedWidth() const
Whether an explicit width / height is set; axis 0 = width, 1 = height.
Definition gui_constraints.h:194
LayoutOverride & PositionX(PositionConstraintAxis ax) &
Sets one axis's constraint, or only its PositionType.
Definition gui_constraints.h:292
PositionConstraintAxis x
Definition gui_constraints.h:153
LayoutOverride & NoShrink() &
Shorthands for FlexGrow(0) / FlexShrink(0).
Definition gui_constraints.h:323
LayoutOverride & KeepWithNext(bool v=true) &
Forces a line break after / before this element, or keeps it on the same line as the next one.
Definition gui_constraints.h:312
PositionConstraintAxis y
Position constraints; set with the position builders.
Definition gui_constraints.h:153
static LayoutOverride FixedWidth(CssPx w)
Definition gui_constraints.h:187
static LayoutOverride FixedSize(CssPx w, CssPx h)
Sizes in CSS px (scaled by the UI scale) or in Pixels (as they are); see gui_units....
Definition gui_constraints.h:184
LayoutOverride & Width(CssPx w) &
Size, min and max size, in CSS px (scaled by the UI scale) or Pixels (as they are).
Definition gui_constraints.h:232
LayoutOverride & MinWidth(CssPx w) &
Size, min and max size, in CSS px (scaled by the UI scale) or Pixels (as they are).
Definition gui_constraints.h:236
LayoutOverride & FlexGrow(int16_t v) &
Overrides the style's flex-grow / flex-shrink.
Definition gui_constraints.h:317
LayoutOverride & NoGrow() &
Shorthands for FlexGrow(0) / FlexShrink(0).
Definition gui_constraints.h:322
static LayoutOverride Auto()
No overrides: everything comes from the style.
Definition gui_constraints.h:182
LayoutOverride & Position(int2 p) &
Position builders, in pixels (near = left/top, far = right/bottom).
Definition gui_constraints.h:252
A button of a MessageDialog.
Definition gui_application.h:110
MessageButtonKind kind
its look; see MessageButtonKind
Definition gui_application.h:114
bool alignLeft
the alternative to the main choice ("Don't save")
Definition gui_application.h:115
std::string_view label
A verb that says what happens ("Quit", "Keep mine"), never Yes / No.
Definition gui_application.h:113
What a MessageDialog shows.
Definition gui_application.h:130
MessageIcon icon
beside the text
Definition gui_application.h:131
std::string_view title
a question: "Quit Test?"
Definition gui_application.h:132
bool * dontAskAgain
shows "Don't ask again" when set
Definition gui_application.h:138
int cancelButton
Esc and the close button; -1: the default one.
Definition gui_application.h:136
std::span< const MessageDialogItem > items
affected items, listed in a well
Definition gui_application.h:137
std::string_view message
one or two sentences on what happens
Definition gui_application.h:133
std::span< const MessageButton > buttons
MessageDialog returns an index into these.
Definition gui_application.h:134
std::string_view details
collapsible technical details (mono)
Definition gui_application.h:139
int defaultButton
focused at first; Enter
Definition gui_application.h:135
An affected item, listed in a well: a name, an optional color dot and note, and a checkbox when check...
Definition gui_application.h:121
std::string_view meta
e.g. "12 edits"
Definition gui_application.h:123
std::string_view name
e.g. a file name
Definition gui_application.h:122
color4f color
alpha 0: no dot
Definition gui_application.h:124
bool * checked
shows a checkbox bound to it when set
Definition gui_application.h:125
Selected item IDs of a multi-select view; user-owned, keep it alive across frames.
Definition gui_widget_state_types.h:22
All state of one node-view widget; no global state.
Definition gui_node_view_types.h:215
Drag speed and range of a numeric Field, specialized per value type.
Definition gui_numeric_field_config.h:19
static constexpr PositionConstraintAxis Relative()
In flow, shifted by near (or back by far when near is unset).
Definition gui_constraints.h:94
int16_t near
left/top inset, or anchor offset (pixels)
Definition gui_constraints.h:82
PositionType type
Definition gui_constraints.h:78
A property's help, shown in a larger tooltip (SetTooltip): its name, what it does,...
Definition gui_content.h:43
A main window of documents as SaveUIState kept it (TakeSavedDocuments).
Definition gui_docking_types.h:246
A document as SaveUIState kept it: which one it was, and how its panels were laid out.
Definition gui_docking_types.h:238
A registered style, as StyleManager::Register returns it: indices into the shared style pools,...
Definition gui_style_ref.h:25
User-owned, persistent state of one table: column widths, selection, sort, options.
Definition gui_table_types.h:145
What a toast says (ShowToast). Change it later through FindToast.
Definition gui_notification_types.h:30
static constexpr int dimensions
Definition gui_type_dimensions.h:15
static T & GetComponent(T &value, int)
Definition gui_type_dimensions.h:16
A VirtualTable column: the TableColumn plus cell generator, sort order and section.
Definition gui_table_types.h:90
Definition gui_base_types.h:384
Definition gui_base_types.h:395
Definition gui_base_types.h:121
Integer 2D vector.
Definition gui_base_types.h:19
int32_t x
Definition gui_base_types.h:20
int32_t y
Definition gui_base_types.h:20
Definition gui_base_types.h:75