summaryrefslogtreecommitdiff
path: root/src/ui/widget.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2020-08-14 15:07:49 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2020-08-14 15:07:49 +0300
commitf8f382ed14151d3c293a9ee754f0a66f513fb7d3 (patch)
tree68b4ef771460378267b02c0499693751f4fb26ee /src/ui/widget.c
parent459f73f2623f66e2887aae6feff2ec0fab185b2c (diff)
Bookmarks: Store in a hash with unique IDs
Diffstat (limited to 'src/ui/widget.c')
-rw-r--r--src/ui/widget.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/ui/widget.c b/src/ui/widget.c
index 07f1f17d..cfd8304b 100644
--- a/src/ui/widget.c
+++ b/src/ui/widget.c
@@ -75,12 +75,16 @@ static void aboutToBeDestroyed_Widget_(iWidget *d) {
75} 75}
76 76
77void destroy_Widget(iWidget *d) { 77void destroy_Widget(iWidget *d) {
78 aboutToBeDestroyed_Widget_(d); 78 if (d) {
79 if (!rootData_.pendingDestruction) { 79 if (isVisible_Widget(d)) {
80 rootData_.pendingDestruction = new_PtrSet(); 80 postRefresh_App();
81 }
82 aboutToBeDestroyed_Widget_(d);
83 if (!rootData_.pendingDestruction) {
84 rootData_.pendingDestruction = new_PtrSet();
85 }
86 insert_PtrSet(rootData_.pendingDestruction, d);
81 } 87 }
82 insert_PtrSet(rootData_.pendingDestruction, d);
83 postRefresh_App();
84} 88}
85 89
86void setId_Widget(iWidget *d, const char *id) { 90void setId_Widget(iWidget *d, const char *id) {
@@ -408,6 +412,10 @@ iBool dispatchEvent_Widget(iWidget *d, const SDL_Event *ev) {
408 } 412 }
409 } 413 }
410 if (class_Widget(d)->processEvent(d, ev)) { 414 if (class_Widget(d)->processEvent(d, ev)) {
415 if (ev->type == SDL_MOUSEBUTTONDOWN) {
416 printf("mb.down eaten by %p '%s'\n", d, cstr_String(id_Widget(d)));
417 fflush(stdout);
418 }
411 return iTrue; 419 return iTrue;
412 } 420 }
413 } 421 }
@@ -560,6 +568,7 @@ size_t childCount_Widget(const iWidget *d) {
560} 568}
561 569
562iBool isVisible_Widget(const iWidget *d) { 570iBool isVisible_Widget(const iWidget *d) {
571 if (!d) return iFalse;
563 for (const iWidget *w = d; w; w = w->parent) { 572 for (const iWidget *w = d; w; w = w->parent) {
564 if (w->flags & hidden_WidgetFlag) { 573 if (w->flags & hidden_WidgetFlag) {
565 return iFalse; 574 return iFalse;