EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BasicTests", "Samples\BasicTests\BasicTests.csproj", "{7AEB6DD5-916E-4415-84E1-78EC6E5881CE}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "glfw-sharp", "..\..\glfw-sharp\glfw-sharp.csproj", "{A07754EB-1CAF-4D2D-8247-A3B6A46FB943}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PerfTests", "PerfTests\PerfTests.csproj", "{18EBB41F-815E-4BF5-B80F-C9E2FAB2993A}"
EndProject
Global
{7AEB6DD5-916E-4415-84E1-78EC6E5881CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7AEB6DD5-916E-4415-84E1-78EC6E5881CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7AEB6DD5-916E-4415-84E1-78EC6E5881CE}.Release|Any CPU.Build.0 = Release|Any CPU
- {A07754EB-1CAF-4D2D-8247-A3B6A46FB943}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {A07754EB-1CAF-4D2D-8247-A3B6A46FB943}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {A07754EB-1CAF-4D2D-8247-A3B6A46FB943}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {A07754EB-1CAF-4D2D-8247-A3B6A46FB943}.Release|Any CPU.Build.0 = Release|Any CPU
{18EBB41F-815E-4BF5-B80F-C9E2FAB2993A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{18EBB41F-815E-4BF5-B80F-C9E2FAB2993A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{18EBB41F-815E-4BF5-B80F-C9E2FAB2993A}.Release|Any CPU.ActiveCfg = Release|Any CPU
ArrowBut {
MouseRepeat="true";
Focusable="true";
- Foreground="Onyx";
- Background="hgradient|0:Grey|1:Jet";
- MouseDown="{Background=hgradient|0:White|0.4:CornflowerBlue|1:Jet}";
- MouseUp="{Background=hgradient|0:Grey|1:DimGrey}";
- MouseEnter="{Foreground=Black}";
- MouseLeave="{Foreground=Onyx}";
-}
-HArrowBut {
- MouseRepeat="true";
- Focusable="true";
- Foreground="Onyx";
- Background="vgradient|0:Grey|1:DimGrey";
- MouseDown="{Background=vgradient|0:White|0.4:DarkBlue|1:Jet}";
- MouseUp="{Background=vgradient|0:Grey|1:DimGrey}";
- MouseEnter="{Foreground=Black}";
- MouseLeave="{Foreground=DimGrey}";
+
+ Foreground="Jet";
+ Background="Transparent";
+
+ MouseUp="{Background=Transparent}";
+ MouseDown="{Background=Grey}";
+
+ MouseEnter="{Foreground=CornflowerBlue}";
+ MouseLeave="{Foreground=Jet}";
+
+ Margin="2";
+ KeepProportions="true";
}
+
ScrollBar {
Maximum = "0";
Value = "0";
- Background = "Silver";
- Foreground = "DimGrey";
- Width = "12";
+ Foreground="Transparent";
+ Background="DimGrey";
+ Width = "12";
CornerRadius = "0";
- Margin="0";
}
HScrollBar {
Template = "#Crow.HScrollBar.template";
<?xml version="1.0"?>
<Border BorderWidth="1" Foreground="{./Foreground}" Background="{./Background}">
<GenericStack Orientation="{./Orientation}" Spacing="0">
- <Shape Style="HArrowBut" MouseDown="./onScrollBack"
- Margin="1" Width="6" Size="10,10" Path="M 0.5,4.5 L 9.5,0.5 L 9.5,9.5 Z G"/>
+ <Shape Style="ArrowBut" MouseDown="./onScrollBack"
+ Width="10" Size="10,10" Path="M 0.5,4.5 L 9.5,0.5 L 9.5,9.5 Z F"/>
<Slider Name="Slider"
Orientation="{./Orientation}"
Value="{²./Value}"
Height="{./HeightPolicy}" Width="{./WidthPolicy}"
LargeIncrement="{./LargeIncrement}"
SmallIncrement="{./SmallIncrement}"
- CursorColor="vgradient|0:Silver|1:Grey"
- Background="Transparent"
- Foreground="{./Foreground}"/>
- <Shape Style="HArrowBut" MouseDown="./onScrollForth"
- Margin="1" Width="6" Size="10,10" Path="M 0.5,0.5 L 9.5,4.5 L 0.5,9.5 Z G"/>
+ CursorColor="Onyx"
+ Background="Transparent" Foreground="{./Foreground}"/>
+ <Shape Style="ArrowBut" MouseDown="./onScrollForth"
+ Width="10" Size="10,10" Path="M 0.5,0.5 L 9.5,4.5 L 0.5,9.5 Z F"/>
</GenericStack>
</Border>
\ No newline at end of file
<Border BorderWidth="1" Foreground="{./Foreground}" Background="{./Background}">
<GenericStack Orientation="{./Orientation}" Spacing="0">
<Shape Style="ArrowBut" MouseDown="./onScrollBack"
- Margin="1" Height="6" Size="10,10" Path="M 4.5,0.5 L 9.5,9.5 L 0.5,9.5 Z G"/>
+ Height="10" Size="10,10" Path="M 4.5,0.5 L 9.5,9.5 L 0.5,9.5 Z F"/>
<Slider Name="Slider"
Orientation="{./Orientation}"
Value="{²./Value}"
Height="{./HeightPolicy}" Width="{./WidthPolicy}"
LargeIncrement="{./LargeIncrement}"
SmallIncrement="{./SmallIncrement}"
- CursorColor="hgradient|0:Silver|1:Grey"
- Foreground="{./Foreground}"
- Background="Transparent"/>
+ CursorColor="Onyx"
+ Background="Transparent" Foreground="{./Foreground}"/>
<Shape Style="ArrowBut" MouseDown="./onScrollForth"
- Margin="1" Height="6" Size="10,10" Path="M 0.5,0.5 L 9.5,0.5 L 4.5,9.5 Z G"/>
+ Height="10" Size="10,10" Path="M 0.5,0.5 L 9.5,0.5 L 4.5,9.5 Z F"/>
</GenericStack>
</Border>
\ No newline at end of file
/// </summary>
/// <remarks>
/// </remarks>
- public class Image : Widget
+ public class Image : Scalable
{
Picture _pic;
string _svgSub;
- bool scaled, keepProps;
+
double opacity;
#region Public properties
/// If false, original size will be kept in any case.
/// </summary>
[DefaultValue(true)]
- public virtual bool Scaled {
- get { return scaled; }
+ public override bool Scaled {
+ get => base.Scaled;
set {
if (scaled == value)
return;
/// If image is scaled, proportions will be preserved.
/// </summary>
[DefaultValue(true)]
- public virtual bool KeepProportions {
+ public override bool KeepProportions {
get { return keepProps; }
set {
if (keepProps == value)
}
/// <summary>
/// Image file path, may be on disk or embedded. Accepts bitmaps or SVG drawings.
- /// </summary>
-
+ /// </summary>
public string Path {
get { return _pic == null ? "" : _pic.Path; }
set {
/// <summary>
/// Used only for svg images, repaint only node named referenced in SvgSub.
/// If null, all the svg is rendered
- /// </summary>
-
+ /// </summary>
public string SvgSub {
get { return _svgSub; }
set {
/// <summary>
/// Object holding the image data once loaded, may be used directely to pupulate this control without
/// specifying a path.
- /// </summary>
-
+ /// </summary>
public Picture Picture {
get { return _pic; }
set {
--- /dev/null
+// Copyright (c) 2013-2020 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
+//
+// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
+using System;
+using System.ComponentModel;
+
+namespace Crow
+{
+ public abstract class Scalable : Widget
+ {
+ #region CTOR
+ protected Scalable () : base () { }
+ public Scalable (Interface iface) : base (iface) { }
+ #endregion
+
+ protected bool scaled, keepProps;
+ /// <summary>
+ /// If true, content will be scalled to fit widget client area.
+ /// </summary>
+ [DefaultValue (true)]
+ public virtual bool Scaled {
+ get { return scaled; }
+ set {
+ if (scaled == value)
+ return;
+ scaled = value;
+ NotifyValueChanged ("Scaled", scaled);
+ RegisterForGraphicUpdate ();
+ }
+ }
+ /// <summary>
+ /// If image is scaled, proportions will be preserved.
+ /// </summary>
+ [DefaultValue (true)]
+ public virtual bool KeepProportions {
+ get { return keepProps; }
+ set {
+ if (keepProps == value)
+ return;
+ keepProps = value;
+ NotifyValueChanged ("KeepProportions", keepProps);
+ RegisterForGraphicUpdate ();
+ }
+ }
+
+
+ }
+}
/// <summary>
/// Widget for drawing a shape define with a path expression as defined in the PathParser.
/// </summary>
- public class Shape : Widget
+ public class Shape : Scalable
{
#region CTOR
protected Shape () : base () { }
string path;
double strokeWidth;
Size size;
+
/// <summary>
/// Path expression, for syntax see 'PathParser'.
/// </summary>
/// <summary>
/// View box
/// </summary>
- /// <value>The size.</value>
[DefaultValue ("0,0")]
public Size Size {
get { return size; }
RegisterForLayouting (LayoutingType.Sizing);
}
}
+
protected override void onDraw (Context gr)
{
base.onDraw (gr);
if (string.IsNullOrEmpty (path))
return;
- gr.Save ();
+ Rectangle cr = ClientRectangle;
+ double widthRatio = 1f, heightRatio = 1f;
- Rectangle r = ClientRectangle;
+ double w = (double)(contentSize.Width == 0 ? size.Width : contentSize.Width);
+ double h = (double)(contentSize.Height == 0 ? size.Height : contentSize.Height);
+ if (Scaled) {
+ widthRatio = cr.Width / w;
+ heightRatio = cr.Height / h;
+ }
- double sx = (double)r.Width / (double)(contentSize.Width == 0 ? size.Width : contentSize.Width);
- double sy = (double)r.Height / (double)(contentSize.Height == 0 ? size.Height : contentSize.Height);
+ if (KeepProportions) {
+ if (widthRatio < heightRatio)
+ heightRatio = widthRatio;
+ else
+ widthRatio = heightRatio;
+ }
+
+ gr.Save ();
- gr.Translate (r.Left, r.Top);
- gr.Scale (sx, sy);
+ gr.Translate (cr.Left, cr.Top);
+ gr.Scale (widthRatio, heightRatio);
+ gr.Translate ((cr.Width / widthRatio - w) / 2, (cr.Height / heightRatio - h) / 2);
gr.LineWidth = strokeWidth;
- Foreground.SetAsSource (gr, r);
+ Foreground.SetAsSource (gr, cr);
using (PathParser parser = new PathParser (path))
parser.Draw (gr);
<?xml version="1.0"?>
-<Group Name="TopContainer" Width="400" Height="400"
- Focusable="True" Background="Grey">
- <ScrollBar Height="16" Orientation="Horizontal" Width="Stretched" Maximum="100"/>
+<Group Name="TopContainer" Focusable="True" Background="Onyx" Margin="50">
+ <ScrollBar Maximum="100" Height="90%"/>
+ <ScrollBar Style="HScrollBar" Maximum="100" VerticalAlignment="Bottom"/>
</Group>
\ No newline at end of file