Win_x86
-
+.nuget
Crow.userprefs
Debug
packages
3,3,OpenTK.Graphics.GraphicsContextFlags.Default)
{
CrowInterface = new Interface ();
+
Thread t = new Thread (interfaceThread);
t.IsBackground = true;
t.Start ();
{
CrowInterface.Quit += Quit;
CrowInterface.MouseCursorChanged += CrowInterface_MouseCursorChanged;
-
+ while (CrowInterface.ClientRectangle.Size.Width == 0)
+ Thread.Sleep (5);
+
while (true) {
CrowInterface.Update ();
Thread.Sleep (5);
//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/GraphicObject", "*.crow").Concat(testFiles).ToArray();
- testFiles = Directory.GetFiles(@"Interfaces/Stack", "*.crow").ToArray();
- testFiles = Directory.GetFiles(@"Interfaces/GraphicObject", "*.crow").Concat(testFiles).ToArray();
- testFiles = Directory.GetFiles(@"Interfaces/Container", "*.crow").Concat(testFiles).ToArray();
//testFiles = Directory.GetFiles(@"Interfaces", "*.crow").Concat(testFiles).ToArray();
- GraphicObject obj = CrowInterface.LoadInterface(testFiles[5]);
+ GraphicObject obj = CrowInterface.LoadInterface(testFiles[idx]);
obj.DataSource = this;
}
--- /dev/null
+<?xml version="1.0"?>
+<Container Background="Onyx" Margin="10" Fit="true">
+ <Label Text="{fps}" Margin="10" Fit="true" Background="Mantis"/>
+</Container>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0"?>
+<Group MinimumSize="50;50" Background="Onyx" Margin="10" Width="90%" Height="90%">
+ <GraphicObject Margin="10" Width="Stretched" Height="Fit" Background="Mantis"
+ VerticalAlignment="Top"
+ MinimumSize="10;10"/>
+ <GraphicObject Margin="10" Width="Stretched" Height="Fit" Background="Mantis"
+ MinimumSize="10;10"/>
+ <GraphicObject Margin="10" Width="Stretched" Height="Fit" Background="Mantis"
+ VerticalAlignment="Bottom"
+ MinimumSize="10;10"/>
+</Group>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0"?>
+<Group Background="Onyx" Margin="10" Width="90%" Height="90%">
+ <GraphicObject Margin="10" Width="20%" Height="20%" Background="Mantis"
+ VerticalAlignment="Top"
+ HorizontalAlignment="Left"
+ MinimumSize="10;10"/>
+ <GraphicObject Margin="10" Width="20%" Height="20%" Background="Mantis"
+ VerticalAlignment="Top"
+ MinimumSize="10;10"/>
+ <GraphicObject Margin="10" Width="20%" Height="20%" Background="Mantis"
+ VerticalAlignment="Top"
+ HorizontalAlignment="Right"
+ MinimumSize="10;10"/>
+ <GraphicObject Margin="10" Width="20%" Height="20%" Background="Mantis"
+ HorizontalAlignment="Left"
+ MinimumSize="10;10"/>
+ <GraphicObject Margin="10" Width="20%" Height="20%" Background="Mantis"
+ MinimumSize="10;10"/>
+ <GraphicObject Margin="10" Width="20%" Height="20%" Background="Mantis"
+ HorizontalAlignment="Right"
+ MinimumSize="10;10"/>
+ <GraphicObject Margin="10" Width="20%" Height="20%" Background="Mantis"
+ VerticalAlignment="Bottom"
+ HorizontalAlignment="Left"
+ MinimumSize="10;10"/>
+ <GraphicObject Margin="10" Width="20%" Height="20%" Background="Mantis"
+ VerticalAlignment="Bottom"
+ MinimumSize="10;10"/>
+ <GraphicObject Margin="10" Width="20%" Height="20%" Background="Mantis"
+ VerticalAlignment="Bottom"
+ HorizontalAlignment="Right"
+ MinimumSize="10;10"/>
+</Group>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0"?>
+<Group Background="Onyx" Margin="10" Fit="true">
+ <GraphicObject Margin="10" Width="20%" Height="20%" Background="Mantis"
+ VerticalAlignment="Top"
+ HorizontalAlignment="Left"
+ MinimumSize="10;10"/>
+ <GraphicObject Margin="10" Width="20%" Height="20%" Background="Mantis"
+ VerticalAlignment="Top"
+ MinimumSize="10;10"/>
+ <GraphicObject Margin="10" Width="20%" Height="20%" Background="Mantis"
+ VerticalAlignment="Top"
+ HorizontalAlignment="Right"
+ MinimumSize="10;10"/>
+ <GraphicObject Margin="10" Width="20%" Height="20%" Background="Mantis"
+ HorizontalAlignment="Left"
+ MinimumSize="10;10"/>
+ <GraphicObject Margin="10" Width="20%" Height="20%" Background="Mantis"
+ MinimumSize="10;10"/>
+ <GraphicObject Margin="10" Width="20%" Height="20%" Background="Mantis"
+ HorizontalAlignment="Right"
+ MinimumSize="10;10"/>
+ <GraphicObject Margin="10" Width="20%" Height="20%" Background="Mantis"
+ VerticalAlignment="Bottom"
+ HorizontalAlignment="Left"
+ MinimumSize="10;10"/>
+ <GraphicObject Margin="10" Width="20%" Height="20%" Background="Mantis"
+ VerticalAlignment="Bottom"
+ MinimumSize="10;10"/>
+ <GraphicObject Margin="10" Width="20%" Height="20%" Background="Mantis"
+ VerticalAlignment="Bottom"
+ HorizontalAlignment="Right"
+ MinimumSize="10;10"/>
+</Group>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0"?>
+<Group Background="Onyx" Margin="10" Width="70%" Height="50%">
+ <GraphicObject Margin="10" Width="20%" Height="20%" Background="Mantis"
+ VerticalAlignment="Top"
+ HorizontalAlignment="Left"
+ MinimumSize="10;10"/>
+ <GraphicObject Margin="10" Width="20%" Height="20%" Background="Mantis"
+ VerticalAlignment="Top"
+ MinimumSize="10;10"/>
+ <GraphicObject Margin="10" Width="20%" Height="20%" Background="Mantis"
+ VerticalAlignment="Top"
+ HorizontalAlignment="Right"
+ MinimumSize="10;10"/>
+ <GraphicObject Margin="10" Width="100%" Height="20%" Background="Mantis"
+ HorizontalAlignment="Left"
+ MinimumSize="10;10"/>
+ <GraphicObject Margin="10" Width="20%" Height="20%" Background="Mantis"
+ MinimumSize="10;10"/>
+ <GraphicObject Margin="10" Width="20%" Height="20%" Background="Mantis"
+ HorizontalAlignment="Right"
+ MinimumSize="10;10"/>
+ <GraphicObject Margin="10" Width="20%" Height="20%" Background="Mantis"
+ VerticalAlignment="Bottom"
+ HorizontalAlignment="Left"
+ MinimumSize="10;10"/>
+ <GraphicObject Margin="10" Width="20%" Height="20%" Background="Mantis"
+ VerticalAlignment="Bottom"
+ MinimumSize="10;10"/>
+ <GraphicObject Margin="10" Width="20%" Height="20%" Background="Mantis"
+ VerticalAlignment="Bottom"
+ HorizontalAlignment="Right"
+ MinimumSize="10;10"/>
+</Group>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0"?>
+<Group Background="Onyx" Margin="10" Fit="true">
+ <Label Font="droid bold,40" Text="{fps}" Margin="10" Fit="true"/>
+ <GraphicObject Margin="10" Width="20%" Height="20%" Background="Mantis"
+ VerticalAlignment="Top"
+ MinimumSize="10;10"/>
+</Group>
\ No newline at end of file
<None Include="Interfaces\Stack\3.crow">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
+ <None Include="Interfaces\Container\3.crow">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ <None Include="Interfaces\Group\0.crow">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ <None Include="Interfaces\Group\1.crow">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ <None Include="Interfaces\Group\2.crow">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ <None Include="Interfaces\Group\3.crow">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ <None Include="Interfaces\Group\3 %28copier%29.crow">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
</ItemGroup>
<ItemGroup>
<Folder Include="Interfaces\" />
<Folder Include="image\" />
<Folder Include="Interfaces\basicTests\" />
<Folder Include="Interfaces\GraphicObject\" />
+ <Folder Include="Interfaces\Group\" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="image\tetra.png" />
get { return layoutingTries; }
set { layoutingTries = value; }
}
+ protected Size contentSize;
/// <summary> return size of content + margins </summary>
protected virtual int measureRawSize (LayoutingType lt) {
return lt == LayoutingType.Width ?
- Width == Measure.Fit ? MinimumSize.Width : (int)Width :
- Height == Measure.Fit ? MinimumSize.Height : (int)Height;
+ contentSize.Width + 2 * Margin: contentSize.Height + 2 * Margin;
}
/// <summary> By default in groups, LayoutingType.ArrangeChildren is reset </summary>
public virtual void ChildrenLayoutingConstraints(ref LayoutingType layoutType){
public event EventHandler<EventArgs> ChildrenCleared;
#endregion
- internal int maxChildrenWidth = 0;
- internal int maxChildrenHeight = 0;
internal GraphicObject largestChild = null;
internal GraphicObject tallestChild = null;
//child.Parent = null;
Children.Remove(child);
- if (child == largestChild)
+ if (child == largestChild && Width == Measure.Fit)
searchLargestChild ();
- if (child == tallestChild)
+ if (child == tallestChild && Height == Measure.Fit)
searchTallestChild ();
this.RegisterForLayouting (LayoutingType.Sizing | LayoutingType.ArrangeChildren);
}
protected override int measureRawSize (LayoutingType lt)
{
- if (Children.Count == 0)
- return base.measureRawSize (lt);
-
- if (lt == LayoutingType.Width) {
- if (largestChild == null)
- searchLargestChild ();
- if (largestChild == null){
- //if still null, not possible to determine a width
- //because all children are stretched, force first one to fit
- Children[0].Width = Measure.Fit;
- return -1;//cancel actual sizing to let child computation take place
- }
- return maxChildrenWidth + 2 * Margin;
- }else{
- if (tallestChild == null)
- searchTallestChild ();
- if (tallestChild == null) {
- Children[0].Height = Measure.Fit;
- return -1;
+ if (Children.Count > 0) {
+ if (lt == LayoutingType.Width) {
+ if (largestChild == null)
+ searchLargestChild ();
+ if (largestChild == null) {
+ //if still null, not possible to determine a width
+ //because all children are stretched, force first one to fit
+ Children [0].Width = Measure.Fit;
+ return -1;//cancel actual sizing to let child computation take place
+ }
+ } else {
+ if (tallestChild == null)
+ searchTallestChild ();
+ if (tallestChild == null) {
+ Children [0].Height = Measure.Fit;
+ return -1;
+ }
}
- return maxChildrenHeight + 2 * Margin;
}
+ return base.measureRawSize (lt);
}
public override void OnLayoutChanges (LayoutingType layoutType)
public virtual void OnChildLayoutChanges (object sender, LayoutingEventArgs arg)
{
GraphicObject g = sender as GraphicObject;
+
switch (arg.LayoutType) {
case LayoutingType.Width:
- if (g.Slot.Width > maxChildrenWidth) {
- maxChildrenWidth = g.Slot.Width;
+ if (Width != Measure.Fit)
+ return;
+ if (g.Slot.Width > contentSize.Width) {
largestChild = g;
- if (Width == Measure.Fit)
- this.RegisterForLayouting (LayoutingType.Width);
- } else if (g == largestChild) {
-
- largestChild = null;
- maxChildrenWidth = 0;
+ contentSize.Width = g.Slot.Width;
+ } else if (g == largestChild)
+ searchLargestChild ();
- if (Width == Measure.Fit)
- this.RegisterForLayouting (LayoutingType.Width);
- }
+ this.RegisterForLayouting (LayoutingType.Width);
break;
case LayoutingType.Height:
- if (g.Slot.Height > maxChildrenHeight) {
- maxChildrenHeight = g.Slot.Height;
+ if (Height != Measure.Fit)
+ return;
+ if (g.Slot.Height > contentSize.Height) {
tallestChild = g;
- if (Height == Measure.Fit)
- this.RegisterForLayouting (LayoutingType.Height);
- } else if (g == tallestChild) {
-
- tallestChild = null;
- maxChildrenHeight = 0;
+ contentSize.Height = g.Slot.Height;
+ } else if (g == tallestChild)
+ searchTallestChild ();
- if (Height == Measure.Fit)
- this.RegisterForLayouting (LayoutingType.Height);
- }
+ this.RegisterForLayouting (LayoutingType.Height);
break;
}
}
void resetChildrenMaxSize(){
largestChild = null;
tallestChild = null;
- maxChildrenWidth = 0;
- maxChildrenHeight = 0;
+ contentSize = 0;
}
void searchLargestChild(){
#if DEBUG_LAYOUTING
Debug.WriteLine("\tSearch largest child");
#endif
largestChild = null;
- maxChildrenWidth = 0;
+ contentSize.Width = 0;
for (int i = 0; i < Children.Count; i++) {
if (!Children [i].Visible)
continue;
if (children [i].RegisteredLayoutings.HasFlag (LayoutingType.Width))
continue;
- if (Children [i].Slot.Width > maxChildrenWidth) {
- maxChildrenWidth = Children [i].Slot.Width;
+ if (Children [i].Slot.Width > contentSize.Width) {
+ contentSize.Width = Children [i].Slot.Width;
largestChild = Children [i];
}
}
Debug.WriteLine("\tSearch tallest child");
#endif
tallestChild = null;
- maxChildrenHeight = 0;
+ contentSize.Height = 0;
for (int i = 0; i < Children.Count; i++) {
if (!Children [i].Visible)
continue;
if (children [i].RegisteredLayoutings.HasFlag (LayoutingType.Height))
continue;
- if (Children [i].Slot.Height > maxChildrenHeight) {
- maxChildrenHeight = Children [i].Slot.Height;
+ if (Children [i].Slot.Height > contentSize.Height) {
+ contentSize.Height = Children [i].Slot.Height;
tallestChild = Children [i];
}
}
{
if (child != null) {
+ contentSize = new Size (0, 0);
child.LayoutChanged -= OnChildLayoutChanges;
this.RegisterForLayouting (LayoutingType.Sizing);
child.Parent = null;
if (child != null) {
child.Parent = this;
child.LayoutChanged += OnChildLayoutChanges;
+ contentSize = child.Slot.Size;
child.RegisterForLayouting (LayoutingType.Sizing);
}
return child == goToFind ? true :
child == null ? false : child.Contains(goToFind);
}
- protected override int measureRawSize (LayoutingType lt)
- {
- if (child == null)
- return base.measureRawSize (lt);
- if (lt == LayoutingType.Width)
- return child.RegisteredLayoutings.HasFlag(LayoutingType.Width) ?
- -1 : child.Slot.Size.Width + 2 * Margin;
- else
- return child.RegisteredLayoutings.HasFlag(LayoutingType.Height) ?
- -1 : child.Slot.Size.Height + 2 * Margin;
- }
public override bool UpdateLayout (LayoutingType layoutType)
{
if (child != null) {
- //force sizing to fit if sizing on children and
- //child has stretched size
+ //force sizing to fit if sizing on children and child has stretched size
switch (layoutType) {
case LayoutingType.Width:
if (Width == Measure.Fit && child.Width.Units == Unit.Percent)
{
base.OnLayoutChanges (layoutType);
- switch (layoutType) {
- case LayoutingType.Width:
- if (child != null) {
- child.RegisterForLayouting (LayoutingType.X | LayoutingType.Width);
+ if (child == null)
+ return;
+
+ LayoutingType ltChild = LayoutingType.None;
+
+ if (layoutType == LayoutingType.Width) {
+ if (Width == Measure.Fit)
+ return;
+ if (child.Width.Units == Unit.Percent) {
+ ltChild |= LayoutingType.Width;
+ if (child.Width.Value < 100 && child.Left == 0)
+ ltChild |= LayoutingType.X;
}
- break;
- case LayoutingType.Height:
- if (child != null) {
- child.RegisterForLayouting (LayoutingType.Y | LayoutingType.Height);
+ } else if (layoutType == LayoutingType.Height) {
+ if (Height == Measure.Fit)
+ return;
+ if (child.Height.Units == Unit.Percent) {
+ ltChild |= LayoutingType.Height;
+ if (child.Height.Value < 100 && child.Top == 0)
+ ltChild |= LayoutingType.Y;
}
- break;
- }
+ }
+ if (ltChild == LayoutingType.None)
+ return;
+ child.RegisterForLayouting (ltChild);
}
public virtual void OnChildLayoutChanges (object sender, LayoutingEventArgs arg)
- {
- switch (arg.LayoutType) {
- case LayoutingType.X:
- break;
- case LayoutingType.Y:
- break;
- case LayoutingType.Width:
- if (Width < 0)
- this.RegisterForLayouting (LayoutingType.Width);
- break;
- case LayoutingType.Height:
- if (Height < 0)
- this.RegisterForLayouting (LayoutingType.Height);
- break;
+ {
+ GraphicObject g = sender as GraphicObject;
+
+ if (arg.LayoutType == LayoutingType.Width) {
+ if (Width != Measure.Fit)
+ return;
+ contentSize.Width = g.Slot.Width;
+ this.RegisterForLayouting (LayoutingType.Width);
+ }else if (arg.LayoutType == LayoutingType.Height){
+ if (Height != Measure.Fit)
+ return;
+ contentSize.Height = g.Slot.Height;
+ this.RegisterForLayouting (LayoutingType.Height);
}
}
protected override void onDraw (Context gr)
namespace Crow
{
+ [Flags]
public enum LayoutingType : byte
{
None = 0x00,
public static Measure Fit = new Measure(-1);
//TODO:implement stretching as 100%, not 0%
- public static Measure Stretched = new Measure(0, Unit.Percent);
+ public static Measure Stretched = new Measure(100, Unit.Percent);
public Measure (int _value, Unit _units = Unit.Pixel)
{
public override string ToString ()
{
return Value == -1 ? "Fit" :
- Value == 0 ? "Stretched" :
- Units == Unit.Percent ? Value.ToString () + "%" : Value.ToString ();
+ Units == Unit.Percent ? Value == 100 ? "Stretched" :
+ Value.ToString () + "%" : Value.ToString ();
}
public static Measure Parse(string s){
if (string.IsNullOrEmpty (s))