From: Jean-Philippe Bruyère Date: Fri, 9 Feb 2018 17:46:40 +0000 (+0100) Subject: Squashed commit devel branch: X-Git-Tag: v0.9.5-beta~179 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=49c7adb31d17bfc9f5349f8c8343a4ca6318d3aa;p=jp%2Fcrow.git Squashed commit devel branch: commit 7f91f7c2e83f7cfb2922ea83586f156f03f88a59 Author: Jean-Philippe Bruyère Date: Fri Feb 9 18:13:59 2018 +0100 go back to OpenTK-2, waiting for an official release commit 125f32758a584c4976d3536eab3702fd37a8a7a9 Author: Jean-Philippe Bruyère Date: Fri Feb 9 17:26:00 2018 +0100 LoadInterface replaced by AddWidget overload, [ide] property view item templates in separate template file commit 7c48cd2f0332d2ec82006edb755fcd37ab1f2b4a Author: Jean-Philippe Bruyère Date: Fri Feb 9 12:10:13 2018 +0100 Tooltips, CrowIDE improvements, Fetch subdata when test not eq TypeOf, debug listener in basicTest, RemoveWidget in iface modifié : Crow.ControlsLib/Crow.ControlsLib.csproj modifié : Crow.csproj modifié : Crow.sln modifié : CrowIDE/CrowIDE.csproj modifié : CrowIDE/src/CrowIDE.cs modifié : CrowIDE/src/ImlVisualEditor.cs nouveau fichier : CrowIDE/src/Project.cs nouveau fichier : CrowIDE/src/Solution.cs nouveau fichier : CrowIDE/src/VerticalLine.cs nouveau fichier : CrowIDE/ui/ProjectProperties.crow nouveau fichier : CrowIDE/ui/ProjectTree.template nouveau fichier : CrowIDE/ui/TreeExpandable.template modifié : CrowIDE/ui/imlEditor.crow modifié : Default.style nouveau fichier : Icons/assembly.svg nouveau fichier : Templates/Tooltip.template modifié : Tests/BasicTests.cs modifié : Tests/HelloWorld.cs modifié : Tests/Interfaces/Divers/0.crow modifié : Tests/Interfaces/Divers/testShape.crow modifié : Tests/Interfaces/Divers/welcome.crow modifié : Tests/Tests.csproj modifié : src/CompilerServices/CompilerServices.cs modifié : src/GraphicObjects/FileDialog.cs modifié : src/GraphicObjects/GraphicObject.cs modifié : src/GraphicObjects/MessageBox.cs modifié : src/Instantiator.cs modifié : src/Interface.cs modifié : src/ItemTemplate.cs --- diff --git a/.nuget/NuGet.config b/.nuget/NuGet.config new file mode 100644 index 00000000..97241036 --- /dev/null +++ b/.nuget/NuGet.config @@ -0,0 +1,6 @@ + + + + + + diff --git a/Crow.ControlsLib/Crow.ControlsLib.csproj b/Crow.ControlsLib/Crow.ControlsLib.csproj index 6309f88e..75fd3f14 100644 --- a/Crow.ControlsLib/Crow.ControlsLib.csproj +++ b/Crow.ControlsLib/Crow.ControlsLib.csproj @@ -6,10 +6,11 @@ 8.0.30703 2.0 {6E48BD3D-7B33-4368-AA8A-D878427DAC83} - Exe + Library Crow.ControlsLib Crow.ControlsLib v4.5 + 0.5 true @@ -29,6 +30,13 @@ 4 false + + + + + @@ -46,4 +54,10 @@ + + + {C2980F9B-4798-4C05-99E2-E174810F7C7B} + Crow + + \ No newline at end of file diff --git a/Crow.Test/Test.cs b/Crow.Test/Test.cs index c0fa9f59..e21177f8 100644 --- a/Crow.Test/Test.cs +++ b/Crow.Test/Test.cs @@ -46,7 +46,7 @@ namespace UnitTest foreach (string s in tests) { string fileName = Path.Combine ("Interfaces", s + ".crow"); - iface.LoadInterface (fileName); + iface.AddWidget (fileName); iface.Update (); iface.Update (); diff --git a/Crow.csproj b/Crow.csproj index 90cc4495..a8b47dc8 100644 --- a/Crow.csproj +++ b/Crow.csproj @@ -361,6 +361,10 @@ + + + Crow.Tooltip.template + diff --git a/Crow.sln b/Crow.sln index 9874dbe3..70736ea4 100644 --- a/Crow.sln +++ b/Crow.sln @@ -7,7 +7,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Crow.Test", "Crow.Test\Crow.Test.csproj", "{42C73BD8-51F5-4BB7-8EE9-9F0BE2D80A2C}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Crow.ControlsLib", "Crow.ControlsLib\Crow.ControlsLib.csproj", "{6E48BD3D-7B33-4368-AA8A-D878427DAC83}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CrowIDE", "CrowIDE\CrowIDE.csproj", "{B6D911CD-1D09-42FC-B300-9187190F2AE1}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -19,14 +19,14 @@ Global {42C73BD8-51F5-4BB7-8EE9-9F0BE2D80A2C}.Debug|Any CPU.Build.0 = Debug|Any CPU {42C73BD8-51F5-4BB7-8EE9-9F0BE2D80A2C}.Release|Any CPU.ActiveCfg = Release|Any CPU {42C73BD8-51F5-4BB7-8EE9-9F0BE2D80A2C}.Release|Any CPU.Build.0 = Release|Any CPU - {6E48BD3D-7B33-4368-AA8A-D878427DAC83}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6E48BD3D-7B33-4368-AA8A-D878427DAC83}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6E48BD3D-7B33-4368-AA8A-D878427DAC83}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6E48BD3D-7B33-4368-AA8A-D878427DAC83}.Release|Any CPU.Build.0 = Release|Any CPU {74289092-9F70-4941-AFCB-DFD7BE2140B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {74289092-9F70-4941-AFCB-DFD7BE2140B6}.Debug|Any CPU.Build.0 = Debug|Any CPU {74289092-9F70-4941-AFCB-DFD7BE2140B6}.Release|Any CPU.ActiveCfg = Release|Any CPU {74289092-9F70-4941-AFCB-DFD7BE2140B6}.Release|Any CPU.Build.0 = Release|Any CPU + {B6D911CD-1D09-42FC-B300-9187190F2AE1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B6D911CD-1D09-42FC-B300-9187190F2AE1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B6D911CD-1D09-42FC-B300-9187190F2AE1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B6D911CD-1D09-42FC-B300-9187190F2AE1}.Release|Any CPU.Build.0 = Release|Any CPU {C2980F9B-4798-4C05-99E2-E174810F7C7B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C2980F9B-4798-4C05-99E2-E174810F7C7B}.Debug|Any CPU.Build.0 = Debug|Any CPU {C2980F9B-4798-4C05-99E2-E174810F7C7B}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/Default.style b/Default.style index b0cbbb82..c5c04ea7 100644 --- a/Default.style +++ b/Default.style @@ -45,6 +45,7 @@ MessageBox { Title=MessageBox; Font = serif, 12; MinimumSize = 200,120; + AlwaysOnTop = true; } Slider { Background = vgradient|0:Black|0.1:Gray|0.9:Gray|1:LightGray; @@ -97,6 +98,7 @@ DockingView { } FileDialog { Template = #Crow.FileDialog.template; + AlwaysOnTop = true; Focusable = true; MinimumSize=50,50; Width = 500; diff --git a/Icons/assembly.svg b/Icons/assembly.svg new file mode 100644 index 00000000..5ac3643a --- /dev/null +++ b/Icons/assembly.svg @@ -0,0 +1,31 @@ + + + + + + image/svg+xml + + + + + + + + diff --git a/Templates/Tooltip.template b/Templates/Tooltip.template new file mode 100644 index 00000000..3c5f8c11 --- /dev/null +++ b/Templates/Tooltip.template @@ -0,0 +1,4 @@ + + + diff --git a/Tests/BasicTests.cs b/Tests/BasicTests.cs index 9d8764f4..e04f160e 100644 --- a/Tests/BasicTests.cs +++ b/Tests/BasicTests.cs @@ -98,7 +98,9 @@ namespace Tests } get { return List2; } } - IList testList = Color.ColorDic.Values.ToList(); + IList testList = Color.ColorDic.Values.OrderBy(c=>c.Hue) + .ThenBy(c=>c.Value).ThenBy(c=>c.Saturation) + .ToList(); public IList TestList { set{ testList = value; @@ -154,7 +156,6 @@ namespace Tests testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Divers", "*.crow")).ToArray (); testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Unsorted", "*.crow")).ToArray (); - object tc = Color.AirForceBlueRaf; Load(testFiles[idx]).DataSource = this; } void KeyboardKeyDown1 (object sender, OpenTK.Input.KeyboardKeyEventArgs e) @@ -201,8 +202,8 @@ namespace Tests GraphicObject obj = Load (testFiles[idx]); obj.DataSource = this; - } catch (Exception ex) { - Debug.WriteLine (ex.Message + ex.InnerException); + } catch (Exception ex) { + MessageBox.Show (MessageBox.Type.Error, ex.Message + "\n" + ex.InnerException); } } // void Tv_SelectedItemChanged (object sender, SelectionChangeEventArgs e) @@ -246,13 +247,18 @@ namespace Tests [STAThread] static void Main () { - TextWriterTraceListener listener = new TextWriterTraceListener ("listen.txt"); + #if DEBUG + TextWriterTraceListener listener = new TextWriterTraceListener ("debug.log"); Debug.Listeners.Add (listener); + #endif + Console.WriteLine ("starting example"); BasicTests win = new BasicTests (); win.VSync = OpenTK.VSyncMode.Adaptive; win.Run (30); + #if DEBUG listener.Dispose (); + #endif } protected override void OnUpdateFrame (OpenTK.FrameEventArgs e) { diff --git a/Tests/CrowWindow.cs b/Tests/CrowWindow.cs index d4447a1f..9a0c4df0 100644 --- a/Tests/CrowWindow.cs +++ b/Tests/CrowWindow.cs @@ -227,7 +227,7 @@ namespace Crow /// interface index to bind to, a default one is created if none exists public GraphicObject Load (string path, int interfaceIdx = 0){ checkDefaultIFace(); - return ifaceControl [interfaceIdx].CrowInterface.LoadInterface (path); + return ifaceControl [interfaceIdx].CrowInterface.AddWidget (path); } /// /// Load the content of the IML string passed as first argument and add it to the current interface diff --git a/Tests/Hello3D.cs b/Tests/Hello3D.cs index 48b95c5c..2730bb63 100644 --- a/Tests/Hello3D.cs +++ b/Tests/Hello3D.cs @@ -66,7 +66,7 @@ namespace Tests void initGL(){ GL.Enable (EnableCap.CullFace); GL.Enable (EnableCap.Blend); - GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha); + GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); cube = vaoMesh.CreateCube (); texture = new Texture ("image/textest.png"); diff --git a/Tests/HelloWorld.cs b/Tests/HelloWorld.cs index b29bfac5..75cc9bd5 100644 --- a/Tests/HelloWorld.cs +++ b/Tests/HelloWorld.cs @@ -26,6 +26,7 @@ using System; using Crow; +using Tutorials; namespace Tests { @@ -39,7 +40,7 @@ namespace Tests protected override void OnLoad (EventArgs e) { base.OnLoad (e); - AddWidget (new Label (CurrentInterface) { Text = "Hello World" }); + LoadIMLFragment (@""); } [STAThread] diff --git a/Tests/Interfaces/Divers/0.crow b/Tests/Interfaces/Divers/0.crow index d5cf83c6..dbb1420d 100755 --- a/Tests/Interfaces/Divers/0.crow +++ b/Tests/Interfaces/Divers/0.crow @@ -4,27 +4,27 @@ - + - + - + - + - + - + diff --git a/Tests/Interfaces/Divers/testShape.crow b/Tests/Interfaces/Divers/testShape.crow index 61501b5a..2c1572a4 100644 --- a/Tests/Interfaces/Divers/testShape.crow +++ b/Tests/Interfaces/Divers/testShape.crow @@ -1,5 +1,5 @@  - + diff --git a/Tests/OpenGL/Extensions.cs b/Tests/OpenGL/Extensions.cs index 0dd1cca6..7b26f76b 100644 --- a/Tests/OpenGL/Extensions.cs +++ b/Tests/OpenGL/Extensions.cs @@ -24,7 +24,7 @@ using Crow; namespace Crow { - public static class Extensions { + public static partial class Extensions { public static Vector4 ToVector4(this Color c){ float[] f = c.floatArray; return new Vector4 (f [0], f [1], f [2], f [3]); diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj index 8096d9a8..75969d9b 100644 --- a/Tests/Tests.csproj +++ b/Tests/Tests.csproj @@ -8,7 +8,7 @@ Exe Tests Tests - Tests.Showcase + Tests.BasicTests v4.5 AnyCPU 0.5 @@ -57,13 +57,19 @@ %24{SolutionDir}\build\%24{ProjectConfigName} false + + Program + %24{TargetName} + %24{SolutionDir}\build\%24{ProjectConfigName} + false + - ..\packages\OpenTK.3.0.0-git00041\lib\net20\OpenTK.dll + ..\packages\OpenTK.2.0.0\lib\net20\OpenTK.dll diff --git a/Tests/Tutorials/T3_OpenGLCube.cs b/Tests/Tutorials/T3_OpenGLCube.cs index c920c62d..2cada668 100644 --- a/Tests/Tutorials/T3_OpenGLCube.cs +++ b/Tests/Tutorials/T3_OpenGLCube.cs @@ -55,7 +55,7 @@ namespace Tutorials GL.Enable (EnableCap.CullFace); GL.Enable (EnableCap.Blend); - GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha); + GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); cube = vaoMesh.CreateCube (); texture = new Texture ("image/textest.png"); diff --git a/Tests/packages.config b/Tests/packages.config index f4e36ffe..b3717663 100644 --- a/Tests/packages.config +++ b/Tests/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/src/CompilerServices/CompilerServices.cs b/src/CompilerServices/CompilerServices.cs index cb8b75b5..16d28490 100644 --- a/src/CompilerServices/CompilerServices.cs +++ b/src/CompilerServices/CompilerServices.cs @@ -67,6 +67,7 @@ namespace Crow.IML internal static MethodInfo miGetValWithRefx = typeof(CompilerServices).GetMethod("getValueWithReflexion", BindingFlags.Static | BindingFlags.NonPublic); internal static MethodInfo miCreateDel = typeof(CompilerServices).GetMethod ("createDel", BindingFlags.Static | BindingFlags.NonPublic); internal static MethodInfo miGetImplOp = typeof(CompilerServices).GetMethod ("getImplicitOp", BindingFlags.Static | BindingFlags.NonPublic); + internal static MethodInfo miGetDataTypeAndFetch = typeof(CompilerServices).GetMethod("getDataTypeAndFetch", BindingFlags.Static | BindingFlags.NonPublic); internal static MethodInfo miGoUpLevels = typeof(CompilerServices).GetMethod("goUpNbLevels", BindingFlags.Static | BindingFlags.NonPublic); @@ -92,7 +93,7 @@ namespace Crow.IML internal static MethodInfo miGetITempFromDic = typeof(Dictionary).GetMethod ("get_Item", new Type[] { typeof(string) }); internal static FieldInfo fldItemTemplates = typeof(TemplatedGroup).GetField("ItemTemplates"); internal static MethodInfo miCreateExpDel = typeof(ItemTemplate).GetMethod ("CreateExpandDelegate"); - + internal static FieldInfo fiFetchMethodName = typeof(ItemTemplate).GetField("fetchMethodName", BindingFlags.Instance | BindingFlags.NonPublic); #region tree handling methods internal static FieldInfo fiChild = typeof(PrivateContainer).GetField ("child", BindingFlags.Instance | BindingFlags.NonPublic); internal static MethodInfo miSetChild = typeof (Container).GetMethod ("SetChild"); @@ -330,22 +331,27 @@ namespace Crow.IML Type dstType = null; if (mi == null) return null; - if (mi.MemberType == MemberTypes.Property) { - PropertyInfo pi = mi as PropertyInfo; - tmp = pi.GetValue (instance); - dstType = pi.PropertyType; - } - if (mi.MemberType == MemberTypes.Field) { - FieldInfo fi = mi as FieldInfo; - tmp = fi.GetValue (instance); - dstType = fi.FieldType; - } - if (tmp != null) - return tmp; - if (dstType == typeof(string) || dstType == CompilerServices.TObject)//TODO:object should be allowed to return null and not "" + try { + if (mi.MemberType == MemberTypes.Property) { + PropertyInfo pi = mi as PropertyInfo; + tmp = pi.GetValue (instance); + dstType = pi.PropertyType; + } + if (mi.MemberType == MemberTypes.Field) { + FieldInfo fi = mi as FieldInfo; + tmp = fi.GetValue (instance); + dstType = fi.FieldType; + } + if (tmp != null) + return tmp; + if (dstType == typeof(string) || dstType == CompilerServices.TObject)//TODO:object should be allowed to return null and not "" + return ""; + if (dstType.IsValueType) + return Activator.CreateInstance (dstType); + } catch (Exception ex) { + Debug.WriteLine (ex.ToString ()); return ""; - if (dstType.IsValueType) - return Activator.CreateInstance (dstType); + } return null; } @@ -863,6 +869,28 @@ namespace Crow.IML } return null; } + + internal static object getDataTypeAndFetch (object data, string fetchMethod){ + Type dataType = data.GetType(); + MethodInfo miGetDatas = dataType.GetMethod (fetchMethod, new Type[] {}); + if (miGetDatas == null) + miGetDatas = CompilerServices.SearchExtMethod (dataType, fetchMethod); + + if (miGetDatas == null) {//in last resort, search among properties + PropertyInfo piDatas = dataType.GetProperty (fetchMethod); + if (piDatas == null) { + FieldInfo fiDatas = dataType.GetField (fetchMethod); + if (fiDatas == null)//and among fields + throw new Exception ("Fetch data member not found in ItemTemplate: " + fetchMethod); + return fiDatas.GetValue (data); + } + miGetDatas = piDatas.GetGetMethod (); + if (miGetDatas == null) + throw new Exception ("Read only property for fetching data in ItemTemplate: " + fetchMethod); + } + object tmp = miGetDatas.Invoke (data, null); + return tmp; + } } } diff --git a/src/GraphicObjects/FileDialog.cs b/src/GraphicObjects/FileDialog.cs index a5ba7b20..285ca253 100644 --- a/src/GraphicObjects/FileDialog.cs +++ b/src/GraphicObjects/FileDialog.cs @@ -52,6 +52,9 @@ namespace Crow public event EventHandler OkClicked; #endregion + public string SelectedFileFullPath { + get { return Path.Combine (SelectedDirectory, SelectedFile); } + } [XmlAttributeAttribute][DefaultValue("/home")] public virtual string CurrentDirectory { get { return curDir; } diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index 3da8330d..e24e9b28 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -808,6 +808,17 @@ namespace Crow NotifyValueChanged ("Style", style); } } + string tooltip; + [XmlAttributeAttribute] + public virtual string Tooltip { + get { return tooltip; } + set { + if (tooltip == value) + return; + tooltip = value; + NotifyValueChanged("Tooltip", tooltip); + } + } #endregion #region Default and Style Values loading diff --git a/src/GraphicObjects/MessageBox.cs b/src/GraphicObjects/MessageBox.cs index 277a7e11..7f945810 100644 --- a/src/GraphicObjects/MessageBox.cs +++ b/src/GraphicObjects/MessageBox.cs @@ -120,7 +120,6 @@ namespace Crow NotifyValueChanged ("MsgIcon", "#Crow.Images.Icons.exit.svg"); Caption = "Error"; OkMessage = "Ok"; - CancelMessage = "Cancel"; break; } } @@ -136,7 +135,7 @@ namespace Crow close (); } public static MessageBox Show (Type msgBoxType, string message, string okMsg = "", string cancelMsg = ""){ - lock (Interface.CurrentInterface.UpdateMutex) { + //lock (Interface.CurrentInterface.UpdateMutex) { MessageBox mb = new MessageBox (Interface.CurrentInterface); mb.CurrentInterface.AddWidget (mb); mb.MsgType = msgBoxType; @@ -146,7 +145,7 @@ namespace Crow if (!string.IsNullOrEmpty(cancelMsg)) mb.CancelMessage = cancelMsg; return mb; - } + //} } } } diff --git a/src/GraphicObjects/Popper.cs b/src/GraphicObjects/Popper.cs index 5316a5a7..41210dc5 100644 --- a/src/GraphicObjects/Popper.cs +++ b/src/GraphicObjects/Popper.cs @@ -224,7 +224,7 @@ namespace Crow if (Content != null) { Content.Visible = true; if (Content.Parent == null) - CurrentInterface.AddWidget (Content, true); + CurrentInterface.AddWidget (Content); if (Content.LogicalParent != this) Content.LogicalParent = this; CurrentInterface.PutOnTop (Content, true); diff --git a/src/Instantiator.cs b/src/Instantiator.cs index b79fbc82..297337ed 100644 --- a/src/Instantiator.cs +++ b/src/Instantiator.cs @@ -560,7 +560,7 @@ namespace Crow.IML System.Reflection.Emit.Label finish = il.DefineLabel (); il.Emit (OpCodes.Br, finish); il.MarkLabel (cancel); - il.EmitWriteLine (string.Format ("Handler method '{0}' for '{1}' not found in new dataSource ", bindingDef.TargetMember, sourceEvent.Name)); + il.EmitWriteLine (string.Format ("Handler method '{0}' for '{1}' not found in new dataSource", bindingDef.TargetMember, sourceEvent.Name)); il.MarkLabel (finish); il.Emit (OpCodes.Ret); diff --git a/src/Interface.cs b/src/Interface.cs index ab78e42d..992ff6f6 100644 --- a/src/Interface.cs +++ b/src/Interface.cs @@ -88,6 +88,8 @@ namespace Crow public Interface(){ CurrentInterface = this; CultureInfo.DefaultThreadCurrentCulture = System.Globalization.CultureInfo.InvariantCulture; + + initTooltip (); } #endregion @@ -100,6 +102,8 @@ namespace Crow public static bool FocusOnHover = false; /// Threshold to catch borders for sizing public static int BorderThreshold = 5; + /// delay before tooltip appear + public static int ToolTipDelay = 500; /// Double click threshold in milisecond public static int DoubleClick = 200;//max duration between two mouse_down evt for a dbl clk in milisec. /// Time to wait in millisecond before starting repeat loop @@ -313,9 +317,12 @@ namespace Crow return tmp; } } - /// Create an instance of a GraphicObject and add it to the GraphicTree - /// of this Interface - public GraphicObject LoadInterface (string path) + /// + /// Create an instance of a GraphicObject and add it to the GraphicTree of this Interface + /// + /// new instance of graphic object created + /// path of the iml file to load + public GraphicObject AddWidget (string path) { lock (UpdateMutex) { GraphicObject tmp = Load (path); @@ -323,8 +330,11 @@ namespace Crow return tmp; } } - /// Create an instance of a GraphicObject linked to this interface but - /// not added to the GraphicTree + /// + /// Create an instance of a GraphicObject linked to this interface but not added to the GraphicTree + /// + /// new instance of graphic object created + /// path of the iml file to load public GraphicObject Load (string path) { try { @@ -333,7 +343,11 @@ namespace Crow throw new Exception ("Error loading <" + path + ">:", ex); } } - /// Fetch instantiator it from cache or create it + /// + /// Fetch instantiator from cache or create it. + /// + /// new Instantiator + /// path of the iml file to load public static Instantiator GetInstantiator(string path){ if (!Instantiators.ContainsKey(path)) Instantiators [path] = new Instantiator(path); @@ -626,7 +640,7 @@ namespace Crow #region GraphicTree handling /// Add widget to the Graphic tree of this interface and register it for layouting - public void AddWidget(GraphicObject g, bool isOverlay = false) + public void AddWidget(GraphicObject g) { g.Parent = this; int ptr = 0; @@ -648,7 +662,7 @@ namespace Crow g.RegisteredLayoutings = LayoutingType.None; g.RegisterForLayouting (LayoutingType.Sizing | LayoutingType.ArrangeChildren); } - /// Set visible state of widget to false and remove if from the graphic tree + /// Set visible state of widget to false and delete if from the graphic tree public void DeleteWidget(GraphicObject g) { lock (UpdateMutex) { @@ -658,6 +672,15 @@ namespace Crow g.Dispose (); } } + /// Set visible state of widget to false and remove if from the graphic tree + public void RemoveWidget(GraphicObject g) + { + lock (UpdateMutex) { + RegisterClip (g.ScreenCoordinates (g.LastPaintedSlot)); + GraphicTree.Remove (g); + g.Parent = null; + } + } /// Remove all Graphic objects from top container public void ClearInterface() { @@ -770,6 +793,7 @@ namespace Crow } if (HoverWidget != null) { + resetTooltip (); //check topmost graphicobject first GraphicObject tmp = HoverWidget; GraphicObject topc = null; @@ -947,6 +971,50 @@ namespace Crow } #endregion + #region Tooltip handling + Stopwatch tooltipTimer = new Stopwatch(); + GraphicObject ToolTipContainer = null; + volatile bool tooltipVisible = false; + + void initTooltip () { + ToolTipContainer = Load ("#Crow.Tooltip.template"); + Thread t = new Thread (toolTipThreadFunc); + t.IsBackground = true; + t.Start (); + } + void toolTipThreadFunc () + { + while(true) { + if (tooltipTimer.ElapsedMilliseconds > ToolTipDelay) { + if (!tooltipVisible) { + GraphicObject g = _hoverWidget; + while (g != null) { + if (!string.IsNullOrEmpty (g.Tooltip)) { + AddWidget (ToolTipContainer); + ToolTipContainer.DataSource = g; + ToolTipContainer.Top = Mouse.Y + 10; + ToolTipContainer.Left = Mouse.X + 10; + tooltipVisible = true; + break; + } + g = g.LogicalParent as GraphicObject; + } + } + } + Thread.Sleep (200); + } + + } + void resetTooltip () { + if (tooltipVisible) { + //ToolTipContainer.DataSource = null; + RemoveWidget (ToolTipContainer); + tooltipVisible = false; + } + tooltipTimer.Restart (); + } + #endregion + #region Device Repeat Events volatile bool mouseRepeatOn, keyboardRepeatOn; volatile int mouseRepeatCount, keyboardRepeatCount; diff --git a/src/ItemTemplate.cs b/src/ItemTemplate.cs index 915aafd8..52bd5207 100644 --- a/src/ItemTemplate.cs +++ b/src/ItemTemplate.cs @@ -97,11 +97,14 @@ namespace Crow /// /// Host. public void CreateExpandDelegate (TemplatedGroup host){ - Type dataType = CompilerServices.tryGetType(strDataType); - if (dataType == null) { - Debug.WriteLine ("ItemTemplate error: DataType not found: {0}.", strDataType); - return; - } + Type dataType = null; + //if (host.DataTest == "TypeOf"){ + dataType = CompilerServices.tryGetType(strDataType); +// if (dataType == null) { +// Debug.WriteLine ("ItemTemplate error: DataType not found: {0}.", strDataType); +// return; +// } +// } Type tmpGrpType = typeof(TemplatedGroup); Type evtType = typeof(EventHandler); @@ -153,9 +156,16 @@ namespace Crow il.Emit (OpCodes.Ldarg_1);//get the dataSource of the sender il.Emit (OpCodes.Callvirt, CompilerServices.miGetDataSource); - if (fetchMethodName != "self")//special keyword self allows the use of recurent list<<< - emitGetSubData(il, dataType); + if (fetchMethodName != "self") {//special keyword self allows the use of recurent list<<< + if (dataType == null) { + //dataTest was not = TypeOF, so we have to get the type of data + //dynamically and fetch + il.Emit (OpCodes.Ldstr, fetchMethodName); + il.Emit (OpCodes.Callvirt, CompilerServices.miGetDataTypeAndFetch); + }else + emitGetSubData(il, dataType); + } //set 'return' from the fetch method as 'data' of the list il.Emit (OpCodes.Callvirt, piData.GetSetMethod ()); @@ -175,8 +185,16 @@ namespace Crow il.Emit (OpCodes.Ldarg_0); il.Emit (OpCodes.Callvirt, CompilerServices.miGetDataSource); - if (fetchMethodName != "self") - emitGetSubData(il, dataType); + if (fetchMethodName != "self") {//special keyword self allows the use of recurent list<<< + if (dataType == null) { + //dataTest was not = TypeOF, so we have to get the type of data + //dynamically and fetch + + il.Emit (OpCodes.Ldstr, fetchMethodName); + il.Emit (OpCodes.Callvirt, CompilerServices.miGetDataTypeAndFetch); + }else + emitGetSubData(il, dataType); + } il.Emit (OpCodes.Callvirt, CompilerServices.miGetColCount); il.Emit (OpCodes.Ldc_I4_0); @@ -185,6 +203,8 @@ namespace Crow HasSubItems = (BooleanTestOnInstance)dm.CreateDelegate (typeof(BooleanTestOnInstance)); #endregion } + + //data is on the stack void emitGetSubData(ILGenerator il, Type dataType){ MethodInfo miGetDatas = dataType.GetMethod (fetchMethodName, new Type[] {}); if (miGetDatas == null)