TachyonUI 0.1.0
High-performance UI for building tools.
Loading...
Searching...
No Matches
Tabs, docking and toolbars

Tab bars, dock nodes, dock layouts, documents, toolbars and the toolbar dock. More...

Classes

struct  tachyon::ToolbarDockState
 Per-instance state for one toolbar dock. More...
struct  tachyon::ToolbarItem
 One toolbar item. More...
struct  tachyon::ToolbarDockCallbacks
 Callbacks through which RenderToolbarDock changes the caller's data; the dock never touches that data itself. More...
struct  tachyon::FloatingToolbarItem
 A torn-off toolbar in its own OS window, owned by the caller. More...
struct  tachyon::FloatingToolbarOptions
 Enables dragging a floating toolbar back onto a dock side; both fields are required, otherwise the drag handle only moves the OS window. More...
struct  tachyon::DockNode
 Docking tree node: a leaf with panel tabs, or a split with two children where splitSize applies to the pinned child. More...
struct  tachyon::SplitSizeRange
 An inclusive splitSize range, in CSS px. More...
struct  tachyon::DockDropTarget
 A drop location: the leaf under the cursor and the zone within its content area. More...
struct  tachyon::TabBarOptions
 What a tab bar offers besides its tabs. More...
struct  tachyon::TabBarState
 Construction state of the current tab bar; internal. More...
struct  tachyon::TabState
 Construction state of the current tab, between BeginTab and EndTab; internal. More...
struct  tachyon::TabBarMemory
 What a tab bar keeps across frames (element data store, by bar ID): its keyboard navigation, and the sizes it measured, in pixels, that decide which tabs fit. More...
struct  tachyon::Panel
 A unit of docked UI content: a title, an optional icon, and the callback that builds it. More...
struct  tachyon::DockingLayout
 A docking area: the split/tab tree and the panels its leaves refer to by ID. More...
struct  tachyon::DockingConstructionState
 Construction state of the current docking container. More...
struct  tachyon::DockLeafResult
 Result of FindDockLeafAtScreenPos: the leaf and its layout, both null on a miss. More...
struct  tachyon::DockDropResult
 Result of FindDockDropTargetAtScreenPos: the drop target and its layout. More...
struct  tachyon::FloatingDockWindow
 A floating OS window holding torn-off panels in its own layout. More...
struct  tachyon::Document
 A document: a level, prefab, material graph, ... with its own panels. More...
struct  tachyon::DocumentSet
 The documents one main window shows, in tab order, and which one is active. More...
struct  tachyon::DocumentWindowRef
 A main window of documents, for PersistDocuments: its OS window and its documents. More...
struct  tachyon::SavedDocument
 A document as SaveUIState kept it: which one it was, and how its panels were laid out. More...
struct  tachyon::SavedDocumentWindow
 A main window of documents as SaveUIState kept it (TakeSavedDocuments). More...
struct  tachyon::DocumentDrag
 A document tab being dragged, for the document bars it passes over; internal. More...
struct  tachyon::DocumentMove
 A document dropped on another bar or torn off, done at the start of the next frame; internal. More...

Enumerations

enum class  tachyon::ToolbarSide : uint8_t { tachyon::ToolbarSide::Top = 0 , tachyon::ToolbarSide::Right = 1 , tachyon::ToolbarSide::Bottom = 2 , tachyon::ToolbarSide::Left = 3 }
 A side of a toolbar dock; indexes the per-side arrays. More...
enum class  tachyon::DockSplitMode : uint8_t { tachyon::DockSplitMode::LeftPinned , tachyon::DockSplitMode::RightPinned , tachyon::DockSplitMode::TopPinned , tachyon::DockSplitMode::BottomPinned }
 Split direction and which child is pinned to splitSize; the other child flexes. More...
