]> O.S.I.I.S - jp/crow.git/commitdiff
adapt to embed cairo in mono
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Thu, 16 Nov 2017 02:28:40 +0000 (03:28 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Thu, 16 Nov 2017 02:28:40 +0000 (03:28 +0100)
Crow.csproj
Crow.dll.config
src/CompilerServices/CompilerServices.cs
src/Configuration.cs
src/GraphicObjects/Layoutable.cs [new file with mode: 0644]
src/GraphicObjects/NumericControl.cs
src/Instantiator.cs
src/Interface.cs
src/rsvg/Global.cs
src/rsvg/Handle.cs

index f6d78c1aa7b59cf95b76420d0a04758b1c168389..6e0b503c82aceaa11c566bfee0b659f70aa68002 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <PropertyGroup>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -15,7 +15,6 @@
     <WarningLevel>4</WarningLevel>
     <NoWin32Manifest>False</NoWin32Manifest>
     <SignAssembly>true</SignAssembly>
-    <DelaySign>False</DelaySign>
     <RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
     <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
     <Description>C# Rapid Open Widget</Description>
     <IntermediateOutputPath>$(SolutionDir)build\obj\$(Configuration)</IntermediateOutputPath>
     <AssemblyOriginatorKeyFile>crow.key</AssemblyOriginatorKeyFile>
     <ProductVersion>8.0.30703</ProductVersion>
-    <SchemaVersion>2.0</SchemaVersion>
     <ReleaseVersion>0.5</ReleaseVersion>
+    <UseMSBuildEngine>false</UseMSBuildEngine>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <DebugSymbols>true</DebugSymbols>
     <DebugType>full</DebugType>
     <CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
-    <DefineConstants>DEBUG_UPDATE0;DEBUG_FOCUS0;DEBUG_LAYOUTING0;TRACE0;DEBUG;__linux__;MEASURE_TIME0;DEBUG_LOAD0;DEBUG_BINDING0;DEBUG_CLIP_RECTANGLE0</DefineConstants>
+    <DefineConstants>DEBUG_UPDATE0;DEBUG_FOCUS0;DEBUG_LAYOUTING0;TRACE0;DEBUG0;__linux__;MEASURE_TIME0;DEBUG_LOAD0;DEBUG_BINDING0;DEBUG_CLIP_RECTANGLE0</DefineConstants>
     <Optimize>false</Optimize>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
index ef7562ac47aa7b4d9008d121bdc494f83e312639..13de603c2c4f36baf24c14bb34994f6314555bec 100644 (file)
@@ -5,7 +5,7 @@
   <dllmap os="!windows,osx" dll="libgobject-2.0-0.dll" target="libgobject-2.0.so.0"/>
   <dllmap os="!windows,osx" dll="libgdk-3-0.dll" target="libgdk-3.so.0"/>
   <dllmap os="!windows,osx" dll="libgdk_pixbuf-2.0-0.dll" target="libgdk_pixbuf-2.0.so.0"/>
-  <dllmap os="!windows,osx" dll="rsvg-2" target="librsvg-2.so.2"/>
+  <dllmap os="!windows,osx" dll="rsvg" target="librsvg-2.so.2"/>
 
   
   <dllmap os="windows" dll="rsvg-2" target="librsvg-2-2.dll"/>
@@ -17,3 +17,4 @@
   <dllmap os="osx" dll="libgdk-3.0.dll" target="libgdk-quartz-3.0.0.dylib"/>
   <dllmap os="osx" dll="libgdk_pixbuf-2.0-0.dll" target="libgdk_pixbuf-2.0.0.dylib"/>
 </configuration>
+    
\ No newline at end of file
index 827ee6178b4667fdef2fb28ccb8154f26b8ab45f..5edcc79e8d8a7ce30f30d10c87e5d210d35e5552 100644 (file)
@@ -386,8 +386,10 @@ namespace Crow
                /// <param name="methodName">Extention method name</param>
                internal static MethodInfo SearchExtMethod(Type t, string methodName){
                        MethodInfo mi = null;
-                       mi = GetExtensionMethods (Assembly.GetEntryAssembly(), t)
-                               .Where (em => em.Name == methodName).FirstOrDefault ();
+                       Assembly entryAss = Assembly.GetEntryAssembly ();
+                       if (entryAss!=null)
+                               mi = GetExtensionMethods (entryAss, t)
+                                       .Where (em => em.Name == methodName).FirstOrDefault ();
                        if (mi != null)
                                return mi;
 
index 8f89dbfc321d8d6eb565c1e53d3e846fa81c9db8..1f91e19cb9c103fd02327f5257db26c7f7536678 100644 (file)
@@ -68,7 +68,7 @@ namespace Crow
                static Dictionary<string, ConfigItem> items;
 
                static Configuration ()
-               {
+               {                       
                        items = new Dictionary<string, ConfigItem> ();
                        string configRoot =
                                Path.Combine(
diff --git a/src/GraphicObjects/Layoutable.cs b/src/GraphicObjects/Layoutable.cs
new file mode 100644 (file)
index 0000000..92aeb25
--- /dev/null
@@ -0,0 +1,55 @@
+//
+// ILayoutable.cs
+//
+// Author:
+//       Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
+//
+// Copyright (c) 2013-2017 Jean-Philippe Bruyère
+//
+// 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.Collections.Generic;
+
+namespace Crow
+{
+       public class Layoutable
+       {
+               /// <summary> Parent in the graphic tree </summary>
+               Layoutable Parent { get; set; }
+               /// <summary> The logical parent (used mainly for bindings) as opposed
+               ///  to the parent in the graphic tree </summary>
+               Layoutable LogicalParent { get; set; }
+
+               Rectangle ClientRectangle { get; }
+               Rectangle getSlot();
+
+               bool ArrangeChildren { get; }
+               LayoutingType RegisteredLayoutings { get; set; }
+               void RegisterForLayouting(LayoutingType layoutType);
+               void RegisterClip(Rectangle clip);
+               bool UpdateLayout(LayoutingType layoutType);
+
+
+               Rectangle ContextCoordinates(Rectangle r);
+               Rectangle ScreenCoordinates (Rectangle r);
+
+       }
+}
+
index 8ab60edbc9638b2972d069582ece0a1862d58cbd..551668b95854cf31bcd490e2f2c364ede7f37087 100644 (file)
@@ -30,6 +30,8 @@ using System.ComponentModel;
 
 namespace Crow
 {
+       //TODO: I'm waiting c#8 for default interface members implementation to set NumericControl and other widget base
+       //mecanics as interface to allow multiple inheritance.
        public abstract class NumericControl : TemplatedControl
        {
                #region CTOR
index 4c236cd47e0afd06c8308c56a84a480ac916330f..6cda11c3b854139bf2fef8fb94c929dcca1a9550 100644 (file)
@@ -336,15 +336,29 @@ namespace Crow
                                        ctx.il.Emit (OpCodes.Ldloc_0);
                                        ctx.il.Emit (OpCodes.Ldloc_0);
 
+                                       //TODO: optimize this
                                        Type t = Type.GetType ("Crow." + reader.Name);
                                        if (t == null) {
-                                               Assembly a = Assembly.GetEntryAssembly ();
-                                               foreach (Type expT in a.GetExportedTypes ()) {
+                                               Assembly ea = Assembly.GetEntryAssembly ();
+                                               foreach (Type expT in ea.GetExportedTypes ()) {
                                                        if (expT.Name == reader.Name) {
                                                                t = expT;
                                                                break;
                                                        }
                                                }
+                                               if (t == null) {
+                                                       foreach (AssemblyName an in Assembly.GetEntryAssembly().GetReferencedAssemblies()) {                                                    
+                                                               Assembly a = Assembly.Load (an);
+                                                               foreach (Type expT in a.GetExportedTypes ()) {
+                                                                       if (expT.Name == reader.Name) {
+                                                                               t = expT;
+                                                                               break;
+                                                                       }
+                                                               }
+                                                               if (t != null)
+                                                                       break;
+                                                       }
+                                               }
                                        }
                                        if (t == null)
                                                throw new Exception (reader.Name + " type not found");
index 53d90ea5fc151d286b2ef77f028bc9169755b258..621f4a34966e4e5b33ecf6e7e0cc4b143e50bfee 100644 (file)
@@ -50,7 +50,7 @@ namespace Crow
        ///     - the resulting bitmap of the interface
        /// </summary>
        public class Interface : ILayoutable
-       {
+       {               
                #region CTOR
                static Interface(){
                        loadCursors ();
@@ -64,6 +64,7 @@ namespace Crow
                        FontRenderingOptions.SubpixelOrder = SubpixelOrder.Rgb;
                }
                public Interface(){
+                       Console.WriteLine ("Interface CTOR");
                        CurrentInterface = this;
                        CultureInfo.DefaultThreadCurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
                }
@@ -188,6 +189,8 @@ namespace Crow
                }
                /// <summary> Search for .style resources in assembly </summary>
                static void loadStylingFromAssembly (Assembly assembly) {
+                       if (assembly == null)
+                               return;
                        foreach (string s in assembly
                                .GetManifestResourceNames ()
                                .Where (r => r.EndsWith (".style", StringComparison.OrdinalIgnoreCase))) {
@@ -197,15 +200,15 @@ namespace Crow
                }
                static void loadCursors(){
                        //Load cursors
-                       XCursor.Cross = XCursorFile.Load("#Crow.Images.Icons.Cursors.cross").Cursors[0];
-                       XCursor.Default = XCursorFile.Load("#Crow.Images.Icons.Cursors.arrow").Cursors[0];
-                       XCursor.NW = XCursorFile.Load("#Crow.Images.Icons.Cursors.top_left_corner").Cursors[0];
-                       XCursor.NE = XCursorFile.Load("#Crow.Images.Icons.Cursors.top_right_corner").Cursors[0];
-                       XCursor.SW = XCursorFile.Load("#Crow.Images.Icons.Cursors.bottom_left_corner").Cursors[0];
-                       XCursor.SE = XCursorFile.Load("#Crow.Images.Icons.Cursors.bottom_right_corner").Cursors[0];
-                       XCursor.H = XCursorFile.Load("#Crow.Images.Icons.Cursors.sb_h_double_arrow").Cursors[0];
-                       XCursor.V = XCursorFile.Load("#Crow.Images.Icons.Cursors.sb_v_double_arrow").Cursors[0];
-                       XCursor.Text = XCursorFile.Load("#Crow.Images.Icons.Cursors.ibeam").Cursors[0];
+                       XCursor.Cross = XCursorFile.Load ("#Crow.Images.Icons.Cursors.cross").Cursors [0];
+                       XCursor.Default = XCursorFile.Load ("#Crow.Images.Icons.Cursors.arrow").Cursors [0];
+                       XCursor.NW = XCursorFile.Load ("#Crow.Images.Icons.Cursors.top_left_corner").Cursors [0];
+                       XCursor.NE = XCursorFile.Load ("#Crow.Images.Icons.Cursors.top_right_corner").Cursors [0];
+                       XCursor.SW = XCursorFile.Load ("#Crow.Images.Icons.Cursors.bottom_left_corner").Cursors [0];
+                       XCursor.SE = XCursorFile.Load ("#Crow.Images.Icons.Cursors.bottom_right_corner").Cursors [0];
+                       XCursor.H = XCursorFile.Load ("#Crow.Images.Icons.Cursors.sb_h_double_arrow").Cursors [0];
+                       XCursor.V = XCursorFile.Load ("#Crow.Images.Icons.Cursors.sb_v_double_arrow").Cursors [0];
+                       XCursor.Text = XCursorFile.Load ("#Crow.Images.Icons.Cursors.ibeam").Cursors [0];
                }
                #endregion
 
@@ -221,6 +224,8 @@ namespace Crow
                        searchTemplatesIn (Assembly.GetExecutingAssembly ());
                }
                static void searchTemplatesIn(Assembly assembly){
+                       if (assembly == null)
+                               return;
                        foreach (string resId in assembly
                                .GetManifestResourceNames ()
                                .Where (r => r.EndsWith (".template", StringComparison.OrdinalIgnoreCase))) {
@@ -240,12 +245,15 @@ namespace Crow
                public static Stream GetStreamFromPath (string path)
                {
                        Stream stream = null;
+                       Assembly ass = null;
 
                        if (path.StartsWith ("#")) {
                                string resId = path.Substring (1);
                                //try/catch added to prevent nunit error
                                try {
-                                       stream = System.Reflection.Assembly.GetEntryAssembly ().GetManifestResourceStream (resId);
+                                       ass = Assembly.GetEntryAssembly ();
+                                       if (ass != null)
+                                               stream = ass.GetManifestResourceStream (resId);
                                } catch{}
                                if (stream == null)//try to find ressource in Crow assembly
                                        stream = System.Reflection.Assembly.GetExecutingAssembly ().GetManifestResourceStream (resId);
@@ -661,7 +669,7 @@ namespace Crow
                }
                #endregion
 
-               public void ProcessResize(Rectangle bounds){
+               public void ProcessResize(Rectangle bounds){                    
                        lock (UpdateMutex) {
                                clientRectangle = bounds;
                                int stride = 4 * ClientRectangle.Width;
index 65917012148b845010bb6cf1557e21e0cbeef3e7..b040ae6326eaf36e827d7a696ad5462dcfb257bb 100644 (file)
@@ -9,14 +9,14 @@ namespace Rsvg {
 #region Autogenerated code
        public class Global {
 
-               [DllImport("rsvg-2")]
+               [DllImport(Handle.librsvg)]
                static extern void rsvg_set_default_dpi_x_y(double dpi_x, double dpi_y);
 
                public static void SetDefaultDpiXY(double dpi_x, double dpi_y) {
                        rsvg_set_default_dpi_x_y(dpi_x, dpi_y);
                }
 
-               [DllImport("rsvg-2")]
+               [DllImport(Handle.librsvg)]
                static extern int rsvg_error_quark();
 
                public static int ErrorQuark {
@@ -27,7 +27,7 @@ namespace Rsvg {
                        }
                }
 
-               [DllImport("rsvg-2")]
+               [DllImport(Handle.librsvg)]
                static extern void rsvg_set_default_dpi(double dpi);
 
                public static double DefaultDpi {
index 039d3b6e7dddf6e2d4f3c9c57c8654d0a10e946d..71528496d3a620af44514483333f12fff3b0a4c2 100644 (file)
@@ -6,10 +6,10 @@ namespace Rsvg {
        using System.Runtime.InteropServices;
 
        public class Handle {
-
+               public const string librsvg = "rsvg";
                public IntPtr Raw;
 
-               [DllImport("rsvg-2")]
+               [DllImport(librsvg)]
                static extern IntPtr rsvg_handle_new();
 
                public Handle ()
@@ -17,7 +17,7 @@ namespace Rsvg {
                        Raw = rsvg_handle_new();
                }
 
-               [DllImport("rsvg-2")]
+               [DllImport(librsvg)]
                static extern unsafe IntPtr rsvg_handle_new_from_data(byte[] data, UIntPtr n_data, out IntPtr error);
 
                public unsafe Handle (byte[] data)
@@ -30,7 +30,7 @@ namespace Rsvg {
                        if (error != IntPtr.Zero) throw new Exception (error.ToString());
                }
 
-               [DllImport("rsvg-2")]
+               [DllImport(librsvg)]
                static extern unsafe IntPtr rsvg_handle_new_from_file(string file_name, out IntPtr error);
 
                public unsafe Handle (string file_name)
@@ -40,10 +40,10 @@ namespace Rsvg {
                        if (error != IntPtr.Zero) throw new Exception (error.ToString());
                }
 
-               [DllImport("rsvg-2")]
+               [DllImport(librsvg)]
                static extern IntPtr rsvg_handle_get_base_uri(IntPtr raw);
 
-               [DllImport("rsvg-2")]
+               [DllImport(librsvg)]
                static extern void rsvg_handle_set_dpi(IntPtr raw, double dpi);
 
                public double Dpi {
@@ -52,7 +52,7 @@ namespace Rsvg {
                        }
                }
 
-               [DllImport("rsvg-2")]
+               [DllImport(librsvg)]
                static extern void rsvg_handle_render_cairo(IntPtr raw, IntPtr cr);
 
                public void RenderCairo(Cairo.Context cr) {
@@ -61,14 +61,14 @@ namespace Rsvg {
                        }
                }
 
-               [DllImport("rsvg-2")]
+               [DllImport(librsvg)]
                static extern void rsvg_handle_set_dpi_x_y(IntPtr raw, double dpi_x, double dpi_y);
 
                public void SetDpiXY(double dpi_x, double dpi_y) {
                        rsvg_handle_set_dpi_x_y(Raw, dpi_x, dpi_y);
                }
 
-               [DllImport("rsvg-2")]
+               [DllImport(librsvg)]
                static extern void rsvg_handle_get_dimensions(IntPtr raw, IntPtr dimension_data);
 
                public Rsvg.DimensionData Dimensions {
@@ -82,7 +82,7 @@ namespace Rsvg {
                        }
                }
 
-               [DllImport("rsvg-2")]
+               [DllImport(librsvg)]
                static extern unsafe bool rsvg_handle_close(IntPtr raw, out IntPtr error);
 
                public unsafe bool Close() {
@@ -92,7 +92,7 @@ namespace Rsvg {
                        return raw_ret;
                }
 
-               [DllImport("rsvg-2")]
+               [DllImport(librsvg)]
                static extern IntPtr rsvg_handle_get_title(IntPtr raw);
 
                public string Title {
@@ -102,14 +102,14 @@ namespace Rsvg {
                        }
                }
 
-               [DllImport("rsvg-2")]
+               [DllImport(librsvg)]
                static extern void rsvg_handle_render_cairo_sub(IntPtr raw, IntPtr cr, string id);
 
                public void RenderCairoSub(Cairo.Context cr, string id) {
                        rsvg_handle_render_cairo_sub(Raw, cr == null ? IntPtr.Zero : cr.Handle, id);
                }
 
-               [DllImport("rsvg-2")]
+               [DllImport(librsvg)]
                static extern IntPtr rsvg_handle_get_metadata(IntPtr raw);
 
                public string Metadata {