--- /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_4_1 : OpenTKGameWindow\r
+ {\r
+ public GOLIBTest_4_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/test4.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_4_1 win = new GOLIBTest_4_1( )) {\r
+ win.Run (30.0);\r
+ }\r
+ }\r
+ }\r
+}
\ No newline at end of file
}\r
);\r
i++;\r
- if (i > 50)\r
- break;\r
+// if (i > 50)\r
+// break;\r
}\r
}\r
void pFps_mousemove(object sender, MouseMoveEventArgs e)\r
redrawClip.AddRectangle (c.ScreenCoordinates(c.Slot));\r
c.Left += e.XDelta;\r
c.Top += e.YDelta;\r
- c.LayoutIsValid = false;\r
c.registerForGraphicUpdate ();\r
}\r
protected override void OnRenderFrame (FrameEventArgs e)\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_fps : OpenTKGameWindow\r
+ {\r
+ #region FPS\r
+ static int _fps = 0;\r
+\r
+ public static int fps {\r
+ get { return _fps; }\r
+ set {\r
+ _fps = value;\r
+ if (_fps > fpsMax)\r
+ fpsMax = _fps;\r
+ else if (_fps < fpsMin)\r
+ fpsMin = _fps;\r
+ }\r
+\r
+ }\r
+\r
+ public static int fpsMin = int.MaxValue;\r
+ public static int fpsMax = 0;\r
+\r
+ static void resetFps ()\r
+ {\r
+ fpsMin = int.MaxValue;\r
+ fpsMax = 0;\r
+ _fps = 0;\r
+ }\r
+ #endregion\r
+\r
+ public GOLIBTest_fps ()\r
+ : base(400, 200,"test")\r
+ {}\r
+\r
+ Container g;\r
+ Label labFps, labFpsMin, labFpsMax, labUpdate;\r
+\r
+ protected override void OnLoad (EventArgs e)\r
+ {\r
+ base.OnLoad (e);\r
+ LoadInterface("Interfaces/fps.goml", out g);\r
+\r
+ labFps = g.FindByName ("labFps") as Label;\r
+ labFpsMin = g.FindByName ("labFpsMin") as Label;\r
+ labFpsMax = g.FindByName ("labFpsMax") as Label;\r
+ labUpdate = g.FindByName ("labUpdate") as Label;\r
+\r
+ }\r
+ protected override void OnRenderFrame (FrameEventArgs e)\r
+ {\r
+ GL.Clear (ClearBufferMask.ColorBufferBit);\r
+ base.OnRenderFrame (e);\r
+ SwapBuffers ();\r
+ }\r
+\r
+ private int frameCpt = 0;\r
+ protected override void OnUpdateFrame (FrameEventArgs e)\r
+ {\r
+ base.OnUpdateFrame (e);\r
+\r
+ fps = (int)RenderFrequency;\r
+\r
+ labFps.Text = fps.ToString();\r
+ labUpdate.Text = this.updateTime.ElapsedMilliseconds.ToString() + " ms";\r
+ if (frameCpt > 200) {\r
+ labFpsMin.Text = fpsMin.ToString();\r
+ labFpsMax.Text = fpsMax.ToString();\r
+ resetFps ();\r
+ frameCpt = 0;\r
+\r
+ }\r
+ frameCpt++;\r
+ }\r
+\r
+ [STAThread]\r
+ static void Main ()\r
+ {\r
+ Console.WriteLine ("starting example");\r
+\r
+ using (GOLIBTest_fps win = new GOLIBTest_fps( )) {\r
+ win.Run (30.0);\r
+ }\r
+ }\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+<?xml version="1.0"?>\r
+<Container Name="MainGrp"\r
+ HorizontalAlignment="Right" VerticalAlignment="Bottom"\r
+ Margin="10" Focusable="True" Fit="True">\r
+\r
+ <VerticalStack Fit="True" BorderWidth="1" Margin="5" WidgetSpacing="4">\r
+ <HorizontalStack>\r
+ <Label Text="Update:" FontColor="White" VerticalAlignment="Center" />\r
+ <Label Name="labUpdate" Text="xxxx" FontSize="12" Width="60" TextAlignment="Center" Background="DarkGreen"/>\r
+ </HorizontalStack>\r
+ <HorizontalStack>\r
+ <Label Text="Fps:" Width = "30" VerticalAlignment="Center" TextAlignment="LeftCenter"/>\r
+ <Label Name="labFps" Text="xxxx" Font="droid bold, 12"\r
+ TextAlignment="Center" Background="AoEnglish"/>\r
+ </HorizontalStack>\r
+ <HorizontalStack>\r
+ <Label Text="Min:" Width = "30" />\r
+ <Label Name="labFpsMin" Text="xxxx" Font="droid bold, 12"\r
+ TextAlignment="Center" Background="AoEnglish"/>\r
+ </HorizontalStack>\r
+ <HorizontalStack>\r
+ <Label Text="Max:" Width = "30"/>\r
+ <Label Name="labFpsMax" Text="xxxx" Font="droid bold, 12"\r
+ TextAlignment="Center" Background="AoEnglish"/>\r
+ </HorizontalStack>\r
+ </VerticalStack> \r
+</Container>
\ No newline at end of file
<?xml version="1.0"?>\r
-<Group Width="0" Height="0" Margin="50"\r
+<Group Name="TopGroup" Width="500" Height="400" Margin="5"\r
Focusable="True" Background="Yellow">\r
- <Group Width="-1" Height="-1" Margin="50" \r
+ <Group Name="InnerGroup" 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
+ Name="PhaseOverlay1" 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
+ Name="PhaseOverlay2" 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
+ <Image VerticalAlignment="Center" HorizontalAlignment="Right"\r
+ Name="PhaseOverlay0" Width="100" Height="100" Path="image/u.svg" Background="Red"/>\r
\r
</Group>
\ No newline at end of file
<?xml version="1.0"?>\r
-<Container>\r
-<VerticalStack>\r
+<Container Background="Green" Height="400" Width="400">\r
+<VerticalStack Margin="10" Background="DarkBlue" Height="-1" Width="0">\r
<Label Text="label11"/>\r
<Label Text="label21"/>\r
- <HorizontalStack Width="-1" Height="-1" Margin="50"\r
- Focusable="True" Background="DarkBlue">\r
+ <HorizontalStack Width="-1" Height="-1" Margin="5"\r
+ Focusable="True" Background="Blue">\r
<Label Text="label12"/>\r
<Label Text="label22"/>\r
<Label Text="label32"/>\r
--- /dev/null
+<?xml version="1.0"?>\r
+<Container Name="MainMenu" \r
+ Margin="30" Focusable="True" Height="-1" Width="300">\r
+ <Border BorderWidth="1" Margin="40" Background="0,5;0,5;0,5;0,5">\r
+ <VerticalStack WidgetSpacing="10">\r
+ <Button Margin = "10" Text="Start New Game" Height="-1" Width="0" \r
+ MouseClick="onStartNewGame"/>\r
+ <Button Margin = "10" Text="Start New Game" Height="-1" Width="0"/>\r
+ <Button Margin = "10" Text="Start New Game" Height="-1" Width="0"/>\r
+ <Button Margin = "10" Text="Exit" Height="-1" Width="0"\r
+ MouseClick="onButExit_MouseClick" />\r
+ </VerticalStack>\r
+ </Border> \r
+</Container>
\ No newline at end of file
<?xml version="1.0"?>\r
-<Container Width="300" Height="-1"\r
+<Container Name="TopContainer" Width="400" Height="350"\r
Margin="20" Focusable="True" Background="Yellow">\r
\r
- <Container Width="-1" Height="-1"\r
+ <Container Name="MiddleContainer" Width="0" Height="0"\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
--- /dev/null
+<?xml version="1.0"?>\r
+<Group Name="MainGrp"\r
+ Width="800" Height="500"\r
+ Background="0,5;0,5;0,5;0,5" Foreground="White"\r
+ Margin="10" >\r
+ <Border \r
+ BorderWidth="2" BorderColor="Transparent"\r
+ Focusable="True"\r
+ MouseEnter="{BorderColor = White}"\r
+ MouseLeave="{BorderColor = Transparent}">\r
+\r
+ <HorizontalStack Name="hs0"\r
+ WidgetSpacing="10" \r
+ VerticalAlignment="Top" \r
+ Background="0,5;0,5;0,5;0,5">\r
+ <VerticalStack Name="vs1"\r
+ Margin="20">\r
+ <Label Name="labMouse" Text="MousePos"/>\r
+ <HorizontalStack Name="hsPbar">\r
+ <ProgressBar Name="pbBar" \r
+ Width="100" Height="20"\r
+ Value="50"\r
+ Foreground="BlueCrayola" Background="DarkGray"\r
+ BorderWidth="2" BorderColor="White"/>\r
+ <Label Name="labPb"\r
+ Width="20"\r
+ TextAlignment="RightCenter"/>\r
+ <ProgressBar Name="pbBar"\r
+ Width="100" Height="10"\r
+ Value="30"/>\r
+ </HorizontalStack>\r
+ <HorizontalStack Name="hsFocus" HorizontalAlignment="Left">\r
+ <Label Text="Focused:"/>\r
+ <Label Name="labFocus" Width="200"/>\r
+ </HorizontalStack>\r
+ <HorizontalStack>\r
+ <Label Text="Active:" Name="hsActive"/>\r
+ <Label Name="labActive" Width="200"/>\r
+ </HorizontalStack>\r
+ <HorizontalStack>\r
+ <Label Text="Hover:" Name="hsHover"/>\r
+ <Label Name="labHover" Width="200"/>\r
+ </HorizontalStack>\r
+ <Button Margin="5" BorderWidth="0" Background="Gray" Width="-1" Height="-1">\r
+ <Label FontSize="10" Text="This is a test" Margin="5" FontColor="White" Foreground="White" />\r
+ </Button>\r
+ <TextBoxWidget TextAlignment="LeftCenter" Font="droid,14" \r
+ Width="300" Height="-1" Margin="2"\r
+ BorderColor="White" BorderWidth="1"\r
+ Text="editable text"/>\r
+ <GroupBox Title="Group Box" Width="300" Height="100" \r
+ BorderColor="White" BorderWidth="2" Margin="3">\r
+ <Label Name="labValue" FontSize="14" Text="000" TextAlignment="Center"/>\r
+ </GroupBox>\r
+ <Slider Height="10" Width="300" BorderWidth="1" Background="Transparent" />\r
+ <GraduatedSlider Name="slider" Height="30" Width="300" Foreground="BlueBell"/>\r
+ </VerticalStack>\r
+ <VerticalStack Width="-1" Height="-1" BorderWidth="1" Margin="5" WidgetSpacing="4">\r
+<!-- <Button Width="-1" Height="-1" Margin="5">\r
+ <Image Path="/mnt/data/Images/130px-Blason_ville_fr_Aubure_(Haut-Rhin).svg.png"/>\r
+ </Button>-->\r
+ <HorizontalStack>\r
+ <Label Text="Update" FontColor="White" VerticalAlignment="Center" />\r
+ <Label Name="labUpdate" Text="xxxx" FontSize="16" Width="60" TextAlignment="Center" Background="DarkGreen"/>\r
+ </HorizontalStack>\r
+ <HorizontalStack>\r
+ <Label Text="Fps:" Width = "30" VerticalAlignment="Center" TextAlignment="LeftCenter"/>\r
+ <Label Name="labFps" Text="xxxx" Font="droid bold, 14"\r
+ TextAlignment="Center" Background="AoEnglish"/>\r
+ </HorizontalStack>\r
+ <HorizontalStack>\r
+ <Label Text="Min:" Width = "30" />\r
+ <Label Name="labFpsMin" Text="xxxx" Font="droid bold, 14"\r
+ TextAlignment="Center" Background="AoEnglish"/>\r
+ </HorizontalStack>\r
+ <HorizontalStack>\r
+ <Label Text="Max:" Width = "30"/>\r
+ <Label Name="labFpsMax" Text="xxxx" Font="droid bold, 14"\r
+ TextAlignment="Center" Background="AoEnglish"/>\r
+ </HorizontalStack>\r
+ </VerticalStack>\r
+\r
+ <Scroller Background="DimGray" Height="350" Width="300" \r
+ Margin="5" VerticalScrolling="true">\r
+ <VerticalStack Name="colors" VerticalAlignment="Top" Margin="5">\r
+ <ProgressBar Name="pbBar2" Width="100" Height="20" Value="50"\r
+ BorderWidth="2" BorderColor="White" Foreground="BlueCrayola" Background="DarkGray"/>\r
+ </VerticalStack>\r
+ </Scroller>\r
+\r
+ </HorizontalStack>\r
+\r
+ <Slider \r
+ Height="20" Width="300" \r
+ Background="Transparent"\r
+ VerticalAlignment="Bottom" />\r
+ </Border>\r
+</Group>
\ No newline at end of file
<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>
<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">
<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\">
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);
}
return child == null ? Bounds.Size : new Size(child.Slot.Width + 2 * (Margin),child.Slot.Height + 2 * (Margin));\r
}\r
\r
- public override void UpdateLayout (LayoutingType layoutType)\r
+ protected override void OnLayoutChanges (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
+ switch (layoutType) {\r
+ case LayoutingType.Width: \r
+ base.OnLayoutChanges (layoutType);\r
+ if (child != null) {\r
+ if (child.getBounds ().Width == 0)\r
+ child.RegisterForLayouting ((int)LayoutingType.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
+ child.RegisterForLayouting ((int)LayoutingType.X);\r
+ }\r
+ break;\r
+ case LayoutingType.Height:\r
+ base.OnLayoutChanges (layoutType);\r
+ if (child != null) {\r
+ if (child.getBounds ().Height == 0)\r
+ child.RegisterForLayouting ((int)LayoutingType.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
+ child.RegisterForLayouting ((int)LayoutingType.Y);\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
+ break;\r
+ } \r
}\r
\r
+// public override void RegisterForLayouting(int layoutType)\r
+// {\r
+// Interface.LayoutingQueue.RemoveAll (lq => lq.GraphicObject == this && (layoutType & (int)lq.LayoutType) > 0);\r
+//\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.Enqueue (LayoutingType.Width, this);\r
+// }\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.Enqueue (LayoutingType.Height, 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 override Rectangle ContextCoordinates (Rectangle r)\r
{\r
return\r
\r
public override T addChild<T> (T child)\r
{\r
+ T tmp = base.addChild (child);\r
this.RegisterForLayouting ((int)LayoutingType.PositionChildren);\r
- return base.addChild (child);\r
+ return tmp;\r
}\r
public override void removeChild (GraphicObject child)\r
{\r
}\r
}\r
}\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
+\r
public override void RegisterForLayouting (int layoutType)\r
{ \r
base.RegisterForLayouting (layoutType);\r
get { return _parent; }\r
set { _parent = value; }\r
}\r
- [XmlIgnore]public virtual bool SizeIsValid {\r
- get { return hIsValid & wIsValid; }\r
- set {\r
- hIsValid = value;\r
- wIsValid = value;\r
- }\r
- }\r
- [XmlIgnore]public virtual bool WIsValid {\r
- get { return wIsValid; }\r
- set { wIsValid = value; }\r
- }\r
- [XmlIgnore]public virtual bool HIsValid {\r
- get { return hIsValid; }\r
- set { hIsValid = value; }\r
- }\r
- [XmlIgnore]public virtual bool XIsValid {\r
- get { return xIsValid; }\r
- set { xIsValid = value; }\r
- }\r
- [XmlIgnore]public virtual bool YIsValid {\r
- get { return yIsValid; }\r
- set { yIsValid = value; }\r
- }\r
- [XmlIgnore]public virtual bool PositionIsValid {\r
- get { return xIsValid & yIsValid; }\r
- set {\r
- xIsValid = value;\r
- yIsValid = value;\r
- }\r
- }\r
- [XmlIgnore]public virtual bool LayoutIsValid {\r
- get { return SizeIsValid & PositionIsValid; }\r
- set {\r
- if (value == SizeIsValid & PositionIsValid)\r
- return;\r
-\r
- SizeIsValid = value;\r
- PositionIsValid = value;\r
-\r
- //if (!layoutIsValid && Parent != null)\r
- // Parent.layoutIsValid = false;\r
- }\r
- }\r
[XmlIgnore]public virtual Rectangle ClientRectangle {\r
get {\r
Rectangle cb = Slot.Size;\r
[XmlIgnore]public virtual IGOLibHost TopContainer {\r
get { return Parent == null ? null : Parent.TopContainer; }\r
}\r
- public virtual void InvalidateLayout ()\r
- {\r
- bmp = null;\r
- LayoutIsValid = false;\r
- }\r
public virtual Rectangle ContextCoordinates(Rectangle r){\r
return\r
Parent.ContextCoordinates (r);// + ClientRectangle.Position;\r
\r
Bounds.X = value;\r
\r
- Interface.LayoutingQueue.Enqueue (LayoutingType.X, this);\r
+ this.RegisterForLayouting ((int)LayoutingType.X);\r
}\r
}\r
[XmlAttributeAttribute()][DefaultValue(0)]\r
\r
Bounds.Y = value;\r
\r
- Interface.LayoutingQueue.Enqueue (LayoutingType.Y, this);\r
+ this.RegisterForLayouting ((int)LayoutingType.Y);\r
}\r
}\r
[XmlAttributeAttribute()][DefaultValue(0)]\r
\r
Bounds.Width = value;\r
\r
- InvalidateLayout ();\r
+ this.RegisterForLayouting ((int)LayoutingType.Width);\r
}\r
}\r
[XmlAttributeAttribute()][DefaultValue(0)]\r
\r
Bounds.Height = value;\r
\r
- InvalidateLayout ();\r
+ this.RegisterForLayouting ((int)LayoutingType.Height);\r
}\r
}\r
[XmlAttributeAttribute()][DefaultValue(false)]\r
return;\r
\r
Bounds.Width = Bounds.Height = -1;\r
- InvalidateLayout ();\r
}\r
}\r
[XmlAttributeAttribute()][DefaultValue(false)]\r
\r
public virtual void RegisterForLayouting(int layoutType)\r
{\r
+ if (Parent == null)\r
+ return;\r
+ \r
Interface.LayoutingQueue.RemoveAll (lq => lq.GraphicObject == this && (layoutType & (int)lq.LayoutType) > 0);\r
\r
if ((layoutType & (int)LayoutingType.Width) > 0) {\r
+\r
+ //force sizing to fit if parent is sizing on children\r
+ if (Parent.getBounds ().Width < 0 && Width == 0)\r
+ Width = -1;\r
+ \r
if (Bounds.Width == 0) //stretch in parent\r
Interface.LayoutingQueue.EnqueueAfterParentSizing (LayoutingType.Width, this);\r
- else //fit ou fixed\r
+ else if (Bounds.Width < 0) //fit \r
+ Interface.LayoutingQueue.EnqueueBeforeParentSizing (LayoutingType.Width, this); \r
+ else\r
Interface.LayoutingQueue.Insert (0, new LayoutingQueueItem (LayoutingType.Width, this));\r
}\r
\r
if ((layoutType & (int)LayoutingType.Height) > 0) {\r
+\r
+ //force sizing to fit if parent is sizing on children\r
+ if (Parent.getBounds ().Height < 0 && Height == 0)\r
+ Height = -1;\r
+\r
if (Bounds.Height == 0) //stretch in parent\r
Interface.LayoutingQueue.EnqueueAfterParentSizing (LayoutingType.Height, this);\r
- else//fit ou fixed\r
+ else if (Bounds.Height < 0) //fit \r
+ Interface.LayoutingQueue.EnqueueBeforeParentSizing (LayoutingType.Height, this);\r
+ else\r
Interface.LayoutingQueue.Insert (0, new LayoutingQueueItem (LayoutingType.Height, this));\r
}\r
\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
+ protected virtual void OnLayoutChanges(LayoutingType layoutType)\r
+ {\r
+ switch (layoutType) {\r
+ case LayoutingType.Width: \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
+ if (!(Parent is GenericStack))\r
+ break;\r
+ if ((Parent as GenericStack).Orientation == Orientation.Horizontal)\r
+ this.Parent.RegisterForLayouting ((int)LayoutingType.PositionChildren);\r
+ break;\r
+ case LayoutingType.Height:\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
+ if (!(Parent is GenericStack))\r
+ break;\r
+ if ((Parent as GenericStack).Orientation == Orientation.Vertical)\r
+ this.Parent.RegisterForLayouting ((int)LayoutingType.PositionChildren);\r
+ break;\r
+ } \r
+ }\r
public virtual void UpdateLayout (LayoutingType layoutType)\r
{ \r
switch (layoutType) {\r
}\r
} else\r
Slot.X = Bounds.X;\r
+\r
if (LastSlots.X == Slot.X)\r
break;\r
- //register layouting here for objects depending on this.x\r
+\r
+ bmp = null;\r
+\r
+ OnLayoutChanges (layoutType);\r
+\r
LastSlots.X = Slot.X;\r
break;\r
case LayoutingType.Y:\r
}\r
}else\r
Slot.Y = Bounds.Y;\r
+\r
if (LastSlots.Y == Slot.Y)\r
break;\r
- //register layouting here for objects depending on this.x\r
+\r
+ bmp = null;\r
+\r
+ OnLayoutChanges (layoutType);\r
+\r
LastSlots.Y = Slot.Y;\r
break;\r
case LayoutingType.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
+ bmp = null;\r
+\r
+ OnLayoutChanges (layoutType);\r
\r
LastSlots.Width = Slot.Width;\r
break;\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
+ bmp = null;\r
+\r
+ OnLayoutChanges (layoutType);\r
\r
LastSlots.Height = Slot.Height;\r
break;\r
onDraw (gr);\r
}\r
draw.Flush ();\r
+ //draw.WriteToPng ("/mnt/data/test.png");\r
}\r
}\r
\r
child.Parent = null;\r
this.RegisterForLayouting ((int)LayoutingType.Sizing);\r
}\r
+\r
public void putWidgetOnTop(GraphicObject w)\r
{\r
if (Children.Contains(w))\r
}\r
return false;\r
}\r
- public override void InvalidateLayout()\r
- {\r
- base.InvalidateLayout();\r
- foreach (GraphicObject w in Children)\r
- w.InvalidateLayout();\r
- }\r
protected override Size measureRawSize ()\r
{\r
Size tmp = new Size ();\r
return tmp;\r
}\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
\r
public override Rectangle ContextCoordinates(Rectangle r){\r
return r + ClientRectangle.Position;\r
}\r
#endregion\r
\r
- public override string ToString()\r
- {\r
- string tmp = base.ToString();\r
- foreach (GraphicObject w in Children)\r
- {\r
- tmp += "\n" + w.ToString();\r
- }\r
- return tmp;\r
- }\r
+// public override string ToString()\r
+// {\r
+// string tmp = base.ToString();\r
+// foreach (GraphicObject w in Children)\r
+// {\r
+// tmp += "\n" + w.ToString();\r
+// }\r
+// return tmp;\r
+// }\r
\r
#region IXmlSerializable\r
\r
return;\r
\r
registerForGraphicUpdate();\r
- InvalidateLayout();\r
+ this.RegisterForLayouting ((int)LayoutingType.Sizing);\r
+\r
\r
_text = value;\r
\r
_minValue = value;
- LayoutIsValid = false;
- registerForGraphicUpdate ();
}
}
[XmlAttributeAttribute()][DefaultValue(10.0)]
_maxValue = value;
- LayoutIsValid = false;
- registerForGraphicUpdate ();
}
}
[XmlAttributeAttribute()][DefaultValue(0.5)]
_smallStep = value;
- LayoutIsValid = false;
- registerForGraphicUpdate ();
}
}
[XmlAttributeAttribute()][DefaultValue(2.0)]
_bigStep = value;
- LayoutIsValid = false;
- registerForGraphicUpdate ();
}
}
[XmlAttributeAttribute()][DefaultValue(0)]
{\r
TopContainer.redrawClip.AddRectangle (base.ScreenCoordinates(Slot));\r
}\r
- public override void UpdateLayout (LayoutingType layoutType)\r
- {\r
+// public override void UpdateLayout (LayoutingType layoutType)\r
+// {\r
// base.UpdateLayout ();\r
//\r
// if (!LayoutIsValid)\r
// child.Slot.Y = 0;\r
// if (HorizontalScrolling)\r
// child.Slot.X = 0;\r
- }\r
+ //}\r
public override void Paint(ref Cairo.Context ctx, Rectangles clip = null)\r
{\r
if (!Visible)//check if necessary??\r
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);
}
public void ProcessLayouting()
{
- Debug.WriteLine ("Layouting => " + this.ToString ());
+ //Debug.WriteLine ("Layouting => " + this.ToString ());
try {
GraphicObject.UpdateLayout (LayoutType);
} catch (Exception ex) {