From dafc620a7514ff55dfd99cdea176447edef88e9e Mon Sep 17 00:00:00 2001 From: Andrea Weikert Date: Sun, 1 Feb 2009 13:52:11 +0000 Subject: [PATCH] 2.5 filebrowser small fix for selection of bookmarks/favorite folders --- source/blender/editors/space_file/file_draw.c | 4 ++-- source/blender/editors/space_file/file_ops.c | 11 ++++++++--- source/blender/editors/space_file/fsmenu.c | 2 +- source/blender/windowmanager/intern/wm_operators.c | 2 +- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index 4f34aac70c0..ac05471ff8b 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -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); diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index c6ed0d159d6..8b8fcbe57fa 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -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) { diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c index b4b2688ed7b..4ea62ea0397 100644 --- a/source/blender/editors/space_file/fsmenu.c +++ b/source/blender/editors/space_file/fsmenu.c @@ -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 */ diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 0ae47c029c2..707cd5f2254 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -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 */