]> O.S.I.I.S - jp/crow.git/commitdiff
wip
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Fri, 16 Mar 2018 04:57:48 +0000 (05:57 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Sun, 18 Mar 2018 14:52:57 +0000 (15:52 +0100)
34 files changed:
Crow.csproj
CrowIDE/src/CrowIDE.cs
CrowIDE/src/Editors/CodeBuffer/TextEditor.cs
CrowIDE/src/Editors/SourceEditor.cs
CrowIDE/src/Editors/SvgEditor.cs
CrowIDE/src/ProjectTree/ProjectFile.cs
CrowIDE/ui/MenuItem.template
Templates/Expandable.template
Tests/BasicTests.cs
Tests/GraphicObjects/TechBorder.cs
Tests/Interfaces/Divers/welcome.crow
Tests/Interfaces/TemplatedContainer/testTreeView1.crow [new file with mode: 0755]
Tests/Interfaces/TemplatedContainer/testTreeView2.crow [new file with mode: 0755]
Tests/Tests.csproj
Tests/test.style
src/BmpPicture.cs
src/GraphicObjects/Border.cs
src/GraphicObjects/DockStack.cs
src/GraphicObjects/Expandable.cs
src/GraphicObjects/GenericStack.cs
src/GraphicObjects/GraphicObject.cs
src/GraphicObjects/Group.cs
src/GraphicObjects/Image.cs
src/GraphicObjects/Label.cs
src/GraphicObjects/PrivateContainer.cs
src/GraphicObjects/Scroller.cs
src/GraphicObjects/Shape.cs
src/GraphicObjects/TemplatedControl.cs
src/GraphicObjects/TextRun.cs
src/GraphicObjects/Wrapper.cs
src/Interface.cs
src/LayoutingQueueItem.cs
src/Picture.cs
src/SvgPicture.cs

index 1b5b3406bf82884fd9a7d1531c6027a3043bc311..466e5b0adc3c99c626656387fe8027ca4e382d41 100644 (file)
@@ -32,7 +32,7 @@
     <CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
     <Optimize>false</Optimize>
     <OutputPath>$(SolutionDir)build\Debug</OutputPath>
-    <DefineConstants>DESIGN_MODE;DEBUG_UPDATE0;DEBUG_FOCUS0;DEBUG_DISPOSE0;DEBUG_LAYOUTING0;TRACE0;DEBUG;MEASURE_TIME;DEBUG_LOAD0;DEBUG_BINDING0;DEBUG_CLIP_RECTANGLE0</DefineConstants>
+    <DefineConstants>DESIGN_MODE;DEBUG_LAYOUTING;DEBUG_UPDATE0;DEBUG_FOCUS0;DEBUG_DISPOSE0;TRACE0;DEBUG;MEASURE_TIME;DEBUG_LOAD0;DEBUG_BINDING0;DEBUG_CLIP_RECTANGLE0</DefineConstants>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
     <Optimize>true</Optimize>
index 46a926e348b73211cbc1a4344227831e321975c2..0332592deb5f9e213824dfd7ea4bcfec4ef4d684 100644 (file)
@@ -47,9 +47,9 @@ namespace Crow.Coding
 
                void initCommands () {
                        CMDNew = new Command(new Action(() => newFile())) { Caption = "New", Icon = new SvgPicture("#Crow.Coding.ui.icons.blank-file.svg"), CanExecute = true};
-                       CMDOpen = new Command(new Action(() => openFileDialog())) { Caption = "Open...", Icon = new SvgPicture("#Crow.Coding.ui.icons.outbox.svg")};
-                       CMDSave = new Command(new Action(() => saveFileDialog())) { Caption = "Save", Icon = new SvgPicture("#Crow.Coding.ui.icons.inbox.svg"), CanExecute = false};
-                       CMDSaveAs = new Command(new Action(() => saveFileDialog())) { Caption = "Save As...", Icon = new SvgPicture("#Crow.Coding.ui.icons.inbox.svg"), CanExecute = false};
+                       CMDOpen = new Command(new Action(() => openFileDialog())) { Caption = "Open...", Icon = new SvgPicture("#Crow.Coding.icons.open.svg")};
+                       CMDSave = new Command(new Action(() => saveFileDialog())) { Caption = "Save", Icon = new SvgPicture("#Crow.Coding.icons.save.svg"), CanExecute = false};
+                       CMDSaveAs = new Command(new Action(() => saveFileDialog())) { Caption = "Save As...", Icon = new SvgPicture("#Crow.Coding.icons.save.svg"), CanExecute = false};
                        CMDQuit = new Command(new Action(() => Quit (null, null))) { Caption = "Quit", Icon = new SvgPicture("#Crow.Coding.ui.icons.sign-out.svg")};
                        CMDUndo = new Command(new Action(() => undo())) { Caption = "Undo", Icon = new SvgPicture("#Crow.Coding.icons.undo.svg"), CanExecute = false};
                        CMDRedo = new Command(new Action(() => redo())) { Caption = "Redo", Icon = new SvgPicture("#Crow.Coding.icons.redo.svg"), CanExecute = false};
@@ -60,7 +60,7 @@ namespace Crow.Coding
                        CMDOptions = new Command(new Action(() => loadWindow("#Crow.Coding.ui.Options.crow"))) { Caption = "Editor Options", Icon = new SvgPicture("#Crow.Coding.icons.tools.svg")};
 
                        cmdCloseSolution = new Command(new Action(() => closeSolution()))
-                       { Caption = "Close Solution", Icon = new SvgPicture("#Crow.Coding.ui.icons.paste-on-document.svg"), CanExecute = false};
+                       { Caption = "Close Solution", Icon = new SvgPicture("#Crow.Coding.icons.paste-on-document.svg"), CanExecute = false};
 
                        CMDViewErrors = new Command(new Action(() => loadWindow ("#Crow.Coding.ui.DockWindows.winErrors.crow",this)))
                        { Caption = "Errors pane"};
@@ -73,7 +73,7 @@ namespace Crow.Coding
                        CMDViewDesign = new Command(new Action(() => loadWindow ("#Crow.Coding.ui.DockWindows.winDesign.crow",this)))
                        { Caption = "Quick Design", CanExecute = true};
                        CMDViewToolbox = new Command(new Action(() => loadWindow ("#Crow.Coding.ui.DockWindows.winToolbox.crow",this)))
-                       { Caption = "Toolbox", CanExecute = false};
+                       { Caption = "Toolbox", CanExecute = true};
                        CMDViewSchema = new Command(new Action(() => loadWindow ("#Crow.Coding.ui.DockWindows.winSchema.crow",this)))
                        { Caption = "IML Shematic View", CanExecute = true};
                        CMDViewStyling = new Command(new Action(() => loadWindow ("#Crow.Coding.ui.DockWindows.winStyleView.crow",this)))
index 6b7234dc23131c7cf8c0e523bfc19cff30b97e5b..81abe482f7c5a24f3b0824eba90631bba1129d4f 100644 (file)
@@ -230,7 +230,7 @@ namespace Crow.Text
                                }
                        }
                }
