aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/GraphicObjects/GenericStack.cs
diff options
context:
space:
mode:
authorj-p <jp.bruyere@live.be>2015-05-02 09:22:03 +0200
committerj-p <jp.bruyere@live.be>2015-05-02 09:22:03 +0200
commit2a48f25993b48535eb84f0e83e4dd7c064ed6e49 (patch)
tree809bc55854f13cb031d26129e7db24076119bca0 /src/GraphicObjects/GenericStack.cs
parent79224ffe3efe06a99cb5dfb183f16a5427504b2a (diff)
parent40392cc3bcaee5b67d85b0aabfd42d2881823bd6 (diff)
Merge pull request #3 from jpbruyere/LayoutingQueue
Layouting queue
Diffstat (limited to 'src/GraphicObjects/GenericStack.cs')
-rw-r--r--src/GraphicObjects/GenericStack.cs114
1 files changed, 34 insertions, 80 deletions
diff --git a/src/GraphicObjects/GenericStack.cs b/src/GraphicObjects/GenericStack.cs
index a36cd7b1..f34e13d3 100644
--- a/src/GraphicObjects/GenericStack.cs
+++ b/src/GraphicObjects/GenericStack.cs
@@ -18,11 +18,22 @@ namespace go
#endregion
#region Private fields
- bool childrenArePositionned = false;
int _spacing;
Orientation _orientation;
#endregion
+ public override T addChild<T> (T child)
+ {
+ T tmp = base.addChild (child);
+ this.RegisterForLayouting ((int)LayoutingType.PositionChildren);
+ return tmp;
+ }
+ public override void removeChild (GraphicObject child)
+ {
+ base.removeChild (child);
+ this.RegisterForLayouting ((int)LayoutingType.PositionChildren);
+ }
+
#region Public Properties
[XmlAttributeAttribute()][DefaultValue(2)]
public int Spacing
@@ -49,49 +60,25 @@ namespace go
get { return base.Height; }
set { base.Height = value; }
}
- [XmlIgnore]public override bool LayoutIsValid {
- get { return childrenArePositionned && base.LayoutIsValid; }
- set { base.LayoutIsValid = value; }
- }
- public override void InvalidateLayout ()
- {
- childrenArePositionned = false;
- base.InvalidateLayout ();
- }
protected override Size measureRawSize ()
{
- Size raw = Bounds.Size;
Size tmp = new Size ();
- if (raw.Width >= 0 && raw.Height >= 0)
- return raw;
-
- foreach (GraphicObject c in Children) {
- if (raw.Width < 0) {
- if (c.WIsValid) {
- if (Orientation == Orientation.Horizontal && c.Bounds.Width != 0)
- tmp.Width += c.Slot.Width + Spacing;
- else
- tmp.Width = Math.Max (tmp.Width, c.Slot.Right);
- }else
- return raw;
+ if (Orientation == Orientation.Horizontal) {
+ foreach (GraphicObject c in Children) {
+ tmp.Width += c.Slot.Width + Spacing;
+ tmp.Height = Math.Max (tmp.Height, c.Slot.Bottom);
}
- if (raw.Height < 0) {
- if (c.HIsValid) {
- if (Orientation == Orientation.Vertical && c.Bounds.Height != 0)
- tmp.Height += c.Slot.Height + Spacing;
- else
- tmp.Height = Math.Max (tmp.Height, c.Slot.Bottom);
- }else
- return raw;
+ } else {
+ foreach (GraphicObject c in Children) {
+ tmp.Width = Math.Max (tmp.Width, c.Slot.Right);
+ tmp.Height += c.Slot.Height + Spacing;
}
}
- if (raw.Width < 0)
- tmp.Width += 2*Margin;
- if (raw.Height < 0)
- tmp.Height += 2*Margin;
+ tmp.Width += 2*Margin;
+ tmp.Height += 2*Margin;
return tmp;
}
@@ -100,66 +87,33 @@ namespace go
int d = 0;
if (Orientation == Orientation.Horizontal) {
foreach (GraphicObject c in Children) {
- if (c.Bounds.Width == 0)
- continue;
-
c.Slot.X = d;
- c.XIsValid = true;
d += c.Slot.Width + Spacing;
}
} else {
foreach (GraphicObject c in Children) {
- if (c.Bounds.Height == 0)
- continue;
-
c.Slot.Y = d;
- c.YIsValid = true;
d += c.Slot.Height + Spacing;
}
}
- childrenArePositionned = true;
}
- public override void UpdateLayout()
- {
- base.UpdateLayout();
-
- ComputeChildrenPositions ();
+ public override void RegisterForLayouting (int layoutType)
+ {
+ base.RegisterForLayouting (layoutType);
- if (LayoutIsValid)
- registerForRedraw();
+ if ((layoutType & (int)LayoutingType.PositionChildren) > 0)
+ Interface.LayoutingQueue.Enqueue (LayoutingType.PositionChildren, this);
+ }
+ public override void UpdateLayout (LayoutingType layoutType)
+ {
+ if (layoutType == LayoutingType.PositionChildren)
+ ComputeChildrenPositions ();
+ else
+ base.UpdateLayout(layoutType);
}
#endregion
- //
-// bool enoughtSpaceForWidget(GraphicObject w)
-// {
-// if (!SizeToContent)
-// {
-// int nextXForWidget = 0;
-// int nextYForWidget = 0;
-//
-// if (Orientation == Orientation.Horizontal)
-// nextXForWidget = currentXForWidget + w.Slot.Width;
-// else
-// nextYForWidget = nextYForWidget + w.Slot.Height;
-//
-//
-// if (nextXForWidget > ClientRectangle.Right )
-// return false;
-// if (currentYForWidget > ClientRectangle.Bottom )
-// return false;
-// }
-// return true;
-// }
-// void advance(GraphicObject w)
-// {
-// if (Orientation == Orientation.Horizontal)
-// currentXForWidget = currentXForWidget + WidgetSpacing + w.Slot.Width;
-// else
-// currentYForWidget = currentYForWidget + WidgetSpacing + w.Slot.Height;
-//
-// }
}
}