GFXprim
2D bitmap graphics library with emphasis on speed and correctness
Loading...
Searching...
No Matches
gp_widget_size_units.h
Go to the documentation of this file.
1//SPDX-License-Identifier: LGPL-2.0-or-later
2
3/*
4
5 Copyright (c) 2014-2024 Cyril Hrubis <metan@ucw.cz>
6
7 */
8
13#ifndef GP_WIDGET_SIZE_UNITS_H
14#define GP_WIDGET_SIZE_UNITS_H
15
18
33 uint16_t px;
35 uint8_t pad;
37 uint8_t asc;
38};
39
48static inline unsigned int gp_widget_size_units_get(gp_widget_size *size,
49 const gp_widget_render_ctx *ctx)
50{
51 return size->px + ctx->padd * size->pad +
52 gp_text_ascent(ctx->font) * size->asc;
53}
54
63int gp_widget_size_units_parse(const char *size, gp_widget_size *ret);
64
74#define GP_WIDGET_SIZE(px_val, pad_val, asc_val) \
75 ((gp_widget_size){.px = px_val, .pad = pad_val, .asc = asc_val})
76
83#define GP_WIDGET_SIZE_DEFAULT ((gp_widget_size){0xffff, 0xff, 0xff})
84
93#define GP_WIDGET_SIZE_EQ(a, b) (((a).px == (b).px) && \
94 ((a).pad == (b).pad) && \
95 ((a).asc == (b).asc))
96
97#endif /* GP_WIDGET_SIZE_UNITS_H */
gp_size gp_text_ascent(const gp_text_style *style)
Returns an ascent.
Widget rendering.
int gp_widget_size_units_parse(const char *size, gp_widget_size *ret)
Parses widget size from a string.
static unsigned int gp_widget_size_units_get(gp_widget_size *size, const gp_widget_render_ctx *ctx)
Returns size in pixel given gp_widget_size and rendering context.
Common widget types.
Global widget (rendering) context.
uint8_t padd
Padding between widgets.
gp_text_style * font
Default font.
A compound size.
uint8_t asc
Size in text ascent units.
uint16_t px
Size in pixel.
uint8_t pad
Size in padding units.