]> O.S.I.I.S - jp/crow.git/commitdiff
Splitter
authorjpbruyere <jp.bruyere@hotmail.com>
Sat, 13 Feb 2016 01:28:12 +0000 (02:28 +0100)
committerjpbruyere <jp.bruyere@hotmail.com>
Sat, 13 Feb 2016 02:19:44 +0000 (03:19 +0100)
15 files changed:
Crow.csproj
Crow.sln
MonoDevelop.GOLib/MonoDevelop.GOLib.csproj
Tests/GOLIBTests.cs
Tests/Interfaces/0.crow
Tests/Interfaces/1.crow
Tests/Tests.csproj
UnitTest/NUnitCrowWindow.cs
UnitTest/UnitTest.csproj
src/GraphicObjects/Button.cs
src/GraphicObjects/GraphicObject.cs
src/GraphicObjects/Group.cs
src/GraphicObjects/PrivateContainer.cs
src/GraphicObjects/Splitter.cs [new file with mode: 0644]
src/GraphicObjects/TemplatedControl.cs

index a29b772156479547ed5d9be557b7e5f6f069d804..19aee4318e05c0fb5e8732b5c8955f8ddf4043a2 100644 (file)
@@ -23,7 +23,7 @@
     <SchemaVersion>2.0</SchemaVersion>
     <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ReleaseVersion>0.3</ReleaseVersion>
+    <ReleaseVersion>0.4</ReleaseVersion>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
     <DebugSymbols>true</DebugSymbols>
     <Compile Include="src\LayoutingEventArgs.cs" />
     <Compile Include="src\ScrollingEventArgs.cs" />
     <Compile Include="src\GraphicObjects\Trend.cs" />
+    <Compile Include="src\GraphicObjects\Splitter.cs" />
   </ItemGroup>
   <ItemGroup>
     <Reference Include="System" />
index 2b78e80909266ab90c776126473a4d9916b787d9..0172fbe1570893aeb1aa9498bd9a4f215bea220b 100644 (file)
--- a/Crow.sln
+++ b/Crow.sln
@@ -42,6 +42,6 @@ Global
                $2.DirectoryNamespaceAssociation = None
                $2.ResourceNamePolicy = FileFormatDefault
                description = @C.R.O.W. Collaborative Radiant Open Widgets\n\nA pure c# toolkit with XML definition of interface with binding and\ndynamic delegates
-               version = 0.3
+               version = 0.4
        EndGlobalSection
 EndGlobal
index d094fdf39c41b7ea24b04c5e22407aaf26231cf7..adbc70fb565bd6f754b413beab1fd58887f30fa1 100644 (file)
@@ -23,7 +23,7 @@
         </Command>
       </CustomCommands>
     </CustomCommands>
