RMGui 0.15.0
C11 retained-mode UI library: layout kernel, style schema, widget painters, fonts, software framebuffer
Loading...
Searching...
No Matches
dock.h File Reference

Caller-owned, capacity-defined docking tree. More...

#include <stddef.h>
#include <stdint.h>
#include "geom.h"

Data Structures

struct  rmgui_dock_node_t
 A node's retained identity and latest arranged geometry. More...
struct  rmgui_dock_window_t
 One window's membership, allocated content before chrome, per-ID aspect lock, and latest arranged tab (zero rectangle for a singleton). More...
struct  rmgui_dock_preview_t
 A potential drag destination; valid only while model generation is unchanged. More...
struct  rmgui_dock_aspect_t
 Caller-owned per-window aspect-lock storage, initialized by dock_init. More...
struct  rmgui_dock_t
 Retained model and geometry; fields are read-only to callers. More...

Macros

#define RMGUI_DOCK_NONE   UINT32_MAX
 No node, or append when passed as a tab insertion index.

Enumerations

enum  rmgui_dock_placement_t {
  RMGUI_DOCK_LEFT , RMGUI_DOCK_RIGHT , RMGUI_DOCK_TOP , RMGUI_DOCK_BOTTOM ,
  RMGUI_DOCK_TAB , RMGUI_DOCK_FLOAT
}
 A window's destination; split directions are relative to target's group. More...
enum  rmgui_dock_kind_t { RMGUI_DOCK_GROUP , RMGUI_DOCK_SPLIT_H , RMGUI_DOCK_SPLIT_V }
 Node interpretation: horizontal splits place first left of second. More...

Functions

int rmgui_dock_init (rmgui_dock_t *self, rmgui_dock_node_t *nodes, size_t node_capacity, uint64_t *ids, size_t id_capacity, rmgui_dock_aspect_t *aspects, size_t window_capacity)
 Reset an empty root using caller-owned nodes, aspects[window_capacity], and ids[id_capacity].
int rmgui_dock_add (rmgui_dock_t *self, uint64_t id, uint64_t target, rmgui_dock_placement_t placement, size_t index, rmgui_rect_t frame)
 Add a nonzero unique ID.
int rmgui_dock_move (rmgui_dock_t *self, uint64_t id, uint64_t target, rmgui_dock_placement_t placement, size_t index, rmgui_rect_t frame)
 Reposition an existing ID using add's destination rules; same-group TAB index is interpreted after removing that ID.
int rmgui_dock_move_group (rmgui_dock_t *self, uint64_t source_id, uint64_t target, rmgui_dock_placement_t placement, size_t index, rmgui_rect_t frame)
 Move the entire group containing source_id, preserving member order and active selection.
int rmgui_dock_remove (rmgui_dock_t *self, uint64_t id)
 Remove ID, collapsing empty groups and their parent splits.
int rmgui_dock_activate (rmgui_dock_t *self, uint64_t id)
 Make ID its group's active tab.
int rmgui_dock_raise (rmgui_dock_t *self, uint64_t id)
 Bring ID's floating group to front.
int rmgui_dock_float_frame (rmgui_dock_t *self, uint64_t id, rmgui_rect_t frame)
 Set the exact floating group frame (positive extent, representable far edges), suitable for frames returned by rmgui_window_frame_drag.
int rmgui_dock_aspect (rmgui_dock_t *self, uint64_t id, uint32_t width, uint32_t height)
 Lock one ID's content viewport to width:height; 0:0 unlocks.
int rmgui_dock_content_fit (const rmgui_dock_t *self, uint64_t id, rmgui_rect_t client, rmgui_rect_t *out)
 Fit the window's locked viewport centrally inside its actual visible client box, after the caller applies style/chrome insets.
int rmgui_dock_arrange (rmgui_dock_t *self, rmgui_rect_t viewport, int title_height, int tab_height, int splitter_width, rmgui_size_t minimum)
 Arrange docked tree inside viewport and each float intersected with it; nonpositive extents become zero.
int rmgui_dock_node (const rmgui_dock_t *self, size_t slot, rmgui_dock_node_t *out)
 Copy occupied node at slot; ids borrows model storage and is valid only until the next model mutation.
int rmgui_dock_window (const rmgui_dock_t *self, uint64_t id, rmgui_dock_window_t *out)
 Resolve ID's membership/geometry; 0 on success, -1 for missing ID.
int rmgui_dock_drag_begin (rmgui_dock_t *self, uint64_t id)
 Start a drag of this ID alone without changing membership; -1 for missing ID.
