]> O.S.I.I.S - jp/crow.git/commitdiff
comments and code clean
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Wed, 1 Nov 2017 07:51:09 +0000 (08:51 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Wed, 1 Nov 2017 07:51:09 +0000 (08:51 +0100)
Crow.OpenTK.nuspec
CrowIDE/src/ImlVisualEditor.cs
Tests/CrowWindow.cs
Tests/HelloWorld.cs
Tests/InterfaceControler.cs
Tests/Showcase.cs
src/GraphicObjects/GraphicObject.cs
src/Interface.cs
src/LayoutingQueueItem.cs

index 21570980a2e3045dbadec35f802691d736bb4e35..f716521ad8ec3cb759cde328acba368e1c22882c 100644 (file)
@@ -2,7 +2,7 @@
 <package >
        <metadata>
                <id>Crow.OpenTK</id>
-               <version>0.5.4</version>
+               <version>0.5.6</version>
                <title>C# Rapid Open Widget Toolkit</title>
                <authors>JP Bruyere</authors>
                <owners>Grand Tetras Software</owners>
index 61a1e8c8326a5e03e0e32f54be6652c463f699c2..62320029f4225a6ce0f882e089304cbd59dd3986 100644 (file)
@@ -189,7 +189,7 @@ namespace CrowIDE
                                        isDirty = imlVE.IsDirty;
 
                                if (isDirty) {
-                                       lock (CurrentInterface.UpdateMutex)
+                                       lock (currentInterface.UpdateMutex)
                                                RegisterForRedraw ();
                                }
 
index e66fa7b3ca1df9bfcad51ae222add2b4d5aa3fa3..304d56af189ee14fc7b6f4831f8ef4f6e0e2e504 100644 (file)
@@ -109,12 +109,29 @@ namespace Crow
                public List<InterfaceControler> ifaceControl = new List<InterfaceControler>();
                int focusedIdx = -1, activeIdx = -2;
 
+               // TODO:We should be able to set the current interface programmaticaly
+               /// <summary>
+               /// Gets the currently focused interface, focus could have been given by creation of new iface controler and
+               /// not only by the mouse
+               /// </summary>
+               public Interface CurrentInterface {
+                       get {
+                               if (ifaceControl.Count == 0) {//create default orthogonal interface
+                                       addInterfaceControler (new InterfaceControler (
+                                               new Rectangle (0, 0, this.ClientRectangle.Width, this.ClientRectangle.Height)));
+                                       focusedIdx = 0;
+                               }
+                               return ifaceControl [focusedIdx].CrowInterface;
+                       }
+               }
+                       
                void addInterfaceControler(InterfaceControler ifaceControler)
                {
                        ifaceControler.CrowInterface.Quit += Quit;
                        ifaceControler.CrowInterface.MouseCursorChanged += CrowInterface_MouseCursorChanged;
 
                        ifaceControl.Add (ifaceControler);
+                       focusedIdx = ifaceControl.Count - 1;
                }
                void openGLDraw(){
                        //save GL states
@@ -190,6 +207,7 @@ namespace Crow
                        ifaceControl [interfaceIdx].CrowInterface.AddWidget (g);
                        return g;
                }
+
                public void DeleteWidget (GraphicObject g, int interfaceIdx = 0){
                        ifaceControl [interfaceIdx].CrowInterface.DeleteWidget (g);
                }
index 94433e9dedadcdab06bc9d8241305d2773c6fbdf..ca1560ef9a80b28494189137a212e57de1ef262e 100644 (file)
@@ -40,7 +40,9 @@ namespace Tests
                {
                        base.OnLoad (e);
 
-                       AddWidget(new Label("Hello World"));
+
+                       AddWidget(Instantiator.CreateFromImlFragment (@"<Border Fit='true' BorderWidth='2' BorderStyle='Normal' MouseDown='{BorderStyle=Sunken}' MouseUp='{BorderStyle=Raised}' MouseEnter='{BorderStyle=Raised}' MouseLeave='{BorderStyle=Normal}'><Label Margin='50'/></Border>").CreateInstance (CurrentInterface));
+                       //Load(@"Interfaces/GraphicObject/0.crow");
                }
 
                [STAThread]
index 4da65d1ee2e982f40b1ec9fb7d21a7bb0f126fe5..5098e1199b8247aeab3e17550c60867c16526a03 100644 (file)
@@ -162,7 +162,7 @@ namespace Crow
 
                        while (true) {
                                CrowInterface.Update ();
-                               Thread.Sleep (1);
+                               Thread.Sleep (2);
                        }
                }
 
index ad57222f82b60ad98a59d62ff22bb3ddfffbf01a..0d68d3836dc1429195761eef4d97a2b08b622a4f 100644 (file)
@@ -70,8 +70,8 @@ namespace Tests
                                return;
                        if (fi is DirectoryInfo)
                                return;
-                       lock (this.ifaceControl [0].CrowInterface.UpdateMutex) {
-                               GraphicObject g = this.ifaceControl [0].CrowInterface.Load (fi.FullName);
+                       lock (this.CurrentInterface.UpdateMutex) {
+                               GraphicObject g = this.CurrentInterface.Load (fi.FullName);
                                crowContainer.SetChild (g);
                                g.DataSource = this;
                        }
index 7b9f0c56c795560fd41a0848f8e80ad4a7e5982a..d443915e245bf4ae5c41caf7b1375026a30f6f9d 100644 (file)
@@ -806,6 +806,13 @@ namespace Crow
                        }
                        return false;
                }
