aboutsummaryrefslogtreecommitdiffstatsci
path: root/src
diff options
context:
space:
mode:
authorj-p <jp.bruyere@live.be>2016-10-04 16:55:37 +0200
committerGitHub <noreply@github.com>2016-10-04 16:55:37 +0200
commitfaad767304aa1280a907c9851e40d2b82a1a4f54 (patch)
treef345bb4a1db2f8f16936019ee9651a20953b6a99 /src
parent2616e6ee7a1a34036cc002d28543d0d7a657fdb2 (diff)
Inherited dims (#31)v0.5
* Implement 'Inherit' measure to reduce bindings load. modifié : Templates/ArrowButTemplate.crow modifié : Templates/Button.template modifié : Templates/CheckBox.template modifié : Templates/ComboBox.template modifié : Templates/DirectoryView.template modifié : Templates/Expandable.template modifié : Templates/GroupBox.template modifié : Templates/ListBox.template modifié : Templates/Menu.template modifié : Templates/MenuItem.template modifié : Templates/MessageBox.template modifié : Templates/Popper.template modifié : Templates/RadioButton.template modifié : Templates/ScrollBar.template modifié : Templates/ScrollingListBox.goml modifié : Templates/Spinner.template modifié : Templates/TabItem.template modifié : Templates/TreeView.template modifié : Templates/Window.template modifié : Templates/treeList.crow modifié : Tests/Interfaces/Container/0.crow modifié : Tests/Interfaces/TemplatedContainer/testTreeView.crow modifié : Tests/Interfaces/TemplatedControl/testItemTemplateTag.crow modifié : Tests/Interfaces/TmpExpandable.goml modifié : Tests/Interfaces/treeList.crow modifié : Tests/ui/Popper.template modifié : Tests/ui/tmpWindow.crow modifié : src/GraphicObjects/GraphicObject.cs modifié : src/Measure.cs * leave template bindings for sizing in ScrollBar template because Inherited values are not working. modifié : Templates/ScrollBar.template renommé : Tests/Interfaces/TemplatedControl/testScrollbar.goml -> Tests/Interfaces/TemplatedControl/testScrollbar.crow renommé : Tests/Interfaces/TemplatedControl/testSpinner.goml -> Tests/Interfaces/TemplatedControl/testSpinner.crow modifié : Tests/Tests.csproj * update nuspec
Diffstat (limited to 'src')
-rw-r--r--src/GraphicObjects/GraphicObject.cs16
-rw-r--r--src/Measure.cs13
2 files changed, 20 insertions, 9 deletions
diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs
index 093664d1..e69aaaca 100644
--- a/src/GraphicObjects/GraphicObject.cs
+++ b/src/GraphicObjects/GraphicObject.cs
@@ -276,9 +276,13 @@ namespace Crow
Width = Height = Measure.Fit;
}
}
- [XmlAttributeAttribute()][DefaultValue("Stretched")]
+ [XmlAttributeAttribute()][DefaultValue("Inherit")]
public virtual Measure Width {
- get { return width; }
+ get {
+ return width.Units == Unit.Inherit ?
+ Parent is GraphicObject ? (Parent as GraphicObject).WidthPolicy :
+ Measure.Stretched : width;
+ }
set {
if (width == value)
return;
@@ -308,9 +312,13 @@ namespace Crow
this.RegisterForLayouting (LayoutingType.Width);
}
}
- [XmlAttributeAttribute()][DefaultValue("Stretched")]
+ [XmlAttributeAttribute()][DefaultValue("Inherit")]
public virtual Measure Height {
- get { return height; }
+ get {
+ return height.Units == Unit.Inherit ?
+ Parent is GraphicObject ? (Parent as GraphicObject).HeightPolicy :
+ Measure.Stretched : height;
+ }
set {
if (height == value)
return;
diff --git a/src/Measure.cs b/src/Measure.cs
index c9b08f22..26c3bfde 100644
--- a/src/Measure.cs
+++ b/src/Measure.cs
@@ -25,7 +25,7 @@ namespace Crow
/// <summary>
/// Measurement unit
/// </summary>
- public enum Unit { Pixel, Percent }
+ public enum Unit { Pixel, Percent, Inherit }
/// <summary>
/// Measure class allow proportional sizes as well as stretched and fit on content.
/// </summary>
@@ -49,7 +49,7 @@ namespace Crow
/// set to 100 Percents
/// </summary>
public static Measure Stretched = new Measure(100, Unit.Percent);
-
+ public static Measure Inherit = new Measure (0, Unit.Inherit);
#region CTOR
public Measure (int _value, Unit _units = Unit.Pixel)
{
@@ -98,7 +98,8 @@ namespace Crow
}
public override string ToString ()
{
- return Value == -1 ? "Fit" :
+ return Units == Unit.Inherit ? "Inherit" :
+ Value == -1 ? "Fit" :
Units == Unit.Percent ? Value == 100 ? "Stretched" :
Value.ToString () + "%" : Value.ToString ();
}
@@ -111,10 +112,12 @@ namespace Crow
string st = s.Trim ();
int tmp = 0;
- if (string.Equals ("Fit", st, StringComparison.Ordinal))
+ if (string.Equals ("Inherit", st, StringComparison.Ordinal))
+ return Measure.Inherit;
+ else if (string.Equals ("Fit", st, StringComparison.Ordinal))
return Measure.Fit;
else if (string.Equals ("Stretched", s, StringComparison.Ordinal))
- return Measure.Stretched;
+ return Measure.Stretched;
else {
if (st.EndsWith ("%", StringComparison.Ordinal)) {
if (int.TryParse (s.Substring(0, st.Length - 1), out tmp))