]> O.S.I.I.S - jp/crow.git/commitdiff
- expandables
authorjpbruyere <jp.bruyere@hotmail.com>
Wed, 10 Jun 2015 07:40:30 +0000 (09:40 +0200)
committerjpbruyere <jp.bruyere@hotmail.com>
Wed, 10 Jun 2015 07:40:31 +0000 (09:40 +0200)
- events resolution stacking
- Inlined template
- xmlserialization debugging

28 files changed:
GOLib.csproj
Images/Icons/buttest4.svg
Images/Icons/expandable.svg [new file with mode: 0644]
Templates/Expandable.goml [new file with mode: 0755]
Tests/GOLIBTest_4.cs
Tests/GOLIBTest_Expandable.cs [new file with mode: 0644]
Tests/Interfaces/test4.goml
Tests/Interfaces/testExpandable.goml [new file with mode: 0755]
Tests/Tests.csproj
src/CompilerServices/CompilerServices.cs
src/GraphicObjects/AnalogMeter.cs
src/GraphicObjects/Border.cs
src/GraphicObjects/Button.cs [changed mode: 0755->0644]
src/GraphicObjects/Checkbox.cs
src/GraphicObjects/Container.cs
src/GraphicObjects/Expandable.cs [new file with mode: 0644]
src/GraphicObjects/GenericStack.cs
src/GraphicObjects/GraphicObject.cs
src/GraphicObjects/Group.cs
src/GraphicObjects/ListBox.cs
src/GraphicObjects/PrivateContainer.cs [new file with mode: 0644]
src/GraphicObjects/RadioButton.cs
src/GraphicObjects/Scroller.cs
src/GraphicObjects/Slider.cs
src/GraphicObjects/Spinner.cs
src/GraphicObjects/TemplatedControl.cs
src/Interface.cs
src/LayoutingQueueItem.cs

index 15e126f0ef414da82aa87945bca4db80b1c33ba2..28b47450458348b16c575f1218a15f0b61da23fe 100644 (file)
     <Compile Include="src\GraphicObjects\TemplatedControl.cs" />\r
     <Compile Include="src\GraphicObjects\Checkbox.cs" />\r
     <Compile Include="src\GraphicObjects\RadioButton.cs" />\r
+    <Compile Include="src\GraphicObjects\Expandable.cs" />\r
+    <Compile Include="src\GraphicObjects\PrivateContainer.cs" />\r
   </ItemGroup>\r
   <ItemGroup>\r
     <Reference Include="System" />\r
     <EmbeddedResource Include="Templates\Spinner %28copier%29.goml" />\r
     <EmbeddedResource Include="Templates\ItemTemplate.goml" />\r
     <EmbeddedResource Include="Templates\ComboListOverlay.goml" />\r
+    <EmbeddedResource Include="Templates\Expandable.goml" />\r
+    <EmbeddedResource Include="Images\Icons\expandable.svg" />\r
   </ItemGroup>\r
 </Project>\r
index 00880ad017162cc8d779c569153de4fdee138d78..5bb1f0b9e34a82d76bb7a5fb0d85f10bde5fc4e3 100644 (file)
@@ -10,9 +10,9 @@
    xmlns:xlink="http://www.w3.org/1999/xlink"
    xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
    xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
-   width="68.136505mm"
-   height="23.384127mm"
-   viewBox="0 0 241.42856 82.857141"
+   width="241.42857"
+   height="87.85714"
+   viewBox="0 0 241.42858 87.857136"
    id="svg6194"
    version="1.1"
    inkscape:version="0.91 r13725"
      id="defs6196">
     <linearGradient
        inkscape:collect="always"
-       xlink:href="#linearGradient6159"
-       id="linearGradient6147"
-       gradientUnits="userSpaceOnUse"
-       gradientTransform="translate(-5.0507576,-7.0710656)"
-       x1="-94.577568"
-       y1="155.6501"
-       x2="-94.577568"
-       y2="239.49275" />
-    <linearGradient
-       id="linearGradient6159"
-       inkscape:collect="always">
+       id="linearGradient5895">
       <stop
-         id="stop6161"
+         style="stop-color:#ffffff;stop-opacity:1"
          offset="0"
-         style="stop-color:#787878;stop-opacity:1" />
-      <stop
-         style="stop-color:#909090;stop-opacity:1;"
-         offset="0.19879514"
-         id="stop6165" />
+         id="stop4179" />
       <stop
-         id="stop6163"
+         style="stop-color:#a9a9a9;stop-opacity:1"
          offset="1"
-         style="stop-color:#a8a8a8;stop-opacity:1" />
+         id="stop4181" />
     </linearGradient>
     <radialGradient
        inkscape:collect="always"
        x2="-94.577568"
        y2="239.49275"
        gradientUnits="userSpaceOnUse"
-       gradientTransform="translate(-5.0507576,-7.0710656)" />
+       gradientTransform="translate(216.17265,-155.05841)" />
     <linearGradient
        inkscape:collect="always"
-       id="linearGradient5895">
-      <stop
-         style="stop-color:#ffffff;stop-opacity:1;"
-         offset="0"
-         id="stop5897" />
-      <stop
-         style="stop-color:#e4e4e4;stop-opacity:1"
-         offset="1"
-         id="stop5899" />
-    </linearGradient>
+       xlink:href="#linearGradient5895"
+       id="linearGradient4185"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="translate(216.17265,-155.05841)"
+       x1="-94.577568"
+       y1="155.6501"
+       x2="-94.577568"
+       y2="239.49275" />
   </defs>
   <sodipodi:namedview
      id="base"
      borderopacity="1.0"
      inkscape:pageopacity="0.0"
      inkscape:pageshadow="2"
-     inkscape:zoom="0.35"
-     inkscape:cx="-201.37781"
-     inkscape:cy="-300.43329"
+     inkscape:zoom="1.979899"
+     inkscape:cx="34.707974"
+     inkscape:cy="28.122813"
      inkscape:document-units="px"
-     inkscape:current-layer="layer1"
+     inkscape:current-layer="svg6194"
      showgrid="false"
      fit-margin-top="0"
      fit-margin-left="0"
      inkscape:window-height="984"
      inkscape:window-x="0"
      inkscape:window-y="16"
-     inkscape:window-maximized="1" />
+     inkscape:window-maximized="1"
+     units="px" />
   <metadata
      id="metadata6199">
     <rdf:RDF>
         <dc:format>image/svg+xml</dc:format>
         <dc:type
            rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
-        <dc:title></dc:title>
+        <dc:title />
       </cc:Work>
     </rdf:RDF>
   </metadata>
   <g
-     inkscape:label="Calque 1"
-     inkscape:groupmode="layer"
-     id="layer1"
-     transform="translate(219.33647,-149.07178)">
-    <g
-       id="normal">
-      <rect
-         ry="20.854177"
-         y="150.58701"
-         x="-219.33647"
-         height="82.85714"
-         width="241.42857"
-         id="rect5893-7"
-         style="opacity:1;fill:url(#radialGradient5944);fill-opacity:1;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
-      <rect
-         ry="20.854177"
-         y="149.07178"
-         x="-219.33647"
-         height="82.85714"
-         width="241.42857"
-         id="rect5893"
-         style="opacity:1;fill:url(#linearGradient5901);fill-opacity:1;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
-    </g>
-    <g
-       id="pressed">
-      <rect
-         ry="20.854177"
-         y="150.58701"
-         x="-219.33647"
-         height="82.85714"
-         width="241.42857"
-         id="rect5893-7-4"
-         style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
-      <rect
-         ry="20.854177"
-         y="149.07178"
-         x="-219.33647"
-         height="82.85714"
-         width="241.42857"
-         id="rect5893-6"
-         style="opacity:1;fill:url(#linearGradient6147);fill-opacity:1;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
-    </g>
+     id="normal">
+    <rect
+       ry="20.854177"
+       y="5"
+       x="0"
+       height="82.85714"
+       width="241.42857"
+       id="rect5893-7"
+       style="opacity:1;fill:url(#radialGradient5944);fill-opacity:1;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+    <rect
+       ry="20.854177"
+       y="0"
+       x="0"
+       height="82.85714"
+       width="241.42857"
+       id="rect5893"
+       style="opacity:1;fill:url(#linearGradient5901);fill-opacity:1;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+  </g>
+  <g
+     id="pressed">
+    <rect
+       style="opacity:1;fill:#616161;fill-opacity:1;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+       id="rect4159"
+       width="241.42857"
+       height="82.85714"
+       x="0"
+       y="0"
+       ry="20.854177" />
+    <rect
+       style="opacity:1;fill:url(#linearGradient4185);fill-opacity:1.0;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+       id="rect4161"
+       width="241.42857"
+       height="82.85714"
+       x="0"
+       y="2"
+       ry="20.854177" />
   </g>
 </svg>