enum class  tachyon::DockDropZone : uint8_t {
  tachyon::DockDropZone::None , tachyon::DockDropZone::Left , tachyon::DockDropZone::Right , tachyon::DockDropZone::Top ,
  tachyon::DockDropZone::Bottom , tachyon::DockDropZone::Center
}
 Edge zone of a point within a dock content area (drop preview and split-on-drop). More...
enum class  tachyon::TabBarLayout : uint8_t { tachyon::TabBarLayout::OneRow , tachyon::TabBarLayout::Rows }
 How a tab bar lays out tabs that don't fit on one row. More...

Functions

void tachyon::InitializeToolbarDockState (ToolbarDockState &state, GUIApplication &app)
 Allocates the state's static IDs; call once before the first RenderToolbarDock.
void tachyon::ReleaseToolbarDockState (ToolbarDockState &state, GUIApplication &app)
 Releases the IDs allocated by InitializeToolbarDockState.
void tachyon::RenderToolbarDock (GUIApplication &app, ToolbarDockState &state, const std::vector< ToolbarItem >(&itemsPerSide)[kToolbarSideCount], const ToolbarDockCallbacks &callbacks, std::function< void()> renderContent)
 Renders the 5-zone scaffold (top / left | content | right / bottom) with a reorderable group per side.
constexpr bool tachyon::IsHorizontalSplit (DockSplitMode m)
 True for LeftPinned / RightPinned (children side by side).
constexpr bool tachyon::PinsSecondChild (DockSplitMode m)
 True for RightPinned / BottomPinned (splitSize applies to the second child).
std::unique_ptr< DockNode > tachyon::MakeLeaf (std::initializer_list< ID > panelIds={})
 A leaf with the given panel tabs.
std::unique_ptr< DockNode > tachyon::MakeSplit (DockSplitMode mode, CssPx splitSize, std::unique_ptr< DockNode > first, std::unique_ptr< DockNode > second, CssPx minFirstSize=80, CssPx minSecondSize=80)
 A split node owning first and second; sizes in CSS px.
void tachyon::ReorderLeafTabs (DockNode &node, int from, int to)
 Moves a tab within a leaf, keeping the selected tab selected. No-op on invalid input.
void tachyon::ReleaseDockTreeIDs (DockNode *node, IDManager *idManager)
 Releases a tree's static node and tab-bar IDs; call before destroying it.
bool tachyon::CloseLeafTab (DockNode &node, int tabIndex)
 Removes a leaf's tab, clamping selectedTab. Returns true if the leaf is now empty.
void tachyon::CollapseEmptyLeaves (std::unique_ptr< DockNode > &rootRef, IDManager *idManager=nullptr)
 Collapses empty leaves by promoting their siblings, bottom-up.
bool tachyon::RemovePanel (std::unique_ptr< DockNode > &rootRef, ID panelId, IDManager *idManager=nullptr)
 Removes the first occurrence of panelId, then collapses empty leaves.
DockNode * tachyon::FindNode (DockNode *root, ID nodeID)
 The node with nodeID under root; nullptr when not found (always for an Invalid ID).
const DockNode * tachyon::FindNode (const DockNode *root, ID nodeID)
SplitSizeRange tachyon::ComputeSplitSizeRange (const DockNode &splitNode, int containerExtent, int sizerThickness)
 Allowed splitSize range: min = the pinned child's minimum, max = containerExtent - sizerThickness - the other child's minimum.
