diff --git a/Source/Libs/CairoSharp/NativeMethods.cs b/Source/Libs/CairoSharp/NativeMethods.cs index a77ba9b8a..4f2f02224 100644 --- a/Source/Libs/CairoSharp/NativeMethods.cs +++ b/Source/Libs/CairoSharp/NativeMethods.cs @@ -1027,6 +1027,10 @@ namespace Cairo internal delegate void d_cairo_surface_get_device_offset(IntPtr surface, out double x, out double y); internal static d_cairo_surface_get_device_offset cairo_surface_get_device_offset = FuncLoader.LoadFunction(FuncLoader.GetProcAddress(GLibrary.Load(Library.Cairo), "cairo_surface_get_device_offset")); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate void d_cairo_surface_get_device_scale(IntPtr surface, out double x, out double y); + internal static d_cairo_surface_get_device_scale cairo_surface_get_device_scale = FuncLoader.LoadFunction(FuncLoader.GetProcAddress(GLibrary.Load(Library.Cairo), "cairo_surface_get_device_scale")); + //[DllImport (cairo, CallingConvention=CallingConvention.Cdecl)] //internal static extern void cairo_surface_get_fallback_resolution (IntPtr surface, out double x_pixels_per_inch, out double y_pixels_per_inch); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] @@ -1065,6 +1069,11 @@ namespace Cairo [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate void d_cairo_surface_set_device_offset(IntPtr surface, double x, double y); internal static d_cairo_surface_set_device_offset cairo_surface_set_device_offset = FuncLoader.LoadFunction(FuncLoader.GetProcAddress(GLibrary.Load(Library.Cairo), "cairo_surface_set_device_offset")); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate void d_cairo_surface_set_device_scale(IntPtr surface, double x, double y); + internal static d_cairo_surface_set_device_scale cairo_surface_set_device_scale = FuncLoader.LoadFunction(FuncLoader.GetProcAddress(GLibrary.Load(Library.Cairo), "cairo_surface_set_device_scale")); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate void d_cairo_surface_set_fallback_resolution(IntPtr surface, double x, double y); internal static d_cairo_surface_set_fallback_resolution cairo_surface_set_fallback_resolution = FuncLoader.LoadFunction(FuncLoader.GetProcAddress(GLibrary.Load(Library.Cairo), "cairo_surface_set_fallback_resolution")); diff --git a/Source/Libs/CairoSharp/Surface.cs b/Source/Libs/CairoSharp/Surface.cs index 959230327..cd2bae8c8 100644 --- a/Source/Libs/CairoSharp/Surface.cs +++ b/Source/Libs/CairoSharp/Surface.cs @@ -205,6 +205,20 @@ namespace Cairo { } } + public PointD DeviceScale { + get { + CheckDisposed (); + double x, y; + NativeMethods.cairo_surface_get_device_scale (handle, out x, out y); + return new PointD(x, y); + } + + set { + CheckDisposed (); + NativeMethods.cairo_surface_set_device_scale (handle, value.X, value.Y); + } + } + [Obsolete ("Use Dispose()")] public void Destroy() { diff --git a/Source/Libs/GLibSharp/Idle.cs b/Source/Libs/GLibSharp/Idle.cs index db65c5205..51724dd19 100644 --- a/Source/Libs/GLibSharp/Idle.cs +++ b/Source/Libs/GLibSharp/Idle.cs @@ -73,19 +73,24 @@ namespace GLib { delegate uint d_g_idle_add_full(int priority, IdleHandlerInternal d, IntPtr data, DestroyNotify notify); static d_g_idle_add_full g_idle_add_full = FuncLoader.LoadFunction(FuncLoader.GetProcAddress(GLibrary.Load(Library.GLib), "g_idle_add_full")); - public static uint Add (IdleHandler hndlr) + public static uint Add (int priority, IdleHandler hndlr) { IdleProxy p = new IdleProxy (hndlr); lock (p) { var gch = GCHandle.Alloc(p); var userData = GCHandle.ToIntPtr(gch); - p.ID = g_idle_add_full (0, (IdleHandlerInternal) p.proxy_handler, userData, DestroyHelper.NotifyHandler); + p.ID = g_idle_add_full (priority, (IdleHandlerInternal) p.proxy_handler, userData, DestroyHelper.NotifyHandler); } return p.ID; } + public static uint Add (IdleHandler hndlr) + { + return Add ((int)Priority.DefaultIdle, hndlr); + } + public static void Remove (uint id) { Source.Remove (id); diff --git a/Source/Libs/GLibSharp/SList.cs b/Source/Libs/GLibSharp/SList.cs index 0b587fc12..c7c264df4 100644 --- a/Source/Libs/GLibSharp/SList.cs +++ b/Source/Libs/GLibSharp/SList.cs @@ -84,7 +84,7 @@ namespace GLib { public SList (IntPtr raw, System.Type element_type) : this (raw, element_type, false, false) {} - public SList (IntPtr raw, System.Type element_type, bool owned, bool elements_owned) : base (raw, element_type, false, false) {} + public SList (IntPtr raw, System.Type element_type, bool owned, bool elements_owned) : base (raw, element_type, owned, elements_owned) {} public SList (object[] members, System.Type element_type, bool owned, bool elements_owned) : this (IntPtr.Zero, element_type, owned, elements_owned) { diff --git a/Source/Libs/GdkSharp/PixbufAnimation.cs b/Source/Libs/GdkSharp/PixbufAnimation.cs index 721ebe91e..30f96b7e3 100644 --- a/Source/Libs/GdkSharp/PixbufAnimation.cs +++ b/Source/Libs/GdkSharp/PixbufAnimation.cs @@ -39,13 +39,21 @@ namespace Gdk { if (error != IntPtr.Zero) throw new GLib.GException(error); } - public PixbufAnimation (System.IO.Stream stream) : base (new PixbufLoader (stream).AnimationHandle) {} + public PixbufAnimation (System.IO.Stream stream) : base (IntPtr.Zero) + { + using (var pl = new PixbufLoader (stream)) { + Raw = pl.AnimationHandle; + } + } public PixbufAnimation (System.Reflection.Assembly assembly, string resource) : base (IntPtr.Zero) { if (assembly == null) assembly = System.Reflection.Assembly.GetCallingAssembly (); - Raw = new PixbufLoader (assembly, resource).AnimationHandle; + + using (var pl = new PixbufLoader (assembly, resource)) { + Raw = pl.AnimationHandle; + } } static public PixbufAnimation LoadFromResource (string resource) diff --git a/Source/Libs/GtkSharp/GtkSharp.metadata b/Source/Libs/GtkSharp/GtkSharp.metadata index eeaf32495..9e497d785 100644 --- a/Source/Libs/GtkSharp/GtkSharp.metadata +++ b/Source/Libs/GtkSharp/GtkSharp.metadata @@ -987,7 +987,8 @@ 1 1 - out + out + out /api/namespace/class[@cname='GtkGlobal'] /api/namespace/object[@cname='GtkStyle'] diff --git a/Source/Libs/PangoSharp/Layout.cs b/Source/Libs/PangoSharp/Layout.cs index b71fbc638..86e4b0102 100644 --- a/Source/Libs/PangoSharp/Layout.cs +++ b/Source/Libs/PangoSharp/Layout.cs @@ -55,23 +55,20 @@ namespace Pango { accel_char = GLib.Marshaller.GUnicharToChar (ucs4_accel_char); } [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - delegate void d_pango_layout_get_log_attrs(IntPtr raw, out IntPtr attrs, out int n_attrs); - static d_pango_layout_get_log_attrs pango_layout_get_log_attrs = FuncLoader.LoadFunction(FuncLoader.GetProcAddress(GLibrary.Load(Library.Pango), "pango_layout_get_log_attrs")); + delegate IntPtr d_pango_layout_get_log_attrs_readonly(IntPtr raw, out int n_attrs); + static d_pango_layout_get_log_attrs_readonly pango_layout_get_log_attrs_readonly = FuncLoader.LoadFunction(FuncLoader.GetProcAddress(GLibrary.Load(Library.Pango), "pango_layout_get_log_attrs_readonly")); public LogAttr [] LogAttrs { get { int count; - IntPtr array_ptr; - pango_layout_get_log_attrs (Handle, out array_ptr, out count); - if (array_ptr == IntPtr.Zero) + IntPtr array_ptr = pango_layout_get_log_attrs_readonly (Handle, out count); + if (array_ptr == IntPtr.Zero || count == 0) return new LogAttr [0]; - LogAttr [] result = new LogAttr [count]; - for (int i = 0; i < count; i++) { - IntPtr fam_ptr = Marshal.ReadIntPtr (array_ptr, i * IntPtr.Size); - result [i] = LogAttr.New (fam_ptr); - } - - GLib.Marshaller.Free (array_ptr); + LogAttr[] result = new LogAttr [count]; + int[] array = new int [count]; + Marshal.Copy(array_ptr, array, 0, count); + for (int i = 0; i < count; i++) + result[i] = new LogAttr ((uint)array[i]); return result; } } @@ -95,6 +92,36 @@ namespace Pango { pango_layout_set_markup (Handle, native_markup, -1); GLib.Marshaller.Free (native_markup); } + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate int d_pango_layout_get_direction(IntPtr raw, int index); + static d_pango_layout_get_direction pango_layout_get_direction = FuncLoader.LoadFunction(FuncLoader.GetProcAddress(GLibrary.Load(Library.Pango), "pango_layout_get_direction")); + + public Pango.Direction GetDirection(int index) + { + int raw_ret = pango_layout_get_direction(Handle, index); + return (Pango.Direction)raw_ret; + } + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate float d_pango_layout_get_line_spacing(IntPtr raw); + static d_pango_layout_get_line_spacing pango_layout_get_line_spacing = FuncLoader.LoadFunction(FuncLoader.GetProcAddress(GLibrary.Load(Library.Pango), "pango_layout_get_line_spacing")); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate void d_pango_layout_set_line_spacing(IntPtr raw, float factor); + static d_pango_layout_set_line_spacing pango_layout_set_line_spacing = FuncLoader.LoadFunction(FuncLoader.GetProcAddress(GLibrary.Load(Library.Pango), "pango_layout_set_line_spacing")); + + public float LineSpacing + { + get + { + float raw_ret = pango_layout_get_line_spacing(Handle); + return raw_ret; + } + set + { + pango_layout_set_line_spacing(Handle, value); + } + } } } - diff --git a/Source/Libs/PangoSharp/LayoutLine.cs b/Source/Libs/PangoSharp/LayoutLine.cs index ac16223a6..41ee39d79 100644 --- a/Source/Libs/PangoSharp/LayoutLine.cs +++ b/Source/Libs/PangoSharp/LayoutLine.cs @@ -22,34 +22,37 @@ namespace Pango { using System; + using System.Runtime.InteropServices; public partial class LayoutLine { -#if NOT_BROKEN [UnmanagedFunctionPointer(CallingConvention.Cdecl)] delegate void d_pango_layout_line_get_x_ranges(IntPtr raw, int start_index, int end_index, out IntPtr ranges_handle, out int n_ranges); static d_pango_layout_line_get_x_ranges pango_layout_line_get_x_ranges = FuncLoader.LoadFunction(FuncLoader.GetProcAddress(GLibrary.Load(Library.Pango), "pango_layout_line_get_x_ranges")); -#endif - public void GetXRanges(int start_index, int end_index, out int[][] ranges) + public int[] GetXRanges(int start_index, int end_index) { - // FIXME: this is broken - throw new NotImplementedException (); -#if NOT_BROKEN int count; IntPtr array_ptr; pango_layout_line_get_x_ranges(Handle, start_index, end_index, out array_ptr, out count); - ranges = new int[count] []; - for (int i = 0; i < count; i++) { - IntPtr tmp = new IntPtr (array_ptr + 2 * i * IntPtr.Size); - IntPtr rng_ptr = Marshal.ReadIntPtr (tmp); - IntPtr end_ptr = Marshal.ReadIntPtr (tmp, IntPtr.Size); - - } - Marshal.Copy (array_ptr, ranges, 0, count); + int[] array = new int[count * 2]; + Marshal.Copy(array_ptr, array, 0, count * 2); GLib.Marshaller.Free (array_ptr); -#endif + return array; + } + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + delegate void d_pango_layout_line_get_height(IntPtr raw, out int height); + static d_pango_layout_line_get_height pango_layout_line_get_height = FuncLoader.LoadFunction(FuncLoader.GetProcAddress(GLibrary.Load(Library.Pango), "pango_layout_line_get_height")); + + public int Height + { + get + { + int height; + pango_layout_line_get_height(Handle, out height); + return height; + } } } } - diff --git a/Source/Libs/PangoSharp/LogAttr.cs b/Source/Libs/PangoSharp/LogAttr.cs new file mode 100644 index 000000000..f74c38932 --- /dev/null +++ b/Source/Libs/PangoSharp/LogAttr.cs @@ -0,0 +1,25 @@ +namespace Pango { + + using System; + + public partial struct LogAttr { + + public LogAttr(uint bitfield) => _bitfield0 = bitfield; + public override string ToString() => Convert.ToString(_bitfield0 & 0x1FFF, 2).PadLeft(13, '0'); + + public uint Bitfield => _bitfield0; + public bool IsLineBreak => (_bitfield0 & (1 << 0)) != 0; + public bool IsMandatoryBreak => (_bitfield0 & (1 << 1)) != 0; + public bool IsCharBreak => (_bitfield0 & (1 << 2)) != 0; + public bool IsWhite => (_bitfield0 & (1 << 3)) != 0; + public bool IsCursorPosition => (_bitfield0 & (1 << 4)) != 0; + public bool IsWordStart => (_bitfield0 & (1 << 5)) != 0; + public bool IsWordEnd => (_bitfield0 & (1 << 6)) != 0; + public bool IsSentenceBoundary => (_bitfield0 & (1 << 7)) != 0; + public bool IsSentenceStart => (_bitfield0 & (1 << 8)) != 0; + public bool IsSentenceEnd => (_bitfield0 & (1 << 9)) != 0; + public bool BackspaceDeletesCharacter => (_bitfield0 & (1 << 10)) != 0; + public bool IsExpandableSpace => (_bitfield0 & (1 << 11)) != 0; + public bool IsWordBoundary => (_bitfield0 & (1 << 12)) != 0; + } +} diff --git a/Source/Libs/PangoSharp/PangoSharp.metadata b/Source/Libs/PangoSharp/PangoSharp.metadata index ec9df6bac..497d0be9f 100644 --- a/Source/Libs/PangoSharp/PangoSharp.metadata +++ b/Source/Libs/PangoSharp/PangoSharp.metadata @@ -40,6 +40,9 @@ 1 1 ref + PangoItem* + true + true 1 1 1 @@ -67,6 +70,7 @@ PangoLayoutLine* GetLinesReadOnly 1 + 1 out out out