diff --git a/Images/Icons/expandable.svg b/Images/Icons/expandable.svg
new file mode 100644 (file)
index 0000000..43fb3eb
--- /dev/null
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   width="64"
+   height="64"
+   viewBox="0 0 64 64.000002"
+   id="svg2"
+   version="1.1"
+   inkscape:version="0.91 r13725"
+   sodipodi:docname="expandable.svg">
+  <defs
+     id="defs4" />
+  <sodipodi:namedview
+     id="base"
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     inkscape:pageopacity="0.0"
+     inkscape:pageshadow="2"
+     inkscape:zoom="6.6713043"
+     inkscape:cx="34.688233"
+     inkscape:cy="18.992144"
+     inkscape:document-units="px"
+     inkscape:current-layer="svg2"
+     showgrid="false"
+     units="px"
+     inkscape:window-width="1280"
+     inkscape:window-height="984"
+     inkscape:window-x="0"
+     inkscape:window-y="16"
+     inkscape:window-maximized="1" />
+  <metadata
+     id="metadata7">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+        <dc:title></dc:title>
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <g
+     id="collapsed">
+    <rect
+       ry="8.8907347"
+       y="4.3914709"
+       x="4.4468598"
+       height="55.122551"
+       width="55.122551"
+       id="rect4136"
+       style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:8.89073467;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:0;stroke-dasharray:none;stroke-opacity:1" />
+    <path
+       inkscape:connector-curvature="0"
+       id="path4177"
+       d="m 32.008136,12.393132 0,39.11923"
+       style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:8.89073467;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+    <path
+       inkscape:connector-curvature="0"
+       id="path4181"
+       d="m 12.448521,31.952746 39.119231,0"
+       style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:8.89073467;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+  </g>
+  <g
+     id="expanded">
+    <rect
+       style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:8.89073467;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:0;stroke-dasharray:none;stroke-opacity:1"
+       id="rect4190"
+       width="55.122551"
+       height="55.122551"
+       x="4.4468598"
+       y="4.3914709"
+       ry="8.8907347" />
+    <path
+       style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:8.89073467;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+       d="m 12.448521,31.952746 39.119231,0"
+       id="path4194"
+       inkscape:connector-curvature="0" />
+  </g>
+</svg>
diff --git a/Templates/Expandable.goml b/Templates/Expandable.goml
new file mode 100755 (executable)
index 0000000..f2c2d09
--- /dev/null
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>\r
+<Border BorderWidth="1" BorderColor="LightGray"  Height="-1" Width="0" MouseClick="onMouseClick">\r
+       <VerticalStack MouseClick="onMouseClick" Height="-1" Width="0" Name="vsTemplateExpander">\r
+               <HorizontalStack Name="hsTemplateExpander" Spacing="1" Focusable="false" Height="-1" Width="0">\r
+                       <Image Name="Image" Margin="3" Width="16" Height="16" Path="#go.Images.Icons.expandable.svg"/>\r
+                       <Label Name="Caption"/>\r
+               </HorizontalStack>\r
+               <Container Name="Content" Visible="false"/>\r
+       </VerticalStack>\r
+</Border>
\ No newline at end of file
index 096d249edaee7988c6bef3941b93ec313e4dd892..796aac6627d6c2cb03ddc25676809fd29773c8e2 100644 (file)
@@ -34,19 +34,31 @@ namespace test
                #region FPS\r
                static int _fps = 0;\r
 \r
-               public static int fps {\r
+               public int fps {\r
                        get { return _fps; }\r
                        set {\r
+                               if (_fps == value)\r
+                                       return;\r
+\r
+                               int oldVal = _fps;\r
                                _fps = value;\r
-                               if (_fps > fpsMax)\r
+\r
+                               if (_fps > fpsMax) {\r
                                        fpsMax = _fps;\r
-                               else if (_fps < fpsMin)\r
+                                       ValueChanged.Raise(this, new ValueChangeEventArgs ("fpsMax", fpsMax, _fps));\r
+                               } else if (_fps < fpsMin) {\r
+                                       ValueChanged.Raise(this, new ValueChangeEventArgs ("fpsMin", fpsMin, _fps));\r
                                        fpsMin = _fps;\r
-                       }\r
+                               }\r
 \r
+                               if (ValueChanged != null)\r
+                                       ValueChanged.Raise(this, new ValueChangeEventArgs ("fps", oldVal, _fps));\r
+\r
+                               //ValueChanged.Raise (this, new ValueChangeEventArgs ("fps", oldVal, _fps));\r
+                       }\r
                }\r
 \r
-               public static int fpsMin = int.MaxValue;\r
+               public static int fpsMin = 0;\r
                public static int fpsMax = 0;\r
 \r
                static void resetFps ()\r
@@ -154,11 +166,9 @@ namespace test
 \r
                        fps = (int)RenderFrequency;\r
 \r
-                       labFps.Text = fps.ToString();\r
                        labUpdate.Text = this.updateTime.ElapsedMilliseconds.ToString() + " ms";\r
