diff options
author | Julian Eisel <eiseljulian@gmail.com> | 2016-06-08 16:51:01 +0300 |
---|---|---|
committer | Julian Eisel <eiseljulian@gmail.com> | 2016-06-08 17:05:23 +0300 |
commit | fc96110bb56f15b947de8e29a12731fe35aa8dff (patch) | |
tree | 87d6bf75570179c37ba2fed63cb2bc58c10f177e /source/blender/editors/interface | |
parent | 37fc4b575fcf8bff2401aefa84df5537fe0d744f (diff) |
Make uiLists placed in popups usable
It's still not completely working - there are still some glitches - but far better than before.
To make buttons of the uiList work, you have to add a 'check' callback to the operator that invokes the menu. Only if it returns True, the uiList gets refreshed. To avoid this we have to make the region refresh tagging in the entire button handling a bit smarter.
Changes I had to do:
* Call uiList handling from menu/popup handling if needed.
* Make uiList handling use special popup refresh tag if placed in menu.
* Allow popups invoked from py operator to tag for refresh by using operator 'check' callback.
* Tag popup for refresh when resizing uiList.
Mostly fixes T48612.
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 34 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 5 |
2 files changed, 31 insertions, 8 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 5b8b8ae5bdb..ff4e11ac58b 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -8436,6 +8436,7 @@ static int ui_handle_list_event(bContext *C, const wmEvent *event, ARegion *ar, uiListDyn *dyn_data; int retval = WM_UI_HANDLER_CONTINUE; int type = event->type, val = event->val; + bool redraw = false; int mx, my; ui_list = listbox->custom_data; @@ -8525,7 +8526,7 @@ static int ui_handle_list_event(bContext *C, const wmEvent *event, ARegion *ar, ui_apply_but_undo(listbox); ui_list->flag |= UILST_SCROLL_TO_ACTIVE_ITEM; - ED_region_tag_redraw(ar); + redraw = true; } retval = WM_UI_HANDLER_BREAK; } @@ -8537,8 +8538,8 @@ static int ui_handle_list_event(bContext *C, const wmEvent *event, ARegion *ar, ui_list->list_grip += (type == WHEELUPMOUSE) ? -1 : 1; ui_list->flag |= UILST_SCROLL_TO_ACTIVE_ITEM; - ED_region_tag_redraw(ar); + redraw = true; retval = WM_UI_HANDLER_BREAK; } else if (ELEM(type, WHEELUPMOUSE, WHEELDOWNMOUSE)) { @@ -8546,13 +8547,22 @@ static int ui_handle_list_event(bContext *C, const wmEvent *event, ARegion *ar, /* list template will clamp */ ui_list->list_scroll += (type == WHEELUPMOUSE) ? -1 : 1; - ED_region_tag_redraw(ar); - + redraw = true; retval = WM_UI_HANDLER_BREAK; } } } + if (redraw) { + if (listbox->block->flag & UI_BLOCK_POPUP) { + /* popups need special refreshing */ + ED_region_tag_refresh_ui(ar); + } + else { + ED_region_tag_redraw(ar); + } + } + return retval; } @@ -9794,11 +9804,21 @@ static int ui_handle_menus_recursive( } else { uiBlock *block = menu->region->uiblocks.first; + uiBut *listbox = ui_list_find_mouse_over(menu->region, event); - if (block->flag & UI_BLOCK_RADIAL) + if (block->flag & UI_BLOCK_RADIAL) { retval = ui_pie_handler(C, event, menu); - else if (event->type == LEFTMOUSE || event->val != KM_DBL_CLICK) - retval = ui_handle_menu_event(C, event, menu, level, is_parent_inside, is_parent_menu, is_floating); + } + else if (event->type == LEFTMOUSE || event->val != KM_DBL_CLICK) { + if (listbox) { + retval = ui_handle_list_event(C, event, menu->region, listbox); + } + if (retval == WM_UI_HANDLER_CONTINUE) { + retval = ui_handle_menu_event( + C, event, menu, level, + is_parent_inside, is_parent_menu, is_floating); + } + } } } diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index a3b04e1c9bc..9f0c4b16523 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -2818,7 +2818,7 @@ static void uilist_prepare( layoutdata->end_idx = min_ii(layoutdata->start_idx + rows * columns, len); } -static void uilist_resize_update_cb(bContext *UNUSED(C), void *arg1, void *UNUSED(arg2)) +static void uilist_resize_update_cb(bContext *C, void *arg1, void *UNUSED(arg2)) { uiList *ui_list = arg1; uiListDyn *dyn_data = ui_list->dyn_data; @@ -2831,6 +2831,9 @@ static void uilist_resize_update_cb(bContext *UNUSED(C), void *arg1, void *UNUSE dyn_data->resize_prev += diff * UI_UNIT_Y; ui_list->flag |= UILST_SCROLL_TO_ACTIVE_ITEM; } + + /* In case uilist is in popup, we need special refreshing */ + ED_region_tag_refresh_ui(CTX_wm_menu(C)); } static void *uilist_item_use_dynamic_tooltip(PointerRNA *itemptr, const char *propname) |