summaryrefslogtreecommitdiff
path: root/src/stage.c
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2019-06-12 14:43:52 -0700
committerVito Caputo <vcaputo@pengaru.com>2019-06-12 14:43:52 -0700
commit83a324a7d4a2c3e0a75148c918171b14f77dd371 (patch)
tree58a0051bf815e647955a82fdc6f0190e9acb1453 /src/stage.c
parent196a44106ef10b343d06be2c130cba4037e85aec (diff)
libstage: introduce stage_conf_t for stage_new()
stage_new() call sites were getting quite annoying, using compound literals with designated initializers on a struct makes the call sites a lot more readable, self-documenting, and often more compact thanks to the automatic zeroing of omitted members. I don't particularly like the name, and may switch it later, something shorter would be nice.
Diffstat (limited to 'src/stage.c')
-rw-r--r--src/stage.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/stage.c b/src/stage.c
index a1d081d..7a088b3 100644
--- a/src/stage.c
+++ b/src/stage.c
@@ -89,22 +89,27 @@ static void _stage_free(stage_t *stage)
/* returns a new stage, attached at the specified layer under parent if supplied */
/* layer has no effect when parent == NULL */
-stage_t * stage_new(stage_t *parent, int layer, const char *name, void *object, stage_prepare_func_t *prepare_func, stage_render_func_t *render_func, stage_free_func_t *free_func, stage_lookup_func_t *lookup_func)
+stage_t * stage_new(const stage_conf_t *conf)
{
stage_t *stage;
- assert(parent || !layer);
- assert(layer < STAGE_LAYERS_MAX);
+ assert(conf);
+ assert(conf->parent || !conf->layer);
+ assert(conf->layer < STAGE_LAYERS_MAX);
- stage = _stage_new(name, object, prepare_func, render_func, free_func, lookup_func);
+ stage = _stage_new(conf->name, conf->object, conf->prepare_func, conf->render_func, conf->free_func, conf->lookup_func);
if (!stage)
return NULL;
- if (parent) {
- stage->parent = parent;
- (void) dll_add_pre(&parent->layers[layer], &stage->layer);
+ if (conf->parent) {
+ stage->parent = conf->parent;
+ (void) dll_add_pre(&stage->parent->layers[conf->layer], &stage->layer);
}
+ stage->alpha = conf->alpha;
+ stage->active = conf->active;
+ stage->locked = conf->locked;
+
return stage;
}
© All Rights Reserved