summaryrefslogtreecommitdiff
path: root/src/lib/eo/efl_object.eo
blob: 6049ceb29ac2295f8ef931f41c3a2e372187cbad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
import eina_types;

struct Efl.Event_Description {
    [[This struct holds the description of a specific event.]]
    name: string; [[name of the event.]]
    unfreezable: bool; [[$true if the event cannot be frozen.]]
    legacy_is: bool; [[Internal use: $true if a legacy event.]]
    restart: bool; [[$true if when the event is triggered again from a callback it'll start from where it was]]
}


type Efl.Callback_Priority : short;
[[
  Callback priority. Range is -32k - 32k. The lower the number, the higher the priority.

  This is used to insert an event handler relative to the existing stack of sorted event
  handlers according to that priority. All event handlers always have a priority. If not
  specified @Efl.Callback_Priority_Default is to be assumed.

  See @Efl.Callback_Priority_Before @Efl.Callback_Priority_Default  @Efl.Callback_Priority_After
 ]]

const Efl.Callback_Priority_Before : Efl.Callback_Priority = -100;
[[Slightly more prioritized than default.]]
const Efl.Callback_Priority_Default : Efl.Callback_Priority = 0;
[[Default priority.]]
const Efl.Callback_Priority_After : Efl.Callback_Priority = 100;
[[Slightly less prioritized than default.]]

abstract Efl.Object
{
   [[Abstract Efl object class]]
   eo_prefix: efl;

   methods {
      @property parent {
         [[The parent of an object.

           Parents keep references to their children. In order to
           delete objects which have parents you need to set parent to
           NULL or use efl_del(). This will both delete & unref
           the object).

           The Eo parent is conceptually user set. That means that a parent
           should not be changed behind the scenes in an unexpected way.

           For example:
           If you have a widget that has a box internally and
           when you 'swallow' a widget and the swallowed object ends up in
           the box, the parent should be the widget, not the box.
         ]]

         set {
         }
         get {
         }
         values {
            parent: Efl.Object @nullable; [[The new parent]]
         }
      }
      @property name {
         [[ The name of the object.

           Every object can have a string name. Names may not contain
           the following characters:
             / ? * [ ] ! \ :
           Using any of these in a name will result in undefined
           behavior later on. An empty string is considered the same as a
           NULL string or no string for the name.
         ]]
         set {
         }
         get {
         }
         values {
           name: string @nullable; [[The name]]
         }
      }
      @property comment {
         [[ A human readable comment for the object

           Every object can have a string comment. This is intended for developers
           and debugging. An empty string is considered the same as a NULL
           string or no string for the comment.
         ]]
         set {
         }
         get {
         }
         values {
           comment: string @nullable; [[The comment]]
         }
      }
      debug_name_override {
         [[ Build a read-only name for this object used for debugging.

            Multiple calls using efl_super() can be chained in order to build
            the entire debug name, from parent to child classes. In C the usual
            way to build the string is as follows:

            efl_debug_name_override(efl_super(obj, MY_CLASS), sb);
            eina_strbuf_append_printf(sb, "new_information");

            Usually more debug information should be added to $sb after
            calling the super function.

            @since 1.21
         ]]
         params {
            @in sb: ptr(Eina.Strbuf); [[A string buffer, must not be $null.]]
         }
      }
      @property event_global_freeze_count @class {
         get {
            [[Return freeze events of object.

              Return event freeze count.
            ]]
         }
         values {
            fcount: int; [[The event freeze count of the object]]
         }
      }
      @property event_freeze_count {
         get {
            [[Return freeze events of object.

              Return event freeze count.
            ]]
         }
         values {
            fcount: int; [[The event freeze count of the object]]
         }
      }
      @property finalized {
         [[True if the object is already finalized, otherwise false.]]
         get {
         }
         values {
            finalized: bool; [[$true if the object is finalized, $false otherwise]]
         }
      }
      @property invalidated {
         [[True if the object is already invalidated, otherwise false.]]
         get {
         }
         values {
            finalized: bool; [[$true if the object is invalidated, $false otherwise]]
         }
      }
      @property invalidating {
         [[True if the object is about to be invalidated, and the invalidation of the children is already happening.

           Note this is true before the invalidate call on the object.
         ]]
         get {
         }
         values {
            invalidating: bool; [[$true if the object is invalidating, $false otherwise]]
         }
      }
      provider_find @const {
        [[Searches upwards in the object tree for a provider which knows the given class/interface.

          The object from the provider will then be returned.
          The base implementation calls the provider_find function on the object parent,
          and returns its result. If no parent is present NULL is returned.
          Each implementation has to support this function by overriding
          it and returning itself if the interface matches the parameter.
          If this is not done the class cannot be found up in the object tree.
        ]]
        params {
          klass : const(Efl.Class); [[The class identifier to search for]]
        }
        return : Efl.Object; [[Object from the provider list]]
      }
      constructor {
         [[Call the object's constructor.

           Should not be used with #eo_do. Only use it with #eo_do_super.
         ]]
         return: Efl.Object; [[The new object created, can be NULL if aborting]]
      }
      destructor {
         [[Call the object's destructor.

           Should not be used with #efl_do. Only use it with #efl_do_super.
	   Will be triggered once #invalidate and #noref have been triggered.
         ]]
      }
      finalize {
         [[Called at the end of efl_add. Should not be called, just overridden.]]
         return: Efl.Object; [[The new object created, can be NULL if aborting]]
      }
      invalidate {
         [[Called when parent reference is lost/set to $NULL and switch the state of the object to invalidate.]]
      }
      noref {
         [[Triggered when no reference are keeping the object alive.

           The parent can be the last one keeping an object alive and so $noref can happen before $invalidate
           as it is only impacted by the ref/unref of the object.]]
      }
      name_find @const {
         [[Find a child object with the given name and return it.

           The search string can be a glob (shell style, using *). It can also
           specify class name in the format of "class:name" where ":"
           separates class and name. Both class and name can be globs.
           If the class is specified but the name is empty like "class:" then
           the search will match any object of that class.
         ]]
         params {
            @in search: string; [[The name search string]]
         }
         return: Efl.Object; [[The first object found]]
      }
      event_thaw {
         [[Thaw events of object.

           Allows event callbacks to be called for an object.
         ]]
      }
      event_freeze {
         [[Freeze events of object.

           Prevents event callbacks from being called for an object.
         ]]
      }
      event_global_thaw @class {
         [[Thaw events of object.

           Allows event callbacks be called for an object.
         ]]
      }
      event_global_freeze @class {
         [[Freeze events of object.

           Prevents event callbacks from being called for an object.
         ]]
      }
      event_callback_stop {
         [[Stop the current callback call.

           This stops the current callback call. Any other callbacks for the
           current event will not be called. This is useful when you want to
           filter out events. Just add higher priority events and call this
           under certain conditions to block a certain event.
         ]]
      }
      event_callback_forwarder_priority_add {
         [[Add an event callback forwarder that will make this object emit an event whenever another
         object ($source) emits it. The event is said to be forwarded from $source to this object.

         The event is unaffected on $source and behave like any other event being propagated on
         any object and will trigger all the handler registered on $source like nothing special
         happened.

         This allow object that hide internally another object to easily be able to propagate an event
         without the need to add custom handler.

         Note: The priority is used to make sure that you are intercepting the event when you expect
         by inserting a handler at the right position in the stack of event handler on the object that
         emit the event.]]
         params {
            @cref desc: Efl.Event_Description; [[The description of the event to listen to]]
            @in priority: Efl.Callback_Priority; [[The priority at which to insert the event forwarder handler
            in the existing list of handler on the source of event object. The lower the number, the higher
            the priority. As a shortcut @Efl.Callback_Priority_Before,
            @Efl.Callback_Priority_Default and @Efl.Callback_Priority_After can be used. See
            @Efl.Callback_Priority for more details.]]
            @in source: Efl.Object @nonull; [[The object which emits the initial event]]
         }
      }
      event_callback_forwarder_del {
         [[Remove an event callback forwarder for a specified event and object.]]
         params {
            @cref desc: Efl.Event_Description; [[The description of the event to listen to]]
            @in new_obj: Efl.Object @nonull; [[The object to emit events from]]
         }
      }
      children_iterator_new {
         [[Get an iterator on all childrens]]
         return: iterator<Efl.Object> @owned @warn_unused; [[Children iterator]]
      }
      composite_attach {
           [[Make an object a composite object of another.

             The class of comp_obj must be part of the extensions of the class of the parent.
             It isn't possible to attach more then 1 composite of the same class.
             This function also sets the parent of comp_obj to parent.

             See @.composite_detach, @.composite_part_is.
           ]]
           params {
                @in comp_obj: Efl.Object; [[the object that will be used to composite the parent.]]
           }
           return: bool; [[$true if successful. $false otherwise.]]
      }
      composite_detach {
           [[Detach a composite object from another object.

             This functions also sets the parent of comp_obj to $null.

             See @.composite_attach, @.composite_part_is.
           ]]
           params {
                @in comp_obj: Efl.Object; [[The object that will be removed from the parent.]]
           }
           return: bool; [[$true if successful. $false otherwise.]]
      }
      composite_part_is {
           [[Check if an object is part of a composite object.

             See @.composite_attach, @.composite_part_is.
           ]]
           return: bool; [[$true if it is. $false otherwise.]]
      }
      @property allow_parent_unref {
         [[Allow an object to be deleted by unref even if it has a parent.

           This simply hides the error message warning that an object being
           destroyed still has a parent. This property is false by default.

           In a normal object use case, when ownership of an object is given
           to a caller, said ownership should be released with efl_unref().
           If the object has a parent, this will print error messages, as
           $efl_unref() is stealing the ref from the parent.

           Warning: Use this function very carefully, unless you're absolutely
           sure of what you are doing.
         ]]
         values {
            allow: bool(false); [[Whether to allow $efl_unref() to zero
               even if @.parent is not $null.]]
         }
      }
   }
   implements {
        class.constructor;
        class.destructor;
   }
   events {
      del @hot: void; [[Object is being deleted.]]
      invalidate @hot: void; [[Object is being invalidated and loosing its parent.]]
      noref @hot: void; [[Object has lost its last reference, only parent relationship is keeping it alive.]]
      destruct @hot: void; [[Object has been fully destroyed. It can not be used
         beyond this point. This event should only serve to clean up any
         dangling pointer.]]
   }
}

struct Efl.Event {
    [[A parameter passed in event callbacks holding extra event parameters.

      This is the full event information passed to callbacks in C.
    ]]
    object: Efl.Object; [[The object the callback was called on.]]
    desc: const(ptr(Efl.Event_Description)); [[The event description.]]
    info: void_ptr; [[Extra event information passed by the event caller]]
}