<Compile Include="src\Mono.Cairo\XlibSurface.cs" />
<Compile Include="src\IML\IMLContext.cs" />
<Compile Include="src\Mono.Cairo\MeshPattern.cs" />
+ <Compile Include="src\GraphicObjects\Shape.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
Background = Transparent;
Checked={Background=DarkSlateGray;Foreground=LightGray;};
Unchecked = {Background=Transparent;Foreground=DimGray;};
+}
+
+ArrowBut {
+ MouseRepeat=true;
+ Height=Fit;
+ Width=Fit;
+ Focusable=true;
+ Foreground=Jet;
+ Background=hgradient|0:Gray|1:Jet;
+ MouseDown={Background=hgradient|0:White|0.2:BlueCrayola|1:Jet};
+ MouseUp={Background=hgradient|0:Gray|1:Jet};
+ MouseEnter={Foreground=Black};
+ MouseLeave={Foreground=Jet};
}
\ No newline at end of file
Name="ItemsContainer" Margin="0" Spacing="1"/>
</Scroller>
<ScrollBar Name="scrollbar1" Value="{²../scroller1.ScrollY}"
+ LargeIncrement="{../scroller1.PageHeight}" SmallIncrement="30"
+ CursorSize="{../scroller1.ChildHeightRatio}"
Maximum="{../scroller1.MaximumScroll}" Orientation="Vertical"
Width="14" />
</HorizontalStack>
<?xml version="1.0"?>
-<Border BorderWidth="1" Foreground="LightGray">
+<Border BorderWidth="1" Foreground="Jet">
<GenericStack Orientation="{./Orientation}" Spacing="0">
- <Button MouseRepeat="true" Width="12" Height="12" MouseClick="./onScrollBack"
- Template="#Crow.Templates.ArrowBut.template">
- <Image Margin="1" Path="#Crow.Images.Icons.updown.svg" SvgSub="up"/>
- </Button>
+ <Shape Style="ArrowBut" MouseClick="./onScrollBack" Path="M 5.5,0.5 L 10.5,10.5 L 0.5,10.5 Z"/>
<Slider Name="Slider"
Orientation="{./Orientation}"
Value="{²./Value}"
Maximum="{./Maximum}"
+ CursorSize="{./CursorSize}"
Height="{./HeightPolicy}" Width="{./WidthPolicy}"
LargeIncrement="{./LargeIncrement}"
SmallIncrement="{./SmallIncrement}"
+ CursorColor="hgradient|0:Gray|1:Jet"
+ Foreground="Jet"
Background="hgradient|0:DimGray|0.1:Gray|0.95:Gray|1:White"/>
- <Button MouseRepeat="true" Width="12" Height="12" MouseClick="./onScrollForth"
- Template="#Crow.Templates.ArrowBut.template">
- <Image Margin="1" Path="#Crow.Images.Icons.updown.svg" SvgSub="down"/>
- </Button>
+ <Shape Style="ArrowBut" MouseClick="./onScrollForth" Path="M 0.5,0.5 L 10.5,0.5 L 5.5,10.5 Z"/>
</GenericStack>
</Border>
\ No newline at end of file
<VerticalStack Height="Fit" MinimumSize="10,10"
Name="ItemsContainer" Margin="0" VerticalAlignment="Top"/>
</Scroller>
- <ScrollBar Name="scrollbar1" Value="{²../scroller1.ScrollY}"
+ <ScrollBar Name="scrollbar1" Value="{²../scroller1.ScrollY}"
+ LargeIncrement="{../scroller1.PageHeight}" SmallIncrement="30" CursorSize="{../scroller1.ChildHeightRatio}"
Maximum="{../scroller1.MaximumScroll}" Orientation="Vertical"
Width="14" />
</HorizontalStack>
</Scroller>
<ScrollBar
Name="scrollbar1"
+ LargeIncrement="{../scroller1.PageHeight}" SmallIncrement="30"
+ CursorSize="{../scroller1.ChildHeightRatio}"
Value="{../scroller1.ScrollY}"
Maximum="{../scroller1.MaximumScroll}"
Width="14" Orientation="Vertical"/>
--- /dev/null
+<?xml version="1.0"?>
+<Container Fit="true" >
+ <Shape Foreground="Transparent" Background="Onyx" Path="M 5.5,0.5 L 10.5,10.5 L 0.5,10.5 Z"
+ MouseEnter="{Background=hgradient|0:Jet|0.5:BlueCrayola|1:Black}"
+ MouseLeave="{Background=Onyx}"/>
+</Container>
\ No newline at end of file
</None>
<None Include="OpenTK.dll.config" />
<None Include="packages.config" />
+ <None Include="Interfaces\Divers\testShape.crow">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
</ItemGroup>
<ItemGroup>
<Folder Include="Interfaces\" />
Font="Courriernew 10"/>
</Scroller>
<ScrollBar Name="scrollbar1" Value="{../scroller1.ScrollY}"
+ LargeIncrement="{../scroller1.PageHeight}" SmallIncrement="30"
+ CursorSize="{../scroller1.ChildHeightRatio}"
Maximum="{../scroller1.MaximumScroll}" Orientation="Vertical"
Width="14" />
</HorizontalStack>
//TODO:could be replaced by a template for a Slider
Orientation _orientation;
+ int _cursorSize;
#region CTOR
protected ScrollBar () : base(){}
RegisterForGraphicUpdate ();
}
}
+ [XmlAttributeAttribute()][DefaultValue(20)]
+ public virtual int CursorSize {
+ get { return _cursorSize; }
+ set {
+ if (_cursorSize == value)
+ return;
+ _cursorSize = value;
+ RegisterForGraphicUpdate ();
+ NotifyValueChanged ("CursorSize", _cursorSize);
+ }
+ }
public void onScrollBack (object sender, MouseButtonEventArgs e)
{
Value -= SmallIncrement;
base.OnLayoutChanges (layoutType);
NotifyValueChanged("MaximumScroll", MaximumScroll);
+ if (layoutType == LayoutingType.Height) {
+ NotifyValueChanged ("PageHeight", Slot.Height);
+ if (child?.Slot.Height > 0)
+ NotifyValueChanged ("ChildHeightRatio", Slot.Height * Slot.Height / child.Slot.Height);
+ } else {
+ NotifyValueChanged ("PageWidth", Slot.Width);
+ if (child?.Slot.Width > 0)
+ NotifyValueChanged ("ChildWidthRatio", Slot.Width * Slot.Width / child.Slot.Width);
+ }
}
void OnChildLayoutChanges (object sender, LayoutingEventArgs arg)
{
ScrollY = maxScroll;
}
NotifyValueChanged("MaximumScroll", maxScroll);
+ if (child?.Slot.Height > 0)
+ NotifyValueChanged ("ChildHeightRatio", Slot.Height * Slot.Height / child.Slot.Height);
}
} else if (arg.LayoutType == LayoutingType.Width) {
if (maxScroll < ScrollX) {
ScrollX = maxScroll;
}
NotifyValueChanged("MaximumScroll", maxScroll);
+ if (child?.Slot.Width > 0)
+ NotifyValueChanged ("ChildWidthRatio", Slot.Width * Slot.Width / child.Slot.Width);
}
}
void onChildListCleared(object sender, EventArgs e){
--- /dev/null
+//
+// Shape.cs
+//
+// Author:
+// jp <>
+//
+// Copyright (c) 2013-2017 Jean-Philippe Bruyère
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using System;
+using System.Xml.Serialization;
+using System.ComponentModel;
+using System.IO;
+using System.Text;
+using Cairo;
+
+namespace Crow
+{
+ public class PathParser : StringReader
+ {
+ public PathParser (string str) : base (str) {}
+
+ public double ReadDouble () {
+ StringBuilder tmp = new StringBuilder();
+
+ while (Peek () >= 0) {
+ char c = (char)Read();
+ if (c.IsWhiteSpaceOrNewLine()) {
+ if (tmp.Length == 0)
+ continue;
+ else
+ break;
+ } else if (c == ',')
+ break;
+ tmp.Append (c);
+ }
+ return double.Parse (tmp.ToString ());
+ }
+
+ }
+ public class Shape : GraphicObject
+ {
+ #region CTOR
+ protected Shape () : base() {}
+ public Shape (Interface iface) : base (iface) {}
+ #endregion
+
+ string path;
+ double strokeWidth;
+
+ public string Path {
+ get { return path; }
+ set {
+ if (path == value)
+ return;
+ path = value;
+ contentSize = default (Size);
+ NotifyValueChanged ("Path", path);
+ RegisterForGraphicUpdate ();
+ }
+ }
+ [XmlAttributeAttribute][DefaultValue(1.0)]
+ public double StokeWidth {
+ get { return strokeWidth; }
+ set {
+ if (strokeWidth == value)
+ return;
+ strokeWidth = value;
+ contentSize = default (Size);
+ NotifyValueChanged ("StrokeWidth", strokeWidth);
+ RegisterForGraphicUpdate ();
+ }
+ }
+
+ protected override void onDraw (Context gr)
+ {
+
+ if (string.IsNullOrEmpty (path))
+ return;
+
+ Rectangle r = ClientRectangle;
+
+ executePath (gr);
+
+ Background.SetAsSource (gr, r);
+ gr.FillPreserve ();
+ gr.LineWidth = strokeWidth;
+ Foreground.SetAsSource (gr, r);
+ gr.Stroke ();
+ }
+
+ void executePath (Context gr){
+ using (PathParser sr = new PathParser (path)) {
+ while (sr.Peek () >= 0) {
+ char c = (char)sr.Read ();
+ if (c.IsWhiteSpaceOrNewLine ())
+ continue;
+ switch (c) {
+ case 'M':
+ gr.MoveTo (sr.ReadDouble (), sr.ReadDouble ());
+ break;
+ case 'm':
+ gr.RelMoveTo (sr.ReadDouble (), sr.ReadDouble ());
+ break;
+ case 'L':
+ gr.LineTo (sr.ReadDouble (), sr.ReadDouble ());
+ break;
+ case 'l':
+ gr.RelLineTo (sr.ReadDouble (), sr.ReadDouble ());
+ break;
+ case 'C':
+ gr.CurveTo (sr.ReadDouble (), sr.ReadDouble (), sr.ReadDouble (), sr.ReadDouble (), sr.ReadDouble (), sr.ReadDouble ());
+ break;
+ case 'c':
+ gr.RelCurveTo (sr.ReadDouble (), sr.ReadDouble (), sr.ReadDouble (), sr.ReadDouble (), sr.ReadDouble (), sr.ReadDouble ());
+ break;
+ case 'Z':
+ gr.ClosePath ();
+ break;
+ case 'F':
+ gr.Fill ();
+ break;
+ case 'G':
+ gr.Stroke ();
+ break;
+ default:
+ throw new Exception ("Invalid character in path string of Shape control");
+ }
+ }
+ }
+ }
+ protected override int measureRawSize (LayoutingType lt)
+ {
+ if ((lt == LayoutingType.Width && contentSize.Width == 0) || (lt == LayoutingType.Height && contentSize.Height == 0)) {
+ using (Surface drawing = new ImageSurface (Format.A1, 1,1)) {
+ using (Context ctx = new Context (drawing)) {
+ executePath (ctx);
+ Rectangle r = ctx.StrokeExtents ();
+ contentSize = new Size (r.Right, r.Bottom);
+ }
+ }
+ }
+ return lt == LayoutingType.Width ?
+ contentSize.Width + 2 * Margin: contentSize.Height + 2 * Margin;
+ }
+ }
+}
+
public virtual int CursorSize {
get { return _cursorSize; }
set {
- if (_cursorSize == value)
+ if (_cursorSize == value || value < 8)
return;
_cursorSize = value;
RegisterForGraphicUpdate ();
if (_orientation == Orientation.Horizontal) {
pStart = r.TopLeft + new Point (_cursorSize / 2, r.Height / 2);
pEnd = r.TopRight + new Point (-_cursorSize / 2, r.Height / 2);
+ pStart.Y += 0.5;
+ pEnd.Y += 0.5;
} else {
pStart = r.TopLeft + new Point (r.Width / 2, _cursorSize / 2);
pEnd = r.BottomLeft + new Point (r.Width / 2,- _cursorSize / 2);
+ pStart.X += 0.5;
+ pEnd.X += 0.5;
+
}
DrawGraduations (gr, pStart,pEnd);
}
_activeWidget.onMouseUp (_activeWidget, e);
+ GraphicObject lastActive = _activeWidget;
ActiveWidget = null;
+ if (!lastActive.MouseIsIn (Mouse.Position)) {
+ ProcessMouseMove (Mouse.X, Mouse.Y);
+ }
return true;
}
/// <summary>