]> O.S.I.I.S - jp/crow.git/commitdiff
testing tabview, ChildLayoutConstraints
authorjpbruyere <jp.bruyere@hotmail.com>
Sun, 14 Feb 2016 18:27:00 +0000 (19:27 +0100)
committerjpbruyere <jp.bruyere@hotmail.com>
Sun, 14 Feb 2016 18:27:00 +0000 (19:27 +0100)
18 files changed:
Crow.csproj
Crow.sln
Templates/TabItem.crow [new file with mode: 0644]
Templates/TreeItem.crow [new file with mode: 0644]
Templates/TreeViewItem.crow [deleted file]
Tests/GOLIBTests.cs
Tests/Interfaces/0.crow
Tests/Interfaces/testExpandable.goml
Tests/Interfaces/testTabView.crow [new file with mode: 0644]
Tests/Tests.csproj
src/GraphicObjects/GenericStack.cs
src/GraphicObjects/GraphicObject.cs
src/GraphicObjects/Grid.cs
src/GraphicObjects/Group.cs
src/GraphicObjects/TabItem.cs [new file with mode: 0644]
src/GraphicObjects/TabView.cs
src/LayoutingQueueItem.cs
src/OpenTKGameWindow.cs

index 9490cde5f43fb7f65b92f782bff42823b3a1f804..8c35fe4ed7dbbc9818b16aaf1b5188f015d92163 100644 (file)
@@ -45,7 +45,7 @@
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <OutputPath>bin\Debug</OutputPath>
-    <DefineConstants>DEBUG_LAYOUTING0;TRACE;DEBUG;__linux__;MEASURE_TIME;DEBUG_LOAD_TIME0;DEBUG_BINDING0;DEBUG_CLIP_RECTANGLE0</DefineConstants>
+    <DefineConstants>DEBUG_LAYOUTING0;TRACE;DEBUG;__linux__;MEASURE_TIME;DEBUG_LOAD_TIME0;DEBUG_BINDING;DEBUG_CLIP_RECTANGLE0</DefineConstants>
   </PropertyGroup>
   <!--  <PropertyGroup Condition=" '$(Platform)' == 'Linux_x86' ">
     <DefineConstants>__linux__</DefineConstants>
     <Compile Include="src\GraphicObjects\Splitter.cs" />
     <Compile Include="src\GraphicObjects\TreeView.cs" />
     <Compile Include="src\GraphicObjects\TabView.cs" />
+    <Compile Include="src\GraphicObjects\TabItem.cs" />
   </ItemGroup>
   <ItemGroup>
     <Reference Include="System" />
       <LogicalName>Crow.image.crow0.svg</LogicalName>
     </EmbeddedResource>
     <EmbeddedResource Include="Templates\TreeView.crow" />
-    <EmbeddedResource Include="Templates\TreeViewItem.crow" />
+    <EmbeddedResource Include="Templates\TabItem.crow" />
+    <EmbeddedResource Include="Templates\TreeItem.crow" />
   </ItemGroup>
   <ItemGroup>
     <None Include="README.md" />
index 0172fbe1570893aeb1aa9498bd9a4f215bea220b..27ea466c572546e593711bacceef297d0fa9dddf 100644 (file)
--- a/Crow.sln
+++ b/Crow.sln
@@ -41,6 +41,18 @@ Global
                $0.DotNetNamingPolicy = $2
                $2.DirectoryNamespaceAssociation = None
                $2.ResourceNamePolicy = FileFormatDefault
+               $0.TextStylePolicy = $3
+               $3.FileWidth = 120
+               $3.TabsToSpaces = False
+               $3.EolMarker = Unix
+               $3.inheritsSet = VisualStudio
+               $3.inheritsScope = text/plain
+               $3.scope = text/x-csharp
+               $0.CSharpFormattingPolicy = $4
+               $4.AfterDelegateDeclarationParameterComma = True
+               $4.inheritsSet = Mono
+               $4.inheritsScope = text/x-csharp
+               $4.scope = text/x-csharp
                description = @C.R.O.W. Collaborative Radiant Open Widgets\n\nA pure c# toolkit with XML definition of interface with binding and\ndynamic delegates
                version = 0.4
        EndGlobalSection