+               /// <summary>
+               /// Gets the default value of the widget's property from either the style, or from xml default
+               /// </summary>
+               /// <returns><c>true</c>, if default value is defined, <c>false</c> otherwise.</returns>
+               /// <param name="pi">PropertyInfo</param>
+               /// <param name="styling">Styling informations</param>
+               /// <param name="defaultValue">output of Default value, null if not found</param>
                bool getDefaultValue(PropertyInfo pi, List<Style> styling,
                        out object defaultValue){
                        defaultValue = null;
@@ -904,7 +911,7 @@ namespace Crow
                public void RegisterForGraphicUpdate ()
                {
                        #if DEBUG_UPDATE
-                       Debug.WriteLine (string.Format("RegisterForGraphicUpdate -> {0}", this.ToString ()));
+                       Debug.WriteLine (string.Format("RegisterForGraphicUpdate (IsDirty set)-> {0}", this.ToString ()));
                        #endif
                        IsDirty = true;
                        if (Width.IsFit || Height.IsFit)
@@ -917,7 +924,7 @@ namespace Crow
                public void RegisterForRedraw ()
                {
                        #if DEBUG_UPDATE
-                       Debug.WriteLine (string.Format("RegisterForRedraw -> {0}", this.ToString ()));
+                       Debug.WriteLine (string.Format("RegisterForRedraw (IsDirty set)-> {0}", this.ToString ()));
                        #endif
                        IsDirty = true;
                        if (RegisteredLayoutings == LayoutingType.None)
@@ -1003,6 +1010,9 @@ namespace Crow
                /// met and LQI has to be re-queued</returns>
                public virtual bool UpdateLayout (LayoutingType layoutType)
                {
+                       #if DEBUG_UPDATE
+                       Debug.WriteLine (string.Format("UpdateLayout ({1})-> {0}", this.ToString (), layoutType));
+                       #endif
                        //unset bit, it would be reset if LQI is re-queued
                        registeredLayoutings &= (~layoutType);
 
@@ -1153,6 +1163,10 @@ namespace Crow
                /// <summary> This is the common overridable drawing routine to create new widget </summary>
                protected virtual void onDraw(Context gr)
                {
+                       #if DEBUG_UPDATE
+                       Debug.WriteLine (string.Format("OnDraw -> {0}", this.ToString ()));
+                       #endif
+
                        Rectangle rBack = new Rectangle (Slot.Size);
 
                        Background.SetAsSource (gr, rBack);
@@ -1166,7 +1180,7 @@ namespace Crow
                protected virtual void RecreateCache ()
                {
                        #if DEBUG_UPDATE
-                       Debug.WriteLine ("RecreateCache -> {0}", this.ToString ());
+                       Debug.WriteLine (string.Format("RecreateCache -> {0}", this.ToString ()));
                        #endif
                        IsDirty = false;
                        if (bmp != null)
@@ -1180,7 +1194,7 @@ namespace Crow
                }
                protected virtual void UpdateCache(Context ctx){
                        #if DEBUG_UPDATE
-                       Debug.WriteLine ("UpdateCache -> {0}", this.ToString ());
+                       Debug.WriteLine (string.Format("UpdateCache -> {0}", this.ToString ()));
                        #endif
                        Rectangle rb = Slot + Parent.ClientRectangle.Position;
                        if (clearBackground) {
index 24bd3ca23adaa84078ea82c1c1c3ebef0950207b..53d90ea5fc151d286b2ef77f028bc9169755b258 100644 (file)
@@ -373,9 +373,14 @@ namespace Crow
 
                #region UPDATE Loops
                /// <summary>Enqueue Graphic object for Repaint, DrawingQueue is locked because
-               /// GraphObj's property Set methods could trigger an update from another thread</summary>
+               /// GraphObj's property Set methods could trigger an update from another thread
+               /// Once in that queue, the layouting of obj and childs is ok, the next step
+               /// when dequeued is clipping registration</summary>
                public void EnqueueForRepaint(GraphicObject g)
                {
+                       #if DEBUG_UPDATE
+                       Debug.WriteLine (string.Format("\tEnqueueForRepaint -> {0}", g?.ToString ()));
+                       #endif
                        lock (DrawingQueue) {
                                if (g.IsQueueForRedraw)
                                        return;
index 47807a9939a2bd2d65150fde85de0ff522cd3ee5..302169bb46ba5518f83206284876264d38a540c0 100644 (file)
@@ -100,7 +100,7 @@ namespace Crow
                        if (Layoutable.Parent == null) {//TODO:improve this
                                //cancel layouting for object without parent, maybe some were in queue when
                                //removed from a listbox
-                               #if DEBUG_LAYOUTING
+                               #if DEBUG_UPDATE || DEBUG_LAYOUTING
                                Debug.WriteLine ("ERROR: processLayouting, no parent for: " + this.ToString ());
                                #endif
                                return;