[Bf-blender-cvs] [bf75b248180] blender2.8: UI: fix incorrect scaling of manipulator widgets with DPI.

Brecht Van Lommel noreply at git.blender.org
Sat Apr 28 16:17:13 CEST 2018


Commit: bf75b248180e5f7411fa27cdc89d7d1f07f7735c
Author: Brecht Van Lommel
Date:   Sat Apr 28 16:00:41 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBbf75b248180e5f7411fa27cdc89d7d1f07f7735c

UI: fix incorrect scaling of manipulator widgets with DPI.

U.ui_scale is the setting from the user preferences and should never be used
for drawing. UI_DPI_FAC is the final scale after DPI from the operating system
is taken into account.

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

M	source/blender/editors/manipulator_library/manipulator_types/button2d_manipulator.c
M	source/blender/editors/space_view3d/view3d_manipulator_navigate.c
M	source/blender/editors/space_view3d/view3d_manipulator_navigate_type.c
M	source/blender/windowmanager/manipulators/intern/wm_manipulator.c

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

diff --git a/source/blender/editors/manipulator_library/manipulator_types/button2d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/button2d_manipulator.c
index 7e57b48c77c..68bddf36b3c 100644
--- a/source/blender/editors/manipulator_library/manipulator_types/button2d_manipulator.c
+++ b/source/blender/editors/manipulator_library/manipulator_types/button2d_manipulator.c
@@ -57,6 +57,7 @@
 #include "ED_view3d.h"
 #include "ED_manipulator_library.h"
 
+#include "UI_interface.h"
 #include "UI_interface_icons.h"
 #include "UI_resources.h"
 
@@ -152,8 +153,8 @@ static void button2d_draw_intern(
 			button2d_geom_draw_backdrop(mpr, color, select);
 			gpuPopMatrix();
 			UI_icon_draw(
-			        mpr->matrix_basis[3][0] - (ICON_DEFAULT_WIDTH / 2.0) * U.ui_scale,
-			        mpr->matrix_basis[3][1] - (ICON_DEFAULT_HEIGHT / 2.0) * U.ui_scale,
+			        mpr->matrix_basis[3][0] - (ICON_DEFAULT_WIDTH / 2.0) * UI_DPI_FAC,
+			        mpr->matrix_basis[3][1] - (ICON_DEFAULT_HEIGHT / 2.0) * UI_DPI_FAC,
 			        button->icon);
 		}
 		else {
@@ -194,7 +195,7 @@ static int manipulator_button2d_test_select(
 	else {
 		copy_v2_v2(point_local, (float [2]){UNPACK2(event->mval)});
 		sub_v2_v2(point_local, mpr->matrix_basis[3]);
-		mul_v2_fl(point_local, 1.0f / (mpr->scale_basis * U.ui_scale));
+		mul_v2_fl(point_local, 1.0f / (mpr->scale_basis * UI_DPI_FAC));
 	}
 	/* The 'mpr->scale_final' is already applied when projecting. */
 	if (len_squared_v2(point_local) < 1.0f) {
diff --git a/source/blender/editors/space_view3d/view3d_manipulator_navigate.c b/source/blender/editors/space_view3d/view3d_manipulator_navigate.c
index 6a5d63b180f..2d3f42f9c61 100644
--- a/source/blender/editors/space_view3d/view3d_manipulator_navigate.c
+++ b/source/blender/editors/space_view3d/view3d_manipulator_navigate.c
@@ -34,6 +34,7 @@
 #include "ED_screen.h"
 #include "ED_manipulator_library.h"
 
+#include "UI_interface.h"
 #include "UI_resources.h"
 
 #include "MEM_guardedalloc.h"
@@ -291,8 +292,8 @@ static void WIDGETGROUP_navigate_draw_prepare(const bContext *C, wmManipulatorGr
 
 
 	const float icon_size = MANIPULATOR_SIZE;
-	const float icon_offset = (icon_size / 2.0) * MANIPULATOR_OFFSET_FAC * U.ui_scale;
-	const float icon_offset_mini = icon_size * MANIPULATOR_MINI_OFFSET_FAC * U.ui_scale;
+	const float icon_offset = (icon_size / 2.0) * MANIPULATOR_OFFSET_FAC * UI_DPI_FAC;
+	const float icon_offset_mini = icon_size * MANIPULATOR_MINI_OFFSET_FAC * UI_DPI_FAC;
 	const float co[2] = {ar->winx - icon_offset, ar->winy - icon_offset};
 
 	wmManipulator *mpr;
diff --git a/source/blender/editors/space_view3d/view3d_manipulator_navigate_type.c b/source/blender/editors/space_view3d/view3d_manipulator_navigate_type.c
index 06ac2f83ea7..8c9696d908c 100644
--- a/source/blender/editors/space_view3d/view3d_manipulator_navigate_type.c
+++ b/source/blender/editors/space_view3d/view3d_manipulator_navigate_type.c
@@ -47,6 +47,7 @@
 #include "RNA_access.h"
 #include "RNA_define.h"
 
+#include "UI_interface.h"
 #include "UI_resources.h"
 
 #include "WM_api.h"
@@ -238,7 +239,7 @@ static int manipulator_axis_test_select(
 {
 	float point_local[2] = {UNPACK2(event->mval)};
 	sub_v2_v2(point_local, mpr->matrix_basis[3]);
-	mul_v2_fl(point_local, 1.0f / (mpr->scale_basis * U.ui_scale));
+	mul_v2_fl(point_local, 1.0f / (mpr->scale_basis * UI_DPI_FAC));
 
 	const float len_sq = len_squared_v2(point_local);
 	if (len_sq > 1.0) {
diff --git a/source/blender/windowmanager/manipulators/intern/wm_manipulator.c b/source/blender/windowmanager/manipulators/intern/wm_manipulator.c
index 3a78dd32f94..856b92096dd 100644
--- a/source/blender/windowmanager/manipulators/intern/wm_manipulator.c
+++ b/source/blender/windowmanager/manipulators/intern/wm_manipulator.c
@@ -53,6 +53,8 @@
 #include "ED_screen.h"
 #include "ED_view3d.h"
 
+#include "UI_interface.h"
+
 #ifdef WITH_PYTHON
 #include "BPY_extern.h"
 #endif
@@ -470,7 +472,7 @@ bool wm_manipulator_select_and_highlight(bContext *C, wmManipulatorMap *mmap, wm
 void wm_manipulator_calculate_scale(wmManipulator *mpr, const bContext *C)
 {
 	const RegionView3D *rv3d = CTX_wm_region_view3d(C);
-	float scale = U.ui_scale;
+	float scale = UI_DPI_FAC;
 
 	if ((mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_SCALE) == 0) {
 		scale *= U.manipulator_size;



More information about the Bf-blender-cvs mailing list