diff --git a/Templates/TabItem.crow b/Templates/TabItem.crow
new file mode 100644 (file)
index 0000000..683c8e5
--- /dev/null
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<GenericStack Margin="2" Background="DarkRed" Orientation="Vertical"
+               Width="{../../TemplatedWidth}" Height="{../../TemplatedHeight}">
+       <Label Name="TabTitle" Width="-1" Background="BlueCrayola"
+               Text="{../../Caption}"
+               Height="{../../../TabThickness}"
+               Left="{../../TabOffset}"
+               LayoutChanged="../../../TabTitleLayoutChanged"/>
+       <Container Background="White" Margin="2"
+               Name="Content" Width="{../../../TemplatedWidth}" Height="{../../../TemplatedHeight}"/>
+</GenericStack>
+
diff --git a/Templates/TreeItem.crow b/Templates/TreeItem.crow
new file mode 100644 (file)
index 0000000..037736a
--- /dev/null
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8" ?>\r
+<!--<Container Fit="true" Margin="0" Focusable="true" Background="Gray"\r
+               MouseEnter="{Background=SteelBlue}"\r
+               MouseLeave="{Background=Gray}">\r
+       <Label Text="{}"/>\r
+</Container>-->\r
+<Expandable Caption="{}">\r
+       <Template>\r
+               <Border BorderWidth="1" Foreground="LightGray" Height="{../TemplatedHeight}" Width="{../TemplatedWidth}" \r
+                       MouseClick="../onMouseClick">\r
+                       <VerticalStack Height="{../../TemplatedHeight}" Width="{../../TemplatedWidth}">\r
+                               <HorizontalStack Spacing="1" Height="-1" Width="{../../../TemplatedWidth}">\r
+                                       <Image Margin="2" Width="12" Height="12" Path="{../../../../Image}" SvgSub="{../../../../SvgSub}"/>\r
+                                       <Label Text="{../../../../Caption}" Width="{../../../../TemplatedWidth}"/>\r
+                               </HorizontalStack>\r
+                               <Container Name="Content" Visible="false" Height="{../../../TemplatedHeight}" Width="{../../../TemplatedWidth}"/>\r
+                       </VerticalStack>\r
+               </Border>\r
+       </Template>\r
+</Expandable>\r
+<!--           <VerticalStack\r
+                       Height="{../TemplatedHeight}" Width="{../TemplatedWidth}"\r
+                       MouseClick="../onMouseClick">\r
+                       <HorizontalStack Spacing="1" Height="-1" Width="{../../TemplatedWidth}">\r
+                               <Image Margin="2" Width="12" Height="12" Path="{../../../Image}" SvgSub="{../../../SvgSub}"/>\r
+                               <Label Text="{../../../Caption}" Width="{../../../TemplatedWidth}"/>\r
+                       </HorizontalStack>\r
+                       <ListBox Name="Content" Visible="false"\r
+                               Height="-1" Width="{../../TemplatedWidth}"/>\r
+               </VerticalStack>-->\r
+\r
diff --git a/Templates/TreeViewItem.crow b/Templates/TreeViewItem.crow
deleted file mode 100644 (file)
index 0cb4417..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--<Container Fit="true" Margin="0" Focusable="true" Background="Gray"
-               MouseEnter="{Background=SteelBlue}"
-               MouseLeave="{Background=Gray}">
-       <Label Text="{}"/>
-</Container>-->
-<Expandable Caption="{}">
-       <Template>
-               <Border BorderWidth="1" Foreground="LightGray" Height="{../TemplatedHeight}" Width="{../TemplatedWidth}" 
-                       MouseClick="../onMouseClick">
-                       <VerticalStack Height="{../../TemplatedHeight}" Width="{../../TemplatedWidth}">
-                               <HorizontalStack Spacing="1" Height="-1" Width="{../../../TemplatedWidth}">
-                                       <Image Margin="2" Width="12" Height="12" Path="{../../../../Image}" SvgSub="{../../../../SvgSub}"/>
-                                       <Label Text="{../../../../Caption}" Width="{../../../../TemplatedWidth}"/>
-                               </HorizontalStack>
-                               <Container Name="Content" Visible="false" Height="{../../../TemplatedHeight}" Width="{../../../TemplatedWidth}"/>
-                       </VerticalStack>
-               </Border>
-       </Template>
-</Expandable>
-<!--           <VerticalStack
-                       Height="{../TemplatedHeight}" Width="{../TemplatedWidth}"
-                       MouseClick="../onMouseClick">
-                       <HorizontalStack Spacing="1" Height="-1" Width="{../../TemplatedWidth}">
-                               <Image Margin="2" Width="12" Height="12" Path="{../../../Image}" SvgSub="{../../../SvgSub}"/>
-                               <Label Text="{../../../Caption}" Width="{../../../TemplatedWidth}"/>
-                       </HorizontalStack>
-                       <ListBox Name="Content" Visible="false"
-                               Height="-1" Width="{../../TemplatedWidth}"/>
-               </VerticalStack>-->
-
index 832cf151d3cfec63081d5c432b34d18e354e299e..a12885ffe5fe2f0623212cff016e6d960b87f1a7 100644 (file)
@@ -37,11 +37,13 @@ namespace test
                int frameCpt = 0;
                int idx = 0;
                string[] testFiles = {
+//                     "testTabView.crow",
+                       "testExpandable.goml",
+                       "0.crow",
                        "testImage.crow",
                        "testOutOfClipUpdate.crow",
                        "test_Listbox.goml",
                        "testTreeView.crow",
-                       "0.crow",
                        "1.crow",
                        "testWindow.goml",
                        "clip4.crow",
@@ -55,7 +57,6 @@ namespace test
                        "testTextBox.crow",
                        "testColorList.crow",
 
-                       "testExpandable.goml",
                        "4.crow",
                        "testSpinner.goml",
                        "testScrollbar.goml",
index 011148a78a52725ec774e993d2cb989eb9590533..d067f4fff9b329cba6d184255294e204669b7404 100755 (executable)
@@ -1,9 +1,10 @@
 <?xml version="1.0"?>
 <!--<Label Text="test" Background="BlueCrayola"/>-->
 <!--<GraphicObject Width="10" Height="10" Background="Red"/>-->
-<VerticalStack Fit="true" Margin="2" Spacing="2">
-       <ProgressBar CornerRadius="5" Background="DimGray" Margin="1" Maximum="1000" Value="{fps}" Width="200" Height="15"/>
-       <Label Text="test" Background="BlueCrayola"/>
+<VerticalStack Width="400" Height="400" Margin="2" Spacing="2">
+       <Label Left="20" Text="test" Background="BlueCrayola"/>
+       <GraphicObject Background="LimeGreen" Width="300" Height="300"/>
+<!--   <ProgressBar CornerRadius="5" Background="DimGray" Margin="1" Maximum="1000" Value="{fps}" Width="200" Height="15"/>
        <RadioButton Caption="test radiobutton"/>
        <Image Width="50" Height="50" Background="vgradient|0:SkyBlue|1:White" Path="#Tests.image.crow0.svg"/>  
        <Button Caption="test button"/>
@@ -12,7 +13,7 @@
        <Border CornerRadius="5" Background="DimGray" Fit="true" >
                <Trend HighThreshold="{fpsMax}" LowThreshold="{fpsMin}" NbValues="5"
                        Height="100" Width="400" NewValue="{fps}" Name="trend" Maximum="600" Foreground="White"/>
-       </Border>
+       </Border>-->
 </VerticalStack>
 <!--           <HorizontalStack Fit="true">
                <Label Text="Memory:" Width="50" TextAlignment="Right"/>
index a2fb1e7880c148cca8cd3e8d8446e9155a604304..d46f4831f0c30f1041acb5a0b355bb47e652c0ec 100755 (executable)
@@ -5,9 +5,9 @@
                        <CheckBox Name="chk2" IsChecked="true"/>
                        <CheckBox Name="chk3"/>
                        <CheckBox Name="chk4"/>
-                       <HorizontalStack Fit="true" Margin="2" Background="Blue">
+<!--                   <HorizontalStack Fit="true" Margin="2" Background="Blue">
                                <Label Name="captionFps" Text="Fps:" Width="30" TextAlignment="Right"/>
                                <Label Name="valueFps" Text="{fps}" Font="droid , 12" Width="-1" TextAlignment="Center" Background="AoEnglish"/>
-                       </HorizontalStack>
+                       </HorizontalStack>-->
                </VerticalStack>
 </Expandable>
diff --git a/Tests/Interfaces/testTabView.crow b/Tests/Interfaces/testTabView.crow
new file mode 100644 (file)
index 0000000..4f829e9
--- /dev/null
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<TabView Orientation="Horizontal" Background="Gray">
+       <TabItem Caption="tab 1">
+               <Label Text="tab content test 1"/>
+       </TabItem>
+       <TabItem Caption="tab 2">
+               <Label Text="tab content test 2"/>
+       </TabItem>
+
+</TabView>
+
index 1d7bbe1803bd0bfaef41932e1257654ac73a1b4f..91ebc43a9e8bd3f9637da7153c27742e3126b0b3 100644 (file)
     <None Include="Interfaces\testOutOfClipUpdate.crow">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
+    <None Include="Interfaces\testTabView.crow">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
   </ItemGroup>
   <ItemGroup>
     <Folder Include="Interfaces\" />
index c828298819c28e2d565f4cc3495a33c0074cfcb5..ed90486d2fe5ef850379345ae5a9ff9c995ccbed 100644 (file)
@@ -10,12 +10,6 @@ namespace Crow
 {
     public class GenericStack : Group
     {
-               internal class Page
-               {
-                       public byte[] bmp;
-                       public int Size;
-               }
-
                #region CTOR
                public GenericStack()
                        : base()
@@ -28,18 +22,6 @@ namespace Crow
         Orientation _orientation;
                #endregion
 
-               public override T AddChild<T> (T child)
-               {
-                       T tmp = base.AddChild (child);
-                       this.RegisterForLayouting (LayoutingType.PositionChildren);
-                       return tmp;
-               }
-               public override void RemoveChild (GraphicObject child)
-               {
-                       base.RemoveChild (child);
-                       this.RegisterForLayouting (LayoutingType.PositionChildren);
-               }
-
                #region Public Properties
         [XmlAttributeAttribute()][DefaultValue(2)]
         public int Spacing
@@ -60,6 +42,15 @@ namespace Crow
         }
                #endregion
 
+               public override void ChildrenLayoutingConstraints (ref LayoutingType layoutType)
+               {
+                       //Prevent child repositionning in the direction of stacking
+                       if (Orientation == Orientation.Horizontal)
+                               layoutType &= (~LayoutingType.X);
+                       else
+                               layoutType &= (~LayoutingType.Y);                       
+               }
+
                #region GraphicObject Overrides
                protected override Size measureRawSize ()
                {
@@ -120,7 +111,7 @@ namespace Crow
         {
                        RegisteredLayoutings &= (~layoutType);
 
-                       if (layoutType == LayoutingType.PositionChildren) {
+                       if (layoutType == LayoutingType.ArrangeChildren) {
                                //allow 1 child to have size to 0 if stack has fixed or streched size policy,
                                //this child will occupy remaining space
                                //if stack size policy is Fit, no child may have stretch enabled
@@ -221,14 +212,14 @@ namespace Crow
                                if (Orientation == Orientation.Horizontal) {
                                        if (this.Bounds.Width < 0)
                                                this.RegisterForLayouting (LayoutingType.Width);
-                                       this.RegisterForLayouting (LayoutingType.PositionChildren);
+                                       this.RegisterForLayouting (LayoutingType.ArrangeChildren);
                                }
                                break;
                        case LayoutingType.Height:
                                if (Orientation == Orientation.Vertical) {
                                        if (this.Bounds.Height < 0)
                                                this.RegisterForLayouting (LayoutingType.Height);
-                                       this.RegisterForLayouting (LayoutingType.PositionChildren);
+                                       this.RegisterForLayouting (LayoutingType.ArrangeChildren);
                                }
                                break;
                        }
index ba11bd772166cc539139e9d49e5d69f2d5210970..f2c50e6fef67b077523946a6d43bc4d11f5f7da2 100644 (file)
@@ -376,20 +376,17 @@ namespace Crow
                                if (!_isVisible && this.Contains (HostContainer.hoverWidget))
                                        HostContainer.hoverWidget = null;
 
+                               if (Parent is GraphicObject)
+                                       Parent.RegisterForLayouting (LayoutingType.Sizing);
                                if (Parent is GenericStack)
-                                       Parent.RegisterForLayouting (LayoutingType.Sizing | LayoutingType.PositionChildren);
-
+                                       Parent.RegisterForLayouting (LayoutingType.ArrangeChildren);
                                RegisterForLayouting (LayoutingType.Sizing);
 
                                RegisterForRedraw ();
+
                                NotifyValueChanged ("Visible", _isVisible);
                        }
                }
-               //TODO: only used in group, should be removed from base go object
-               [XmlIgnore]public virtual bool DrawingIsValid
-               { get { return bmp == null ? 
-                               false : 
-                               true; } }
                [XmlAttributeAttribute()][DefaultValue("0;0")]
                public virtual Size MaximumSize {
                        get { return _maximumSize; }
@@ -623,12 +620,14 @@ namespace Crow
                        get { return layoutingTries; }
                        set { layoutingTries = value; }
                }
-
                /// <summary> return size of content + margins </summary>
                protected virtual Size measureRawSize () {
                        return Bounds.Size;
                }
-                       
+               /// <summary> By default in groups, LayoutingType.ArrangeChildren is reset </summary>
+               public virtual void ChildrenLayoutingConstraints(ref LayoutingType layoutType){
+                       layoutType &= (~LayoutingType.ArrangeChildren);
+               }       
                public virtual void RegisterForLayouting(LayoutingType layoutType){
                        if (Parent == null)
                                return;
@@ -638,15 +637,9 @@ namespace Crow
                        if (Height == 0)
                                layoutType &= (~LayoutingType.Y);
 
-                       //Prevent child repositionning in a stack
-                       //TODO:this should be done inside GenericStack
-                       GenericStack gs = Parent as GenericStack;
-                       if (gs != null) {
-                               if (gs.Orientation == Orientation.Horizontal)
-                                       layoutType &= (~LayoutingType.X);
-                               else
-                                       layoutType &= (~LayoutingType.Y);
-                       }
+                       //apply constraints depending on parent type
+                       if (Parent is GraphicObject)
+                               (Parent as GraphicObject).ChildrenLayoutingConstraints (ref layoutType);
 
                        //prevent queueing same LayoutingType for this
                        layoutType &= (~RegisteredLayoutings);
@@ -667,8 +660,8 @@ namespace Crow
                                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));
+                       if (layoutType.HasFlag (LayoutingType.ArrangeChildren))
+                               Interface.LayoutingQueue.Enqueue (new LayoutingQueueItem (LayoutingType.ArrangeChildren, this));
                }
 
                /// <summary> trigger dependant sizing component update </summary>
@@ -1009,11 +1002,11 @@ namespace Crow
                #region Binding
                public virtual void ResolveBindings()
                {
+                       if (Bindings.Count == 0)
+                               return;
                        #if DEBUG_BINDING
                        Debug.WriteLine ("ResolveBinding => " + this.ToString ());
                        #endif
-                       if (Bindings.Count == 0)
-                               return;
                        Dictionary<object,List<Binding>> resolved = new Dictionary<object, List<Binding>>();
                        foreach (Binding b in Bindings) {
                                if (b.Resolved)
@@ -1024,12 +1017,14 @@ namespace Crow
                                                continue;
                                        }
                                }
-                               if (!b.FindTarget ())
+                               if (!b.FindTarget ()) {
+                                       Debug.WriteLine ("BINDING ERROR: target not found => " + b.ToString());
                                        continue;
+                               }
                                if (b.Source.Member.MemberType == MemberTypes.Event) {
                                        //register handler for event
                                        if (b.Target.Method == null) {
-                                               Debug.WriteLine ("Handler Method not found: " + b.Expression);
+                                               Debug.WriteLine ("Handler Method not found: " + b.ToString());
                                                continue;
                                        }
 
@@ -1037,6 +1032,9 @@ namespace Crow
                                        Delegate del = Delegate.CreateDelegate (b.Source.Event.EventHandlerType, b.Target.Instance, b.Target.Method);
                                        addHandler.Invoke (this, new object[] { del });
                                        b.Resolved = true;
+                                       #if DEBUG_BINDING
+                                       Debug.WriteLine ("\tHandler binded => " + b.ToString());
+                                       #endif
                                        continue;
                                }
                                List<Binding> bindings = null;
@@ -1046,6 +1044,9 @@ namespace Crow
                                }
                                bindings.Add (b);
                                b.Resolved = true;