+\r
                        if (frameCpt > 200) {\r
-                               labFpsMin.Text = fpsMin.ToString();\r
-                               labFpsMax.Text = fpsMax.ToString();\r
                                resetFps ();\r
                                frameCpt = 0;\r
 \r
diff --git a/Tests/GOLIBTest_Expandable.cs b/Tests/GOLIBTest_Expandable.cs
new file mode 100644 (file)
index 0000000..9da9b1a
--- /dev/null
@@ -0,0 +1,55 @@
+#define MONO_CAIRO_DEBUG_DISPOSE\r
+\r
+\r
+using System;\r
+using System.Runtime.InteropServices;\r
+using OpenTK;\r
+using OpenTK.Graphics.OpenGL;\r
+using OpenTK.Input;\r
+\r
+using System.Diagnostics;\r
+\r
+//using GGL;\r
+using go;\r
+using System.Threading;\r
+\r
+\r
+namespace test\r
+{\r
+       class GOLIBTest_Expandable : OpenTKGameWindow\r
+       {\r
+               public GOLIBTest_Expandable ()\r
+                       : base(1024, 600,"test")\r
+               {}\r
+\r
+               Container g;\r
+\r
+               protected override void OnLoad (EventArgs e)\r
+               {\r
+                       base.OnLoad (e);\r
+                       LoadInterface("Interfaces/testExpandable.goml", out g);\r
+\r
+               }\r
+               protected override void OnRenderFrame (FrameEventArgs e)\r
+               {\r
+                       GL.Clear (ClearBufferMask.ColorBufferBit);\r
+                       base.OnRenderFrame (e);\r
+                       SwapBuffers ();\r
+               }\r
+\r
+               protected override void OnUpdateFrame (FrameEventArgs e)\r
+               {\r
+                       base.OnUpdateFrame (e);\r
+               }\r
+\r
+               [STAThread]\r
+               static void Main ()\r
+               {\r
+                       Console.WriteLine ("starting example");\r
+\r
+                       using (GOLIBTest_Expandable win = new GOLIBTest_Expandable( )) {\r
+                               win.Run (30.0);\r
+                       }\r
+               }\r
+       }\r
+}
\ No newline at end of file
index 914bce008879ef78610b633892952b3e680cfe34..8b4f769121711a5221685e8ba62f4a8d234a24dc 100755 (executable)
@@ -13,7 +13,7 @@
                        WidgetSpacing="1" \r
                        VerticalAlignment="Top">\r
                        <VerticalStack Name="vs1" Spacing="5">\r
-                                                       <Slider Height="10" Width="300" BorderWidth="1" Background="Transparent" />\r
+                               <Slider Height="10" Width="300" BorderWidth="1" Background="Transparent" />\r
                                <Label Name="labMouse" Text="MousePos"/>\r
                                <HorizontalStack WidgetSpacing="10">\r
                                        <VerticalStack Width="100">\r
                                        <VerticalStack Width="100">\r
                                                <RadioButton IsChecked="true"/>\r
                                                <RadioButton/>\r
-                                               <RadioButton/>\r
+                                               <RadioButton>                                                   \r
+                                                       <Template>\r
+                                                               <HorizontalStack Background="Green" Margin="0" Spacing="1" Focusable="false">\r
+                                                                       <Image Name="Image" Width="16" Height="16" Path="#go.Images.Icons.radiobutton.svg"/>\r
+                                                                       <Label Name="Caption"/>\r
+                                                               </HorizontalStack>\r
+                                                       </Template>\r
+                                               </RadioButton>\r
                                                <RadioButton/>\r
                                        </VerticalStack>\r
-                                       <Spinner Value="5"></Spinner>\r
+                                       <Spinner Width="50" Value="5"></Spinner>\r
                                </HorizontalStack>\r
 <!--                           <ListBox Data="{TestList}"></ListBox>-->\r
                                <HorizontalStack Name="hsPbar" Margin="5">\r
                                \r
                        </VerticalStack>\r
                        <VerticalStack Width="-1" Height="-1" BorderWidth="1" Margin="5" WidgetSpacing="4">\r
-                               <Button  Margin="1" Width="150" Height="40">\r
+                               <Button  Margin="1" Width="150" Height="100">\r
                                        <Image  Path="#Tests.image.tetra.png"/>\r
                                </Button>\r
+                               <Expandable Name="expander" Width="150" Height="-1">\r
+                                       <VerticalStack Name="vsExpanded" Width="100">\r
+                                               <Checkbox Name="chk1"/>\r
+                                               <Checkbox Name="chk2" IsChecked="true"/>\r
+                                               <Checkbox Name="chk3"/>\r
+                                               <Checkbox Name="chk4"/>\r
+                                       </VerticalStack>                \r
+                               </Expandable>\r
+                               <Expandable Name="expander2" Width="150" Height="-1">\r
+                                       <VerticalStack Name="vsExpanded" Width="100">\r
+                                               <Checkbox Name="chk1"/>\r
+                                               <Checkbox Name="chk2" IsChecked="true"/>\r
+                                       </VerticalStack>                \r
+                               </Expandable>\r
+                               <Expandable Name="expander3" Width="150" Height="-1">\r
+                                       <VerticalStack Name="vsExpanded" Width="100">\r
+                                               <Checkbox Name="chk1" IsChecked="true"/>\r
+                                               <Checkbox Name="chk2"/>\r
+                                       </VerticalStack>                \r
+                               </Expandable>\r
+\r
                                <HorizontalStack>\r
-                                       <Label Text="Update" FontColor="White" VerticalAlignment="Center" />\r
+                                       <Label Text="Update" FontColor="White"/>\r
                                        <Label Name="labUpdate" Text="xxxx" FontSize="16" Width="60" TextAlignment="Center" Background="DarkGreen"/>\r
                                </HorizontalStack>\r
                                <HorizontalStack>\r
-                                       <Label Text="Fps:" Width = "30" VerticalAlignment="Center"  TextAlignment="LeftCenter"/>\r
-                                       <Label Name="labFps" Text="xxxx" Font="droid bold, 14"\r
+                                       <Label Text="Fps:" Width = "30"/>\r
+                                       <Label Name="labFps" Text="{fps}" Font="droid bold, 14"\r
                                                TextAlignment="Center" Background="AoEnglish"/>\r
                                </HorizontalStack>\r
                                <HorizontalStack>\r
-                                       <Label Text="Min:" Width = "30" />\r
-                                       <Label Name="labFpsMin" Text="xxxx" Font="droid bold, 14"\r
+                                       <Label Text="Min:" Width = "30"/>\r
+                                       <Label Name="labFpsMin" Text="{fpsMin}" Font="droid bold, 14"\r
                                                TextAlignment="Center" Background="AoEnglish"/>\r
                                </HorizontalStack>\r
                                <HorizontalStack>\r
                                        <Label Text="Max:" Width = "30"/>\r
-                                       <Label Name="labFpsMax" Text="xxxx" Font="droid bold, 14"\r
+                                       <Label Name="labFpsMax" Text="{fpsMax}" Font="droid bold, 14"\r
                                                TextAlignment="Center" Background="AoEnglish"/>\r
                                </HorizontalStack>\r
                        </VerticalStack>\r
diff --git a/Tests/Interfaces/testExpandable.goml b/Tests/Interfaces/testExpandable.goml
new file mode 100755 (executable)
index 0000000..3349f61
--- /dev/null
@@ -0,0 +1,13 @@
+<?xml version="1.0"?>\r
+<Container Name="TopContainer" Width="400" Height="-1"\r
+       Margin="20" Focusable="True" Background="Gray">\r
+\r
+       <Expandable Width="150" Background="Green" Margin="2">\r
+                       <VerticalStack Width="100" Background="Red">\r
+                               <Checkbox Name="chk1"/>\r
+                               <Checkbox Name="chk2" IsChecked="true"/>\r
+                               <Checkbox Name="chk3"/>\r
+                               <Checkbox Name="chk4"/>\r
+                       </VerticalStack>                \r
+       </Expandable>\r
+</Container>
\ No newline at end of file
index 4d2046bba099a716b0a0940b5b08c3bae1517a27..674e9325c56c083212639a5315fb8b64856cbd77 100644 (file)
@@ -8,11 +8,12 @@
     <OutputType>Exe</OutputType>
     <RootNamespace>Tests</RootNamespace>
     <AssemblyName>Tests</AssemblyName>
-    <StartupObject>test.GOLIBTest_Spinner</StartupObject>
+    <StartupObject>test.GOLIBTest_4</StartupObject>
     <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
     <OutputPath>..\bin\$(configuration)</OutputPath>
     <IntermediateOutputPath>obj\$(configuration)</IntermediateOutputPath>
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SynchReleaseVersion>false</SynchReleaseVersion>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
     <OutputPath>..\bin\Debug</OutputPath>
@@ -55,6 +56,7 @@
     <Compile Include="GOLIBTest_fps.cs" />
     <Compile Include="GOLIBTest_Listbox.cs" />
     <Compile Include="GOLIBTest_Spinner.cs" />
+    <Compile Include="GOLIBTest_Expandable.cs" />
   </ItemGroup>
   <ItemGroup>
     <None Include="image\u.svg">
     <None Include="Interfaces\testSpinner.goml">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
+    <None Include="Interfaces\testExpandable.goml">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
   </ItemGroup>
   <ItemGroup>
     <Folder Include="Interfaces\" />
index 6f00d36d895299445734366397c37e3eea03220d..065c6924e2fadeeb0c7ff7d7144df68ba283680a 100644 (file)
@@ -163,20 +163,28 @@ namespace go
                        MemberInfo miSrc = srcType.GetMember (binding.Value).FirstOrDefault();
 
                        //initialize target with actual value
+                       object srcVal = null;
+                       if (miSrc == null)
+                               srcVal = _source;//if no member is provided for binding, source raw value is taken
+                       else {
+                               if (miSrc.MemberType == MemberTypes.Property)
+                                       srcVal = (miSrc as PropertyInfo).GetGetMethod ().Invoke (_source, null);
+                               else if (miSrc.MemberType == MemberTypes.Field)
+                                       srcVal = (miSrc as FieldInfo).GetValue (_source);
+                               else
+                                       throw new Exception ("unandled source member type for binding");
+                       }
                        if (miDst.MemberType == MemberTypes.Property) {
-                               if (miSrc == null)//if no member is provided for binding, source raw value is taken
-                                       (miDst as PropertyInfo).GetSetMethod ().Invoke (binding.Source, new object[] { _source });
-                               else if (miSrc.MemberType == MemberTypes.Property)
-                                       (miDst as PropertyInfo).GetSetMethod ().Invoke (binding.Source, new object[] { (miSrc as PropertyInfo).GetGetMethod ().Invoke (_source, null) });
-                               else if (miSrc.MemberType == MemberTypes.Field)                         
-                                       (miDst as PropertyInfo).GetSetMethod ().Invoke (binding.Source, new object[] { (miSrc as FieldInfo).GetValue (_source) });                      
+                               PropertyInfo piDst = miDst as PropertyInfo;
+                               //TODO: handle other dest type conversions
+                               if (piDst.PropertyType == typeof(string))
+                                       srcVal = srcVal.ToString ();
+                               piDst.GetSetMethod ().Invoke (binding.Source, new object[] { srcVal });
                        } else if (miDst.MemberType == MemberTypes.Field) {
-                               if (miSrc == null)//if no member is provided for binding, source raw value is taken
-                                       (miDst as FieldInfo).SetValue (binding.Source, _source );
-                               else if (miSrc.MemberType == MemberTypes.Property)
-                                       (miDst as FieldInfo).SetValue (binding.Source, (miSrc as PropertyInfo).GetGetMethod ().Invoke (_source, null));
-                               else if (miSrc.MemberType == MemberTypes.Field)                         
-                                       (miDst as FieldInfo).SetValue (binding.Source, (miSrc as FieldInfo).GetValue (_source));                                                        
+                               FieldInfo fiDst = miDst as FieldInfo;
+                               if (fiDst.FieldType == typeof(string))
+                                       srcVal = srcVal.ToString ();
+                               fiDst.SetValue (binding.Source, srcVal );
                        }else
                                throw new Exception("unandled destination member type for binding");
                        
index e487189d81a2bf771d2faa60fe691edcae7f0a55..dd248ceeaf2b2053422263151b607c301a668551 100644 (file)
@@ -18,7 +18,7 @@ namespace go
 
                #region implemented abstract members of TemplatedControl
 
-               protected override void loadTemplate ()
+               protected override void loadTemplate (GraphicObject template = null)
                {
                        throw new NotImplementedException ();
                }
index e2451582432aadd1acbb746b3124d713c3947c61..352b626a31441e15c2a0077cea3b0d9de4f9017f 100644 (file)
@@ -47,11 +47,11 @@ namespace go
                {
                        Size raw = Bounds.Size;
 
-                       if (child != null) {
+                       if (Child != null) {
                                if (Bounds.Width < 0)
-                                       raw.Width = child.Slot.Width + 2 * (Margin+BorderWidth);
+                                       raw.Width = Child.Slot.Width + 2 * (Margin+BorderWidth);
                                if (Bounds.Height < 0)
-                                       raw.Height = child.Slot.Height + 2 * (Margin+BorderWidth);
+                                       raw.Height = Child.Slot.Height + 2 * (Margin+BorderWidth);
                        }
 
                        return raw;
old mode 100755 (executable)
new mode 100644 (file)
index fcbdecd..c092ac1
@@ -63,14 +63,14 @@ namespace go
                public string Text\r
                {\r
                        get {\r
-                               Label l = child as Label;\r
+                               Label l = Child as Label;\r
                                return l == null ? "" : l.Text; \r
                        }\r
                        set\r
                        {\r
-                               Label l = child as Label;\r
+                               Label l = Child as Label;\r
                                if (l == null)\r
-                                       this.setChild(new Label (value) \r
+                                       this.SetChild(new Label (value) \r
                                                { \r
                                                        TextAlignment = Alignment.Center,\r
                                                        Foreground = Color.Black\r
index 07be76c5eb0e72936535a780ae0f7720f54cbca5..d36f1266f5c72ddc812953456e50763aed3743ba 100644 (file)
@@ -25,9 +25,13 @@ namespace go
                {\r
                }       \r
 \r
-               protected override void loadTemplate()\r
-               {\r
-                       this.setChild (Interface.Load ("#go.Templates.Checkbox.goml"));\r
+               protected override void loadTemplate(GraphicObject template = null)\r
+               {                       \r
+                       if (template == null)\r
+                               this.SetChild (Interface.Load ("#go.Templates.Checkbox.goml", this));\r
+                       else\r
+                               this.SetChild (template);\r
+\r
                        _caption = this.child.FindByName ("Caption") as Label;\r
                        _image = this.child.FindByName ("Image") as Image;\r
                        _image.SvgSub = "unchecked";\r
@@ -36,8 +40,10 @@ namespace go
 \r
                [XmlAttributeAttribute()][DefaultValue("Checkbox")]\r
                public string Caption {\r
-                       get { return _caption.Text; } \r
+                       get { return _caption == null ? "" : _caption.Text; } \r
                        set { \r
+                               if (_caption == null)\r
+                                       return;\r
                                _caption.Text = value; \r
                        }\r
                }\r
@@ -64,5 +70,10 @@ namespace go
                        IsChecked = !IsChecked;\r
                        base.onMouseClick (sender, e);\r
                }\r
+\r
+               public override void ReadXml (System.Xml.XmlReader reader)\r
+               {\r
+                       base.ReadXml (reader);\r
+               }\r
        }\r
 }\r
index 66e3b9e4c8277a9560de6129eec1fa2d5ad10d96..c0ac00c617f7362849a3333cc71401b2917de7f3 100644 (file)
@@ -7,7 +7,7 @@ using System.Linq;
 \r
 namespace go\r
 {\r
-    public class Container : GraphicObject, IXmlSerializable\r
+    public class Container : PrivateContainer, IXmlSerializable\r
     {\r
                #region CTOR\r
                public Container()\r
@@ -20,151 +20,16 @@ namespace go
                }\r
                #endregion\r
 \r
-               public GraphicObject child;\r
-\r
-        public T setChild<T>(T _child)\r
-        {\r
-\r
-                       if (child != null) {\r
-                               this.RegisterForLayouting ((int)LayoutingType.Sizing);\r
-                               child.Parent = null;\r
-                       }\r
-\r
-            child = _child as GraphicObject;\r
-\r
-                       if (child != null) {\r
-                               child.Parent = this;\r
-                               child.RegisterForLayouting ((int)LayoutingType.Sizing);\r
-                       }\r
-\r
-            return (T)_child;\r
-        }\r
-\r
-               #region GraphicObject Overrides\r
-               //check if not causing problems\r
-               [XmlAttributeAttribute()][DefaultValue(true)]\r
-               public override bool Focusable\r
-               {\r
-                       get { return base.Focusable; }\r
-                       set { base.Focusable = value; }\r
-               }\r
-\r
-               public override GraphicObject FindByName (string nameToFind)\r
-               {\r
-                       if (Name == nameToFind)\r
-                               return this;\r
-\r
-                       return child == null ? null : child.FindByName (nameToFind);\r
-               }\r
-               public override bool Contains (GraphicObject goToFind)\r
-               {\r
-                       return child == goToFind ? true : \r
-                               child == null ? false : child.Contains(goToFind);\r
-               }\r
-               protected override Size measureRawSize ()\r
-               {                       \r
-                       return child == null ? Bounds.Size : new Size(child.Slot.Width + 2 * Margin, child.Slot.Height + 2 * (Margin));\r
+               [XmlIgnore]\r
+               public GraphicObject Child {\r
+                       get { return child; }\r
+                       set { child = value; }\r
                }\r
-\r
-               protected override void OnLayoutChanges (LayoutingType layoutType)\r
+               public T SetChild<T> (T _child)\r
                {\r
-                       switch (layoutType) {\r
-                       case LayoutingType.Width:                               \r
-                               base.OnLayoutChanges (layoutType);\r
-                               if (child != null) {\r
-                                       if (child.getBounds ().Width == 0)\r
-                                               child.RegisterForLayouting ((int)LayoutingType.Width);\r
-                                       else\r
-                                               child.RegisterForLayouting ((int)LayoutingType.X);\r
-                               }\r
-                               break;\r
-                       case LayoutingType.Height:\r
-                               base.OnLayoutChanges (layoutType);\r
-                               if (child != null) {\r
-                                       if (child.getBounds ().Height == 0)\r
-                                               child.RegisterForLayouting ((int)LayoutingType.Height);\r
-                                       else\r
-                                               child.RegisterForLayouting ((int)LayoutingType.Y);\r
-                               }\r
-                               break;\r
-                       }                                                       \r
+                       return base.SetChild (_child);\r
                }\r
 \r
-//             public override void RegisterForLayouting(int layoutType)\r
-//             {\r
-//                     Interface.LayoutingQueue.RemoveAll (lq => lq.GraphicObject == this && (layoutType & (int)lq.LayoutType) > 0);\r
-//\r
-//                     if ((layoutType & (int)LayoutingType.Width) > 0) {\r
-//                             if (Bounds.Width == 0) //stretch in parent\r
-//                                     Interface.LayoutingQueue.EnqueueAfterParentSizing (LayoutingType.Width, this);\r
-//                             else //fit ou fixed\r
-//                                     Interface.LayoutingQueue.Enqueue (LayoutingType.Width, this);\r
-//                     }\r
-//\r
-//                     if ((layoutType & (int)LayoutingType.Height) > 0) {\r
-//                             if (Bounds.Height == 0) //stretch in parent\r
-//                                     Interface.LayoutingQueue.EnqueueAfterParentSizing (LayoutingType.Height, this);\r
-//                             else//fit ou fixed\r
-//                                     Interface.LayoutingQueue.Enqueue (LayoutingType.Height, this);\r
-//                     }\r
-//\r
-//                     if ((layoutType & (int)LayoutingType.X) > 0)\r
-//                             //for x positionning, sizing of parent and this have to be done\r
-//                             Interface.LayoutingQueue.EnqueueAfterThisAndParentSizing (LayoutingType.X, this);\r
-//\r
-//                     if ((layoutType & (int)LayoutingType.Y) > 0)\r
-//                             //for x positionning, sizing of parent and this have to be done\r
-//                             Interface.LayoutingQueue.EnqueueAfterThisAndParentSizing (LayoutingType.Y, this);\r
-//\r
-//             }\r
-\r
-               public override Rectangle ContextCoordinates (Rectangle r)\r
-               {\r
-                       return\r
-                               Parent.ContextCoordinates(r) + getSlot().Position +  ClientRectangle.Position;\r
-\r
-               }\r
-               public override void Paint(ref Cairo.Context ctx, Rectangles clip = null)\r
-        {\r
-            if (!Visible)//check if necessary??\r
-                return;\r
-\r
-            ctx.Save();\r
-\r
-//                     ctx.Rectangle(ContextCoordinates(Slot));\r
-//            ctx.Clip();\r
-//\r
-            if (clip != null)\r
-                               clip.clip(ctx);\r
-\r
-            base.Paint(ref ctx, clip);\r
-\r
-            //clip to client zone\r
-                       ctx.Rectangle(Parent.ContextCoordinates(ClientRectangle + Slot.Position));\r
-                       ctx.Clip();\r
-\r
-//            if (clip != null)\r
-//                clip.Rebase(this);\r
-\r
-            if (child != null)\r
-                child.Paint(ref ctx, clip);\r
-\r
-            ctx.Restore();            \r
-        }\r
-               #endregion\r
-\r
-               #region Mouse handling\r
-               public override void onMouseMove (object sender, MouseMoveEventArgs e)\r
-               {\r
-                       base.onMouseMove (sender, e);\r
-\r
-                       if (child != null) \r
-                               if (child.MouseIsIn (e.Position)) \r
-                                       child.onMouseMove (sender, e);\r
-                       \r
-               }\r
-               #endregion\r
-\r
                #region IXmlSerializable\r
 \r
         public override System.Xml.Schema.XmlSchema GetSchema()\r
@@ -173,8 +38,10 @@ namespace go
         }\r
         public override void ReadXml(System.Xml.XmlReader reader)\r
         {\r
+                       //only read attributes in GraphicObject IXmlReader implementation\r
             base.ReadXml(reader);\r
 \r
+\r
             using (System.Xml.XmlReader subTree = reader.ReadSubtree())\r
             {\r
                 subTree.Read(); //skip current node\r
@@ -188,24 +55,20 @@ namespace go
 \r
                 (go as IXmlSerializable).ReadXml(subTree);\r
                 \r
-                setChild(go);\r
-\r
-                subTree.Read();\r
-\r
-                if (!subTree.IsStartElement())\r
-                    return;\r
+                SetChild(go);\r
 \r
+                subTree.Read();//closing tag\r
             }\r
         }\r
         public override void WriteXml(System.Xml.XmlWriter writer)\r
         {\r
             base.WriteXml(writer);\r
 \r
-            if (child == null)\r
+            if (Child == null)\r
                 return;\r
 \r
-            writer.WriteStartElement(child.GetType().Name);\r
-            (child as IXmlSerializable).WriteXml(writer);\r
+            writer.WriteStartElement(Child.GetType().Name);\r
+            (Child as IXmlSerializable).WriteXml(writer);\r
             writer.WriteEndElement();\r
         }\r
     \r
diff --git a/src/GraphicObjects/Expandable.cs b/src/GraphicObjects/Expandable.cs
new file mode 100644 (file)
index 0000000..e3274ca
--- /dev/null
@@ -0,0 +1,144 @@
+using System;\r
+\r
+\r
+using System.Collections.Generic;\r
+using System.Linq;\r
+using System.Text;\r
+//using OpenTK.Graphics.OpenGL;\r
+\r
+using Cairo;\r
+\r
+using winColors = System.Drawing.Color;\r
+using System.Diagnostics;\r
+using System.Xml.Serialization;\r
+using OpenTK.Input;\r
+using System.ComponentModel;\r
+using System.Xml;\r
+using System.IO;\r
+\r
+namespace go\r
+{\r
+    public class Expandable : TemplatedControl\r
+    {          \r
+               bool _isExpanded;\r
+               Label _caption;\r
+\r
+               public Container Content;\r
+\r
+               public event EventHandler Expand;\r
+               public event EventHandler Collapse;\r
+\r
+               public Expandable() : base()\r
+               {\r
+               }       \r
+\r
+               protected override void loadTemplate(GraphicObject template = null)\r
+               {\r
+                       if (template == null)\r
+                               this.SetChild (Interface.Load ("#go.Templates.Expandable.goml",this));\r
+                       else\r
+                               this.SetChild (template);\r
+\r
+                       _caption = this.child.FindByName ("Caption") as Label;\r
+                       Content = this.child.FindByName ("Content") as Container;\r
+               }\r
+                       \r
+\r
+               [XmlAttributeAttribute()][DefaultValue("Expandable")]\r
+               public string Title {\r
+                       get { return _caption.Text; } \r
+                       set {\r
+                               if (_caption == null)\r
+                                       return;\r
+                               _caption.Text = value; \r
+                       }\r
+               }        \r
+      \r
+               [XmlAttributeAttribute()][DefaultValue(false)]\r
+        public bool IsExpanded\r
+        {\r
+                       get { return _isExpanded; }\r
+            set\r
+            {\r
+                if (value == _isExpanded)\r
+                    return;\r
+\r
+                               _isExpanded = value;\r
+\r
+                               if (_isExpanded)\r
+                                       onExpand (this, null);\r
+                               else\r
+                                       onCollapse (this, null);\r
+\r
+                registerForGraphicUpdate();\r
+            }\r
+        }\r
+\r
+               public virtual void onExpand(object sender, EventArgs e)\r
+               {\r
+                       Content.Visible = true;\r
+                       Expand.Raise (this, e);\r
+               }\r
+               public virtual void onCollapse(object sender, EventArgs e)\r
+               {\r
+                       Content.Visible = false;\r
+                       Collapse.Raise (this, e);\r
+               }\r
+                       \r
+               public override void onMouseClick (object sender, MouseButtonEventArgs e)\r
+               {\r
+                       IsExpanded = !IsExpanded;\r
+                       base.onMouseClick (sender, e);\r
+               }\r
+\r
+               public override void ReadXml(System.Xml.XmlReader reader)\r
+               {\r
+                       using (System.Xml.XmlReader subTree = reader.ReadSubtree ()) {\r
+                               subTree.Read ();\r
+                               string tmp = subTree.ReadOuterXml ();\r
+\r
+                               //seek for template tag\r
+                               using (XmlReader xr = new XmlTextReader (tmp, XmlNodeType.Element, null)) {\r
+                                       xr.Read ();\r
+                                       base.ReadXml (xr);              \r
+                               }\r
+                               //process content\r
+                               using (XmlReader xr = new XmlTextReader (tmp, XmlNodeType.Element, null)) {\r
+                                       xr.Read (); //skip current node\r
+\r
+                                       while (!xr.EOF) {\r
+                                               xr.Read (); //read first child\r
+\r
+                                               if (!xr.IsStartElement ())\r
+                                                       continue;\r
+                                               if (xr.Name == "Template")\r
+                                                       continue;\r
+\r
+                                               Type t = Type.GetType ("go." + xr.Name);\r
+                                               GraphicObject go = (GraphicObject)Activator.CreateInstance (t);                                \r
+\r
+                                               (go as IXmlSerializable).ReadXml (xr);\r
+\r
+                                               Content.SetChild (go);\r
+\r
+                                               xr.Read (); //closing tag\r
+                                       }\r
+                                               \r
+                               }\r
+                       }\r
+               }\r
+               public override void WriteXml(System.Xml.XmlWriter writer)\r
+               {\r
+                       base.WriteXml(writer);\r
+\r
+                       if (Content == null)\r
+                               return;\r
+                       if (Content.Child == null)\r
+                               return;\r
+                       //TODO: if template is not the default one, we have to save it\r
+                       writer.WriteStartElement(Content.Child.GetType().Name);\r
+                       (Content.Child as IXmlSerializable).WriteXml(writer);\r
+                       writer.WriteEndElement();\r
+               }\r
+       }\r
+}\r
index 63a70ad3e479751541cb9243c8fefc578a511ece..0b37f07b3c8c593940ef4ad14ed666c28580d93e 100644 (file)
@@ -66,14 +66,14 @@ namespace go
                        Size tmp = new Size ();\r
 \r
                        if (Orientation == Orientation.Horizontal) {\r
-                               foreach (GraphicObject c in Children) {\r
+                               foreach (GraphicObject c in Children.Where(ch=>ch.Visible)) {\r
                                        tmp.Width += c.Slot.Width + Spacing;\r
                                        tmp.Height = Math.Max (tmp.Height, c.Slot.Bottom);\r
                                }\r
                                if (tmp.Width > 0)\r
                                        tmp.Width -= Spacing;\r
                        } else {\r
-                               foreach (GraphicObject c in Children) {\r
+                               foreach (GraphicObject c in Children.Where(ch=>ch.Visible)) {\r
                                        tmp.Width = Math.Max (tmp.Width, c.Slot.Right);\r
                                        tmp.Height += c.Slot.Height + Spacing;\r
                                }\r
@@ -90,13 +90,13 @@ namespace go
                {\r
                        int d = 0;\r
                        if (Orientation == Orientation.Horizontal) {\r
-                               foreach (GraphicObject c in Children) {\r
+                               foreach (GraphicObject c in Children.Where(ch=>ch.Visible)) {\r
                                        c.Slot.X = d;\r
                                        d += c.Slot.Width + Spacing;\r
                                        c.RegisterForLayouting ((int)LayoutingType.Y);\r
                                }\r
                        } else {\r
-                               foreach (GraphicObject c in Children) {\r
+                               foreach (GraphicObject c in Children.Where(ch=>ch.Visible)) {\r
                                        c.Slot.Y = d;\r
                                        d += c.Slot.Height + Spacing;\r
                                        c.RegisterForLayouting ((int)LayoutingType.X);\r
@@ -119,11 +119,11 @@ namespace go
                                //this child will occupy remaining space\r
                                if (Orientation == Orientation.Horizontal) {\r
                                        if (Width >= 0) {\r
-                                               GraphicObject[] gobjs = Children.Where (c => c.Width == 0).ToArray();\r
+                                               GraphicObject[] gobjs = Children.Where (c => c.Width == 0 && c.Visible).ToArray();\r
                                                if (gobjs.Length > 1)\r
                                                        throw new Exception ("Only one child in stack may have size to stretched");\r
                                                else if (gobjs.Length == 1) {\r
-                                                       int sz = Children.Except (gobjs).Sum (g => g.Slot.Width);\r
+                                                       int sz = Children.Where(ch=>ch.Visible).Except (gobjs).Sum (g => g.Slot.Width);\r
                                                        if (sz < Slot.Width) {\r
                                                                gobjs [0].Slot.Width = Slot.Width - sz - Spacing;\r
                                                                int idx = Children.IndexOf (gobjs [0]);\r
@@ -139,11 +139,11 @@ namespace go
                                        }                                       \r
                                } else {\r
                                        if (Height >= 0) {\r
-                                               GraphicObject[] gobjs = Children.Where (c => c.Height == 0).ToArray();\r
+                                               GraphicObject[] gobjs = Children.Where(ch=>ch.Visible).Where (c => c.Height == 0).ToArray();\r
                                                if (gobjs.Length > 1)\r
                                                        throw new Exception ("Only one child in stack may have size to stretched");\r
                                                else if (gobjs.Length == 1) {\r
-                                                       int sz = Children.Except (gobjs).Sum (g => g.Slot.Height);\r
+                                                       int sz = Children.Where(ch=>ch.Visible).Except (gobjs).Sum (g => g.Slot.Height);\r
                                                        if (sz < Slot.Height) {\r
                                                                gobjs [0].Slot.Height = Slot.Height - sz;\r
                                                                int idx = Children.IndexOf (gobjs [0]);\r
index 9e55d1cfabedd63c72ed44afc90fb1012a1e6937..8098f86334e700c7dca1f34c53f36e7f0e922237 100644 (file)
@@ -238,13 +238,16 @@ namespace go
 \r
                                _isVisible = value;\r
 \r
+                               if (TopContainer == null)\r
+                                       return;\r
                                //add slot to clipping to redraw\r
                                TopContainer.gobjsToRedraw.Add (this);\r
 \r
                                //ensure main win doesn't keep hidden childrens ref\r
                                if (this.Contains (TopContainer.hoverWidget))\r
                                        TopContainer.hoverWidget = null;\r
-//                             if (Parent != null)\r
+                               if (Parent is GenericStack)\r
+                                       Parent.RegisterForLayouting ((int)LayoutingType.Sizing | (int)LayoutingType.PositionChildren);\r
 //                                     Parent.InvalidateLayout ();\r
                                //else\r
                                //    registerForRedraw();\r
@@ -666,7 +669,6 @@ namespace go
                }\r
                        \r
                #region IXmlSerializable\r
-\r
                public virtual System.Xml.Schema.XmlSchema GetSchema ()\r
                {\r
                        return null;\r
@@ -802,7 +804,6 @@ namespace go
                        }\r
 \r
                }\r
-\r
                public virtual void WriteXml (System.Xml.XmlWriter writer)\r
                {\r
                        foreach (PropertyInfo pi in this.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance)) {\r
@@ -889,7 +890,7 @@ namespace go
                                } \r
                        }\r
                }\r
+               #endregion\r
 \r
-               #endregion      \r
        }\r
 }\r
index 42da7983016d6c64e90bd3deea98baa317e27d82..f1620a2a4261c3f87ac7135fdcee4f11d6b76397 100644 (file)
@@ -109,7 +109,7 @@ namespace go
                {\r
                        Size tmp = new Size ();\r
 \r
-                       foreach (GraphicObject c in Children) {\r
+                       foreach (GraphicObject c in Children.Where(ch=>ch.Visible)) {\r
                                tmp.Width = Math.Max (tmp.Width, c.Slot.Right);\r
                                tmp.Height = Math.Max (tmp.Height, c.Slot.Bottom);\r
                        }\r
@@ -129,14 +129,14 @@ namespace go
                        case LayoutingType.Width:                               \r
                                if (Width < 0) {\r
                                        int crw = ClientRectangle.Width;\r
-                                       foreach (GraphicObject c in Children.Where(ch => ch.Slot.Width != crw))\r
+                                       foreach (GraphicObject c in Children.Where(ch => ch.Slot.Width != crw && ch.Visible))\r
                                                c.RegisterForLayouting ((int)LayoutingType.X);                                          \r
                                }\r
                                break;\r
                        case LayoutingType.Height:\r
                                if (Height < 0) {\r
                                        int crh = ClientRectangle.Height;\r
-                                       foreach (GraphicObject c in Children.Where(ch => ch.Slot.Height != crh))\r
+                                       foreach (GraphicObject c in Children.Where(ch => ch.Slot.Height != crh && ch.Visible))\r
                                                c.RegisterForLayouting ((int)LayoutingType.Y);                                          \r
                                }\r
                                break;\r
@@ -154,7 +154,7 @@ namespace go
                        CairoHelpers.CairoRectangle(gr,rBack,CornerRadius);\r
                        gr.Fill ();\r
 \r
-                       foreach (GraphicObject g in Children) {\r
+                       foreach (GraphicObject g in Children.Where(ch=>ch.Visible)) {\r
                                g.Paint (ref gr);\r
                        }\r
                }\r
@@ -197,7 +197,7 @@ namespace go
                                                #if DEBUG_CLIP_RECTANGLE\r
                                                clip.stroke (gr, Color.Amaranth.AdjustAlpha (0.8));\r
                                                #endif\r
-                                               foreach (GraphicObject c in Children) {\r
+                                               foreach (GraphicObject c in Children.Where(ch=>ch.Visible)) {\r
                                                        Rectangles childClip = clip.intersectingRects (ContextCoordinates(c.Slot));\r
                                                        if (!c.DrawingIsValid || childClip.count > 0)\r
                                                                c.Paint (ref gr,childClip);//, localClip);\r
index 1f0ccf5eeafee461963aedb1c21f7153d9ef9179..ce6db79b078beefbe5aad3b0c1a6c7029ee7f975 100644 (file)
@@ -34,9 +34,13 @@ namespace go
                }
 
                #region implemented abstract members of TemplatedControl
-               protected override void loadTemplate ()
+               protected override void loadTemplate (GraphicObject template = null)
                {
-                       this.setChild (Interface.Load ("#go.Templates.Listbox.goml"));
+                       if (template == null)
+                               this.SetChild (Interface.Load ("#go.Templates.Listbox.goml"));
+                       else
+                               this.SetChild (template);
+                       
                        _list = this.child.FindByName ("List") as Group;
                }
                #endregion
diff --git a/src/GraphicObjects/PrivateContainer.cs b/src/GraphicObjects/PrivateContainer.cs
new file mode 100644 (file)
index 0000000..23d65c2
--- /dev/null
@@ -0,0 +1,165 @@
+//
+//  PrivateContainer.cs
+//
+//  Author:
+//       Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
+//
+//  Copyright (c) 2015 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;
+using OpenTK.Input;
+
+namespace go
+{
+       /// <summary>
+       /// Implement drawing and layouting for a single child, but
+       /// does not implement IXmlSerialisation to allow reuse of container
+       /// behaviour for widgets that have other xml hierarchy: example
+       /// TemplatedControl may have 3 children (template,templateItem,content) but
+       /// behave exactely as a container for layouting and drawing
+       /// </summary>
+       public class PrivateContainer : GraphicObject
+       {
+               #region CTOR
+               public PrivateContainer()
+                       : base()
+               {
+               }
+               public PrivateContainer(Rectangle _bounds)
+                       : base(_bounds)
+               {
+               }
+               #endregion
+
+               protected GraphicObject child;
+
+               protected virtual T SetChild<T>(T _child)
+               {
+
+                       if (child != null) {
+                               this.RegisterForLayouting ((int)LayoutingType.Sizing);
+                               child.Parent = null;
+                       }
+
+                       child = _child as GraphicObject;
+
+                       if (child != null) {
+                               child.Parent = this;
+                               child.RegisterForLayouting ((int)LayoutingType.Sizing);
+                       }
+
+                       return (T)_child;
+               }
+
+               #region GraphicObject Overrides
+               //check if not causing problems
+               [XmlAttributeAttribute()][DefaultValue(true)]
+               public override bool Focusable
+               {
+                       get { return base.Focusable; }
+                       set { base.Focusable = value; }
+               }
+
+               public override GraphicObject FindByName (string nameToFind)
+               {
+                       if (Name == nameToFind)
+                               return this;
+
+                       return child == null ? null : child.FindByName (nameToFind);
+               }
+               public override bool Contains (GraphicObject goToFind)
+               {
+                       return child == goToFind ? true : 
+                               child == null ? false : child.Contains(goToFind);
+               }
+               protected override Size measureRawSize ()
+               {                       
+                       return child == null ? Bounds.Size : new Size(child.Slot.Width + 2 * Margin, child.Slot.Height + 2 * (Margin));
+               }
+
+               protected override void OnLayoutChanges (LayoutingType layoutType)
+               {
+                       switch (layoutType) {
+                       case LayoutingType.Width:                               
+                               base.OnLayoutChanges (layoutType);
+                               if (child != null) {
+                                       if (child.getBounds ().Width == 0)
+                                               child.RegisterForLayouting ((int)LayoutingType.Width);
+                                       else
+                                               child.RegisterForLayouting ((int)LayoutingType.X);
+                               }
+                               break;
+                       case LayoutingType.Height:
+                               base.OnLayoutChanges (layoutType);
+                               if (child != null) {
+                                       if (child.getBounds ().Height == 0)
+                                               child.RegisterForLayouting ((int)LayoutingType.Height);
+                                       else
+                                               child.RegisterForLayouting ((int)LayoutingType.Y);
+                               }
+                               break;
+                       }                                                       
+               }
+
+               public override Rectangle ContextCoordinates (Rectangle r)
+               {
+                       return
+                               Parent.ContextCoordinates(r) + getSlot().Position +  ClientRectangle.Position;
+               }
+               public override void Paint(ref Cairo.Context ctx, Rectangles clip = null)
+               {
+                       if (!Visible)//check if necessary??
+                               return;
+
+                       ctx.Save();
+
+                       //                      ctx.Rectangle(ContextCoordinates(Slot));
+                       //            ctx.Clip();
+                       //
+                       if (clip != null)
+                               clip.clip(ctx);
+
+                       base.Paint(ref ctx, clip);
+
+                       //clip to client zone
+                       ctx.Rectangle(Parent.ContextCoordinates(ClientRectangle + Slot.Position));
+                       ctx.Clip();
+
+                       //            if (clip != null)
+                       //                clip.Rebase(this);
+
+                       if (child != null)
+                               child.Paint(ref ctx, clip);
+
+                       ctx.Restore();            
+               }
+               #endregion
+
+               #region Mouse handling
+               public override void onMouseMove (object sender, MouseMoveEventArgs e)
+               {
+                       base.onMouseMove (sender, e);
+
+                       if (child != null) 
+                       if (child.MouseIsIn (e.Position)) 
+                               child.onMouseMove (sender, e);
+
+               }
+               #endregion
+       }
+}
+
index 9d6990db94e2b1c4b936dd5fd52da056666c40aa..71911d6801312d91832fdadcd30568161f582aab 100644 (file)
@@ -25,9 +25,13 @@ namespace go
                {\r
                }       \r
 \r
-               protected override void loadTemplate()\r
+               protected override void loadTemplate(GraphicObject template = null)\r
                {\r
-                       this.setChild (Interface.Load ("#go.Templates.RadioButton.goml"));\r
+                       if (template == null)\r
+                               this.SetChild (Interface.Load ("#go.Templates.RadioButton.goml"));\r
+                       else\r
+                               this.SetChild (template);\r
+\r
                        _caption = this.child.FindByName ("Caption") as Label;\r
                        _image = this.child.FindByName ("Image") as Image;\r
                        _image.SvgSub = "unchecked";\r
index fa323f0d4c222f528a39990d7bc6c51ecd5a1666..0b0eaae77528602ef467b8ab1136fe0b3149472a 100644 (file)
@@ -66,7 +66,7 @@ namespace go
 //                     if (MouseWheelChanged!=null)\r
 //                             MouseWheelChanged (this, e);\r
 \r
-                       if (child == null)\r
+                       if (Child == null)\r
                                return;\r
                        \r
                        if (VerticalScrolling )\r
@@ -78,8 +78,8 @@ namespace go
 \r
                 if (scrollY > 0)\r
                     scrollY = 0;\r
-                               else if (scrollY < -child.Slot.Height + ClientRectangle.Height)\r
-                                       scrollY = -child.Slot.Height + ClientRectangle.Height;\r
+                               else if (scrollY < -Child.Slot.Height + ClientRectangle.Height)\r
+                                       scrollY = -Child.Slot.Height + ClientRectangle.Height;\r
 \r
             }\r
             if (HorizontalScrolling )\r
@@ -91,8 +91,8 @@ namespace go
 \r
                                if (scrollX > 0)\r
                                        scrollX = 0;\r
-                               else if (scrollX < -child.Slot.Width + ClientRectangle.Width)\r
-                                       scrollX = -child.Slot.Width + ClientRectangle.Width;\r
+                               else if (scrollX < -Child.Slot.Width + ClientRectangle.Width)\r
+                                       scrollX = -Child.Slot.Width + ClientRectangle.Width;\r
             }\r
 \r
 \r
@@ -141,8 +141,8 @@ namespace go
                        //            if (clip != null)\r
                        //                clip.Rebase(this);\r
 \r
-                       if (child != null)\r
-                               child.Paint(ref ctx, clip);\r
+                       if (Child != null)\r
+                               Child.Paint(ref ctx, clip);\r
 \r
                        ctx.Restore();            \r
                }\r
index 8c314377615c30e438e0ca3fde8e57dfde6daadd..7a5623f826847ff20d730cf98defe060e1f54896 100644 (file)
@@ -22,7 +22,7 @@ namespace go
 \r
                #region implemented abstract members of TemplatedControl\r
 \r
-               protected override void loadTemplate ()\r
+               protected override void loadTemplate (GraphicObject template = null)\r
                {\r
                        \r
                }\r
index 4706effe42fceee7e2041b34e8dca0c41cefb230..4bd3a723b005b45e68ed9ec9e71648effdc589d4 100644 (file)
@@ -40,9 +40,13 @@ namespace go
 
                #region implemented abstract members of TemplatedControl
 
-               protected override void loadTemplate ()
+               protected override void loadTemplate (GraphicObject template = null)
                {
-                       this.setChild (Interface.Load ("#go.Templates.Spinner.goml", this));
+                       if (template == null)
+                               this.SetChild (Interface.Load ("#go.Templates.Spinner.goml", this));
+                       else
+                               this.SetChild (template);
+                       
                        labCpt = this.child.FindByName ("labCpt") as Label;
                }
 
index df84307683045e4fa235639495db6cc1d9503f27..75d5b54ffb23287c9b06d4f3e55a5141e901d55f 100644 (file)
 using System;
 using System.Xml.Serialization;
 using System.ComponentModel;
+using System.IO;
+using System.Xml;
 
 namespace go
 {
-       public abstract class TemplatedControl : Container, IXmlSerializable
+       public abstract class TemplatedControl : PrivateContainer, IXmlSerializable
        {
                public TemplatedControl () : base()
                {
@@ -38,11 +40,12 @@ namespace go
 //             }
 
 
-               protected abstract void loadTemplate();
+               protected abstract void loadTemplate(GraphicObject template = null);
 
                protected override void loadDefaultValues ()
                {
-                       loadTemplate ();
+                       if (child == null)//trigger loading of default template if child is empty
+                               loadTemplate ();
                        base.loadDefaultValues ();
                        this.Focusable = true;
                }
@@ -61,29 +64,42 @@ namespace go
                }
                public override void ReadXml(System.Xml.XmlReader reader)
                {
-                       base.ReadXml(reader);
+                       using (System.Xml.XmlReader subTree = reader.ReadSubtree())
+                       {
+                               subTree.Read ();
+                               string tmp = subTree.ReadOuterXml ();
 
-//                     using (System.Xml.XmlReader subTree = reader.ReadSubtree())
-//                     {
-//                             subTree.Read(); //skip current node
-//                             subTree.Read(); //read first child
-//
-//                             if (!subTree.IsStartElement())
-//                                     return;
-//
-//                             Type t = Type.GetType("go." + subTree.Name);
-//                             GraphicObject go = (GraphicObject)Activator.CreateInstance(t);                                
-//
-//                             (go as IXmlSerializable).ReadXml(subTree);
-//
-//                             setChild(go);
-//
-//                             subTree.Read();
-//
-//                             if (!subTree.IsStartElement())
-//                                     return;
-//
-//                     }
+                                       //seek for template tag first
+                               using (XmlReader xr = new XmlTextReader (tmp, XmlNodeType.Element, null)) {
+                                       //load template first if inlined
+
+                                       xr.Read (); //skip current node
+
+                                       while (!xr.EOF) {
+                                               xr.Read (); //read first child
+                                               if (!xr.IsStartElement ())
+                                                       continue;
+                                               if (xr.Name == "Template") {
+                                                       xr.Read ();
+
+                                                       Type t = Type.GetType ("go." + xr.Name);
+                                                       GraphicObject go = (GraphicObject)Activator.CreateInstance (t);                                
+                                                       (go as IXmlSerializable).ReadXml (xr);
+
+                                                       loadTemplate (go);
+
+                                                       xr.Read ();//go close tag
+                                                       xr.Read ();//Template close tag
+                                               } else {
+                                                       xr.ReadInnerXml ();
+                                               }
+                                       }
+                               }
+                               using (XmlReader xr = new XmlTextReader (tmp, XmlNodeType.Element, null)) {
+                                       xr.Read ();
+                                       base.ReadXml(xr);
+                               }
+                       }
                }
                public override void WriteXml(System.Xml.XmlWriter writer)
                {
index 2b80564ffdcca4ae59706f7eedcaf9d9bf7dd408..29e276c04bd2d8968418907b4b41fba08cca2d96 100644 (file)
@@ -45,9 +45,14 @@ namespace go
 
                #region Load/Save
 
-               internal static List<DynAttribute> EventsToResolve;
+               internal static Stack<List<DynAttribute>> EventsResolutionStack = new Stack<List<DynAttribute>>();
+               internal static List<DynAttribute> EventsToResolve
+               {
+                       get { return EventsResolutionStack.Peek ();}
+               }
                internal static List<DynAttribute> Bindings;
 
+
                public static void Save<T>(string file, T graphicObject)
                {            
                        XmlSerializerNamespaces xn = new XmlSerializerNamespaces();
@@ -105,7 +110,7 @@ namespace go
                {
                        //result = (T)(Load (file, hostClass) as object);
 
-                       EventsToResolve = new List<DynAttribute>();
+                       EventsResolutionStack.Push(new List<DynAttribute>());
                        Bindings = new List<DynAttribute> ();
 
                        XmlSerializerNamespaces xn = new XmlSerializerNamespaces();
@@ -120,27 +125,8 @@ namespace go
                        if (hostClass == null)
                                return;
 
-                       foreach (DynAttribute es in EventsToResolve)
-                       {
-                               if (string.IsNullOrEmpty(es.Value))
-                                       continue;
+                       resolveEvents (hostClass);
 
-                               if (es.Value.StartsWith ("{")) {
-                                       CompilerServices.CompileEventSource (es);
-                               } else {                                        
-                                       MethodInfo mi = hostClass.GetType ().GetMethod (es.Value, BindingFlags.NonPublic | BindingFlags.Public
-                                               | BindingFlags.Instance);
-
-                                       if (mi == null) {
-                                               Debug.WriteLine ("Handler Method not found: " + es.Value);
-                                               continue;
-                                       }
-
-                                       FieldInfo fi = CompilerServices.getEventHandlerField (es.Source.GetType (), es.MemberName);
-                                       Delegate del = Delegate.CreateDelegate(fi.FieldType, hostClass, mi);
-                                       fi.SetValue(es.Source, del);
-                               }
-                       }
                        while (Bindings.Count > 0) {
                                DynAttribute binding = Bindings [0];
                                Bindings.RemoveAt (0);
@@ -157,10 +143,11 @@ namespace go
 //                     }
 //                     Bindings.Clear ();
                }
+
                public static GraphicObject Load(Stream stream, Type type, object hostClass = null)
                {
                        GraphicObject result;
-                       EventsToResolve = new List<DynAttribute>();
+                       EventsResolutionStack.Push(new List<DynAttribute>());
 
                        XmlSerializerNamespaces xn = new XmlSerializerNamespaces();
                        xn.Add("", "");
@@ -171,6 +158,31 @@ namespace go
                        if (hostClass == null)
                                return result;
 
+                       resolveEvents (hostClass);
+
+                       while (Bindings.Count > 0) {
+                               DynAttribute binding = Bindings [0];
+                               Bindings.RemoveAt (0);
+                               CompilerServices.ResolveBinding (binding, hostClass);
+                       }
+
+//                     foreach (DynAttribute binding in Bindings) {
+//                             //                              Type tSource = binding.Source.GetType ();
+//                             //                              if (!tSource.GetInterfaces ().Any (i => i.Name == "IValueChange")){
+//                             //                                      Debug.WriteLine ("Binding source does not implement IValueChange.");
+//                             //                                      continue;
+//                             //                              }
+//                             //MemberInfo mi = binding.Source.GetType ().GetMember (binding.MemberName);
+//                             CompilerServices.CreateBinding (binding, hostClass);
+//                     }
+//                     Bindings.Clear ();
+
+
+                       return result;
+               }
+
+               static void resolveEvents(object hostClass)
+               {
                        foreach (DynAttribute es in EventsToResolve)
                        {
                                if (string.IsNullOrEmpty(es.Value))
@@ -192,25 +204,8 @@ namespace go
                                        fi.SetValue(es.Source, del);
                                }
                        }
-                       while (Bindings.Count > 0) {
-                               DynAttribute binding = Bindings [0];
-                               Bindings.RemoveAt (0);
-                               CompilerServices.ResolveBinding (binding, hostClass);
-                       }
-
-//                     foreach (DynAttribute binding in Bindings) {
-//                             //                              Type tSource = binding.Source.GetType ();
-//                             //                              if (!tSource.GetInterfaces ().Any (i => i.Name == "IValueChange")){
-//                             //                                      Debug.WriteLine ("Binding source does not implement IValueChange.");
-//                             //                                      continue;
-//                             //                              }
-//                             //MemberInfo mi = binding.Source.GetType ().GetMember (binding.MemberName);
-//                             CompilerServices.CreateBinding (binding, hostClass);
-//                     }
-//                     Bindings.Clear ();
-                       return result;
+                       EventsResolutionStack.Pop();                    
                }
-
                #endregion
        }
 }
index e1d21792790b0f06f05b01b68a79d8b6e351815e..b028fb83be76f7cce1169893a10c5a35b8829000 100644 (file)
@@ -47,7 +47,7 @@ namespace go
                }
                public void ProcessLayouting()
                {
-                       Debug.WriteLine ("Layouting => " + this.ToString ());
+                       //Debug.WriteLine ("Layouting => " + this.ToString ());
                        try {
                                GraphicObject.UpdateLayout (LayoutType);
                        } catch (Exception ex) {