diff options
author | Sybren A. Stüvel <sybren@blender.org> | 2021-03-08 15:57:15 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2021-03-08 17:21:34 +0300 |
commit | 5a67407d5aa8800faf78f40811b703d07e8f7300 (patch) | |
tree | 3b10f385b1d26d6399d6fdaa75f5792a18384369 /source/blender/editors/space_file/filelist.c | |
parent | e20b31504a2381011e60c5eadffb67f18918bc71 (diff) |
File Browser: scroll selected files into view
Add operator `FILE_OT_view_selected` to the file browser (and thus also
to the asset browser) that scrolls selected files into view.
This includes the active file, even though it is not selected. In
certain cases the active file can loose its selected state (clicking
next to it, or refreshing the asset browser), but then it's still shown
in the right-hand sidebar. Because of this, I found it important to take
it into account when scrolling.
This also includes a change to the keymaps:
- Blender default: {key NUMPAD_PERIOD} is removed from the "reload"
operator, and assigned to the new "view selected files" operator. The
reload operator was already doubly bound, and now {key R} is the only
remaining hotkey for it.
- Industry compatible: {key F} is assigned to the new "view selected
files" operator. This is consistent with the other "view selected"
operators in other editors.
Reviewed By: Severin
Differential Revision: https://developer.blender.org/D10583
Diffstat (limited to 'source/blender/editors/space_file/filelist.c')
-rw-r--r-- | source/blender/editors/space_file/filelist.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index 757ec7c741f..f5ec9a0e8a1 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -2701,6 +2701,19 @@ uint filelist_entry_select_index_get(FileList *filelist, const int index, FileCh return 0; } +bool filelist_entry_is_selected(FileList *filelist, const int index) +{ + BLI_assert(index >= 0 && index < filelist->filelist.nbr_entries_filtered); + FileListInternEntry *intern_entry = filelist->filelist_intern.filtered[index]; + + /* BLI_ghash_lookup returns NULL if not found, which gets mapped to 0, which gets mapped to + * "not selected". */ + const uint selection_state = POINTER_AS_UINT( + BLI_ghash_lookup(filelist->selection_state, intern_entry->uuid)); + + return selection_state != 0; +} + /** * Set selection of the '..' parent entry, but only if it's actually visible. */ |