int rmgui_dock_drag_begin_group (rmgui_dock_t *self, uint64_t id)
 Start a whole-group drag using any member ID and the same hover/commit/ cancel token.
int rmgui_dock_drag_hover (rmgui_dock_t *self, int x, int y, rmgui_dock_preview_t *out)
 Classify pointer against arranged groups, frontmost float first.
int rmgui_dock_drag_commit (rmgui_dock_t *self)
 Apply latest preview, preserving model on invalid/stale/impossible target; always end the drag.
void rmgui_dock_drag_cancel (rmgui_dock_t *self)
 End drag without altering membership, order, ratio or frame.
int rmgui_dock_resize_split (rmgui_dock_t *self, size_t slot, int coordinate)
 Resize a split to pointer coordinate along its axis, respecting recursive content minima; in undersized viewports both children remain nonnegative.
int rmgui_dock_split_ratio (rmgui_dock_t *self, size_t slot, uint16_t ratio)
 Restore an exact saved split ratio (0..1000), for canceling a live splitter gesture or applying caller-owned workspace state.

Detailed Description

Caller-owned, capacity-defined docking tree.

Rectangles are logical pixels.

Macro Definition Documentation

◆ RMGUI_DOCK_NONE

#define RMGUI_DOCK_NONE   UINT32_MAX

No node, or append when passed as a tab insertion index.

Enumeration Type Documentation

◆ rmgui_dock_placement_t

A window's destination; split directions are relative to target's group.

Enumerator
RMGUI_DOCK_LEFT 
RMGUI_DOCK_RIGHT 
RMGUI_DOCK_TOP 
RMGUI_DOCK_BOTTOM 
RMGUI_DOCK_TAB 
RMGUI_DOCK_FLOAT 

◆ rmgui_dock_kind_t

Node interpretation: horizontal splits place first left of second.

Enumerator
RMGUI_DOCK_GROUP 
RMGUI_DOCK_SPLIT_H 
RMGUI_DOCK_SPLIT_V 

Function Documentation

◆ rmgui_dock_init()

int rmgui_dock_init ( rmgui_dock_t * self,
rmgui_dock_node_t * nodes,
size_t node_capacity,
uint64_t * ids,
size_t id_capacity,
rmgui_dock_aspect_t * aspects,
size_t window_capacity )

Reset an empty root using caller-owned nodes, aspects[window_capacity], and ids[id_capacity].

Each node borrows window_capacity IDs from ids, so id_capacity must be at least node_capacity * window_capacity. All storage must remain alive, nonoverlapping, and unmodified until model retirement. Capacities are 1..INT_MAX (internal integer index ceiling). Returns 0, or -1 leaving model and storage unchanged for NULL, invalid capacities or insufficient ID storage. Add/move refuse unchanged on storage exhaustion.

◆ rmgui_dock_add()

int rmgui_dock_add ( rmgui_dock_t * self,
uint64_t id,
uint64_t target,
rmgui_dock_placement_t placement,
size_t index,
rmgui_rect_t frame )

Add a nonzero unique ID.

For an empty root use TAB with target 0; FLOAT ignores target/index and requires positive frame. For other placements target must identify a docked or floating group. Index is 0..count for TAB, or RMGUI_DOCK_NONE to append. Return 0, or -1 with model unchanged.

◆ rmgui_dock_move()

int rmgui_dock_move ( rmgui_dock_t * self,
uint64_t id,
uint64_t target,
rmgui_dock_placement_t placement,
size_t index,
rmgui_rect_t frame )

Reposition an existing ID using add's destination rules; same-group TAB index is interpreted after removing that ID.

0, or -1 unchanged.

◆ rmgui_dock_move_group()

int rmgui_dock_move_group ( rmgui_dock_t * self,
uint64_t source_id,
uint64_t target,
rmgui_dock_placement_t placement,
size_t index,
rmgui_rect_t frame )

Move the entire group containing source_id, preserving member order and active selection.

TAB merges at index (or appends at NONE); self TAB succeeds unchanged, other self destinations refuse unchanged. FLOAT uses a positive frame. TAB target 0 docks into an empty root. Refused moves leave the entire model unchanged.

◆ rmgui_dock_remove()

int rmgui_dock_remove ( rmgui_dock_t * self,
uint64_t id )

Remove ID, collapsing empty groups and their parent splits.

0, or -1 unchanged.

◆ rmgui_dock_activate()

int rmgui_dock_activate ( rmgui_dock_t * self,
uint64_t id )

Make ID its group's active tab.

0, or -1 unchanged for missing ID.

◆ rmgui_dock_raise()

