From 2dafd1bfb8294acd996607f2b31961f66b5a3587 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 8 Feb 2014 09:03:25 +1100 Subject: UI: butstore API to generalize button storage for modal handlers --- source/blender/editors/interface/interface.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'source/blender/editors/interface/interface.c') diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index db2b804363c..40e3b15e191 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -525,7 +525,7 @@ static bool ui_but_equals_old(const uiBut *but, const uiBut *oldbut) return true; } -static uiBut *ui_but_find_old(uiBlock *block_old, const uiBut *but_new) +uiBut *ui_but_find_old(uiBlock *block_old, const uiBut *but_new) { uiBut *but_old; for (but_old = block_old->buttons.first; but_old; but_old = but_old->next) { @@ -535,6 +535,16 @@ static uiBut *ui_but_find_old(uiBlock *block_old, const uiBut *but_new) } return but_old; } +uiBut *ui_but_find_new(uiBlock *block_new, const uiBut *but_old) +{ + uiBut *but_new; + for (but_new = block_new->buttons.first; but_new; but_new = but_new->next) { + if (ui_but_equals_old(but_new, but_old)) { + break; + } + } + return but_new; +} /* oldbut is being inserted in new block, so we use the lines from new button, and replace button pointers */ static void ui_but_update_linklines(uiBlock *block, uiBut *oldbut, uiBut *newbut) @@ -1020,6 +1030,11 @@ void uiEndBlock(const bContext *C, uiBlock *block) uiBut *but; Scene *scene = CTX_data_scene(C); + + if (has_old && BLI_listbase_is_empty(&block->oldblock->butstore) == false) { + UI_butstore_update(block); + } + /* inherit flags from 'old' buttons that was drawn here previous, based * on matching buttons, we need this to make button event handling non * blocking, while still allowing buttons to be remade each redraw as it @@ -2228,6 +2243,8 @@ static void ui_free_but(const bContext *C, uiBut *but) IMB_freeImBuf((struct ImBuf *)but->poin); } + BLI_assert(UI_butstore_is_registered(but->block, but) == false); + MEM_freeN(but); } @@ -2236,6 +2253,8 @@ void uiFreeBlock(const bContext *C, uiBlock *block) { uiBut *but; + UI_butstore_clear(block); + while ((but = BLI_pophead(&block->buttons))) { ui_free_but(C, but); } -- cgit v1.2.3