Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Weikert <elubie@gmx.net>2009-06-30 00:23:40 +0400
committerAndrea Weikert <elubie@gmx.net>2009-06-30 00:23:40 +0400
commit5e20f574310626c453b7372c6e3d0dcf2c575b74 (patch)
treec65adf1d04a2ae6f45d5080e933ac00d3aa070d2 /source/blender/editors/space_file
parent5d491681e0d1e6b8450dedc64bd45408bb9066cd (diff)
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.
Diffstat (limited to 'source/blender/editors/space_file')
-rw-r--r--source/blender/editors/space_file/file_draw.c128
-rw-r--r--source/blender/editors/space_file/file_intern.h9
-rw-r--r--source/blender/editors/space_file/file_ops.c109
-rw-r--r--source/blender/editors/space_file/file_panels.c124
-rw-r--r--source/blender/editors/space_file/filelist.c8
-rw-r--r--source/blender/editors/space_file/filelist.h1
-rw-r--r--source/blender/editors/space_file/filesel.c2
-rw-r--r--source/blender/editors/space_file/space_file.c118
8 files changed, 235 insertions, 264 deletions
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index bb47d3458fe..02ee8f508c1 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -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);
- }
-}
diff --git a/source/blender/editors/space_file/file_intern.h b/source/blender/editors/space_file/file_intern.h
index 642189ad3fd..6ce30bb48cb 100644
--- a/source/blender/editors/space_file/file_intern.h
+++ b/source/blender/editors/space_file/file_intern.h
@@ -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 */
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index ab02147d020..ebece6dd5e6 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -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)
diff --git a/source/blender/editors/space_file/file_panels.c b/source/blender/editors/space_file/file_panels.c
new file mode 100644
index 00000000000..815345f34c8
--- /dev/null
+++ b/source/blender/editors/space_file/file_panels.c
@@ -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);
+} \ No newline at end of file
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index 766dec7c064..573aed72728 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -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);
}
diff --git a/source/blender/editors/space_file/filelist.h b/source/blender/editors/space_file/filelist.h
index f10c89926d6..e929e028849 100644
--- a/source/blender/editors/space_file/filelist.h
+++ b/source/blender/editors/space_file/filelist.h
@@ -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);
diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c
index 479d9cabc55..ea42ad80fe6 100644
--- a/source/blender/editors/space_file/filesel.c
+++ b/source/blender/editors/space_file/filesel.c
@@ -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;
}
diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c
index 37d8f2bffa4..4ed92d3f5d9 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -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];
-
- 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);
+ ED_region_panels(C, ar, 1, NULL);
+}
- 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);
}