Merge branch 'GtkSharp:develop' into style-properties

This commit is contained in:
zii-dmg 2021-06-17 17:39:57 +03:00 committed by GitHub
commit a58f601e9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 131 additions and 35 deletions

View File

@ -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<d_cairo_surface_get_device_offset>(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<d_cairo_surface_get_device_scale>(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<d_cairo_surface_set_device_offset>(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<d_cairo_surface_set_device_scale>(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<d_cairo_surface_set_fallback_resolution>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Cairo), "cairo_surface_set_fallback_resolution"));

View File

@ -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()
{

View File

@ -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<d_g_idle_add_full>(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);

View File

@ -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)
{

View File

@ -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)

View File

@ -987,7 +987,8 @@
<attr path="/api/namespace/struct[@cname='GtkTextLogAttrCache']" name="hidden">1</attr>
<attr path="/api/namespace/struct[@cname='GtkWindowGeometryInfo']" name="hidden">1</attr>
<attr path="/api/namespace/interface[@cname='GtkScrollable']/method[@name='GetBorder']/*/parameter[@name='border']" name="pass_as">out</attr>
<attr path="/api/namespace/interface[@cname='GtkScrollable']/method[@name='GetBorder']/*/parameter[@name='border']" name="pass_as">out</attr>
<attr path="/api/namespace/interface[@cname='GtkScrollable']/virtual_method[@name='GetBorder']/*/parameter[@name='border']" name="pass_as">out</attr>
<move-node path="/api/namespace/class[@cname='GtkBindings_']/method[@name='BindingsActivate']">/api/namespace/class[@cname='GtkGlobal']</move-node>
<move-node path="/api/namespace/class[@cname='GtkGlobal']/method[@name='PaintArrow']">/api/namespace/object[@cname='GtkStyle']</move-node>

View File

@ -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<d_pango_layout_get_log_attrs>(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<d_pango_layout_get_log_attrs_readonly>(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<d_pango_layout_get_direction>(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<d_pango_layout_get_line_spacing>(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<d_pango_layout_set_line_spacing>(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);
}
}
}
}

View File

@ -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<d_pango_layout_line_get_x_ranges>(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<d_pango_layout_line_get_height>(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;
}
}
}
}

View File

@ -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;
}
}

View File

@ -40,6 +40,9 @@
<attr path="/api/namespace/class[@cname='PangoCairo_']/method[@name='ContextGetFontOptions']" name="hidden">1</attr>
<attr path="/api/namespace/class[@cname='PangoCairo_']/method[@name='ContextSetFontOptions']" name="hidden">1</attr>
<attr path="/api/namespace/class[@cname='PangoGlobal']/method[@name='ExtentsToPixels']/*/*[@type='PangoRectangle*']" name="pass_as">ref</attr>
<attr path="/api/namespace/class[@cname='PangoGlobal']/method[@name='ItemizeWithBaseDir']/return-type" name="element_type">PangoItem*</attr>
<attr path="/api/namespace/class[@cname='PangoGlobal']/method[@name='ItemizeWithBaseDir']/return-type" name="owned">true</attr>
<attr path="/api/namespace/class[@cname='PangoGlobal']/method[@name='ItemizeWithBaseDir']/return-type" name="elements_owned">true</attr>
<attr path="/api/namespace/class[@cname='PangoGlobal']/method[@name='ParseMarkup']" name="hidden">1</attr>
<attr path="/api/namespace/class[@cname='PangoGlobal']/method[@name='ReadLine']" name="hidden">1</attr>
<attr path="/api/namespace/class[@cname='PangoGlobal']/method[@name='ReorderItems']" name="hidden">1</attr>
@ -67,6 +70,7 @@
<attr path="/api/namespace/object[@cname='PangoLayout']/method[@cname='pango_layout_get_lines_readonly']/return-type" name="element_type">PangoLayoutLine*</attr>
<attr path="/api/namespace/object[@cname='PangoLayout']/method[@name='GetLinesReadonly']" name="name">GetLinesReadOnly</attr>
<attr path="/api/namespace/object[@cname='PangoLayout']/method[@name='GetLogAttrs']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='PangoLayout']/method[@name='GetLogAttrsReadonly']" name="hidden">1</attr>
<attr path="/api/namespace/object[@cname='PangoLayout']/method[@name='GetPixelExtents']/*/*[@type='PangoRectangle*']" name="pass_as">out</attr>
<attr path="/api/namespace/object[@cname='PangoLayout']/method[@name='GetPixelSize']/*/*[@type='int*']" name="pass_as">out</attr>
<attr path="/api/namespace/object[@cname='PangoLayout']/method[@name='GetSize']/*/*[@type='int*']" name="pass_as">out</attr>