GFXprim
2D bitmap graphics library with emphasis on speed and correctness
Loading...
Searching...
No Matches
include
widgets
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
16
#include <
widgets/gp_widget_types.h
>
17
#include <
widgets/gp_widget_render.h
>
18
31
struct
gp_widget_size
{
33
uint16_t
px
;
35
uint8_t
pad
;
37
uint8_t
asc
;
38
};
39
48
static
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
63
int
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_text_ascent
gp_size gp_text_ascent(const gp_text_style *style)
Returns an ascent.
gp_widget_render.h
Widget rendering.
gp_widget_size_units_parse
int gp_widget_size_units_parse(const char *size, gp_widget_size *ret)
Parses widget size from a string.
gp_widget_size_units_get
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.
Definition
gp_widget_size_units.h:48
gp_widget_types.h
Common widget types.
gp_widget_render_ctx
Global widget (rendering) context.
Definition
gp_widget_render.h:29
gp_widget_render_ctx::padd
uint8_t padd
Padding between widgets.
Definition
gp_widget_render.h:103
gp_widget_render_ctx::font
gp_text_style * font
Default font.
Definition
gp_widget_render.h:87
gp_widget_size
A compound size.
Definition
gp_widget_size_units.h:31
gp_widget_size::asc
uint8_t asc
Size in text ascent units.
Definition
gp_widget_size_units.h:37
gp_widget_size::px
uint16_t px
Size in pixel.
Definition
gp_widget_size_units.h:33
gp_widget_size::pad
uint8_t pad
Size in padding units.
Definition
gp_widget_size_units.h:35
Generated by
1.9.8