RMGui 0.15.0
C11 retained-mode UI library: layout kernel, style schema, widget painters, fonts, software framebuffer
Loading...
Searching...
No Matches
window_frame.h File Reference

window_frame.h — the window frame element (one window's chrome: arrange, measure, paint, control input, move/resize drag) and the desktop chrome catalog a shell host arranges its taskbar, tray, clock, cursor and windows with. More...

#include <stddef.h>
#include <stdint.h>
#include "fb.h"
#include "font.h"
#include "geom.h"
#include "input.h"
#include "style.h"
#include "draw_target.h"
#include "ui_context.h"

Data Structures

struct  rmgui_window_frame_metrics_t
 Chrome metrics are device pixels, except explicitly named percentages and selectors. More...
struct  rmgui_window_frame_window_decl_t
 One declared window of a catalog. More...
struct  rmgui_window_frame_decl_t
 A desktop declaration: windows[0..window_count) are arranged, the first taskbar_count of them also get taskbar cells. More...
struct  rmgui_window_frame_window_t
 One arranged window. More...
struct  rmgui_window_frame_catalog_t
 An arranged desktop. More...
struct  rmgui_window_frame_t
 Retained control state of one window; zero-initialised is the initial state. More...
struct  rmgui_window_frame_view_t
 Caption control state and optional borrowed, NUL-terminated title. More...
struct  rmgui_window_frame_drag_t
 One pointer drag of a window, caller-owned; zero-initialised is idle. More...
struct  rmgui_window_frame_constraints_t
struct  rmgui_window_frame_proposal_t

Macros

#define RMGUI_WINDOW_FRAME_CLOSE   0x01u
 Caption control/capability bits.
#define RMGUI_WINDOW_FRAME_MINIMIZE   0x02u
#define RMGUI_WINDOW_FRAME_RESIZABLE   0x04u
#define RMGUI_WINDOW_FRAME_MAXIMIZABLE   0x08u
#define RMGUI_WINDOW_FRAME_FLAGS_ALL   0x0fu

Enumerations

enum  rmgui_window_frame_control_t {
  RMGUI_WINDOW_FRAME_CONTROL_NONE , RMGUI_WINDOW_FRAME_CONTROL_CLOSE , RMGUI_WINDOW_FRAME_CONTROL_MINIMIZE , RMGUI_WINDOW_FRAME_CONTROL_MAXIMIZE ,
  RMGUI_WINDOW_FRAME_CONTROL_RESTORE
}
 A window control; NONE is 0 so a zeroed rmgui_window_frame_t holds none. More...
enum  rmgui_window_frame_kind_t { RMGUI_WINDOW_FRAME_KIND_STANDARD , RMGUI_WINDOW_FRAME_KIND_CARD }
 Chrome of one declared window: framed shell window, or rounded card. More...
enum  rmgui_window_frame_part_t {
  RMGUI_WINDOW_FRAME_PART_NONE , RMGUI_WINDOW_FRAME_PART_MOVE , RMGUI_WINDOW_FRAME_PART_RESIZE_L , RMGUI_WINDOW_FRAME_PART_RESIZE_T ,
  RMGUI_WINDOW_FRAME_PART_RESIZE_R , RMGUI_WINDOW_FRAME_PART_RESIZE_B , RMGUI_WINDOW_FRAME_PART_RESIZE_LT , RMGUI_WINDOW_FRAME_PART_RESIZE_RT ,
  RMGUI_WINDOW_FRAME_PART_RESIZE_LB , RMGUI_WINDOW_FRAME_PART_RESIZE_RB
}
 A part of an arranged window the pointer can drag: the drag handle moves the frame, a corner grip or edge band resizes it. More...

Functions

int rmgui_window_frame_catalog (const rmgui_window_frame_decl_t *declaration, rmgui_window_frame_catalog_t *out)
 Arranges a whole desktop.
int rmgui_window_frame_arrange (const rmgui_style_resolved_t *rs, rmgui_rect_t frame, int title_label_w, unsigned flags, int maximized, rmgui_window_frame_window_t *out)
 Arranges one STANDARD window at frame with the chrome metrics the WINDOW record rs implies and a title_label_w wide title.
rmgui_size_t rmgui_window_frame_measure (const rmgui_style_resolved_t *rs, int title_label_w, rmgui_size_t content_min, unsigned flags)
 Smallest frame rmgui_window_frame_arrange accepts whose content holds content_min and whose title bar shows a title_label_w wide title whole between the frame edge and the controls selected by flags, assuming not maximized.
void rmgui_window_frame_paint (rmgui_fb_t *fb, rmgui_font_t *font, const rmgui_style_resolved_t *rs, const rmgui_window_frame_window_t *window, rmgui_rect_t clip, const char *title, const rmgui_window_frame_t *self)
 Paints STANDARD chrome of an arranged window: outer and inner outlines, the title gradient, title (NULL: none) in font cut with "..." to title_label's width and kept inside its free interval, and each present control (face, bevel and glyph).
void rmgui_window_frame_paint_to (rmgui_target_t *, rmgui_font_t *, const rmgui_style_resolved_t *, const rmgui_window_frame_window_t *, rmgui_rect_t, const char *, const rmgui_window_frame_t *)
 Explicit destination STANDARD chrome, preserving CPU geometry and order.
rmgui_input_result_t rmgui_window_frame_activate (const rmgui_window_frame_t *self, const rmgui_window_frame_window_t *window, rmgui_window_frame_control_t control)
 Activate a present control using the same validation as pointer release.
rmgui_rect_t rmgui_window_frame_shadow_bounds (const rmgui_style_resolved_t *rs, const rmgui_window_frame_window_t *window)
 Conservative device bounds of the offset/inset rounded shadow plus glow.
void rmgui_window_frame_paint_shadow (rmgui_fb_t *fb, const rmgui_style_resolved_t *rs, const rmgui_window_frame_window_t *window, rmgui_rect_t clip)
 Paint WINDOW/SHADOW over shadow_bounds when bound; otherwise paint the shadow silhouette fill and outer glow.
void rmgui_window_frame_paint_shadow_to (rmgui_target_t *, const rmgui_style_resolved_t *, const rmgui_window_frame_window_t *, rmgui_rect_t)
 Explicit shadow destination; skin dispatch precedes the procedural shadow.
rmgui_input_result_t rmgui_window_frame_input (rmgui_window_frame_t *self, const rmgui_window_frame_window_t *window, const rmgui_input_t *in)
 Applies one event to an arranged window.
void rmgui_window_frame_metrics (const rmgui_style_resolved_t *window, const rmgui_desktop_style_resolved_t *desktop, int taskbar_height, int clock_label_width, int cursor_width, int cursor_height, rmgui_window_frame_metrics_t *out)
 Fills out from a WINDOW and a DESKTOP resolved record, plus the host's taskbar height, measured clock label width and cursor size; tray_count is 0.
rmgui_window_frame_part_t rmgui_window_frame_part_at (const rmgui_window_frame_window_t *window, int x, int y)
 The part under (x, y): NONE over any present control, even a disabled one, else corner grip, edge band, MOVE over drag_handle, else NONE.
int rmgui_window_frame_constrain (rmgui_window_frame_part_t part, rmgui_rect_t start, const rmgui_window_frame_proposal_t *proposed, rmgui_size_t min_size, rmgui_rect_t bounds, const rmgui_window_frame_constraints_t *constraints, rmgui_rect_t *out_frame)
rmgui_input_result_t rmgui_window_frame_drag (rmgui_window_frame_drag_t *self, const rmgui_window_frame_window_t *window, rmgui_size_t min_size, rmgui_rect_t bounds, const rmgui_window_frame_constraints_t *constraints, const rmgui_input_t *in, rmgui_rect_t *out_frame)
 Applies one pointer event to a drag of window.
rmgui_input_result_t rmgui_window_frame_event (rmgui_window_frame_view_t *frame, const rmgui_window_frame_window_t *window, const rmgui_input_t *event)
 Route one caption control event against the arranged window.
int rmgui_window_frame_prepare (const rmgui_ui_t *ui, const rmgui_window_frame_view_t *frame, const rmgui_window_frame_window_t *window)
 Stage title glyphs for the arranged normal frame before recording, including the fitted suffix when used.
int rmgui_window_frame_draw (const rmgui_ui_t *ui, const rmgui_window_frame_view_t *frame, const rmgui_window_frame_window_t *window)
 Draw the arranged normal frame.

Detailed Description

window_frame.h — the window frame element (one window's chrome: arrange, measure, paint, control input, move/resize drag) and the desktop chrome catalog a shell host arranges its taskbar, tray, clock, cursor and windows with.

Every rectangle and resolved metric is in device pixels, half-open on its right and bottom edges.

Macro Definition Documentation

◆ RMGUI_WINDOW_FRAME_CLOSE

#define RMGUI_WINDOW_FRAME_CLOSE   0x01u

Caption control/capability bits.

MAXIMIZABLE without RESIZABLE displays a disabled maximize control; unknown bits are invalid.

◆ RMGUI_WINDOW_FRAME_MINIMIZE

#define RMGUI_WINDOW_FRAME_MINIMIZE   0x02u

◆ RMGUI_WINDOW_FRAME_RESIZABLE

#define RMGUI_WINDOW_FRAME_RESIZABLE   0x04u

◆ RMGUI_WINDOW_FRAME_MAXIMIZABLE

#define RMGUI_WINDOW_FRAME_MAXIMIZABLE   0x08u

◆ RMGUI_WINDOW_FRAME_FLAGS_ALL

#define RMGUI_WINDOW_FRAME_FLAGS_ALL   0x0fu

Enumeration Type Documentation

◆ rmgui_window_frame_control_t

A window control; NONE is 0 so a zeroed rmgui_window_frame_t holds none.

Enumerator
RMGUI_WINDOW_FRAME_CONTROL_NONE 
RMGUI_WINDOW_FRAME_CONTROL_CLOSE 
RMGUI_WINDOW_FRAME_CONTROL_MINIMIZE 
RMGUI_WINDOW_FRAME_CONTROL_MAXIMIZE 
RMGUI_WINDOW_FRAME_CONTROL_RESTORE 

◆ rmgui_window_frame_kind_t

Chrome of one declared window: framed shell window, or rounded card.

Enumerator
RMGUI_WINDOW_FRAME_KIND_STANDARD 
RMGUI_WINDOW_FRAME_KIND_CARD 

◆ rmgui_window_frame_part_t

A part of an arranged window the pointer can drag: the drag handle moves the frame, a corner grip or edge band resizes it.

RESIZE_* follow the resize_* rects of rmgui_window_frame_window_t. NONE is 0 so a zeroed drag is idle.

Enumerator
RMGUI_WINDOW_FRAME_PART_NONE 
RMGUI_WINDOW_FRAME_PART_MOVE 
RMGUI_WINDOW_FRAME_PART_RESIZE_L 
RMGUI_WINDOW_FRAME_PART_RESIZE_T 
RMGUI_WINDOW_FRAME_PART_RESIZE_R 
RMGUI_WINDOW_FRAME_PART_RESIZE_B 
RMGUI_WINDOW_FRAME_PART_RESIZE_LT 
RMGUI_WINDOW_FRAME_PART_RESIZE_RT 
RMGUI_WINDOW_FRAME_PART_RESIZE_LB 
RMGUI_WINDOW_FRAME_PART_RESIZE_RB 

Function Documentation

◆ rmgui_window_frame_catalog()

int rmgui_window_frame_catalog ( const rmgui_window_frame_decl_t * declaration,
rmgui_window_frame_catalog_t * out )

Arranges a whole desktop.

When taskbar cells, tray and clock do not fit, cells first shrink to their minimum, then tray cells drop from the end, then the clock, then trailing cells. Returns 0, or -1 (*out unchanged) when an argument is NULL, a declared value is outside its documented range, storage is NULL or insufficient, a window is smaller than its chrome, or a rect overflows int.

◆ rmgui_window_frame_arrange()

int rmgui_window_frame_arrange ( const rmgui_style_resolved_t * rs,
rmgui_rect_t frame,
int title_label_w,
unsigned flags,
int maximized,
rmgui_window_frame_window_t * out )

Arranges one STANDARD window at frame with the chrome metrics the WINDOW record rs implies and a title_label_w wide title.

flags selects present controls/capabilities; maximized is 0/1 and requires RESIZABLE and MAXIMIZABLE. No resize bands exist if not resizable or if maximized. Returns 0, or -1 (*out unchanged) for NULL, invalid flags/state/metrics, negative title_label_w, overflow, or a frame smaller than its chrome.

◆ rmgui_window_frame_measure()

rmgui_size_t rmgui_window_frame_measure ( const rmgui_style_resolved_t * rs,
int title_label_w,
rmgui_size_t content_min,
unsigned flags )

Smallest frame rmgui_window_frame_arrange accepts whose content holds content_min and whose title bar shows a title_label_w wide title whole between the frame edge and the controls selected by flags, assuming not maximized.

Negative dimensions count as 0; NULL rs or invalid flags returns {0, 0}.

◆ rmgui_window_frame_paint()

void rmgui_window_frame_paint ( rmgui_fb_t * fb,
rmgui_font_t * font,
const rmgui_style_resolved_t * rs,
const rmgui_window_frame_window_t * window,
rmgui_rect_t clip,
const char * title,
const rmgui_window_frame_t * self )

Paints STANDARD chrome of an arranged window: outer and inner outlines, the title gradient, title (NULL: none) in font cut with "..." to title_label's width and kept inside its free interval, and each present control (face, bevel and glyph).

self=NULL selects normal interaction; otherwise hover/press are per control. rs DISABLED/INACTIVE remain orthogonal; glyph-hover-only uses group_hover or rs FOCUSED. group_hover supplies HOVER to every glyph query without changing the other faces. A ROLE_RAMP title selects scheme TEXT or BACKGROUND ink by contrast to its center source sample; other titles retain rs->text. Body ink is unchanged. A CARD paints nothing. No pixel outside window->frame intersect clip is written. NULL fb/rs/window paints nothing; NULL font paints no title.

◆ rmgui_window_frame_paint_to()

void rmgui_window_frame_paint_to ( rmgui_target_t * ,
rmgui_font_t * ,
const rmgui_style_resolved_t * ,
const rmgui_window_frame_window_t * ,
rmgui_rect_t ,
const char * ,
const rmgui_window_frame_t *  )

Explicit destination STANDARD chrome, preserving CPU geometry and order.

RECORD titles require prepared glyphs, including "..."; sheets remain immutable until submit/discard. No allocation; stream failures latch.

◆ rmgui_window_frame_activate()

rmgui_input_result_t rmgui_window_frame_activate ( const rmgui_window_frame_t * self,
const rmgui_window_frame_window_t * window,
rmgui_window_frame_control_t control )

Activate a present control using the same validation as pointer release.

ACTION carries its control (MAXIMIZE becomes RESTORE when maximized). Disabled whole window/capability returns consumed REFUSED; inactive alone remains actionable. NULL, invalid or absent control returns NONE. Hosts route Enter/Space from their own logical caption focus targets.

◆ rmgui_window_frame_shadow_bounds()

rmgui_rect_t rmgui_window_frame_shadow_bounds ( const rmgui_style_resolved_t * rs,
const rmgui_window_frame_window_t * window )

Conservative device bounds of the offset/inset rounded shadow plus glow.

Transparent shadow or NULL arguments return an empty rect; overflow is clamped. Damage unions old/new shadow bounds with old/new frame bounds.

◆ rmgui_window_frame_paint_shadow()

void rmgui_window_frame_paint_shadow ( rmgui_fb_t * fb,
const rmgui_style_resolved_t * rs,
const rmgui_window_frame_window_t * window,
rmgui_rect_t clip )

Paint WINDOW/SHADOW over shadow_bounds when bound; otherwise paint the shadow silhouette fill and outer glow.

Clipped to fb and clip, before host body and frame paint. NULL or transparent shadow paints nothing. No allocation or pixels outside shadow_bounds are permitted.

◆ rmgui_window_frame_paint_shadow_to()

void rmgui_window_frame_paint_shadow_to ( rmgui_target_t * ,
const rmgui_style_resolved_t * ,
const rmgui_window_frame_window_t * ,
rmgui_rect_t  )

Explicit shadow destination; skin dispatch precedes the procedural shadow.

RECORD pins skin sheets and appends bounded commands; failures latch.

◆ rmgui_window_frame_input()

rmgui_input_result_t rmgui_window_frame_input ( rmgui_window_frame_t * self,
const rmgui_window_frame_window_t * window,
const rmgui_input_t * in )

Applies one event to an arranged window.

A press inside the frame holds the pointer (PRESSED while it stays inside the frame); releasing it over the control the press began on returns ACTION, value = that rmgui_window_frame_control_t through activate. group_hover includes gaps. Keys are host-owned. Disabled whole/capability presses return consumed REFUSED without capture/action; INACTIVE alone remains actionable. Rearrangement removing the captured control cancels it on the next input. self, window or in NULL returns NONE.

◆ rmgui_window_frame_metrics()

void rmgui_window_frame_metrics ( const rmgui_style_resolved_t * window,
const rmgui_desktop_style_resolved_t * desktop,
int taskbar_height,
int clock_label_width,
int cursor_width,
int cursor_height,
rmgui_window_frame_metrics_t * out )

Fills out from a WINDOW and a DESKTOP resolved record, plus the host's taskbar height, measured clock label width and cursor size; tray_count is 0.

NULL window, desktop or out writes nothing. The host sizes are pixel dimensions and must not be scaled again.

◆ rmgui_window_frame_part_at()

rmgui_window_frame_part_t rmgui_window_frame_part_at ( const rmgui_window_frame_window_t * window,
int x,
int y )

The part under (x, y): NONE over any present control, even a disabled one, else corner grip, edge band, MOVE over drag_handle, else NONE.

window NULL returns NONE.

◆ rmgui_window_frame_constrain()

int rmgui_window_frame_constrain ( rmgui_window_frame_part_t part,
rmgui_rect_t start,
const rmgui_window_frame_proposal_t * proposed,
rmgui_size_t min_size,
rmgui_rect_t bounds,
const rmgui_window_frame_constraints_t * constraints,
rmgui_rect_t * out_frame )

◆ rmgui_window_frame_drag()

rmgui_input_result_t rmgui_window_frame_drag ( rmgui_window_frame_drag_t * self,
const rmgui_window_frame_window_t * window,
rmgui_size_t min_size,
rmgui_rect_t bounds,
const rmgui_window_frame_constraints_t * constraints,
const rmgui_input_t * in,
rmgui_rect_t * out_frame )

Applies one pointer event to a drag of window.

PRESS on a part (see rmgui_window_frame_part_at) starts a drag: consumed and captured; a PRESS while a drag is held is consumed and changes nothing. MOVE or RELEASE while one is held writes out_frame: the frame at the press moved (MOVE) or with the grabbed edges moved (RESIZE_) by the pointer's travel since the press. A moving edge stops where the frame would be narrower or lower than min_size (negative counts as 0) or leave bounds, and never travels further past a limit its start already crossed; a moved frame is kept inside bounds (its top-left wins when it is larger). A frame that would not fit int is written as window->frame. Returns CHANGE, value = the part, when *out_frame differs from window->frame, else NONE. RELEASE and LEAVE end the drag (consumed). Other events, and a press off every part, are not consumed and leave *out_frame unwritten. Call it beside rmgui_window_frame_input with the same event; a host skips it for a DISABLED window. self, window, in or out_frame NULL, or bounds with w or h <= 0, returns NONE and writes nothing.

◆ rmgui_window_frame_event()

rmgui_input_result_t rmgui_window_frame_event ( rmgui_window_frame_view_t * frame,
const rmgui_window_frame_window_t * window,
const rmgui_input_t * event )

Route one caption control event against the arranged window.

◆ rmgui_window_frame_prepare()

int rmgui_window_frame_prepare ( const rmgui_ui_t * ui,
const rmgui_window_frame_view_t * frame,
const rmgui_window_frame_window_t * window )

Stage title glyphs for the arranged normal frame before recording, including the fitted suffix when used.

CPU targets and omitted titles or fonts need no staging. Returns 0 on success or -1 on error.

◆ rmgui_window_frame_draw()

int rmgui_window_frame_draw ( const rmgui_ui_t * ui,
const rmgui_window_frame_view_t * frame,
const rmgui_window_frame_window_t * window )

Draw the arranged normal frame.

A NULL font omits the title. Returns -1 for invalid arguments or style, otherwise 0; check the target for paint errors.