diff options
author | Valentin <Poulpator> | 2020-03-02 18:05:59 +0300 |
---|---|---|
committer | Julian Eisel <eiseljulian@gmail.com> | 2020-03-02 18:07:34 +0300 |
commit | 7b8db971d42f6d6b7b1c74959758266ce8c859e0 (patch) | |
tree | 1ba8b885eaa68a50cdfd4ca37a229ae46c21e00a /source/blender/editors/space_file | |
parent | 51bce18b6f97dd6c21899e43f4ee4491d0061e92 (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/blender/editors/space_file')
-rw-r--r-- | source/blender/editors/space_file/file_intern.h | 7 | ||||
-rw-r--r-- | source/blender/editors/space_file/file_ops.c | 35 |
2 files changed, 11 insertions, 31 deletions
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, |