DVUI

Window

Maps to an OS window, and save all the state needed between frames.

Usually this is created at app startup and deinit called on app shutdown.

dvui.currentWindow returns this when between begin/end.

Fields

#
backend:dvui.Backend
dvui.Backend
previous_window:?*Window
?*Window
subwindows:dvui.Subwindows
dvui.Subwindows
defer_render_cmds:?*std.ArrayList(dvui.RenderCommand)
?*std.ArrayList(dvui.RenderCommand)
defer_render_cmds_after:?*std.ArrayList(dvui.RenderCommand)
?*std.ArrayList(dvui.RenderCommand)
last_focused_id_this_frame:Id
Id
last_focused_id_in_subwindow:Id
Id
last_registered_id_this_frame:Id
Id
scroll_to_focused:bool
bool
text_input_rect:?Rect.Natural

natural rect telling the backend where our text input box is:

snap_to_pixels:bool
bool
kerning:bool
bool
alpha:f32

The alpha value for all rendering. All colors alpha values will be

events:std.ArrayList(Event)

Uses arena allocator

event_num:u16
u16
mouse_pt:Point.Physical

mouse_pt tracks the last position we got a mouse event for

mouse_pt_prev:Point.Physical
Point.Physical
mouse_type:dvui.enums.MouseType
dvui.enums.MouseType
mouse_type_min:[2]f32
[2]f32
mouse_type_last_wheel_ns:i128
i128
modifiers:dvui.enums.Mod

Holds the current state of the modifiers from the most

inject_motion_event:bool
bool
dragging:dvui.Dragging
dvui.Dragging
hold_menu_duration_ns:i128

Press-and-hold duration before a context menu opens from touch or long click.

frame_time_ns:i128
i128
loop_wait_target:?i128
?i128
loop_wait_target_can_interrupt:bool
bool
loop_target_slop:i32
i32
loop_target_slop_frames:i32
i32
frame_times:[10]u32
[10]u32
render_stats:RenderStats

Render stats accumulated during the in-progress frame. Reset in begin,

render_stats_last:RenderStats
RenderStats
frame_timing_last:FrameTiming

FrameTiming snapshot of the last completed frame. Query with

ft_total_start:i128

backend.nanoTime at the top of begin (start of the whole frame).

ft_events_start:i128

backend.nanoTime at the bottom of begin (start of the event-injection

ft_build_start:i128

backend.nanoTime when the first widget of the frame registered (start of

ft_awaiting_build:bool

True between begin returning and the first widget registering, i.e. while

max_fps:?f32

Debugging aid, only used in waitTime(), null means no max

secs_since_last_frame:f32
f32
extra_frames_needed:u8
u8
clipRect:dvui.Rect.Physical
dvui.Rect.Physical
theme:Theme

Active theme for colors and fonts. Set with dvui.themeSet or themeSet.

button_order:dvui.enums.DialogButtonOrder

Used by dvui.dialog for button order of Ok and Cancel.

data_store:dvui.Data

Uses gpa allocator

tab_index_prev:std.ArrayList(dvui.TabIndex)

Uses gpa allocator

tab_index:std.ArrayList(dvui.TabIndex)

Uses gpa allocator

fonts:dvui.Font.Cache

Uses gpa allocator

texture_cache:dvui.Texture.Cache

Uses gpa allocator

dialogs:dvui.Dialogs

Uses gpa allocator

toasts:dvui.Dialogs

Uses gpa allocator

keybinds:std.StringHashMapUnmanaged(dvui.enums.Keybind)

Uses gpa allocator

is_primary:bool

set to false by dvui.OsWindow to spot child windows.

cursor_requested:?dvui.enums.Cursor
?dvui.enums.Cursor
wd:WidgetData
WidgetData
current_parent:Widget
Widget
rect_pixels:dvui.Rect.Physical
dvui.Rect.Physical
natural_scale:f32
f32
content_scale:f32

used for whole-app scaling, combined with backend/system/monitor content

layout:dvui.BasicLayout
dvui.BasicLayout
capture:?dvui.CaptureMouse
?dvui.CaptureMouse
captured_last_frame:bool
bool
gpa:std.mem.Allocator
std.mem.Allocator
_arena:std.heap.ArenaAllocator
std.heap.ArenaAllocator
_lifo_arena:std.heap.ArenaAllocator
std.heap.ArenaAllocator
_widget_stack:WidgetStack

Used to allocate widgets with a fixed location

render_target:dvui.RenderTarget
dvui.RenderTarget
end_rendering_done:bool
bool
open_flag:?*bool

See InitOptions.open_flag

accesskit:dvui.AccessKit
dvui.AccessKit

Types

#
RenderStats

Per-frame rendering cost counters. Accumulated above the backend, so the

FrameTiming

CPU phase timing for one dvui frame, in nanoseconds. Measured with the

Functions

#
title

Change the title of the OS window, if supported by the backend.

lifo

This allocator requires that the allocations are freed in a

arena

A general allocator for using during a frame. All allocations

refreshWindow

called from gui thread

refreshBackend

called from any thread

addEventKey

Add a keyboard event (key up/down/repeat) to the dvui event list.

addEventText

Add an event that represents text being typed. This is distinct from

addEventTextSelect

Add an event that represents text being selected.

addEventFocus

Focus the widget under pt, without moving mouse_pt.

addEventMouseMotion

Add a mouse motion event that the mouse is now at physical pixel pt. This

addEventMouseButton

Add a mouse button event (like left button down/up).

addEventPointer

Add a touch up/down event. This is similar to addEventMouseButton but

mouseTypeGLFW

Heuristic for detecting MouseType for GLFW-based backends (like raylib)

mouseWheelBatch

This helps backends guess at the mouse type to pass to addEventMouseWheel.

addEventMouseWheel

Add a mouse wheel event. Positive ticks means scrolling up / scrolling right.

addEventTouchMotion

Add an event that represents a finger moving while touching the screen.

addEventWindow

Add an event for a OS Window-level action (close, resize, etc.)

addEventApp

Add an event for an Application-level action (quit, going to background, etc.)

renderStats

RenderStats from the last completed frame: draw calls, triangles,

frameTiming

FrameTiming from the last completed frame: CPU nanoseconds spent in the

beginWait

Coordinates with Window.waitTime to run frames only when needed.

waitTime

Takes output of Window.end. Returns microseconds the app should wait

begin

Make this window the current window.

cursorRequested

Return the cursor the gui wants. Client code should cache this if

cursorRequestedFloating

Return the cursor the gui wants or null if mouse is not in gui windows.

textInputRequested

If a widget called wantTextInput this frame, return the rect of where the

toastsShow

Standard way of showing toasts. For the main window, this is called with

endRendering

Normally this is called for you in end, but you can call it separately in

end

End of this window gui's rendering. Renders retained dialogs and all

Constants

#

Aliases

#
Window

Maps to an OS window, and save all the state needed between frames.