<LogicalName>\r
</LogicalName>\r
</Compile>\r
+ <Compile Include="src\LayoutingQueueItem.cs">\r
+ <LogicalName>\r
+ </LogicalName>\r
+ </Compile>\r
+ <Compile Include="src\LayoutingQueue.cs">\r
+ <LogicalName>\r
+ </LogicalName>\r
+ </Compile>\r
</ItemGroup>\r
<ItemGroup>\r
<Reference Include="System" />\r
--- /dev/null
+#define MONO_CAIRO_DEBUG_DISPOSE\r
+\r
+\r
+using System;\r
+using System.Runtime.InteropServices;\r
+using OpenTK;\r
+using OpenTK.Graphics.OpenGL;\r
+using OpenTK.Input;\r
+\r
+using System.Diagnostics;\r
+\r
+//using GGL;\r
+using go;\r
+using System.Threading;\r
+\r
+\r
+namespace test\r
+{\r
+ class GOLIBTest_1_1 : OpenTKGameWindow\r
+ {\r
+ public GOLIBTest_1_1 ()\r
+ : base(1024, 600,"test")\r
+ {}\r
+\r
+ Group g;\r
+\r
+ protected override void OnLoad (EventArgs e)\r
+ {\r
+ base.OnLoad (e);\r
+ LoadInterface("Interfaces/test1.1.goml", out g);\r
+\r
+ }\r
+ protected override void OnRenderFrame (FrameEventArgs e)\r
+ {\r
+ GL.Clear (ClearBufferMask.ColorBufferBit);\r
+ base.OnRenderFrame (e);\r
+ SwapBuffers ();\r
+ }\r
+\r
+ protected override void OnUpdateFrame (FrameEventArgs e)\r
+ {\r
+ base.OnUpdateFrame (e);\r
+ }\r
+\r
+ [STAThread]\r
+ static void Main ()\r
+ {\r
+ Console.WriteLine ("starting example");\r
+\r
+ using (GOLIBTest_1_1 win = new GOLIBTest_1_1( )) {\r
+ win.Run (30.0);\r
+ }\r
+ }\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+#define MONO_CAIRO_DEBUG_DISPOSE\r
+\r
+\r
+using System;\r
+using System.Runtime.InteropServices;\r
+using OpenTK;\r
+using OpenTK.Graphics.OpenGL;\r
+using OpenTK.Input;\r
+\r
+using System.Diagnostics;\r
+\r
+//using GGL;\r
+using go;\r
+using System.Threading;\r
+\r
+\r
+namespace test\r
+{\r
+ class GOLIBTest_1_2 : OpenTKGameWindow\r
+ {\r
+ public GOLIBTest_1_2 ()\r
+ : base(1024, 600,"test")\r
+ {}\r
+\r
+ VerticalStack g;\r
+\r
+ protected override void OnLoad (EventArgs e)\r
+ {\r
+ base.OnLoad (e);\r
+ LoadInterface("Interfaces/test1.2.goml", out g);\r
+\r
+ }\r
+ protected override void OnRenderFrame (FrameEventArgs e)\r
+ {\r
+ GL.Clear (ClearBufferMask.ColorBufferBit);\r
+ base.OnRenderFrame (e);\r
+ SwapBuffers ();\r
+ }\r
+\r
+ protected override void OnUpdateFrame (FrameEventArgs e)\r
+ {\r
+ base.OnUpdateFrame (e);\r
+ }\r
+\r
+ [STAThread]\r
+ static void Main ()\r
+ {\r
+ Console.WriteLine ("starting example");\r
+\r
+ using (GOLIBTest_1_2 win = new GOLIBTest_1_2( )) {\r
+ win.Run (30.0);\r
+ }\r
+ }\r
+ }\r
+}
\ No newline at end of file
<?xml version="1.0"?>\r
<GraphicObject \r
- Top="10" Left="10"\r
- Width="10" Height="50" \r
+ HorizontalAlignment="Right"\r
+ VerticalAlignment="Bottom"\r
Margin="10" Background="Green"/>\r
--- /dev/null
+<?xml version="1.0"?>\r
+<Group Width="0" Height="0" Margin="50"\r
+ Focusable="True" Background="Yellow">\r
+ <Group Width="-1" Height="-1" Margin="50" \r
+ VerticalAlignment="Top" HorizontalAlignment="Left"\r
+ Focusable="True" Background="Green">\r
+ <Image VerticalAlignment="Bottom" \r
+ Name="PhaseOverlay" Width="100" Height="100" Path="image/u.svg" Background="Red"/>\r
+ <Image Top="100" \r
+ Name="PhaseOverlay" Width="100" Height="100" Path="image/u.svg" Background="Red"/>\r
+ </Group>\r
+ <Image Top="100" \r
+ Name="PhaseOverlay" Width="100" Height="100" Path="image/u.svg" Background="Red"/>\r
+\r
+</Group>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0"?>\r
+<VerticalStack>\r
+ <Label Text="label11"/>\r
+ <Label Text="label21"/>\r
+ <HorizontalStack Width="-1" Height="-1" Margin="50"\r
+ Focusable="True" Background="DarkBlue">\r
+ <Label Text="label12"/>\r
+ <Label Text="label22"/>\r
+ <Label Text="label32"/>\r
+ <Label Text="label42"/>\r
+ <Label Text="label52"/>\r
+ </HorizontalStack>\r
+ <Label Text="label33" Background="Green" Width="0"/>\r
+ <Button/>\r
+ <Label Text="label43"/>\r
+ <Label Text="label53"/>\r
+\r
+</VerticalStack>
\ No newline at end of file
<?xml version="1.0"?>\r
-<Container\r
- HorizontalAlignment="Left" VerticalAlignment="Center"\r
- Margin="10" Focusable="True" Fit="True" Background="Green">\r
- <Group Background="White" >\r
- <Image Name="PhaseOverlay" Width="40" Height="40"\r
- Path="image/u.svg" Background="Red"/>\r
- </Group>\r
+<Container Width="0" Height="-1"\r
+ Margin="100" Focusable="True" Background="Yellow">\r
+\r
+ <Container Width="-1" Height="-1"\r
+ Margin="10" Focusable="True" Background="Green">\r
+ <Image VerticalAlignment="Bottom" \r
+ Name="PhaseOverlay" Width="100" Height="100" Path="image/u.svg" Background="Red"/>\r
+ </Container>\r
</Container>
\ No newline at end of file
<OutputType>Exe</OutputType>
<RootNamespace>Tests</RootNamespace>
<AssemblyName>Tests</AssemblyName>
- <StartupObject>test.GOLIBTest_4</StartupObject>
+ <StartupObject>test.GOLIBTest_5</StartupObject>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<OutputPath>..\bin\$(configuration)</OutputPath>
<IntermediateOutputPath>obj\$(configuration)</IntermediateOutputPath>
<LogicalName>
</LogicalName>
</Compile>
+ <Compile Include="GOLIBTest_1.1.cs">
+ <LogicalName>
+ </LogicalName>
+ </Compile>
+ <Compile Include="GOLIBTest_1.2.cs">
+ <LogicalName>
+ </LogicalName>
+ </Compile>
</ItemGroup>
<ItemGroup>
<None Include="image\u.svg">
<LogicalName>
</LogicalName>
</None>
+ <None Include="Interfaces\test1.1.goml">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ <LogicalName>
+ </LogicalName>
+ </None>
+ <None Include="Interfaces\test1.2.goml">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ <LogicalName>
+ </LogicalName>
+ </None>
</ItemGroup>
<ItemGroup>
<Folder Include="Interfaces\">
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
- Size raw = Bounds.Size;\r
-\r
- if (child != null) {\r
- if (Bounds.Width < 0 && child.WIsValid)\r
- raw.Width = child.Slot.Width + 2 * (Margin);\r
- if (Bounds.Height < 0 && child.HIsValid)\r
- raw.Height = child.Slot.Height + 2 * (Margin);\r
- }\r
+ base.RegisterForLayouting ();\r
\r
- return raw;\r
+ if (child != null)\r
+ child.RegisterForLayouting ();\r
}\r
- public override void UpdateLayout()\r
- {\r
- if (LayoutIsValid)\r
- return;\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
+// 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
public override Rectangle ContextCoordinates (Rectangle r)\r
{\r
return\r
#endregion\r
\r
#region Private fields\r
- bool childrenArePositionned = false;\r
int _spacing;\r
Orientation _orientation;\r
#endregion\r
get { return base.Height; }\r
set { base.Height = value; }\r
}\r
- [XmlIgnore]public override bool LayoutIsValid {\r
- get { return childrenArePositionned && base.LayoutIsValid; }\r
- set { base.LayoutIsValid = value; }\r
- }\r
\r
- public override void InvalidateLayout ()\r
- {\r
- childrenArePositionned = false;\r
- base.InvalidateLayout ();\r
- }\r
protected override Size measureRawSize ()\r
{\r
- Size raw = Bounds.Size;\r
Size tmp = new Size ();\r
\r
- if (raw.Width >= 0 && raw.Height >= 0)\r
- return raw;\r
- \r
- foreach (GraphicObject c in Children) {\r
- if (raw.Width < 0) {\r
- if (c.WIsValid) {\r
- if (Orientation == Orientation.Horizontal && c.Bounds.Width != 0)\r
- tmp.Width += c.Slot.Width + Spacing;\r
- else\r
- tmp.Width = Math.Max (tmp.Width, c.Slot.Right);\r
- }else\r
- return raw;\r
+ if (Orientation == Orientation.Horizontal) {\r
+ foreach (GraphicObject c in Children) {\r
+ tmp.Width += c.Slot.Width + Spacing;\r
+ tmp.Height = Math.Max (tmp.Height, c.Slot.Bottom);\r
}\r
- if (raw.Height < 0) {\r
- if (c.HIsValid) {\r
- if (Orientation == Orientation.Vertical && c.Bounds.Height != 0)\r
- tmp.Height += c.Slot.Height + Spacing;\r
- else\r
- tmp.Height = Math.Max (tmp.Height, c.Slot.Bottom);\r
- }else\r
- return raw;\r
+ } else {\r
+ foreach (GraphicObject c in Children) {\r
+ tmp.Width = Math.Max (tmp.Width, c.Slot.Right);\r
+ tmp.Height += c.Slot.Height + Spacing;\r
}\r
}\r
\r
- if (raw.Width < 0)\r
- tmp.Width += 2*Margin;\r
- if (raw.Height < 0)\r
- tmp.Height += 2*Margin;\r
+ tmp.Width += 2*Margin;\r
+ tmp.Height += 2*Margin;\r
\r
return tmp;\r
}\r
int d = 0;\r
if (Orientation == Orientation.Horizontal) {\r
foreach (GraphicObject c in Children) {\r
- if (c.Bounds.Width == 0)\r
- continue;\r
-\r
c.Slot.X = d;\r
- c.XIsValid = true;\r
d += c.Slot.Width + Spacing;\r
}\r
} else {\r
foreach (GraphicObject c in Children) {\r
- if (c.Bounds.Height == 0)\r
- continue;\r
-\r
c.Slot.Y = d;\r
- c.YIsValid = true;\r
d += c.Slot.Height + Spacing;\r
}\r
}\r
- childrenArePositionned = true;\r
}\r
+ public override void RegisterForLayouting ()\r
+ {\r
+ base.RegisterForLayouting ();\r
\r
- public override void UpdateLayout()\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 UpdateLayout (LayoutingType layoutType)\r
{ \r
- base.UpdateLayout();\r
-\r
- ComputeChildrenPositions ();\r
+ if (layoutType == LayoutingType.PositionChildren)\r
+ ComputeChildrenPositions ();\r
\r
- if (LayoutIsValid)\r
- registerForRedraw();\r
+ base.UpdateLayout(layoutType);\r
}\r
#endregion\r
\r
- //\r
-// bool enoughtSpaceForWidget(GraphicObject w)\r
-// {\r
-// if (!SizeToContent)\r
-// {\r
-// int nextXForWidget = 0;\r
-// int nextYForWidget = 0;\r
-//\r
-// if (Orientation == Orientation.Horizontal)\r
-// nextXForWidget = currentXForWidget + w.Slot.Width;\r
-// else\r
-// nextYForWidget = nextYForWidget + w.Slot.Height;\r
-//\r
-//\r
-// if (nextXForWidget > ClientRectangle.Right )\r
-// return false;\r
-// if (currentYForWidget > ClientRectangle.Bottom )\r
-// return false;\r
-// }\r
-// return true;\r
-// }\r
-// void advance(GraphicObject w)\r
-// {\r
-// if (Orientation == Orientation.Horizontal)\r
-// currentXForWidget = currentXForWidget + WidgetSpacing + w.Slot.Width;\r
-// else\r
-// currentYForWidget = currentYForWidget + WidgetSpacing + w.Slot.Height;\r
-//\r
-// }\r
\r
}\r
}\r
}\r
}\r
[XmlIgnore]public virtual IGOLibHost TopContainer {\r
- get { return Parent.TopContainer; }\r
+ get { return Parent == null ? null : Parent.TopContainer; }\r
}\r
public virtual void InvalidateLayout ()\r
{\r
public virtual void registerForGraphicUpdate ()\r
{\r
bmp = null;\r
- registerForRedraw ();\r
+ RegisterForLayouting ();\r
+ //registerForRedraw ();\r
//Interface.registerForGraphicUpdate(this);\r
}\r
/// <summary>\r
/// </summary>\r
public virtual void registerForRedraw ()\r
{\r
- if (LayoutIsValid && Visible)\r
+ if (Visible && TopContainer != null)\r
TopContainer.gobjsToRedraw.Add (this);\r
}\r
public virtual void registerClipRect()\r
{\r
return Bounds.Size;\r
}\r
-\r
- protected virtual void ComputeSize()\r
+ public virtual void RegisterForLayouting()\r
{\r
- Size rawSize = measureRawSize ();\r
-\r
- if (!wIsValid) {\r
- wIsValid = true;\r
- if (Width > 0)\r
- Slot.Width = Width;\r
- else if (Width < 0) {\r
- if (rawSize.Width > 0)\r
- Slot.Width = rawSize.Width;\r
- else\r
- wIsValid = false;\r
- } else if (Parent.WIsValid)\r
- Slot.Width = Parent.ClientRectangle.Width;\r
- else\r
- wIsValid = false; \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
-\r
- if (!hIsValid) {\r
- hIsValid = true;\r
- if (Height > 0)\r
- Slot.Height = Height;\r
- else if (Height < 0) {\r
- if (rawSize.Height > 0)\r
- Slot.Height = rawSize.Height;\r
- else\r
- hIsValid = false;\r
- } else if (Parent.HIsValid)\r
- Slot.Height = Parent.ClientRectangle.Height;\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
- hIsValid = false; \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
- protected virtual void ComputePosition()\r
- {\r
- if (!xIsValid) {\r
- xIsValid = true;\r
- if (Width == 0)\r
- Slot.X = 0;\r
- else if (Left != 0)\r
- Slot.X = Left;\r
- else if (Parent.WIsValid && WIsValid) {\r
+\r
+ public virtual void UpdateLayout (LayoutingType layoutType)\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
Slot.X = Parent.ClientRectangle.Width / 2 - Slot.Width / 2;\r
break;\r
}\r
- } else// if (Parent.getBounds().Width>=0)\r
- xIsValid = false;\r
- }\r
-\r
- if (!yIsValid) {\r
- yIsValid = true;\r
- if (Height== 0)\r
- Slot.Y = 0;\r
- else if (Top != 0)\r
- Slot.Y = Top;\r
- else if (Parent.HIsValid && HIsValid) {\r
+ break;\r
+ }\r
+ Slot.X = Bounds.X;\r
+ break;\r
+ case LayoutingType.Y:\r
+ if (Bounds.Y == 0) {\r
switch (VerticalAlignment) {\r
case VerticalAlignment.Top:\r
Slot.Y = 0;\r
Slot.Y = Parent.ClientRectangle.Height / 2 - Slot.Height / 2;\r
break;\r
}\r
- } else// if (Parent.getBounds().Height>=0)\r
- yIsValid = false;\r
+ break;\r
+ }\r
+ Slot.Y = Bounds.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
+ 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
+ break;\r
}\r
- }\r
- public virtual void UpdateLayout ()\r
- {\r
- if (!SizeIsValid)\r
- ComputeSize ();\r
- if (!PositionIsValid)\r
- ComputePosition (); \r
- if (LayoutIsValid)\r
- registerForRedraw ();\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
protected virtual void onDraw(Context gr)\r
{\r
}\r
protected override Size measureRawSize ()\r
{\r
- Size raw = Bounds.Size;\r
Size tmp = new Size ();\r
\r
- if (raw.Width >= 0 && raw.Height >= 0)\r
- return raw;\r
-\r
foreach (GraphicObject c in Children) {\r
- if (raw.Width < 0) {\r
- if (c.WIsValid)\r
- tmp.Width = Math.Max (tmp.Width, c.Slot.Right);\r
- else\r
- return raw;\r
- }\r
- if (raw.Height < 0) {\r
- if (c.HIsValid)\r
- tmp.Height = Math.Max (tmp.Height, c.Slot.Bottom);\r
- else\r
- return raw;\r
- }\r
+ tmp.Width = Math.Max (tmp.Width, c.Slot.Right);\r
+ tmp.Height = Math.Max (tmp.Height, c.Slot.Bottom);\r
}\r
\r
- if (raw.Width < 0)\r
- tmp.Width += 2*Margin;\r
- if (raw.Height < 0)\r
- tmp.Height += 2*Margin;\r
+ tmp.Width += 2*Margin;\r
+ tmp.Height += 2*Margin;\r
\r
return tmp;\r
}\r
- public override void UpdateLayout()\r
+ public override void RegisterForLayouting ()\r
{\r
- if (LayoutIsValid)\r
- return;\r
-\r
- bool atLeastOneChildHasWNotDependingOnParent = false;\r
- bool atLeastOneChildHasHNotDependingOnParent = false;\r
-\r
- foreach (GraphicObject c in Children) {\r
- if (c.LayoutIsValid)\r
- continue;\r
+ base.RegisterForLayouting ();\r
\r
- if (Width < 0 && c.WIsValid) {\r
- if (!atLeastOneChildHasWNotDependingOnParent && !(this is GenericStack))\r
- c.XIsValid = true;\r
- atLeastOneChildHasWNotDependingOnParent = true;\r
- }\r
- if (Height < 0 && c.HIsValid) {\r
- if (!atLeastOneChildHasHNotDependingOnParent && !(this is GenericStack))\r
- c.YIsValid = true;\r
- atLeastOneChildHasHNotDependingOnParent = true;\r
- }\r
-\r
- c.UpdateLayout ();\r
- }\r
-\r
-// if (Width < 0 && !atLeastOneChildHasWNotDependingOnParent)\r
-// Debug.WriteLine ("ERROR: no child has fixed width and parent width is set to content!");\r
-// if (Height < 0 && !atLeastOneChildHasHNotDependingOnParent)\r
-// Debug.WriteLine ("ERROR: no child has fixed height and parent height is set to content!");\r
-\r
- base.UpdateLayout ();\r
+ foreach (GraphicObject g in Children)\r
+ g.RegisterForLayouting (); \r
}\r
+// public override void UpdateLayout (LayoutingType layoutType)\r
+// {\r
+// if (LayoutIsValid)\r
+// return;\r
+//\r
+// bool atLeastOneChildHasWNotDependingOnParent = false;\r
+// bool atLeastOneChildHasHNotDependingOnParent = false;\r
+//\r
+//// foreach (GraphicObject c in Children) {\r
+//// if (c.LayoutIsValid)\r
+//// continue;\r
+////\r
+//// if (Width < 0 && c.WIsValid) {\r
+//// if (!atLeastOneChildHasWNotDependingOnParent && !(this is GenericStack))\r
+//// c.XIsValid = true;\r
+//// atLeastOneChildHasWNotDependingOnParent = true;\r
+//// }\r
+//// if (Height < 0 && c.HIsValid) {\r
+//// if (!atLeastOneChildHasHNotDependingOnParent && !(this is GenericStack))\r
+//// c.YIsValid = true;\r
+//// atLeastOneChildHasHNotDependingOnParent = true;\r
+//// }\r
+////\r
+//// c.UpdateLayout ();\r
+//// }\r
+//\r
+//// if (Width < 0 && !atLeastOneChildHasWNotDependingOnParent)\r
+//// Debug.WriteLine ("ERROR: no child has fixed width and parent width is set to content!");\r
+//// if (Height < 0 && !atLeastOneChildHasHNotDependingOnParent)\r
+//// Debug.WriteLine ("ERROR: no child has fixed height and parent height is set to content!");\r
+//\r
+// //base.UpdateLayout ();\r
+// }\r
\r
public override Rectangle ContextCoordinates(Rectangle r){\r
return r + ClientRectangle.Position;\r
\r
public override void Paint(ref Context ctx, Rectangles clip = null)\r
{\r
- if ( !(Visible&LayoutIsValid) )\r
+ if ( !(Visible) )\r
return;\r
\r
// ctx.Save ();\r
{
ILayoutable Parent { get; set; }
- bool SizeIsValid { get; set; }
- bool WIsValid { get; set; }
- bool HIsValid { get; set; }
- bool PositionIsValid { get; set; }
- bool XIsValid { get; set; }
- bool YIsValid { get; set; }
- bool LayoutIsValid { get; set; }
-
Rectangle ClientRectangle { get; }
Rectangle getSlot();
Rectangle getBounds();
IGOLibHost TopContainer { get; }
void InvalidateLayout ();
+ void UpdateLayout(LayoutingType layoutType);
Rectangle ContextCoordinates(Rectangle r);
{\r
TopContainer.redrawClip.AddRectangle (base.ScreenCoordinates(Slot));\r
}\r
- public override void UpdateLayout ()\r
+ public override void UpdateLayout (LayoutingType layoutType)\r
{\r
- base.UpdateLayout ();\r
-\r
- if (!LayoutIsValid)\r
- return;\r
-\r
- //override child positionning inside scroller in the \r
- //scrolling direction\r
- if (child == null)\r
- return;\r
- if (VerticalScrolling)\r
- child.Slot.Y = 0;\r
- if (HorizontalScrolling)\r
- child.Slot.X = 0;\r
+// base.UpdateLayout ();\r
+//\r
+// if (!LayoutIsValid)\r
+// return;\r
+//\r
+// //override child positionning inside scroller in the \r
+// //scrolling direction\r
+// if (child == null)\r
+// return;\r
+// if (VerticalScrolling)\r
+// child.Slot.Y = 0;\r
+// if (HorizontalScrolling)\r
+// child.Slot.X = 0;\r
}\r
public override void Paint(ref Cairo.Context ctx, Rectangles clip = null)\r
{\r
public static bool ReplaceTabsWithSpace = false;
public static bool DesignerMode = false;
+ public static LayoutingQueue LayoutingQueue = new LayoutingQueue();
+
#region Load/Save
internal static List<EventSource> EventsToResolve;
--- /dev/null
+//
+// LayoutingQueue.cs
+//
+// Author:
+// Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
+//
+// Copyright (c) 2015 jp
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+using System;
+using System.Collections.Generic;
+
+namespace go
+{
+ public class LayoutingQueue : List<LayoutingQueueItem>
+ {
+ public LayoutingQueue ()
+ {
+ }
+
+ public LayoutingQueueItem Dequeue()
+ {
+ LayoutingQueueItem tmp = this [0];
+ this.RemoveAt (0);
+ return tmp;
+ }
+ }
+}
+
--- /dev/null
+//
+// LayoutingQueueItem.cs
+//
+// Author:
+// Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
+//
+// Copyright (c) 2015 jp
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+using System;
+using System.Diagnostics;
+
+namespace go
+{
+ public enum LayoutingType
+ {
+ X,
+ Y,
+ Width,
+ Height,
+ PositionChildren
+ }
+
+ public class LayoutingQueueItem
+ {
+
+ public ILayoutable GraphicObject;
+ public LayoutingType LayoutType;
+
+ public LayoutingQueueItem (LayoutingType _layoutType, ILayoutable _graphicObject)
+ {
+ LayoutType = _layoutType;
+ GraphicObject = _graphicObject;
+ }
+ public void ProcessLayouting()
+ {
+ Debug.WriteLine ("Layouting => " + this.ToString ());
+ try {
+ GraphicObject.UpdateLayout (LayoutType);
+ } catch (Exception ex) {
+ Debug.WriteLine ("Layouting error: " + ex.ToString ());
+ }
+ }
+
+ public static implicit operator GraphicObject(LayoutingQueueItem queueItem)
+ {
+ return queueItem.GraphicObject as GraphicObject;
+ }
+ public static implicit operator LayoutingType(LayoutingQueueItem lqi)
+ {
+ return lqi.LayoutType;
+ }
+ public override string ToString ()
+ {
+ return string.Format ("{0}->{1}", LayoutType,GraphicObject.ToString());
+ }
+ }
+}
+
{\r
g.Parent = this;\r
GraphicObjects.Add (g);\r
+\r
+ g.RegisterForLayouting ();\r
}\r
public void DeleteWidget(GraphicObject g)\r
{\r
GraphicObject[] invGOList = new GraphicObject[GraphicObjects.Count];\r
GraphicObjects.CopyTo (invGOList,0);\r
invGOList = invGOList.Reverse ().ToArray ();\r
-\r
- foreach (GraphicObject p in invGOList) {\r
- if (p.Visible) {\r
- layoutTime.Start ();\r
- while(!p.LayoutIsValid)\r
- p.UpdateLayout ();\r
- layoutTime.Stop ();\r
- }\r
+//\r
+// foreach (GraphicObject p in invGOList) {\r
+// if (p.Visible) {\r
+// layoutTime.Start ();\r
+// while(!p.LayoutIsValid)\r
+// p.UpdateLayout ();\r
+// layoutTime.Stop ();\r
+// }\r
+// }\r
+ while (Interface.LayoutingQueue.Count > 0) {\r
+ LayoutingQueueItem lqi = Interface.LayoutingQueue.Dequeue ();\r
+ lqi.ProcessLayouting ();\r
}\r
\r
//Debug.WriteLine ("otd:" + gobjsToRedraw.Count.ToString () + "-");\r
\r
#region ILayoutable implementation\r
\r
+ public void UpdateLayout (LayoutingType layoutType)\r
+ {\r
+ throw new NotImplementedException ();\r
+ }\r
+\r
public Rectangle ContextCoordinates (Rectangle r)\r
{\r
return r;\r