1 #pragma warning disable CS1591
3 using System.Runtime.InteropServices;
4 using System.Collections.Generic;
6 using System.Threading;
7 using System.ComponentModel;
12 /// <summary>Efl Canvas Pointer interface
13 /// (Since EFL 1.22)</summary>
14 [Efl.Canvas.IPointerConcrete.NativeMethods]
15 public interface IPointer :
16 Efl.Eo.IWrapper, IDisposable
18 /// <summary>Returns whether the mouse pointer is logically inside the canvas.
19 /// When this function is called it will return a value of either <c>false</c> or <c>true</c>, depending on whether a pointer,in or pointer,out event has been called previously.
21 /// A return value of <c>true</c> indicates the mouse is logically inside the canvas, and <c>false</c> implies it is logically outside the canvas.
23 /// A canvas begins with the mouse being assumed outside (<c>false</c>).
24 /// (Since EFL 1.22)</summary>
25 /// <param name="seat">The seat to consider, if <c>null</c> then the default seat will be used.</param>
26 /// <returns><c>true</c> if the mouse pointer is inside the canvas, <c>false</c> otherwise</returns>
27 bool GetPointerInside(Efl.Input.Device seat);
29 /// <summary>Efl Canvas Pointer interface
30 /// (Since EFL 1.22)</summary>
31 sealed public class IPointerConcrete :
36 ///<summary>Pointer to the native class description.</summary>
37 public System.IntPtr NativeClass
41 if (((object)this).GetType() == typeof(IPointerConcrete))
43 return GetEflClassStatic();
47 return Efl.Eo.ClassRegister.klassFromType[((object)this).GetType()];
52 private System.IntPtr handle;
53 ///<summary>Pointer to the native instance.</summary>
54 public System.IntPtr NativeHandle
56 get { return handle; }
59 [System.Runtime.InteropServices.DllImport(efl.Libs.Efl)] internal static extern System.IntPtr
60 efl_canvas_pointer_interface_get();
61 /// <summary>Initializes a new instance of the <see cref="IPointer"/> class.
62 /// Internal usage: This is used when interacting with C code and should not be used directly.</summary>
63 private IPointerConcrete(System.IntPtr raw)
67 ///<summary>Destructor.</summary>
73 ///<summary>Releases the underlying native instance.</summary>
74 private void Dispose(bool disposing)
76 if (handle != System.IntPtr.Zero)
81 IntPtr gcHandlePtr = IntPtr.Zero;
84 Efl.Eo.Globals.efl_mono_native_dispose(h, gcHandlePtr);
88 Monitor.Enter(Efl.All.InitLock);
89 if (Efl.All.MainLoopInitialized)
91 Efl.Eo.Globals.efl_mono_thread_safe_native_dispose(h, gcHandlePtr);
94 Monitor.Exit(Efl.All.InitLock);
100 ///<summary>Releases the underlying native instance.</summary>
101 public void Dispose()
104 GC.SuppressFinalize(this);
107 /// <summary>Verifies if the given object is equal to this one.</summary>
108 /// <param name="instance">The object to compare to.</param>
109 /// <returns>True if both objects point to the same native object.</returns>
110 public override bool Equals(object instance)
112 var other = instance as Efl.Object;
117 return this.NativeHandle == other.NativeHandle;
120 /// <summary>Gets the hash code for this object based on the native pointer it points to.</summary>
121 /// <returns>The value of the pointer, to be used as the hash code of this object.</returns>
122 public override int GetHashCode()
124 return this.NativeHandle.ToInt32();
127 /// <summary>Turns the native pointer into a string representation.</summary>
128 /// <returns>A string with the type and the native pointer for this object.</returns>
129 public override String ToString()
131 return $"{this.GetType().Name}@[{this.NativeHandle.ToInt32():x}]";
134 /// <summary>Returns whether the mouse pointer is logically inside the canvas.
135 /// When this function is called it will return a value of either <c>false</c> or <c>true</c>, depending on whether a pointer,in or pointer,out event has been called previously.
137 /// A return value of <c>true</c> indicates the mouse is logically inside the canvas, and <c>false</c> implies it is logically outside the canvas.
139 /// A canvas begins with the mouse being assumed outside (<c>false</c>).
140 /// (Since EFL 1.22)</summary>
141 /// <param name="seat">The seat to consider, if <c>null</c> then the default seat will be used.</param>
142 /// <returns><c>true</c> if the mouse pointer is inside the canvas, <c>false</c> otherwise</returns>
143 public bool GetPointerInside(Efl.Input.Device seat) {
144 var _ret_var = Efl.Canvas.IPointerConcrete.NativeMethods.efl_canvas_pointer_inside_get_ptr.Value.Delegate(this.NativeHandle,seat);
145 Eina.Error.RaiseIfUnhandledException();
148 private static IntPtr GetEflClassStatic()
150 return Efl.Canvas.IPointerConcrete.efl_canvas_pointer_interface_get();
152 /// <summary>Wrapper for native methods and virtual method delegates.
153 /// For internal use by generated code only.</summary>
154 public class NativeMethods : Efl.Eo.NativeClass
156 private static Efl.Eo.NativeModule Module = new Efl.Eo.NativeModule( efl.Libs.Efl);
157 /// <summary>Gets the list of Eo operations to override.</summary>
158 /// <returns>The list of Eo operations to be overload.</returns>
159 public override System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type type)
161 var descs = new System.Collections.Generic.List<Efl_Op_Description>();
162 var methods = Efl.Eo.Globals.GetUserMethods(type);
164 if (efl_canvas_pointer_inside_get_static_delegate == null)
166 efl_canvas_pointer_inside_get_static_delegate = new efl_canvas_pointer_inside_get_delegate(pointer_inside_get);
169 if (methods.FirstOrDefault(m => m.Name == "GetPointerInside") != null)
171 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_canvas_pointer_inside_get"), func = Marshal.GetFunctionPointerForDelegate(efl_canvas_pointer_inside_get_static_delegate) });
176 /// <summary>Returns the Eo class for the native methods of this class.</summary>
177 /// <returns>The native class pointer.</returns>
178 public override IntPtr GetEflClass()
180 return Efl.Canvas.IPointerConcrete.efl_canvas_pointer_interface_get();
183 #pragma warning disable CA1707, SA1300, SA1600
185 [return: MarshalAs(UnmanagedType.U1)]
186 private delegate bool efl_canvas_pointer_inside_get_delegate(System.IntPtr obj, System.IntPtr pd, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.MarshalEo<Efl.Eo.NonOwnTag>))] Efl.Input.Device seat);
188 [return: MarshalAs(UnmanagedType.U1)]
189 public delegate bool efl_canvas_pointer_inside_get_api_delegate(System.IntPtr obj, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Efl.Eo.MarshalEo<Efl.Eo.NonOwnTag>))] Efl.Input.Device seat);
191 public static Efl.Eo.FunctionWrapper<efl_canvas_pointer_inside_get_api_delegate> efl_canvas_pointer_inside_get_ptr = new Efl.Eo.FunctionWrapper<efl_canvas_pointer_inside_get_api_delegate>(Module, "efl_canvas_pointer_inside_get");
193 private static bool pointer_inside_get(System.IntPtr obj, System.IntPtr pd, Efl.Input.Device seat)
195 Eina.Log.Debug("function efl_canvas_pointer_inside_get was called");
196 Efl.Eo.IWrapper wrapper = Efl.Eo.Globals.PrivateDataGet(pd);
199 bool _ret_var = default(bool);
202 _ret_var = ((IPointer)wrapper).GetPointerInside(seat);
206 Eina.Log.Warning($"Callback error: {e.ToString()}");
207 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
215 return efl_canvas_pointer_inside_get_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)), seat);
219 private static efl_canvas_pointer_inside_get_delegate efl_canvas_pointer_inside_get_static_delegate;
221 #pragma warning restore CA1707, SA1300, SA1600