|
RMGui 0.15.0
C11 retained-mode UI library: layout kernel, style schema, widget painters, fonts, software framebuffer
|
paint.h — element-agnostic painters: the face box model (inset and content box), the face box itself, clipped text and published paragraphs. More...
#include <stddef.h>#include "fb.h"#include "font.h"#include "geom.h"#include "layout.h"#include "mask.h"#include "style.h"#include "draw_target.h"Data Structures | |
| struct | rmgui_paint_inset_t |
| The box model every face obeys. More... | |
Macros | |
| #define | RMGUI_PAINT_STROKE_PX 1 |
| Width in pixels of the one-pixel face stroke BUTTON reserves outside its padding. | |
Functions | |
| rmgui_paint_inset_t | rmgui_paint_face_inset (rmgui_style_class_t class_id, const rmgui_style_resolved_t *style) |
| The content inset of class_id's face for the resolved record style (resolved for that class). | |
| rmgui_rect_t | rmgui_paint_content_box (rmgui_rect_t r, rmgui_paint_inset_t inset) |
| r inset by inset on both axes; negative inset components count as 0. | |
| void | rmgui_paint_box (rmgui_fb_t *fb, rmgui_rect_t r, const rmgui_style_resolved_t *style) |
| Paints PANEL/FACE for style->states when bound. | |
| void | rmgui_paint_box_clipped (rmgui_fb_t *fb, rmgui_rect_t r, rmgui_rect_t clip, const rmgui_style_resolved_t *style) |
| rmgui_paint_box's pixels for r, written only where they lie inside clip: the box keeps the place and size of r, so a box clip cuts loses the rings and fill outside it rather than drawing them at the clip's edge. | |
| int | rmgui_paint_box_ground (const rmgui_style_resolved_t *style, rmgui_mask_nine_t *ground) |
| Replaces *ground (zero-initialized, or filled by an earlier call) with the background of the box rmgui_paint_box paints for style: the shape a backdrop laid over that box must keep to so that it reaches the border on every side, follows rounded corners and leaves the border its colours. | |
| void | rmgui_paint_text (rmgui_fb_t *fb, rmgui_font_t *font, rmgui_rect_t r, rmgui_rect_t clip, int x, int y, const char *text, size_t length, int font_px, rmgui_color_t color) |
| Draws the UTF-8 text[0, length) with its line box's top-left at (x, y) in color at font_px through font, writing only pixels inside the intersection of r and clip. | |
| void | rmgui_paint_paragraph (rmgui_fb_t *fb, rmgui_font_t *font, const rmgui_layout_snapshot_node_t *node, const char *text, int font_px, rmgui_color_t color) |
| Paints one TEXT node as the kernel published it through font, writing only pixels inside the intersection of node->rect and node->clip: | |
| void | rmgui_paint_box_to (rmgui_target_t *, rmgui_rect_t, const rmgui_style_resolved_t *) |
| Explicit destination versions preserve the corresponding framebuffer painter's geometry and clipping. | |
| void | rmgui_paint_box_clipped_to (rmgui_target_t *, rmgui_rect_t, rmgui_rect_t, const rmgui_style_resolved_t *) |
| Paint a box through clip, with the same target failure contract above. | |
| void | rmgui_paint_text_to (rmgui_target_t *, rmgui_font_t *, rmgui_rect_t, rmgui_rect_t, int, int, const char *, size_t, int, rmgui_color_t) |
| Paint prepared text through rect intersect clip; no allocation in RECORD. | |
| void | rmgui_paint_paragraph_to (rmgui_target_t *, rmgui_font_t *, const rmgui_layout_snapshot_node_t *, const char *, int, rmgui_color_t) |
| Paint the published paragraph; every emitted glyph must be prepared. | |
paint.h — element-agnostic painters: the face box model (inset and content box), the face box itself, clipped text and published paragraphs.
Every coordinate is a logical framebuffer pixel. Painters that draw text take the font as the parameter after the framebuffer (see font.h).
| #define RMGUI_PAINT_STROKE_PX 1 |
Width in pixels of the one-pixel face stroke BUTTON reserves outside its padding.
| rmgui_paint_inset_t rmgui_paint_face_inset | ( | rmgui_style_class_t | class_id, |
| const rmgui_style_resolved_t * | style ) |
The content inset of class_id's face for the resolved record style (resolved for that class).
Returns {0, 0} when style is NULL.
| rmgui_rect_t rmgui_paint_content_box | ( | rmgui_rect_t | r, |
| rmgui_paint_inset_t | inset ) |
r inset by inset on both axes; negative inset components count as 0.
The result always lies inside r: an inset wider than the rect yields an empty box centred in it, never a negative extent.
| void rmgui_paint_box | ( | rmgui_fb_t * | fb, |
| rmgui_rect_t | r, | ||
| const rmgui_style_resolved_t * | style ) |
Paints PANEL/FACE for style->states when bound.
Otherwise fills r with style->background and strokes style->border_width nested one-pixel rings of style->border inside it. Writes only pixels of r that lie in the framebuffer. NULL fb or style paints nothing.
| void rmgui_paint_box_clipped | ( | rmgui_fb_t * | fb, |
| rmgui_rect_t | r, | ||
| rmgui_rect_t | clip, | ||
| const rmgui_style_resolved_t * | style ) |
rmgui_paint_box's pixels for r, written only where they lie inside clip: the box keeps the place and size of r, so a box clip cuts loses the rings and fill outside it rather than drawing them at the clip's edge.
With clip covering r the result equals rmgui_paint_box(fb, r, style). NULL fb or style, or an empty overlap of r and clip, paints nothing.
| int rmgui_paint_box_ground | ( | const rmgui_style_resolved_t * | style, |
| rmgui_mask_nine_t * | ground ) |
Replaces *ground (zero-initialized, or filled by an earlier call) with the background of the box rmgui_paint_box paints for style: the shape a backdrop laid over that box must keep to so that it reaches the border on every side, follows rounded corners and leaves the border its colours.
| void rmgui_paint_text | ( | rmgui_fb_t * | fb, |
| rmgui_font_t * | font, | ||
| rmgui_rect_t | r, | ||
| rmgui_rect_t | clip, | ||
| int | x, | ||
| int | y, | ||
| const char * | text, | ||
| size_t | length, | ||
| int | font_px, | ||
| rmgui_color_t | color ) |
Draws the UTF-8 text[0, length) with its line box's top-left at (x, y) in color at font_px through font, writing only pixels inside the intersection of r and clip.
NULL fb, font or text, or an empty intersection, paints nothing.
| void rmgui_paint_paragraph | ( | rmgui_fb_t * | fb, |
| rmgui_font_t * | font, | ||
| const rmgui_layout_snapshot_node_t * | node, | ||
| const char * | text, | ||
| int | font_px, | ||
| rmgui_color_t | color ) |
Paints one TEXT node as the kernel published it through font, writing only pixels inside the intersection of node->rect and node->clip:
| void rmgui_paint_box_to | ( | rmgui_target_t * | , |
| rmgui_rect_t | , | ||
| const rmgui_style_resolved_t * | ) |
Explicit destination versions preserve the corresponding framebuffer painter's geometry and clipping.
RECORD text requires prepared glyphs; failures latch on the stream, without allocation or implicit preparation.
| void rmgui_paint_box_clipped_to | ( | rmgui_target_t * | , |
| rmgui_rect_t | , | ||
| rmgui_rect_t | , | ||
| const rmgui_style_resolved_t * | ) |
Paint a box through clip, with the same target failure contract above.
| void rmgui_paint_text_to | ( | rmgui_target_t * | , |
| rmgui_font_t * | , | ||
| rmgui_rect_t | , | ||
| rmgui_rect_t | , | ||
| int | , | ||
| int | , | ||
| const char * | , | ||
| size_t | , | ||
| int | , | ||
| rmgui_color_t | ) |
Paint prepared text through rect intersect clip; no allocation in RECORD.
| void rmgui_paint_paragraph_to | ( | rmgui_target_t * | , |
| rmgui_font_t * | , | ||
| const rmgui_layout_snapshot_node_t * | , | ||
| const char * | , | ||
| int | , | ||
| rmgui_color_t | ) |
Paint the published paragraph; every emitted glyph must be prepared.