diff options
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 13 | ||||
-rw-r--r-- | source/blender/editors/interface/interface.h | 1 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_draw.c | 131 | ||||
-rw-r--r-- | source/blender/editors/interface/view2d.c | 186 | ||||
-rw-r--r-- | source/blender/editors/interface/view2d_ops.c | 15 | ||||
-rw-r--r-- | source/blender/editors/space_buttons/space_buttons.c | 5 | ||||
-rw-r--r-- | source/blender/editors/space_node/space_node.c | 3 | ||||
-rw-r--r-- | source/blender/editors/space_outliner/space_outliner.c | 6 | ||||
-rw-r--r-- | source/blender/editors/space_time/space_time.c | 7 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_view2d_types.h | 3 |
10 files changed, 273 insertions, 97 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index a2b08e4890b..93cacaf61a1 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -5052,8 +5052,7 @@ static void area_add_header_region(ScrArea *sa, ListBase *lb) /* initialise view2d data for header region, to allow panning */ /* is copy from ui_view2d.c */ - ar->v2d.keepaspect= 1; - ar->v2d.keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_KEEPZOOM); + ar->v2d.keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_KEEPZOOM|V2D_KEEPASPECT); ar->v2d.keepofs = V2D_LOCKOFS_Y; ar->v2d.keeptot = 2; // this keeps the view in place when region size changes... ar->v2d.align = V2D_ALIGN_NO_NEG_X; @@ -5101,9 +5100,8 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb) ar->v2d.scroll &= ~V2D_SCROLL_LEFT; ar->v2d.scroll |= (V2D_SCROLL_RIGHT|V2D_SCROLL_HORIZONTAL_O); ar->v2d.align = (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_POS_Y); - ar->v2d.keepzoom |= (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y); + ar->v2d.keepzoom |= (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_KEEPASPECT); ar->v2d.keeptot = 2; - ar->v2d.keepaspect= 1; } break; case SPACE_TIME: @@ -5115,7 +5113,8 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb) ar->v2d.align |= V2D_ALIGN_NO_NEG_Y; ar->v2d.keepofs |= V2D_LOCKOFS_Y; ar->v2d.keepzoom |= V2D_LOCKZOOM_Y; - ar->v2d.min[1]= ar->v2d.max[1]= 500.0; + ar->v2d.tot.ymin= ar->v2d.cur.ymin= -10.0; + ar->v2d.min[1]= ar->v2d.max[1]= 20.0; } break; case SPACE_IPO: @@ -5137,6 +5136,7 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb) { SpaceButs *sbuts= (SpaceButs *)sl; memcpy(&ar->v2d, &sbuts->v2d, sizeof(View2D)); + ar->v2d.keepzoom |= V2D_KEEPASPECT; break; } //case SPACE_XXX: // FIXME... add other ones @@ -7439,8 +7439,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) simasel->v2d.minzoom= 0.5f; simasel->v2d.maxzoom= 1.21f; simasel->v2d.scroll= 0; - simasel->v2d.keepaspect= 1; - simasel->v2d.keepzoom= 1; + simasel->v2d.keepzoom= V2D_KEEPZOOM|V2D_KEEPASPECT; simasel->v2d.keeptot= 0; simasel->prv_h = 96; simasel->prv_w = 96; diff --git a/source/blender/editors/interface/interface.h b/source/blender/editors/interface/interface.h index 330639cce93..fac72b22089 100644 --- a/source/blender/editors/interface/interface.h +++ b/source/blender/editors/interface/interface.h @@ -274,6 +274,7 @@ extern void ui_do_panel(uiBlock *block, uiEvent *uevent); extern void ui_scale_panel(uiBlock *block); extern void gl_round_box(int mode, float minx, float miny, float maxx, float maxy, float rad); extern void gl_round_box_shade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadetop, float shadedown); +extern void gl_round_box_vertical_shade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadeLeft, float shadeRight); /* interface_draw.c */ extern void ui_set_embossfunc(uiBut *but, int drawtype); diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 6fe7a166b7f..613c0b1c3b2 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -179,19 +179,19 @@ void gl_round_box_shade(int mode, float minx, float miny, float maxx, float maxy if(roundboxtype & 4) { round_box_shade_col(coltop, coldown, 0.0); - glVertex2f( maxx-rad, miny); + glVertex2f(maxx-rad, miny); for(a=0; a<7; a++) { round_box_shade_col(coltop, coldown, vec[a][1]/div); - glVertex2f( maxx-rad+vec[a][0], miny+vec[a][1]); + glVertex2f(maxx-rad+vec[a][0], miny+vec[a][1]); } round_box_shade_col(coltop, coldown, rad/div); - glVertex2f( maxx, miny+rad); + glVertex2f(maxx, miny+rad); } else { round_box_shade_col(coltop, coldown, 0.0); - glVertex2f( maxx, miny); + glVertex2f(maxx, miny); } /* corner right-top */ @@ -202,14 +202,14 @@ void gl_round_box_shade(int mode, float minx, float miny, float maxx, float maxy for(a=0; a<7; a++) { round_box_shade_col(coltop, coldown, (div-rad+vec[a][1])/div); - glVertex2f( maxx-vec[a][1], maxy-rad+vec[a][0]); + glVertex2f(maxx-vec[a][1], maxy-rad+vec[a][0]); } round_box_shade_col(coltop, coldown, 1.0); - glVertex2f( maxx-rad, maxy); + glVertex2f(maxx-rad, maxy); } else { round_box_shade_col(coltop, coldown, 1.0); - glVertex2f( maxx, maxy); + glVertex2f(maxx, maxy); } /* corner left-top */ @@ -224,30 +224,135 @@ void gl_round_box_shade(int mode, float minx, float miny, float maxx, float maxy } round_box_shade_col(coltop, coldown, (div-rad)/div); - glVertex2f( minx, maxy-rad); + glVertex2f(minx, maxy-rad); } else { round_box_shade_col(coltop, coldown, 1.0); - glVertex2f( minx, maxy); + glVertex2f(minx, maxy); } /* corner left-bottom */ if(roundboxtype & 8) { round_box_shade_col(coltop, coldown, rad/div); - glVertex2f( minx, miny+rad); + glVertex2f(minx, miny+rad); for(a=0; a<7; a++) { round_box_shade_col(coltop, coldown, (rad-vec[a][1])/div); - glVertex2f( minx+vec[a][1], miny+rad-vec[a][0]); + glVertex2f(minx+vec[a][1], miny+rad-vec[a][0]); } round_box_shade_col(coltop, coldown, 0.0); - glVertex2f( minx+rad, miny); + glVertex2f(minx+rad, miny); } else { round_box_shade_col(coltop, coldown, 0.0); - glVertex2f( minx, miny); + glVertex2f(minx, miny); + } + + glEnd(); + glShadeModel(GL_FLAT); +} + +/* linear vertical shade within button or in outline */ +void gl_round_box_vertical_shade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadeLeft, float shadeRight) +{ + float vec[7][2]= {{0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169}, {0.707, 0.293}, + {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}}; + float div= maxx-minx; + float colLeft[3], colRight[3], color[4]; + int a; + + /* mult */ + for(a=0; a<7; a++) { + vec[a][0]*= rad; vec[a][1]*= rad; + } + /* get current color, needs to be outside of glBegin/End */ + glGetFloatv(GL_CURRENT_COLOR, color); + + /* 'shade' defines strength of shading */ + colLeft[0]= color[0]+shadeLeft; if(colLeft[0]>1.0) colLeft[0]= 1.0; + colLeft[1]= color[1]+shadeLeft; if(colLeft[1]>1.0) colLeft[1]= 1.0; + colLeft[2]= color[2]+shadeLeft; if(colLeft[2]>1.0) colLeft[2]= 1.0; + colRight[0]= color[0]+shadeRight; if(colRight[0]<0.0) colRight[0]= 0.0; + colRight[1]= color[1]+shadeRight; if(colRight[1]<0.0) colRight[1]= 0.0; + colRight[2]= color[2]+shadeRight; if(colRight[2]<0.0) colRight[2]= 0.0; + + if (UI_GetThemeValue(TH_BUT_DRAWTYPE) != TH_MINIMAL) { + glShadeModel(GL_SMOOTH); + glBegin(mode); + } + + /* start with corner right-bottom */ + if(roundboxtype & 4) { + round_box_shade_col(colLeft, colRight, 0.0); + glVertex2f(maxx-rad, miny); + + for(a=0; a<7; a++) { + round_box_shade_col(colLeft, colRight, vec[a][0]/div); + glVertex2f(maxx-rad+vec[a][0], miny+vec[a][1]); + } + + round_box_shade_col(colLeft, colRight, rad/div); + glVertex2f(maxx, miny+rad); + } + else { + round_box_shade_col(colLeft, colRight, 0.0); + glVertex2f(maxx, miny); + } + + /* corner right-top */ + if(roundboxtype & 2) { + round_box_shade_col(colLeft, colRight, 0.0); + glVertex2f(maxx, maxy-rad); + + for(a=0; a<7; a++) { + + round_box_shade_col(colLeft, colRight, (div-rad-vec[a][0])/div); + glVertex2f(maxx-vec[a][1], maxy-rad+vec[a][0]); + } + round_box_shade_col(colLeft, colRight, (div-rad)/div); + glVertex2f(maxx-rad, maxy); + } + else { + round_box_shade_col(colLeft, colRight, 0.0); + glVertex2f(maxx, maxy); + } + + /* corner left-top */ + if(roundboxtype & 1) { + round_box_shade_col(colLeft, colRight, (div-rad)/div); + glVertex2f(minx+rad, maxy); + + for(a=0; a<7; a++) { + round_box_shade_col(colLeft, colRight, (div-rad+vec[a][0])/div); + glVertex2f(minx+rad-vec[a][0], maxy-vec[a][1]); + } + + round_box_shade_col(colLeft, colRight, 1.0); + glVertex2f(minx, maxy-rad); + } + else { + round_box_shade_col(colLeft, colRight, 1.0); + glVertex2f(minx, maxy); + } + + /* corner left-bottom */ + if(roundboxtype & 8) { + round_box_shade_col(colLeft, colRight, 1.0); + glVertex2f(minx, miny+rad); + + for(a=0; a<7; a++) { + round_box_shade_col(colLeft, colRight, (vec[a][0])/div); + glVertex2f(minx+vec[a][1], miny+rad-vec[a][0]); + } + + round_box_shade_col(colLeft, colRight, 1.0); + glVertex2f(minx+rad, miny); + } + else { + round_box_shade_col(colLeft, colRight, 1.0); + glVertex2f(minx, miny); } glEnd(); diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 95e68ee89f0..4a762b9a778 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -57,6 +57,26 @@ /* *********************************************************************** */ /* Refresh and Validation */ +#if 0 // experimental code - not ready to be used yet! +/* common View2D view types */ +// XXX move this to header as part of API +enum { + /* 4 quadrants, centered at (0,0), zoomable and pannable, best for flexible sized data with precision needed */ + V2D_VIEWTYPE_CANVAS = 0, + V2D_VIEWTYPE_LIST, + V2D_VIEWTYPE_PANEL, + /* same as canvas, except aspect ratio is important */ + // XXX is this more of the sort tweaks that region should do to its view2d data first? + V2D_VIEWTYPE_IMAGE, +} eView2D_CommonViewTypes; + +/* Initialise all View2D data for a given region */ +void UI_view2d_regiondata_init(View2D *v2d, short type, int winx, int winy) +{ + +} +#endif + /* Adjust mask size in response to view size changes * - This should only be called in region init() callbacks, which are * called when the region is resized or area changes... @@ -106,6 +126,7 @@ void UI_view2d_size_update(View2D *v2d, int winx, int winy) } /* cope with unitialized veriables for simple cases, like header or outliner */ + // XXX er... this shouldn't be here??? or at least some extra checks are needed for some things... if(v2d->tot.xmin==v2d->tot.xmax || v2d->cur.xmin==v2d->cur.xmax) { if(v2d->keepzoom) { BLI_init_rctf(&v2d->tot, v2d->mask.xmin, v2d->mask.xmax, v2d->mask.ymin, v2d->mask.ymax); @@ -157,10 +178,14 @@ void UI_view2d_curRect_validate(View2D *v2d) curheight= height= cur->ymax - cur->ymin; /* if zoom is locked, size on the appropriate axis is reset to mask size */ - if (v2d->keepzoom & V2D_LOCKZOOM_X) - width= winx; - if (v2d->keepzoom & V2D_LOCKZOOM_Y) - height= winy; + if (v2d->keepzoom & V2D_LOCKZOOM_X) { + cur->xmax= cur->xmin + winx; + curwidth= width= winx; + } + if (v2d->keepzoom & V2D_LOCKZOOM_Y) { + cur->ymax= cur->ymin + winy; + curheight= height= winy; + } /* keepzoom (V2D_KEEPZOOM set), indicates that zoom level on each axis must not exceed limits * NOTE: in general, it is not expected that the lock-zoom will be used in conjunction with this @@ -193,7 +218,7 @@ void UI_view2d_curRect_validate(View2D *v2d) } /* check if we should restore aspect ratio (if view size changed) */ - if (v2d->keepaspect) { + if (v2d->keepzoom & V2D_KEEPASPECT) { short do_x=0, do_y=0, do_cur, do_win; float curRatio, winRatio; @@ -336,20 +361,32 @@ void UI_view2d_curRect_validate(View2D *v2d) cur->ymin= temp - diff; cur->ymax= temp + diff; } - else if (cur->xmin > tot->xmin) { - /* there's still space remaining, so shift left */ - temp= cur->xmin - tot->xmin; - - cur->xmin -= temp; - cur->xmax -= temp; - } - else if (cur->xmax < tot->xmax) { - /* there's still space remaining, so shift right */ - temp= tot->xmax - cur->xmax; + else if (cur->xmin < tot->xmin) { + /* move cur across so that it sits at minimum of tot */ + temp= tot->xmin - cur->xmin; cur->xmin += temp; cur->xmax += temp; } + else if (cur->xmax > tot->xmax) { + /* - only offset by difference of cur-xmax and tot-xmax if that would not move + * cur-xmin to lie past tot-xmin + * - otherwise, simply shift to tot-xmin??? + */ + temp= cur->xmax - tot->xmax; + + if ((cur->xmin - temp) < tot->xmin) { + /* only offset by difference from cur-min and tot-min */ + temp= cur->xmin - tot->xmin; + + cur->xmin -= temp; + cur->xmax -= temp; + } + else { + cur->xmin -= temp; + cur->xmax -= temp; + } + } } /* height */ @@ -570,8 +607,7 @@ void UI_view2d_view_restore(const bContext *C) /* allowing horizontal pan */ void UI_view2d_header_default(View2D *v2d) { - v2d->keepaspect= 1; - v2d->keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_KEEPZOOM); + v2d->keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_KEEPZOOM|V2D_KEEPASPECT); v2d->keepofs = V2D_LOCKOFS_Y; v2d->keeptot = 2; // this keeps the view in place when region size changes... v2d->align = V2D_ALIGN_NO_NEG_X; @@ -1017,13 +1053,18 @@ static void scroll_printstr(View2DScrollers *scrollers, float x, float y, float UI_DrawString(G.fonts, str, 0); // XXX check this again when new text-drawing api is done } -/* local define for radius of scroller 'button' caps */ -#define V2D_SCROLLCAP_RAD 5 +/* local defines for scrollers drawing */ + /* radius of scroller 'button' caps */ +#define V2D_SCROLLCAP_RAD 5 + /* shading factor for scroller 'bar' */ +#define V2D_SCROLLBAR_SHADE 0.1f + /* shading factor for scroller 'button' caps */ +#define V2D_SCROLLCAP_SHADE 0.2f /* Draw scrollbars in the given 2d-region */ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *vs) { - const int darker= -50, dark= -10, light= 20, lighter= 50; + const short darker= -50, dark= -10, light= 20, lighter= 50; rcti vert, hor; /* make copies of rects for less typing */ @@ -1043,41 +1084,54 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v if (v2d->keepzoom & V2D_LOCKZOOM_X) { /* draw base bar as rounded shape */ UI_ThemeColorShade(TH_SHADE1, dark); - uiSetRoundBox(15); - gl_round_box_shade(GL_POLYGON, + + /* check that box is large enough for round drawing */ + if ((vs->hor_max - vs->hor_min) < (V2D_SCROLLCAP_RAD * 2)) { + /* Rounded box still gets drawn at the minimum size limit + * This doesn't represent extreme scaling well, but looks nicer... + */ + float mid= 0.5f * (vs->hor_max + vs->hor_min); + + gl_round_box_shade(GL_POLYGON, + mid-V2D_SCROLLCAP_RAD, hor.ymin+2, + mid+V2D_SCROLLCAP_RAD, hor.ymax-2, + V2D_SCROLLCAP_RAD, V2D_SCROLLBAR_SHADE, -V2D_SCROLLBAR_SHADE); + } + else { + /* draw rounded box as per normal */ + gl_round_box_shade(GL_POLYGON, vs->hor_min, hor.ymin+2, vs->hor_max, hor.ymax-2, - V2D_SCROLLCAP_RAD, 0.05f, -0.05f); + V2D_SCROLLCAP_RAD, V2D_SCROLLBAR_SHADE, -V2D_SCROLLBAR_SHADE); + } } else { /* base bar drawn as shaded rect */ UI_ThemeColorShade(TH_SHADE1, dark); uiSetRoundBox(0); gl_round_box_shade(GL_POLYGON, - vs->hor_min, hor.ymin+2, - vs->hor_max, hor.ymax-2, - V2D_SCROLLCAP_RAD, 0.05f, -0.05f); - - /* handles draw darker */ - // XXX handles are drawn with the two last args set to same values, otherwise, max appears darker than min - UI_ThemeColorShade(TH_SHADE1, darker); + vs->hor_min, hor.ymin+2, + vs->hor_max, hor.ymax-2, + V2D_SCROLLCAP_RAD, V2D_SCROLLBAR_SHADE, -V2D_SCROLLBAR_SHADE); /* 'minimum' handle */ uiSetRoundBox(9); + UI_ThemeColorShade(TH_SHADE1, darker); + gl_round_box_shade(GL_POLYGON, - vs->hor_min-V2D_SCROLLER_HANDLE_SIZE, hor.ymin+2, - vs->hor_min+V2D_SCROLLER_HANDLE_SIZE, hor.ymax-2, - V2D_SCROLLCAP_RAD, 0.07f, -0.07f); - //V2D_SCROLLCAP_RAD, 0, 0); + vs->hor_min-V2D_SCROLLER_HANDLE_SIZE, hor.ymin+2, + vs->hor_min+V2D_SCROLLER_HANDLE_SIZE, hor.ymax-2, + V2D_SCROLLCAP_RAD, V2D_SCROLLCAP_SHADE, -V2D_SCROLLCAP_SHADE); /* maximum handle */ uiSetRoundBox(6); + UI_ThemeColorShade(TH_SHADE1, darker); + gl_round_box_shade(GL_POLYGON, - vs->hor_max-V2D_SCROLLER_HANDLE_SIZE, hor.ymin+2, - vs->hor_max+V2D_SCROLLER_HANDLE_SIZE, hor.ymax-2, - V2D_SCROLLCAP_RAD, 0.07f, -0.07f); - //V2D_SCROLLCAP_RAD, 0, 0); + vs->hor_max-V2D_SCROLLER_HANDLE_SIZE, hor.ymin+2, + vs->hor_max+V2D_SCROLLER_HANDLE_SIZE, hor.ymax-2, + V2D_SCROLLCAP_RAD, V2D_SCROLLCAP_SHADE, -V2D_SCROLLCAP_SHADE); } /* scale indicators */ @@ -1162,41 +1216,57 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v * - if view is zoomable in y, draw handles too * - handles are drawn darker */ - // XXX gl_round_box_shade is currently hardcoded to do horizontal buts only... need a vertical region if (v2d->keepzoom & V2D_LOCKZOOM_Y) { /* draw base bar as rounded shape */ UI_ThemeColorShade(TH_SHADE1, dark); - uiSetRoundBox(15); - gl_round_box_shade(GL_POLYGON, + + /* check that box is large enough for round drawing */ + if ((vs->vert_max - vs->vert_min) < (V2D_SCROLLCAP_RAD * 2)) { + /* Rounded box still gets drawn at the minimum size limit + * This doesn't represent extreme scaling well, but looks nicer... + */ + float mid= 0.5f * (vs->vert_max + vs->vert_min); + + gl_round_box_vertical_shade(GL_POLYGON, + vert.xmin+2, mid-V2D_SCROLLCAP_RAD, + vert.xmax-2, mid+V2D_SCROLLCAP_RAD, + V2D_SCROLLCAP_RAD, V2D_SCROLLBAR_SHADE, -V2D_SCROLLBAR_SHADE); + } + else { + /* draw rounded box as per normal */ + gl_round_box_vertical_shade(GL_POLYGON, vert.xmin+2, vs->vert_min, vert.xmax-2, vs->vert_max, - V2D_SCROLLCAP_RAD, 0.05f, -0.05f); + V2D_SCROLLCAP_RAD, V2D_SCROLLBAR_SHADE, -V2D_SCROLLBAR_SHADE); + } } else { - /* for now, draw base bar as unshaded rect */ - // FIXME: this should be shaded horizontally too + /* base bar drawn as shaded rect */ UI_ThemeColorShade(TH_SHADE1, dark); - glRecti(vert.xmin+2, vs->vert_min, - vert.xmax-2, vs->vert_max); - - /* handles draw darker */ - // XXX handles are drawn with the two last args set to same values, otherwise, max appears darker than min - UI_ThemeColorShade(TH_SHADE1, darker); + uiSetRoundBox(0); + gl_round_box_vertical_shade(GL_POLYGON, + vert.xmin+2, vs->vert_min, + vert.xmax-2, vs->vert_max, + V2D_SCROLLCAP_RAD, V2D_SCROLLBAR_SHADE, -V2D_SCROLLBAR_SHADE); /* 'minimum' handle */ + UI_ThemeColorShade(TH_SHADE1, darker); uiSetRoundBox(12); - gl_round_box_shade(GL_POLYGON, - vert.xmin+2, vs->vert_min-V2D_SCROLLER_HANDLE_SIZE, - vert.xmax-2, vs->vert_min+V2D_SCROLLER_HANDLE_SIZE, - V2D_SCROLLCAP_RAD, 0, 0); + + gl_round_box_vertical_shade(GL_POLYGON, + vert.xmin+2, vs->vert_min-V2D_SCROLLER_HANDLE_SIZE, + vert.xmax-2, vs->vert_min+V2D_SCROLLER_HANDLE_SIZE, + V2D_SCROLLCAP_RAD, V2D_SCROLLCAP_SHADE, -V2D_SCROLLCAP_SHADE); /* maximum handle */ + UI_ThemeColorShade(TH_SHADE1, darker); uiSetRoundBox(3); - gl_round_box_shade(GL_POLYGON, - vert.xmin+2, vs->vert_max-V2D_SCROLLER_HANDLE_SIZE, - vert.xmax-2, vs->vert_max+V2D_SCROLLER_HANDLE_SIZE, - V2D_SCROLLCAP_RAD, 0, 0); + + gl_round_box_vertical_shade(GL_POLYGON, + vert.xmin+2, vs->vert_max-V2D_SCROLLER_HANDLE_SIZE, + vert.xmax-2, vs->vert_max+V2D_SCROLLER_HANDLE_SIZE, + V2D_SCROLLCAP_RAD, V2D_SCROLLCAP_SHADE, -V2D_SCROLLCAP_SHADE); } /* scale indiators */ diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index 42b7515e207..0564e6436a7 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -878,11 +878,15 @@ static short mouse_in_scroller_handle(int mouse, int sc_min, int sc_max, int sh_ ((sh_min <= sc_min) && (sh_max <= sc_max)) || ((sh_min >= sc_max) && (sh_max >= sc_max)) ) { - /* use midpoint to determine which handle to use (favour 'max' handle) */ - if (mouse >= ((sc_max + sc_min) / 2)) + /* handles are only activated if the mouse is within the relative quater lengths of the scroller */ + int qLen = (sc_max + sc_min) / 4; + + if (mouse >= (sc_max - qLen)) return SCROLLHANDLE_MAX; - else + else if (mouse <= qLen) return SCROLLHANDLE_MIN; + else + return SCROLLHANDLE_BAR; } /* check if mouse is in or past either handle */ @@ -894,12 +898,11 @@ static short mouse_in_scroller_handle(int mouse, int sc_min, int sc_max, int sh_ return SCROLLHANDLE_BAR; if (in_max) return SCROLLHANDLE_MAX; - else if (in_min) + if (in_min) return SCROLLHANDLE_MIN; /* unlikely to happen, though we just cover it in case */ - else - return SCROLLHANDLE_BAR; + return SCROLLHANDLE_BAR; } /* initialise customdata for scroller manipulation operator */ diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index ccc8f18d983..9fc7ca123dc 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -101,9 +101,8 @@ static SpaceLink *buttons_new(void) sbuts->v2d.minzoom= 0.5f; sbuts->v2d.maxzoom= 1.21f; - sbuts->v2d.scroll= 0; - sbuts->v2d.keepaspect= 1; - sbuts->v2d.keepzoom= 1; + sbuts->v2d.scroll= 0; // TODO: will we need scrollbars? + sbuts->v2d.keepzoom= V2D_KEEPZOOM|V2D_KEEPASPECT; sbuts->v2d.keeptot= 1; sbuts->v2d.cur= sbuts->v2d.tot; diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index 76d1034762c..6569200196c 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -103,8 +103,7 @@ static SpaceLink *node_new(void) ar->v2d.maxzoom= 1.21f; ar->v2d.scroll= 0; - ar->v2d.keepaspect= 1; - ar->v2d.keepzoom= 1; + ar->v2d.keepzoom= V2D_KEEPZOOM|V2D_KEEPASPECT; ar->v2d.keeptot= 0; diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c index 7ddcd87d867..c687ca17907 100644 --- a/source/blender/editors/space_outliner/space_outliner.c +++ b/source/blender/editors/space_outliner/space_outliner.c @@ -484,11 +484,9 @@ static SpaceLink *outliner_new(void) BLI_addtail(&soutliner->regionbase, ar); ar->regiontype= RGN_TYPE_WINDOW; - ar->v2d.scroll |= V2D_SCROLL_RIGHT; + ar->v2d.scroll = (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM_O); ar->v2d.align = (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_POS_Y); - ar->v2d.keepzoom |= (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y); - ar->v2d.keepaspect= 1; - ar->v2d.keepzoom= 1; + ar->v2d.keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_KEEPZOOM|V2D_KEEPASPECT); ar->v2d.keeptot= 2; /* XXX make define */ return (SpaceLink*)soutliner; diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c index 728beae364e..9ed69979dba 100644 --- a/source/blender/editors/space_time/space_time.c +++ b/source/blender/editors/space_time/space_time.c @@ -223,17 +223,17 @@ static SpaceLink *time_new(void) ar->regiontype= RGN_TYPE_WINDOW; ar->v2d.tot.xmin= -4.0; - ar->v2d.tot.ymin= 0.0; + ar->v2d.tot.ymin= -10.0; ar->v2d.tot.xmax= (float)EFRA + 4.0; ar->v2d.tot.ymax= 10; ar->v2d.cur= ar->v2d.tot; ar->v2d.min[0]= 1.0; - ar->v2d.min[1]= 500.0; /* XXX */ + ar->v2d.min[1]= 20.0; /* XXX */ ar->v2d.max[0]= 32000.0; - ar->v2d.max[1]= 500; /* XXX */ + ar->v2d.max[1]= 20; /* XXX */ ar->v2d.minzoom= 0.1f; ar->v2d.maxzoom= 10.0; @@ -241,6 +241,7 @@ static SpaceLink *time_new(void) ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_BOTTOM); ar->v2d.align |= V2D_ALIGN_NO_NEG_Y; ar->v2d.keepofs |= V2D_LOCKOFS_Y; + ar->v2d.keepzoom |= V2D_LOCKZOOM_Y; return (SpaceLink*)stime; } diff --git a/source/blender/makesdna/DNA_view2d_types.h b/source/blender/makesdna/DNA_view2d_types.h index e60fe90fbb9..986996e4341 100644 --- a/source/blender/makesdna/DNA_view2d_types.h +++ b/source/blender/makesdna/DNA_view2d_types.h @@ -46,12 +46,12 @@ typedef struct View2D { short scroll; /* scroll - scrollbars to display (bitflag) */ short keeptot; /* keeptot - 'cur' rect cannot move outside the 'tot' rect? */ - short keepaspect; /* keepaspect - need to maintain aspect ratio (0 or 1 boolean only) */ short keepzoom; /* keepzoom - axes that zooming cannot occur on, and also clamp within zoom-limits */ short keepofs; /* keepofs - axes that translation is not allowed to occur on */ short flag; /* settings */ short align; /* alignment of content in totrect */ + short type; /* basic 'type' of View2D (for easy init) */ // err... do we want to store this? short winx, winy; /* storage of current winx/winy values, set in UI_view2d_size_update */ short oldwinx, oldwiny; /* storage of previous winx/winy values encountered by UI_view2d_curRect_validate(), for keepaspect */ @@ -64,6 +64,7 @@ typedef struct View2D { /* view zooming restrictions, per axis (v2d->keepzoom) */ #define V2D_KEEPZOOM 0x0001 +#define V2D_KEEPASPECT 0x0002 #define V2D_LOCKZOOM_X 0x0100 #define V2D_LOCKZOOM_Y 0x0200 |