diff options
| author | Federico Angelilli <code@fedang.net> | 2024-05-14 12:04:22 +0200 |
|---|---|---|
| committer | Federico Angelilli <code@fedang.net> | 2024-05-14 12:04:22 +0200 |
| commit | 92feb3c130966202c7caa6d9bf3a3800c97ca7a1 (patch) | |
| tree | bcbbb8afca932d20c11a81fc7d7d53096dbf931e /src/button.c | |
| parent | 247a74810374894a74ca63af4eb86d9614cf6c74 (diff) | |
Start working on mirroringlegacy
Diffstat (limited to 'src/button.c')
| -rw-r--r-- | src/button.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/button.c b/src/button.c index aac4ec0..b11f5b1 100644 --- a/src/button.c +++ b/src/button.c @@ -86,6 +86,29 @@ void button_set_width(Button *btn, int max, int min) btn->min_width = min; } +Button *button_copy(Button *btn) +{ + if (btn->simple) { + ButtonSimple *copy = g_malloc0(sizeof(ButtonSimple)); + memcpy(copy, CAST(btn, ButtonSimple), sizeof(ButtonSimple)); + copy->text = g_strdup(CAST(btn, ButtonSimple)->text); + copy->btn.anim = NULL; + // NOTE: What to do with data? + return CAST(copy, Button); + } else { + ButtonGroup *copy = g_malloc0(sizeof(ButtonGroup)); + memcpy(copy, CAST(btn, ButtonGroup), sizeof(ButtonGroup)); + copy->btn.anim = NULL; + copy->children = NULL; + + for (GList *it = CAST(btn, ButtonGroup)->children; it != NULL; it = it->next) { + copy->children = g_list_prepend(copy->children, button_copy(it->data)); + } + copy->children = g_list_reverse(copy->children); + return CAST(copy, Button); + } +} + void button_destroy(Button *btn) { animation_destroy(btn->anim); |
