[Bf-blender-cvs] [495c7463fc3] blender2.8: UI: fractional DPI scaling of splash, instead of always 1x or 2x.

Brecht Van Lommel noreply at git.blender.org
Fri Sep 21 10:46:42 CEST 2018


Commit: 495c7463fc39b8bec1f678af28e94a207e0d1217
Author: Brecht Van Lommel
Date:   Fri Sep 21 10:43:36 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB495c7463fc39b8bec1f678af28e94a207e0d1217

UI: fractional DPI scaling of splash, instead of always 1x or 2x.

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

M	source/blender/windowmanager/intern/wm_operators.c

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

diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 7b231e6fd6b..928995ce248 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -1416,7 +1416,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
 #endif  /* WITH_BUILDINFO */
 
 #ifndef WITH_HEADLESS
-	if (U.pixelsize == 2) {
+	if (U.dpi_fac > 1.0) {
 		ibuf = IMB_ibImageFromMemory((unsigned char *)datatoc_splash_2x_png,
 		                             datatoc_splash_2x_png_size, IB_rect, NULL, "<splash screen>");
 	}
@@ -1441,7 +1441,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
 			ibuf_template = IMB_loadiffname(splash_filepath, IB_rect, NULL);
 			if (ibuf_template) {
 				const int x_expect = ibuf->x;
-				const int y_expect = 282 * (int)U.pixelsize;
+				const int y_expect = 282 * (int)U.dpi_fac;
 				/* don't cover the header text */
 				if (ibuf_template->x == x_expect && ibuf_template->y == y_expect) {
 					memcpy(ibuf->rect, ibuf_template->rect, ibuf_template->x * ibuf_template->y * sizeof(char[4]));
@@ -1465,8 +1465,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
 	UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_KEEP_OPEN | UI_BLOCK_NO_WIN_CLIP);
 	UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP);
 
-	/* XXX splash scales with pixelsize, should become widget-units */
-	but = uiDefBut(block, UI_BTYPE_IMAGE, 0, "", 0, 0.5f * U.widget_unit, U.pixelsize * 501, U.pixelsize * 282, ibuf, 0.0, 0.0, 0, 0, ""); /* button owns the imbuf now */
+	but = uiDefBut(block, UI_BTYPE_IMAGE, 0, "", 0, 0.5f * U.widget_unit, U.dpi_fac * 501, U.dpi_fac * 282, ibuf, 0.0, 0.0, 0, 0, ""); /* button owns the imbuf now */
 	UI_but_func_set(but, wm_block_splash_close, block, NULL);
 	UI_block_func_set(block, wm_block_splash_refreshmenu, block, NULL);
 
@@ -1487,9 +1486,9 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
 	if (version_suffix != NULL && version_suffix[0]) {
 		/* placed after the version number in the image,
 		 * placing y is tricky to match baseline */
-		int x = 236 * U.pixelsize - (2 * UI_DPI_FAC);
-		int y = 231 * U.pixelsize + (4 * UI_DPI_FAC);
-		int w = 240 * U.pixelsize;
+		int x = 234 * U.dpi_fac;
+		int y = 235 * U.dpi_fac;
+		int w = 240 * U.dpi_fac;
 
 		/* hack to have text draw 'text_sel' */
 		UI_block_emboss_set(block, UI_EMBOSS_NONE);
@@ -1503,7 +1502,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
 	if (build_commit_timestamp != 0) {
 		but = uiDefBut(
 		          block, UI_BTYPE_LABEL, 0, date_buf,
-		          U.pixelsize * 502 - date_width, U.pixelsize * 267,
+		          U.dpi_fac * 502 - date_width, U.dpi_fac * 267,
 		          date_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL);
 		/* XXX, set internal flag - UI_SELECT */
 		UI_but_flag_enable(but, 1);
@@ -1511,7 +1510,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
 	}
 	but = uiDefBut(
 	          block, UI_BTYPE_LABEL, 0, hash_buf,
-	          U.pixelsize * 502 - hash_width, U.pixelsize * (267 - label_delta),
+	          U.dpi_fac * 502 - hash_width, U.dpi_fac * (267 - label_delta),
 	          hash_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL);
 	/* XXX, set internal flag - UI_SELECT */
 	UI_but_flag_enable(but, 1);
@@ -1523,7 +1522,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
 		branch_width = (int)BLF_width(style->widgetlabel.uifont_id, branch_buf, sizeof(branch_buf)) + U.widget_unit;
 		but = uiDefBut(
 		          block, UI_BTYPE_LABEL, 0, branch_buf,
-		          U.pixelsize * 502 - branch_width, U.pixelsize * (255 - label_delta),
+		          U.dpi_fac * 502 - branch_width, U.dpi_fac * (255 - label_delta),
 		          branch_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL);
 		/* XXX, set internal flag - UI_SELECT */
 		UI_but_flag_enable(but, 1);
@@ -1532,7 +1531,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
 
 	uiLayout *layout = UI_block_layout(
 	        block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 10, 2,
-	        U.pixelsize * 480, U.pixelsize * 110, 0, style);
+	        U.dpi_fac * 480, U.dpi_fac * 110, 0, style);
 
 	MenuType *mt = WM_menutype_find("WM_MT_splash", true);
 	if (mt) {



More information about the Bf-blender-cvs mailing list