1 #pragma warning disable CS1591
3 using System.Runtime.InteropServices;
4 using System.Collections.Generic;
6 using System.Threading;
7 using System.ComponentModel;
10 /// <summary>Low-level APIs for object that can lay their children out.
11 /// Used for containers (box, grid).</summary>
12 [Efl.IPackLayoutConcrete.NativeMethods]
13 public interface IPackLayout :
14 Efl.Eo.IWrapper, IDisposable
16 /// <summary>Requests EFL to call the <see cref="Efl.IPackLayout.UpdateLayout"/> method on this object.
17 /// This <see cref="Efl.IPackLayout.UpdateLayout"/> may be called asynchronously.</summary>
19 /// <summary>Implementation of this container's layout algorithm.
20 /// EFL will call this function whenever the contents of this container need to be re-laid out on the canvas.
22 /// This can be overriden to implement custom layout behaviors.</summary>
24 /// <summary>Sent after the layout was updated.</summary>
25 event EventHandler LayoutUpdatedEvt;
27 /// <summary>Low-level APIs for object that can lay their children out.
28 /// Used for containers (box, grid).</summary>
29 sealed public class IPackLayoutConcrete :
34 ///<summary>Pointer to the native class description.</summary>
35 public override System.IntPtr NativeClass
39 if (((object)this).GetType() == typeof(IPackLayoutConcrete))
41 return GetEflClassStatic();
45 return Efl.Eo.ClassRegister.klassFromType[((object)this).GetType()];
50 [System.Runtime.InteropServices.DllImport("libefl.so.1")] internal static extern System.IntPtr
51 efl_pack_layout_interface_get();
52 /// <summary>Initializes a new instance of the <see cref="IPackLayout"/> class.
53 /// Internal usage: This is used when interacting with C code and should not be used directly.</summary>
54 private IPackLayoutConcrete(System.IntPtr raw) : base(raw)
58 /// <summary>Sent after the layout was updated.</summary>
59 public event EventHandler LayoutUpdatedEvt
65 Efl.EventCb callerCb = (IntPtr data, ref Efl.Event.NativeStruct evt) =>
67 var obj = Efl.Eo.Globals.WrapperSupervisorPtrToManaged(data).Target;
70 EventArgs args = EventArgs.Empty;
73 value?.Invoke(obj, args);
77 Eina.Log.Error(e.ToString());
78 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
83 string key = "_EFL_PACK_EVENT_LAYOUT_UPDATED";
84 AddNativeEventHandler(efl.Libs.Efl, key, callerCb, value);
92 string key = "_EFL_PACK_EVENT_LAYOUT_UPDATED";
93 RemoveNativeEventHandler(efl.Libs.Efl, key, value);
97 ///<summary>Method to raise event LayoutUpdatedEvt.</summary>
98 public void OnLayoutUpdatedEvt(EventArgs e)
100 var key = "_EFL_PACK_EVENT_LAYOUT_UPDATED";
101 IntPtr desc = Efl.EventDescription.GetNative(efl.Libs.Efl, key);
102 if (desc == IntPtr.Zero)
104 Eina.Log.Error($"Failed to get native event {key}");
108 Efl.Eo.Globals.efl_event_callback_call(this.NativeHandle, desc, IntPtr.Zero);
110 /// <summary>Requests EFL to call the <see cref="Efl.IPackLayout.UpdateLayout"/> method on this object.
111 /// This <see cref="Efl.IPackLayout.UpdateLayout"/> may be called asynchronously.</summary>
112 public void LayoutRequest() {
113 Efl.IPackLayoutConcrete.NativeMethods.efl_pack_layout_request_ptr.Value.Delegate(this.NativeHandle);
114 Eina.Error.RaiseIfUnhandledException();
116 /// <summary>Implementation of this container's layout algorithm.
117 /// EFL will call this function whenever the contents of this container need to be re-laid out on the canvas.
119 /// This can be overriden to implement custom layout behaviors.</summary>
120 public void UpdateLayout() {
121 Efl.IPackLayoutConcrete.NativeMethods.efl_pack_layout_update_ptr.Value.Delegate(this.NativeHandle);
122 Eina.Error.RaiseIfUnhandledException();
124 private static IntPtr GetEflClassStatic()
126 return Efl.IPackLayoutConcrete.efl_pack_layout_interface_get();
128 /// <summary>Wrapper for native methods and virtual method delegates.
129 /// For internal use by generated code only.</summary>
130 public class NativeMethods : Efl.Eo.NativeClass
132 private static Efl.Eo.NativeModule Module = new Efl.Eo.NativeModule( efl.Libs.Efl);
133 /// <summary>Gets the list of Eo operations to override.</summary>
134 /// <returns>The list of Eo operations to be overload.</returns>
135 public override System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type type)
137 var descs = new System.Collections.Generic.List<Efl_Op_Description>();
138 var methods = Efl.Eo.Globals.GetUserMethods(type);
140 if (efl_pack_layout_request_static_delegate == null)
142 efl_pack_layout_request_static_delegate = new efl_pack_layout_request_delegate(layout_request);
145 if (methods.FirstOrDefault(m => m.Name == "LayoutRequest") != null)
147 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_pack_layout_request"), func = Marshal.GetFunctionPointerForDelegate(efl_pack_layout_request_static_delegate) });
150 if (efl_pack_layout_update_static_delegate == null)
152 efl_pack_layout_update_static_delegate = new efl_pack_layout_update_delegate(layout_update);
155 if (methods.FirstOrDefault(m => m.Name == "UpdateLayout") != null)
157 descs.Add(new Efl_Op_Description() {api_func = Efl.Eo.FunctionInterop.LoadFunctionPointer(Module.Module, "efl_pack_layout_update"), func = Marshal.GetFunctionPointerForDelegate(efl_pack_layout_update_static_delegate) });
162 /// <summary>Returns the Eo class for the native methods of this class.</summary>
163 /// <returns>The native class pointer.</returns>
164 public override IntPtr GetEflClass()
166 return Efl.IPackLayoutConcrete.efl_pack_layout_interface_get();
169 #pragma warning disable CA1707, CS1591, SA1300, SA1600
172 private delegate void efl_pack_layout_request_delegate(System.IntPtr obj, System.IntPtr pd);
175 public delegate void efl_pack_layout_request_api_delegate(System.IntPtr obj);
177 public static Efl.Eo.FunctionWrapper<efl_pack_layout_request_api_delegate> efl_pack_layout_request_ptr = new Efl.Eo.FunctionWrapper<efl_pack_layout_request_api_delegate>(Module, "efl_pack_layout_request");
179 private static void layout_request(System.IntPtr obj, System.IntPtr pd)
181 Eina.Log.Debug("function efl_pack_layout_request was called");
182 var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);
188 ((IPackLayout)ws.Target).LayoutRequest();
192 Eina.Log.Warning($"Callback error: {e.ToString()}");
193 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
200 efl_pack_layout_request_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
204 private static efl_pack_layout_request_delegate efl_pack_layout_request_static_delegate;
207 private delegate void efl_pack_layout_update_delegate(System.IntPtr obj, System.IntPtr pd);
210 public delegate void efl_pack_layout_update_api_delegate(System.IntPtr obj);
212 public static Efl.Eo.FunctionWrapper<efl_pack_layout_update_api_delegate> efl_pack_layout_update_ptr = new Efl.Eo.FunctionWrapper<efl_pack_layout_update_api_delegate>(Module, "efl_pack_layout_update");
214 private static void layout_update(System.IntPtr obj, System.IntPtr pd)
216 Eina.Log.Debug("function efl_pack_layout_update was called");
217 var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);
223 ((IPackLayout)ws.Target).UpdateLayout();
227 Eina.Log.Warning($"Callback error: {e.ToString()}");
228 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
235 efl_pack_layout_update_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
239 private static efl_pack_layout_update_delegate efl_pack_layout_update_static_delegate;
241 #pragma warning restore CA1707, CS1591, SA1300, SA1600