forked from bartvdbraak/blender
2.5: File browser
* Side panels now use list widgets. * Enabled theme colors for side panel. * Add button in bookmarks panel. * Operator panel title now uses operator name. * For unix, added / to system, and home and desktop to bookmarks. * For opening fileselect with filter, cleaned up the code a bit, adding WM_operator_properties_filesel instead of duplicating code. * Also added filter for all operators calling fileselect, only image and file open did it before. * Hide . files by default, and also hide files ending with ~. * Added back .. (but not .) in the file list, I really missed this. * File highlight now only happens when you're actually over a file, instead staying after you move the mouse away. * Fix some redraw/refresh issues.
This commit is contained in:
parent
74e4ad20c9
commit
aa44603146
@ -218,7 +218,7 @@ void BLI_builddir(char *dirname, char *relname)
|
||||
{
|
||||
struct dirent *fname;
|
||||
struct dirlink *dlink;
|
||||
int rellen, newnum = 0;
|
||||
int rellen, newnum = 0, len;
|
||||
char buf[256];
|
||||
DIR *dir;
|
||||
|
||||
@ -237,13 +237,11 @@ void BLI_builddir(char *dirname, char *relname)
|
||||
|
||||
if ( (dir = (DIR *)opendir(".")) ){
|
||||
while ((fname = (struct dirent*) readdir(dir)) != NULL) {
|
||||
len= strlen(fname->d_name);
|
||||
|
||||
if(hide_dot && fname->d_name[0]=='.' && fname->d_name[1]!='.' && fname->d_name[1]!=0) {
|
||||
}
|
||||
else if ( ( (fname->d_name[0] == '.') && (fname->d_name[1] == 0) ) ||
|
||||
( (fname->d_name[0] == '.') && (fname->d_name[1] == '.') && (fname->d_name[2] == 0)) ) {
|
||||
/* ignore '.' and '..' */
|
||||
}
|
||||
if(hide_dot && fname->d_name[0]=='.' && fname->d_name[1]!='.' && fname->d_name[1]!=0); /* ignore .file */
|
||||
else if(hide_dot && len && fname->d_name[len-1]=='~'); /* ignore file~ */
|
||||
else if (((fname->d_name[0] == '.') && (fname->d_name[1] == 0) )); /* ignore . */
|
||||
else {
|
||||
dlink = (struct dirlink *)malloc(sizeof(struct dirlink));
|
||||
if (dlink){
|
||||
|
@ -416,7 +416,7 @@ void FONT_OT_file_paste(wmOperatorType *ot)
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
|
||||
/* properties */
|
||||
RNA_def_string_file_path(ot->srna, "filename", "", 0, "Filename", "File path of text file to load.");
|
||||
WM_operator_properties_filesel(ot, FOLDERFILE|TEXTFILE);
|
||||
}
|
||||
|
||||
/******************* paste buffer operator ********************/
|
||||
|
@ -173,7 +173,7 @@ void SCREEN_OT_screenshot(wmOperatorType *ot)
|
||||
|
||||
ot->flag= 0;
|
||||
|
||||
RNA_def_property(ot->srna, "filename", PROP_STRING, PROP_FILEPATH);
|
||||
WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE);
|
||||
RNA_def_boolean(ot->srna, "full", 1, "Full Screen", "");
|
||||
}
|
||||
|
||||
|
@ -153,7 +153,7 @@ void file_draw_buttons(const bContext *C, ARegion *ar)
|
||||
|
||||
uiBut* but;
|
||||
uiBlock* block;
|
||||
SpaceFile* sfile = (SpaceFile*) CTX_wm_space_data(C);
|
||||
SpaceFile* sfile = CTX_wm_space_file(C);
|
||||
FileSelectParams* params = ED_fileselect_get_params(sfile);
|
||||
|
||||
/* Initialize UI block. */
|
||||
@ -345,7 +345,7 @@ static void file_draw_string(short sx, short sy, const char* string, float width
|
||||
|
||||
void file_calc_previews(const bContext *C, ARegion *ar)
|
||||
{
|
||||
SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
|
||||
SpaceFile *sfile= CTX_wm_space_file(C);
|
||||
View2D *v2d= &ar->v2d;
|
||||
|
||||
ED_fileselect_init_layout(sfile, ar);
|
||||
@ -354,7 +354,7 @@ void file_calc_previews(const bContext *C, ARegion *ar)
|
||||
|
||||
void file_draw_previews(const bContext *C, ARegion *ar)
|
||||
{
|
||||
SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
|
||||
SpaceFile *sfile= CTX_wm_space_file(C);
|
||||
FileSelectParams* params= ED_fileselect_get_params(sfile);
|
||||
FileLayout* layout= ED_fileselect_get_layout(sfile, ar);
|
||||
View2D *v2d= &ar->v2d;
|
||||
@ -517,7 +517,7 @@ static void renamebutton_cb(bContext *C, void *arg1, char *oldname)
|
||||
|
||||
void file_draw_list(const bContext *C, ARegion *ar)
|
||||
{
|
||||
SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
|
||||
SpaceFile *sfile= CTX_wm_space_file(C);
|
||||
FileSelectParams* params = ED_fileselect_get_params(sfile);
|
||||
FileLayout* layout= ED_fileselect_get_layout(sfile, ar);
|
||||
View2D *v2d= &ar->v2d;
|
||||
|
@ -143,14 +143,20 @@ static FileSelect file_select(SpaceFile* sfile, ARegion* ar, const rcti* rect, s
|
||||
params->active_file = last_file;
|
||||
|
||||
if(file && S_ISDIR(file->type)) {
|
||||
/* the path is too long! */
|
||||
if (strlen(params->dir) + strlen(file->relname) >= FILE_MAX )
|
||||
/* the path is too long and we are not going up! */
|
||||
if (strcmp(file->relname, "..") && strlen(params->dir) + strlen(file->relname) >= FILE_MAX )
|
||||
{
|
||||
// XXX error("Path too long, cannot enter this directory");
|
||||
} else {
|
||||
BLI_cleanup_dir(G.sce, params->dir);
|
||||
strcat(params->dir, file->relname);
|
||||
BLI_add_slash(params->dir);
|
||||
if (strcmp(file->relname, "..")==0) {
|
||||
/* avoids /../../ */
|
||||
BLI_parent_dir(params->dir);
|
||||
} else {
|
||||
BLI_cleanup_dir(G.sce, params->dir);
|
||||
strcat(params->dir, file->relname);
|
||||
BLI_add_slash(params->dir);
|
||||
}
|
||||
|
||||
params->file[0] = '\0';
|
||||
file_change_dir(sfile);
|
||||
retval = FILE_SELECT_DIR;
|
||||
@ -172,7 +178,7 @@ static FileSelect file_select(SpaceFile* sfile, ARegion* ar, const rcti* rect, s
|
||||
static int file_border_select_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
ARegion *ar= CTX_wm_region(C);
|
||||
SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
|
||||
SpaceFile *sfile= CTX_wm_space_file(C);
|
||||
short val;
|
||||
rcti rect;
|
||||
|
||||
@ -216,24 +222,31 @@ void FILE_OT_select_border(wmOperatorType *ot)
|
||||
static int file_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
ARegion *ar= CTX_wm_region(C);
|
||||
SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
|
||||
SpaceFile *sfile= CTX_wm_space_file(C);
|
||||
short val;
|
||||
rcti rect;
|
||||
|
||||
if(ar->regiontype != RGN_TYPE_WINDOW)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
rect.xmin = rect.xmax = event->x - ar->winrct.xmin;
|
||||
rect.ymin = rect.ymax = event->y - ar->winrct.ymin;
|
||||
val = event->val;
|
||||
|
||||
if (BLI_in_rcti(&ar->v2d.mask, rect.xmin, rect.ymin)) {
|
||||
if(!BLI_in_rcti(&ar->v2d.mask, rect.xmin, rect.ymin))
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
/* single select, deselect all selected first */
|
||||
file_deselect_all(sfile);
|
||||
|
||||
if (FILE_SELECT_DIR == file_select(sfile, ar, &rect, val ))
|
||||
WM_event_add_notifier(C, NC_FILE|ND_FILELIST, NULL);
|
||||
else
|
||||
WM_event_add_notifier(C, NC_FILE|ND_PARAMS, NULL);
|
||||
|
||||
WM_event_add_mousemove(C); /* for directory changes */
|
||||
WM_event_add_notifier(C, NC_FILE|ND_PARAMS, NULL);
|
||||
|
||||
/* single select, deselect all selected first */
|
||||
file_deselect_all(sfile);
|
||||
if (FILE_SELECT_DIR == file_select(sfile, ar, &rect, val )) {
|
||||
WM_event_add_notifier(C, NC_FILE|ND_FILELIST, NULL);
|
||||
} else {
|
||||
WM_event_add_notifier(C, NC_FILE|ND_PARAMS, NULL);
|
||||
}
|
||||
}
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
@ -254,7 +267,7 @@ void FILE_OT_select(wmOperatorType *ot)
|
||||
static int file_select_all_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
|
||||
SpaceFile *sfile= CTX_wm_space_file(C);
|
||||
int numfiles = filelist_numfiles(sfile->files);
|
||||
int i;
|
||||
int select = 1;
|
||||
@ -299,7 +312,7 @@ void FILE_OT_select_all_toggle(wmOperatorType *ot)
|
||||
|
||||
static int bookmark_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
|
||||
SpaceFile *sfile= CTX_wm_space_file(C);
|
||||
|
||||
if(RNA_struct_find_property(op->ptr, "dir")) {
|
||||
char entry[256];
|
||||
@ -333,7 +346,7 @@ void FILE_OT_select_bookmark(wmOperatorType *ot)
|
||||
static int bookmark_add_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
|
||||
SpaceFile *sfile= CTX_wm_space_file(C);
|
||||
struct FSMenu* fsmenu = fsmenu_get();
|
||||
struct FileSelectParams* params= ED_fileselect_get_params(sfile);
|
||||
|
||||
@ -398,7 +411,7 @@ void FILE_OT_delete_bookmark(wmOperatorType *ot)
|
||||
static int loadimages_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
|
||||
SpaceFile *sfile= CTX_wm_space_file(C);
|
||||
if (sfile->files) {
|
||||
filelist_loadimage_timer(sfile->files);
|
||||
if (filelist_changed(sfile->files)) {
|
||||
@ -425,31 +438,41 @@ void FILE_OT_loadimages(wmOperatorType *ot)
|
||||
int file_hilight_set(SpaceFile *sfile, ARegion *ar, int mx, int my)
|
||||
{
|
||||
FileSelectParams* params;
|
||||
int numfiles, actfile;
|
||||
int numfiles, actfile, origfile;
|
||||
|
||||
if(sfile==NULL || sfile->files==NULL) return 0;
|
||||
|
||||
|
||||
numfiles = filelist_numfiles(sfile->files);
|
||||
params = ED_fileselect_get_params(sfile);
|
||||
|
||||
actfile = find_file_mouse(sfile, ar, mx , my, 0);
|
||||
|
||||
if (params && (actfile >= 0) && (actfile < numfiles) ) {
|
||||
params->active_file=actfile;
|
||||
return 1;
|
||||
}
|
||||
params->active_file= -1;
|
||||
return 0;
|
||||
origfile= params->active_file;
|
||||
|
||||
mx -= ar->winrct.xmin;
|
||||
my -= ar->winrct.ymin;
|
||||
|
||||
if(BLI_in_rcti(&ar->v2d.mask, mx, my)) {
|
||||
actfile = find_file_mouse(sfile, ar, mx , my, 0);
|
||||
|
||||
if((actfile >= 0) && (actfile < numfiles))
|
||||
params->active_file=actfile;
|
||||
else
|
||||
params->active_file= -1;
|
||||
}
|
||||
else
|
||||
params->active_file= -1;
|
||||
|
||||
return (params->active_file != origfile);
|
||||
}
|
||||
|
||||
static int file_highlight_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
ARegion *ar= CTX_wm_region(C);
|
||||
SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
|
||||
|
||||
if( file_hilight_set(sfile, ar, event->x - ar->winrct.xmin, event->y - ar->winrct.ymin)) {
|
||||
ED_area_tag_redraw(CTX_wm_area(C));
|
||||
}
|
||||
SpaceFile *sfile= CTX_wm_space_file(C);
|
||||
|
||||
if(!file_hilight_set(sfile, ar, event->x, event->y))
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
ED_area_tag_redraw(CTX_wm_area(C));
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@ -467,7 +490,7 @@ void FILE_OT_highlight(struct wmOperatorType *ot)
|
||||
|
||||
int file_cancel_exec(bContext *C, wmOperator *unused)
|
||||
{
|
||||
SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
|
||||
SpaceFile *sfile= CTX_wm_space_file(C);
|
||||
|
||||
folderlist_free(sfile->folders_prev);
|
||||
folderlist_free(sfile->folders_next);
|
||||
@ -492,7 +515,7 @@ void FILE_OT_cancel(struct wmOperatorType *ot)
|
||||
/* sends events now, so things get handled on windowqueue level */
|
||||
int file_exec(bContext *C, wmOperator *unused)
|
||||
{
|
||||
SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
|
||||
SpaceFile *sfile= CTX_wm_space_file(C);
|
||||
char name[FILE_MAX];
|
||||
|
||||
if(sfile->op) {
|
||||
@ -559,7 +582,7 @@ void FILE_OT_exec(struct wmOperatorType *ot)
|
||||
|
||||
int file_parent_exec(bContext *C, wmOperator *unused)
|
||||
{
|
||||
SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
|
||||
SpaceFile *sfile= CTX_wm_space_file(C);
|
||||
|
||||
if(sfile->params) {
|
||||
if (BLI_has_parent(sfile->params->dir)) {
|
||||
@ -589,7 +612,7 @@ void FILE_OT_parent(struct wmOperatorType *ot)
|
||||
|
||||
int file_refresh_exec(bContext *C, wmOperator *unused)
|
||||
{
|
||||
SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
|
||||
SpaceFile *sfile= CTX_wm_space_file(C);
|
||||
|
||||
file_change_dir(sfile);
|
||||
|
||||
@ -612,7 +635,7 @@ void FILE_OT_previous(struct wmOperatorType *ot)
|
||||
|
||||
int file_previous_exec(bContext *C, wmOperator *unused)
|
||||
{
|
||||
SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
|
||||
SpaceFile *sfile= CTX_wm_space_file(C);
|
||||
|
||||
if(sfile->params) {
|
||||
if (!sfile->folders_next)
|
||||
@ -642,7 +665,7 @@ void FILE_OT_next(struct wmOperatorType *ot)
|
||||
|
||||
int file_next_exec(bContext *C, wmOperator *unused)
|
||||
{
|
||||
SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
|
||||
SpaceFile *sfile= CTX_wm_space_file(C);
|
||||
if(sfile->params) {
|
||||
if (!sfile->folders_next)
|
||||
sfile->folders_next = folderlist_new();
|
||||
@ -666,7 +689,7 @@ int file_directory_new_exec(bContext *C, wmOperator *unused)
|
||||
char tmpdir[FILE_MAXFILE];
|
||||
int i = 1;
|
||||
|
||||
SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
|
||||
SpaceFile *sfile= CTX_wm_space_file(C);
|
||||
|
||||
if(sfile->params) {
|
||||
|
||||
@ -706,7 +729,7 @@ int file_directory_exec(bContext *C, wmOperator *unused)
|
||||
{
|
||||
char tmpstr[FILE_MAX];
|
||||
|
||||
SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
|
||||
SpaceFile *sfile= CTX_wm_space_file(C);
|
||||
|
||||
if(sfile->params) {
|
||||
|
||||
@ -741,7 +764,7 @@ int file_directory_exec(bContext *C, wmOperator *unused)
|
||||
|
||||
int file_filename_exec(bContext *C, wmOperator *unused)
|
||||
{
|
||||
SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
|
||||
SpaceFile *sfile= CTX_wm_space_file(C);
|
||||
|
||||
if(sfile->params) {
|
||||
if (file_select_match(sfile, sfile->params->file))
|
||||
@ -768,7 +791,7 @@ void FILE_OT_refresh(struct wmOperatorType *ot)
|
||||
|
||||
int file_hidedot_exec(bContext *C, wmOperator *unused)
|
||||
{
|
||||
SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
|
||||
SpaceFile *sfile= CTX_wm_space_file(C);
|
||||
|
||||
if(sfile->params) {
|
||||
sfile->params->flag ^= FILE_HIDE_DOT;
|
||||
@ -849,7 +872,7 @@ void FILE_OT_bookmark_toggle(struct wmOperatorType *ot)
|
||||
|
||||
int file_filenum_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
|
||||
SpaceFile *sfile= CTX_wm_space_file(C);
|
||||
|
||||
int inc = RNA_int_get(op->ptr, "increment");
|
||||
if(sfile->params && (inc != 0)) {
|
||||
@ -909,7 +932,7 @@ void FILE_OT_rename(struct wmOperatorType *ot)
|
||||
int file_delete_poll(bContext *C)
|
||||
{
|
||||
int poll = ED_operator_file_active(C);
|
||||
SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
|
||||
SpaceFile *sfile= CTX_wm_space_file(C);
|
||||
struct direntry* file;
|
||||
|
||||
if (sfile->params) {
|
||||
@ -929,7 +952,7 @@ int file_delete_poll(bContext *C)
|
||||
int file_delete_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
char str[FILE_MAX];
|
||||
SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
|
||||
SpaceFile *sfile= CTX_wm_space_file(C);
|
||||
struct direntry* file;
|
||||
|
||||
|
||||
|
@ -44,97 +44,150 @@
|
||||
#include "UI_resources.h"
|
||||
#include "UI_view2d.h"
|
||||
|
||||
#include "WM_api.h"
|
||||
#include "WM_types.h"
|
||||
|
||||
#include "file_intern.h"
|
||||
#include "fsmenu.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
static void do_file_panel_events(bContext *C, void *arg, int event)
|
||||
static void file_panel_cb(bContext *C, void *arg_entry, void *arg_unused)
|
||||
{
|
||||
PointerRNA ptr;
|
||||
char *entry= (char*)arg_entry;
|
||||
|
||||
WM_operator_properties_create(&ptr, "FILE_OT_select_bookmark");
|
||||
RNA_string_set(&ptr, "dir", entry);
|
||||
WM_operator_name_call(C, "FILE_OT_select_bookmark", WM_OP_INVOKE_REGION_WIN, &ptr);
|
||||
WM_operator_properties_free(&ptr);
|
||||
}
|
||||
|
||||
static void file_panel_category(const bContext *C, Panel *pa, FSMenuCategory category, int icon, int allow_delete)
|
||||
static void file_panel_category(const bContext *C, Panel *pa, FSMenuCategory category, short *nr, int icon, int allow_delete)
|
||||
{
|
||||
SpaceFile *sfile= CTX_wm_space_file(C);
|
||||
uiBlock *block;
|
||||
uiBut *but;
|
||||
uiLayout *box, *col;
|
||||
struct FSMenu* fsmenu = fsmenu_get();
|
||||
int nentries = fsmenu_get_nentries(fsmenu, category);
|
||||
int i;
|
||||
char *curdir= (sfile->params)? sfile->params->dir: "";
|
||||
int i, nentries = fsmenu_get_nentries(fsmenu, category);
|
||||
|
||||
/* reset each time */
|
||||
*nr= -1;
|
||||
|
||||
/* hide if no entries */
|
||||
if(nentries == 0)
|
||||
return;
|
||||
|
||||
/* layout */
|
||||
uiLayoutSetAlignment(pa->layout, UI_LAYOUT_ALIGN_LEFT);
|
||||
block= uiLayoutFreeBlock(pa->layout);
|
||||
uiBlockSetHandleFunc(block, do_file_panel_events, NULL);
|
||||
uiBlockSetEmboss(block, UI_EMBOSSP);
|
||||
uiBlockBeginAlign(block);
|
||||
block= uiLayoutGetBlock(pa->layout);
|
||||
box= uiLayoutBox(pa->layout);
|
||||
col= uiLayoutColumn(box, 1);
|
||||
|
||||
for (i=0; i< nentries;++i) {
|
||||
char dir[FILE_MAX];
|
||||
char temp[FILE_MAX];
|
||||
uiLayout* layout = uiLayoutRow(pa->layout, UI_LAYOUT_ALIGN_LEFT);
|
||||
uiLayout* layout = uiLayoutRow(col, 0);
|
||||
char *entry = fsmenu_get_entry(fsmenu, category, i);
|
||||
|
||||
/* set this list item as active if we have a match */
|
||||
if(strcmp(curdir, entry) == 0)
|
||||
*nr= i;
|
||||
|
||||
/* create nice bookmark name, shows last directory in the full path currently */
|
||||
BLI_strncpy(temp, entry, FILE_MAX);
|
||||
BLI_add_slash(temp);
|
||||
BLI_getlastdir(temp, dir, FILE_MAX);
|
||||
BLI_del_slash(dir);
|
||||
|
||||
/* operator shows the short bookmark name, should eventually have tooltip */
|
||||
uiItemStringO(layout, dir, icon, "FILE_OT_select_bookmark", "dir", entry);
|
||||
if (allow_delete && fsmenu_can_save(fsmenu, category, i) )
|
||||
if(dir[0] == 0)
|
||||
BLI_strncpy(dir, entry, FILE_MAX);
|
||||
|
||||
/* create list item */
|
||||
but= uiDefIconTextButS(block, LISTROW, 0, icon, dir, 0,0,UI_UNIT_X*10,UI_UNIT_Y, nr, 0, i, 0, 0, entry);
|
||||
uiButSetFunc(but, file_panel_cb, entry, NULL);
|
||||
uiButSetFlag(but, UI_ICON_LEFT|UI_TEXT_LEFT);
|
||||
|
||||
/* create delete button */
|
||||
if(allow_delete && fsmenu_can_save(fsmenu, category, i)) {
|
||||
uiBlockSetEmboss(block, UI_EMBOSSN);
|
||||
uiItemIntO(layout, "", ICON_X, "FILE_OT_delete_bookmark", "index", i);
|
||||
uiBlockSetEmboss(block, UI_EMBOSS);
|
||||
}
|
||||
}
|
||||
uiBlockEndAlign(block);
|
||||
}
|
||||
|
||||
static void file_panel_system(const bContext *C, Panel *pa)
|
||||
{
|
||||
file_panel_category(C, pa, FS_CATEGORY_SYSTEM, ICON_DISK_DRIVE, 0);
|
||||
SpaceFile *sfile= CTX_wm_space_file(C);
|
||||
|
||||
if(sfile)
|
||||
file_panel_category(C, pa, FS_CATEGORY_SYSTEM, &sfile->systemnr, ICON_DISK_DRIVE, 0);
|
||||
}
|
||||
|
||||
static void file_panel_bookmarks(const bContext *C, Panel *pa)
|
||||
{
|
||||
file_panel_category(C, pa, FS_CATEGORY_BOOKMARKS, ICON_BOOKMARKS, 1);
|
||||
}
|
||||
SpaceFile *sfile= CTX_wm_space_file(C);
|
||||
uiLayout *row;
|
||||
|
||||
if(sfile) {
|
||||
row= uiLayoutRow(pa->layout, 0);
|
||||
uiItemO(row, "Add", ICON_ZOOMIN, "file.add_bookmark");
|
||||
uiItemL(row, NULL, 0);
|
||||
|
||||
file_panel_category(C, pa, FS_CATEGORY_BOOKMARKS, &sfile->bookmarknr, ICON_BOOKMARKS, 1);
|
||||
}
|
||||
}
|
||||
|
||||
static void file_panel_recent(const bContext *C, Panel *pa)
|
||||
{
|
||||
file_panel_category(C, pa, FS_CATEGORY_RECENT, ICON_FILE_FOLDER, 0);
|
||||
SpaceFile *sfile= CTX_wm_space_file(C);
|
||||
|
||||
if(sfile)
|
||||
file_panel_category(C, pa, FS_CATEGORY_RECENT, &sfile->recentnr, ICON_FILE_FOLDER, 0);
|
||||
}
|
||||
|
||||
|
||||
static int file_panel_operator_poll(const bContext *C, PanelType *pt)
|
||||
{
|
||||
SpaceFile *sfile= CTX_wm_space_file(C);
|
||||
return (sfile && sfile->op);
|
||||
}
|
||||
|
||||
static void file_panel_operator_header(const bContext *C, Panel *pa)
|
||||
{
|
||||
SpaceFile *sfile= CTX_wm_space_file(C);
|
||||
wmOperator *op= sfile->op;
|
||||
|
||||
BLI_strncpy(pa->drawname, op->type->name, sizeof(pa->drawname));
|
||||
}
|
||||
|
||||
static void file_panel_operator(const bContext *C, Panel *pa)
|
||||
{
|
||||
SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
|
||||
struct wmOperator *op = sfile ? sfile->op : NULL;
|
||||
uiBlock *block;
|
||||
int sy;
|
||||
SpaceFile *sfile= CTX_wm_space_file(C);
|
||||
wmOperator *op= sfile->op;
|
||||
int empty= 1;
|
||||
|
||||
block= uiLayoutFreeBlock(pa->layout);
|
||||
uiBlockSetHandleFunc(block, do_file_panel_events, NULL);
|
||||
RNA_STRUCT_BEGIN(op->ptr, prop) {
|
||||
if(strcmp(RNA_property_identifier(prop), "rna_type") == 0)
|
||||
continue;
|
||||
if(strcmp(RNA_property_identifier(prop), "filename") == 0)
|
||||
continue;
|
||||
if(strcmp(RNA_property_identifier(prop), "display") == 0)
|
||||
continue;
|
||||
if(strncmp(RNA_property_identifier(prop), "filter", 6) == 0)
|
||||
continue;
|
||||
|
||||
sy= 0;
|
||||
if (op) {
|
||||
uiBlockBeginAlign(block);
|
||||
RNA_STRUCT_BEGIN(op->ptr, prop) {
|
||||
if(strcmp(RNA_property_identifier(prop), "rna_type") == 0)
|
||||
continue;
|
||||
if(strcmp(RNA_property_identifier(prop), "filename") == 0)
|
||||
continue;
|
||||
if(strcmp(RNA_property_identifier(prop), "display") == 0)
|
||||
continue;
|
||||
if(strncmp(RNA_property_identifier(prop), "filter", 6) == 0)
|
||||
continue;
|
||||
uiItemFullR(pa->layout, NULL, 0, op->ptr, prop, -1, 0, 0, 0, 0);
|
||||
}
|
||||
RNA_STRUCT_END;
|
||||
uiBlockEndAlign(block);
|
||||
uiItemFullR(pa->layout, NULL, 0, op->ptr, prop, -1, 0, 0, 0, 0);
|
||||
empty= 0;
|
||||
}
|
||||
uiBlockLayoutResolve(C, block, NULL, &sy);
|
||||
uiEndBlock(C, block);
|
||||
uiDrawBlock(C, block);
|
||||
}
|
||||
RNA_STRUCT_END;
|
||||
|
||||
if(empty)
|
||||
uiItemL(pa->layout, "No properties.", 0);
|
||||
}
|
||||
|
||||
void file_panels_register(ARegionType *art)
|
||||
{
|
||||
@ -161,6 +214,8 @@ void file_panels_register(ARegionType *art)
|
||||
pt= MEM_callocN(sizeof(PanelType), "spacetype file operator properties");
|
||||
strcpy(pt->idname, "FILE_PT_operator");
|
||||
strcpy(pt->label, "Operator");
|
||||
pt->poll= file_panel_operator_poll;
|
||||
pt->draw_header= file_panel_operator_header;
|
||||
pt->draw= file_panel_operator;
|
||||
BLI_addtail(&art->paneltypes, pt);
|
||||
}
|
||||
|
@ -124,18 +124,24 @@ short ED_fileselect_set_params(SpaceFile *sfile)
|
||||
if (op) {
|
||||
BLI_strncpy(params->title, op->type->name, sizeof(params->title));
|
||||
params->filter = 0;
|
||||
params->filter |= RNA_boolean_get(op->ptr, "filter_folder") ? FOLDERFILE : 0;
|
||||
params->filter |= RNA_boolean_get(op->ptr, "filter_blender") ? BLENDERFILE : 0;
|
||||
params->filter |= RNA_boolean_get(op->ptr, "filter_image") ? IMAGEFILE : 0;
|
||||
params->filter |= RNA_boolean_get(op->ptr, "filter_movie") ? MOVIEFILE : 0;
|
||||
params->filter |= RNA_boolean_get(op->ptr, "filter_text") ? TEXTFILE : 0;
|
||||
params->filter |= RNA_boolean_get(op->ptr, "filter_python") ? PYSCRIPTFILE : 0;
|
||||
params->filter |= RNA_boolean_get(op->ptr, "filter_font") ? FTFONTFILE : 0;
|
||||
params->filter |= RNA_boolean_get(op->ptr, "filter_sound") ? SOUNDFILE : 0;
|
||||
params->filter |= RNA_boolean_get(op->ptr, "filter_text") ? TEXTFILE : 0;
|
||||
params->filter |= RNA_boolean_get(op->ptr, "filter_folder") ? FOLDERFILE : 0;
|
||||
if (params->filter != 0)
|
||||
params->flag |= FILE_FILTER;
|
||||
|
||||
params->flag |= FILE_HIDE_DOT;
|
||||
|
||||
if (RNA_property_is_set(op->ptr, "display")) {
|
||||
params->display= RNA_int_get(op->ptr, "display");
|
||||
} else {
|
||||
params->display = FILE_SHORTDISPLAY;
|
||||
}
|
||||
if(params->filter & (IMAGEFILE|MOVIEFILE))
|
||||
params->display= FILE_IMGDISPLAY;
|
||||
else
|
||||
params->display= FILE_SHORTDISPLAY;
|
||||
|
||||
/* if operator has path set, use it, otherwise keep the last */
|
||||
if (RNA_property_is_set(op->ptr, "filename")) {
|
||||
@ -147,12 +153,15 @@ short ED_fileselect_set_params(SpaceFile *sfile)
|
||||
}
|
||||
} else {
|
||||
/* default values, if no operator */
|
||||
params->flag = 0;
|
||||
params->flag |= FILE_HIDE_DOT;
|
||||
params->display = FILE_SHORTDISPLAY;
|
||||
params->filter = 0;
|
||||
params->sort = FILE_SORT_ALPHA;
|
||||
}
|
||||
|
||||
/* new params, refresh file list */
|
||||
if(sfile->files) filelist_free(sfile->files);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -188,8 +197,8 @@ int ED_fileselect_layout_offset(FileLayout* layout, int x, int y)
|
||||
offsetx = (x)/(layout->tile_w + 2*layout->tile_border_x);
|
||||
offsety = (y)/(layout->tile_h + 2*layout->tile_border_y);
|
||||
|
||||
if (offsetx > layout->columns-1) offsetx = -1 ;
|
||||
if (offsety > layout->rows-1) offsety = -1 ;
|
||||
if (offsetx > layout->columns-1) return -1 ;
|
||||
if (offsety > layout->rows-1) return -1 ;
|
||||
|
||||
if (layout->flag & FILE_LAYOUT_HOR)
|
||||
active_file = layout->rows*offsetx + offsety;
|
||||
@ -386,7 +395,7 @@ int file_select_match(struct SpaceFile *sfile, const char *pattern)
|
||||
void autocomplete_directory(struct bContext *C, char *str, void *arg_v)
|
||||
{
|
||||
char tmp[FILE_MAX];
|
||||
SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
|
||||
SpaceFile *sfile= CTX_wm_space_file(C);
|
||||
|
||||
/* search if str matches the beginning of name */
|
||||
if(str[0] && sfile->files) {
|
||||
|
@ -34,9 +34,12 @@
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "DNA_space_types.h" /* FILE_MAX */
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BLI_linklist.h"
|
||||
#include "BLI_dynstr.h"
|
||||
#include "BLI_string.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#include <windows.h> /* need to include windows.h so _WIN32_IE is defined */
|
||||
@ -245,7 +248,7 @@ void fsmenu_read_file(struct FSMenu* fsmenu, const char *filename)
|
||||
FSMenuCategory category = FS_CATEGORY_BOOKMARKS;
|
||||
FILE *fp;
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef WIN32
|
||||
/* Add the drive names to the listing */
|
||||
{
|
||||
__int64 tmp;
|
||||
@ -272,8 +275,7 @@ void fsmenu_read_file(struct FSMenu* fsmenu, const char *filename)
|
||||
SHGetSpecialFolderPath(0, folder, CSIDL_DESKTOPDIRECTORY, 0);
|
||||
fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, folder, 1, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#else
|
||||
#ifdef __APPLE__
|
||||
{
|
||||
OSErr err=noErr;
|
||||
@ -293,6 +295,22 @@ void fsmenu_read_file(struct FSMenu* fsmenu, const char *filename)
|
||||
fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, (char *)path, 1, 0);
|
||||
}
|
||||
}
|
||||
#else
|
||||
/* unix */
|
||||
{
|
||||
char dir[FILE_MAXDIR];
|
||||
char *home= BLI_gethome();
|
||||
|
||||
fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, "/", 1, 0);
|
||||
|
||||
if(home) {
|
||||
BLI_snprintf(dir, FILE_MAXDIR, "%s/", home);
|
||||
fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, dir, 1, 0);
|
||||
BLI_snprintf(dir, FILE_MAXDIR, "%s/Desktop/", home);
|
||||
fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, dir, 1, 0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
fp = fopen(filename, "r");
|
||||
|
@ -184,7 +184,7 @@ static SpaceLink *file_duplicate(SpaceLink *sl)
|
||||
|
||||
static void file_refresh(const bContext *C, ScrArea *sa)
|
||||
{
|
||||
SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
|
||||
SpaceFile *sfile= CTX_wm_space_file(C);
|
||||
FileSelectParams *params = ED_fileselect_get_params(sfile);
|
||||
|
||||
if (!sfile->folders_prev)
|
||||
@ -217,9 +217,11 @@ static void file_listener(ScrArea *sa, wmNotifier *wmn)
|
||||
case ND_FILELIST:
|
||||
if (sfile->files) filelist_free(sfile->files);
|
||||
ED_area_tag_refresh(sa);
|
||||
ED_area_tag_redraw(sa);
|
||||
break;
|
||||
case ND_PARAMS:
|
||||
ED_area_tag_refresh(sa);
|
||||
ED_area_tag_redraw(sa);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@ -263,7 +265,7 @@ static void file_main_area_listener(ARegion *ar, wmNotifier *wmn)
|
||||
static void file_main_area_draw(const bContext *C, ARegion *ar)
|
||||
{
|
||||
/* draw entirely, view changes should be handled here */
|
||||
SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
|
||||
SpaceFile *sfile= CTX_wm_space_file(C);
|
||||
FileSelectParams *params = ED_fileselect_get_params(sfile);
|
||||
FileLayout *layout=NULL;
|
||||
|
||||
@ -305,7 +307,7 @@ static void file_main_area_draw(const bContext *C, ARegion *ar)
|
||||
/* on first read, find active file */
|
||||
if (params->active_file == -1) {
|
||||
wmEvent *event= CTX_wm_window(C)->eventstate;
|
||||
file_hilight_set(sfile, ar, event->x - ar->winrct.xmin, event->y - ar->winrct.ymin);
|
||||
file_hilight_set(sfile, ar, event->x, event->y);
|
||||
}
|
||||
|
||||
if (params->display == FILE_IMGDISPLAY) {
|
||||
|
@ -609,10 +609,6 @@ static const EnumPropertyItem image_file_type_items[] = {
|
||||
static void image_filesel(bContext *C, wmOperator *op, const char *path)
|
||||
{
|
||||
RNA_string_set(op->ptr, "filename", path);
|
||||
RNA_boolean_set(op->ptr, "filter_image", 1);
|
||||
RNA_boolean_set(op->ptr, "filter_movie", 1);
|
||||
RNA_boolean_set(op->ptr, "filter_folder", 1);
|
||||
RNA_enum_set(op->ptr, "display", FILE_IMGDISPLAY);
|
||||
WM_event_add_fileselect(C, op);
|
||||
}
|
||||
|
||||
@ -653,14 +649,6 @@ static int open_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
|
||||
void IMAGE_OT_open(wmOperatorType *ot)
|
||||
{
|
||||
PropertyRNA *prop;
|
||||
|
||||
static EnumPropertyItem file_display_items[] = {
|
||||
{FILE_SHORTDISPLAY, "FILE_SHORTDISPLAY", ICON_SHORTDISPLAY, "Short List", "Display files as short list"},
|
||||
{FILE_LONGDISPLAY, "FILE_LONGDISPLAY", ICON_LONGDISPLAY, "Long List", "Display files as a detailed list"},
|
||||
{FILE_IMGDISPLAY, "FILE_IMGDISPLAY", ICON_IMGDISPLAY, "Thumbnails", "Display files as thumbnails"},
|
||||
{0, NULL, 0, NULL, NULL}};
|
||||
|
||||
/* identifiers */
|
||||
ot->name= "Open";
|
||||
ot->idname= "IMAGE_OT_open";
|
||||
@ -674,27 +662,14 @@ void IMAGE_OT_open(wmOperatorType *ot)
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
|
||||
/* properties */
|
||||
RNA_def_string_file_path(ot->srna, "filename", "", FILE_MAX, "Filename", "File path of image to open.");
|
||||
|
||||
prop= RNA_def_boolean(ot->srna, "filter_image", 0, "Show image files", "");
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "filter", IMAGEFILE);
|
||||
prop= RNA_def_boolean(ot->srna, "filter_movie", 0, "Show movie files", "");
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "filter", MOVIEFILE);
|
||||
prop= RNA_def_boolean(ot->srna, "filter_folder", 0, "Show folders", "");
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "filter", FOLDERFILE);
|
||||
|
||||
prop= RNA_def_property(ot->srna, "display", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_sdna(prop, NULL, "display");
|
||||
RNA_def_property_enum_items(prop, file_display_items);
|
||||
RNA_def_property_ui_text(prop, "Display Mode", "Display mode for the file list");
|
||||
|
||||
WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE);
|
||||
}
|
||||
|
||||
/******************** replace image operator ********************/
|
||||
|
||||
static int replace_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C);
|
||||
SpaceImage *sima= CTX_wm_space_image(C);
|
||||
char str[FILE_MAX];
|
||||
|
||||
if(!sima->image)
|
||||
@ -740,7 +715,7 @@ void IMAGE_OT_replace(wmOperatorType *ot)
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
|
||||
/* properties */
|
||||
RNA_def_string_file_path(ot->srna, "filename", "", FILE_MAX, "Filename", "File path of image to replace current image with.");
|
||||
WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE);
|
||||
}
|
||||
|
||||
/******************** save image as operator ********************/
|
||||
@ -884,15 +859,15 @@ void IMAGE_OT_save_as(wmOperatorType *ot)
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
|
||||
/* properties */
|
||||
RNA_def_string_file_path(ot->srna, "filename", "", FILE_MAX, "Filename", "File path to save image to.");
|
||||
RNA_def_enum(ot->srna, "file_type", image_file_type_items, R_PNG, "File Type", "File type to save image as.");
|
||||
WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE);
|
||||
}
|
||||
|
||||
/******************** save image operator ********************/
|
||||
|
||||
static int save_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
SpaceImage *sima= (SpaceImage*)CTX_wm_space_data(C);
|
||||
SpaceImage *sima= CTX_wm_space_image(C);
|
||||
Image *ima = ED_space_image(sima);
|
||||
ImBuf *ibuf= ED_space_image_buffer(sima);
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
|
@ -330,7 +330,7 @@ void FILE_OT_find_missing_files(wmOperatorType *ot)
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
|
||||
/* properties */
|
||||
RNA_def_string_file_path(ot->srna, "filename", "", FILE_MAX, "Filename", "File path of image to open.");
|
||||
WM_operator_properties_filesel(ot, 0);
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
@ -97,7 +97,6 @@
|
||||
/* avoid passing multiple args and be more verbose */
|
||||
#define SEQPROP_STARTFRAME 1<<0
|
||||
#define SEQPROP_ENDFRAME 1<<1
|
||||
#define SEQPROP_FILENAME 1<<2
|
||||
|
||||
static void sequencer_generic_props__internal(wmOperatorType *ot, int flag)
|
||||
{
|
||||
@ -111,9 +110,6 @@ static void sequencer_generic_props__internal(wmOperatorType *ot, int flag)
|
||||
|
||||
RNA_def_int(ot->srna, "channel", 1, 1, MAXSEQ, "Channel", "Channel to place this strip into", 1, MAXSEQ);
|
||||
|
||||
if(flag & SEQPROP_FILENAME)
|
||||
RNA_def_string(ot->srna, "filename", "", FILE_MAX, "Scene Name", "full path to load the strip data from");
|
||||
|
||||
RNA_def_boolean(ot->srna, "replace_sel", 1, "Replace Selection", "replace the current selection");
|
||||
}
|
||||
|
||||
@ -312,7 +308,8 @@ void SEQUENCER_OT_movie_strip_add(struct wmOperatorType *ot)
|
||||
/* flags */
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
|
||||
sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME|SEQPROP_FILENAME);
|
||||
WM_operator_properties_filesel(ot, FOLDERFILE|MOVIEFILE);
|
||||
sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME);
|
||||
RNA_def_boolean(ot->srna, "sound", FALSE, "Sound", "Load hd sound with the movie"); // XXX need to impliment this
|
||||
}
|
||||
|
||||
@ -417,7 +414,8 @@ void SEQUENCER_OT_sound_strip_add(struct wmOperatorType *ot)
|
||||
/* flags */
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
|
||||
sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME|SEQPROP_FILENAME);
|
||||
WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE);
|
||||
sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME);
|
||||
RNA_def_boolean(ot->srna, "hd", FALSE, "HD Sound", "Load the sound as streaming audio"); // XXX need to impliment this
|
||||
}
|
||||
|
||||
@ -512,7 +510,8 @@ void SEQUENCER_OT_image_strip_add(struct wmOperatorType *ot)
|
||||
/* flags */
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
|
||||
sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME|SEQPROP_FILENAME);
|
||||
WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE);
|
||||
sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME);
|
||||
|
||||
RNA_def_collection_runtime(ot->srna, "files", &RNA_OperatorFileListElement, "Files", "");
|
||||
}
|
||||
@ -646,7 +645,8 @@ void SEQUENCER_OT_effect_strip_add(struct wmOperatorType *ot)
|
||||
/* flags */
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
|
||||
sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME|SEQPROP_ENDFRAME|SEQPROP_FILENAME);
|
||||
WM_operator_properties_filesel(ot, 0);
|
||||
sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME|SEQPROP_ENDFRAME);
|
||||
RNA_def_enum(ot->srna, "type", sequencer_prop_effect_types, SEQ_CROSS, "Type", "Sequencer effect type");
|
||||
RNA_def_float_vector(ot->srna, "color", 3, NULL, 0.0f, 1.0f, "Color", "Initialize the strip with this color (only used when type='COLOR')", 0.0f, 1.0f);
|
||||
}
|
||||
|
@ -231,7 +231,7 @@ void TEXT_OT_open(wmOperatorType *ot)
|
||||
ot->poll= text_new_poll;
|
||||
|
||||
/* properties */
|
||||
RNA_def_string_file_path(ot->srna, "filename", "", FILE_MAX, "Filename", "File path of image to open.");
|
||||
WM_operator_properties_filesel(ot, FOLDERFILE|TEXTFILE|PYSCRIPTFILE);
|
||||
}
|
||||
|
||||
/******************* reload operator *********************/
|
||||
@ -498,7 +498,7 @@ void TEXT_OT_save_as(wmOperatorType *ot)
|
||||
ot->poll= text_edit_poll;
|
||||
|
||||
/* properties */
|
||||
RNA_def_string_file_path(ot->srna, "filename", "", FILE_MAX, "Filename", "File path to save image to.");
|
||||
WM_operator_properties_filesel(ot, FOLDERFILE|TEXTFILE|PYSCRIPTFILE);
|
||||
}
|
||||
|
||||
/******************* run script operator *********************/
|
||||
|
@ -200,6 +200,8 @@ typedef struct SpaceFile {
|
||||
|
||||
struct FileLayout *layout;
|
||||
|
||||
short recentnr, bookmarknr;
|
||||
short systemnr, pad2;
|
||||
} SpaceFile;
|
||||
|
||||
typedef struct SpaceOops {
|
||||
|
@ -1232,7 +1232,7 @@ static void rna_def_fileselect_params(BlenderRNA *brna)
|
||||
prop= RNA_def_property(srna, "do_filter", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "flag", FILE_FILTER);
|
||||
RNA_def_property_ui_text(prop, "Filter Files", "Enable filtering of files.");
|
||||
RNA_def_property_update(prop, NC_FILE | ND_PARAMS, NULL);
|
||||
RNA_def_property_update(prop, NC_FILE | ND_FILELIST, NULL);
|
||||
|
||||
prop= RNA_def_property(srna, "hide_dot", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "flag", FILE_HIDE_DOT);
|
||||
@ -1249,49 +1249,49 @@ static void rna_def_fileselect_params(BlenderRNA *brna)
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "filter", IMAGEFILE);
|
||||
RNA_def_property_ui_text(prop, "Filter Images", "Show image files.");
|
||||
RNA_def_property_ui_icon(prop, ICON_FILE_IMAGE, 0);
|
||||
RNA_def_property_update(prop, NC_FILE | ND_PARAMS, NULL);
|
||||
RNA_def_property_update(prop, NC_FILE | ND_FILELIST, NULL);
|
||||
|
||||
prop= RNA_def_property(srna, "filter_blender", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "filter", BLENDERFILE);
|
||||
RNA_def_property_ui_text(prop, "Filter Blender", "Show .blend files.");
|
||||
RNA_def_property_ui_icon(prop, ICON_FILE_BLEND, 0);
|
||||
RNA_def_property_update(prop, NC_FILE | ND_PARAMS, NULL);
|
||||
RNA_def_property_update(prop, NC_FILE | ND_FILELIST, NULL);
|
||||
|
||||
prop= RNA_def_property(srna, "filter_movie", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "filter", MOVIEFILE);
|
||||
RNA_def_property_ui_text(prop, "Filter Movies", "Show movie files.");
|
||||
RNA_def_property_ui_icon(prop, ICON_FILE_MOVIE, 0);
|
||||
RNA_def_property_update(prop, NC_FILE | ND_PARAMS, NULL);
|
||||
RNA_def_property_update(prop, NC_FILE | ND_FILELIST, NULL);
|
||||
|
||||
prop= RNA_def_property(srna, "filter_script", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "filter", PYSCRIPTFILE);
|
||||
RNA_def_property_ui_text(prop, "Filter Script", "Show script files.");
|
||||
RNA_def_property_ui_icon(prop, ICON_FILE_SCRIPT, 0);
|
||||
RNA_def_property_update(prop, NC_FILE | ND_PARAMS, NULL);
|
||||
RNA_def_property_update(prop, NC_FILE | ND_FILELIST, NULL);
|
||||
|
||||
prop= RNA_def_property(srna, "filter_font", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "filter", FTFONTFILE);
|
||||
RNA_def_property_ui_text(prop, "Filter Fonts", "Show font files.");
|
||||
RNA_def_property_ui_icon(prop, ICON_FILE_FONT, 0);
|
||||
RNA_def_property_update(prop, NC_FILE | ND_PARAMS, NULL);
|
||||
RNA_def_property_update(prop, NC_FILE | ND_FILELIST, NULL);
|
||||
|
||||
prop= RNA_def_property(srna, "filter_sound", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "filter", SOUNDFILE);
|
||||
RNA_def_property_ui_text(prop, "Filter Sound", "Show sound files.");
|
||||
RNA_def_property_ui_icon(prop, ICON_FILE_SOUND, 0);
|
||||
RNA_def_property_update(prop, NC_FILE | ND_PARAMS, NULL);
|
||||
RNA_def_property_update(prop, NC_FILE | ND_FILELIST, NULL);
|
||||
|
||||
prop= RNA_def_property(srna, "filter_text", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "filter", TEXTFILE);
|
||||
RNA_def_property_ui_text(prop, "Filter Text", "Show text files.");
|
||||
RNA_def_property_ui_icon(prop, ICON_FILE_BLANK, 0);
|
||||
RNA_def_property_update(prop, NC_FILE | ND_PARAMS, NULL);
|
||||
RNA_def_property_update(prop, NC_FILE | ND_FILELIST, NULL);
|
||||
|
||||
prop= RNA_def_property(srna, "filter_folder", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "filter", FOLDERFILE);
|
||||
RNA_def_property_ui_text(prop, "Filter Folder", "Show folders.");
|
||||
RNA_def_property_ui_icon(prop, ICON_FILE_FOLDER, 0);
|
||||
RNA_def_property_update(prop, NC_FILE | ND_PARAMS, NULL);
|
||||
RNA_def_property_update(prop, NC_FILE | ND_FILELIST, NULL);
|
||||
|
||||
|
||||
}
|
||||
|
@ -620,6 +620,9 @@ static void rna_def_panel(BlenderRNA *brna)
|
||||
prop= RNA_def_property(srna, "layout", PROP_POINTER, PROP_NONE);
|
||||
RNA_def_property_struct_type(prop, "UILayout");
|
||||
|
||||
prop= RNA_def_property(srna, "text", PROP_STRING, PROP_NONE);
|
||||
RNA_def_property_string_sdna(prop, NULL, "drawname");
|
||||
|
||||
/* registration */
|
||||
prop= RNA_def_property(srna, "idname", PROP_STRING, PROP_NONE);
|
||||
RNA_def_property_string_sdna(prop, NULL, "type->idname");
|
||||
|
@ -488,7 +488,7 @@ static void rna_def_userdef_theme_spaces_main(StructRNA *srna, int spacetype)
|
||||
}
|
||||
|
||||
/* list/channels */
|
||||
if(ELEM4(spacetype, SPACE_IPO, SPACE_ACTION, SPACE_NLA, SPACE_NODE)) {
|
||||
if(ELEM5(spacetype, SPACE_IPO, SPACE_ACTION, SPACE_NLA, SPACE_NODE, SPACE_FILE)) {
|
||||
prop= RNA_def_property(srna, "list", PROP_FLOAT, PROP_COLOR);
|
||||
RNA_def_property_array(prop, 3);
|
||||
RNA_def_property_ui_text(prop, "List Back", "");
|
||||
|
@ -164,6 +164,7 @@ int WM_operator_call_py(struct bContext *C, struct wmOperatorType *ot, struct
|
||||
|
||||
void WM_operator_properties_create(struct PointerRNA *ptr, const char *opstring);
|
||||
void WM_operator_properties_free(struct PointerRNA *ptr);
|
||||
void WM_operator_properties_filesel(struct wmOperatorType *ot, int filter);
|
||||
|
||||
/* operator as a python command (resultuing string must be free'd) */
|
||||
char *WM_operator_pystring(struct wmOperator *op);
|
||||
|
@ -885,10 +885,22 @@ static int handler_boundbox_test(wmEventHandler *handler, wmEvent *event)
|
||||
if(handler->bblocal) {
|
||||
rcti rect= *handler->bblocal;
|
||||
BLI_translate_rcti(&rect, handler->bbwin->xmin, handler->bbwin->ymin);
|
||||
return BLI_in_rcti(&rect, event->x, event->y);
|
||||
|
||||
if(BLI_in_rcti(&rect, event->x, event->y))
|
||||
return 1;
|
||||
else if(event->type==MOUSEMOVE && BLI_in_rcti(&rect, event->prevx, event->prevy))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
if(BLI_in_rcti(handler->bbwin, event->x, event->y))
|
||||
return 1;
|
||||
else if(event->type==MOUSEMOVE && BLI_in_rcti(handler->bbwin, event->prevx, event->prevy))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return BLI_in_rcti(handler->bbwin, event->x, event->y);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
@ -320,6 +320,21 @@ int WM_operator_filesel(bContext *C, wmOperator *op, wmEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
/* default properties for fileselect */
|
||||
void WM_operator_properties_filesel(wmOperatorType *ot, int filter)
|
||||
{
|
||||
RNA_def_string_file_path(ot->srna, "filename", "", FILE_MAX, "Filename", "Path to file.");
|
||||
|
||||
RNA_def_boolean(ot->srna, "filter_blender", (filter & BLENDERFILE), "Filter .blend files", "");
|
||||
RNA_def_boolean(ot->srna, "filter_image", (filter & IMAGEFILE), "Filter image files", "");
|
||||
RNA_def_boolean(ot->srna, "filter_movie", (filter & MOVIEFILE), "Filter movie files", "");
|
||||
RNA_def_boolean(ot->srna, "filter_python", (filter & PYSCRIPTFILE), "Filter python files", "");
|
||||
RNA_def_boolean(ot->srna, "filter_font", (filter & FTFONTFILE), "Filter font files", "");
|
||||
RNA_def_boolean(ot->srna, "filter_sound", (filter & SOUNDFILE), "Filter sound files", "");
|
||||
RNA_def_boolean(ot->srna, "filter_text", (filter & TEXTFILE), "Filter text files", "");
|
||||
RNA_def_boolean(ot->srna, "filter_folder", (filter & FOLDERFILE), "Filter folders", "");
|
||||
}
|
||||
|
||||
/* op->poll */
|
||||
int WM_operator_winactive(bContext *C)
|
||||
{
|
||||
@ -678,10 +693,7 @@ static void untitled(char *name)
|
||||
|
||||
static int wm_open_mainfile_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
|
||||
RNA_string_set(op->ptr, "filename", G.sce);
|
||||
RNA_boolean_set(op->ptr, "filter_blender", 1);
|
||||
RNA_boolean_set(op->ptr, "filter_folder", 1);
|
||||
WM_event_add_fileselect(C, op);
|
||||
|
||||
return OPERATOR_RUNNING_MODAL;
|
||||
@ -703,7 +715,6 @@ static int wm_open_mainfile_exec(bContext *C, wmOperator *op)
|
||||
|
||||
static void WM_OT_open_mainfile(wmOperatorType *ot)
|
||||
{
|
||||
PropertyRNA *prop;
|
||||
ot->name= "Open Blender File";
|
||||
ot->idname= "WM_OT_open_mainfile";
|
||||
|
||||
@ -711,13 +722,7 @@ static void WM_OT_open_mainfile(wmOperatorType *ot)
|
||||
ot->exec= wm_open_mainfile_exec;
|
||||
ot->poll= WM_operator_winactive;
|
||||
|
||||
RNA_def_string_file_path(ot->srna, "filename", "", FILE_MAX, "Filename", "File path of blendfile to open.");
|
||||
|
||||
prop= RNA_def_boolean(ot->srna, "filter_blender", 0, "Filter Blendfiles", "");
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "filter", BLENDERFILE);
|
||||
prop= RNA_def_boolean(ot->srna, "filter_folder", 0, "Filter Blendfiles", "");
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "filter", FOLDERFILE);
|
||||
|
||||
WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE);
|
||||
}
|
||||
|
||||
static int wm_recover_last_session_exec(bContext *C, wmOperator *op)
|
||||
@ -810,7 +815,7 @@ static void WM_OT_save_as_mainfile(wmOperatorType *ot)
|
||||
ot->exec= wm_save_as_mainfile_exec;
|
||||
ot->poll= WM_operator_winactive;
|
||||
|
||||
RNA_def_string_file_path(ot->srna, "filename", "", 0, "Filename", "");
|
||||
WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE);
|
||||
RNA_def_boolean(ot->srna, "compress", 0, "Compress", "Write compressed .blend file.");
|
||||
}
|
||||
|
||||
@ -839,7 +844,7 @@ static void WM_OT_save_mainfile(wmOperatorType *ot)
|
||||
ot->exec= wm_save_as_mainfile_exec;
|
||||
ot->poll= WM_operator_winactive;
|
||||
|
||||
RNA_def_string_file_path(ot->srna, "filename", "", 0, "Filename", "");
|
||||
WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE);
|
||||
RNA_def_boolean(ot->srna, "compress", 0, "Compress", "Write compressed .blend file.");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user