* Fixed a scrollbug 4.x-dev

Tue, 26 Oct 2021 14:22:22 +0300

author
cemkalyoncu
date
Tue, 26 Oct 2021 14:22:22 +0300
branch
4.x-dev
changeset 1743
ad4507937c5d
parent 1742
6e10cbe21ea3
child 1744
5f97a7c6a353

* Fixed a scrollbug
#337 If parentboundschanged does not cause a difference in location/size,
move/resize will not be called

Source/Gorgon/UI/Widget.cpp file | annotate | diff | comparison | revisions
Source/Gorgon/Widgets/Panel.cpp file | annotate | diff | comparison | revisions
Source/Gorgon/Widgets/Panel.h file | annotate | diff | comparison | revisions
--- a/Source/Gorgon/UI/Widget.cpp	Mon Oct 25 06:58:50 2021 +0300
+++ b/Source/Gorgon/UI/Widget.cpp	Tue Oct 26 14:22:22 2021 +0300
@@ -193,8 +193,6 @@
 
 
     void Widget::parentboundschanged() {
-        //for now
-
         //move out
         int unitsize = 0, spacing = 0;
         Geometry::Size sz;
@@ -208,18 +206,25 @@
             spacing  = Widgets::Registry::Active().GetSpacing();
             sz = GetCurrentSize();
         }
-
-        move(Convert(
+        
+        auto l= Convert(
             location, sz,
             unitsize, spacing,
             Widgets::Registry::Active().GetEmSize()
-        ));
-
-        resize(Convert(
+        );
+        
+        if(GetCurrentLocation() != l) {
+            move(l);
+        }
+        
+        auto s = Convert(
             size, sz,
             unitsize, spacing,
             Widgets::Registry::Active().GetEmSize()
-        ));
+        );
+        
+        if(GetCurrentSize() != s)
+            resize(s);
     }
 
 } }
--- a/Source/Gorgon/Widgets/Panel.cpp	Mon Oct 25 06:58:50 2021 +0300
+++ b/Source/Gorgon/Widgets/Panel.cpp	Tue Oct 26 14:22:22 2021 +0300
@@ -200,7 +200,7 @@
         
         stack.SetTagSize(UI::ComponentTemplate::ContentsTag, {maxx, maxy});
         
-        ScrollTo(ScrollOffset(), scrollclipped);
+        ScrollTo(ScrollTarget(), scrollclipped);
 
         auto size = GetInteriorSize();
         auto val = stack.GetValue();
--- a/Source/Gorgon/Widgets/Panel.h	Mon Oct 25 06:58:50 2021 +0300
+++ b/Source/Gorgon/Widgets/Panel.h	Tue Oct 26 14:22:22 2021 +0300
@@ -180,11 +180,16 @@
             ScrollTo(target.X + x, target.Y + y, clip);
         }
         
-        /// Returns the current scroll offset
+        /// Returns the current scroll offset, updates during animations
         Geometry::Point ScrollOffset() const {
             return scrolloffset;
         }
         
+        /// Returns the current scroll offset target.
+        Geometry::Point ScrollTarget() const {
+            return target;
+        }
+        
         /// Returns the current maximum scroll offset
         Geometry::Point MaxScrollOffset() const {
             return maxscrolloffset();

mercurial