[util, formatting] shorten list loop names to for_list_xxx
This commit is contained in:
parent
3682605f97
commit
7b2ef080e8
|
@ -27,7 +27,7 @@ void debug_print_indent(int indent)
|
||||||
|
|
||||||
void debug_print_rule(ui_style_rule* rule)
|
void debug_print_rule(ui_style_rule* rule)
|
||||||
{
|
{
|
||||||
for_each_in_list(&rule->pattern.l, selector, ui_selector, listElt)
|
for_list(&rule->pattern.l, selector, ui_selector, listElt)
|
||||||
{
|
{
|
||||||
switch(selector->kind)
|
switch(selector->kind)
|
||||||
{
|
{
|
||||||
|
@ -115,7 +115,7 @@ void debug_print_styles(ui_box* box, int indent)
|
||||||
{
|
{
|
||||||
debug_print_indent(indent);
|
debug_print_indent(indent);
|
||||||
printf("before rules:\n");
|
printf("before rules:\n");
|
||||||
for_each_in_list(&box->beforeRules, rule, ui_style_rule, boxElt)
|
for_list(&box->beforeRules, rule, ui_style_rule, boxElt)
|
||||||
{
|
{
|
||||||
debug_print_indent(indent+1);
|
debug_print_indent(indent+1);
|
||||||
debug_print_rule(rule);
|
debug_print_rule(rule);
|
||||||
|
@ -126,7 +126,7 @@ void debug_print_styles(ui_box* box, int indent)
|
||||||
{
|
{
|
||||||
debug_print_indent(indent);
|
debug_print_indent(indent);
|
||||||
printf("after rules:\n");
|
printf("after rules:\n");
|
||||||
for_each_in_list(&box->afterRules, rule, ui_style_rule, boxElt)
|
for_list(&box->afterRules, rule, ui_style_rule, boxElt)
|
||||||
{
|
{
|
||||||
debug_print_indent(indent+1);
|
debug_print_indent(indent+1);
|
||||||
debug_print_rule(rule);
|
debug_print_rule(rule);
|
||||||
|
@ -138,7 +138,7 @@ void debug_print_styles(ui_box* box, int indent)
|
||||||
debug_print_indent(indent);
|
debug_print_indent(indent);
|
||||||
printf("children:\n");
|
printf("children:\n");
|
||||||
indent++;
|
indent++;
|
||||||
for_each_in_list(&box->children, child, ui_box, listElt)
|
for_list(&box->children, child, ui_box, listElt)
|
||||||
{
|
{
|
||||||
debug_print_styles(child, indent);
|
debug_print_styles(child, indent);
|
||||||
}
|
}
|
||||||
|
|
38
src/ui.c
38
src/ui.c
|
@ -257,7 +257,7 @@ ui_key ui_key_make_path(str8_list path)
|
||||||
{
|
{
|
||||||
seed = parent->key.hash;
|
seed = parent->key.hash;
|
||||||
}
|
}
|
||||||
for_each_in_list(&path.list, elt, str8_elt, listElt)
|
for_list(&path.list, elt, str8_elt, listElt)
|
||||||
{
|
{
|
||||||
seed = mp_hash_aes_string_seed(elt->string, seed);
|
seed = mp_hash_aes_string_seed(elt->string, seed);
|
||||||
}
|
}
|
||||||
|
@ -281,7 +281,7 @@ ui_box* ui_box_lookup_key(ui_key key)
|
||||||
ui_context* ui = ui_get_context();
|
ui_context* ui = ui_get_context();
|
||||||
u64 index = key.hash & (UI_BOX_MAP_BUCKET_COUNT-1);
|
u64 index = key.hash & (UI_BOX_MAP_BUCKET_COUNT-1);
|
||||||
|
|
||||||
for_each_in_list(&ui->boxMap[index], box, ui_box, bucketElt)
|
for_list(&ui->boxMap[index], box, ui_box, bucketElt)
|
||||||
{
|
{
|
||||||
if(ui_key_equal(key, box->key))
|
if(ui_key_equal(key, box->key))
|
||||||
{
|
{
|
||||||
|
@ -459,14 +459,14 @@ ui_box* ui_box_make_str8(str8 string, ui_flags flags)
|
||||||
ui->nextBoxTags = (list_info){0};
|
ui->nextBoxTags = (list_info){0};
|
||||||
|
|
||||||
box->beforeRules = ui->nextBoxBeforeRules;
|
box->beforeRules = ui->nextBoxBeforeRules;
|
||||||
for_each_in_list(&box->beforeRules, rule, ui_style_rule, boxElt)
|
for_list(&box->beforeRules, rule, ui_style_rule, boxElt)
|
||||||
{
|
{
|
||||||
rule->owner = box;
|
rule->owner = box;
|
||||||
}
|
}
|
||||||
ui->nextBoxBeforeRules = (list_info){0};
|
ui->nextBoxBeforeRules = (list_info){0};
|
||||||
|
|
||||||
box->afterRules = ui->nextBoxAfterRules;
|
box->afterRules = ui->nextBoxAfterRules;
|
||||||
for_each_in_list(&box->afterRules, rule, ui_style_rule, boxElt)
|
for_list(&box->afterRules, rule, ui_style_rule, boxElt)
|
||||||
{
|
{
|
||||||
rule->owner = box;
|
rule->owner = box;
|
||||||
}
|
}
|
||||||
|
@ -830,7 +830,7 @@ bool ui_style_selector_match(ui_box* box, ui_style_rule* rule, ui_selector* sele
|
||||||
|
|
||||||
case UI_SEL_TAG:
|
case UI_SEL_TAG:
|
||||||
{
|
{
|
||||||
for_each_in_list(&box->tags, elt, ui_tag_elt, listElt)
|
for_list(&box->tags, elt, ui_tag_elt, listElt)
|
||||||
{
|
{
|
||||||
if(elt->tag.hash == selector->tag.hash)
|
if(elt->tag.hash == selector->tag.hash)
|
||||||
{
|
{
|
||||||
|
@ -909,11 +909,11 @@ void ui_styling_prepass(ui_context* ui, ui_box* box, list_info* before, list_inf
|
||||||
|
|
||||||
//NOTE: match rules
|
//NOTE: match rules
|
||||||
list_info tmpBefore = {0};
|
list_info tmpBefore = {0};
|
||||||
for_each_in_list(before, rule, ui_style_rule, buildElt)
|
for_list(before, rule, ui_style_rule, buildElt)
|
||||||
{
|
{
|
||||||
ui_style_rule_match(ui, box, rule, before, &tmpBefore);
|
ui_style_rule_match(ui, box, rule, before, &tmpBefore);
|
||||||
}
|
}
|
||||||
for_each_in_list(&box->beforeRules, rule, ui_style_rule, boxElt)
|
for_list(&box->beforeRules, rule, ui_style_rule, boxElt)
|
||||||
{
|
{
|
||||||
list_append(before, &rule->buildElt);
|
list_append(before, &rule->buildElt);
|
||||||
list_append(&tmpBefore, &rule->tmpElt);
|
list_append(&tmpBefore, &rule->tmpElt);
|
||||||
|
@ -921,11 +921,11 @@ void ui_styling_prepass(ui_context* ui, ui_box* box, list_info* before, list_inf
|
||||||
}
|
}
|
||||||
|
|
||||||
list_info tmpAfter = {0};
|
list_info tmpAfter = {0};
|
||||||
for_each_in_list(after, rule, ui_style_rule, buildElt)
|
for_list(after, rule, ui_style_rule, buildElt)
|
||||||
{
|
{
|
||||||
ui_style_rule_match(ui, box, rule, after, &tmpAfter);
|
ui_style_rule_match(ui, box, rule, after, &tmpAfter);
|
||||||
}
|
}
|
||||||
for_each_in_list(&box->afterRules, rule, ui_style_rule, boxElt)
|
for_list(&box->afterRules, rule, ui_style_rule, boxElt)
|
||||||
{
|
{
|
||||||
list_append(after, &rule->buildElt);
|
list_append(after, &rule->buildElt);
|
||||||
list_append(&tmpAfter, &rule->tmpElt);
|
list_append(&tmpAfter, &rule->tmpElt);
|
||||||
|
@ -968,17 +968,17 @@ void ui_styling_prepass(ui_context* ui, ui_box* box, list_info* before, list_inf
|
||||||
}
|
}
|
||||||
|
|
||||||
//NOTE: descend in children
|
//NOTE: descend in children
|
||||||
for_each_in_list(&box->children, child, ui_box, listElt)
|
for_list(&box->children, child, ui_box, listElt)
|
||||||
{
|
{
|
||||||
ui_styling_prepass(ui, child, before, after);
|
ui_styling_prepass(ui, child, before, after);
|
||||||
}
|
}
|
||||||
|
|
||||||
//NOTE: remove temporary rules
|
//NOTE: remove temporary rules
|
||||||
for_each_in_list(&tmpBefore, rule, ui_style_rule, tmpElt)
|
for_list(&tmpBefore, rule, ui_style_rule, tmpElt)
|
||||||
{
|
{
|
||||||
list_remove(before, &rule->buildElt);
|
list_remove(before, &rule->buildElt);
|
||||||
}
|
}
|
||||||
for_each_in_list(&tmpAfter, rule, ui_style_rule, tmpElt)
|
for_list(&tmpAfter, rule, ui_style_rule, tmpElt)
|
||||||
{
|
{
|
||||||
list_remove(after, &rule->buildElt);
|
list_remove(after, &rule->buildElt);
|
||||||
}
|
}
|
||||||
|
@ -1004,7 +1004,7 @@ void ui_layout_upward_dependent_size(ui_context* ui, ui_box* box, int axis)
|
||||||
//TODO else?
|
//TODO else?
|
||||||
}
|
}
|
||||||
|
|
||||||
for_each_in_list(&box->children, child, ui_box, listElt)
|
for_list(&box->children, child, ui_box, listElt)
|
||||||
{
|
{
|
||||||
ui_layout_upward_dependent_size(ui, child, axis);
|
ui_layout_upward_dependent_size(ui, child, axis);
|
||||||
}
|
}
|
||||||
|
@ -1017,7 +1017,7 @@ void ui_layout_downward_dependent_size(ui_context* ui, ui_box* box, int axis)
|
||||||
if(box->style.layout.axis == axis)
|
if(box->style.layout.axis == axis)
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for_each_in_list(&box->children, child, ui_box, listElt)
|
for_list(&box->children, child, ui_box, listElt)
|
||||||
{
|
{
|
||||||
if(!ui_box_hidden(child))
|
if(!ui_box_hidden(child))
|
||||||
{
|
{
|
||||||
|
@ -1034,7 +1034,7 @@ void ui_layout_downward_dependent_size(ui_context* ui, ui_box* box, int axis)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for_each_in_list(&box->children, child, ui_box, listElt)
|
for_list(&box->children, child, ui_box, listElt)
|
||||||
{
|
{
|
||||||
if(!ui_box_hidden(child))
|
if(!ui_box_hidden(child))
|
||||||
{
|
{
|
||||||
|
@ -1105,7 +1105,7 @@ void ui_layout_compute_rect(ui_context* ui, ui_box* box, vec2 pos)
|
||||||
currentPos.c[layoutAxis] += 0.5*(contentsSize.c[layoutAxis] - box->childrenSum[layoutAxis]);
|
currentPos.c[layoutAxis] += 0.5*(contentsSize.c[layoutAxis] - box->childrenSum[layoutAxis]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for_each_in_list(&box->children, child, ui_box, listElt)
|
for_list(&box->children, child, ui_box, listElt)
|
||||||
{
|
{
|
||||||
if(align[secondAxis] == UI_ALIGN_CENTER)
|
if(align[secondAxis] == UI_ALIGN_CENTER)
|
||||||
{
|
{
|
||||||
|
@ -1154,7 +1154,7 @@ void ui_layout_find_next_hovered_recursive(ui_context* ui, ui_box* box, vec2 p)
|
||||||
}
|
}
|
||||||
if(hit || !(box->flags & UI_FLAG_CLIP))
|
if(hit || !(box->flags & UI_FLAG_CLIP))
|
||||||
{
|
{
|
||||||
for_each_in_list(&box->children, child, ui_box, listElt)
|
for_list(&box->children, child, ui_box, listElt)
|
||||||
{
|
{
|
||||||
ui_layout_find_next_hovered_recursive(ui, child, p);
|
ui_layout_find_next_hovered_recursive(ui, child, p);
|
||||||
}
|
}
|
||||||
|
@ -1239,7 +1239,7 @@ void ui_draw_box(ui_box* box)
|
||||||
box->renderProc(box, box->renderData);
|
box->renderProc(box, box->renderData);
|
||||||
}
|
}
|
||||||
|
|
||||||
for_each_in_list(&box->children, child, ui_box, listElt)
|
for_list(&box->children, child, ui_box, listElt)
|
||||||
{
|
{
|
||||||
ui_draw_box(child);
|
ui_draw_box(child);
|
||||||
}
|
}
|
||||||
|
@ -1358,7 +1358,7 @@ void ui_end_frame(void)
|
||||||
//NOTE: prune unused boxes
|
//NOTE: prune unused boxes
|
||||||
for(int i=0; i<UI_BOX_MAP_BUCKET_COUNT; i++)
|
for(int i=0; i<UI_BOX_MAP_BUCKET_COUNT; i++)
|
||||||
{
|
{
|
||||||
for_each_in_list_safe(&ui->boxMap[i], box, ui_box, bucketElt)
|
for_list_safe(&ui->boxMap[i], box, ui_box, bucketElt)
|
||||||
{
|
{
|
||||||
if(box->frameCounter < ui->frameCounter)
|
if(box->frameCounter < ui->frameCounter)
|
||||||
{
|
{
|
||||||
|
|
|
@ -57,17 +57,17 @@ extern "C" {
|
||||||
#define list_last_entry(list, type, member) \
|
#define list_last_entry(list, type, member) \
|
||||||
(list_checked_entry(list_last(list), type, member))
|
(list_checked_entry(list_last(list), type, member))
|
||||||
|
|
||||||
#define for_each_in_list(list, elt, type, member) \
|
#define for_list(list, elt, type, member) \
|
||||||
for(type* elt = list_checked_entry(list_begin(list), type, member); \
|
for(type* elt = list_checked_entry(list_begin(list), type, member); \
|
||||||
elt != 0; \
|
elt != 0; \
|
||||||
elt = list_checked_entry(elt->member.next, type, member)) \
|
elt = list_checked_entry(elt->member.next, type, member)) \
|
||||||
|
|
||||||
#define for_each_in_list_reverse(list, elt, type, member) \
|
#define for_list_reverse(list, elt, type, member) \
|
||||||
for(type* elt = list_checked_entry(list_last(list), type, member); \
|
for(type* elt = list_checked_entry(list_last(list), type, member); \
|
||||||
elt != 0; \
|
elt != 0; \
|
||||||
elt = list_checked_entry(elt->member.prev, type, member)) \
|
elt = list_checked_entry(elt->member.prev, type, member)) \
|
||||||
|
|
||||||
#define for_each_in_list_safe(list, elt, type, member) \
|
#define for_list_safe(list, elt, type, member) \
|
||||||
for(type* elt = list_checked_entry(list_begin(list), type, member), \
|
for(type* elt = list_checked_entry(list_begin(list), type, member), \
|
||||||
*__tmp = elt ? list_checked_entry(elt->member.next, type, member) : 0 ; \
|
*__tmp = elt ? list_checked_entry(elt->member.next, type, member) : 0 ; \
|
||||||
elt != 0; \
|
elt != 0; \
|
||||||
|
@ -255,19 +255,19 @@ static inline bool list_empty(list_info* list)
|
||||||
#define clist_last_entry(head, type, member) \
|
#define clist_last_entry(head, type, member) \
|
||||||
(clist_checked_entry(head, clist_last(head), type, member))
|
(clist_checked_entry(head, clist_last(head), type, member))
|
||||||
|
|
||||||
#define for_each_in_clist(list, elt, type, member) \
|
#define for_clist(list, elt, type, member) \
|
||||||
for(type* elt = clist_entry(clist_begin(list), type, member); \
|
for(type* elt = clist_entry(clist_begin(list), type, member); \
|
||||||
&elt->member != clist_end(list); \
|
&elt->member != clist_end(list); \
|
||||||
elt = clist_entry(elt->member.next, type, member)) \
|
elt = clist_entry(elt->member.next, type, member)) \
|
||||||
|
|
||||||
|
|
||||||
#define for_each_in_clist_reverse(list, elt, type, member) \
|
#define for_clist_reverse(list, elt, type, member) \
|
||||||
for(type* elt = clist_entry(clist_last(list), type, member); \
|
for(type* elt = clist_entry(clist_last(list), type, member); \
|
||||||
&elt->member != clist_end(list); \
|
&elt->member != clist_end(list); \
|
||||||
elt = clist_entry(elt->member.prev, type, member)) \
|
elt = clist_entry(elt->member.prev, type, member)) \
|
||||||
|
|
||||||
|
|
||||||
#define for_each_in_clist_safe(list, elt, type, member) \
|
#define for_clist_safe(list, elt, type, member) \
|
||||||
for(type* elt = clist_entry(clist_begin(list), type, member), \
|
for(type* elt = clist_entry(clist_begin(list), type, member), \
|
||||||
*__tmp = clist_entry(elt->member.next, type, member); \
|
*__tmp = clist_entry(elt->member.next, type, member); \
|
||||||
&elt->member != clist_end(list); \
|
&elt->member != clist_end(list); \
|
||||||
|
|
|
@ -183,7 +183,7 @@ str8_list str8_split(mem_arena* arena, str8 str, str8_list separators)
|
||||||
{
|
{
|
||||||
//NOTE(martin): search all separators and try to match them to the current ptr
|
//NOTE(martin): search all separators and try to match them to the current ptr
|
||||||
str8* foundSep = 0;
|
str8* foundSep = 0;
|
||||||
for_each_in_list(&separators.list, elt, str8_elt, listElt)
|
for_list(&separators.list, elt, str8_elt, listElt)
|
||||||
{
|
{
|
||||||
str8* separator = &elt->string;
|
str8* separator = &elt->string;
|
||||||
bool equal = true;
|
bool equal = true;
|
||||||
|
|
Loading…
Reference in New Issue