Gui Derived Type

type, public :: Gui

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


Inherits

type~~gui~~InheritsGraph type~gui Gui c_ptr c_ptr type~gui->c_ptr handle

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

  • 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)

procedure, public :: button

  • 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

procedure, public :: checkbox

  • 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

procedure, public :: combo

  • 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

procedure, public :: end_panel

  • private subroutine end_panel(self)

    End the panel started by begin_panel.

    Arguments

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

procedure, public :: is_valid

  • 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

procedure, public :: same_line

  • 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

procedure, public :: separator

  • private subroutine separator(self)

    A horizontal separator line.

    Arguments

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

procedure, public :: slider

  • 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

procedure, public :: text

  • 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

Source Code

    type, public :: Gui
        type(c_ptr) :: handle = c_null_ptr      !! the window's GUI in the C++ layer (null: none)
    contains
        procedure :: begin_panel, end_panel
        procedure :: text, button, checkbox, slider, combo, separator, same_line
        procedure :: is_valid
    end type Gui