From: jpbruyere Date: Sun, 20 Mar 2016 21:04:14 +0000 (+0100) Subject: try update monodevelop addin, workin progress X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=8d7b17fdacb9dde5d5775115303b9e095a0631d1;p=jp%2Fcrow.git try update monodevelop addin, workin progress --- diff --git a/.gitignore b/.gitignore index 7aa58178..90925af9 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,4 @@ Tests/Tests.userprefs src/GraphicObjects/Panel.cs src/GraphicObjects/VerticalWrappingWidget.cs src/GraphicObjects/HorizontalWrappingWidget.cs +MonoDevelop.Crow/build diff --git a/Crow.csproj b/Crow.csproj index 5ebe65f5..d57d8ddf 100644 --- a/Crow.csproj +++ b/Crow.csproj @@ -21,8 +21,10 @@ OnBuildSuccess v4.5 AnyCPU - 0.1.* + 0.4 Crow project description + 8.0.30703 + 2.0 true @@ -156,17 +158,12 @@ - - ..\..\packages\gtk-sharp.Linux.3.14.3.14.7\lib\net40\cairo-sharp.dll + + + glib-sharp-2.0 - - ..\..\packages\gtk-sharp.Linux.3.14.3.14.7\lib\net40\gdk-sharp.dll - - - ..\..\packages\gtk-sharp.Linux.3.14.3.14.7\lib\net40\gio-sharp.dll - - - ..\..\packages\gtk-sharp.Linux.3.14.3.14.7\lib\net40\glib-sharp.dll + + gtk-sharp-2.0 @@ -264,6 +261,5 @@ - diff --git a/Crow.sln b/Crow.sln index ed803ba7..b414a9eb 100644 --- a/Crow.sln +++ b/Crow.sln @@ -5,7 +5,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Crow", "Crow.csproj", "{C29 EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{74289092-9F70-4941-AFCB-DFD7BE2140B6}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.GOLib", "MonoDevelop.GOLib\MonoDevelop.GOLib.csproj", "{E9E14DB5-3C67-4E01-B5C3-4D90D7E31A2E}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.Crow", "MonoDevelop.GOLib\MonoDevelop.Crow.csproj", "{E9E14DB5-3C67-4E01-B5C3-4D90D7E31A2E}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.Diagram", "..\MonoDevelop.Diagram\MonoDevelop.Diagram.csproj", "{232716B4-D19D-4FD7-B310-94A98FD926F0}" EndProject @@ -24,25 +24,22 @@ Global {232716B4-D19D-4FD7-B310-94A98FD926F0}.Debug|Linux_x86.ActiveCfg = Debug|Any CPU {232716B4-D19D-4FD7-B310-94A98FD926F0}.Release|Linux_x86.ActiveCfg = Debug|Any CPU {350D4F49-9901-4998-9903-BCA7D48DA58C}.Debug|Linux_x86.ActiveCfg = Debug|Linux_x86 - {350D4F49-9901-4998-9903-BCA7D48DA58C}.Debug|Linux_x86.Build.0 = Debug|Linux_x86 {350D4F49-9901-4998-9903-BCA7D48DA58C}.Release|Linux_x86.ActiveCfg = Release|Linux_x86 {350D4F49-9901-4998-9903-BCA7D48DA58C}.Release|Linux_x86.Build.0 = Release|Linux_x86 {74289092-9F70-4941-AFCB-DFD7BE2140B6}.Debug|Linux_x86.ActiveCfg = Debug|Any CPU - {74289092-9F70-4941-AFCB-DFD7BE2140B6}.Debug|Linux_x86.Build.0 = Debug|Any CPU {74289092-9F70-4941-AFCB-DFD7BE2140B6}.Release|Linux_x86.ActiveCfg = Release|Any CPU {74289092-9F70-4941-AFCB-DFD7BE2140B6}.Release|Linux_x86.Build.0 = Release|Any CPU {7BAE4448-E8F4-48B3-BB11-FA78E7F4506B}.Debug|Linux_x86.ActiveCfg = Debug|Any CPU - {7BAE4448-E8F4-48B3-BB11-FA78E7F4506B}.Debug|Linux_x86.Build.0 = Debug|Any CPU {7BAE4448-E8F4-48B3-BB11-FA78E7F4506B}.Release|Linux_x86.ActiveCfg = Release|Any CPU {C2980F9B-4798-4C05-99E2-E174810F7C7B}.Debug|Linux_x86.ActiveCfg = Debug|Any CPU {C2980F9B-4798-4C05-99E2-E174810F7C7B}.Debug|Linux_x86.Build.0 = Debug|Any CPU {C2980F9B-4798-4C05-99E2-E174810F7C7B}.Release|Linux_x86.ActiveCfg = Release|Any CPU {C2980F9B-4798-4C05-99E2-E174810F7C7B}.Release|Linux_x86.Build.0 = Release|Any CPU {D6F98B08-56B8-405C-9212-F9D26097E35F}.Debug|Linux_x86.ActiveCfg = Debug|Linux_x86 - {D6F98B08-56B8-405C-9212-F9D26097E35F}.Debug|Linux_x86.Build.0 = Debug|Linux_x86 {D6F98B08-56B8-405C-9212-F9D26097E35F}.Release|Linux_x86.ActiveCfg = Release|Linux_x86 {D6F98B08-56B8-405C-9212-F9D26097E35F}.Release|Linux_x86.Build.0 = Release|Linux_x86 {E9E14DB5-3C67-4E01-B5C3-4D90D7E31A2E}.Debug|Linux_x86.ActiveCfg = Debug|Any CPU + {E9E14DB5-3C67-4E01-B5C3-4D90D7E31A2E}.Debug|Linux_x86.Build.0 = Debug|Any CPU {E9E14DB5-3C67-4E01-B5C3-4D90D7E31A2E}.Release|Linux_x86.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution diff --git a/MonoDevelop.GOLib/MonoDevelop.Crow.addin.xml b/MonoDevelop.GOLib/MonoDevelop.Crow.addin.xml new file mode 100644 index 00000000..6155263e --- /dev/null +++ b/MonoDevelop.GOLib/MonoDevelop.Crow.addin.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MonoDevelop.GOLib/MonoDevelop.Crow.csproj b/MonoDevelop.GOLib/MonoDevelop.Crow.csproj new file mode 100644 index 00000000..31683755 --- /dev/null +++ b/MonoDevelop.GOLib/MonoDevelop.Crow.csproj @@ -0,0 +1,139 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {E9E14DB5-3C67-4E01-B5C3-4D90D7E31A2E} + Library + MonoDevelop.Crow + MonoDevelop.Crow + v4.5 + build + + + + + + + + + + + + + 0.4 + + + true + full + false + DEBUG; + prompt + 4 + false + + + + + + + + + + + + ..\MonoDevelop.Crow\build + + + none + true + prompt + 4 + false + + + + + + + + + + + + + ..\MonoDevelop.Crow\build + + + + + \opt\lib\monodevelop\bin\ICSharpCode.NRefactory.dll + + + \opt\lib\monodevelop\bin\MonoDevelop.Ide.dll + + + \opt\lib\monodevelop\bin\MonoDevelop.Core.dll + + + \opt\lib\monodevelop\AddIns\MonoDevelop.DesignerSupport\MonoDevelop.DesignerSupport.dll + + + + + + \opt\lib\monodevelop\AddIns\DisplayBindings\SourceEditor\MonoDevelop.SourceEditor2.dll + + + \opt\lib\monodevelop\bin\Mono.TextEditor.dll + + + gtk-sharp-2.0 + + + gtk-sharp-2.0 + + + gio-sharp-2.0 + + + glib-sharp-2.0 + + + gtk-sharp-2.0 + + + + mono-addins + + + ..\..\..\..\..\opt\lib\monodevelop\bin\Xwt.dll + + + + + + + + + + + + + + + + + + + + {C2980F9B-4798-4C05-99E2-E174810F7C7B} + Crow + + + + + + \ No newline at end of file diff --git a/MonoDevelop.GOLib/MonoDevelop.GOLib.addin.xml b/MonoDevelop.GOLib/MonoDevelop.GOLib.addin.xml deleted file mode 100644 index fe15b3e9..00000000 --- a/MonoDevelop.GOLib/MonoDevelop.GOLib.addin.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/MonoDevelop.GOLib/MonoDevelop.GOLib.csproj b/MonoDevelop.GOLib/MonoDevelop.GOLib.csproj deleted file mode 100644 index b09de992..00000000 --- a/MonoDevelop.GOLib/MonoDevelop.GOLib.csproj +++ /dev/null @@ -1,118 +0,0 @@ - - - - Debug - AnyCPU - 8.0.30703 - 2.0 - {E9E14DB5-3C67-4E01-B5C3-4D90D7E31A2E} - Library - MonoDevelop.GOLib - MonoDevelop.GOLib - v4.5 - build - - - - - - - - - - - - - 0.4 - - - true - full - false - DEBUG; - prompt - 4 - false - - - - - - - - none - true - prompt - 4 - false - - - - - - - - - - \usr\local\lib\monodevelop\bin\ICSharpCode.NRefactory.dll - - - mono-addins - - - \usr\local\lib\monodevelop\bin\MonoDevelop.Ide.dll - - - \usr\local\lib\monodevelop\bin\MonoDevelop.Core.dll - - - \usr\local\lib\monodevelop\AddIns\MonoDevelop.DesignerSupport\MonoDevelop.DesignerSupport.dll - - - - gtk-sharp-2.0 - - - gtk-sharp-2.0 - - - gtk-sharp-2.0 - - - glib-sharp-2.0 - - - - - - ..\..\opentk\Binaries\OpenTK\Release\OpenTK.dll - - - ..\..\..\..\..\usr\local\lib\monodevelop\AddIns\DisplayBindings\SourceEditor\MonoDevelop.SourceEditor2.dll - - - ..\..\..\..\..\usr\local\lib\monodevelop\bin\Mono.TextEditor.dll - - - - - - - - - - - - - - - - - - - - {C2980F9B-4798-4C05-99E2-E174810F7C7B} - Crow - - - \ No newline at end of file diff --git a/MonoDevelop.GOLib/Properties/AddinInfo.cs b/MonoDevelop.GOLib/Properties/AddinInfo.cs index f5af5b8d..551c66db 100644 --- a/MonoDevelop.GOLib/Properties/AddinInfo.cs +++ b/MonoDevelop.GOLib/Properties/AddinInfo.cs @@ -3,12 +3,12 @@ using System; using Mono.Addins; using Mono.Addins.Description; -[assembly:Addin ("GOLib", +[assembly:Addin ("Crow", Namespace = "MonoDevelop", Version = MonoDevelop.BuildInfo.Version, Category = "IDE extensions")] -[assembly:AddinName ("MonoDevelop GOLib interface designer")] +[assembly:AddinName ("MonoDevelop Crow interface designer")] [assembly:AddinDescription ("")] [assembly:AddinDependency ("Core", MonoDevelop.BuildInfo.Version)] diff --git a/MonoDevelop.GOLib/Properties/AssemblyInfo.cs b/MonoDevelop.GOLib/Properties/AssemblyInfo.cs index 117b1534..a5fb350d 100644 --- a/MonoDevelop.GOLib/Properties/AssemblyInfo.cs +++ b/MonoDevelop.GOLib/Properties/AssemblyInfo.cs @@ -4,8 +4,8 @@ using System.Runtime.CompilerServices; // Information about this assembly is defined by the following attributes. // Change them to the values specific to your project. -[assembly: AssemblyTitle ("MonoDevelop.GOLib")] -[assembly: AssemblyDescription ("GOLib interface designer for MonoDevelop")] +[assembly: AssemblyTitle ("MonoDevelop.Crow")] +[assembly: AssemblyDescription ("Crow interface designer for MonoDevelop")] [assembly: AssemblyConfiguration ("")] [assembly: AssemblyCompany ("")] [assembly: AssemblyProduct ("")] diff --git a/MonoDevelop.GOLib/src/CrowDisplayBinding.cs b/MonoDevelop.GOLib/src/CrowDisplayBinding.cs new file mode 100644 index 00000000..0776de73 --- /dev/null +++ b/MonoDevelop.GOLib/src/CrowDisplayBinding.cs @@ -0,0 +1,82 @@ +// +// DisplayBinding.cs +// +// Author: +// Jean-Philippe Bruyère +// +// Copyright (c) 2015 jp +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . + +// +// DisplayBinding.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System.IO; +using MonoDevelop.Core; +using MonoDevelop.Ide.Gui; +using MonoDevelop.Projects; +using System.Globalization; +using System.Diagnostics; + +namespace MonoDevelop.Crow +{ + class CrowDisplayBinding : IViewDisplayBinding + { + bool canHandle = false; + + public string Name { + get { + return GettextCatalog.GetString ("Crow designer"); + } + } + public bool CanUseAsDefault + { get { return true; }} + + public IViewContent CreateContent (FilePath fileName, string mimeType, Project ownerProject) + { + return new CrowView (); + + + } + public bool CanHandle (FilePath fileName, string mimeType, Project ownerProject) + { + canHandle = mimeType.StartsWith("text/x-goml", System.StringComparison.OrdinalIgnoreCase) | + mimeType.StartsWith ("text/x-crow", System.StringComparison.OrdinalIgnoreCase); + return canHandle; + } + } +} diff --git a/MonoDevelop.GOLib/src/CrowNodeExtension.cs b/MonoDevelop.GOLib/src/CrowNodeExtension.cs new file mode 100644 index 00000000..035f2353 --- /dev/null +++ b/MonoDevelop.GOLib/src/CrowNodeExtension.cs @@ -0,0 +1,135 @@ +// +// ImageViewerNodeExtension.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2010 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; +using MonoDevelop.Projects; +using MonoDevelop.Ide.Gui.Components; +using MonoDevelop.Components; +using MonoDevelop.Components.Commands; +using MonoDevelop.Ide; +using System.Linq; +using MonoDevelop.DesignerSupport; + +namespace MonoDevelop.Crow +{ + enum Commands { + ShowGOLibViewer + } + + class CrowNodeExtension : NodeBuilderExtension + { + public override Type CommandHandlerType { + get { return typeof(CrowCommandHandler); } + } + public override bool CanBuildNode (Type dataType) + { + return typeof(ProjectFile).IsAssignableFrom (dataType); + } + public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, NodeInfo nodeInfo) + { + ProjectFile pf = dataObject as ProjectFile; + +// string mimeType = DesktopService.GetMimeTypeForUri (pf.FilePath); +// if (mimeType.StartsWith ("image/", StringComparison.CurrentCultureIgnoreCase)) { +// Image i; +// if (pf != null) { +// i = Image.FromFile (pf.FilePath); +// nodeInfo.Icon = i.Scale (16.0 / i.Width, 16.0 / i.Height); +// } +// } + + base.BuildNode (treeBuilder, dataObject, nodeInfo); + } + } + + class CrowCommandHandler: NodeCommandHandler //, IPropertyPadProvider + { + [CommandHandler (Commands.ShowGOLibViewer)] + protected void OnShowGOLibViewer () + { + + CrowView view = new CrowView (); + + ProjectFile file = CurrentNode.DataItem as ProjectFile; + + if (file != null) + view.Load (file.FilePath); + + + IdeApp.Workbench.OpenDocument (view, true); + //IdeApp.Workbench.Documents.Where (d => d.FileName == file.FilePath); + } + +// public override void ActivateItem () +// { +// ProjectFile o = this.CurrentNode.DataItem as ProjectFile; +// +// Ide.Gui.Document[] doc = IdeApp.Workbench.Documents.Where (d => d.FileName == o.FilePath).ToArray(); +// var tmp = MonoDevelop.Ide.Gui.DisplayBindingService.GetFileViewers (o.FilePath, o.Project).ToList(); +// +// OnShowGOLibViewer (); +// } + +// #region IPropertyPadProvider implementation +// public object GetActiveComponent () +// { +// if (CurrentNodes.Length == 1) +// return CurrentNode.DataItem; +// else +// return null; +// } +// public object GetProvider () +// { +// return null; +// } +// public void OnEndEditing (object obj) +// { +// throw new NotImplementedException (); +// } +// public void OnChanged (object obj) +// { +// +// } +// #endregion + } + +// class GOLibItemPropertyProvider : IPropertyProvider +// { +// #region IPropertyProvider implementation +// public object CreateProvider (object obj) +// { +// var projectFile = obj as ProjectFile; +// return projectFile; +// } +// +// public bool SupportsObject (object obj) +// { +// return obj is ProjectFile; +// } +// #endregion +// } +} + diff --git a/MonoDevelop.GOLib/src/CrowView.cs b/MonoDevelop.GOLib/src/CrowView.cs new file mode 100644 index 00000000..abdac98a --- /dev/null +++ b/MonoDevelop.GOLib/src/CrowView.cs @@ -0,0 +1,155 @@ +// +// ImageViewer.cs +// +// Author: +// Jean-Philippe Bruyère +// +// Copyright (c) 2015 jp +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . + +// +// HexEditorView.cs +// +// Author: +// Mike Krüger +// +// Copyright (c) 2009 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; +using System.IO; +using Crow; +using MonoDevelop.DesignerSupport; +using MonoDevelop.SourceEditor; + +namespace MonoDevelop.Crow +{ + class CustomVPaned : Gtk.VPaned, IPropertyPadProvider + { + #region IPropertyPadProvider implementation + public object GetActiveComponent () + { + return this.Child1 == null ? this as object: (this.Child1 as XwtContainer).CrowInterface.activeWidget as object; + } + public object GetProvider () + { + return null; + //throw new NotImplementedException (); + } + public void OnEndEditing (object obj) + { + //throw new NotImplementedException (); + } + public void OnChanged (object obj) + { + //throw new NotImplementedException (); + } + #endregion + + } + class CrowView : SourceEditorView + { + XwtContainer gtkCrowHost; + CustomVPaned gtkCrowWidget; + + + double zoom = 1.0; + + public override Gtk.Widget Control { + get { + return gtkCrowWidget; + } + } + + public CrowView () : base() + { + gtkCrowHost = new XwtContainer (); + gtkCrowWidget = new CustomVPaned (); + gtkCrowWidget.CanFocus = true; + gtkCrowWidget.Name = "vpaned1"; + gtkCrowWidget.Add (gtkCrowHost); + gtkCrowWidget.Add (base.Control); + gtkCrowWidget.SizeAllocated += GtkGOMLWidget_SizeAllocated; + + this.Document.DocumentUpdated += Document_DocumentUpdated; + //this.DirtyChanged += GOLibView_DirtyChanged; + } + + void Document_DocumentUpdated (object sender, EventArgs e) + { + reloadGOML (); + } + + void GOLibView_DirtyChanged (object sender, EventArgs e) + { + + } + + void reloadGOML() + { + using (MemoryStream stream = new MemoryStream ()) { + using (StreamWriter writer = new StreamWriter (stream)) { + writer.Write (this.Document.Text); + writer.Flush (); + + stream.Position = 0; + gtkCrowHost.CrowInterface.LoadInterface (stream); + } + } + } + + void GtkGOMLWidget_SizeAllocated (object o, Gtk.SizeAllocatedArgs args) + { + gtkCrowHost.SetSizeRequest (-1, args.Allocation.Height / 2); + } + + public override void Load (string fileName) + { + gtkCrowHost.CrowInterface.LoadInterface (fileName); + //ContentName = fileName; + //this.IsDirty = false; + gtkCrowWidget.ShowAll (); + gtkCrowWidget.Show (); + + base.Load (fileName); + } +// public override bool CanReuseView (string fileName) +// { +// return base.CanReuseView (fileName); +// } +// public override void RedrawContent () +// { +// base.RedrawContent (); +// } + + } +} diff --git a/MonoDevelop.GOLib/src/DisplayBinding.cs b/MonoDevelop.GOLib/src/DisplayBinding.cs deleted file mode 100644 index 1898f16b..00000000 --- a/MonoDevelop.GOLib/src/DisplayBinding.cs +++ /dev/null @@ -1,81 +0,0 @@ -// -// DisplayBinding.cs -// -// Author: -// Jean-Philippe Bruyère -// -// Copyright (c) 2015 jp -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with this program. If not, see . - -// -// DisplayBinding.cs -// -// Author: -// Mike Krüger -// -// Copyright (c) 2009 Novell, Inc (http://www.novell.com) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -using System.IO; -using MonoDevelop.Core; -using MonoDevelop.Ide.Gui; -using MonoDevelop.Projects; -using System.Globalization; -using System.Diagnostics; - -namespace MonoDevelop.GOLib -{ - class GOLibDisplayBinding : IViewDisplayBinding - { - bool canHandle = false; - - public string Name { - get { - return GettextCatalog.GetString ("GOLib designer"); - } - } - public bool CanUseAsDefault - { get { return true; }} - - public IViewContent CreateContent (FilePath fileName, string mimeType, Project ownerProject) - { - return new GOLibView (); - - - } - public bool CanHandle (FilePath fileName, string mimeType, Project ownerProject) - { - canHandle = mimeType.StartsWith("text/x-goml"); - return canHandle; - } - } -} diff --git a/MonoDevelop.GOLib/src/GOLibGtkHost.cs b/MonoDevelop.GOLib/src/GOLibGtkHost.cs index 0069e3e7..1a86d457 100644 --- a/MonoDevelop.GOLib/src/GOLibGtkHost.cs +++ b/MonoDevelop.GOLib/src/GOLibGtkHost.cs @@ -1,20 +1,20 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Diagnostics; +using System.IO; using System.Linq; using Crow; +using MonoDevelop.Components.Commands; using MonoDevelop.Core; +using MonoDevelop.DesignerSupport; using MonoDevelop.Ide; using MonoDevelop.Projects; -using System.Diagnostics; using OpenTK.Input; -using MonoDevelop.DesignerSupport; -using System.IO; -using MonoDevelop.Components.Commands; -namespace MonoDevelop.GOLib +namespace MonoDevelop.Crow { - public class GOLibGtkHost : Gtk.DrawingArea, ILayoutable, IGOLibHost, IPropertyPadProvider,ICommandDelegator + public class GOLibGtkHost : Gtk.DrawingArea, IPropertyPadProvider,ICommandDelegator { #region ICommandDelegator implementation diff --git a/MonoDevelop.GOLib/src/GOLibNodeExtension.cs b/MonoDevelop.GOLib/src/GOLibNodeExtension.cs deleted file mode 100644 index 8c68d4cf..00000000 --- a/MonoDevelop.GOLib/src/GOLibNodeExtension.cs +++ /dev/null @@ -1,135 +0,0 @@ -// -// ImageViewerNodeExtension.cs -// -// Author: -// Mike Krüger -// -// Copyright (c) 2010 Novell, Inc (http://www.novell.com) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -using System; -using MonoDevelop.Projects; -using MonoDevelop.Ide.Gui.Components; -using MonoDevelop.Components; -using MonoDevelop.Components.Commands; -using MonoDevelop.Ide; -using System.Linq; -using MonoDevelop.DesignerSupport; - -namespace MonoDevelop.GOLib -{ - enum Commands { - ShowGOLibViewer - } - - class GOLibNodeExtension : NodeBuilderExtension - { - public override Type CommandHandlerType { - get { return typeof(GOLibCommandHandler); } - } - public override bool CanBuildNode (Type dataType) - { - return typeof(ProjectFile).IsAssignableFrom (dataType); - } - public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, NodeInfo nodeInfo) - { - ProjectFile pf = dataObject as ProjectFile; - -// string mimeType = DesktopService.GetMimeTypeForUri (pf.FilePath); -// if (mimeType.StartsWith ("image/", StringComparison.CurrentCultureIgnoreCase)) { -// Image i; -// if (pf != null) { -// i = Image.FromFile (pf.FilePath); -// nodeInfo.Icon = i.Scale (16.0 / i.Width, 16.0 / i.Height); -// } -// } - - base.BuildNode (treeBuilder, dataObject, nodeInfo); - } - } - - class GOLibCommandHandler: NodeCommandHandler //, IPropertyPadProvider - { - [CommandHandler (Commands.ShowGOLibViewer)] - protected void OnShowGOLibViewer () - { - - GOLibView view = new GOLibView (); - - ProjectFile file = CurrentNode.DataItem as ProjectFile; - - if (file != null) - view.Load (file.FilePath); - - - IdeApp.Workbench.OpenDocument (view, true); - //IdeApp.Workbench.Documents.Where (d => d.FileName == file.FilePath); - } - -// public override void ActivateItem () -// { -// ProjectFile o = this.CurrentNode.DataItem as ProjectFile; -// -// Ide.Gui.Document[] doc = IdeApp.Workbench.Documents.Where (d => d.FileName == o.FilePath).ToArray(); -// var tmp = MonoDevelop.Ide.Gui.DisplayBindingService.GetFileViewers (o.FilePath, o.Project).ToList(); -// -// OnShowGOLibViewer (); -// } - -// #region IPropertyPadProvider implementation -// public object GetActiveComponent () -// { -// if (CurrentNodes.Length == 1) -// return CurrentNode.DataItem; -// else -// return null; -// } -// public object GetProvider () -// { -// return null; -// } -// public void OnEndEditing (object obj) -// { -// throw new NotImplementedException (); -// } -// public void OnChanged (object obj) -// { -// -// } -// #endregion - } - -// class GOLibItemPropertyProvider : IPropertyProvider -// { -// #region IPropertyProvider implementation -// public object CreateProvider (object obj) -// { -// var projectFile = obj as ProjectFile; -// return projectFile; -// } -// -// public bool SupportsObject (object obj) -// { -// return obj is ProjectFile; -// } -// #endregion -// } -} - diff --git a/MonoDevelop.GOLib/src/GOLibView.cs b/MonoDevelop.GOLib/src/GOLibView.cs deleted file mode 100644 index 52dbf2cb..00000000 --- a/MonoDevelop.GOLib/src/GOLibView.cs +++ /dev/null @@ -1,161 +0,0 @@ -// -// ImageViewer.cs -// -// Author: -// Jean-Philippe Bruyère -// -// Copyright (c) 2015 jp -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with this program. If not, see . - -// -// HexEditorView.cs -// -// Author: -// Mike Krüger -// -// Copyright (c) 2009 Novell, Inc (http://www.novell.com) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -using System; -using System.IO; -using MonoDevelop.Ide.Gui; -using MonoDevelop.Ide.Gui.Content; -using MonoDevelop.Ide.Fonts; -using Mono.Addins; -using MonoDevelop.Core; -using MonoDevelop.Ide; -using Crow; -using MonoDevelop.DesignerSupport; -using MonoDevelop.SourceEditor; - -namespace MonoDevelop.GOLib -{ - class CustomVPaned : Gtk.VPaned, IPropertyPadProvider - { - #region IPropertyPadProvider implementation - public object GetActiveComponent () - { - return this.Child1 == null ? this as object: (this.Child1 as GOLibGtkHost).activeWidget as object; - } - public object GetProvider () - { - return null; - //throw new NotImplementedException (); - } - public void OnEndEditing (object obj) - { - //throw new NotImplementedException (); - } - public void OnChanged (object obj) - { - //throw new NotImplementedException (); - } - #endregion - - } - class GOLibView : SourceEditorView - { - GOLibGtkHost gtkGoWidgetHost; - CustomVPaned gtkGOMLWidget; - - - double zoom = 1.0; - - public override Gtk.Widget Control { - get { - return gtkGOMLWidget; - } - } - - public GOLibView () : base() - { - gtkGoWidgetHost = new GOLibGtkHost (); - gtkGOMLWidget = new CustomVPaned (); - gtkGOMLWidget.CanFocus = true; - gtkGOMLWidget.Name = "vpaned1"; - gtkGOMLWidget.Add (gtkGoWidgetHost); - gtkGOMLWidget.Add (base.Control); - gtkGOMLWidget.SizeAllocated += GtkGOMLWidget_SizeAllocated; - - this.Document.DocumentUpdated += Document_DocumentUpdated; - //this.DirtyChanged += GOLibView_DirtyChanged; - } - - void Document_DocumentUpdated (object sender, EventArgs e) - { - reloadGOML (); - } - - void GOLibView_DirtyChanged (object sender, EventArgs e) - { - - } - - void reloadGOML() - { - using (MemoryStream stream = new MemoryStream ()) { - using (StreamWriter writer = new StreamWriter (stream)) { - writer.Write (this.Document.Text); - writer.Flush (); - - stream.Position = 0; - gtkGoWidgetHost.Load (stream); - } - } - } - - void GtkGOMLWidget_SizeAllocated (object o, Gtk.SizeAllocatedArgs args) - { - gtkGoWidgetHost.SetSizeRequest (-1, args.Allocation.Height / 2); - } - - public override void Load (string fileName) - { - gtkGoWidgetHost.Load (fileName); - //ContentName = fileName; - //this.IsDirty = false; - gtkGOMLWidget.ShowAll (); - gtkGOMLWidget.Show (); - - base.Load (fileName); - } -// public override bool CanReuseView (string fileName) -// { -// return base.CanReuseView (fileName); -// } -// public override void RedrawContent () -// { -// base.RedrawContent (); -// } - - } -} diff --git a/MonoDevelop.GOLib/src/XwtContainer.cs b/MonoDevelop.GOLib/src/XwtContainer.cs new file mode 100644 index 00000000..6a648f5c --- /dev/null +++ b/MonoDevelop.GOLib/src/XwtContainer.cs @@ -0,0 +1,209 @@ +// +// OpenTKGameWindow.cs +// +// Author: +// Jean-Philippe Bruyère +// +// Copyright (c) 2016 jp +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Threading; +using System.Xml; +using Cairo; +using Crow; +using MonoDevelop.Components.Commands; +using MonoDevelop.Core; +using MonoDevelop.DesignerSupport; +using MonoDevelop.Ide; +using MonoDevelop.Projects; + +namespace MonoDevelop.Crow +{ + public class XwtContainer : Xwt.Canvas, IPropertyPadProvider,ICommandDelegator + { + public Interface CrowInterface; + + #region ICommandDelegator implementation + + public object GetDelegatedCommandTarget () + { + return CrowInterface.hoverWidget; + } + + #endregion + + #region IPropertyPadProvider implementation + + public object GetActiveComponent () + { + return CrowInterface.activeWidget; + } + public object GetProvider () + { + return CrowInterface.activeWidget; + } + public void OnEndEditing (object obj) + { + + } + public void OnChanged (object obj) + { + (obj as GraphicObject).RegisterForGraphicUpdate (); + QueueDraw (); + } + #endregion + + #region ctor + public XwtContainer() : this(0,0,"test"){} + public XwtContainer(int _width, int _height, string _title="Crow") + : base() + { + CrowInterface = new Interface (); + CrowInterface.Quit += Quit; + + + //this.OverrideBackgroundColor (Gtk.StateFlags.Normal, Gdk.RGBA.Zero); + //this.Visual = Gdk.Global.DefaultRootWindow.Screen.RgbaVisual; + + this.ButtonPressEvent += OpenTKGameWindow_ButtonPressEvent; + this.ButtonReleaseEvent += OpenTKGameWindow_ButtonReleaseEvent; + this.MotionNotifyEvent += OpenTKGameWindow_MotionNotifyEvent; + this.KeyPressEvent += OpenTKGameWindow_KeyPressEvent; + this.SizeAllocated += OpenTKGameWindow_SizeAllocated; + + this.Show (); + + //GLib.Idle.Add (new GLib.IdleHandler (idleHandler)); + GLib.Timeout.Add (10, new GLib.TimeoutHandler (updateHandler)); + } + #endregion + + + + #region Timers + bool updateHandler(){ + CrowInterface.Update(); + return true; + } + bool idleHandler(){ + if (CrowInterface.IsDirty) { + QueueDrawArea (CrowInterface.DirtyRect.X, CrowInterface.DirtyRect.Y, CrowInterface.DirtyRect.Width, CrowInterface.DirtyRect.Height); + return false; + } + return true; + } + #endregion + + protected void Quit (object sender, EventArgs e) + { + Gtk.Application.Quit (); + } + + static double[] dashed = {2.0}; + protected override void OnDraw (Xwt.Drawing.Context ctx, Xwt.Rectangle dirtyRect) + { + base.OnDraw (ctx, dirtyRect); + if (CrowInterface.IsDirty) { + using (MemoryStream ms = new MemoryStream (CrowInterface.dirtyBmp)) { + //Xwt.Drawing.ImageBuilder im = new Xwt.Drawing.ImageBuilder(CrowInterface.DirtyRect.Width, CrowInterface.DirtyRect.Height); + //bmp. + using (Xwt.Drawing.Image img = Xwt.Drawing.BitmapImage.FromStream (ms)) { + img.WithSize (CrowInterface.DirtyRect.Width, CrowInterface.DirtyRect.Height); + ctx.DrawImage (img, CrowInterface.DirtyRect.X, CrowInterface.DirtyRect.Y); + ctx.Fill (); + } + } + CrowInterface.IsDirty = false; + GLib.Idle.Add (new GLib.IdleHandler (idleHandler)); + return; + } + if (CrowInterface.bmp != null) { + using (ImageSurface img = new ImageSurface (CrowInterface.bmp, Format.Argb32, CrowInterface.ClientRectangle.Width, CrowInterface.ClientRectangle.Height, 4 * CrowInterface.ClientRectangle.Width)) { + cr.SetSourceSurface (img, CrowInterface.ClientRectangle.X, CrowInterface.ClientRectangle.Y); + cr.Paint (); + } + } + if (CrowInterface.hoverWidget != null) { + cr.Rectangle (CrowInterface.hoverWidget.ScreenCoordinates ( + CrowInterface.hoverWidget.getSlot ())); + cr.LineWidth = 1; + cr.SetDash (dashed, 0); + //cr.Color = Crow.Color.Yellow; + cr.Stroke (); + } + + } + void Win_DeleteEvent (object o, Gtk.DeleteEventArgs args) + { + Gtk.Application.Quit (); + } + void OpenTKGameWindow_SizeAllocated (object o, Gtk.SizeAllocatedArgs args) + { + CrowInterface.ProcessResize (new Rectangle (args.Allocation.X, args.Allocation.Y, args.Allocation.Width, args.Allocation.Height)); + } + void OpenTKGameWindow_MotionNotifyEvent (object o, Gtk.MotionNotifyEventArgs args) + { + CrowInterface.ProcessMouseMove ((int)args.Event.X, (int)args.Event.Y); + } + + void OpenTKGameWindow_ButtonReleaseEvent (object o, Gtk.ButtonReleaseEventArgs args) + { + CrowInterface.ProcessMouseButtonUp ((int)args.Event.Button - 1); + } + void OpenTKGameWindow_ButtonPressEvent (object o, Gtk.ButtonPressEventArgs args) + { + CrowInterface.ProcessMouseButtonDown ((int)args.Event.Button - 1); + } + +// void Mouse_WheelChanged(object sender, OpenTK.Input.MouseWheelEventArgs otk_e) +// { +// MouseWheelEventArgs e = new MouseWheelEventArgs (otk_e.X, otk_e.Y, otk_e.Value, otk_e.Delta); +// MouseState ms = e.Mouse; +// update_mouseButtonStates (ref ms, otk_e.Mouse); +// e.Mouse = ms; +// +// if (hoverWidget == null) { +// MouseWheelChanged.Raise (this, otk_e); +// return; +// } +// hoverWidget.onMouseWheel (this, e); +// } + + + + #region keyboard Handling +// KeyboardState Keyboad = new KeyboardState (); +// void Keyboard_KeyDown(object sender, OpenTK.Input.KeyboardKeyEventArgs otk_e) +// { +//// if (_focusedWidget == null) { +// KeyboardKeyDown.Raise (this, otk_e); +//// return; +//// } +// Keyboad.SetKeyState ((Crow.Key)otk_e.Key, true); +// KeyboardKeyEventArgs e = new KeyboardKeyEventArgs((Crow.Key)otk_e.Key, otk_e.IsRepeat,Keyboad); +// _focusedWidget.onKeyDown (sender, e); +// } + void OpenTKGameWindow_KeyPressEvent (object o, Gtk.KeyPressEventArgs args) + { + + } + + #endregion + } +} diff --git a/OTKCrow/OTKCrow.csproj b/OTKCrow/OTKCrow.csproj index 7b2974d0..a2f455b0 100644 --- a/OTKCrow/OTKCrow.csproj +++ b/OTKCrow/OTKCrow.csproj @@ -10,6 +10,7 @@ v4.5 8.0.30703 2.0 + 0.4 true diff --git a/packages.config b/packages.config deleted file mode 100644 index d77cff2a..00000000 --- a/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/Interface.cs b/src/Interface.cs index 4cb94e76..e1062a55 100644 --- a/src/Interface.cs +++ b/src/Interface.cs @@ -227,7 +227,15 @@ namespace Crow return tmp; } } - + public GraphicObject LoadInterface (Stream stream) + { + lock (UpdateMutex) { + GraphicObject tmp = Interface.Load (stream, + Interface.GetTopContainerOfGOMLStream(stream), this); + AddWidget (tmp); + return tmp; + } + } #endregion #if MEASURE_TIME