vkf_hud Module

HUD text: text drawn on top of the scene at a fixed place in a window, as OpenFrames' HUD text (one per RenderRectangle there; any number here).

Its position is (x, y) from 0 to 1 across the window, left to right and bottom to top, and the text's alignment (an ALIGN_* constant) says which point of the text is there; its size is in window units (logical pixels). Everything can change at any time, also while shown: the text (e.g. a clock; up to 256 characters, or twice the text's length when first shown if more: longer ones are cut), color, position, size and alignment in place, and the font (the text is made again). Moved each frame to an object's place on the screen (screen_position), it is a callout that follows the object. A HUDText can be shown in several windows (add_hud_text); it is not owned by them and must stay alive while shown.


Uses

  • module~~vkf_hud~~UsesGraph module~vkf_hud vkf_hud module~vkf_frames vkf_frames module~vkf_hud->module~vkf_frames module~vkf_math vkf_math module~vkf_hud->module~vkf_math module~vkf_frames->module~vkf_math iso_c_binding iso_c_binding module~vkf_frames->iso_c_binding module~vkf_follower vkf_follower module~vkf_frames->module~vkf_follower module~vkf_geometry vkf_geometry module~vkf_frames->module~vkf_geometry module~vkf_layer vkf_layer module~vkf_frames->module~vkf_layer module~vkf_pick vkf_pick module~vkf_frames->module~vkf_pick module~vkf_text vkf_text module~vkf_frames->module~vkf_text module~vkf_trajectory vkf_trajectory module~vkf_frames->module~vkf_trajectory iso_fortran_env iso_fortran_env module~vkf_math->iso_fortran_env module~vkf_follower->module~vkf_math module~vkf_follower->module~vkf_trajectory module~vkf_geometry->module~vkf_math module~vkf_geometry->iso_c_binding module~vkf_geometry->module~vkf_layer module~vkf_layer->iso_c_binding module~vkf_pick->module~vkf_math module~vkf_text->module~vkf_math module~vkf_text->iso_c_binding module~vkf_text->module~vkf_layer module~vkf_files vkf_files module~vkf_text->module~vkf_files module~vkf_trajectory->module~vkf_math module~vkf_trajectory->iso_c_binding module~vkf_trajectory->iso_fortran_env

Used by

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

Interfaces

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)


Derived Types

type, public ::  HUDText

HUD text (see the module documentation).

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

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

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

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

Type-Bound Procedures

procedure, public :: alignment
procedure, public :: color
procedure, public :: font
procedure, public :: is_shown
procedure, public :: position
procedure, public :: revision
procedure, public :: set_alignment
procedure, public :: set_color
procedure, public :: set_font
procedure, public :: set_position
procedure, public :: set_size
procedure, public :: set_text
procedure, public :: show
procedure, public :: size
procedure, public :: text

Functions

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

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)

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

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

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)

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)

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

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)

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


Subroutines

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

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)

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

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)

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)

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

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