[Bf-blender-cvs] [846c0343237] master: UI: scale region hide threshold by zoom level

Campbell Barton noreply at git.blender.org
Fri Jan 3 06:42:02 CET 2020


Commit: 846c034323784ac938249b08ad622753d4f3dd34
Author: Campbell Barton
Date:   Fri Jan 3 16:40:10 2020 +1100
Branches: master
https://developer.blender.org/rB846c034323784ac938249b08ad622753d4f3dd34

UI: scale region hide threshold by zoom level

Resolves issue were it wasn't possible to have a single column toolbar
when zoomed out.

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

M	source/blender/editors/screen/area_utils.c
M	source/blender/editors/screen/screen_ops.c

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

diff --git a/source/blender/editors/screen/area_utils.c b/source/blender/editors/screen/area_utils.c
index a9fdaf52ee5..12de1ddb795 100644
--- a/source/blender/editors/screen/area_utils.c
+++ b/source/blender/editors/screen/area_utils.c
@@ -70,7 +70,6 @@ int ED_region_generic_tools_region_snap_size(const ARegion *ar, int size, int ax
     const float column = 1.25f * icon_size;
     const float margin = 0.5f * icon_size;
     const float snap_units[] = {
-        0, /* Without this we can't hide the toolbar. */
         column + margin,
         (2.0f * column) + margin,
         (2.7f * column) + margin,
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index f5ce026e6d6..dd09def2df6 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -2666,7 +2666,8 @@ static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event)
         /* region sizes now get multiplied */
         delta /= UI_DPI_FAC;
 
-        rmd->ar->sizex = rmd->origval + delta;
+        const int size_no_snap = rmd->origval + delta;
+        rmd->ar->sizex = size_no_snap;
 
         if (rmd->ar->type->snap_size) {
           short sizex_test = rmd->ar->type->snap_size(rmd->ar, rmd->ar->sizex, 0);
@@ -2676,7 +2677,7 @@ static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event)
         }
         CLAMP(rmd->ar->sizex, 0, rmd->maxsize);
 
-        if (rmd->ar->sizex < UI_UNIT_X) {
+        if (size_no_snap < UI_UNIT_X / aspect) {
           rmd->ar->sizex = rmd->origval;
           if (!(rmd->ar->flag & RGN_FLAG_HIDDEN)) {
             region_scale_toggle_hidden(C, rmd);
@@ -2698,7 +2699,8 @@ static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event)
         /* region sizes now get multiplied */
         delta /= UI_DPI_FAC;
 
-        rmd->ar->sizey = rmd->origval + delta;
+        const int size_no_snap = rmd->origval + delta;
+        rmd->ar->sizey = size_no_snap;
 
         if (rmd->ar->type->snap_size) {
           short sizey_test = rmd->ar->type->snap_size(rmd->ar, rmd->ar->sizey, 1);
@@ -2711,7 +2713,7 @@ static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event)
         /* note, 'UI_UNIT_Y/4' means you need to drag the footer and execute region
          * almost all the way down for it to become hidden, this is done
          * otherwise its too easy to do this by accident */
-        if (rmd->ar->sizey < UI_UNIT_Y / 4) {
+        if (size_no_snap < (UI_UNIT_Y / 4) / aspect) {
           rmd->ar->sizey = rmd->origval;
           if (!(rmd->ar->flag & RGN_FLAG_HIDDEN)) {
             region_scale_toggle_hidden(C, rmd);



More information about the Bf-blender-cvs mailing list