Skip to content

figure_dock ​

figure_dock, docking: windows docked into one another or into a dock space, and layouts set by the program.

Every drawing procedure of this module refuses a call from a task (FIG_ERR_STATE): see processes.md; and a call with no frame open, a usage error (FIG_ERR_STATE, <procedure>: no frame open). Every begin/end and push/pop pair registers in the scope record of the frame, which checks each end before Dear ImGui sees it: a wrong end is refused and reported by app%next_frame (app%set_checks; errors.md, "Pairing and frames").

Docking is on by default (app%set_docking turns it off): the user drags a window by its title bar onto another window, or onto a dock space, and drops it as a tab or a split. A dock space over the whole display is declared every frame with ig_dock_space, before the windows that dock into it. A program lays out a dock space once, the first time it appears:

fortran
 root = ig_dock_id('main')
 if (ig_dock_layout_begin(root)) then
    call ig_dock_split(root, 'left', 0.3_real64, left, right)
    call ig_dock_window('Controls', left)
    call ig_dock_window('Plots', right)
    call ig_dock_layout_end(root)
 endif
 call ig_dock_space(root)

A window that appears after the layout was built (a file found later) is docked into a node with ig_set_next_window_dock(node) before its ig_begin: the first time it appears, then where the user moves it.

Dock ids are Dear ImGui's ImGuiID (unsigned 32-bit), carried in integer(int32): compare and pass them, do not do arithmetic on them.

Source: src/lib/figure_dock.F90

Dependencies

Contents ​

Subroutines ​

ig_dock_space ​

A dock space covering the display, every frame, before the windows docked into it. Where nothing is docked it is transparent: floating windows and the window background show through.

Attributes: recursive

fortran
subroutine ig_dock_space(id, flags, stat)

Arguments

NameTypeIntentAttributesDescription
idinteger(kind=int32)inDock id (ig_dock_id).
flagsinteger(kind=int32)inoptionalImGuiDockNodeFlags_* (default none).
statinteger(kind=int32)outoptionalStatus: FIG_ERR_STATE outside a frame or with docking off.

Call graph

ig_dock_split ​

Split the node id in two: id_at_dir takes fraction of it on the side direction ('left', 'right', 'up', 'down'), id_other the rest. Split the new nodes again for more areas.

Attributes: recursive

fortran
subroutine ig_dock_split(id, direction, fraction, id_at_dir, id_other, stat)

Arguments

NameTypeIntentAttributesDescription
idinteger(kind=int32)inNode to split.
directioncharacter(len=*)in'left', 'right', 'up' or 'down'.
fractionreal(kind=real64)inPart of the node at direction, in (0, 1).
id_at_dirinteger(kind=int32)outThe new node at direction.
id_otherinteger(kind=int32)outThe new node on the other side.
statinteger(kind=int32)outoptionalStatus: FIG_ERR_ARGUMENT for a bad direction or fraction.

Call graph

ig_dock_window ​

Dock the window name (as passed to ig_begin) into the node id of a layout being built.

Attributes: recursive

fortran
subroutine ig_dock_window(name, id, stat)

Arguments

NameTypeIntentAttributesDescription
namecharacter(len=*)inWindow name.
idinteger(kind=int32)inDock node.
statinteger(kind=int32)outoptionalStatus.

Call graph

ig_dock_layout_end ​

Finish the layout started by ig_dock_layout_begin.

Attributes: recursive

fortran
subroutine ig_dock_layout_end(id, stat)

Arguments

NameTypeIntentAttributesDescription
idinteger(kind=int32)inDock id.
statinteger(kind=int32)outoptionalStatus.

Call graph

ig_window_dock ​

Inside a window (between ig_begin and ig_end): the dock node it is in (0 if none) and whether it is docked.

Attributes: recursive

fortran
subroutine ig_window_dock(id, docked)

Arguments

NameTypeIntentAttributesDescription
idinteger(kind=int32)outDock node.
dockedlogicaloutThe window is docked.

Call graph

ig_set_next_window_dock ​

Dock the next window (the next ig_begin) into the node id: the first time it appears (a window created after the layout was built), or every frame with always.

Attributes: recursive

fortran
subroutine ig_set_next_window_dock(id, always)

Arguments

NameTypeIntentAttributesDescription
idinteger(kind=int32)inDock node (from the layout, or ig_window_dock of a docked window).
alwayslogicalinoptionalEvery frame (default: first use only, then the user decides).

Call graph

Functions ​

ig_dock_id ​

The dock id of a name: the same name gives the same id in every frame and every run.

Returns: integer(kind=int32)

fortran
function ig_dock_id(name) result(id)

Arguments

NameTypeIntentAttributesDescription
namecharacter(len=*)inName.

Call graph

ig_dock_layout_begin ​

True when the dock space id has no layout yet (its first frame, without an ini file keeping one), or must be laid out again (app%switch_layout to a layout not arranged yet, app%reset_layout): then lay it out (the layout app%layout(), if the program has several) with ig_dock_split and ig_dock_window, and close with ig_dock_layout_end. Call it before ig_dock_space.

Attributes: recursive

Returns: logical

fortran
function ig_dock_layout_begin(id, stat) result(needed)

Arguments

NameTypeIntentAttributesDescription
idinteger(kind=int32)inDock id.
statinteger(kind=int32)outoptionalStatus.

Call graph

Released under the MIT licence.