emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 88d474308e: Fix inconsistent thumb position on Haiku scroll bars


From: Po Lu
Subject: master 88d474308e: Fix inconsistent thumb position on Haiku scroll bars
Date: Fri, 11 Mar 2022 03:58:45 -0500 (EST)

branch: master
commit 88d474308e2a0b4a6cac2714135f6bbcae689ed4
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Fix inconsistent thumb position on Haiku scroll bars
    
    * src/haikuterm.c (haiku_set_scroll_bar_thumb): If
    scroll_bar_adjust_thumb_portion is nil, directly calculate thumb
    portions without setting page_size.
---
 src/haikuterm.c | 41 ++++++++++++++++++++++++-----------------
 1 file changed, 24 insertions(+), 17 deletions(-)

diff --git a/src/haikuterm.c b/src/haikuterm.c
index b100952f11..a7b971f2c1 100644
--- a/src/haikuterm.c
+++ b/src/haikuterm.c
@@ -456,27 +456,34 @@ haiku_set_scroll_bar_thumb (struct scroll_bar *bar, int 
portion,
       /* When the thumb is at the bottom, position == whole.  So we
          need to increase `whole' to make space for the thumb.  */
       whole += portion;
-    }
 
-  if (whole <= 0)
-    top = 0, shown = 1;
-  else
-    {
-      top = (float) position / whole;
-      shown = (float) portion / whole;
-    }
+      if (whole <= 0)
+       top = 0, shown = 1;
+      else
+       {
+         top = (float) position / whole;
+         shown = (float) portion / whole;
+       }
 
-  /* Slider size.  Must be in the range [1 .. MAX - MIN] where MAX
-     is the scroll bar's maximum and MIN is the scroll bar's minimum
-     value.  */
-  size = clip_to_bounds (1, shown * BE_SB_MAX, BE_SB_MAX);
+      /* Slider size.  Must be in the range [1 .. MAX - MIN] where MAX
+        is the scroll bar's maximum and MIN is the scroll bar's minimum
+        value.  */
+      size = clip_to_bounds (1, shown * BE_SB_MAX, BE_SB_MAX);
 
-  /* Position.  Must be in the range [MIN .. MAX - SLIDER_SIZE].  */
-  value = top * BE_SB_MAX;
-  value = min (value, BE_SB_MAX - size);
+      /* Position.  Must be in the range [MIN .. MAX - SLIDER_SIZE].  */
+      value = top * BE_SB_MAX;
+      value = min (value, BE_SB_MAX - size);
 
-  if (!bar->dragging)
-    bar->page_size = size;
+      if (!bar->dragging)
+       bar->page_size = size;
+    }
+  else
+    {
+      bar->page_size = 0;
+
+      size = (((float) portion / whole) * BE_SB_MAX);
+      value = (((float) position / whole) * BE_SB_MAX);
+    }
 
   BView_scroll_bar_update (scroll_bar, size, BE_SB_MAX, value,
                           bar->dragging);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]