Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2018-04-27 18:55:17 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-04-27 19:02:45 +0300
commiteb4c60124cc2b3aeba5eeb3090bea92543f066a9 (patch)
treea55b2a7cdbcebe42a2279e7ebfb2012630201573 /source/blender/editors/space_view3d
parent964a2dd73f687cbc293434eb3cbaa1b45ede20c5 (diff)
UI: multi-column toolbar support
Diffstat (limited to 'source/blender/editors/space_view3d')
-rw-r--r--source/blender/editors/space_view3d/space_view3d.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index 1a23dd0feff..5fcffc75693 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -1268,10 +1268,19 @@ static int view3d_tools_region_snap_size(const ARegion *ar, int size, int axis)
{
if (axis == 0) {
/* Note, this depends on the icon size: see #ICON_DEFAULT_HEIGHT_TOOLBAR. */
- const float snap_units = 3.25f;
+ const float snap_units[3] = {3 + 0.25f, 5 + 0.25, 7 + 0.25};
const float aspect = BLI_rctf_size_x(&ar->v2d.cur) / (BLI_rcti_size_x(&ar->v2d.mask) + 1);
- const int snap_size = (snap_units * U.widget_unit) / aspect;
- return snap_size;
+ 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_diff = ABS(test_size - size);
+ if (test_diff < best_diff) {
+ best_size = test_size;
+ best_diff = test_diff;
+ }
+ }
+ return best_size;
}
return size;
}