<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" />
$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
</Command>
</CustomCommands>
</CustomCommands>
- <ReleaseVersion>0.3</ReleaseVersion>
+ <ReleaseVersion>0.4</ReleaseVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
int frameCpt = 0;
int idx = 0;
string[] testFiles = {
+ "0.crow",
"1.crow",
"testWindow.goml",
"clip4.crow",
"clip2.crow",
"clip0.crow",
"clip1.crow",
- "0.crow",
"5.crow",
"testCombobox.goml",
"testPopper.goml",
<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>
<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"/>
<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"/>
<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
<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>
List<GraphicObject> _gobjsToRedraw = new List<GraphicObject>();
#region IGOLibHost implementation
+ public XCursor MouseCursor {
+ set { throw new NotImplementedException ();}
+ }
public Rectangles clipping {
get {
return _redrawClip;
<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>
{
#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;
/// <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);
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))
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);
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)
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)
{
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;
{
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);
--- /dev/null
+//
+// 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
+ }
+}
+
}
}
[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){}