HUDText Derived Type

type, public :: HUDText

HUD text (see the module documentation).


Inherited by

type~~hudtext~~InheritedByGraph type~hudtext HUDText type~hudentry HUDEntry type~hudentry->type~hudtext p type~windowproxy WindowProxy type~windowproxy->type~hudentry huds

Components

Type Visibility Attributes Name Initial
integer, private :: alignment_ = ALIGN_LEFT_BOTTOM

the point of the text at position_ (ALIGN_*)

real(kind=wp), private :: color_(4) = [1.0_wp, 1.0_wp, 1.0_wp, 1.0_wp]

[r, g, b, a] (0 to 1)

character(len=:), private, allocatable :: font_

font file (unallocated: the default font)

real(kind=wp), private :: position_(2) = [0.01_wp, 0.01_wp]

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

integer, private :: revision_ = 0

incremented by each change

logical, private :: shown = .true.

false while hidden

real(kind=wp), private :: size_ = 20.0_wp

character height (window units)

character(len=:), private, allocatable :: text_

the text


Constructor

public interface HUDText

The HUDText constructor: HUDText(...) makes one (see new_hud_text for its arguments).

  • private function new_hud_text(text, position, alignment, size, color, font) result(h)

    HUD text text, optionally at position ([x, y], 0 to 1; default near the bottom left), with alignment (default ALIGN_LEFT_BOTTOM), size (window units; default 20), color ([r, g, b] or [r, g, b, a]; default white) and font (default: the default font).

    Arguments

    Type IntentOptional Attributes Name
    character(len=*), intent(in) :: text

    the text

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

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

    integer, intent(in), optional :: alignment

    an ALIGN_* constant

    real(kind=wp), intent(in), optional :: size

    character height (window units)

    real(kind=wp), intent(in), optional :: color(:)

    [r, g, b] or [r, g, b, a] (0 to 1)

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

    font file

    Return Value type(HUDText)


Type-Bound Procedures

procedure, public :: alignment

  • private pure function alignment(self)

    Which point of the text is at its position (an ALIGN_* constant).

    Arguments

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

    Return Value integer

procedure, public :: color

  • private pure function color(self) result(c)

    The color: [r, g, b, a] (0 to 1).

    Arguments

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

    Return Value real(kind=wp), (4)

procedure, public :: font

  • private function font(self) result(f)

    The font file ('' for the default font).

    Arguments

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

    Return Value character(len=:), allocatable

procedure, public :: is_shown

  • private pure function is_shown(self)

    True if the text is shown.

    Arguments

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

    Return Value logical

procedure, public :: position

  • private pure function position(self) result(p)

    Where the text is: [x, y] (0 to 1 across the window, y up).

    Arguments

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

    Return Value real(kind=wp), (2)

procedure, public :: revision

  • private pure function revision(self)

    Number of changes so far (for the windows drawing the text to update it).

    Arguments

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

    Return Value integer

procedure, public :: set_alignment

  • private subroutine set_alignment(self, alignment)

    Set which point of the text is at its position.

    Arguments

    Type IntentOptional Attributes Name
    class(HUDText), intent(inout) :: self
    integer, intent(in) :: alignment

    an ALIGN_* constant

procedure, public :: set_color

  • private subroutine set_color(self, color)

    [r, g, b] (alpha unchanged) or [r, g, b, a], 0 to 1.

    Arguments

    Type IntentOptional Attributes Name
    class(HUDText), intent(inout) :: self
    real(kind=wp), intent(in) :: color(:)

    [r, g, b] or [r, g, b, a] (0 to 1)

procedure, public :: set_font

  • private subroutine set_font(self, font)

    Set the font (the text is made again when next drawn).

    Arguments

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

    font file

procedure, public :: set_position

  • private subroutine set_position(self, position)

    Set where the text is.

    Arguments

    Type IntentOptional Attributes Name
    class(HUDText), intent(inout) :: self
    real(kind=wp), intent(in) :: position(2)

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

procedure, public :: set_size

  • private subroutine set_size(self, size)

    Set the size of the text.

    Arguments

    Type IntentOptional Attributes Name
    class(HUDText), intent(inout) :: self
    real(kind=wp), intent(in) :: size

    character height (window units)

procedure, public :: set_text

  • private subroutine set_text(self, text)

    Set the text (up to 256 characters, or twice the first text's length; see the module documentation).

    Arguments

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

    the text

procedure, public :: show

  • private subroutine show(self, shown)

    Show (true) or hide the text (OpenFrames' enable HUD text).

    Arguments

    Type IntentOptional Attributes Name
    class(HUDText), intent(inout) :: self
    logical, intent(in) :: shown

    true: show; false: hide

procedure, public :: size

  • private pure function size(self)

    The size of the text: character height (window units).

    Arguments

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

    Return Value real(kind=wp)

procedure, public :: text

  • private function text(self) result(t)

    The text (as shown: '' while hidden).

    Arguments

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

    Return Value character(len=:), allocatable

Source Code

    type, public :: HUDText
        private
        character(len=:), allocatable :: text_       !! the text
        real(wp) :: position_(2) = [0.01_wp, 0.01_wp]   !! [x, y] (0 to 1 across the window, y up)
        integer :: alignment_ = ALIGN_LEFT_BOTTOM    !! the point of the text at `position_` (ALIGN_*)
        real(wp) :: size_ = 20.0_wp                  !! character height (window units)
        real(wp) :: color_(4) = [1.0_wp, 1.0_wp, 1.0_wp, 1.0_wp]   !! [r, g, b, a] (0 to 1)
        character(len=:), allocatable :: font_       !! font file (unallocated: the default font)
        logical :: shown = .true.                    !! false while hidden
        integer :: revision_ = 0                     !! incremented by each change
    contains
        procedure :: set_text, text
        procedure :: set_position, position
        procedure :: set_alignment, alignment
        procedure :: set_size, size
        procedure :: set_color, color
        procedure :: set_font, font
        procedure :: show, is_shown
        procedure :: revision
    end type HUDText