dsekai
World engine for retrocomputers.
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Functions | Variables
window.h File Reference

Tools for drawing and interacting with graphical windows on-screen. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

union  CONTROL_DATA
 A piece of data attached to CONTROL::data. More...
 
struct  WINDOW_FRAME
 Defines a graphical window frame/background with a set of image assets. More...
 
struct  WINDOW
 Struct representing an on-screen graphical window. More...
 

Macros

#define GUI_X   0
 Specifies X coordinate in WINDOW::coords.
 
#define GUI_Y   1
 Specifies X coordinate in WINDOW::coords.
 
#define GUI_W   2
 Specifies width coordinate in WINDOW::coords.
 
#define GUI_H   3
 Specifies height in WINDOW::coords.
 
#define WINDOW_NUM_BUFFER_SZ   10
 Size of internal text buffer used to represent WINDOW_FLAG_TEXT_NUM.
 
#define WINDOW_FLAG_ACTIVE   0x01
 WINDOW::flags indicating window is visible and interactive.
 
#define WINDOW_FLAG_DIRTY   0x04
 
#define WINDOW_FLAG_MODAL   0x08
 WINDOW::status indicating window is blocking all input.
 
#define WINDOW_FLAG_CHECKED   0x10
 WINDOW::flags indicating window option has been selected.
 
#define WINDOW_FLAG_TEXT_NUM   0x10
 WINDOW::flags for WINDOW_TYPE_LABEL indicating text is a number.
 
#define WINDOW_FLAG_TEXT_PTR   0x20
 
#define WINDOW_FLAG_TEXT_MASK   0x30
 
#define WINDOW_FLAG_SPRITE_DIR_MASK   0x30
 
#define WINDOW_FLAG_SPRITE_SOUTH   0x00
 
#define WINDOW_FLAG_SPRITE_NORTH   0x10
 
#define WINDOW_FLAG_SPRITE_EAST   0x20
 
#define WINDOW_FLAG_SPRITE_WEST   0x30
 
#define WINDOW_FLAG_SPRITE_BORDER_SINGLE   0x40
 
#define WINDOW_STRING_SZ_MAX   100
 
#define WINDOW_PLACEMENT_CENTER   0x8000
 WINDOW::x or WINDOW::y value indicating the system should do its best to center the WINDOW onscreen.
 
#define WINDOW_PLACEMENT_RIGHT_BOTTOM   0x2000
 Alight the window's right side (if specified as X) or bottom side (if specified as Y) to the window's respective side.
 
#define WINDOW_PLACEMENT_GRID_RIGHT_DOWN   0xc000
 Place the window at the grid X or Y as relevant, and set the grid width or height respectively at the window's width or height.
 
#define WINDOW_PLACEMENT_GRID   0x4000
 Place the window at the grid X or Y without modifying the grid.
 
#define WINDOW_PLACEMENT_AUTO_MASK   0xe000
 Bitmask for WINDOW::coords fields GUI_X and GUI_Y that specifies automatic placement flags.
 
#define WINDOW_PLACEMENT_PHYS_MASK   0x1fff
 Bitmask for WINDOW::coords fields GUI_X and GUI_Y that specifies physical placement coordinate number. Inverse of WINDOW_SIZE_AUTO_MASK.
 
#define WINDOW_SIZE_AUTO   0x8000
 
#define WINDOW_SIZE_AUTO_MASK   (WINDOW_PLACEMENT_AUTO_MASK)
 Bitmask for WINDOW::coords fields GUI_W and GUI_H that specifies automatic sizing flags.
 
#define WINDOW_SIZE_PHYS_MASK   (WINDOW_PLACEMENT_PHYS_MASK)
 Bitmask for WINDOW::coords fields GUI_W and GUI_H that specifies physical sizing coordinate number. Inverse of WINDOW_SIZE_AUTO_MASK.
 
#define window_screen_reset_grid()   memory_zero_ptr( g_window_screen_grid, 4 * sizeof( int16_t ) );
 
#define window_update_coords(window, x_y_w_h, coord)   (window)->coords[x_y_w_h] = ((window)->coords[x_y_w_h] & WINDOW_PLACEMENT_AUTO_MASK) | (WINDOW_PLACEMENT_PHYS_MASK & (coord));
 Set the physical coordinates of a window without corrupting attached flags.
 
#define window_get_coords(window, x_y_w_h)   (((window)->coords[x_y_w_h] & WINDOW_PLACEMENT_PHYS_MASK))
 Get the physical coordinates of a window without flags attached.
 
#define window_trace_printf(...)
 Alias for debug_printf() enabled when WINDOW_TRACE is defined.
 
#define window_modal()   (g_window_modals)
 
#define WINDOW_CB_TABLE_4(f)   f( 4, WINDOW )
 WINDOW_TYPE_WINDOW: A parent container to group subordinate windows with a graphical background.
 
#define WINDOW_CB_TABLE_3(f)   f( 3, SPRITE ) WINDOW_CB_TABLE_4( f )
 WINDOW_TYPE_SPRITE: A sprite from a GRAPHICS_BITMAP spritesheet.
 
#define WINDOW_CB_TABLE_2(f)   f( 2, CHECK ) WINDOW_CB_TABLE_3( f )
 WINDOW_TYPE_CHECK: A toggleable checkbox.
 
#define WINDOW_CB_TABLE_1(f)   f( 1, BUTTON ) WINDOW_CB_TABLE_2( f )
 WINDOW_TYPE_BUTTON: A clickable button.
 
#define WINDOW_CB_TABLE(f)   f( 0, LABEL ) WINDOW_CB_TABLE_1( f )
 WINDOW_TYPE_LABEL: A static text label.
 
#define WINDOW_CB_TABLE_CONSTS(idx, name)   extern RES_CONST uint16_t WINDOW_TYPE_ ## name;
 Define extern constants that can be used e.g. in spawners.
 

Typedefs

typedef int16_t(* WINDOW_CB_DRAW) (uint16_t w_id, struct WINDOW *windows)
 
typedef uint8_t(* WINDOW_CB_SZ) (uint16_t w_id, struct WINDOW *windows, uint8_t w_h, uint16_t *out)
 

Functions

int16_t window_init (uint16_t auto_x, uint16_t auto_y, uint16_t auto_w, uint16_t auto_h) SECTION_WINDOW
 Global initialization for the window subsystem. Runs at startup.
 
int16_t window_reload_frames () SECTION_WINDOW
 
void window_shutdown () SECTION_WINDOW
 Global shutdown for the window subsystem. Runs at shutdown.
 
int16_t window_draw_all ()
 
int16_t window_push (uint16_t id, uint16_t parent_id, uint8_t type, uint8_t flags, uint16_t x, uint16_t y, uint16_t w, uint16_t h, GRAPHICS_COLOR fg, GRAPHICS_COLOR bg, uint8_t render_flags, int32_t data_scalar, const char *data_string) SECTION_WINDOW
 Push a new window onto the global window stack.
 
void window_pop (uint16_t id) SECTION_WINDOW
 Destroy the top-most onscreen WINDOW with the given WINDOW::id.
 
void window_refresh (uint16_t w_id) SECTION_WINDOW
 

Variables

uint8_t g_window_modals
 

Detailed Description

Tools for drawing and interacting with graphical windows on-screen.