]> O.S.I.I.S - jp/crow.git/commitdiff
- min and max dimensions for objects
authorjpbruyere <jp.bruyere@hotmail.com>
Wed, 3 Jun 2015 15:05:51 +0000 (17:05 +0200)
committerjpbruyere <jp.bruyere@hotmail.com>
Wed, 3 Jun 2015 15:05:51 +0000 (17:05 +0200)
GOLib.csproj
Templates/ComboListOverlay.goml [new file with mode: 0755]
Templates/Listbox.goml
Tests/GOLIBTest_Listbox.cs
Tests/Interfaces/test_Listbox.goml
src/GraphicObjects/GraphicObject.cs
src/Size.cs

index a89eeb501ff4b1b737774eb615e396dfa609567a..c281a642d49ea2d67ca3fe3fabbb4311a79482aa 100644 (file)
     <EmbeddedResource Include="Templates\Spinner.goml" />\r
     <EmbeddedResource Include="Templates\Spinner %28copier%29.goml" />\r
     <EmbeddedResource Include="Templates\ItemTemplate.goml" />\r
+    <EmbeddedResource Include="Templates\ComboListOverlay.goml" />\r
   </ItemGroup>\r
 </Project>\r
diff --git a/Templates/ComboListOverlay.goml b/Templates/ComboListOverlay.goml
new file mode 100755 (executable)
index 0000000..65bac62
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>\r
+<Border MaximumSize="0;100" Fit="True" Background="Gray">\r
+       <Scroller Height="0" MaximumSize="0;100" Background="DimGray" Margin="0" VerticalScrolling="true">\r
+               <VerticalStack Name="List" Margin="0" VerticalAlignment="Top"/>\r
+       </Scroller>\r
+</Border>
\ No newline at end of file
index 43f8425b5928132abf33e1c9fe6287e878bce0f8..4a661db0e01f0385e8415e56446835ebb4a6abb8 100755 (executable)
@@ -1,5 +1,4 @@
 <?xml version="1.0"?>\r
-<Border  Fit="True" Background="Gray">\r
-       <VerticalStack Name="List" Margin="5">\r
-       </VerticalStack>\r
+<Border Margin="2" MinimumSize="0;200" Fit="True" Background="Gray">\r
+       <VerticalStack Name="List" Margin="0"/>\r
 </Border>
\ No newline at end of file
index 624bc2c7b16436c9094de6eb9a0cde9d28cd7bc3..815acfd2755323043342832770487e68963d7aff 100644 (file)
@@ -66,7 +66,13 @@ namespace test
                        {\r
                                "string 1",\r
                                "string 2",\r
-                               "string 3"\r
+//                             "string 3",\r
+//                             "string 4",\r
+//                             "string 5",\r
+//                             "string 6",\r
+//                             "string 7",\r
+//                             "string 8",\r
+                               "string 9"\r
                        });             \r
 //             string[] TestList = new string[] \r
 //                     {\r
index d336ae3c6a2939a67704f6897815e40102587711..2263793a5e084ab134c56b8f8bbc3ce07a637069 100755 (executable)
@@ -1,3 +1,3 @@
 <?xml version="1.0"?>\r
-       <ListBox Data="{TestList}">\r
-       </ListBox>\r
+<ListBox Data="{TestList}">\r
+</ListBox>\r
index 72fccfba7090617810d5c590b8252259555b3d89..0a402f12215fc100a4ae6deb3edd6a2a98e2ed93 100644 (file)
@@ -47,6 +47,8 @@ namespace go
                protected bool _isVisible = true;\r
                VerticalAlignment _verticalAlignment;\r
                HorizontalAlignment _horizontalAlignment;\r
+               Size _maximumSize;\r
+               Size _minimumSize;\r
 \r
                Picture _backgroundImage;\r
                string _template;\r
@@ -264,7 +266,18 @@ namespace go
                                registerForGraphicUpdate ();\r
                        }\r
                }\r
+               [XmlAttributeAttribute()][DefaultValue("0;0")]\r
+               public Size MaximumSize {\r
+                       get { return _maximumSize; }\r
+                       set { _maximumSize = value; }\r
+               }\r
+               [XmlAttributeAttribute()][DefaultValue("0;0")]\r
+               public Size MinimumSize {\r
+                       get { return _minimumSize; }\r
+                       set { _minimumSize = value; }\r
+               }\r
                #endregion\r
+\r
                public string BackImgSub = null;\r
 \r
                /// <summary>\r
@@ -307,6 +320,8 @@ namespace go
                                                        pi.SetValue (this, Font.Parse ((string)dv.Value), null);\r
                                                else if (pi.PropertyType == typeof(Picture))\r
                                                        pi.SetValue (this, Picture.Parse ((string)dv.Value), null);\r
