[Bf-blender-cvs] [cd90986bcb4] master: UI: Prevent scrollbars from getting too small to grab

EitanSomething noreply at git.blender.org
Mon Jun 3 18:19:30 CEST 2019


Commit: cd90986bcb4e20a3e731a3e2d6340bb582b43f38
Author: EitanSomething
Date:   Mon Jun 3 18:13:52 2019 +0200
Branches: master
https://developer.blender.org/rBcd90986bcb4e20a3e731a3e2d6340bb582b43f38

UI: Prevent scrollbars from getting too small to grab

Differential Revision: https://developer.blender.org/D5001

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

M	source/blender/editors/include/UI_view2d.h
M	source/blender/editors/interface/view2d.c

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

diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h
index 4f880a8d46f..bfdb52a4a5d 100644
--- a/source/blender/editors/include/UI_view2d.h
+++ b/source/blender/editors/include/UI_view2d.h
@@ -70,6 +70,8 @@ enum eView2D_CommonViewTypes {
 /* scroller 'handles' hotspot radius for mouse */
 #define V2D_SCROLLER_HANDLE_SIZE (0.6f * U.widget_unit)
 
+#define V2D_MIN_SCROLLER_SIZE (50.0 * UI_DPI_FAC)
+
 /* ------ Define for UI_view2d_sync ----- */
 
 /* means copy it from another v2d */
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index 36b984e229b..07c971aeb11 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -1504,12 +1504,12 @@ View2DScrollers *UI_view2d_scrollers_calc(View2D *v2d, const rcti *mask_custom)
     if (scrollers->hor_min > scrollers->hor_max) {
       scrollers->hor_min = scrollers->hor_max;
     }
-    /* prevent sliders from being too small, and disappearing */
-    if ((scrollers->hor_max - scrollers->hor_min) < V2D_SCROLLER_HANDLE_SIZE) {
-      scrollers->hor_max = scrollers->hor_min + V2D_SCROLLER_HANDLE_SIZE;
+    /* prevent sliders from being too small to grab */
+    if ((scrollers->hor_max - scrollers->hor_min) < V2D_MIN_SCROLLER_SIZE) {
+      scrollers->hor_max = scrollers->hor_min + V2D_MIN_SCROLLER_SIZE;
 
-      CLAMP(scrollers->hor_max, hor.xmin + V2D_SCROLLER_HANDLE_SIZE, hor.xmax);
-      CLAMP(scrollers->hor_min, hor.xmin, hor.xmax - V2D_SCROLLER_HANDLE_SIZE);
+      CLAMP(scrollers->hor_max, hor.xmin + V2D_MIN_SCROLLER_SIZE, hor.xmax);
+      CLAMP(scrollers->hor_min, hor.xmin, hor.xmax - V2D_MIN_SCROLLER_SIZE);
     }
   }
 
@@ -1542,13 +1542,12 @@ View2DScrollers *UI_view2d_scrollers_calc(View2D *v2d, const rcti *mask_custom)
     if (scrollers->vert_min > scrollers->vert_max) {
       scrollers->vert_min = scrollers->vert_max;
     }
-    /* prevent sliders from being too small, and disappearing */
-    if ((scrollers->vert_max - scrollers->vert_min) < V2D_SCROLLER_HANDLE_SIZE) {
+    /* prevent sliders from being too small to grab */
+    if ((scrollers->vert_max - scrollers->vert_min) < V2D_MIN_SCROLLER_SIZE) {
+      scrollers->vert_max = scrollers->vert_min + V2D_MIN_SCROLLER_SIZE;
 
-      scrollers->vert_max = scrollers->vert_min + V2D_SCROLLER_HANDLE_SIZE;
-
-      CLAMP(scrollers->vert_max, vert.ymin + V2D_SCROLLER_HANDLE_SIZE, vert.ymax);
-      CLAMP(scrollers->vert_min, vert.ymin, vert.ymax - V2D_SCROLLER_HANDLE_SIZE);
+      CLAMP(scrollers->vert_max, vert.ymin + V2D_MIN_SCROLLER_SIZE, vert.ymax);
+      CLAMP(scrollers->vert_min, vert.ymin, vert.ymax - V2D_MIN_SCROLLER_SIZE);
     }
   }



More information about the Bf-blender-cvs mailing list