mirror of
https://codeberg.org/dnkl/yambar.git
synced 2025-04-24 12:55:41 +02:00
config: clean up particle_string_from_config()
This commit is contained in:
parent
7670473735
commit
6019129acc
1 changed files with 17 additions and 26 deletions
43
config.c
43
config.c
|
@ -187,37 +187,28 @@ particle_string_from_config(const struct yml_node *node,
|
||||||
{
|
{
|
||||||
assert(yml_is_dict(node));
|
assert(yml_is_dict(node));
|
||||||
|
|
||||||
const struct yml_node *text_node = yml_get_value(node, "text");
|
const struct yml_node *text = yml_get_value(node, "text");
|
||||||
const struct yml_node *font_node = yml_get_value(node, "font");
|
const struct yml_node *font = yml_get_value(node, "font");
|
||||||
const struct yml_node *foreground_node = yml_get_value(node, "foreground");
|
const struct yml_node *foreground = yml_get_value(node, "foreground");
|
||||||
const struct yml_node *margin_node = yml_get_value(node, "margin");
|
const struct yml_node *margin = yml_get_value(node, "margin");
|
||||||
const struct yml_node *left_margin_node = yml_get_value(node, "left_margin");
|
const struct yml_node *left_margin = yml_get_value(node, "left_margin");
|
||||||
const struct yml_node *right_margin_node = yml_get_value(node, "right_margin");
|
const struct yml_node *right_margin = yml_get_value(node, "right_margin");
|
||||||
|
|
||||||
/* TODO: inherit values? At least color... */
|
assert(text != NULL && yml_is_scalar(text));
|
||||||
struct rgba foreground = {1.0, 1.0, 1.0, 1.0};
|
|
||||||
int left_margin = 0;
|
|
||||||
int right_margin = 0;
|
|
||||||
|
|
||||||
struct font *font = NULL;
|
struct rgba fg_color = foreground != NULL
|
||||||
if (font_node != NULL)
|
? color_from_hexstr(yml_value_as_string(foreground)) :
|
||||||
font = font_from_config(font_node);
|
(struct rgba){1.0, 1.0, 1.0, 1.0};
|
||||||
else
|
|
||||||
font = font_clone(parent_font);
|
|
||||||
|
|
||||||
if (foreground_node != NULL)
|
int left = margin != NULL ? yml_value_as_int(margin) :
|
||||||
foreground = color_from_hexstr(yml_value_as_string(foreground_node));
|
left_margin != NULL ? yml_value_as_int(left_margin) : 0;
|
||||||
|
int right = margin != NULL ? yml_value_as_int(margin) :
|
||||||
|
right_margin != NULL ? yml_value_as_int(right_margin) : 0;
|
||||||
|
|
||||||
if (margin_node != NULL)
|
|
||||||
left_margin = right_margin = yml_value_as_int(margin_node);
|
|
||||||
if (left_margin_node != NULL)
|
|
||||||
left_margin = yml_value_as_int(left_margin_node);
|
|
||||||
if (right_margin_node != NULL)
|
|
||||||
right_margin = yml_value_as_int(right_margin_node);
|
|
||||||
|
|
||||||
assert(text_node != NULL);
|
|
||||||
return particle_string_new(
|
return particle_string_new(
|
||||||
yml_value_as_string(text_node), font, foreground, left_margin, right_margin);
|
yml_value_as_string(text),
|
||||||
|
font != NULL ? font_from_config(font) : font_clone(parent_font),
|
||||||
|
fg_color, left, right);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct particle * particle_from_config(
|
static struct particle * particle_from_config(
|
||||||
|
|
Loading…
Add table
Reference in a new issue