+                               #if DEBUG_BINDING
+                               Debug.WriteLine ("\tmarked as resolved => " + b.ToString());
+                               #endif
                        }
 
                        MethodInfo stringEquals = typeof(string).GetMethod
@@ -1332,6 +1333,9 @@ namespace Crow
                        addHandler.Invoke(this, new object[] {del});
 
                        binding.Resolved = true;
+                       #if DEBUG_BINDING
+                       Debug.WriteLine ("\tCompiled Event Source => " + binding.ToString());
+                       #endif
                }
                /// <summary>
                /// Remove dynamic delegates by ids from dataSource
index c242899f2425d2d1c54e1d41e66837525658aecd..281f4ae0c51e9aa0bbdb9929c8258f29e748e280 100644 (file)
@@ -32,13 +32,13 @@ namespace Crow
                public override T AddChild<T> (T child)
                {
                        T tmp = base.AddChild (child);
-                       this.RegisterForLayouting (LayoutingType.PositionChildren);
+                       this.RegisterForLayouting (LayoutingType.ArrangeChildren);
                        return tmp;
                }
                public override void RemoveChild (GraphicObject child)
                {
                        base.RemoveChild (child);
-                       this.RegisterForLayouting (LayoutingType.PositionChildren);
+                       this.RegisterForLayouting (LayoutingType.ArrangeChildren);
                }
 
                #region Public Properties
