[Bf-blender-cvs] [d069dc9859e] filebrowser_redesign: Initially split filename and directory-path into two regions
Julian Eisel
noreply at git.blender.org
Wed Apr 24 15:16:41 CEST 2019
Commit: d069dc9859eacb06821b67a3db0ab40c2627c2ed
Author: Julian Eisel
Date: Mon Apr 1 14:48:35 2019 +0200
Branches: filebrowser_redesign
https://developer.blender.org/rBd069dc9859eacb06821b67a3db0ab40c2627c2ed
Initially split filename and directory-path into two regions
===================================================================
M release/scripts/startup/bl_ui/space_filebrowser.py
M source/blender/blenkernel/BKE_blender_version.h
M source/blender/blenloader/intern/versioning_userdef.c
M source/blender/editors/screen/area.c
M source/blender/editors/space_file/file_draw.c
M source/blender/editors/space_file/file_intern.h
M source/blender/editors/space_file/space_file.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/space_filebrowser.py b/release/scripts/startup/bl_ui/space_filebrowser.py
index 5ab4dbfd16b..d1690a1c589 100644
--- a/release/scripts/startup/bl_ui/space_filebrowser.py
+++ b/release/scripts/startup/bl_ui/space_filebrowser.py
@@ -241,6 +241,54 @@ class FILEBROWSER_PT_advanced_filter(Panel):
col.prop(params, "filter_id")
+class FILEBROWSER_PT_directory_path(Panel):
+ bl_space_type = 'FILE_BROWSER'
+ bl_region_type = 'UI'
+ bl_label = "Directory Path"
+ bl_category = "Directory Path"
+ bl_options = {'HIDE_HEADER'}
+
+ def draw(self, context):
+ layout = self.layout
+ space = context.space_data
+ params = space.params
+
+ layout.scale_x = 1.3
+ layout.scale_y = 1.3
+
+ row = layout.row()
+ # TODO proper directory input text field
+ row.prop(params, "directory", text="")
+
+
+class FILEBROWSER_PT_file_operation(Panel):
+ bl_space_type = 'FILE_BROWSER'
+ bl_region_type = 'EXECUTE'
+ bl_label = "Execute File Operation"
+ bl_options = {'HIDE_HEADER'}
+
+ @classmethod
+ def poll(cls, context):
+ return context.space_data.active_operator
+
+ def draw(self, context):
+ layout = self.layout
+ space = context.space_data
+ params = space.params
+
+ layout.scale_x = 1.3
+ layout.scale_y = 1.3
+
+ row = layout.row()
+ sub = row.row()
+ sub.prop(params, "filename", text="")
+ sub = row.row()
+ sub.ui_units_x = 5
+ # TODO change to "Open Directory"/"Parent Directory" based on highlight.
+ sub.operator("FILE_OT_execute", text=params.title)
+ sub.operator("FILE_OT_cancel", text="Cancel")
+
+
class FILEBROWSER_MT_view(Menu):
bl_label = "View"
@@ -266,6 +314,8 @@ classes = (
FILEBROWSER_PT_bookmarks,
FILEBROWSER_PT_recent_folders,
FILEBROWSER_PT_advanced_filter,
+ FILEBROWSER_PT_directory_path,
+ FILEBROWSER_PT_file_operation,
FILEBROWSER_MT_view,
)
diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h
index 9ae85725488..4c88410134c 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -24,7 +24,7 @@
* and keep comment above the defines.
* Use STRINGIFY() rather than defining with quotes */
#define BLENDER_VERSION 280
-#define BLENDER_SUBVERSION 53
+#define BLENDER_SUBVERSION 54
/* Several breakages with 280, e.g. collections vs layers */
#define BLENDER_MINVERSION 280
#define BLENDER_MINSUBVERSION 0
diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c
index 5bff0cd1c93..b709039923a 100644
--- a/source/blender/blenloader/intern/versioning_userdef.c
+++ b/source/blender/blenloader/intern/versioning_userdef.c
@@ -114,6 +114,10 @@ static void do_versions_theme(UserDef *userdef, bTheme *btheme)
FROM_DEFAULT_V4_UCHAR(space_info.info_info);
}
+ if (!USER_VERSION_ATLEAST(280, 54)) {
+ FROM_DEFAULT_V4_UCHAR(space_file.execution_buts);
+ }
+
#undef FROM_DEFAULT_V4_UCHAR
#undef USER_VERSION_ATLEAST
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 411826d79c1..2aa724728cd 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -1169,9 +1169,6 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, rct
else if (ED_area_is_global(sa)) {
prefsizey = ED_region_global_size_y();
}
- else if (ar->regiontype == RGN_TYPE_UI && sa->spacetype == SPACE_FILE) {
- prefsizey = UI_UNIT_Y * 2 + (UI_UNIT_Y / 2);
- }
else {
prefsizey = UI_DPI_FAC * (ar->sizey > 1 ? ar->sizey + 0.5f : ar->type->prefsizey);
}
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index c0aa03abece..b3f520f74d7 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -78,6 +78,7 @@ static char *file_draw_tooltip_func(bContext *UNUSED(C), void *argN, const char
return BLI_strdup(dyn_tooltip);
}
+#if 0
/* Note: This function uses pixelspace (0, 0, winx, winy), not view2d.
* The controls are laid out as follows:
*
@@ -91,7 +92,7 @@ static char *file_draw_tooltip_func(bContext *UNUSED(C), void *argN, const char
* When there isn't enough space for all controls to be shown, they are
* hidden in this order: x/-, execute/cancel, input widgets.
*/
-void file_draw_buttons(const bContext *C, ARegion *ar)
+void file_draw_filepath_buttons(const bContext *C, ARegion *ar)
{
/* Button layout. */
const int max_x = ar->winx - 10;
@@ -186,29 +187,80 @@ void file_draw_buttons(const bContext *C, ARegion *ar)
if (sfile->files && filelist_lib(sfile->files))
UI_but_flag_enable(but, UI_BUT_DISABLED);
- if ((params->flag & FILE_DIRSEL_ONLY) == 0) {
- but = uiDefBut(block, UI_BTYPE_TEXT, -1, "",
- min_x, line2_y, line2_w - chan_offs, btn_h,
- is_active_dir ? (char *)"" : params->file,
- 0.0, (float)FILE_MAXFILE, 0, 0,
- TIP_(overwrite_alert ? N_("File name, overwrite existing") : N_("File name")));
- UI_but_func_complete_set(but, autocomplete_file, NULL);
- UI_but_flag_enable(but, UI_BUT_NO_UTF8);
- UI_but_flag_disable(but, UI_BUT_UNDO);
- /* silly workaround calling NFunc to ensure this does not get called
- * immediate ui_apply_but_func but only after button deactivates */
- UI_but_funcN_set(but, file_filename_enter_handle, NULL, but);
+ /* clear func */
+ UI_block_func_set(block, NULL, NULL, NULL);
+ }
- /* check if this overrides a file and if the operator option is used */
- if (overwrite_alert) {
- UI_but_flag_enable(but, UI_BUT_REDALERT);
- }
+ UI_block_end(C, block);
+ UI_block_draw(C, block);
+}
+
+void file_draw_execute_buttons(const bContext *C, ARegion *ar)
+{
+ /* Button layout. */
+ const int max_x = ar->winx - 10;
+ const int line_y = ar->winy - (IMASEL_BUTTONS_HEIGHT / 2 + IMASEL_BUTTONS_MARGIN);
+ const int input_minw = 20;
+ const int btn_h = UI_UNIT_Y;
+ const int btn_fn_w = UI_UNIT_X;
+ const int btn_minw = 80;
+ const int btn_margin = 20;
+ const int separator = 4;
+
+ SpaceFile *sfile = CTX_wm_space_file(C);
+ FileSelectParams *params = ED_fileselect_get_params(sfile);
+ const bool is_browse_only = (sfile->op == NULL);
+
+ char uiblockstr[32];
+ int loadbutton;
+ int min_x = 10;
+ int available_w = max_x - min_x;
+ int line1_w = available_w;
+ int line2_w = available_w;
+
+ uiBlock *block;
+ uiBut *but;
+
+ /* Initialize UI block. */
+ BLI_snprintf(uiblockstr, sizeof(uiblockstr), "win %p", (void *)ar);
+ block = UI_block_begin(C, ar, uiblockstr, UI_EMBOSS);
+
+ if (is_browse_only) {
+ loadbutton = 0;
+ }
+ else {
+ const uiFontStyle *fstyle = UI_FSTYLE_WIDGET;
+ loadbutton = UI_fontstyle_string_width(fstyle, params->title) + btn_margin;
+ CLAMP_MIN(loadbutton, btn_minw);
+ if (available_w <= loadbutton + separator + input_minw) {
+ loadbutton = 0;
}
+ }
- /* clear func */
- UI_block_func_set(block, NULL, NULL, NULL);
+ const struct FileDirEntry *file = sfile->files ? filelist_file(sfile->files, params->active_file) : NULL;
+ int overwrite_alert = file_draw_check_exists(sfile);
+ const bool is_active_dir = file && (file->typeflag & FILE_TYPE_FOLDER);
+
+ if ((params->flag & FILE_DIRSEL_ONLY) == 0) {
+ but = uiDefBut(block, UI_BTYPE_TEXT, -1, "",
+ min_x, line_y, line2_w, btn_h,
+ is_active_dir ? (char *)"" : params->file,
+ 0.0, (float)FILE_MAXFILE, 0, 0,
+ TIP_(overwrite_alert ? N_("File name, overwrite existing") : N_("File name")));
+ UI_but_func_complete_set(but, autocomplete_file, NULL);
+ UI_but_flag_enable(but, UI_BUT_NO_UTF8);
+ UI_but_flag_disable(but, UI_BUT_UNDO);
+ /* silly workaround calling NFunc to ensure this does not get called
+ * immediate ui_apply_but_func but only after button deactivates */
+ UI_but_funcN_set(but, file_filename_enter_handle, NULL, but);
+
+ /* check if this overrides a file and if the operator option is used */
+ if (overwrite_alert) {
+ UI_but_flag_enable(but, UI_BUT_REDALERT);
+ }
}
+#if 0
/* Filename number increment / decrement buttons. */
if (fnumbuttons && (params->flag & FILE_DIRSEL_ONLY) == 0) {
UI_block_align_begin(block);
@@ -225,6 +277,7 @@ void file_draw_buttons(const bContext *C, ARegion *ar)
RNA_int_set(UI_but_operator_ptr_get(but), "increment", 1);
UI_block_align_end(block);
}
+#endif
/* Execute / cancel buttons. */
if (loadbutton) {
@@ -243,17 +296,18 @@ void file_draw_buttons(const bContext *C, ARegion *ar)
but = uiDefButO(
block, UI_BTYPE_BUT, "FILE_OT_execute", WM_OP_EXEC_REGION_WIN, str_exec,
- max_x - loadbutton, line1_y, loadbutton, btn_h, "");
+ max_x - loadbutton, line_y, loadbutton, btn_h, "");
/* Just a display hint. */
UI_but_flag_enable(but, UI_BUT_ACTIVE_DEFAULT);
uiDefButO(block, UI_BTYPE_BUT, "FILE_OT_cancel", WM_OP_EXEC_REGION_WIN, IFACE_("Cancel"),
- max_x - loadbutton, line2_y, loadbutton, btn_h, "");
+ max_x - loadbutton, line_y, loadbutton, btn_h, "");
}
UI_block_end(C, block);
UI_block_draw(C, block);
}
+#endif
static void draw_tile(int sx, int sy, int width, int height, int colorid, int shade)
diff --git a/source/blender/editors/space_file/file_intern.h b/source/blender/editors/space_file/file_intern.h
index 46e30e556d1..ef6a73bfac4 100644
--- a/source/blender/editors/space_file/file_intern.h
+++ b/source/blender/editors/space_file/file_intern.h
@@ -44,7 +44,10 @@ struct ARegion *file_tools_region(struct ScrArea *sa);
#define SMALL_SIZE_CHECK(_size) ((_size) < 64) /* Related to FileSelectParams.thumbnail_size. */
-void file_draw_buttons(const bContext *C, ARegion *ar);
+#if 0
+void file_draw_filepath_buttons(const bContext *C, ARegion *ar);
+void file_draw_execute_buttons(const bContext *C, ARegion *ar);
+#endif
void file_calc_previews(const bContext *C, ARegion *ar);
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list