]> O.S.I.I.S - jp/crow.git/commitdiff
:memo:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Wed, 31 Jan 2018 13:27:38 +0000 (14:27 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Wed, 31 Jan 2018 13:57:11 +0000 (14:57 +0100)
14 files changed:
CrowIDE/src/ImlVisualEditor.cs
Images/screenshot.png [new file with mode: 0644]
README.md
src/GraphicObjects/Border.cs
src/GraphicObjects/Button.cs
src/GraphicObjects/Expandable.cs
src/GraphicObjects/GroupBox.cs
src/GraphicObjects/Popper.cs
src/GraphicObjects/PrivateContainer.cs
src/GraphicObjects/TabItem.cs
src/GraphicObjects/TemplatedContainer.cs
src/GraphicObjects/TemplatedControl.cs
src/GraphicObjects/Window.cs
src/Interface.cs

index 62320029f4225a6ce0f882e089304cbd59dd3986..61a1e8c8326a5e03e0e32f54be6652c463f699c2 100644 (file)
@@ -189,7 +189,7 @@ namespace CrowIDE
                                        isDirty = imlVE.IsDirty;
 
                                if (isDirty) {
-                                       lock (currentInterface.UpdateMutex)
+                                       lock (CurrentInterface.UpdateMutex)
                                                RegisterForRedraw ();
                                }
 
diff --git a/Images/screenshot.png b/Images/screenshot.png
new file mode 100644 (file)
index 0000000..23be2ad
Binary files /dev/null and b/Images/screenshot.png differ
index ffe27ae47539700ce9b2ac70f25b30d239026b5e..31893653142b0da69ced17410646884b350e8a95 100644 (file)
--- 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)_
+<h1 align="center">
+  <br>
+  <a href="http://www.amitmerchant.com/electron-markdownify">
+    <img src="https://github.com/jpbruyere/Crow/blob/master/Images/Icons/crow.png" alt="C.R.O.W." width="140">
+  </a>
+  <br>  
+    <br>
+  C# Rapid Open Widgets
+  <br>  
+<p align="center">
+  <a href="https://www.paypal.me/GrandTetraSoftware">
+    <img src="https://img.shields.io/badge/Donate-PayPal-green.svg">
+  </a>
+  <a href="https://www.nuget.org/packages/Crow.OpenTK">
+    <img src="https://buildstats.info/nuget/Crow.OpenTK">
+  </a>
+  <a href="https://travis-ci.org/jpbruyere/Crow">
+      <img src="https://travis-ci.org/jpbruyere/Crow.svg?branch=master">
+  </a>
+  <a href="https://ci.appveyor.com/project/jpbruyere/Crow">
+    <img src="https://ci.appveyor.com/api/projects/status/j387lo59vnov8jbc?svg=true">
+  </a>
+</p>
+</h1>
+
+**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.
+<p align="center">
+  <a href="https://github.com/jpbruyere/Crow/blob/master/Images/screenshot.png">
+    <img src="https://github.com/jpbruyere/Crow/blob/master/Images/screenshot.png" width="400">
+  </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.
 
 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