int tachyon::ClampSplitSize (const DockNode &splitNode, int containerExtent, int sizerThickness)
 Returns splitSize clamped to that range (doesn't modify the node).
void tachyon::AssignMissingNodeIDs (DockNode *root, IDManager &idManager)
 Gives every node (and leaf tab bar) without an ID a static ID. Idempotent.
DockDropZone tachyon::ComputeDropZone (IntRect rect, int2 point, float edgeFraction=0.25f)
 The zone of rect that point is in.
int2 tachyon::TabRowCursor (const DockNode &leaf, int2 cursor)
 The cursor as the tab rows see it: off the rows (above, below, or in a gap between wrapped rows) it moves to the nearest row, so it is on one.
int tachyon::TabInsertionIndex (const DockNode &leaf, int2 cursor)
 Where a tab dropped at cursor goes (0 = before the first, count = after the last): after every tab on the rows above, and those on its row it is right of the middle of.
std::unique_ptr< DockNode > * tachyon::FindNodeOwner (std::unique_ptr< DockNode > &rootRef, const DockNode *target)
 The unique_ptr that owns target, or nullptr.
DockNode * tachyon::SplitLeafAtZone (std::unique_ptr< DockNode > &leafRef, ID droppedPanelId, DockDropZone zone, CssPx initialSplitSize=200)
 Replaces the leaf with a split: droppedPanelId goes into a new leaf on the zone side (Left/Right/Top/Bottom only).
std::string tachyon::SerializeDockTree (const DockNode &root, const std::function< std::string(ID)> &keyOf)
 Writes the tree as JSON, naming each panel by keyOf's stable key (a title or type), never its runtime ID, so the layout survives restarts.
std::unique_ptr< DockNode > tachyon::ParseDockTree (std::string_view text, const std::function< std::optional< ID >(std::string_view)> &idOf)
 Rebuilds a tree from SerializeDockTree output.
std::vector< ID > tachyon::UnplacedPanels (const DockNode &root, const std::vector< ID > &allPanels)
 Every ID in allPanels that does not appear in the tree, in order.

Variables

constexpr int tachyon::kToolbarSideCount = 4
 number of ToolbarSide values

Detailed Description

Tab bars, dock nodes, dock layouts, documents, toolbars and the toolbar dock.

Calls (members of tachyon::GUIApplication): BeginTabBar, Tab, BeginDockingContainer, Documents, BeginToolbar. The toolbar dock: tachyon::RenderToolbarDock. Guide: Tabs, docking and toolbars.

Enumeration Type Documentation

◆ ToolbarSide

enum class tachyon::ToolbarSide : uint8_t
strong

#include <gui_controls/controls_toolbar_dock.h>

A side of a toolbar dock; indexes the per-side arrays.

Enumerator
Top 
Right 
Bottom 
Left 

◆ DockSplitMode

enum class tachyon::DockSplitMode : uint8_t
strong

#include <gui_controls/gui_dock_node.h>

Split direction and which child is pinned to splitSize; the other child flexes.

Enumerator
LeftPinned 

horizontal split: first child (left) pinned, right flexes

RightPinned 

horizontal split: second child (right) pinned, left flexes

TopPinned 

vertical split: first child (top) pinned, bottom flexes

BottomPinned 

vertical split: second child (bottom) pinned, top flexes

Examples
docking/docking.cpp.

◆ DockDropZone

enum class tachyon::DockDropZone : uint8_t
strong

#include <gui_controls/gui_dock_node.h>

Edge zone of a point within a dock content area (drop preview and split-on-drop).

Enumerator
None 

outside the rect entirely

Left 
Right 
Top 
Bottom 
Center 

the interior, not near any edge

◆ TabBarLayout

enum class tachyon::TabBarLayout : uint8_t
strong

#include <gui_controls/gui_dock_node.h>

How a tab bar lays out tabs that don't fit on one row.

Enumerator
OneRow 

one row; the tabs that don't fit are listed by a "+N" button after the others

Rows 

every tab shown, on as many rows as they take

Function Documentation

◆ InitializeToolbarDockState()

void tachyon::InitializeToolbarDockState ( ToolbarDockState & state,
GUIApplication & app )

#include <gui_controls/controls_toolbar_dock.h>

Allocates the state's static IDs; call once before the first RenderToolbarDock.

◆ ReleaseToolbarDockState()

void tachyon::ReleaseToolbarDockState ( ToolbarDockState & state,
GUIApplication & app )

#include <gui_controls/controls_toolbar_dock.h>

Releases the IDs allocated by InitializeToolbarDockState.

◆ RenderToolbarDock()

void tachyon::RenderToolbarDock ( GUIApplication & app,
ToolbarDockState & state,
const std::vector< ToolbarItem >(&) itemsPerSide[kToolbarSideCount],
const ToolbarDockCallbacks & callbacks,
std::function< void()> renderContent )

#include <gui_controls/controls_toolbar_dock.h>

Renders the 5-zone scaffold (top / left | content | right / bottom) with a reorderable group per side.

itemsPerSide is indexed by (int)ToolbarSide; renderContent is called once between the left and right sides to emit the central content.

◆ IsHorizontalSplit()

bool tachyon::IsHorizontalSplit ( DockSplitMode m)
constexpr

#include <gui_controls/gui_dock_node.h>

True for LeftPinned / RightPinned (children side by side).

◆ PinsSecondChild()

bool tachyon::PinsSecondChild ( DockSplitMode m)
constexpr

#include <gui_controls/gui_dock_node.h>

True for RightPinned / BottomPinned (splitSize applies to the second child).

◆ MakeLeaf()

std::unique_ptr< DockNode > tachyon::MakeLeaf ( std::initializer_list< ID > panelIds = {})

#include <gui_controls/gui_dock_node.h>

A leaf with the given panel tabs.

Examples
docking/docking.cpp.

◆ MakeSplit()

std::unique_ptr< DockNode > tachyon::MakeSplit ( DockSplitMode mode,
CssPx splitSize,
std::unique_ptr< DockNode > first,
std::unique_ptr< DockNode > second,
CssPx minFirstSize = 80,
CssPx minSecondSize = 80 )

#include <gui_controls/gui_dock_node.h>

A split node owning first and second; sizes in CSS px.

Examples
docking/docking.cpp.

◆ ReorderLeafTabs()

void tachyon::ReorderLeafTabs ( DockNode & node,
int from,
int to )

#include <gui_controls/gui_dock_node.h>

Moves a tab within a leaf, keeping the selected tab selected. No-op on invalid input.

◆ ReleaseDockTreeIDs()

void tachyon::ReleaseDockTreeIDs ( DockNode * node,
IDManager * idManager )

#include <gui_controls/gui_dock_node.h>

Releases a tree's static node and tab-bar IDs; call before destroying it.

◆ CloseLeafTab()

bool tachyon::CloseLeafTab ( DockNode & node,
int tabIndex )

#include <gui_controls/gui_dock_node.h>

Removes a leaf's tab, clamping selectedTab. Returns true if the leaf is now empty.

◆ CollapseEmptyLeaves()

void tachyon::CollapseEmptyLeaves ( std::unique_ptr< DockNode > & rootRef,
IDManager * idManager = nullptr )

#include <gui_controls/gui_dock_node.h>

Collapses empty leaves by promoting their siblings, bottom-up.

An empty root stays an empty leaf, never nullptr.

◆ RemovePanel()

bool tachyon::RemovePanel ( std::unique_ptr< DockNode > & rootRef,
ID panelId,
IDManager * idManager = nullptr )

#include <gui_controls/gui_dock_node.h>

Removes the first occurrence of panelId, then collapses empty leaves.

Returns true when the panel was found.

◆ FindNode() [1/2]

DockNode * tachyon::FindNode ( DockNode * root,
ID nodeID )

#include <gui_controls/gui_dock_node.h>

The node with nodeID under root; nullptr when not found (always for an Invalid ID).

◆ FindNode() [2/2]

const DockNode * tachyon::FindNode ( const DockNode * root,
ID nodeID )

◆ ComputeSplitSizeRange()

SplitSizeRange tachyon::ComputeSplitSizeRange ( const DockNode & splitNode,
int containerExtent,
int sizerThickness )

#include <gui_controls/gui_dock_node.h>

Allowed splitSize range: min = the pinned child's minimum, max = containerExtent - sizerThickness - the other child's minimum.

Both arguments are CSS px. When the container is too small for both, returns {min, min}.

◆ ClampSplitSize()

int tachyon::ClampSplitSize ( const DockNode & splitNode,
int containerExtent,
int sizerThickness )

#include <gui_controls/gui_dock_node.h>

Returns splitSize clamped to that range (doesn't modify the node).

◆ AssignMissingNodeIDs()

void tachyon::AssignMissingNodeIDs ( DockNode * root,
IDManager & idManager )

#include <gui_controls/gui_dock_node.h>

Gives every node (and leaf tab bar) without an ID a static ID. Idempotent.

◆ ComputeDropZone()

DockDropZone tachyon::ComputeDropZone ( IntRect rect,
int2 point,
float edgeFraction = 0.25f )

#include <gui_controls/gui_dock_node.h>

The zone of rect that point is in.

Edge strips are edgeFraction of the rect's size; corners go to the nearer edge. None outside the rect.

◆ TabRowCursor()

int2 tachyon::TabRowCursor ( const DockNode & leaf,
int2 cursor )

#include <gui_controls/gui_dock_node.h>

The cursor as the tab rows see it: off the rows (above, below, or in a gap between wrapped rows) it moves to the nearest row, so it is on one.

◆ TabInsertionIndex()

int tachyon::TabInsertionIndex ( const DockNode & leaf,
int2 cursor )

#include <gui_controls/gui_dock_node.h>

Where a tab dropped at cursor goes (0 = before the first, count = after the last): after every tab on the rows above, and those on its row it is right of the middle of.

Uses last frame's tab rects.

◆ FindNodeOwner()

std::unique_ptr< DockNode > * tachyon::FindNodeOwner ( std::unique_ptr< DockNode > & rootRef,
const DockNode * target )

#include <gui_controls/gui_dock_node.h>

The unique_ptr that owns target, or nullptr.

◆ SplitLeafAtZone()

DockNode * tachyon::SplitLeafAtZone ( std::unique_ptr< DockNode > & leafRef,
ID droppedPanelId,
DockDropZone zone,
CssPx initialSplitSize = 200 )

#include <gui_controls/gui_dock_node.h>

Replaces the leaf with a split: droppedPanelId goes into a new leaf on the zone side (Left/Right/Top/Bottom only).

Returns the new leaf.

◆ SerializeDockTree()

std::string tachyon::SerializeDockTree ( const DockNode & root,
const std::function< std::string(ID)> & keyOf )

#include <gui_controls/gui_dock_node.h>

Writes the tree as JSON, naming each panel by keyOf's stable key (a title or type), never its runtime ID, so the layout survives restarts.

Sizes are saved, per-frame caches aren't:

{"split":"LeftPinned","size":300,"minFirst":80,"minSecond":80,"first":{...},"second":{...}}
{"tabs":["Hierarchy","Viewport"],"selected":1} 

◆ ParseDockTree()

std::unique_ptr< DockNode > tachyon::ParseDockTree ( std::string_view text,
const std::function< std::optional< ID >(std::string_view)> & idOf )

#include <gui_controls/gui_dock_node.h>

Rebuilds a tree from SerializeDockTree output.

idOf maps a key back to a live panel ID and returns nullopt for panels that no longer exist; those tabs are dropped and the emptied leaves collapse. Returns nullptr when the text is malformed, deeper than 32 levels, or no panel survives, so the caller can fall back to its default layout. Panels the saved layout does not mention are not added; see UnplacedPanels(). Each key is used at most once (a repeated key is dropped).

◆ UnplacedPanels()

std::vector< ID > tachyon::UnplacedPanels ( const DockNode & root,
const std::vector< ID > & allPanels )

#include <gui_controls/gui_dock_node.h>

Every ID in allPanels that does not appear in the tree, in order.

A caller restoring a saved layout uses this to place panels added since the layout was saved.

Variable Documentation

◆ kToolbarSideCount

int tachyon::kToolbarSideCount = 4
inlineconstexpr