Nuklear
This is a minimal-state, immediate-mode graphical user interface toolkit written in ANSI C and licensed under public domain. It was designed as a simple embeddable user interface for application and does not have any dependencies, a default render backend or OS window/input handling but instead provides a highly modular, library-based approach, with simple input state for input and draw commands describing primitive shapes as output. So instead of providing a layered library that tries to abstract over a number of platform and render backends, it focuses only on the actual UI.
 
Loading...
Searching...
No Matches
Tree

=============================================================================

                            TREE

=============================================================================

Trees represent two different concept. First the concept of a collapsible UI section that can be either in a hidden or visible state. They allow the UI user to selectively minimize the current set of visible UI to comprehend. The second concept are tree widgets for visual UI representation of trees.

Trees thereby can be nested for tree representations and multiple nested collapsible UI sections. All trees are started by calling of the nk_tree_xxx_push_tree functions and ended by calling one of the nk_tree_xxx_pop_xxx() functions. Each starting functions takes a title label and optionally an image to be displayed and the initial collapse state from the nk_collapse_states section.

The runtime state of the tree is either stored outside the library by the caller or inside which requires a unique ID. The unique ID can either be generated automatically from __FILE__ and __LINE__ with function nk_tree_push, by __FILE__ and a user provided ID generated for example by loop index with function nk_tree_push_id or completely provided from outside by user with function nk_tree_push_hashed.

Usage

To create a tree you have to call one of the seven nk_tree_xxx_push_xxx functions to start a collapsible UI section and nk_tree_xxx_pop to mark the end. Each starting function will either return false(0) if the tree is collapsed or hidden and therefore does not need to be filled with content or true(1) if visible and required to be filled.

!!! Note The tree header does not require and layouting function and instead calculates a auto height based on the currently used font size

The tree ending functions only need to be called if the tree content is actually visible. So make sure the tree push function is guarded by if and the pop call is only taken if the tree is visible.

if (nk_tree_push(ctx, NK_TREE_TAB, "Tree", NK_MINIMIZED)) {
nk_widget(...);
}
NK_API void nk_tree_pop(struct nk_context *)
NK_API void nk_layout_row_dynamic(struct nk_context *ctx, float height, int cols)
Sets current row layout to share horizontal space between @cols number of widgets evenly.
#define nk_tree_push(ctx, type, title, state)
Definition nuklear.h:2879

Reference

Function Description
nk_tree_push Start a collapsible UI section with internal state management
nk_tree_push_id Start a collapsible UI section with internal state management callable in a look
nk_tree_push_hashed Start a collapsible UI section with internal state management with full control over internal unique ID use to store state
nk_tree_image_push Start a collapsible UI section with image and label header
nk_tree_image_push_id Start a collapsible UI section with image and label header and internal state management callable in a look
nk_tree_image_push_hashed Start a collapsible UI section with image and label header and internal state management with full control over internal unique ID use to store state
nk_tree_pop Ends a collapsible UI section
nk_tree_state_push Start a collapsible UI section with external state management
nk_tree_state_image_push Start a collapsible UI section with image and label header and external state management
nk_tree_state_pop Ends a collapsabale UI section

nk_tree_type

Flag Description
NK_TREE_NODE Highlighted tree header to mark a collapsible UI section
NK_TREE_TAB Non-highlighted tree header closer to tree representations