@@ -59,7 +59,7 @@ namespace Crow
                                _columnCount = value; 
 
                                NotifyValueChanged ("ColumnCount", ColumnCount);
-                               this.RegisterForLayouting (LayoutingType.PositionChildren);
+                               this.RegisterForLayouting (LayoutingType.ArrangeChildren);
                        }
         }
                [XmlAttributeAttribute()][DefaultValue(1)]
@@ -73,7 +73,7 @@ namespace Crow
                                _rowCount = value; 
 
                                NotifyValueChanged ("RowCount", RowCount);
-                               this.RegisterForLayouting (LayoutingType.PositionChildren);
+                               this.RegisterForLayouting (LayoutingType.ArrangeChildren);
                        }
                }
                public virtual int CaseWidth {
@@ -130,7 +130,7 @@ namespace Crow
                {
                        RegisteredLayoutings &= (~layoutType);
 
-                       if (layoutType == LayoutingType.PositionChildren) {                             
+                       if (layoutType == LayoutingType.ArrangeChildren) {                              
 
                                ComputeChildrenPositions ();
 
index 32e45fef08b94bab70ecd3dfdc12224977a322c8..cb9ac8468bf67bd3f8d2ef30e8135f16237674be 100644 (file)
@@ -45,7 +45,7 @@ namespace Crow
                        GraphicObject g = child as GraphicObject;
             Children.Add(g);
             g.Parent = this as GraphicObject;            
-                       g.RegisterForLayouting (LayoutingType.Sizing);
+                       g.RegisterForLayouting (LayoutingType.Sizing | LayoutingType.ArrangeChildren);
                        g.LayoutChanged += OnChildLayoutChanges;
             return (T)child;
         }
@@ -55,7 +55,13 @@ namespace Crow
                        child.ClearBinding ();
                        child.Parent = null;
             Children.Remove(child);
-                       this.RegisterForLayouting (LayoutingType.Sizing);
+
+                       if (child == largestChild)
+                               searchLargestChild ();
+                       if (child == tallestChild)
+                               searchTallestChild ();
+                       
+                       this.RegisterForLayouting (LayoutingType.Sizing | LayoutingType.ArrangeChildren);
         }
                public virtual void ClearChildren()
                {
@@ -66,9 +72,13 @@ namespace Crow
                                g.Parent = null;
                                Children.RemoveAt(Children.Count-1);
                        }
+
+                       resetChildrenMaxSize ();
+
                        this.RegisterForLayouting (LayoutingType.Sizing);
                        ChildrenCleared.Raise (this, new EventArgs ());
                }
+
                public void putWidgetOnTop(GraphicObject w)
                {
                        if (Children.Contains(w))
@@ -87,17 +97,6 @@ namespace Crow
                }
 
                #region GraphicObject overrides
-               [XmlIgnore]public override bool DrawingIsValid {
-                       get {
-                               if (!base.DrawingIsValid)
-                                       return false;
-                               foreach (GraphicObject g in Children) {
-                                       if (!g.DrawingIsValid)
-                                               return false;
-                               }
-                               return true;
-                       }
-               }
                public override void ResolveBindings ()
                {
                        base.ResolveBindings ();
@@ -163,15 +162,9 @@ namespace Crow
                                        if (this.Bounds.Width < 0)
                                                this.RegisterForLayouting (LayoutingType.Width);
                                } else if (g == largestChild) {
-                                       //search for the new largest child
-                                       largestChild = null;
-                                       maxChildrenWidth = 0;
-                                       for (int i = 0; i < Children.Count; i++) {
-                                               if (Children [i].Slot.Width > maxChildrenWidth) {
-                                                       maxChildrenWidth = Children [i].Slot.Width;
-                                                       largestChild = Children [i];
-                                               }
-                                       }
+                                       
+                                       searchLargestChild ();
+
                                        if (this.Bounds.Width < 0)
                                                this.RegisterForLayouting (LayoutingType.Width);
                                }
@@ -183,15 +176,9 @@ namespace Crow
                                        if (this.Bounds.Height < 0)
                                                this.RegisterForLayouting (LayoutingType.Height);
                                } else if (g == tallestChild) {
-                                       //search for the new tallest child
-                                       tallestChild = null;
-                                       maxChildrenHeight = 0;
-                                       for (int i = 0; i < Children.Count; i++) {
-                                               if (Children [i].Slot.Height > maxChildrenHeight) {
-                                                       maxChildrenHeight = Children [i].Slot.Height;
-                                                       tallestChild = Children [i];
-                                               }
-                                       }
+
+                                       searchTallestChild ();
+
                                        if (this.Bounds.Height < 0)
                                                this.RegisterForLayouting (LayoutingType.Height);
                                }
