diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-10-22 08:41:18 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-10-22 08:43:09 +0300 |
commit | 827207b08ee4077f313d29dafa0bc96ea10c2c67 (patch) | |
tree | cc2f2dd7382931bb99ddcb4f09320f73e59c0d94 | |
parent | 84eff5c1269f18b063d6b5637efe90f78958cc62 (diff) |
UI: move scrollbars inside region tabs
-rw-r--r-- | source/blender/editors/include/UI_view2d.h | 7 | ||||
-rw-r--r-- | source/blender/editors/interface/view2d.c | 39 | ||||
-rw-r--r-- | source/blender/editors/interface/view2d_ops.c | 2 | ||||
-rw-r--r-- | source/blender/editors/screen/area.c | 9 | ||||
-rw-r--r-- | source/blender/editors/space_action/space_action.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_clip/space_clip.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_console/space_console.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_file/space_file.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_graph/space_graph.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_info/space_info.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_nla/space_nla.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_draw.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_outliner/space_outliner.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_sequencer/sequencer_draw.c | 2 |
14 files changed, 53 insertions, 30 deletions
diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h index 4c4ee1e01c5..92aca0a707e 100644 --- a/source/blender/editors/include/UI_view2d.h +++ b/source/blender/editors/include/UI_view2d.h @@ -158,6 +158,8 @@ void UI_view2d_sync(struct bScreen *screen, struct ScrArea *sa, struct View2D *v void UI_view2d_totRect_set(struct View2D *v2d, int width, int height); void UI_view2d_totRect_set_resize(struct View2D *v2d, int width, int height, bool resize); +void UI_view2d_mask_from_win(const struct View2D *v2d, struct rcti *r_mask); + /* per tab offsets, returns 1 if tab changed */ bool UI_view2d_tab_set(struct View2D *v2d, int tab); @@ -178,8 +180,9 @@ void UI_view2d_grid_size(View2DGrid *grid, float *r_dx, float *r_dy); void UI_view2d_grid_free(View2DGrid *grid); /* scrollbar drawing */ -View2DScrollers *UI_view2d_scrollers_calc(const struct bContext *C, struct View2D *v2d, - short xunits, short xclamp, short yunits, short yclamp); +View2DScrollers *UI_view2d_scrollers_calc( + const struct bContext *C, struct View2D *v2d, const struct rcti *mask_custom, + short xunits, short xclamp, short yunits, short yclamp); void UI_view2d_scrollers_draw(const struct bContext *C, struct View2D *v2d, View2DScrollers *scrollers); void UI_view2d_scrollers_free(View2DScrollers *scrollers); diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index baaaac2e814..20ca492c8d1 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -116,15 +116,28 @@ static int view2d_scroll_mapped(int scroll) return scroll; } -/* called each time cur changes, to dynamically update masks */ -static void view2d_masks(View2D *v2d, bool check_scrollers) +void UI_view2d_mask_from_win(const View2D *v2d, rcti *r_mask) +{ + r_mask->xmin = 0; + r_mask->ymin = 0; + r_mask->xmax = v2d->winx - 1; /* -1 yes! masks are pixels */ + r_mask->ymax = v2d->winy - 1; +} + +/** + * Called each time #View2D.cur changes, to dynamically update masks. + * + * \param mask_scroll: Optionally clamp scrollbars by this region. + */ +static void view2d_masks(View2D *v2d, bool check_scrollers, const rcti *mask_scroll) { int scroll; /* mask - view frame */ - v2d->mask.xmin = v2d->mask.ymin = 0; - v2d->mask.xmax = v2d->winx - 1; /* -1 yes! masks are pixels */ - v2d->mask.ymax = v2d->winy - 1; + UI_view2d_mask_from_win(v2d, &v2d->mask); + if (mask_scroll == NULL) { + mask_scroll = &v2d->mask; + } if (check_scrollers) { /* check size if hiding flag is set: */ @@ -161,12 +174,12 @@ static void view2d_masks(View2D *v2d, bool check_scrollers) /* vertical scroller */ if (scroll & V2D_SCROLL_LEFT) { /* on left-hand edge of region */ - v2d->vert = v2d->mask; + v2d->vert = *mask_scroll; v2d->vert.xmax = scroll_width; } else if (scroll & V2D_SCROLL_RIGHT) { /* on right-hand edge of region */ - v2d->vert = v2d->mask; + v2d->vert = *mask_scroll; v2d->vert.xmax++; /* one pixel extra... was leaving a minor gap... */ v2d->vert.xmin = v2d->vert.xmax - scroll_width; } @@ -174,12 +187,12 @@ static void view2d_masks(View2D *v2d, bool check_scrollers) /* horizontal scroller */ if (scroll & (V2D_SCROLL_BOTTOM)) { /* on bottom edge of region */ - v2d->hor = v2d->mask; + v2d->hor = *mask_scroll; v2d->hor.ymax = scroll_height; } else if (scroll & V2D_SCROLL_TOP) { /* on upper edge of region */ - v2d->hor = v2d->mask; + v2d->hor = *mask_scroll; v2d->hor.ymin = v2d->hor.ymax - scroll_height; } @@ -356,7 +369,7 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy) v2d->winy = winy; /* set masks (always do), but leave scroller scheck to totrect_set */ - view2d_masks(v2d, 0); + view2d_masks(v2d, 0, NULL); if (do_init) { /* Visible by default. */ @@ -780,7 +793,7 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas } /* set masks */ - view2d_masks(v2d, mask_scrollers); + view2d_masks(v2d, mask_scrollers, NULL); } void UI_view2d_curRect_validate(View2D *v2d) @@ -1635,7 +1648,7 @@ struct View2DScrollers { /* Calculate relevant scroller properties */ View2DScrollers *UI_view2d_scrollers_calc( - const bContext *C, View2D *v2d, + const bContext *C, View2D *v2d, const rcti *mask_custom, short xunits, short xclamp, short yunits, short yclamp) { View2DScrollers *scrollers; @@ -1648,7 +1661,7 @@ View2DScrollers *UI_view2d_scrollers_calc( scrollers = MEM_callocN(sizeof(View2DScrollers), "View2DScrollers"); /* Always update before drawing (for dynamically sized scrollers). */ - view2d_masks(v2d, false); + view2d_masks(v2d, false, mask_custom); vert = v2d->vert; hor = v2d->hor; diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index 5ea09a40ac8..0ec6e3d5fd2 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -1718,7 +1718,7 @@ static void scroller_activate_init(bContext *C, wmOperator *op, const wmEvent *e /* 'zone' depends on where mouse is relative to bubble * - zooming must be allowed on this axis, otherwise, default to pan */ - scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); + scrollers = UI_view2d_scrollers_calc(C, v2d, NULL, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); /* use a union of 'cur' & 'tot' incase the current view is far outside 'tot'. * In this cases moving the scroll bars has far too little effect and the view can get stuck [#31476] */ diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index bd49f3fc0fd..5faa35729c4 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -2289,8 +2289,15 @@ void ED_region_panels_draw(const bContext *C, ARegion *ar) } /* scrollers */ + const rcti *mask = NULL; + rcti mask_buf; + if (ar->runtime.category && (ar->alignment == RGN_ALIGN_RIGHT)) { + UI_view2d_mask_from_win(v2d, &mask_buf); + mask_buf.xmax -= UI_PANEL_CATEGORY_MARGIN_WIDTH; + mask = &mask_buf; + } View2DScrollers *scrollers = UI_view2d_scrollers_calc( - C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); + C, v2d, mask, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); UI_view2d_scrollers_draw(C, v2d, scrollers); UI_view2d_scrollers_free(scrollers); } diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c index 3e8e92d814d..dbbbe6d0edb 100644 --- a/source/blender/editors/space_action/space_action.c +++ b/source/blender/editors/space_action/space_action.c @@ -274,7 +274,7 @@ static void action_main_region_draw(const bContext *C, ARegion *ar) UI_view2d_view_restore(C); /* scrollers */ - scrollers = UI_view2d_scrollers_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY); + scrollers = UI_view2d_scrollers_calc(C, v2d, NULL, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY); UI_view2d_scrollers_draw(C, v2d, scrollers); UI_view2d_scrollers_free(scrollers); diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 8afc0c33271..c70811860a8 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -1254,7 +1254,7 @@ static void graph_region_draw(const bContext *C, ARegion *ar) /* scrollers */ unitx = (sc->flag & SC_SHOW_SECONDS) ? V2D_UNIT_SECONDS : V2D_UNIT_FRAMES; unity = V2D_UNIT_VALUES; - scrollers = UI_view2d_scrollers_calc(C, v2d, unitx, V2D_GRID_NOCLAMP, unity, V2D_GRID_NOCLAMP); + scrollers = UI_view2d_scrollers_calc(C, v2d, NULL, unitx, V2D_GRID_NOCLAMP, unity, V2D_GRID_NOCLAMP); UI_view2d_scrollers_draw(C, v2d, scrollers); UI_view2d_scrollers_free(scrollers); @@ -1301,7 +1301,7 @@ static void dopesheet_region_draw(const bContext *C, ARegion *ar) UI_view2d_view_restore(C); /* scrollers */ - scrollers = UI_view2d_scrollers_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY); + scrollers = UI_view2d_scrollers_calc(C, v2d, NULL, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY); UI_view2d_scrollers_draw(C, v2d, scrollers); UI_view2d_scrollers_free(scrollers); diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c index a5e9f6cf641..ddfeb2119d9 100644 --- a/source/blender/editors/space_console/space_console.c +++ b/source/blender/editors/space_console/space_console.c @@ -235,7 +235,7 @@ static void console_main_region_draw(const bContext *C, ARegion *ar) UI_view2d_view_restore(C); /* scrollers */ - scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_GRID_CLAMP); + scrollers = UI_view2d_scrollers_calc(C, v2d, NULL, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_GRID_CLAMP); UI_view2d_scrollers_draw(C, v2d, scrollers); UI_view2d_scrollers_free(scrollers); } diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index 4b02c5be2f0..cdad11d8ad0 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -451,7 +451,7 @@ static void file_main_region_draw(const bContext *C, ARegion *ar) UI_view2d_view_restore(C); /* scrollers */ - scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); + scrollers = UI_view2d_scrollers_calc(C, v2d, NULL, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); UI_view2d_scrollers_draw(C, v2d, scrollers); UI_view2d_scrollers_free(scrollers); diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c index 6a921eede4a..eff216f8c02 100644 --- a/source/blender/editors/space_graph/space_graph.c +++ b/source/blender/editors/space_graph/space_graph.c @@ -344,7 +344,7 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar) /* scrollers */ // FIXME: args for scrollers depend on the type of data being shown... - scrollers = UI_view2d_scrollers_calc(C, v2d, unitx, V2D_GRID_NOCLAMP, unity, V2D_GRID_NOCLAMP); + scrollers = UI_view2d_scrollers_calc(C, v2d, NULL, unitx, V2D_GRID_NOCLAMP, unity, V2D_GRID_NOCLAMP); UI_view2d_scrollers_draw(C, v2d, scrollers); UI_view2d_scrollers_free(scrollers); @@ -397,7 +397,7 @@ static void graph_channel_region_draw(const bContext *C, ARegion *ar) UI_view2d_view_restore(C); /* scrollers */ - scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); + scrollers = UI_view2d_scrollers_calc(C, v2d, NULL, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); UI_view2d_scrollers_draw(C, v2d, scrollers); UI_view2d_scrollers_free(scrollers); } diff --git a/source/blender/editors/space_info/space_info.c b/source/blender/editors/space_info/space_info.c index a43b5ae1760..ab7d688cebb 100644 --- a/source/blender/editors/space_info/space_info.c +++ b/source/blender/editors/space_info/space_info.c @@ -175,7 +175,7 @@ static void info_main_region_draw(const bContext *C, ARegion *ar) UI_view2d_view_restore(C); /* scrollers */ - scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_GRID_CLAMP); + scrollers = UI_view2d_scrollers_calc(C, v2d, NULL, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_GRID_CLAMP); UI_view2d_scrollers_draw(C, v2d, scrollers); UI_view2d_scrollers_free(scrollers); } diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c index bf9aa090b94..d72014901a6 100644 --- a/source/blender/editors/space_nla/space_nla.c +++ b/source/blender/editors/space_nla/space_nla.c @@ -246,7 +246,7 @@ static void nla_channel_region_draw(const bContext *C, ARegion *ar) UI_view2d_view_restore(C); /* scrollers */ - scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); + scrollers = UI_view2d_scrollers_calc(C, v2d, NULL, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); UI_view2d_scrollers_draw(C, v2d, scrollers); UI_view2d_scrollers_free(scrollers); } @@ -325,7 +325,7 @@ static void nla_main_region_draw(const bContext *C, ARegion *ar) UI_view2d_view_restore(C); /* scrollers */ - scrollers = UI_view2d_scrollers_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY); + scrollers = UI_view2d_scrollers_calc(C, v2d, NULL, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY); UI_view2d_scrollers_draw(C, v2d, scrollers); UI_view2d_scrollers_free(scrollers); diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index 17ef2c32160..f00b745a317 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -1460,7 +1460,7 @@ void drawnodespace(const bContext *C, ARegion *ar) draw_tree_path(snode); /* scrollers */ - scrollers = UI_view2d_scrollers_calc(C, v2d, 10, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY); + scrollers = UI_view2d_scrollers_calc(C, v2d, NULL, 10, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY); UI_view2d_scrollers_draw(C, v2d, scrollers); UI_view2d_scrollers_free(scrollers); } diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c index 37fa44f7386..57b13749f2b 100644 --- a/source/blender/editors/space_outliner/space_outliner.c +++ b/source/blender/editors/space_outliner/space_outliner.c @@ -108,7 +108,7 @@ static void outliner_main_region_draw(const bContext *C, ARegion *ar) UI_view2d_view_restore(C); /* scrollers */ - scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); + scrollers = UI_view2d_scrollers_calc(C, v2d, NULL, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); UI_view2d_scrollers_draw(C, v2d, scrollers); UI_view2d_scrollers_free(scrollers); } diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 96193d375d5..d91ade75807 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -1756,7 +1756,7 @@ void draw_timeline_seq(const bContext *C, ARegion *ar) /* scrollers */ unit = (sseq->flag & SEQ_DRAWFRAMES) ? V2D_UNIT_FRAMES : V2D_UNIT_SECONDS; - scrollers = UI_view2d_scrollers_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_UNIT_VALUES, V2D_GRID_CLAMP); + scrollers = UI_view2d_scrollers_calc(C, v2d, NULL, unit, V2D_GRID_CLAMP, V2D_UNIT_VALUES, V2D_GRID_CLAMP); UI_view2d_scrollers_draw(C, v2d, scrollers); UI_view2d_scrollers_free(scrollers); |