</ItemGroup>
<ItemGroup>
<PackageReference Include="FastEnum" Version="1.5.3" />
- <PackageReference Include="glfw-sharp" Version="0.2.10-beta" />
+ <PackageReference Include="glfw-sharp" Version="0.2.11-beta" />
</ItemGroup>
<PropertyGroup Condition=" '$(CrowStbSharp)' == 'true'">
Height = "300";
}
ProgressBar {
- Foreground = "vgradient|0:DarkBlue|0.5:SkyBlue|1:DarkBlue";
+ Background = "Jet";
+ Foreground = "RoyalBlue";
+ Orientation = "Horizontal";
+ Height = "10";
}
Scroller {
CacheEnabled = "false";
--- /dev/null
+<?xml version="1.0"?>
+<Gauge Background="{./Background}" Foreground="{./Foreground}" CornerRadius="{./CornerRadius}"
+ Orientation="{./Orientation}" Minimum="{./Minimum}" Maximum="{./Maximum}" Value="{./Value}"/>
NotifyValueChanged ("Icon", icon);
}
}
+
+ public CommandGroup () { }
+ public CommandGroup (params Command[] commands) {
+ AddRange (commands);
+ }
}
#region protected fields
protected double actualValue, minValue, maxValue;
- CursorType cursorType;
Orientation orientation;
- int borderWidth;
#endregion
#region public properties
RegisterForGraphicUpdate();
}
}
- [DefaultValue (CursorType.Pentagone)]
- public CursorType CursorType {
- get => cursorType;
- set {
- if (cursorType == value)
- return;
- cursorType = value;
- NotifyValueChangedAuto (cursorType);
- RegisterForRedraw ();
- }
- }
[DefaultValue (Orientation.Horizontal)]
public virtual Orientation Orientation {
get => orientation;
RegisterForLayouting (LayoutingType.Sizing | LayoutingType.ArrangeChildren);
}
}
- /// <summary>
- /// border width in pixels
- /// </summary>
- [DefaultValue (0)]
- public virtual int BorderWidth {
- get { return borderWidth; }
- set {
- if (borderWidth == value)
- return;
- borderWidth = value;
- NotifyValueChangedAuto (borderWidth);
- RegisterForGraphicUpdate ();
- }
- }
#endregion
protected override void onDraw (Context gr) {
+ base.onDraw (gr);
+
Rectangle cb = ClientRectangle;
if (orientation == Orientation.Horizontal)
else
cb.Height = (int)(cb.Height / Maximum * Value);
- Background.SetAsSource (IFace, gr, cb);
+
+ Foreground.SetAsSource (IFace, gr, cb);
CairoHelpers.CairoRectangle (gr, cb, CornerRadius);
gr.Fill ();
- Foreground.SetAsSource (IFace, gr, cb);
- if (borderWidth > 0)
- CairoHelpers.CairoRectangle (gr, cb, CornerRadius, borderWidth);
}
}
}
return;
decimals = value;
NotifyValueChangedAuto (decimals);
- RegisterForGraphicUpdate();
+ registerUpdate ();
}
}
[DefaultValue(0.0)]
minValue = value;
NotifyValueChangedAuto (minValue);
- RegisterForRedraw ();
+ registerUpdate ();
}
}
[DefaultValue(100.0)]
maxValue = value;
NotifyValueChangedAuto (maxValue);
- RegisterForRedraw ();
+ registerUpdate ();
}
}
[DefaultValue(1.0)]
smallStep = value;
NotifyValueChangedAuto (smallStep);
- RegisterForRedraw ();
+ registerUpdate ();
}
}
[DefaultValue(5.0)]
bigStep = value;
NotifyValueChangedAuto (bigStep);
- RegisterForRedraw ();
+ registerUpdate ();
}
}
[DefaultValue(0.0)]
actualValue = Math.Round (actualValue, decimals);
NotifyValueChangedAuto (actualValue);
- RegisterForGraphicUpdate();
+ registerUpdate ();
}
}
#endregion
+ protected virtual void registerUpdate ()
+ => RegisterForRedraw ();
}
}
//
// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
+using System.ComponentModel;
using Crow.Cairo;
namespace Crow
{
- //TODO:to be removed, numeric control with template having Gauge child is enough
+ /// <summary>
+ /// Templated numeric control for displaying a progress indicator
+ /// </summary>
public class ProgressBar : NumericControl
{
#region CTOR
public ProgressBar(Interface iface, string style = null) : base (iface, style) { }
#endregion
- protected override void loadTemplate (Widget template)
- {
- }
-
- #region GraphicObject overrides
- protected override void onDraw (Context gr)
- {
- base.onDraw (gr);
-
- if (Maximum == 0)
- return;
+ Orientation orientation;
- Rectangle rBack = ClientRectangle;
- rBack.Width = (int)((double)rBack.Width / Maximum * Value);
- Foreground.SetAsSource (IFace, gr, rBack);
-
- CairoHelpers.CairoRectangle(gr,rBack,CornerRadius);
- gr.Fill();
+ [DefaultValue (Orientation.Horizontal)]
+ public virtual Orientation Orientation {
+ get => orientation;
+ set {
+ if (orientation == value)
+ return;
+ orientation = value;
+ NotifyValueChangedAuto (orientation);
+ RegisterForLayouting (LayoutingType.Sizing | LayoutingType.ArrangeChildren);
+ }
}
- #endregion
- }
+ }
}
namespace Crow
{
/// <summary>
- /// templated numeric control to select a value
- /// by slidding a cursor
+ /// templated numeric control to select a value by slidding a cursor.
/// </summary>
- public class Slider : TemplatedControl
+ public class Slider : NumericControl
{
#region CTOR
protected Slider() {}
}
#endregion
- #region protected fields
- protected double actualValue, minValue, maxValue, smallStep, bigStep;
- protected int decimals;
- #endregion
-
- #region public properties
- [DefaultValue (2)]
- public int Decimals {
- get { return decimals; }
- set {
- if (value == decimals)
- return;
- decimals = value;
- NotifyValueChangedAuto (decimals);
- RegisterForGraphicUpdate ();
- }
- }
- [DefaultValue (0.0)]
- public virtual double Minimum {
- get { return minValue; }
- set {
- if (minValue == value)
- return;
-
- minValue = value;
- NotifyValueChangedAuto (minValue);
- RegisterForLayouting (LayoutingType.ArrangeChildren);
- }
- }
- [DefaultValue (100.0)]
- public virtual double Maximum {
- get { return maxValue; }
- set {
- if (maxValue == value)
- return;
-
- maxValue = value;
- NotifyValueChangedAuto (maxValue);
- RegisterForLayouting (LayoutingType.ArrangeChildren);
- }
- }
- [DefaultValue (1.0)]
- public virtual double SmallIncrement {
- get { return smallStep; }
- set {
- if (smallStep == value)
- return;
-
- smallStep = value;
- NotifyValueChangedAuto (smallStep);
- RegisterForLayouting (LayoutingType.ArrangeChildren);
- }
- }
- [DefaultValue (5.0)]
- public virtual double LargeIncrement {
- get { return bigStep; }
- set {
- if (bigStep == value)
- return;
-
- bigStep = value;
- NotifyValueChangedAuto (bigStep);
- RegisterForLayouting (LayoutingType.ArrangeChildren);
- }
- }
- [DefaultValue (0.0)]
- public virtual double Value {
- get { return actualValue; }
- set {
- if (value == actualValue)
- return;
- if (value < minValue)
- actualValue = minValue;
- else if (value > maxValue)
- actualValue = maxValue;
- else
- actualValue = value;
- actualValue = Math.Round (actualValue, decimals);
-
- NotifyValueChangedAuto (actualValue);
- RegisterForLayouting (LayoutingType.ArrangeChildren);
- }
- }
- #endregion
+ protected override void registerUpdate ()
+ => RegisterForLayouting (LayoutingType.ArrangeChildren);
#region private fields
- //Rectangle cursor;
int cursorSize;
- //Fill _cursorColor;
Orientation _orientation;
- //CursorType cursorType;
bool holdCursor = false;
- #endregion
Widget cursor;
+ #endregion
protected double unity;
/// Checks to handle when widget is removed from the visible graphic tree
/// </summary>
void unshownPostActions () {
- if (IFace.HoverWidget != null) {
- if (IFace.HoverWidget.IsOrIsInside (this)) {
- IFace.HoverWidget = null;
- IFace.OnMouseMove (IFace.MousePosition.X, IFace.MousePosition.Y);
- }
- }
if (IFace.ActiveWidget != null) {
if (IFace.ActiveWidget.IsOrIsInside (this))
IFace.ActiveWidget = null;
if (IFace.FocusedWidget != null) {
if (IFace.FocusedWidget.IsOrIsInside (this))
IFace.FocusedWidget = null;
- }
+ }
+ if (IFace.HoverWidget != null) {
+ if (IFace.HoverWidget.IsOrIsInside (this)) {
+ IFace.HoverWidget = null;
+ IFace.OnMouseMove (IFace.MousePosition.X, IFace.MousePosition.Y);
+ }
+ }
}
}
}
<Authors>Jean-Philippe Bruyère</Authors>
<EnableDefaultNoneItems>false</EnableDefaultNoneItems>
- <SamplesDir>$(SolutionDir)Samples\</SamplesDir>
+ <SamplesDir>$(MSBuildThisFileDirectory)\</SamplesDir>
<AppConfig>$(SolutionDir)Crow\App.config</AppConfig>
</PropertyGroup>
<LogicalName>ui.%(Filename)%(Extension)</LogicalName>
<Link>Templates\%(Filename)%(Extension)</Link>
</EmbeddedResource>
- <EmbeddedResource Include="$(SamplesDir)common\samples.style" />
<EmbeddedResource Include="$(SamplesDir)common\ui\images\**\*.*">
<LogicalName>images.%(Filename)%(Extension)</LogicalName>
<Link>Images\%(Filename)%(Extension)</Link>
<LogicalName>Icons.%(Filename)%(Extension)</LogicalName>
<Link>Icons\%(Filename)%(Extension)</Link>
</EmbeddedResource>
- <Compile Include="$(SamplesDir)common\SampleBase.cs"/>
+ <EmbeddedResource Include="$(SamplesDir)common\samples.style" >
+ <Link>common\%(Filename)%(Extension)</Link>
+ </EmbeddedResource>
+ <Compile Include="$(SamplesDir)common\SampleBase.cs">
+ <Link>common\%(Filename)%(Extension)</Link>
+ </Compile>
</ItemGroup>
</Project>