TachyonUI 1.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 <algorithm>
4#include <chrono>
5#include <cmath>
6#include <cstdint>
7#include <memory>
8#include <optional>
9#include <unordered_map>
10#include <unordered_set>
11#include <variant>
12#include <vector>
13#include <cassert>
14#include <source_location>
15#include <span>
16#include <functional>
17#include <initializer_list>
18#include <string>
19#include <thread>
20#include <utility>
21
25
29
34
38
44
46
49
51
54
56
58
74#include <gui_core/gui_result.h>
75
83
91
92namespace tachyon
93{
96
101 void VERIFY(RegistryResult result);
102
108
109
110 // ---- MessageDialog: a modal question (GUIApplication::MessageDialog) ----
112 enum class MessageIcon : uint8_t { Warning, Quit, Question, Info, Error };
114 enum class MessageButtonKind : uint8_t { Secondary, Primary, Danger };
115
118 {
121 std::string_view label;
123 bool alignLeft = false;
124 };
125
129 {
130 std::string_view name;
131 std::string_view meta;
133 bool* checked = nullptr;
134 };
135
138 {
140 std::string_view title;
141 std::string_view message;
142 std::span<const MessageButton> buttons;
144 int cancelButton = -1;
145 std::span<const MessageDialogItem> items;
146 bool* dontAskAgain = nullptr;
147 std::string_view details;
150 std::string* input = nullptr;
151 };
152
153 // Outside GUIApplication: GCC can't use a nested struct's member initializers in a
154 // default argument of the class being defined.
158 {
159 bool loadStyles = true;
160 bool commandShortcuts = true;
165 std::string_view fallbackFonts {};
169 uint32_t imageSlots = 0;
173 std::string_view gpu {};
178 std::optional<GraphicsAPI> graphicsAPI {};
179 };
180
209 {
210 public:
212 std::unique_ptr<InputManager> inputManager;
214 std::unique_ptr<LayoutEngine> layoutEngine;
216 std::unique_ptr<OSWindowManager> windowManager;
218 std::unique_ptr<TextAtlasManager> textAtlasManager;
220 std::unique_ptr<IClipboard> clipboard;
221
228
239
244
245 private:
248 FramePipeline m_frame{};
249
250 std::unique_ptr<SliderFieldTrackSubsystem> m_sliderFieldTrack;
251 std::unique_ptr<MenuRectsSubsystem> m_menuRects;
252 std::unique_ptr<LabelGroupSubsystem> m_labelGroup;
253 std::unique_ptr<ButtonGroupSubsystem> m_buttonGroup;
254 std::unique_ptr<ColorPickerSubsystem> m_colorPickerSub;
255 std::unique_ptr<GradientEditorSubsystem> m_gradientEditorSub;
256 std::unique_ptr<RenameSubsystem> m_renameSub;
257 std::unique_ptr<ReorderableSubsystem> m_reorderable;
258 std::unique_ptr<DockTabDragSubsystem> m_dockTabDragSub;
259 ToolbarWindowDragSubsystem m_toolbarWindowDrag{};
260 std::unique_ptr<UICacheManager> m_uiCache;
261
262 public:
265
270
275
278
282
286
287
289 bool applicationQuit = false;
291 std::chrono::steady_clock::time_point m_frameStart{};
293 float frameTime = 0.0f;
295 float frameBuildTime = 0.0f;
296
298 struct FrameTimingSample { float buildMs = 0.0f; float totalMs = 0.0f; };
299 static constexpr int kFrameHistoryCount = 240;
300
302 void GetFrameTimingHistory(std::span<FrameTimingSample> out) const;
303
305
306
309
313 void CreatePanel(std::unordered_map<tachyon::ID, tachyon::Panel>& panels, ID id, std::string title, tachyon::IconID icon,
314 std::function<void()> onPanelGUI,
315 std::string panelType = {},
316 std::function<void()> onEnable = {},
317 std::function<void()> onDisable = {});
318
321 tachyon::ID CreatePanel(std::unordered_map<tachyon::ID, tachyon::Panel>& panels, std::string title, tachyon::IconID icon,
322 std::function<void()> onPanelGUI,
323 std::string panelType = {},
324 std::function<void()> onEnable = {},
325 std::function<void()> onDisable = {})
326 {
327 ID id = idManager.CreateStaticID();
328 CreatePanel(panels, id, std::move(title), icon, std::move(onPanelGUI),
329 std::move(panelType), std::move(onEnable), std::move(onDisable));
330 panels[id].internal.ownsID = true;
331 return id;
332 }
333
334
339
341 void EmitFloatingToolbarWindows(std::vector<struct FloatingToolbarItem>& floatingItems,
342 const struct FloatingToolbarOptions* options = nullptr);
343
347
352
358 void EmitFloatingDockWindows(const DocumentSet& documents);
361 bool FloatPanel(DockingLayout& layout, ID panelID, int2 screenPos);
369
371 void CloseFloatingDockWindow(size_t index);
372
374 void CloseDockedPanel(DockingLayout& layout, DockNode& leaf, int tabIndex);
380 void ClaimCommandMode(ID owner, CommandMode mode);
381
386 void ClosePanel(DockingLayout& layout, ID panelID);
387
390 Document& CreateDocument(DocumentSet& set, std::string name, std::string extension, std::string kind,
391 tachyon::IconID icon);
397 void CloseDocument(DocumentSet& set, int index);
400
402 static void TransferPanel(tachyon::ID panelID, tachyon::DockNode* sourceNode,
403 DockingLayout* sourceLayout,
404 DockingLayout* targetLayout);
405
407
410
414
417
420 virtual Result<void> Initialize(const InitializeOptions& options = {});
423 virtual void Cleanup();
424
427
430 virtual void OnStylesReloaded() {}
431
434 void RequestReloadTheme(std::string_view themePath, float fontScale);
436 const Result<void>& ThemeReloadResult() const { return m_themeReload; }
437 const std::string& GetThemePath() const { return m_themePath; }
438
444 void SetAccent(std::optional<AccentColors> accent);
446 const std::optional<AccentColors>& GetAccent() const { return m_accent; }
447
455 void SetThemeVariable(std::string_view name, std::string_view value);
457 void ClearThemeVariable(std::string_view name);
462
467 void SetResourceRoot(std::string_view root) { m_resourceRoot = std::string(root); }
468 const std::string& GetResourceRoot() const { return m_resourceRoot; }
469
471
474
483 void InjectMouseButton(ID windowID, int2 pos, MouseButtons button, bool down, KeyModifier mods = KeyModifier::None);
485 void InjectMouseScroll(ID windowID, int2 pos, float2 offset, KeyModifier mods = KeyModifier::None);
487 void InjectMouseLeave(ID windowID);
489 void InjectPen(ID windowID, const PenState& pen);
491 void InjectPinch(ID windowID, float scale, KeyModifier mods = KeyModifier::None);
493 void InjectFocus(ID windowID, bool focused);
495 void InjectKey(ID windowID, KeyCode key, KeyAction action, KeyModifier mods = KeyModifier::None);
497 void InjectText(ID windowID, std::string_view utf8);
498
501 Result<void> ReadWindowPixels(ID windowID, std::span<uint8_t> bgra);
502
504
507
512 void SetGraphicsBackend(std::unique_ptr<GraphicsContext> backend) { m_graphicsBackend = std::move(backend); }
513
517 void SetWindowBackend(std::unique_ptr<IWindowBackend> backend) { m_osWindowBackend = std::move(backend); }
520 void SetClipboard(std::unique_ptr<IClipboard> clipboardImpl) { clipboard = std::move(clipboardImpl); }
521
525 void SetAllocationHooks(const AllocationHooks& hooks) { m_allocationHooks = hooks; }
526
531 void SetStyleFiles(std::span<const std::string_view> files);
532 float GetGlobalFontScale() const { return m_globalFontScale; }
533
536 void SetUIScale(float scale);
537 float GetUIScale() const { return m_uiScale; }
538
542 void SetReducedMotion(std::optional<bool> reduced);
544 bool IsThemeCrossfading() const { return !m_crossfades.empty(); }
547
552 void SetWheelMode(WheelMode mode) { m_wheelMode = mode; }
553 WheelMode GetWheelMode() const { return m_wheelMode; }
554
556
559
561 virtual void OnGUI() = 0;
562
566
582
586 void SetRedrawMode(RedrawMode mode) { m_redrawMode = mode; RequestRedraw(); }
587 RedrawMode GetRedrawMode() const { return m_redrawMode; }
592 void RequestRedrawIn(float seconds);
599 bool NeedsFrame() const;
602 float SecondsUntilFrame() const;
603
605
608
609 // ---- Event handler factories ----
610 //
611 // Event handlers run at END OF FRAME (input dispatch), not during OnGUI. Captures must
612 // outlive the frame: user-owned pointers, GUIApplication members and copies are fine;
613 // transient construction state (m_treeState, ...) and OnGUI stack locals are not.
614 //
619 template <class OnClick>
620 tachyon::EventHandler MakeButtonHandler(OnClick&& onClick) { return tachyon::MakeButtonHandler(guiStateManager, std::forward<OnClick>(onClick)); }
623
627 tachyon::ElementRef RegisterElement(tachyon::Element&& element, std::string_view text, LayoutOverride&& constraints);
628
629
632 bool TakeEscapeFor(ID popupWindowID, ID triggerID);
633
640 tachyon::ElementRef RegisterControl(tachyon::Element&& element, std::string_view text, LayoutOverride&& constraints);
642 tachyon::ElementRef RegisterControl(tachyon::Element&& element, std::function<TextID(tachyon::Element& element)> createTextID, LayoutOverride&& constraints);
643
649 bool reserveIcon, IconID icon, std::string_view text,
650 std::string_view trailing, StyleRef trailingStyle,
651 LayoutOverride&& constraints, bool destructive = false, bool lit = false);
654 bool MenuItemImpl(ID id, const GUIContent& content, std::string_view shortcut,
655 std::function<void()> onClick, StyleRef style, bool destructive, LayoutOverride&& constraints);
657 void ShowContentTooltip(ID id, const GUIContent& content) { if (!content.tooltip.empty()) SetTooltip(id, content.tooltip); }
658
664
666
669
674 bool Button(ID id, const GUIContent& content, std::function<void()> onClick, StyleRef style, LayoutOverride&& constraints = {});
676 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)); }
680 bool ShortcutButton(ID id, const CommandManager::Command& command, std::function<void()> onClick,
681 std::string_view unassigned = "Unassigned", LayoutOverride&& constraints = {});
683 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)); }
685 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)); }
686
689 bool CommandButton(CommandID command, StyleRef style, LayoutOverride&& constraints = {});
691 inline bool CommandButton(CommandID command, LayoutOverride&& constraints = {}) { return CommandButton(command, theme.controls->button, std::move(constraints)); }
692
694 bool Checkbox(ID id, bool value, std::string_view text, std::function<void(bool)> onToggle, StyleRef style, LayoutOverride&& constraints = {});
696 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)); }
698 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)); }
700 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)); }
702 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)); }
704 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)); }
706 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)); }
708 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)); }
709
711 bool Switch(ID id, bool value, std::string_view text, std::function<void(bool)> onToggle, StyleRef style, LayoutOverride&& constraints = {});
713 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)); }
715 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)); }
717 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)); }
719 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)); }
721 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)); }
723 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)); }
725 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)); }
726
728 bool Toggle(ID id, bool value, const GUIContent& content, std::function<void(bool)> onToggle, StyleRef style, LayoutOverride&& constraints = {});
730 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)); }
732 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)); }
734 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)); }
736 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)); }
738 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)); }
740 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)); }
742 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)); }
743
747 bool BusyButton(ID id, const GUIContent& content, bool busy, std::string_view busyText,
748 std::function<void()> onClick, StyleRef style, LayoutOverride&& constraints = {});
750 inline bool BusyButton(ID id, const GUIContent& content, bool busy, std::string_view busyText,
751 std::function<void()> onClick, LayoutOverride&& constraints = {}) { return BusyButton(id, content, busy, busyText, std::move(onClick), theme.controls->button, std::move(constraints)); }
752
754
759
763 void ProgressBar(ID id, float value, bool failed, StyleRef style, LayoutOverride&& constraints = {});
765 inline void ProgressBar(ID id, float value, LayoutOverride&& constraints = {}) { ProgressBar(id, value, false, theme.progressBarStyleRef, std::move(constraints)); }
767 inline void ProgressBar( float value, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { ProgressBar(idManager.AllocateDynamicID(site), value, false, theme.progressBarStyleRef, std::move(constraints)); }
768
771 void IndeterminateProgressBar(ID id, StyleRef style, LayoutOverride&& constraints = {});
773 inline void IndeterminateProgressBar(ID id, LayoutOverride&& constraints = {}) { IndeterminateProgressBar(id, theme.progressBarStyleRef, std::move(constraints)); }
775 inline void IndeterminateProgressBar(LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { IndeterminateProgressBar(idManager.AllocateDynamicID(site), theme.progressBarStyleRef, std::move(constraints)); }
776
779 void Spinner(ID id, SpinnerSize size = SpinnerSize::Medium, LayoutOverride&& constraints = {});
781 inline void Spinner(SpinnerSize size = SpinnerSize::Medium, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { Spinner(idManager.AllocateDynamicID(site), size, std::move(constraints)); }
782
785 void CircularProgress(ID id, float value, StyleRef style, LayoutOverride&& constraints = {});
787 inline void CircularProgress(ID id, float value, LayoutOverride&& constraints = {}) { CircularProgress(id, value, theme.circularProgressStyleRef, std::move(constraints)); }
789 inline void CircularProgress( float value, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { CircularProgress(idManager.AllocateDynamicID(site), value, theme.circularProgressStyleRef, std::move(constraints)); }
790
794 void Skeleton(ID id, StyleRef style, LayoutOverride&& constraints = {});
796 inline void Skeleton(ID id, LayoutOverride&& constraints = {}) { Skeleton(id, theme.skeletonStyleRef, std::move(constraints)); }
798 inline void Skeleton(LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { Skeleton(idManager.AllocateDynamicID(site), theme.skeletonStyleRef, std::move(constraints)); }
799
804 void TaskProgress(ID id, const ProgressTask& task, LayoutOverride&& constraints = {});
806 inline void TaskProgress( const ProgressTask& task, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { TaskProgress(idManager.AllocateDynamicID(site), task, std::move(constraints)); }
807
812 void ProgressSteps(ID id, std::span<const ProgressTask> steps, LayoutOverride&& constraints = {});
814 inline void ProgressSteps( std::span<const ProgressTask> steps, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { ProgressSteps(idManager.AllocateDynamicID(site), steps, std::move(constraints)); }
815
818 void StatusProgress(ID id, const ProgressTask& task, LayoutOverride&& constraints = {});
820 inline void StatusProgress( const ProgressTask& task, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { StatusProgress(idManager.AllocateDynamicID(site), task, std::move(constraints)); }
821
825 bool BackgroundTasks(ID id, std::span<const ProgressTask> tasks, LayoutOverride&& constraints = {});
827 inline bool BackgroundTasks( std::span<const ProgressTask> tasks, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return BackgroundTasks(idManager.AllocateDynamicID(site), tasks, std::move(constraints)); }
828
830
833
844 bool Timeline(ID id, TimelineState& state, const TimelineOptions& options, LayoutOverride&& constraints = {});
846 inline bool Timeline( TimelineState& state, const TimelineOptions& options, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return Timeline(idManager.AllocateDynamicID(site), state, options, std::move(constraints)); }
847
869 void TimelineEditor(ID id, TimelineViewRef view, LayoutOverride&& constraints = {});
871 inline void TimelineEditor( TimelineViewRef view, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { TimelineEditor(idManager.AllocateDynamicID(site), view, std::move(constraints)); }
872
874
877
885 bool CurveField(ID id, CurveViewRef view, LayoutOverride&& constraints = {});
887 inline bool CurveField( CurveViewRef view, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return CurveField(idManager.AllocateDynamicID(site), view, std::move(constraints)); }
888
892 void CurveEditor(ID id, CurveViewRef view, LayoutOverride&& constraints = {});
894 inline void CurveEditor( CurveViewRef view, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { CurveEditor(idManager.AllocateDynamicID(site), view, std::move(constraints)); }
895
906 bool Plot(ID id, PlotViewRef view, LayoutOverride&& constraints = {});
908 inline bool Plot( PlotViewRef view, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return Plot(idManager.AllocateDynamicID(site), view, std::move(constraints)); }
909
920 bool Viewport(ID id, ViewportView& view, LayoutOverride&& constraints = {});
922 inline bool Viewport( ViewportView& view, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return Viewport(idManager.AllocateDynamicID(site), view, std::move(constraints)); }
923
925
928
932 bool BeginMenu(ID id, const GUIContent& content, StyleRef buttonStyle, StyleRef menuStyle, StyleRef itemStyle, LayoutOverride&& constraints = {});
934 inline bool BeginMenu(ID id, const GUIContent& content, LayoutOverride&& constraints = {}) { return BeginMenu(id, content, theme.controls->menuTrigger, theme.menuStyleRef, theme.menuItemRowStyleRef, std::move(constraints)); }
936 inline bool BeginMenu( const GUIContent& content, StyleRef buttonStyle, StyleRef menuStyle, StyleRef itemStyle, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return BeginMenu(idManager.AllocateDynamicID(site), content, buttonStyle, menuStyle, itemStyle, std::move(constraints)); }
938 inline bool BeginMenu( const GUIContent& content, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return BeginMenu(idManager.AllocateDynamicID(site), content, theme.controls->menuTrigger, theme.menuStyleRef, theme.menuItemRowStyleRef, std::move(constraints)); }
942 bool BeginDropdownMenu(ID id, const GUIContent& content, StyleRef buttonStyle, StyleRef menuStyle, StyleRef itemStyle, LayoutOverride&& constraints = {});
944 inline bool BeginDropdownMenu(ID id, const GUIContent& content, LayoutOverride&& constraints = {}) { return BeginDropdownMenu(id, content, theme.menuBarDropdownStyleRef, theme.menuStyleRef, theme.menuItemRowStyleRef, std::move(constraints)); }
949 bool Dropdown(ID id, int& selected, std::span<const std::string_view> options, StyleRef style, LayoutOverride&& constraints = {});
951 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)); }
953 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)); }
955 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)); }
957 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)); }
959 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)); }
961 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)); }
963 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)); }
965 void MenuHeader(std::string_view text);
969 int MessageDialog(ID id, const MessageDialogDesc& desc, StyleRef style);
971 inline int MessageDialog(ID id, const MessageDialogDesc& desc) { return MessageDialog(id, desc, theme.messageBoxStyleRef); }
973 inline int MessageDialog( const MessageDialogDesc& desc, StyleRef style, std::source_location site = std::source_location::current()) { return MessageDialog(idManager.AllocateDynamicID(site), desc, style); }
975 inline int MessageDialog( const MessageDialogDesc& desc, std::source_location site = std::source_location::current()) { return MessageDialog(idManager.AllocateDynamicID(site), desc, theme.messageBoxStyleRef); }
976
989 void Toasts();
992 void Banner(ID id, Severity severity, const GUIContent& message, std::span<const BannerAction> actions = {},
993 LayoutOverride&& constraints = {});
995 inline void Banner(Severity severity, const GUIContent& message, std::span<const BannerAction> actions = {},
996 LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current())
997 { Banner(idManager.AllocateDynamicID(site), severity, message, actions, std::move(constraints)); }
998
1001 bool CloseRequested(ID windowID);
1002
1007
1009 bool MenuItem(ID id, const GUIContent& content, std::string_view shortcut, std::function<void()> onClick, StyleRef style, LayoutOverride&& constraints = {});
1011 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)); }
1013 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)); }
1015 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)); }
1017 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)); }
1019 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)); }
1021 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)); }
1023 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)); }
1024
1026 bool MenuItem(CommandID command);
1028 bool DestructiveMenuItem(ID id, const GUIContent& content, std::string_view shortcut, std::function<void()> onClick, StyleRef style, LayoutOverride&& constraints = {});
1030 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)); }
1032 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)); }
1034 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)); }
1036 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)); }
1038 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)); }
1040 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)); }
1042 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)); }
1044 void EndMenu();
1045
1048 bool BeginMenuBar(ID id, StyleRef style, LayoutOverride&& constraints = {});
1050 inline bool BeginMenuBar(ID id, LayoutOverride&& constraints = {}) { return BeginMenuBar(id, theme.menuBarStyleRef, std::move(constraints)); }
1052 inline bool BeginMenuBar( LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return BeginMenuBar(idManager.AllocateDynamicID(site), theme.menuBarStyleRef, std::move(constraints)); }
1054 inline bool BeginMenuBar( StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return BeginMenuBar(idManager.AllocateDynamicID(site), style, std::move(constraints)); }
1057
1059
1062
1063 // ---- Title bar: a menu bar the window is dragged by ----
1064 // Whatever in it isn't a control is the caption: dragging it moves the window and a
1065 // double-click maximizes it. In a window with ElementFlags::WindowCustomTitleBar,
1066 // EndTitleBar adds the minimize, maximize / restore and close buttons.
1070 bool BeginTitleBar(ID id, StyleRef style, LayoutOverride&& constraints = {});
1072 inline bool BeginTitleBar(ID id, LayoutOverride&& constraints = {}) { return BeginTitleBar(id, theme.titleBarStyleRef, std::move(constraints)); }
1074 inline bool BeginTitleBar( LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return BeginTitleBar(idManager.AllocateDynamicID(site), theme.titleBarStyleRef, std::move(constraints)); }
1076 inline bool BeginTitleBar( StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return BeginTitleBar(idManager.AllocateDynamicID(site), style, std::move(constraints)); }
1079
1081 WindowHitArea TitleBarHitTest(ID windowID, int2 screenPos) const;
1082
1085
1087 void SetTooltip(ID targetID, std::string_view text);
1089 void SetTooltip(ID targetID, IconID icon, std::string_view text);
1091 inline void SetTooltip(std::string_view text) { SetTooltip(elementStorage.GetLastItemID(), text); }
1093 inline void SetTooltip(IconID icon, std::string_view text) { SetTooltip(elementStorage.GetLastItemID(), icon, text); }
1095 void SetTooltip(ID targetID, std::string_view text, std::string_view shortcut);
1097 void SetTooltip(ID targetID, IconID icon, std::string_view text, std::string_view shortcut);
1099 inline void SetTooltip(std::string_view text, std::string_view shortcut) { SetTooltip(elementStorage.GetLastItemID(), text, shortcut); }
1102 void SetTooltip(ID targetID, const PropertyHelp& help);
1104 inline void SetTooltip(const PropertyHelp& help) { SetTooltip(elementStorage.GetLastItemID(), help); }
1107 void SetErrorTooltip(ID targetID, std::string_view message);
1109 inline void SetErrorTooltip(std::string_view message) { SetErrorTooltip(elementStorage.GetLastItemID(), message); }
1112 void SetDisabledTooltip(ID targetID, std::string_view text, std::string_view reason);
1114 inline void SetDisabledTooltip(std::string_view text, std::string_view reason) { SetDisabledTooltip(elementStorage.GetLastItemID(), text, reason); }
1115
1118 bool BeginTooltip(ID targetID);
1123
1128 bool BeginContextMenu(ID targetID);
1135 void OpenContextMenu(ID targetID, int2 screenPos);
1139 uint32_t ContextMenuOpenings() const { return m_contextMenuOpenings; }
1140
1142
1145
1148 bool BeginLabelGroup(ID id, CssPx defaultWidth = 120, CssPx minWidth = 40, CssPx maxWidth = 500, bool resizable = true);
1150 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); }
1153
1156 bool BeginButtonGroup(LayoutOverride&& constraints = {});
1158 bool BeginButtonGroup(ID id, LayoutOverride&& constraints = {});
1162 bool BeginToggleGroup(LayoutOverride&& constraints = {});
1165
1169 bool Segmented(ID id, int& selected, std::span<const std::string_view> options, LayoutOverride&& constraints = {});
1171 template<typename E> requires std::is_enum_v<E>
1172 bool Segmented(ID id, E& selected, std::span<const std::string_view> options, LayoutOverride&& constraints = {})
1173 {
1174 return SegmentedImpl(id, int(selected), options, [&selected](int index) { selected = E(index); }, std::move(constraints));
1175 }
1176
1177 template<typename T> requires (std::is_enum_v<T> || std::is_same_v<T, int>)
1178 bool Segmented(T& selected, std::span<const std::string_view> options, LayoutOverride&& constraints = {},
1179 std::source_location site = std::source_location::current())
1180 {
1181 return Segmented(idManager.AllocateDynamicID(site), selected, options, std::move(constraints));
1182 }
1183
1187
1190 bool BeginArea(ID id, StyleRef style, LayoutOverride&& constraints = {});
1192 inline bool BeginArea(ID id, LayoutOverride&& constraints = {}) { return BeginArea(id, theme.collectionStyleRef, std::move(constraints)); }
1194 inline bool BeginArea( StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return BeginArea(idManager.AllocateDynamicID(site), style, std::move(constraints)); }
1196 inline bool BeginArea( LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return BeginArea(idManager.AllocateDynamicID(site), theme.collectionStyleRef, std::move(constraints)); }
1198 void EndArea();
1199
1206 bool BeginCached(ID id, StyleRef style, uint64_t signature = 0, LayoutOverride&& constraints = {});
1208 inline bool BeginCached(ID id, uint64_t signature = 0, LayoutOverride&& constraints = {}) { return BeginCached(id, theme.collectionStyleRef, signature, std::move(constraints)); }
1212 void Invalidate(ID id);
1213
1215 void SetDrawCacheEnabled(bool enabled) { if (m_uiCache) m_uiCache->SetDrawCacheEnabled(enabled); }
1216
1218 void InvalidatePanel(ID panelId);
1219
1221 bool BeginHorizontal(ID id, StyleRef style, LayoutOverride&& constraints = {});
1223 inline bool BeginHorizontal(ID id, LayoutOverride&& constraints = {}) { return BeginHorizontal(id, theme.emptyHorzStyleRef, std::move(constraints)); }
1225 inline bool BeginHorizontal( StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return BeginHorizontal(idManager.AllocateDynamicID(site), style, std::move(constraints)); }
1227 inline bool BeginHorizontal( LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return BeginHorizontal(idManager.AllocateDynamicID(site), theme.emptyHorzStyleRef, std::move(constraints)); }
1230
1232 bool BeginHorizontalWrap(ID id, StyleRef style, LayoutOverride&& constraints = {});
1234 inline bool BeginHorizontalWrap(ID id, LayoutOverride&& constraints = {}) { return BeginHorizontalWrap(id, theme.emptyHorzWrapStyleRef, std::move(constraints)); }
1236 inline bool BeginHorizontalWrap( StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return BeginHorizontalWrap(idManager.AllocateDynamicID(site), style, std::move(constraints)); }
1238 inline bool BeginHorizontalWrap( LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return BeginHorizontalWrap(idManager.AllocateDynamicID(site), theme.emptyHorzWrapStyleRef, std::move(constraints)); }
1241
1243 bool BeginVertical(ID id, StyleRef style, LayoutOverride&& constraints = {});
1245 inline bool BeginVertical(ID id, LayoutOverride&& constraints = {}) { return BeginVertical(id, theme.emptyVertStyleRef, std::move(constraints)); }
1247 inline bool BeginVertical( StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return BeginVertical(idManager.AllocateDynamicID(site), style, std::move(constraints)); }
1249 inline bool BeginVertical( LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return BeginVertical(idManager.AllocateDynamicID(site), theme.emptyVertStyleRef, std::move(constraints)); }
1252
1254 bool BeginVerticalWrap(ID id, StyleRef style, LayoutOverride&& constraints = {});
1256 inline bool BeginVerticalWrap(ID id, LayoutOverride&& constraints = {}) { return BeginVerticalWrap(id, theme.emptyVertWrapStyleRef, std::move(constraints)); }
1258 inline bool BeginVerticalWrap( StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return BeginVerticalWrap(idManager.AllocateDynamicID(site), style, std::move(constraints)); }
1260 inline bool BeginVerticalWrap( LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return BeginVerticalWrap(idManager.AllocateDynamicID(site), theme.emptyVertWrapStyleRef, std::move(constraints)); }
1263
1266 bool BeginToolbar(bool horizontal = true);
1269
1271
1274
1275 // ---- Scrollbars ----
1276 // Call from INSIDE the scrollable container `containerID`: the bar overlays
1277 // its border box, unaffected by its scroll offset. Paints nothing without
1278 // overflow, so it can always be emitted.
1281 void VerticalScrollbar (ID scrollBarID, ID containerID);
1283 void VerticalScrollbar (ID containerID) { (void)idManager.PushParent(containerID); const ID barID = idManager.AllocateDynamicID("vertical_scrollbar"); (void)idManager.PopParent(); VerticalScrollbar(barID, containerID); }
1285 void HorizontalScrollbar(ID scrollBarID, ID containerID);
1287 void HorizontalScrollbar(ID containerID) { (void)idManager.PushParent(containerID); const ID barID = idManager.AllocateDynamicID("horizontal_scrollbar"); (void)idManager.PopParent(); HorizontalScrollbar(barID, containerID); }
1288
1291 void ScrollbarOverlay(ID containerID,
1292 int2 lastInnerSize = int2{0, 0},
1293 ID vertScrollBarID = ID::Invalid(),
1294 ID horzScrollBarID = ID::Invalid(),
1295 bool emitVert = true,
1296 bool emitHorz = true);
1297
1299
1302
1303 // ---- Reorderable Group: drag-to-reorder container ----
1304 // onReorder(fromIndex, toIndex) fires on drop. isWrapped allows multi-line layout.
1305 // onDragOut(index, screenPos): an item was released outside the group.
1306 // dragVisualizer(index, screenPos): each frame while dragging outside the group,
1307 // typically to draw a ghost window; suppresses the in-place cross-axis offset.
1310 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);
1312 inline bool BeginReorderableGroup(ID id, ReorderDirection direction, std::function<void(int fromIndex, int toIndex)> onReorder, StyleRef style, LayoutOverride&& constraints = {})
1313 { return BeginReorderableGroup(id, direction, false, std::move(onReorder), style, std::move(constraints)); }
1314
1315 inline bool BeginReorderableGroup(ID id, ReorderDirection direction, std::function<void(int fromIndex, int toIndex)> onReorder, LayoutOverride&& constraints = {})
1316 { return BeginReorderableGroup(id, direction, false, std::move(onReorder), ReorderableGroupStyle(direction, false), std::move(constraints)); }
1317
1318 inline bool BeginReorderableGroup(ID id, ReorderDirection direction, bool isWrapped, std::function<void(int fromIndex, int toIndex)> onReorder, LayoutOverride&& constraints = {})
1319 { return BeginReorderableGroup(id, direction, isWrapped, std::move(onReorder), ReorderableGroupStyle(direction, isWrapped), std::move(constraints)); }
1320
1321 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())
1322 { return BeginReorderableGroup(idManager.AllocateDynamicID(site), direction, isWrapped, std::move(onReorder), style, std::move(constraints)); }
1323
1324 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())
1325 { return BeginReorderableGroup(idManager.AllocateDynamicID(site), direction, isWrapped, std::move(onReorder), ReorderableGroupStyle(direction, isWrapped), std::move(constraints)); }
1326
1327 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())
1328 { return BeginReorderableGroup(idManager.AllocateDynamicID(site), direction, false, std::move(onReorder), style, std::move(constraints)); }
1329
1330 inline bool BeginReorderableGroup(ReorderDirection direction, std::function<void(int fromIndex, int toIndex)> onReorder, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current())
1331 { return BeginReorderableGroup(idManager.AllocateDynamicID(site), direction, false, std::move(onReorder), ReorderableGroupStyle(direction, false), std::move(constraints)); }
1332
1339
1341
1343 bool BeginReorderableItem(ID id, StyleRef style, LayoutOverride&& constraints = {});
1345 inline bool BeginReorderableItem(ID id, LayoutOverride&& constraints = {}) { return BeginReorderableItem(id, theme.reorderableItemStyleRef, std::move(constraints)); }
1347 inline bool BeginReorderableItem(StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return BeginReorderableItem(idManager.AllocateDynamicID(site), style, std::move(constraints)); }
1349 inline bool BeginReorderableItem(LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return BeginReorderableItem(idManager.AllocateDynamicID(site), theme.reorderableItemStyleRef, std::move(constraints)); }
1352
1355
1357
1360
1361 // ---- ListView: scrollable list with selectable items ----
1364 bool BeginListView(ID id, int* selectedIndex, int itemCount, ItemDragDropConfig* dragDrop, StyleRef style, LayoutOverride&& constraints = {});
1366 inline bool BeginListView(ID id, int* selectedIndex, int itemCount, StyleRef style, LayoutOverride&& constraints = {}) { return BeginListView(id, selectedIndex, itemCount, nullptr, style, std::move(constraints)); }
1368 inline bool BeginListView(ID id, int* selectedIndex, int itemCount, LayoutOverride&& constraints = {}) { return BeginListView(id, selectedIndex, itemCount, nullptr, theme.listViewStyleRef, std::move(constraints)); }
1370 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)); }
1372 inline bool BeginListView(ID id, int* selectedIndex, int itemCount, ItemDragDropConfig* dragDrop, LayoutOverride&& constraints = {}) { return BeginListView(id, selectedIndex, itemCount, dragDrop, theme.listViewStyleRef, std::move(constraints)); }
1374 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)); }
1376 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)); }
1378 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)); }
1381
1385
1387 bool ListItem(ID id, const GUIContent& content, StyleRef style, LayoutOverride&& constraints = {});
1389 inline bool ListItem(ID id, const GUIContent& content, LayoutOverride&& constraints = {}) { return ListItem(id, content, theme.listItemStyleRef, std::move(constraints)); }
1391 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)); }
1393 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)); }
1394
1395
1398 static void RebuildTreeViewIndex(std::vector<TreeViewRow>& rows);
1399
1402 static void WalkTreeViewVisibility(const std::vector<TreeViewRow>& rows,
1403 const std::unordered_set<ID>& openRows,
1404 std::vector<int>& visibleIdx);
1409 static void WalkTreeViewVisibility(const std::vector<TreeViewRow>& rows,
1410 std::vector<int>& visibleIdx, TableState& state);
1413 static TreeOpenRef TreeViewOpenRef(const std::vector<TreeViewRow>& rows, size_t flat, TableState& state)
1414 {
1415 const TreeViewRow& row = rows[flat];
1416 return row.HasChildren() ? TreeOpenRef{ .set = &state.openRows, .key = TreeViewRowKey(row, flat) } : TreeOpenRef{};
1417 }
1418
1422 std::vector<TreeViewRow>& rows,
1423 std::vector<int>& visibleIdx,
1424 TableState& state,
1425 StyleRef style = {},
1426 LayoutOverride&& constraints = {},
1427 std::string_view header = {});
1429 inline void VirtualTreeView(std::vector<TreeViewRow>& rows, std::vector<int>& visibleIdx, TableState& state,
1430 StyleRef style = {}, LayoutOverride&& constraints = {}, std::string_view header = {},
1431 std::source_location site = std::source_location::current())
1432 { VirtualTreeView(idManager.AllocateDynamicID(site), rows, visibleIdx, state, style, std::move(constraints), header); }
1433
1435 ID TreeDropTargetRow() const { return m_treeDropState.targetRowID; }
1436
1439 bool IsFileDragging() const { return inputManager && inputManager->GetFileDrag() != nullptr; }
1443 ID FileDragTargetID() const { return m_fileDragTargetID; }
1446 void SetFileDropHandler(std::function<void(const FileDrop&)> handler) { m_fileDropHandler = std::move(handler); }
1447
1453 {
1454 return m_fileDragTargetID != ID::Invalid() ? m_fileDragTargetID : guiStateManager.Drag().GetTakerID();
1455 }
1456
1458 ID DragGhostWindowID() const { return tabDragGhostWindowID; }
1462
1485 bool ShowsFocusRing(const tachyon::Element& element) const
1486 {
1488 return false;
1491 }
1492
1494
1497
1498 // ---- GridView: 2D icon grid (like file explorer) ----
1502 bool BeginGridView(ID id, int* selectedIndex, StyleRef style, MultiSelectState* multiSelect = nullptr, ItemDragDropConfig* dragDrop = nullptr, LayoutOverride&& constraints = {});
1504 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)); }
1506 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)); }
1508 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)); }
1511
1514 bool GridViewItem(ID id, const GUIContent& content,
1516 std::string* renameBuffer = nullptr,
1517 StyleRef itemStyle = {},
1518 LayoutOverride&& constraints = {});
1520 inline bool GridViewItem(ID id, const GUIContent& content, LayoutOverride&& constraints)
1521 { return GridViewItem(id, content, tachyon::ElementState::None, nullptr, {}, std::move(constraints)); }
1522
1523 inline bool GridViewItem(const GUIContent& content, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current())
1524 { return GridViewItem(idManager.AllocateDynamicID(site), content, tachyon::ElementState::None, nullptr, {}, std::move(constraints)); }
1525
1526 inline bool GridViewItem(ID id, const GUIContent& content, StyleRef style, LayoutOverride&& constraints = {})
1527 { return GridViewItem(id, content, tachyon::ElementState::None, nullptr, style, std::move(constraints)); }
1528
1529 inline bool GridViewItem(const GUIContent& content, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current())
1530 { return GridViewItem(idManager.AllocateDynamicID(site), content, tachyon::ElementState::None, nullptr, style, std::move(constraints)); }
1531
1534 bool IsRenaming() const { return m_renameSub && m_renameSub->isActive; }
1535
1536
1541 int itemCount, int2 cellSize,
1542 const std::function<void(int index, ID itemID)>& generateItem,
1543 int* selectedIndex = nullptr,
1544 MultiSelectState* multiSelect = nullptr,
1545 ItemDragDropConfig* dragDrop = nullptr,
1546 StyleRef scrollStyle = {},
1547 StyleRef rowStyle = {},
1548 LayoutOverride&& constraints = {});
1550 inline void VirtualGridView(GridViewVirtualState& vstate, int itemCount, int2 cellSize,
1551 const std::function<void(int index, ID itemID)>& generateItem,
1552 int* selectedIndex = nullptr, MultiSelectState* multiSelect = nullptr,
1553 ItemDragDropConfig* dragDrop = nullptr, StyleRef scrollStyle = {}, StyleRef rowStyle = {},
1554 LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current())
1555 { VirtualGridView(idManager.AllocateDynamicID(site), vstate, itemCount, cellSize, generateItem, selectedIndex, multiSelect, dragDrop, scrollStyle, rowStyle, std::move(constraints)); }
1556
1558
1561
1562 // ---- Table: row x column data grid ----
1567 bool BeginTable(ID id, VirtualTableColumn* columns, size_t columnCount,
1568 TableState& state, StyleRef style,
1569 LayoutOverride&& constraints = {});
1571 inline bool BeginTable(ID id, VirtualTableColumn* columns, size_t columnCount,
1572 TableState& state, LayoutOverride&& constraints = {})
1573 { return BeginTable(id, columns, columnCount, state, theme.tableStyleRef, std::move(constraints)); }
1574
1575 template <size_t N>
1576 inline bool BeginTable(ID id, VirtualTableColumn (&columns)[N], TableState& state,
1577 StyleRef style, LayoutOverride&& constraints = {})
1578 { return BeginTable(id, columns, N, state, style, std::move(constraints)); }
1579
1580 template <size_t N>
1581 inline bool BeginTable(ID id, VirtualTableColumn (&columns)[N], TableState& state,
1582 LayoutOverride&& constraints = {})
1583 { return BeginTable(id, columns, N, state, theme.tableStyleRef, std::move(constraints)); }
1584
1585 inline bool BeginTable(VirtualTableColumn* columns, size_t columnCount, TableState& state, StyleRef style,
1586 LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current())
1587 { return BeginTable(idManager.AllocateDynamicID(site), columns, columnCount, state, style, std::move(constraints)); }
1588
1589 inline bool BeginTable(VirtualTableColumn* columns, size_t columnCount, TableState& state,
1590 LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current())
1591 { return BeginTable(idManager.AllocateDynamicID(site), columns, columnCount, state, theme.tableStyleRef, std::move(constraints)); }
1592
1593 template <size_t N>
1594 inline bool BeginTable(VirtualTableColumn (&columns)[N], TableState& state, StyleRef style,
1595 LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current())
1596 { return BeginTable(idManager.AllocateDynamicID(site), columns, N, state, style, std::move(constraints)); }
1597
1598 template <size_t N>
1599 inline bool BeginTable(VirtualTableColumn (&columns)[N], TableState& state,
1600 LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current())
1601 { return BeginTable(idManager.AllocateDynamicID(site), columns, N, state, theme.tableStyleRef, std::move(constraints)); }
1602
1603 void EndTable();
1604
1606 bool BeginRow();
1608 void EndRow();
1609
1611 void Cell(std::string_view text);
1612
1615 void Cell(std::function<void()> emit);
1616
1631 void TreeCell(std::string_view text, int depth, TreeOpenRef isOpen,
1632 IconID icon = IconID::Invalid,
1633 uint32_t ancestorLineMask = 0,
1634 bool isLastSibling = true,
1635 std::string* renameBuffer = nullptr,
1636 bool reserveExpander = true);
1638 inline void TreeCell(std::string_view text, int depth, bool* isOpen,
1639 IconID icon = IconID::Invalid,
1640 uint32_t ancestorLineMask = 0,
1641 bool isLastSibling = true,
1642 std::string* renameBuffer = nullptr,
1643 bool reserveExpander = true)
1644 { TreeCell(text, depth, TreeOpenRef{ .flag = isOpen }, icon, ancestorLineMask, isLastSibling, renameBuffer, reserveExpander); }
1645
1654 void VirtualTable(ID id, TableState& state,
1655 std::span<VirtualTableColumn> columns,
1656 int totalRowCount,
1657 CssPx rowHeight = 0,
1658 StyleRef style = {},
1659 LayoutOverride&& constraints = {});
1661 inline void VirtualTable(TableState& state, std::span<VirtualTableColumn> columns, int totalRowCount,
1662 CssPx rowHeight = 0, StyleRef style = {}, LayoutOverride&& constraints = {},
1663 std::source_location site = std::source_location::current())
1664 { VirtualTable(idManager.AllocateDynamicID(site), state, columns, totalRowCount, rowHeight, style, std::move(constraints)); }
1665
1667
1670
1671 // ---- Breadcrumb ----
1674 bool Breadcrumb(ID id, std::span<const std::string> segments, std::function<void(int)> onSelect, StyleRef style, LayoutOverride&& constraints = {});
1676 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)); }
1678 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)); }
1680 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)); }
1681
1683
1686
1687 // ---- Status bar ----
1690 bool BeginStatusBar(ID id, StyleRef style, LayoutOverride&& constraints = {});
1692 inline bool BeginStatusBar(ID id, LayoutOverride&& constraints = {}) { return BeginStatusBar(id, theme.statusBarStyleRef, std::move(constraints)); }
1694 inline bool BeginStatusBar( LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return BeginStatusBar(idManager.AllocateDynamicID(site), theme.statusBarStyleRef, std::move(constraints)); }
1696 inline bool BeginStatusBar( StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return BeginStatusBar(idManager.AllocateDynamicID(site), style, std::move(constraints)); }
1700 void StatusText(ID id, std::string_view text, StyleRef style, LayoutOverride&& constraints = {});
1702 inline void StatusText(ID id, std::string_view text, LayoutOverride&& constraints = {}) { StatusText(id, text, theme.statusTextStyleRef, std::move(constraints)); }
1704 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)); }
1706 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)); }
1707
1709
1712
1713 // ---- Command search ----
1717 bool CommandSearch(ID id, CommandSearchState& state, StyleRef style, LayoutOverride&& constraints = {});
1719 inline bool CommandSearch(ID id, CommandSearchState& state, LayoutOverride&& constraints = {}) { return CommandSearch(id, state, theme.commandSearchStyleRef, std::move(constraints)); }
1721 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)); }
1723 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)); }
1725 static void FocusCommandSearch(CommandSearchState& state) { state.focusRequested = true; }
1726
1728
1731
1732 // ---- Node view: self-contained graph editor ----
1733 // All state lives in the graph and its view state, so several views can coexist,
1734 // of one graph too (a NodeViewState each).
1738
1741 void NodeText(std::string_view text);
1742
1744
1747
1748 // ---- TabBar: reorderable tabs ----
1755 bool BeginTabBar(ID id, int* selectedIndex,
1756 std::function<void(int, int)> onReorder,
1757 std::function<void(int)> onClose = nullptr,
1758 std::function<void(int, tachyon::int2)> onDragOut = nullptr,
1759 std::function<void(int, tachyon::int2)> dragVisualizer = nullptr,
1760 StyleRef style = {},
1761 LayoutOverride&& constraints = {},
1762 TabBarLayout* layout = nullptr,
1763 const TabBarOptions& options = {});
1765 inline bool BeginTabBar(int* selectedIndex,
1766 std::function<void(int, int)> onReorder,
1767 std::function<void(int)> onClose = nullptr,
1768 std::function<void(int, tachyon::int2)> onDragOut = nullptr,
1769 std::function<void(int, tachyon::int2)> dragVisualizer = nullptr,
1770 StyleRef style = {},
1771 LayoutOverride&& constraints = {}, TabBarLayout* layout = nullptr,
1772 std::source_location site = std::source_location::current())
1773 { return BeginTabBar(idManager.AllocateDynamicID(site), selectedIndex, std::move(onReorder), std::move(onClose), std::move(onDragOut), std::move(dragVisualizer), style, std::move(constraints), layout); }
1774
1776
1778 bool Tab(ID id, const GUIContent& content, StyleRef style, LayoutOverride&& constraints = {});
1782 bool BeginTab(ID id, const GUIContent& content, StyleRef style, StyleRef contentStyle,
1783 LayoutOverride&& constraints = {});
1785 void EndTab();
1787 inline bool Tab(ID id, const GUIContent& content, LayoutOverride&& constraints = {}) { return Tab(id, content, theme.tabStyleRef, std::move(constraints)); }
1789 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)); }
1791 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)); }
1792
1794
1797
1798 // ---- DockingContainer ----
1801 bool BeginDockingContainer(ID id, DockingLayout* layout, StyleRef style, LayoutOverride&& constraints = {});
1803 inline bool BeginDockingContainer(ID id, DockingLayout* layout, LayoutOverride&& constraints = {})
1804 { return BeginDockingContainer(id, layout, theme.dockContainerStyleRef, std::move(constraints)); }
1805
1806 inline bool BeginDockingContainer(DockingLayout* layout, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current())
1807 { return BeginDockingContainer(idManager.AllocateDynamicID(site), layout, style, std::move(constraints)); }
1808
1809 inline bool BeginDockingContainer(DockingLayout* layout, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current())
1810 { return BeginDockingContainer(idManager.AllocateDynamicID(site), layout, theme.dockContainerStyleRef, std::move(constraints)); }
1811
1813
1818 void Documents(ID id, DocumentSet& set, LayoutOverride&& constraints = {});
1824 void DocumentBar(ID id, DocumentSet& set, StyleRef style, LayoutOverride&& constraints = LayoutOverride::Auto());
1826 inline void DocumentBar(ID id, DocumentSet& set, LayoutOverride&& constraints = LayoutOverride::Auto()) { DocumentBar(id, set, theme.documentBarStyleRef, std::move(constraints)); }
1832
1834
1837
1839 bool Field(ID id, bool& value, std::string_view text, StyleRef style, LayoutOverride&& constraints = {});
1841 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)); }
1843 inline bool Field(ID id, bool& value, std::string_view text, LayoutOverride&& constraints = {}) { return Field(id, value, text, theme.controls->toggle, std::move(constraints)); }
1845 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)); }
1846
1849 bool Field(ID id, std::string& value, TextEditBehavior textEditBehavior, StyleRef style, LayoutOverride&& constraints = {});
1851 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)); }
1853 inline bool Field(ID id, std::string& value, StyleRef style, LayoutOverride&& constraints = {}) { return Field(id, value, TextEditBehavior::ContinuousUpdate, style, std::move(constraints)); }
1855 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)); }
1857 inline bool Field(ID id, std::string& value, TextEditBehavior textEditBehavior, LayoutOverride&& constraints = {}) { return Field(id, value, textEditBehavior, theme.controls->textbox, std::move(constraints)); }
1859 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)); }
1861 inline bool Field(ID id, std::string& value, LayoutOverride&& constraints = {}) { return Field(id, value, TextEditBehavior::ContinuousUpdate, theme.controls->textbox, std::move(constraints)); }
1863 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)); }
1864
1868 inline bool SearchField(ID id, std::string& value, const GUIContent& content, TextEditBehavior textEditBehavior, StyleRef style, LayoutOverride&& constraints = {}) { return SearchField(id, value, content, textEditBehavior, style, std::move(constraints), nullptr); }
1870 inline bool SearchField(ID id, std::string& value, const GUIContent& content, TextEditBehavior textEditBehavior = TextEditBehavior::ContinuousUpdate, LayoutOverride&& constraints = {}) { return SearchField(id, value, content, textEditBehavior, theme.searchTextboxStyleRef, std::move(constraints)); }
1872 inline bool SearchField( std::string& value, const GUIContent& content, TextEditBehavior textEditBehavior, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return SearchField(idManager.AllocateDynamicID(site), value, content, textEditBehavior, style, std::move(constraints)); }
1874 inline bool SearchField( std::string& value, const GUIContent& content, TextEditBehavior textEditBehavior = TextEditBehavior::ContinuousUpdate, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return SearchField(idManager.AllocateDynamicID(site), value, content, textEditBehavior, theme.searchTextboxStyleRef, std::move(constraints)); }
1875
1881 bool AutocompleteField(ID id, std::string& value, std::span<const std::string_view> suggestions, StyleRef style, LayoutOverride&& constraints = {});
1883 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)); }
1885 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)); }
1887 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)); }
1888
1889
1890
1891
1895 template<typename T, typename ComponentT = typename TypeDimensions<T>::ComponentType>
1896 inline bool Field(ID id, T& value, TextEditBehavior textEditBehavior, StyleRef style, NumericFieldConfig<ComponentT> config = {}, LayoutOverride&& constraints = {})
1897 {
1899 {
1900 RegisterControl(tachyon::Element { .id = id, .styleRef = style, .flags = ElementFlags::DoNotMeasureText },
1901 [this](tachyon::Element& element) { return textSystem->RegisterText(element.id, "\xe2\x80\x94", element.styleRef, element.state); },
1902 std::move(constraints));
1904 return false;
1905 }
1906
1907 if constexpr (TypeDimensions<T>::dimensions == 1)
1908 {
1909 // Inside a node row, fill the body after the label so the node stays grid-aligned.
1910 if (nodeRowFieldMinWidth > 0 && !constraints.HasFixedWidth())
1911 constraints.FlexGrow(1).MinWidth(Pixels{ nodeRowFieldMinWidth });
1912 bool modified = false;
1913 RegisterControl(tachyon::Element { .id = id, .eventHandler = ReportingChanges(guiStateManager, &value, MakeNumericalBoxHandler(guiStateManager, value, config)),
1914 .styleRef = style, .flags = ElementFlags::DoNotMeasureText },
1915 [this, &modified, &value, textEditBehavior, config](tachyon::Element& element) {
1916 const TextID textID = textSystem->RegisterEditableNumber(element.id, value, textEditBehavior, element.styleRef, element.state, modified, config);
1917 if constexpr (std::is_floating_point_v<T>)
1918 if (std::isnan(value))
1919 textSystem->SetTextColor(textID, theme.nanTextColor); // NaN reads as a warning
1920 return textID;
1921 },
1922 std::move(constraints));
1923 // A label drag writes the value from the handler: reported the frame after.
1924 modified = modified || guiStateManager.Interaction().HasBeenClicked(id);
1925 guiStateManager.SetModified(modified);
1926 return modified;
1927 } else
1928 {
1929 bool modified = false;
1930 // Width 0 + flex-grow: the group fills remaining space after the label.
1931 constraints.Width(0);
1932 // Takes its components' states, so a tooltip or context menu on it covers them.
1933 RegisterElement(tachyon::Element{ .id = id, .eventHandler = ReportingChanges(guiStateManager, &value, MakeMultiDimDragHandler<T>(guiStateManager, value, config)),
1934 .styleRef = theme.fieldElementGroupStyleRef,
1935 .flags = ElementFlags::PropagatesDescendantState }, std::move(constraints));
1937 {
1938 // Each component: a colored axis label (drag it to change the value) attached
1939 // to the component's field. A caller's own style replaces the attached field.
1940 const StyleRef componentStyle = (style == theme.controls->number || style == theme.controls->textbox) ? theme.vectorComponentStyleRef : style;
1941 for (int i = 0; i < TypeDimensions<T>::dimensions; i++)
1942 {
1943 DragLabel(TypeDimensions<T>::names[i], theme.axisLabelStyleRefs[i % 4],
1944 LayoutOverride::FixedWidth(Pixels{ theme.axisLabelWidth }).KeepWithNext()); // wraps with its field
1945 modified = Field(TypeDimensions<T>::GetComponent(value, i), textEditBehavior, componentStyle, config, LayoutOverride::Auto()
1946 .MinWidth(40)) || modified;
1947 }
1948 }
1950 modified = modified || guiStateManager.Interaction().HasBeenClicked(id);
1951 guiStateManager.SetModified(modified);
1952 return modified;
1953 }
1954 }
1955
1956 template<typename T, typename ComponentT = typename TypeDimensions<T>::ComponentType>
1957 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)); }
1959 template<typename T, typename ComponentT = typename TypeDimensions<T>::ComponentType>
1960 inline bool Field(ID id, T& value, TextEditBehavior textEditBehavior, LayoutOverride&& constraints = {}) { return Field<T>(id, value, textEditBehavior, theme.controls->number, {}, std::move(constraints)); }
1962 template<typename T, typename ComponentT = typename TypeDimensions<T>::ComponentType>
1963 inline bool Field(ID id, T& value, LayoutOverride&& constraints = {}) { return Field<T>(id, value, TextEditBehavior::ContinuousUpdate, theme.controls->number, {}, std::move(constraints)); }
1965 template<typename T, typename ComponentT = typename TypeDimensions<T>::ComponentType>
1966 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)); }
1968 template<typename T, typename ComponentT = typename TypeDimensions<T>::ComponentType>
1969 inline bool Field(ID id, T& value, StyleRef style, LayoutOverride&& constraints = {}) { return Field<T>(id, value, TextEditBehavior::ContinuousUpdate, style, {}, std::move(constraints)); }
1971 template<typename T, typename ComponentT = typename TypeDimensions<T>::ComponentType>
1972 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)); }
1974 template<typename T, typename ComponentT = typename TypeDimensions<T>::ComponentType>
1975 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)); }
1977 template<typename T, typename ComponentT = typename TypeDimensions<T>::ComponentType>
1978 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)); }
1980 template<typename T, typename ComponentT = typename TypeDimensions<T>::ComponentType>
1981 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)); }
1983 template<typename T, typename ComponentT = typename TypeDimensions<T>::ComponentType>
1984 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)); }
1986 template<typename T, typename ComponentT = typename TypeDimensions<T>::ComponentType>
1987 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)); }
1989 template<typename T, typename ComponentT = typename TypeDimensions<T>::ComponentType>
1990 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)); }
1992 template<typename T, typename ComponentT = typename TypeDimensions<T>::ComponentType>
1993 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)); }
1996 template<typename T, typename ComponentT = typename TypeDimensions<T>::ComponentType>
1997 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)); }
1998
1999
2001 template<typename T>
2002 static constexpr std::string_view TypeTag()
2003 {
2004 if constexpr (std::is_same_v<T, float>) return "f32";
2005 else if constexpr (std::is_same_v<T, double>) return "f64";
2006 else if constexpr (std::is_same_v<T, int8_t>) return "i8";
2007 else if constexpr (std::is_same_v<T, int16_t>) return "i16";
2008 else if constexpr (std::is_same_v<T, int32_t>) return "i32";
2009 else if constexpr (std::is_same_v<T, int64_t>) return "i64";
2010 else if constexpr (std::is_same_v<T, uint8_t>) return "u8";
2011 else if constexpr (std::is_same_v<T, uint16_t>) return "u16";
2012 else if constexpr (std::is_same_v<T, uint32_t>) return "u32";
2013 else if constexpr (std::is_same_v<T, uint64_t>) return "u64";
2014 else if constexpr (std::is_same_v<T, std::string>) return "string";
2015 else return {};
2016 }
2017
2019 template<typename T>
2020 bool TypedField(ID id, T& value, LayoutOverride&& constraints = {}) { return TypedField(id, value, theme.typedFieldStyleRef, std::move(constraints)); }
2022 template<typename T>
2023 bool TypedField(ID id, T& value, StyleRef style, LayoutOverride&& constraints = {})
2024 {
2025 // The box's and the type's IDs under the field's own, so they don't depend on what came before.
2026 [[maybe_unused]] const bool pushed = idManager.PushParent(id);
2027 const ID boxID = idManager.AllocateDynamicID("typed_field");
2028 const ID typeID = idManager.AllocateDynamicID("typed_field_type");
2029 if (pushed) (void)idManager.PopParent();
2030 BeginFieldBox(boxID, style, std::move(constraints));
2031 const bool changed = Field(id, value, TextEditBehavior::ContinuousUpdate, theme.typedFieldInputStyleRef, {},
2034 EndFieldBox();
2035 return changed;
2036 }
2037
2038 template<typename T>
2039 bool TypedField(T& value, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return TypedField(idManager.AllocateDynamicID(site), value, std::move(constraints)); }
2041 template<typename T>
2042 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)); }
2043
2047 template<typename T>
2048 void Field(ID id, std::vector<T>& items, StyleRef style, LayoutOverride&& constraints = {})
2049 {
2050 if (BeginArea(id, style, std::move(constraints)))
2051 {
2052 // Everything inside under the list's own ID.
2053 [[maybe_unused]] const bool pushed = idManager.PushParent(id);
2054 auto onReorder = [&items](int from, int to)
2055 {
2056 if (from < 0 || from >= (int)items.size()) return;
2057 if (to < 0 || to >= (int)items.size()) return;
2058 T moved = std::move(items[from]);
2059 items.erase(items.begin() + from);
2060 items.insert(items.begin() + to, std::move(moved));
2061 };
2062
2063 if (BeginReorderableGroup(idManager.AllocateDynamicID("list_rows"), ReorderDirection::Vertical, std::move(onReorder),
2065 {
2066 for (int i = 0; i < (int)items.size(); i++)
2067 {
2068 BeginReorderableItem(idManager.AllocateDynamicID("list_row"), theme.collectionRowStyleRef,
2070 {
2072 Text(idManager.AllocateDynamicID("list_index"), std::to_string(i), theme.collectionIndexStyleRef);
2073 if constexpr (std::is_arithmetic_v<T>)
2075 else
2076 Field(items[i], tachyon::LayoutOverride{}.FlexGrow(1));
2077 Button(theme.tabCloseIcon, [&items, i]() { items.erase(items.begin() + i); },
2078 theme.collectionRemoveStyleRef, tachyon::LayoutOverride{}.NoGrow());
2079 }
2081 }
2083 }
2084 Button(idManager.AllocateDynamicID("list_add"), "+ Add item", [&items]() { items.push_back({}); },
2086 if (pushed) (void)idManager.PopParent();
2087 EndArea();
2088 }
2089 }
2090
2091 template<typename T>
2092 void Field(ID id, std::vector<T>& items, LayoutOverride&& constraints = {}) { Field(id, items, theme.collectionAreaStyleRef, std::move(constraints)); }
2094 template<typename T>
2095 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)); }
2097 template<typename T>
2098 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)); }
2099
2102 template<typename V>
2103 void Field(ID id, std::vector<std::pair<std::string, V>>& items, StyleRef style, LayoutOverride&& constraints = {})
2104 {
2105 if (BeginArea(id, style, std::move(constraints)))
2106 {
2107 // Everything inside under the dictionary's own ID.
2108 [[maybe_unused]] const bool pushed = idManager.PushParent(id);
2109 CollectionHeader(TypeTag<V>());
2110 for (int i = 0; i < (int)items.size(); i++)
2111 {
2112 BeginHorizontal(idManager.AllocateDynamicID("dictionary_row"), theme.collectionEntryStyleRef, tachyon::LayoutOverride{}.NoShrink());
2113 // Key and value share the row evenly whatever they hold, as the header's
2114 // cells do: the columns line up from row to row.
2115 Field(items[i].first, tachyon::LayoutOverride{}.FlexGrow(1).FlexBasis(Pixels{ 0 }));
2116 Field(items[i].second, TextEditBehavior::ContinuousUpdate, theme.collectionValueStyleRef,
2117 tachyon::LayoutOverride{}.FlexGrow(1).FlexBasis(Pixels{ 0 }));
2118 Button(theme.tabCloseIcon, [&items, i]() { items.erase(items.begin() + i); },
2119 theme.collectionRemoveStyleRef, tachyon::LayoutOverride{}.NoGrow());
2120 EndHorizontal();
2121 }
2122 Button(idManager.AllocateDynamicID("dictionary_add"), "+ Add entry",
2123 [&items]() { items.push_back({ std::string{}, V{} }); }, theme.collectionAddEntryStyleRef);
2124 if (pushed) (void)idManager.PopParent();
2125 EndArea();
2126 }
2127 }
2128
2129 template<typename V>
2130 void Field(ID id, std::vector<std::pair<std::string, V>>& items, LayoutOverride&& constraints = {}) { Field(id, items, theme.collectionAreaStyleRef, std::move(constraints)); }
2132 template<typename V>
2133 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)); }
2135 template<typename V>
2136 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)); }
2137
2140 template<typename V>
2141 void Field(ID id, std::unordered_map<std::string, V>& items, StyleRef style, LayoutOverride&& constraints = {})
2142 {
2143 if (BeginArea(id, style, std::move(constraints)))
2144 {
2145 // Everything inside under the dictionary's own ID.
2146 [[maybe_unused]] const bool pushed = idManager.PushParent(id);
2147 CollectionHeader(TypeTag<V>());
2148 // Map keys are const: edit a copy, committed on Enter/blur, and re-key
2149 // after the loop (renaming onto an existing key is ignored).
2150 std::string renameFrom, renameTo;
2151 bool rename = false;
2152 for (auto& pair : items)
2153 {
2154 BeginHorizontal(idManager.AllocateDynamicID("dictionary_row"), theme.collectionEntryStyleRef, tachyon::LayoutOverride{}.NoShrink());
2155 std::string key = pair.first;
2156 if (Field(key, TextEditBehavior::None, tachyon::LayoutOverride{}.FlexGrow(1)) && key != pair.first)
2157 {
2158 renameFrom = pair.first;
2159 renameTo = key;
2160 rename = true;
2161 }
2162 Field(pair.second, TextEditBehavior::ContinuousUpdate, theme.collectionValueStyleRef, tachyon::LayoutOverride{}.FlexGrow(1));
2163 Button(theme.tabCloseIcon, [&items, k = pair.first]() { items.erase(k); },
2165 EndHorizontal();
2166 }
2167 if (rename && !items.contains(renameTo))
2168 {
2169 auto node = items.extract(renameFrom);
2170 node.key() = renameTo;
2171 items.insert(std::move(node));
2172 }
2173 Button(idManager.AllocateDynamicID("dictionary_add"), "+ Add entry",
2174 [&items]() { items.emplace(std::string{}, V{}); }, theme.collectionAddEntryStyleRef);
2175 if (pushed) (void)idManager.PopParent();
2176 EndArea();
2177 }
2178 }
2179
2180 template<typename V>
2181 void Field(ID id, std::unordered_map<std::string, V>& items, LayoutOverride&& constraints = {}) { Field(id, items, theme.collectionAreaStyleRef, std::move(constraints)); }
2183 template<typename V>
2184 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)); }
2186 template<typename V>
2187 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)); }
2188
2190 void CollectionHeader(std::string_view valueType);
2191
2193
2196
2202 bool EdgesField(ID id, BoxEdges& value, NumericFieldConfig<int32_t> config = { .stepPerPixel = 0.25, .minVal = 0, .maxVal = 64 },
2203 LayoutOverride&& constraints = {});
2205 bool CornersField(ID id, BoxCorners& value, NumericFieldConfig<int32_t> config = { .stepPerPixel = 0.25, .minVal = 0, .maxVal = 64 },
2206 LayoutOverride&& constraints = {});
2211 bool ShadowField(ID id, BoxShadow& value, LayoutOverride&& constraints = {});
2212
2214
2215
2218
2219 // ---- ColorField: swatch + color picker popup ----
2222 bool ColorField(ID id, tachyon::color4f& value, bool allowHDR, StyleRef style, LayoutOverride&& constraints = {});
2224 inline bool ColorField(ID id, tachyon::color4f& value, bool allowHDR = false, LayoutOverride&& constraints = {}) { return ColorField(id, value, allowHDR, theme.colorFieldStyleRef, std::move(constraints)); }
2226 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)); }
2228 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)); }
2230 bool ColorField(ID id, tachyon::color4b& value, StyleRef style, LayoutOverride&& constraints = {});
2232 inline bool ColorField(ID id, tachyon::color4b& value, LayoutOverride&& constraints = {}) { return ColorField(id, value, theme.colorFieldStyleRef, std::move(constraints)); }
2234 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)); }
2236 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)); }
2239 void SetColorSwatches(std::span<const tachyon::color4f> colors);
2240 std::vector<tachyon::color4f> ColorSwatches() const;
2244
2245 // ---- GradientField: gradient swatch + editor popup ----
2247 bool GradientField(ID id, tachyon::Gradient& value, StyleRef style, LayoutOverride&& constraints = {});
2249 inline bool GradientField(ID id, tachyon::Gradient& value, LayoutOverride&& constraints = {}) { return GradientField(id, value, theme.gradientSwatchStyleRef, std::move(constraints)); }
2251 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)); }
2253 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)); }
2256 bool GradientField(ID id, tachyon::GradientF& value, StyleRef style, LayoutOverride&& constraints = {});
2258 inline bool GradientField(ID id, tachyon::GradientF& value, LayoutOverride&& constraints = {}) { return GradientField(id, value, theme.gradientSwatchStyleRef, std::move(constraints)); }
2260 inline bool GradientField( tachyon::GradientF& value, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return GradientField(idManager.AllocateDynamicID(site), value, style, std::move(constraints)); }
2262 inline bool GradientField( tachyon::GradientF& value, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return GradientField(idManager.AllocateDynamicID(site), value, theme.gradientSwatchStyleRef, std::move(constraints)); }
2263
2265
2268
2269 // ---- SliderField: DragLabel + horizontal slider track + numeric textbox ----
2272 bool SliderField(ID id, float& value, float minVal, float maxVal,
2273 std::string_view text, StyleRef style, LayoutOverride&& constraints = {});
2275 inline bool SliderField(ID id, float& value, float minVal, float maxVal,
2276 std::string_view text, LayoutOverride&& constraints = {}) { return SliderField(id, value, minVal, maxVal, text, theme.sliderFieldTrackStyleRef, std::move(constraints)); }
2277
2278 inline bool SliderField(float& value, float minVal, float maxVal,
2279 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)); }
2280
2281 inline bool SliderField(float& value, float minVal, float maxVal,
2282 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)); }
2283
2285 bool SliderField(ID id, int& value, int minVal, int maxVal,
2286 std::string_view text, StyleRef style, LayoutOverride&& constraints = {});
2288 inline bool SliderField(ID id, int& value, int minVal, int maxVal,
2289 std::string_view text, LayoutOverride&& constraints = {}) { return SliderField(id, value, minVal, maxVal, text, theme.sliderFieldTrackStyleRef, std::move(constraints)); }
2290
2291 inline bool SliderField(int& value, int minVal, int maxVal,
2292 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)); }
2293
2294 inline bool SliderField(int& value, int minVal, int maxVal,
2295 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)); }
2296
2300 template<typename T> requires std::is_arithmetic_v<T>
2301 bool Slider(ID id, T& value, std::type_identity_t<T> minVal, std::type_identity_t<T> maxVal, StyleRef style, LayoutOverride&& constraints = {});
2303 template<typename T> requires std::is_arithmetic_v<T>
2304 inline bool Slider(ID id, T& value, std::type_identity_t<T> minVal, std::type_identity_t<T> maxVal, LayoutOverride&& constraints = {}) { return Slider<T>(id, value, minVal, maxVal, theme.sliderStyleRef, std::move(constraints)); }
2306 template<typename T> requires std::is_arithmetic_v<T>
2307 inline bool Slider(T& value, std::type_identity_t<T> minVal, std::type_identity_t<T> maxVal, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return Slider<T>(idManager.AllocateDynamicID(site), value, minVal, maxVal, style, std::move(constraints)); }
2309 template<typename T> requires std::is_arithmetic_v<T>
2310 inline bool Slider(T& value, std::type_identity_t<T> minVal, std::type_identity_t<T> maxVal, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return Slider<T>(idManager.AllocateDynamicID(site), value, minVal, maxVal, theme.sliderStyleRef, std::move(constraints)); }
2311
2314 template<typename T> requires std::is_arithmetic_v<T>
2315 bool RangeField(ID id, T& value, std::type_identity_t<T> minVal, std::type_identity_t<T> maxVal, LayoutOverride&& constraints = {})
2316 {
2317 if (maxVal < minVal) std::swap(minVal, maxVal);
2318 BeginHorizontal(id, theme.rangeFieldStyleRef, std::move(constraints));
2319 [[maybe_unused]] const bool pushed = idManager.PushParent(id); // the parts' IDs under the field's
2320 bool changed = Slider<T>(idManager.AllocateDynamicID("range_slider"), value, minVal, maxVal,
2322 NumericFieldConfig<T> config{};
2323 config.minVal = minVal;
2324 config.maxVal = maxVal;
2325 changed = Field<T>(idManager.AllocateDynamicID("range_value"), value, TextEditBehavior::ContinuousUpdate,
2326 theme.controls->number, config, LayoutOverride::FixedWidth(CssPx{ 56 }).NoGrow().NoShrink()) || changed;
2327 if (pushed) (void)idManager.PopParent();
2328 EndHorizontal();
2329 guiStateManager.SetModified(changed);
2330 return changed;
2331 }
2332
2333 template<typename T> requires std::is_arithmetic_v<T>
2334 inline bool RangeField(T& value, std::type_identity_t<T> minVal, std::type_identity_t<T> maxVal, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { return RangeField<T>(idManager.AllocateDynamicID(site), value, minVal, maxVal, std::move(constraints)); }
2335
2336
2337
2339
2342
2345 void DragLabel(ID id, std::string_view text, StyleRef style, LayoutOverride&& constraints = {});
2347 inline void DragLabel(ID id, std::string_view text, LayoutOverride&& constraints = {}) { DragLabel(id, text, theme.dragLabelStyleRef, std::move(constraints)); }
2349 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)); }
2351 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)); }
2352
2355 void Label(ID id, std::string_view text, StyleRef style, LayoutOverride&& constraints = {});
2358 void Label(ID id, std::string_view text, std::string_view caption, StyleRef style, LayoutOverride&& constraints = {});
2360 inline void Label(ID id, std::string_view text, std::string_view caption, LayoutOverride&& constraints = {}) { Label(id, text, caption, theme.groupLabelTopStyleRef, std::move(constraints)); }
2362 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)); }
2364 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)); }
2366 inline void Label(ID id, std::string_view text, LayoutOverride&& constraints = {}) { Label(id, text, theme.labelStyleRef, std::move(constraints)); }
2368 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)); }
2370 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)); }
2371
2373 void Text(ID id, std::string_view text, StyleRef style, LayoutOverride&& constraints = {});
2375 inline void Text(ID id, std::string_view text, LayoutOverride&& constraints = {}) { Text(id, text, theme.staticTextStyleRef, std::move(constraints)); }
2377 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)); }
2379 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)); }
2380
2383 void SelectableText(ID id, const std::span<ContentRun>& runs,
2384 std::function<void(intptr_t contentId)> onLinkActivate,
2385 StyleRef style, LayoutOverride&& constraints = {});
2387 inline void SelectableText(ID id, const std::span<ContentRun>& runs, StyleRef style, LayoutOverride&& constraints = {})
2388 { SelectableText(id, runs, {}, style, std::move(constraints)); }
2389
2390 inline void SelectableText(ID id, const std::span<ContentRun>& runs, LayoutOverride&& constraints = {})
2391 { SelectableText(id, runs, {}, theme.staticTextStyleRef, std::move(constraints)); }
2392
2393 inline void SelectableText(const std::span<ContentRun>& runs, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current())
2394 { SelectableText(idManager.AllocateDynamicID(site), runs, {}, style, std::move(constraints)); }
2395
2396 inline void SelectableText(const std::span<ContentRun>& runs, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current())
2397 { SelectableText(idManager.AllocateDynamicID(site), runs, {}, theme.staticTextStyleRef, std::move(constraints)); }
2398
2400 void Image(ID id, ImageIndex image, StyleRef style, LayoutOverride&& constraints = {});
2402 inline void Image(ID id, ImageIndex image, LayoutOverride&& constraints = {}) { Image(id, image, theme.imageStyleRef, std::move(constraints)); }
2404 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)); }
2406 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)); }
2407
2410 void Image(ID id, ImageIndex image, uint2 sourceSize, StyleRef style, LayoutOverride&& constraints = {});
2412 inline void Image(ID id, ImageIndex image, uint2 sourceSize, LayoutOverride&& constraints = {}) { Image(id, image, sourceSize, theme.imageStyleRef, std::move(constraints)); }
2414 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)); }
2416 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)); }
2417
2420 void Image(ID id, ImageIndex image, const UVRect& uv, StyleRef style, LayoutOverride&& constraints = {});
2422 inline void Image(ID id, ImageIndex image, const UVRect& uv, LayoutOverride&& constraints = {}) { Image(id, image, uv, theme.imageStyleRef, std::move(constraints)); }
2424 inline void Image( ImageIndex image, const UVRect& uv, StyleRef style, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { Image(idManager.AllocateDynamicID(site), image, uv, style, std::move(constraints)); }
2426 inline void Image( ImageIndex image, const UVRect& uv, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { Image(idManager.AllocateDynamicID(site), image, uv, theme.imageStyleRef, std::move(constraints)); }
2427
2430 void Image(ID id, ImageIndex image, uint2 sourceSize, const UVRect& uv, StyleRef style, LayoutOverride&& constraints = {});
2432 inline void Image(ID id, ImageIndex image, uint2 sourceSize, const UVRect& uv, LayoutOverride&& constraints = {}) { Image(id, image, sourceSize, uv, theme.imageStyleRef, std::move(constraints)); }
2434 inline void Image( ImageIndex image, uint2 sourceSize, const UVRect& uv, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { Image(idManager.AllocateDynamicID(site), image, sourceSize, uv, theme.imageStyleRef, std::move(constraints)); }
2435
2438 void Image(ID id, ImageIndex image, const UVRect& uv, const ImageDisplay& display, StyleRef style, LayoutOverride&& constraints = {});
2440 inline void Image(ID id, ImageIndex image, const ImageDisplay& display, LayoutOverride&& constraints = {}) { Image(id, image, UVRect{}, display, theme.imageStyleRef, std::move(constraints)); }
2442 inline void Image( ImageIndex image, const ImageDisplay& display, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { Image(idManager.AllocateDynamicID(site), image, UVRect{}, display, theme.imageStyleRef, std::move(constraints)); }
2445 void Image(ID id, ImageIndex image, uint2 sourceSize, const UVRect& uv, const ImageDisplay& display, StyleRef style, LayoutOverride&& constraints = {});
2447 inline void Image(ID id, ImageIndex image, uint2 sourceSize, const ImageDisplay& display, LayoutOverride&& constraints = {}) { Image(id, image, sourceSize, UVRect{}, display, theme.imageStyleRef, std::move(constraints)); }
2449 inline void Image( ImageIndex image, uint2 sourceSize, const ImageDisplay& display, LayoutOverride&& constraints = {}, std::source_location site = std::source_location::current()) { Image(idManager.AllocateDynamicID(site), image, sourceSize, UVRect{}, display, theme.imageStyleRef, std::move(constraints)); }
2450
2452
2455
2458 bool BeginGhostWindow(ID windowLayoutID, int2 position)
2459 {
2460 return BeginGhostWindow(windowLayoutID, position, int2{ styleManager.Px(28), styleManager.Px(28) });
2461 }
2462
2464 bool BeginGhostWindow(ID windowLayoutID, int2 position, int2 size, StyleRef styleRef)
2465 {
2466 if (windowManager->GetWindowState(windowLayoutID) == WindowState::Closing)
2467 {
2468 m_windowOpen.push_back(false); // its EndGhostWindow is still called
2469 return false;
2470 }
2471
2472 LayoutOverride constraints = LayoutOverride::FixedSize(size).Position(position.x, position.y);
2473
2475 return BeginWindow(windowLayoutID, styleRef, std::move(constraints), elementFlags);
2476 }
2477
2479 bool BeginGhostWindow(ID windowLayoutID, int2 position, int2 size)
2480 {
2481 return BeginGhostWindow(windowLayoutID, position, size, theme.ghostWindowStyleRef);
2482 }
2483
2485 bool BeginGhostWindow(ID windowLayoutID, int2 position, StyleRef styleRef)
2486 {
2487 if (windowManager->GetWindowState(windowLayoutID) == WindowState::Closing)
2488 {
2489 m_windowOpen.push_back(false); // its EndGhostWindow is still called
2490 return false;
2491 }
2492 LayoutOverride constraints = LayoutOverride{}.Position(position.x, position.y);
2494 return BeginWindow(windowLayoutID, styleRef, std::move(constraints), elementFlags);
2495 }
2496
2500 {
2501 const int32_t o = m_cursorSize > 0 ? (m_cursorSize * 14 + 16) / 32 : styleManager.Px(14);
2502 return int2{ o, o };
2503 }
2504
2505 bool BeginCursorGhostWindow(ID windowLayoutID, int2 cursorPos)
2506 {
2507 return BeginGhostWindow(windowLayoutID, cursorPos + CursorGhostOffset());
2508 }
2509
2510 bool BeginCursorGhostWindow(ID windowLayoutID, int2 cursorPos, int2 size, StyleRef styleRef)
2511 {
2512 return BeginGhostWindow(windowLayoutID, cursorPos + CursorGhostOffset(), size, styleRef);
2513 }
2514
2515 bool BeginCursorGhostWindow(ID windowLayoutID, int2 cursorPos, int2 size)
2516 {
2517 return BeginGhostWindow(windowLayoutID, cursorPos + CursorGhostOffset(), size);
2518 }
2519
2520 bool BeginCursorGhostWindow(ID windowLayoutID, int2 cursorPos, StyleRef styleRef)
2521 {
2522 return BeginGhostWindow(windowLayoutID, cursorPos + CursorGhostOffset(), styleRef);
2523 }
2524
2526 void AddGhostIcon(IconID icon, std::source_location site = std::source_location::current())
2527 {
2528 AddGhostIcon(icon, int2{ styleManager.Px(28), styleManager.Px(28) }, site);
2529 }
2530
2532 void AddGhostIcon(IconID icon, int2 size, std::source_location site = std::source_location::current())
2533 {
2534 auto dragGhostIconID = idManager.AllocateDynamicID(site);
2535 tachyon::Element ghostIcon
2536 {
2537 .id = dragGhostIconID,
2538 .textID = TextID::Invalid,
2539 .iconID = icon,
2540 .styleRef = theme.ghostIconStyleRef,
2541 };
2542
2543 auto ghostIconRes = elementStorage.Add(std::move(ghostIcon), tachyon::LayoutOverride::FixedSize(size));
2544 VERIFY(ghostIconRes.status);
2545 VERIFY(windowRegistry.Add(ghostIconRes.ref));
2546 }
2547
2550 {
2551 EndWindow();
2552 }
2553
2555
2558
2560 bool BeginWindow(ID windowLayoutID, std::string_view title, ElementFlags flags = ElementFlags::WindowUserControlled | ElementFlags::WindowIsCentered, int monitorIndex = -1)
2561 {
2562 return BeginWindow(windowLayoutID, title, theme.windowStyleRef, LayoutOverride{}, flags, monitorIndex);
2563 }
2564
2566 bool BeginWindow(ID windowLayoutID, std::string_view title, StyleRef styleRef, ElementFlags flags = ElementFlags::WindowUserControlled | ElementFlags::WindowIsCentered, int monitorIndex = -1)
2567 {
2568 return BeginWindow(windowLayoutID, title, styleRef, LayoutOverride{}, flags, monitorIndex);
2569 }
2570
2572 bool BeginWindow(ID windowLayoutID, std::string_view title, LayoutOverride&& constraints, ElementFlags flags = ElementFlags::WindowUserControlled | ElementFlags::WindowIsCentered, int monitorIndex = -1)
2573 {
2574 return BeginWindow(windowLayoutID, title, theme.windowStyleRef, std::move(constraints), flags, monitorIndex);
2575 }
2576
2577
2580 {
2581 return BeginWindow(windowLayoutID, theme.windowStyleRef, LayoutOverride{}, flags, monitorIndex);
2582 }
2583
2585 bool BeginWindow(ID windowLayoutID, StyleRef styleRef, ElementFlags flags = ElementFlags::WindowUserControlled | ElementFlags::WindowIsCentered, int monitorIndex = -1)
2586 {
2587 return BeginWindow(windowLayoutID, styleRef, LayoutOverride{}, flags, monitorIndex);
2588 }
2589
2591 bool BeginWindow(ID windowLayoutID, LayoutOverride&& constraints, ElementFlags flags = ElementFlags::WindowUserControlled | ElementFlags::WindowIsCentered, int monitorIndex = -1)
2592 {
2593 return BeginWindow(windowLayoutID, theme.windowStyleRef, std::move(constraints), flags, monitorIndex);
2594 }
2595
2597 bool BeginWindow(ID windowLayoutID, StyleRef styleRef, LayoutOverride&& constraints, ElementFlags flags = ElementFlags::WindowUserControlled | ElementFlags::WindowIsCentered, int monitorIndex = -1)
2598 {
2599 return BeginWindow(windowLayoutID, "", styleRef, std::move(constraints), flags, monitorIndex);
2600 }
2601
2602
2607 bool BeginWindow(ID windowLayoutID, std::string_view title, StyleRef styleRef, LayoutOverride&& constraints, ElementFlags flags = ElementFlags::WindowUserControlled | ElementFlags::WindowIsCentered, int monitorIndex = -1)
2608 {
2609 const bool open = OpenWindow(windowLayoutID, title, styleRef, std::move(constraints), flags, monitorIndex);
2610 m_windowOpen.push_back(open);
2611 return open;
2612 }
2613
2615 bool OpenWindow(ID windowLayoutID, std::string_view title, StyleRef styleRef, LayoutOverride&& constraints, ElementFlags flags, int monitorIndex)
2616 {
2617 if (windowLayoutID == ID::Invalid())
2618 {
2619 ReportMisuse("GUIApplication: BeginWindow with an invalid ID (not shown)");
2620 return false;
2621 }
2622
2623 // Closed by the user since last frame.
2624 if (windowManager->GetWindowState(windowLayoutID) == WindowState::Closing
2625 || windowManager->WasUserClosed(windowLayoutID))
2626 {
2627 return false;
2628 }
2629 if (!m_restoredWindows.empty())
2630 ApplyRestoredWindow(windowLayoutID, constraints, flags);
2631
2632 if (monitorIndex == -1)
2633 {
2634 if (constraints.x.type == PositionType::Fixed &&
2635 constraints.y.type == PositionType::Fixed)
2636 {
2637 monitorIndex = windowManager->GetMonitorIndexAt(tachyon::int2{ .x = constraints.x.near, .y = constraints.y.near });
2638 } else
2639 monitorIndex = windowManager->GetPrimaryMonitorIndex();
2640 }
2641
2642 Element windowElement
2643 {
2644 .id = windowLayoutID,
2645 .textID = (title.size() == 0) ? TextID::Invalid : textSystem->RegisterText(windowLayoutID, title, styleRef, tachyon::ElementState::None),
2646 .styleRef = styleRef,
2647 .monitorIndex = (int16_t)monitorIndex,
2648 .flags = ElementFlags::IsWindow | flags
2649 };
2650
2651 auto addResult = elementStorage.Add(std::move(windowElement),
2652 std::move(constraints));
2653 VERIFY(addResult.status);
2654 windowRegistry.BeginWindowScope(windowLayoutID, addResult.ref);
2656
2657 tabChainManager.BeginWindow(windowLayoutID);
2658 [[maybe_unused]] bool pushed = idManager.PushParent(windowLayoutID);
2659 assert(pushed); // windows are top-level, so this can't fail
2660
2661 m_windowIdScopeStack.push_back(pushed);
2662 activeWindowID = windowLayoutID;
2663 return true;
2664 }
2665
2668 {
2669 if (m_windowOpen.empty())
2670 {
2671 ReportMisuse("GUIApplication: EndWindow without BeginWindow (ignored)");
2672 return;
2673 }
2674 const bool open = m_windowOpen.back();
2675 m_windowOpen.pop_back();
2676 if (open)
2677 CloseWindow();
2678 }
2679
2681
2686 template<void (GUIApplication::*EndFn)()>
2687 class [[nodiscard]] Scope
2688 {
2689 public:
2691 Scope(GUIApplication& app, bool open) : m_app(&app), m_open(open) {}
2692 Scope(Scope&& other) noexcept : m_app(std::exchange(other.m_app, nullptr)), m_open(other.m_open) {}
2693 Scope(const Scope&) = delete;
2694 Scope& operator=(const Scope&) = delete;
2695 Scope& operator=(Scope&&) = delete;
2696 ~Scope() { End(); }
2697
2699 void End()
2700 {
2701 if (GUIApplication* app = std::exchange(m_app, nullptr))
2702 (app->*EndFn)();
2703 }
2704 explicit operator bool() const { return m_open; }
2705
2706 private:
2707 GUIApplication* m_app;
2708 bool m_open;
2709 };
2710
2714 template<class... A> auto Window(A&&... a) { return Scope<&GUIApplication::EndWindow>(*this, BeginWindow(std::forward<A>(a)...)); }
2715 template<class... A> auto GhostWindow(A&&... a) { return Scope<&GUIApplication::EndGhostWindow>(*this, BeginGhostWindow(std::forward<A>(a)...)); }
2716 template<class... A> auto CursorGhostWindow(A&&... a){ return Scope<&GUIApplication::EndGhostWindow>(*this, BeginCursorGhostWindow(std::forward<A>(a)...)); }
2717 template<class... A> auto Menu(A&&... a) { return Scope<&GUIApplication::EndMenu>(*this, BeginMenu(std::forward<A>(a)...)); }
2718 template<class... A> auto MenuBar(A&&... a) { return Scope<&GUIApplication::EndMenuBar>(*this, BeginMenuBar(std::forward<A>(a)...)); }
2719 template<class... A> auto ContextMenu(A&&... a) { return Scope<&GUIApplication::EndContextMenu>(*this, BeginContextMenu(std::forward<A>(a)...)); }
2720 template<class... A> auto Tooltip(A&&... a) { return Scope<&GUIApplication::EndTooltip>(*this, BeginTooltip(std::forward<A>(a)...)); }
2721 template<class... A> auto Cached(A&&... a) { return Scope<&GUIApplication::EndCached>(*this, BeginCached(std::forward<A>(a)...)); }
2722 template<class... A> auto Horizontal(A&&... a) { return Scope<&GUIApplication::EndHorizontal>(*this, BeginHorizontal(std::forward<A>(a)...)); }
2723 template<class... A> auto Vertical(A&&... a) { return Scope<&GUIApplication::EndVertical>(*this, BeginVertical(std::forward<A>(a)...)); }
2724 template<class... A> auto HorizontalWrap(A&&... a) { return Scope<&GUIApplication::EndHorizontalWrap>(*this, BeginHorizontalWrap(std::forward<A>(a)...)); }
2725 template<class... A> auto VerticalWrap(A&&... a) { return Scope<&GUIApplication::EndVerticalWrap>(*this, BeginVerticalWrap(std::forward<A>(a)...)); }
2726 template<class... A> auto Area(A&&... a) { return Scope<&GUIApplication::EndArea>(*this, BeginArea(std::forward<A>(a)...)); }
2727 template<class... A> auto LabelGroup(A&&... a) { return Scope<&GUIApplication::EndLabelGroup>(*this, BeginLabelGroup(std::forward<A>(a)...)); }
2728 template<class... A> auto ButtonGroup(A&&... a) { return Scope<&GUIApplication::EndButtonGroup>(*this, BeginButtonGroup(std::forward<A>(a)...)); }
2729 template<class... A> auto ToggleGroup(A&&... a) { return Scope<&GUIApplication::EndToggleGroup>(*this, BeginToggleGroup(std::forward<A>(a)...)); }
2730 template<class... A> auto Table(A&&... a) { return Scope<&GUIApplication::EndTable>(*this, BeginTable(std::forward<A>(a)...)); }
2731 template<class... A> auto Row(A&&... a) { return Scope<&GUIApplication::EndRow>(*this, BeginRow(std::forward<A>(a)...)); }
2732 template<class... A> auto ListView(A&&... a) { return Scope<&GUIApplication::EndListView>(*this, BeginListView(std::forward<A>(a)...)); }
2733 template<class... A> auto GridView(A&&... a) { return Scope<&GUIApplication::EndGridView>(*this, BeginGridView(std::forward<A>(a)...)); }
2734 template<class... A> auto TabBar(A&&... a) { return Scope<&GUIApplication::EndTabBar>(*this, BeginTabBar(std::forward<A>(a)...)); }
2735 template<class... A> auto Toolbar(A&&... a) { return Scope<&GUIApplication::EndToolbar>(*this, BeginToolbar(std::forward<A>(a)...)); }
2736 template<class... A> auto StatusBar(A&&... a) { return Scope<&GUIApplication::EndStatusBar>(*this, BeginStatusBar(std::forward<A>(a)...)); }
2737 template<class... A> auto TitleBar(A&&... a) { return Scope<&GUIApplication::EndTitleBar>(*this, BeginTitleBar(std::forward<A>(a)...)); }
2738 template<class... A> auto ReorderableGroup(A&&... a) { return Scope<&GUIApplication::EndReorderableGroup>(*this, BeginReorderableGroup(std::forward<A>(a)...)); }
2739 template<class... A> auto ReorderableItem(A&&... a) { return Scope<&GUIApplication::EndReorderableItem>(*this, BeginReorderableItem(std::forward<A>(a)...)); }
2740 template<class... A> auto Disabled(A&&... a) { return Scope<&GUIApplication::EndDisabled>(*this, BeginDisabled(std::forward<A>(a)...)); }
2741 template<class... A> auto Invalid(A&&... a) { return Scope<&GUIApplication::EndInvalid>(*this, BeginInvalid(std::forward<A>(a)...)); }
2742 template<class... A> auto Selected(A&&... a) { return Scope<&GUIApplication::EndSelected>(*this, BeginSelected(std::forward<A>(a)...)); }
2743 template<class... A> auto Indeterminate(A&&... a) { return Scope<&GUIApplication::EndIndeterminate>(*this, BeginIndeterminate(std::forward<A>(a)...)); }
2744 template<class... A> auto DockingContainer(A&&... a) { return Scope<&GUIApplication::EndDockingContainer>(*this, BeginDockingContainer(std::forward<A>(a)...)); }
2745 template<class... A> auto DockingFrame(A&&... a) { return Scope<&GUIApplication::EndDockingFrame>(*this, BeginDockingFrame(std::forward<A>(a)...)); }
2747
2750
2753 {
2755 if (!m_windowIdScopeStack.empty() && m_windowIdScopeStack.back())
2756 (void)idManager.PopParent();
2757 if (!m_windowIdScopeStack.empty())
2758 m_windowIdScopeStack.pop_back();
2761 activeWindowID = ID::Invalid();
2763 }
2764
2766 void AddBox(ID id, int2 size, StyleRef styleRef, TextID textID = TextID::Invalid)
2767 {
2768 Element boxElement {};
2769 boxElement.id = id;
2770 boxElement.flags = ElementFlags::None;
2771 boxElement.styleRef = styleRef;
2772 boxElement.textID = textID;
2773 boxElement.state = guiStateManager.GetCurrentState(id);
2774
2775 auto childB1 = elementStorage.Add(std::move(boxElement), LayoutOverride::FixedSize(size));
2776 VERIFY(childB1.status);
2777 VERIFY(windowRegistry.Add(childB1.ref));
2778 }
2779
2781 void AddBox(int2 size, StyleRef styleRef, TextID textID = TextID::Invalid, std::source_location site = std::source_location::current())
2782 {
2783 AddBox(idManager.AllocateDynamicID(site), size, styleRef, textID);
2784 }
2785
2787 void AddBox(ID id, int2 size, StyleRef styleRef, std::string_view text)
2788 {
2790 auto childB1 = elementStorage.Add(Element
2791 {
2792 .id = id,
2793 .textID = textSystem->RegisterText(id, text, styleRef, state),
2794 .styleRef = styleRef,
2795 .flags = ElementFlags::None,
2796 .state = state
2797 },
2799 VERIFY(childB1.status);
2800 VERIFY(windowRegistry.Add(childB1.ref));
2801 }
2802
2804 void AddBox(ID id, int2 size, StyleRef styleRef, IconID iconID, std::string_view text)
2805 {
2807 auto childB1 = elementStorage.Add(Element
2808 {
2809 .id = id,
2810 .textID = textSystem->RegisterText(id, iconID, text, styleRef, state),
2811 .styleRef = styleRef,
2812 .flags = ElementFlags::None,
2813 .state = state
2814 },
2816 VERIFY(childB1.status);
2817 VERIFY(windowRegistry.Add(childB1.ref));
2818 }
2819
2821 void AddBox(ID id, StyleRef styleRef, IconID iconID, std::string_view text)
2822 {
2824 auto childB1 = elementStorage.Add(Element
2825 {
2826 .id = id,
2827 .textID = textSystem->RegisterText(id, iconID, text, styleRef, state),
2828 .styleRef = styleRef,
2829 .flags = ElementFlags::None,
2830 .state = state
2831 });
2832 VERIFY(childB1.status);
2833 VERIFY(windowRegistry.Add(childB1.ref));
2834 }
2835
2837 void AddBox(StyleRef styleRef, std::string_view text, std::source_location site = std::source_location::current())
2838 {
2839 AddBox(idManager.AllocateDynamicID(site), styleRef, IconID::Invalid, text);
2840 }
2841
2843 void AddBox(int2 size, StyleRef styleRef, std::string_view text, std::source_location site = std::source_location::current())
2844 {
2845 AddBox(idManager.AllocateDynamicID(site), size, styleRef, text);
2846 }
2847
2849
2852
2853 // ------------------------------------------------------------------
2854 // Settings panel
2855 // ------------------------------------------------------------------
2856 // Two-pane settings panel: a page tree, a sizer, and the selected page's content.
2857 // Owns only selection and tree width; page state belongs to the application.
2860 {
2862 struct Page
2863 {
2867 std::string name;
2869 std::function<void()> render;
2872 };
2873
2875 std::vector<Page> pages;
2877 std::string header;
2882
2885 {
2886 std::vector<TreeViewRow> rows;
2887 std::vector<int> visibleIdx;
2889 } internal;
2890
2892 tachyon::ID AddPage(tachyon::ID id, std::string_view name,
2893 std::function<void()> render)
2894 {
2895 return AddPage(id, name, IconID::Invalid, std::move(render));
2896 }
2897
2898 tachyon::ID AddPage(tachyon::ID id, std::string_view name, IconID icon,
2899 std::function<void()> render)
2900 {
2901 pages.push_back({ id, std::string(name), std::move(render), icon });
2903 return id;
2904 }
2905 };
2906
2909
2911
2929
2931 void PersistWindow(std::string key, ID windowID);
2933 void PersistDocking(std::string key, DockingLayout& layout);
2935 void PersistTable(std::string key, TableState& state, std::span<VirtualTableColumn> columns);
2937 void PersistToolbars(std::string key, std::span<std::vector<ToolbarItem>, kToolbarSideCount> sides);
2939 void PersistValue(std::string key, bool& value);
2941 void PersistValue(std::string key, int& value);
2943 void PersistValue(std::string key, float& value);
2945 void PersistValue(std::string key, std::string& value);
2949 void PersistDocuments(std::string key, std::function<std::vector<DocumentWindowRef>()> windows);
2953 void PersistShortcuts(std::string key, CommandManager& commands);
2956 void PersistLayoutPresets(std::string key, LayoutPresets& presets);
2958 void PersistThemeVariables(std::string key);
2962 std::vector<SavedDocumentWindow> TakeSavedDocuments(std::string_view key);
2971 bool RestoreDocumentLayout(Document& document, const SavedDocument& saved,
2972 const std::function<std::optional<ID>(std::string_view key)>& makePanel = {});
2975 void RestoreWindowPlace(ID windowID, const SavedDocumentWindow& saved);
2978 std::string SaveDockLayout(const DockingLayout& layout) const;
2989 bool ApplyDockLayout(DockingLayout& layout, std::string_view tree,
2990 const std::function<std::optional<ID>(std::string_view key)>& makePanel = {});
2992 std::string SaveUIState() const;
2995 Result<void> RestoreUIState(std::string_view json);
2996
2998
2999 private:
3003
3005 bool SegmentedImpl(ID id, int selected, std::span<const std::string_view> options,
3006 std::function<void(int)> pick, LayoutOverride&& constraints);
3007
3009 std::vector<ID> m_cacheRecordStack;
3010
3012 bool m_keyboardPending = false;
3013 bool m_tabPending = false;
3014 uint64_t m_inputFlagsFrame = 0;
3015 void RefreshCachedInputFlags();
3016
3018 void NoteSwatchClaim(ID swatchID);
3022 VisualColorStyleIndex AppColorStyle(ID owner, color4f color);
3024 std::string PendingLabelText() const;
3026 std::string_view PendingLabelTextView() const;
3028 struct ColorSwatchLook SwatchLook() const;
3029
3031 RecentIDMap<tachyon::ID> m_panelContentIDs;
3032
3034 std::vector<const ControlStyles*> controlStylesStack;
3035
3036 ID tooltipWindowID { ID::Invalid() };
3037 ID contextMenuWindowID { ID::Invalid() };
3038 ID contextMenuTargetID { ID::Invalid() };
3039 std::optional<int2> contextMenuScreenPos;
3040 bool m_contextMenuClaimed = false;
3041 uint32_t m_contextMenuOpenings = 0;
3042 ID tabDragGhostWindowID{ ID::Invalid() };
3043
3044 FrameTimingSample frameTimingHistory[kFrameHistoryCount] = {};
3045 int frameTimingHead = 0;
3046
3048 ColumnDragState m_columnDrag{};
3049 TreeDropState m_treeDropState{};
3050
3051 // ---- ListView ID->index map (shared by every list view; cleared once per frame) ----
3052 // Filled by ListItem when dragDrop is on; valid in end-of-frame handlers via FindListItemIndex().
3053 std::unordered_map<tachyon::ID, int> m_listItemIndexByID;
3055 RecentIDMap<int32_t> m_busyButtonWidths;
3057 struct TasksPopover
3058 {
3059 tachyon::ID windowID = tachyon::ID::Invalid();
3060 bool open = false;
3061 };
3062 RecentIDMap<TasksPopover> m_tasksPopovers;
3064 void TaskBar(ID id, const ProgressTask& task, StyleRef trackStyle, LayoutOverride&& constraints);
3066 void StepGlyph(ID id, TaskState state);
3067
3068
3071 TreeViewState m_treeState{};
3072 GridViewState m_gridViewState;
3073
3075 std::unordered_map<tachyon::ID, GridItemRenameInfo> m_gridItemRenameByID;
3076
3077
3079 std::optional<TableEmit> m_tableEmit;
3081 std::vector<std::optional<TableEmit>> m_outerTableEmits;
3082
3083 int CurrentCellCol() const
3084 {
3085 const int c = m_tableEmit->currentCol;
3086 assert(c < int(m_tableEmit->columnCount));
3087 return c;
3088 }
3089
3090 TabBarState m_tabBarState;
3091 TabState m_tabState;
3092
3094 void EnableVisiblePanels(DockingLayout& layout);
3095
3098 DockingConstructionState m_dockingState;
3099
3102 std::vector<DockingLayout*> m_dockingLayoutsThisFrame{};
3104 std::vector<Panel> m_closedPanels;
3107 struct CommandModeClaim { CommandMode mode; uint64_t frame; };
3108 std::unordered_map<ID, CommandModeClaim> m_commandModeClaims;
3109 uint64_t m_commandModeFrame = 0;
3111 CommandMode m_claimedCommandMode = CommandMode::Default;
3112
3114 std::vector<struct ToolbarDockState*> m_toolbarDocksThisFrame{};
3115
3117 void SyncDockingScrollOffsets();
3118
3120 void SyncToolbarDockRects();
3121
3123 tachyon::DockNode* FindDockLeafTabBarCachedAtScreenPos(tachyon::int2 screenPos);
3124
3125 std::vector<std::unique_ptr<FloatingDockWindow>> m_floatingDockWindows;
3126
3128 void EmitFloatingDockWindowsOf(const DocumentSet* documents);
3129
3132 std::vector<DocumentSet*> m_documentSetsThisFrame{};
3134 bool ActivateDocumentOf(const DockingLayout* layout);
3136 struct ShownToast
3137 {
3138 ToastID handle = 0;
3139 ToastDesc desc;
3140 ID id = ID::Invalid();
3141 float shownAt = 0.0f;
3142 float leftAt = -1.0f;
3143 float shownFor = 0.0f;
3144 };
3145 std::vector<ShownToast> m_toasts;
3146 ToastID m_nextToast = 0;
3147 float m_toastsTime = -1.0f;
3148 bool m_toastsExpanded = false;
3150 struct StatusBarSeen { ID id = ID::Invalid(); float builtAt = -1.0f; };
3151 std::unordered_map<ID, StatusBarSeen> m_statusBars;
3152 ID m_toastStackID = ID::Invalid();
3153 bool m_toastsBuilt = false;
3154
3155 DocumentDrag m_documentDrag;
3156 std::vector<IntRect> m_documentBarRects;
3157 std::optional<DocumentMove> m_documentMove;
3159 void ApplyDocumentMove();
3161 void SyncDocumentRects();
3163 DocumentSet* FindDocumentBarAt(tachyon::int2 screenPos);
3164
3166 void RegisterFrameHooks(); // per-frame stage hooks; Initialize (and test harnesses) call it
3167 void RegisterFrameBalanceChecks();
3169 static void ReportMisuse(const char* message);
3171 bool OpenMenu(ID menuID, const GUIContent& content, StyleRef buttonStyle, StyleRef menuStyle, StyleRef itemStyle, LayoutOverride&& constraints);
3172 void CloseMenu();
3175 enum class TooltipBox : uint8_t { Plain, Lines, Help, Error };
3176 bool OpenTooltip(ID targetID, TooltipBox box = TooltipBox::Plain);
3178 void ShowPinTooltip(const NodeGraph& view, ID socketID, PropertyEndpoint pin, bool isOutput);
3180 void CloseTooltip();
3182 struct CutShortText
3183 {
3184 ID id = ID::Invalid();
3185 ID windowID = ID::Invalid();
3186 int2 windowPos{};
3187 int2 at{};
3188 int32_t width = 0;
3189 int32_t height = 0;
3190 bool textOnly = false;
3191 int16_t monitorIndex = -1;
3192 };
3196 CutShortText FindCutShortText(int2 mousePos) const;
3199 void ShowCutShortText();
3200 CutShortText m_cutShort{};
3202 mutable std::vector<ElementRef> m_cutShortWalk;
3204 GradientF m_gradientFieldGiven, m_gradientFieldEdited;
3205 bool OpenContextMenuWindow(ID targetID);
3206 bool OpenCached(ID id, StyleRef style, uint64_t signature, LayoutOverride&& constraints);
3207 static void ReportInvalidControlID(ID id);
3209 void RegisterTabStop(ID id);
3211 bool SearchField(ID id, std::string& value, const GUIContent& content, TextEditBehavior textEditBehavior, StyleRef style, LayoutOverride&& constraints, ID* outFieldID);
3214 void BeginFieldBox(ID id, StyleRef style, LayoutOverride&& constraints);
3215 void EndFieldBox();
3216
3219 void ApplyPendingStyleReload();
3221 bool BoxSidesField(ID id, uint16_t* const (&sides)[4], const std::string_view (&captions)[4],
3222 const std::string_view (&names)[4], NumericFieldConfig<int32_t> config, LayoutOverride&& constraints);
3223
3226 void UpdateMouseCursor(ID hoverID, ID hoverWindowID, int2 mousePosition);
3227
3228 void OnRender(float elapsedTimeSecs);
3231 void FireStateTransitions(float elapsedTimeSecs);
3234 struct TransitionsSeen
3235 {
3236 std::vector<ID> hover;
3237 std::vector<ID> focused;
3238 ID active = ID::Invalid();
3239 };
3240 TransitionsSeen m_transitionsSeen;
3241 TransitionsSeen m_transitionsNow;
3243 void RenderBoxShadows(IntRect rectLayout, IntRect clipRectScreen, const TransitionState& ts, bool ring);
3245 void RenderShadowLayer(IntRect rectLayout, IntRect clipRectScreen, const VisualShadow& s, float radius);
3247 void RenderInvalidHalo(IntRect rectLayout, IntRect clipRectScreen, const TransitionState& ts, float grown);
3250 void RenderInvalidBorder(IntRect rectLayout, IntRect clipRectScreen, const TransitionState& ts, IntRect snappedPx);
3254 IntRect OpaqueInterior(IntRect rectLayout, const TransitionState& ts) const;
3257 bool IsBoxBlank(const Element& element, const TransitionState& ts) const;
3258 void OnFrame();
3259 Result<void> RecoverDevice();
3260
3262 std::string m_resourceRoot;
3263 std::unique_ptr<IWindowBackend> m_osWindowBackend;
3264 ImageWindowBackend* m_imageWindows { nullptr };
3265 MouseButtons m_injectedButtons { MouseButtons::None };
3266 int2 InjectedScreenPos(ID windowID, int2 pos, bool press = false);
3267 void InjectedFocus(ID windowID, bool press);
3268 AllocationHooks m_allocationHooks;
3269 std::unique_ptr<GraphicsContext> m_graphicsBackend;
3270 MouseButtons m_lastPhysicalButtons { MouseButtons::None };
3271 std::string ResourcePath(std::string_view path) const; // relative paths resolve against m_resourceRoot
3272 std::string m_themePath { "themes/dark.css" };
3273 bool m_initialized = false;
3274 bool m_inFrame = false;
3275 Result<void> m_themeReload {};
3276
3278 struct PersistedWindow { std::string key; ID target; };
3279 struct PersistedDock { std::string key; DockingLayout* target; };
3280 struct PersistedTable { struct Target { TableState* state; std::span<VirtualTableColumn> columns; }; std::string key; Target target; };
3281 struct PersistedToolbars { std::string key; std::span<std::vector<ToolbarItem>, kToolbarSideCount> target; };
3282 struct PersistedValue { using Target = std::variant<bool*, int*, float*, std::string*>; std::string key; Target target; };
3283 struct PersistedDocuments { std::string key; std::function<std::vector<DocumentWindowRef>()> target; };
3284 struct PersistedShortcuts { std::string key; CommandManager* target; };
3285 struct PersistedPresets { std::string key; LayoutPresets* target; };
3286 struct RestoredWindow
3287 {
3288 IntRect rect {};
3289 IntRect monitor {};
3290 WindowMode mode = WindowMode::Normal;
3291 bool hasMonitor = false;
3292 bool hasPosition = false;
3293 bool rectDone = false;
3294 };
3295 std::vector<PersistedWindow> m_persistWindows;
3296 std::vector<PersistedDock> m_persistDocks;
3297 std::vector<PersistedTable> m_persistTables;
3298 std::vector<PersistedToolbars> m_persistToolbars;
3299 std::vector<PersistedValue> m_persistValues;
3300 std::vector<PersistedDocuments> m_persistDocuments;
3301 std::vector<PersistedShortcuts> m_persistShortcuts;
3302 std::vector<PersistedPresets> m_persistPresets;
3303 std::vector<std::string> m_persistThemeVariables;
3305 std::unordered_map<std::string, std::vector<SavedDocumentWindow>> m_savedDocuments;
3306 std::unordered_map<ID, RestoredWindow> m_restoredWindows;
3307 void ApplyRestoredWindow(ID windowID, LayoutOverride& constraints, ElementFlags& flags);
3309 void PlaceOnSavedMonitor(RestoredWindow& restored) const;
3310 int32_t m_cursorSize = 0;
3313 std::vector<bool> m_windowOpen, m_menuOpen, m_tooltipOpen, m_cachedOpen;
3314 bool m_nextMenuIsDropdown = false;
3317 std::vector<ConstructionScopes> m_tooltipScopes;
3320 std::vector<ConstructionScopes> m_menuScopes;
3322 std::string m_loadedThemePath;
3323 float m_loadedFontScale { 1.0f };
3324 std::optional<AccentColors> m_accent;
3325 std::optional<AccentColors> m_loadedAccent;
3327 std::map<std::string, ThemeVariableOverrides, std::less<>> m_themeVariables;
3329 ThemeVariableOverrides& ThemeVariables();
3331 void CurveTree(CurveViewRef view);
3332 void CurveRuler(CurveViewRef view);
3335 static std::string ThemePathKey(std::string_view themePath);
3337 double m_themeReloadAt = -1.0;
3339 static constexpr double kThemeSettleSecs = 0.4;
3340 std::vector<std::string> m_styleFiles { "styles.css" };
3341 float m_globalFontScale { 1.0f };
3342 float m_uiScale { 1.0f };
3343 std::optional<bool> m_reducedMotion;
3344 WheelMode m_wheelMode = DefaultWheelMode();
3345
3348 struct ThemeCrossfade
3349 {
3350 ID window = ID::Invalid();
3351 tachyon::Image* image = nullptr;
3352 ImageIndex index = ImageIndex::Invalid;
3353 };
3354 static constexpr float kThemeCrossfadeSecs = 0.2f;
3355 std::vector<ThemeCrossfade> m_crossfades;
3356 float m_crossfadeStart = 0.0f;
3357 VisualBoxStyleIndex m_crossfadeStyle = VisualBoxStyleIndex::Invalid;
3359 void CaptureThemeCrossfade();
3361 void EndThemeCrossfade();
3362 float m_displayScale { 1.0f };
3363 FrameClock m_frameClock;
3364 bool m_themeReloadPending { false };
3365
3366 // ---- Redrawing only when needed (SetRedrawMode) ----
3367 RedrawMode m_redrawMode = RedrawMode::WhenNeeded;
3368 RedrawRequests m_redrawRequests;
3369 bool m_moreFrames = true;
3370 uint64_t m_seenEvents = 0;
3371 int64_t m_timerAt = INT64_MAX;
3372 float m_buildTimerAt = INFINITY;
3373 int64_t m_frameTickNanos = 0;
3374 bool m_paceFrames = false;
3375 std::thread::id m_uiThread;
3376 VsyncLock m_vsyncLock;
3379 void PaceFrame(float hz);
3382 float AnimationRefreshRate() const;
3385 void ScheduleFrameAt(float frameSecs) { m_buildTimerAt = std::min(m_buildTimerAt, frameSecs); }
3387 void NoteFrameNeeds(float elapsedTimeSecs);
3388
3389 tachyon::ElementRef RegisterElementInternal(tachyon::Element&& element, LayoutOverride&& constraints, bool updateState = true);
3390
3393 void InvalidateCachedScopesForInput(ID overID);
3395 static std::vector<ID> CollectPropagatedAncestors(const ElementStorage& storage, ID leafID);
3397 static void CollectPropagatedAncestors(const ElementStorage& storage, ID leafID, std::vector<ID>& out);
3401 void NoteTargetAncestors(int2 mousePos);
3404 void NoteContextMenuOwner();
3406 ID TooltipHoverID() const
3407 {
3408 const ID hovered = guiStateManager.Interaction().GetHoveredID();
3409 return hovered != ID::Invalid() ? hovered : guiStateManager.Interaction().GetHoveredDisabledID();
3410 }
3412 void InvalidateCachedScopesAbove(ID id);
3415 void RebuildCachedScopesAbove(ID id) { m_cacheRebuildRequests.push_back(id); }
3416 std::vector<ID> m_cacheRebuildRequests;
3417
3419 void NotePanelContentID(ID panelId, ID contentID) { m_panelContentIDs[panelId] = contentID; }
3422 void ReleaseOwnIDs();
3424 void ErasePanels(DockingLayout& layout);
3427 void ApplyClaimedCommandMode();
3430 void DispatchInput(ID overID);
3434 std::vector<ID> ActedOnIDs(ID overID) const;
3436 void ReportChangedPanels(std::vector<ID> actedOn);
3437
3439 TextAlign nodeRowTextAlign = TextAlign::Start;
3440
3443 int32_t nodeRowFieldMinWidth = 0;
3444
3445 bool BeginDockingFrame();
3446 void EndDockingFrame();
3447
3448 ID activeWindowID { ID::Invalid() };
3449 std::vector<bool> m_windowIdScopeStack;
3450
3452 void EmitNodeViewOverlays(NodeViewRef view, ID canvasID);
3453
3455 struct TitleBarInfo { ID barID = ID::Invalid(); ID maximizeID = ID::Invalid(); std::vector<ID> captions; };
3456 RecentIDMap<TitleBarInfo> m_titleBars;
3457 std::vector<ID> m_titleBarStack;
3458 std::vector<ID> m_titleBarCaptions;
3459 std::unordered_set<ID> m_closeRequests;
3463 struct SuggestionRow { IconID icon = IconID::Invalid; std::string_view text; std::string_view trailing; };
3464 static constexpr int kMaxSuggestions = 12;
3465 void SuggestionPopup(ID windowID, ID anchorID, std::span<const SuggestionRow> rows, int current,
3466 bool reserveIcon, int32_t minWidth, std::function<void(int)> onPick);
3468 struct AutocompleteState
3469 {
3470 ID listWindowID = ID::Invalid();
3471 int current = -1;
3472 bool dismissed = false;
3473 bool picked = false;
3474 int32_t width = 0;
3475 };
3476 RecentIDMap<AutocompleteState> m_autocomplete;
3479 struct RetiredWindow { ID id = ID::Invalid(); uint32_t framesLeft = 0; };
3480 std::vector<RetiredWindow> m_retiredWindows;
3482 void PruneStaleControlState();
3483
3486 struct PressOutsideWatch { ID inside[2]; std::function<void()> onPressOutside; };
3487 std::vector<PressOutsideWatch> m_pressOutsideWatches;
3488 void CloseOnPressOutside(ID inside, ID alsoInside, std::function<void()> onPressOutside)
3489 { m_pressOutsideWatches.push_back({ { inside, alsoInside }, std::move(onPressOutside) }); }
3490 void RunPressOutsideWatches();
3495 void DispatchFileDrops(const FrameInput& input);
3497 ID OfferFileDrop(EventType type, ID overID, int2 screenPos, const FileDrop* drop);
3498 ID m_fileDragTargetID = ID::Invalid();
3499 ID m_drawnDropTargetID = ID::Invalid();
3500 std::vector<FileDrop> m_heldFileDrops;
3501 std::function<void(const FileDrop&)> m_fileDropHandler;
3502 std::vector<TextStyle> m_mnemonicStyles;
3504 struct ScrimFade { float amount = 0.0f; bool wanted = false; VisualColorStyleIndex color = VisualColorStyleIndex::Invalid; };
3505 std::unordered_map<ID, ScrimFade> m_scrims;
3506 float m_scrimTime = -1.0f;
3507 void DrawScrims(float now);
3509 struct PendingAfterDraw { uint32_t endIdx; ElementRef owner; };
3510 std::vector<PendingAfterDraw> m_pendingAfterDraws;
3512 void TitleBarCaption(ID id) { m_titleBarCaptions.push_back(id); }
3513 void DockFloatingWindow(FloatingDockWindow& fw);
3514
3516 void EmitColorPicker(tachyon::color4f& outColor, bool allowHDR);
3518 void EmitGradientEditor(tachyon::GradientF& outGradient);
3522 bool GradientFieldCore(ID id, tachyon::GradientF& value, const tachyon::Gradient* gradient8,
3523 bool& cancelled, StyleRef style, LayoutOverride&& constraints);
3524
3527 void EmitColumnSizers(TableEmit& emit, int colStart, int colEnd,
3528 bool skipDragged = false);
3530 void EmitColumnSeparators(TableEmit& emit, int colStart, int colEnd);
3532 void EmitColumnBackgrounds(TableEmit& emit, int colStart, int colEnd);
3533
3535 void UpdateTableFollowTail(TableState& state, int32_t viewportH, int32_t contentH);
3536 void ScrollTableSectionsToBottom(TableState& state);
3538 void EmitTableSectionSeparator();
3539
3541 tachyon::LayoutOverride ApplyColumnDragOffsetX(tachyon::LayoutOverride lo,
3542 const TableEmit& emit, int c) const
3543 {
3544 if (emit.dragActive)
3545 lo = std::move(lo).PositionX(tachyon::PositionConstraintAxis::Relative(emit.columns[c].internal.dragOffsetX));
3546 return lo;
3547 }
3549 void MirrorTableScroll(TableState* state);
3552 void EmitTableHeaderCell(TableEmit& emit, tachyon::ID tableID, int c, int16_t gridCol,
3553 bool isStretchTrack, int sectionMin, int sectionMax,
3554 int effectiveSortCol, IconID sortIcon);
3556 void EmitTableHeaderSection(TableEmit& emit, tachyon::ID tableID,
3557 int colStart, int colEnd, bool lastColIsStretch,
3558 int effectiveSortCol, IconID sortIcon);
3561 GridTrack ComputeSectionColumnTrack(const TableEmit& emit, int c, int colEnd,
3562 bool isMiddle, bool fitContent = false) const;
3565 void OpenTableBodySection(TableEmit& emit, tachyon::ID sectionID, tachyon::StyleRef sectionStyle,
3566 tachyon::LayoutOverride&& layout, bool sampleViewport);
3569 void CloseTableBodySection(TableEmit& emit,
3570 tachyon::ID sectionBodyID, bool emitVerticalScrollbar,
3571 bool suppressHorzScrollbar = false);
3573 void EmitVirtualBodyRows(TableEmit& emit,
3574 int colStart, int colEnd,
3575 int totalRowCount, int32_t actualRowHeight,
3576 int firstVisible, int lastVisible,
3577 tachyon::ID rowsRangeID,
3578 bool isLastSection);
3579
3582 void EmitDraggedColumnOnTop(TableEmit& emit, tachyon::ID tableID,
3583 int colStart, int colEnd,
3584 int firstVisible, int lastVisible,
3585 tachyon::ID rowsRangeID,
3586 bool lastColIsStretch,
3587 int effectiveSortCol, IconID sortIcon);
3589 void EmitDirectCellText(const VirtualTableColumn& column, TableEmit& emit,
3590 tachyon::ID cellID, tachyon::ElementState cellState, tachyon::ElementFlags cellFlags,
3591 tachyon::StyleRef cellStyleRef, tachyon::EventHandler cellHandler,
3592 tachyon::TextID textID,
3593 int colIdx, int colStart, int16_t gridRow);
3594 void EmitDirectCellCustom(const VirtualTableColumn& column, TableEmit& emit,
3595 tachyon::ID cellID, tachyon::ElementState cellState, tachyon::ElementFlags cellFlags,
3596 tachyon::StyleRef cellStyleRef, tachyon::EventHandler cellHandler,
3597 bool cellSelected,
3598 std::function<void()> emit_fn,
3599 int colIdx, int colStart, int16_t gridRow);
3601 tachyon::ElementRef EmitDirectCellTree(const VirtualTableColumn& column, TableEmit& emit,
3602 tachyon::ID cellID, tachyon::ElementState cellState, tachyon::ElementFlags cellFlags,
3603 tachyon::StyleRef cellStyleRef, tachyon::EventHandler cellHandler,
3604 bool cellSelected,
3605 tachyon::TextID textID,
3606 int treeDepth, TreeOpenRef treeIsOpen, IconID treeIcon,
3607 uint32_t treeAncestorMask, bool treeIsLastSibling,
3608 std::string* treeRenameBuffer, bool treeRenameActive,
3609 tachyon::ID treeBodyID, bool reserveExpander,
3610 int colIdx, int colStart, int16_t gridRow);
3612 void EmitDirectRowBackdrop(tachyon::ID rowID, int16_t gridRow,
3613 int colStart, int colEnd,
3614 tachyon::ElementState backdropState,
3615 tachyon::ElementFlags backdropFlags,
3616 tachyon::StyleRef rowStyle,
3617 tachyon::EventHandler backdropHandler,
3618 TableState* tableState,
3619 bool isLastSection);
3621 void EmitDirectRowSpacer(int16_t gridRow,
3622 int colStart, int colEnd, int32_t height);
3625 tachyon::EventHandler BuildRowBackdropHandler(TableState* state,
3626 tachyon::ID containerID);
3628 tachyon::EventHandler BuildTableContainerHandler(TableState* state,
3629 tachyon::ID containerID);
3630
3632 bool IsTreeItemSelected(tachyon::ID id, int itemIndex) const;
3633 tachyon::TextID TreeItemRegisterText(tachyon::ID id, std::string_view text, IconID icon, StyleRef style, tachyon::ElementState state);
3634 void TreeItemRowCustomDraw(const tachyon::ElementRef& rowRef, bool hasArrow, tachyon::ID rowID);
3635 tachyon::EventHandler MakeTreeRowDragDropHandler(tachyon::ID rowID, bool rowHasChildren, ItemDragDropConfig* dd, bool* isOpen = nullptr);
3636 bool TreeItemRenameCheck(tachyon::ID bodyID, std::string* renameBuffer, StyleRef textStyle);
3637
3638 struct TreeClickState { tachyon::ID lastClickID = tachyon::ID::Invalid(); int64_t lastClickTimeNanos = 0; };
3639
3640 };
3641
3643} // 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:63
void PopShownState()
Definition gui_state_atomic_values.h:82
void PopSelected()
Definition gui_state_atomic_values.h:66
void PushIndeterminate()
Definition gui_state_atomic_values.h:71
void PushShownState(ElementState states)
Everything built until PopShownState looks as in states too (Hover, Active, Focused): a picture of a ...
Definition gui_state_atomic_values.h:77
void PopIndeterminate()
Definition gui_state_atomic_values.h:72
void PushDisabled()
Definition gui_state_atomic_values.h:62
void PushInvalid()
Definition gui_state_atomic_values.h:68
bool IsIndeterminate() const
Definition gui_state_atomic_values.h:93
void PopInvalid()
Definition gui_state_atomic_values.h:69
void PushSelected()
Definition gui_state_atomic_values.h:65
ID GetTakerID() const
The element whose handler took the drag under the pointer: the validated target or one of its ancesto...
Definition gui_drag_drop_state.h:116
The frame's element tree.
Definition gui_element_storage.h:96
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:193
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:2688
Scope & operator=(const Scope &)=delete
Scope(Scope &&other) noexcept
Definition gui_application.h:2692
~Scope()
Definition gui_application.h:2696
void End()
Ends the container now instead of when the scope leaves.
Definition gui_application.h:2699
Scope(GUIApplication &app, bool open)
Made by the scope functions below.
Definition gui_application.h:2691
Scope(const Scope &)=delete
Scope & operator=(Scope &&)=delete
The application: owns the windows, the systems and the frame loop.
Definition gui_application.h:209
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:2393
void Image(ID id, ImageIndex image, uint2 sourceSize, const UVRect &uv, LayoutOverride &&constraints={})
As above, in the theme's image style.
Definition gui_application.h:2432
bool BeginShownState(ElementState states)
The controls until EndShownState look hovered, pressed (Active) or focused as states say,...
Definition gui_application.h:1480
void Spinner(ID id, SpinnerSize size=SpinnerSize::Medium, LayoutOverride &&constraints={})
A ring with an arc going round it, a turn every 0.8 s, in the theme's track and accent colors: work u...
bool Slider(T &value, std::type_identity_t< T > minVal, std::type_identity_t< T > 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:2310
tachyon::ElementRef RegisterElement(tachyon::Element &&element, std::string_view text, LayoutOverride &&constraints)
As above, with text registered as its text.
bool BeginMenu(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 menu styles.
Definition gui_application.h:938
void TaskProgress(const ProgressTask &task, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:806
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:1576
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:1845
bool Plot(ID id, PlotViewRef view, LayoutOverride &&constraints={})
Series of values as lines, bars or areas over the x range (a histogram's channels),...
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:715
bool SearchField(std::string &value, const GUIContent &content, 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:1872
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:1076
void ClearThemeVariables()
Back to the theme's own values for all of them, for the theme loaded.
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:1476
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:2351
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:2098
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:1376
auto Horizontal(A &&... a)
Definition gui_application.h:2722
friend class GUIApplicationInternals
GUIApplicationInternals (gui_application_internal.h) re-exposes these to the library's own code and t...
Definition gui_application.h:3002
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:1474
bool SearchField(std::string &value, const GUIContent &content, 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:1874
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:1506
void SetTooltip(std::string_view text, std::string_view shortcut)
As above, for the last control.
Definition gui_application.h:1099
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:1074
void SetRedrawMode(RedrawMode mode)
How often Run draws a frame; RedrawMode::WhenNeeded by default, which sleeps while nothing changes.
Definition gui_application.h:586
auto ReorderableItem(A &&... a)
Definition gui_application.h:2739
bool BeginDockingContainer(ID id, DockingLayout *layout, LayoutOverride &&constraints={})
As above, in the theme's dock style.
Definition gui_application.h:1803
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:1347
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:1997
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:2416
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:1109
bool CommandButton(CommandID command, StyleRef style, LayoutOverride &&constraints={})
Icon button for a command; the tooltip shows its name, and its shortcut in a chip after it ("Undo" th...
Result< void > Run()
Loops over the frame calls below until the app quits; an error when the GPU device was lost and could...
virtual ~GUIApplication()
Cleans up when Cleanup wasn't called (an early return, a failed test), so the device,...
void EndIndeterminate()
Closes BeginIndeterminate.
Definition gui_application.h:663
void EndArea()
Closes BeginArea.
auto Table(A &&... a)
Definition gui_application.h:2730
bool BeginListView(ID id, int *selectedIndex, int itemCount, StyleRef style, LayoutOverride &&constraints={})
As above, without drag and drop.
Definition gui_application.h:1366
const std::string & GetThemePath() const
See GUIApplicationInitializeOptions.
Definition gui_application.h:437
void InjectPen(ID windowID, const PenState &pen)
The pen, before the pointer events it goes with; a default PenState is the mouse.
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:1791
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:2607
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:1993
void Label(ID id, std::string_view text, LayoutOverride &&constraints={})
As the first, in the theme's label style.
Definition gui_application.h:2366
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:2023
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:2294
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:2396
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:2251
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:2039
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:702
void AddBox(ID id, int2 size, StyleRef styleRef, std::string_view text)
As above, with text.
Definition gui_application.h:2787
bool BeginListView(ID id, int *selectedIndex, int itemCount, ItemDragDropConfig *dragDrop, StyleRef style, LayoutOverride &&constraints={})
Opens a list view of ListItems.
void ProgressBar(ID id, float value, bool failed, StyleRef style, LayoutOverride &&constraints={})
A bar value (0 to 1, clamped) of the way full; failed fills it in the error color,...
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:975
auto ContextMenu(A &&... a)
Definition gui_application.h:2719
void Image(ID id, ImageIndex image, const ImageDisplay &display, LayoutOverride &&constraints={})
As above, the whole image, in the theme's image style.
Definition gui_application.h:2440
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:2103
static void WalkTreeViewVisibility(const std::vector< TreeViewRow > &rows, const std::unordered_set< ID > &openRows, std::vector< int > &visibleIdx)
Writes the flat indices of the rows shown to visibleIdx: those under no closed branch,...
std::unique_ptr< LayoutEngine > layoutEngine
Lays out the elements each frame. Created by Initialize.
Definition gui_application.h:214
std::unique_ptr< TextAtlasManager > textAtlasManager
The glyph atlas. Created by Initialize.
Definition gui_application.h:218
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.
StyleRef ReorderableGroupStyle(ReorderDirection direction, bool isWrapped) const
The theme's reorderable group style for a direction and wrapping.
Definition gui_application.h:1333
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,...
void StatusProgress(const ProgressTask &task, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:820
static void TransferPanel(tachyon::ID panelID, tachyon::DockNode *sourceNode, DockingLayout *sourceLayout, DockingLayout *targetLayout)
Moves a panel from sourceNode/sourceLayout to targetLayout, fixing up selectedTab.
bool Plot(PlotViewRef view, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:908
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:1704
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:2020
bool BeginVerticalWrap(ID id, LayoutOverride &&constraints={})
As above, in the theme's plain style.
Definition gui_application.h:1256
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:2187
bool Field(ID id, T &value, StyleRef style, LayoutOverride &&constraints={})
As the first, updating continuously, with the default config.
Definition gui_application.h:1969
void EndGhostWindow()
Closes BeginGhostWindow or BeginCursorGhostWindow.
Definition gui_application.h:2549
TransitionManager transitionManager
In-progress visual state transitions, per element.
Definition gui_application.h:236
bool MenuItem(ID id, const GUIContent &content, std::function< void()> onClick, StyleRef style, LayoutOverride &&constraints={})
Without a shortcut, in style.
Definition gui_application.h:1021
void InjectMouseLeave(ID windowID)
The pointer left the window.
auto VerticalWrap(A &&... a)
Definition gui_application.h:2725
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:1429
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:963
void EmitFloatingDockWindows(const DocumentSet &documents)
With documents in several main windows: in each, after its Documents, the windows of the panels torn ...
void ClaimCommandMode(ID owner, CommandMode mode)
For a control with shortcuts of its own (CommandManager::RegisterMode): while the focus is within own...
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:736
void EndVerticalWrap()
Closes BeginVerticalWrap.
WheelMode GetWheelMode() const
The graphics backend Initialize uses; without one it creates a vulkan::VulkanGraphicsContext.
Definition gui_application.h:553
void Image(ID id, ImageIndex image, const UVRect &uv, const ImageDisplay &display, StyleRef style, LayoutOverride &&constraints={})
The part uv of image shown as display says: tinted, its channels picked (one shown as grey,...
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:2738
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:321
GUITheme theme
The loaded theme: the style refs, icons and metrics the controls use; theme.GetStyle finds a CSS clas...
Definition gui_application.h:285
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:1287
MenuManager menuManager
The open menus and the menu bar's triggers.
Definition gui_application.h:241
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:1990
void CurveEditor(CurveViewRef view, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:894
auto ListView(A &&... a)
Definition gui_application.h:2732
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:1439
StyleManager styleManager
The registered styles; Px converts CSS pixels to pixels at the UI scale.
Definition gui_application.h:269
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:1676
bool BeginCursorGhostWindow(ID windowLayoutID, int2 cursorPos, StyleRef styleRef)
As above, with a style, sized to its content.
Definition gui_application.h:2520
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:2843
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:1725
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:2275
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 ...
std::string SaveDockLayout(const DockingLayout &layout) const
A layout's dock tree as text, panels by type, else title, as a LayoutPreset keeps it; empty when it h...
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:1038
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:2406
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:1581
bool BusyButton(ID id, const GUIContent &content, bool busy, std::string_view busyText, std::function< void()> onClick, LayoutOverride &&constraints={})
As above, in the theme's button style.
Definition gui_application.h:750
static void RebuildTreeViewIndex(std::vector< TreeViewRow > &rows)
Recomputes skipCount / ancestorLineMask / isLastSibling from row depths.
void SetAccent(std::optional< AccentColors > accent)
Replaces the palette's accent with accent (its dark color in a dark palette, its light one in a light...
auto DockingContainer(A &&... a)
Definition gui_application.h:2744
void EndWindow()
Closes BeginWindow; called whether or not it returned true.
Definition gui_application.h:2667
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:234
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:725
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:2379
Result< void > RestoreUIState(std::string_view json)
Applies JSON text from SaveUIState.
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)
As above, the open state a bool of yours; null for leaves.
Definition gui_application.h:1638
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:2226
bool Segmented(T &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.
Definition gui_application.h:1178
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:685
auto CursorGhostWindow(A &&... a)
Definition gui_application.h:2716
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:1327
void DocumentBar(ID id, DocumentSet &set, LayoutOverride &&constraints=LayoutOverride::Auto())
As above, in the theme's document bar style.
Definition gui_application.h:1826
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.
CommandManager commandManager
Commands, their shortcuts and the undo history.
Definition gui_application.h:277
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:1150
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:1678
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:1661
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:1972
void GetFrameTimingHistory(std::span< FrameTimingSample > out) const
Copies the ring chronologically (oldest first) into out.
bool GradientField(ID id, tachyon::GradientF &value, StyleRef style, LayoutOverride &&constraints={})
As above, for a GradientF: up to GradientF::kMaxStops stops, colors over 1 (HDR), and each stop's int...
void EndContextMenu()
Closes BeginContextMenu; called whether or not it returned true.
void EndShownState()
Closes BeginShownState.
Definition gui_application.h:1482
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:1885
bool Timeline(ID id, TimelineState &state, const TimelineOptions &options, LayoutOverride &&constraints={})
Playback on one row: go to the start, step back a frame, play or pause, step on a frame,...
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:2837
void ClosePanel(DockingLayout &layout, ID panelID)
Closes a panel of layout for good, wherever it is: out of its tree (its leaf closing up when it empti...
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:1330
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:517
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:1034
float GetUIScale() const
The graphics backend Initialize uses; without one it creates a vulkan::VulkanGraphicsContext.
Definition gui_application.h:537
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:1841
void SetClipboard(std::unique_ptr< IClipboard > clipboardImpl)
Copy and paste for text fields, and of images.
Definition gui_application.h:520
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:2560
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:1721
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:959
void RequestReloadTheme(std::string_view themePath, float fontScale)
Deferred to the start of the next frame; safe from event handlers.
static void WalkTreeViewVisibility(const std::vector< TreeViewRow > &rows, std::vector< int > &visibleIdx, TableState &state)
As above, for a tree drawn by a table with state, open as its openRows says: when rows were opened or...
void CurveEditor(ID id, CurveViewRef view, LayoutOverride &&constraints={})
The curve editor a CurveField opens, as a control of its own: the channels and the selected key's tim...
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:2464
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:1223
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:1589
WindowRegistry windowRegistry
The elements of each window, filled as the windows are built.
Definition gui_application.h:274
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:532
bool CommandSearch(ID id, CommandSearchState &state, LayoutOverride &&constraints={})
As above, in the theme's command search style.
Definition gui_application.h:1719
bool Toggle(ID id, bool &value, const GUIContent &content, LayoutOverride &&constraints={})
As above, in the theme's toggle style.
Definition gui_application.h:738
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:2288
auto TabBar(A &&... a)
Definition gui_application.h:2734
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:730
auto Tooltip(A &&... a)
Definition gui_application.h:2720
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:1017
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:1215
bool BeginTable(ID id, VirtualTableColumn *columns, size_t columnCount, TableState &state, StyleRef style, LayoutOverride &&constraints={})
Opens a table.
bool Slider(ID id, T &value, std::type_identity_t< T > minVal, std::type_identity_t< T > maxVal, LayoutOverride &&constraints={})
As above, in the theme's slider style.
Definition gui_application.h:2304
auto TitleBar(A &&... a)
Definition gui_application.h:2737
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:1863
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:1315
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:1368
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:953
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:683
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:1723
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:2745
bool GradientField(ID id, tachyon::GradientF &value, LayoutOverride &&constraints={})
As above, in the theme's gradient swatch style.
Definition gui_application.h:2258
void EndDisabled()
Closes BeginDisabled.
Definition gui_application.h:1470
std::chrono::steady_clock::time_point m_frameStart
Internal: when the current frame started (set by UpdateFrame).
Definition gui_application.h:291
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:951
void IndeterminateProgressBar(LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:775
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:1571
float frameTime
The last frame's duration in seconds, including any vsync wait or Run's pace wait.
Definition gui_application.h:293
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:1523
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:2526
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:1389
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:272
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:2236
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:1013
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:995
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:1978
GraphicsContext * graphicsContext
the backend from SetGraphicsBackend
Definition gui_application.h:225
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...
void CircularProgress(ID id, float value, LayoutOverride &&constraints={})
As above, in the theme's style.
Definition gui_application.h:787
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:1806
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:1859
tachyon::EventHandler MakeLabelHandler()
A label's handler: a click focuses the control the label belongs to.
bool SearchField(ID id, std::string &value, const GUIContent &content, TextEditBehavior textEditBehavior, StyleRef style, LayoutOverride &&constraints={})
A Field with a leading icon inside its border; style is the border's.
Definition gui_application.h:1868
bool Switch(ID id, bool &value, std::string_view text, StyleRef style, LayoutOverride &&constraints={})
Switches value itself.
Definition gui_application.h:719
bool Viewport(ID id, ViewportView &view, LayoutOverride &&constraints={})
A 3D view: the app's scene, drawn by view.onRender into an image the library keeps at the view's size...
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:1052
void SetColorSwatches(std::span< const tachyon::color4f > colors)
The color picker's swatches, which the user adds to and removes from; set them to start from the app'...
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...
auto StatusBar(A &&... a)
Definition gui_application.h:2736
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:2278
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 SearchField(ID id, std::string &value, const GUIContent &content, TextEditBehavior textEditBehavior=TextEditBehavior::ContinuousUpdate, LayoutOverride &&constraints={})
As above, in the theme's search style.
Definition gui_application.h:1870
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:2249
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:2585
DockDropResult FindDockDropTargetAtScreenPos(tachyon::int2 screenPos)
The leaf whose content (as last laid out) holds screenPos, the part of it the point is in (an edge,...
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.
bool BeginMenu(ID id, const GUIContent &content, LayoutOverride &&constraints={})
As above, in the theme's menu styles.
Definition gui_application.h:934
void Image(ImageIndex image, uint2 sourceSize, const ImageDisplay &display, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:2449
ID TreeDropTargetRow() const
The tree row a drag is over (drives the drop indicator), or Invalid.
Definition gui_application.h:1435
bool Timeline(TimelineState &state, const TimelineOptions &options, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:846
bool CornersField(ID id, BoxCorners &value, NumericFieldConfig< int32_t > config={ .stepPerPixel=0.25,.minVal=0,.maxVal=64 }, LayoutOverride &&constraints={})
As EdgesField, for corner radii: top left, top right, bottom right and bottom left.
auto ToggleGroup(A &&... a)
Definition gui_application.h:2729
void SetDisabledTooltip(std::string_view text, std::string_view reason)
As above, for the last control.
Definition gui_application.h:1114
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:2048
void TaskProgress(ID id, const ProgressTask &task, LayoutOverride &&constraints={})
A piece of work in full: its name and percent (or note) over its bar, a cancel button when onCancel i...
bool Field(ID id, T &value, StyleRef style, NumericFieldConfig< ComponentT > config, LayoutOverride &&constraints={})
As the first, updating continuously.
Definition gui_application.h:1966
uint32_t ContextMenuOpenings() const
Counts the context menus opened, a right click on a target whose menu is already open included.
Definition gui_application.h:1139
void PersistValue(std::string key, bool &value)
Keeps an app value.
bool BeginDropdownMenu(ID id, const GUIContent &content, StyleRef buttonStyle, StyleRef menuStyle, StyleRef itemStyle, LayoutOverride &&constraints={})
A menu opened from a dropdown: as BeginMenu, with an arrow after its text also in a menu bar or title...
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:1981
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:717
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:2715
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:2228
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:2566
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:2597
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:723
void DocumentLine(const DocumentSet &set, LayoutOverride &&constraints=LayoutOverride::Auto())
The line under the document bar of set, in the active document's color, across what it's in: after th...
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:1957
void CloseAllDocuments(DocumentSet &set)
Closes every document of set, as CloseDocument does each: at exit, say.
void RenderNodeView(NodeViewRef view)
Builds view (canvas, nodes, wires and overlays) in the current container: a NodeView,...
DragVisualizer ImageDragGhost(ImageIndex image, uint2 size)
A ghost for a drag of a picture: image fitted into 64 x 64 CSS px by the pointer, keeping its shape.
void DismissToast(ToastID toast)
Takes a toast away, as its close button does.
void Skeleton(LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:798
auto Selected(A &&... a)
Definition gui_application.h:2742
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:961
bool CurveField(ID id, CurveViewRef view, LayoutOverride &&constraints={})
A curve in a box, over the curves' range: a click opens the curve editor (CurveEditor) in a window un...
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,...
void ProgressSteps(ID id, std::span< const ProgressTask > steps, LayoutOverride &&constraints={})
The steps of a longer job, one a row: a glyph for its state (a check once done, a spinner while runni...
bool RangeField(T &value, std::type_identity_t< T > minVal, std::type_identity_t< T > maxVal, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:2334
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:1809
void ProgressSteps(std::span< const ProgressTask > steps, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:814
const std::string & GetResourceRoot() const
See GUIApplicationInitializeOptions.
Definition gui_application.h:468
static constexpr int kFrameHistoryCount
~4s @ 60fps
Definition gui_application.h:299
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:1765
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:2092
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:1091
bool BeginVerticalWrap(ID id, StyleRef style, LayoutOverride &&constraints={})
A vertical container whose children wrap onto further columns.
void Image(ImageIndex image, const UVRect &uv, 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:2424
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:2402
IWindowBackend * windowBackend
SetWindowBackend's windows plus render-to-image windows.
Definition gui_application.h:224
void SetTooltip(IconID icon, std::string_view text)
As above, with an icon, on the control just drawn.
Definition gui_application.h:1093
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:1234
void Spinner(SpinnerSize size=SpinnerSize::Medium, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:781
bool BeginArea(ID id, LayoutOverride &&constraints={})
As above, in the theme's area style.
Definition gui_application.h:1192
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:1023
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:525
void IndeterminateProgressBar(ID id, StyleRef style, LayoutOverride &&constraints={})
A bar for work of unknown length: a segment with soft ends slides along it, from start to end every 1...
RedrawMode GetRedrawMode() const
Builds the UI; called each frame.
Definition gui_application.h:587
bool Field(ID id, std::string &value, StyleRef style, LayoutOverride &&constraints={})
As above, updating continuously.
Definition gui_application.h:1853
bool BeginStatusBar(ID id, LayoutOverride &&constraints={})
As above, in the theme's status bar style.
Definition gui_application.h:1692
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:2130
void ProgressBar(ID id, float value, LayoutOverride &&constraints={})
As above, not failed, in the theme's bar style.
Definition gui_application.h:765
auto Cached(A &&... a)
Definition gui_application.h:2721
bool Field(ID id, T &value, TextEditBehavior textEditBehavior, LayoutOverride &&constraints={})
As above, with the default config.
Definition gui_application.h:1960
void Image(ID id, ImageIndex image, const UVRect &uv, StyleRef style, LayoutOverride &&constraints={})
Draws the part uv of image stretched over the element's padding box: a cell of an atlas (UVRect::From...
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:1694
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:2136
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.
void ReleaseDockingLayout(DockingLayout &layout)
Closes a layout for good, as ForgetDockingLayout does, and empties it: its panels are hidden (onDisab...
bool BeginMenuBar(ID id, LayoutOverride &&constraints={})
As above, in the theme's menu bar style.
Definition gui_application.h:1050
void TimelineEditor(TimelineViewRef view, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:871
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:1225
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:698
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:1321
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.
ID DropTargetID() const
The element that takes the drag under the pointer, wherever the drag came from: files from another ap...
Definition gui_application.h:1452
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:2724
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:2095
void RequestRedrawIn(float seconds)
Asks for a frame seconds from now (a clock's next tick). Safe from any thread.
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:1851
const ThemeVariableOverrides & GetThemeVariables() const
The variables set with SetThemeVariable for the theme loaded.
GradientManager gradientManager
GPU pages for the gradients styles use.
Definition gui_application.h:267
void Image(ID id, ImageIndex image, uint2 sourceSize, const ImageDisplay &display, LayoutOverride &&constraints={})
As above, the whole image, in the theme's image style.
Definition gui_application.h:2447
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.
float SecondsUntilFrame() const
Seconds until a frame is needed: 0 when NeedsFrame is true, INFINITY when nothing is due (only input ...
void PersistValue(std::string key, float &value)
As above, for a float.
auto Invalid(A &&... a)
Definition gui_application.h:2741
bool BeginMenu(const GUIContent &content, 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:936
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:1227
void DragLabel(ID id, std::string_view text, LayoutOverride &&constraints={})
As above, in the theme's drag label style.
Definition gui_application.h:2347
bool BeginDisabled()
Controls emitted in between are disabled: drawn dimmed, and they take no input.
Definition gui_application.h:1468
void Toasts()
The toasts, in the current window's bottom-right corner over what's built before; call it last in the...
void IndeterminateProgressBar(ID id, LayoutOverride &&constraints={})
As above, in the theme's bar style.
Definition gui_application.h:773
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:1196
bool BeginTooltip()
As above, on the control just drawn.
Definition gui_application.h:1120
bool CurveField(CurveViewRef view, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:887
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:973
void ShowContentTooltip(ID id, const GUIContent &content)
The content's tooltip, if it has one, on the control id.
Definition gui_application.h:657
IDManager idManager
Element IDs: static ones (CreateStaticID), call-site ones (AllocateDynamicID) and parent scopes (Push...
Definition gui_application.h:231
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:700
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:2042
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:2387
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:2615
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:2141
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:1040
static TreeOpenRef TreeViewOpenRef(const std::vector< TreeViewRow > &rows, size_t flat, TableState &state)
The TreeCell open state of flat row flat in the view with state: its key in state....
Definition gui_application.h:1413
bool Field(ID id, bool &value, std::string_view text, LayoutOverride &&constraints={})
As above, in the theme's toggle style.
Definition gui_application.h:1843
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:1312
OnGuiFunc onGui
Runs a frame from inside the OS's modal resize loop, so windows repaint while resized.
Definition gui_application.h:281
bool BeginVertical(ID id, LayoutOverride &&constraints={})
As above, in the theme's plain style.
Definition gui_application.h:1245
bool applicationQuit
Set to true to end Run (UpdateFrame then returns false).
Definition gui_application.h:289
void PersistValue(std::string key, std::string &value)
As above, for a string.
bool GradientField(tachyon::GradientF &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:2262
void StatusProgress(ID id, const ProgressTask &task, LayoutOverride &&constraints={})
A piece of work in a status bar: a small spinner, its name, a 120px bar and its note ("1,...
bool Field(ID id, T &value, LayoutOverride &&constraints={})
As above, updating continuously.
Definition gui_application.h:1963
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:1529
void SetReducedMotion(std::optional< bool > reduced)
Reduced motion: changes of state show at once instead of blending.
bool ShadowField(ID id, BoxShadow &value, LayoutOverride &&constraints={})
A shadow: its color over its offsets (X, Y), blur and spread.
void DocumentBar(ID id, DocumentSet &set, StyleRef style, LayoutOverride &&constraints=LayoutOverride::Auto())
The document bar of set alone: its tabs, "+", "N open" and the line in the active document's color.
bool BeginSelected()
Items emitted in between render as selected.
Definition gui_application.h:1464
void SetResourceRoot(std::string_view root)
The folder the resources load from: compiled shaders, default fonts and relative theme paths.
Definition gui_application.h:467
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:223
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:1599
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:734
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:227
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:713
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.
ID DragGhostWindowID() const
The window a drag's ghost goes in, by the pointer (see BeginCursorGhostWindow).
Definition gui_application.h:1458
auto Row(A &&... a)
Definition gui_application.h:2731
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:1260
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:2184
void PersistLayoutPresets(std::string key, LayoutPresets &presets)
Keeps the layouts the user saved and the file types' layouts; the app adds its built-in ones itself,...
bool BusyButton(ID id, const GUIContent &content, bool busy, std::string_view busyText, std::function< void()> onClick, StyleRef style, LayoutOverride &&constraints={})
A button at work: a spinner in place of its icon and busyText ("Saving...") in place of its text,...
void Image(ID id, ImageIndex image, const UVRect &uv, LayoutOverride &&constraints={})
As above, in the theme's image style.
Definition gui_application.h:2422
bool CommandButton(CommandID command, LayoutOverride &&constraints={})
As above, in the theme's button style.
Definition gui_application.h:691
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).
bool BeginDropdownMenu(ID id, const GUIContent &content, LayoutOverride &&constraints={})
As above, in the theme's menu-bar dropdown style (menu-bar-dropdown) and menu styles.
Definition gui_application.h:944
void AddRecentColor(tachyon::color4f color)
Adds a color to the picker's recent ones, as OK does: newest first, each once, at most 8.
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:2364
void TreeCell(std::string_view text, int depth, TreeOpenRef 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].
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:295
auto Window(A &&... a)
Definition gui_application.h:2714
const Result< void > & ThemeReloadResult() const
How the last reload went; on an error the previous theme stays.
Definition gui_application.h:436
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:2002
void Skeleton(ID id, LayoutOverride &&constraints={})
As above, in the theme's style.
Definition gui_application.h:796
bool DestructiveMenuItem(ID id, const GUIContent &content, std::function< void()> onClick, StyleRef style, LayoutOverride &&constraints={})
Without a shortcut, in style.
Definition gui_application.h:1036
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:1030
auto Menu(A &&... a)
Definition gui_application.h:2717
bool BeginToggleGroup(LayoutOverride &&constraints={})
The same for Toggles and Field(bool).
void PersistThemeVariables(std::string key)
Keeps each theme's variables, set with SetThemeVariable.
void AddBox(ID id, StyleRef styleRef, IconID iconID, std::string_view text)
As above, sized to its content.
Definition gui_application.h:2821
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:2362
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:2133
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:2404
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:1194
bool BeginGhostWindow(ID windowLayoutID, int2 position, StyleRef styleRef)
Sized to its content.
Definition gui_application.h:2485
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:2291
bool GridViewItem(ID id, const GUIContent &content, StyleRef style, LayoutOverride &&constraints={})
Without rename, in style.
Definition gui_application.h:1526
void CloseDockedPanel(DockingLayout &layout, DockNode &leaf, int tabIndex)
Closes the panel at tabIndex of a docked leaf, as the tab's Close action does.
const std::optional< AccentColors > & GetAccent() const
SetAccent's accent; none while the palette's own is used.
Definition gui_application.h:446
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:708
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:955
bool ShortcutButton(ID id, const CommandManager::Command &command, std::function< void()> onClick, std::string_view unassigned="Unassigned", LayoutOverride &&constraints={})
A command's shortcut as keycaps, one per key ("Ctrl" "C"); a chord's two steps apart by a comma.
bool IsReducedMotion() const
Whether changes of state show at once now.
Definition gui_application.h:546
auto Vertical(A &&... a)
Definition gui_application.h:2723
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:1585
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:2370
void SetThemeVariable(std::string_view name, std::string_view value)
Sets a theme variable ("--bg-panel") to a CSS value ("#202020", "6px", "0 4px 12px rgba(0,...
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:1318
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:2234
bool Segmented(ID id, int &selected, std::span< const std::string_view > options, LayoutOverride &&constraints={})
One of a few choices side by side, as a button group with the chosen segment selected: selected is it...
bool Slider(T &value, std::type_identity_t< T > minVal, std::type_identity_t< T > 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:2307
bool Segmented(ID id, E &selected, std::span< const std::string_view > options, LayoutOverride &&constraints={})
As above, for an enum whose values are the segments' indices.
Definition gui_application.h:1172
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:706
bool BeginGhostWindow(ID windowLayoutID, int2 position)
A ghost window: caption-less and transparent, e.g.
Definition gui_application.h:2458
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:2375
bool RestoreDocumentLayout(Document &document, const SavedDocument &saved, const std::function< std::optional< ID >(std::string_view key)> &makePanel={})
Lays a document's panels out as saved, and gives them their own states back:
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:957
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:1249
bool BeginCursorGhostWindow(ID windowLayoutID, int2 cursorPos, int2 size, StyleRef styleRef)
As above, with a size and style.
Definition gui_application.h:2510
tachyon::EventHandler MakeButtonHandler(OnClick &&onClick)
A handler that calls onClick on click.
Definition gui_application.h:620
bool Checkbox(ID id, bool &value, std::string_view text={}, LayoutOverride &&constraints={})
As above, in the theme's checkbox style.
Definition gui_application.h:704
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:2579
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:1032
void Image(ID id, ImageIndex image, uint2 sourceSize, LayoutOverride &&constraints={})
As above, in the theme's image style.
Definition gui_application.h:2412
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:1208
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.
void Image(ID id, ImageIndex image, uint2 sourceSize, const UVRect &uv, const ImageDisplay &display, StyleRef style, LayoutOverride &&constraints={})
The part uv of an image sourceSize pixels big, shown as display says, sized like the aspect-preservin...
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:2572
auto Area(A &&... a)
Definition gui_application.h:2726
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:1238
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:1504
std::unique_ptr< OSWindowManager > windowManager
The OS windows and their render contexts. Created by Initialize.
Definition gui_application.h:216
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:2479
bool Viewport(ViewportView &view, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:922
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:1883
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:732
void SetWheelMode(WheelMode mode)
What the wheel and a trackpad's two-finger scroll do over the canvases that pan and zoom (node view,...
Definition gui_application.h:552
void SetTooltip(const PropertyHelp &help)
As above, for the last control.
Definition gui_application.h:1104
void PersistValue(std::string key, int &value)
As above, for an int.
void Image(ID id, ImageIndex image, uint2 sourceSize, const UVRect &uv, StyleRef style, LayoutOverride &&constraints={})
The part uv of an image sourceSize pixels big, sized like the aspect-preserving Image above to the as...
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:2591
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:2368
bool BeginCursorGhostWindow(ID windowLayoutID, int2 cursorPos, int2 size)
As above, with a size.
Definition gui_application.h:2515
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:1446
bool BeginReorderableItem(ID id, StyleRef style, LayoutOverride &&constraints={})
One draggable item of a reorderable group; any content goes inside.
bool ShowsFocusRing(const tachyon::Element &element) const
Whether element draws its focus ring (:focus-visible): it's focused and focus came from the keyboard,...
Definition gui_application.h:1485
GUIApplicationInitializeOptions InitializeOptions
See GUIApplicationInitializeOptions.
Definition gui_application.h:416
auto MenuBar(A &&... a)
Definition gui_application.h:2718
bool Tab(ID id, const GUIContent &content, LayoutOverride &&constraints={})
As above, in the theme's tab style.
Definition gui_application.h:1787
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:1534
void ForgetDockingLayout(DockingLayout &layout)
Before an app destroys layout: closes the windows of the panels torn off it (they would dock back int...
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:1984
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:1011
void CircularProgress(ID id, float value, StyleRef style, LayoutOverride &&constraints={})
A ring filled value (0 to 1, clamped) of the way round, clockwise from the top, the percentage in its...
bool BackgroundTasks(std::span< const ProgressTask > tasks, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:827
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:1443
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:1372
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:1550
void TimelineEditor(ID id, TimelineViewRef view, LayoutOverride &&constraints={})
A timeline editor over view: a toolbar (the transport, with the previous and next key in place of the...
void EndToggleGroup()
Closes BeginToggleGroup.
void PresentFrame()
See UpdateFrame.
void Image(ImageIndex image, uint2 sourceSize, const UVRect &uv, 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:2434
bool BeginReorderableItem(ID id, LayoutOverride &&constraints={})
As above, in the theme's item style.
Definition gui_application.h:1345
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:2377
bool BeginTitleBar(ID id, LayoutOverride &&constraints={})
As above, in the theme's title bar style.
Definition gui_application.h:1072
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:1987
auto LabelGroup(A &&... a)
Definition gui_application.h:2727
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:1378
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:1236
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:238
void EndTable()
Builds the recorded rows as a VirtualTable.
void DocumentPanels(DocumentSet &set, LayoutOverride &&constraints=LayoutOverride::Auto())
The active document's panels of set, after its DocumentBar.
void ClearThemeVariable(std::string_view name)
Back to the theme's own value for name.
int MessageDialog(ID id, const MessageDialogDesc &desc)
As above, in the theme's message box style.
Definition gui_application.h:971
bool ColorField(ID id, tachyon::color4b &value, LayoutOverride &&constraints={})
As above, in the theme's color field style.
Definition gui_application.h:2232
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:1680
auto ButtonGroup(A &&... a)
Definition gui_application.h:2728
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:2181
auto Disabled(A &&... a)
Definition gui_application.h:2740
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:1706
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:243
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:1019
void PersistWindow(std::string key, ID windowID)
Keeps the window's position, size and mode.
std::vector< tachyon::color4f > ColorSwatches() const
A color swatch that opens a color picker; true when the color changed.
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:1887
void CloseWindow()
Internal: the body of EndWindow for an open window; call EndWindow.
Definition gui_application.h:2752
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:2281
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:2766
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:2349
virtual void OnStylesReloaded()
Called after every successful theme/font reload (and by subclasses at startup) to re-register styles/...
Definition gui_application.h:430
bool BackgroundTasks(ID id, std::span< const ProgressTask > tasks, LayoutOverride &&constraints={})
A "3 tasks" pill with a chevron, for a status bar, that opens a popover listing tasks: each with its ...
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, bool lit=false)
A menu row: an icon slot, the label and a trailing text (a shortcut or a submenu arrow).
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:2253
void EndHorizontal()
Closes BeginHorizontal.
void ProgressBar(float value, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:767
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:676
std::unique_ptr< IClipboard > clipboard
Text and images to copy and paste (Get / Set, GetImage / SetImage); from SetClipboard.
Definition gui_application.h:220
void SelectableText(ID id, const std::span< ContentRun > &runs, LayoutOverride &&constraints={})
As above, in the theme's text style.
Definition gui_application.h:2390
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:1857
auto GridView(A &&... a)
Definition gui_application.h:2733
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:2360
bool IsThemeCrossfading() const
True while a theme switch is crossfading (the old look fading out over the new).
Definition gui_application.h:544
bool RangeField(ID id, T &value, std::type_identity_t< T > minVal, std::type_identity_t< T > maxVal, LayoutOverride &&constraints={})
A number in [minVal, maxVal]: a slider taking the row's room and a value box after it to type into.
Definition gui_application.h:2315
ToastDesc * FindToast(ToastID toast)
A shown toast's description, to change (its progress, its body); null once it's gone.
bool Slider(ID id, T &value, std::type_identity_t< T > minVal, std::type_identity_t< T > maxVal, StyleRef style, LayoutOverride &&constraints={})
Groove + knob without value text; drag-only.
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:1391
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:2224
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:2804
bool GradientField(ID id, tachyon::Gradient &value, StyleRef style, LayoutOverride &&constraints={})
A gradient swatch that opens a gradient editor; true when the gradient changed.
void Image(ImageIndex image, const ImageDisplay &display, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:2442
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:1324
void Skeleton(ID id, StyleRef style, LayoutOverride &&constraints={})
A placeholder bar where content is still loading, sized as the content it stands for (give it a width...
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:1393
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:742
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:1896
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:1466
bool BeginIndeterminate()
Value fields emitted in between show a dash for mixed values (e.g.
Definition gui_application.h:661
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:2499
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:1374
void Image(ImageIndex image, const UVRect &uv, 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:2426
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:1349
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:1370
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:1508
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:1789
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:1054
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:1696
void DisableAllPanels(DockingLayout &layout)
Panel lifecycle.
void CircularProgress(float value, LayoutOverride &&constraints={}, std::source_location site=std::source_location::current())
As above, with the call site as the ID.
Definition gui_application.h:789
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:512
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:1015
bool ApplyDockLayout(DockingLayout &layout, std::string_view tree, const std::function< std::optional< ID >(std::string_view key)> &makePanel={})
Lays a layout's panels out as tree (SaveDockLayout's text) says:
bool EdgesField(ID id, BoxEdges &value, NumericFieldConfig< int32_t > config={ .stepPerPixel=0.25,.minVal=0,.maxVal=64 }, LayoutOverride &&constraints={})
Border widths, padding or the like: a number field for each side, captioned T, R, B and L,...
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:1975
auto Toolbar(A &&... a)
Definition gui_application.h:2735
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:1861
bool Switch(ID id, bool &value, std::string_view text={}, LayoutOverride &&constraints={})
As above, in the theme's switch style.
Definition gui_application.h:721
bool NeedsFrame() const
Whether a frame is needed now.
void AddGhostIcon(IconID icon, int2 size, std::source_location site=std::source_location::current())
As above, size in pixels: in a ghost window of that size, a small icon by the cursor,...
Definition gui_application.h:2532
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:1283
void InjectPinch(ID windowID, float scale, KeyModifier mods=KeyModifier::None)
A trackpad pinch by scale where the pointer is.
bool BeginButtonGroup(ID id, LayoutOverride &&constraints={})
As above, with the group's own ID.
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:740
bool BeginMenu(ID id, const GUIContent &content, 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 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:1855
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.
void RequestRedraw()
Asks for a frame, for a change the UI can't see by itself: data from another thread,...
bool BeginContextMenu()
As above, on the control just drawn.
Definition gui_application.h:1130
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:2414
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:1042
bool GridViewItem(ID id, const GUIContent &content, LayoutOverride &&constraints)
As above, without rename.
Definition gui_application.h:1520
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:2505
void DrawnValid(tachyon::ElementRef ref)
The element just registered drawn as valid inside a BeginInvalid scope: the part of a control that sh...
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:1594
bool GradientField(tachyon::GradientF &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:2260
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:696
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:1702
auto Indeterminate(A &&... a)
Definition gui_application.h:2743
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:1258
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:1247
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:2781
std::unique_ptr< InputManager > inputManager
Routes input events to the elements; also holds global handlers. Created by Initialize.
Definition gui_application.h:212
Definition gui_renderer.h:78
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
DragDropState & Drag()
Definition gui_state_manager.h:90
ElementState GetCurrentState(ID id) const
The state of id (hovered, focused, disabled, ...) from Interaction, Construction and Labels.
void SetModified(bool v)
Whether transient state changed this frame.
Definition gui_state_manager.h:118
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:80
StyleRef emptyVertWrapStyleRef
vertical flex, wrap
Definition gui_theme.h:90
StyleRef imageStyleRef
default box for the Image() element
Definition gui_theme.h:117
StyleRef collectionAreaStyleRef
card-like well behind the list & dictionary Field() helpers
Definition gui_theme.h:376
StyleRef collectionRowStyleRef
list field: a row
Definition gui_theme.h:381
StyleRef rangeFieldStyleRef
RangeField: the row holding the slider and value box.
Definition gui_theme.h:152
StyleRef tableStyleRef
Table: the table.
Definition gui_theme.h:265
StyleRef titleBarStyleRef
a window's own title bar (BeginTitleBar)
Definition gui_theme.h:416
StyleRef checkboxStyleRef
Checkbox: the control.
Definition gui_theme.h:202
StyleRef gradientSwatchStyleRef
GradientField: the swatch.
Definition gui_theme.h:230
StyleRef vectorComponentStyleRef
a vector component's field
Definition gui_theme.h:338
StyleRef menuBarDropdownStyleRef
a dropdown in the menu bar or title bar (BeginDropdownMenu)
Definition gui_theme.h:402
StyleRef staticTextStyleRef
plain non-interactive text
Definition gui_theme.h:116
StyleRef collectionIndexStyleRef
list field: a row's index
Definition gui_theme.h:382
StyleRef switchStyleRef
Switch: the control (track + label).
Definition gui_theme.h:153
StyleRef gridViewStyleRef
BeginGridView's default.
Definition gui_theme.h:473
StyleRef vertReorderableGroupStyleRef
Definition gui_theme.h:462
StyleRef typedFieldTypeStyleRef
TypedField: the type tag.
Definition gui_theme.h:379
StyleRef sliderFieldTrackStyleRef
SliderField: the track holding the parts below.
Definition gui_theme.h:142
StyleRef vertReorderableGroupWrapStyleRef
Definition gui_theme.h:464
StyleRef dockContainerStyleRef
a docking container
Definition gui_theme.h:696
StyleRef windowStyleRef
BeginWindow's default.
Definition gui_theme.h:364
StyleRef groupLabelTopStyleRef
Label with a caption: the container.
Definition gui_theme.h:392
StyleRef ghostIconStyleRef
the icon in a drag ghost
Definition gui_theme.h:114
StyleRef emptyHorzStyleRef
horizontal flex, no wrap; groups elements without drawing anything
Definition gui_theme.h:87
StyleRef collectionEntryStyleRef
dictionary: a row
Definition gui_theme.h:386
StyleRef menuStyleRef
a menu's window
Definition gui_theme.h:397
StyleRef circularProgressStyleRef
CircularProgress: its size and its percentage's text.
Definition gui_theme.h:517
StyleRef emptyHorzWrapStyleRef
horizontal flex, wrap
Definition gui_theme.h:88
StyleRef collectionAddEntryStyleRef
dictionary: Add entry
Definition gui_theme.h:385
IconID tabCloseIcon
a tab's close button
Definition gui_theme.h:722
StyleRef collectionValueStyleRef
dictionary: a value
Definition gui_theme.h:387
StyleRef colorFieldStyleRef
ColorField: swatch, hex and alpha in a row.
Definition gui_theme.h:168
StyleRef listItemStyleRef
ListItem's default.
Definition gui_theme.h:467
StyleRef menuItemRowStyleRef
interactive row: icon slot + label + trailing shortcut/arrow
Definition gui_theme.h:427
StyleRef listViewStyleRef
BeginListView's default.
Definition gui_theme.h:466
const ControlStyles * controls
the bundle in use
Definition gui_theme.h:85
StyleRef collectionListStyleRef
list field: the rows
Definition gui_theme.h:380
StyleRef commandSearchStyleRef
a field's placeholder while it is empty (SearchField)
Definition gui_theme.h:344
StyleRef statusBarStyleRef
BeginStatusBar's default.
Definition gui_theme.h:339
StyleRef typedFieldStyleRef
TypedField: the box.
Definition gui_theme.h:377
StyleRef menuBarStyleRef
horizontal strip at the top of the main window
Definition gui_theme.h:400
StyleRef tabStyleRef
a docked tab whose group holds the focus
Definition gui_theme.h:503
StyleRef fieldElementGroupStyleRef
Built in code: an undecorated, growing, wrapping flex row (a multi-value drag field).
Definition gui_theme.h:92
StyleRef breadcrumbStyleRef
the breadcrumb path bar
Definition gui_theme.h:330
StyleRef skeletonStyleRef
Skeleton: a placeholder bar.
Definition gui_theme.h:518
StyleRef ghostWindowStyleRef
BeginGhostWindow's default: the window following a drag.
Definition gui_theme.h:113
StyleRef collectionAddStyleRef
list field: Add item
Definition gui_theme.h:384
StyleRef horzReorderableGroupStyleRef
Definition gui_theme.h:461
StyleRef messageBoxStyleRef
MessageDialog: the window.
Definition gui_theme.h:186
StyleRef typedFieldInputStyleRef
TypedField: the value.
Definition gui_theme.h:378
tachyon::VisualColorStyleIndex nanTextColor
a number field's NaN
Definition gui_theme.h:790
StyleRef progressBarStyleRef
ProgressBar's track, 6px high.
Definition gui_theme.h:512
StyleRef labelStyleRef
Label()'s default.
Definition gui_theme.h:118
StyleRef searchTextboxStyleRef
Definition gui_theme.h:489
StyleRef reorderableItemStyleRef
Definition gui_theme.h:460
StyleRef collectionRemoveStyleRef
list / dictionary: remove
Definition gui_theme.h:383
StyleRef emptyVertStyleRef
vertical flex, no wrap
Definition gui_theme.h:89
StyleRef sliderStyleRef
Slider: a groove and knob, no value text.
Definition gui_theme.h:148
StyleRef documentBarStyleRef
the bar: its row over the line
Definition gui_theme.h:681
StyleRef statusTextStyleRef
text in the status bar
Definition gui_theme.h:340
StyleRef axisLabelStyleRefs[4]
vector fields: the label of each component (X, Y, Z, W)
Definition gui_theme.h:334
StyleRef dragLabelStyleRef
DragLabel()'s default.
Definition gui_theme.h:121
StyleRef collectionStyleRef
BeginArea / BeginCached default.
Definition gui_theme.h:455
StyleRef horzReorderableGroupWrapStyleRef
Definition gui_theme.h:463
The atlas that the colors of color styles are baked into: pages of 2D textures, one row per gradient,...
Definition gui_gradient_manager.h:65
A graphics backend: the device, the window contexts that render the GUI's windows,...
Definition gui_graphics_context.h:53
Makes element IDs: per-frame dynamic / ranged IDs (hashed from the call site or a hint and the parent...
Definition gui_id_manager.h:31
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:189
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, a float or double s...
Definition gui_text_system.h:297
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:112
An image made by GraphicsContext::CreateImage; the backend defines its contents.
Definition gui_image.h:102
ID GetHoveredID() const
Definition gui_interaction_state.h:63
bool HasBeenClicked(ID id) const
Definition gui_interaction_state.h:94
bool IsFocusVisible() const
Definition gui_interaction_state.h:88
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:66
void ClearPendingLabel()
Definition gui_label_binding.h:32
The layouts a document can be given: the app's built-in ones, then the ones the user saved,...
Definition gui_layout_presets.h:33
State of the open menus (menu bar dropdowns, context menus, submenus) and their mouse and keyboard be...
Definition gui_menu_manager.h:29
Per-ID state kept between frames for the elements still built: an entry not written for kKeepFrames f...
Definition gui_recent_id_map.h:25
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:78
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:52
void EndWindow()
Ends the window begun by BeginWindow; its chain wraps around.
Definition gui_tab_chain_manager.h:109
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 the running transitions of the elements' state channels.
Definition gui_transition_manager.h:53
bool IsReducedMotion() const
Definition gui_transition_manager.h:108
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:112
SpinnerSize
How large a Spinner is.
Definition gui_progress_types.h:14
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:273
RedrawMode
How often GUIApplication::Run draws a frame (GUIApplication::SetRedrawMode).
Definition gui_redraw.h:15
BasicViewRef< TimelineData, TimelineViewState > TimelineViewRef
A timeline and one view of it, as TimelineEditor and the helpers take them.
Definition gui_timeline_types.h:259
MessageButtonKind
How a MessageButton is styled: Primary for the main choice, Danger for a destructive one.
Definition gui_application.h:114
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:257
BasicViewRef< CurveData, CurveViewState > CurveViewRef
Curves and one view of them, as CurveField, CurveEditor and the helpers take them.
Definition gui_curve_types.h:231
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:337
EventHandler MakeButtonHandler(GUIStateManager &guiStateManager, OnClick &&onClick)
Button handler: a left click, or an activation key while focused, calls onClick (a null one is nothin...
Definition gui_default_handlers.h:141
@ Quit
Definition gui_application.h:112
@ Question
Definition gui_application.h:112
@ Medium
16px, beside a line of text
Definition gui_progress_types.h:16
@ Primary
Definition gui_application.h:114
@ Secondary
Definition gui_application.h:114
@ Danger
Definition gui_application.h:114
tachyon::ID TreeViewRowKey(const TreeViewRow &row, size_t flat)
How a view's TableState::openRows names the row at flat index flat: its own ID, or for a row without ...
Definition gui_tree_grid_types.h:89
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:35
BasicNodeViewRef< NodeGraph, NodeViewState > NodeViewRef
Definition gui_node_view_types.h:593
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:42
BasicViewRef< PlotData, PlotViewState > PlotViewRef
A plot and one view of it, as Plot and the helpers take them.
Definition gui_plot_types.h:112
@ 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:39
ElementFlags
What an element is and how it behaves, combined with |.
Definition gui_element_flags.h:17
std::function< void(const DragVisualContext &context)> DragVisualizer
Draws the dragged item while a drag is in progress.
Definition gui_drag_drop_state.h:62
@ DoNotMeasureText
Definition gui_element_flags.h:25
@ ShownFocused
Shown focused (GUIApplication::BeginShownState): its focus ring shows whether or not focus came from ...
Definition gui_element_flags.h:60
@ WindowNoCaption
Definition gui_element_flags.h:32
@ WindowIsCentered
Definition gui_element_flags.h:33
@ None
Definition gui_element_flags.h:18
@ WindowUserControlled
Definition gui_element_flags.h:31
@ PropagatesDescendantState
Hover/Focused when any descendant is.
Definition gui_element_flags.h:47
@ IsWindow
Definition gui_element_flags.h:27
@ WindowIsTransparent
Definition gui_element_flags.h:34
ImageIndex
Index of an image in the graphics context's image set, as the shaders sample it.
Definition gui_image.h:99
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
WheelMode
What the wheel, and a trackpad's two-finger scroll, does over such a canvas.
Definition gui_navigation.h:19
constexpr WheelMode DefaultWheelMode()
The mode a platform's users expect: Pan on macOS, where most pointers are trackpads; Zoom elsewhere.
Definition gui_navigation.h:26
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
CommandMode
A set of shortcuts that is active while the app says so (e.g.
Definition gui_command_manager.h:25
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
std::map< std::string, std::string, std::less<> > ThemeVariableOverrides
Theme variables set in code, by name ("--bg-panel") to a CSS value ("#202020", "6px",...
Definition gui_theme.h:56
@ 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
@ Focused
has keyboard focus (CSS: :focus)
Definition gui_style.h:46
TextEditBehavior
Definition gui_text_system.h:98
@ None
Definition gui_text_system.h:99
@ ContinuousUpdate
update the text on every keystroke, not only on commit
Definition gui_text_system.h:100
std::function< void()> OnGuiFunc
Definition gui_base_types.h:13
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:17
Per-corner values (border radius).
Definition gui_style.h:90
Per-side values of the box model (margin, padding, border widths).
Definition gui_style.h:64
One CSS box-shadow layer, outside the border box.
Definition gui_style.h:121
Handle to a registered command, stable for the manager's lifetime.
Definition gui_command_manager.h:32
A registered command.
Definition gui_command_manager.h:62
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:64
StyleRef menuTrigger
.menu-trigger / .toolbar-menu-trigger
Definition gui_theme.h:66
StyleRef toggle
.toggle / .toolbar-toggle
Definition gui_theme.h:63
StyleRef number
numeric fields: the textbox in the monospace font
Definition gui_theme.h:65
StyleRef button
.button / .toolbar-button
Definition gui_theme.h:62
A size in CSS px.
Definition gui_units.h:18
Result of FindDockDropTargetAtScreenPos: the drop target and its layout.
Definition gui_docking_types.h:190
Result of FindDockLeafAtScreenPos: the leaf and its layout, both null on a miss.
Definition gui_docking_types.h:184
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:158
The documents one main window shows, in tab order, and which one is active.
Definition gui_docking_types.h:239
A document: a level, prefab, material graph, ... with its own panels.
Definition gui_docking_types.h:212
An element's slot in ElementStorage: its depth and index within that depth.
Definition gui_element.h:126
Definition gui_element.h:32
ElementState state
Definition gui_element.h:44
TextID textID
Definition gui_element.h:38
ElementFlags flags
Definition gui_element.h:43
ID id
Definition gui_element.h:33
StyleRef styleRef
Definition gui_element.h:41
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:142
Enables dragging a floating toolbar back onto a dock side; both fields are required,...
Definition controls_toolbar_dock.h:115
What GUIApplication::Initialize sets up besides the core systems.
Definition gui_application.h:158
bool closeMenusOnWindowMove
open menus close when a window moves or resizes
Definition gui_application.h:162
bool loadStyles
load the theme (InitializeStyles)
Definition gui_application.h:159
std::string_view fallbackFonts
The optional fallback fonts (Noto: other scripts, emoji, symbols), relative to the resource root,...
Definition gui_application.h:165
std::optional< GraphicsAPI > graphicsAPI
The graphics API to render with.
Definition gui_application.h:178
bool repaintWhileResizing
onGui = OnFrame, unless onGui is already set
Definition gui_application.h:161
std::string_view gpu
Which GPU to render with, when there's more than one: "integrated", "discrete", the GPU's number in t...
Definition gui_application.h:173
bool commandShortcuts
route keys to commandManager's shortcuts
Definition gui_application.h:160
uint32_t imageSlots
How many images can be registered at once, fonts, icons and gradients included.
Definition gui_application.h:169
Rolling per-frame timing history in ms, recorded only while profiling is enabled.
Definition gui_application.h:298
float buildMs
Definition gui_application.h:298
float totalMs
Definition gui_application.h:298
Definition gui_application.h:3280
std::span< VirtualTableColumn > columns
Definition gui_application.h:3280
TableState * state
Definition gui_application.h:3280
Tree-view backing state, rebuilt per frame; not part of the API.
Definition gui_application.h:2885
std::vector< TreeViewRow > rows
Definition gui_application.h:2886
std::vector< int > visibleIdx
Definition gui_application.h:2887
TableState tableState
Definition gui_application.h:2888
A page: a stable ID, its name in the tree, and render, which builds its content.
Definition gui_application.h:2863
std::function< void()> render
Builds the page's content while it is selected.
Definition gui_application.h:2869
std::string name
Shown in the page tree.
Definition gui_application.h:2867
IconID icon
Before its name in the page list; optional.
Definition gui_application.h:2871
tachyon::ID id
Stable across frames.
Definition gui_application.h:2865
What RenderSettingsPanel shows: its pages, the selected one and the tree width.
Definition gui_application.h:2860
CssPx treeWidth
The page tree's width; its sizer changes it.
Definition gui_application.h:2881
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:2892
std::vector< Page > pages
Added with AddPage.
Definition gui_application.h:2875
tachyon::ID selectedID
The page shown; a click in the tree changes it.
Definition gui_application.h:2879
std::string header
Above the page list, as a small caption ("Preferences"); none when empty.
Definition gui_application.h:2877
tachyon::ID AddPage(tachyon::ID id, std::string_view name, IconID icon, std::function< void()> render)
As above, with an icon before its name in the page list.
Definition gui_application.h:2898
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
A gradient of float colors, for data such as a material editor's gradient map: up to kMaxStops stops,...
Definition gui_style_gradient.h:303
Up to kMaxStops color stops plus an angle and interpolation color space.
Definition gui_style_gradient.h:93
User-owned, persistent state of a virtualized GridView; keep it alive across frames.
Definition gui_tree_grid_types.h:105
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
How an image is shown, in this order:
Definition gui_image.h:42
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:57
Per-element overrides of style layout properties.
Definition gui_constraints.h:151
constexpr bool HasFixedWidth() const
Whether an explicit width / height is set; axis 0 = width, 1 = height.
Definition gui_constraints.h:195
LayoutOverride & PositionX(PositionConstraintAxis ax) &
Sets one axis's constraint, or only its PositionType.
Definition gui_constraints.h:293
PositionConstraintAxis x
Definition gui_constraints.h:154
LayoutOverride & NoShrink() &
Shorthands for FlexGrow(0) / FlexShrink(0).
Definition gui_constraints.h:328
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:313
PositionConstraintAxis y
Position constraints; set with the position builders.
Definition gui_constraints.h:154
static LayoutOverride FixedWidth(CssPx w)
Definition gui_constraints.h:188
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:185
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:233
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:237
LayoutOverride & FlexGrow(int16_t v) &
Overrides the style's flex-grow / flex-shrink.
Definition gui_constraints.h:318
LayoutOverride & NoGrow() &
Shorthands for FlexGrow(0) / FlexShrink(0).
Definition gui_constraints.h:327
static LayoutOverride Auto()
No overrides: everything comes from the style.
Definition gui_constraints.h:183
LayoutOverride & Position(int2 p) &
Position builders, in pixels (near = left/top, far = right/bottom).
Definition gui_constraints.h:253
A button of a MessageDialog.
Definition gui_application.h:118
MessageButtonKind kind
its look; see MessageButtonKind
Definition gui_application.h:122
bool alignLeft
the alternative to the main choice ("Don't save")
Definition gui_application.h:123
std::string_view label
A verb that says what happens ("Quit", "Keep mine"), never Yes / No.
Definition gui_application.h:121
What a MessageDialog shows.
Definition gui_application.h:138
MessageIcon icon
beside the text
Definition gui_application.h:139
std::string_view title
a question: "Quit Test?"
Definition gui_application.h:140
bool * dontAskAgain
shows "Don't ask again" when set
Definition gui_application.h:146
int cancelButton
Esc and the close button; -1: the default one.
Definition gui_application.h:144
std::span< const MessageDialogItem > items
affected items, listed in a well
Definition gui_application.h:145
std::string_view message
one or two sentences on what happens
Definition gui_application.h:141
std::string * input
Shows a text field editing it, under the message, with the keyboard in it at first; Enter in it choos...
Definition gui_application.h:150
std::span< const MessageButton > buttons
MessageDialog returns an index into these.
Definition gui_application.h:142
std::string_view details
collapsible technical details (mono)
Definition gui_application.h:147
int defaultButton
focused at first; Enter
Definition gui_application.h:143
An affected item, listed in a well: a name, an optional color dot and note, and a checkbox when check...
Definition gui_application.h:129
std::string_view meta
e.g. "12 edits"
Definition gui_application.h:131
std::string_view name
e.g. a file name
Definition gui_application.h:130
color4f color
alpha 0: no dot
Definition gui_application.h:132
bool * checked
shows a checkbox bound to it when set
Definition gui_application.h:133
Selected item IDs of a multi-select view; user-owned, keep it alive across frames.
Definition gui_widget_state_types.h:22
Drag speed and range of a numeric Field, specialized per value type.
Definition gui_numeric_field_config.h:54
The pen, as it was at a pointer event.
Definition gui_input_state.h:40
A size in device pixels, used as is (not scaled by the UI scale).
Definition gui_units.h:28
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 piece of work, as TaskProgress, ProgressSteps, StatusProgress and BackgroundTasks show it.
Definition gui_progress_types.h:33
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:289
A document as SaveUIState kept it: which one it was, and how its panels were laid out.
Definition gui_docking_types.h:278
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:162
std::unordered_set< tachyon::ID > openRows
VirtualTreeView and WalkTreeViewVisibility: the rows open in this view, by TreeViewRowKey.
Definition gui_table_types.h:256
What a Timeline covers. The markers are only read during the call.
Definition gui_timeline_types.h:46
Where playback is: what a Timeline shows and edits.
Definition gui_timeline_types.h:25
What a toast says (ShowToast). Change it later through FindToast.
Definition gui_notification_types.h:30
Where a tree row's open state lives: a bool of the caller's (flag), or the rows a view has open (set,...
Definition gui_table_types.h:142
One row of a flat-data tree view (VirtualTreeView); rows are in depth-first order.
Definition gui_tree_grid_types.h:66
bool HasChildren() const
Definition gui_tree_grid_types.h:84
static constexpr int dimensions
Definition gui_type_dimensions.h:15
static T & GetComponent(T &value, int)
Definition gui_type_dimensions.h:16
The part of an image to draw, in UV: 0,0 is its top-left corner and 1,1 its bottom-right.
Definition gui_image.h:15
A viewport: what it shows and how. Keep it from frame to frame, as a CurveView.
Definition gui_viewport_types.h:100
A VirtualTable column: the TableColumn plus cell generator, sort order and section.
Definition gui_table_types.h:90
Definition gui_base_types.h:383
Definition gui_base_types.h:394
Definition gui_base_types.h:120
Integer 2D vector.
Definition gui_base_types.h:18
int32_t x
Definition gui_base_types.h:19
int32_t y
Definition gui_base_types.h:19
Definition gui_base_types.h:74