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
diff options
context:
space:
mode:
authorJulian Eisel <eiseljulian@gmail.com>2015-06-11 18:20:29 +0300
committerJulian Eisel <eiseljulian@gmail.com>2015-06-11 18:20:29 +0300
commit939948c23384119dbcc7d94614cabf76dde22391 (patch)
treeee70ead880a234ab45bd21b6591f1ae629762880 /source/blender/editors/space_file/space_file.c
parent356afe0085718cd326f4e830c943537923c2e976 (diff)
File Browser Arrow Keys Navigation
Adds support for selecting/deselecting files in File Browser using the arrow keys. All directions (up, down, left, right) are possible. When to Select, When to Deselect? Standard behaviour is selecting, however if we move into a block of already selected files (meaning 2+ files are selected) we start deselecting Possible Selection Methods Simple selection (arrow-key): All other files are deselected Expand selection (Shift+arrow key): Add to/remove from existing selection ill-Expand selection (Ctrl+Shift+arrow key): Add to/remove from existing selection and fill everything in-between From which file do we start navigating? From each available selection method (Mouse-, Walk-, All-, Border Select), we use the last selected file. If there's no selection at all we use the first (down/right arrow) or last (up/left arrow) file. (Ideally, the view would automatically be set to the new selection, but this behaviour overlaps with an other patch I've been working on, so prefer to do that separately) (Also tweaks color for highlighted file for better feedback) D1297, Review done by @campbellbarton, thx a lot :)
Diffstat (limited to 'source/blender/editors/space_file/space_file.c')
-rw-r--r--source/blender/editors/space_file/space_file.c48
1 files changed, 46 insertions, 2 deletions
diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c
index 782b318b8a2..c7e0e4ad4e9 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -212,7 +212,7 @@ static void file_refresh(const bContext *C, ScrArea *sa)
if (!sfile->files) {
sfile->files = filelist_new(params->type);
filelist_setdir(sfile->files, params->dir);
- params->active_file = -1; /* added this so it opens nicer (ton) */
+ params->highlight_file = -1; /* added this so it opens nicer (ton) */
}
filelist_setsorting(sfile->files, params->sort);
filelist_setfilter_options(sfile->files, params->flag & FILE_HIDE_DOT,
@@ -377,7 +377,7 @@ static void file_main_area_draw(const bContext *C, ARegion *ar)
UI_view2d_view_ortho(v2d);
/* on first read, find active file */
- if (params->active_file == -1) {
+ if (params->highlight_file == -1) {
wmEvent *event = CTX_wm_window(C)->eventstate;
file_highlight_set(sfile, ar, event->x, event->y);
}
@@ -397,6 +397,7 @@ static void file_main_area_draw(const bContext *C, ARegion *ar)
static void file_operatortypes(void)
{
WM_operatortype_append(FILE_OT_select);
+ WM_operatortype_append(FILE_OT_select_walk);
WM_operatortype_append(FILE_OT_select_all_toggle);
WM_operatortype_append(FILE_OT_select_border);
WM_operatortype_append(FILE_OT_select_bookmark);
@@ -462,6 +463,49 @@ static void file_keymap(struct wmKeyConfig *keyconf)
RNA_boolean_set(kmi->ptr, "fill", true);
RNA_boolean_set(kmi->ptr, "open", false);
+
+ /* arrow keys navigation (walk selecting) */
+ kmi = WM_keymap_add_item(keymap, "FILE_OT_select_walk", UPARROWKEY, KM_PRESS, 0, 0);
+ RNA_enum_set(kmi->ptr, "direction", FILE_SELECT_WALK_UP);
+ kmi = WM_keymap_add_item(keymap, "FILE_OT_select_walk", UPARROWKEY, KM_PRESS, KM_SHIFT, 0);
+ RNA_enum_set(kmi->ptr, "direction", FILE_SELECT_WALK_UP);
+ RNA_boolean_set(kmi->ptr, "extend", true);
+ kmi = WM_keymap_add_item(keymap, "FILE_OT_select_walk", UPARROWKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
+ RNA_enum_set(kmi->ptr, "direction", FILE_SELECT_WALK_UP);
+ RNA_boolean_set(kmi->ptr, "extend", true);
+ RNA_boolean_set(kmi->ptr, "fill", true);
+
+ kmi = WM_keymap_add_item(keymap, "FILE_OT_select_walk", DOWNARROWKEY, KM_PRESS, 0, 0);
+ RNA_enum_set(kmi->ptr, "direction", FILE_SELECT_WALK_DOWN);
+ kmi = WM_keymap_add_item(keymap, "FILE_OT_select_walk", DOWNARROWKEY, KM_PRESS, KM_SHIFT, 0);
+ RNA_enum_set(kmi->ptr, "direction", FILE_SELECT_WALK_DOWN);
+ RNA_boolean_set(kmi->ptr, "extend", true);
+ kmi = WM_keymap_add_item(keymap, "FILE_OT_select_walk", DOWNARROWKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
+ RNA_enum_set(kmi->ptr, "direction", FILE_SELECT_WALK_DOWN);
+ RNA_boolean_set(kmi->ptr, "extend", true);
+ RNA_boolean_set(kmi->ptr, "fill", true);
+
+ kmi = WM_keymap_add_item(keymap, "FILE_OT_select_walk", LEFTARROWKEY, KM_PRESS, 0, 0);
+ RNA_enum_set(kmi->ptr, "direction", FILE_SELECT_WALK_LEFT);
+ kmi = WM_keymap_add_item(keymap, "FILE_OT_select_walk", LEFTARROWKEY, KM_PRESS, KM_SHIFT, 0);
+ RNA_enum_set(kmi->ptr, "direction", FILE_SELECT_WALK_LEFT);
+ RNA_boolean_set(kmi->ptr, "extend", true);
+ kmi = WM_keymap_add_item(keymap, "FILE_OT_select_walk", LEFTARROWKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
+ RNA_enum_set(kmi->ptr, "direction", FILE_SELECT_WALK_LEFT);
+ RNA_boolean_set(kmi->ptr, "extend", true);
+ RNA_boolean_set(kmi->ptr, "fill", true);
+
+ kmi = WM_keymap_add_item(keymap, "FILE_OT_select_walk", RIGHTARROWKEY, KM_PRESS, 0, 0);
+ RNA_enum_set(kmi->ptr, "direction", FILE_SELECT_WALK_RIGHT);
+ kmi = WM_keymap_add_item(keymap, "FILE_OT_select_walk", RIGHTARROWKEY, KM_PRESS, KM_SHIFT, 0);
+ RNA_enum_set(kmi->ptr, "direction", FILE_SELECT_WALK_RIGHT);
+ RNA_boolean_set(kmi->ptr, "extend", true);
+ kmi = WM_keymap_add_item(keymap, "FILE_OT_select_walk", RIGHTARROWKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
+ RNA_enum_set(kmi->ptr, "direction", FILE_SELECT_WALK_RIGHT);
+ RNA_boolean_set(kmi->ptr, "extend", true);
+ RNA_boolean_set(kmi->ptr, "fill", true);
+
+
/* front and back mouse folder navigation */
WM_keymap_add_item(keymap, "FILE_OT_previous", BUTTON4MOUSE, KM_CLICK, 0, 0);
WM_keymap_add_item(keymap, "FILE_OT_next", BUTTON5MOUSE, KM_CLICK, 0, 0);