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!
This commit is contained in:
@@ -367,9 +367,16 @@ static int view_scrolldown_exec(bContext *C, wmOperator *op)
|
||||
return OPERATOR_PASS_THROUGH;
|
||||
}
|
||||
|
||||
/* set RNA-Props - only movement in positive x-direction */
|
||||
RNA_int_set(op->ptr, "deltax", 0);
|
||||
RNA_int_set(op->ptr, "deltay", -20);
|
||||
/* set RNA-Props */
|
||||
/* automatically fall back to horizontal on this exception: */
|
||||
if( ELEM(vpd->v2d->scroll, V2D_SCROLL_BOTTOM, V2D_SCROLL_TOP) ) {
|
||||
RNA_int_set(op->ptr, "deltax", -20);
|
||||
RNA_int_set(op->ptr, "deltay", 0);
|
||||
}
|
||||
else {
|
||||
RNA_int_set(op->ptr, "deltax", 0);
|
||||
RNA_int_set(op->ptr, "deltay", -20);
|
||||
}
|
||||
|
||||
/* apply movement, then we're done */
|
||||
view_pan_apply(C, op);
|
||||
@@ -413,9 +420,16 @@ static int view_scrollup_exec(bContext *C, wmOperator *op)
|
||||
return OPERATOR_PASS_THROUGH;
|
||||
}
|
||||
|
||||
/* set RNA-Props - only movement in negative x-direction */
|
||||
RNA_int_set(op->ptr, "deltax", 0);
|
||||
RNA_int_set(op->ptr, "deltay", 20);
|
||||
/* set RNA-Props */
|
||||
/* automatically fall back to horizontal on this exception: */
|
||||
if( ELEM(vpd->v2d->scroll, V2D_SCROLL_BOTTOM, V2D_SCROLL_TOP) ) {
|
||||
RNA_int_set(op->ptr, "deltax", 20);
|
||||
RNA_int_set(op->ptr, "deltay", 0);
|
||||
}
|
||||
else {
|
||||
RNA_int_set(op->ptr, "deltax", 0);
|
||||
RNA_int_set(op->ptr, "deltay", 20);
|
||||
}
|
||||
|
||||
/* apply movement, then we're done */
|
||||
view_pan_apply(C, op);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user