ecere/gui/Window Scrollbars: Optimization to reduce operations on turning on scrollba...
authorJerome St-Louis <jerome@ecere.com>
Thu, 29 Mar 2012 06:59:55 +0000 (02:59 -0400)
committerJerome St-Louis <jerome@ecere.com>
Thu, 29 Mar 2012 06:59:55 +0000 (02:59 -0400)
ecere/src/gui/Window.ec
ecere/src/gui/controls/ScrollBar.ec

index fc731cb..1ba1e95 100644 (file)
@@ -1837,12 +1837,19 @@ private:
             }
             else
             {
+               int oldHRange = sbh ? sbh.range : 0;
+               int oldVRange = sbv ? sbv.range : 0;
                // Then start off with horizontal scrollbar range
                if(sbh)
                {
                   positionH = sbh.thumbPosition;
+
+                  /*
                   sbh.seen = cw;
                   sbh.total = rvw;
+                  */
+                  SBSetSeen(sbh, cw);
+                  SBSetTotal(sbh, rvw);
                   rangeH = sbh.range;
                   if(rangeH > 1)
                      ch -= guiApp.currentSkin.HorizontalSBH();
@@ -1852,8 +1859,12 @@ private:
                if(sbv)
                {
                   positionV = sbv.thumbPosition;
+                  /*
                   sbv.seen = ch;
                   sbv.total = rvh;
+                  */
+                  SBSetSeen(sbv, ch);
+                  SBSetTotal(sbv, rvh);
                   rangeV = sbv.range;
                   if(rangeV > 1)
                   {
@@ -1861,20 +1872,30 @@ private:
                      // Maybe we need to set the range on the horizontal scrollbar again
                      if(sbh)
                      {
+                        /*
                         sbh.seen = cw;
                         sbh.total = rvw;
-                        sbh.Action(setRange, positionH, 0);
+                        */
+                        SBSetSeen(sbh, cw);
+                        SBSetTotal(sbh, rvw);
+                        //sbh.Action(setRange, positionH, 0);
                         if(rangeH <= 1 && sbh.range > 1)
                         {
                            ch -= guiApp.currentSkin.HorizontalSBH();
+                           /*
                            sbv.seen = ch;
                            sbv.total = rvh;
+                           */
+                           SBSetSeen(sbv, ch);
+                           SBSetTotal(sbv, rvh);
                            rangeV = sbv.range;
-                           sbv.Action(setRange, positionV, 0);
+                           //sbv.Action(setRange, positionV, 0);
                         }
                         rangeH = sbh.range;
                      }
                   }
+                  if(sbh && sbh.range != oldHRange) sbh.Action(setRange, positionH, 0);
+                  if(sbv && sbv.range != oldVRange) sbv.Action(setRange, positionV, 0);
                }
 
                // Update the scrollbar visibility
index 0fef8cb..f79164c 100644 (file)
@@ -592,3 +592,17 @@ private:
       thumb.visible = !disabled;
    };
 };
+
+void SBSetSeen(ScrollBar sb, int value)
+{
+   value = Max(1,value);
+   if(sb.sbStyle.snap)
+      SNAPDOWN(value, *&sb.lineStep);
+   *&sb.seen = value;
+}
+
+void SBSetTotal(ScrollBar sb, int value)
+{
+   if(!value) value = *&sb.seen;
+   *&sb.total = value;
+}