-               [DefaultValue("BlueGray")]
+               [DefaultValue("SlateGray")]
                public virtual Color SelectionBackground {
                        get { return selBackground; }
                        set {
@@ -363,7 +363,7 @@ namespace Crow.Text
                                RegisterForGraphicUpdate ();
                        }
                }
-               protected override int measureRawSize(LayoutingType lt)
+               public override int measureRawSize(LayoutingType lt)
                {
                        if (lt == LayoutingType.Height)
                                return (int)Math.Ceiling((fe.Ascent+fe.Descent) * buffer.LineCount) + Margin * 2;
index 724def34fa05ed67a4a4276d20053c1ec4f6ab84..7e949451bc8e092693bda641072d40bd54d05c87 100644 (file)
@@ -809,7 +809,7 @@ namespace Crow.Coding
                                RegisterForGraphicUpdate ();
                        }
                }
-               protected override int measureRawSize(LayoutingType lt)
+               public override int measureRawSize(LayoutingType lt)
                {
                        if (lt == LayoutingType.Height)
                                return (int)Math.Ceiling((fe.Ascent+fe.Descent) * buffer.LineCount) + Margin * 2;
index fce3d1aae4967fbd94e7524bac5179171031125a..8166e66e5456b2327bb11f3ef62e1a56a290d48c 100644 (file)
@@ -91,7 +91,7 @@ namespace Crow.Coding
                #endregion
 
                #region GraphicObject overrides
-               protected override int measureRawSize(LayoutingType lt)
+               public override int measureRawSize(LayoutingType lt)
                {
                        if (_pic == null)
                                return 2 * Margin;
index 2fac2f91e9df7d20207078ff0e3eb1b27f6208c1..c26cb7cfb9d0852d568d2f154c3552288019a3df 100644 (file)
@@ -51,11 +51,11 @@ namespace Crow.Coding
 
                void initCommands (){
                        cmdSave = new Crow.Command (new Action (() => Save ()))
-                       { Caption = "Save", Icon = new SvgPicture ("#Crow.Coding.ui.icons.inbox.svg"), CanExecute = false };
+                       { Caption = "Save", Icon = new SvgPicture ("#Crow.Coding.icons.save.svg"), CanExecute = false };
                        cmdSaveAs = new Crow.Command (new Action (() => SaveAs ()))
-                       { Caption = "Save As ..", Icon = new SvgPicture ("#Crow.Coding.ui.icons.inbox.svg"), CanExecute = false };
+                       { Caption = "Save As ..", Icon = new SvgPicture ("#Crow.Coding.icons.save.svg"), CanExecute = false };
                        cmdOpen = new Crow.Command (new Action (() => Open ())) 
-                       { Caption = "Open", Icon = new SvgPicture ("#Crow.Coding.ui.icons.outbox.svg"), CanExecute = false };
+                       { Caption = "Open", Icon = new SvgPicture ("#Crow.Coding.icons.open.svg"), CanExecute = false };
                        cmdUndo = new Crow.Command (new Action (() => Undo (null))) 
                        { Caption = "Undo", Icon = new SvgPicture ("#Crow.Coding.icons.undo.svg"), CanExecute = false };
                        cmdRedo = new Crow.Command (new Action (() => Redo (null))) 
index 97ee0272b3823eb6c54905f6fd5eda5f783b7c30..dd7de7a9c21f444317ea030e3fbb8ab8bff0bc85 100644 (file)
@@ -14,7 +14,7 @@
                                                Foreground="Transparent"
                                                Background="{./Background}">
                                                <HorizontalStack HorizontalAlignment="Left" Margin="1">
-                                                       <Image MaximumSize="10,10" Picture="{../../../../../Icon}"/>
+                                                       <Image Width="10" Height="10" Picture="{../../../../../Icon}" />
                                                        <Label Text="{./Caption}"
                                                                Foreground="{./Foreground}"
                                                                Font="{./Font}" />
index a36958d554a9ad20b58c4db6cdd1b653f68c8360..23bce31924b1e77689a89c371bd974e5c2269e4e 100755 (executable)
@@ -1,7 +1,7 @@
 <?xml version="1.0"?>
 <Border Style="ControlBorder" Foreground="{./Foreground}" Background="{./Background}">
        <VerticalStack>
-               <HorizontalStack Spacing="1" Height="Fit" MouseDoubleClick="./onClickForExpand">
+               <HorizontalStack Width="Stretched" Spacing="1" Height="Fit" MouseDoubleClick="./onClickForExpand">
                        <Container Margin="1" Width="9" Height="9" Focusable="true" MouseDown="./onClickForExpand"
                                                                                                                MouseEnter="{Background=LightGray}"
                                                                                                                MouseLeave="{Background=Transparent}">
@@ -10,7 +10,7 @@
                                        Visible="{./IsExpandable}"
                                        SvgSub="{./IsExpanded}"/>
                        </Container>
-                       <Label Style="ControlCaption" Text="{./Caption}"/>
+                       <Label Style="ControlCaption" Text="{./Caption}" Width="Stretched"/>
                </HorizontalStack>
                <Container Name="Content" Visible="false"/>
        </VerticalStack>
index 9691f9ec9a2d6cb052c2782589b5edce1bce9660..af624ee500fe2b33510981251e1e1cfd68aea5a0 100644 (file)
@@ -36,6 +36,12 @@ using System.Diagnostics;
 
 namespace Tests
 {
+       public class TestContainer : TestItem {                 
+               public List<TestItem> Children;
+       }
+       public class TestItem {
+               public string Name;
+       }
        class BasicTests : CrowWindow
        {
                public BasicTests ()
@@ -52,10 +58,20 @@ namespace Tests
                        }
                }
 
+
+
                #region Test values for Binding
                public List<Crow.Command> Commands;
                public int intValue = 500;
                DirectoryInfo curDir = new DirectoryInfo (Path.GetDirectoryName(Assembly.GetEntryAssembly().Location));
+               public List<TestContainer> TestTree = new List<TestContainer>(
+                       new TestContainer[] {
+                               new TestContainer() { Name = "main", Children = new List<TestItem>(
+                                               new TestItem[] {
+                                                       new TestItem() { Name="item1"},
+                                                       new TestItem() { Name="item2"}
+                                               }
+                               )}});
                //DirectoryInfo curDir = new DirectoryInfo (@"/mnt/data/Images");
                public FileSystemInfo[] CurDirectory {
                        get { return curDir.GetFileSystemInfos (); }
@@ -178,9 +194,9 @@ namespace Tests
                        this.KeyDown += KeyboardKeyDown1;
 
                        //testFiles = new string [] { @"Interfaces/Experimental/testDock.crow" };
-                       //testFiles = new string [] { @"Interfaces/Divers/welcome.crow" };
+                       testFiles = new string [] { @"Interfaces/Divers/welcome.crow" };
                        //testFiles = new string [] { @"Interfaces/Divers/0.crow" };
-                       testFiles = new string [] { @"Interfaces/TemplatedContainer/testTreeView.crow" };
+                       //testFiles = new string [] { @"Interfaces/TemplatedContainer/testTreeView.crow" };
                        //testFiles = new string [] { @"Interfaces/Divers/colorPicker.crow" };
 //                     testFiles = new string[] { @"Interfaces/TemplatedControl/testItemTemplateTag.crow" };
 
@@ -199,6 +215,7 @@ namespace Tests
 
                        Load(testFiles[idx]).DataSource = this;
 
+                       showTarget = FindByName ("ShowTarget");
 //                     LoadIMLFragment (@"<DockWindow Width=""150"" Height=""150"" Background=""DarkRed"" />", 0);
 //                     LoadIMLFragment (@"<DockWindow Width=""200"" Height=""150"" Background=""DarkGreen"" />", 0);
 //                     LoadIMLFragment (@"<DockWindow Width=""250"" Height=""150"" Background=""Brown"" />", 0);
@@ -206,6 +223,7 @@ namespace Tests
 
 
                }
+               GraphicObject showTarget;
                void KeyboardKeyDown1 (object sender, OpenTK.Input.KeyboardKeyEventArgs e)
                {
                        try {
@@ -214,8 +232,9 @@ namespace Tests
                                Quit (null, null);
                                return;
                        } else if (e.Key == OpenTK.Input.Key.F1) {
-                               TestList.Add ("new string");
-                               NotifyValueChanged ("TestList", TestList);
+//                             TestList.Add ("new string");
+//                             NotifyValueChanged ("TestList", TestList);
+                                       showTarget.Visible = !showTarget.Visible;
                                return;
                        } else if (e.Key == OpenTK.Input.Key.F4) {
                                GraphicObject w = Load ("Interfaces/TemplatedContainer/testWindow.goml");
index d1f73324f260c5552b60655b4e2b8b2242e34992..b2e2b23d9cbdcd0eee0bd4bfdd120d62b8ac5c57 100644 (file)
@@ -33,7 +33,7 @@ namespace Tests
                public TechBorder () : base() {}
                public TechBorder (Interface iface): base (iface){}
 
-               protected override int measureRawSize(LayoutingType lt)
+               public override int measureRawSize(LayoutingType lt)
                {
                        return base.measureRawSize (lt) + 6;
                }
index 74018ebea4b9e3c96be153cce456b55878dfa7c2..b65a4553ab071ef2540ec5d7a7a768d26049230e 100644 (file)
@@ -1,2 +1,7 @@
 <?xml version="1.0"?>
-<ColorCircleSelector />
\ No newline at end of file
+<!--<VerticalStack Width="Fit">
+       <Label Background="Brown" />
+       <Slider Orientation="Vertical" Height="Stretched" Width="20" Background="DimGray"/>
+       <Label Name="ShowTarget" Background="DarkBlue"/>
+</VerticalStack>-->
+<Slider Orientation="Horizontal" Height="10" Width="100" Background="DimGray"/>
\ No newline at end of file
diff --git a/Tests/Interfaces/TemplatedContainer/testTreeView1.crow b/Tests/Interfaces/TemplatedContainer/testTreeView1.crow
new file mode 100755 (executable)
index 0000000..6932881
--- /dev/null
@@ -0,0 +1,35 @@
+<?xml version="1.0"?>
+<Container Width="500">
+       <TreeView Data="{TestTree}" Focusable="true">
+               <Template>
+                               <VerticalStack
+                                       Height="Fit" Name="ItemsContainer" Margin="0" VerticalAlignment="Top"/>
+               </Template>
+               <ItemTemplate DataType="Tests.TestContainer" Data="Children">
+                       <Expandable Caption="{Name}" Focusable="true">
+                               <Template>
+                                       <VerticalStack>
+                                               <HorizontalStack Spacing="1" Margin="3" Background="Brown">
+                                                       <Image Margin="1" Width="9" Height="9" Focusable="true" MouseDown="./onClickForExpand"
+                                                               Path="{./Image}"
+                                                               Visible="{./IsExpandable}"
+                                                               SvgSub="{./IsExpanded}"
+                                                               MouseEnter="{Background=LightGray}"
+                                                               MouseLeave="{Background=Transparent}"/>
+                                                       <Label Text="{./Caption}"/>
+                                               </HorizontalStack>
+                                               <Container Name="Content" Visible="false"/>
+                                       </VerticalStack>
+                               </Template>
+                               <VerticalStack Height="Fit" Name="ItemsContainer"/>
+                       </Expandable>           
+               </ItemTemplate>
+               <ItemTemplate DataType="Tests.TestItem" >
+                               <HorizontalStack Margin="0" Background="Teal">
+                                       <GraphicObject Width="5" Height="5" Background="Green"/>
+                                       <Label Text="{Name}" Width="Stretched"/>
+                               </HorizontalStack>
+               </ItemTemplate>
+
+       </TreeView>
+</Container>
\ No newline at end of file
diff --git a/Tests/Interfaces/TemplatedContainer/testTreeView2.crow b/Tests/Interfaces/TemplatedContainer/testTreeView2.crow
new file mode 100755 (executable)
index 0000000..dfbe00c
--- /dev/null
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+<TreeView Data="{TestTree}">
+       <Template>
+                       <VerticalStack
+                               Height="Fit" Name="ItemsContainer" Margin="0" VerticalAlignment="Top"/>
+       </Template>
+       <ItemTemplate DataType="Tests.TestContainer" Data="Children">
+               <Expandable Caption="{Name}" >
+                       <Template>
+                               <VerticalStack>
+                                       <Border Style="TreeItemBorder" Focusable="false" MouseDoubleClick="./onClickForExpand">
+                                               <HorizontalStack Spacing="1">
+                                                       <Image Margin="1" Width="9" Height="9" Focusable="true" MouseDown="./onClickForExpand"
+                                                               Path="{./Image}"
+                                                               Visible="{./IsExpandable}"
+                                                               SvgSub="{./IsExpanded}"
+                                                               MouseEnter="{Background=LightGray}"
+                                                               MouseLeave="{Background=Transparent}"/>
+                                                       <Image Style="TreeIcon"
+                                                               Path="#Crow.Icons.crowproj.svg"/>
+                                                       <GraphicObject Width="2" Height="9" Background="Green" Visible="{IsStartupProject}"/>
+                                                       <Label Text="{./Caption}"/>
+                                               </HorizontalStack>
+                                       </Border>
+                                       <Container Name="Content" Visible="false"/>
+                               </VerticalStack>
+                       </Template>
+                       <HorizontalStack Height="Fit">
+                               <GraphicObject Width="8" Height="10"/>
+                               <VerticalStack Height="Fit" Name="ItemsContainer"/>
+                       </HorizontalStack>
+               </Expandable>           
+       </ItemTemplate>
+       <ItemTemplate DataType="Tests.TestItem" >
+               <Border Style="TreeItemBorder">
+                       <HorizontalStack>
+                               <GraphicObject Width="5" Height="5"/>
+                               <Image Style="TreeIcon"
+                                       Path="#Crow.Icons.assembly.svg"/>
+                               <Label Text="{Name}" Width="Stretched"/>
+                       </HorizontalStack>
+               </Border>
+       </ItemTemplate>
+
+</TreeView>
\ No newline at end of file
index ab976241bd1b2152c1a976ab9f2e4fd1dad9e693..67c3ddaa6e2a235b7052530ba361683ec2087233 100644 (file)
     <None Include="Interfaces\TemplatedContainer\testTabView2.crow">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
+    <None Include="Interfaces\TemplatedContainer\testTreeView2.crow">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
+    <None Include="Interfaces\TemplatedContainer\testTreeView1.crow">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
   </ItemGroup>
   <ItemGroup>
     <Folder Include="Interfaces\" />
index bbe53513333f02ef393ad0dea5eed4928e1523d5..7b296cba66a14cec9b9ee6ab94f5266b7913328e 100644 (file)
@@ -32,3 +32,18 @@ labPerfVal{
        Font = "droid, 8";
        Width = "50%";
 }
+TreeItemBorder {
+       CornerRadius="2";
+       Margin="0";
+       Focusable="true";
+       Height="Fit";
+       Width="Stretched";
+       Foreground="Transparent";
+       MouseEnter="{Foreground=DimGray}";
+       MouseLeave="{Foreground=Transparent}";
+}
+TreeIcon {
+       Margin="0";
+       Width="14";
+       Height="14";
+}
\ No newline at end of file
index e3af9c79781761a5a6abb6fdffce3788b3a17470..42ab2a0861cbf7d7440081d65185951c87b2f6cb 100644 (file)
@@ -62,12 +62,13 @@ namespace Crow
                                sharedPicture sp = sharedResources [path];
                                image = (byte[])sp.Data;
                                Dimensions = sp.Dims;
-                               return;
-                       }
-                       using (Stream stream = iface.GetStreamFromPath (path)) {                                
-                               loadBitmap (new System.Drawing.Bitmap (stream));        
+                       } else {
+                               using (Stream stream = iface.GetStreamFromPath (path)) {                                
+                                       loadBitmap (new System.Drawing.Bitmap (stream));        
+                               }
+                               sharedResources [path] = new sharedPicture (image, Dimensions);
                        }
-                       sharedResources [path] = new sharedPicture (image, Dimensions);
+                       Loaded = true;
                }
 
                //load image via System.Drawing.Bitmap, cairo load png only
index a02c6a3c8f2dc4fdacba9eecceb143e9b491b15d..066c68e0762fab00dd0e04a8db498e950afd5676 100644 (file)
@@ -122,7 +122,7 @@ namespace Crow
                        }
                }
 
-               protected override int measureRawSize(LayoutingType lt)
+               public override int measureRawSize(LayoutingType lt)
                {
                        int tmp = base.measureRawSize (lt);
                        return tmp < 0 ? tmp : tmp + 2 * BorderWidth;
@@ -130,17 +130,20 @@ namespace Crow
                protected override void onDraw (Context gr)
                {
                        drawborder2 (gr);
+                       if (child != null) {
+                               gr.Save ();
+                               if (ClipToClientRect) {
+                                       //clip to client zone
+                                       CairoHelpers.CairoRectangle (gr, ClientRectangle,Math.Max(0.0, CornerRadius-Margin));
+                                       gr.Clip ();
+                               }
 
-                       gr.Save ();
-                       if (ClipToClientRect) {
-                               //clip to client zone
-                               CairoHelpers.CairoRectangle (gr, ClientRectangle,Math.Max(0.0, CornerRadius-Margin));
-                               gr.Clip ();
+                               if (child.requestedLayoutings != LayoutingType.None) 
+                                       child.RegisterForLayouting ();
+                               else if (child.Visible)
+                                       child.Paint (ref gr);
+                               gr.Restore ();
                        }
-
-                       if (child != null)
-                               child.Paint (ref gr);
-                       gr.Restore ();
                }
                void drawborder2(Context gr){
                        Rectangle rBack = new Rectangle (Slot.Size);
index ae8b9c89093a9fec17bba8be91606f602c2726e7..3af3481698e5820dd68f773cbf0a44da3f91d42f 100644 (file)
@@ -196,8 +196,14 @@ namespace Crow
 
                        childrenRWLock.EnterReadLock ();
 
-                       foreach (GraphicObject g in Children)
-                               g.Paint (ref gr);                       
+                       foreach (GraphicObject g in Children) {
+                               if (!g.Visible)
+                                       continue;
+                               if (g.requestedLayoutings != LayoutingType.None) 
+                                       g.RegisterForLayouting ();
+                               else
+                                       g.Paint (ref gr);
+                       }
 
                        childrenRWLock.ExitReadLock ();
 
index 1920a8fe202b8e0b10fa2ed08a4b3e97f02002b9..45ec9932b90db1dcead4f510ac95a4cb4e543328 100644 (file)
@@ -127,5 +127,13 @@ namespace Crow
 
                        Collapse.Raise (this, e);
                }
+
+               public override void onKeyDown (object sender, KeyboardKeyEventArgs e)
+               {
+                       base.onKeyDown (sender, e);
+
+                       if (e.Key == Key.Plus || e.Key == Key.KeypadPlus)
+                               IsExpanded = !IsExpanded;
+               }
        }
 }
index 7f452cb00d3115021b434f8bd788661846059d5b..9bf1944a7497f46e8a8b21392e7f1a6ea92dff26 100644 (file)
@@ -78,16 +78,22 @@ namespace Crow
                        else
                                layoutType &= (~LayoutingType.Y);                       
                }
