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>2019-09-30 19:54:11 +0300
committerJulian Eisel <eiseljulian@gmail.com>2019-09-30 20:27:02 +0300
commitddb157999eed6907e3fd8753d61e65491f2f3a6d (patch)
tree4235cd3bc8f647a8ff71fe5ca17efe1ddbcf2c2f
parent5940f6b3d9cfa99a1b893b6149d36ee0a8c51584 (diff)
UI: Remember File Browser Display Options in Preferences
This makes it so that some display related properties of the file browser state are remembered in the Preferences. Otherwise, users often end up doing the same set up work over and over again, so this is a nice way to save users some work. It's typical for other file browsers to remember their state too, so another benefit is having a more conventional behavior, meeting user expectations better. Some points: * We currently store: Window size, display type, thumbnail size, enabled details-columns, sort options, "Show Hidden" option. More can be added easily. * No changes are stored to the Preferences if "Auto-save Preferences" is disabled. This is how Quick Favorites behave too and it's a reasonable way to make this behavior optional. * The Preferences are only saved to permanent memory upon closing Blender, following existing convention of Preferences and Quick Favorites. * If settings weren't actually changed, Preference saving is skipped. * Only temporary file browsers save their state (invoked through actions like open or save), not regular file browser editors. These are usually used for different purposes and workflows. * Removes "Show Thumbnails" Preferences option. It would need some special handling, possibly introducing bugs. For users, this simplifies behavior and should make things more predictable. Left in DNA data in case we decide to bring it back. Reviewers: brecht, #user_interface, billreynish, campbellbarton Reviewed By: #user_interface, William Reynish, Campbell Barton, Brecht van Lommel (quick first pass review in person) Maniphest Tasks: T69460 Differential Revision: https://developer.blender.org/D5893
-rw-r--r--release/datafiles/userdef/userdef_default.c13
-rw-r--r--release/scripts/startup/bl_ui/space_userpref.py1
-rw-r--r--source/blender/blenloader/intern/versioning_userdef.c5
-rw-r--r--source/blender/editors/include/ED_fileselect.h2
-rw-r--r--source/blender/editors/space_file/filesel.c97
-rw-r--r--source/blender/makesdna/DNA_space_types.h3
-rw-r--r--source/blender/makesdna/DNA_userdef_types.h25
-rw-r--r--source/blender/makesdna/intern/dna_defaults.c1
-rw-r--r--source/blender/makesrna/intern/rna_userdef.c5
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c21
10 files changed, 135 insertions, 38 deletions
diff --git a/release/datafiles/userdef/userdef_default.c b/release/datafiles/userdef/userdef_default.c
index 1b14e8920c9..7785c9d2962 100644
--- a/release/datafiles/userdef/userdef_default.c
+++ b/release/datafiles/userdef/userdef_default.c
@@ -21,6 +21,7 @@
#include "DNA_userdef_types.h"
#include "DNA_curve_types.h"
+#include "DNA_space_types.h"
#include "BLI_math_rotation.h"
@@ -203,6 +204,18 @@ const UserDef U_default = {
.section_active = USER_SECTION_INTERFACE,
},
+ .file_space_data =
+ {
+ .display_type = FILE_VERTICALDISPLAY,
+ .thumbnail_size = 128,
+ .sort_type = FILE_SORT_ALPHA,
+ .details_flags = FILE_DETAILS_SIZE | FILE_DETAILS_DATETIME,
+ .flag = FILE_HIDE_DOT,
+
+ .temp_win_sizex = 1020,
+ .temp_win_sizey = 600,
+ },
+
.runtime =
{
.is_dirty = 0,
diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index 2384cd0fe38..be41fb52118 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -1405,7 +1405,6 @@ class USERPREF_PT_saveload_file_browser(PreferencePanel, Panel):
flow.prop(paths, "show_hidden_files_datablocks")
flow.prop(paths, "hide_recent_locations")
flow.prop(paths, "hide_system_bookmarks")
- flow.prop(paths, "show_thumbnails")
class USERPREF_MT_ndof_settings(Menu):
diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c
index ad11be1a5f5..bbae1c8e85e 100644
--- a/source/blender/blenloader/intern/versioning_userdef.c
+++ b/source/blender/blenloader/intern/versioning_userdef.c
@@ -29,6 +29,7 @@
#include "DNA_curve_types.h"
#include "DNA_windowmanager_types.h"
#include "DNA_scene_types.h"
+#include "DNA_space_types.h"
#include "BKE_addon.h"
#include "BKE_colorband.h"
@@ -627,6 +628,10 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
*/
{
/* pass */
+ if (userdef->file_space_data.display_type == FILE_DEFAULTDISPLAY) {
+ memcpy(
+ &userdef->file_space_data, &U_default.file_space_data, sizeof(userdef->file_space_data));
+ }
}
if (userdef->pixelsize == 0.0f) {
diff --git a/source/blender/editors/include/ED_fileselect.h b/source/blender/editors/include/ED_fileselect.h
index 37090ce3421..83890c1621c 100644
--- a/source/blender/editors/include/ED_fileselect.h
+++ b/source/blender/editors/include/ED_fileselect.h
@@ -98,6 +98,8 @@ struct rcti;
struct FileSelectParams *ED_fileselect_get_params(struct SpaceFile *sfile);
short ED_fileselect_set_params(struct SpaceFile *sfile);
+void ED_fileselect_set_params_from_userdef(struct SpaceFile *sfile);
+void ED_fileselect_params_to_userdef(struct SpaceFile *sfile, int temp_win_size[]);
void ED_fileselect_reset_params(struct SpaceFile *sfile);
diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c
index 6e576006332..e2c9bb8d6e5 100644
--- a/source/blender/editors/space_file/filesel.c
+++ b/source/blender/editors/space_file/filesel.c
@@ -49,6 +49,8 @@
#include "BLI_utildefines.h"
#include "BLI_fnmatch.h"
+#include "BLO_readfile.h"
+
#include "BLT_translation.h"
#include "BKE_appdir.h"
@@ -102,9 +104,9 @@ short ED_fileselect_set_params(SpaceFile *sfile)
sizeof(sfile->params->file));
sfile->params->filter_glob[0] = '\0';
/* set the default thumbnails size */
- sfile->params->thumbnail_size = 128;
+ sfile->params->thumbnail_size = U_default.file_space_data.thumbnail_size;
/* Show size column by default. */
- sfile->params->details_flags = FILE_DETAILS_SIZE | FILE_DETAILS_DATETIME;
+ sfile->params->details_flags = U_default.file_space_data.details_flags;
}
params = sfile->params;
@@ -274,26 +276,11 @@ short ED_fileselect_set_params(SpaceFile *sfile)
params->sort = RNA_property_enum_get(op->ptr, prop);
}
else {
- params->sort = FILE_SORT_ALPHA;
+ params->sort = U_default.file_space_data.sort_type;
}
if (params->display == FILE_DEFAULTDISPLAY) {
- if (params->display_previous == FILE_DEFAULTDISPLAY) {
- if (U.uiflag & USER_SHOW_THUMBNAILS) {
- if (params->filter & (FILE_TYPE_IMAGE | FILE_TYPE_MOVIE | FILE_TYPE_FTFONT)) {
- params->display = FILE_IMGDISPLAY;
- }
- else {
- params->display = FILE_VERTICALDISPLAY;
- }
- }
- else {
- params->display = FILE_VERTICALDISPLAY;
- }
- }
- else {
- params->display = params->display_previous;
- }
+ params->display = U_default.file_space_data.display_type;
}
if (is_relative_path) {
@@ -307,10 +294,9 @@ short ED_fileselect_set_params(SpaceFile *sfile)
else {
/* default values, if no operator */
params->type = FILE_UNIX;
- params->flag |= FILE_HIDE_DOT;
+ params->flag |= U_default.file_space_data.flag;
params->flag &= ~FILE_DIRSEL_ONLY;
params->display = FILE_VERTICALDISPLAY;
- params->display_previous = FILE_DEFAULTDISPLAY;
params->sort = FILE_SORT_ALPHA;
params->filter = 0;
params->filter_glob[0] = '\0';
@@ -346,6 +332,63 @@ short ED_fileselect_set_params(SpaceFile *sfile)
return 1;
}
+/* The subset of FileSelectParams.flag items we store into preferences. */
+#define PARAMS_FLAGS_REMEMBERED (FILE_HIDE_DOT | FILE_SORT_INVERT)
+
+void ED_fileselect_set_params_from_userdef(SpaceFile *sfile)
+{
+ wmOperator *op = sfile->op;
+ UserDef_FileSpaceData *sfile_udata = &U.file_space_data;
+
+ ED_fileselect_set_params(sfile);
+
+ if (!op) {
+ return;
+ }
+
+ if (!RNA_struct_property_is_set(op->ptr, "display_type")) {
+ sfile->params->display = sfile_udata->display_type;
+ }
+ if (!RNA_struct_property_is_set(op->ptr, "sort_method")) {
+ sfile->params->sort = sfile_udata->sort_type;
+ }
+ sfile->params->thumbnail_size = sfile_udata->thumbnail_size;
+ sfile->params->details_flags = sfile_udata->details_flags;
+
+ /* Combine flags we take from params with the flags we take from userdef. */
+ sfile->params->flag = (sfile->params->flag & ~PARAMS_FLAGS_REMEMBERED) |
+ (sfile_udata->flag & PARAMS_FLAGS_REMEMBERED);
+}
+
+/**
+ * Update the user-preference data for the file space. In fact, this also contains some
+ * non-FileSelectParams data, but it's neglectable.
+ *
+ * \param temp_win_size: If the browser was opened in a temporary window, pass its size here so we
+ * can store that in the preferences. Otherwise NULL.
+ */
+void ED_fileselect_params_to_userdef(SpaceFile *sfile, int temp_win_size[2])
+{
+ UserDef_FileSpaceData *sfile_udata_new = &U.file_space_data;
+ UserDef_FileSpaceData sfile_udata_old = U.file_space_data;
+
+ sfile_udata_new->display_type = sfile->params->display;
+ sfile_udata_new->thumbnail_size = sfile->params->thumbnail_size;
+ sfile_udata_new->sort_type = sfile->params->sort;
+ sfile_udata_new->details_flags = sfile->params->details_flags;
+ sfile_udata_new->flag = sfile->params->flag & PARAMS_FLAGS_REMEMBERED;
+
+ if (temp_win_size) {
+ sfile_udata_new->temp_win_sizex = temp_win_size[0];
+ sfile_udata_new->temp_win_sizey = temp_win_size[1];
+ }
+
+ /* Tag prefs as dirty if something has changed. */
+ if (memcmp(sfile_udata_new, &sfile_udata_old, sizeof(sfile_udata_old)) != 0) {
+ U.runtime.is_dirty = true;
+ }
+}
+
void ED_fileselect_reset_params(SpaceFile *sfile)
{
sfile->params->type = FILE_UNIX;
@@ -766,7 +809,6 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, ARegion *ar)
layout->tile_border_x * 2;
layout->flag = FILE_LAYOUT_HOR;
}
- params->display_previous = params->display;
layout->dirty = false;
}
@@ -923,6 +965,17 @@ void ED_fileselect_exit(wmWindowManager *wm, ScrArea *sa, SpaceFile *sfile)
return;
}
if (sfile->op) {
+ wmWindow *temp_win = WM_window_is_temp_screen(wm->winactive) ? wm->winactive : NULL;
+ int win_size[2];
+
+ if (temp_win) {
+ /* Get DPI/pixelsize independent size to be stored in preferences. */
+ WM_window_set_dpi(temp_win); /* Ensure the DPI is taken from the right window. */
+ win_size[0] = WM_window_pixels_x(temp_win) / UI_DPI_FAC;
+ win_size[1] = WM_window_pixels_y(temp_win) / UI_DPI_FAC;
+ }
+ ED_fileselect_params_to_userdef(sfile, temp_win ? win_size : NULL);
+
WM_event_fileselect_event(wm, sfile->op, EVT_FILESELECT_EXTERNAL_CANCEL);
sfile->op = NULL;
}
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index 3be3daa8dfb..0f957a946d9 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -676,10 +676,9 @@ typedef struct FileSelectParams {
short sort;
/** Display mode flag. */
short display;
- short display_previous;
/** Details toggles (file size, creation date, etc.) */
char details_flags;
- char _pad2;
+ char _pad2[3];
/** Filter when (flags & FILE_FILTER) is true. */
int filter;
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index 4006cbc977e..126b4638ca1 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -577,6 +577,24 @@ typedef struct UserDef_SpaceData {
char _pad0[6];
} UserDef_SpaceData;
+/**
+ * Storage for UI data that to keep it even after the window was closed. (Similar to
+ * #UserDef_SpaceData.)
+ */
+typedef struct UserDef_FileSpaceData {
+ int display_type; /* FileSelectParams.display */
+ int thumbnail_size; /* FileSelectParams.thumbnail_size */
+ int sort_type; /* FileSelectParams.sort */
+ int details_flags; /* FileSelectParams.details_flags */
+ int flag; /* FileSelectParams.flag */
+
+ char _pad[4];
+
+ /** Info used when creating the file browser in a temporary window. */
+ int temp_win_sizex;
+ int temp_win_sizey;
+} UserDef_FileSpaceData;
+
typedef struct UserDef {
/** UserDef has separate do-version handling, and can be read from other files. */
int versionfile, subversionfile;
@@ -823,6 +841,7 @@ typedef struct UserDef {
/** The UI for the user preferences. */
UserDef_SpaceData space_data;
+ UserDef_FileSpaceData file_space_data;
/** Runtime data (keep last). */
UserDef_Runtime runtime;
@@ -972,7 +991,11 @@ typedef enum eUserpref_UI_Flag {
USER_ZOOM_HORIZ = (1 << 26), /* for CONTINUE and DOLLY zoom */
USER_SPLASH_DISABLE = (1 << 27),
USER_HIDE_RECENT = (1 << 28),
- USER_SHOW_THUMBNAILS = (1 << 29),
+#ifdef DNA_DEPRECATED
+ USER_SHOW_THUMBNAILS =
+ (1 << 29), /* deprecated - We're just trying if there's much desire for this feature, or if
+ we can make it go for good. Should be cleared if so - Julian, Oct. 2019 */
+#endif
USER_SAVE_PROMPT = (1 << 30),
USER_HIDE_SYSTEM_BOOKMARKS = (1u << 31),
} eUserpref_UI_Flag;
diff --git a/source/blender/makesdna/intern/dna_defaults.c b/source/blender/makesdna/intern/dna_defaults.c
index 76d076a8638..260f1cd20f6 100644
--- a/source/blender/makesdna/intern/dna_defaults.c
+++ b/source/blender/makesdna/intern/dna_defaults.c
@@ -250,6 +250,7 @@ const void *DNA_default_table[SDNA_TYPE_MAX] = {
SDNA_DEFAULT_DECL(UserDef),
SDNA_DEFAULT_DECL(bTheme),
SDNA_DEFAULT_DECL_EX(UserDef_SpaceData, UserDef.space_data),
+ SDNA_DEFAULT_DECL_EX(UserDef_FileSpaceData, UserDef.file_space_data),
SDNA_DEFAULT_DECL_EX(WalkNavigation, UserDef.walk_navigation),
/* DNA_view3d_defaults.h */
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index bba4bc1cb54..c9b6f46ab04 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -5573,11 +5573,6 @@ static void rna_def_userdef_filepaths(BlenderRNA *brna)
RNA_def_property_ui_text(
prop, "Hide System Bookmarks", "Hide system bookmarks in the file selector");
- prop = RNA_def_property(srna, "show_thumbnails", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_SHOW_THUMBNAILS);
- RNA_def_property_ui_text(
- prop, "Show Thumbnails", "Open in thumbnail view for images and movies");
-
prop = RNA_def_property(srna, "use_relative_paths", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", USER_RELPATHS);
RNA_def_property_ui_text(
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index fb91a65a7cc..6b4327d5f44 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -2338,22 +2338,19 @@ static int wm_handler_fileselect_do(bContext *C,
int val)
{
wmWindowManager *wm = CTX_wm_manager(C);
- SpaceFile *sfile;
int action = WM_HANDLER_CONTINUE;
switch (val) {
case EVT_FILESELECT_FULL_OPEN: {
wmWindow *win = CTX_wm_window(C);
- const int sizex = 1020 * UI_DPI_FAC;
- const int sizey = 600 * UI_DPI_FAC;
ScrArea *area;
if ((area = ED_screen_temp_space_open(C,
IFACE_("Blender File View"),
WM_window_pixels_x(win) / 2,
WM_window_pixels_y(win) / 2,
- sizex,
- sizey,
+ U.file_space_data.temp_win_sizex * UI_DPI_FAC,
+ U.file_space_data.temp_win_sizey * UI_DPI_FAC,
SPACE_FILE,
U.filebrowser_display_type))) {
ARegion *region_header = BKE_area_find_region_type(area, RGN_TYPE_HEADER);
@@ -2365,10 +2362,10 @@ static int wm_handler_fileselect_do(bContext *C,
region_header->alignment = RGN_ALIGN_BOTTOM;
/* settings for filebrowser, sfile is not operator owner but sends events */
- sfile = (SpaceFile *)area->spacedata.first;
+ SpaceFile *sfile = (SpaceFile *)area->spacedata.first;
sfile->op = handler->op;
- ED_fileselect_set_params(sfile);
+ ED_fileselect_set_params_from_userdef(sfile);
}
else {
BKE_report(&wm->reports, RPT_ERROR, "Failed to open window!");
@@ -2402,6 +2399,15 @@ static int wm_handler_fileselect_do(bContext *C,
ScrArea *file_sa = screen->areabase.first;
if (screen->temp && (file_sa->spacetype == SPACE_FILE)) {
+ int win_size[2];
+
+ /* Get DPI/pixelsize independent size to be stored in preferences. */
+ WM_window_set_dpi(temp_win); /* Ensure the DPI is taken from the right window. */
+ win_size[0] = WM_window_pixels_x(temp_win) / UI_DPI_FAC;
+ win_size[1] = WM_window_pixels_y(temp_win) / UI_DPI_FAC;
+
+ ED_fileselect_params_to_userdef(file_sa->spacedata.first, win_size);
+
if (BLI_listbase_is_single(&file_sa->spacedata)) {
BLI_assert(ctx_win != temp_win);
@@ -2430,6 +2436,7 @@ static int wm_handler_fileselect_do(bContext *C,
}
if (!temp_win && ctx_sa->full) {
+ ED_fileselect_params_to_userdef(ctx_sa->spacedata.first, NULL);
ED_screen_full_prevspace(C, ctx_sa);
}
}