From 025a522c98cf5d5155d5200ae80be6df7a9cf602 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Philippe=20Bruy=C3=A8re?= Date: Wed, 1 Nov 2017 08:51:09 +0100 Subject: [PATCH] comments and code clean --- Crow.OpenTK.nuspec | 2 +- CrowIDE/src/ImlVisualEditor.cs | 2 +- Tests/CrowWindow.cs | 18 ++++++++++++++++++ Tests/HelloWorld.cs | 4 +++- Tests/InterfaceControler.cs | 2 +- Tests/Showcase.cs | 4 ++-- src/GraphicObjects/GraphicObject.cs | 22 ++++++++++++++++++---- src/Interface.cs | 7 ++++++- src/LayoutingQueueItem.cs | 2 +- 9 files changed, 51 insertions(+), 12 deletions(-) diff --git a/Crow.OpenTK.nuspec b/Crow.OpenTK.nuspec index 21570980..f716521a 100644 --- a/Crow.OpenTK.nuspec +++ b/Crow.OpenTK.nuspec @@ -2,7 +2,7 @@ Crow.OpenTK - 0.5.4 + 0.5.6 C# Rapid Open Widget Toolkit JP Bruyere Grand Tetras Software diff --git a/CrowIDE/src/ImlVisualEditor.cs b/CrowIDE/src/ImlVisualEditor.cs index 61a1e8c8..62320029 100644 --- a/CrowIDE/src/ImlVisualEditor.cs +++ b/CrowIDE/src/ImlVisualEditor.cs @@ -189,7 +189,7 @@ namespace CrowIDE isDirty = imlVE.IsDirty; if (isDirty) { - lock (CurrentInterface.UpdateMutex) + lock (currentInterface.UpdateMutex) RegisterForRedraw (); } diff --git a/Tests/CrowWindow.cs b/Tests/CrowWindow.cs index e66fa7b3..304d56af 100644 --- a/Tests/CrowWindow.cs +++ b/Tests/CrowWindow.cs @@ -109,12 +109,29 @@ namespace Crow public List ifaceControl = new List(); int focusedIdx = -1, activeIdx = -2; + // TODO:We should be able to set the current interface programmaticaly + /// + /// Gets the currently focused interface, focus could have been given by creation of new iface controler and + /// not only by the mouse + /// + 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); } diff --git a/Tests/HelloWorld.cs b/Tests/HelloWorld.cs index 94433e9d..ca1560ef 100644 --- a/Tests/HelloWorld.cs +++ b/Tests/HelloWorld.cs @@ -40,7 +40,9 @@ namespace Tests { base.OnLoad (e); - AddWidget(new Label("Hello World")); + + AddWidget(Instantiator.CreateFromImlFragment (@"").CreateInstance (CurrentInterface)); + //Load(@"Interfaces/GraphicObject/0.crow"); } [STAThread] diff --git a/Tests/InterfaceControler.cs b/Tests/InterfaceControler.cs index 4da65d1e..5098e119 100644 --- a/Tests/InterfaceControler.cs +++ b/Tests/InterfaceControler.cs @@ -162,7 +162,7 @@ namespace Crow while (true) { CrowInterface.Update (); - Thread.Sleep (1); + Thread.Sleep (2); } } diff --git a/Tests/Showcase.cs b/Tests/Showcase.cs index ad57222f..0d68d383 100644 --- a/Tests/Showcase.cs +++ b/Tests/Showcase.cs @@ -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; } diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index 7b9f0c56..d443915e 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -806,6 +806,13 @@ namespace Crow } return false; } + /// + /// Gets the default value of the widget's property from either the style, or from xml default + /// + /// true, if default value is defined, false otherwise. + /// PropertyInfo + /// Styling informations + /// output of Default value, null if not found bool getDefaultValue(PropertyInfo pi, List