diff options
author | Ton Roosendaal <ton@blender.org> | 2009-07-03 17:21:09 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2009-07-03 17:21:09 +0400 |
commit | ea287fc4ec7f52a690730eb890c1c548d1d60773 (patch) | |
tree | b2ec12b51487a8f493f1c5de66bf8f6f78f30224 /source/blender | |
parent | 3c6f957097cec1bc8f7e64af304cc8dec12b2158 (diff) |
2.5
More scroller work:
- Added subtle arrow widgets to denote a scroller can zoom the view.
- Made zoom symmetric (old convention to only zoom "one side" just
worked badly)
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/include/UI_interface.h | 4 | ||||
-rw-r--r-- | source/blender/editors/include/UI_view2d.h | 4 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_widgets.c | 54 | ||||
-rw-r--r-- | source/blender/editors/interface/view2d.c | 20 | ||||
-rw-r--r-- | source/blender/editors/interface/view2d_ops.c | 14 | ||||
-rw-r--r-- | source/blender/editors/space_text/text_draw.c | 2 |
6 files changed, 65 insertions, 33 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index b7c13505d2e..cf284e7b111 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -216,9 +216,11 @@ void uiRoundRect(float minx, float miny, float maxx, float maxy, float rad); void uiDrawMenuBox(float minx, float miny, float maxx, float maxy, short flag, short direction); void uiDrawBoxShadow(unsigned char alpha, float minx, float miny, float maxx, float maxy); +/* state for scrolldrawing */ +#define UI_SCROLL_PRESSED 1 +#define UI_SCROLL_ARROWS 2 void uiWidgetScrollDraw(struct uiWidgetColors *wcol, struct rcti *rect, struct rcti *slider, int state); - /* Menu Callbacks */ typedef void (*uiMenuCreateFunc)(struct bContext *C, struct uiLayout *layout, void *arg1); diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h index b5e675af64e..537c1b42b97 100644 --- a/source/blender/editors/include/UI_view2d.h +++ b/source/blender/editors/include/UI_view2d.h @@ -101,8 +101,8 @@ enum { #define V2D_SCROLL_HEIGHT 17 #define V2D_SCROLL_WIDTH 17 -/* half the size (in pixels) of scroller 'handles' */ -#define V2D_SCROLLER_HANDLE_SIZE 5 +/* scroller 'handles' hotspot radius for mouse */ +#define V2D_SCROLLER_HANDLE_SIZE 12 /* ------ Define for UI_view2d_sync ----- */ diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index b63c7f105c3..2cd7c1d61cd 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -435,22 +435,33 @@ static void round_box_edges(uiWidgetBase *wt, int roundboxalign, rcti *rect, flo /* based on button rect, return scaled array of triangles */ static void widget_num_tria(uiWidgetTrias *tria, rcti *rect, float triasize, char where) { - float centx, centy, size; - int a; + float centx, centy, sizex, sizey, minsize; + int a, i1=0, i2=1; + + minsize= MIN2(rect->xmax-rect->xmin, rect->ymax-rect->ymin); /* center position and size */ - centx= (float)rect->xmin + 0.5f*(rect->ymax-rect->ymin); - centy= (float)rect->ymin + 0.5f*(rect->ymax-rect->ymin); - size= -0.5f*triasize*(rect->ymax-rect->ymin); + centx= (float)rect->xmin + 0.5f*minsize; + centy= (float)rect->ymin + 0.5f*minsize; + sizex= sizey= -0.5f*triasize*minsize; if(where=='r') { - centx= (float)rect->xmax - 0.5f*(rect->ymax-rect->ymin); - size= -size; + centx= (float)rect->xmax - 0.5f*minsize; + sizex= -sizex; + } + else if(where=='t') { + centy= (float)rect->ymax - 0.5f*minsize; + sizey= -sizey; + i2=0; i1= 1; + } + else if(where=='b') { + sizex= -sizex; + i2=0; i1= 1; } for(a=0; a<19; a++) { - tria->vec[a][0]= size*num_tria_vert[a][0] + centx; - tria->vec[a][1]= size*num_tria_vert[a][1] + centy; + tria->vec[a][0]= sizex*num_tria_vert[a][i1] + centx; + tria->vec[a][1]= sizey*num_tria_vert[a][i2] + centy; } tria->tot= 19; @@ -1576,7 +1587,7 @@ static void widget_numbut(uiWidgetColors *wcol, rcti *rect, int state, int round /* decoration */ if(!(state & UI_TEXTINPUT)) { - widget_num_tria(&wtb.tria1, rect, 0.6f, 0); + widget_num_tria(&wtb.tria1, rect, 0.6f, 'l'); widget_num_tria(&wtb.tria2, rect, 0.6f, 'r'); } widgetbase_draw(&wtb, wcol); @@ -1676,15 +1687,30 @@ void uiWidgetScrollDraw(uiWidgetColors *wcol, rcti *rect, rcti *slider, int stat wcol->shadetop+= 20; /* XXX violates themes... */ else wcol->shadedown+= 20; - if(state & UI_SELECT) + if(state & UI_SCROLL_PRESSED) SWAP(short, wcol->shadetop, wcol->shadedown); /* draw */ wtb.emboss= 0; /* only emboss once */ round_box_edges(&wtb, 15, slider, rad); - widgetbase_draw(&wtb, wcol); + if(state & UI_SCROLL_ARROWS) { + if(wcol->item[0] > 48) wcol->item[0]-= 48; + if(wcol->item[1] > 48) wcol->item[1]-= 48; + if(wcol->item[2] > 48) wcol->item[2]-= 48; + wcol->item[3]= 255; + + if(horizontal) { + widget_num_tria(&wtb.tria1, slider, 0.6f, 'l'); + widget_num_tria(&wtb.tria2, slider, 0.6f, 'r'); + } + else { + widget_num_tria(&wtb.tria1, slider, 0.6f, 'b'); + widget_num_tria(&wtb.tria2, slider, 0.6f, 't'); + } + } + widgetbase_draw(&wtb, wcol); } } @@ -1718,6 +1744,10 @@ static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat rect1.ymin= rect1.ymax - ceil(fac*(but->a1 - but->softmin)); } + if(state & UI_SELECT) + state= UI_SCROLL_PRESSED; + else + state= 0; uiWidgetScrollDraw(wcol, rect, &rect1, state); } diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 705963981c8..11714df0491 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -1207,14 +1207,14 @@ void UI_view2d_grid_free(View2DGrid *grid) * For now, we don't need to have a separate (internal) header for structs like this... */ struct View2DScrollers { - rcti hor, vert; /* exact size of slider backdrop */ - int horfull, vertfull; /* set if sliders are full, we don't draw them */ - /* focus bubbles */ int vert_min, vert_max; /* vertical scrollbar */ int hor_min, hor_max; /* horizontal scrollbar */ - /* scales */ + rcti hor, vert; /* exact size of slider backdrop */ + int horfull, vertfull; /* set if sliders are full, we don't draw them */ + + /* scales */ View2DGrid *grid; /* grid for coordinate drawing */ short xunits, xclamp; /* units and clamping options for x-axis */ short yunits, yclamp; /* units and clamping options for y-axis */ @@ -1455,13 +1455,17 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v bTheme *btheme= U.themes.first; uiWidgetColors wcol= btheme->tui.wcol_scroll; rcti slider; + int state; slider.xmin= vs->hor_min; slider.xmax= vs->hor_max; slider.ymin= hor.ymin; slider.ymax= hor.ymax; - uiWidgetScrollDraw(&wcol, &hor, &slider, (v2d->scroll_ui & V2D_SCROLL_H_ACTIVE)?UI_SELECT:0); + state= (v2d->scroll_ui & V2D_SCROLL_H_ACTIVE)?UI_SCROLL_PRESSED:0; + if (!(v2d->keepzoom & V2D_LOCKZOOM_X)) + state |= UI_SCROLL_ARROWS; + uiWidgetScrollDraw(&wcol, &hor, &slider, state); } /* scale indicators */ @@ -1547,13 +1551,17 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v bTheme *btheme= U.themes.first; uiWidgetColors wcol= btheme->tui.wcol_scroll; rcti slider; + int state; slider.xmin= vert.xmin; slider.xmax= vert.xmax; slider.ymin= vs->vert_min; slider.ymax= vs->vert_max; - uiWidgetScrollDraw(&wcol, &vert, &slider, (v2d->scroll_ui & V2D_SCROLL_V_ACTIVE)?UI_SELECT:0); + state= (v2d->scroll_ui & V2D_SCROLL_V_ACTIVE)?UI_SCROLL_PRESSED:0; + if (!(v2d->keepzoom & V2D_LOCKZOOM_Y)) + state |= UI_SCROLL_ARROWS; + uiWidgetScrollDraw(&wcol, &vert, &slider, state); } diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index ae89e215a03..101d89da618 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -1010,15 +1010,7 @@ static short mouse_in_scroller_handle(int mouse, int sc_min, int sc_max, int sh_ if (in_view == 0) { - /* 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 if (mouse <= qLen) - return SCROLLHANDLE_MIN; - else - return SCROLLHANDLE_BAR; + return SCROLLHANDLE_BAR; } /* check if mouse is in or past either handle */ @@ -1128,14 +1120,14 @@ static void scroller_activate_apply(bContext *C, wmOperator *op) /* type of movement */ switch (vsm->zone) { case SCROLLHANDLE_MIN: + case SCROLLHANDLE_MAX: + /* only expand view on axis if zoom is allowed */ if ((vsm->scroller == 'h') && !(v2d->keepzoom & V2D_LOCKZOOM_X)) v2d->cur.xmin -= temp; if ((vsm->scroller == 'v') && !(v2d->keepzoom & V2D_LOCKZOOM_Y)) v2d->cur.ymin -= temp; - break; - case SCROLLHANDLE_MAX: /* only expand view on axis if zoom is allowed */ if ((vsm->scroller == 'h') && !(v2d->keepzoom & V2D_LOCKZOOM_X)) v2d->cur.xmax += temp; diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index 03b6a8dd862..48c14804b13 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -826,7 +826,7 @@ static void draw_textscroll(SpaceText *st, ARegion *ar, rcti *scroll) // uiEmboss(st->txtbar.xmin, st->txtbar.ymin, st->txtbar.xmax, st->txtbar.ymax, st->flags & ST_SCROLL_SELECT); - uiWidgetScrollDraw(&wcol, scroll, &st->txtbar, (st->flags & ST_SCROLL_SELECT)?1:0); + uiWidgetScrollDraw(&wcol, scroll, &st->txtbar, (st->flags & ST_SCROLL_SELECT)?UI_SCROLL_PRESSED:0); uiSetRoundBox(15); rad= 0.4f*MIN2(st->txtscroll.xmax - st->txtscroll.xmin, st->txtscroll.ymax - st->txtscroll.ymin); |