UI: Show in-/decrement buttons for exporters
As per Brecht's suggestion, use the check_existing property to control visibility of the '+' and '-' icons. It is typically set for save operations. Adds another FileSelectParams flag (to avoid duplicated propertie lookups) and removes the recently introduced FileSelectParams.action_type again. Fixes T69881.
This commit is contained in:
parent
3618b2c359
commit
8d6b0eda5d
Notes:
blender-bot
2023-09-08 04:55:43 +02:00
Referenced by issue #69881, Missing +/- icons in export file browser UI
|
@ -1506,14 +1506,11 @@ void file_draw_check_cb(bContext *C, void *UNUSED(arg1), void *UNUSED(arg2))
|
|||
bool file_draw_check_exists(SpaceFile *sfile)
|
||||
{
|
||||
if (sfile->op) { /* fails on reload */
|
||||
PropertyRNA *prop;
|
||||
if ((prop = RNA_struct_find_property(sfile->op->ptr, "check_existing"))) {
|
||||
if (RNA_property_boolean_get(sfile->op->ptr, prop)) {
|
||||
char filepath[FILE_MAX];
|
||||
BLI_join_dirfile(filepath, sizeof(filepath), sfile->params->dir, sfile->params->file);
|
||||
if (BLI_is_file(filepath)) {
|
||||
return true;
|
||||
}
|
||||
if (sfile->params && (sfile->params->flag & FILE_CHECK_EXISTING)) {
|
||||
char filepath[FILE_MAX];
|
||||
BLI_join_dirfile(filepath, sizeof(filepath), sfile->params->dir, sfile->params->file);
|
||||
if (BLI_is_file(filepath)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2398,7 +2395,7 @@ static bool file_filenum_poll(bContext *C)
|
|||
return false;
|
||||
}
|
||||
|
||||
return sfile->params && (sfile->params->action_type == FILE_SAVE);
|
||||
return sfile->params && (sfile->params->flag & FILE_CHECK_EXISTING);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -176,7 +176,7 @@ static void file_panel_execution_buttons_draw(const bContext *C, Panel *pa)
|
|||
* immediate ui_apply_but_func but only after button deactivates */
|
||||
UI_but_funcN_set(but, file_filename_enter_handle, NULL, but);
|
||||
|
||||
if (params->action_type == FILE_SAVE) {
|
||||
if (params->flag & FILE_CHECK_EXISTING) {
|
||||
but_extra_rna_ptr = UI_but_extra_operator_icon_add(
|
||||
but, "FILE_OT_filenum", WM_OP_EXEC_REGION_WIN, ICON_ADD);
|
||||
RNA_int_set(but_extra_rna_ptr, "increment", 1);
|
||||
|
|
|
@ -167,6 +167,9 @@ short ED_fileselect_set_params(SpaceFile *sfile)
|
|||
params->flag &= ~FILE_DIRSEL_ONLY;
|
||||
}
|
||||
|
||||
if ((prop = RNA_struct_find_property(op->ptr, "check_existing"))) {
|
||||
params->flag |= RNA_property_boolean_get(op->ptr, prop) ? FILE_CHECK_EXISTING : 0;
|
||||
}
|
||||
if ((prop = RNA_struct_find_property(op->ptr, "hide_props_region"))) {
|
||||
params->flag |= RNA_property_boolean_get(op->ptr, prop) ? FILE_HIDE_TOOL_PROPS : 0;
|
||||
}
|
||||
|
@ -274,10 +277,6 @@ short ED_fileselect_set_params(SpaceFile *sfile)
|
|||
params->sort = FILE_SORT_ALPHA;
|
||||
}
|
||||
|
||||
if ((prop = RNA_struct_find_property(op->ptr, "action_type"))) {
|
||||
params->action_type = RNA_property_enum_get(op->ptr, prop);
|
||||
}
|
||||
|
||||
if (params->display == FILE_DEFAULTDISPLAY) {
|
||||
if (params->display_previous == FILE_DEFAULTDISPLAY) {
|
||||
if (U.uiflag & USER_SHOW_THUMBNAILS) {
|
||||
|
|
|
@ -679,8 +679,7 @@ typedef struct FileSelectParams {
|
|||
short display_previous;
|
||||
/** Details toggles (file size, creation date, etc.) */
|
||||
char details_flags;
|
||||
/* The type of file action (opening or saving) */
|
||||
char action_type; /* eFileSel_Action */
|
||||
char _pad2;
|
||||
/** Filter when (flags & FILE_FILTER) is true. */
|
||||
int filter;
|
||||
|
||||
|
@ -797,7 +796,8 @@ typedef enum eFileSel_Params_Flag {
|
|||
FILE_PARAMS_FLAG_UNUSED_9 = (1 << 9), /* cleared */
|
||||
FILE_GROUP_INSTANCE = (1 << 10),
|
||||
FILE_SORT_INVERT = (1 << 11),
|
||||
FILE_HIDE_TOOL_PROPS = (1 << 12)
|
||||
FILE_HIDE_TOOL_PROPS = (1 << 12),
|
||||
FILE_CHECK_EXISTING = (1 << 13),
|
||||
} eFileSel_Params_Flag;
|
||||
|
||||
/* sfile->params->rename_flag */
|
||||
|
|
|
@ -78,15 +78,6 @@ void WM_operator_properties_filesel(wmOperatorType *ot,
|
|||
{FILE_IMGDISPLAY, "THUMBNAIL", ICON_IMGDISPLAY, "Thumbnails", "Display files as thumbnails"},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
};
|
||||
static const EnumPropertyItem file_action_types[] = {
|
||||
{FILE_OPENFILE,
|
||||
"OPENFILE",
|
||||
0,
|
||||
"Open",
|
||||
"Use the file browser for opening files or a directory"},
|
||||
{FILE_SAVE, "SAVE", 0, "Save", "Use the file browser for saving a file"},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
};
|
||||
|
||||
if (flag & WM_FILESEL_FILEPATH) {
|
||||
RNA_def_string_file_path(ot->srna, "filepath", NULL, FILE_MAX, "File Path", "Path to file");
|
||||
|
@ -207,9 +198,6 @@ void WM_operator_properties_filesel(wmOperatorType *ot,
|
|||
prop = RNA_def_enum(
|
||||
ot->srna, "sort_method", rna_enum_file_sort_items, sort, "File sorting mode", "");
|
||||
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
||||
|
||||
prop = RNA_def_enum(ot->srna, "action_type", file_action_types, action, "Action Type", "");
|
||||
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
||||
}
|
||||
|
||||
static void wm_operator_properties_select_action_ex(wmOperatorType *ot,
|
||||
|
|
Loading…
Reference in New Issue