TachyonUI 0.1.0
High-performance UI for building tools.
Loading...
Searching...
No Matches
gui_dock_node.h File Reference
#include <gui_core/gui_id.h>
#include <gui_core/gui_base_types.h>
#include <gui_core/gui_units.h>
#include <functional>
#include <initializer_list>
#include <memory>
#include <optional>
#include <string>
#include <string_view>
#include <vector>

Go to the source code of this file.

Classes

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...

Namespaces

namespace  tachyon

Enumerations

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

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.