forked from external/yambar
config: allow simple lists without actually declaring a list node
That is, instead of writing: content: list: items: - string: .. - string: .. It is now possible to write: content: - string: ... - string: ... Obviously, this means it's not possible to assign spacing, margin or on-click handlers to such a list.
This commit is contained in:
parent
ed4716a600
commit
a9110cc936
1 changed files with 23 additions and 0 deletions
23
config.c
23
config.c
|
@ -334,9 +334,32 @@ particle_progress_bar_from_config(const struct yml_node *node,
|
|||
left_margin, right_margin, on_click_template);
|
||||
}
|
||||
|
||||
static struct particle *
|
||||
particle_simple_list_from_config(const struct yml_node *node,
|
||||
const struct font *parent_font)
|
||||
{
|
||||
assert(yml_is_list(node));
|
||||
|
||||
size_t count = yml_list_length(node);
|
||||
struct particle *parts[count];
|
||||
|
||||
size_t idx = 0;
|
||||
for (struct yml_list_iter it = yml_list_iter(node);
|
||||
it.node != NULL;
|
||||
yml_list_next(&it), idx++)
|
||||
{
|
||||
parts[idx] = particle_from_config(it.node, parent_font);
|
||||
}
|
||||
|
||||
return particle_list_new(parts, count, 0, 0, 0, 0, NULL);
|
||||
}
|
||||
|
||||
static struct particle *
|
||||
particle_from_config(const struct yml_node *node, const struct font *parent_font)
|
||||
{
|
||||
if (yml_is_list(node))
|
||||
return particle_simple_list_from_config(node, parent_font);
|
||||
|
||||
assert(yml_is_dict(node));
|
||||
assert(yml_dict_length(node) == 1);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue