== filebrowser ==
Bringing back missing feature: Create new directory by typing a not existing name into the directory button. Note: Small issue still with autocomplete -> if typing the new directory directly after autocomplete, it doesn't execute the operator yet. Also fixed some minor compile/cleanup issues with warning about signed/unsigned comparison and missing header.
This commit is contained in:
@@ -409,8 +409,8 @@ IF(WIN32)
|
||||
SET(LLIBS kernel32 user32 gdi32 comdlg32 advapi32 shell32 ole32 oleaut32 uuid ws2_32 vfw32 winmm)
|
||||
ENDIF(CMAKE_CL_64)
|
||||
|
||||
SET(CMAKE_CXX_FLAGS "/D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /we4013 /wd4800 /wd4244 /wd4305 /wd4065 /wd4267" CACHE STRING "MSVC MT C++ flags " FORCE)
|
||||
SET(CMAKE_C_FLAGS "/D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /we4013 /wd4800 /wd4244 /wd4305 /wd4065 /wd4267" CACHE STRING "MSVC MT C++ flags " FORCE)
|
||||
SET(CMAKE_CXX_FLAGS "/D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /we4013 /wd4018 /wd4800 /wd4244 /wd4305 /wd4065 /wd4267" CACHE STRING "MSVC MT C++ flags " FORCE)
|
||||
SET(CMAKE_C_FLAGS "/D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /we4013 /wd4018 /wd4800 /wd4244 /wd4305 /wd4065 /wd4267" CACHE STRING "MSVC MT C++ flags " FORCE)
|
||||
|
||||
IF(CMAKE_CL_64)
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
|
||||
|
@@ -400,6 +400,7 @@ uiBut *uiDefButC(uiBlock *block, int type, int retval, char *str, short x1, shor
|
||||
uiBut *uiDefButBitC(uiBlock *block, int type, int bit, int retval, char *str, short x1, short y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, char *tip);
|
||||
uiBut *uiDefButR(uiBlock *block, int type, int retval, char *str, short x1, short y1, short x2, short y2, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, char *tip);
|
||||
uiBut *uiDefButO(uiBlock *block, int type, char *opname, int opcontext, char *str, short x1, short y1, short x2, short y2, char *tip);
|
||||
uiBut *uiDefButTextO(uiBlock *block, int type, char *opname, int opcontext, char *str, short x1, short y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, char *tip);
|
||||
|
||||
uiBut *uiDefIconBut(uiBlock *block,
|
||||
int type, int retval, int icon,
|
||||
|
@@ -2634,6 +2634,35 @@ uiBut *ui_def_but_operator(uiBlock *block, int type, char *opname, int opcontext
|
||||
return but;
|
||||
}
|
||||
|
||||
uiBut *ui_def_but_operator_text(uiBlock *block, int type, char *opname, int opcontext, char *str, short x1, short y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, char *tip)
|
||||
{
|
||||
uiBut *but;
|
||||
wmOperatorType *ot;
|
||||
|
||||
ot= WM_operatortype_find(opname, 0);
|
||||
|
||||
if(!str) {
|
||||
if(ot) str= ot->name;
|
||||
else str= opname;
|
||||
}
|
||||
|
||||
if ((!tip || tip[0]=='\0') && ot && ot->description) {
|
||||
tip= ot->description;
|
||||
}
|
||||
|
||||
but= ui_def_but(block, type, -1, str, x1, y1, x2, y2, poin, min, max, a1, a2, tip);
|
||||
but->optype= ot;
|
||||
but->opcontext= opcontext;
|
||||
|
||||
if(!ot) {
|
||||
but->flag |= UI_BUT_DISABLED;
|
||||
but->lock = 1;
|
||||
but->lockstr = "";
|
||||
}
|
||||
|
||||
return but;
|
||||
}
|
||||
|
||||
uiBut *uiDefBut(uiBlock *block, int type, int retval, char *str, short x1, short y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, char *tip)
|
||||
{
|
||||
uiBut *but= ui_def_but(block, type, retval, str, x1, y1, x2, y2, poin, min, max, a1, a2, tip);
|
||||
@@ -2805,6 +2834,16 @@ uiBut *uiDefButO(uiBlock *block, int type, char *opname, int opcontext, char *st
|
||||
return but;
|
||||
}
|
||||
|
||||
uiBut *uiDefButTextO(uiBlock *block, int type, char *opname, int opcontext, char *str, short x1, short y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, char *tip)
|
||||
{
|
||||
uiBut *but= ui_def_but_operator_text(block, type, opname, opcontext, str, x1, y1, x2, y2, poin, min, max, a1, a2, tip);
|
||||
|
||||
if(but)
|
||||
ui_check_but(but);
|
||||
|
||||
return but;
|
||||
}
|
||||
|
||||
/* if a1==1.0 then a2 is an extra icon blending factor (alpha 0.0 - 1.0) */
|
||||
uiBut *uiDefIconBut(uiBlock *block, int type, int retval, int icon, short x1, short y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, char *tip)
|
||||
{
|
||||
|
@@ -177,7 +177,7 @@ void file_draw_buttons(const bContext *C, ARegion *ar)
|
||||
/* callbacks for operator check functions */
|
||||
uiBlockSetFunc(block, file_draw_check_cb, NULL, NULL);
|
||||
|
||||
but = uiDefBut(block, TEX, B_FS_DIRNAME, "",
|
||||
but = uiDefButTextO(block, TEX, "FILE_OT_directory", 0, "",
|
||||
min_x, line1_y, line1_w-chan_offs, btn_h,
|
||||
params->dir, 0.0, (float)FILE_MAX-1, 0, 0,
|
||||
"File path.");
|
||||
|
@@ -66,6 +66,7 @@ void FILE_OT_cancel(struct wmOperatorType *ot);
|
||||
void FILE_OT_parent(struct wmOperatorType *ot);
|
||||
void FILE_OT_directory_new(struct wmOperatorType *ot);
|
||||
void FILE_OT_filename(struct wmOperatorType *ot);
|
||||
void FILE_OT_directory(struct wmOperatorType *ot);
|
||||
void FILE_OT_previous(struct wmOperatorType *ot);
|
||||
void FILE_OT_next(struct wmOperatorType *ot);
|
||||
void FILE_OT_refresh(struct wmOperatorType *ot);
|
||||
|
@@ -947,6 +947,8 @@ int file_directory_new_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
char name[FILE_MAXFILE];
|
||||
char path[FILE_MAX];
|
||||
int generate_name= 1;
|
||||
|
||||
SpaceFile *sfile= CTX_wm_space_file(C);
|
||||
|
||||
if(!sfile->params) {
|
||||
@@ -954,13 +956,22 @@ int file_directory_new_exec(bContext *C, wmOperator *op)
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
/* create a new, non-existing folder name */
|
||||
if (!new_folder_path(sfile->params->dir, path, name)) {
|
||||
BKE_report(op->reports,RPT_ERROR, "Couldn't create new folder name.");
|
||||
return OPERATOR_CANCELLED;
|
||||
path[0] = '\0';
|
||||
|
||||
if(RNA_struct_find_property(op->ptr, "directory")) {
|
||||
RNA_string_get(op->ptr, "directory", path);
|
||||
if (path[0] != '\0') generate_name= 0;
|
||||
}
|
||||
|
||||
/* rename the file */
|
||||
|
||||
if (generate_name) {
|
||||
/* create a new, non-existing folder name */
|
||||
if (!new_folder_path(sfile->params->dir, path, name)) {
|
||||
BKE_report(op->reports,RPT_ERROR, "Couldn't create new folder name.");
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
}
|
||||
|
||||
/* create the file */
|
||||
BLI_recurdir_fileops(path);
|
||||
|
||||
if (!BLI_exists(path)) {
|
||||
@@ -994,9 +1005,13 @@ void FILE_OT_directory_new(struct wmOperatorType *ot)
|
||||
ot->invoke= WM_operator_confirm;
|
||||
ot->exec= file_directory_new_exec;
|
||||
ot->poll= ED_operator_file_active; /* <- important, handler is on window level */
|
||||
|
||||
RNA_def_string_dir_path(ot->srna, "directory", "", FILE_MAX, "Directory", "Name of new directory");
|
||||
|
||||
}
|
||||
|
||||
int file_directory_exec(bContext *C, wmOperator *UNUSED(unused))
|
||||
|
||||
static void file_expand_directory(bContext *C)
|
||||
{
|
||||
SpaceFile *sfile= CTX_wm_space_file(C);
|
||||
|
||||
@@ -1011,6 +1026,39 @@ int file_directory_exec(bContext *C, wmOperator *UNUSED(unused))
|
||||
if (sfile->params->dir[0] == '\0')
|
||||
get_default_root(sfile->params->dir);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
int file_directory_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
|
||||
{
|
||||
SpaceFile *sfile= CTX_wm_space_file(C);
|
||||
|
||||
if(sfile->params) {
|
||||
file_expand_directory(C);
|
||||
|
||||
if (!BLI_exists(sfile->params->dir)) {
|
||||
return WM_operator_confirm_message(C, op, "Create new directory?");
|
||||
}
|
||||
|
||||
return file_directory_exec(C, op);
|
||||
}
|
||||
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int file_directory_exec(bContext *C, wmOperator *UNUSED(unused))
|
||||
{
|
||||
SpaceFile *sfile= CTX_wm_space_file(C);
|
||||
|
||||
if(sfile->params) {
|
||||
file_expand_directory(C);
|
||||
|
||||
if (!BLI_exists(sfile->params->dir)) {
|
||||
BLI_recurdir_fileops(sfile->params->dir);
|
||||
}
|
||||
|
||||
BLI_cleanup_dir(G.main->name, sfile->params->dir);
|
||||
BLI_add_slash(sfile->params->dir);
|
||||
file_change_dir(C, 1);
|
||||
@@ -1037,6 +1085,18 @@ int file_filename_exec(bContext *C, wmOperator *UNUSED(unused))
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void FILE_OT_directory(struct wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Enter Directory Name";
|
||||
ot->description= "Enter a directory name";
|
||||
ot->idname= "FILE_OT_directory";
|
||||
|
||||
/* api callbacks */
|
||||
ot->invoke= file_directory_invoke;
|
||||
ot->exec= file_directory_exec;
|
||||
ot->poll= ED_operator_file_active; /* <- important, handler is on window level */
|
||||
}
|
||||
|
||||
void FILE_OT_refresh(struct wmOperatorType *ot)
|
||||
{
|
||||
|
@@ -377,6 +377,7 @@ void file_operatortypes(void)
|
||||
WM_operatortype_append(FILE_OT_delete);
|
||||
WM_operatortype_append(FILE_OT_rename);
|
||||
WM_operatortype_append(FILE_OT_smoothscroll);
|
||||
WM_operatortype_append(FILE_OT_directory);
|
||||
}
|
||||
|
||||
/* NOTE: do not add .blend file reading on this level */
|
||||
|
@@ -61,6 +61,9 @@
|
||||
#include <Movies.h>
|
||||
#include <QuickTimeComponents.h>
|
||||
#include <TextUtils.h>
|
||||
#include <string.h>
|
||||
#include <memory.h>
|
||||
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#ifdef __APPLE__
|
||||
|
Reference in New Issue
Block a user