-------------
-
-<table width="100%">
-  <tr>
-    <td width="30%" align="center"><img src="https://jpbruyere.github.io/Crow/images/screenshot5.png" alt="CrowIDE" width="90%"/></td>
-    <td width="30%" align="center"><img src="https://jpbruyere.github.io/Crow/images/screenshot4.png" alt="Screen Shot" width="90%" /> </td>
-    <td width="30%" align="center"><img src="https://jpbruyere.github.io/Crow/images/screenshot3.png" alt="Screen Shot" width="90%"/> </td>
-  </tr>
-</table>
-
-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` .
index 6ac97d7f1bc6509724e592a60e651f4802960e51..a7c039c3001080cfd347c1c7895cd7cc4dd69676 100644 (file)
@@ -31,12 +31,18 @@ using System.Diagnostics;
 
 namespace Crow
 {
+       /// <summary>
+       /// provide an easy way to get 3d border for buttons
+       /// </summary>
        public enum BorderStyle {
                Normal,
                Raised,
                Sunken
        };
 
+       /// <summary>
+       /// simple container with border
+       /// </summary>
        public class Border : Container
        {
                #region CTOR
@@ -52,6 +58,9 @@ namespace Crow
                #endregion
 
                #region public properties
+               /// <summary>
+               /// use to define the colors of the 3d border
+               /// </summary>
                [XmlAttributeAttribute]
                public virtual Fill RaisedColor {
                        get { return raisedColor; }
@@ -63,6 +72,9 @@ namespace Crow
                                RegisterForRedraw ();
                        }
                }
+               /// <summary>
+               /// use to define the colors of the 3d border
+               /// </summary>
                [XmlAttributeAttribute]
                public virtual Fill SunkenColor {
                        get { return sunkenColor; }
@@ -74,6 +86,9 @@ namespace Crow
                                RegisterForRedraw ();
                        }
                }
+               /// <summary>
+               /// border width in pixels
+               /// </summary>
                [XmlAttributeAttribute()][DefaultValue(1)]
                public virtual int BorderWidth {
                        get { return _borderWidth; }
@@ -82,6 +97,9 @@ namespace Crow
                                RegisterForGraphicUpdate ();
                        }
                }
+               /// <summary>
+               /// allow 3d border effects
+               /// </summary>
                [XmlAttributeAttribute][DefaultValue(BorderStyle.Normal)]
                public virtual BorderStyle BorderStyle {
                        get { return _borderStyle; }
index 4f791ed9e810e5af7046a49d02732106f463b058..f8697f913ba07ba402afa771912a2b88eb855d12 100644 (file)
@@ -47,7 +47,6 @@ namespace Crow
 
                string image;
                bool isPressed;
-               Container _contentContainer;
 
                public event EventHandler Pressed;
                public event EventHandler Released;
index 243caf06b6744c5b600fe1cf3dd46bbc9dec5a38..2328fd5f00acaf65f40f49aa8eb6c3126cd53906 100644 (file)
@@ -30,6 +30,9 @@ using System.Xml.Serialization;
 
 namespace Crow
 {
+       /// <summary>
+       /// templated control whose content can be hidden and shown on demand
+       /// </summary>
     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
+               /// <summary>
+               /// Occurs when control is expanded.
+               /// </summary>
                public event EventHandler Expand;
+               /// <summary>
+               /// Occurs when control is collapsed.
+               /// </summary>
                public event EventHandler Collapse;
                #endregion
 
                public BooleanTestOnInstance GetIsExpandable;
 
+               /// <summary>
+               /// mouse click event handler for easy expand triggering in IML
+               /// </summary>
                public void onClickForExpand (object sender, MouseButtonEventArgs e)
                {
                        IsExpanded = !IsExpanded;
                }
-
+               /// <summary>
+               /// Implement the abstract Content property of TemplatedControl
+               /// </summary>
                public override GraphicObject Content {
                        get {
                                return _contentContainer == null ? null : _contentContainer.Child;
index ad79231e9ff0c44d45f06873ee8d2f49a0e166c4..d843f9931a9c47c9ea3356226f7c01ccca48edc7 100644 (file)
@@ -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;
index 9f60aa4022f26b84d0a1cf7a3c50a8c78e64ed43..175c99fd172ea5ac758fc0e81d3f544733bd4bd6 100644 (file)
@@ -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);
                }
index f25190ea6764f1512f8a3c8ea34e10aa1fca9363..6eb5e95e787760444ae448eb5ae9cfbf243da666 100644 (file)
@@ -33,7 +33,7 @@ namespace Crow
 {
        /// <summary>
        /// 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
index 2b578d18086afa8899de6dee5462c8d3f2a90dfe..afafb0f191d4efe7da873266b2be37f46ad843c9 100644 (file)
@@ -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")]
index c219f9b610e19376e7bd7b8b82efc86815db9ab1..02c14d381d26a4c7abd8dc8b95fff6e1c155c2a2 100644 (file)
@@ -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
index 6476265a3ecf6e069428d9c8c7a707352ec0a9c9..01ba22c23f333882a710534c6f0be73436564ca4 100644 (file)
@@ -37,6 +37,9 @@ using System.Reflection;
 
 namespace Crow
 {
+       /// <summary>
+       /// Base class for all templated widget
+       /// </summary>
        public abstract class TemplatedControl : PrivateContainer
        {
                #region CTOR
@@ -64,6 +67,9 @@ namespace Crow
                                        loadTemplate (CurrentInterface.Load (_template));
                        }
                }
+               /// <summary>
+               /// caption property being recurrent in templated widget, it is declared here.
+               /// </summary>
                [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 ();
                }
+               /// <summary>
+               /// override search method from GraphicObject to prevent
+               /// searching inside template
+               /// </summary>
+               /// <returns>widget identified by name, or null if not found</returns>
+               /// <param name="nameToFind">widget's name to find</param>
                public override GraphicObject FindByName (string nameToFind)
                {
                        //prevent name searching in template
                        return nameToFind == this.Name ? this : null;
                }
+               /// <summary>
+               ///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
+               /// </summary>
+               /// <param name="gr">Backend context</param>
                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
 
+               /// <summary>
+               /// Loads the template.
+               /// </summary>
+               /// <param name="template">Optional template instance</param>
                protected virtual void loadTemplate(GraphicObject template = null)
                {
                        if (this.child != null)//template change, bindings has to be reset
index d4087d0285c4aba16a2abdd146489148070bd139..336784e29fba7ad51f5a76b5e17942ad40eb496b 100644 (file)
@@ -55,7 +55,6 @@ namespace Crow
                Rectangle savedBounds;
                bool _minimized = false;
 
-               Container _contentContainer;
                Direction currentDirection = Direction.None;
 
                #region Events
index 19f4a88914c613ac08222c90e0624d74d65fa850..188c4a39e25d2f9d1a937c045d41b5755812c620 100644 (file)
@@ -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
+               /// <summary>
+               /// Crow configuration root path
+               /// </summary>
+               public static string CrowConfigRoot;
                /// <summary>If true, mouse focus is given when mouse is over control</summary>
                public static bool FocusOnHover = false;
                /// <summary> Threshold to catch borders for sizing </summary>
@@ -217,9 +229,22 @@ namespace Crow
                public static Dictionary<string, string> DefaultTemplates = new Dictionary<string, string>();
                /// <summary>Finds available default templates at startup</summary>
                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 ()