int rmgui_dock_raise ( rmgui_dock_t * self,
uint64_t id )

Bring ID's floating group to front.

0, or -1 unchanged for docked/missing.

◆ rmgui_dock_float_frame()

int rmgui_dock_float_frame ( rmgui_dock_t * self,
uint64_t id,
rmgui_rect_t frame )

Set the exact floating group frame (positive extent, representable far edges), suitable for frames returned by rmgui_window_frame_drag.

0 or -1 unchanged on invalid frame or docked/missing ID.

◆ rmgui_dock_aspect()

int rmgui_dock_aspect ( rmgui_dock_t * self,
uint64_t id,
uint32_t width,
uint32_t height )

Lock one ID's content viewport to width:height; 0:0 unlocks.

Mixed zero, missing ID, or invalid ratio returns -1 without changing the model.

◆ rmgui_dock_content_fit()

int rmgui_dock_content_fit ( const rmgui_dock_t * self,
uint64_t id,
rmgui_rect_t client,
rmgui_rect_t * out )

Fit the window's locked viewport centrally inside its actual visible client box, after the caller applies style/chrome insets.

Client must be a nonnegative representable rectangle. Unlocked IDs return client unchanged; -1 leaves out unchanged. Locked dimensions use the largest whole multiple of the reduced width:height pair that fits; if too small, both are zero. Centering offsets round down.

◆ rmgui_dock_arrange()

int rmgui_dock_arrange ( rmgui_dock_t * self,
rmgui_rect_t viewport,
int title_height,
int tab_height,
int splitter_width,
rmgui_size_t minimum )

Arrange docked tree inside viewport and each float intersected with it; nonpositive extents become zero.

A single-member group reserves only title_height, a multi-member group reserves only tab_height. Negative metrics/minimum components count as zero. Return -1 unchanged for an unrepresentable viewport; otherwise 0. A changed viewport or metric invalidates an old drag preview but preserves its source and membership.

◆ rmgui_dock_node()

int rmgui_dock_node ( const rmgui_dock_t * self,
size_t slot,
rmgui_dock_node_t * out )

Copy occupied node at slot; ids borrows model storage and is valid only until the next model mutation.

Return 0, or -1 with out unchanged for NULL, unused or out-of-range.

◆ rmgui_dock_window()

int rmgui_dock_window ( const rmgui_dock_t * self,
uint64_t id,
rmgui_dock_window_t * out )

Resolve ID's membership/geometry; 0 on success, -1 for missing ID.

◆ rmgui_dock_drag_begin()

int rmgui_dock_drag_begin ( rmgui_dock_t * self,
uint64_t id )

Start a drag of this ID alone without changing membership; -1 for missing ID.

◆ rmgui_dock_drag_begin_group()

int rmgui_dock_drag_begin_group ( rmgui_dock_t * self,
uint64_t id )

Start a whole-group drag using any member ID and the same hover/commit/ cancel token.

Return 0 on success, -1 for a NULL model or missing ID; membership is unchanged.

◆ rmgui_dock_drag_hover()

int rmgui_dock_drag_hover ( rmgui_dock_t * self,
int x,
int y,
rmgui_dock_preview_t * out )

Classify pointer against arranged groups, frontmost float first.

A blank empty root offers TAB with target 0; elsewhere outside groups gives FLOAT, clamped wholly into the viewport with source/minimum-derived dimensions. Return preview in out on success, -1 for idle/stale drag or an impossible self-split. Hover never mutates membership, order, ratios or frames.

◆ rmgui_dock_drag_commit()

int rmgui_dock_drag_commit ( rmgui_dock_t * self)

Apply latest preview, preserving model on invalid/stale/impossible target; always end the drag.

0 success, -1 refusal.

◆ rmgui_dock_drag_cancel()

void rmgui_dock_drag_cancel ( rmgui_dock_t * self)

End drag without altering membership, order, ratio or frame.

◆ rmgui_dock_resize_split()

int rmgui_dock_resize_split ( rmgui_dock_t * self,
size_t slot,
int coordinate )

Resize a split to pointer coordinate along its axis, respecting recursive content minima; in undersized viewports both children remain nonnegative.

0 on success, -1 unchanged on a non-split/unused slot.

◆ rmgui_dock_split_ratio()

int rmgui_dock_split_ratio ( rmgui_dock_t * self,
size_t slot,
uint16_t ratio )

Restore an exact saved split ratio (0..1000), for canceling a live splitter gesture or applying caller-owned workspace state.

Arrangement still enforces content minima. 0 on success, -1 unchanged for invalid slot or ratio.