Table of Contents
- xtk_dockframe.h
- Types
- Functions
- xtk_dockframe_create
- xtk_dockframe_destroy
- xtk_dockframe_add_tool_window
- xtk_dockframe_remove_tool_window
- xtk_dockframe_stack_tool_windows
- xtk_dockframe_unstack_tool_window
- xtk_dockframe_set_tool_window_auto_hide
- xtk_dockframe_get_tool_window_auto_hide
- xtk_dockframe_set_extra_options_callback
- xtk_dockframe_find_tool_window
- xtk_dockframe_set_region_visible
- xtk_dockframe_set_region_fraction
- xtk_dockframe_set_bottom_span
- xtk_dockframe_get_bottom_span
- xtk_dockframe_reset_layout
- xtk_dockframe_set_docking_enabled
- xtk_dockframe_get_docking_enabled
- xtk_dockframe_set_all_always_on_top
- xtk_dockframe_lower_all_floating
- xtk_dockframe_is_own_window
- xtk_dockframe_sync_floating_focus
- xtk_dockframe_set_tool_window_visible
- xtk_dockframe_get_tool_window_visible
- xtk_dockframe_set_theme
- xtk_dockframe_resize
- xtk_dockframe_flush_pending_layout
- xtk_dockframe_get_window
- xtk_dockframe_handle_event
- xtk_dockframe_serialize_layout
- xtk_dockframe_load_layout
- xtk_dockframe_force_tool_window_edge
- xtk_dockframe_show_drop_highlight
- xtk_dockframe_config_init_defaults
- xtk_dockframe_config_parse_styling
- xtk_dockframe_config_write_styling
- xtk_dockframe_widget_config_init_defaults
- xtk_dockframe_widget_config_parse
- xtk_dockframe_widget_config_write
xtk_dockframe.h
A docking layout: panels (tool windows) arranged at the left, right, bottom and center of a window, which the user can drag, float, stack, hide and resize.
A dock frame fills a box of a program's window with four regions: left, center and right as three columns, and bottom under them (under all three columns, or only two, see XtkDockSpan). Each region holds up to four tool windows (see xtk_toolwindow.h) in a tree of splits, so a panel can sit beside or above another one. The center region usually holds the main view, but it is a region like the others. The user can:
- drag a region's divider to resize it, and the dividers between panels in a region;
- drag a panel by its header to another place: while it is dragged, a thin outline shows where it will go (one side of a docked panel, or a whole region), and dropping it elsewhere leaves it floating;
- use the panel's "..." menu: Move to Left, Move to Right, Move to Bottom, Float (or Dock), Auto Hide and Close, plus items the program adds (see
xtk_dockframe_set_extra_options_callback()); the move items are disabled while the panel is pinned; - close a panel with its close button, which hides it (it is not destroyed);
- collapse a panel to a button on a 22-pixel strip at its edge (auto-hide) and show it from there over the other panels for a moment.
The dock frame does not know what is in its panels: it knows their ids, titles and places. There is no built-in list of panels to show again; the program offers that (a View menu, say) with xtk_dockframe_set_tool_window_visible(). The layout can be saved as text and restored (xtk_dockframe_serialize_layout()).
Making it. Call xtk_dockframe_create() with the parent window (the program's top-level window), the box and the whole XtkConfig; the dock frame keeps the config pointer. Add the panels with xtk_dockframe_add_tool_window(), each with an id, a title and a region, and make each panel's widget in xtk_toolwindow_get_content_window() of the tool window it returns. The dock frame owns its tool windows: xtk_dockframe_remove_tool_window() destroys one, and xtk_dockframe_destroy() destroys them all with the dock frame. Call xtk_dockframe_resize() when the parent window changes size.
Events. Pass every XEvent to xtk_dockframe_handle_event(), before the program's other widgets: it handles the dividers, the panels' headers, scrollbars and menus, the auto-hide strips, and the splits inside the regions. It also notices every button press of the program: the press raises the program's window (or the floating panel it landed on) and gives it the keyboard focus. Once per pass of the main loop, call xtk_dockframe_flush_pending_layout() (it finishes the layout after a panel is dragged out) and xtk_dockframe_sync_floating_focus() (it lowers the floating panels when another program takes the focus). Events of the widgets inside the panels go to those widgets.
Theme keys. Section [dockframe]:
background: the dock frame's background and the auto-hide strips (a gradient is allowed). Default#292929.drop-zone-highlight: the outline that shows where a dragged panel will go (a gradient is allowed). Default#598CE6.
Section [dockframe-widget]: drop-zone-alpha (0 to 255, default 96) is the outline's opacity. A compositing window manager blends the outline over the panels by it; without one the outline is opaque.
The dock frame also uses other sections: [splitpane] for the splits in the regions (divider-background also colors the three region dividers), [splitpane-widget] min-size as the smallest size of a panel in a split and divider-thickness for the dividers inside a region, [toolwindow] and [toolwindow-widget] for the panels, [menubar] for the "..." menu, [main] color for the labels on the auto-hide strips, and [frame] border for the strip button of a panel that is shown. The defaults are those xtk_config_init_defaults() sets; a theme applied with xtk_theme_apply() replaces the colors.
Example.
XtkConfig config;
xtk_config_init_defaults(&config);
XtkTheme *theme = xtk_theme_new();
if (theme && xtk_theme_builtin("Dark", theme)) xtk_theme_apply(&config, theme);
xtk_theme_free(theme);
XtkDockFrame *dock = xtk_dockframe_create(display, screen, window, 0, 0, 1000, 700, &config);
XtkToolWindow *files = xtk_dockframe_add_tool_window(dock, "files", "Files", XTK_DOCK_LEFT);
XtkToolWindow *editor = xtk_dockframe_add_tool_window(dock, "editor", "Editor", XTK_DOCK_CENTER);
xtk_dockframe_add_tool_window(dock, "messages", "Messages", XTK_DOCK_BOTTOM);
// make each panel's widget in xtk_toolwindow_get_content_window(files) and so on
(void)editor;
XEvent event;
while (running) {
while (XPending(display)) {
XNextEvent(display, &event);
if (xtk_dockframe_handle_event(dock, &event)) continue;
// ... the panels' widgets and the program's other windows
}
xtk_dockframe_flush_pending_layout(dock);
xtk_dockframe_sync_floating_focus(dock);
// ... wait a little (for example with select() on the X connection)
}
xtk_dockframe_destroy(dock);
*
Limitations.
- A dock frame holds at most 32 tool windows, and a region at most 4 docked ones; a drop on a full region is refused and the panel stays where it was.
- Stacking panels as tabs is done only by the program (
xtk_dockframe_stack_tool_windows()); dragging cannot stack. - The center region cannot be auto-hidden.
- The labels on the auto-hide strips use a fixed font (sans, 10 pixels).
#include "xtk_dockframe.h"
Types: XtkDockFrame, XtkDockEdge, XtkDockSpan, XtkDockFrameExtraOptionsCallback
Functions: xtk_dockframe_create, xtk_dockframe_destroy, xtk_dockframe_add_tool_window, xtk_dockframe_remove_tool_window, xtk_dockframe_stack_tool_windows, xtk_dockframe_unstack_tool_window, xtk_dockframe_set_tool_window_auto_hide, xtk_dockframe_get_tool_window_auto_hide, xtk_dockframe_set_extra_options_callback, xtk_dockframe_find_tool_window, xtk_dockframe_set_region_visible, xtk_dockframe_set_region_fraction, xtk_dockframe_set_bottom_span, xtk_dockframe_get_bottom_span, xtk_dockframe_reset_layout, xtk_dockframe_set_docking_enabled, xtk_dockframe_get_docking_enabled, xtk_dockframe_set_all_always_on_top, xtk_dockframe_lower_all_floating, xtk_dockframe_is_own_window, xtk_dockframe_sync_floating_focus, xtk_dockframe_set_tool_window_visible, xtk_dockframe_get_tool_window_visible, xtk_dockframe_set_theme, xtk_dockframe_resize, xtk_dockframe_flush_pending_layout, xtk_dockframe_get_window, xtk_dockframe_handle_event, xtk_dockframe_serialize_layout, xtk_dockframe_load_layout, xtk_dockframe_force_tool_window_edge, xtk_dockframe_show_drop_highlight, xtk_dockframe_config_init_defaults, xtk_dockframe_config_parse_styling, xtk_dockframe_config_write_styling, xtk_dockframe_widget_config_init_defaults, xtk_dockframe_widget_config_parse, xtk_dockframe_widget_config_write
Types
XtkDockFrame
typedef struct XtkDockFrame XtkDockFrame;
A dock frame; opaque, made by xtk_dockframe_create().
XtkDockEdge
A region of a dock frame.
| Name | Value | Description |
|---|---|---|
XTK_DOCK_LEFT |
0 |
The left column. |
XTK_DOCK_RIGHT |
The right column. | |
XTK_DOCK_BOTTOM |
The row under the columns (see XtkDockSpan) |
|
XTK_DOCK_CENTER |
The middle column, usually the main view. |
XtkDockSpan
Which columns the bottom region runs under.
The left, center and right regions are three columns; a column the bottom region does not run under takes the full height instead.
| Name | Value | Description |
|---|---|---|
XTK_DOCK_SPAN_ALL |
0 |
Under all three columns (the default) |
XTK_DOCK_SPAN_LEFT_CENTER |
Under the left and center columns; the right one is full height. | |
XTK_DOCK_SPAN_CENTER_RIGHT |
Under the center and right columns; the left one is full height. |
XtkDockFrameExtraOptionsCallback
typedef int (*XtkDockFrameExtraOptionsCallback)(const char *id, XtkPopupMenuItem *out_items, int max_items, void *user_data);
Called when a panel's "..." menu is about to open, so the program can add items of its own under the dock frame's items.
The dock frame's items (Move to Left, Move to Right, Move to Bottom, Float or Dock, Auto Hide, Close) always come first; when the function adds items, a separator comes before them. Each item needs its own callback and user_data (see xtk_popup_menu.h): the item's position in the menu means nothing to the program.
Functions
xtk_dockframe_create
XtkDockFrame *xtk_dockframe_create(
Display *display,
int screen,
Window parent,
int x,
int y,
int width,
int height,
XtkConfig *config);
Create an empty dock frame and map it.
The left and right regions start at 20 percent of the width and the bottom region at 25 percent of the height (see xtk_dockframe_set_region_fraction()).
| Parameter | Description |
|---|---|
display |
The X display |
screen |
The screen number |
parent |
The parent window: the program's top-level window, which the dock frame also raises and focuses on a click |
x |
The X position in the parent, in pixels |
y |
The Y position in the parent, in pixels |
width |
The width in pixels (held to 1 through 32767) |
height |
The height in pixels (held to 1 through 32767) |
config |
The configuration (see the theme keys above). The dock frame keeps the pointer, so it must stay valid as long as the dock frame does. |
Returns: The new dock frame, or NULL if display, parent or config is missing, memory runs out or the window cannot be made
xtk_dockframe_destroy
void xtk_dockframe_destroy(XtkDockFrame *dockframe);
Destroy the dock frame and every tool window it owns, docked, floating or hidden, with every window inside them.
Destroy the widgets inside the panels first.
| Parameter | Description |
|---|---|
dockframe |
The dock frame (NULL does nothing) |
xtk_dockframe_add_tool_window
XtkToolWindow *xtk_dockframe_add_tool_window(
XtkDockFrame *dockframe,
const char *id,
const char *title,
XtkDockEdge edge);
Make a tool window and dock it in a region, after the panels already there.
In the left, right and center regions a new panel goes under the others; in the bottom region, to their right. The panel shows a pin button, and it can be dragged unless docking is disabled.
| Parameter | Description |
|---|---|
dockframe |
The dock frame |
id |
The panel's id: one word, without spaces or parentheses, the same in every run (saved layouts use it); copied (at most 63 bytes) |
title |
The header's title, or NULL for none |
edge |
The region to dock it in |
Returns: The new tool window, owned by the dock frame (make the panel's widget in xtk_toolwindow_get_content_window() of it), or NULL if dockframe or id is NULL, the id is already used, the dock frame already has 32 tool windows, or the tool window cannot be made. If the region already has 4 panels, the tool window is made but not docked.
xtk_dockframe_remove_tool_window
void xtk_dockframe_remove_tool_window(XtkDockFrame *dockframe, const char *id);
Take a tool window out of the dock frame and destroy it, with every window inside it.
The other panels of its region take its space. Destroy the widget inside it first.
| Parameter | Description |
|---|---|
dockframe |
The dock frame (NULL does nothing) |
id |
The id given to xtk_dockframe_add_tool_window() (an unknown id does nothing) |
xtk_dockframe_stack_tool_windows
int xtk_dockframe_stack_tool_windows(
XtkDockFrame *dockframe,
const char *base_id,
const char *other_id);
Put a tool window into another one's place, as a tab.
Only one panel of a stack is docked and shown at a time; the others are hidden until the user clicks their tab in the header's tab row. Dragging cannot make a stack: the program calls this, for example from a menu.
| Parameter | Description |
|---|---|
dockframe |
The dock frame |
base_id |
The id of a docked tool window; the stack takes its place. If it is in a stack already, the other one joins that stack. |
other_id |
The id of the tool window to add; it is first taken from wherever it is (docked elsewhere, floating or in another stack) |
Returns: 1 on success; 0 if an id is not found, base_id is not docked, the two are already in one stack, or the stack already has XTK_TOOLWINDOW_MAX_STACK_TABS panels
xtk_dockframe_unstack_tool_window
void xtk_dockframe_unstack_tool_window(XtkDockFrame *dockframe, const char *id);
Take a tool window out of its stack and dock it on its own, after the panels of the same region.
If it was the stack's shown panel, another member takes its place first. A stack left with one panel becomes a plain docked panel again (its tab row goes).
| Parameter | Description |
|---|---|
dockframe |
The dock frame (NULL does nothing) |
id |
The id of a tool window in a stack (any other id does nothing) |
xtk_dockframe_set_tool_window_auto_hide
void xtk_dockframe_set_tool_window_auto_hide(
XtkDockFrame *dockframe,
const char *id,
int auto_hide);
Collapse a tool window to its edge's strip, or dock it normally again.
| Parameter | Description |
|---|---|
dockframe |
The dock frame (NULL does nothing) |
id |
The id of a tool window whose region is not the center; it may be docked, floating or in a stack (it is taken out of the stack first) |
auto_hide |
Not 0 to collapse it to a strip button; 0 to dock it again after the other panels of its region |
xtk_dockframe_get_tool_window_auto_hide
int xtk_dockframe_get_tool_window_auto_hide(
const XtkDockFrame *dockframe,
const char *id);
Tell whether a tool window is collapsed to its edge's strip.
| Parameter | Description |
|---|---|
dockframe |
The dock frame |
id |
The tool window's id |
Returns: Not 0 if it is collapsed; 0 if not, or if the id is not found
xtk_dockframe_set_extra_options_callback
void xtk_dockframe_set_extra_options_callback(
XtkDockFrame *dockframe,
XtkDockFrameExtraOptionsCallback callback,
void *user_data);
Set the function that adds the program's own items to the panels' "..." menus.
There is one function for the whole dock frame; it gets the panel's id, so it can add different items for each panel.
| Parameter | Description |
|---|---|
dockframe |
The dock frame (NULL does nothing) |
callback |
The function, or NULL for none |
user_data |
A pointer passed to the function |
xtk_dockframe_find_tool_window
XtkToolWindow *xtk_dockframe_find_tool_window(
const XtkDockFrame *dockframe,
const char *id);
Find a tool window by its id.
| Parameter | Description |
|---|---|
dockframe |
The dock frame |
id |
The id given to xtk_dockframe_add_tool_window() |
Returns: The tool window (owned by the dock frame), or NULL if it is not found or an argument is NULL
xtk_dockframe_set_region_visible
void xtk_dockframe_set_region_visible(
XtkDockFrame *dockframe,
XtkDockEdge edge,
int visible);
Show or hide a whole region, with all its docked panels.
A hidden region takes no space. Docking a panel into it shows it again. To show or hide one panel, docked or floating, use xtk_dockframe_set_tool_window_visible() instead.
| Parameter | Description |
|---|---|
dockframe |
The dock frame (NULL does nothing) |
edge |
The region; a value that is not an XtkDockEdge does nothing |
visible |
1 to show it, 0 to hide it |
xtk_dockframe_set_region_fraction
void xtk_dockframe_set_region_fraction(
XtkDockFrame *dockframe,
XtkDockEdge edge,
float fraction);
Set the size of the left, right or bottom region as a part of the dock frame's width (left, right) or height (bottom), and lay out again.
The defaults are 0.20, 0.20 and 0.25. The user can still drag the dividers afterwards; the region keeps its share when the dock frame is resized.
| Parameter | Description |
|---|---|
dockframe |
The dock frame (NULL does nothing) |
edge |
XTK_DOCK_LEFT, XTK_DOCK_RIGHT or XTK_DOCK_BOTTOM; XTK_DOCK_CENTER (which gets what is left) does nothing |
fraction |
The share, from 0.0 to 1.0 (values outside are clamped) |
xtk_dockframe_set_bottom_span
void xtk_dockframe_set_bottom_span(XtkDockFrame *dockframe, XtkDockSpan span);
Set which columns the bottom region runs under, and lay out again.
Dropping a panel on the bottom region near the frame's bottom-left or bottom-right corner sets it too (the outline shows the region it would make), and near the bottom middle sets it back to all three. It is saved and restored with the layout.
| Parameter | Description |
|---|---|
dockframe |
The dock frame (NULL does nothing) |
span |
The span (a value that is not an XtkDockSpan does nothing) |
xtk_dockframe_get_bottom_span
XtkDockSpan xtk_dockframe_get_bottom_span(const XtkDockFrame *dockframe);
Get which columns the bottom region runs under.
| Parameter | Description |
|---|---|
dockframe |
The dock frame |
Returns: The span, or XTK_DOCK_SPAN_ALL if dockframe is NULL
xtk_dockframe_reset_layout
void xtk_dockframe_reset_layout(
XtkDockFrame *dockframe,
const char *const *ids,
const XtkDockEdge *edges,
int count);
Dock tool windows again from scratch, in a given order (a "reset layout" command).
Each listed tool window is shown again if it was closed, taken out of any stack or auto-hide strip, and docked in its region after the ones listed before it: top to bottom in the left, right and center regions, left to right in the bottom region. Tool windows not listed stay as they are. Region sizes and the bottom span do not change; set them with xtk_dockframe_set_region_fraction() and xtk_dockframe_set_bottom_span().
| Parameter | Description |
|---|---|
dockframe |
The dock frame (NULL does nothing) |
ids |
The tool window ids, in the order to dock them (unknown ids are skipped) |
edges |
Each one's region, in the same order |
count |
The number of ids |
xtk_dockframe_set_docking_enabled
void xtk_dockframe_set_docking_enabled(XtkDockFrame *dockframe, int enabled);
Allow or forbid dragging panels by their headers.
Turning it off forbids dragging on every tool window, and docks every floating panel back in its region, so none is left floating with no way to move it. The "..." menu still works.
| Parameter | Description |
|---|---|
dockframe |
The dock frame (NULL does nothing) |
enabled |
1 to allow dragging and docking by drag (the default), 0 to forbid it |
xtk_dockframe_get_docking_enabled
int xtk_dockframe_get_docking_enabled(const XtkDockFrame *dockframe);
Tell whether panels can be dragged to dock or float.
| Parameter | Description |
|---|---|
dockframe |
The dock frame |
Returns: 1 if they can (also if dockframe is NULL), 0 if not
xtk_dockframe_set_all_always_on_top
void xtk_dockframe_set_all_always_on_top(XtkDockFrame *dockframe, int always_on_top);
Call xtk_toolwindow_set_always_on_top() for every tool window of the dock frame, docked or floating.
| Parameter | Description |
|---|---|
dockframe |
The dock frame (NULL does nothing) |
always_on_top |
1 to keep floating panels above other windows, 0 for normal stacking |
xtk_dockframe_lower_all_floating
void xtk_dockframe_lower_all_floating(XtkDockFrame *dockframe, Window below);
Put every floating panel that is not always on top just below a window.
xtk_dockframe_sync_floating_focus() calls it when another program takes the focus. The window must be a child of the root window, as floating panels are, or the X server refuses the request (BadMatch): walk up from the focused window to its top-level ancestor first.
| Parameter | Description |
|---|---|
dockframe |
The dock frame (NULL does nothing) |
below |
A child of the root window, usually the top-level window that now has the focus; None puts the panels below every window on the screen instead |
xtk_dockframe_is_own_window
int xtk_dockframe_is_own_window(const XtkDockFrame *dockframe, Window w);
Tell whether a window is the frame window of one of the dock frame's tool windows, docked or floating.
Only that window itself is compared, not its ancestors or children; a caller that starts from the window with the focus walks up and asks at each step, as xtk_dockframe_sync_floating_focus() does. The test is by identity, because a window manager's decoration frames can be override-redirect too and look like floating panels.
| Parameter | Description |
|---|---|
dockframe |
The dock frame |
w |
The window |
Returns: Not 0 if it is a frame of one of the dock frame's tool windows; 0 if not or dockframe is NULL
xtk_dockframe_sync_floating_focus
void xtk_dockframe_sync_floating_focus(XtkDockFrame *dockframe);
Lower the floating panels when another program takes the keyboard focus.
Call it once per pass of the main loop, besides passing the events to xtk_dockframe_handle_event(). It reads the X input focus and walks up from the focused window: if it reaches the dock frame's parent window or one of its tool windows, the program still has the focus; if it reaches another top-level window, the program has lost it. When the focus is lost, it puts every floating panel that is not always on top just below that window (see xtk_dockframe_lower_all_floating()). If the walk is not clear, nothing is lowered. It works because xtk_dockframe_handle_event() gives the focus to the program's window on every click there, so each click in another program is a new loss of focus.
| Parameter | Description |
|---|---|
dockframe |
The dock frame (NULL does nothing) |
xtk_dockframe_set_tool_window_visible
void xtk_dockframe_set_tool_window_visible(
XtkDockFrame *dockframe,
const char *id,
int visible);
Show or hide one tool window, docked or floating.
Hiding does what the header's close button does: a docked panel leaves its region (the others take its space) and is unmapped; a floating panel is unmapped where it is. Showing docks the panel again in its last region, after the others, or maps a floating one where it was. Nothing happens if the panel is already in that state.
| Parameter | Description |
|---|---|
dockframe |
The dock frame (NULL does nothing) |
id |
The id given to xtk_dockframe_add_tool_window() (an unknown id does nothing) |
visible |
1 to show it, 0 to hide it |
xtk_dockframe_get_tool_window_visible
int xtk_dockframe_get_tool_window_visible(const XtkDockFrame *dockframe, const char *id);
Tell whether a tool window is shown (not closed).
| Parameter | Description |
|---|---|
dockframe |
The dock frame |
id |
The id given to xtk_dockframe_add_tool_window() |
Returns: 1 if it is not hidden (docked, floating, in a stack or auto-hidden all count), 0 if it was closed or hidden, or the id is not found
xtk_dockframe_set_theme
void xtk_dockframe_set_theme(XtkDockFrame *dockframe, XtkConfig *config);
Use a configuration's new style for the dock frame, its dividers and outline, and every split pane and tool window it owns.
Some colors are set on windows only when they are made, so after a new theme is applied to the configuration nothing shows it until this is called. The widgets inside the panels are re-themed by the program.
| Parameter | Description |
|---|---|
dockframe |
The dock frame (NULL does nothing) |
config |
The configuration (NULL does nothing): usually the same one given to xtk_dockframe_create(), but another one works too. The dock frame keeps this pointer in place of the old one. |
xtk_dockframe_resize
void xtk_dockframe_resize(XtkDockFrame *dockframe, int width, int height);
Resize the dock frame and lay out every region again; the regions keep their shares of the size.
| Parameter | Description |
|---|---|
dockframe |
The dock frame (NULL does nothing) |
width |
The new width in pixels; 0 or less does nothing |
height |
The new height in pixels; 0 or less does nothing |
xtk_dockframe_flush_pending_layout
void xtk_dockframe_flush_pending_layout(XtkDockFrame *dockframe);
Finish a layout that was put off while a panel was being dragged out of its region.
When the user drags a docked panel away, the other panels of its region are not laid out at once (that would make the drag lag); this call does it. Call it once per pass of the main loop; it does nothing when nothing is waiting.
| Parameter | Description |
|---|---|
dockframe |
The dock frame (NULL does nothing) |
xtk_dockframe_get_window
Window xtk_dockframe_get_window(const XtkDockFrame *dockframe);
Get the dock frame's own window.
| Parameter | Description |
|---|---|
dockframe |
The dock frame |
Returns: The window, or None if dockframe is NULL
xtk_dockframe_handle_event
int xtk_dockframe_handle_event(XtkDockFrame *dockframe, XEvent *event);
Give an X event to the dock frame and everything it owns.
Pass every event, before the program's other widgets. Whatever the return value, a button press anywhere in the program raises the program's window (or the floating panel it landed on) and gives it the keyboard focus; a widget under the click that takes the focus itself still gets it afterwards. Callbacks of the dock frame and its tool windows are called from inside this call.
| Parameter | Description |
|---|---|
dockframe |
The dock frame |
event |
The event |
Returns: 1 if the dock frame used the event (a divider, a panel's header, scrollbar or resize corner, a "..." menu, an auto-hide strip, a split in a region, or its own Expose); 0 otherwise, for example for the events of the widgets inside the panels, and if an argument is NULL
xtk_dockframe_serialize_layout
int xtk_dockframe_serialize_layout(
const XtkDockFrame *dockframe,
char *buffer,
size_t buflen);
Write the layout as text, for the program to save.
The text holds the region sizes, the bottom span, each tool window's region and state (docked, floating with its place and size, closed, auto-hidden) and each region's split tree. The program stores it as it is, for example in its settings, and gives it back to xtk_dockframe_load_layout(). The format is the dock frame's own and may change; do not parse it.
| Parameter | Description |
|---|---|
dockframe |
The dock frame |
buffer |
Receives the text, ended with a 0 byte |
buflen |
The size of buffer in bytes |
Returns: The number of bytes written (without the 0 byte), or -1 if the buffer is too small or an argument is NULL or 0
xtk_dockframe_load_layout
int xtk_dockframe_load_layout(XtkDockFrame *dockframe, const char *layout);
Restore a layout written by xtk_dockframe_serialize_layout().
It places the tool windows already added with xtk_dockframe_add_tool_window(); it does not make any. Ids in the text that are not added are skipped. Each region's split tree comes back as it was saved (which panel is above or beside which, and the shares), and the region sizes come back as shares of the dock frame's present size. A tool window added since the layout was saved is docked in its region after the rest. Layouts saved by older versions are read too.
| Parameter | Description |
|---|---|
dockframe |
The dock frame |
layout |
The text |
Returns: 1 on success; 0 if an argument is NULL or the first line cannot be read, and then nothing changes
xtk_dockframe_force_tool_window_edge
void xtk_dockframe_force_tool_window_edge(
XtkDockFrame *dockframe,
const char *id,
XtkDockEdge edge);
Dock a tool window, docked or floating, in a given region, after the panels there; nothing happens if it is docked there already.
It is for a panel the program never lets the user move (for example a main view in the center, with its header hidden): call it right after xtk_dockframe_load_layout(), so a layout saved before that rule does not put the panel anywhere else. If the region already has 4 panels, nothing happens.
| Parameter | Description |
|---|---|
dockframe |
The dock frame (NULL does nothing) |
id |
The id given to xtk_dockframe_add_tool_window() |
edge |
The region, XTK_DOCK_CENTER included |
xtk_dockframe_show_drop_highlight
void xtk_dockframe_show_drop_highlight(XtkDockFrame *dockframe, int show);
Show the outline a panel dragged to the left region would show (a third of the dock frame's width, its full height), or hide it, without a drag (for example for a screenshot).
The next event the dock frame handles while no drag is going on hides it again.
| Parameter | Description |
|---|---|
dockframe |
The dock frame (NULL does nothing) |
show |
1 to show the outline, 0 to hide it |
xtk_dockframe_config_init_defaults
void xtk_dockframe_config_init_defaults(DockFrameBlock *dockframe_config);
Set a DockFrameBlock to the [dockframe] defaults (listed above).
xtk_config_init_defaults() already calls it for config.dockframe.
| Parameter | Description |
|---|---|
dockframe_config |
The block to set (NULL does nothing) |
xtk_dockframe_config_parse_styling
int xtk_dockframe_config_parse_styling(
DockFrameBlock *dockframe_config,
const char *key,
const char *value);
Set one [dockframe] key of a DockFrameBlock from its text value.
| Parameter | Description |
|---|---|
dockframe_config |
The block to change |
key |
The key: "background" or "drop-zone-highlight" |
value |
The color as written in the file |
Returns: 1 if the key is a [dockframe] key, 0 if not or an argument is NULL
xtk_dockframe_config_write_styling
int xtk_dockframe_config_write_styling(
FILE *file,
const DockFrameBlock *dockframe_config);
Write a DockFrameBlock as a [dockframe] section, with both keys.
| Parameter | Description |
|---|---|
file |
The file to write to |
dockframe_config |
The block to write |
Returns: 1 on success, 0 if an argument is NULL
xtk_dockframe_widget_config_init_defaults
void xtk_dockframe_widget_config_init_defaults(XtkConfig *config);
Set the [dockframe-widget] default (listed above) in a configuration.
xtk_config_init_defaults() already calls it.
| Parameter | Description |
|---|---|
config |
The configuration to change (NULL does nothing) |
xtk_dockframe_widget_config_parse
int xtk_dockframe_widget_config_parse(
XtkConfig *config,
const char *key,
const char *value);
Set one [dockframe-widget] key of a configuration from its text value.
| Parameter | Description |
|---|---|
config |
The configuration to change |
key |
The key: "drop-zone-alpha" |
value |
The value as written in the file (a whole number) |
Returns: 1 if the key is a [dockframe-widget] key, 0 if not or an argument is NULL
xtk_dockframe_widget_config_write
int xtk_dockframe_widget_config_write(FILE *file, const XtkConfig *config);
Write a configuration's [dockframe-widget] section.
| Parameter | Description |
|---|---|
file |
The file to write to |
config |
The configuration to write |
Returns: 1 on success, 0 if an argument is NULL
xtk API
Widgets
- button
- checkbox
- radiobutton
- label
- entry
- textview
- edit_history
- spinbutton
- slider
- progressbar
- combobox
- scrollbar
- swatch
- panel
- statusbar
- tooltip
- toolbar
- icongrid
- iconview
- pathbar
- treeview
- datagrid
- graph
- scheme_wheel
- zoom
- tray
Containers and menus
Dialogs
Rich text
Drawing and images
Color
Configuration and themes
Input and the X server
Safety
Data formats