2.5 filebrowser

small fix for selection of bookmarks/favorite folders
This commit is contained in:
2009-02-01 13:52:11 +00:00
parent 3783d7fcbb
commit dafc620a75
4 changed files with 12 additions and 7 deletions

View File

@@ -132,7 +132,7 @@ void file_draw_buttons(const bContext *C, ARegion *ar)
/* space available for load/save buttons? */
slen = UI_GetStringWidth(G.font, sfile->params->title, 0);
loadbutton= slen > 60 ? slen + 20 : MAX2(80, 20+UI_GetStringWidth(G.font, params->title, 0));
if(ar->v2d.mask.xmax-ar->v2d.mask.xmin > loadbutton+20) {
if(ar->v2d.cur.xmax-ar->v2d.cur.xmin > loadbutton+20) {
if(params->title[0]==0) {
loadbutton= 0;
}
@@ -544,7 +544,7 @@ void file_draw_fsmenu(const bContext *C, ARegion *ar)
int fontsize = U.fontsize;
sx = ar->v2d.cur.xmin + TILE_BORDER_X;
sy = -2*TILE_BORDER_Y;
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);

View File

@@ -318,10 +318,15 @@ void ED_FILE_OT_select_all(wmOperatorType *ot)
/* ---------- BOOKMARKS ----------- */
static void set_active_bookmark(FileSelectParams* params, struct ARegion* ar, short y)
static void set_active_bookmark(FileSelectParams* params, struct ARegion* ar, short x, short y)
{
int nentries = fsmenu_get_nentries();
short posy = ar->v2d.mask.ymax - TILE_BORDER_Y - y;
float fx, fy;
short posy;
UI_view2d_region_to_view(&ar->v2d, x, y, &fx, &fy);
posy = ar->v2d.cur.ymax - 2*TILE_BORDER_Y - fy;
params->active_bookmark = ((float)posy / (U.fontsize*3.0f/2.0f));
if (params->active_bookmark < 0 || params->active_bookmark > nentries) {
params->active_bookmark = -1;
@@ -332,7 +337,7 @@ static void file_select_bookmark(SpaceFile* sfile, ARegion* ar, short x, short y
{
if (BLI_in_rcti(&ar->v2d.mask, x, y)) {
char *selected;
set_active_bookmark(sfile->params, ar, y);
set_active_bookmark(sfile->params, ar, x, y);
selected= fsmenu_get_entry(sfile->params->active_bookmark);
/* which string */
if (selected) {

View File

@@ -280,7 +280,7 @@ void fsmenu_read_file(const char *filename)
}
#endif
fp = fopen(filename, "w");
fp = fopen(filename, "r");
if (!fp) return;
while ( fgets ( line, 256, fp ) != NULL ) /* read a line */

View File

@@ -370,7 +370,7 @@ static int wm_mainfile_invoke(bContext *C, wmOperator *op, wmEvent *event)
sfile= (SpaceFile*)CTX_wm_space_data(C);
sfile->op = op;
// XXX replace G.sce
ED_fileselect_set_params(sfile, FILE_BLENDER, "Load As", G.sce, 0, 0, 0);
ED_fileselect_set_params(sfile, FILE_BLENDER, "Load", G.sce, 0, 0, 0);
/* screen and area have been reset already in ED_screen_full_newspace */