+                                               else if (pi.PropertyType == typeof(Size))\r
+                                                       pi.SetValue (this, Size.Parse ((string)dv.Value), null);\r
                                                else\r
                                                        pi.SetValue (this, dv.Value, null);\r
                                                continue;\r
@@ -354,7 +369,7 @@ namespace go
                        TopContainer.redrawClip.AddRectangle (ScreenCoordinates(Slot));\r
                }\r
                protected virtual Size measureRawSize ()\r
-               {                       \r
+               {\r
                        return Bounds.Size;\r
                }\r
 \r
@@ -489,6 +504,12 @@ namespace go
                                else\r
                                        Slot.Width = Parent.ClientRectangle.Width;\r
 \r
+                               //size constrain\r
+                               if (Slot.Width < MinimumSize.Width)\r
+                                       Slot.Width = MinimumSize.Width;\r
+                               else if (Slot.Width > MaximumSize.Width && MaximumSize.Width > 0)\r
+                                       Slot.Width = MaximumSize.Width;\r
+\r
                                if (LastSlots.Width == Slot.Width)\r
                                        break;\r
 \r
@@ -506,6 +527,13 @@ namespace go
                                else\r
                                        Slot.Height = Parent.ClientRectangle.Height;\r
 \r
+                               //size constrain\r
+                               if (Slot.Height < MinimumSize.Height)\r
+                                       Slot.Height = MinimumSize.Height;\r
+                               else if (Slot.Height > MaximumSize.Height && MaximumSize.Height > 0)\r
+                                       Slot.Height = MaximumSize.Height;\r
+\r
+\r
                                if (LastSlots.Height == Slot.Height)\r
                                        break;\r
 \r
@@ -728,6 +756,8 @@ namespace go
                                                        pi.SetValue (this, Font.Parse ((string)defaultValue), null);\r
                                                else if (pi.PropertyType == typeof(Picture))\r
                                                        pi.SetValue (this, Picture.Parse ((string)defaultValue), null);\r
+                                               else if (pi.PropertyType == typeof(Size))\r
+                                                       pi.SetValue (this, Size.Parse ((string)defaultValue), null);\r
                                                else\r
                                                        pi.SetValue (this, defaultValue, null);\r
                                        } else {\r
index 72f8fff17f0ff92e85ff555fe2c38021159c1f73..c22315768412b70e80dc2bbaa0923cb68ef517e6 100755 (executable)
@@ -9,16 +9,20 @@ namespace go
     {\r
         public static Size Zero\r
         { get { return new Size(0, 0); } }\r
+\r
         int _width;\r
         int _height;\r
 \r
-        //public Size()\r
-        //{ }\r
         public Size(int width, int height)\r
         {\r
             _width = width;\r
             _height = height;\r
         }\r
+               public Size(int size)\r
+               {\r
+                       _width = size;\r
+                       _height = size;\r
+               }\r
         public int Width\r
         {\r
             get { return _width; }\r
@@ -29,10 +33,7 @@ namespace go
             get { return _height; }\r
             set { _height = value; }\r
         }\r
-        public override string ToString()\r
-        {\r
-            return string.Format("({0},{1})", Width, Height);\r
-        }\r
+               #region operators\r
                public static implicit operator Rectangle(Size s)\r
                {\r
                        return new Rectangle (s);\r
@@ -41,7 +42,15 @@ namespace go
         {\r
             return new Size(i, i);\r
         }\r
-        public static bool operator ==(Size s1, Size s2)\r
+               public static implicit operator string(Size s)\r
+               {\r
+                       return s.ToString ();\r
+               }\r
+               public static implicit operator Size(string s)\r
+               {\r
+                       return string.IsNullOrEmpty (s) ? Size.Zero : Parse (s);\r
+               }\r
+               public static bool operator ==(Size s1, Size s2)\r
         {\r
             if (s1.Width == s2.Width && s1.Height == s2.Height)\r
                 return true;\r
@@ -118,6 +127,19 @@ namespace go
         {\r
             return new Size(s.Width + i, s.Height + i);\r
         }\r
-    }\r
+               #endregion\r
+    \r
+               public override string ToString()\r
+               {\r
+                       return string.Format("{0},{1}", Width, Height);\r
+               }\r
+               public static Size Parse(string s)\r
+               {\r
+                       string[] d = s.Split(new char[] { ';' });\r
+                       return d.Length == 1 ? new Size(int.Parse(d[0])) : new Size(\r
+                               int.Parse(d[0]),\r
+                               int.Parse(d[1]));\r
+               }\r
+       }\r
 \r
 }\r