diff options
author | Ton Roosendaal <ton@blender.org> | 2009-02-17 16:11:09 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2009-02-17 16:11:09 +0300 |
commit | 8020515ab2bf52aedc4250a51f7f928f057092e4 (patch) | |
tree | cfaa18eefa60d6c62d2d4cbbe5e0110e3f12b7fe /source/blender/editors/space_file | |
parent | ba3cacc33f392297ec8658535aaa82d2ac34dc35 (diff) |
2.5
Small fixes for filewindow;
- on resize area/window, the load button disappeared.
- made scrollers indicate what direction works
- mousewheel scroll switches to horizontal automatically now
(assuming we keep filelists horiz, previews vertical scrolled)
View2d got hacked a bit by me for it; i guess for some cases
the scroll value should become customizable. Will come back
later!
Diffstat (limited to 'source/blender/editors/space_file')
-rw-r--r-- | source/blender/editors/space_file/file_draw.c | 11 | ||||
-rw-r--r-- | source/blender/editors/space_file/space_file.c | 37 |
2 files changed, 22 insertions, 26 deletions
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index 4cd511082c0..29faf660575 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -103,6 +103,7 @@ static void do_file_buttons(bContext *C, void *arg, int event) } } +/* note; this function uses pixelspace (0, 0, winx, winy), not view2d */ void file_draw_buttons(const bContext *C, ARegion *ar) { SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C); @@ -118,14 +119,14 @@ void file_draw_buttons(const bContext *C, ARegion *ar) int filebuty1, filebuty2; - float xmin = ar->v2d.mask.xmin + 10; - float xmax = ar->v2d.mask.xmax - 10; + float xmin = 10; + float xmax = ar->winx - 10; - filebuty1= ar->v2d.mask.ymax - IMASEL_BUTTONS_HEIGHT; + filebuty1= ar->winy - IMASEL_BUTTONS_HEIGHT; filebuty2= filebuty1+IMASEL_BUTTONS_HEIGHT/2 -6; /* HEADER */ - sprintf(name, "win %d", 1); // XXX sa-win??? + sprintf(name, "win %p", ar); block = uiBeginBlock(C, ar, name, UI_EMBOSS, UI_HELV); uiBlockSetHandleFunc(block, do_file_buttons, NULL); @@ -136,7 +137,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.cur.xmax-ar->v2d.cur.xmin > loadbutton+20) { + if(ar->winx > loadbutton+20) { if(params->title[0]==0) { loadbutton= 0; } diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index 6eed864ff47..c73c6e7b6a9 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -128,35 +128,21 @@ static void file_free(SpaceLink *sl) } -/* spacetype; init callback */ +/* spacetype; init callback, area size changes, screen set, etc */ static void file_init(struct wmWindowManager *wm, ScrArea *sa) { - SpaceFile *sfile= sa->spacedata.first; /* XXX get through context? */ - if (sfile->params) { - ED_fileselect_reset_params(sfile); - } - if (sfile->files) { - filelist_free(sfile->files); - filelist_freelib(sfile->files); - MEM_freeN(sfile->files); - sfile->files= NULL; - } } + static SpaceLink *file_duplicate(SpaceLink *sl) { SpaceFile *sfileo= (SpaceFile*)sl; SpaceFile *sfilen= MEM_dupallocN(sl); /* clear or remove stuff from old */ - sfilen->op = NULL; // XXX check if operator can be duplicated + sfilen->op = NULL; /* file window doesn't own operators */ sfilen->params= MEM_dupallocN(sfileo->params); - if (!sfilen->params) { - sfilen->params= MEM_callocN(sizeof(FileSelectParams), "fileselparams"); - ED_fileselect_set_params(sfilen, FILE_UNIX, "", "/", 0, 0, 0); - sfilen->params->pupmenu = NULL; - } sfilen->files = filelist_new(); filelist_setdir(sfilen->files, sfilen->params->dir); @@ -176,6 +162,8 @@ static void file_main_area_init(wmWindowManager *wm, ARegion *ar) /* own keymap */ keymap= WM_keymap_listbase(wm, "File", SPACE_FILE, 0); /* XXX weak? */ WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); + + } static void file_main_area_draw(const bContext *C, ARegion *ar) @@ -215,19 +203,26 @@ static void file_main_area_draw(const bContext *C, ARegion *ar) glClearColor(col[0], col[1], col[2], 0.0); glClear(GL_COLOR_BUFFER_BIT); + /* Allow dynamically sliders to be set, saves notifiers etc. */ + if (sfile->params && sfile->params->display) + v2d->scroll = V2D_SCROLL_RIGHT; + else + v2d->scroll = V2D_SCROLL_BOTTOM; + /* v2d has initialized flag, so this call will only set the mask correct */ + UI_view2d_region_reinit(v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy); + /* sets tile/border settings in sfile */ file_calc_previews(C, ar); + /* set view */ + UI_view2d_view_ortho(C, v2d); + /* on first read, find active file */ if (params->active_file == -1) { wmEvent *event= CTX_wm_window(C)->eventstate; file_hilight_set(sfile, ar, event->x - ar->winrct.xmin, event->y - ar->winrct.ymin); - } - /* data... */ - UI_view2d_view_ortho(C, v2d); - if (params->display) { file_draw_previews(C, ar); } else { |