Module: gameui.context

Source: ./gameui/context.reef


Overview

gameui/context.reef - Immediate mode UI context Part of reef-stdlib Game UI module

The UIContext is the core of the immediate mode UI system. Unlike retained mode UI where widgets are created once and persist, immediate mode rebuilds the UI every frame. This is simpler for game UIs that change frequently.

Usage pattern: let ctx = ui_context(surface, input) ui_begin_frame(ctx) if ui_button(ctx, "Play") { start_game() } if ui_checkbox(ctx, "Sound", &sound_enabled) { ... } ui_end_frame(ctx)


Types

StateEntry

Fields:

Name Type
id int
float_value float
bool_value bool
has_float bool
has_bool bool

UIContext

Fields:

Name Type
surf surface.Surface
inp input.InputState
st style.Style
next_id int
id_stack [int]
id_stack_size int
hot_id int
active_id int
cursor_x float
cursor_y float
line_height float
indent_level float
same_line bool
clip_stack [core.Rect]
clip_stack_size int
state [StateEntry]
state_count int

Functions

fn ui_context(surf: surface.Surface, inp: input.InputState): UIContext

fn ui_context_with_style(surf: surface.Surface, inp: input.InputState, st: style.Style): UIContext

fn ui_surface(ctx: UIContext): surface.Surface

fn ui_input(ctx: UIContext): input.InputState

fn ui_style(ctx: UIContext): style.Style

fn ui_hot_id(ctx: UIContext): int

fn ui_active_id(ctx: UIContext): int

fn ui_gen_id(ctx: UIContext): int

fn ui_push_id(ctx: UIContext, id: int): UIContext

fn ui_pop_id(ctx: UIContext): UIContext

fn ui_get_id(ctx: UIContext, name: string): int

fn string_hash(s: string): int

fn string_length(s: string): int

fn char_at(s: string, idx: int): int

fn ui_set_hot(ctx: UIContext, id: int): UIContext

fn ui_set_active(ctx: UIContext, id: int): UIContext

fn ui_clear_active(ctx: UIContext): UIContext

fn ui_is_hot(ctx: UIContext, id: int): bool

fn ui_is_active(ctx: UIContext, id: int): bool

fn ui_cursor(ctx: UIContext): core.Point

fn ui_set_cursor(ctx: UIContext, x: float, y: float): UIContext

fn ui_advance_cursor(ctx: UIContext, dx: float, dy: float): UIContext

fn ui_same_line(ctx: UIContext): UIContext

fn ui_new_line(ctx: UIContext): UIContext

fn ui_indent(ctx: UIContext, amount: float): UIContext

fn ui_unindent(ctx: UIContext, amount: float): UIContext

fn ui_space(ctx: UIContext, amount: float): UIContext

fn ui_push_clip(ctx: UIContext, rect: core.Rect): UIContext

fn ui_pop_clip(ctx: UIContext): UIContext

fn ui_get_clip(ctx: UIContext): core.Rect

fn find_state(ctx: UIContext, id: int): int

fn ensure_state(ctx: UIContext, id: int): int

fn ui_get_float(ctx: UIContext, id: int, default: float): float

fn ui_set_float(ctx: UIContext, id: int, value: float): UIContext

fn ui_get_bool(ctx: UIContext, id: int, default: bool): bool

fn ui_set_bool(ctx: UIContext, id: int, value: bool): UIContext

fn reef_int_to_float(i: int): float

fn int_to_float_ctx(i: int): float


Procedures

proc ui_begin_frame(ctx: UIContext)

proc ui_end_frame(ctx: UIContext)

proc update_line_height(ctx: UIContext, height: float)

proc advance_after_widget(ctx: UIContext, width: float, height: float)

Called after drawing a widget to advance cursor


Generated by reefc doc