WIP: uv-simple-select #1

Closed
Chris Blackbourn wants to merge 182 commits from uv-simple-select into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
6 changed files with 46 additions and 31 deletions
Showing only changes of commit 0d09e56cce - Show all commits

View File

@ -986,7 +986,7 @@ void file_draw_list(const bContext *C, ARegion *region)
UI_GetThemeColor4ubv(TH_TEXT, text_col);
for (i = offset; (i < numfiles) && (i < offset + numfiles_layout); i++) {
uint file_selflag;
eDirEntry_SelectFlag file_selflag;
const int padx = 0.1f * UI_UNIT_X;
int icon_ofs = 0;

View File

@ -137,7 +137,7 @@ FileAttributeColumnType file_attribute_column_type_find_isect(const View2D *v2d,
float file_string_width(const char *str);
float file_font_pointsize(void);
void file_select_deselect_all(SpaceFile *sfile, uint flag);
void file_select_deselect_all(SpaceFile *sfile, eDirEntry_SelectFlag flag);
int file_select_match(struct SpaceFile *sfile, const char *pattern, char *matched_file);
int autocomplete_directory(struct bContext *C, char *str, void *arg_v);
int autocomplete_file(struct bContext *C, char *str, void *arg_v);

View File

@ -233,11 +233,15 @@ struct FileList {
FileListEntryCache filelist_cache;
/* We need to keep those info outside of actual filelist items,
/**
* We need to keep those info outside of actual file-list items,
* because those are no more persistent
* (only generated on demand, and freed as soon as possible).
* Persistent part (mere list of paths + stat info)
* is kept as small as possible, and file-browser agnostic.
*
* - The key is a #FileDirEntry::uid
* - The value is an #eDirEntry_SelectFlag.
*/
GHash *selection_state;
@ -2737,13 +2741,13 @@ int filelist_needs_reading(FileList *filelist)
uint filelist_entry_select_set(const FileList *filelist,
const FileDirEntry *entry,
FileSelType select,
uint flag,
const eDirEntry_SelectFlag flag,
FileCheckType check)
{
/* Default nullptr pointer if not found is fine here! */
void **es_p = BLI_ghash_lookup_p(filelist->selection_state, POINTER_FROM_UINT(entry->uid));
uint entry_flag = es_p ? POINTER_AS_UINT(*es_p) : 0;
const uint org_entry_flag = entry_flag;
eDirEntry_SelectFlag entry_flag = eDirEntry_SelectFlag(es_p ? POINTER_AS_UINT(*es_p) : 0);
const eDirEntry_SelectFlag org_entry_flag = entry_flag;
BLI_assert(entry);
BLI_assert(ELEM(check, CHECK_DIRS, CHECK_FILES, CHECK_ALL));
@ -2782,8 +2786,11 @@ uint filelist_entry_select_set(const FileList *filelist,
return entry_flag;
}
void filelist_entry_select_index_set(
FileList *filelist, const int index, FileSelType select, uint flag, FileCheckType check)
void filelist_entry_select_index_set(FileList *filelist,
const int index,
FileSelType select,
const eDirEntry_SelectFlag flag,
FileCheckType check)
{
FileDirEntry *entry = filelist_file(filelist, index);
@ -2792,8 +2799,11 @@ void filelist_entry_select_index_set(
}
}
void filelist_entries_select_index_range_set(
FileList *filelist, FileSelection *sel, FileSelType select, uint flag, FileCheckType check)
void filelist_entries_select_index_range_set(FileList *filelist,
FileSelection *sel,
FileSelType select,
const eDirEntry_SelectFlag flag,
FileCheckType check)
{
/* select all valid files between first and last indicated */
if ((sel->first >= 0) && (sel->first < filelist->filelist.entries_filtered_num) &&
@ -2805,7 +2815,9 @@ void filelist_entries_select_index_range_set(
}
}
uint filelist_entry_select_get(FileList *filelist, FileDirEntry *entry, FileCheckType check)
eDirEntry_SelectFlag filelist_entry_select_get(FileList *filelist,
FileDirEntry *entry,
FileCheckType check)
{
BLI_assert(entry);
BLI_assert(ELEM(check, CHECK_DIRS, CHECK_FILES, CHECK_ALL));
@ -2813,14 +2825,16 @@ uint filelist_entry_select_get(FileList *filelist, FileDirEntry *entry, FileChec
if ((check == CHECK_ALL) || ((check == CHECK_DIRS) && (entry->typeflag & FILE_TYPE_DIR)) ||
((check == CHECK_FILES) && !(entry->typeflag & FILE_TYPE_DIR))) {
/* Default nullptr pointer if not found is fine here! */
return POINTER_AS_UINT(
BLI_ghash_lookup(filelist->selection_state, POINTER_FROM_UINT(entry->uid)));
return eDirEntry_SelectFlag(POINTER_AS_UINT(
BLI_ghash_lookup(filelist->selection_state, POINTER_FROM_UINT(entry->uid))));
}
return 0;
return eDirEntry_SelectFlag(0);
}
uint filelist_entry_select_index_get(FileList *filelist, const int index, FileCheckType check)
eDirEntry_SelectFlag filelist_entry_select_index_get(FileList *filelist,
const int index,
FileCheckType check)
{
FileDirEntry *entry = filelist_file(filelist, index);
@ -2828,7 +2842,7 @@ uint filelist_entry_select_index_get(FileList *filelist, const int index, FileCh
return filelist_entry_select_get(filelist, entry, check);
}
return 0;
return eDirEntry_SelectFlag(0);
}
bool filelist_entry_is_selected(FileList *filelist, const int index)
@ -2838,15 +2852,15 @@ bool filelist_entry_is_selected(FileList *filelist, const int index)
/* BLI_ghash_lookup returns nullptr 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, POINTER_FROM_UINT(intern_entry->uid)));
const eDirEntry_SelectFlag selection_state = eDirEntry_SelectFlag(POINTER_AS_UINT(
BLI_ghash_lookup(filelist->selection_state, POINTER_FROM_UINT(intern_entry->uid))));
return selection_state != 0;
}
void filelist_entry_parent_select_set(FileList *filelist,
FileSelType select,
uint flag,
const eDirEntry_SelectFlag flag,
FileCheckType check)
{
if ((filelist->filter_data.flags & FLF_HIDE_PARENT) == 0) {

View File

@ -148,31 +148,31 @@ bool filelist_is_ready(struct FileList *filelist);
unsigned int filelist_entry_select_set(const struct FileList *filelist,
const struct FileDirEntry *entry,
FileSelType select,
unsigned int flag,
const eDirEntry_SelectFlag flag,
FileCheckType check);
void filelist_entry_select_index_set(struct FileList *filelist,
int index,
FileSelType select,
unsigned int flag,
eDirEntry_SelectFlag flag,
FileCheckType check);
void filelist_entries_select_index_range_set(struct FileList *filelist,
FileSelection *sel,
FileSelType select,
unsigned int flag,
FileCheckType check);
unsigned int filelist_entry_select_get(struct FileList *filelist,
struct FileDirEntry *entry,
FileCheckType check);
unsigned int filelist_entry_select_index_get(struct FileList *filelist,
int index,
eDirEntry_SelectFlag flag,
FileCheckType check);
eDirEntry_SelectFlag filelist_entry_select_get(struct FileList *filelist,
struct FileDirEntry *entry,
FileCheckType check);
eDirEntry_SelectFlag filelist_entry_select_index_get(struct FileList *filelist,
int index,
FileCheckType check);
bool filelist_entry_is_selected(struct FileList *filelist, int index);
/**
* Set selection of the '..' parent entry, but only if it's actually visible.
*/
void filelist_entry_parent_select_set(struct FileList *filelist,
FileSelType select,
unsigned int flag,
eDirEntry_SelectFlag flag,
FileCheckType check);
void filelist_setrecursion(struct FileList *filelist, int recursion_level);

View File

@ -1124,7 +1124,7 @@ void ED_file_change_dir(bContext *C)
ED_file_change_dir_ex(C, area);
}
void file_select_deselect_all(SpaceFile *sfile, uint flag)
void file_select_deselect_all(SpaceFile *sfile, const eDirEntry_SelectFlag flag)
{
FileSelection sel;
sel.first = 0;

View File

@ -1091,13 +1091,14 @@ typedef enum eFileSel_File_Types {
} eFileSel_File_Types;
ENUM_OPERATORS(eFileSel_File_Types, FILE_TYPE_BLENDERLIB);
/** Selection Flags in filesel: struct direntry, unsigned char selflag. */
/** Selection Flags #FileList::selection_state. */
typedef enum eDirEntry_SelectFlag {
/* FILE_SEL_ACTIVE = (1 << 1), */ /* UNUSED */
FILE_SEL_HIGHLIGHTED = (1 << 2),
FILE_SEL_SELECTED = (1 << 3),
FILE_SEL_EDITING = (1 << 4),
} eDirEntry_SelectFlag;
ENUM_OPERATORS(eDirEntry_SelectFlag, FILE_SEL_EDITING);
/* ***** Related to file browser, but never saved in DNA, only here to help with RNA. ***** */