From f4b3975d65792f8cdb258fcdce6d3af6321e6e88 Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Tue, 2 Jun 2015 19:02:24 +0200 Subject: Make scrollbars thinner! (And draw them without outline) Scrollbars with units printed on them stay the same size. --- source/blender/blenloader/intern/versioning_270.c | 36 ++++++++++++++++++++++ source/blender/editors/include/UI_view2d.h | 6 ++-- .../blender/editors/interface/interface_widgets.c | 1 + source/blender/editors/interface/view2d.c | 11 ++++--- source/blender/editors/space_action/space_action.c | 2 +- source/blender/editors/space_graph/space_graph.c | 1 + source/blender/editors/space_nla/space_nla.c | 2 +- .../editors/space_sequencer/space_sequencer.c | 1 + source/blender/editors/space_time/space_time.c | 1 + source/blender/makesdna/DNA_view2d_types.h | 3 ++ 10 files changed, 56 insertions(+), 8 deletions(-) (limited to 'source') diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c index df985448ccd..1e54aa87b85 100644 --- a/source/blender/blenloader/intern/versioning_270.c +++ b/source/blender/blenloader/intern/versioning_270.c @@ -831,4 +831,40 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } } } + + { + bScreen *screen; + for (screen = main->screen.first; screen; screen = screen->id.next) { + ScrArea *sa; + + for (sa = screen->areabase.first; sa; sa = sa->next) { + ARegion *ar; + SpaceLink *sl; + + for (ar = sa->regionbase.first; ar; ar = ar->next) { + if (ar->regiontype == RGN_TYPE_WINDOW) { + break; + } + } + + if (ar) { + for (sl = sa->spacedata.first; sl; sl = sl->next) { + switch (sl->spacetype) { + case SPACE_TIME: + case SPACE_ACTION: + case SPACE_NLA: + ar->v2d.flag |= V2D_USES_UNITS_HORIZONTAL; + break; + case SPACE_IPO: + case SPACE_SEQ: + ar->v2d.flag |= (V2D_USES_UNITS_HORIZONTAL | V2D_USES_UNITS_VERTICAL); + break; + default: + break; + } + } + } + } + } + } } diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h index 2c8f5f6590a..43a55845d49 100644 --- a/source/blender/editors/include/UI_view2d.h +++ b/source/blender/editors/include/UI_view2d.h @@ -103,8 +103,10 @@ enum eView2D_Gridlines { /* ------ Defines for Scrollers ----- */ /* scroller area */ -#define V2D_SCROLL_HEIGHT (0.85f * U.widget_unit) -#define V2D_SCROLL_WIDTH (0.85f * U.widget_unit) +#define V2D_SCROLL_HEIGHT (0.50f * U.widget_unit) +#define V2D_SCROLL_WIDTH (0.50f * U.widget_unit) +#define V2D_SCROLL_HEIGHT_TEXT (0.85f * U.widget_unit) +#define V2D_SCROLL_WIDTH_TEXT (0.85f * U.widget_unit) /* scroller 'handles' hotspot radius for mouse */ #define V2D_SCROLLER_HANDLE_SIZE (0.6f * U.widget_unit) diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 52020fffff1..03932c61fc2 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -2742,6 +2742,7 @@ void UI_draw_widget_scroll(uiWidgetColors *wcol, const rcti *rect, const rcti *s rad = wcol->roundness * BLI_rcti_size_x(rect); wtb.draw_shadedir = (horizontal) ? true : false; + wtb.draw_outline = false; /* draw back part, colors swapped and shading inverted */ if (horizontal) diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 04ab50053a2..0af8386285c 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -152,18 +152,21 @@ static void view2d_masks(View2D *v2d, int check_scrollers) * - if they overlap, they must not occupy the corners (which are reserved for other widgets) */ if (scroll) { + const int scroll_width = (v2d->flag & V2D_USES_UNITS_VERTICAL) ? V2D_SCROLL_WIDTH_TEXT : V2D_SCROLL_WIDTH; + const int scroll_height = (v2d->flag & V2D_USES_UNITS_HORIZONTAL) ? V2D_SCROLL_HEIGHT_TEXT : V2D_SCROLL_HEIGHT; + /* vertical scroller */ if (scroll & V2D_SCROLL_LEFT) { /* on left-hand edge of region */ v2d->vert = v2d->mask; - v2d->vert.xmax = V2D_SCROLL_WIDTH; + v2d->vert.xmax = scroll_width; v2d->mask.xmin = v2d->vert.xmax + 1; } else if (scroll & V2D_SCROLL_RIGHT) { /* on right-hand edge of region */ v2d->vert = v2d->mask; v2d->vert.xmax++; /* one pixel extra... was leaving a minor gap... */ - v2d->vert.xmin = v2d->vert.xmax - V2D_SCROLL_WIDTH; + v2d->vert.xmin = v2d->vert.xmax - scroll_width; v2d->mask.xmax = v2d->vert.xmin - 1; } @@ -171,13 +174,13 @@ static void view2d_masks(View2D *v2d, int check_scrollers) if (scroll & (V2D_SCROLL_BOTTOM)) { /* on bottom edge of region */ v2d->hor = v2d->mask; - v2d->hor.ymax = V2D_SCROLL_HEIGHT; + v2d->hor.ymax = scroll_height; v2d->mask.ymin = v2d->hor.ymax + 1; } else if (scroll & V2D_SCROLL_TOP) { /* on upper edge of region */ v2d->hor = v2d->mask; - v2d->hor.ymin = v2d->hor.ymax - V2D_SCROLL_HEIGHT; + v2d->hor.ymin = v2d->hor.ymax - scroll_height; v2d->mask.ymax = v2d->hor.ymin - 1; } diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c index 5d0b34a2e0c..af16f9cf73a 100644 --- a/source/blender/editors/space_action/space_action.c +++ b/source/blender/editors/space_action/space_action.c @@ -118,7 +118,7 @@ static SpaceLink *action_new(const bContext *C) ar->v2d.keepzoom = V2D_LOCKZOOM_Y; ar->v2d.keepofs = V2D_KEEPOFS_Y; ar->v2d.align = V2D_ALIGN_NO_POS_Y; - ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL; + ar->v2d.flag = (V2D_VIEWSYNC_AREA_VERTICAL | V2D_USES_UNITS_HORIZONTAL); return (SpaceLink *)saction; } diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c index ad6f3ff5c7e..8b2f7e7c679 100644 --- a/source/blender/editors/space_graph/space_graph.c +++ b/source/blender/editors/space_graph/space_graph.c @@ -156,6 +156,7 @@ static SpaceLink *graph_new(const bContext *C) ar->v2d.scroll = (V2D_SCROLL_BOTTOM | V2D_SCROLL_SCALE_HORIZONTAL); ar->v2d.scroll |= (V2D_SCROLL_LEFT | V2D_SCROLL_SCALE_VERTICAL); + ar->v2d.flag |= (V2D_USES_UNITS_HORIZONTAL | V2D_USES_UNITS_VERTICAL); ar->v2d.keeptot = 0; diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c index ec584525aeb..9da9ef35f1a 100644 --- a/source/blender/editors/space_nla/space_nla.c +++ b/source/blender/editors/space_nla/space_nla.c @@ -158,7 +158,7 @@ static SpaceLink *nla_new(const bContext *C) ar->v2d.keepzoom = V2D_LOCKZOOM_Y; ar->v2d.keepofs = V2D_KEEPOFS_Y; ar->v2d.align = V2D_ALIGN_NO_POS_Y; - ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL; + ar->v2d.flag = (V2D_VIEWSYNC_AREA_VERTICAL | V2D_USES_UNITS_HORIZONTAL); return (SpaceLink *)snla; } diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c index 769718e1567..704e6c5775e 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.c +++ b/source/blender/editors/space_sequencer/space_sequencer.c @@ -190,6 +190,7 @@ static SpaceLink *sequencer_new(const bContext *C) ar->v2d.keepzoom = 0; ar->v2d.keeptot = 0; ar->v2d.align = V2D_ALIGN_NO_NEG_Y; + ar->v2d.flag |= (V2D_USES_UNITS_HORIZONTAL | V2D_USES_UNITS_VERTICAL); return (SpaceLink *)sseq; } diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c index 91a09708e1d..dbd6bff2a93 100644 --- a/source/blender/editors/space_time/space_time.c +++ b/source/blender/editors/space_time/space_time.c @@ -671,6 +671,7 @@ static SpaceLink *time_new(const bContext *C) ar->v2d.align |= V2D_ALIGN_NO_NEG_Y; ar->v2d.keepofs |= V2D_LOCKOFS_Y; ar->v2d.keepzoom |= V2D_LOCKZOOM_Y; + ar->v2d.flag |= V2D_USES_UNITS_HORIZONTAL; return (SpaceLink *)stime; diff --git a/source/blender/makesdna/DNA_view2d_types.h b/source/blender/makesdna/DNA_view2d_types.h index 6f2e347c84d..4a019476ee7 100644 --- a/source/blender/makesdna/DNA_view2d_types.h +++ b/source/blender/makesdna/DNA_view2d_types.h @@ -114,6 +114,9 @@ typedef struct View2D { #define V2D_PIXELOFS_Y (1<<3) /* view settings need to be set still... */ #define V2D_IS_INITIALISED (1<<10) + /* for screens that need to draw units on top of the scroller */ +#define V2D_USES_UNITS_VERTICAL (1 << 11) +#define V2D_USES_UNITS_HORIZONTAL (1 << 12) /* scroller flags for View2D (v2d->scroll) */ /* left scrollbar */ -- cgit v1.2.3