<Compile Include="src\OpenGL\TexturedShader.cs" />\r
<Compile Include="src\OpenGL\VertexArrayObject.cs" />\r
<Compile Include="src\GraphicObjects\Window.cs" />\r
+ <Compile Include="src\GraphicObjects\IGOLibHost.cs" />\r
</ItemGroup>\r
<ItemGroup>\r
<Reference Include="System" />\r
<Reference Include="System.Data" />\r
<Reference Include="System.Drawing" />\r
<Reference Include="System.Windows.Forms" />\r
- <Reference Include="Mono.Cairo" />\r
<Reference Include="System.Xml" />\r
<Reference Include="OpenTK.Compatibility, Version=1.1.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4">\r
<HintPath>dependencies\OpenTK.Compatibility.dll</HintPath>\r
<Package>glib-sharp-3.0</Package>\r
</Reference>\r
<Reference Include="Microsoft.CSharp" />\r
+ <Reference Include="Mono.Cairo" />\r
</ItemGroup>\r
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. \r
EndProject\r
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{74289092-9F70-4941-AFCB-DFD7BE2140B6}"\r
EndProject\r
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.GOLib", "MonoDevelop.GOLib\MonoDevelop.GOLib.csproj", "{E9E14DB5-3C67-4E01-B5C3-4D90D7E31A2E}"\r
+EndProject\r
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoDevelop.Diagram", "..\MonoDevelop.Diagram\MonoDevelop.Diagram.csproj", "{232716B4-D19D-4FD7-B310-94A98FD926F0}"\r
+EndProject\r
Global\r
GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
Debug|Linux_x86 = Debug|Linux_x86\r
Release|Linux_x86 = Release|Linux_x86\r
EndGlobalSection\r
GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
+ {232716B4-D19D-4FD7-B310-94A98FD926F0}.Debug|Linux_x86.ActiveCfg = Debug|Any CPU\r
+ {232716B4-D19D-4FD7-B310-94A98FD926F0}.Debug|Linux_x86.Build.0 = Debug|Any CPU\r
+ {232716B4-D19D-4FD7-B310-94A98FD926F0}.Release|Linux_x86.ActiveCfg = Release|Linux_x86\r
+ {232716B4-D19D-4FD7-B310-94A98FD926F0}.Release|Linux_x86.Build.0 = Release|Linux_x86\r
{74289092-9F70-4941-AFCB-DFD7BE2140B6}.Debug|Linux_x86.ActiveCfg = Debug|Linux_x86\r
{74289092-9F70-4941-AFCB-DFD7BE2140B6}.Debug|Linux_x86.Build.0 = Debug|Linux_x86\r
{74289092-9F70-4941-AFCB-DFD7BE2140B6}.Release|Linux_x86.ActiveCfg = Release|Linux_x86\r
{C2980F9B-4798-4C05-99E2-E174810F7C7B}.Debug|Linux_x86.Build.0 = Debug|Linux_x86\r
{C2980F9B-4798-4C05-99E2-E174810F7C7B}.Release|Linux_x86.ActiveCfg = Release|Linux_x86\r
{C2980F9B-4798-4C05-99E2-E174810F7C7B}.Release|Linux_x86.Build.0 = Release|Linux_x86\r
- EndGlobalSection\r
- GlobalSection(MonoDevelopProperties) = preSolution\r
- StartupItem = Tests\Tests.csproj\r
+ {E9E14DB5-3C67-4E01-B5C3-4D90D7E31A2E}.Debug|Linux_x86.ActiveCfg = Debug|Any CPU\r
+ {E9E14DB5-3C67-4E01-B5C3-4D90D7E31A2E}.Debug|Linux_x86.Build.0 = Debug|Any CPU\r
+ {E9E14DB5-3C67-4E01-B5C3-4D90D7E31A2E}.Release|Linux_x86.ActiveCfg = Release|Any CPU\r
+ {E9E14DB5-3C67-4E01-B5C3-4D90D7E31A2E}.Release|Linux_x86.Build.0 = Release|Any CPU\r
EndGlobalSection\r
EndGlobal\r
--- /dev/null
+<ExtensionModel>
+ <Extension path = "/MonoDevelop/Ide/DisplayBindings">
+ <DisplayBinding
+ id = "GOLib designer"
+ insertafter ="AssemblyBrowser"
+ class = "MonoDevelop.GOLib.GOLibDisplayBinding" />
+ </Extension>
+ <Extension path = "/MonoDevelop/Ide/Pads/ProjectPad">
+ <NodeBuilder id = "GOLibNodeExtension" class = "MonoDevelop.GOLib.GOLibNodeExtension"/>
+ </Extension>
+ <Extension path = "/MonoDevelop/Core/MimeTypes">
+ <MimeType id="text/x-goml" _description="GOlib interface definition" icon="md-csharp-file" isText="false">
+ <File pattern="*.goml" />
+ </MimeType>
+ </Extension>
+</ExtensionModel>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{E9E14DB5-3C67-4E01-B5C3-4D90D7E31A2E}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <RootNamespace>MonoDevelop.GOLib</RootNamespace>
+ <AssemblyName>MonoDevelop.GOLib</AssemblyName>
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <CustomCommands>
+ <CustomCommands>
+ <Command type="Execute" command="/usr/local/lib/monodevelop/bin/MonoDevelop.exe" workingdir="/usr/local/lib/monodevelop/bin/">
+ <EnvironmentVariables>
+ <Variable name="MONODEVELOP_DEV_ADDINS" value="${TargetDir}" />
+ </EnvironmentVariables>
+ </Command>
+ </CustomCommands>
+ </CustomCommands>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>build</OutputPath>
+ <DefineConstants>DEBUG;</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <ConsolePause>false</ConsolePause>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>full</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>build</OutputPath>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <ConsolePause>false</ConsolePause>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="ICSharpCode.NRefactory">
+ <HintPath>..\..\..\..\..\opt\lib\monodevelop\bin\ICSharpCode.NRefactory.dll</HintPath>
+ </Reference>
+ <Reference Include="Mono.Addins">
+ <Package>mono-addins</Package>
+ </Reference>
+ <Reference Include="MonoDevelop.Core">
+ <HintPath>..\..\..\..\..\opt\lib\monodevelop\bin\MonoDevelop.Core.dll</HintPath>
+ </Reference>
+ <Reference Include="MonoDevelop.Ide">
+ <HintPath>..\..\..\..\..\opt\lib\monodevelop\bin\MonoDevelop.Ide.dll</HintPath>
+ </Reference>
+ <Reference Include="Mono.Cairo" />
+ <Reference Include="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
+ <Package>gtk-sharp-2.0</Package>
+ </Reference>
+ <Reference Include="gdk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
+ <Package>gtk-sharp-2.0</Package>
+ </Reference>
+ <Reference Include="atk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
+ <Package>gtk-sharp-2.0</Package>
+ </Reference>
+ <Reference Include="glib-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
+ <Package>glib-sharp-2.0</Package>
+ </Reference>
+ <Reference Include="System.Xml" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="OpenTK, Version=1.1.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4">
+ <HintPath>..\dependencies\OpenTK.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Drawing" />
+ <Reference Include="MonoDevelop.DesignerSupport">
+ <HintPath>..\..\..\..\..\usr\local\lib\monodevelop\AddIns\MonoDevelop.DesignerSupport\MonoDevelop.DesignerSupport.dll</HintPath>
+ </Reference>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Properties\AddinInfo.cs" />
+ <Compile Include="src\DisplayBinding.cs" />
+ <Compile Include="src\GOLibView.cs" />
+ <Compile Include="src\GOLibNodeExtension.cs" />
+ <Compile Include="src\GOLibGtkHost.cs" />
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <ItemGroup>
+ <Folder Include="src\" />
+ </ItemGroup>
+ <ItemGroup>
+ <EmbeddedResource Include="MonoDevelop.GOLib.addin.xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\GOLib.csproj">
+ <Project>{C2980F9B-4798-4C05-99E2-E174810F7C7B}</Project>
+ <Name>GOLib</Name>
+ </ProjectReference>
+ </ItemGroup>
+</Project>
\ No newline at end of file
--- /dev/null
+using System;
+
+namespace MonoDevelop.GOLib
+{
+ public class MyClass
+ {
+ public MyClass ()
+ {
+ }
+ }
+}
+
--- /dev/null
+
+using System;
+using Mono.Addins;
+using Mono.Addins.Description;
+
+[assembly:Addin ("GOLib",
+ Namespace = "MonoDevelop",
+ Version = MonoDevelop.BuildInfo.Version,
+ Category = "IDE extensions")]
+
+[assembly:AddinName ("MonoDevelop GOLib interface designer")]
+[assembly:AddinDescription ("")]
+
+[assembly:AddinDependency ("Core", MonoDevelop.BuildInfo.Version)]
+[assembly:AddinDependency ("Ide", MonoDevelop.BuildInfo.Version)]
+[assembly:AddinDependency ("Debugger", MonoDevelop.BuildInfo.Version)]
--- /dev/null
+using System.Reflection;
+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: AssemblyConfiguration ("")]
+[assembly: AssemblyCompany ("")]
+[assembly: AssemblyProduct ("")]
+[assembly: AssemblyCopyright ("jp")]
+[assembly: AssemblyTrademark ("")]
+[assembly: AssemblyCulture ("")]
+
+// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
+// The form "{Major}.{Minor}.*" will automatically update the build and revision,
+// and "{Major}.{Minor}.{Build}.*" will update just the revision.
+
+[assembly: AssemblyVersion ("1.0.*")]
+
+// The following attributes are used to specify the signing key for the assembly,
+// if desired. See the Mono documentation for more information about signing.
+
+//[assembly: AssemblyDelaySign(false)]
+//[assembly: AssemblyKeyFile("")]
+
--- /dev/null
+//
+// DisplayBinding.cs
+//
+// Author:
+// Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
+//
+// 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 <http://www.gnu.org/licenses/>.
+
+//
+// DisplayBinding.cs
+//
+// Author:
+// Mike Krüger <mkrueger@novell.com>
+//
+// 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 canHandle; } }
+
+ 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 true;
+ }
+ }
+}
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using go;
+using MonoDevelop.Core;
+using MonoDevelop.Ide;
+using MonoDevelop.Projects;
+using System.Diagnostics;
+using OpenTK.Input;
+using MonoDevelop.DesignerSupport;
+
+namespace MonoDevelop.GOLib
+{
+ public class GOLibGtkHost : Gtk.DrawingArea, ILayoutable, IGOLibHost, IPropertyPadProvider
+ {
+ #region IPropertyPadProvider implementation
+
+ public object GetActiveComponent ()
+ {
+ return activeWidget;
+ }
+ public object GetProvider ()
+ {
+ return activeWidget;
+ }
+ public void OnEndEditing (object obj)
+ {
+
+ }
+ public void OnChanged (object obj)
+ {
+
+ }
+ #endregion
+
+ string _path;
+ GraphicObject goWidget;
+
+ public GOLibGtkHost ()
+ {
+ this.ExposeEvent += onExpose;
+ this.ButtonPressEvent += GOLibGtkHost_ButtonPressEvent;
+ this.ButtonReleaseEvent += GOLibGtkHost_ButtonReleaseEvent;
+ this.MotionNotifyEvent += GOLibGtkHost_MotionNotifyEvent;
+
+ this.Events |= Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask |
+ Gdk.EventMask.PointerMotionMask | Gdk.EventMask.PointerMotionHintMask;
+ }
+ static double[] dashed = {2.0};
+
+ void onExpose(object o, Gtk.ExposeEventArgs args)
+ {
+ Gtk.DrawingArea area = (Gtk.DrawingArea) o;
+ Cairo.Context cr = Gdk.CairoHelper.Create(area.GdkWindow);
+ _redrawClip.AddRectangle (this.ClientRectangle);
+ update (cr);
+
+ if (_hoverWidget != null) {
+ cr.Rectangle (_hoverWidget.ScreenCoordinates(_hoverWidget.getSlot ()));
+ cr.LineWidth = 1;
+ cr.SetDash (dashed, 0);
+ cr.Color = go.Color.Yellow;
+ cr.Stroke ();
+ }
+ ((IDisposable) cr.Target).Dispose();
+ ((IDisposable) cr).Dispose();
+ }
+ // TODO: should find a more safer way to link gtk button to otk.
+ void GOLibGtkHost_ButtonPressEvent (object o, Gtk.ButtonPressEventArgs args)
+ {
+ MouseButtonEventArgs e = new MouseButtonEventArgs
+ ((int)args.Event.X, (int)args.Event.Y,
+ gtkButtonIdToOpenTkButton(args.Event.Button), true);
+ activeWidget = hoverWidget;
+ DesignerSupport.DesignerSupport.Service.SetPadContent (this);
+ }
+ void GOLibGtkHost_ButtonReleaseEvent (object o, Gtk.ButtonReleaseEventArgs args)
+ {
+ MouseButtonEventArgs e = new MouseButtonEventArgs
+ ((int)args.Event.X, (int)args.Event.Y,
+ gtkButtonIdToOpenTkButton(args.Event.Button), false);
+ }
+ int lastX,LastY;
+ void GOLibGtkHost_MotionNotifyEvent (object o, Gtk.MotionNotifyEventArgs args)
+ {
+
+ Mouse_Move(this, new MouseMoveEventArgs (
+ (int)args.Event.X,(int)args.Event.Y,
+ (int)args.Event.X-lastX, (int)args.Event.Y-LastY
+ ));
+ lastX = (int)args.Event.X;
+ LastY = (int)args.Event.Y;
+
+ QueueDraw ();
+ }
+
+ MouseButton gtkButtonIdToOpenTkButton(uint gtkMouseButton)
+ {
+ switch (gtkMouseButton) {
+ case 1:
+ return MouseButton.Left;
+ case 2:
+ return MouseButton.Middle;
+ case 3:
+ return MouseButton.Right;
+ case 4:
+ return MouseButton.Button4;
+ case 5:
+ return MouseButton.Button5;
+ }
+ return MouseButton.LastButton;
+ }
+
+
+
+ public void Load(string path)
+ {
+ goWidget = GraphicObject.Load (path);
+ this.AddWidget (goWidget);
+ }
+
+
+
+ public List<GraphicObject> GraphicObjects = new List<GraphicObject>();
+ public Color Background = Color.Transparent;
+
+ Rectangles _redrawClip = new Rectangles();//should find another way to access it from child
+ List<GraphicObject> _gobjsToRedraw = new List<GraphicObject>();
+
+ public Rectangles redrawClip {
+ get {
+ return _redrawClip;
+ }
+ set {
+ _redrawClip = value;
+ }
+ }
+ public List<GraphicObject> gobjsToRedraw {
+ get {
+ return _gobjsToRedraw;
+ }
+ set {
+ _gobjsToRedraw = value;
+ }
+ }
+
+ #region focus
+
+ GraphicObject _activeWidget; //button is pressed on widget
+ GraphicObject _hoverWidget; //mouse is over
+ GraphicObject _focusedWidget; //has keyboard (or other perif) focus
+
+ public GraphicObject activeWidget
+ {
+ get { return _activeWidget; }
+ set
+ {
+ if (_activeWidget == value)
+ return;
+
+ _activeWidget = value;
+ }
+ }
+ public GraphicObject hoverWidget
+ {
+ get { return _hoverWidget; }
+ set { _hoverWidget = value; }
+ }
+ public GraphicObject FocusedWidget {
+ get { return _focusedWidget; }
+ set {
+ if (_focusedWidget == value)
+ return;
+ if (_focusedWidget != null)
+ _focusedWidget.onUnfocused (this, null);
+ _focusedWidget = value;
+ _focusedWidget.onFocused (this, null);
+ }
+ }
+
+ #endregion
+
+ Rectangle dirtyZone = Rectangle.Empty;
+
+ #region Chrono's
+ public Stopwatch updateTime = new Stopwatch ();
+ public Stopwatch layoutTime = new Stopwatch ();
+ public Stopwatch guTime = new Stopwatch ();
+ public Stopwatch drawingTime = new Stopwatch ();
+ #endregion
+
+ void update (Cairo.Context ctx)
+ {
+ updateTime.Restart ();
+ layoutTime.Reset ();
+ guTime.Reset ();
+ drawingTime.Reset ();
+
+ GraphicObject[] invGOList = new GraphicObject[GraphicObjects.Count];
+ GraphicObjects.CopyTo (invGOList,0);
+ invGOList = invGOList.Reverse ().ToArray ();
+
+ foreach (GraphicObject p in invGOList) {
+ if (p.Visible) {
+ layoutTime.Start ();
+ while(!p.LayoutIsValid)
+ p.UpdateLayout ();
+ layoutTime.Stop ();
+ }
+ }
+
+ GraphicObject[] gotr = new GraphicObject[_gobjsToRedraw.Count];
+ _gobjsToRedraw.CopyTo (gotr);
+ _gobjsToRedraw.Clear ();
+ foreach (GraphicObject p in gotr) {
+ p.registerClipRect ();
+ }
+
+
+ lock (_redrawClip) {
+ if (_redrawClip.count > 0) {
+ // #if DEBUG_CLIP_RECTANGLE
+ // redrawClip.stroke (ctx, new Color(1.0,0,0,0.3));
+ // #endif
+ _redrawClip.clearAndClip (ctx);//rajouté après, tester si utile
+ //Link.draw (ctx);
+ foreach (GraphicObject p in invGOList) {
+ if (p.Visible) {
+ drawingTime.Start ();
+
+ ctx.Save ();
+ if (_redrawClip.count > 0) {
+ Rectangles clip = _redrawClip.intersectingRects (p.ContextCoordinates(p.Slot.Size));
+
+ if (clip.count > 0)
+ p.Paint (ref ctx, clip);
+ }
+ ctx.Restore ();
+
+ drawingTime.Stop ();
+ }
+ }
+ ctx.ResetClip ();
+ dirtyZone = _redrawClip.Bounds;
+ // #if DEBUG_CLIP_RECTANGLE
+ // redrawClip.stroke (ctx, Color.Red.AdjustAlpha(0.1));
+ // #endif
+ _redrawClip.Reset ();
+ }
+ }
+ // if (ToolTip.isVisible) {
+ // ToolTip.panel.processkLayouting();
+ // if (ToolTip.panel.layoutIsValid)
+ // ToolTip.panel.Paint(ref ctx);
+ // }
+ // Debug.WriteLine("INTERFACE: layouting: {0} ticks \t graphical update {1} ticks \t drawing {2} ticks",
+ // layoutTime.ElapsedTicks,
+ // guTime.ElapsedTicks,
+ // drawingTime.ElapsedTicks);
+ // Debug.WriteLine("INTERFACE: layouting: {0} ms \t graphical update {1} ms \t drawing {2} ms",
+ // layoutTime.ElapsedMilliseconds,
+ // guTime.ElapsedMilliseconds,
+ // drawingTime.ElapsedMilliseconds);
+ updateTime.Stop ();
+ // Debug.WriteLine("UPDATE: {0} ticks \t, {1} ms",
+ // updateTime.ElapsedTicks,
+ // updateTime.ElapsedMilliseconds);
+
+ }
+
+ public void AddWidget(GraphicObject g)
+ {
+ g.Parent = this;
+ GraphicObjects.Add (g);
+ }
+ public void DeleteWidget(GraphicObject g)
+ {
+ g.Visible = false;//trick to ensure clip is added to refresh zone
+ GraphicObjects.Remove (g);
+ }
+
+ public void LoadInterface<T>(string path, out T result)
+ {
+ GraphicObject.Load<T> (path, out result, this);
+ AddWidget (result as GraphicObject);
+ }
+ public T LoadInterface<T> (string Path)
+ {
+ T result;
+ GraphicObject.Load<T> (Path, out result, this);
+ AddWidget (result as GraphicObject);
+ return result;
+ }
+
+
+
+ public void PutOnTop(GraphicObject g)
+ {
+ if (GraphicObjects.IndexOf(g) > 0)
+ {
+ GraphicObjects.Remove(g);
+ GraphicObjects.Insert(0, g);
+ }
+ }
+
+ #region Mouse Handling
+ void Mouse_Move(object sender, MouseMoveEventArgs e)
+ {
+ if (_activeWidget != null) {
+ //send move evt even if mouse move outside bounds
+ _activeWidget.onMouseMove (this, e);
+ return;
+ }
+
+ if (_hoverWidget != null) {
+ if (_hoverWidget.MouseIsIn (e.Position)) {
+ _hoverWidget.onMouseMove (this, e);
+ return;
+ } else {
+ _hoverWidget.onMouseLeave (this, e);
+ //seek upward from last focused graph obj's
+ while (_hoverWidget.Parent as GraphicObject!=null) {
+ _hoverWidget = _hoverWidget.Parent as GraphicObject;
+ if (_hoverWidget.MouseIsIn (e.Position)) {
+ _hoverWidget.onMouseMove (this, e);
+ return;
+ } else
+ _hoverWidget.onMouseLeave (this, e);
+ }
+ }
+ }
+
+ //top level graphic obj's parsing
+ for (int i = 0; i < GraphicObjects.Count; i++) {
+ GraphicObject g = GraphicObjects[i];
+ if (g.MouseIsIn (e.Position)) {
+ g.onMouseMove (this, e);
+ PutOnTop (g);
+ return;
+ }
+ }
+ _hoverWidget = null;
+ }
+ void Mouse_ButtonUp(object sender, MouseButtonEventArgs e)
+ {
+ if (_activeWidget == null)
+ return;
+
+ _activeWidget.onMouseButtonUp (this, e);
+ _activeWidget = null;
+ }
+ void Mouse_ButtonDown(object sender, MouseButtonEventArgs e)
+ {
+ if (_hoverWidget == null) {
+ return;
+ }
+
+ GraphicObject g = _hoverWidget;
+ while (!g.Focusable) {
+ g = g.Parent as GraphicObject;
+ if (g == null) {
+ return;
+ }
+ }
+
+ _activeWidget = g;
+ _activeWidget.onMouseButtonDown (this, e);
+ }
+ void Mouse_WheelChanged(object sender, MouseWheelEventArgs e)
+ {
+ if (_hoverWidget == null) {
+ return;
+ }
+ _hoverWidget.onMouseWheel (this, e);
+ }
+ #endregion
+
+ #region keyboard Handling
+ void Keyboard_KeyDown(object sender, KeyboardKeyEventArgs e)
+ {
+ if (_focusedWidget == null)
+ return;
+ _focusedWidget.onKeyDown (sender, e);
+ }
+ #endregion
+
+
+ #region ILayoutable implementation
+
+ public Rectangle ContextCoordinates (Rectangle r)
+ {
+ return r;
+ }
+ public Rectangle ScreenCoordinates (Rectangle r)
+ {
+ return r;
+ }
+
+ public ILayoutable Parent {
+ get {
+ return null;
+ }
+ set {
+ throw new NotImplementedException ();
+ }
+ }
+
+ public bool SizeIsValid {
+ get { return true; }
+ set { throw new NotImplementedException (); }
+ }
+ public bool PositionIsValid {
+ get {
+ return true;
+ }
+ set {
+ throw new NotImplementedException ();
+ }
+ }
+ public bool LayoutIsValid {
+ get {
+ return true;//tester tout les enfants a mon avis
+ }
+ set {
+ throw new NotImplementedException ();
+ }
+ }
+
+ public Rectangle ClientRectangle {
+ get {
+ return new go.Size(Allocation.Width,Allocation.Height);
+ }
+ }
+
+ public IGOLibHost TopContainer {
+ get { return this as IGOLibHost; }
+ }
+
+ public Rectangle getSlot ()
+ {
+ return ClientRectangle;
+ }
+ public Rectangle getBounds ()//redundant but fill ILayoutable implementation
+ {
+ return ClientRectangle;
+ }
+
+ public bool WIsValid {
+ get {
+ return true;
+ }
+ set {
+ throw new NotImplementedException ();
+ }
+ }
+ public bool HIsValid {
+ get {
+ return true;
+ }
+ set {
+ throw new NotImplementedException ();
+ }
+ }
+ public bool XIsValid {
+ get {
+ return true;
+ }
+ set {
+ throw new NotImplementedException ();
+ }
+ }
+ public bool YIsValid {
+ get {
+ return true;
+ }
+ set {
+ throw new NotImplementedException ();
+ }
+ }
+
+ public virtual void InvalidateLayout ()
+ {
+ // foreach (GraphicObject g in GraphicObjects) {
+ // g.InvalidateLayout ();
+ // }
+ }
+
+ #endregion
+ }
+}
+
--- /dev/null
+//
+// ImageViewerNodeExtension.cs
+//
+// Author:
+// Mike Krüger <mkrueger@novell.com>
+//
+// 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;
+
+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
+ {
+ [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);
+ }
+ }
+
+}
+
--- /dev/null
+//
+// ImageViewer.cs
+//
+// Author:
+// Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
+//
+// 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 <http://www.gnu.org/licenses/>.
+
+//
+// HexEditorView.cs
+//
+// Author:
+// Mike Krüger <mkrueger@novell.com>
+//
+// 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 go;
+using MonoDevelop.DesignerSupport;
+
+namespace MonoDevelop.GOLib
+{
+ class GOLibView : AbstractViewContent
+ {
+ GOLibGtkHost gtkGoWidgetHost;
+
+
+ double zoom = 1.0;
+
+ public override Gtk.Widget Control {
+ get {
+ return gtkGoWidgetHost;
+ }
+ }
+
+ public GOLibView ()
+ {
+ gtkGoWidgetHost = new GOLibGtkHost ();
+ }
+
+ public override void Load (string fileName)
+ {
+ gtkGoWidgetHost.Load (fileName);
+ ContentName = fileName;
+ this.IsDirty = false;
+ gtkGoWidgetHost.Show ();
+ }
+ public override bool CanReuseView (string fileName)
+ {
+ return base.CanReuseView (fileName);
+ }
+ public override void RedrawContent ()
+ {
+ base.RedrawContent ();
+ }
+ }
+}
--- /dev/null
+<?xml version="1.0"?>\r
+<GraphicObject \r
+ Top="10" Left="10"\r
+ Width="10" Height="50" \r
+ Margin="10" Background="Green"/>\r
+++ /dev/null
-<?xml version="1.0"?>\r
-<GraphicObject \r
- Width="100" Height="50" \r
- BorderWidth="10" Margin="10" Background="Green"/>\r
--- /dev/null
+<?xml version="1.0"?>\r
+<Container\r
+ HorizontalAlignment="Left" VerticalAlignment="Center"\r
+ Margin="10" Focusable="True" Fit="True" Background="Green">\r
+ <Group Background="White" >\r
+ <Image Name="PhaseOverlay" Width="40" Height="40"\r
+ Path="image/u.svg" Background="Red"/>\r
+ </Group>\r
+</Container>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0"?>\r
-<Container\r
- HorizontalAlignment="Left" VerticalAlignment="Center"\r
- Margin="10" Focusable="True" Fit="True" Background="Green">\r
- <Group Background="White" >\r
- <Image Name="PhaseOverlay" Width="40" Height="40"\r
- Path="image/u.svg" Background="Red"/>\r
- </Group>\r
-</Container>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0"?>\r
+<Container Name="MainGrp" \r
+ Width="600" Height="600" \r
+ Background="White" Margin="10" Focusable="True">\r
+\r
+ <Button Margin="1" BorderWidth="0" Background="Gray" Width="400" Height="400">\r
+ <Image Path="image/u.svg"/>\r
+ </Button> \r
+</Container>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0"?>\r
-<Container Name="MainGrp" \r
- Width="600" Height="600" \r
- Background="White" Margin="10" Focusable="True">\r
-\r
- <Button Margin="1" BorderWidth="0" Background="Gray" Width="400" Height="400">\r
- <Image Path="image/u.svg"/>\r
- </Button> \r
-</Container>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0"?>\r
+<Group Name="MainGrp"\r
+ Width="800" Height="500"\r
+ Background="0,5;0,5;0,5;0,5" Foreground="White"\r
+ Margin="10" >\r
+ <Border \r
+ BorderWidth="2" BorderColor="Transparent"\r
+ Focusable="True"\r
+ MouseEnter="{BorderColor = White}"\r
+ MouseLeave="{BorderColor = Transparent}">\r
+\r
+ <HorizontalStack Name="hs0"\r
+ WidgetSpacing="10" \r
+ VerticalAlignment="Top" \r
+ Background="0,5;0,5;0,5;0,5">\r
+ <VerticalStack Name="vs1"\r
+ Margin="20">\r
+ <Label Name="labMouse" Text="MousePos"/>\r
+ <HorizontalStack Name="hsPbar">\r
+ <ProgressBar Name="pbBar" \r
+ Width="100" Height="20"\r
+ Value="50"\r
+ Foreground="BlueCrayola" Background="DarkGray"\r
+ BorderWidth="2" BorderColor="White"/>\r
+ <Label Name="labPb"\r
+ Width="20"\r
+ TextAlignment="RightCenter"/>\r
+ <ProgressBar Name="pbBar"\r
+ Width="100" Height="10"\r
+ Value="30"/>\r
+ </HorizontalStack>\r
+ <HorizontalStack Name="hsFocus">\r
+ <Label Text="Focused:"/>\r
+ <Label Name="labFocus" Width="200"/>\r
+ </HorizontalStack>\r
+ <HorizontalStack>\r
+ <Label Text="Active:" Name="hsActive"/>\r
+ <Label Name="labActive" Width="200"/>\r
+ </HorizontalStack>\r
+ <HorizontalStack>\r
+ <Label Text="Hover:" Name="hsHover"/>\r
+ <Label Name="labHover" Width="200"/>\r
+ </HorizontalStack>\r
+ <Button Margin="5" BorderWidth="0" Background="Gray" Width="-1" Height="-1">\r
+ <Label FontSize="10" Text="This is a test" Margin="5" FontColor="White" Foreground="White" />\r
+ </Button>\r
+ <TextBoxWidget TextAlignment="LeftCenter" Font="droid,14" \r
+ Width="300" Height="-1" Margin="2"\r
+ BorderColor="White" BorderWidth="1"\r
+ Text="editable text"/>\r
+ <GroupBox Title="Group Box" Width="300" Height="100" \r
+ BorderColor="White" BorderWidth="2" Margin="3">\r
+ <Label Name="labValue" FontSize="14" Text="000" TextAlignment="Center"/>\r
+ </GroupBox>\r
+ <Slider Height="10" Width="300" BorderWidth="1" Background="Transparent" />\r
+ <GraduatedSlider Name="slider" Height="30" Width="300" Foreground="BlueBell"/>\r
+ </VerticalStack>\r
+ <VerticalStack Width="-1" Height="-1" BorderWidth="1" Margin="5" WidgetSpacing="4">\r
+ <Button Width="-1" Height="-1" Margin="5">\r
+ <Image Path="/mnt/data/Images/130px-Blason_ville_fr_Aubure_(Haut-Rhin).svg.png"/>\r
+ </Button>\r
+ <HorizontalStack>\r
+ <Label Text="Update" FontColor="White" VerticalAlignment="Center" />\r
+ <Label Name="labUpdate" Text="xxxx" FontSize="16" Width="60" TextAlignment="Center" Background="DarkGreen"/>\r
+ </HorizontalStack>\r
+ <HorizontalStack>\r
+ <Label Text="Fps:" Width = "30" VerticalAlignment="Center" TextAlignment="LeftCenter"/>\r
+ <Label Name="labFps" Text="xxxx" Font="droid bold, 14"\r
+ TextAlignment="Center" Background="AoEnglish"/>\r
+ </HorizontalStack>\r
+ <HorizontalStack>\r
+ <Label Text="Min:" Width = "30" />\r
+ <Label Name="labFpsMin" Text="xxxx" Font="droid bold, 14"\r
+ TextAlignment="Center" Background="AoEnglish"/>\r
+ </HorizontalStack>\r
+ <HorizontalStack>\r
+ <Label Text="Max:" Width = "30"/>\r
+ <Label Name="labFpsMax" Text="xxxx" Font="droid bold, 14"\r
+ TextAlignment="Center" Background="AoEnglish"/>\r
+ </HorizontalStack>\r
+ </VerticalStack>\r
+\r
+ <Scroller Background="DimGray" Height="350" Width="300" \r
+ Margin="5" VerticalScrolling="true">\r
+ <VerticalStack Name="colors" VerticalAlignment="Top" Margin="5">\r
+ <ProgressBar Name="pbBar2" Width="100" Height="20" Value="50"\r
+ BorderWidth="2" BorderColor="White" Foreground="BlueCrayola" Background="DarkGray"/>\r
+ </VerticalStack>\r
+ </Scroller>\r
+\r
+ </HorizontalStack>\r
+\r
+ <Slider \r
+ Height="20" Width="300" \r
+ Background="Transparent"\r
+ VerticalAlignment="Bottom" />\r
+ </Border>\r
+</Group>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0"?>\r
-<Group Name="MainGrp"\r
- Width="800" Height="500"\r
- Background="0,5;0,5;0,5;0,5" Foreground="White"\r
- Margin="10" >\r
- <Border \r
- BorderWidth="2" BorderColor="Transparent"\r
- Focusable="True"\r
- MouseEnter="{BorderColor = White}"\r
- MouseLeave="{BorderColor = Transparent}">\r
-\r
- <HorizontalStack Name="hs0"\r
- WidgetSpacing="10" \r
- VerticalAlignment="Top" \r
- Background="0,5;0,5;0,5;0,5">\r
- <VerticalStack Name="vs1"\r
- Margin="20">\r
- <Label Name="labMouse" Text="MousePos"/>\r
- <HorizontalStack Name="hsPbar">\r
- <ProgressBar Name="pbBar" \r
- Width="100" Height="20"\r
- Value="50"\r
- Foreground="BlueCrayola" Background="DarkGray"\r
- BorderWidth="2" BorderColor="White"/>\r
- <Label Name="labPb"\r
- Width="20"\r
- TextAlignment="RightCenter"/>\r
- <ProgressBar Name="pbBar"\r
- Width="100" Height="10"\r
- Value="30"/>\r
- </HorizontalStack>\r
- <HorizontalStack Name="hsFocus">\r
- <Label Text="Focused:"/>\r
- <Label Name="labFocus" Width="200"/>\r
- </HorizontalStack>\r
- <HorizontalStack>\r
- <Label Text="Active:" Name="hsActive"/>\r
- <Label Name="labActive" Width="200"/>\r
- </HorizontalStack>\r
- <HorizontalStack>\r
- <Label Text="Hover:" Name="hsHover"/>\r
- <Label Name="labHover" Width="200"/>\r
- </HorizontalStack>\r
- <Button Margin="5" BorderWidth="0" Background="Gray" Width="-1" Height="-1">\r
- <Label FontSize="10" Text="This is a test" Margin="5" FontColor="White" Foreground="White" />\r
- </Button>\r
- <TextBoxWidget TextAlignment="LeftCenter" Font="droid,14" \r
- Width="300" Height="-1" Margin="2"\r
- BorderColor="White" BorderWidth="1"\r
- Text="editable text"/>\r
- <GroupBox Title="Group Box" Width="300" Height="100" \r
- BorderColor="White" BorderWidth="2" Margin="3">\r
- <Label Name="labValue" FontSize="14" Text="000" TextAlignment="Center"/>\r
- </GroupBox>\r
- <Slider Height="10" Width="300" BorderWidth="1" Background="Transparent" />\r
- <GraduatedSlider Name="slider" Height="30" Width="300" Foreground="BlueBell"/>\r
- </VerticalStack>\r
- <VerticalStack Width="-1" Height="-1" BorderWidth="1" Margin="5" WidgetSpacing="4">\r
- <Button Width="-1" Height="-1" Margin="5">\r
- <Image Path="/mnt/data/Images/130px-Blason_ville_fr_Aubure_(Haut-Rhin).svg.png"/>\r
- </Button>\r
- <HorizontalStack>\r
- <Label Text="Update" FontColor="White" VerticalAlignment="Center" />\r
- <Label Name="labUpdate" Text="xxxx" FontSize="16" Width="60" TextAlignment="Center" Background="DarkGreen"/>\r
- </HorizontalStack>\r
- <HorizontalStack>\r
- <Label Text="Fps:" Width = "30" VerticalAlignment="Center" TextAlignment="LeftCenter"/>\r
- <Label Name="labFps" Text="xxxx" Font="droid bold, 14"\r
- TextAlignment="Center" Background="AoEnglish"/>\r
- </HorizontalStack>\r
- <HorizontalStack>\r
- <Label Text="Min:" Width = "30" />\r
- <Label Name="labFpsMin" Text="xxxx" Font="droid bold, 14"\r
- TextAlignment="Center" Background="AoEnglish"/>\r
- </HorizontalStack>\r
- <HorizontalStack>\r
- <Label Text="Max:" Width = "30"/>\r
- <Label Name="labFpsMax" Text="xxxx" Font="droid bold, 14"\r
- TextAlignment="Center" Background="AoEnglish"/>\r
- </HorizontalStack>\r
- </VerticalStack>\r
-\r
- <Scroller Background="DimGray" Height="350" Width="300" \r
- Margin="5" VerticalScrolling="true">\r
- <VerticalStack Name="colors" VerticalAlignment="Top" Margin="5">\r
- <ProgressBar Name="pbBar2" Width="100" Height="20" Value="50"\r
- BorderWidth="2" BorderColor="White" Foreground="BlueCrayola" Background="DarkGray"/>\r
- </VerticalStack>\r
- </Scroller>\r
-\r
- </HorizontalStack>\r
-\r
- <Slider \r
- Height="20" Width="300" \r
- Background="Transparent"\r
- VerticalAlignment="Bottom" />\r
- </Border>\r
-</Group>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0"?>\r
+<Container Name="container0" BorderColor="White" BorderWidth="2" Margin="100"\r
+ CornerRadius="50">\r
+ <Group Name="group0" Background="Green" Margin="20">\r
+ <HorizontalStack Name="hs0" Background="Blue" Margin="20">\r
+ <GraphicObject Name="g0" Background="Desert" Width="50" Height="50"\r
+ MouseEnter="g_MouseEnter" MouseLeave="g_MouseLeave"/>\r
+ <GraphicObject Name="g1" Background="Desert" Width="50" Height="50"\r
+ MouseEnter="g_MouseEnter" MouseLeave="g_MouseLeave"/>\r
+ <GraphicObject Name="g2" Background="Desert" Width="50" Height="50"\r
+ MouseEnter="g_MouseEnter" MouseLeave="g_MouseLeave"/>\r
+ <Label Name="lab0" Text="000" FontSize="16"/>\r
+ <GraphicObject Name="g3" Background="Desert" Width="50" Height="50"\r
+ MouseEnter="g_MouseEnter" MouseLeave="g_MouseLeave"/>\r
+ <GraphicObject Name="g4" Background="Desert" Width="50" Height="50"\r
+ MouseEnter="g_MouseEnter" MouseLeave="g_MouseLeave"/>\r
+ <GraphicObject Name="g5" Background="Desert" Width="50" Height="50"\r
+ MouseEnter="g_MouseEnter" MouseLeave="g_MouseLeave"/>\r
+ </HorizontalStack>\r
+ </Group>\r
+<!-- <Scroller Height="100" Width="300" Background="Green" VerticalScrolling="true" Margin="5">\r
+ <Group Name="MainGrp" Background="Red" VerticalAlignment="Top"\r
+ BorderColor="White" BorderWidth="2" Margin="10" Focusable="True" \r
+ Width="400" Height="200">\r
+ <HorizontalStack>\r
+ <Button Width="-1" Height="-1" Margin="5" BorderWidth="2" Background="Gray">\r
+ <Label Text="button"/>\r
+ </Button>\r
+ <Button Width="-1" Height="-1" Margin="5" BorderWidth="2">\r
+ <Label Text="button"/>\r
+ </Button>\r
+ <Button Width="-1" Height="-1" Margin="5" BorderWidth="2">\r
+ <Label Text="button"/>\r
+ </Button>\r
+ <Button Width="-1" Height="-1" Margin="5" BorderWidth="2">\r
+ <Label Text="button"/>\r
+ </Button>\r
+ <Button Width="-1" Height="200" Margin="5" BorderWidth="2" >\r
+ <Label Text="button"/>\r
+ </Button> \r
+ </HorizontalStack>\r
+ </Group>\r
+ <Container Width="100" Height="200" Margin="5" BorderWidth="2" VerticalAlignment="Top"/>\r
+ </Scroller>-->\r
+\r
+</Container>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0"?>\r
-<Container Name="container0" BorderColor="White" BorderWidth="2" Margin="100"\r
- CornerRadius="50">\r
- <Group Name="group0" Background="Green" Margin="20">\r
- <HorizontalStack Name="hs0" Background="Blue" Margin="20">\r
- <GraphicObject Name="g0" Background="Desert" Width="50" Height="50"\r
- MouseEnter="g_MouseEnter" MouseLeave="g_MouseLeave"/>\r
- <GraphicObject Name="g1" Background="Desert" Width="50" Height="50"\r
- MouseEnter="g_MouseEnter" MouseLeave="g_MouseLeave"/>\r
- <GraphicObject Name="g2" Background="Desert" Width="50" Height="50"\r
- MouseEnter="g_MouseEnter" MouseLeave="g_MouseLeave"/>\r
- <Label Name="lab0" Text="000" FontSize="16"/>\r
- <GraphicObject Name="g3" Background="Desert" Width="50" Height="50"\r
- MouseEnter="g_MouseEnter" MouseLeave="g_MouseLeave"/>\r
- <GraphicObject Name="g4" Background="Desert" Width="50" Height="50"\r
- MouseEnter="g_MouseEnter" MouseLeave="g_MouseLeave"/>\r
- <GraphicObject Name="g5" Background="Desert" Width="50" Height="50"\r
- MouseEnter="g_MouseEnter" MouseLeave="g_MouseLeave"/>\r
- </HorizontalStack>\r
- </Group>\r
-<!-- <Scroller Height="100" Width="300" Background="Green" VerticalScrolling="true" Margin="5">\r
- <Group Name="MainGrp" Background="Red" VerticalAlignment="Top"\r
- BorderColor="White" BorderWidth="2" Margin="10" Focusable="True" \r
- Width="400" Height="200">\r
- <HorizontalStack>\r
- <Button Width="-1" Height="-1" Margin="5" BorderWidth="2" Background="Gray">\r
- <Label Text="button"/>\r
- </Button>\r
- <Button Width="-1" Height="-1" Margin="5" BorderWidth="2">\r
- <Label Text="button"/>\r
- </Button>\r
- <Button Width="-1" Height="-1" Margin="5" BorderWidth="2">\r
- <Label Text="button"/>\r
- </Button>\r
- <Button Width="-1" Height="-1" Margin="5" BorderWidth="2">\r
- <Label Text="button"/>\r
- </Button>\r
- <Button Width="-1" Height="200" Margin="5" BorderWidth="2" >\r
- <Label Text="button"/>\r
- </Button> \r
- </HorizontalStack>\r
- </Group>\r
- <Container Width="100" Height="200" Margin="5" BorderWidth="2" VerticalAlignment="Top"/>\r
- </Scroller>-->\r
-\r
-</Container>
\ No newline at end of file
<OutputType>Exe</OutputType>
<RootNamespace>Tests</RootNamespace>
<AssemblyName>Tests</AssemblyName>
- <StartupObject>test.GOLIBTest_4</StartupObject>
+ <StartupObject>test.GOLIBTest_0</StartupObject>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<OutputPath>..\bin\$(configuration)</OutputPath>
<IntermediateOutputPath>obj\$(configuration)</IntermediateOutputPath>
<Compile Include="GOLIBTest_1.cs" />
</ItemGroup>
<ItemGroup>
- <None Include="Interfaces\test0.xml">
+ <None Include="image\u.svg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
- <None Include="Interfaces\test5.xml">
+ <None Include="Interfaces\test1.goml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
- <None Include="Interfaces\test4.xml">
+ <None Include="Interfaces\test3.goml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
- <None Include="Interfaces\test3.xml">
+ <None Include="Interfaces\test4.goml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
- <None Include="image\u.svg">
+ <None Include="Interfaces\test5.goml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
- <None Include="Interfaces\test1.xml">
+ <None Include="Interfaces\test0.goml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
\r
namespace go\r
{\r
- public class Button : Container\r
+ public class Button : Container, IXmlSerializable\r
{\r
#region CTOR\r
public Button() : base()\r
using System.Reflection;\r
using System.ComponentModel;\r
using System.IO;\r
+//using System.Xml;\r
+using System.Xml;\r
\r
namespace go\r
{\r
bool yIsValid = false;\r
#endregion\r
\r
+ public static bool DesignerMode = false;\r
+\r
#region public fields\r
public Rectangle Bounds;\r
public Rectangle Slot = new Rectangle ();\r
return cb;\r
}\r
}\r
- [XmlIgnore]public virtual OpenTKGameWindow TopContainer {\r
+ [XmlIgnore]public virtual IGOLibHost TopContainer {\r
get { return Parent.TopContainer; }\r
}\r
public virtual void InvalidateLayout ()\r
}\r
[XmlAttributeAttribute()][DefaultValue(false)]\r
public virtual bool Focusable {\r
- get { return _focusable; }\r
+ get { return _focusable | DesignerMode; }\r
set { _focusable = value; }\r
} \r
[XmlAttributeAttribute()][DefaultValue("Transparent")]\r
_isVisible = value;\r
\r
//add slot to clipping to redraw\r
- OpenTKGameWindow.gobjsToRedraw.Add (this);\r
+ TopContainer.gobjsToRedraw.Add (this);\r
\r
//ensure main win doesn't keep hidden childrens ref\r
- if (this.Contains (OpenTKGameWindow.currentWindow.hoverWidget))\r
- OpenTKGameWindow.currentWindow.hoverWidget = null;\r
+ if (this.Contains (TopContainer.hoverWidget))\r
+ TopContainer.hoverWidget = null;\r
// if (Parent != null)\r
// Parent.InvalidateLayout ();\r
//else\r
public virtual void registerForRedraw ()\r
{\r
if (LayoutIsValid && Visible)\r
- OpenTKGameWindow.gobjsToRedraw.Add (this);\r
+ TopContainer.gobjsToRedraw.Add (this);\r
}\r
public virtual void registerClipRect()\r
{\r
- OpenTKGameWindow.redrawClip.AddRectangle (ScreenCoordinates(Slot));\r
+ TopContainer.redrawClip.AddRectangle (ScreenCoordinates(Slot));\r
}\r
protected virtual Size measureRawSize ()\r
{\r
}\r
public virtual void onMouseMove(object sender, MouseMoveEventArgs e)\r
{\r
- OpenTKGameWindow w = sender as OpenTKGameWindow;\r
+ //ILayoutable w = sender as ILayoutable;\r
\r
- if (w.hoverWidget != this) {\r
- w.hoverWidget = this;\r
+ if (TopContainer.hoverWidget != this) {\r
+ TopContainer.hoverWidget = this;\r
onMouseEnter (sender, e);\r
}\r
\r
MouseButtonUp (this, e);\r
}\r
public virtual void onMouseButtonDown(object sender, MouseButtonEventArgs e){\r
- (sender as OpenTKGameWindow).FocusedWidget = this;\r
+ TopContainer.FocusedWidget = this;\r
\r
MouseButtonDown (this, e);\r
}\r
{\r
xs.Serialize(s, graphicObject, xn);\r
}\r
- } \r
+ }\r
+ public static GraphicObject Load(string path)\r
+ {\r
+ string root = "Object";\r
+ using (Stream s = new FileStream (path, FileMode.Open)) {\r
+ using (XmlReader reader = XmlReader.Create (s)) {\r
+ while (reader.Read()) {\r
+ // first element is the root element\r
+ if (reader.NodeType == XmlNodeType.Element) {\r
+ root = reader.Name;\r
+ break;\r
+ }\r
+ }\r
+ }\r
+ }\r
+ Type t = Type.GetType("go." + root);\r
+ var go = Activator.CreateInstance(t);\r
+ return Load(path, t);\r
+ }\r
public static void Load<T>(string file, out T result, object ClassContainingHandlers = null)\r
{\r
EventsToResolve = new List<EventSource>();\r
fi.SetValue(es.Source, del);\r
}\r
}\r
+ }\r
+\r
+ public static GraphicObject Load(string file, Type type, object ClassContainingHandlers = null)\r
+ {\r
+ GraphicObject result;\r
+ EventsToResolve = new List<EventSource>();\r
+\r
+ XmlSerializerNamespaces xn = new XmlSerializerNamespaces();\r
+ xn.Add("", "");\r
+ XmlSerializer xs = new XmlSerializer(type); \r
+\r
+ using (Stream s = new FileStream(file, FileMode.Open))\r
+ {\r
+ result = (GraphicObject)xs.Deserialize(s);\r
+ }\r
+\r
+ if (ClassContainingHandlers == null)\r
+ return result;\r
+\r
+ foreach (EventSource es in EventsToResolve)\r
+ {\r
+ if (string.IsNullOrEmpty(es.Handler))\r
+ continue;\r
+\r
+ if (es.Handler.StartsWith ("{")) {\r
+ CompilerServices.CompileEventSource (es);\r
+ } else { \r
+ MethodInfo mi = ClassContainingHandlers.GetType ().GetMethod (es.Handler, BindingFlags.NonPublic | BindingFlags.Public\r
+ | BindingFlags.Instance);\r
\r
+ if (mi == null) {\r
+ Debug.WriteLine ("Handler Method not found: " + es.Handler);\r
+ continue;\r
+ }\r
+\r
+ FieldInfo fi = CompilerServices.getEventHandlerField (es.Source.GetType (), es.EventName);\r
+ Delegate del = Delegate.CreateDelegate(fi.FieldType, ClassContainingHandlers, mi);\r
+ fi.SetValue(es.Source, del);\r
+ }\r
+ }\r
+ return result;\r
}\r
\r
#endregion\r
--- /dev/null
+using System;
+using System.Collections.Generic;
+
+namespace go
+{
+ public interface IGOLibHost
+ {
+ Rectangles redrawClip { get; set; }
+ List<GraphicObject> gobjsToRedraw { get; }
+ GraphicObject activeWidget { get; set; }
+ GraphicObject hoverWidget { get; set; }
+ GraphicObject FocusedWidget { get; set; }
+ void AddWidget (GraphicObject g);
+ void DeleteWidget(GraphicObject g);
+ }
+}
+
Rectangle getSlot();
Rectangle getBounds();
- OpenTKGameWindow TopContainer { get; }
+ IGOLibHost TopContainer { get; }
void InvalidateLayout ();
\r
public override void registerClipRect ()\r
{\r
- OpenTKGameWindow.redrawClip.AddRectangle (base.ScreenCoordinates(Slot));\r
+ TopContainer.redrawClip.AddRectangle (base.ScreenCoordinates(Slot));\r
}\r
public override void UpdateLayout ()\r
{\r
using System.Drawing.Imaging;\r
//using System.Xml.Serialization;\r
//using System.Reflection;\r
+using System.Xml;\r
+using System.IO;\r
\r
\r
\r
namespace go\r
{\r
- public class OpenTKGameWindow : GameWindow, ILayoutable\r
+ public class OpenTKGameWindow : GameWindow, ILayoutable, IGOLibHost\r
{\r
#region ctor\r
// public OpenTKGameWindow(int _width, int _height, string _title="golib")\r
public List<GraphicObject> GraphicObjects = new List<GraphicObject>();\r
public Color Background = Color.Transparent;\r
\r
- public static Rectangles redrawClip = new Rectangles();//should find another way to access it from child\r
- public static List<GraphicObject> gobjsToRedraw = new List<GraphicObject>();\r
internal static OpenTKGameWindow currentWindow;\r
\r
+ Rectangles _redrawClip = new Rectangles();//should find another way to access it from child\r
+ List<GraphicObject> _gobjsToRedraw = new List<GraphicObject>();\r
+\r
+ public Rectangles redrawClip {\r
+ get {\r
+ return _redrawClip;\r
+ }\r
+ set {\r
+ _redrawClip = value;\r
+ }\r
+ }\r
+\r
+ public List<GraphicObject> gobjsToRedraw {\r
+ get {\r
+ return _gobjsToRedraw;\r
+ }\r
+ set {\r
+ _gobjsToRedraw = value;\r
+ }\r
+ }\r
+ public void AddWidget(GraphicObject g)\r
+ {\r
+ g.Parent = this;\r
+ GraphicObjects.Add (g);\r
+ }\r
+ public void DeleteWidget(GraphicObject g)\r
+ {\r
+ g.Visible = false;//trick to ensure clip is added to refresh zone\r
+ GraphicObjects.Remove (g);\r
+ }\r
+\r
#region Events\r
//those events are raised only if mouse isn't in a graphic object\r
public event EventHandler<MouseWheelEventArgs> MouseWheelChanged = delegate { };\r
// updateTime.ElapsedMilliseconds);\r
\r
} \r
-\r
- public void AddWidget(GraphicObject g)\r
- {\r
- g.Parent = this;\r
- GraphicObjects.Add (g);\r
- }\r
- public void DeleteWidget(GraphicObject g)\r
- {\r
- g.Visible = false;//ensure clip is added to refresh zone\r
- GraphicObjects.Remove (g);\r
- }\r
+ \r
public void LoadInterface<T>(string path, out T result)\r
{\r
GraphicObject.Load<T> (path, out result, this);\r
AddWidget (result as GraphicObject);\r
return result;\r
}\r
-\r
+ \r
#region Game win overrides\r
protected override void OnUpdateFrame(FrameEventArgs e)\r
{ \r
}\r
#endregion\r
\r
-\r
#region ILayoutable implementation\r
\r
public Rectangle ContextCoordinates (Rectangle r)\r
{\r
return r;\r
}\r
-\r
public Rectangle ScreenCoordinates (Rectangle r)\r
{\r
return r;\r
get { return true; }\r
set { throw new NotImplementedException (); }\r
}\r
-\r
public bool PositionIsValid {\r
get {\r
return true;\r
throw new NotImplementedException ();\r
}\r
}\r
-\r
public bool LayoutIsValid {\r
get {\r
return true;//tester tout les enfants a mon avis\r
get { return new Size(this.ClientRectangle.Size.Width,this.ClientRectangle.Size.Height); }\r
}\r
\r
- public OpenTKGameWindow TopContainer {\r
+ public IGOLibHost TopContainer {\r
get { return this; }\r
}\r
\r
{\r
return ClientRectangle;\r
}\r
+\r
public bool WIsValid {\r
get {\r
return true;\r
throw new NotImplementedException ();\r
}\r
}\r
-\r
public bool HIsValid {\r
get {\r
return true;\r
throw new NotImplementedException ();\r
}\r
}\r
-\r
public bool XIsValid {\r
get {\r
return true;\r
throw new NotImplementedException ();\r
}\r
}\r
-\r
public bool YIsValid {\r
get {\r
return true;\r
throw new NotImplementedException ();\r
}\r
}\r
+\r
public virtual void InvalidateLayout ()\r
{\r
// foreach (GraphicObject g in GraphicObjects) {\r
// g.InvalidateLayout ();\r
// }\r
}\r
- public Rectangle rectInScreenCoord (Rectangle r)\r
- {\r
- throw new NotImplementedException ();\r
- }\r
-\r
- public Rectangle renderBoundsInContextCoordonate {\r
- get { return ClientRectangle; }\r
- }\r
-\r
- public Rectangle ClientBoundsInContextCoordonate {\r
- get {\r
- throw new NotImplementedException ();\r
- }\r
- }\r
-\r
- public Rectangle renderBoundsInBackendSurfaceCoordonate {\r
- get { return ClientRectangle; }\r
- }\r
-\r
- public Rectangle ClientBoundsInBackendSurfaceCoordonate {\r
- get {\r
- throw new NotImplementedException ();\r
- }\r
- set {\r
- throw new NotImplementedException ();\r
- }\r
- }\r
-\r
- public Rectangle ScreenCoordBounds {\r
- get { return ClientRectangle; }\r
- }\r
-\r
- public Rectangle ScreenCoordClientBounds {\r
- get {\r
- throw new NotImplementedException ();\r
- }\r
- set {\r
- throw new NotImplementedException ();\r
- }\r
- }\r
+// public Rectangle rectInScreenCoord (Rectangle r)\r
+// {\r
+// throw new NotImplementedException ();\r
+// }\r
+// public Rectangle renderBoundsInContextCoordonate {\r
+// get { return ClientRectangle; }\r
+// }\r
+// public Rectangle ClientBoundsInContextCoordonate {\r
+// get {\r
+// throw new NotImplementedException ();\r
+// }\r
+// }\r
+// public Rectangle renderBoundsInBackendSurfaceCoordonate {\r
+// get { return ClientRectangle; }\r
+// }\r
+// public Rectangle ClientBoundsInBackendSurfaceCoordonate {\r
+// get {\r
+// throw new NotImplementedException ();\r
+// }\r
+// set {\r
+// throw new NotImplementedException ();\r
+// }\r
+// }\r
+// public Rectangle ScreenCoordBounds {\r
+// get { return ClientRectangle; }\r
+// }\r
+// public Rectangle ScreenCoordClientBounds {\r
+// get {\r
+// throw new NotImplementedException ();\r
+// }\r
+// set {\r
+// throw new NotImplementedException ();\r
+// }\r
+// }\r
#endregion\r
}\r
}
\ No newline at end of file