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

button.h — the button element: a face with a flowed, centred label that activates on click completion or SPACE/ENTER. More...

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

Data Structures

struct  rmgui_button_t
 Retained, zero-initialized button state. More...

Functions

rmgui_size_t rmgui_button_measure (const rmgui_font_t *font, const rmgui_style_resolved_t *rs, const char *label, int max_w)
 Minimum outer size of a BUTTON face showing label (NULL = empty) in font: the label flowed with rmgui_text_flow_line_prefix at wrap width max_w - 2 * inset.x (unbounded when max_w <= 0), plus the rmgui_paint_face_inset on both sides.
void rmgui_button_paint (rmgui_fb_t *fb, rmgui_font_t *font, const rmgui_style_resolved_t *rs, rmgui_rect_t rect, rmgui_rect_t clip, const char *label)
 Paints the button face (rs->background, with rs->overlay_disabled composited over it under DISABLED, then a one-pixel rs->border stroke), then label in font flowed at the content-box width exactly as rmgui_button_measure flows it, each line centred horizontally and the block centred vertically (one pixel lower under PRESSED), in rs->text.
void rmgui_button_paint_to (rmgui_target_t *, rmgui_font_t *, const rmgui_style_resolved_t *, rmgui_rect_t, rmgui_rect_t, const char *)
 Explicit destination button paint; RECORD labels require prepared glyphs and immutable skin sheets until submit/discard.
rmgui_input_result_t rmgui_button_input (rmgui_button_t *self, rmgui_rect_t rect, const rmgui_input_t *in)
 Applies one event to the button whose arranged rect is rect.

Detailed Description

button.h — the button element: a face with a flowed, centred label that activates on click completion or SPACE/ENTER.

Function Documentation

◆ rmgui_button_measure()

rmgui_size_t rmgui_button_measure ( const rmgui_font_t * font,
const rmgui_style_resolved_t * rs,
const char * label,
int max_w )

Minimum outer size of a BUTTON face showing label (NULL = empty) in font: the label flowed with rmgui_text_flow_line_prefix at wrap width max_w - 2 * inset.x (unbounded when max_w <= 0), plus the rmgui_paint_face_inset on both sides.

The height is at least rs->min_height and the width at least rs->min_width. rs is resolved for BUTTON; a NULL rs yields {0, 0}. A label font cannot measure (NULL, or holding no face) measures as an empty label. There is no label byte-length cap.

◆ rmgui_button_paint()

void rmgui_button_paint ( rmgui_fb_t * fb,
rmgui_font_t * font,
const rmgui_style_resolved_t * rs,
rmgui_rect_t rect,
rmgui_rect_t clip,
const char * label )

Paints the button face (rs->background, with rs->overlay_disabled composited over it under DISABLED, then a one-pixel rs->border stroke), then label in font flowed at the content-box width exactly as rmgui_button_measure flows it, each line centred horizontally and the block centred vertically (one pixel lower under PRESSED), in rs->text.

Writes only pixels inside the intersection of rect and clip. NULL fb or rs paints nothing; NULL label or font paints no label.

◆ rmgui_button_paint_to()

void rmgui_button_paint_to ( rmgui_target_t * ,
rmgui_font_t * ,
const rmgui_style_resolved_t * ,
rmgui_rect_t ,
rmgui_rect_t ,
const char *  )

Explicit destination button paint; RECORD labels require prepared glyphs and immutable skin sheets until submit/discard.

Errors latch; no allocation.

◆ rmgui_button_input()

rmgui_input_result_t rmgui_button_input ( rmgui_button_t * self,
rmgui_rect_t rect,
const rmgui_input_t * in )

Applies one event to the button whose arranged rect is rect.

For shaped buttons, the host first filters the event with rmgui_input_shape using the node's shape and this rect. Pointer: HOVER follows the pointer; PRESS inside captures, and PRESSED holds while the captured pointer is inside; RELEASE ends the capture and reports ACTIVATE (value 0) when it lands inside. LEAVE clears HOVER, PRESSED and the capture. KEY SPACE/ENTER reports ACTIVATE. FOCUS_IN/FOCUS_OUT set/clear FOCUSED. While DISABLED an inside PRESS reports REFUSED (value 0, consumed 1, captured 0); other events report NONE, PRESSED/capture clear, HOVER/FOCUSED still track. NULL self or in returns an all-zero result.