2 #pragma warning disable CS1591
4 using System.Runtime.InteropServices;
5 using System.Collections.Generic;
7 using System.Threading;
8 using System.ComponentModel;
11 /// <summary>Low-level APIs for object that can lay their children out.
12 /// Used for containers (box, grid).</summary>
13 /// <remarks>This is a <b>BETA</b> class. It can be modified or removed in the future. Do not use it for product development.</remarks>
14 [Efl.IPackLayoutConcrete.NativeMethods]
15 [Efl.Eo.BindingEntity]
16 public interface IPackLayout :
17 Efl.Eo.IWrapper, IDisposable
19 /// <summary>Requests EFL to call the <see cref="Efl.IPackLayout.UpdateLayout"/> method on this object.
20 /// This <see cref="Efl.IPackLayout.UpdateLayout"/> may be called asynchronously.</summary>
22 /// <summary>Implementation of this container's layout algorithm.
23 /// EFL will call this function whenever the contents of this container need to be re-laid out on the canvas.
25 /// This can be overriden to implement custom layout behaviors.</summary>
27 /// <summary>Sent after the layout was updated.</summary>
28 event EventHandler LayoutUpdatedEvt;
30 /// <summary>Low-level APIs for object that can lay their children out.
31 /// Used for containers (box, grid).</summary>
32 /// <remarks>This is a <b>BETA</b> class. It can be modified or removed in the future. Do not use it for product development.</remarks>
33 sealed public class IPackLayoutConcrete :
38 /// <summary>Pointer to the native class description.</summary>
39 public override System.IntPtr NativeClass
43 if (((object)this).GetType() == typeof(IPackLayoutConcrete))
45 return GetEflClassStatic();
49 return Efl.Eo.ClassRegister.klassFromType[((object)this).GetType()];
54 /// <summary>Subclasses should override this constructor if they are expected to be instantiated from native code.
55 /// Do not call this constructor directly.</summary>
56 /// <param name="ch">Tag struct storing the native handle of the object being constructed.</param>
57 private IPackLayoutConcrete(ConstructingHandle ch) : base(ch)
61 [System.Runtime.InteropServices.DllImport("libefl.so.1")] internal static extern System.IntPtr
62 efl_pack_layout_interface_get();
63 /// <summary>Initializes a new instance of the <see cref="IPackLayout"/> class.
64 /// Internal usage: This is used when interacting with C code and should not be used directly.</summary>
65 /// <param name="wh">The native pointer to be wrapped.</param>
66 private IPackLayoutConcrete(Efl.Eo.Globals.WrappingHandle wh) : base(wh)
70 /// <summary>Sent after the layout was updated.</summary>
71 public event EventHandler LayoutUpdatedEvt
75 lock (eflBindingEventLock)
77 Efl.EventCb callerCb = (IntPtr data, ref Efl.Event.NativeStruct evt) =>
79 var obj = Efl.Eo.Globals.WrapperSupervisorPtrToManaged(data).Target;
82 EventArgs args = EventArgs.Empty;
85 value?.Invoke(obj, args);
89 Eina.Log.Error(e.ToString());
90 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
95 string key = "_EFL_PACK_EVENT_LAYOUT_UPDATED";
96 AddNativeEventHandler(efl.Libs.Efl, key, callerCb, value);
102 lock (eflBindingEventLock)
104 string key = "_EFL_PACK_EVENT_LAYOUT_UPDATED";
105 RemoveNativeEventHandler(efl.Libs.Efl, key, value);
109 /// <summary>Method to raise event LayoutUpdatedEvt.</summary>
110 public void OnLayoutUpdatedEvt(EventArgs e)
112 var key = "_EFL_PACK_EVENT_LAYOUT_UPDATED";
113 IntPtr desc = Efl.EventDescription.GetNative(efl.Libs.Efl, key);
114 if (desc == IntPtr.Zero)
116 Eina.Log.Error($"Failed to get native event {key}");
120 Efl.Eo.Globals.efl_event_callback_call(this.NativeHandle, desc, IntPtr.Zero);
122 /// <summary>Requests EFL to call the <see cref="Efl.IPackLayout.UpdateLayout"/> method on this object.
123 /// This <see cref="Efl.IPackLayout.UpdateLayout"/> may be called asynchronously.</summary>
124 public void LayoutRequest() {
125 Efl.IPackLayoutConcrete.NativeMethods.efl_pack_layout_request_ptr.Value.Delegate(this.NativeHandle);
126 Eina.Error.RaiseIfUnhandledException();
128 /// <summary>Implementation of this container's layout algorithm.
129 /// EFL will call this function whenever the contents of this container need to be re-laid out on the canvas.
131 /// This can be overriden to implement custom layout behaviors.</summary>
132 public void UpdateLayout() {
133 Efl.IPackLayoutConcrete.NativeMethods.efl_pack_layout_update_ptr.Value.Delegate(this.NativeHandle);
134 Eina.Error.RaiseIfUnhandledException();
136 private static IntPtr GetEflClassStatic()
138 return Efl.IPackLayoutConcrete.efl_pack_layout_interface_get();
140 /// <summary>Wrapper for native methods and virtual method delegates.
141 /// For internal use by generated code only.</summary>
142 public new class NativeMethods : Efl.Eo.EoWrapper.NativeMethods
144 private static Efl.Eo.NativeModule Module = new Efl.Eo.NativeModule( efl.Libs.Efl);
145 /// <summary>Gets the list of Eo operations to override.</summary>
146 /// <returns>The list of Eo operations to be overload.</returns>
147 public override System.Collections.Generic.List<Efl_Op_Description> GetEoOps(System.Type type)
149 var descs = new System.Collections.Generic.List<Efl_Op_Description>();
150 var methods = Efl.Eo.Globals.GetUserMethods(type);
152 if (efl_pack_layout_request_static_delegate == null)
154 efl_pack_layout_request_static_delegate = new efl_pack_layout_request_delegate(layout_request);
157 if (methods.FirstOrDefault(m => m.Name == "LayoutRequest") != null)
159 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) });
162 if (efl_pack_layout_update_static_delegate == null)
164 efl_pack_layout_update_static_delegate = new efl_pack_layout_update_delegate(layout_update);
167 if (methods.FirstOrDefault(m => m.Name == "UpdateLayout") != null)
169 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) });
174 /// <summary>Returns the Eo class for the native methods of this class.</summary>
175 /// <returns>The native class pointer.</returns>
176 public override IntPtr GetEflClass()
178 return Efl.IPackLayoutConcrete.efl_pack_layout_interface_get();
181 #pragma warning disable CA1707, CS1591, SA1300, SA1600
184 private delegate void efl_pack_layout_request_delegate(System.IntPtr obj, System.IntPtr pd);
187 public delegate void efl_pack_layout_request_api_delegate(System.IntPtr obj);
189 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");
191 private static void layout_request(System.IntPtr obj, System.IntPtr pd)
193 Eina.Log.Debug("function efl_pack_layout_request was called");
194 var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);
200 ((IPackLayout)ws.Target).LayoutRequest();
204 Eina.Log.Warning($"Callback error: {e.ToString()}");
205 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
212 efl_pack_layout_request_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
216 private static efl_pack_layout_request_delegate efl_pack_layout_request_static_delegate;
219 private delegate void efl_pack_layout_update_delegate(System.IntPtr obj, System.IntPtr pd);
222 public delegate void efl_pack_layout_update_api_delegate(System.IntPtr obj);
224 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");
226 private static void layout_update(System.IntPtr obj, System.IntPtr pd)
228 Eina.Log.Debug("function efl_pack_layout_update was called");
229 var ws = Efl.Eo.Globals.GetWrapperSupervisor(obj);
235 ((IPackLayout)ws.Target).UpdateLayout();
239 Eina.Log.Warning($"Callback error: {e.ToString()}");
240 Eina.Error.Set(Eina.Error.UNHANDLED_EXCEPTION);
247 efl_pack_layout_update_ptr.Value.Delegate(Efl.Eo.Globals.efl_super(obj, Efl.Eo.Globals.efl_class_get(obj)));
251 private static efl_pack_layout_update_delegate efl_pack_layout_update_static_delegate;
253 #pragma warning restore CA1707, CS1591, SA1300, SA1600
260 #pragma warning disable CS1591
261 public static class EflIPackLayoutConcrete_ExtensionMethods {
263 #pragma warning restore CS1591