+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<configuration>
- <config>
- <add key="repositoryPath" value="../packages" />
- </config>
-</configuration>
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-<packages>
- <package id="OpenTK" version="2.0.0" targetFramework="net45" />
-</packages>
<Compile Include="src\GraphicObjects\Menu.cs" />
<Compile Include="src\Command.cs" />
<Compile Include="src\GraphicObjects\DataSourceChangeEventArgs.cs" />
- <Compile Include="src\IML\Context.cs" />
<Compile Include="src\IML\NodeAddress.cs" />
<Compile Include="src\IML\Node.cs" />
<Compile Include="src\IML\MemberAddress.cs" />
<Compile Include="src\Mono.Cairo\Win32Surface.cs" />
<Compile Include="src\Mono.Cairo\XcbSurface.cs" />
<Compile Include="src\Mono.Cairo\XlibSurface.cs" />
+ <Compile Include="src\GraphicObjects\DocksView.cs" />
+ <Compile Include="src\GraphicObjects\DockingView.cs" />
+ <Compile Include="src\IML\IMLContext.cs" />
+ <Compile Include="src\Mono.Cairo\MeshPattern.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
<EmbeddedResource Include="Icons\folder.svg" />
<EmbeddedResource Include="Icons\file.svg" />
<EmbeddedResource Include="Icons\level-up.svg" />
+ <EmbeddedResource Include="Templates\DockingView.template">
+ <LogicalName>Crow.DockingView.template</LogicalName>
+ </EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="Crow.dll.config">
<dllmap os="!windows,osx" dll="libgdk-3-0.dll" target="libgdk-3.so.0"/>
<dllmap os="!windows,osx" dll="libgdk_pixbuf-2.0-0.dll" target="libgdk_pixbuf-2.0.so.0"/>
<dllmap os="!windows,osx" dll="rsvg-2" target="librsvg-2.so.2"/>
+ <dllmap os="!windows,osx" dll="libinput" target="libinput.so.10"/>
<dllmap os="windows" dll="rsvg-2" target="librsvg-2-2.dll"/>
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- version="1.1"
- id="svg2"
- viewBox="0 0 64 64.000002"
- height="64"
- width="64">
- <defs
- id="defs4" />
- <metadata
- id="metadata7">
- <rdf:RDF>
- <cc:Work
- rdf:about="">
- <dc:format>image/svg+xml</dc:format>
- <dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
- </cc:Work>
- </rdf:RDF>
- </metadata>
- <g
- id="False">
- <rect
- style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:8.89073467;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:0;stroke-dasharray:none;stroke-opacity:1"
- id="rect4136"
- width="55.122551"
- height="55.122551"
- x="4.4468598"
- y="4.3914709"
- ry="8.8907347" />
- <path
- style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:8.89073467;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- d="m 32.008136,12.393132 0,39.11923"
- id="path4177" />
- <path
- style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:8.89073467;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- d="m 12.448521,31.952746 39.119231,0"
- id="path4181" />
- </g>
- <g
- id="True">
- <rect
- ry="8.8907347"
- y="4.3914709"
- x="4.4468598"
- height="55.122551"
- width="55.122551"
- id="rect4190"
- style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:8.89073467;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:0;stroke-dasharray:none;stroke-opacity:1" />
- <path
- id="path4194"
- d="m 12.448521,31.952746 39.119231,0"
- style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:8.89073467;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
- </g>
-</svg>
+<svg width="9" height="9" xmlns="http://www.w3.org/2000/svg">
+ <g id="False">
+ <rect height="8" width="8" y="0.5" x="0.5" stroke="#000" fill="#fff" stroke-width="1"/>
+ <line stroke-linecap="undefined" stroke-linejoin="undefined" id="svg_2" y2="4.5" x2="7" y1="4.5" x1="2" stroke="#000" fill="none"/>
+ <line stroke-linecap="undefined" stroke-linejoin="undefined" id="svg_3" y2="7" x2="4.5" y1="2" x1="4.5" stroke="#000" fill="none"/>
+ </g>
+ <g id="True">
+ <rect height="8" width="8" y="0.5" x="0.5" stroke="#000" fill="#fff" stroke-width="1"/>
+ <line stroke-linecap="undefined" stroke-linejoin="undefined" id="svg_2" y2="4.5" x2="7" y1="4.5" x1="2" stroke="#000" fill="none"/>
+ </g>
+</svg>
\ No newline at end of file
[assembly: AssemblyConfiguration ("")]
[assembly: AssemblyCompany ("Grand Tetra Software")]
[assembly: AssemblyProduct ("Crow")]
-[assembly: AssemblyCopyright ("Copyright (c) 2016 - Jean-Philippe Bruyère <jp_bruyere@hotmail.com>")]
+[assembly: AssemblyCopyright ("Copyright (c) 2018 - Jean-Philippe Bruyère <jp_bruyere@hotmail.com>")]
[assembly: AssemblyTrademark ("")]
-[assembly: AssemblyCulture ("en-US")]
+[assembly: AssemblyCulture ("")]
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
</a>
</p>
-You can visit the [Wiki](https://github.com/jpbruyere/Crow/wiki) or the [Project Site](https://jpbruyere.github.io/Crow/)
-for documentation and tutorials.
+For **documentation** and **tutorials** visit the [Wiki](https://github.com/jpbruyere/Crow/wiki)
+or the [Project Site](https://jpbruyere.github.io/Crow/).
Please report bugs and issues on [GitHub](https://github.com/jpbruyere/Crow/issues)
## Getting Start
+
### Requirements
-- [mono > 4.5](http://www.mono-project.com/)
+- [mono > 4.5](http://www.mono-project.com/download/)
- [Cairo Graphic Library](https://cairographics.org/) >= 1.10
- [rsvg library](https://developer.gnome.org/rsvg/) for svg rendering
- [nuget](https://www.nuget.org/).
+
### Building from source
+
_[Git](https://git-scm.com) has to be installed._
+
```bash
git clone https://github.com/jpbruyere/Crow.git # Download source code from github
cd Crow # Enter the source directory
nuget restore Crow.sln # Restore nuget packages
xbuild /p:Configuration=Release Crow.sln # Build with Mono
```
+
### Using nuget
+
* add [Crow.OpenTK NuGet package](https://www.nuget.org/packages/Crow.OpenTK/) to your project.
* Derive **CrowWindow** class.
* Load some widget in the **OnLoad** override with `CrowWindow.Load` .
MouseEnter="{Foreground=DimGray}"
MouseLeave="{Foreground=Transparent}">
<HorizontalStack Spacing="1">
- <Image Margin="1" Width="10" Height="10" Focusable="true" MouseClick="./onClickForExpand"
+ <Image Margin="1" Width="9" Height="9" Focusable="true" MouseClick="./onClickForExpand"
Path="{./Image}"
Visible="{./IsExpandable}"
SvgSub="{./IsExpanded}"
<Border BorderWidth="1" Foreground="{./Foreground}" Background="{./Background}">
<VerticalStack>
<HorizontalStack Spacing="1" Height="Fit" MouseDoubleClick="./onClickForExpand">
- <Container Margin="1" Width="10" Height="10" Focusable="true" MouseClick="./onClickForExpand"
+ <Container Margin="1" Width="9" Height="9" Focusable="true" MouseClick="./onClickForExpand"
MouseEnter="{Background=LightGray}"
MouseLeave="{Background=Transparent}">
<Image
<?xml version="1.0"?>
<Border Background="{./Background}" BorderWidth="1" Foreground="{./Foreground}" Height="Fit">
<HorizontalStack Spacing="1" Height="Fit">
- <Image Style="Icon" Margin="2"
+ <Image Style="Icon" Margin="1" Width="9" Height="9"
Path="#Crow.Images.Icons.expandable.svg" SvgSub="{./IsPopped}"/>
<Label Text="{./Caption}" />
</HorizontalStack>
class BasicTests : CrowWindow
{
public BasicTests ()
- : base(800, 600,"test: press <F3> to toogle test files")
+ : base(1280, 800,"test: press <F3> to toogle test files")
{
}
//testFiles = new string [] { @"Interfaces/Unsorted/testFileDialog.crow" };
//testFiles = new string [] { @"Interfaces/Divers/colorPicker.crow" };
- testFiles = new string [] { @"Interfaces/TemplatedContainer/testTabView.crow" };
+ testFiles = new string [] { @"Interfaces/Divers/welcome.crow" };
testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/GraphicObject", "*.crow")).ToArray ();
testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Container", "*.crow")).ToArray ();
testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Group", "*.crow")).ToArray ();
[STAThread]
static void Main ()
{
+ TextWriterTraceListener listener = new TextWriterTraceListener ("listen.txt");
+ Debug.Listeners.Add (listener);
Console.WriteLine ("starting example");
BasicTests win = new BasicTests ();
win.VSync = OpenTK.VSyncMode.Adaptive;
win.Run (30);
+ listener.Dispose ();
}
protected override void OnUpdateFrame (OpenTK.FrameEventArgs e)
{
#region Events
//those events are raised only if mouse isn't in a graphic object
- public event EventHandler<OpenTK.Input.MouseWheelEventArgs> MouseWheelChanged;
- public event EventHandler<OpenTK.Input.MouseButtonEventArgs> MouseButtonUp;
- public event EventHandler<OpenTK.Input.MouseButtonEventArgs> MouseButtonDown;
- public event EventHandler<OpenTK.Input.MouseButtonEventArgs> MouseClick;
- public event EventHandler<OpenTK.Input.MouseMoveEventArgs> MouseMove;
- public event EventHandler<OpenTK.Input.KeyboardKeyEventArgs> KeyboardKeyDown;
- public event EventHandler<OpenTK.Input.KeyboardKeyEventArgs> KeyboardKeyUp;
+ public event EventHandler<OpenTK.Input.MouseWheelEventArgs> CrowMouseWheel;
+ public event EventHandler<OpenTK.Input.MouseButtonEventArgs> CrowMouseUp;
+ public event EventHandler<OpenTK.Input.MouseButtonEventArgs> CrowMouseDown;
+ public event EventHandler<OpenTK.Input.MouseButtonEventArgs> CrowMouseClick;
+ public event EventHandler<OpenTK.Input.MouseMoveEventArgs> CrowMouseMove;
+ public event EventHandler<OpenTK.Input.KeyboardKeyEventArgs> CrowKeyDown;
+ public event EventHandler<OpenTK.Input.KeyboardKeyEventArgs> CrowKeyUp;
#endregion
base.OnLoad(e);
this.KeyPress += new EventHandler<OpenTK.KeyPressEventArgs>(OpenTKGameWindow_KeyPress);
- Keyboard.KeyDown += new EventHandler<OpenTK.Input.KeyboardKeyEventArgs>(Keyboard_KeyDown);
- Keyboard.KeyUp += new EventHandler<OpenTK.Input.KeyboardKeyEventArgs>(Keyboard_KeyUp);
- Mouse.WheelChanged += new EventHandler<OpenTK.Input.MouseWheelEventArgs>(GL_Mouse_WheelChanged);
- Mouse.ButtonDown += new EventHandler<OpenTK.Input.MouseButtonEventArgs>(GL_Mouse_ButtonDown);
- Mouse.ButtonUp += new EventHandler<OpenTK.Input.MouseButtonEventArgs>(GL_Mouse_ButtonUp);
- Mouse.Move += new EventHandler<OpenTK.Input.MouseMoveEventArgs>(GL_Mouse_Move);
+ KeyDown += new EventHandler<OpenTK.Input.KeyboardKeyEventArgs>(Keyboard_KeyDown);
+ KeyUp += new EventHandler<OpenTK.Input.KeyboardKeyEventArgs>(Keyboard_KeyUp);
+
+ MouseWheel += new EventHandler<OpenTK.Input.MouseWheelEventArgs>(GL_Mouse_WheelChanged);
+ MouseDown += new EventHandler<OpenTK.Input.MouseButtonEventArgs>(GL_Mouse_ButtonDown);
+ MouseUp += new EventHandler<OpenTK.Input.MouseButtonEventArgs>(GL_Mouse_ButtonUp);
+ MouseMove += new EventHandler<OpenTK.Input.MouseMoveEventArgs>(GL_Mouse_Move);
#if DEBUG
Console.WriteLine("\n\n*************************************");
return;
}
if (focusedIdx < 0)
- MouseMove.Raise (sender, otk_e);
+ CrowMouseMove.Raise (sender, otk_e);
}
protected virtual void GL_Mouse_ButtonUp(object sender, OpenTK.Input.MouseButtonEventArgs otk_e)
{
if (ifaceControl [focusedIdx].ProcessMouseButtonUp ((int)otk_e.Button))
return;
}
- MouseButtonUp.Raise (sender, otk_e);
+ CrowMouseUp.Raise (sender, otk_e);
}
protected virtual void GL_Mouse_ButtonDown(object sender, OpenTK.Input.MouseButtonEventArgs otk_e)
{
if (ifaceControl [focusedIdx].ProcessMouseButtonDown ((int)otk_e.Button))
return;
}
- MouseButtonDown.Raise (sender, otk_e);
+ CrowMouseDown.Raise (sender, otk_e);
}
protected virtual void GL_Mouse_WheelChanged(object sender, OpenTK.Input.MouseWheelEventArgs otk_e)
{
if (ifaceControl [focusedIdx].ProcessMouseWheelChanged (otk_e.DeltaPrecise))
return;
}
- MouseWheelChanged.Raise (sender, otk_e);
+ CrowMouseWheel.Raise (sender, otk_e);
}
protected virtual void Keyboard_KeyDown(object sender, OpenTK.Input.KeyboardKeyEventArgs otk_e)
if (ifaceControl [focusedIdx].ProcessKeyDown((int)otk_e.Key))
return;
}
- KeyboardKeyDown.Raise (this, otk_e);
+ CrowKeyDown.Raise (this, otk_e);
}
protected virtual void Keyboard_KeyUp(object sender, OpenTK.Input.KeyboardKeyEventArgs otk_e)
{
if (ifaceControl [focusedIdx].ProcessKeyUp((int)otk_e.Key))
return;
}
- KeyboardKeyUp.Raise (this, otk_e);
+ CrowKeyUp.Raise (this, otk_e);
}
protected virtual void OpenTKGameWindow_KeyPress (object sender, OpenTK.KeyPressEventArgs e)
{
void initGL(){
GL.Enable (EnableCap.CullFace);
GL.Enable (EnableCap.Blend);
- GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
+ GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha);
cube = vaoMesh.CreateCube ();
texture = new Texture ("image/textest.png");
{
base.OnLoad (e);
- MouseMove += HelloCube_MouseMove;
- MouseWheelChanged += Hello3D_MouseWheelChanged;
+ CrowMouseMove += HelloCube_MouseMove;
+ CrowMouseWheel += Hello3D_MouseWheelChanged;
iface3D = Add3DInterface (800, 800,
Matrix4.CreateScale (6f) *
void Hello3D_MouseWheelChanged (object sender, OpenTK.Input.MouseWheelEventArgs e)
{
float speed = ZoomSpeed;
- if (Keyboard[OpenTK.Input.Key.ControlLeft])
- speed *= 20.0f;
+ //if (Keyboard[OpenTK.Input.Key.ControlLeft])
+ // speed *= 20.0f;
eyeDist -= e.Delta * speed;
if (eyeDist < zNear)
void initGL(){
GL.Enable (EnableCap.CullFace);
GL.Enable (EnableCap.Blend);
- GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
+ GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha);
cube = vaoMesh.CreateCube ();
texture = new Texture ("image/textest.png");
GeomSourcePath;
#region Sources
protected string _vertSource = @"
- #version 330
+ #version 300 es
precision lowp float;
uniform mat4 mvp;
}";
protected string _fragSource = @"
- #version 330
+ #version 300 es
precision lowp float;
uniform sampler2D tex;
{
base.OnLoad (e);
+ this.CrowKeyDown += Showcase_CrowKeyDown;
GraphicObject g = Load ("#Tests.ui.showcase.crow");
g.DataSource = this;
crowContainer = g.FindByName ("CrowContainer") as Container;
hideError ();
}
+ void Showcase_CrowKeyDown (object sender, OpenTK.Input.KeyboardKeyEventArgs e)
+ {
+ if (e.Key == OpenTK.Input.Key.Escape) {
+ Quit (null, null);
+ return;
+ }
+ }
+
void Dv_SelectedItemChanged (object sender, SelectionChangeEventArgs e)
{
FileSystemInfo fi = e.NewValue as FileSystemInfo;
<Reference Include="System.Xml" />
<Reference Include="System.Drawing" />
<Reference Include="OpenTK">
- <HintPath>$(SolutionDir)packages\OpenTK.2.0.0\lib\net20\OpenTK.dll</HintPath>
+ <HintPath>$(SolutionDir)libs\OpenTK.dll</HintPath>
</Reference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<None Include="Interfaces\Splitter\1.crow">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
- <None Include="OpenTK.dll.config" />
<None Include="image\textest.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Interfaces\Divers\welcome.crow">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
- <None Include="packages.config" />
<None Include="Interfaces\Unsorted\testTypeViewer.goml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
--- /dev/null
+<configuration>
+ <dllmap os="linux" dll="opengl32.dll" target="libGL.so.1"/>
+ <dllmap os="linux" dll="glu32.dll" target="libGLU.so.1"/>
+ <dllmap os="linux" dll="openal32.dll" target="libopenal.so.1"/>
+ <dllmap os="linux" dll="alut.dll" target="libalut.so.0"/>
+ <dllmap os="linux" dll="opencl.dll" target="libOpenCL.so"/>
+ <dllmap os="linux" dll="libX11" target="libX11.so.6"/>
+ <dllmap os="linux" dll="libXi" target="libXi.so.6"/>
+ <dllmap os="linux" dll="SDL2.dll" target="libSDL2-2.0.so.0"/>
+ <dllmap os="osx" dll="opengl32.dll" target="/System/Library/Frameworks/OpenGL.framework/OpenGL"/>
+ <dllmap os="osx" dll="openal32.dll" target="/System/Library/Frameworks/OpenAL.framework/OpenAL" />
+ <dllmap os="osx" dll="alut.dll" target="/System/Library/Frameworks/OpenAL.framework/OpenAL" />
+ <dllmap os="osx" dll="libGLES.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
+ <dllmap os="osx" dll="libGLESv1_CM.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
+ <dllmap os="osx" dll="libGLESv2.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
+ <dllmap os="osx" dll="opencl.dll" target="/System/Library/Frameworks/OpenCL.framework/OpenCL"/>
+ <dllmap os="osx" dll="SDL2.dll" target="libSDL2.dylib"/>
+ <!-- XQuartz compatibility (X11 on Mac) -->
+ <dllmap os="osx" dll="libGL.so.1" target="/usr/X11/lib/libGL.dylib"/>
+ <dllmap os="osx" dll="libX11" target="/usr/X11/lib/libX11.dylib"/>
+ <dllmap os="osx" dll="libXcursor.so.1" target="/usr/X11/lib/libXcursor.dylib"/>
+ <dllmap os="osx" dll="libXi" target="/usr/X11/lib/libXi.dylib"/>
+ <dllmap os="osx" dll="libXinerama" target="/usr/X11/lib/libXinerama.dylib"/>
+ <dllmap os="osx" dll="libXrandr.so.2" target="/usr/X11/lib/libXrandr.dylib"/>
+</configuration>
namespace Crow
{
+ /// <summary>
+ /// Store focused widget while bubbling mouse down event to the top
+ /// </summary>
public class BubblingMouseButtonEventArg: MouseButtonEventArgs
{
public GraphicObject Focused;
- public BubblingMouseButtonEventArg(MouseButtonEventArgs mbe) : base(mbe){
-
- }
+ public BubblingMouseButtonEventArg(MouseButtonEventArgs mbe) : base(mbe){}
}
}
}
#endregion
+ /// <summary>
+ /// color names dictionary
+ /// </summary>
public static Dictionary<string, Color> ColorDic = new Dictionary<string, Color>();
internal string Name;
}
#endregion
-
+ /// <summary>
+ /// compute the hue of the color
+ /// </summary>
public double Hue {
get {
double min = Math.Min (R, Math.Min (G, B)); //Min. value of RGB
return h;
}
}
+ /// <summary>
+ /// compute the saturation of the color
+ /// </summary>
public double Saturation {
get {
return Math.Max (R, Math.Max (G, B)); //Max. value of RGB
}
}
+ /// <summary>
+ /// compute the RGB intensity of the color
+ /// </summary>
+ /// <value>The value.</value>
public double Value {
get {
double min = Math.Min (R, Math.Min (G, B)); //Min. value of RGB
{
get { return new float[]{ (float)R, (float)G, (float)B, (float)A }; }
}
+ /// <summary>
+ /// return a copy of the color with the alpha component modified
+ /// </summary>
+ /// <returns>new modified color</returns>
+ /// <param name="_A">normalized alpha component</param>
public Color AdjustAlpha(double _A)
{
return new Color (this.R, this.G, this.B, _A);
namespace Crow
{
+ /// <summary>
+ /// helper class to bind in one step icon, caption, action, and validity tests to a controls
+ /// </summary>
public class Command : IValueChange
{
#region IValueChange implementation
#endregion
#region CTOR
+ /// <summary>
+ /// Initializes a new instance of Command with the action pass as argument.
+ /// </summary>
+ /// <param name="_executeAction">action to excecute when command is triggered</param>
public Command (Action _executeAction)
{
execute = _executeAction;
bool canExecute = true;
#region Public properties
+ /// <summary>
+ /// if true, action defined in this command may be executed,
+ /// </summary>
[XmlAttributeAttribute][DefaultValue(true)]
public virtual bool CanExecute {
get { return canExecute; }
NotifyValueChanged ("CanExecute", canExecute);
}
}
+ /// <summary>
+ /// label to display in the bound control
+ /// </summary>
[XmlAttributeAttribute][DefaultValue("Unamed Command")]
public virtual string Caption {
get { return caption; }
}
}
+ /// <summary>
+ /// Icon to display in the bound control
+ /// </summary>
[XmlAttributeAttribute]
public Picture Icon {
get { return icon; }
}
#endregion
+ /// <summary>
+ /// trigger the execution of the command
+ /// </summary>
public void Execute(){
if (execute != null && CanExecute)
execute ();
using Crow.IML;
-namespace Crow
+namespace Crow.IML
{
public static class CompilerServices
{
namespace Crow
{
+ /// <summary>
+ /// single element of configuration
+ /// </summary>
public class ConfigItem {
Type type;
internal object curVal;
}
}
/// <summary>
- /// Application wide Configuration utility
+ /// Application wide Configuration store utility
+ ///
+ /// configuration files are automatically stored in **_user/.config/appname/app.config_** on close and every minutes
+ /// if some items have changed.
+ /// New items are automaticaly added on first use. Configuration class expose one templated Get and one Templated Set, so
+ /// creating, storing and retrieving config items is simple as:
+ ///
+ /// ```csharp\n
+ /// //storing\n
+ /// Configuration.Set ("Option1", 42);\n
+ /// //loading\n
+ /// int op1 = Configuration.Get<int> ("Option1");\n
+ /// ```\n
/// </summary>
+ ///
+ /// **.config** file are simple text files with per line, a key/value pair of the form `option=value`. Keys have to be unique
+ /// in the application scope.
+ ///
+ /// When running the application for the first time, some default options may be necessary. Their can be defined
+ /// in a special embedded resource text file with the key '**appname.default.config**'
public static class Configuration
{
volatile static bool isDirty = false;
Thread.Sleep (1000);
}
}
+ /// <summary>
+ /// retrive the value of the configuration key given in parameter
+ /// </summary>
+ /// <param name="key">option name</param>
public static T Get<T>(string key)
{
return !items.ContainsKey (key) ? default(T) : items [key].GetValue<T> ();
}
+ /// <summary>
+ /// store the value of the configuration key given in parameter
+ /// </summary>
+ /// <param name="key">option name</param>
+ /// <param name="value">value for that option</param>
public static void Set<T>(string key, T value)
{
if (!items.ContainsKey (key)) {
namespace Crow
{
+ /// <summary>
+ /// base class for drawing content to paint on backend
+ /// </summary>
public abstract class Fill
{
+ /// <summary>
+ /// set content of fill as source for drawing operations on the backend context
+ /// </summary>
+ /// <param name="ctx">backend context</param>
+ /// <param name="bounds">drawing operation bounding box</param>
public abstract void SetAsSource (Cairo.Context ctx, Rectangle bounds = default(Rectangle));
public static object Parse (string s){
if (string.IsNullOrEmpty (s))
namespace Crow
{
+ /// <summary>
+ /// templated button control
+ /// </summary>
public class Button : TemplatedContainer
{
#region CTOR
namespace Crow
{
+ /// <summary>
+ /// templated checkbox control
+ /// </summary>
public class CheckBox : TemplatedControl
{
#region CTOR
namespace Crow
{
+ /// <summary>
+ /// templated color selector control
+ /// </summary>
public class ColorPicker : TemplatedControl
{
#region CTOR
namespace Crow
{
+ /// <summary>
+ /// simple squarred rgb color selector
+ /// </summary>
public class ColorSelector : GraphicObject
{
#region CTOR
namespace Crow
{
+ /// <summary>
+ /// templated control for selecting value in a pop up list
+ /// </summary>
public class ComboBox : ListBox
{
#region CTOR
namespace Crow
{
+ /// <summary>
+ /// simple container accepting one child
+ /// </summary>
public class Container : PrivateContainer
{
#region CTOR
namespace Crow
{
+ /// <summary>
+ /// templated directory viewer
+ /// </summary>
public class DirectoryView : TemplatedControl
{
#region CTOR
namespace Crow
{
+ /// <summary>
+ /// templated control for selecting files
+ /// </summary>
public class FileDialog: Window
{
#region CTOR
namespace Crow
{
+ /// <summary>
+ /// group container that stacked its children horizontally or vertically
+ /// </summary>
public class GenericStack : Group
{
#region CTOR
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using Cairo;
-using System.Linq;
using System.Diagnostics;
-using System.IO;
+using Crow.IML;
namespace Crow
{
protected object dataSource;
string style;
object tag;
+ bool isDragged;
+ bool allowDrag;
+ bool allowDrop;
+
#endregion
#region public fields
public event EventHandler Enabled;
/// <summary>Occurs when the enabled state this object is set to false</summary>
public event EventHandler Disabled;
+ public event EventHandler Dragged;
+ public event EventHandler Dropped;
/// <summary>Occurs when one part of the rendering slot changed</summary>
public event EventHandler<LayoutingEventArgs> LayoutChanged;
/// <summary>Occurs when DataSource changed</summary>
return false;
}
+ #region Drag&Drop
+ [XmlAttributeAttribute][DefaultValue(false)]
+ public virtual bool AllowDrag {
+ get { return allowDrag; }
+ set {
+ if (allowDrag == value)
+ return;
+ allowDrag = value;
+ NotifyValueChanged ("AllowDrag", allowDrag);
+ }
+ }
+ [XmlAttributeAttribute][DefaultValue(false)]
+ public virtual bool AllowDrop {
+ get { return allowDrop; }
+ set {
+ if (allowDrop == value)
+ return;
+ allowDrop = value;
+ NotifyValueChanged ("AllowDrop", allowDrop);
+ }
+ }
+
+// public List<Type> AllowedDroppedTypes;
+// public void AddAllowedDroppedType (Type newType){
+// if (AllowedDroppedTypes == null)
+// AllowedDroppedTypes = new List<Type> ();
+// AllowedDroppedTypes.Add (newType);
+// NotifyValueChanged ("AllowDrop", AllowDrop);
+// }
+// [XmlIgnore]public virtual bool AllowDrop {
+// get { return AllowedDroppedTypes?.Count>0; }
+// }
+ [XmlIgnore]public virtual bool IsDragged {
+ get { return isDragged; }
+ set {
+ if (isDragged == value)
+ return;
+ isDragged = value;
+
+ if (isDragged) {
+ CurrentInterface.HoverWidget = null;
+ onStartDrag (this, null);
+ }
+
+ NotifyValueChanged ("IsDrag", IsDragged);
+ }
+ }
+ /// <summary>
+ /// start dragging
+ /// </summary>
+ protected virtual void onStartDrag (object sender, EventArgs e){
+ Debug.WriteLine("DRAG => " + this.ToString());
+ Dragged.Raise (this, null);
+ }
+ /// <summary>
+ /// Occured when dragging ends without dropping
+ /// </summary>
+ protected virtual void onEndDrag (object sender, EventArgs e){
+ IsDragged = false;
+ Debug.WriteLine("END DRAG => " + this.ToString());
+ }
+ /// <summary>
+ /// Dragging end with a dropping
+ /// </summary>
+ protected virtual void onDrop (object sender, EventArgs e){
+ IsDragged = false;
+ Debug.WriteLine("DROPPED => " + this.ToString());
+ Dropped.Raise (this, null);
+ }
+ #endregion
+
#region Queuing
/// <summary>
/// Register old and new slot for clipping
#region Rendering
/// <summary> This is the common overridable drawing routine to create new widget </summary>
- protected virtual void onDraw(Context gr)
+ protected virtual void onDraw(Cairo.Context gr)
{
#if DEBUG_UPDATE
Debug.WriteLine (string.Format("OnDraw -> {0}", this.ToString ()));
if (bmp != null)
bmp.Dispose ();
bmp = new ImageSurface (Format.Argb32, Slot.Width, Slot.Height);
- using (Context gr = new Context (bmp)) {
+ using (Cairo.Context gr = new Cairo.Context (bmp)) {
gr.Antialias = Interface.Antialias;
onDraw (gr);
}
bmp.Flush ();
}
- protected virtual void UpdateCache(Context ctx){
+ protected virtual void UpdateCache(Cairo.Context ctx){
#if DEBUG_UPDATE
Debug.WriteLine (string.Format("UpdateCache -> {0}", this.ToString ()));
#endif
}
/// <summary> Chained painting routine on the parent context of the actual cached version
/// of the widget </summary>
- public virtual void Paint (ref Context ctx)
+ public virtual void Paint (ref Cairo.Context ctx)
{
#if DEBUG_UPDATE
Debug.WriteLine (string.Format("Paint -> {0}", this.ToString ()));
LastPaintedSlot = Slot;
}
}
- void paintDisabled(Context gr, Rectangle rb){
+ void paintDisabled(Cairo.Context gr, Rectangle rb){
gr.Operator = Operator.Xor;
gr.SetSourceRGBA (0.6, 0.6, 0.6, 0.3);
gr.Rectangle (rb);
public virtual bool MouseIsIn(Point m)
{
try {
- if (!(Visible & isEnabled))
+ if (!(Visible & isEnabled)||IsDragged)
return false;
if (ScreenCoordinates (Slot).ContainsOrIsEqual (m)) {
Scroller scr = Parent as Scroller;
}
public virtual void onMouseMove(object sender, MouseMoveEventArgs e)
{
+ if (AllowDrag & !IsDragged & IsActive)
+ IsDragged = true;
+
//bubble event to the top
GraphicObject p = Parent as GraphicObject;
if (p != null)
MouseDown.Raise (this, e);
}
public virtual void onMouseUp(object sender, MouseButtonEventArgs e){
+ if (IsDragged){
+ bool dropOK = false;
+ if (CurrentInterface.HoverWidget!=null) {
+ if (CurrentInterface.HoverWidget.AllowDrop)
+ dropOK = true;
+ }
+ if (dropOK)
+ onDrop (this, null);
+ else
+ onEndDrag (this, null);
+ }
+
//bubble event to the top
GraphicObject p = Parent as GraphicObject;
if (p != null)
g.RegisterForLayouting (LayoutingType.Sizing | LayoutingType.ArrangeChildren);
g.LayoutChanged += OnChildLayoutChanges;
}
- public virtual void RemoveChild(GraphicObject child)
+ public virtual void RemoveChild(GraphicObject child)
{
child.LayoutChanged -= OnChildLayoutChanges;
//check if HoverWidget is removed from Tree
searchLargestChild ();
if (child == tallestChild && Height == Measure.Fit)
searchTallestChild ();
-
+
this.RegisterForLayouting (LayoutingType.Sizing | LayoutingType.ArrangeChildren);
}
public virtual void ClearChildren()
ChildrenCleared.Raise (this, new EventArgs ());
}
-// public void putWidgetOnTop(GraphicObject w)
-// {
-// if (Children.Contains(w))
-// {
-// lock (children) {
-// Children.Remove (w);
-// Children.Add (w);
-// }
-// }
-// }
-// public void putWidgetOnBottom(GraphicObject w)
-// {
-// if (Children.Contains(w))
-// {
-// lock (children) {
-// Children.Remove (w);
-// Children.Insert (0, w);
-// }
-// }
-// }
+ public void putWidgetOnTop(GraphicObject w)
+ {
+ if (Children.Contains(w))
+ {
+ lock (children) {
+ Children.Remove (w);
+ Children.Add (w);
+ }
+ }
+ }
+ public void putWidgetOnBottom(GraphicObject w)
+ {
+ if (Children.Contains(w))
+ {
+ lock (children) {
+ Children.Remove (w);
+ Children.Insert (0, w);
+ }
+ }
+ }
#region GraphicObject overrides
public override void OnDataSourceChanged (object sender, DataSourceChangeEventArgs e)
}
return base.measureRawSize (lt);
}
-
+
public override void OnLayoutChanges (LayoutingType layoutType)
{
base.OnLayoutChanges (layoutType);
}
}
-
+
#region Mouse handling
public override void checkHoverWidget (MouseMoveEventArgs e)
{
namespace Crow
{
+ /// <summary>
+ /// templated container accepting one child
+ /// </summary>
public class GroupBox : TemplatedContainer
{
#region CTOR
namespace Crow
{
+ /// <summary>
+ /// group control stacking its children horizontally
+ /// </summary>
public class HorizontalStack : GenericStack
{
#region CTOR
else
pic = new BmpPicture ();
- pic.LoadImage (path);
+ pic.Load (path);
pic.Scaled = scaled;
pic.KeepProportions = keepProps;
}
public override bool MouseIsIn (Point m)
{
- return IsEnabled ? base.MouseIsIn (m) || child.MouseIsIn (m) : false;
+ return IsEnabled && !IsDragged ? base.MouseIsIn (m) || child.MouseIsIn (m) : false;
}
public override void onMouseEnter (object sender, MouseMoveEventArgs e)
{
grad.SetAsSource (gr, r);
CairoHelpers.CairoRectangle (gr, r, CornerRadius);
gr.Fill();
+
}
public override void Paint (ref Context ctx)
namespace Crow
{
+ /// <summary>
+ /// templeted numeric control
+ /// </summary>
public class ScrollBar : NumericControl
{
+ //TODO:could be replaced by a template for a Slider
+
Orientation _orientation;
#region CTOR
namespace Crow
{
+ /// <summary>
+ /// scrolling surface, to be contained in a smaller container in which it will be scrolled
+ /// </summary>
public class Scroller : Container
{
#region CTOR
namespace Crow
{
+ /// <summary>
+ /// generic class to build scrolling control in both directions
+ /// </summary>
public class ScrollingObject : GraphicObject
{
#region CTOR
namespace Crow
{
+ /// <summary>
+ /// templated numeric control to select a value
+ /// by slidding a cursor
+ /// </summary>
public class Slider : NumericControl
{
#region CTOR
namespace Crow
{
+ /// <summary>
+ /// templated control for selecting a numeric value by clicking on
+ /// up and down buttons
+ /// </summary>
public class Spinner : NumericControl
{
#region CTOR
namespace Crow
{
+ /// <summary>
+ /// control to add between children of a Stack to allow them to be resized
+ /// with the pointer
+ /// </summary>
public class Splitter : GraphicObject
{
#region CTOR
#region Mouse Handling
public override bool MouseIsIn (Point m)
{
- if (!Visible)
+ if (!(Visible & IsEnabled) || IsDragged)
return false;
bool mouseIsInTitle = TabTitle.ScreenCoordinates (TabTitle.Slot).ContainsOrIsEqual (m);
using System.Collections;
using System.Threading;
using System.Linq;
+using Crow.IML;
namespace Crow
{
namespace Crow
{
+ /// <summary>
+ /// group control stacking its children vertically
+ /// </summary>
public class VerticalStack : GenericStack
{
public VerticalStack() : base(){}
{
public class Window : TemplatedContainer
{
- enum Direction
+ protected enum Direction
{
None,
N,
string _icon;
bool _resizable;
bool _movable;
- bool hoverBorder = false;
+ protected bool hoverBorder = false;
bool alwaysOnTop = false;
Rectangle savedBounds;
Minimize.Raise (sender, e);
}
- protected void onBorderMouseLeave (object sender, MouseMoveEventArgs e)
+ protected virtual void onBorderMouseLeave (object sender, MouseMoveEventArgs e)
{
hoverBorder = false;
currentDirection = Direction.None;
CurrentInterface.MouseCursor = XCursor.Default;
}
- protected void onBorderMouseEnter (object sender, MouseMoveEventArgs e)
+ protected virtual void onBorderMouseEnter (object sender, MouseMoveEventArgs e)
{
hoverBorder = true;
}
namespace Crow
{
+ /// <summary>
+ /// group control that arrange its children in a direction and jump to
+ /// the next line or row when no room is left
+ /// </summary>
public class Wrapper : GenericStack
{
#region CTOR
using System;
using System.Reflection.Emit;
-namespace Crow
+namespace Crow.IML
{
/// <summary>
- /// Expression token, a variable, a string constant or a parsable constant (having a static Parse method)
- /// '../' => 1 level up in graphic tree
- /// './' or '/' => template root level
- /// '.Name1.Name2' current level properties
- /// 'name.prop' named descendant in graphic tree, search with 'FindByName' method of GraphicObject
+ /// Binding expression parser.
+ ///
+ /// Valid tokens in binding expression:
+ /// - '../' => 1 level up in graphic tree
+ /// - './' or '/' => template root level
+ /// - '.Name1.Name2' current level properties
+ /// - 'name.prop' named descendant in graphic tree, search with 'FindByName' method of GraphicObject
/// </summary>
public class BindingMember
{
public bool IsSingleName { get { return LevelsUp == 0 && Tokens.Length == 1; }}
#region CTOR
+ /// <summary>
+ /// Initializes a new instance of BindingMember.
+ /// </summary>
public BindingMember (){}
+ /// <summary>
+ /// Initializes a new instance of BindingMember by parsing the string passed as argument
+ /// </summary>
+ /// <param name="expression">binding expression</param>
public BindingMember (string expression){
if (string.IsNullOrEmpty (expression))
return;
}
#endregion
+ /// <summary>
+ /// Emits the MSIL instructions to get the target of the binding expression
+ /// </summary>
+ /// <param name="il">current MSIL generator</param>
+ /// <param name="cancel">cancel branching in MSIL if something go wrong</param>
public void emitGetTarget(ILGenerator il, System.Reflection.Emit.Label cancel){
if (IsTemplateBinding) {
il.Emit (OpCodes.Brfalse, cancel);
}
}
+ /// <summary>
+ /// Emit the MSIL instructions to get the target property of the binding expression
+ /// </summary>
+ /// <param name="il">current MSIL generator</param>
+ /// <param name="cancel">cancel branching in MSIL if something go wrong</param>
public void emitGetProperty(ILGenerator il, System.Reflection.Emit.Label cancel) {
System.Reflection.Emit.Label miOK = il.DefineLabel ();
il.Emit (OpCodes.Dup);//duplicate instance
il.MarkLabel (miOK);
il.Emit (OpCodes.Call, CompilerServices.miGetValWithRefx);
}
+ /// <summary>
+ /// Emit the MSIL instructions to set the target property of the binding expression
+ /// </summary>
+ /// <param name="il">current MSIL generator</param>
public void emitSetProperty(ILGenerator il) {
il.Emit (OpCodes.Ldstr, Tokens [Tokens.Length -1]);//load member name
il.Emit (OpCodes.Call, CompilerServices.miSetValWithRefx);
/// Parses IML and build a dynamic method that will be used to instanciate one or multiple occurence of the IML file or fragment
/// </summary>
void parseIML (XmlTextReader reader) {
- Context ctx = new Context (findRootType (reader));
+ IMLContext ctx = new IMLContext (findRootType (reader));
ctx.nodesStack.Push (new Node (ctx.RootType));
emitLoader (reader, ctx);
throw new Exception ("IML parsing error: undefined root type (" + root + ")");
return t;
}
- void emitLoader (XmlTextReader reader, Context ctx)
+ void emitLoader (XmlTextReader reader, IMLContext ctx)
{
string tmpXml = reader.ReadOuterXml ();
/// </summary>
/// <param name="ctx">Loading Context</param>
/// <param name="tmpXml">xml fragment</param>
- void emitTemplateLoad (Context ctx, string tmpXml) {
+ void emitTemplateLoad (IMLContext ctx, string tmpXml) {
//if its a template, first read template elements
using (XmlTextReader reader = new XmlTextReader (tmpXml, XmlNodeType.Element, null)) {
List<string[]> itemTemplateIds = new List<string[]> ();
/// </summary>
/// <param name="ctx">parsing context</param>
/// <param name="tmpXml">xml fragment</param>
- void emitGOLoad (Context ctx, string tmpXml) {
+ void emitGOLoad (IMLContext ctx, string tmpXml) {
using (XmlTextReader reader = new XmlTextReader (tmpXml, XmlNodeType.Element, null)) {
reader.Read ();
/// <summary>
/// Parse child node an generate corresponding msil
/// </summary>
- void readChildren (XmlTextReader reader, Context ctx, int startingIdx = 0)
+ void readChildren (XmlTextReader reader, IMLContext ctx, int startingIdx = 0)
{
bool endTagReached = false;
int nodeIdx = startingIdx;
}
#endregion
- void readPropertyBinding (Context ctx, string sourceMember, string expression)
+ void readPropertyBinding (IMLContext ctx, string sourceMember, string expression)
{
NodeAddress sourceNA = ctx.CurrentNodeAddress;
BindingDefinition bindingDef = sourceNA.GetBindingDef (sourceMember, expression);
/// Compile events expression in IML attributes, and store the result in the instanciator
/// Those handlers will be bound when instatiing
/// </summary>
- void compileAndStoreDynHandler (Context ctx, EventInfo sourceEvent, string expression)
+ void compileAndStoreDynHandler (IMLContext ctx, EventInfo sourceEvent, string expression)
{
//store event handler dynamic method in instanciator
int dmIdx = cachedDelegates.Count;
ctx.emitCachedDelegateHandlerAddition(dmIdx, sourceEvent);
}
/// <summary> Emits handler method bindings </summary>
- void emitHandlerBinding (Context ctx, EventInfo sourceEvent, string expression){
+ void emitHandlerBinding (IMLContext ctx, EventInfo sourceEvent, string expression){
NodeAddress currentNode = ctx.CurrentNodeAddress;
BindingDefinition bindingDef = currentNode.GetBindingDef (sourceEvent.Name, expression);
/// those delegates uses grtree functions to set destination value so they don't
/// need to be bound to destination instance as in the ancient system.
/// </summary>
- void emitBindingDelegates(Context ctx){
+ void emitBindingDelegates(IMLContext ctx){
foreach (KeyValuePair<NodeAddress,Dictionary<string, List<MemberAddress>>> bindings in ctx.Bindings ) {
if (bindings.Key.Count == 0)//template binding
emitTemplateBindings (ctx, bindings.Value);
emitPropertyBindings (ctx, bindings.Key, bindings.Value);
}
}
- void emitPropertyBindings(Context ctx, NodeAddress origine, Dictionary<string, List<MemberAddress>> bindings){
+ void emitPropertyBindings(IMLContext ctx, NodeAddress origine, Dictionary<string, List<MemberAddress>> bindings){
Type origineNodeType = origine.NodeType;
//value changed dyn method
#endif
}
- void emitTemplateBindings(Context ctx, Dictionary<string, List<MemberAddress>> bindings){
+ void emitTemplateBindings(IMLContext ctx, Dictionary<string, List<MemberAddress>> bindings){
//value changed dyn method
DynamicMethod dm = new DynamicMethod ("dyn_tmpValueChanged",
typeof (void), CompilerServices.argsValueChange, true);
/// <summary>
/// create the valuechanged handler, the datasourcechanged handler and emit event handling
/// </summary>
- void emitDataSourceBindings(Context ctx, BindingDefinition bindingDef){
+ void emitDataSourceBindings(IMLContext ctx, BindingDefinition bindingDef){
DynamicMethod dm = null;
ILGenerator il = null;
int dmVC = 0;
//TODO, ensure object is still in the graphic tree
//send move evt even if mouse move outside bounds
ActiveWidget.onMouseMove (this, e);
- return true;
+ if (!ActiveWidget.IsDragged)//if active is dragged, process mouse move as it was not visible.
+ return true;
}
if (HoverWidget != null) {
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
+using Crow.IML;
namespace Crow
{