public OpenTKGameWindow(int _width, int _height, string _title="Crow")
: base(_width, _height, new OpenTK.Graphics.GraphicsMode(32, 24, 0, 1),
_title,GameWindowFlags.Default,DisplayDevice.GetDisplay(DisplayIndex.Second),
- 3,3,OpenTK.Graphics.GraphicsContextFlags.Debug)
+ 3,3,OpenTK.Graphics.GraphicsContextFlags.Default)
// public OpenTKGameWindow(int _width, int _height, string _title="golib")
// : base(_width, _height, new OpenTK.Graphics.GraphicsMode(32, 24, 0, 8), _title)
{
while (true) {
CrowInterface.Update ();
- Thread.Sleep (5);
+ Thread.Sleep (1);
}
}
//this.AddWidget(new test4());
KeyboardKeyDown += GOLIBTests_KeyboardKeyDown1;;
- testFiles = Directory.GetFiles(@"Interfaces/Group", "*.crow").ToArray();
+ testFiles = Directory.GetFiles(@"Interfaces/Stack", "*.crow").ToArray();
//testFiles = Directory.GetFiles(@"Interfaces/Stack", "*.crow").ToArray();
//testFiles = Directory.GetFiles(@"Interfaces/GraphicObject", "*.crow").Concat(testFiles).ToArray();
//testFiles = Directory.GetFiles(@"Interfaces", "*.crow").Concat(testFiles).ToArray();
-
+ this.Title = testFiles [idx];
GraphicObject obj = CrowInterface.LoadInterface(testFiles[idx]);
obj.DataSource = this;
if (idx == testFiles.Length)
idx = 0;
this.Title = testFiles [idx];
- GraphicObject obj = CrowInterface.LoadInterface("Interfaces/" + testFiles[idx]);
+ GraphicObject obj = CrowInterface.LoadInterface(testFiles[2]);
obj.DataSource = this;
}
--- /dev/null
+<?xml version="1.0"?>
+<HorizontalStack MinimumSize="50;50" Background="Onyx" Margin="10" Width="90%" Height="90%">
+ <GraphicObject Margin="10" Width="Stretched" Height="Fit" Background="Mantis"
+ MinimumSize="10;10"/>
+ <GraphicObject Margin="10" Width="Stretched" Height="Fit" Background="Mantis"
+ MinimumSize="10;10"/>
+ <GraphicObject Margin="10" Width="Stretched" Height="Fit" Background="Mantis"
+ MinimumSize="10;10"/>
+</HorizontalStack>
\ No newline at end of file
<?xml version="1.0"?>
<VerticalStack Background="Onyx" Margin="10" Width="90%" Height="90%">
- <GraphicObject Margin="10" Width="Stretched" Height="Fit" Background="Mantis"
+ <GraphicObject Margin="10" Width="Stretched" Height="20%" Background="Mantis"
MinimumSize="10;10"/>
- <GraphicObject Margin="10" Width="Stretched" Height="Stretched" Background="Mantis"
+ <GraphicObject Margin="10" Width="Stretched" Height="60%" Background="Mantis"
MinimumSize="10;10"/>
- <GraphicObject Margin="10" Width="Stretched" Height="Fit" Background="Mantis"
+ <GraphicObject Margin="10" Width="Stretched" Height="20%" Background="Mantis"
MinimumSize="10;10"/>
</VerticalStack>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0"?>
+<HorizontalStack Background="Onyx" Margin="10" Width="90%" Height="90%">
+ <GraphicObject Margin="10" Width="Stretched" Height="20%" Background="Mantis"
+ MinimumSize="10;10"/>
+ <GraphicObject Margin="10" Width="Stretched" Height="60%" Background="Mantis"
+ MinimumSize="10;10"/>
+ <GraphicObject Margin="10" Width="Stretched" Height="20%" Background="Mantis"
+ MinimumSize="10;10"/>
+</HorizontalStack>
\ No newline at end of file
<?xml version="1.0"?>
-<VerticalStack Background="Onyx" Margin="10" Width="90%" Height="90%">
- <GraphicObject Margin="10" Width="Stretched" Height="20%" Background="Mantis"
+<VerticalStack Background="Onyx" Margin="10" Width="90%" Height="100%">
+ <GraphicObject Margin="10" Width="Stretched" Height="Fit" Background="Mantis"
MinimumSize="10;10"/>
- <GraphicObject Margin="10" Width="Stretched" Height="20%" Background="Mantis"
+ <GraphicObject Margin="10" Width="Stretched" Height="Stretched" Background="Mantis"
MinimumSize="10;10"/>
- <GraphicObject Margin="10" Width="Stretched" Height="20%" Background="Mantis"
+ <GraphicObject Margin="10" Width="Stretched" Height="Fit" Background="Mantis"
MinimumSize="10;10"/>
</VerticalStack>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0"?>
+<HorizontalStack Background="Onyx" Margin="10" Width="90%" Height="100%">
+ <GraphicObject Margin="10" Width="Stretched" Height="Fit" Background="Mantis"
+ MinimumSize="10;10"/>
+ <GraphicObject Margin="10" Width="Stretched" Height="Stretched" Background="Mantis"
+ MinimumSize="10;10"/>
+ <GraphicObject Margin="10" Width="Stretched" Height="Fit" Background="Mantis"
+ MinimumSize="10;10"/>
+</HorizontalStack>
\ No newline at end of file
<?xml version="1.0"?>
<VerticalStack Background="Onyx" Margin="10" Width="90%" Height="90%">
- <GraphicObject Margin="10" Width="Stretched" Height="Fit" Background="Mantis"
- MinimumSize="10;10"/>
- <GraphicObject Margin="10" Width="Stretched" Height="Stretched" Background="Mantis"
- MinimumSize="10;10"/>
- <GraphicObject Margin="10" Width="Stretched" Height="Stretched" Background="Mantis"
- MinimumSize="10;10"/>
+ <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+ MinimumSize="2;2"/>
+ <GraphicObject Margin="1" Width="Stretched" Height="Stretched" Background="Mantis"
+ MinimumSize="2;2"/>
+ <GraphicObject Margin="1" Width="Stretched" Height="Stretched" Background="Mantis"
+ MinimumSize="2;2"/>
+ <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+ MinimumSize="2;2"/>
+ <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+ MinimumSize="2;2"/>
+ <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+ MinimumSize="2;2"/>
+ <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+ MinimumSize="2;2"/>
+ <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+ MinimumSize="2;2"/>
+ <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+ MinimumSize="2;2"/>
+ <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+ MinimumSize="2;2"/>
+ <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+ MinimumSize="2;2"/>
+ <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+ MinimumSize="2;2"/>
+ <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+ MinimumSize="2;2"/>
+ <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+ MinimumSize="2;2"/>
+ <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+ MinimumSize="2;2"/>
+ <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+ MinimumSize="2;2"/>
+ <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+ MinimumSize="2;2"/>
+ <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+ MinimumSize="2;2"/>
+ <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+ MinimumSize="2;2"/>
+ <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+ MinimumSize="2;2"/>
+ <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+ MinimumSize="2;2"/>
</VerticalStack>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0"?>
+<HorizontalStack Background="Onyx" Margin="10" Width="90%" Height="90%">
+ <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+ MinimumSize="2;2"/>
+ <GraphicObject Margin="1" Width="Stretched" Height="Stretched" Background="Mantis"
+ MinimumSize="2;2"/>
+ <GraphicObject Margin="1" Width="Stretched" Height="Stretched" Background="Mantis"
+ MinimumSize="2;2"/>
+ <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+ MinimumSize="2;2"/>
+ <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+ MinimumSize="2;2"/>
+ <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+ MinimumSize="2;2"/>
+ <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+ MinimumSize="2;2"/>
+ <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+ MinimumSize="2;2"/>
+ <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+ MinimumSize="2;2"/>
+ <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+ MinimumSize="2;2"/>
+ <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+ MinimumSize="2;2"/>
+ <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+ MinimumSize="2;2"/>
+ <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+ MinimumSize="2;2"/>
+ <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+ MinimumSize="2;2"/>
+ <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+ MinimumSize="2;2"/>
+ <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+ MinimumSize="2;2"/>
+ <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+ MinimumSize="2;2"/>
+ <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+ MinimumSize="2;2"/>
+ <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+ MinimumSize="2;2"/>
+ <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+ MinimumSize="2;2"/>
+ <GraphicObject Margin="1" Width="Stretched" Height="Fit" Background="Mantis"
+ MinimumSize="2;2"/>
+</HorizontalStack>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0"?>
+<VerticalStack>
+ <HorizontalStack Background="Onyx" Margin="10" Width="90%" Height="20%">
+ <Label Font="droid bold, 20" Text="{fps}" Margin="5" Fit="true" Background="Mantis"/>
+ <Label Font="droid bold, 20" Text="{fps}" Margin="5" Fit="true" Background="Mantis"/>
+ <Label Font="droid bold, 20" Text="{fps}" Margin="5" Fit="true" Background="Mantis"/>
+ <Label Font="droid bold, 20" Text="{fps}" Margin="5" Fit="true" Background="Mantis"/>
+ <Label Font="droid bold, 20" Text="{fps}" Margin="5" Fit="true" Background="Mantis"/>
+ <Label Font="droid bold, 20" Text="{fps}" Margin="5" Fit="true" Background="Mantis"/>
+ <Label Font="droid bold, 20" Text="{fps}" Margin="5" Width="100%" Background="Mantis"/>
+ <Label Font="droid bold, 20" Text="{fps}" Margin="5" Fit="true" Background="Mantis"/>
+ <Label Font="droid bold, 20" Text="{fps}" Margin="5" Fit="true" Background="Mantis"/>
+ <Label Font="droid bold, 20" Text="{fps}" Margin="5" Fit="true" Background="Mantis"/>
+ </HorizontalStack>
+ <HorizontalStack Background="Onyx" Margin="10" Width="Fit" Height="20%">
+ <Label Font="droid bold, 20" Text="{fps}" Margin="5" Fit="true" Background="Mantis"/>
+ <Label Font="droid bold, 20" Text="{fps}" Margin="5" Fit="true" Background="Mantis"/>
+ <Label Font="droid bold, 20" Text="{fps}" Margin="5" Fit="true" Background="Mantis"/>
+ <Label Font="droid bold, 20" Text="{fps}" Margin="5" Fit="true" Background="Mantis"/>
+ <Label Font="droid bold, 20" Text="{fps}" Margin="5" Fit="true" Background="Mantis"/>
+ <Label Font="droid bold, 20" Text="{fps}" Margin="5" Fit="true" Background="Mantis"/>
+ <Label Font="droid bold, 20" Text="{fps}" Margin="5" Width="100%" Background="Mantis"/>
+ <Label Font="droid bold, 20" Text="{fps}" Margin="5" Fit="true" Background="Mantis"/>
+ <Label Font="droid bold, 20" Text="{fps}" Margin="5" Fit="true" Background="Mantis"/>
+ <Label Font="droid bold, 20" Text="{fps}" Margin="5" Fit="true" Background="Mantis"/>
+ </HorizontalStack>
+</VerticalStack>
\ No newline at end of file
<None Include="Interfaces\Group\3.crow">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
- <None Include="Interfaces\Group\3 %28copier%29.crow">
+ <None Include="Interfaces\Group\4.crow">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ <None Include="Interfaces\Stack\0h.crow">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ <None Include="Interfaces\Stack\1h.crow">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ <None Include="Interfaces\Stack\2h.crow">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ <None Include="Interfaces\Stack\3h.crow">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ <None Include="Interfaces\Stack\4.crow">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
-using System;
+using System.ComponentModel;
using System.Diagnostics;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
using System.Xml.Serialization;
-using System.ComponentModel;
namespace Crow
{
- public class GenericStack : Group
+ public class GenericStack : Group
{
#region CTOR
public GenericStack()
}
protected override int measureRawSize (LayoutingType lt)
{
- int tmp = 0;
- switch (lt) {
- case LayoutingType.Width:
- if (Orientation == Orientation.Horizontal) {
- if (Children.Count > 0) {
- foreach (GraphicObject c in Children) {
- if (!c.Visible)
- continue;
- if (c.RegisteredLayoutings.HasFlag (LayoutingType.Width))
- return -1;
- tmp += c.Slot.Width + Spacing;
- }
- tmp -= Spacing;
- }
- break;
- }
- return base.measureRawSize (lt);
- case LayoutingType.Height:
- if (Orientation == Orientation.Vertical) {
- if (Children.Count > 0) {
- foreach (GraphicObject c in Children) {
- if (!c.Visible)
- continue;
- if (c.RegisteredLayoutings.HasFlag (LayoutingType.Height))
- return -1;
- tmp += c.Slot.Height + Spacing;
- }
- tmp -= Spacing;
- }
- break;
- }
- return base.measureRawSize (lt);
- }
-
- return tmp + 2 * Margin;
+ if (lt == LayoutingType.Width) {
+ if (Orientation == Orientation.Horizontal)
+ return contentSize.Width + (Children.Count - 1) * Spacing + 2 * Margin;
+ }else if (Orientation == Orientation.Vertical)
+ return contentSize.Height + (Children.Count - 1) * Spacing + 2 * Margin;
+
+ return base.measureRawSize (lt);
}
public virtual void ComputeChildrenPositions()
{
continue;
c.Slot.X = d;
d += c.Slot.Width + Spacing;
- c.RegisterForLayouting (LayoutingType.Y);
}
} else {
foreach (GraphicObject c in Children) {
continue;
c.Slot.Y = d;
d += c.Slot.Height + Spacing;
- c.RegisterForLayouting (LayoutingType.X);
}
}
bmp = null;
}
-
+ GraphicObject stretchedGO = null;
public override bool UpdateLayout (LayoutingType layoutType)
{
RegisteredLayoutings &= (~layoutType);
//this child will occupy remaining space
//if stack size policy is Fit, no child may have stretch enabled
//in the direction of stacking.
- if (Orientation == Orientation.Horizontal) {
- GraphicObject stretchedGO = null;
- int tmpWidth = Slot.Width;
- int cptChildren = 0;
- for (int i = 0; i < Children.Count; i++) {
- if (!Children [i].Visible)
- continue;
- //requeue Positionning if child is not layouted
- if (Children [i].RegisteredLayoutings.HasFlag (LayoutingType.Width))
- return false;
- cptChildren++;
- if (Children [i].Width == Measure.Stretched) {
- if (!(stretchedGO == null && Width != Measure.Fit)) {
- //change size policy of other stretched children
- Children [i].Width = Measure.Fit;
- return false;
- }
- stretchedGO = Children [i];
- if (i < Children.Count - 1)
- tmpWidth -= Spacing;
- continue;
- }
- tmpWidth -= Children [i].Slot.Width + Spacing;
- }
- if (stretchedGO != null && Width != Measure.Fit) {
- tmpWidth += (Spacing - 2 * Margin);
- if (tmpWidth < MinimumSize.Width)
- tmpWidth = MinimumSize.Width;
- else if (tmpWidth > MaximumSize.Width && MaximumSize.Width > 0)
- tmpWidth = MaximumSize.Width;
- if (stretchedGO.LastSlots.Width != tmpWidth) {
- stretchedGO.Slot.Width = tmpWidth;
- stretchedGO.bmp = null;
- #if DEBUG_LAYOUTING
- Debug.WriteLine ("\tAdjusting Width of " + stretchedGO.ToString());
- #endif
- stretchedGO.OnLayoutChanges (LayoutingType.Width);
- stretchedGO.LastSlots.Width = stretchedGO.Slot.Width;
- }
- }
- } else {
- GraphicObject stretchedGO = null;
- int tmpHeight = Slot.Height;
- int cptChildren = 0;
- for (int i = 0; i < Children.Count; i++) {
- if (!Children [i].Visible)
- continue;
- if (Children [i].RegisteredLayoutings.HasFlag (LayoutingType.Height))
- return false;
- cptChildren++;
- if (Children [i].Height == Measure.Stretched) {
- if (!(stretchedGO == null && Height != Measure.Fit)){
- Children [i].Height = Measure.Fit;
- return false;
- }
- stretchedGO = Children [i];
- if (i < Children.Count - 1)
- tmpHeight -= Spacing;
- continue;
- }
- tmpHeight -= Children[i].Slot.Height + Spacing;
- }
- if (stretchedGO != null && Height != Measure.Fit) {
- tmpHeight += (Spacing - 2 * Margin);
- if (tmpHeight < MinimumSize.Height)
- tmpHeight = MinimumSize.Height;
- else if (tmpHeight > MaximumSize.Height && MaximumSize.Height > 0)
- tmpHeight = MaximumSize.Height;
- if (stretchedGO.LastSlots.Height != tmpHeight) {
- stretchedGO.Slot.Height = tmpHeight;
- stretchedGO.bmp = null;
- #if DEBUG_LAYOUTING
- Debug.WriteLine ("\tAdjusting Height of " + stretchedGO.ToString());
- #endif
- stretchedGO.OnLayoutChanges (LayoutingType.Height);
- stretchedGO.LastSlots.Height = stretchedGO.Slot.Height;
- }
- }
- }
-
ComputeChildrenPositions ();
//if no layouting remains in queue for item, registre for redraw
public override void OnChildLayoutChanges (object sender, LayoutingEventArgs arg)
{
- base.OnChildLayoutChanges (sender, arg);
-
GraphicObject go = sender as GraphicObject;
-
+ Debug.WriteLine ("child layout change: " + go.LastSlots.ToString() + " => " + go.Slot.ToString());
switch (arg.LayoutType) {
case LayoutingType.Width:
if (Orientation == Orientation.Horizontal) {
+ if (go.Width == Measure.Stretched) {
+ if (stretchedGO == null && Width != Measure.Fit)
+ stretchedGO = go;
+ else if (stretchedGO != go) {
+ go.Slot.Width = 0;
+ go.Width = Measure.Fit;
+ return;
+ }
+ } else
+ contentSize.Width += go.Slot.Width - go.LastSlots.Width;
+
+ if (stretchedGO != null) {
+ stretchedGO.Slot.Width = this.ClientRectangle.Width - contentSize.Width - Spacing * (Children.Count - 1);
+ stretchedGO.bmp = null;
+#if DEBUG_LAYOUTING
+ Debug.WriteLine ("\tAdjusting Width of " + stretchedGO.ToString());
+#endif
+ stretchedGO.LayoutChanged -= OnChildLayoutChanges;
+ stretchedGO.OnLayoutChanges (LayoutingType.Width);
+ stretchedGO.LayoutChanged += OnChildLayoutChanges;
+ stretchedGO.LastSlots.Width = stretchedGO.Slot.Width;
+ }
+
if (Width == Measure.Fit)
this.RegisterForLayouting (LayoutingType.Width);
+
this.RegisterForLayouting (LayoutingType.ArrangeChildren);
+ return;
}
break;
case LayoutingType.Height:
if (Orientation == Orientation.Vertical) {
+ if (go.Height == Measure.Stretched) {
+ if (stretchedGO == null && Height != Measure.Fit)
+ stretchedGO = go;
+ else if (stretchedGO != go){
+ go.Slot.Height = 0;
+ go.Height = Measure.Fit;
+ return;
+ }
+ } else
+ contentSize.Height += go.Slot.Height - go.LastSlots.Height;
+
+ if (stretchedGO != null) {
+ stretchedGO.Slot.Height = this.ClientRectangle.Height - contentSize.Height - Spacing * (Children.Count -1);
+ stretchedGO.bmp = null;
+#if DEBUG_LAYOUTING
+ Debug.WriteLine ("\tAdjusting Width of " + stretchedGO.ToString());
+#endif
+ stretchedGO.LayoutChanged -= OnChildLayoutChanges;
+ stretchedGO.OnLayoutChanges (LayoutingType.Height);
+ stretchedGO.LayoutChanged += OnChildLayoutChanges;
+ stretchedGO.LastSlots.Height = stretchedGO.Slot.Height;
+ }
+
if (Height == Measure.Fit)
this.RegisterForLayouting (LayoutingType.Height);
+
this.RegisterForLayouting (LayoutingType.ArrangeChildren);
+ return;
}
break;
}
+ base.OnChildLayoutChanges (sender, arg);
}
#endregion