]> O.S.I.I.S - jp/crow.git/commitdiff
positif scrolling value
authorjpbruyere <jp.bruyere@hotmail.com>
Mon, 22 Jun 2015 11:42:32 +0000 (13:42 +0200)
committerjpbruyere <jp.bruyere@hotmail.com>
Mon, 22 Jun 2015 11:42:32 +0000 (13:42 +0200)
scrollx and y as properties for xml binding

src/GraphicObjects/Scroller.cs
src/Rectangle.cs

index 0b0eaae77528602ef467b8ab1136fe0b3149472a..bd8384a2fe8a745b8d7f2bb48824b1d540259282 100644 (file)
@@ -7,6 +7,7 @@ using System.Drawing;
 using Cairo;\r
 using System.Xml.Serialization;\r
 using OpenTK.Input;\r
+using System.ComponentModel;\r
 \r
 namespace go\r
 {\r
@@ -14,27 +15,51 @@ namespace go
     {\r
                bool _verticalScrolling;\r
                bool _horizontalScrolling;\r
+               bool _scrollbarVisible;\r
+               int _scrollX = 0;\r
+               int _scrollY = 0;\r
+\r
 \r
                #region public properties\r
 \r
-               [System.Xml.Serialization.XmlAttributeAttribute()]\r
-               [System.ComponentModel.DefaultValue(false)]\r
+               [XmlAttributeAttribute][DefaultValue(false)]\r
                public bool VerticalScrolling {\r
                        get { return _verticalScrolling; }\r
                        set { _verticalScrolling = value; }\r
                }\r
         \r
-               [System.Xml.Serialization.XmlAttributeAttribute()]\r
-               [System.ComponentModel.DefaultValue(false)]\r
+               [XmlAttributeAttribute][DefaultValue(false)]\r
         public bool HorizontalScrolling {\r
                        get { return _horizontalScrolling; }\r
                        set { _horizontalScrolling = value; }\r
                }\r
+               [XmlAttributeAttribute][DefaultValue(true)]\r
+               public bool ScrollbarVisible {\r
+                       get { return _scrollbarVisible; }\r
+                       set { _scrollbarVisible = value; }\r
+               }\r
 \r
-        [XmlIgnore]         \r
-        public int scrollX = 0;\r
-        [XmlIgnore]\r
-        public int scrollY = 0;\r
+\r
+               [XmlIgnore]         \r
+               public int ScrollX {\r
+                       get {\r
+                               return _scrollX;\r
+                       }\r
+                       set {\r
+                               _scrollX = value;\r
+                       }\r
+               }\r
+\r
+\r
+               [XmlIgnore]\r
+               public int ScrollY {\r
+                       get {\r
+                               return _scrollY;\r
+                       }\r
+                       set {\r
+                               _scrollY = value;\r
+                       }\r
+               }\r
 \r
                public static int ScrollSpeed = 10;\r
 \r
@@ -57,7 +82,7 @@ namespace go
                }\r
                public override void onMouseMove (object sender, MouseMoveEventArgs e)\r
                {\r
-                       Point m = e.Position + new Point (scrollX, scrollY);\r
+                       Point m = e.Position - new Point (ScrollX, ScrollY);\r
                        base.onMouseMove (sender, new MouseMoveEventArgs(m.X,m.Y,e.XDelta,e.YDelta));\r
                }\r
                public override void onMouseWheel (object sender, MouseWheelEventArgs e)\r
@@ -74,12 +99,12 @@ namespace go
                 //add redraw call with old bounds to errase old position\r
                 RegisterForRedraw();\r
 \r
-                               scrollY += e.Delta * ScrollSpeed;\r
+                               ScrollY -= e.Delta * ScrollSpeed;\r
 \r
-                if (scrollY > 0)\r
-                    scrollY = 0;\r
-                               else if (scrollY < -Child.Slot.Height + ClientRectangle.Height)\r
-                                       scrollY = -Child.Slot.Height + ClientRectangle.Height;\r
+                if (ScrollY < 0)\r
+                    ScrollY = 0;\r
+                               else if (ScrollY > Child.Slot.Height - ClientRectangle.Height)\r
+                                       ScrollY = Child.Slot.Height - ClientRectangle.Height;\r
 \r
             }\r
             if (HorizontalScrolling )\r
@@ -87,12 +112,12 @@ namespace go
                 //add redraw call with old bounds to errase old position\r
                 RegisterForRedraw();\r
 \r
-                               scrollX += e.Delta * ScrollSpeed;\r
+                               ScrollX -= e.Delta * ScrollSpeed;\r
 \r
-                               if (scrollX > 0)\r
-                                       scrollX = 0;\r
-                               else if (scrollX < -Child.Slot.Width + ClientRectangle.Width)\r
-                                       scrollX = -Child.Slot.Width + ClientRectangle.Width;\r
+                               if (ScrollX < 0)\r
+                                       ScrollX = 0;\r
+                               else if (ScrollX > Child.Slot.Width - ClientRectangle.Width)\r
+                                       ScrollX = Child.Slot.Width - ClientRectangle.Width;\r
             }\r
 \r
 \r
@@ -104,11 +129,11 @@ namespace go
 \r
                public override Rectangle ContextCoordinates (Rectangle r)\r
                {\r
-                       return base.ContextCoordinates (r) + new Point(scrollX,scrollY);\r
+                       return base.ContextCoordinates (r) - new Point(ScrollX,ScrollY);\r
                }\r
                public override Rectangle ScreenCoordinates (Rectangle r)\r
                {\r
-                       return base.ScreenCoordinates (r) + new Point(scrollX,scrollY);\r
+                       return base.ScreenCoordinates (r) - new Point(ScrollX,ScrollY);\r
                }\r
 \r
                public override void registerClipRect ()\r
index dfe819b704fbd20678d1f1ad139ebc59995faacb..0944af661f3262d423ce2a54019d80c95f94a5a7 100755 (executable)
@@ -192,7 +192,11 @@ namespace go
                {\r
                        return new Rectangle(r.X + p.X, r.Y + p.Y, r.Width, r.Height);\r
                }\r
-        public static bool operator ==(Rectangle r1, Rectangle r2)\r
+               public static Rectangle operator -(Rectangle r, Point p)\r
+               {\r
+                       return new Rectangle(r.X - p.X, r.Y - p.Y, r.Width, r.Height);\r
+               }\r
+               public static bool operator ==(Rectangle r1, Rectangle r2)\r
         {\r
             return r1.TopLeft == r2.TopLeft && r1.Size == r2.Size ? true : false;\r
         }\r