2.5 filebrowser
* start of filebrowser RNA * system files, bookmarks, etc. now nicely inside panels to allow collapsing etc. * filebrowser header now defined in space_filebrowser.py TODO: * button type for bookmarks etc. not final yet, at least should get centered still. Suggestions welcome here.
This commit is contained in:
@@ -762,6 +762,10 @@
|
||||
RelativePath="..\..\..\source\blender\editors\space_file\file_ops.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\source\blender\editors\space_file\file_panels.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\source\blender\editors\space_file\filelist.c"
|
||||
>
|
||||
|
||||
43
release/ui/space_filebrowser.py
Normal file
43
release/ui/space_filebrowser.py
Normal file
@@ -0,0 +1,43 @@
|
||||
|
||||
import bpy
|
||||
|
||||
|
||||
class FILEBROWSER_HT_header(bpy.types.Header):
|
||||
__space_type__ = "FILE_BROWSER"
|
||||
__idname__ = "FILEBROWSER_HT_header"
|
||||
|
||||
def draw(self, context):
|
||||
st = context.space_data
|
||||
layout = self.layout
|
||||
|
||||
params = st.params
|
||||
layout.template_header(context)
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.itemO("FILE_OT_parent", text="", icon='ICON_FILE_PARENT')
|
||||
row.itemO("FILE_OT_refresh", text="", icon='ICON_FILE_REFRESH')
|
||||
|
||||
layout.itemR(params, "display", expand=True, text="")
|
||||
layout.itemR(params, "sort", expand=True, text="")
|
||||
|
||||
layout.itemR(params, "hide_dot")
|
||||
layout.itemR(params, "do_filter")
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.itemR(params, "filter_folder", text="");
|
||||
row.itemR(params, "filter_blender", text="");
|
||||
row.itemR(params, "filter_image", text="");
|
||||
row.itemR(params, "filter_movie", text="");
|
||||
row.itemR(params, "filter_script", text="");
|
||||
row.itemR(params, "filter_font", text="");
|
||||
row.itemR(params, "filter_sound", text="");
|
||||
row.itemR(params, "filter_text", text="");
|
||||
|
||||
if params.do_filter:
|
||||
row.active = True
|
||||
else:
|
||||
row.active = False
|
||||
|
||||
bpy.types.register(FILEBROWSER_HT_header)
|
||||
|
||||
|
||||
@@ -5595,21 +5595,6 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb)
|
||||
/* temporarily hide it */
|
||||
ar->flag = RGN_FLAG_HIDDEN;
|
||||
break;
|
||||
|
||||
case SPACE_FILE:
|
||||
/* channel (bookmarks/directories) region */
|
||||
ar= MEM_callocN(sizeof(ARegion), "area region from do_versions");
|
||||
BLI_addtail(lb, ar);
|
||||
ar->regiontype= RGN_TYPE_CHANNELS;
|
||||
ar->alignment= RGN_ALIGN_LEFT;
|
||||
ar->v2d.scroll= V2D_SCROLL_RIGHT;
|
||||
/* button UI region */
|
||||
ar= MEM_callocN(sizeof(ARegion), "area region from do_versions");
|
||||
BLI_addtail(lb, ar);
|
||||
ar->regiontype= RGN_TYPE_UI;
|
||||
ar->alignment= RGN_ALIGN_TOP;
|
||||
break;
|
||||
|
||||
#if 0
|
||||
case SPACE_BUTS:
|
||||
/* context UI region */
|
||||
|
||||
@@ -29,34 +29,8 @@
|
||||
#define ED_FILES_H
|
||||
|
||||
struct SpaceFile;
|
||||
|
||||
#define FILE_SHORTDISPLAY 1
|
||||
#define FILE_LONGDISPLAY 2
|
||||
#define FILE_IMGDISPLAY 3
|
||||
|
||||
typedef struct FileSelectParams {
|
||||
char title[24]; /* title, also used for the text of the execute button */
|
||||
char dir[240]; /* directory */
|
||||
char file[80]; /* file */
|
||||
|
||||
short flag; /* settings for filter, hiding files and display mode */
|
||||
short sort; /* sort order */
|
||||
short display; /* display mode flag */
|
||||
short filter; /* filter when (flags & FILE_FILTER) is true */
|
||||
|
||||
/* XXX - temporary, better move to filelist */
|
||||
short active_bookmark;
|
||||
int active_file;
|
||||
int selstate;
|
||||
|
||||
/* XXX --- still unused -- */
|
||||
short f_fp; /* show font preview */
|
||||
char fp_str[8]; /* string to use for font preview */
|
||||
|
||||
char *pupmenu; /* allows menu for save options - result stored in menup */
|
||||
short menu; /* currently selected option in pupmenu */
|
||||
/* XXX --- end unused -- */
|
||||
} FileSelectParams;
|
||||
struct ARegion;
|
||||
struct FileSelectParams;
|
||||
|
||||
#define FILE_LAYOUT_HOR 1
|
||||
#define FILE_LAYOUT_VER 2
|
||||
@@ -93,7 +67,7 @@ typedef struct FileLayout
|
||||
float column_widths[MAX_FILE_COLUMN];
|
||||
} FileLayout;
|
||||
|
||||
FileSelectParams* ED_fileselect_get_params(struct SpaceFile *sfile);
|
||||
struct FileSelectParams* ED_fileselect_get_params(struct SpaceFile *sfile);
|
||||
|
||||
short ED_fileselect_set_params(struct SpaceFile *sfile, const char *title, const char *path,
|
||||
short flag, short display, short filter, short sort);
|
||||
|
||||
@@ -104,6 +104,8 @@ static int panel_aligned(ScrArea *sa, ARegion *ar)
|
||||
SpaceButs *sbuts= sa->spacedata.first;
|
||||
return sbuts->align;
|
||||
}
|
||||
else if(sa->spacetype==SPACE_FILE && ar->regiontype == RGN_TYPE_CHANNELS)
|
||||
return BUT_VERTICAL;
|
||||
else if(ELEM(ar->regiontype, RGN_TYPE_UI, RGN_TYPE_TOOLS))
|
||||
return BUT_VERTICAL;
|
||||
|
||||
@@ -126,6 +128,8 @@ static int panels_re_align(ScrArea *sa, ARegion *ar, Panel **r_pa)
|
||||
}
|
||||
else if(ar->regiontype==RGN_TYPE_UI)
|
||||
return 1;
|
||||
else if(sa->spacetype==SPACE_FILE && ar->regiontype == RGN_TYPE_CHANNELS)
|
||||
return 1;
|
||||
|
||||
/* in case panel is added or disappears */
|
||||
for(pa=ar->panels.first; pa; pa=pa->next) {
|
||||
|
||||
@@ -550,132 +550,4 @@ void file_draw_list(const bContext *C, ARegion *ar)
|
||||
}
|
||||
}
|
||||
|
||||
static void file_draw_fsmenu_category_name(ARegion *ar, const char *category_name, short *starty)
|
||||
{
|
||||
short sx, sy;
|
||||
int bmwidth = ar->v2d.cur.xmax - ar->v2d.cur.xmin - 2*TILE_BORDER_X - ICON_DEFAULT_WIDTH - 4;
|
||||
int fontsize = file_font_pointsize();
|
||||
|
||||
sx = ar->v2d.cur.xmin + TILE_BORDER_X;
|
||||
sy = *starty;
|
||||
|
||||
UI_ThemeColor(TH_TEXT_HI);
|
||||
file_draw_string(sx, sy, category_name, bmwidth, fontsize, FILE_SHORTEN_END);
|
||||
|
||||
sy -= fontsize*2.0f;
|
||||
|
||||
*starty= sy;
|
||||
}
|
||||
|
||||
static void file_draw_fsmenu_category(const bContext *C, ARegion *ar, FSMenuCategory category, short *starty)
|
||||
{
|
||||
struct FSMenu* fsmenu = fsmenu_get();
|
||||
char bookmark[FILE_MAX];
|
||||
int nentries = fsmenu_get_nentries(fsmenu, category);
|
||||
|
||||
short sx, sy, xpos, ypos;
|
||||
int bmwidth = ar->v2d.cur.xmax - ar->v2d.cur.xmin - 2*TILE_BORDER_X - ICON_DEFAULT_WIDTH - 4;
|
||||
int fontsize = file_font_pointsize();
|
||||
int cat_icon;
|
||||
int i;
|
||||
|
||||
sx = ar->v2d.cur.xmin + TILE_BORDER_X;
|
||||
sy = *starty;
|
||||
|
||||
switch(category) {
|
||||
case FS_CATEGORY_SYSTEM:
|
||||
cat_icon = ICON_DISK_DRIVE; break;
|
||||
case FS_CATEGORY_BOOKMARKS:
|
||||
cat_icon = ICON_BOOKMARKS; break;
|
||||
case FS_CATEGORY_RECENT:
|
||||
cat_icon = ICON_FILE_FOLDER; break;
|
||||
}
|
||||
|
||||
for (i=0; i< nentries && (sy > ar->v2d.cur.ymin) ;++i) {
|
||||
char *fname = fsmenu_get_entry(fsmenu, category, i);
|
||||
|
||||
if (fname) {
|
||||
int sl;
|
||||
BLI_strncpy(bookmark, fname, FILE_MAX);
|
||||
|
||||
sl = strlen(bookmark)-1;
|
||||
if (sl > 1) {
|
||||
while (bookmark[sl] == '\\' || bookmark[sl] == '/') {
|
||||
bookmark[sl] = '\0';
|
||||
sl--;
|
||||
}
|
||||
}
|
||||
|
||||
if (fsmenu_is_selected(fsmenu, category, i) ) {
|
||||
UI_ThemeColor(TH_HILITE);
|
||||
uiRoundBox(sx, sy - fontsize*2.0f, ar->v2d.cur.xmax - TILE_BORDER_X, sy, 4.0f);
|
||||
UI_ThemeColor(TH_TEXT);
|
||||
} else {
|
||||
UI_ThemeColor(TH_TEXT_HI);
|
||||
}
|
||||
|
||||
xpos = sx;
|
||||
ypos = sy - (TILE_BORDER_Y * 0.5);
|
||||
|
||||
file_draw_icon(xpos, ypos, cat_icon, ICON_DEFAULT_WIDTH, ICON_DEFAULT_WIDTH);
|
||||
xpos += ICON_DEFAULT_WIDTH + 4;
|
||||
file_draw_string(xpos, ypos, bookmark, bmwidth, fontsize, FILE_SHORTEN_FRONT);
|
||||
sy -= fontsize*2.0;
|
||||
fsmenu_set_pos(fsmenu, category, i, xpos, ypos);
|
||||
}
|
||||
}
|
||||
|
||||
*starty = sy;
|
||||
}
|
||||
|
||||
void file_draw_fsmenu_operator(const bContext *C, ARegion *ar, wmOperator *op, short *starty)
|
||||
{
|
||||
uiStyle *style= U.uistyles.first;
|
||||
uiBlock *block;
|
||||
uiLayout *layout;
|
||||
int sy;
|
||||
|
||||
sy= *starty;
|
||||
|
||||
block= uiBeginBlock(C, ar, "file_options", UI_EMBOSS);
|
||||
layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, TILE_BORDER_X, sy, ar->winx-2*TILE_BORDER_X, 20, style);
|
||||
|
||||
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;
|
||||
|
||||
uiItemFullR(layout, NULL, 0, op->ptr, prop, -1, 0, 0, 0, 0);
|
||||
}
|
||||
RNA_STRUCT_END;
|
||||
|
||||
uiBlockLayoutResolve(C, block, NULL, &sy);
|
||||
uiEndBlock(C, block);
|
||||
uiDrawBlock(C, block);
|
||||
|
||||
*starty= sy;
|
||||
}
|
||||
|
||||
void file_draw_fsmenu(const bContext *C, ARegion *ar)
|
||||
{
|
||||
SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
|
||||
int linestep = file_font_pointsize()*2.0f;
|
||||
short sy= ar->v2d.cur.ymax-2*TILE_BORDER_Y;
|
||||
|
||||
file_draw_fsmenu_category_name(ar, "SYSTEM", &sy);
|
||||
file_draw_fsmenu_category(C, ar, FS_CATEGORY_SYSTEM, &sy);
|
||||
sy -= linestep;
|
||||
file_draw_fsmenu_category_name(ar, "BOOKMARKS", &sy);
|
||||
file_draw_fsmenu_category(C, ar, FS_CATEGORY_BOOKMARKS, &sy);
|
||||
sy -= linestep;
|
||||
file_draw_fsmenu_category_name(ar, "RECENT", &sy);
|
||||
file_draw_fsmenu_category(C, ar, FS_CATEGORY_RECENT, &sy);
|
||||
|
||||
if(sfile->op) {
|
||||
sy -= linestep;
|
||||
file_draw_fsmenu_category_name(ar, "OPTIONS", &sy);
|
||||
file_draw_fsmenu_operator(C, ar, sfile->op, &sy);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,9 @@
|
||||
|
||||
/* internal exports only */
|
||||
|
||||
struct ARegion;
|
||||
struct ARegionType;
|
||||
struct SpaceFile;
|
||||
|
||||
/* file_header.c */
|
||||
void file_header_buttons(const bContext *C, ARegion *ar);
|
||||
@@ -45,7 +48,6 @@ void file_draw_buttons(const bContext *C, ARegion *ar);
|
||||
void file_calc_previews(const bContext *C, ARegion *ar);
|
||||
void file_draw_previews(const bContext *C, ARegion *ar);
|
||||
void file_draw_list(const bContext *C, ARegion *ar);
|
||||
void file_draw_fsmenu(const bContext *C, ARegion *ar);
|
||||
|
||||
/* file_ops.h */
|
||||
struct wmOperatorType;
|
||||
@@ -66,11 +68,14 @@ void FILE_OT_bookmark_toggle(struct wmOperatorType *ot);
|
||||
int file_exec(bContext *C, struct wmOperator *unused);
|
||||
int file_cancel_exec(bContext *C, struct wmOperator *unused);
|
||||
int file_parent_exec(bContext *C, struct wmOperator *unused);
|
||||
int file_hilight_set(SpaceFile *sfile, ARegion *ar, int mx, int my);
|
||||
int file_hilight_set(struct SpaceFile *sfile, struct ARegion *ar, int mx, int my);
|
||||
|
||||
/* filesel.c */
|
||||
float file_string_width(const char* str);
|
||||
float file_font_pointsize();
|
||||
|
||||
/* file_panels.c */
|
||||
void file_panels_register(struct ARegionType *art);
|
||||
|
||||
#endif /* ED_FILE_INTERN_H */
|
||||
|
||||
|
||||
@@ -42,6 +42,8 @@
|
||||
#include "ED_screen.h"
|
||||
#include "ED_fileselect.h"
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
#include "RNA_define.h"
|
||||
|
||||
@@ -234,7 +236,7 @@ static int file_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
/* single select, deselect all selected first */
|
||||
file_deselect_all(sfile);
|
||||
file_select(sfile, ar, &rect, val );
|
||||
WM_event_add_notifier(C, NC_WINDOW, NULL);
|
||||
WM_event_add_notifier(C, NC_FILE|ND_PARAMS, NULL);
|
||||
}
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -299,75 +301,25 @@ void FILE_OT_select_all_toggle(wmOperatorType *ot)
|
||||
|
||||
/* ---------- BOOKMARKS ----------- */
|
||||
|
||||
static int file_select_bookmark_category(SpaceFile* sfile, ARegion* ar, short x, short y, FSMenuCategory category)
|
||||
{
|
||||
struct FSMenu* fsmenu = fsmenu_get();
|
||||
int nentries = fsmenu_get_nentries(fsmenu, category);
|
||||
int linestep = file_font_pointsize()*2.0f;
|
||||
short xs, ys;
|
||||
int i;
|
||||
int selected = -1;
|
||||
|
||||
for (i=0; i < nentries; ++i) {
|
||||
fsmenu_get_pos(fsmenu, category, i, &xs, &ys);
|
||||
if ( (y<=ys) && (y>ys-linestep) ) {
|
||||
fsmenu_select_entry(fsmenu, category, i);
|
||||
selected = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return selected;
|
||||
}
|
||||
|
||||
static void file_select_bookmark(SpaceFile* sfile, ARegion* ar, short x, short y)
|
||||
{
|
||||
float fx, fy;
|
||||
int selected;
|
||||
FSMenuCategory category = FS_CATEGORY_SYSTEM;
|
||||
|
||||
if (BLI_in_rcti(&ar->v2d.mask, x, y)) {
|
||||
char *entry;
|
||||
|
||||
UI_view2d_region_to_view(&ar->v2d, x, y, &fx, &fy);
|
||||
selected = file_select_bookmark_category(sfile, ar, fx, fy, FS_CATEGORY_SYSTEM);
|
||||
if (selected<0) {
|
||||
category = FS_CATEGORY_BOOKMARKS;
|
||||
selected = file_select_bookmark_category(sfile, ar, fx, fy, category);
|
||||
}
|
||||
if (selected<0) {
|
||||
category = FS_CATEGORY_RECENT;
|
||||
selected = file_select_bookmark_category(sfile, ar, fx, fy, category);
|
||||
}
|
||||
|
||||
if (selected>=0) {
|
||||
entry= fsmenu_get_entry(fsmenu_get(), category, selected);
|
||||
/* which string */
|
||||
if (entry) {
|
||||
FileSelectParams* params = sfile->params;
|
||||
BLI_strncpy(params->dir, entry, sizeof(params->dir));
|
||||
BLI_cleanup_dir(G.sce, params->dir);
|
||||
filelist_free(sfile->files);
|
||||
filelist_setdir(sfile->files, params->dir);
|
||||
params->file[0] = '\0';
|
||||
params->active_file = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int bookmark_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
ARegion *ar= CTX_wm_region(C);
|
||||
SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
|
||||
|
||||
short x, y;
|
||||
if(RNA_struct_find_property(op->ptr, "dir")) {
|
||||
char entry[256];
|
||||
FileSelectParams* params = sfile->params;
|
||||
|
||||
x = event->x - ar->winrct.xmin;
|
||||
y = event->y - ar->winrct.ymin;
|
||||
RNA_string_get(op->ptr, "dir", entry);
|
||||
BLI_strncpy(params->dir, entry, sizeof(params->dir));
|
||||
BLI_cleanup_dir(G.sce, params->dir);
|
||||
filelist_free(sfile->files);
|
||||
filelist_setdir(sfile->files, params->dir);
|
||||
params->file[0] = '\0';
|
||||
params->active_file = -1;
|
||||
|
||||
file_select_bookmark(sfile, ar, x, y);
|
||||
ED_area_tag_redraw(sa);
|
||||
WM_event_add_notifier(C, NC_FILE|ND_PARAMS, NULL);
|
||||
}
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
@@ -380,6 +332,8 @@ void FILE_OT_select_bookmark(wmOperatorType *ot)
|
||||
/* api callbacks */
|
||||
ot->invoke= bookmark_select_invoke;
|
||||
ot->poll= ED_operator_file_active;
|
||||
|
||||
RNA_def_string(ot->srna, "dir", "", 256, "Dir", "");
|
||||
}
|
||||
|
||||
static int loadimages_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
@@ -548,7 +502,7 @@ int file_parent_exec(bContext *C, wmOperator *unused)
|
||||
filelist_free(sfile->files);
|
||||
sfile->params->active_file = -1;
|
||||
}
|
||||
ED_area_tag_redraw(CTX_wm_area(C));
|
||||
WM_event_add_notifier(C, NC_FILE|ND_FILELIST, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
|
||||
@@ -575,8 +529,8 @@ int file_refresh_exec(bContext *C, wmOperator *unused)
|
||||
filelist_setdir(sfile->files, sfile->params->dir);
|
||||
filelist_free(sfile->files);
|
||||
sfile->params->active_file = -1;
|
||||
}
|
||||
ED_area_tag_redraw(CTX_wm_area(C));
|
||||
}
|
||||
WM_event_add_notifier(C, NC_FILE|ND_FILELIST, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
|
||||
@@ -596,12 +550,29 @@ void FILE_OT_refresh(struct wmOperatorType *ot)
|
||||
|
||||
struct ARegion *file_buttons_region(struct ScrArea *sa)
|
||||
{
|
||||
ARegion *ar;
|
||||
ARegion *ar, *arnew;
|
||||
|
||||
for(ar= sa->regionbase.first; ar; ar= ar->next)
|
||||
if(ar->regiontype==RGN_TYPE_CHANNELS)
|
||||
return ar;
|
||||
return NULL;
|
||||
|
||||
/* add subdiv level; after header */
|
||||
for(ar= sa->regionbase.first; ar; ar= ar->next)
|
||||
if(ar->regiontype==RGN_TYPE_HEADER)
|
||||
break;
|
||||
|
||||
/* is error! */
|
||||
if(ar==NULL) return NULL;
|
||||
|
||||
arnew= MEM_callocN(sizeof(ARegion), "buttons for file panels");
|
||||
|
||||
BLI_insertlinkafter(&sa->regionbase, ar, arnew);
|
||||
arnew->regiontype= RGN_TYPE_CHANNELS;
|
||||
arnew->alignment= RGN_ALIGN_LEFT;
|
||||
|
||||
arnew->flag = RGN_FLAG_HIDDEN;
|
||||
|
||||
return arnew;
|
||||
}
|
||||
|
||||
int file_bookmark_toggle_exec(bContext *C, wmOperator *unused)
|
||||
|
||||
124
source/blender/editors/space_file/file_panels.c
Normal file
124
source/blender/editors/space_file/file_panels.c
Normal file
@@ -0,0 +1,124 @@
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_screen.h"
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
|
||||
#include "DNA_screen_types.h"
|
||||
#include "DNA_space_types.h"
|
||||
#include "DNA_userdef_types.h"
|
||||
#include "DNA_windowmanager_types.h"
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
|
||||
#include "UI_interface.h"
|
||||
#include "UI_resources.h"
|
||||
#include "UI_view2d.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_category(const bContext *C, Panel *pa, FSMenuCategory category, int icon)
|
||||
{
|
||||
uiBlock *block;
|
||||
uiStyle *style= U.uistyles.first;
|
||||
int i;
|
||||
int fontsize = file_font_pointsize();
|
||||
struct FSMenu* fsmenu = fsmenu_get();
|
||||
int nentries = fsmenu_get_nentries(fsmenu, category);
|
||||
|
||||
uiLayoutSetAlignment(pa->layout, UI_LAYOUT_ALIGN_LEFT);
|
||||
block= uiLayoutFreeBlock(pa->layout);
|
||||
uiBlockSetHandleFunc(block, do_file_panel_events, NULL);
|
||||
uiBlockSetEmboss(block, UI_EMBOSSP);
|
||||
uiBlockBeginAlign(block);
|
||||
for (i=0; i< nentries;++i) {
|
||||
char *fname = fsmenu_get_entry(fsmenu, category, i);
|
||||
uiItemStringO(pa->layout, fname, icon, "FILE_OT_select_bookmark", "dir", fname);
|
||||
}
|
||||
uiBlockEndAlign(block);
|
||||
}
|
||||
|
||||
static void file_panel_system(const bContext *C, Panel *pa)
|
||||
{
|
||||
file_panel_category(C, pa, FS_CATEGORY_SYSTEM, ICON_DISK_DRIVE);
|
||||
}
|
||||
|
||||
static void file_panel_bookmarks(const bContext *C, Panel *pa)
|
||||
{
|
||||
file_panel_category(C, pa, FS_CATEGORY_BOOKMARKS, ICON_BOOKMARKS);
|
||||
}
|
||||
|
||||
|
||||
static void file_panel_recent(const bContext *C, Panel *pa)
|
||||
{
|
||||
file_panel_category(C, pa, FS_CATEGORY_RECENT, ICON_FILE_FOLDER);
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
|
||||
block= uiLayoutFreeBlock(pa->layout);
|
||||
uiBlockSetHandleFunc(block, do_file_panel_events, NULL);
|
||||
|
||||
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;
|
||||
|
||||
uiItemFullR(pa->layout, NULL, 0, op->ptr, prop, -1, 0, 0, 0, 0);
|
||||
}
|
||||
RNA_STRUCT_END;
|
||||
uiBlockEndAlign(block);
|
||||
}
|
||||
uiBlockLayoutResolve(C, block, NULL, &sy);
|
||||
uiEndBlock(C, block);
|
||||
uiDrawBlock(C, block);
|
||||
}
|
||||
|
||||
|
||||
void file_panels_register(ARegionType *art)
|
||||
{
|
||||
PanelType *pt;
|
||||
|
||||
pt= MEM_callocN(sizeof(PanelType), "spacetype file system directories");
|
||||
strcpy(pt->idname, "FILE_PT_system");
|
||||
strcpy(pt->label, "System");
|
||||
pt->draw= file_panel_system;
|
||||
BLI_addtail(&art->paneltypes, pt);
|
||||
|
||||
pt= MEM_callocN(sizeof(PanelType), "spacetype file bookmarks");
|
||||
strcpy(pt->idname, "FILE_PT_bookmarks");
|
||||
strcpy(pt->label, "Bookmarks");
|
||||
pt->draw= file_panel_bookmarks;
|
||||
BLI_addtail(&art->paneltypes, pt);
|
||||
|
||||
pt= MEM_callocN(sizeof(PanelType), "spacetype file recent directories");
|
||||
strcpy(pt->idname, "FILE_PT_recent");
|
||||
strcpy(pt->label, "Recent");
|
||||
pt->draw= file_panel_recent;
|
||||
BLI_addtail(&art->paneltypes, pt);
|
||||
|
||||
pt= MEM_callocN(sizeof(PanelType), "spacetype file operator properties");
|
||||
strcpy(pt->idname, "FILE_PT_operator");
|
||||
strcpy(pt->label, "Operator");
|
||||
pt->draw= file_panel_operator;
|
||||
BLI_addtail(&art->paneltypes, pt);
|
||||
}
|
||||
@@ -823,16 +823,16 @@ void filelist_sort(struct FileList* filelist, short sort)
|
||||
int num;/* , act= 0; */
|
||||
|
||||
switch(sort) {
|
||||
case FILE_SORTALPHA:
|
||||
case FILE_SORT_ALPHA:
|
||||
qsort(filelist->filelist, filelist->numfiles, sizeof(struct direntry), compare_name);
|
||||
break;
|
||||
case FILE_SORTDATE:
|
||||
case FILE_SORT_TIME:
|
||||
qsort(filelist->filelist, filelist->numfiles, sizeof(struct direntry), compare_date);
|
||||
break;
|
||||
case FILE_SORTSIZE:
|
||||
case FILE_SORT_SIZE:
|
||||
qsort(filelist->filelist, filelist->numfiles, sizeof(struct direntry), compare_size);
|
||||
break;
|
||||
case FILE_SORTEXTENS:
|
||||
case FILE_SORT_EXTENSION:
|
||||
qsort(filelist->filelist, filelist->numfiles, sizeof(struct direntry), compare_extension);
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,6 @@ void filelist_free_icons();
|
||||
struct FileList * filelist_copy(struct FileList* filelist);
|
||||
int filelist_find(struct FileList* filelist, char *file);
|
||||
void filelist_free(struct FileList* filelist);
|
||||
void filelist_freelib(struct FileList* filelist);
|
||||
void filelist_sort(struct FileList* filelist, short sort);
|
||||
int filelist_numfiles(struct FileList* filelist);
|
||||
const char * filelist_dir(struct FileList* filelist);
|
||||
|
||||
@@ -84,7 +84,7 @@
|
||||
FileSelectParams* ED_fileselect_get_params(struct SpaceFile *sfile)
|
||||
{
|
||||
if (!sfile->params) {
|
||||
ED_fileselect_set_params(sfile, "", "/", 0, FILE_SHORTDISPLAY, 0, FILE_SORTALPHA);
|
||||
ED_fileselect_set_params(sfile, "", "/", 0, FILE_SHORTDISPLAY, 0, FILE_SORT_ALPHA);
|
||||
}
|
||||
return sfile->params;
|
||||
}
|
||||
|
||||
@@ -163,6 +163,46 @@ static SpaceLink *file_duplicate(SpaceLink *sl)
|
||||
return (SpaceLink *)sfilen;
|
||||
}
|
||||
|
||||
static void file_refresh(const bContext *C, ScrArea *sa)
|
||||
{
|
||||
SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
|
||||
FileSelectParams *params = ED_fileselect_get_params(sfile);
|
||||
|
||||
if (!sfile->files) {
|
||||
sfile->files = filelist_new();
|
||||
filelist_setdir(sfile->files, params->dir);
|
||||
params->active_file = -1; // added this so it opens nicer (ton)
|
||||
}
|
||||
filelist_hidedot(sfile->files, params->flag & FILE_HIDE_DOT);
|
||||
if (filelist_empty(sfile->files))
|
||||
{
|
||||
filelist_readdir(sfile->files);
|
||||
}
|
||||
filelist_setfilter(sfile->files, params->flag & FILE_FILTER ? params->filter : 0);
|
||||
if(params->sort!=FILE_SORT_NONE) filelist_sort(sfile->files, params->sort);
|
||||
}
|
||||
|
||||
static void file_listener(ScrArea *sa, wmNotifier *wmn)
|
||||
{
|
||||
SpaceFile* sfile = (SpaceFile*)sa->spacedata.first;
|
||||
|
||||
/* context changes */
|
||||
switch(wmn->category) {
|
||||
case NC_FILE:
|
||||
switch (wmn->data) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/* add handlers, stuff you only do once or on area/region changes */
|
||||
static void file_main_area_init(wmWindowManager *wm, ARegion *ar)
|
||||
@@ -188,31 +228,9 @@ static void file_main_area_draw(const bContext *C, ARegion *ar)
|
||||
View2D *v2d= &ar->v2d;
|
||||
View2DScrollers *scrollers;
|
||||
float col[3];
|
||||
|
||||
if (!sfile->files) {
|
||||
sfile->files = filelist_new();
|
||||
filelist_setdir(sfile->files, params->dir);
|
||||
params->active_file = -1; // added this so it opens nicer (ton)
|
||||
}
|
||||
|
||||
layout = ED_fileselect_get_layout(sfile, ar);
|
||||
|
||||
if (filelist_empty(sfile->files))
|
||||
{
|
||||
unsigned int filter = 0;
|
||||
filelist_hidedot(sfile->files, params->flag & FILE_HIDE_DOT);
|
||||
if (params->flag & FILE_FILTER) {
|
||||
filter = params->filter ;
|
||||
} else {
|
||||
filter = 0;
|
||||
}
|
||||
|
||||
filelist_setfilter(sfile->files, filter);
|
||||
filelist_readdir(sfile->files);
|
||||
|
||||
if(params->sort!=FILE_SORTALPHA) filelist_sort(sfile->files, params->sort);
|
||||
}
|
||||
|
||||
/* clear and setup matrix */
|
||||
UI_GetThemeColor3fv(TH_BACK, col);
|
||||
glClearColor(col[0], col[1], col[2], 0.0);
|
||||
@@ -280,6 +298,7 @@ void file_operatortypes(void)
|
||||
void file_keymap(struct wmWindowManager *wm)
|
||||
{
|
||||
ListBase *keymap= WM_keymap_listbase(wm, "File", SPACE_FILE, 0);
|
||||
WM_keymap_add_item(keymap, "FILE_OT_bookmark_toggle", NKEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "FILE_OT_select", LEFTMOUSE, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "FILE_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "FILE_OT_select_border", BKEY, KM_PRESS, 0, 0);
|
||||
@@ -295,56 +314,31 @@ void file_keymap(struct wmWindowManager *wm)
|
||||
|
||||
static void file_channel_area_init(wmWindowManager *wm, ARegion *ar)
|
||||
{
|
||||
ListBase *keymap;
|
||||
|
||||
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy);
|
||||
|
||||
/* own keymap */
|
||||
keymap= WM_keymap_listbase(wm, "FileBookmark", SPACE_FILE, 0);
|
||||
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, NULL, NULL);
|
||||
ED_region_panels_init(wm, ar);
|
||||
}
|
||||
|
||||
static void file_channel_area_draw(const bContext *C, ARegion *ar)
|
||||
{
|
||||
View2D *v2d= &ar->v2d;
|
||||
float col[3];
|
||||
ED_region_panels(C, ar, 1, NULL);
|
||||
}
|
||||
|
||||
UI_GetThemeColor3fv(TH_PANEL, col);
|
||||
glClearColor(col[0], col[1], col[2], 0.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
/* data... */
|
||||
UI_view2d_view_ortho(C, v2d);
|
||||
|
||||
file_draw_fsmenu(C, ar);
|
||||
static void file_channel_area_listener(ARegion *ar, wmNotifier *wmn)
|
||||
{
|
||||
/* context changes */
|
||||
switch(wmn->category) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* add handlers, stuff you only do once or on area/region changes */
|
||||
static void file_header_area_init(wmWindowManager *wm, ARegion *ar)
|
||||
{
|
||||
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy);
|
||||
ED_region_header_init(ar);
|
||||
}
|
||||
|
||||
static void file_header_area_draw(const bContext *C, ARegion *ar)
|
||||
{
|
||||
float col[3];
|
||||
|
||||
/* clear */
|
||||
if(ED_screen_area_active(C))
|
||||
UI_GetThemeColor3fv(TH_HEADER, col);
|
||||
else
|
||||
UI_GetThemeColor3fv(TH_HEADERDESEL, col);
|
||||
|
||||
glClearColor(col[0], col[1], col[2], 0.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
/* set view2d view matrix for scrolling (without scrollers) */
|
||||
UI_view2d_view_ortho(C, &ar->v2d);
|
||||
|
||||
file_header_buttons(C, ar);
|
||||
|
||||
/* restore view matrix? */
|
||||
UI_view2d_view_restore(C);
|
||||
ED_region_header(C, ar);
|
||||
}
|
||||
|
||||
/* add handlers, stuff you only do once or on area/region changes */
|
||||
@@ -386,6 +380,8 @@ void ED_spacetype_file(void)
|
||||
st->free= file_free;
|
||||
st->init= file_init;
|
||||
st->duplicate= file_duplicate;
|
||||
st->refresh= file_refresh;
|
||||
st->listener= file_listener;
|
||||
st->operatortypes= file_operatortypes;
|
||||
st->keymap= file_keymap;
|
||||
|
||||
@@ -405,6 +401,7 @@ void ED_spacetype_file(void)
|
||||
art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D;
|
||||
art->init= file_header_area_init;
|
||||
art->draw= file_header_area_draw;
|
||||
// art->listener= file_header_area_listener;
|
||||
BLI_addhead(&st->regiontypes, art);
|
||||
|
||||
/* regions: ui */
|
||||
@@ -421,10 +418,13 @@ void ED_spacetype_file(void)
|
||||
art->regionid = RGN_TYPE_CHANNELS;
|
||||
art->minsizex= 240;
|
||||
art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D;
|
||||
art->listener= file_channel_area_listener;
|
||||
art->init= file_channel_area_init;
|
||||
art->draw= file_channel_area_draw;
|
||||
BLI_addhead(&st->regiontypes, art);
|
||||
|
||||
file_panels_register(art);
|
||||
|
||||
|
||||
BKE_spacetype_register(st);
|
||||
|
||||
}
|
||||
|
||||
@@ -165,6 +165,48 @@ typedef struct SpaceSeq {
|
||||
struct bGPdata *gpd; /* grease-pencil data */
|
||||
} SpaceSeq;
|
||||
|
||||
typedef struct FileSelectParams {
|
||||
char title[24]; /* title, also used for the text of the execute button */
|
||||
char dir[240]; /* directory */
|
||||
char file[80]; /* file */
|
||||
|
||||
short flag; /* settings for filter, hiding files and display mode */
|
||||
short sort; /* sort order */
|
||||
short display; /* display mode flag */
|
||||
short filter; /* filter when (flags & FILE_FILTER) is true */
|
||||
|
||||
/* XXX - temporary, better move to filelist */
|
||||
short active_bookmark;
|
||||
short pad;
|
||||
int active_file;
|
||||
int selstate;
|
||||
|
||||
/* XXX --- still unused -- */
|
||||
short f_fp; /* show font preview */
|
||||
short menu; /* currently selected option in pupmenu */
|
||||
char fp_str[8]; /* string to use for font preview */
|
||||
|
||||
char *pupmenu; /* allows menu for save options - result stored in menup */
|
||||
|
||||
/* XXX --- end unused -- */
|
||||
} FileSelectParams;
|
||||
|
||||
/* FileSelectParams.display */
|
||||
enum FileDisplayTypeE {
|
||||
FILE_SHORTDISPLAY = 1,
|
||||
FILE_LONGDISPLAY,
|
||||
FILE_IMGDISPLAY
|
||||
};
|
||||
|
||||
/* FileSelectParams.sort */
|
||||
enum FileSortTypeE {
|
||||
FILE_SORT_NONE = 0,
|
||||
FILE_SORT_ALPHA = 1,
|
||||
FILE_SORT_EXTENSION,
|
||||
FILE_SORT_TIME,
|
||||
FILE_SORT_SIZE
|
||||
};
|
||||
|
||||
typedef struct SpaceFile {
|
||||
SpaceLink *next, *prev;
|
||||
ListBase regionbase; /* storage of regions for inactive spaces */
|
||||
@@ -554,12 +596,6 @@ typedef struct SpaceImaSel {
|
||||
#define FILE_FILTER 256
|
||||
#define FILE_BOOKMARKS 512
|
||||
|
||||
/* sfile->sort */
|
||||
#define FILE_SORTALPHA 0
|
||||
#define FILE_SORTDATE 1
|
||||
#define FILE_SORTSIZE 2
|
||||
#define FILE_SORTEXTENS 3
|
||||
|
||||
/* files in filesel list: 2=ACTIVE */
|
||||
#define HILITE 1
|
||||
#define BLENDERFILE 4
|
||||
|
||||
@@ -174,6 +174,7 @@ extern StructRNA RNA_ExplodeModifier;
|
||||
extern StructRNA RNA_ExpressionController;
|
||||
extern StructRNA RNA_Event;
|
||||
extern StructRNA RNA_FCurve;
|
||||
extern StructRNA RNA_FileSelectParams;
|
||||
extern StructRNA RNA_FModifier;
|
||||
extern StructRNA RNA_FModifierCycles;
|
||||
extern StructRNA RNA_FModifierEnvelope;
|
||||
@@ -369,6 +370,7 @@ extern StructRNA RNA_SpaceImageEditor;
|
||||
extern StructRNA RNA_SpaceOutliner;
|
||||
extern StructRNA RNA_SpaceSequenceEditor;
|
||||
extern StructRNA RNA_SpaceTextEditor;
|
||||
extern StructRNA RNA_SpaceFileBrowser;
|
||||
extern StructRNA RNA_SpaceUVEditor;
|
||||
extern StructRNA RNA_SpeedControlSequence;
|
||||
extern StructRNA RNA_SpotLamp;
|
||||
|
||||
@@ -96,8 +96,8 @@ static StructRNA* rna_Space_refine(struct PointerRNA *ptr)
|
||||
return &RNA_SpaceOutliner;
|
||||
case SPACE_BUTS:
|
||||
return &RNA_SpaceButtonsWindow;
|
||||
/* case SPACE_FILE:
|
||||
return &RNA_SpaceFileBrowser;*/
|
||||
case SPACE_FILE:
|
||||
return &RNA_SpaceFileBrowser;
|
||||
case SPACE_IMAGE:
|
||||
return &RNA_SpaceImageEditor;
|
||||
/*case SPACE_INFO:
|
||||
@@ -210,6 +210,13 @@ void rna_SpaceTextEditor_text_set(PointerRNA *ptr, PointerRNA value)
|
||||
st->top= 0;
|
||||
}
|
||||
|
||||
void rna_SpaceFileBrowser_params_set(PointerRNA *ptr, PointerRNA value)
|
||||
{
|
||||
SpaceFile *sfile= (SpaceFile*)(ptr->data);
|
||||
|
||||
sfile->params= value.data;
|
||||
}
|
||||
|
||||
/* Space Buttons */
|
||||
|
||||
StructRNA *rna_SpaceButtonsWindow_pin_id_typef(PointerRNA *ptr)
|
||||
@@ -860,12 +867,124 @@ static void rna_def_space_text(BlenderRNA *brna)
|
||||
RNA_def_property_ui_text(prop, "Replace Text", "Text to replace selected text with using the replace tool.");
|
||||
}
|
||||
|
||||
static void rna_def_fileselect_params(BlenderRNA *brna)
|
||||
{
|
||||
StructRNA *srna;
|
||||
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}};
|
||||
|
||||
static EnumPropertyItem file_sort_items[] = {
|
||||
{FILE_SORT_ALPHA, "FILE_SORT_ALPHA", ICON_SORTALPHA, "Sort alphabetically", "Sort the file list alphabetically."},
|
||||
{FILE_SORT_EXTENSION, "FILE_SORT_EXTENSION", ICON_SORTBYEXT, "Sort by extension", "Sort the file list by extension."},
|
||||
{FILE_SORT_TIME, "FILE_SORT_TIME", ICON_SORTTIME, "Sort by time", "Sort files by modification time."},
|
||||
{FILE_SORT_SIZE, "FILE_SORT_SIZE", ICON_SORTSIZE, "Sort by size", "Sort files by size."},
|
||||
{0, NULL, 0, NULL, NULL}};
|
||||
|
||||
srna= RNA_def_struct(brna, "FileSelectParams", NULL);
|
||||
RNA_def_struct_ui_text(srna, "File Select Parameters", "File Select Parameters.");
|
||||
|
||||
prop= RNA_def_property(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");
|
||||
RNA_def_property_update(prop, NC_FILE | ND_PARAMS, NULL);
|
||||
|
||||
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);
|
||||
|
||||
prop= RNA_def_property(srna, "hide_dot", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "flag", FILE_HIDE_DOT);
|
||||
RNA_def_property_ui_text(prop, "Hide Dot Files", "Hide hidden dot files.");
|
||||
RNA_def_property_update(prop, NC_FILE | ND_FILELIST , NULL);
|
||||
|
||||
prop= RNA_def_property(srna, "sort", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_sdna(prop, NULL, "sort");
|
||||
RNA_def_property_enum_items(prop, file_sort_items);
|
||||
RNA_def_property_ui_text(prop, "Sort", "");
|
||||
RNA_def_property_update(prop, NC_FILE | ND_PARAMS, NULL);
|
||||
|
||||
prop= RNA_def_property(srna, "filter_image", PROP_BOOLEAN, PROP_NONE);
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
|
||||
}
|
||||
|
||||
static void rna_def_space_filebrowser(BlenderRNA *brna)
|
||||
{
|
||||
StructRNA *srna;
|
||||
PropertyRNA *prop;
|
||||
|
||||
srna= RNA_def_struct(brna, "SpaceFileBrowser", "Space");
|
||||
RNA_def_struct_sdna(srna, "SpaceFile");
|
||||
RNA_def_struct_ui_text(srna, "Space File Browser", "File browser space data.");
|
||||
|
||||
prop= RNA_def_property(srna, "params", PROP_POINTER, PROP_NONE);
|
||||
RNA_def_property_pointer_sdna(prop, NULL, "params");
|
||||
RNA_def_property_pointer_funcs(prop, NULL, "rna_SpaceFileBrowser_params_set", NULL);
|
||||
RNA_def_property_ui_text(prop, "Filebrowser Parameter", "Parameters and Settings for the Filebrowser.");
|
||||
|
||||
}
|
||||
|
||||
void RNA_def_space(BlenderRNA *brna)
|
||||
{
|
||||
rna_def_space(brna);
|
||||
rna_def_space_image(brna);
|
||||
rna_def_space_sequencer(brna);
|
||||
rna_def_space_text(brna);
|
||||
rna_def_fileselect_params(brna);
|
||||
rna_def_space_filebrowser(brna);
|
||||
rna_def_space_outliner(brna);
|
||||
rna_def_background_image(brna);
|
||||
rna_def_space_3dview(brna);
|
||||
|
||||
@@ -128,6 +128,7 @@ typedef struct wmNotifier {
|
||||
#define NC_BRUSH (11<<24)
|
||||
#define NC_TEXT (12<<24)
|
||||
#define NC_WORLD (13<<24)
|
||||
#define NC_FILE (14<<24)
|
||||
|
||||
/* data type, 256 entries is enough, it can overlap */
|
||||
#define NOTE_DATA 0x00FF0000
|
||||
@@ -182,6 +183,10 @@ typedef struct wmNotifier {
|
||||
/* NC_TEXT Text */
|
||||
#define ND_CURSOR (50<<16)
|
||||
#define ND_DISPLAY (51<<16)
|
||||
|
||||
/* NC_FILE Filebrowser */
|
||||
#define ND_PARAMS (60<<16)
|
||||
#define ND_FILELIST (61<<16)
|
||||
|
||||
/* subtype, 256 entries too */
|
||||
#define NOTE_SUBTYPE 0x0000FF00
|
||||
|
||||
@@ -776,7 +776,7 @@ static int wm_handler_fileselect_call(bContext *C, ListBase *handlers, wmEventHa
|
||||
case EVT_FILESELECT_OPEN:
|
||||
case EVT_FILESELECT_FULL_OPEN:
|
||||
{
|
||||
short flag =0; short display =FILE_SHORTDISPLAY; short filter =0; short sort =FILE_SORTALPHA;
|
||||
short flag =0; short display =FILE_SHORTDISPLAY; short filter =0; short sort =FILE_SORT_ALPHA;
|
||||
char *path= RNA_string_get_alloc(handler->op->ptr, "filename", NULL, 0);
|
||||
|
||||
if(event->val==EVT_FILESELECT_OPEN)
|
||||
|
||||
Reference in New Issue
Block a user