From 718bf8fd9d17bddf500bd6b878b0ebcf0d950584 Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Mon, 5 Sep 2016 16:58:40 +0200 Subject: UI: Ctrl+Tab and Ctrl+Shift+Tab to cycle through space context "tabs" In User Preferences, Properties Editor and toolshelf, Ctrl+Tab and Ctrl+Shift+Tab now activates the next or previous space context (or category in case of toolshelf tabs), respectively. For Properties Editor such functionality was completely missing, only toolshelf allowed cycling using ctrl+mousewheel (or only mousewheel while hovering tab region). Ctrl+Tab and Ctrl+Shift+Tab are common web browser shortcuts, so they're a reasonable choice to go with. Reaching the first/last item doesn't cause the cycling to stop, we continue at the other end of the list then. (I didn't add this to Ctrl+Mousewheel toggling in toolshelf since I wanted to keep its behavior unchanged.) We could get rid of (Ctrl+)Mousewheel cycling in toolshelf, but this may break user habits. The cycling happens using a new operator, UI_OT_space_context_cycle, for toolshelf tabs it's hardcoded in panel handling code though. Generalized rna_property_enum_step a bit and moved it to rna_access.c to allow external reuse. Reviewed By: venomgfx Differential Revision: https://developer.blender.org/D2189 --- .../blender/editors/interface/interface_regions.c | 35 ++-------------------- 1 file changed, 2 insertions(+), 33 deletions(-) (limited to 'source/blender/editors/interface/interface_regions.c') diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index c507401b9a0..4ea5e2092b6 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -73,38 +73,6 @@ #define MENU_PADDING (int)(0.2f * UI_UNIT_Y) #define MENU_BORDER (int)(0.3f * U.widget_unit) -static int rna_property_enum_step(const bContext *C, PointerRNA *ptr, PropertyRNA *prop, int direction) -{ - EnumPropertyItem *item_array; - int totitem; - bool free; - int value; - int i, i_init; - int step = (direction < 0) ? -1 : 1; - int step_tot = 0; - - RNA_property_enum_items((bContext *)C, ptr, prop, &item_array, &totitem, &free); - value = RNA_property_enum_get(ptr, prop); - i = RNA_enum_from_value(item_array, value); - i_init = i; - - do { - i = mod_i(i + step, totitem); - if (item_array[i].identifier[0]) { - step_tot += step; - } - } while ((i != i_init) && (step_tot != direction)); - - if (i != i_init) { - value = item_array[i].value; - } - - if (free) { - MEM_freeN(item_array); - } - - return value; -} bool ui_but_menu_step_poll(const uiBut *but) { @@ -122,7 +90,8 @@ int ui_but_menu_step(uiBut *but, int direction) return but->menu_step_func(but->block->evil_C, direction, but->poin); } else { - return rna_property_enum_step(but->block->evil_C, &but->rnapoin, but->rnaprop, direction); + const int curval = RNA_property_enum_get(&but->rnapoin, but->rnaprop); + return RNA_property_enum_step(but->block->evil_C, &but->rnapoin, but->rnaprop, curval, direction); } } -- cgit v1.2.3