-               protected override int measureRawSize(LayoutingType lt)
+               public override int measureRawSize(LayoutingType lt)
                {
                        childrenRWLock.EnterReadLock ();
                        int totSpace = Math.Max(0, Spacing * (Children.Count (c => c.Visible) - 1));
                        childrenRWLock.ExitReadLock ();
                        if (lt == LayoutingType.Width) {
-                               if (Orientation == Orientation.Horizontal)
+                               if (Orientation == Orientation.Horizontal) {
+                                       if (stretchedGO != null)
+                                               totSpace += stretchedGO.Slot.Width;
                                        return contentSize.Width + totSpace + 2 * Margin;
-                       }else if (Orientation == Orientation.Vertical)
-                               return contentSize.Height + totSpace + 2 * Margin;                                                      
+                               }
+                       } else if (Orientation == Orientation.Vertical) {
+                               if (stretchedGO != null)
+                                       totSpace += stretchedGO.Slot.Height;                            
+                               return contentSize.Height + totSpace + 2 * Margin;
+                       }
                        
                        return base.measureRawSize (lt);
                }
@@ -136,10 +142,21 @@ namespace Crow
                void adjustStretchedGo (LayoutingType lt){
                        if (stretchedGO == null)
                                return;
+                       if (!stretchedGO.Visible) {
+                               stretchedGO = null;
+                               return;
+                       }
+                               
                        if (lt == LayoutingType.Width) {
-                               int newW = Math.Max (
+                               int newW = 0;
+
+                               if (Width == Measure.Fit)
+                                       newW = stretchedGO.measureRawSize (LayoutingType.Width);
+                               else 
+                                       newW = Math.Max (
                                                   this.ClientRectangle.Width - contentSize.Width - Spacing * (Children.Count - 1),
                                                   stretchedGO.MinimumSize.Width);
+                               
                                if (stretchedGO.MaximumSize.Width > 0)
                                        newW = Math.Min (newW, stretchedGO.MaximumSize.Width);
                                if (newW != stretchedGO.Slot.Width) {                                                   
@@ -154,9 +171,15 @@ namespace Crow
                                        stretchedGO.LastSlots.Width = stretchedGO.Slot.Width;
                                }
                        } else {
-                               int newH = Math.Max (
-                                       this.ClientRectangle.Height - contentSize.Height - Spacing * (Children.Count - 1),
-                                       stretchedGO.MinimumSize.Height);
+                               int newH = 0;
+
+                               if (Height == Measure.Fit)
+                                       newH = stretchedGO.measureRawSize (LayoutingType.Height);
+                               else
+                                       newH = Math.Max (
+                                               this.ClientRectangle.Height - contentSize.Height - Spacing * (Children.Count - 1),
+                                               stretchedGO.MinimumSize.Height);
+                               
                                if (stretchedGO.MaximumSize.Height > 0)
                                        newH = Math.Min (newH, stretchedGO.MaximumSize.Height);
                                if (newH != stretchedGO.Slot.Height) {
@@ -181,7 +204,7 @@ namespace Crow
                        case LayoutingType.Width:
                                if (Orientation == Orientation.Horizontal) {
                                        if (go.Width == Measure.Stretched) {
-                                               if (stretchedGO == null && Width != Measure.Fit)
+                                               if (stretchedGO == null)
                                                        stretchedGO = go;
                                                else if (stretchedGO != go) {
                                                        go.Slot.Width = 0;
@@ -203,7 +226,7 @@ namespace Crow
                        case LayoutingType.Height:
                                if (Orientation == Orientation.Vertical) {
                                        if (go.Height == Measure.Stretched) {
-                                               if (stretchedGO == null && Height != Measure.Fit)
+                                               if (stretchedGO == null)
                                                        stretchedGO = go;
                                                else if (stretchedGO != go){
                                                        go.Slot.Height = 0;
@@ -244,5 +267,11 @@ namespace Crow
                        else                            
                                adjustStretchedGo (LayoutingType.Height);                       
                }
+//             public override void LayoutingDiscardCheck (LayoutingType lt)
+//             {
+//                     if ((lt == LayoutingType.Height && _orientation == Orientation.Horizontal) ||
+//                             (lt == LayoutingType.Width && _orientation == Orientation.Vertical))
+//                             base.LayoutingDiscardCheck (lt);
+//             }
        }
 }
index 6903b9f978b64720193de9264a827571c3760f48..1147f2082c3dee0a15883adb2770bab0241855d2 100644 (file)
@@ -663,6 +663,8 @@ namespace Crow
                                        Measure.Stretched : height;
                        }
                        set {
+                               if (Name == "colIco" && value == Measure.Fit)
+                                       Debugger.Break ();
                                if (height == value)
                                        return;
                                if (value.IsFixed) {
@@ -1386,7 +1388,7 @@ namespace Crow
                protected void EnqueueForRepaint (){
                        //if no layouting remains in queue for item, registre for redraw
                        if (requestedLayoutings != LayoutingType.None)
-                               RegisterForLayouting (LayoutingType.None);
+                               RegisterForLayouting ();
                        else if (RegisteredLayoutings == LayoutingType.None && IsDirty)
                                IFace.EnqueueForRepaint (this);                 
                }
@@ -1395,7 +1397,7 @@ namespace Crow
                #region Layouting
 
                /// <summary> return size of content + margins </summary>
-               protected virtual int measureRawSize (LayoutingType lt) {
+               public virtual int measureRawSize (LayoutingType lt) {
                        return lt == LayoutingType.Width ?
                                contentSize.Width + 2 * Margin: contentSize.Height + 2 * Margin;
                }
@@ -1403,7 +1405,7 @@ namespace Crow
                public virtual void ChildrenLayoutingConstraints(ref LayoutingType layoutType){
                }
                public virtual bool ArrangeChildren { get { return false; } }
-               public virtual void RegisterForLayouting(LayoutingType layoutType){
+               public virtual void RegisterForLayouting(LayoutingType layoutType = LayoutingType.None){
                        if (Parent == null || !Monitor.TryEnter(IFace.LayoutMutex)) {
                                requestedLayoutings |= layoutType;
 //                             if (registeredLayoutings != LayoutingType.None)
@@ -1468,7 +1470,6 @@ namespace Crow
 //                             Debug.WriteLine ("\t\t{2}: {0} => {1}",LastSlots,Slot,this.name);
 //                     }
 //                     #endif
-
                        switch (layoutType) {
                        case LayoutingType.Width:
                                RegisterForLayouting (LayoutingType.X);
@@ -1497,25 +1498,28 @@ namespace Crow
 
                        switch (layoutType) {
                        case LayoutingType.X:
-                               if (Left == 0) {
+                               if (Visible) {
+                                       if (Left == 0) {
 
-                                       if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Width) ||
-                                           RegisteredLayoutings.HasFlag (LayoutingType.Width))
-                                               return false;
+                                               if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Width) ||
+                                                   RegisteredLayoutings.HasFlag (LayoutingType.Width))
+                                                       return false;
 
-                                       switch (HorizontalAlignment) {
-                                       case HorizontalAlignment.Left:
-                                               Slot.X = 0;
-                                               break;
-                                       case HorizontalAlignment.Right:
-                                               Slot.X = Parent.ClientRectangle.Width - Slot.Width;
-                                               break;
-                                       case HorizontalAlignment.Center:
-                                               Slot.X = Parent.ClientRectangle.Width / 2 - Slot.Width / 2;
-                                               break;
-                                       }
+                                               switch (HorizontalAlignment) {
+                                               case HorizontalAlignment.Left:
+                                                       Slot.X = 0;
+                                                       break;
+                                               case HorizontalAlignment.Right:
+                                                       Slot.X = Parent.ClientRectangle.Width - Slot.Width;
+                                                       break;
+                                               case HorizontalAlignment.Center:
+                                                       Slot.X = Parent.ClientRectangle.Width / 2 - Slot.Width / 2;
+                                                       break;
+                                               }
+                                       } else
+                                               Slot.X = Left;
                                } else
-                                       Slot.X = Left;
+                                       Slot.X = 0;
 
                                if (LastSlots.X == Slot.X)
                                        break;
@@ -1527,26 +1531,29 @@ namespace Crow
                                LastSlots.X = Slot.X;
                                break;
                        case LayoutingType.Y:
-                               if (Top == 0) {
+                               if (Visible) {
+                                       if (Top == 0) {
 
-                                       if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Height) ||
-                                           RegisteredLayoutings.HasFlag (LayoutingType.Height))
-                                               return false;
+                                               if (Parent.RegisteredLayoutings.HasFlag (LayoutingType.Height) ||
+                                                   RegisteredLayoutings.HasFlag (LayoutingType.Height))
+                                                       return false;
 
-                                       switch (VerticalAlignment) {
-                                       case VerticalAlignment.Top://this could be processed even if parent Height is not known
-                                               Slot.Y = 0;
-                                               break;
-                                       case VerticalAlignment.Bottom:
-                                               Slot.Y = Parent.ClientRectangle.Height - Slot.Height;
-                                               break;
-                                       case VerticalAlignment.Center:
-                                               Slot.Y = Parent.ClientRectangle.Height / 2 - Slot.Height / 2;
-                                               break;
-                                       }
+                                               switch (VerticalAlignment) {
+                                               case VerticalAlignment.Top://this could be processed even if parent Height is not known
+                                                       Slot.Y = 0;
+                                                       break;
+                                               case VerticalAlignment.Bottom:
+                                                       Slot.Y = Parent.ClientRectangle.Height - Slot.Height;
+                                                       break;
+                                               case VerticalAlignment.Center:
+                                                       Slot.Y = Parent.ClientRectangle.Height / 2 - Slot.Height / 2;
+                                                       break;
+                                               }
+                                       } else
+                                               Slot.Y = Top;
                                } else
-                                       Slot.Y = Top;
-
+                                       Slot.Y = 0;
+                               
                                if (LastSlots.Y == Slot.Y)
                                        break;
 
@@ -1637,6 +1644,16 @@ namespace Crow
 
                        return true;
                }
+               /// <summary>
+               /// Run after layouting item has been discarded for the first time,
+               /// check if sizing has no conflicting rules like fit container, and children all
+               /// stretched.
+               /// </summary>
+               public virtual void LayoutingDiscardCheck (LayoutingType lt) {
+                       //#if DEBUG_LAYOUTING
+                       Debug.WriteLine ("LayoutingDiscardCheck for {0}",this.ToString());
+                       // #endif
+               }
                #endregion
 
                #region Rendering
@@ -1738,9 +1755,17 @@ namespace Crow
 
         #region Keyboard handling
                public virtual void onKeyDown(object sender, KeyboardKeyEventArgs e){
+                       GraphicObject p = focusParent;
+                       if (p != null)
+                               p.onKeyDown(sender,e);
+                       
                        KeyDown.Raise (sender, e);
                }
                public virtual void onKeyUp(object sender, KeyboardKeyEventArgs e){
+                       GraphicObject p = focusParent;
+                       if (p != null)
+                               p.onKeyUp(sender,e);
+
                        KeyUp.Raise (sender, e);
                }
                public virtual void onKeyPress(object sender, KeyPressEventArgs e){
@@ -1931,7 +1956,7 @@ namespace Crow
                        Disabled.Raise (this, e);
                }
                protected virtual void onParentChanged(object sender, DataSourceChangeEventArgs e) {                    
-                       RegisterForLayouting (LayoutingType.None);
+                       RegisterForLayouting ();
                        
                        ParentChanged.Raise (this, e);
                        if (logicalParent == null)
index ebf75d641c12fbc5eb418330a174cc1ada4a5287..c8bf3f651314b31c59f64b1dde056b2500b2a460 100644 (file)
@@ -32,6 +32,7 @@ using Cairo;
 using System.Diagnostics;
 using System.Reflection;
 using System.Threading;
+using System.Linq;
 
 
 namespace Crow
@@ -234,26 +235,16 @@ namespace Crow
                        }
                        return false;
                }
-               protected override int measureRawSize (LayoutingType lt)
+               public override int measureRawSize (LayoutingType lt)
                {
-                       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;
+                       if (lt == LayoutingType.Width) {
+                               if (largestChild == null) {
+                                       if (!searchLargestChild ())
                                                return -1;
-                                       }
                                }
+                       } else if (tallestChild == null) {                                                                              
+                               if (!searchTallestChild ())
+                                       return -1;
                        }
                        return base.measureRawSize (lt);
                }
@@ -284,6 +275,24 @@ namespace Crow
                        }
                        childrenRWLock.ExitReadLock ();
                }
+               // TODO: this could be reworked to measure each item
+               public override void LayoutingDiscardCheck (LayoutingType lt)
+               {
+                       if (Children.Count == 0)
+                               return;
+                       base.LayoutingDiscardCheck (lt);
+                       if (lt == LayoutingType.Height) {
+                               //if (HeightPolicy == Measure.Fit) {
+                               if (tallestChild == null)
+                                       searchTallestChild (true);
+                               //}
+                       } else if (lt == LayoutingType.Width) {
+                               //if (WidthPolicy == Measure.Fit) {
+                               if (largestChild == null)
+                                       searchLargestChild (true);
+                               //}
+                       }
+               }
                protected override void onDraw (Context gr)
                {
                        base.onDraw (gr);
@@ -297,12 +306,18 @@ namespace Crow
                        }
 
                        childrenRWLock.EnterReadLock ();
+                       List<GraphicObject> visibles = Children.Where (c => c.Visible).ToList ();
+                       childrenRWLock.ExitReadLock ();
+                       if (visibles.Count == 0)
+                               return;
 
-                       foreach (GraphicObject g in Children) {
-                               g.Paint (ref gr);
+                       foreach (GraphicObject g in visibles) {
+                               if (g.requestedLayoutings != LayoutingType.None) 
+                                       g.RegisterForLayouting ();
+                               else
+                                       g.Paint (ref gr);
                        }
 
-                       childrenRWLock.ExitReadLock ();
                        gr.Restore ();
                }
                protected override void UpdateCache (Context ctx)
@@ -328,17 +343,20 @@ namespace Crow
                                }
 
                                childrenRWLock.EnterReadLock ();
-
-                               foreach (GraphicObject c in Children) {
-                                       if (!c.Visible)
-                                               continue;
+                               List<GraphicObject> visibles = Children.Where (c => c.Visible).ToList();
+                               childrenRWLock.ExitReadLock ();
+                               if (visibles.Count == 0)
+                                       return;
+                               
+                               foreach (GraphicObject c in visibles) {
                                        if (Clipping.Contains (c.Slot + ClientRectangle.Position) == RegionOverlap.Out)
                                                continue;
-                                       c.Paint (ref gr);
+                                       if (c.requestedLayoutings != LayoutingType.None) 
+                                               c.RegisterForLayouting ();
+                                       else
+                                               c.Paint (ref gr);
                                }
 
-                               childrenRWLock.ExitReadLock ();
-
                                #if DEBUG_CLIP_RECTANGLE
                                Clipping.stroke (gr, Color.Amaranth.AdjustAlpha (0.8));
                                #endif
@@ -388,43 +406,59 @@ namespace Crow
                        tallestChild = null;
                        contentSize = 0;
                }
-               void searchLargestChild(){
+               bool searchLargestChild(bool measure = false){
                        #if DEBUG_LAYOUTING
                        Debug.WriteLine("\tSearch largest child");
                        #endif
                        largestChild = null;
                        contentSize.Width = 0;
                        childrenRWLock.EnterReadLock ();
-                       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 > contentSize.Width) {
-                                       contentSize.Width = Children [i].Slot.Width;
-                                       largestChild = Children [i];
+                       List<GraphicObject> visibles = Children.Where (c => c.Visible).ToList();
+                       childrenRWLock.ExitReadLock ();
+                       if (visibles.Count == 0)
+                               return true;
+                       foreach (GraphicObject c in visibles) {
+                               int childWidth = 0;
+                               if (measure)
+                                       childWidth = c.measureRawSize (LayoutingType.Width);
+                               else {                                  
+                                       if (c.RegisteredLayoutings.HasFlag (LayoutingType.Width))
+                                               return false;
+                                       childWidth = c.Slot.Width;
+                               }
+                               if (childWidth > contentSize.Width) {
+                                       contentSize.Width = childWidth;
+                                       largestChild = c;
                                }
                        }
-                       childrenRWLock.ExitReadLock ();
+                       return true;
                }
-               void searchTallestChild(){
+               bool searchTallestChild(bool measure = false){
                        #if DEBUG_LAYOUTING
                        Debug.WriteLine("\tSearch tallest child");
                        #endif
                        tallestChild = null;
                        contentSize.Height = 0;
                        childrenRWLock.EnterReadLock ();
-                       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 > contentSize.Height) {
-                                       contentSize.Height = Children [i].Slot.Height;
-                                       tallestChild = Children [i];
+                       List<GraphicObject> visibles = Children.Where (c => c.Visible).ToList();
+                       childrenRWLock.ExitReadLock ();
+                       if (visibles.Count == 0)
+                               return true;
+                       foreach (GraphicObject c in visibles) {
+                               int childHeight = 0;
+                               if (measure)
+                                       childHeight = c.measureRawSize (LayoutingType.Height);
+                               else {
+                                       if (c.RegisteredLayoutings.HasFlag (LayoutingType.Height))
+                                               return false;
+                                       childHeight = c.Slot.Height;
+                               }
+                               if (childHeight > contentSize.Height) {
+                                       contentSize.Height = childHeight;
+                                       tallestChild = c;
                                }
                        }
-                       childrenRWLock.ExitReadLock ();
+                       return true;
                }
 
 
@@ -444,21 +478,6 @@ namespace Crow
                        }
                        base.checkHoverWidget (e);
                }
-//             public override bool PointIsIn (ref Point m)
-//             {
-//                     if (!base.PointIsIn (ref m))
-//                             return false;
-//                     if (CurrentInterface.HoverWidget == this)
-//                             return true;
-//                     lock (Children) {
-//                             for (int i = Children.Count - 1; i >= 0; i--) {
-//                                     if (Children [i].Slot.ContainsOrIsEqual (m) && !(bool)CurrentInterface.HoverWidget?.IsOrIsInside(Children[i])) {                                                
-//                                             return false;
-//                                     }
-//                             }
-//                     }
-//                     return true;
-//             }
                #endregion
 
                protected override void Dispose (bool disposing)
index e83183c003c34ee423b6279791e052b3aa2896da..faa13ec455d4b12a1528a0e241c9fa7ebde30963 100644 (file)
@@ -129,6 +129,12 @@ namespace Crow
                                if (_pic == value)
                                        return;
                                _pic = value;
+                               if (_pic!=null){
+                                       if (!_pic.Loaded)
+                                               _pic.Load (IFace, _pic.Path);
+                                       Scaled = _pic.Scaled;
+                                       KeepProportions = _pic.KeepProportions;
+                               }
                                NotifyValueChanged ("Picture", _pic);
                                RegisterForGraphicUpdate ();
                        }
@@ -182,7 +188,7 @@ namespace Crow
                #endregion
 
                #region GraphicObject overrides
-               protected override int measureRawSize (LayoutingType lt)
+               public override int measureRawSize (LayoutingType lt)
                {
                        if (_pic == null)
                                return 2 * Margin;
index 0e0d9fe19ee0262ad4711e2740372cd54263826c..02720a207e9bcab87e6d200c17276692e2768a52 100644 (file)
@@ -442,7 +442,7 @@ namespace Crow
                Size cachedTextSize = default(Size);
 
                #region GraphicObject overrides
-               protected override int measureRawSize(LayoutingType lt)
+               public override int measureRawSize(LayoutingType lt)
                {
                        if (lines == null)
                                lines = getLines;
index f3f6dbf1f923c8c4a2a4b135f58ac5d52263d6f3..190449b68b55708eea595a120be1455075469e62 100644 (file)
@@ -178,19 +178,22 @@ namespace Crow
                {
                        base.onDraw (gr);
 
-                       gr.Save ();
+                       if (child != null) {
+                               gr.Save ();
 
-                       if (ClipToClientRect) {
-                               //clip to client zone
-                               CairoHelpers.CairoRectangle (gr, ClientRectangle, CornerRadius);
-                               gr.Clip ();
-                       }
+                               if (ClipToClientRect) {
+                                       //clip to client zone
+                                       CairoHelpers.CairoRectangle (gr, ClientRectangle, CornerRadius);
+                                       gr.Clip ();
+                               }
 
-                       if (child != null) {
-                               if (child.Visible)
+                               if (child.requestedLayoutings != LayoutingType.None) 
+                                       child.RegisterForLayouting ();
+                               else if (child.Visible)
                                        child.Paint (ref gr);
+
+                               gr.Restore ();
                        }
-                       gr.Restore ();
                }
                protected override void UpdateCache (Context ctx)
                {
index 30dd14800c2d4a05e15d2ae4760c5bba90611c3e..88b79f3e5ccfd150e40a682c96abac16b34ba4cd 100644 (file)
@@ -204,16 +204,20 @@ namespace Crow
                        CairoHelpers.CairoRectangle(gr,rBack, CornerRadius);
                        gr.Fill ();
 
-                       gr.Save ();
-                       if (ClipToClientRect) {
-                               //clip to scrolled client zone
-                               CairoHelpers.CairoRectangle (gr, ClientRectangle, CornerRadius);
-                               gr.Clip ();
+                       if (child != null) {
+                               gr.Save ();
+                               if (ClipToClientRect) {
+                                       //clip to scrolled client zone
+                                       CairoHelpers.CairoRectangle (gr, ClientRectangle, CornerRadius);
+                                       gr.Clip ();
+                               }
+
+                               gr.Translate (-ScrollX, -ScrollY);
+                               if (child.requestedLayoutings != LayoutingType.None) 
+                                       child.RegisterForLayouting ();
+                               else if (child.Visible)
+                                       child.Paint (ref gr);
                        }
-
-                       gr.Translate (-ScrollX, -ScrollY);
-                       if (child != null)
-                               child.Paint (ref gr);
                        gr.Restore ();
                }
 
index 3bc465907e0bf56719d7826ba1c910674055d72d..c08ffaa908a79d046cfc824e42df40b4b6691c1d 100644 (file)
@@ -145,7 +145,7 @@ namespace Crow
                                }
                        }
                }
-               protected override int measureRawSize(LayoutingType lt)
+               public override int measureRawSize(LayoutingType lt)
                {
                        if ((lt == LayoutingType.Width && contentSize.Width == 0) || (lt == LayoutingType.Height && contentSize.Height == 0)) {
                                using (Surface drawing = new ImageSurface (Format.A1, 1,1)) {
index 54991a415960e24b1e85080c36cfdb12302f49f4..037cae32a45e3832b5e2ea30fda94e4a326127be 100644 (file)
@@ -123,17 +123,25 @@ namespace Crow
                /// <param name="gr">Backend context</param>
                protected override void onDraw (Context gr)
                {
-                       gr.Save ();
+                       if (child != null) {
 
-                       if (ClipToClientRect) {
-                               //clip to client zone
-                               CairoHelpers.CairoRectangle (gr, ClientRectangle, CornerRadius);
-                               gr.Clip ();
+                               gr.Save ();
+
+                               if (ClipToClientRect) {
+                                       //clip to client zone
+                                       CairoHelpers.CairoRectangle (gr, ClientRectangle, CornerRadius);
+                                       gr.Clip ();
+                               }
+
+                               if (child.requestedLayoutings != LayoutingType.None) 
+                                       child.RegisterForLayouting ();
+                               else if (child.Visible)
+                                       child.Paint (ref gr);
+
+                               gr.Restore ();
                        }
 
-                       if (child != null)
-                               child.Paint (ref gr);
-                       gr.Restore ();
+
                }
                #endregion
 
index 50e4f47fce6713de5d5064ca7e06c11a0d6cc79d..2c047cc22039dde0f5662cb2fb647a977a74250d 100644 (file)
@@ -145,7 +145,7 @@ namespace Crow
                }
 
                #region GraphicObject overrides
-               protected override int measureRawSize(LayoutingType lt)
+               public override int measureRawSize(LayoutingType lt)
                {
                        if (lines == null)
                                lines = getLines;
index 9efb989cab7b04db253ec8fbec29e8ac3dcfe376..43ffedc6a6e1a45bb4887eb995a20fc2101dd053 100644 (file)
@@ -25,6 +25,7 @@
 // THE SOFTWARE.
 
 using System;
+using Cairo;
 
 namespace Crow
 {
@@ -118,7 +119,7 @@ namespace Crow
                #endregion
 
                #region GraphicObject Overrides
-               protected override int measureRawSize(LayoutingType lt)
+               public override int measureRawSize(LayoutingType lt)
                {
                        int tmp = 0;
                        //Wrapper can't fit in the opposite direction of the wrapper, this func is called only if Fit
@@ -219,19 +220,23 @@ namespace Crow
                        #endif
                        switch (layoutType) {
                        case LayoutingType.Width:
+                               childrenRWLock.EnterReadLock ();
                                foreach (GraphicObject c in Children) {
                                        if (c.Width.IsRelativeToParent)
                                                c.RegisterForLayouting (LayoutingType.Width);
                                }
+                               childrenRWLock.ExitReadLock ();
                                if (Height == Measure.Fit)
                                        RegisterForLayouting (LayoutingType.Height);
                                RegisterForLayouting (LayoutingType.X);
                                break;
                        case LayoutingType.Height:
+                               childrenRWLock.EnterReadLock ();
                                foreach (GraphicObject c in Children) {
                                        if (c.Height.IsRelativeToParent)
                                                c.RegisterForLayouting (LayoutingType.Height);
                                }
+                               childrenRWLock.ExitReadLock ();
                                if (Width == Measure.Fit)
                                        RegisterForLayouting (LayoutingType.Width);
                                RegisterForLayouting (LayoutingType.Y);
index 4716ec4e4b0e690d4e15ffb610fc6d3c83ec5671..7902424d00b6c9b56801377c676e741a02fd9c2b 100644 (file)
@@ -134,10 +134,10 @@ namespace Crow
                public const int MaxCacheSize = 2048;
                /// <summary> Above this count, the layouting is discard from the current
                /// update cycle and requeued for the next</summary>
-               public const int MaxLayoutingTries = 3;
+               public const int MaxLayoutingTries = 30;
                /// <summary> Above this count, the layouting is discard for the widget and it
                /// will not be rendered on screen </summary>
-               public const int MaxDiscardCount = 5;
+               public const int MaxDiscardCount = 3;
                /// <summary> Global font rendering settings for Cairo </summary>
                public static FontOptions FontRenderingOptions;
                /// <summary> Global font rendering settings for Cairo </summary>
index 91385c3ef80504234cc6c37d6532e531eecdfa60..cf72aeb9b5daacce96cf37b42c05bf2b51612f09 100644 (file)
@@ -129,6 +129,7 @@ namespace Crow
                                        #if DEBUG_LAYOUTING
                                        Debug.WriteLine ("\t\tDiscarded");
                                        #endif
+                                       go.LayoutingDiscardCheck (LayoutType);
                                        LayoutingTries = 0;
                                        DiscardCount++;
                                        Layoutable.RegisteredLayoutings |= LayoutType;
index 3784780b812dbcae8def3491e482634dc238fc46..69ff25748e087e73adef8e2fd61398d889e48cba 100644 (file)
@@ -74,6 +74,8 @@ namespace Crow
                /// </summary>
                public bool Scaled = true;
 
+               public bool Loaded = false;
+
                #region CTOR
                /// <summary>
                /// Initializes a new instance of Picture.
index f676a4975d3796be9b280a4cca519415df4695eb..a7362582307480149137f98e0b9a271648520412 100644 (file)
@@ -58,26 +58,27 @@ namespace Crow
                                sharedPicture sp = sharedResources [path];
                                hSVG = (Rsvg.Handle)sp.Data;
                                Dimensions = sp.Dims;
-                               return;
-                       }
-                       using (Stream stream = iface.GetStreamFromPath (path)) {
-                               using (MemoryStream ms = new MemoryStream ()) {
-                                       stream.CopyTo (ms);
-
-                                       hSVG = new Rsvg.Handle (ms.ToArray ());
-                                       Dimensions = new Size (hSVG.Dimensions.Width, hSVG.Dimensions.Height);
+                       } else {
+                               using (Stream stream = iface.GetStreamFromPath (path)) {
+                                       using (MemoryStream ms = new MemoryStream ()) {
+                                               stream.CopyTo (ms);
+
+                                               hSVG = new Rsvg.Handle (ms.ToArray ());
+                                               Dimensions = new Size (hSVG.Dimensions.Width, hSVG.Dimensions.Height);
+                                       }
                                }
+                               sharedResources [path] = new sharedPicture (hSVG, Dimensions);
                        }
-                       sharedResources [path] = new sharedPicture (hSVG, Dimensions);
+                       Loaded = true;
                }
 
                public void LoadSvgFragment (string fragment) {                 
                        hSVG = new Rsvg.Handle (System.Text.Encoding.Unicode.GetBytes(fragment));
                        Dimensions = new Size (hSVG.Dimensions.Width, hSVG.Dimensions.Height);
+                       Loaded = true;
                }
 
                #region implemented abstract members of Fill
-
                public override void SetAsSource (Context ctx, Rectangle bounds = default(Rectangle))
                {
                        float widthRatio = 1f;