aboutsummaryrefslogtreecommitdiffstatsci
diff options
context:
space:
mode:
authorjpbruyere <jp.bruyere@hotmail.com>2015-05-02 09:19:19 +0200
committerjpbruyere <jp.bruyere@hotmail.com>2015-05-02 09:19:19 +0200
commit40392cc3bcaee5b67d85b0aabfd42d2881823bd6 (patch)
tree809bc55854f13cb031d26129e7db24076119bca0
parentc88d3c2e0b3e9e69df5f1879b9d8935d3ae0d390 (diff)
Layouting queue, debug
test4 validated
-rw-r--r--Tests/GOLIBTest_4.1.cs55
-rw-r--r--Tests/GOLIBTest_4.cs5
-rw-r--r--Tests/GOLIBTest_fps.cs101
-rwxr-xr-xTests/Interfaces/fps.goml27
-rwxr-xr-xTests/Interfaces/test1.1.goml12
-rwxr-xr-xTests/Interfaces/test1.2.goml8
-rwxr-xr-xTests/Interfaces/test1.3.goml14
-rwxr-xr-xTests/Interfaces/test1.goml4
-rwxr-xr-xTests/Interfaces/test4.1.goml98
-rw-r--r--Tests/Tests.csproj25
-rw-r--r--src/GraphicObjects/Border.cs4
-rw-r--r--src/GraphicObjects/Container.cs141
-rw-r--r--src/GraphicObjects/GenericStack.cs15
-rw-r--r--[-rwxr-xr-x]src/GraphicObjects/GraphicObject.cs170
-rw-r--r--src/GraphicObjects/Group.cs59
-rwxr-xr-xsrc/GraphicObjects/Label.cs3
-rw-r--r--src/GraphicObjects/NumericControl.cs8
-rw-r--r--src/GraphicObjects/Scroller.cs6
-rw-r--r--src/LayoutingQueue.cs11
-rw-r--r--src/LayoutingQueueItem.cs2
20 files changed, 480 insertions, 288 deletions
diff --git a/Tests/GOLIBTest_4.1.cs b/Tests/GOLIBTest_4.1.cs
new file mode 100644
index 00000000..01621df8
--- /dev/null
+++ b/Tests/GOLIBTest_4.1.cs
@@ -0,0 +1,55 @@
+#define MONO_CAIRO_DEBUG_DISPOSE
+
+
+using System;
+using System.Runtime.InteropServices;
+using OpenTK;
+using OpenTK.Graphics.OpenGL;
+using OpenTK.Input;
+
+using System.Diagnostics;
+
+//using GGL;
+using go;
+using System.Threading;
+
+
+namespace test
+{
+ class GOLIBTest_4_1 : OpenTKGameWindow
+ {
+ public GOLIBTest_4_1 ()
+ : base(1024, 600,"test")
+ {}
+
+ Group g;
+
+ protected override void OnLoad (EventArgs e)
+ {
+ base.OnLoad (e);
+ LoadInterface("Interfaces/test4.1.goml", out g);
+
+ }
+ protected override void OnRenderFrame (FrameEventArgs e)
+ {
+ GL.Clear (ClearBufferMask.ColorBufferBit);
+ base.OnRenderFrame (e);
+ SwapBuffers ();
+ }
+
+ protected override void OnUpdateFrame (FrameEventArgs e)
+ {
+ base.OnUpdateFrame (e);
+ }
+
+ [STAThread]
+ static void Main ()
+ {
+ Console.WriteLine ("starting example");
+
+ using (GOLIBTest_4_1 win = new GOLIBTest_4_1( )) {
+ win.Run (30.0);
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/Tests/GOLIBTest_4.cs b/Tests/GOLIBTest_4.cs
index 2482a66e..5ee286b6 100644
--- a/Tests/GOLIBTest_4.cs
+++ b/Tests/GOLIBTest_4.cs
@@ -113,8 +113,8 @@ namespace test
}
);
i++;
- if (i > 50)
- break;
+// if (i > 50)
+// break;
}
}
void pFps_mousemove(object sender, MouseMoveEventArgs e)
@@ -124,7 +124,6 @@ namespace test
redrawClip.AddRectangle (c.ScreenCoordinates(c.Slot));
c.Left += e.XDelta;
c.Top += e.YDelta;
- c.LayoutIsValid = false;
c.registerForGraphicUpdate ();
}
protected override void OnRenderFrame (FrameEventArgs e)
diff --git a/Tests/GOLIBTest_fps.cs b/Tests/GOLIBTest_fps.cs
new file mode 100644
index 00000000..946eb5e1
--- /dev/null
+++ b/Tests/GOLIBTest_fps.cs
@@ -0,0 +1,101 @@
+#define MONO_CAIRO_DEBUG_DISPOSE
+
+
+using System;
+using System.Runtime.InteropServices;
+using OpenTK;
+using OpenTK.Graphics.OpenGL;
+using OpenTK.Input;
+
+using System.Diagnostics;
+
+//using GGL;
+using go;
+using System.Threading;
+
+
+namespace test
+{
+ class GOLIBTest_fps : OpenTKGameWindow
+ {
+ #region FPS
+ static int _fps = 0;
+
+ public static int fps {
+ get { return _fps; }
+ set {
+ _fps = value;
+ if (_fps > fpsMax)
+ fpsMax = _fps;
+ else if (_fps < fpsMin)
+ fpsMin = _fps;
+ }
+
+ }
+
+ public static int fpsMin = int.MaxValue;
+ public static int fpsMax = 0;
+
+ static void resetFps ()
+ {
+ fpsMin = int.MaxValue;
+ fpsMax = 0;
+ _fps = 0;
+ }
+ #endregion
+
+ public GOLIBTest_fps ()
+ : base(400, 200,"test")
+ {}
+
+ Container g;
+ Label labFps, labFpsMin, labFpsMax, labUpdate;
+
+ protected override void OnLoad (EventArgs e)
+ {
+ base.OnLoad (e);
+ LoadInterface("Interfaces/fps.goml", out g);
+
+ labFps = g.FindByName ("labFps") as Label;
+ labFpsMin = g.FindByName ("labFpsMin") as Label;
+ labFpsMax = g.FindByName ("labFpsMax") as Label;
+ labUpdate = g.FindByName ("labUpdate") as Label;
+
+ }
+ protected override void OnRenderFrame (FrameEventArgs e)
+ {
+ GL.Clear (ClearBufferMask.ColorBufferBit);
+ base.OnRenderFrame (e);
+ SwapBuffers ();
+ }
+
+ private int frameCpt = 0;
+ protected override void OnUpdateFrame (FrameEventArgs e)
+ {
+ base.OnUpdateFrame (e);
+
+ fps = (int)RenderFrequency;
+
+ labFps.Text = fps.ToString();
+ labUpdate.Text = this.updateTime.ElapsedMilliseconds.ToString() + " ms";
+ if (frameCpt > 200) {
+ labFpsMin.Text = fpsMin.ToString();
+ labFpsMax.Text = fpsMax.ToString();
+ resetFps ();
+ frameCpt = 0;
+
+ }
+ frameCpt++;
+ }
+
+ [STAThread]
+ static void Main ()
+ {
+ Console.WriteLine ("starting example");
+
+ using (GOLIBTest_fps win = new GOLIBTest_fps( )) {
+ win.Run (30.0);
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/Tests/Interfaces/fps.goml b/Tests/Interfaces/fps.goml
new file mode 100755
index 00000000..85b60afd
--- /dev/null
+++ b/Tests/Interfaces/fps.goml
@@ -0,0 +1,27 @@
+<?xml version="1.0"?>
+<Container Name="MainGrp"
+ HorizontalAlignment="Right" VerticalAlignment="Bottom"
+ Margin="10" Focusable="True" Fit="True">
+
+ <VerticalStack Fit="True" BorderWidth="1" Margin="5" WidgetSpacing="4">
+ <HorizontalStack>
+ <Label Text="Update:" FontColor="White" VerticalAlignment="Center" />
+ <Label Name="labUpdate" Text="xxxx" FontSize="12" Width="60" TextAlignment="Center" Background="DarkGreen"/>
+ </HorizontalStack>
+ <HorizontalStack>
+ <Label Text="Fps:" Width = "30" VerticalAlignment="Center" TextAlignment="LeftCenter"/>
+ <Label Name="labFps" Text="xxxx" Font="droid bold, 12"
+ TextAlignment="Center" Background="AoEnglish"/>
+ </HorizontalStack>
+ <HorizontalStack>
+ <Label Text="Min:" Width = "30" />
+ <Label Name="labFpsMin" Text="xxxx" Font="droid bold, 12"
+ TextAlignment="Center" Background="AoEnglish"/>
+ </HorizontalStack>
+ <HorizontalStack>
+ <Label Text="Max:" Width = "30"/>
+ <Label Name="labFpsMax" Text="xxxx" Font="droid bold, 12"
+ TextAlignment="Center" Background="AoEnglish"/>
+ </HorizontalStack>
+ </VerticalStack>
+</Container> \ No newline at end of file
diff --git a/Tests/Interfaces/test1.1.goml b/Tests/Interfaces/test1.1.goml
index 6ccf2c1c..86faa998 100755
--- a/Tests/Interfaces/test1.1.goml
+++ b/Tests/Interfaces/test1.1.goml
@@ -1,15 +1,15 @@
<?xml version="1.0"?>
-<Group Width="0" Height="0" Margin="50"
+<Group Name="TopGroup" Width="500" Height="400" Margin="5"
Focusable="True" Background="Yellow">
- <Group Width="-1" Height="-1" Margin="50"
+ <Group Name="InnerGroup" Width="-1" Height="-1" Margin="50"
VerticalAlignment="Top" HorizontalAlignment="Left"
Focusable="True" Background="Green">
<Image VerticalAlignment="Bottom"
- Name="PhaseOverlay" Width="100" Height="100" Path="image/u.svg" Background="Red"/>
+ Name="PhaseOverlay1" Width="100" Height="100" Path="image/u.svg" Background="Red"/>
<Image Top="100"
- Name="PhaseOverlay" Width="100" Height="100" Path="image/u.svg" Background="Red"/>
+ Name="PhaseOverlay2" Width="100" Height="100" Path="image/u.svg" Background="Red"/>
</Group>
- <Image Top="100"
- Name="PhaseOverlay" Width="100" Height="100" Path="image/u.svg" Background="Red"/>
+ <Image VerticalAlignment="Center" HorizontalAlignment="Right"
+ Name="PhaseOverlay0" Width="100" Height="100" Path="image/u.svg" Background="Red"/>
</Group> \ No newline at end of file
diff --git a/Tests/Interfaces/test1.2.goml b/Tests/Interfaces/test1.2.goml
index 1ccc51ec..c467cd51 100755
--- a/Tests/Interfaces/test1.2.goml
+++ b/Tests/Interfaces/test1.2.goml
@@ -1,10 +1,10 @@
<?xml version="1.0"?>
-<Container>
-<VerticalStack>
+<Container Background="Green" Height="400" Width="400">
+<VerticalStack Margin="10" Background="DarkBlue" Height="-1" Width="0">
<Label Text="label11"/>
<Label Text="label21"/>
- <HorizontalStack Width="-1" Height="-1" Margin="50"
- Focusable="True" Background="DarkBlue">
+ <HorizontalStack Width="-1" Height="-1" Margin="5"
+ Focusable="True" Background="Blue">
<Label Text="label12"/>
<Label Text="label22"/>
<Label Text="label32"/>
diff --git a/Tests/Interfaces/test1.3.goml b/Tests/Interfaces/test1.3.goml
new file mode 100755
index 00000000..c6fffe4e
--- /dev/null
+++ b/Tests/Interfaces/test1.3.goml
@@ -0,0 +1,14 @@
+<?xml version="1.0"?>
+<Container Name="MainMenu"
+ Margin="30" Focusable="True" Height="-1" Width="300">
+ <Border BorderWidth="1" Margin="40" Background="0,5;0,5;0,5;0,5">
+ <VerticalStack WidgetSpacing="10">
+ <Button Margin = "10" Text="Start New Game" Height="-1" Width="0"
+ MouseClick="onStartNewGame"/>
+ <Button Margin = "10" Text="Start New Game" Height="-1" Width="0"/>
+ <Button Margin = "10" Text="Start New Game" Height="-1" Width="0"/>
+ <Button Margin = "10" Text="Exit" Height="-1" Width="0"
+ MouseClick="onButExit_MouseClick" />
+ </VerticalStack>
+ </Border>
+</Container> \ No newline at end of file
diff --git a/Tests/Interfaces/test1.goml b/Tests/Interfaces/test1.goml
index 9601a87b..2177065e 100755
--- a/Tests/Interfaces/test1.goml
+++ b/Tests/Interfaces/test1.goml
@@ -1,8 +1,8 @@
<?xml version="1.0"?>
-<Container Width="300" Height="-1"
+<Container Name="TopContainer" Width="400" Height="350"
Margin="20" Focusable="True" Background="Yellow">
- <Container Width="-1" Height="-1"
+ <Container Name="MiddleContainer" Width="0" Height="0"
Margin="20" Focusable="True" Background="Green">
<Image VerticalAlignment="Bottom"
Name="PhaseOverlay" Width="100" Height="100" Path="image/u.svg" Background="Red"/>
diff --git a/Tests/Interfaces/test4.1.goml b/Tests/Interfaces/test4.1.goml
new file mode 100755
index 00000000..d854d0a0
--- /dev/null
+++ b/Tests/Interfaces/test4.1.goml
@@ -0,0 +1,98 @@
+<?xml version="1.0"?>
+<Group Name="MainGrp"
+ Width="800" Height="500"
+ Background="0,5;0,5;0,5;0,5" Foreground="White"
+ Margin="10" >
+ <Border
+ BorderWidth="2" BorderColor="Transparent"
+ Focusable="True"
+ MouseEnter="{BorderColor = White}"
+ MouseLeave="{BorderColor = Transparent}">
+
+ <HorizontalStack Name="hs0"
+ WidgetSpacing="10"
+ VerticalAlignment="Top"
+ Background="0,5;0,5;0,5;0,5">
+ <VerticalStack Name="vs1"
+ Margin="20">
+ <Label Name="labMouse" Text="MousePos"/>
+ <HorizontalStack Name="hsPbar">
+ <ProgressBar Name="pbBar"
+ Width="100" Height="20"
+ Value="50"
+ Foreground="BlueCrayola" Background="DarkGray"
+ BorderWidth="2" BorderColor="White"/>
+ <Label Name="labPb"
+ Width="20"
+ TextAlignment="RightCenter"/>
+ <ProgressBar Name="pbBar"
+ Width="100" Height="10"
+ Value="30"/>
+ </HorizontalStack>
+ <HorizontalStack Name="hsFocus" HorizontalAlignment="Left">
+ <Label Text="Focused:"/>
+ <Label Name="labFocus" Width="200"/>
+ </HorizontalStack>
+ <HorizontalStack>
+ <Label Text="Active:" Name="hsActive"/>
+ <Label Name="labActive" Width="200"/>
+ </HorizontalStack>
+ <HorizontalStack>
+ <Label Text="Hover:" Name="hsHover"/>
+ <Label Name="labHover" Width="200"/>
+ </HorizontalStack>
+ <Button Margin="5" BorderWidth="0" Background="Gray" Width="-1" Height="-1">
+ <Label FontSize="10" Text="This is a test" Margin="5" FontColor="White" Foreground="White" />
+ </Button>
+ <TextBoxWidget TextAlignment="LeftCenter" Font="droid,14"
+ Width="300" Height="-1" Margin="2"
+ BorderColor="White" BorderWidth="1"
+ Text="editable text"/>
+ <GroupBox Title="Group Box" Width="300" Height="100"
+ BorderColor="White" BorderWidth="2" Margin="3">
+ <Label Name="labValue" FontSize="14" Text="000" TextAlignment="Center"/>
+ </GroupBox>
+ <Slider Height="10" Width="300" BorderWidth="1" Background="Transparent" />
+ <GraduatedSlider Name="slider" Height="30" Width="300" Foreground="BlueBell"/>
+ </VerticalStack>
+ <VerticalStack Width="-1" Height="-1" BorderWidth="1" Margin="5" WidgetSpacing="4">
+<!-- <Button Width="-1" Height="-1" Margin="5">
+ <Image Path="/mnt/data/Images/130px-Blason_ville_fr_Aubure_(Haut-Rhin).svg.png"/>
+ </Button>-->
+ <HorizontalStack>
+ <Label Text="Update" FontColor="White" VerticalAlignment="Center" />
+ <Label Name="labUpdate" Text="xxxx" FontSize="16" Width="60" TextAlignment="Center" Background="DarkGreen"/>
+ </HorizontalStack>
+ <HorizontalStack>
+ <Label Text="Fps:" Width = "30" VerticalAlignment="Center" TextAlignment="LeftCenter"/>
+ <Label Name="labFps" Text="xxxx" Font="droid bold, 14"
+ TextAlignment="Center" Background="AoEnglish"/>
+ </HorizontalStack>
+ <HorizontalStack>
+ <Label Text="Min:" Width = "30" />
+ <Label Name="labFpsMin" Text="xxxx" Font="droid bold, 14"
+ TextAlignment="Center" Background="AoEnglish"/>
+ </HorizontalStack>
+ <HorizontalStack>
+ <Label Text="Max:" Width = "30"/>
+ <Label Name="labFpsMax" Text="xxxx" Font="droid bold, 14"
+ TextAlignment="Center" Background="AoEnglish"/>
+ </HorizontalStack>
+ </VerticalStack>
+
+ <Scroller Background="DimGray" Height="350" Width="300"
+ Margin="5" VerticalScrolling="true">
+ <VerticalStack Name="colors" VerticalAlignment="Top" Margin="5">
+ <ProgressBar Name="pbBar2" Width="100" Height="20" Value="50"
+ BorderWidth="2" BorderColor="White" Foreground="BlueCrayola" Background="DarkGray"/>
+ </VerticalStack>
+ </Scroller>
+
+ </HorizontalStack>
+
+ <Slider
+ Height="20" Width="300"
+ Background="Transparent"
+ VerticalAlignment="Bottom" />
+ </Border>
+</Group> \ No newline at end of file
diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj
index a0af8a64..02a19005 100644
--- a/Tests/Tests.csproj
+++ b/Tests/Tests.csproj
@@ -8,7 +8,7 @@
<OutputType>Exe</OutputType>
<RootNamespace>Tests</RootNamespace>
<AssemblyName>Tests</AssemblyName>
- <StartupObject>test.GOLIBTest_1</StartupObject>
+ <StartupObject>test.GOLIBTest_4</StartupObject>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<OutputPath>..\bin\$(configuration)</OutputPath>
<IntermediateOutputPath>obj\$(configuration)</IntermediateOutputPath>
@@ -72,6 +72,14 @@
<LogicalName>
</LogicalName>
</Compile>
+ <Compile Include="GOLIBTest_4.1.cs">
+ <LogicalName>
+ </LogicalName>
+ </Compile>
+ <Compile Include="GOLIBTest_fps.cs">
+ <LogicalName>
+ </LogicalName>
+ </Compile>
</ItemGroup>
<ItemGroup>
<None Include="image\u.svg">
@@ -119,6 +127,21 @@
<LogicalName>
</LogicalName>
</None>
+ <None Include="Interfaces\test4.1.goml">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ <LogicalName>
+ </LogicalName>
+ </None>
+ <None Include="Interfaces\test1.3.goml">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ <LogicalName>
+ </LogicalName>
+ </None>
+ <None Include="Interfaces\fps.goml">
+ <LogicalName>
+ </LogicalName>
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
</ItemGroup>
<ItemGroup>
<Folder Include="Interfaces\">
diff --git a/src/GraphicObjects/Border.cs b/src/GraphicObjects/Border.cs
index 281db215..e2451582 100644
--- a/src/GraphicObjects/Border.cs
+++ b/src/GraphicObjects/Border.cs
@@ -48,9 +48,9 @@ namespace go
Size raw = Bounds.Size;
if (child != null) {
- if (Bounds.Width < 0 && child.WIsValid)
+ if (Bounds.Width < 0)
raw.Width = child.Slot.Width + 2 * (Margin+BorderWidth);
- if (Bounds.Height < 0 && child.HIsValid)
+ if (Bounds.Height < 0)
raw.Height = child.Slot.Height + 2 * (Margin+BorderWidth);
}
diff --git a/src/GraphicObjects/Container.cs b/src/GraphicObjects/Container.cs
index 862f7947..0d0ad5b3 100644
--- a/src/GraphicObjects/Container.cs
+++ b/src/GraphicObjects/Container.cs
@@ -66,107 +66,58 @@ namespace go
return child == null ? Bounds.Size : new Size(child.Slot.Width + 2 * (Margin),child.Slot.Height + 2 * (Margin));
}
- public override void UpdateLayout (LayoutingType layoutType)
+ protected override void OnLayoutChanges (LayoutingType layoutType)
{
- {
- switch (layoutType) {
- case LayoutingType.X:
- if (Bounds.X == 0) {
- switch (HorizontalAlignment) {
- case HorizontalAlignment.Left:
- Slot.X = 0;
- break;
- case HorizontalAlignment.Right:
- Slot.X = Parent.ClientRectangle.Width - Slot.Width;
- break;
- case HorizontalAlignment.Center:
- Slot.X = Parent.ClientRectangle.Width / 2 - Slot.Width / 2;
- break;
- }
- } else
- Slot.X = Bounds.X;
- if (LastSlots.X == Slot.X)
- break;
- //register layouting here for objects depending on this.x
- LastSlots.X = Slot.X;
- break;
- case LayoutingType.Y:
- if (Bounds.Y == 0) {
- switch (VerticalAlignment) {
- case VerticalAlignment.Top:
- Slot.Y = 0;
- break;
- case VerticalAlignment.Bottom:
- Slot.Y = Parent.ClientRectangle.Height - Slot.Height;
- break;
- case VerticalAlignment.Center:
- Slot.Y = Parent.ClientRectangle.Height / 2 - Slot.Height / 2;
- break;
- }
- }else
- Slot.Y = Bounds.Y;
- if (LastSlots.Y == Slot.Y)
- break;
- //register layouting here for objects depending on this.x
- LastSlots.Y = Slot.Y;
- break;
- case LayoutingType.Width:
- if (Width > 0)
- Slot.Width = Width;
- else if (Width < 0)
- Slot.Width = measureRawSize ().Width;
+ switch (layoutType) {
+ case LayoutingType.Width:
+ base.OnLayoutChanges (layoutType);
+ if (child != null) {
+ if (child.getBounds ().Width == 0)
+ child.RegisterForLayouting ((int)LayoutingType.Width);
else
- Slot.Width = Parent.ClientRectangle.Width;
-
- if (LastSlots.Width == Slot.Width)
- break;
-
- if (Parent.getBounds ().Width < 0)
- this.Parent.RegisterForLayouting ((int)LayoutingType.Width);
- else if (Width != 0) //update position in parent
- this.RegisterForLayouting ((int)LayoutingType.X);
-
- if (child != null) {
- if (child.getBounds ().Width == 0)
- child.RegisterForLayouting ((int)LayoutingType.Width);
- else
- child.RegisterForLayouting ((int)LayoutingType.X);
- }
- LastSlots.Width = Slot.Width;
- break;
- case LayoutingType.Height:
- if (Height > 0)
- Slot.Height = Height;
- else if (Height < 0)
- Slot.Height = measureRawSize ().Height;
+ child.RegisterForLayouting ((int)LayoutingType.X);
+ }
+ break;
+ case LayoutingType.Height:
+ base.OnLayoutChanges (layoutType);
+ if (child != null) {
+ if (child.getBounds ().Height == 0)
+ child.RegisterForLayouting ((int)LayoutingType.Height);
else
- Slot.Height = Parent.ClientRectangle.Height;
-
- if (LastSlots.Height == Slot.Height)
- break;
-
- if (Parent.getBounds().Height < 0)
- this.Parent.RegisterForLayouting((int)LayoutingType.Height);
- else if (Height != 0) //update position in parent
- this.RegisterForLayouting ((int)LayoutingType.Y);
-
- if (child != null) {
- if (child.getBounds ().Height == 0)
- child.RegisterForLayouting ((int)LayoutingType.Height);
- else
- child.RegisterForLayouting ((int)LayoutingType.Y);
- }
-
- LastSlots.Height = Slot.Height;
- break;
+ child.RegisterForLayouting ((int)LayoutingType.Y);
}
-
- //if no layouting remains in queue for item, registre for redraw
- if (Interface.LayoutingQueue.Where (lq => lq.GraphicObject == this).Count () <= 0)
- this.RegisterForRedraw ();
- }
+ break;
+ }
}
+// public override void RegisterForLayouting(int layoutType)
+// {
+// Interface.LayoutingQueue.RemoveAll (lq => lq.GraphicObject == this && (layoutType & (int)lq.LayoutType) > 0);
+//
+// if ((layoutType & (int)LayoutingType.Width) > 0) {
+// if (Bounds.Width == 0) //stretch in parent
+// Interface.LayoutingQueue.EnqueueAfterParentSizing (LayoutingType.Width, this);
+// else //fit ou fixed
+// Interface.LayoutingQueue.Enqueue (LayoutingType.Width, this);
+// }
+//
+// if ((layoutType & (int)LayoutingType.Height) > 0) {
+// if (Bounds.Height == 0) //stretch in parent
+// Interface.LayoutingQueue.EnqueueAfterParentSizing (LayoutingType.Height, this);
+// else//fit ou fixed
+// Interface.LayoutingQueue.Enqueue (LayoutingType.Height, this);
+// }
+//
+// if ((layoutType & (int)LayoutingType.X) > 0)
+// //for x positionning, sizing of parent and this have to be done
+// Interface.LayoutingQueue.EnqueueAfterThisAndParentSizing (LayoutingType.X, this);
+//
+// if ((layoutType & (int)LayoutingType.Y) > 0)
+// //for x positionning, sizing of parent and this have to be done
+// Interface.LayoutingQueue.EnqueueAfterThisAndParentSizing (LayoutingType.Y, this);
+//
+// }
+
public override Rectangle ContextCoordinates (Rectangle r)
{
return
diff --git a/src/GraphicObjects/GenericStack.cs b/src/GraphicObjects/GenericStack.cs
index 04e63d15..f34e13d3 100644
--- a/src/GraphicObjects/GenericStack.cs
+++ b/src/GraphicObjects/GenericStack.cs
@@ -24,8 +24,9 @@ namespace go
public override T addChild<T> (T child)
{
+ T tmp = base.addChild (child);
this.RegisterForLayouting ((int)LayoutingType.PositionChildren);
- return base.addChild (child);
+ return tmp;
}
public override void removeChild (GraphicObject child)
{
@@ -96,17 +97,7 @@ namespace go
}
}
}
-// public void RegisterForLayouting ()
-// {
-// base.RegisterForLayouting ();
-//
-// int idx = Interface.LayoutingQueue.IndexOf (Interface.LayoutingQueue.Where (lq => lq.GraphicObject.Parent == this).LastOrDefault ());
-// if (idx < 0)
-// return;
-// Interface.LayoutingQueue.Insert (
-// idx+1,
-// new LayoutingQueueItem (LayoutingType.PositionChildren, this));
-// }
+
public override void RegisterForLayouting (int layoutType)
{
base.RegisterForLayouting (layoutType);
diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs
index 9317f409..a7b9e93e 100755..100644
--- a/src/GraphicObjects/GraphicObject.cs
+++ b/src/GraphicObjects/GraphicObject.cs
@@ -66,49 +66,6 @@ namespace go
get { return _parent; }
set { _parent = value; }
}
- [XmlIgnore]public virtual bool SizeIsValid {
- get { return hIsValid & wIsValid; }
- set {
- hIsValid = value;
- wIsValid = value;
- }
- }
- [XmlIgnore]public virtual bool WIsValid {
- get { return wIsValid; }
- set { wIsValid = value; }
- }
- [XmlIgnore]public virtual bool HIsValid {
- get { return hIsValid; }
- set { hIsValid = value; }
- }
- [XmlIgnore]public virtual bool XIsValid {
- get { return xIsValid; }
- set { xIsValid = value; }
- }
- [XmlIgnore]public virtual bool YIsValid {
- get { return yIsValid; }
- set { yIsValid = value; }
- }
- [XmlIgnore]public virtual bool PositionIsValid {
- get { return xIsValid & yIsValid; }
- set {
- xIsValid = value;
- yIsValid = value;
- }
- }
- [XmlIgnore]public virtual bool LayoutIsValid {
- get { return SizeIsValid & PositionIsValid; }
- set {
- if (value == SizeIsValid & PositionIsValid)
- return;
-
- SizeIsValid = value;
- PositionIsValid = value;
-
- //if (!layoutIsValid && Parent != null)
- // Parent.layoutIsValid = false;
- }
- }
[XmlIgnore]public virtual Rectangle ClientRectangle {
get {
Rectangle cb = Slot.Size;
@@ -119,11 +76,6 @@ namespace go
[XmlIgnore]public virtual IGOLibHost TopContainer {
get { return Parent == null ? null : Parent.TopContainer; }
}
- public virtual void InvalidateLayout ()
- {
- bmp = null;
- LayoutIsValid = false;
- }
public virtual Rectangle ContextCoordinates(Rectangle r){
return
Parent.ContextCoordinates (r);// + ClientRectangle.Position;
@@ -190,7 +142,7 @@ namespace go
Bounds.X = value;
- Interface.LayoutingQueue.Enqueue (LayoutingType.X, this);
+ this.RegisterForLayouting ((int)LayoutingType.X);
}
}
[XmlAttributeAttribute()][DefaultValue(0)]
@@ -202,7 +154,7 @@ namespace go
Bounds.Y = value;
- Interface.LayoutingQueue.Enqueue (LayoutingType.Y, this);
+ this.RegisterForLayouting ((int)LayoutingType.Y);
}
}
[XmlAttributeAttribute()][DefaultValue(0)]
@@ -214,7 +166,7 @@ namespace go
Bounds.Width = value;
- InvalidateLayout ();
+ this.RegisterForLayouting ((int)LayoutingType.Width);
}
}
[XmlAttributeAttribute()][DefaultValue(0)]
@@ -226,7 +178,7 @@ namespace go
Bounds.Height = value;
- InvalidateLayout ();
+ this.RegisterForLayouting ((int)LayoutingType.Height);
}
}
[XmlAttributeAttribute()][DefaultValue(false)]
@@ -237,7 +189,6 @@ namespace go
return;
Bounds.Width = Bounds.Height = -1;
- InvalidateLayout ();
}
}
[XmlAttributeAttribute()][DefaultValue(false)]
@@ -399,19 +350,36 @@ namespace go
public virtual void RegisterForLayouting(int layoutType)
{
+ if (Parent == null)
+ return;
+
Interface.LayoutingQueue.RemoveAll (lq => lq.GraphicObject == this && (layoutType & (int)lq.LayoutType) > 0);
if ((layoutType & (int)LayoutingType.Width) > 0) {
+
+ //force sizing to fit if parent is sizing on children
+ if (Parent.getBounds ().Width < 0 && Width == 0)
+ Width = -1;
+
if (Bounds.Width == 0) //stretch in parent
Interface.LayoutingQueue.EnqueueAfterParentSizing (LayoutingType.Width, this);
- else //fit ou fixed
+ else if (Bounds.Width < 0) //fit
+ Interface.LayoutingQueue.EnqueueBeforeParentSizing (LayoutingType.Width, this);
+ else
Interface.LayoutingQueue.Insert (0, new LayoutingQueueItem (LayoutingType.Width, this));
}
if ((layoutType & (int)LayoutingType.Height) > 0) {
+
+ //force sizing to fit if parent is sizing on children
+ if (Parent.getBounds ().Height < 0 && Height == 0)
+ Height = -1;
+
if (Bounds.Height == 0) //stretch in parent
Interface.LayoutingQueue.EnqueueAfterParentSizing (LayoutingType.Height, this);
- else//fit ou fixed
+ else if (Bounds.Height < 0) //fit
+ Interface.LayoutingQueue.EnqueueBeforeParentSizing (LayoutingType.Height, this);
+ else
Interface.LayoutingQueue.Insert (0, new LayoutingQueueItem (LayoutingType.Height, this));
}
@@ -425,42 +393,31 @@ namespace go
}
-// public virtual void RegisterForLayouting()
-// {
-// //clear previous layouting for item
-// Interface.LayoutingQueue.RemoveAll (lq => lq.GraphicObject == this);
-//
-// if (Bounds.Width == 0) { //stretch in parent
-// int idxParentW = Interface.LayoutingQueue.IndexOf (Interface.LayoutingQueue.Where(lq => lq.GraphicObject == this.Parent && lq.LayoutType == LayoutingType.Width).FirstOrDefault());
-// if (idxParentW < 0)
-// Interface.LayoutingQueue.Insert (0, new LayoutingQueueItem (LayoutingType.Width, this));
-// else//insert after parent sizing
-// Interface.LayoutingQueue.Insert (idxParentW + 1, new LayoutingQueueItem (LayoutingType.Width, this));
-// } else {//fit ou fixed
-// Interface.LayoutingQueue.Insert (0, new LayoutingQueueItem (LayoutingType.Width, this));
-// //for x positionning, sizing of obj and parent have to be done
-//// int idxParentW = Interface.LayoutingQueue.IndexOf (Interface.LayoutingQueue.Where(lq => lq.GraphicObject == this.Parent && lq.LayoutType == LayoutingType.Width).FirstOrDefault());
-//// if (idxParentW < 0)
-//// Interface.LayoutingQueue.Insert (1, new LayoutingQueueItem (LayoutingType.X, this));
-//// else//insert after parent sizing
-//// Interface.LayoutingQueue.Insert (idxParentW + 1, new LayoutingQueueItem (LayoutingType.X, this));
-// }
-// if (Bounds.Height == 0) { //stretch
-// int idxParentH = Interface.LayoutingQueue.IndexOf (Interface.LayoutingQueue.Where(lq => lq.GraphicObject == this.Parent && lq.LayoutType == LayoutingType.Height).FirstOrDefault());
-// if (idxParentH < 0)
-// Interface.LayoutingQueue.Insert (0, new LayoutingQueueItem (LayoutingType.Height, this));
-// else
-// Interface.LayoutingQueue.Insert (idxParentH + 1, new LayoutingQueueItem (LayoutingType.Height, this));
-// } else {
-// Interface.LayoutingQueue.Insert (0, new LayoutingQueueItem (LayoutingType.Height, this));
-//// int idxParentH = Interface.LayoutingQueue.IndexOf (Interface.LayoutingQueue.Where(lq => lq.GraphicObject == this.Parent && lq.LayoutType == LayoutingType.Height).FirstOrDefault());
-//// if (idxParentH < 0)
-//// Interface.LayoutingQueue.Insert (1, new LayoutingQueueItem (LayoutingType.Y, this));
-//// else//insert after parent sizing
-//// Interface.LayoutingQueue.Insert (idxParentH + 1, new LayoutingQueueItem (LayoutingType.Y, this));
-// }
-// }
-//
+ protected virtual void OnLayoutChanges(LayoutingType layoutType)
+ {
+ switch (layoutType) {
+ case LayoutingType.Width:
+ if (Parent.getBounds ().Width < 0)
+ this.Parent.RegisterForLayouting ((int)LayoutingType.Width);
+ else if (Width != 0) //update position in parent
+ this.RegisterForLayouting ((int)LayoutingType.X);
+ if (!(Parent is GenericStack))
+ break;
+ if ((Parent as GenericStack).Orientation == Orientation.Horizontal)
+ this.Parent.RegisterForLayouting ((int)LayoutingType.PositionChildren);
+ break;
+ case LayoutingType.Height:
+ if (Parent.getBounds().Height < 0)
+ this.Parent.RegisterForLayouting((int)LayoutingType.Height);
+ else if (Height != 0) //update position in parent
+ this.RegisterForLayouting ((int)LayoutingType.Y);
+ if (!(Parent is GenericStack))
+ break;
+ if ((Parent as GenericStack).Orientation == Orientation.Vertical)
+ this.Parent.RegisterForLayouting ((int)LayoutingType.PositionChildren);
+ break;
+ }
+ }
public virtual void UpdateLayout (LayoutingType layoutType)
{
switch (layoutType) {
@@ -479,9 +436,14 @@ namespace go
}
} else
Slot.X = Bounds.X;
+
if (LastSlots.X == Slot.X)
break;
- //register layouting here for objects depending on this.x
+
+ bmp = null;
+
+ OnLayoutChanges (layoutType);
+
LastSlots.X = Slot.X;
break;
case LayoutingType.Y:
@@ -499,9 +461,14 @@ namespace go
}
}else
Slot.Y = Bounds.Y;
+
if (LastSlots.Y == Slot.Y)
break;
- //register layouting here for objects depending on this.x
+
+ bmp = null;
+
+ OnLayoutChanges (layoutType);
+
LastSlots.Y = Slot.Y;
break;
case LayoutingType.Width:
@@ -514,11 +481,10 @@ namespace go
if (LastSlots.Width == Slot.Width)
break;
-
- if (Parent.getBounds().Width < 0)
- this.Parent.RegisterForLayouting((int)LayoutingType.Width);
- else if (Width != 0) //update position in parent
- this.RegisterForLayouting ((int)LayoutingType.X);
+
+ bmp = null;
+
+ OnLayoutChanges (layoutType);
LastSlots.Width = Slot.Width;
break;
@@ -533,10 +499,9 @@ namespace go
if (LastSlots.Height == Slot.Height)
break;
- if (Parent.getBounds().Height < 0)
- this.Parent.RegisterForLayouting((int)LayoutingType.Height);
- else if (Height != 0) //update position in parent
- this.RegisterForLayouting ((int)LayoutingType.Y);
+ bmp = null;
+
+ OnLayoutChanges (layoutType);
LastSlots.Height = Slot.Height;
break;
@@ -569,6 +534,7 @@ namespace go
onDraw (gr);
}
draw.Flush ();
+ //draw.WriteToPng ("/mnt/data/test.png");
}
}
diff --git a/src/GraphicObjects/Group.cs b/src/GraphicObjects/Group.cs
index e1639533..7b63156f 100644
--- a/src/GraphicObjects/Group.cs
+++ b/src/GraphicObjects/Group.cs
@@ -46,6 +46,7 @@ namespace go
child.Parent = null;
this.RegisterForLayouting ((int)LayoutingType.Sizing);
}
+
public void putWidgetOnTop(GraphicObject w)
{
if (Children.Contains(w))
@@ -104,12 +105,6 @@ namespace go
}
return false;
}
- public override void InvalidateLayout()
- {
- base.InvalidateLayout();
- foreach (GraphicObject w in Children)
- w.InvalidateLayout();
- }
protected override Size measureRawSize ()
{
Size tmp = new Size ();
@@ -125,39 +120,7 @@ namespace go
return tmp;
}
-// public override void UpdateLayout (LayoutingType layoutType)
-// {
-// if (LayoutIsValid)
-// return;
-//
-// bool atLeastOneChildHasWNotDependingOnParent = false;
-// bool atLeastOneChildHasHNotDependingOnParent = false;
-//
-//// foreach (GraphicObject c in Children) {
-//// if (c.LayoutIsValid)
-//// continue;
-////
-//// if (Width < 0 && c.WIsValid) {
-//// if (!atLeastOneChildHasWNotDependingOnParent && !(this is GenericStack))
-//// c.XIsValid = true;
-//// atLeastOneChildHasWNotDependingOnParent = true;
-//// }
-//// if (Height < 0 && c.HIsValid) {
-//// if (!atLeastOneChildHasHNotDependingOnParent && !(this is GenericStack))
-//// c.YIsValid = true;
-//// atLeastOneChildHasHNotDependingOnParent = true;
-//// }
-////
-//// c.UpdateLayout ();
-//// }
-//
-//// if (Width < 0 && !atLeastOneChildHasWNotDependingOnParent)
-//// Debug.WriteLine ("ERROR: no child has fixed width and parent width is set to content!");
-//// if (Height < 0 && !atLeastOneChildHasHNotDependingOnParent)
-//// Debug.WriteLine ("ERROR: no child has fixed height and parent height is set to content!");
-//
-// //base.UpdateLayout ();
-// }
+
public override Rectangle ContextCoordinates(Rectangle r){
return r + ClientRectangle.Position;
@@ -246,15 +209,15 @@ namespace go
}
#endregion
- public override string ToString()
- {
- string tmp = base.ToString();
- foreach (GraphicObject w in Children)
- {
- tmp += "\n" + w.ToString();
- }
- return tmp;
- }
+// public override string ToString()
+// {
+// string tmp = base.ToString();
+// foreach (GraphicObject w in Children)
+// {
+// tmp += "\n" + w.ToString();
+// }
+// return tmp;
+// }
#region IXmlSerializable
diff --git a/src/GraphicObjects/Label.cs b/src/GraphicObjects/Label.cs
index ee62a266..1f6048d1 100755
--- a/src/GraphicObjects/Label.cs
+++ b/src/GraphicObjects/Label.cs
@@ -86,7 +86,8 @@ namespace go
return;
registerForGraphicUpdate();
- InvalidateLayout();
+ this.RegisterForLayouting ((int)LayoutingType.Sizing);
+
_text = value;
diff --git a/src/GraphicObjects/NumericControl.cs b/src/GraphicObjects/NumericControl.cs
index 51a3fdc5..93aadc84 100644
--- a/src/GraphicObjects/NumericControl.cs
+++ b/src/GraphicObjects/NumericControl.cs
@@ -43,8 +43,6 @@ namespace go
_minValue = value;
- LayoutIsValid = false;
- registerForGraphicUpdate ();
}
}
[XmlAttributeAttribute()][DefaultValue(10.0)]
@@ -57,8 +55,6 @@ namespace go
_maxValue = value;
- LayoutIsValid = false;
- registerForGraphicUpdate ();
}
}
[XmlAttributeAttribute()][DefaultValue(0.5)]
@@ -71,8 +67,6 @@ namespace go
_smallStep = value;
- LayoutIsValid = false;
- registerForGraphicUpdate ();
}
}
[XmlAttributeAttribute()][DefaultValue(2.0)]
@@ -85,8 +79,6 @@ namespace go
_bigStep = value;
- LayoutIsValid = false;
- registerForGraphicUpdate ();
}
}
[XmlAttributeAttribute()][DefaultValue(0)]
diff --git a/src/GraphicObjects/Scroller.cs b/src/GraphicObjects/Scroller.cs
index 6855e924..19b93cd8 100644
--- a/src/GraphicObjects/Scroller.cs
+++ b/src/GraphicObjects/Scroller.cs
@@ -115,8 +115,8 @@ namespace go
{
TopContainer.redrawClip.AddRectangle (base.ScreenCoordinates(Slot));
}
- public override void UpdateLayout (LayoutingType layoutType)
- {
+// public override void UpdateLayout (LayoutingType layoutType)
+// {
// base.UpdateLayout ();
//
// if (!LayoutIsValid)
@@ -130,7 +130,7 @@ namespace go
// child.Slot.Y = 0;
// if (HorizontalScrolling)
// child.Slot.X = 0;
- }
+ //}
public override void Paint(ref Cairo.Context ctx, Rectangles clip = null)
{
if (!Visible)//check if necessary??
diff --git a/src/LayoutingQueue.cs b/src/LayoutingQueue.cs
index 142a3079..2d96788f 100644
--- a/src/LayoutingQueue.cs
+++ b/src/LayoutingQueue.cs
@@ -43,6 +43,17 @@ namespace go
Interface.LayoutingQueue.Insert (idxParentSz + 1, lqi);
}
+ public void EnqueueBeforeParentSizing (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).FirstOrDefault());
+
+ if (idxParentSz < 0)
+ Interface.LayoutingQueue.Enqueue (_lt, _object);
+ else
+ Interface.LayoutingQueue.Insert (idxParentSz, lqi);
+ }
public void EnqueueAfterThisAndParentSizing (LayoutingType _lt, ILayoutable _object)
{
LayoutingQueueItem lqi = new LayoutingQueueItem (_lt, _object);
diff --git a/src/LayoutingQueueItem.cs b/src/LayoutingQueueItem.cs
index e1d21792..b028fb83 100644
--- a/src/LayoutingQueueItem.cs
+++ b/src/LayoutingQueueItem.cs
@@ -47,7 +47,7 @@ namespace go
}
public void ProcessLayouting()
{
- Debug.WriteLine ("Layouting => " + this.ToString ());
+ //Debug.WriteLine ("Layouting => " + this.ToString ());
try {
GraphicObject.UpdateLayout (LayoutType);
} catch (Exception ex) {