2.5 filebrowser

- WIP commit
- bookmarks toggling (region collapsing needs to be done still)
- switching between display types in header (long filenames needs to be done still)
This commit is contained in:
2009-03-03 13:15:40 +00:00
parent ead30e5bc1
commit 0f040e2f26
6 changed files with 52 additions and 36 deletions

View File

@@ -30,6 +30,10 @@
struct SpaceFile;
#define FILE_SHORTDISPLAY 1
#define FILE_LONGDISPLAY 2
#define FILE_IMGDISPLAY 3
typedef struct FileSelectParams {
int type; /* the mode of the filebrowser, FILE_BLENDER, FILE_SPECIAL, FILE_MAIN or FILE_LOADLIB */
char title[24]; /* title, also used for the text of the execute button */

View File

@@ -606,7 +606,7 @@ typedef enum {
ICON_LONGDISPLAY,
ICON_SHORTDISPLAY,
ICON_GHOST,
ICON_BLANK283,
ICON_IMGDISPLAY,
ICON_BLANK284,
ICON_BLANK285,
ICON_FOLDER_DEHLT,

View File

@@ -262,7 +262,7 @@ void file_calc_previews(const bContext *C, ARegion *ar)
int width=0, height=0;
int rows, columns;
if (params->display) {
if (params->display == FILE_IMGDISPLAY) {
sfile->prv_w = 96;
sfile->prv_h = 96;
sfile->tile_border_x = 4;
@@ -531,39 +531,41 @@ void file_draw_fsmenu(const bContext *C, ARegion *ar)
int bmwidth = ar->v2d.cur.xmax - ar->v2d.cur.xmin - 2*TILE_BORDER_X;
int fontsize = U.fontsize;
sx = ar->v2d.cur.xmin + TILE_BORDER_X;
sy = ar->v2d.cur.ymax-2*TILE_BORDER_Y;
for (i=0; i< nentries && (sy > ar->v2d.cur.ymin) ;++i) {
char *fname = fsmenu_get_entry(i);
if (params->flag & FILE_BOOKMARKS) {
sx = ar->v2d.cur.xmin + TILE_BORDER_X;
sy = ar->v2d.cur.ymax-2*TILE_BORDER_Y;
for (i=0; i< nentries && (sy > ar->v2d.cur.ymin) ;++i) {
char *fname = fsmenu_get_entry(i);
if (fname) {
int sl;
BLI_strncpy(bookmark, fname, FILE_MAX);
sl = strlen(bookmark)-1;
while (bookmark[sl] == '\\' || bookmark[sl] == '/') {
bookmark[sl] = '\0';
sl--;
}
if (params->active_bookmark == i ) {
glColor4ub(0, 0, 0, 100);
UI_ThemeColor(TH_HILITE);
uiSetRoundBox(15);
uiRoundBox(sx, sy - linestep, sx + bmwidth, sy, 6);
// glRecti(sx, sy - linestep, sx + bmwidth, sy);
UI_ThemeColor(TH_TEXT_HI);
if (fname) {
int sl;
BLI_strncpy(bookmark, fname, FILE_MAX);
sl = strlen(bookmark)-1;
while (bookmark[sl] == '\\' || bookmark[sl] == '/') {
bookmark[sl] = '\0';
sl--;
}
if (params->active_bookmark == i ) {
glColor4ub(0, 0, 0, 100);
UI_ThemeColor(TH_HILITE);
uiSetRoundBox(15);
uiRoundBox(sx, sy - linestep, sx + bmwidth, sy, 6);
// glRecti(sx, sy - linestep, sx + bmwidth, sy);
UI_ThemeColor(TH_TEXT_HI);
} else {
UI_ThemeColor(TH_TEXT);
}
file_draw_string(sx, sy, bookmark, bmwidth, fontsize);
sy -= linestep;
} else {
UI_ThemeColor(TH_TEXT);
glColor4ub(0xB0,0xB0,0xB0, 0xFF);
sdrawline(sx, sy-1-fontsize/2 , sx + bmwidth, sy-1-fontsize/2);
glColor4ub(0x30,0x30,0x30, 0xFF);
sdrawline(sx, sy-fontsize/2 , sx + bmwidth, sy - fontsize/2);
sy -= linestep;
}
file_draw_string(sx, sy, bookmark, bmwidth, fontsize);
sy -= linestep;
} else {
glColor4ub(0xB0,0xB0,0xB0, 0xFF);
sdrawline(sx, sy-1-fontsize/2 , sx + bmwidth, sy-1-fontsize/2);
glColor4ub(0x30,0x30,0x30, 0xFF);
sdrawline(sx, sy-fontsize/2 , sx + bmwidth, sy - fontsize/2);
sy -= linestep;
}
}
}

View File

@@ -141,6 +141,7 @@ void file_header_buttons(const bContext *C, ARegion *ar)
}
/* SORT TYPE */
uiBlockSetEmboss(block, UI_EMBOSSX);
xco+=XIC;
uiBlockBeginAlign(block);
uiDefIconButS(block, ROW, B_SORTIMASELLIST, ICON_SORTALPHA, xco+=XIC,0,XIC,YIC, &params->sort, 1.0, 0.0, 0, 0, "Sorts files alphabetically");
@@ -151,7 +152,16 @@ void file_header_buttons(const bContext *C, ARegion *ar)
xco+=XIC+10;
if (sfile->params->type != FILE_MAIN) {
uiDefIconButBitS(block, TOG, 1, B_RELOADIMASELDIR, ICON_BOOKMARKS,xco+=XIC,0,XIC,YIC, &params->display, 0, 0, 0, 0, "Toggles Bookmarks on/off");
uiDefIconButBitS(block, TOG, FILE_BOOKMARKS, B_RELOADIMASELDIR, ICON_BOOKMARKS,xco+=XIC,0,XIC,YIC, &params->flag, 0, 0, 0, 0, "Toggles Bookmarks on/off");
xco+=XIC+10;
}
if (sfile->params->type != FILE_MAIN) {
uiBlockBeginAlign(block);
uiDefIconButS(block, ROW, B_RELOADIMASELDIR, ICON_SHORTDISPLAY, xco+=XIC,0,XIC,YIC, &params->display, 1.0, 1.0, 0, 0, "Displays short file description");
uiDefIconButS(block, ROW, B_RELOADIMASELDIR, ICON_LONGDISPLAY, xco+=XIC,0,XIC,YIC, &params->display, 1.0, 2.0, 0, 0, "Displays long file description");
uiDefIconButS(block, ROW, B_RELOADIMASELDIR, ICON_IMAGE_COL /* ICON_IMGDISPLAY */, xco+=XIC,0,XIC,YIC, &params->display, 1.0, 3.0, 0, 0, "Displays files as thumbnails");
uiBlockEndAlign(block);
xco+=XIC+10;
}
xcotitle= xco;

View File

@@ -417,7 +417,7 @@ int file_hilight_set(SpaceFile *sfile, ARegion *ar, int mx, int my)
numfiles = filelist_numfiles(sfile->files);
params = ED_fileselect_get_params(sfile);
if (params->display) {
if (params->display == FILE_IMGDISPLAY) {
actfile = find_file_mouse_hor(sfile, ar, mx , my);
} else {
actfile = find_file_mouse_vert(sfile, ar, mx, my);

View File

@@ -209,7 +209,7 @@ static void file_main_area_draw(const bContext *C, ARegion *ar)
glClear(GL_COLOR_BUFFER_BIT);
/* Allow dynamically sliders to be set, saves notifiers etc. */
if (sfile->params && sfile->params->display)
if (sfile->params && (sfile->params->display == FILE_IMGDISPLAY) )
v2d->scroll = V2D_SCROLL_RIGHT;
else
v2d->scroll = V2D_SCROLL_BOTTOM;
@@ -228,7 +228,7 @@ static void file_main_area_draw(const bContext *C, ARegion *ar)
file_hilight_set(sfile, ar, event->x - ar->winrct.xmin, event->y - ar->winrct.ymin);
}
if (params->display) {
if (params->display == FILE_IMGDISPLAY) {
file_draw_previews(C, ar);
} else {
file_draw_list(C, ar);