From: Jean-Philippe Bruyère Date: Wed, 31 Jan 2018 13:27:38 +0000 (+0100) Subject: :memo: X-Git-Tag: v0.9.5-beta~192 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=e3a586148d084b7eea974bae4fa00a19fc547c28;p=jp%2Fcrow.git :memo: --- diff --git a/Images/screenshot.png b/Images/screenshot.png new file mode 100644 index 00000000..23be2ad4 Binary files /dev/null and b/Images/screenshot.png differ diff --git a/README.md b/README.md index ffe27ae4..31893653 100644 --- a/README.md +++ b/README.md @@ -1,48 +1,61 @@ -# C# Rapid Open Widgets -[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.me/GrandTetraSoftware) [![NuGet Version and Downloads](https://buildstats.info/nuget/Crow.OpenTK)](https://www.nuget.org/packages/Crow.OpenTK) [![Build Status](https://travis-ci.org/jpbruyere/Crow.svg?branch=master)](https://travis-ci.org/jpbruyere/Crow) [![Build Status Windows](https://ci.appveyor.com/api/projects/status/j387lo59vnov8jbc?svg=true)](https://ci.appveyor.com/project/jpbruyere/Crow) - -**CROW** is a pure **C#** widget toolkit originally developed for fast GUI implementation in [OpenTK](http://opentk.github.io/) applications. - -You can visit the [Wiki](https://github.com/jpbruyere/Crow/wiki) or the [Project Site](https://jpbruyere.github.io/Crow/) for documentation and tutorials. _(in progress)_ +

+
+ + C.R.O.W. + +
+
+ C# Rapid Open Widgets +
+

+ + + + + + + + + + + + +

+

