base.OnRenderFrame (e);\r
SwapBuffers ();\r
}\r
-\r
+ protected override void OnKeyDown (KeyboardKeyEventArgs e)\r
+ {\r
+ switch (e.Key) {\r
+ case Key.Left:\r
+ g.Left++;\r
+ break;\r
+ case Key.Right:\r
+ g.Left--;\r
+ break;\r
+ case Key.Up:\r
+ g.Top--;\r
+ break;\r
+ case Key.Down:\r
+ g.Top++;\r
+ break;\r
+ default:\r
+ break;\r
+ }\r
+ }\r
protected override void OnUpdateFrame (FrameEventArgs e)\r
{\r
base.OnUpdateFrame (e);\r
: base(1024, 600,"test")\r
{}\r
\r
- VerticalStack g;\r
+ Container g;\r
\r
protected override void OnLoad (EventArgs e)\r
{\r
<?xml version="1.0"?>\r
-<GraphicObject \r
- HorizontalAlignment="Right"\r
- VerticalAlignment="Bottom"\r
+<GraphicObject\r
+ Width="100" Height="100"\r
+ Top="200" Left="200" \r
Margin="10" Background="Green"/>\r
<?xml version="1.0"?>\r
+<Container>\r
<VerticalStack>\r
<Label Text="label11"/>\r
<Label Text="label21"/>\r
<Label Text="label43"/>\r
<Label Text="label53"/>\r
\r
-</VerticalStack>
\ No newline at end of file
+</VerticalStack>\r
+</Container>
\ No newline at end of file
<?xml version="1.0"?>\r
-<Container Width="0" Height="-1"\r
- Margin="100" Focusable="True" Background="Yellow">\r
+<Container Width="300" Height="-1"\r
+ Margin="20" Focusable="True" Background="Yellow">\r
\r
<Container Width="-1" Height="-1"\r
- Margin="10" Focusable="True" Background="Green">\r
+ Margin="20" Focusable="True" Background="Green">\r
<Image VerticalAlignment="Bottom" \r
Name="PhaseOverlay" Width="100" Height="100" Path="image/u.svg" Background="Red"/>\r
</Container>\r
<OutputType>Exe</OutputType>
<RootNamespace>Tests</RootNamespace>
<AssemblyName>Tests</AssemblyName>
- <StartupObject>test.GOLIBTest_5</StartupObject>
+ <StartupObject>test.GOLIBTest_1</StartupObject>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<OutputPath>..\bin\$(configuration)</OutputPath>
<IntermediateOutputPath>obj\$(configuration)</IntermediateOutputPath>
if (value == _CurrentState)\r
return;\r
_CurrentState = value;\r
- registerForRedraw();\r
+ RegisterForRedraw();\r
}\r
}\r
\r
using System.Reflection;\r
using OpenTK.Input;\r
using System.ComponentModel;\r
+using System.Linq;\r
\r
namespace go\r
{\r
public T setChild<T>(T _child)\r
{\r
\r
- if (child != null)\r
- child.Parent = null;\r
+ if (child != null) {\r
+ this.RegisterForLayouting ((int)LayoutingType.Sizing);\r
+ child.Parent = null;\r
+ }\r
\r
child = _child as GraphicObject;\r
\r
- if (child != null)\r
- child.Parent = this;\r
+ if (child != null) {\r
+ child.Parent = this;\r
+ child.RegisterForLayouting ((int)LayoutingType.Sizing);\r
+ }\r
\r
return (T)_child;\r
}\r
get { return base.Focusable; }\r
set { base.Focusable = value; }\r
}\r
- [XmlIgnore]public override bool LayoutIsValid\r
- {\r
- get\r
- {\r
- if (!Visible)\r
- return true;\r
-\r
- return !base.LayoutIsValid || child == null ?\r
- base.LayoutIsValid :\r
- child.LayoutIsValid;\r
- }\r
- set { base.LayoutIsValid = value; }\r
- }\r
\r
public override GraphicObject FindByName (string nameToFind)\r
{\r
return child == goToFind ? true : \r
child == null ? false : child.Contains(goToFind);\r
}\r
- public override void InvalidateLayout()\r
- {\r
- base.InvalidateLayout();\r
-\r
- if (child != null)\r
- child.InvalidateLayout();\r
- }\r
protected override Size measureRawSize ()\r
{ \r
return child == null ? Bounds.Size : new Size(child.Slot.Width + 2 * (Margin),child.Slot.Height + 2 * (Margin));\r
}\r
- public override void RegisterForLayouting ()\r
- {\r
- base.RegisterForLayouting ();\r
\r
- if (child != null)\r
- child.RegisterForLayouting ();\r
+ public override void UpdateLayout (LayoutingType layoutType)\r
+ {\r
+ { \r
+ switch (layoutType) {\r
+ case LayoutingType.X:\r
+ if (Bounds.X == 0) {\r
+ switch (HorizontalAlignment) {\r
+ case HorizontalAlignment.Left:\r
+ Slot.X = 0;\r
+ break;\r
+ case HorizontalAlignment.Right:\r
+ Slot.X = Parent.ClientRectangle.Width - Slot.Width;\r
+ break;\r
+ case HorizontalAlignment.Center:\r
+ Slot.X = Parent.ClientRectangle.Width / 2 - Slot.Width / 2;\r
+ break;\r
+ }\r
+ } else\r
+ Slot.X = Bounds.X;\r
+ if (LastSlots.X == Slot.X)\r
+ break;\r
+ //register layouting here for objects depending on this.x\r
+ LastSlots.X = Slot.X;\r
+ break;\r
+ case LayoutingType.Y:\r
+ if (Bounds.Y == 0) {\r
+ switch (VerticalAlignment) {\r
+ case VerticalAlignment.Top:\r
+ Slot.Y = 0;\r
+ break;\r
+ case VerticalAlignment.Bottom:\r
+ Slot.Y = Parent.ClientRectangle.Height - Slot.Height;\r
+ break;\r
+ case VerticalAlignment.Center:\r
+ Slot.Y = Parent.ClientRectangle.Height / 2 - Slot.Height / 2;\r
+ break;\r
+ }\r
+ }else\r
+ Slot.Y = Bounds.Y;\r
+ if (LastSlots.Y == Slot.Y)\r
+ break;\r
+ //register layouting here for objects depending on this.x\r
+ LastSlots.Y = Slot.Y;\r
+ break;\r
+ case LayoutingType.Width: \r
+ if (Width > 0)\r
+ Slot.Width = Width;\r
+ else if (Width < 0)\r
+ Slot.Width = measureRawSize ().Width;\r
+ else\r
+ Slot.Width = Parent.ClientRectangle.Width;\r
+\r
+ if (LastSlots.Width == Slot.Width)\r
+ break;\r
+\r
+ if (Parent.getBounds ().Width < 0)\r
+ this.Parent.RegisterForLayouting ((int)LayoutingType.Width);\r
+ else if (Width != 0) //update position in parent\r
+ this.RegisterForLayouting ((int)LayoutingType.X);\r
+\r
+ if (child != null) {\r
+ if (child.getBounds ().Width == 0)\r
+ child.RegisterForLayouting ((int)LayoutingType.Width);\r
+ else\r
+ child.RegisterForLayouting ((int)LayoutingType.X);\r
+ }\r
+ LastSlots.Width = Slot.Width;\r
+ break;\r
+ case LayoutingType.Height:\r
+ if (Height > 0)\r
+ Slot.Height = Height;\r
+ else if (Height < 0)\r
+ Slot.Height = measureRawSize ().Height;\r
+ else\r
+ Slot.Height = Parent.ClientRectangle.Height;\r
+\r
+ if (LastSlots.Height == Slot.Height)\r
+ break;\r
+\r
+ if (Parent.getBounds().Height < 0)\r
+ this.Parent.RegisterForLayouting((int)LayoutingType.Height);\r
+ else if (Height != 0) //update position in parent\r
+ this.RegisterForLayouting ((int)LayoutingType.Y);\r
+\r
+ if (child != null) {\r
+ if (child.getBounds ().Height == 0)\r
+ child.RegisterForLayouting ((int)LayoutingType.Height);\r
+ else\r
+ child.RegisterForLayouting ((int)LayoutingType.Y);\r
+ }\r
+\r
+ LastSlots.Height = Slot.Height;\r
+ break;\r
+ }\r
+\r
+ //if no layouting remains in queue for item, registre for redraw\r
+ if (Interface.LayoutingQueue.Where (lq => lq.GraphicObject == this).Count () <= 0)\r
+ this.RegisterForRedraw ();\r
+ } \r
}\r
-// public override void UpdateLayout (LayoutingType layoutType)\r
-// {\r
-//\r
-//// if (Width < 0 && child.Width == 0)\r
-//// child.Width = -1;\r
-//// if (Height < 0 && child.Height == 0)\r
-//// child.Height = -1;\r
-////\r
-//// if (!(base.LayoutIsValid))\r
-//// base.UpdateLayout();\r
-//// \r
-//// if (child != null)\r
-//// {\r
-//// if (!child.LayoutIsValid) {\r
-//// child.UpdateLayout ();\r
-//// }\r
-//// }\r
-////\r
-//// if (LayoutIsValid)\r
-//// registerForRedraw();\r
-// }\r
+\r
public override Rectangle ContextCoordinates (Rectangle r)\r
{\r
return\r
Orientation _orientation;\r
#endregion\r
\r
+ public override T addChild<T> (T child)\r
+ {\r
+ this.RegisterForLayouting ((int)LayoutingType.PositionChildren);\r
+ return base.addChild (child);\r
+ }\r
+ public override void removeChild (GraphicObject child)\r
+ {\r
+ base.removeChild (child);\r
+ this.RegisterForLayouting ((int)LayoutingType.PositionChildren);\r
+ }\r
+\r
#region Public Properties\r
[XmlAttributeAttribute()][DefaultValue(2)]\r
public int Spacing\r
}\r
}\r
}\r
- public override void RegisterForLayouting ()\r
- {\r
- base.RegisterForLayouting ();\r
+// public void RegisterForLayouting ()\r
+// {\r
+// base.RegisterForLayouting ();\r
+//\r
+// int idx = Interface.LayoutingQueue.IndexOf (Interface.LayoutingQueue.Where (lq => lq.GraphicObject.Parent == this).LastOrDefault ());\r
+// if (idx < 0)\r
+// return;\r
+// Interface.LayoutingQueue.Insert (\r
+// idx+1,\r
+// new LayoutingQueueItem (LayoutingType.PositionChildren, this));\r
+// }\r
+ public override void RegisterForLayouting (int layoutType)\r
+ { \r
+ base.RegisterForLayouting (layoutType);\r
\r
- int idx = Interface.LayoutingQueue.IndexOf (Interface.LayoutingQueue.Where (lq => lq.GraphicObject.Parent == this).LastOrDefault ());\r
- if (idx < 0)\r
- return;\r
- Interface.LayoutingQueue.Insert (\r
- idx+1,\r
- new LayoutingQueueItem (LayoutingType.PositionChildren, this));\r
+ if ((layoutType & (int)LayoutingType.PositionChildren) > 0)\r
+ Interface.LayoutingQueue.Enqueue (LayoutingType.PositionChildren, this);\r
}\r
public override void UpdateLayout (LayoutingType layoutType)\r
{ \r
if (layoutType == LayoutingType.PositionChildren)\r
ComputeChildrenPositions ();\r
-\r
- base.UpdateLayout(layoutType);\r
+ else\r
+ base.UpdateLayout(layoutType);\r
}\r
#endregion\r
\r
\r
Bounds.X = value;\r
\r
- LayoutIsValid = false;\r
- registerForGraphicUpdate ();\r
+ Interface.LayoutingQueue.Enqueue (LayoutingType.X, this);\r
}\r
}\r
[XmlAttributeAttribute()][DefaultValue(0)]\r
\r
Bounds.Y = value;\r
\r
- LayoutIsValid = false;\r
- registerForGraphicUpdate ();\r
+ Interface.LayoutingQueue.Enqueue (LayoutingType.Y, this);\r
}\r
}\r
[XmlAttributeAttribute()][DefaultValue(0)]\r
public virtual void registerForGraphicUpdate ()\r
{\r
bmp = null;\r
- RegisterForLayouting ();\r
+ if (TopContainer != null)\r
+ TopContainer.gobjsToRedraw.Add (this);\r
+ //RegisterForLayouting ();\r
//registerForRedraw ();\r
//Interface.registerForGraphicUpdate(this);\r
}\r
/// <summary>\r
/// Add clipping region in redraw list of interface, dont update cached object content\r
/// </summary>\r
- public virtual void registerForRedraw ()\r
+ public virtual void RegisterForRedraw ()\r
{\r
- if (Visible && TopContainer != null)\r
- TopContainer.gobjsToRedraw.Add (this);\r
+ bmp = null;\r
+ TopContainer.gobjsToRedraw.Add (this);\r
}\r
+\r
+ public Rectangle LastSlots;\r
+\r
public virtual void registerClipRect()\r
{\r
TopContainer.redrawClip.AddRectangle (ScreenCoordinates(Slot));\r
}\r
protected virtual Size measureRawSize ()\r
- {\r
+ { \r
return Bounds.Size;\r
}\r
- public virtual void RegisterForLayouting()\r
+\r
+ public virtual void RegisterForLayouting(int layoutType)\r
{\r
- //clear previous layouting for item\r
- Interface.LayoutingQueue.RemoveAll (lq => lq.GraphicObject == this);\r
+ Interface.LayoutingQueue.RemoveAll (lq => lq.GraphicObject == this && (layoutType & (int)lq.LayoutType) > 0);\r
\r
- if (Bounds.Width == 0) { //stretch in parent\r
- int idxParentW = Interface.LayoutingQueue.IndexOf (Interface.LayoutingQueue.Where(lq => lq.GraphicObject == this.Parent && lq.LayoutType == LayoutingType.Width).FirstOrDefault());\r
- if (idxParentW < 0)\r
+ if ((layoutType & (int)LayoutingType.Width) > 0) {\r
+ if (Bounds.Width == 0) //stretch in parent\r
+ Interface.LayoutingQueue.EnqueueAfterParentSizing (LayoutingType.Width, this);\r
+ else //fit ou fixed\r
Interface.LayoutingQueue.Insert (0, new LayoutingQueueItem (LayoutingType.Width, this));\r
- else//insert after parent sizing\r
- Interface.LayoutingQueue.Insert (idxParentW + 1, new LayoutingQueueItem (LayoutingType.Width, this));\r
- } else {//fit ou fixed\r
- Interface.LayoutingQueue.Insert (0, new LayoutingQueueItem (LayoutingType.Width, this));\r
- //for x positionning, sizing of obj and parent have to be done\r
- int idxParentW = Interface.LayoutingQueue.IndexOf (Interface.LayoutingQueue.Where(lq => lq.GraphicObject == this.Parent && lq.LayoutType == LayoutingType.Width).FirstOrDefault());\r
- if (idxParentW < 0)\r
- Interface.LayoutingQueue.Insert (1, new LayoutingQueueItem (LayoutingType.X, this));\r
- else//insert after parent sizing\r
- Interface.LayoutingQueue.Insert (idxParentW + 1, new LayoutingQueueItem (LayoutingType.X, this));\r
}\r
- if (Bounds.Height == 0) { //stretch\r
- int idxParentH = Interface.LayoutingQueue.IndexOf (Interface.LayoutingQueue.Where(lq => lq.GraphicObject == this.Parent && lq.LayoutType == LayoutingType.Height).FirstOrDefault());\r
- if (idxParentH < 0)\r
+\r
+ if ((layoutType & (int)LayoutingType.Height) > 0) {\r
+ if (Bounds.Height == 0) //stretch in parent\r
+ Interface.LayoutingQueue.EnqueueAfterParentSizing (LayoutingType.Height, this);\r
+ else//fit ou fixed\r
Interface.LayoutingQueue.Insert (0, new LayoutingQueueItem (LayoutingType.Height, this));\r
- else\r
- Interface.LayoutingQueue.Insert (idxParentH + 1, new LayoutingQueueItem (LayoutingType.Height, this));\r
- } else {\r
- Interface.LayoutingQueue.Insert (0, new LayoutingQueueItem (LayoutingType.Height, this));\r
- int idxParentH = Interface.LayoutingQueue.IndexOf (Interface.LayoutingQueue.Where(lq => lq.GraphicObject == this.Parent && lq.LayoutType == LayoutingType.Height).FirstOrDefault());\r
- if (idxParentH < 0)\r
- Interface.LayoutingQueue.Insert (1, new LayoutingQueueItem (LayoutingType.Y, this));\r
- else//insert after parent sizing\r
- Interface.LayoutingQueue.Insert (idxParentH + 1, new LayoutingQueueItem (LayoutingType.Y, this));\r
}\r
\r
+ if ((layoutType & (int)LayoutingType.X) > 0)\r
+ //for x positionning, sizing of parent and this have to be done\r
+ Interface.LayoutingQueue.EnqueueAfterThisAndParentSizing (LayoutingType.X, this);\r
+\r
+ if ((layoutType & (int)LayoutingType.Y) > 0)\r
+ //for x positionning, sizing of parent and this have to be done\r
+ Interface.LayoutingQueue.EnqueueAfterThisAndParentSizing (LayoutingType.Y, this);\r
+ \r
}\r
\r
+// public virtual void RegisterForLayouting()\r
+// {\r
+// //clear previous layouting for item\r
+// Interface.LayoutingQueue.RemoveAll (lq => lq.GraphicObject == this);\r
+//\r
+// if (Bounds.Width == 0) { //stretch in parent\r
+// int idxParentW = Interface.LayoutingQueue.IndexOf (Interface.LayoutingQueue.Where(lq => lq.GraphicObject == this.Parent && lq.LayoutType == LayoutingType.Width).FirstOrDefault());\r
+// if (idxParentW < 0)\r
+// Interface.LayoutingQueue.Insert (0, new LayoutingQueueItem (LayoutingType.Width, this));\r
+// else//insert after parent sizing\r
+// Interface.LayoutingQueue.Insert (idxParentW + 1, new LayoutingQueueItem (LayoutingType.Width, this));\r
+// } else {//fit ou fixed\r
+// Interface.LayoutingQueue.Insert (0, new LayoutingQueueItem (LayoutingType.Width, this));\r
+// //for x positionning, sizing of obj and parent have to be done\r
+//// int idxParentW = Interface.LayoutingQueue.IndexOf (Interface.LayoutingQueue.Where(lq => lq.GraphicObject == this.Parent && lq.LayoutType == LayoutingType.Width).FirstOrDefault());\r
+//// if (idxParentW < 0)\r
+//// Interface.LayoutingQueue.Insert (1, new LayoutingQueueItem (LayoutingType.X, this));\r
+//// else//insert after parent sizing\r
+//// Interface.LayoutingQueue.Insert (idxParentW + 1, new LayoutingQueueItem (LayoutingType.X, this));\r
+// }\r
+// if (Bounds.Height == 0) { //stretch\r
+// int idxParentH = Interface.LayoutingQueue.IndexOf (Interface.LayoutingQueue.Where(lq => lq.GraphicObject == this.Parent && lq.LayoutType == LayoutingType.Height).FirstOrDefault());\r
+// if (idxParentH < 0)\r
+// Interface.LayoutingQueue.Insert (0, new LayoutingQueueItem (LayoutingType.Height, this));\r
+// else\r
+// Interface.LayoutingQueue.Insert (idxParentH + 1, new LayoutingQueueItem (LayoutingType.Height, this));\r
+// } else {\r
+// Interface.LayoutingQueue.Insert (0, new LayoutingQueueItem (LayoutingType.Height, this));\r
+//// int idxParentH = Interface.LayoutingQueue.IndexOf (Interface.LayoutingQueue.Where(lq => lq.GraphicObject == this.Parent && lq.LayoutType == LayoutingType.Height).FirstOrDefault());\r
+//// if (idxParentH < 0)\r
+//// Interface.LayoutingQueue.Insert (1, new LayoutingQueueItem (LayoutingType.Y, this));\r
+//// else//insert after parent sizing\r
+//// Interface.LayoutingQueue.Insert (idxParentH + 1, new LayoutingQueueItem (LayoutingType.Y, this));\r
+// }\r
+// }\r
+//\r
public virtual void UpdateLayout (LayoutingType layoutType)\r
{ \r
switch (layoutType) {\r
Slot.X = Parent.ClientRectangle.Width / 2 - Slot.Width / 2;\r
break;\r
}\r
+ } else\r
+ Slot.X = Bounds.X;\r
+ if (LastSlots.X == Slot.X)\r
break;\r
- }\r
- Slot.X = Bounds.X;\r
+ //register layouting here for objects depending on this.x\r
+ LastSlots.X = Slot.X;\r
break;\r
case LayoutingType.Y:\r
if (Bounds.Y == 0) {\r
Slot.Y = Parent.ClientRectangle.Height / 2 - Slot.Height / 2;\r
break;\r
}\r
+ }else\r
+ Slot.Y = Bounds.Y;\r
+ if (LastSlots.Y == Slot.Y)\r
break;\r
- }\r
- Slot.Y = Bounds.Y;\r
+ //register layouting here for objects depending on this.x\r
+ LastSlots.Y = Slot.Y;\r
break;\r
case LayoutingType.Width: \r
if (Width > 0)\r
Slot.Width = measureRawSize ().Width;\r
else\r
Slot.Width = Parent.ClientRectangle.Width;\r
+\r
+ if (LastSlots.Width == Slot.Width)\r
+ break;\r
+ \r
+ if (Parent.getBounds().Width < 0)\r
+ this.Parent.RegisterForLayouting((int)LayoutingType.Width);\r
+ else if (Width != 0) //update position in parent\r
+ this.RegisterForLayouting ((int)LayoutingType.X);\r
+\r
+ LastSlots.Width = Slot.Width;\r
break;\r
case LayoutingType.Height:\r
if (Height > 0)\r
Slot.Height = measureRawSize ().Height;\r
else\r
Slot.Height = Parent.ClientRectangle.Height;\r
+\r
+ if (LastSlots.Height == Slot.Height)\r
+ break;\r
+\r
+ if (Parent.getBounds().Height < 0)\r
+ this.Parent.RegisterForLayouting((int)LayoutingType.Height);\r
+ else if (Height != 0) //update position in parent\r
+ this.RegisterForLayouting ((int)LayoutingType.Y);\r
+\r
+ LastSlots.Height = Slot.Height;\r
break;\r
}\r
+\r
//if no layouting remains in queue for item, registre for redraw\r
- if (Interface.LayoutingQueue.Where (lq => lq.GraphicObject == this).Count() <= 0)\r
- this.registerForRedraw ();\r
+ if (Interface.LayoutingQueue.Where (lq => lq.GraphicObject == this).Count () <= 0)\r
+ this.RegisterForRedraw ();\r
}\r
+\r
protected virtual void onDraw(Context gr)\r
{\r
Rectangle rBack = new Rectangle (Slot.Size);\r
{\r
GraphicObject g = child as GraphicObject;\r
Children.Add(g);\r
- g.Parent = this as GraphicObject;\r
- LayoutIsValid = false;\r
+ g.Parent = this as GraphicObject; \r
+ g.RegisterForLayouting ((int)LayoutingType.Sizing);\r
return (T)child;\r
}\r
- public void removeChild(GraphicObject child) \r
+ public virtual void removeChild(GraphicObject child) \r
{\r
Children.Remove(child);\r
child.Parent = null;\r
- LayoutIsValid = false;\r
+ this.RegisterForLayouting ((int)LayoutingType.Sizing);\r
}\r
public void putWidgetOnTop(GraphicObject w)\r
{\r
return true;\r
}\r
}\r
- [XmlIgnore]public override bool LayoutIsValid\r
- {\r
- get\r
- {\r
- if (!Visible)\r
- return true;\r
-\r
- if (!base.LayoutIsValid)\r
- return false;\r
- else//le layout n'est valide que si tous les enfents sont validés aussi\r
- {\r
- foreach (GraphicObject w in Children)\r
- if (!w.LayoutIsValid)\r
- return false;\r
- }\r
-\r
- return true;\r
- }\r
- set { base.LayoutIsValid = value; }\r
- }\r
\r
public override GraphicObject FindByName (string nameToFind)\r
{\r
\r
return tmp;\r
}\r
- public override void RegisterForLayouting ()\r
- {\r
- base.RegisterForLayouting ();\r
\r
- foreach (GraphicObject g in Children)\r
- g.RegisterForLayouting (); \r
- }\r
// public override void UpdateLayout (LayoutingType layoutType)\r
// {\r
// if (LayoutIsValid)\r
IGOLibHost TopContainer { get; }
- void InvalidateLayout ();
+ void RegisterForLayouting(int layoutType);
void UpdateLayout(LayoutingType layoutType);
if (VerticalScrolling )\r
{\r
//add redraw call with old bounds to errase old position\r
- registerForRedraw();\r
+ RegisterForRedraw();\r
\r
scrollY += e.Delta * ScrollSpeed;\r
\r
if (HorizontalScrolling )\r
{\r
//add redraw call with old bounds to errase old position\r
- registerForRedraw();\r
+ RegisterForRedraw();\r
\r
scrollX += e.Delta * ScrollSpeed;\r
\r
\r
\r
//renderBounds.Y = -scrollY;\r
- registerForRedraw();\r
+ RegisterForRedraw();\r
//Parent.registerForGraphicUpdate ();\r
}\r
#endregion\r
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using System.Collections.Generic;
+using System.Linq;
namespace go
{
public LayoutingQueue ()
{
}
-
+ public void Enqueue(LayoutingType _lt, ILayoutable _object)
+ {
+ Interface.LayoutingQueue.RemoveAll(lq => lq.GraphicObject == _object && lq.LayoutType == _lt);
+ Interface.LayoutingQueue.Add (new LayoutingQueueItem (_lt, _object));
+ }
+
+ public void EnqueueAfterParentSizing (LayoutingType _lt, ILayoutable _object)
+ {
+ LayoutingQueueItem lqi = new LayoutingQueueItem (_lt, _object);
+ int idxParentSz = Interface.LayoutingQueue.IndexOf
+ (Interface.LayoutingQueue.Where(lq => lq.GraphicObject == _object.Parent && lq.LayoutType == _lt).LastOrDefault());
+
+ Interface.LayoutingQueue.Insert (idxParentSz + 1, lqi);
+ }
+ public void EnqueueAfterThisAndParentSizing (LayoutingType _lt, ILayoutable _object)
+ {
+ LayoutingQueueItem lqi = new LayoutingQueueItem (_lt, _object);
+ LayoutingType sizing = LayoutingType.Width;
+
+ if (_lt == LayoutingType.Y)
+ sizing = LayoutingType.Height;
+
+ int idxW = Interface.LayoutingQueue.IndexOf (Interface.LayoutingQueue.Where
+ (lq => (lq.GraphicObject == _object.Parent || lq.GraphicObject == _object) && lq.LayoutType == sizing).LastOrDefault());
+
+ Interface.LayoutingQueue.Insert (idxW + 1, lqi);
+ }
+
public LayoutingQueueItem Dequeue()
{
LayoutingQueueItem tmp = this [0];
{
public enum LayoutingType
{
- X,
- Y,
- Width,
- Height,
- PositionChildren
+ X = 0x01,
+ Y = 0x02,
+ Width = 0x04,
+ Height = 0x08,
+ Sizing = 0x0C,
+ PositionChildren = 0x10,
+ All = 0xFF
}
public class LayoutingQueueItem
}
public override string ToString ()
{
- return string.Format ("{0}->{1}", LayoutType,GraphicObject.ToString());
+ return string.Format ("{1}->{0}", LayoutType,GraphicObject.ToString());
}
}
}
g.Parent = this;\r
GraphicObjects.Add (g);\r
\r
- g.RegisterForLayouting ();\r
+ g.RegisterForLayouting ((int)LayoutingType.Sizing);\r
}\r
public void DeleteWidget(GraphicObject g)\r
{\r
\r
#region ILayoutable implementation\r
\r
+ public void RegisterForLayouting (int layoutType)\r
+ {\r
+ throw new NotImplementedException ();\r
+ }\r
+\r
public void UpdateLayout (LayoutingType layoutType)\r
{\r
throw new NotImplementedException ();\r
return ClientRectangle;\r
}\r
\r
- public bool WIsValid {\r
- get {\r
- return true;\r
- }\r
- set {\r
- throw new NotImplementedException ();\r
- }\r
- }\r
- public bool HIsValid {\r
- get {\r
- return true;\r
- }\r
- set {\r
- throw new NotImplementedException ();\r
- }\r
- }\r
- public bool XIsValid {\r
- get {\r
- return true;\r
- }\r
- set {\r
- throw new NotImplementedException ();\r
- }\r
- }\r
- public bool YIsValid {\r
- get {\r
- return true;\r
- }\r
- set {\r
- throw new NotImplementedException ();\r
- }\r
- }\r
\r
- public virtual void InvalidateLayout ()\r
- {\r
-// foreach (GraphicObject g in GraphicObjects) {\r
-// g.InvalidateLayout ();\r
-// }\r
- }\r
-// public Rectangle rectInScreenCoord (Rectangle r)\r
-// {\r
-// throw new NotImplementedException ();\r
-// }\r
-// public Rectangle renderBoundsInContextCoordonate {\r
-// get { return ClientRectangle; }\r
-// }\r
-// public Rectangle ClientBoundsInContextCoordonate {\r
-// get {\r
-// throw new NotImplementedException ();\r
-// }\r
-// }\r
-// public Rectangle renderBoundsInBackendSurfaceCoordonate {\r
-// get { return ClientRectangle; }\r
-// }\r
-// public Rectangle ClientBoundsInBackendSurfaceCoordonate {\r
-// get {\r
-// throw new NotImplementedException ();\r
-// }\r
-// set {\r
-// throw new NotImplementedException ();\r
-// }\r
-// }\r
-// public Rectangle ScreenCoordBounds {\r
-// get { return ClientRectangle; }\r
-// }\r
-// public Rectangle ScreenCoordClientBounds {\r
-// get {\r
-// throw new NotImplementedException ();\r
-// }\r
-// set {\r
-// throw new NotImplementedException ();\r
-// }\r
-// }\r
#endregion\r
}\r
}
\ No newline at end of file