@@ -199,6 +186,37 @@ namespace Crow
                        }
                }
 
+               void resetChildrenMaxSize(){
+                       largestChild = null;
+                       tallestChild = null;
+                       maxChildrenWidth = 0;
+                       maxChildrenHeight = 0;
+               }
+               void searchLargestChild(){
+                       largestChild = null;
+                       maxChildrenWidth = 0;
+                       for (int i = 0; i < Children.Count; i++) {
+                               if (!Children [i].Visible)
+                                       continue;
+                               if (Children [i].Slot.Width > maxChildrenWidth) {
+                                       maxChildrenWidth = Children [i].Slot.Width;
+                                       largestChild = Children [i];
+                               }
+                       }
+               }
+               void searchTallestChild(){
+                       tallestChild = null;
+                       maxChildrenHeight = 0;
+                       for (int i = 0; i < Children.Count; i++) {
+                               if (!Children [i].Visible)
+                                       continue;
+                               if (Children [i].Slot.Height > maxChildrenHeight) {
+                                       maxChildrenHeight = Children [i].Slot.Height;
+                                       tallestChild = Children [i];
+                               }
+                       }
+               }
+
                protected override void onDraw (Context gr)
                {
                        base.onDraw (gr);
diff --git a/src/GraphicObjects/TabItem.cs b/src/GraphicObjects/TabItem.cs
new file mode 100644 (file)
index 0000000..29c682c
--- /dev/null
@@ -0,0 +1,93 @@
+//
+//  TabItem.cs
+//
+//  Author:
+//       Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+//
+//  Copyright (c) 2016 jp
+//
+//  This program is free software: you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation, either version 3 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+using System;
+using System.Xml.Serialization;
+using System.ComponentModel;
+
+namespace Crow
+{
+       [DefaultTemplate("#Crow.Templates.TabItem.crow")]
+       public class TabItem : TemplatedContainer
+       {
+               string caption;
+               Container _contentContainer;
+               GraphicObject _tabTitle;
+
+               public TabItem () : base()
+               {
+               }
+               public override GraphicObject Content {
+                       get {
+                               return _contentContainer == null ? null : _contentContainer.Child;
+                       }
+                       set {
+                               _contentContainer.SetChild(value);
+                       }
+               }
+               public override void ResolveBindings ()
+               {
+                       base.ResolveBindings ();
+                       if (_contentContainer != null)
+                               _contentContainer.ResolveBindings ();
+               }
+               protected override void loadTemplate(GraphicObject template = null)
+               {
+                       base.loadTemplate (template);
+
+                       _contentContainer = this.child.FindByName ("Content") as Container;
+                       _tabTitle = this.child.FindByName ("TabTitle");
+               }
+               internal GraphicObject TabTitle { get { return _tabTitle; }}
+
+               #region GraphicObject overrides
+               [XmlAttributeAttribute()][DefaultValue(true)]
+               public override bool Focusable
+               {
+                       get { return base.Focusable; }
+                       set { base.Focusable = value; }
+               }
+               #endregion
+               int tabOffset;
+               [XmlAttributeAttribute()][DefaultValue(0)]
+               public virtual int TabOffset {
+                       get { return tabOffset; }
+                       set {
+                               if (tabOffset == value)
+                                       return;
+                               tabOffset = value; 
+                               NotifyValueChanged ("TabOffset", tabOffset);
+                       }
+               } 
+               [XmlAttributeAttribute()][DefaultValue("TabItem")]
+               public string Caption {
+                       get { return caption; } 
+                       set {
+                               if (caption == value)
+                                       return;
+                               caption = value; 
+                               NotifyValueChanged ("Caption", caption);
+                       }
+               } 
+
+
+       }
+}
+
index f9f44754534937064c35288c4627d31d4630da17..6a18cf26ce7255a4497dbace6aa563ba5e90c30a 100644 (file)
 //  You should have received a copy of the GNU General Public License
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 using System;
+using System.Xml.Serialization;
+using System.ComponentModel;
 
 namespace Crow
 {
-       public class TabView
+       public class TabView : Group
        {
-               public TabView ()
+               Orientation _orientation;
+               int selectedTab = 0;
+
+               public TabView () : base()
+               {
+               }
+
+               [XmlAttributeAttribute()][DefaultValue(Orientation.Horizontal)]
+               public virtual Orientation Orientation
+               {
+                       get { return _orientation; }
+                       set { 
+                               if (_orientation == value)
+                                       return;
+                               _orientation = value; 
+                               NotifyValueChanged ("Orientation", _orientation);
+                               if (_orientation == Orientation.Horizontal)
+                                       NotifyValueChanged ("TabOrientation", Orientation.Vertical);
+                               else
+                                       NotifyValueChanged ("TabOrientation", Orientation.Horizontal);
+                       }
+               }
+               [XmlAttributeAttribute()][DefaultValue(0)]
+               public virtual int SelectedTab {
+                       get { return selectedTab; }
+                       set {
+                               if (selectedTab == value)
+                                       return;
+                               selectedTab = value; 
+                               NotifyValueChanged ("SelectedTab", selectedTab);
+                       }
+               }
+               int tabThickness;
+               [XmlAttributeAttribute()][DefaultValue(20)]
+               public virtual int TabThickness {
+                       get { return tabThickness; }
+                       set {
+                               if (tabThickness == value)
+                                       return;
+                               tabThickness = value; 
+                               NotifyValueChanged ("TabThickness", tabThickness);
+                       }
+               }
+               public override T AddChild<T> (T child)
+               {
+                       TabItem ti = child as TabItem;
+                       if (ti == null)
+                               throw new Exception ("TabView control accept only TabItem as child.");
+                       
+                       ti.MouseDown += Ti_MouseDown;
+
+                       return base.AddChild (child);
+               }
+
+               public override void ChildrenLayoutingConstraints (ref LayoutingType layoutType)
+               {
+//                     //Prevent child repositionning in the direction of 
+//                     if (Orientation == Orientation.Horizontal)
+//                             layoutType &= (~LayoutingType.X);
+//                     else
+//                             layoutType &= (~LayoutingType.Y);                       
+               }
+               public override bool UpdateLayout (LayoutingType layoutType)
                {
+                       RegisteredLayoutings &= (~layoutType);
+
+                       if (layoutType == LayoutingType.ArrangeChildren) {                       
+                               int curOffset = 0;
+                               for (int i = 0; i < Children.Count; i++) {
+                                       if (!Children [i].Visible)
+                                               continue;
+                                       TabItem ti = Children [i] as TabItem;
+                                       ti.TabOffset = curOffset;
+                                       if (Orientation == Orientation.Horizontal) {
+                                               if (ti.TabTitle.RegisteredLayoutings.HasFlag (LayoutingType.Width))
+                                                       return false;
+                                               curOffset += ti.TabTitle.Slot.Width;
+                                       } else {
+                                               if (ti.TabTitle.RegisteredLayoutings.HasFlag (LayoutingType.Height))
+                                                       return false;
+                                               curOffset += ti.TabTitle.Slot.Height;
+                                       }
+                               }
+
+                               //if no layouting remains in queue for item, registre for redraw
+                               if (RegisteredLayoutings == LayoutingType.None && bmp==null)
+                                       this.RegisterForRedraw ();
+
+                               return true;
+                       }
+
+                       return base.UpdateLayout(layoutType);
+               }
+
+               void TabTitleLayoutChanged (object sender, LayoutingEventArgs e)
+               {
+                       
+               }
+
+               void Ti_MouseDown (object sender, OpenTK.Input.MouseButtonEventArgs e)
+               {
+                       SelectedTab = Children.IndexOf (sender as GraphicObject);
+               }
+               protected override void onDraw (Cairo.Context gr)
+               {
+                       base.onDraw (gr);
+
+
                }
        }
 }
index 03a39c5c3fd1a6db24642a4177c83454249e08bc..50dbe3915b87e8ef99799e274390773a1fc50462 100644 (file)
@@ -32,8 +32,7 @@ namespace Crow
                Width = 0x04,
                Height = 0x08,
                Sizing = 0x0C,
-               PositionChildren = 0x10,
-               ChildAddition = 0x20,
+               ArrangeChildren = 0x10,
                All = 0xFF
        }
 
index 72d8fb9c358d3b68f3a67efbc6c79e11165fcac5..97695657031601dbcecdd7ee8a0d7def7e210398 100644 (file)
@@ -169,6 +169,8 @@ namespace Crow
                {
                        int i = 0;
                        while (GraphicObjects.Count>0) {
+                               //TODO:parent is not reset to null because object will be added
+                               //to ObjectToRedraw list, and without parent, it fails
                                GraphicObject g = GraphicObjects [i];
                                g.Visible = false;
                                g.ClearBinding ();