+ +**C.R.O.W.** is a [widget toolkit](https://en.wikipedia.org/wiki/Widget_toolkit) and +rendering engine entirely developed in **C#**, offering a nice trade-off between +complexity of language and performances. Crow provides a declarative interface language +with styling and templates +called [IML](interface-markup-language) for **Interface Markup Language** similar to +[XAML](https://en.wikipedia.org/wiki/Extensible_Application_Markup_Language) and a binding system +for easy c# code linking. +

+ + + +

+ +You can visit the [Wiki](https://github.com/jpbruyere/Crow/wiki) or the [Project Site](https://jpbruyere.github.io/Crow/) +for documentation and tutorials. Please report bugs and issues on [GitHub](https://github.com/jpbruyere/Crow/issues) -Features --------- - -- **XML** interface definition. -- Templates and styling -- Dynamic binding system with code injection. -- Inlined delegates in XML - -Screen shots ------------- - - - - - - - -
CrowIDEScreen Shot Screen Shot
- -Requirements ------------- - -- c# compiler +## Getting Start +### Requirements +- [mono > 4.5](http://www.mono-project.com/) - [Cairo Graphic Library](https://cairographics.org/) >= 1.10 - -Building ------------------- +- [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 +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 CROW in your OpenTK project ---------------------------------- +### 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` . diff --git a/src/GraphicObjects/Border.cs b/src/GraphicObjects/Border.cs index 6ac97d7f..a7c039c3 100644 --- a/src/GraphicObjects/Border.cs +++ b/src/GraphicObjects/Border.cs @@ -31,12 +31,18 @@ using System.Diagnostics; namespace Crow { + /// + /// provide an easy way to get 3d border for buttons + /// public enum BorderStyle { Normal, Raised, Sunken }; + /// + /// simple container with border + /// public class Border : Container { #region CTOR @@ -52,6 +58,9 @@ namespace Crow #endregion #region public properties + /// + /// use to define the colors of the 3d border + /// [XmlAttributeAttribute] public virtual Fill RaisedColor { get { return raisedColor; } @@ -63,6 +72,9 @@ namespace Crow RegisterForRedraw (); } } + /// + /// use to define the colors of the 3d border + /// [XmlAttributeAttribute] public virtual Fill SunkenColor { get { return sunkenColor; } @@ -74,6 +86,9 @@ namespace Crow RegisterForRedraw (); } } + /// + /// border width in pixels + /// [XmlAttributeAttribute()][DefaultValue(1)] public virtual int BorderWidth { get { return _borderWidth; } @@ -82,6 +97,9 @@ namespace Crow RegisterForGraphicUpdate (); } } + /// + /// allow 3d border effects + /// [XmlAttributeAttribute][DefaultValue(BorderStyle.Normal)] public virtual BorderStyle BorderStyle { get { return _borderStyle; } diff --git a/src/GraphicObjects/Button.cs b/src/GraphicObjects/Button.cs index 4f791ed9..f8697f91 100644 --- a/src/GraphicObjects/Button.cs +++ b/src/GraphicObjects/Button.cs @@ -47,7 +47,6 @@ namespace Crow string image; bool isPressed; - Container _contentContainer; public event EventHandler Pressed; public event EventHandler Released; diff --git a/src/GraphicObjects/Expandable.cs b/src/GraphicObjects/Expandable.cs index 243caf06..2328fd5f 100644 --- a/src/GraphicObjects/Expandable.cs +++ b/src/GraphicObjects/Expandable.cs @@ -30,6 +30,9 @@ using System.Xml.Serialization; namespace Crow { + /// + /// templated control whose content can be hidden and shown on demand + /// public class Expandable : TemplatedContainer { #region CTOR @@ -40,21 +43,31 @@ namespace Crow #region Private fields bool _isExpanded; string image; - Container _contentContainer; #endregion #region Event Handlers + /// + /// Occurs when control is expanded. + /// public event EventHandler Expand; + /// + /// Occurs when control is collapsed. + /// public event EventHandler Collapse; #endregion public BooleanTestOnInstance GetIsExpandable; + /// + /// mouse click event handler for easy expand triggering in IML + /// public void onClickForExpand (object sender, MouseButtonEventArgs e) { IsExpanded = !IsExpanded; } - + /// + /// Implement the abstract Content property of TemplatedControl + /// public override GraphicObject Content { get { return _contentContainer == null ? null : _contentContainer.Child; diff --git a/src/GraphicObjects/GroupBox.cs b/src/GraphicObjects/GroupBox.cs index ad79231e..d843f993 100644 --- a/src/GraphicObjects/GroupBox.cs +++ b/src/GraphicObjects/GroupBox.cs @@ -31,15 +31,13 @@ using System.ComponentModel; namespace Crow { public class GroupBox : TemplatedContainer - { - Container _contentContainer; - + { #region CTOR public GroupBox () : base(){} public GroupBox(Interface iface) : base(iface){} #endregion - #region Template overrides + #region TemplatedContainer implementation public override GraphicObject Content { get { return _contentContainer == null ? null : _contentContainer.Child; diff --git a/src/GraphicObjects/Popper.cs b/src/GraphicObjects/Popper.cs index 9f60aa40..175c99fd 100644 --- a/src/GraphicObjects/Popper.cs +++ b/src/GraphicObjects/Popper.cs @@ -39,7 +39,7 @@ namespace Crow bool _isPopped, _canPop; Alignment popDirection; - GraphicObject _content; + GraphicObject _contentContainer; Measure popWidth, popHeight; public event EventHandler Popped; @@ -111,22 +111,22 @@ namespace Crow #endregion public override GraphicObject Content { - get { return _content; } + get { return _contentContainer; } set { - if (_content != null) { - _content.LogicalParent = null; - _content.LayoutChanged -= _content_LayoutChanged; + if (_contentContainer != null) { + _contentContainer.LogicalParent = null; + _contentContainer.LayoutChanged -= _content_LayoutChanged; } - _content = value; + _contentContainer = value; - if (_content == null) + if (_contentContainer == null) return; - _content.LogicalParent = this; - _content.HorizontalAlignment = HorizontalAlignment.Left; - _content.VerticalAlignment = VerticalAlignment.Top; - _content.LayoutChanged += _content_LayoutChanged; + _contentContainer.LogicalParent = this; + _contentContainer.HorizontalAlignment = HorizontalAlignment.Left; + _contentContainer.VerticalAlignment = VerticalAlignment.Top; + _contentContainer.LayoutChanged += _content_LayoutChanged; } } void positionContent(LayoutingType lt){ @@ -242,9 +242,9 @@ namespace Crow protected override void Dispose (bool disposing) { - if (_content != null && disposing) { - if (_content.Parent == null) - _content.Dispose (); + if (_contentContainer != null && disposing) { + if (_contentContainer.Parent == null) + _contentContainer.Dispose (); } base.Dispose (disposing); } diff --git a/src/GraphicObjects/PrivateContainer.cs b/src/GraphicObjects/PrivateContainer.cs index f25190ea..6eb5e95e 100644 --- a/src/GraphicObjects/PrivateContainer.cs +++ b/src/GraphicObjects/PrivateContainer.cs @@ -33,7 +33,7 @@ namespace Crow { /// /// Implement drawing and layouting for a single child, but - /// does not implement IXmlSerialisation to allow reuse of container + /// does not expose child to allow reuse of container /// behaviour for widgets that have other xml hierarchy: example /// TemplatedControl may have 3 children (template,templateItem,content) but /// behave exactely as a container for layouting and drawing diff --git a/src/GraphicObjects/TabItem.cs b/src/GraphicObjects/TabItem.cs index 2b578d18..afafb0f1 100644 --- a/src/GraphicObjects/TabItem.cs +++ b/src/GraphicObjects/TabItem.cs @@ -39,9 +39,7 @@ namespace Crow #endregion #region Private fields - string caption; - Container _contentContainer; - GraphicObject _tabTitle; + GraphicObject titleWidget; int tabOffset; bool isSelected; Measure tabThickness; @@ -67,9 +65,9 @@ namespace Crow base.loadTemplate (template); _contentContainer = this.child.FindByName ("Content") as Container; - _tabTitle = this.child.FindByName ("TabTitle"); + titleWidget = this.child.FindByName ("TabTitle"); } - internal GraphicObject TabTitle { get { return _tabTitle; }} + internal GraphicObject TabTitle { get { return titleWidget; }} #endregion [XmlAttributeAttribute][DefaultValue("18")] diff --git a/src/GraphicObjects/TemplatedContainer.cs b/src/GraphicObjects/TemplatedContainer.cs index c219f9b6..02c14d38 100644 --- a/src/GraphicObjects/TemplatedContainer.cs +++ b/src/GraphicObjects/TemplatedContainer.cs @@ -38,6 +38,8 @@ namespace Crow public TemplatedContainer (Interface iface) : base(iface){} #endregion + protected Container _contentContainer; + [XmlAttributeAttribute]public virtual GraphicObject Content{ get; set;} #region GraphicObject overrides diff --git a/src/GraphicObjects/TemplatedControl.cs b/src/GraphicObjects/TemplatedControl.cs index 6476265a..01ba22c2 100644 --- a/src/GraphicObjects/TemplatedControl.cs +++ b/src/GraphicObjects/TemplatedControl.cs @@ -37,6 +37,9 @@ using System.Reflection; namespace Crow { + /// + /// Base class for all templated widget + /// public abstract class TemplatedControl : PrivateContainer { #region CTOR @@ -64,6 +67,9 @@ namespace Crow loadTemplate (CurrentInterface.Load (_template)); } } + /// + /// caption property being recurrent in templated widget, it is declared here. + /// [XmlAttributeAttribute()][DefaultValue("Templated Control")] public virtual string Caption { get { return caption; } @@ -74,22 +80,33 @@ namespace Crow NotifyValueChanged ("Caption", caption); } } + #region GraphicObject overrides + public override void Initialize () { loadTemplate (); base.Initialize (); } + /// + /// override search method from GraphicObject to prevent + /// searching inside template + /// + /// widget identified by name, or null if not found + /// widget's name to find public override GraphicObject FindByName (string nameToFind) { //prevent name searching in template return nameToFind == this.Name ? this : null; } + /// + ///onDraw is overrided to prevent default drawing of background, template top container + ///may have a binding to root background or a fixed one. + ///this allow applying root background to random template's component + /// + /// Backend context protected override void onDraw (Cairo.Context gr) { - //onDraw is overrided to prevent default drawing of background, template top container - //may have a binding to root background or a fixed one. - //this allow applying root background to random template's component gr.Save (); if (ClipToClientRect) { @@ -104,6 +121,10 @@ namespace Crow } #endregion + /// + /// Loads the template. + /// + /// Optional template instance protected virtual void loadTemplate(GraphicObject template = null) { if (this.child != null)//template change, bindings has to be reset diff --git a/src/GraphicObjects/Window.cs b/src/GraphicObjects/Window.cs index d4087d02..336784e2 100644 --- a/src/GraphicObjects/Window.cs +++ b/src/GraphicObjects/Window.cs @@ -55,7 +55,6 @@ namespace Crow Rectangle savedBounds; bool _minimized = false; - Container _contentContainer; Direction currentDirection = Direction.None; #region Events diff --git a/src/Interface.cs b/src/Interface.cs index 19f4a889..188c4a39 100644 --- a/src/Interface.cs +++ b/src/Interface.cs @@ -53,6 +53,14 @@ namespace Crow { #region CTOR static Interface(){ + CrowConfigRoot = + System.IO.Path.Combine( + Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), + ".config"); + CrowConfigRoot = System.IO.Path.Combine (CrowConfigRoot, "crow"); + if (!Directory.Exists (CrowConfigRoot)) + Directory.CreateDirectory (CrowConfigRoot); + loadCursors (); loadStyling (); findAvailableTemplates (); @@ -70,6 +78,10 @@ namespace Crow #endregion #region Static and constants + /// + /// Crow configuration root path + /// + public static string CrowConfigRoot; /// If true, mouse focus is given when mouse is over control public static bool FocusOnHover = false; /// Threshold to catch borders for sizing @@ -217,9 +229,22 @@ namespace Crow public static Dictionary DefaultTemplates = new Dictionary(); /// Finds available default templates at startup static void findAvailableTemplates(){ + searchTemplatesOnDisk ("./"); + string defTemplatePath = System.IO.Path.Combine (CrowConfigRoot, "defaultTemplates"); + searchTemplatesOnDisk (defTemplatePath); searchTemplatesIn (Assembly.GetEntryAssembly ()); searchTemplatesIn (Assembly.GetExecutingAssembly ()); } + static void searchTemplatesOnDisk (string templatePath){ + if (!Directory.Exists (templatePath)) + return; + foreach (string f in Directory.GetFiles(templatePath, "*.template",SearchOption.AllDirectories)) { + string clsName = System.IO.Path.GetFileNameWithoutExtension(f); + if (DefaultTemplates.ContainsKey (clsName)) + continue; + DefaultTemplates [clsName] = f; + } + } static void searchTemplatesIn(Assembly assembly){ foreach (string resId in assembly .GetManifestResourceNames ()