vkf_gui Module

GUI panels in a window (not in OpenFrames): Dear ImGui panels, buttons, checkboxes and sliders, drawn flat on top of the scene, through vsgImGui.

A window's Gui (WindowProxy%gui(), made on first use) is described immediate-mode, each frame (e.g. in the event handler's before_draw, or in the frame loop before frame()): panels (begin_panel ... end_panel) holding text, buttons, checkboxes, sliders, combo boxes (drop-down menus), separators. A widget's call gives what the user did with it at the frame before: button is true once after a click; checkbox, slider and combo change the value given (and are true then). What isn't described in a frame isn't shown in it.

A panel is placed where ImGui puts it (and can be moved), or at a position (0 to 1 across the window, y up, as HUD text), at first or every frame (follow): e.g. next to a picked object, kept at its screen position (screen_position). A title starting with '##' gives no title bar (a callout). Clicks, drags and keys over a panel go to it: the camera, the event handler and picking don't get them. The GUI is scaled by the window's pixel ratio. A Gui is a handle (copies are the same GUI), valid while its window is open.


Uses

  • module~~vkf_gui~~UsesGraph module~vkf_gui vkf_gui iso_c_binding iso_c_binding module~vkf_gui->iso_c_binding module~vkf_layer vkf_layer module~vkf_gui->module~vkf_layer module~vkf_math vkf_math module~vkf_gui->module~vkf_math module~vkf_layer->iso_c_binding iso_fortran_env iso_fortran_env module~vkf_math->iso_fortran_env

Used by

  • module~~vkf_gui~~UsedByGraph module~vkf_gui vkf_gui module~vkf_window vkf_window module~vkf_window->module~vkf_gui module~vkframes vkframes module~vkframes->module~vkf_gui module~vkframes->module~vkf_window

Derived Types

type, public ::  Gui

A window's GUI panels (see the module documentation).

Components

Type Visibility Attributes Name Initial
type(c_ptr), public :: handle = c_null_ptr

the window's GUI in the C++ layer (null: none)

Type-Bound Procedures

procedure, public :: begin_panel
procedure, public :: button
procedure, public :: checkbox
procedure, public :: combo
procedure, public :: end_panel
procedure, public :: is_valid
procedure, public :: same_line
procedure, public :: separator
procedure, public :: slider
procedure, public :: text

Functions

private function button(self, label)

A button: true once after it was clicked.

Arguments

Type IntentOptional Attributes Name
class(Gui), intent(inout) :: self
character(len=*), intent(in) :: label

the button's text

Return Value logical

private function checkbox(self, label, value) result(changed)

A checkbox showing value: true (and value changed) after the user changed it.

Arguments

Type IntentOptional Attributes Name
class(Gui), intent(inout) :: self
character(len=*), intent(in) :: label

the text next to it

logical, intent(inout) :: value

checked or not (changed by the user)

Return Value logical

private function combo(self, label, index, items) result(changed)

A combo box (a drop-down menu) of items (trailing blanks trimmed), showing item index (1-based): true (and index changed) after the user chose another.

Arguments

Type IntentOptional Attributes Name
class(Gui), intent(inout) :: self
character(len=*), intent(in) :: label

the text next to it

integer, intent(inout) :: index

the item shown (1-based; changed by the user)

character(len=*), intent(in) :: items(:)

the menu's items (trailing blanks trimmed)

Return Value logical

private pure function is_valid(self)

False if the window has no GUI (not open).

Arguments

Type IntentOptional Attributes Name
class(Gui), intent(in) :: self

Return Value logical

private function slider(self, label, value, low, high, format) result(changed)

A slider showing value, from low to high: true (and value changed) after the user moved it. format: how the value is shown (printf's, e.g. '%.0f km'; default '%.4g').

Arguments

Type IntentOptional Attributes Name
class(Gui), intent(inout) :: self
character(len=*), intent(in) :: label

the text next to it

real(kind=wp), intent(inout) :: value

shown, and changed by the user

real(kind=wp), intent(in) :: low

the slider's range

real(kind=wp), intent(in) :: high

the slider's range

character(len=*), intent(in), optional :: format

printf's (default '%.4g')

Return Value logical


Subroutines

private subroutine begin_panel(self, title, position, pivot, follow)

A panel titled title, with the widgets up to end_panel. A title starting with ## (e.g. '##callout') gives a panel with no title bar, e.g. a callout next to an object: what follows ## still names the panel (Dear ImGui tells panels apart and keeps their state by it), but isn't shown. position ([x, y], 0 to 1 across the window, y up; default: where ImGui puts it) is where its point pivot is ([0, 0], the default: its top left; [0.5, 1]: the middle of its bottom); with follow, every frame (and it can't be moved), else at first.

Arguments

Type IntentOptional Attributes Name
class(Gui), intent(inout) :: self
character(len=*), intent(in) :: title

the title ('##' then a name: no title bar)

real(kind=wp), intent(in), optional :: position(2)

[x, y] (0 to 1 across the window, y up)

real(kind=wp), intent(in), optional :: pivot(2)

the panel's point at position (0 to 1, from its top left)

logical, intent(in), optional :: follow

place it every frame (default false: at first)

private subroutine end_panel(self)

End the panel started by begin_panel.

Arguments

Type IntentOptional Attributes Name
class(Gui), intent(inout) :: self

private subroutine same_line(self)

The next widget on the same line as the last.

Arguments

Type IntentOptional Attributes Name
class(Gui), intent(inout) :: self

private subroutine separator(self)

A horizontal separator line.

Arguments

Type IntentOptional Attributes Name
class(Gui), intent(inout) :: self

private subroutine text(self, line)

A line of text.

Arguments

Type IntentOptional Attributes Name
class(Gui), intent(inout) :: self
character(len=*), intent(in) :: line

the text