TachyonUI 1.1.0
High-performance UI for building tools.
Loading...
Searching...
No Matches
tachyon::Panel Struct Reference

A unit of docked UI content: a title, an optional icon, and the callback that builds it. More...

#include <gui_controls/gui_docking_types.h>

Classes

struct  Internal
 Kept by the docking; not part of the API. More...

Public Attributes

tachyon::ID id = tachyon::ID::Invalid()
 key in DockingLayout::panels
std::string title
 tab label
tachyon::IconID icon = tachyon::IconID::Invalid
 tab icon
std::string panelType
 Optional kind tag that presets serialize to pick a factory on load.
std::function< void()> onPanelGUI
 Builds the panel's content (inside the panel's area); not called while hidden.
std::function< std::optional< uint64_t >()> cacheSignature
 Docked panels are cached by default (rebuilt on resize and input inside them).
std::function< void()> onEnable
 Called when the panel becomes visible (its leaf's selected tab).
std::function< void()> onDisable
 Called when the panel is hidden.
std::function< void()> onChanged
 Called after a frame in which the user acted in the panel: pressed, released or dragged the mouse in it, scrolled over it, or typed in it (its focused element).
std::function< std::string()> saveState
 The panel's own view state, kept with its layout in the saved UI state (a pan and zoom, a camera, the page open), as text in a form of the panel's choosing.
std::function< void(std::string_view)> restoreState
struct tachyon::Panel::Internal internal
 not part of the API
tachyon::int2 scrollOffset { 0, 0 }
 Scroll position, kept here so a hidden tab keeps it (ScrollManagement prunes handles of elements not in the tree).

Detailed Description

A unit of docked UI content: a title, an optional icon, and the callback that builds it.

Member Data Documentation

◆ id

◆ title

std::string tachyon::Panel::title

tab label

◆ icon

tachyon::IconID tachyon::Panel::icon = tachyon::IconID::Invalid

tab icon

◆ panelType

std::string tachyon::Panel::panelType

Optional kind tag that presets serialize to pick a factory on load.

Empty for one-off panels.

◆ onPanelGUI

std::function<void()> tachyon::Panel::onPanelGUI

Builds the panel's content (inside the panel's area); not called while hidden.

◆ cacheSignature

std::function<std::optional<uint64_t>()> tachyon::Panel::cacheSignature

Docked panels are cached by default (rebuilt on resize and input inside them).

  • return a value -> also rebuild whenever it changes (data the cache can't observe);
  • return nullopt -> don't cache this frame (e.g. a live profiler).

◆ onEnable

std::function<void()> tachyon::Panel::onEnable

Called when the panel becomes visible (its leaf's selected tab).

◆ onDisable

std::function<void()> tachyon::Panel::onDisable

Called when the panel is hidden.

Hidden panels get no onPanelGUI and should release lazily created resources.

◆ onChanged

std::function<void()> tachyon::Panel::onChanged

Called after a frame in which the user acted in the panel: pressed, released or dragged the mouse in it, scrolled over it, or typed in it (its focused element).

The handlers have run by then, so what they changed is changed. The pointer only passing over it doesn't count.

For panels that show the same data: the others are cached and don't see the change, so rebuild the ones that need it. What needs it is the app's to say.

panel.onChanged = [this, id] {
    for (const ID other : inspectorPanels)
        if (other != id) InvalidatePanel(other);
}; 

◆ saveState

std::function<std::string()> tachyon::Panel::saveState

The panel's own view state, kept with its layout in the saved UI state (a pan and zoom, a camera, the page open), as text in a form of the panel's choosing.

saveState runs as the state is saved; an empty string keeps nothing. restoreState gets that text back when the layout it was saved with comes back (RestoreUIState for a PersistDocking layout, RestoreDocumentLayout for a document's), for the panel of the same key. With several of one key, each gets its own: they're matched by the order they're in in the dock tree.

panel.saveState    = [this] { return SaveViewState(graph); };   // gui_view_state.h
panel.restoreState = [this](std::string_view s) { RestoreViewState(graph, s); }; 

◆ restoreState

std::function<void(std::string_view)> tachyon::Panel::restoreState

◆ internal

struct tachyon::Panel::Internal tachyon::Panel::internal

not part of the API

◆ scrollOffset

tachyon::int2 tachyon::Panel::scrollOffset { 0, 0 }

Scroll position, kept here so a hidden tab keeps it (ScrollManagement prunes handles of elements not in the tree).


The documentation for this struct was generated from the following file: