[Bf-blender-cvs] [4d1c5f1ec51] blender2.8: Change earlier fix to work with hiDPI

Severin noreply at git.blender.org
Thu Jun 28 21:10:35 CEST 2018


Commit: 4d1c5f1ec51e7978c76271730d479e0aef15c63a
Author: Severin
Date:   Thu Jun 28 21:07:30 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB4d1c5f1ec51e7978c76271730d479e0aef15c63a

Change earlier fix to work with hiDPI

Referring to ca8f787349dcdf5. Thought in this case the simple `+ 1` would be
correct, but we need to make the same pixel adjustment as we do in other places.

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

M	source/blender/editors/screen/screen_edit.c
M	source/blender/editors/screen/screen_intern.h
M	source/blender/editors/screen/screen_ops.c

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

diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c
index e1c4962a97b..3e67ced783d 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -212,11 +212,12 @@ static void screen_delarea(bContext *C, bScreen *sc, ScrArea *sa)
 
 /* return 0: no split possible */
 /* else return (integer) screencoordinate split point */
-static short testsplitpoint(ScrArea *sa, char dir, float fac)
+static short testsplitpoint(ScrArea *sa, const rcti *window_rect, char dir, float fac)
 {
 	short x, y;
 	const short area_min_x = AREAMINX;
-	const short area_min_y = ED_area_headersize() + 1;
+	const short area_min_y = ED_area_headersize();
+	int area_min;
 
 	// area big enough?
 	if (dir == 'v' && (sa->v4->vec.x - sa->v1->vec.x <= 2 * area_min_x)) return 0;
@@ -229,10 +230,21 @@ static short testsplitpoint(ScrArea *sa, char dir, float fac)
 		y = sa->v1->vec.y +
 		        round_fl_to_short(fac * (float)(sa->v2->vec.y - sa->v1->vec.y));
 
-		if (y - sa->v1->vec.y < area_min_y)
-			y = sa->v1->vec.y + area_min_y;
-		else if (sa->v2->vec.y - y < area_min_y)
-			y = sa->v2->vec.y - area_min_y;
+		area_min = area_min_y;
+
+		if (sa->v1->vec.y > window_rect->ymin) {
+			area_min += U.pixelsize;
+		}
+		if (sa->v2->vec.y < (window_rect->ymax - 1)) {
+			area_min += U.pixelsize;
+		}
+
+		if (y - sa->v1->vec.y < area_min) {
+			y = sa->v1->vec.y + area_min;
+		}
+		else if (sa->v2->vec.y - y < area_min) {
+			y = sa->v2->vec.y - area_min;
+		}
 
 		return y;
 	}
@@ -240,24 +252,38 @@ static short testsplitpoint(ScrArea *sa, char dir, float fac)
 		x = sa->v1->vec.x +
 		        round_fl_to_short(fac * (float)(sa->v4->vec.x - sa->v1->vec.x));
 
-		if (x - sa->v1->vec.x < area_min_x)
-			x = sa->v1->vec.x + area_min_x;
-		else if (sa->v4->vec.x - x < area_min_x)
-			x = sa->v4->vec.x - area_min_x;
+		area_min = area_min_x;
+
+		if (sa->v1->vec.x > window_rect->xmin) {
+			area_min += U.pixelsize;
+		}
+		if (sa->v4->vec.x < (window_rect->xmax - 1)) {
+			area_min += U.pixelsize;
+		}
+
+		if (x - sa->v1->vec.x < area_min) {
+			x = sa->v1->vec.x + area_min;
+		}
+		else if (sa->v4->vec.x - x < area_min) {
+			x = sa->v4->vec.x - area_min;
+		}
 
 		return x;
 	}
 }
 
-ScrArea *area_split(bScreen *sc, ScrArea *sa, char dir, float fac, int merge)
+ScrArea *area_split(const wmWindow *win, bScreen *sc, ScrArea *sa, char dir, float fac, int merge)
 {
 	ScrArea *newa = NULL;
 	ScrVert *sv1, *sv2;
 	short split;
+	rcti window_rect;
 
 	if (sa == NULL) return NULL;
 
-	split = testsplitpoint(sa, dir, fac);
+	WM_window_rect_calc(win, &window_rect);
+
+	split = testsplitpoint(sa, &window_rect, dir, fac);
 	if (split == 0) return NULL;
 
 	/* note regarding (fac > 0.5f) checks below.
diff --git a/source/blender/editors/screen/screen_intern.h b/source/blender/editors/screen/screen_intern.h
index 2c343fb9d70..f7828c7cff9 100644
--- a/source/blender/editors/screen/screen_intern.h
+++ b/source/blender/editors/screen/screen_intern.h
@@ -53,7 +53,7 @@ void        screen_data_copy(bScreen *to, bScreen *from);
 void        screen_new_activate_prepare(const wmWindow *win, bScreen *screen_new);
 void        screen_change_update(struct bContext *C, wmWindow *win, bScreen *sc);
 bScreen    *screen_change_prepare(bScreen *screen_old, bScreen *screen_new, struct Main *bmain, struct bContext *C, wmWindow *win);
-ScrArea    *area_split(bScreen *sc, ScrArea *sa, char dir, float fac, int merge);
+ScrArea    *area_split(const wmWindow *win, bScreen *sc, ScrArea *sa, char dir, float fac, int merge);
 int         screen_area_join(struct bContext *C, bScreen *scr, ScrArea *sa1, ScrArea *sa2);
 int         area_getorientation(ScrArea *sa, ScrArea *sb);
 void        select_connected_scredge(const wmWindow *win, ScrEdge *edge);
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index 201a7d438ed..be5b77bbd3a 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -1763,7 +1763,7 @@ static int area_split_apply(bContext *C, wmOperator *op)
 	fac = RNA_float_get(op->ptr, "factor");
 	dir = RNA_enum_get(op->ptr, "direction");
 
-	sd->narea = area_split(sc, sd->sarea, dir, fac, 0); /* 0 = no merge */
+	sd->narea = area_split(CTX_wm_window(C), sc, sd->sarea, dir, fac, 0); /* 0 = no merge */
 
 	if (sd->narea) {
 		ScrVert *sv;



More information about the Bf-blender-cvs mailing list