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:
-rw-r--r--release/scripts/startup/bl_ui/space_filebrowser.py2
-rw-r--r--source/blender/editors/include/ED_fileselect.h7
-rw-r--r--source/blender/editors/include/UI_interface.h4
-rw-r--r--source/blender/editors/interface/interface_templates.c11
-rw-r--r--source/blender/editors/space_file/file_draw.c46
-rw-r--r--source/blender/makesrna/intern/rna_ui_api.c7
6 files changed, 76 insertions, 1 deletions
diff --git a/release/scripts/startup/bl_ui/space_filebrowser.py b/release/scripts/startup/bl_ui/space_filebrowser.py
index 414e0bf0b95..f03699ad879 100644
--- a/release/scripts/startup/bl_ui/space_filebrowser.py
+++ b/release/scripts/startup/bl_ui/space_filebrowser.py
@@ -391,7 +391,7 @@ class FILEBROWSER_PT_directory_path(Panel):
row.operator("file.directory_new", icon='NEWFOLDER', text="")
subrow = row.row()
- subrow.prop(params, "directory", text="")
+ subrow.template_file_select_path(params)
subrow = row.row()
subrow.scale_x = 0.5
diff --git a/source/blender/editors/include/ED_fileselect.h b/source/blender/editors/include/ED_fileselect.h
index fd7aada1b9f..96d83dedc0d 100644
--- a/source/blender/editors/include/ED_fileselect.h
+++ b/source/blender/editors/include/ED_fileselect.h
@@ -25,11 +25,13 @@
#define __ED_FILESELECT_H__
struct ARegion;
+struct bScreen;
struct FileSelectParams;
struct ScrArea;
struct SpaceFile;
struct bContext;
struct wmWindowManager;
+struct uiBlock;
#define FILE_LAYOUT_HOR 1
#define FILE_LAYOUT_VER 2
@@ -133,6 +135,11 @@ void ED_file_read_bookmarks(void);
void ED_file_change_dir(struct bContext *C);
+void ED_file_path_button(struct bScreen *screen,
+ const struct SpaceFile *sfile,
+ struct FileSelectParams *params,
+ struct uiBlock *block);
+
/* File menu stuff */
/* FSMenuEntry's without paths indicate separators */
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 529f70193c3..da4097bb544 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -32,6 +32,7 @@
struct ARegion;
struct AutoComplete;
+struct FileSelectParams;
struct ID;
struct IDProperty;
struct ImBuf;
@@ -2082,6 +2083,9 @@ void uiTemplateColormanagedViewSettings(struct uiLayout *layout,
const char *propname);
int uiTemplateRecentFiles(struct uiLayout *layout, int rows);
+void uiTemplateFileSelectPath(uiLayout *layout,
+ struct bContext *C,
+ struct FileSelectParams *params);
/* items */
void uiItemO(uiLayout *layout, const char *name, int icon, const char *opname);
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 62eebfdd3c7..0dfa6e9ddf5 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -76,6 +76,7 @@
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
+#include "ED_fileselect.h"
#include "ED_screen.h"
#include "ED_object.h"
#include "ED_render.h"
@@ -6779,3 +6780,13 @@ int uiTemplateRecentFiles(uiLayout *layout, int rows)
return i;
}
+
+/******************************* FileSelectParams Path Button *******************************/
+
+void uiTemplateFileSelectPath(uiLayout *layout, bContext *C, FileSelectParams *params)
+{
+ bScreen *screen = CTX_wm_screen(C);
+ SpaceFile *sfile = CTX_wm_space_file(C);
+
+ ED_file_path_button(screen, sfile, params, uiLayoutGetBlock(layout));
+}
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index 0083fc244d8..722cb885614 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -71,6 +71,52 @@
#include "file_intern.h" // own include
+void ED_file_path_button(bScreen *screen,
+ const SpaceFile *sfile,
+ FileSelectParams *params,
+ uiBlock *block)
+{
+ PointerRNA params_rna_ptr;
+ uiBut *but;
+
+ RNA_pointer_create(&screen->id, &RNA_FileSelectParams, params, &params_rna_ptr);
+
+ /* callbacks for operator check functions */
+ UI_block_func_set(block, file_draw_check_cb, NULL, NULL);
+
+ but = uiDefButR(block,
+ UI_BTYPE_TEXT,
+ -1,
+ "",
+ 0,
+ 0,
+ UI_UNIT_X * 10,
+ UI_UNIT_Y,
+ &params_rna_ptr,
+ "directory",
+ 0,
+ 0.0f,
+ (float)FILE_MAX,
+ 0.0f,
+ 0.0f,
+ TIP_("File path"));
+
+ BLI_assert(!UI_but_flag_is_set(but, UI_BUT_UNDO));
+ BLI_assert(!UI_but_is_utf8(but));
+
+ UI_but_func_complete_set(but, autocomplete_directory, NULL);
+ UI_but_funcN_set(but, file_directory_enter_handle, NULL, but);
+
+ /* TODO, directory editing is non-functional while a library is loaded
+ * until this is properly supported just disable it. */
+ if (sfile && sfile->files && filelist_lib(sfile->files)) {
+ UI_but_flag_enable(but, UI_BUT_DISABLED);
+ }
+
+ /* clear func */
+ UI_block_func_set(block, NULL, NULL, NULL);
+}
+
/* Dummy helper - we need dynamic tooltips here. */
static char *file_draw_tooltip_func(bContext *UNUSED(C), void *argN, const char *UNUSED(tip))
{
diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c
index c8b039bd2d6..74d1743dfc1 100644
--- a/source/blender/makesrna/intern/rna_ui_api.c
+++ b/source/blender/makesrna/intern/rna_ui_api.c
@@ -1519,6 +1519,13 @@ void RNA_api_ui_layout(StructRNA *srna)
RNA_def_int(func, "rows", 5, 1, INT_MAX, "", "Maximum number of items to show", 1, INT_MAX);
parm = RNA_def_int(func, "found", 0, 0, INT_MAX, "", "Number of items drawn", 0, INT_MAX);
RNA_def_function_return(func, parm);
+
+ func = RNA_def_function(srna, "template_file_select_path", "uiTemplateFileSelectPath");
+ RNA_def_function_ui_description(func,
+ "Item. A text button to set the active file browser path.");
+ parm = RNA_def_pointer(func, "params", "FileSelectParams", "", "");
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+ RNA_def_function_flag(func, FUNC_USE_CONTEXT);
}
#endif