-    <ReleaseVersion>0.3</ReleaseVersion>
+    <ReleaseVersion>0.4</ReleaseVersion>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <DebugSymbols>true</DebugSymbols>
index a98fccf7f17a3310af1c5d36696aa186c80d6da2..bf0c4b6416f2736343b0d81b3e83c044ec849e5a 100644 (file)
@@ -37,6 +37,7 @@ namespace test
                int frameCpt = 0;
                int idx = 0;
                string[] testFiles = {
+                       "0.crow",
                        "1.crow",
                        "testWindow.goml",
                        "clip4.crow",
@@ -44,7 +45,6 @@ namespace test
                        "clip2.crow",
                        "clip0.crow",
                        "clip1.crow",
-                       "0.crow",
                        "5.crow",
                        "testCombobox.goml",
                        "testPopper.goml",
index 0d84b541c6e8d4c3b55ccf713aa6a05ad40c5595..011148a78a52725ec774e993d2cb989eb9590533 100755 (executable)
@@ -9,7 +9,7 @@
        <Button Caption="test button"/>
        <TextRun Text="text run test"/>
        <TextBox Text="text run test"/>
-       <Border CornerRadius="5" Background="DimGray" >
+       <Border CornerRadius="5" Background="DimGray" Fit="true" >
                <Trend HighThreshold="{fpsMax}" LowThreshold="{fpsMin}" NbValues="5"
                        Height="100" Width="400" NewValue="{fps}" Name="trend" Maximum="600" Foreground="White"/>
        </Border>
index 732814a57f750dace6d81bb5c8e00f849cd53de0..28523e1468da1c8acee2779f4e08a2c24b4d88ee 100755 (executable)
                                <CheckBox IsChecked="false" Caption="Check 4" Background="hgradient|0:LimeGreen|1:Transparent"/>
                        </VerticalStack>
                </Border>
+               <Splitter/>
                <Border Fit="true" CornerRadius="10" BorderWidth="1">
                        <VerticalStack Margin="10">
                                <RadioButton IsChecked="false" Caption="Choice 1" Background="hgradient|0:DarkRed|1:Transparent"/>
+                               <Splitter/>
                                <RadioButton IsChecked="false" Caption="Choice 2"  Background="hgradient|0:DarkRed|1:Transparent"/>
                                <RadioButton IsChecked="true" Caption="Choice 3"  Background="hgradient|0:DarkRed|1:Transparent"/>
                                <RadioButton IsChecked="false" Caption="Choice 4" Background="hgradient|0:DarkRed|1:Transparent"/>
                        </VerticalStack>
                </Border>
-               <Border Fit="true" CornerRadius="10" BorderWidth="1">
+               <Splitter Thickness="3" />
+               <Border Fit="true" CornerRadius="10" BorderWidth="1" MinimumSize="200;200">
                        <VerticalStack Margin="10">
                                <Label Text="label 1" Background="hgradient|0:BlueCrayola|1:Transparent"/>
                                <Label Text="label 2" Background="hgradient|0:BlueCrayola|1:Transparent"/>
@@ -26,6 +29,7 @@
                                <Label Text="label 4" Background="hgradient|0:BlueCrayola|1:Transparent"/>
                        </VerticalStack>
                </Border>
+               <Splitter/>
                <Border Fit="true" CornerRadius="10" BorderWidth="1">
                        <VerticalStack Margin="10">
                                <Button Caption="Button 1" Background="hgradient|0:Red|1:DarkRed" CornerRadius="5"/>
@@ -34,6 +38,7 @@
                                <Button Caption="Button 4" Background="hgradient|0:DarkRed|1:Transparent" CornerRadius="8"/>
                        </VerticalStack>
                </Border>
+               <Splitter/>
        </HorizontalStack>
        <GraphicObject CornerRadius="5" Height="10" Width="600" Background="vgradient|0:Transparent|0,5:White|1:Transparent"/>
 </VerticalStack>
\ No newline at end of file
index 48afea5c8c665cd811bfeed0384098ca7e81878e..e88c107832b430e69f17aadc19717b36f8704144 100644 (file)
@@ -13,7 +13,7 @@
     <OutputPath>..\bin\$(configuration)</OutputPath>
     <IntermediateOutputPath>obj\$(configuration)</IntermediateOutputPath>
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ReleaseVersion>0.3</ReleaseVersion>
+    <ReleaseVersion>0.4</ReleaseVersion>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
     <OutputPath>..\bin\Debug</OutputPath>
index 8be6a568c05fdc38e0154950162d55522eb5bccd..961001e79525bef3f6d9a2b5b45807030cfa0056 100644 (file)
@@ -37,6 +37,9 @@ namespace Crow
                List<GraphicObject> _gobjsToRedraw = new List<GraphicObject>();
 
                #region IGOLibHost implementation
+               public XCursor MouseCursor {
+                       set { throw new NotImplementedException ();}
+               }
                public Rectangles clipping {
                        get {
                                return _redrawClip;
index 47c7e261be0479511df0ebe61445402ec34c2d0e..ddc46b62a35a238218306d3b8b31ee5e58cefbc5 100644 (file)
@@ -10,7 +10,7 @@
     <RootNamespace>UnitTest</RootNamespace>
     <AssemblyName>UnitTest</AssemblyName>
     <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
-    <ReleaseVersion>0.3</ReleaseVersion>
+    <ReleaseVersion>0.4</ReleaseVersion>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <DebugSymbols>true</DebugSymbols>
index 5bf11f68d156bfdf8192188d86d10ffe3a6f964d..9903888b35af2b7df84e4c82ad948ed160af9d63 100644 (file)
@@ -18,12 +18,7 @@ namespace Crow
     {
                #region CTOR
         public Button() : base()
-        {
-                       //MouseEnter += delegate { Background = Color.RedDevil;};
-                       //MouseLeave += delegate { Background = Color.Transparent;};
-//                     MouseButtonDown += delegate { BackImgSub = "pressed"; registerForGraphicUpdate();};
-//                     MouseButtonUp += delegate { BackImgSub = "normal";registerForGraphicUpdate();};
-               }
+        {}
                #endregion
 
                string caption;
index 1f07e9223c4a9b2f0b59be605d18774f527e01d7..b6c3a69dc905c5f008c4a86dfcd9176228fe4672 100644 (file)
@@ -431,7 +431,7 @@ namespace Crow
 
                /// <summary> Loads the default values from XML attributes default </summary>
                protected virtual void loadDefaultValues()
-               {
+               {                       
                        Type thisType = this.GetType ();
                        if (Interface.DefaultValuesLoader.ContainsKey(thisType.FullName)) {
                                Interface.DefaultValuesLoader[thisType.FullName] (this);
@@ -456,20 +456,19 @@ namespace Crow
 
                        il.Emit(OpCodes.Nop);
 
+                       StyleAttribute[] style = thisType.GetCustomAttributes().OfType<StyleAttribute>().ToArray();
+
                        foreach (PropertyInfo pi in thisType.GetProperties(BindingFlags.Public | BindingFlags.Instance)) {
                                string name = "";
+                               object defaultValue = null;
 
                                #region retrieve custom attributes
                                if (pi.GetSetMethod () == null)
                                        continue;
+
                                XmlIgnoreAttribute xia = (XmlIgnoreAttribute)pi.GetCustomAttribute (typeof(XmlIgnoreAttribute));
                                if (xia != null)
-                                       continue;
-                               DefaultValueAttribute dv = (DefaultValueAttribute)pi.GetCustomAttribute (typeof(DefaultValueAttribute));
-                               if (dv == null)
-                                       continue;
-                               object defaultValue = dv.Value;
-
+                                       continue;                                       
                                XmlAttributeAttribute xaa = (XmlAttributeAttribute)pi.GetCustomAttribute (typeof(XmlAttributeAttribute));
                                if (xaa != null) {
                                        if (string.IsNullOrEmpty (xaa.AttributeName))
@@ -477,6 +476,16 @@ namespace Crow
                                        else
                                                name = xaa.AttributeName;
                                }
+
+                               StyleAttribute piStyle = style.Where(s => s.PropertyName == pi.Name).FirstOrDefault();
+                               if (piStyle != null){
+                                       defaultValue = piStyle.DefaultValue;
+                               }else{
+                                       DefaultValueAttribute dv = (DefaultValueAttribute)pi.GetCustomAttribute (typeof(DefaultValueAttribute));
+                                       if (dv == null)
+                                               continue;
+                                       defaultValue = dv.Value;
+                               }                               
                                #endregion
 
                                il.Emit (OpCodes.Ldarg_0);
@@ -758,11 +767,6 @@ namespace Crow
                                LastSlots.Y = Slot.Y;
                                break;
                        case LayoutingType.Width:
-                               //force sizing to fit if parent is sizing on children and
-                               //this object has stretched size
-                               if (Parent.getBounds ().Width < 0 && Width == 0)
-                                       Width = -1;
-
                                if (Width > 0)
                                        Slot.Width = Width;
                                else if (Width < 0)
@@ -788,10 +792,6 @@ namespace Crow
                                LastSlots.Width = Slot.Width;
                                break;
                        case LayoutingType.Height:
-                               //force sizing to fit if parent is sizing on children
-                               if (Parent.getBounds ().Height < 0 && Height == 0)
-                                       Height = -1;
-
                                if (Height > 0)
                                        Slot.Height = Height;
                                else if (Height < 0)
index e1e955793c0f809e09fbe0f0c65cbb8cc9b1cbf6..db2107c4c5b801be0f30fbef48f36e6820e51854 100644 (file)
@@ -158,10 +158,6 @@ namespace Crow
                {
                        GraphicObject g = sender as GraphicObject;
                        switch (arg.LayoutType) {
-                       case LayoutingType.X:
-                               break;
-                       case LayoutingType.Y:
-                               break;
                        case LayoutingType.Width:
                                if (g.Slot.Width > maxChildrenWidth) {
                                        maxChildrenWidth = g.Slot.Width;
index 77bf655f55bfb2a4a60c320b39bb0e8433d39abb..5a680da09ffe71ab9ba24190e0094ab0e762134b 100644 (file)
@@ -95,7 +95,24 @@ namespace Crow
                {                       
                        return child == null ? Bounds.Size : child.Slot.Size + 2 * Margin;
                }
-
+               public override bool UpdateLayout (LayoutingType layoutType)
+               {
+                       if (child != null) {
+                               //force sizing to fit if sizing on children and
+                               //child has stretched size
+                               switch (layoutType) {
+                               case LayoutingType.Width:
+                                       if (Width < 0 && child.Width == 0)
+                                               child.Width = -1;
+                                       break;
+                               case LayoutingType.Height:
+                                       if (Height < 0 && child.Height == 0)
+                                               child.Height = -1;
+                                       break;
+                               }
+                       }
+                       return base.UpdateLayout (layoutType);
+               }
                public override void OnLayoutChanges (LayoutingType layoutType)
                {
                        base.OnLayoutChanges (layoutType);
diff --git a/src/GraphicObjects/Splitter.cs b/src/GraphicObjects/Splitter.cs
new file mode 100644 (file)
index 0000000..09ff6d1
--- /dev/null
@@ -0,0 +1,113 @@
+//
+//  Spliter.cs
+//
+//  Author:
+//       Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+//
+//  Copyright (c) 2016 jp
+//
+//  This program is free software: you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation, either version 3 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+using System;
+using System.Xml.Serialization;
+using System.ComponentModel;
+
+namespace Crow
+{
+       [StyleAttribute("Background", "DimGray")]
+       public class Splitter : GraphicObject
+       {
+               #region CTOR
+               public Splitter (): base(){}
+               #endregion
+
+               int thickness;
+               [XmlAttributeAttribute()][DefaultValue(1)]
+               public virtual int Thickness {
+                       get { return thickness; }
+                       set {
+                               if (thickness == value)
+                                       return;
+                               thickness = value; 
+                               NotifyValueChanged ("Thickness", thickness);
+                               RegisterForLayouting (LayoutingType.Sizing);
+                               registerForGraphicUpdate ();
+                       }
+               } 
+               #region GraphicObject override
+               public override ILayoutable Parent {
+                       get { return base.Parent; }
+                       set {
+                               if (value != null) {                    
+                                       GenericStack gs = value as GenericStack;
+                                       if (gs == null)
+                                               throw new Exception ("Splitter may only be chil of stack");
+                                       
+                               }
+                               base.Parent = value;
+                       }
+               }
+               public override void onMouseEnter (object sender, OpenTK.Input.MouseMoveEventArgs e)
+               {
+                       base.onMouseEnter (sender, e);
+                       if ((Parent as GenericStack).Orientation == Orientation.Horizontal)
+                               this.HostContainer.MouseCursor = XCursor.H;
+                       else
+                               this.HostContainer.MouseCursor = XCursor.V;
+               }
+               public override void onMouseLeave (object sender, OpenTK.Input.MouseMoveEventArgs e)
+               {
+                       base.onMouseLeave (sender, e);
+                       this.HostContainer.MouseCursor = XCursor.Default;
+               }
+               public override void onMouseMove (object sender, OpenTK.Input.MouseMoveEventArgs e)
+               {
+                       base.onMouseMove (sender, e);
+
+                       if (!IsActive)
+                               return;
+
+                       GenericStack gs = Parent as GenericStack;
+                       int ptrThis = gs.Children.IndexOf (this);
+
+                       if (ptrThis == 0 || ptrThis == gs.Children.Count - 1)
+                               return;
+
+                       if (gs.Orientation == Orientation.Horizontal) {
+                               gs.Children [ptrThis - 1].Width = Math.Max(gs.Children [ptrThis - 1].Slot.Width + e.XDelta*2, 1);
+                               gs.Children [ptrThis + 1].Width = Math.Max(gs.Children [ptrThis + 1].Slot.Width - e.XDelta*2, 1);
+                       } else {
+                               gs.Children [ptrThis - 1].Height = Math.Max(gs.Children [ptrThis - 1].Slot.Height + e.YDelta*2, 1);
+                               gs.Children [ptrThis + 1].Height = Math.Max(gs.Children [ptrThis + 1].Slot.Height - e.YDelta*2, 1);
+                       }
+               }
+               public override bool UpdateLayout (LayoutingType layoutType)
+               {
+                       GenericStack gs = Parent as GenericStack;
+                       if (layoutType == LayoutingType.Width){
+                               if (gs.Orientation == Orientation.Horizontal)
+                                       Width = thickness;
+                               else
+                                       Width = 0;
+                       } else if (layoutType == LayoutingType.Height){
+                               if (gs.Orientation == Orientation.Vertical)
+                                       Height = thickness;
+                               else
+                                       Height = 0;
+                       }
+                       return base.UpdateLayout (layoutType);
+               }
+               #endregion
+       }
+}
+
index 50199f7a75c05cfc1883e48d0a217f4e98aeffaa..dd7c742d4b805fdaa2dd0383f3328e3fea326d68 100644 (file)
@@ -38,6 +38,16 @@ namespace Crow
                }
        }
        [AttributeUsage(AttributeTargets.Class)]
+       public class StyleAttribute : Attribute
+       {
+               public string PropertyName = "";
+               public object DefaultValue = null;
+               public StyleAttribute(string _property, object _defValue){
+                       PropertyName = _property;
+                       DefaultValue = _defValue;
+               }
+       }
+       [AttributeUsage(AttributeTargets.Class)]
        public class DefaultTemplate : TemplateAttribute
        {
                public DefaultTemplate(string path) : base(path){}