[Bf-blender-cvs] [827207b08ee] blender2.8: UI: move scrollbars inside region tabs

Campbell Barton noreply at git.blender.org
Mon Oct 22 07:44:01 CEST 2018


Commit: 827207b08ee4077f313d29dafa0bc96ea10c2c67
Author: Campbell Barton
Date:   Mon Oct 22 16:41:18 2018 +1100
Branches: blender2.8
https://developer.blender.org/rB827207b08ee4077f313d29dafa0bc96ea10c2c67

UI: move scrollbars inside region tabs

===================================================================

M	source/blender/editors/include/UI_view2d.h
M	source/blender/editors/interface/view2d.c
M	source/blender/editors/interface/view2d_ops.c
M	source/blender/editors/screen/area.c
M	source/blender/editors/space_action/space_action.c
M	source/blender/editors/space_clip/space_clip.c
M	source/blender/editors/space_console/space_console.c
M	source/blender/editors/space_file/space_file.c
M	source/blender/editors/space_graph/space_graph.c
M	source/blender/editors/space_info/space_info.c
M	source/blender/editors/space_nla/space_nla.c
M	source/blender/editors/space_node/node_draw.c
M	source/blender/editors/space_outliner/space_outliner.c
M	source/blender/editors/space_sequencer/sequencer_draw.c

===================================================================

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 vo

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list