[Bf-blender-cvs] [ca7964c24b8] blender2.8: UI: fix toolbar not snapping properly with system DPI and display scale.
Brecht Van Lommel
noreply at git.blender.org
Sat Apr 28 21:54:26 CEST 2018
Commit: ca7964c24b814182c0261d1c3f4ffeb6cfd799a7
Author: Brecht Van Lommel
Date: Sat Apr 28 20:48:47 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBca7964c24b814182c0261d1c3f4ffeb6cfd799a7
UI: fix toolbar not snapping properly with system DPI and display scale.
===================================================================
M release/scripts/startup/bl_ui/space_toolsystem_common.py
M source/blender/editors/space_view3d/space_view3d.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_common.py b/release/scripts/startup/bl_ui/space_toolsystem_common.py
index 12e2f6c3fd8..6bbf311b520 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_common.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_common.py
@@ -299,12 +299,13 @@ class ToolSelectPanelHelper:
"""
# Currently this just checks the width,
# we could have different layouts as preferences too.
+ system = bpy.context.user_preferences.system
view2d = region.view2d
- ui_scale = (
+ view2d_scale = (
view2d.region_to_view(1.0, 0.0)[0] -
view2d.region_to_view(0.0, 0.0)[0]
)
- width_scale = region.width * ui_scale
+ width_scale = region.width * view2d_scale / system.ui_scale
if width_scale > 120.0:
show_text = True
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index c219da36faf..d1b352d56f9 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -75,6 +75,7 @@
#include "RNA_access.h"
+#include "UI_interface.h"
#include "UI_resources.h"
#ifdef WITH_PYTHON
@@ -1273,7 +1274,7 @@ static int view3d_tools_region_snap_size(const ARegion *ar, int size, int axis)
int best_diff = INT_MAX;
int best_size = size;
for (uint i = 0; i < ARRAY_SIZE(snap_units); i += 1) {
- const int test_size = (snap_units[i] * U.widget_unit) / aspect;
+ const int test_size = (snap_units[i] * U.widget_unit) / (UI_DPI_FAC * aspect);
const int test_diff = ABS(test_size - size);
if (test_diff < best_diff) {
best_size = test_size;
More information about the Bf-blender-cvs
mailing list