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

section.h — the section element: a titled panel grouping host content. More...

#include "fb.h"
#include "font.h"
#include "geom.h"
#include "style.h"
#include "draw_target.h"
#include "ui_context.h"

Data Structures

struct  rmgui_section_t
 A section with optional borrowed NUL-terminated title and its alignment. More...
struct  rmgui_section_insets_t
 Distances from a section's outer edges to its content box, device px. More...
struct  rmgui_section_parts_t
 An arranged section. More...

Enumerations

enum  rmgui_section_title_t { RMGUI_SECTION_TITLE_START , RMGUI_SECTION_TITLE_CENTER }
 Horizontal placement of the title in the section's title row. More...

Functions

int rmgui_section_prepare (const rmgui_ui_t *ui, const rmgui_section_t *section)
 Prepare the title before recording without emitting commands.
int rmgui_section_draw (const rmgui_ui_t *ui, const rmgui_section_t *section, rmgui_rect_t box)
 Draw the face and title using the theme's TEXT_FIELD style, without laying out children.
rmgui_section_insets_t rmgui_section_insets (const rmgui_style_resolved_t *rs, const char *title)
 The insets of a section resolved by rs (any class the host resolves: the element reads border_width, padding_x, padding_y and line_height): the border plus the padding on every side, and on top one title line and one more padding_y when title is a non-empty string.
rmgui_size_t rmgui_section_measure (const rmgui_font_t *font, const rmgui_style_resolved_t *rs, const char *title, rmgui_size_t content)
 The outer size of a section around a content box: the content plus the insets, and never narrower than the title's single-line width in font at rs->font_px plus the horizontal insets.
int rmgui_section_arrange (const rmgui_font_t *font, const rmgui_style_resolved_t *rs, rmgui_rect_t rect, const char *title, rmgui_section_title_t align, rmgui_section_parts_t *out)
 Arranges a section in rect.
void rmgui_section_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 *title, rmgui_section_title_t align)
 Paints the section's face over rect as rmgui_paint_box_clipped does (PANEL/FACE for rs->states when a skin binds it, else rs->background under border_width strokes of rs->border), then the title in font and rs->text inside its arranged line box.
void rmgui_section_paint_to (rmgui_target_t *, rmgui_font_t *, const rmgui_style_resolved_t *, rmgui_rect_t, rmgui_rect_t, const char *, rmgui_section_title_t)
 Explicit section destination with identical face, title and clipping.
void rmgui_section_paint_title (rmgui_fb_t *fb, rmgui_font_t *font, const rmgui_style_resolved_t *rs, rmgui_rect_t rect, rmgui_rect_t clip, const char *title, rmgui_section_title_t align)
 Paints the title alone, exactly the title pixels rmgui_section_paint writes over its face: a host that lays its own backdrop over the face paints the face (rmgui_section_paint with a NULL font, or rmgui_paint_box_clipped), the backdrop, then this.
void rmgui_section_paint_title_to (rmgui_target_t *, rmgui_font_t *, const rmgui_style_resolved_t *, rmgui_rect_t, rmgui_rect_t, const char *, rmgui_section_title_t)
 Explicit destination for rmgui_section_paint_title.

Detailed Description

section.h — the section element: a titled panel grouping host content.

It owns no state and no input: the host arranges its own controls in the content box and paints them after the section.

Enumeration Type Documentation

◆ rmgui_section_title_t

Horizontal placement of the title in the section's title row.

Enumerator
RMGUI_SECTION_TITLE_START 
RMGUI_SECTION_TITLE_CENTER 

Function Documentation

◆ rmgui_section_prepare()

int rmgui_section_prepare ( const rmgui_ui_t * ui,
const rmgui_section_t * section )

Prepare the title before recording without emitting commands.

Returns 0 or -1 for invalid arguments, style or preparation.

◆ rmgui_section_draw()

int rmgui_section_draw ( const rmgui_ui_t * ui,
const rmgui_section_t * section,
rmgui_rect_t box )

Draw the face and title using the theme's TEXT_FIELD style, without laying out children.

Returns 0 or -1 for invalid arguments or style; paint errors latch on the target.

◆ rmgui_section_insets()

rmgui_section_insets_t rmgui_section_insets ( const rmgui_style_resolved_t * rs,
const char * title )

The insets of a section resolved by rs (any class the host resolves: the element reads border_width, padding_x, padding_y and line_height): the border plus the padding on every side, and on top one title line and one more padding_y when title is a non-empty string.

Negative record lengths count as 0. NULL rs yields all zeros.

◆ rmgui_section_measure()

rmgui_size_t rmgui_section_measure ( const rmgui_font_t * font,
const rmgui_style_resolved_t * rs,
const char * title,
rmgui_size_t content )

The outer size of a section around a content box: the content plus the insets, and never narrower than the title's single-line width in font at rs->font_px plus the horizontal insets.

Negative content extents count as 0; the result saturates at INT_MAX. NULL rs yields {0, 0}; NULL font measures the title as 0 wide.

◆ rmgui_section_arrange()

int rmgui_section_arrange ( const rmgui_font_t * font,
const rmgui_style_resolved_t * rs,
rmgui_rect_t rect,
const char * title,
rmgui_section_title_t align,
rmgui_section_parts_t * out )

Arranges a section in rect.

The content box is rect less the insets, empty (never negative) when rect is smaller than them. The title's line box sits one border and one padding_y below the top edge, as wide as the title measures and no wider than the content box, at the content box's left edge (START) or centred in it (CENTER). Returns 0, or -1 with out unchanged for NULL rs or out or an align outside the enum.

◆ rmgui_section_paint()

void rmgui_section_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 * title,
rmgui_section_title_t align )

Paints the section's face over rect as rmgui_paint_box_clipped does (PANEL/FACE for rs->states when a skin binds it, else rs->background under border_width strokes of rs->border), then the title in font and rs->text inside its arranged line box.

Writes only pixels inside rect, clip and the framebuffer; the content box holds face pixels only. NULL fb or rs or an invalid align paints nothing; NULL font or no title paints the face alone.

◆ rmgui_section_paint_to()

void rmgui_section_paint_to ( rmgui_target_t * ,
rmgui_font_t * ,
const rmgui_style_resolved_t * ,
rmgui_rect_t ,
rmgui_rect_t ,
const char * ,
rmgui_section_title_t  )

Explicit section destination with identical face, title and clipping.

RECORD requires prepared title glyphs and latches bounded-storage failures.

◆ rmgui_section_paint_title()

void rmgui_section_paint_title ( rmgui_fb_t * fb,
rmgui_font_t * font,
const rmgui_style_resolved_t * rs,
rmgui_rect_t rect,
rmgui_rect_t clip,
const char * title,
rmgui_section_title_t align )

Paints the title alone, exactly the title pixels rmgui_section_paint writes over its face: a host that lays its own backdrop over the face paints the face (rmgui_section_paint with a NULL font, or rmgui_paint_box_clipped), the backdrop, then this.

Same refusals as rmgui_section_paint; NULL font or no title paints nothing.

◆ rmgui_section_paint_title_to()

void rmgui_section_paint_title_to ( rmgui_target_t * ,
rmgui_font_t * ,
const rmgui_style_resolved_t * ,
rmgui_rect_t ,
rmgui_rect_t ,
const char * ,
rmgui_section_title_t  )

Explicit destination for rmgui_section_paint_title.