[Bf-blender-cvs] [73392fc29b2] soc-2019-outliner: Outliner: Add walk select operator
Nathan Craddock
noreply at git.blender.org
Sun Jun 2 06:43:32 CEST 2019
Commit: 73392fc29b28193f8e663e89dcf8a6c68716e10b
Author: Nathan Craddock
Date: Sat Jun 1 22:41:35 2019 -0600
Branches: soc-2019-outliner
https://developer.blender.org/rB73392fc29b28193f8e663e89dcf8a6c68716e10b
Outliner: Add walk select operator
Adds a walk select operator to the outliner. Currently only up
and down walk are supported, opening and closing and walking left
and right will be added later.
===================================================================
M release/scripts/presets/keyconfig/keymap_data/blender_default.py
M source/blender/editors/space_outliner/outliner_intern.h
M source/blender/editors/space_outliner/outliner_ops.c
M source/blender/editors/space_outliner/outliner_select.c
M source/blender/editors/space_outliner/space_outliner.c
===================================================================
diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index 14b0b06de56..d3cc88d2036 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -696,6 +696,10 @@ def km_outliner(params):
{"properties": [("extend", True), ("range", False), ("recursive", True)]}),
("outliner.select_box", {"type": 'B', "value": 'PRESS'}, {"properties": [("tweak", False)]}),
("outliner.select_box", {"type": 'EVT_TWEAK_L', "value": 'ANY'}, {"properties": [("tweak", True)]}),
+ ("outliner.select_walk", {"type": 'UP_ARROW', "value": 'PRESS'}, {"properties": [("direction", 'UP')]}),
+ ("outliner.select_walk", {"type": 'DOWN_ARROW', "value": 'PRESS'}, {"properties": [("direction", 'DOWN')]}),
+ ("outliner.select_walk", {"type": 'LEFT_ARROW', "value": 'PRESS'}, {"properties": [("direction", 'LEFT')]}),
+ ("outliner.select_walk", {"type": 'RIGHT_ARROW', "value": 'PRESS'}, {"properties": [("direction", 'RIGHT')]}),
("outliner.item_openclose", {"type": 'RET', "value": 'PRESS'},
{"properties": [("all", False)]}),
("outliner.item_openclose", {"type": 'RET', "value": 'PRESS', "shift": True},
diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h
index 33dc2729c7e..bf51b05c240 100644
--- a/source/blender/editors/space_outliner/outliner_intern.h
+++ b/source/blender/editors/space_outliner/outliner_intern.h
@@ -50,6 +50,14 @@ typedef enum TreeElementInsertType {
TE_INSERT_INTO,
} TreeElementInsertType;
+/* Use generic walk select after D4771 is committed */
+typedef enum WalkSelectDirection {
+ OUTLINER_SELECT_WALK_UP,
+ OUTLINER_SELECT_WALK_DOWN,
+ OUTLINER_SELECT_WALK_LEFT,
+ OUTLINER_SELECT_WALK_RIGHT,
+} WalkSelectDirection;
+
typedef enum TreeTraversalAction {
/* Continue traversal regularly, don't skip children. */
TRAVERSE_CONTINUE = 0,
@@ -364,6 +372,7 @@ void OUTLINER_OT_show_active(struct wmOperatorType *ot);
void OUTLINER_OT_show_hierarchy(struct wmOperatorType *ot);
void OUTLINER_OT_select_box(struct wmOperatorType *ot);
+void OUTLINER_OT_select_walk(struct wmOperatorType *ot);
void OUTLINER_OT_select_all(struct wmOperatorType *ot);
void OUTLINER_OT_expanded_toggle(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_outliner/outliner_ops.c b/source/blender/editors/space_outliner/outliner_ops.c
index f155a2d5f89..4b57d4ad771 100644
--- a/source/blender/editors/space_outliner/outliner_ops.c
+++ b/source/blender/editors/space_outliner/outliner_ops.c
@@ -50,6 +50,7 @@ void outliner_operatortypes(void)
WM_operatortype_append(OUTLINER_OT_highlight_update);
WM_operatortype_append(OUTLINER_OT_item_activate);
WM_operatortype_append(OUTLINER_OT_select_box);
+ WM_operatortype_append(OUTLINER_OT_select_walk);
WM_operatortype_append(OUTLINER_OT_item_openclose);
WM_operatortype_append(OUTLINER_OT_item_rename);
WM_operatortype_append(OUTLINER_OT_item_drag_drop);
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index 25e3d2580bc..823f4cd6ce6 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -1528,3 +1528,95 @@ void OUTLINER_OT_select_box(wmOperatorType *ot)
}
/* ****************************************************** */
+
+/* **************** Walk Select Tool ****************** */
+
+static void do_outliner_select_walk(SpaceOutliner *soops, TreeElement *active, const int direction)
+{
+ TreeStoreElem *tselem = TREESTORE(active);
+
+ outliner_flag_set(&soops->tree, TSE_SELECTED, false);
+ tselem->flag &= ~TSE_ACTIVE;
+
+ if (direction == OUTLINER_SELECT_WALK_DOWN) {
+ if (TSELEM_OPEN(tselem, soops)) {
+ active = active->subtree.first;
+ }
+ else if (active->next) {
+ active = active->next;
+ }
+ else if (active->parent->next) {
+ active = active->parent->next;
+ }
+ }
+ else if (direction == OUTLINER_SELECT_WALK_UP) {
+ if (active->prev) {
+ tselem = TREESTORE(active->prev);
+ if (TSELEM_OPEN(tselem, soops)) {
+ active = active->prev->subtree.first;
+ }
+ else {
+ active = active->prev;
+ }
+ }
+ else if (active->parent) {
+ active = active->parent;
+ }
+ }
+
+ tselem = TREESTORE(active);
+ tselem->flag |= TSE_SELECTED | TSE_ACTIVE;
+}
+
+static int outliner_walk_select_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
+{
+ SpaceOutliner *soops = CTX_wm_space_outliner(C);
+ ARegion *ar = CTX_wm_region(C);
+ const int direction = RNA_enum_get(op->ptr, "direction");
+
+ TreeElement *active = outliner_find_active_element(&soops->tree);
+
+ /* Set root to active if no active exists */
+ if (!active) {
+ active = soops->tree.first;
+ TREESTORE(active)->flag |= TSE_SELECTED | TSE_ACTIVE;
+ }
+ else {
+ do_outliner_select_walk(soops, active, direction);
+ }
+
+ ED_region_tag_redraw(ar);
+
+ return OPERATOR_FINISHED;
+}
+
+void OUTLINER_OT_select_walk(wmOperatorType *ot)
+{
+ static const EnumPropertyItem direction_items[] = {
+ {OUTLINER_SELECT_WALK_UP, "UP", 0, "Up", ""},
+ {OUTLINER_SELECT_WALK_DOWN, "DOWN", 0, "Down", ""},
+ {OUTLINER_SELECT_WALK_LEFT, "LEFT", 0, "Left", ""},
+ {OUTLINER_SELECT_WALK_RIGHT, "RIGHT", 0, "Right", ""},
+ };
+
+ /* identifiers */
+ ot->name = "Walk Select";
+ ot->idname = "OUTLINER_OT_select_walk";
+ ot->description = "Use walk selection to select tree elements";
+
+ /* api callbacks */
+ ot->invoke = outliner_walk_select_invoke;
+ ot->poll = ED_operator_outliner_active;
+
+ /* properties */
+ PropertyRNA *prop;
+ prop = RNA_def_enum(ot->srna,
+ "direction",
+ direction_items,
+ 0,
+ "Walk Direction",
+ "Select file in this direction");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+}
+
+/* ****************************************************** */
diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c
index 091efc56c09..17decb45ff1 100644
--- a/source/blender/editors/space_outliner/space_outliner.c
+++ b/source/blender/editors/space_outliner/space_outliner.c
@@ -415,7 +415,7 @@ void ED_spacetype_outliner(void)
/* regions: main window */
art = MEM_callocN(sizeof(ARegionType), "spacetype outliner region");
art->regionid = RGN_TYPE_WINDOW;
- art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES;
+ art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D;
art->init = outliner_main_region_init;
art->draw = outliner_main_region_draw;
@@ -428,7 +428,7 @@ void ED_spacetype_outliner(void)
art = MEM_callocN(sizeof(ARegionType), "spacetype outliner header region");
art->regionid = RGN_TYPE_HEADER;
art->prefsizey = HEADERY;
- art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER;
+ art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_HEADER;
art->init = outliner_header_region_init;
art->draw = outliner_header_region_draw;
More information about the Bf-blender-cvs
mailing list