Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorValentin <Poulpator>2020-03-02 18:05:59 +0300
committerJulian Eisel <eiseljulian@gmail.com>2020-03-02 18:07:34 +0300
commit7b8db971d42f6d6b7b1c74959758266ce8c859e0 (patch)
tree1ba8b885eaa68a50cdfd4ca37a229ae46c21e00a /source
parent51bce18b6f97dd6c21899e43f4ee4491d0061e92 (diff)
Cleanup: Use generics properties for arrow keys navigation (walk-select)
This patch refactors arrow keys navigation to move properties and enum to generic ED_select_utils.h and property to WM_operator_properties_select_walk_direction() No functional change Reviewed By: Julian Eisel Differential Revision: https://developer.blender.org/D4771
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/include/ED_select_utils.h7
-rw-r--r--source/blender/editors/space_file/file_intern.h7
-rw-r--r--source/blender/editors/space_file/file_ops.c35
-rw-r--r--source/blender/editors/space_outliner/outliner_intern.h8
-rw-r--r--source/blender/editors/space_outliner/outliner_select.c24
-rw-r--r--source/blender/windowmanager/WM_api.h1
-rw-r--r--source/blender/windowmanager/intern/wm_operator_props.c19
7 files changed, 43 insertions, 58 deletions
diff --git a/source/blender/editors/include/ED_select_utils.h b/source/blender/editors/include/ED_select_utils.h
index 9a4846391c2..9c7cc0ef7a2 100644
--- a/source/blender/editors/include/ED_select_utils.h
+++ b/source/blender/editors/include/ED_select_utils.h
@@ -34,6 +34,13 @@ enum {
SEL_INVERT = 3,
};
+typedef enum WalkSelectDirection {
+ UI_SELECT_WALK_UP,
+ UI_SELECT_WALK_DOWN,
+ UI_SELECT_WALK_LEFT,
+ UI_SELECT_WALK_RIGHT,
+} WalkSelectDirections;
+
/** See #WM_operator_properties_select_operation */
typedef enum {
SEL_OP_ADD = 1,
diff --git a/source/blender/editors/space_file/file_intern.h b/source/blender/editors/space_file/file_intern.h
index 730df53813c..2ded69aef2f 100644
--- a/source/blender/editors/space_file/file_intern.h
+++ b/source/blender/editors/space_file/file_intern.h
@@ -48,13 +48,6 @@ bool file_draw_check_exists(SpaceFile *sfile);
struct wmOperator;
struct wmOperatorType;
-typedef enum WalkSelectDirection {
- FILE_SELECT_WALK_UP,
- FILE_SELECT_WALK_DOWN,
- FILE_SELECT_WALK_LEFT,
- FILE_SELECT_WALK_RIGHT,
-} WalkSelectDirections;
-
void FILE_OT_highlight(struct wmOperatorType *ot);
void FILE_OT_sort_column_ui_context(struct wmOperatorType *ot);
void FILE_OT_select(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index 32c5cdde0a3..9281653efa5 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -626,11 +626,11 @@ static bool file_walk_select_selection_set(bContext *C,
}
else {
/* select last file */
- if (ELEM(direction, FILE_SELECT_WALK_UP, FILE_SELECT_WALK_LEFT)) {
+ if (ELEM(direction, UI_SELECT_WALK_UP, UI_SELECT_WALK_LEFT)) {
params->active_file = active = numfiles - 1;
}
/* select first file */
- else if (ELEM(direction, FILE_SELECT_WALK_DOWN, FILE_SELECT_WALK_RIGHT)) {
+ else if (ELEM(direction, UI_SELECT_WALK_DOWN, UI_SELECT_WALK_RIGHT)) {
params->active_file = active = 0;
}
else {
@@ -721,23 +721,23 @@ static bool file_walk_select_do(bContext *C,
FileLayout *layout = ED_fileselect_get_layout(sfile, ar);
const int idx_shift = (layout->flag & FILE_LAYOUT_HOR) ? layout->rows : layout->flow_columns;
- if ((layout->flag & FILE_LAYOUT_HOR && direction == FILE_SELECT_WALK_UP) ||
- (layout->flag & FILE_LAYOUT_VER && direction == FILE_SELECT_WALK_LEFT)) {
+ if ((layout->flag & FILE_LAYOUT_HOR && direction == UI_SELECT_WALK_UP) ||
+ (layout->flag & FILE_LAYOUT_VER && direction == UI_SELECT_WALK_LEFT)) {
active_new = active_old - 1;
other_site = active_old + 1;
}
- else if ((layout->flag & FILE_LAYOUT_HOR && direction == FILE_SELECT_WALK_DOWN) ||
- (layout->flag & FILE_LAYOUT_VER && direction == FILE_SELECT_WALK_RIGHT)) {
+ else if ((layout->flag & FILE_LAYOUT_HOR && direction == UI_SELECT_WALK_DOWN) ||
+ (layout->flag & FILE_LAYOUT_VER && direction == UI_SELECT_WALK_RIGHT)) {
active_new = active_old + 1;
other_site = active_old - 1;
}
- else if ((layout->flag & FILE_LAYOUT_HOR && direction == FILE_SELECT_WALK_LEFT) ||
- (layout->flag & FILE_LAYOUT_VER && direction == FILE_SELECT_WALK_UP)) {
+ else if ((layout->flag & FILE_LAYOUT_HOR && direction == UI_SELECT_WALK_LEFT) ||
+ (layout->flag & FILE_LAYOUT_VER && direction == UI_SELECT_WALK_UP)) {
active_new = active_old - idx_shift;
other_site = active_old + idx_shift;
}
- else if ((layout->flag & FILE_LAYOUT_HOR && direction == FILE_SELECT_WALK_RIGHT) ||
- (layout->flag & FILE_LAYOUT_VER && direction == FILE_SELECT_WALK_DOWN)) {
+ else if ((layout->flag & FILE_LAYOUT_HOR && direction == UI_SELECT_WALK_RIGHT) ||
+ (layout->flag & FILE_LAYOUT_VER && direction == UI_SELECT_WALK_DOWN)) {
active_new = active_old + idx_shift;
other_site = active_old - idx_shift;
@@ -793,13 +793,6 @@ static int file_walk_select_invoke(bContext *C, wmOperator *op, const wmEvent *U
void FILE_OT_select_walk(wmOperatorType *ot)
{
- static const EnumPropertyItem direction_items[] = {
- {FILE_SELECT_WALK_UP, "UP", 0, "Prev", ""},
- {FILE_SELECT_WALK_DOWN, "DOWN", 0, "Next", ""},
- {FILE_SELECT_WALK_LEFT, "LEFT", 0, "Left", ""},
- {FILE_SELECT_WALK_RIGHT, "RIGHT", 0, "Right", ""},
- {0, NULL, 0, NULL, NULL},
- };
PropertyRNA *prop;
/* identifiers */
@@ -812,13 +805,7 @@ void FILE_OT_select_walk(wmOperatorType *ot)
ot->poll = ED_operator_file_active;
/* properties */
- prop = RNA_def_enum(ot->srna,
- "direction",
- direction_items,
- 0,
- "Walk Direction",
- "Select/Deselect file in this direction");
- RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+ WM_operator_properties_select_walk_direction(ot);
prop = RNA_def_boolean(ot->srna,
"extend",
false,
diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h
index 8075065e5c2..f83f53c5300 100644
--- a/source/blender/editors/space_outliner/outliner_intern.h
+++ b/source/blender/editors/space_outliner/outliner_intern.h
@@ -49,14 +49,6 @@ 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,
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index 51e837db4c2..fd0dbd63c89 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -1636,16 +1636,16 @@ static TreeElement *do_outliner_select_walk(SpaceOutliner *soops,
tselem->flag &= ~TSE_ACTIVE_WALK;
switch (direction) {
- case OUTLINER_SELECT_WALK_UP:
+ case UI_SELECT_WALK_UP:
walk_element = outliner_find_previous_element(soops, walk_element);
break;
- case OUTLINER_SELECT_WALK_DOWN:
+ case UI_SELECT_WALK_DOWN:
walk_element = outliner_find_next_element(soops, walk_element);
break;
- case OUTLINER_SELECT_WALK_LEFT:
+ case UI_SELECT_WALK_LEFT:
outliner_item_openclose(walk_element, false, toggle_all);
break;
- case OUTLINER_SELECT_WALK_RIGHT:
+ case UI_SELECT_WALK_RIGHT:
outliner_item_openclose(walk_element, true, toggle_all);
break;
}
@@ -1748,14 +1748,6 @@ static int outliner_walk_select_invoke(bContext *C, wmOperator *op, const wmEven
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", ""},
- {0, NULL, 0, NULL, NULL},
- };
-
/* identifiers */
ot->name = "Walk Select";
ot->idname = "OUTLINER_OT_select_walk";
@@ -1769,13 +1761,7 @@ void OUTLINER_OT_select_walk(wmOperatorType *ot)
/* properties */
PropertyRNA *prop;
- prop = RNA_def_enum(ot->srna,
- "direction",
- direction_items,
- 0,
- "Walk Direction",
- "Select element in this direction");
- RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+ WM_operator_properties_select_walk_direction(ot);
prop = RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend selection on walk");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
prop = RNA_def_boolean(
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index 58e312c67c9..1c86e4da291 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -483,6 +483,7 @@ void WM_operator_properties_select_random(struct wmOperatorType *ot);
int WM_operator_properties_select_random_seed_increment_get(wmOperator *op);
void WM_operator_properties_select_operation(struct wmOperatorType *ot);
void WM_operator_properties_select_operation_simple(struct wmOperatorType *ot);
+void WM_operator_properties_select_walk_direction(struct wmOperatorType *ot);
void WM_operator_properties_generic_select(struct wmOperatorType *ot);
struct CheckerIntervalParams {
int nth; /* bypass when set to zero */
diff --git a/source/blender/windowmanager/intern/wm_operator_props.c b/source/blender/windowmanager/intern/wm_operator_props.c
index 4c0b35a65e5..676ce655a42 100644
--- a/source/blender/windowmanager/intern/wm_operator_props.c
+++ b/source/blender/windowmanager/intern/wm_operator_props.c
@@ -399,6 +399,25 @@ void WM_operator_properties_select_operation_simple(wmOperatorType *ot)
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
+void WM_operator_properties_select_walk_direction(wmOperatorType *ot)
+{
+ static const EnumPropertyItem direction_items[] = {
+ {UI_SELECT_WALK_UP, "UP", 0, "Prev", ""},
+ {UI_SELECT_WALK_DOWN, "DOWN", 0, "Next", ""},
+ {UI_SELECT_WALK_LEFT, "LEFT", 0, "Left", ""},
+ {UI_SELECT_WALK_RIGHT, "RIGHT", 0, "Right", ""},
+ {0, NULL, 0, NULL, NULL},
+ };
+ PropertyRNA *prop;
+ prop = RNA_def_enum(ot->srna,
+ "direction",
+ direction_items,
+ 0,
+ "Walk Direction",
+ "Select/Deselect element in this direction");
+ RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+}
+
/**
* Selecting and tweaking items are overlapping operations. Getting both to work without conflicts
* requires special care. See