aboutsummaryrefslogtreecommitdiffstatsci
diff options
context:
space:
mode:
authorjpbruyere <jp.bruyere@hotmail.com>2015-06-03 17:05:51 +0200
committerjpbruyere <jp.bruyere@hotmail.com>2015-06-03 17:05:51 +0200
commita7363d1f7e4eb1611e4ab522c8cf381b70570b7e (patch)
treed8f9f599fb6c13d55db8bc48a998b0c7430333ef
parentef87679b886e5ce8b4defc21e3b9eac6c5030663 (diff)
- min and max dimensions for objects
-rw-r--r--GOLib.csproj1
-rwxr-xr-xTemplates/ComboListOverlay.goml6
-rwxr-xr-xTemplates/Listbox.goml5
-rw-r--r--Tests/GOLIBTest_Listbox.cs8
-rwxr-xr-xTests/Interfaces/test_Listbox.goml4
-rw-r--r--src/GraphicObjects/GraphicObject.cs32
-rwxr-xr-xsrc/Size.cs38
7 files changed, 79 insertions, 15 deletions
diff --git a/GOLib.csproj b/GOLib.csproj
index a89eeb50..c281a642 100644
--- a/GOLib.csproj
+++ b/GOLib.csproj
@@ -346,5 +346,6 @@
<EmbeddedResource Include="Templates\Spinner.goml" />
<EmbeddedResource Include="Templates\Spinner %28copier%29.goml" />
<EmbeddedResource Include="Templates\ItemTemplate.goml" />
+ <EmbeddedResource Include="Templates\ComboListOverlay.goml" />
</ItemGroup>
</Project>
diff --git a/Templates/ComboListOverlay.goml b/Templates/ComboListOverlay.goml
new file mode 100755
index 00000000..65bac62b
--- /dev/null
+++ b/Templates/ComboListOverlay.goml
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+<Border MaximumSize="0;100" Fit="True" Background="Gray">
+ <Scroller Height="0" MaximumSize="0;100" Background="DimGray" Margin="0" VerticalScrolling="true">
+ <VerticalStack Name="List" Margin="0" VerticalAlignment="Top"/>
+ </Scroller>
+</Border> \ No newline at end of file
diff --git a/Templates/Listbox.goml b/Templates/Listbox.goml
index 43f8425b..4a661db0 100755
--- a/Templates/Listbox.goml
+++ b/Templates/Listbox.goml
@@ -1,5 +1,4 @@
<?xml version="1.0"?>
-<Border Fit="True" Background="Gray">
- <VerticalStack Name="List" Margin="5">
- </VerticalStack>
+<Border Margin="2" MinimumSize="0;200" Fit="True" Background="Gray">
+ <VerticalStack Name="List" Margin="0"/>
</Border> \ No newline at end of file
diff --git a/Tests/GOLIBTest_Listbox.cs b/Tests/GOLIBTest_Listbox.cs
index 624bc2c7..815acfd2 100644
--- a/Tests/GOLIBTest_Listbox.cs
+++ b/Tests/GOLIBTest_Listbox.cs
@@ -66,7 +66,13 @@ namespace test
{
"string 1",
"string 2",
- "string 3"
+// "string 3",
+// "string 4",
+// "string 5",
+// "string 6",
+// "string 7",
+// "string 8",
+ "string 9"
});
// string[] TestList = new string[]
// {
diff --git a/Tests/Interfaces/test_Listbox.goml b/Tests/Interfaces/test_Listbox.goml
index d336ae3c..2263793a 100755
--- a/Tests/Interfaces/test_Listbox.goml
+++ b/Tests/Interfaces/test_Listbox.goml
@@ -1,3 +1,3 @@
<?xml version="1.0"?>
- <ListBox Data="{TestList}">
- </ListBox>
+<ListBox Data="{TestList}">
+</ListBox>
diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs
index 72fccfba..0a402f12 100644
--- a/src/GraphicObjects/GraphicObject.cs
+++ b/src/GraphicObjects/GraphicObject.cs
@@ -47,6 +47,8 @@ namespace go
protected bool _isVisible = true;
VerticalAlignment _verticalAlignment;
HorizontalAlignment _horizontalAlignment;
+ Size _maximumSize;
+ Size _minimumSize;
Picture _backgroundImage;
string _template;
@@ -264,7 +266,18 @@ namespace go
registerForGraphicUpdate ();
}
}
+ [XmlAttributeAttribute()][DefaultValue("0;0")]
+ public Size MaximumSize {
+ get { return _maximumSize; }
+ set { _maximumSize = value; }
+ }
+ [XmlAttributeAttribute()][DefaultValue("0;0")]
+ public Size MinimumSize {
+ get { return _minimumSize; }
+ set { _minimumSize = value; }
+ }
#endregion
+
public string BackImgSub = null;
/// <summary>
@@ -307,6 +320,8 @@ namespace go
pi.SetValue (this, Font.Parse ((string)dv.Value), null);
else if (pi.PropertyType == typeof(Picture))
pi.SetValue (this, Picture.Parse ((string)dv.Value), null);
+ else if (pi.PropertyType == typeof(Size))
+ pi.SetValue (this, Size.Parse ((string)dv.Value), null);
else
pi.SetValue (this, dv.Value, null);
continue;
@@ -354,7 +369,7 @@ namespace go
TopContainer.redrawClip.AddRectangle (ScreenCoordinates(Slot));
}
protected virtual Size measureRawSize ()
- {
+ {
return Bounds.Size;
}
@@ -489,6 +504,12 @@ namespace go
else
Slot.Width = Parent.ClientRectangle.Width;
+ //size constrain
+ if (Slot.Width < MinimumSize.Width)
+ Slot.Width = MinimumSize.Width;
+ else if (Slot.Width > MaximumSize.Width && MaximumSize.Width > 0)
+ Slot.Width = MaximumSize.Width;
+
if (LastSlots.Width == Slot.Width)
break;
@@ -506,6 +527,13 @@ namespace go
else
Slot.Height = Parent.ClientRectangle.Height;
+ //size constrain
+ if (Slot.Height < MinimumSize.Height)
+ Slot.Height = MinimumSize.Height;
+ else if (Slot.Height > MaximumSize.Height && MaximumSize.Height > 0)
+ Slot.Height = MaximumSize.Height;
+
+
if (LastSlots.Height == Slot.Height)
break;
@@ -728,6 +756,8 @@ namespace go
pi.SetValue (this, Font.Parse ((string)defaultValue), null);
else if (pi.PropertyType == typeof(Picture))
pi.SetValue (this, Picture.Parse ((string)defaultValue), null);
+ else if (pi.PropertyType == typeof(Size))
+ pi.SetValue (this, Size.Parse ((string)defaultValue), null);
else
pi.SetValue (this, defaultValue, null);
} else {
diff --git a/src/Size.cs b/src/Size.cs
index 72f8fff1..c2231576 100755
--- a/src/Size.cs
+++ b/src/Size.cs
@@ -9,16 +9,20 @@ namespace go
{
public static Size Zero
{ get { return new Size(0, 0); } }
+
int _width;
int _height;
- //public Size()
- //{ }
public Size(int width, int height)
{
_width = width;
_height = height;
}
+ public Size(int size)
+ {
+ _width = size;
+ _height = size;
+ }
public int Width
{
get { return _width; }
@@ -29,10 +33,7 @@ namespace go
get { return _height; }
set { _height = value; }
}
- public override string ToString()
- {
- return string.Format("({0},{1})", Width, Height);
- }
+ #region operators
public static implicit operator Rectangle(Size s)
{
return new Rectangle (s);
@@ -41,7 +42,15 @@ namespace go
{
return new Size(i, i);
}
- public static bool operator ==(Size s1, Size s2)
+ public static implicit operator string(Size s)
+ {
+ return s.ToString ();
+ }
+ public static implicit operator Size(string s)
+ {
+ return string.IsNullOrEmpty (s) ? Size.Zero : Parse (s);
+ }
+ public static bool operator ==(Size s1, Size s2)
{
if (s1.Width == s2.Width && s1.Height == s2.Height)
return true;
@@ -118,6 +127,19 @@ namespace go
{
return new Size(s.Width + i, s.Height + i);
}
- }
+ #endregion
+
+ public override string ToString()
+ {
+ return string.Format("{0},{1}", Width, Height);
+ }
+ public static Size Parse(string s)
+ {
+ string[] d = s.Split(new char[] { ';' });
+ return d.Length == 1 ? new Size(int.Parse(d[0])) : new Size(
+ int.Parse(d[0]),
+ int.Parse(d[1]));
+ }
+ }
}