UI: fix toolbar not snapping properly with system DPI and display scale.

This commit is contained in:
Brecht Van Lommel 2018-04-28 20:48:47 +02:00
parent b5d3fcc9f5
commit ca7964c24b
2 changed files with 5 additions and 3 deletions

View File

@ -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

View File

@ -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;