]> O.S.I.I.S - jp/crow.git/commitdiff
reset scrollX and Y when scroller child is group and it's children
authorjpbruyere <jp.bruyere@hotmail.com>
Wed, 21 Oct 2015 10:03:07 +0000 (12:03 +0200)
committerjpbruyere <jp.bruyere@hotmail.com>
Wed, 21 Oct 2015 10:03:07 +0000 (12:03 +0200)
have been cleared

src/GraphicObjects/Group.cs
src/GraphicObjects/Scroller.cs

index 78378aa8642897cefffbf17170e1f8a8e2f5ca99..bf04617d18ea739fe24e4a477b8eab7356b6701d 100644 (file)
@@ -19,6 +19,10 @@ namespace go
                }\r
                #endregion\r
 \r
+               #region EVENT HANDLERS\r
+               public event EventHandler<EventArgs> ChildrenCleared;\r
+               #endregion\r
+\r
         bool _multiSelect = false;\r
                List<GraphicObject> children = new List<GraphicObject>();\r
 \r
@@ -63,6 +67,7 @@ namespace go
                                Children.Remove(g);                             \r
                        }\r
                        this.RegisterForLayouting ((int)LayoutingType.Sizing);\r
+                       ChildrenCleared.Raise (this, new EventArgs ());\r
                }\r
                public void putWidgetOnTop(GraphicObject w)\r
                {\r
index b0fdc120cc5f8bb6b00b4e7eb01f1d268ac994c0..8c2303ccf02c713f9505f7a7d5cda67fd4dcd080 100644 (file)
@@ -105,20 +105,41 @@ namespace go
                #region GraphicObject Overrides\r
                void OnChildLayoutChanges (object sender, LayoutChangeEventArgs arg)\r
                {\r
+                       int maxScroll = MaximumScroll;\r
                        if (_verticalScrolling) {\r
-                               if (arg.LayoutType  == LayoutingType.Height)\r
-                                       ValueChanged.Raise(this, new ValueChangeEventArgs("MaximumScroll", MaximumScroll));                             \r
-                       }else if (arg.LayoutType  == LayoutingType.Width)\r
-                               ValueChanged.Raise(this, new ValueChangeEventArgs("MaximumScroll", MaximumScroll));                             \r
+                               if (arg.LayoutType == LayoutingType.Height) {\r
+                                       if (maxScroll < ScrollY) {\r
+                                               Debug.WriteLine ("scrolly={0} maxscroll={1}", ScrollY, maxScroll);\r
+                                               ScrollY = 0;\r
+                                       }\r
+                                       ValueChanged.Raise (this, new ValueChangeEventArgs ("MaximumScroll", maxScroll));\r
+                               }\r
+                       } else if (arg.LayoutType == LayoutingType.Width) {\r
+                               if (maxScroll < ScrollX)\r
+                                       ScrollX = 0;\r
+                               ValueChanged.Raise (this, new ValueChangeEventArgs ("MaximumScroll", maxScroll));\r
+                       }\r
+               }\r
+               void onChildListCleared(object sender, EventArgs e){\r
+                       ScrollY = 0;\r
+                       ScrollX = 0;\r
                }\r
                public override T SetChild<T> (T _child)\r
                {                       \r
                        GraphicObject c = child as GraphicObject;\r
-                       if (c != null)\r
+                       Group g = child as Group;\r
+                       if (c != null) {\r
                                c.LayoutChanged -= OnChildLayoutChanges;\r
+                               if (g != null)\r
+                                       g.ChildrenCleared -= onChildListCleared;\r
+                       }\r
                        c = _child as GraphicObject;\r
-                       if (c != null)\r
+                       g = _child as Group;\r
+                       if (c != null) {\r
                                c.LayoutChanged += OnChildLayoutChanges;\r
+                               if (g != null)\r
+                                       g.ChildrenCleared += onChildListCleared;                                \r
+                       }\r
                        return base.SetChild (_child);\r
                }\r
                #endregion\r