diff options
author | Julian Eisel <eiseljulian@gmail.com> | 2019-09-16 19:14:23 +0300 |
---|---|---|
committer | Julian Eisel <eiseljulian@gmail.com> | 2019-09-16 19:25:31 +0300 |
commit | 8d6b0eda5db45b63de8fccea1e3af41bf0bf09e0 (patch) | |
tree | 2f49c918125a63460b3878346425efcd44b799c4 /source | |
parent | 3618b2c3599d172cad3e0ee3fa7bd0eb886771a2 (diff) |
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.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/space_file/file_ops.c | 15 | ||||
-rw-r--r-- | source/blender/editors/space_file/file_panels.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_file/filesel.c | 7 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_space_types.h | 6 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operator_props.c | 12 |
5 files changed, 13 insertions, 29 deletions
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 127196cca74..b741a255383 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -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); } /** diff --git a/source/blender/editors/space_file/file_panels.c b/source/blender/editors/space_file/file_panels.c index b0fed1fafd4..8b83b5e1b05 100644 --- a/source/blender/editors/space_file/file_panels.c +++ b/source/blender/editors/space_file/file_panels.c @@ -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); diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index e54f13e9356..6e576006332 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -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) { diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index f212346f547..3be3daa8dfb 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -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 */ diff --git a/source/blender/windowmanager/intern/wm_operator_props.c b/source/blender/windowmanager/intern/wm_operator_props.c index 04775a7a880..a8feb22cbf8 100644 --- a/source/blender/windowmanager/intern/wm_operator_props.c +++ b/source/blender/windowmanager/intern/wm_operator_props.c @@ -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, |