<Compile Include="src\ExtensionsMethods.cs" />
<Compile Include="src\Interface.cs" />
<Compile Include="src\LayoutingQueueItem.cs" />
- <Compile Include="src\LayoutingQueue.cs" />
<Compile Include="src\GraphicObjects\Spinner.cs" />
<Compile Include="src\DynAttribute.cs" />
<Compile Include="src\GraphicObjects\IValueChange.cs" />
{74289092-9F70-4941-AFCB-DFD7BE2140B6}.Release|Linux_x86.ActiveCfg = Release|Any CPU
{74289092-9F70-4941-AFCB-DFD7BE2140B6}.Release|Linux_x86.Build.0 = Release|Any CPU
{7BAE4448-E8F4-48B3-BB11-FA78E7F4506B}.Debug|Linux_x86.ActiveCfg = Debug|Any CPU
- {7BAE4448-E8F4-48B3-BB11-FA78E7F4506B}.Debug|Linux_x86.Build.0 = Debug|Any CPU
{7BAE4448-E8F4-48B3-BB11-FA78E7F4506B}.Release|Linux_x86.ActiveCfg = Release|Any CPU
- {7BAE4448-E8F4-48B3-BB11-FA78E7F4506B}.Release|Linux_x86.Build.0 = Release|Any CPU
{C2980F9B-4798-4C05-99E2-E174810F7C7B}.Debug|Linux_x86.ActiveCfg = Debug|Any CPU
{C2980F9B-4798-4C05-99E2-E174810F7C7B}.Debug|Linux_x86.Build.0 = Debug|Any CPU
{C2980F9B-4798-4C05-99E2-E174810F7C7B}.Release|Linux_x86.ActiveCfg = Release|Any CPU
{C2980F9B-4798-4C05-99E2-E174810F7C7B}.Release|Linux_x86.Build.0 = Release|Any CPU
{E9E14DB5-3C67-4E01-B5C3-4D90D7E31A2E}.Debug|Linux_x86.ActiveCfg = Debug|Any CPU
- {E9E14DB5-3C67-4E01-B5C3-4D90D7E31A2E}.Debug|Linux_x86.Build.0 = Debug|Any CPU
{E9E14DB5-3C67-4E01-B5C3-4D90D7E31A2E}.Release|Linux_x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
<Properties GitUserInfo="UsingGIT" StartupItem="Tests/Tests.csproj">
- <MonoDevelop.Ide.Workspace ActiveConfiguration="Debug|Linux_x86" />
- <MonoDevelop.Ide.Workbench ActiveDocument="src/LayoutingQueueItem.cs">
+ <MonoDevelop.Ide.Workspace ActiveConfiguration="Release|Linux_x86" />
+ <MonoDevelop.Ide.Workbench ActiveDocument="src/GraphicObjects/GenericStack.cs">
<Files>
- <File FileName="src/GraphicObjects/GraphicObject.cs" Line="589" Column="47" />
- <File FileName="Tests/Interfaces/0.crow" Line="13" Column="49" />
- <File FileName="src/LayoutingQueueItem.cs" Line="54" Column="57" />
- <File FileName="src/LayoutingQueue.cs" Line="50" Column="48" />
- <File FileName="Tests/Interfaces/testWindow.goml" Line="9" Column="55" />
- <File FileName="Templates/CheckBox.goml" Line="10" Column="46" />
- <File FileName="src/GraphicObjects/Group.cs" Line="152" Column="45" />
- <File FileName="src/OpenTKGameWindow.cs" Line="411" Column="43" />
- <File FileName="src/GraphicObjects/Slider.cs" Line="75" Column="41" />
- <File FileName="src/GraphicObjects/GenericStack.cs" Line="107" Column="7" />
+ <File FileName="src/GraphicObjects/GraphicObject.cs" Line="532" Column="1" />
+ <File FileName="src/GraphicObjects/GenericStack.cs" Line="116" Column="4" />
+ <File FileName="src/GraphicObjects/Grid.cs" Line="129" Column="24" />
+ <File FileName="src/OpenTKGameWindow.cs" Line="548" Column="35" />
+ <File FileName="src/LayoutingQueueItem.cs" Line="63" Column="1" />
+ <File FileName="src/GraphicObjects/ILayoutable.cs" Line="17" Column="50" />
+ <File FileName="src/GraphicObjects/ComboBox.cs" Line="167" Column="1" />
</Files>
+ <Pads>
+ <Pad Id="ProjectPad">
+ <State name="__root__">
+ <Node name="Crow" expanded="True" selected="True">
+ <Node name="Crow" expanded="True">
+ <Node name="src" expanded="True">
+ <Node name="GraphicObjects" expanded="True" />
+ </Node>
+ </Node>
+ <Node name="MonoDevelop.Diagram" expanded="True">
+ <Node name="src" expanded="True" />
+ </Node>
+ <Node name="MonoDevelop.GOLib" expanded="True">
+ <Node name="src" expanded="True" />
+ </Node>
+ <Node name="Tests" expanded="True">
+ <Node name="Interfaces" expanded="True" />
+ </Node>
+ <Node name="UnitTest" expanded="True" />
+ </Node>
+ </State>
+ </Pad>
+ </Pads>
</MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.DebuggingService.Breakpoints>
<BreakpointStore />
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
+ <CustomCommands>
+ <CustomCommands>
+ <Command type="Execute" command="/usr/local/lib/monodevelop/bin/MonoDevelop.exe --no-redirect" workingdir="/usr/local/lib/monodevelop/bin" />
+ </CustomCommands>
+ </CustomCommands>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
+ <CustomCommands>
+ <CustomCommands>
+ <Command type="Execute" command="/usr/local/lib/monodevelop/bin/MonoDevelop.exe --no-redirect" workingdir="/usr/local/lib/monodevelop/bin" />
+ </CustomCommands>
+ </CustomCommands>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<?xml version="1.0"?>
-<!--<GroupBox Height="-1" Width="0" Margin="5">
- <VerticalStack Height="-1" Width="0" >
- <RadioButton Caption="Radio 1" Background="Red" Width="0"/>
- <RadioButton Caption="Radio 2" IsChecked="true" />
- <RadioButton Caption="Radio 3" />
- <RadioButton Caption="Radio 1" Background="SkyBlue" Width="0"/>
- </VerticalStack>
-</GroupBox>-->
-<GroupBox Height="-1" Width="0" Margin="5">
- <VerticalStack Height="-1" Width="0" >
-<!-- <RadioButton Caption="Radio 1" Background="Red" Width="0"/>-->
- <CheckBox Caption="Radio 1" Background="Red" Width="0"/>
-<!-- <Button Background="Red" Width="0"/>-->
-<!-- <Popper Caption="Radio 1" Background="Red" Width="0"/>-->
-
-<!-- <GraphicObject Height="20" Background="Red" Width="0"/>-->
-<!-- <RadioButton Caption="Radio 3" />-->
-
- </VerticalStack>
-</GroupBox>
\ No newline at end of file
+<VerticalStack Fit="true" Background="Green" Margin="5">
+ <GraphicObject Height="20" Background="Red" Width="20"/>
+ <GraphicObject Height="20" Background="Red" Width="20"/>
+ <GraphicObject Height="20" Background="Red" Width="20"/>
+ <GraphicObject Height="20" Background="Red" Width="20"/>
+ <GraphicObject Height="20" Background="Red" Width="20"/>
+</VerticalStack>
\ No newline at end of file
}
}
- public override void UpdateLayout (LayoutingType layoutType)
- {
- CheckPendingChildrenAddition ();
- base.UpdateLayout (layoutType);
- }
+
internal void CheckPendingChildrenAddition()
{
if (pendingChildrenAddition == null)
}
bmp = null;
}
+
+ public override bool UpdateLayout (LayoutingType layoutType)
+ {
+ RegisteredLayoutings &= (~layoutType);
- public override void EnqueueForLayouting ()
- {
- if (Parent == null)
- return;
-
- base.EnqueueForLayouting ();
-
- if (RegisteredLayoutings.HasFlag(LayoutingType.PositionChildren))
- Interface.LayoutingQueue.Enqueue (LayoutingType.PositionChildren, this);
- }
- public override void UpdateLayout (LayoutingType layoutType)
- {
if (layoutType == LayoutingType.PositionChildren) {
//allow 1 child to have size to 0 if stack has fixed or streched size,
//this child will occupy remaining space
}
}
}
- }
+ }
+
ComputeChildrenPositions ();
+
//if no layouting remains in queue for item, registre for redraw
- if (RegisteredLQINodes.Count () <= 0 && bmp==null)
+ if (RegisteredLayoutings == LayoutingType.None && bmp==null)
this.RegisterForRedraw ();
- }else
- base.UpdateLayout(layoutType);
+
+ return true;
+ }
+
+ return base.UpdateLayout(layoutType);
}
public override void OnLayoutChanges (LayoutingType layoutType)
{
#endregion
#region private fields
+ LayoutingType registeredLayoutings = LayoutingType.None;
ILayoutable _parent;
string _name = "unamed";
Fill _background = Color.Transparent;
#endregion
#region ILayoutable
-
- public List<LinkedListNode<LayoutingQueueItem>> RegisteredLQINodes { get; } = new List<LinkedListNode<LayoutingQueueItem>>();
+ [XmlIgnore]public LayoutingType RegisteredLayoutings { get { return registeredLayoutings; } set { registeredLayoutings = value; } }
//TODO: it would save the recurent cost of a cast in event bubbling if parent type was GraphicObject
// or we could add to the interface the mouse events
/// <summary>
protected virtual Size measureRawSize () {
return Bounds.Size;
}
-
- void deleteLQI(int lt){
- LinkedListNode<LayoutingQueueItem>[] lqis = this.RegisteredLQINodes.Where (n => (lt & (int)n.Value.LayoutType) > 0).ToArray ();
- for (int i = 0; i < lqis.Length; i++) {
- Interface.LayoutingQueue.Remove (lqis [i]);
- RegisteredLQINodes.Remove (lqis [i]);
- }
- }
- public LayoutingType RegisteredLayoutings = 0;
-
+
public virtual void RegisterForLayouting(LayoutingType layoutType){
+ //dont set position for stretched item
if (Width == 0)
layoutType &= (~LayoutingType.X);
if (Height == 0)
layoutType &= (~LayoutingType.Y);
+
//Prevent child repositionning in a stack
//TODO:this should be done inside GenericStack
GenericStack gs = Parent as GenericStack;
else
layoutType &= (~LayoutingType.Y);
}
+
+ //prevent queueing same LayoutingType for this
+ layoutType &= (~RegisteredLayoutings);
+
if (layoutType == LayoutingType.None)
return;
- if (RegisteredLayoutings == LayoutingType.None)
- Interface.RegisteredGOForLayouting.Enqueue (this);
- RegisteredLayoutings |= (LayoutingType)layoutType;
- }
- /// <summary> clear current layoutingQueue items for object and
- /// trigger a new layouting pass for a layoutType </summary>
- public virtual void EnqueueForLayouting()
- {
- if (Parent == null)
- return;
+
#if DEBUG_LAYOUTING
- Debug.WriteLine ("RegisterForLayouting => {1}->{0}", RegisteredLayoutings.ToString(), this.ToString());
+ Debug.WriteLine ("RegisterForLayouting => {1}->{0}", layoutType, this.ToString());
#endif
- //deleteLQI (RegisteredLayoutings);
- if (RegisteredLayoutings.HasFlag(LayoutingType.Width)) {
- if (Bounds.Width == 0) //stretch in parent
- Interface.LayoutingQueue.EnqueueAfterParentSizing (LayoutingType.Width, this);
- else if (Bounds.Width < 0) //fit
- Interface.LayoutingQueue.EnqueueBeforeParentSizing (LayoutingType.Width, this);
- else
- RegisteredLQINodes.Add(
- Interface.LayoutingQueue.AddFirst (
- new LayoutingQueueItem (LayoutingType.Width, this)));
- }
-
- if (RegisteredLayoutings.HasFlag(LayoutingType.Height)) {
- if (Bounds.Height == 0) //stretch in parent
- Interface.LayoutingQueue.EnqueueAfterParentSizing (LayoutingType.Height, this);
- else if (Bounds.Height < 0) //fit
- Interface.LayoutingQueue.EnqueueBeforeParentSizing (LayoutingType.Height, this);
- else{
- RegisteredLQINodes.Add(
- Interface.LayoutingQueue.AddFirst (
- new LayoutingQueueItem (LayoutingType.Height, this)));
-
- }
- }
-
- if (RegisteredLayoutings.HasFlag(LayoutingType.X))
- //for x positionning, sizing of parent and this have to be done
- Interface.LayoutingQueue.EnqueueAfterThisAndParentSizing (LayoutingType.X, this);
-
- if (RegisteredLayoutings.HasFlag(LayoutingType.Y))
- //for x positionning, sizing of parent and this have to be done
- Interface.LayoutingQueue.EnqueueAfterThisAndParentSizing (LayoutingType.Y, this);
+ if (layoutType.HasFlag (LayoutingType.Width))
+ Interface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Width, this));
+ if (layoutType.HasFlag (LayoutingType.Height))
+ Interface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Height, this));
+ if (layoutType.HasFlag (LayoutingType.X))
+ Interface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.X, this));
+ if (layoutType.HasFlag (LayoutingType.Y))
+ Interface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.Y, this));
+ if (layoutType.HasFlag (LayoutingType.PositionChildren))
+ Interface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.PositionChildren, this));
}
-
/// <summary> trigger dependant sizing component update </summary>
public virtual void OnLayoutChanges(LayoutingType layoutType)
{
- if (Parent==null)
- return;
#if DEBUG_LAYOUTING
Debug.WriteLine ("Layout change: " + this.ToString () + ":" + LastSlots.ToString() + "=>" + Slot.ToString ());
#endif
-
+
switch (layoutType) {
case LayoutingType.Width:
if (Width != 0 && Parent.getBounds().Width >=0) //update position in parent
}
LayoutChanged.Raise (this, new LayoutingEventArgs (layoutType));
}
+
/// <summary> Update layout component, this is where the computation of alignement
/// and size take place </summary>
- public virtual void UpdateLayout (LayoutingType layoutType)
- {
+ /// <returns><c>true</c>, if layouting was possible, <c>false</c> if conditions were not
+ /// met and LQI has to be re-queued</returns>
+ public virtual bool UpdateLayout (LayoutingType layoutType)
+ {
+ //unset bit, it would be reset if LQI is re-queued
+ registeredLayoutings &= (~layoutType);
+
switch (layoutType) {
case LayoutingType.X:
if (Bounds.X == 0) {
+
+ if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Width))
+ return false;
+
switch (HorizontalAlignment) {
case HorizontalAlignment.Left:
Slot.X = 0;
break;
case LayoutingType.Y:
if (Bounds.Y == 0) {
+
+ if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Height))
+ return false;
+
switch (VerticalAlignment) {
- case VerticalAlignment.Top:
+ case VerticalAlignment.Top://this could be processed even if parent Height is not known
Slot.Y = 0;
break;
case VerticalAlignment.Bottom:
Slot.Width = Width;
else if (Width < 0)
Slot.Width = measureRawSize ().Width;
+ else if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Width))
+ return false;
else
Slot.Width = Parent.ClientRectangle.Width;
Slot.Height = Height;
else if (Height < 0)
Slot.Height = measureRawSize ().Height;
+ else if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Width))
+ return false;
else
Slot.Height = Parent.ClientRectangle.Height;
else if (Slot.Height > MaximumSize.Height && MaximumSize.Height > 0)
Slot.Height = MaximumSize.Height;
-
if (LastSlots.Height == Slot.Height)
break;
LastSlots.Height = Slot.Height;
break;
}
+
//if no layouting remains in queue for item, registre for redraw
- if (this.RegisteredLQINodes.Count () <= 0 && bmp == null)
+ if (this.registeredLayoutings == LayoutingType.None && bmp == null)
this.RegisterForRedraw ();
+
+ return true;
}
#endregion
}
}
- public override void EnqueueForLayouting ()
- {
- base.EnqueueForLayouting ();
- if (RegisteredLayoutings.HasFlag(LayoutingType.PositionChildren))
- Interface.LayoutingQueue.Enqueue (LayoutingType.PositionChildren, this);
- }
- public override void UpdateLayout (LayoutingType layoutType)
- {
+ public override bool UpdateLayout (LayoutingType layoutType)
+ {
+ RegisteredLayoutings &= (~layoutType);
+
if (layoutType == LayoutingType.PositionChildren) {
+
ComputeChildrenPositions ();
+
//if no layouting remains in queue for item, registre for redraw
- if (RegisteredLQINodes.Count () <= 0 && bmp==null)
+ if (RegisteredLayoutings == LayoutingType.None && bmp==null)
this.RegisterForRedraw ();
- }else
- base.UpdateLayout(layoutType);
+
+ return true;
+ }
+
+ return base.UpdateLayout(layoutType);
}
#endregion
IGOLibHost HostContainer { get; }
- List<LinkedListNode<LayoutingQueueItem>> RegisteredLQINodes { get; }
+ LayoutingType RegisteredLayoutings { get; set; }
void RegisterForLayouting(LayoutingType layoutType);
- void UpdateLayout(LayoutingType layoutType);
+ bool UpdateLayout(LayoutingType layoutType);
Rectangle ContextCoordinates(Rectangle r);
/// <summary> Threshold to catch borders for sizing </summary>
public static int BorderThreshold = 5;
- public static LayoutingQueue LayoutingQueue = new LayoutingQueue ();
- public static Queue<GraphicObject> RegisteredGOForLayouting = new Queue<GraphicObject>();
+ public static Queue<LayoutingQueueItem> LayoutingQueue = new Queue<LayoutingQueueItem>();
#region Load/Save
- //internal static List<DynAttribute> Bindings;
-
public static void Save<T> (string file, T graphicObject)
{
{
LayoutType = _layoutType;
GraphicObject = _graphicObject;
+ GraphicObject.RegisteredLayoutings |= LayoutType;
}
public void ProcessLayouting()
#if DEBUG_LAYOUTING
Debug.WriteLine ("Layouting => " + this.ToString ());
#endif
+
try {
if (GraphicObject.Parent == null){
Debug.WriteLine("ERROR: processLayouting, no parent for: " + GraphicObject.ToString());
return;
}
- GraphicObject.UpdateLayout (LayoutType);
+ if (!GraphicObject.UpdateLayout (LayoutType))
+ Interface.LayoutingQueue.Enqueue(this);
} catch (Exception ex) {
Debug.WriteLine ("Layouting error: " + ex.ToString ());
}
#endif
//Debug.WriteLine ("======= Layouting queue start =======");
- while (Interface.RegisteredGOForLayouting.Count > 0){
- while (Interface.RegisteredGOForLayouting.Count > 0){
- GraphicObject go = Interface.RegisteredGOForLayouting.Dequeue ();
- go.EnqueueForLayouting ();
- go.RegisteredLayoutings = LayoutingType.None;
- }
- while (Interface.LayoutingQueue.First != null) {
- LayoutingQueueItem lqi = Interface.LayoutingQueue.Dequeue ();
- lqi.ProcessLayouting ();
- }
+ while (Interface.LayoutingQueue.Count > 0) {
+ LayoutingQueueItem lqi = Interface.LayoutingQueue.Dequeue ();
+ lqi.ProcessLayouting ();
}
#if MEASURE_TIME
#endregion
#region ILayoutable implementation
-
- //TODO:uneeded list, should be removed
- public List<LinkedListNode<LayoutingQueueItem>> RegisteredLQINodes { get; } = new List<LinkedListNode<LayoutingQueueItem>>();
+ public LayoutingType RegisteredLayoutings {
+ get { return LayoutingType.None; }
+ set { throw new NotImplementedException (); }
+ }
public void RegisterForLayouting (LayoutingType layoutType) { throw new NotImplementedException (); }
- public void UpdateLayout (LayoutingType layoutType) { throw new NotImplementedException (); }
+ public bool UpdateLayout (LayoutingType layoutType) { throw new NotImplementedException (); }
public Rectangle ContextCoordinates (Rectangle r)
{
return r;