aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/edje/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/edje/src/lib')
-rw-r--r--libraries/edje/src/lib/Edje.h3926
-rw-r--r--libraries/edje/src/lib/Edje_Edit.h3539
-rw-r--r--libraries/edje/src/lib/Makefile.am140
-rw-r--r--libraries/edje/src/lib/Makefile.in810
-rw-r--r--libraries/edje/src/lib/edje_box_layout.c242
-rw-r--r--libraries/edje/src/lib/edje_cache.c570
-rw-r--r--libraries/edje/src/lib/edje_calc.c2801
-rw-r--r--libraries/edje/src/lib/edje_callbacks.c546
-rw-r--r--libraries/edje/src/lib/edje_container.c955
-rw-r--r--libraries/edje/src/lib/edje_container.h165
-rw-r--r--libraries/edje/src/lib/edje_convert.h143
-rw-r--r--libraries/edje/src/lib/edje_data.c877
-rw-r--r--libraries/edje/src/lib/edje_edit.c7829
-rw-r--r--libraries/edje/src/lib/edje_embryo.c3179
-rw-r--r--libraries/edje/src/lib/edje_entry.c3110
-rw-r--r--libraries/edje/src/lib/edje_external.c559
-rw-r--r--libraries/edje/src/lib/edje_load.c1525
-rw-r--r--libraries/edje/src/lib/edje_lua.c5150
-rw-r--r--libraries/edje/src/lib/edje_lua2.c4129
-rw-r--r--libraries/edje/src/lib/edje_lua_script_only.c59
-rw-r--r--libraries/edje/src/lib/edje_main.c274
-rw-r--r--libraries/edje/src/lib/edje_match.c814
-rw-r--r--libraries/edje/src/lib/edje_message_queue.c865
-rw-r--r--libraries/edje/src/lib/edje_misc.c1
-rw-r--r--libraries/edje/src/lib/edje_module.c154
-rw-r--r--libraries/edje/src/lib/edje_multisense.c408
-rw-r--r--libraries/edje/src/lib/edje_private.h2028
-rw-r--r--libraries/edje/src/lib/edje_program.c2090
-rw-r--r--libraries/edje/src/lib/edje_script_only.c643
-rw-r--r--libraries/edje/src/lib/edje_smart.c336
-rw-r--r--libraries/edje/src/lib/edje_text.c790
-rw-r--r--libraries/edje/src/lib/edje_textblock_styles.c424
-rw-r--r--libraries/edje/src/lib/edje_util.c4317
-rw-r--r--libraries/edje/src/lib/edje_var.c1093
34 files changed, 54491 insertions, 0 deletions
diff --git a/libraries/edje/src/lib/Edje.h b/libraries/edje/src/lib/Edje.h
new file mode 100644
index 0000000..c8094b4
--- /dev/null
+++ b/libraries/edje/src/lib/Edje.h
@@ -0,0 +1,3926 @@
1/**
2@brief Edje Graphical Design Library
3
4These routines are used for Edje.
5
6@mainpage Edje Library Documentation
7@version 1.1
8@date 2003-2011
9
10Please see the @ref authors page for contact details.
11
12
13
14
15
16
17
18@section intro What is Edje?
19
20Edje is a complex graphical design & layout library.
21
22It doesn't pretend to do containing and regular layout like a widget
23set, but it is the base for such components. Based on the requirements
24of Enlightenment 0.17, Edje should serve all the purposes of creating
25visual elements (borders of windows, buttons, scrollbars, etc.) and
26allow the designer the ability to animate, layout and control the look
27and feel of any program using Edje as its basic GUI constructor. This
28library allows for multiple collections of Layouts in one file,
29sharing the same image and font database and thus allowing a whole
30theme to be conveniently packaged into 1 file and shipped around.
31
32Edje separates the layout and behavior logic. Edje files ship with an
33image and font database, used by all the parts in all the collections
34to source graphical data. It has a directory of logical part names
35pointing to the part collection entry ID in the file (thus allowing
36for multiple logical names to point to the same part collection,
37allowing for the sharing of data between display elements). Each part
38collection consists of a list of visual parts, as well as a list of
39programs. A program is a conditionally run program that if a
40particular event occurs (a button is pressed, a mouse enters or leaves
41a part) will trigger an action that may affect other parts. In this
42way a part collection can be "programmed" via its file as to hilight
43buttons when the mouse passes over them or show hidden parts when a
44button is clicked somewhere etc. The actions performed in changing
45from one state to another are also allowed to transition over a period
46of time, allowing animation. Programs and animations can be run in
47"parallel".
48
49This separation and simplistic event driven style of programming can produce
50almost any look and feel one could want for basic visual elements. Anything
51more complex is likely the domain of an application or widget set that may
52use Edje as a convenient way of being able to configure parts of the display.
53
54For details of Edje's history, see the \ref history section.
55
56
57@section requirements What does Edje require?
58
59Edje requires fairly little on your system. to use the Edje runtime library
60you need:
61
62 - Evas (library)
63 - Ecore (library)
64 - Eet (library)
65 - Embryo (library)
66 - Eina (library)
67 - Lua 5.1 (library)
68
69Evas needs to be build with the JPEG, PNG and EET image loaders enabled at a
70minimum. You will also need the buffer engine (which requires the
71software_generic engine) as well.
72
73Ecore needs the ECORE, ECORE_EVAS and ECORE_X modules built at a minimum.
74It's suggested to build all the Ecore modules. You will beed the Buffer
75engine support built into Ecore_Evas for edje?_cc to function.
76
77
78@section compiling How to compile and test Edje
79
80Now you need to compile and install Edje.
81
82@verbatim
83 ./configure
84 make
85 sudo make install
86@endverbatim
87
88You now have it installed and ready to go, but you need input
89data. There are lots of examples in SVN, the best one is
90Enlightenment's own theme file.
91
92You may use different tools to edit and view the generated ".edj"
93files, for instance:
94
95 - edje_player (provided by Edje)
96 - editje (http://trac.enlightenment.org/e/wiki/Editje)
97 - edje_viewer (http://trac.enlightenment.org/e/wiki/Edje_Viewer)
98
99
100@section details So how does this all work?
101
102Edje internally holds a geometry state machine and state graph of what is
103visible, not, where, at what size, with what colors etc. This is described
104to Edje from an Edje .edj file containing this information. These files can
105be produced by using edje_cc to take a text file (a .edc file) and "compile"
106an output .edj file that contains this information, images and any other
107data needed.
108
109The application using Edje will then create an object in its Evas
110canvas and set the bundle file to use, specifying the @b group name to
111use. Edje will load such information and create all the required
112children objects with the specified properties as defined in each @b
113part of the given group. See the following annotated example:
114
115@code
116
117#include <Eina.h>
118#include <Evas.h>
119#include <Ecore.h>
120#include <Ecore_Evas.h>
121#include <Edje.h>
122
123#define WIDTH 320
124#define HEIGHT 240
125
126static Evas_Object *create_my_group(Evas *canvas, const char *text)
127{
128 Evas_Object *edje;
129
130 edje = edje_object_add(canvas);
131 if (!edje)
132 {
133 EINA_LOG_CRIT("could not create edje object!");
134 return NULL;
135 }
136
137 if (!edje_object_file_set(edje, "edje_example.edj", "my_group"))
138 {
139 int err = edje_object_load_error_get(edje);
140 const char *errmsg = edje_load_error_str(err);
141 EINA_LOG_ERR("could not load 'my_group' from edje_example.edj: %s",
142 errmsg);
143
144 evas_object_del(edje);
145 return NULL;
146 }
147
148 if (text)
149 {
150 if (!edje_object_part_text_set(edje, "text", text))
151 {
152 EINA_LOG_WARN("could not set the text. "
153 "Maybe part 'text' does not exist?");
154 }
155 }
156
157 evas_object_move(edje, 0, 0);
158 evas_object_resize(edje, WIDTH, HEIGHT);
159 evas_object_show(edje);
160 return edje;
161}
162
163int main(int argc, char *argv[])
164{
165 Ecore_Evas *window;
166 Evas *canvas;
167 Evas_Object *edje;
168 const char *text;
169
170 eina_init();
171 evas_init();
172 ecore_init();
173 ecore_evas_init();
174 edje_init();
175
176 window = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
177 if (!window)
178 {
179 EINA_LOG_CRIT("could not create window.");
180 return -1;
181 }
182 canvas = ecore_evas_get(window);
183
184 text = (argc > 1) ? argv[1] : NULL;
185
186 edje = create_my_group(canvas, text);
187 if (!edje)
188 return -2;
189
190 ecore_evas_show(window);
191 ecore_main_loop_begin();
192
193 evas_object_del(edje);
194 ecore_evas_free(window);
195
196 return 0;
197}
198@endcode
199
200It requires the following source Edje file:
201@code
202// compile: edje_cc edje_example.edc
203collections {
204 group {
205 name: "my_group"; // must be the same as in edje_example.c
206
207 parts {
208 part {
209 name: "background";
210 type: RECT; // plain boring rectangle
211 mouse_events: 0; // we don't need any mouse event on the background
212
213 // just one state "default"
214 description {
215 state: "default" 0.0; // must always exist
216 color: 255 255 255 255; // white
217
218 // define part coordinates:
219
220 rel1 { // top-left point at (0, 0) [WIDTH * 0 + 0, HEIGHT * 0 + 0]
221 relative: 0.0 0.0;
222 offset: 0 0;
223 }
224 rel2 { // bottom-right point at (WIDTH * 1.0 - 1, HEIGHT * 1.0 - 1)
225 relative: 1.0 1.0;
226 offset: -1 -1;
227 }
228 }
229 }
230
231 part {
232 name: "text";
233 type: TEXT;
234 mouse_events: 1; // we want to change the color on mouse-over
235
236 // 2 states, one "default" and another "over" to be used
237 // on mouse over effect
238
239 description {
240 state: "default" 0.0;
241 color: 255 0 0 255; // red
242
243 // define part coordinates:
244
245 rel1 { // top-left at (WIDTH * 0.1 + 5, HEIGHT * 0.2 + 10)
246 relative: 0.1 0.2;
247 offset: 5 10;
248 }
249 rel2 { // bottom-right at (WIDTH * 0.9 - 6, HEIGHT * 0.8 - 11)
250 relative: 0.9 0.8;
251 offset: -6 -11;
252 }
253
254 // define text specific state details
255 text {
256 font: "Sans"; // using fontconfig name!
257 size: 10;
258 text: "hello world";
259 }
260 }
261
262 description {
263 state: "over" 0.0;
264 inherit: "default" 0.0; // copy everything from "default" at this point
265
266 color: 0 255 0 255; // override color, now it is green
267 }
268 }
269
270 // do programs to change color on text mouse in/out (over)
271 programs {
272 program {
273 // what triggers this program:
274 signal: "mouse,in";
275 source: "text";
276
277 // what this program does:
278 action: STATE_SET "over" 0.0;
279 target: "text";
280
281 // do the state-set in a nice interpolation animation
282 // using linear time in 0.1 second
283 transition: LINEAR 0.1;
284 }
285
286 program {
287 // what triggers this program:
288 signal: "mouse,out";
289 source: "text";
290
291 // what this program does:
292 action: STATE_SET "default" 0.0;
293 target: "text";
294
295 // do the state-set in a nice interpolation animation
296 // using linear time in 0.1 second
297 transition: LINEAR 0.1;
298 }
299 }
300 }
301 }
302}
303@endcode
304
305
306One should save these files as edje_example.c and edje_example.edc then:
307@verbatim
308gcc -o edje_example edje_example.c `pkg-config --cflags --libs eina evas ecore ecore-evas edje`
309edje_cc edje_example.edc
310
311./edje_example "some text"
312@endverbatim
313
314Although simple, this example illustrates that animations and state
315changes can be done from the Edje file itself without any requirement
316in the C application.
317
318Before digging into changing or creating your own Edje source (edc)
319files, read the @ref edcref.
320
321
322
323@section history Edje History
324
325It's a sequel to "Ebits" which has serviced the needs of Enlightenment
326development for early version 0.17. The original design parameters under
327which Ebits came about were a lot more restricted than the resulting
328use of them, thus Edje was born.
329
330Edje is a more complex layout engine compared to Ebits. It doesn't
331pretend to do containing and regular layout like a widget set. It
332still inherits the more simplistic layout ideas behind Ebits, but it
333now does them a lot more cleanly, allowing for easy expansion, and the
334ability to cover much more ground than Ebits ever could. For the
335purposes of Enlightenment 0.17, Edje was conceived to serve all the
336purposes of creating visual elements (borders of windows, buttons,
337scrollbars, etc.) and allow the designer the ability to animate,
338layout and control the look and feel of any program using Edje as its
339basic GUI constructor.
340
341Unlike Ebits, Edje separates the layout and behavior logic.
342
343
344
345@section Edje_Examples Examples on Edje's usage
346
347What follows is a list with various commented examples, covering a great
348part of Edje's API:
349
350- @ref Example_Edje_Basics
351- @ref tutorial_edje_swallow
352- @ref tutorial_edje_table
353- @ref tutorial_edje_box
354- @ref tutorial_edje_box2
355- @ref tutorial_edje_color_class
356- @ref tutorial_edje_animations
357- @ref Example_Edje_Signals_Messages
358
359
360*/
361
362/**
363@page authors Authors
364@author Carsten Haitzler <raster@@rasterman.com>
365@author Tilman Sauerbeck (tilman at code-monkey de)
366@author ZigsMcKenzie <zigsmckenzie@@gmail.com>
367@author Cedric BAIL <cedric.bail@@free.fr>
368@author Brian Mattern <rephorm@@rephorm.com>
369@author Mathieu Taillefumier <mathieu.taillefumier@@free.fr>
370@author Tristan <blunderer@@gmail.com>
371@author Gustavo Lima Chaves <glima@@profusion.mobi>
372@author Bruno Dilly <bdilly@@profusion.mobi>
373@author Fabiano Fidêncio <fidencio@@profusion.mobi>
374@author Jihoon Kim <jihoon48.kim@@samsung.com>
375@author Tiago Falcão <tiago@@profusion.mobi>
376@author Davide Andreoli <dave@@gurumeditation.it>
377@author Sebastian Dransfeld <sd@@tango.flipp.net>
378@author Tom Hacohen <tom@@stosb.com>
379@author Aharon Hillel <a.hillel@@partner.samsung.com>
380
381Please contact <enlightenment-devel@lists.sourceforge.net> to get in
382contact with the developers and maintainers.
383*/
384
385
386/**
387
388@example embryo_custom_state.edc
389This example show how to create a custom state from embryo. Clicking on the
3903 labels will rotate the object in the given direction.
391
392@example embryo_pong.edc
393Super-simple Pong implementation in pure embryo.
394
395@example embryo_run_program.edc
396This example show how to run an edje program from embryo code.
397
398@example embryo_set_state.edc
399This example show how to change the state of a part from embryo code.
400
401@example embryo_set_text.edc
402This example show how to set the text in TEXT part from embryo code.
403
404@example embryo_timer.edc
405This example show the usage of timers in embryo.
406
407@example external_elm_anchorblock.edc
408This example use an elementary anchorblock and a button to animate the text.
409
410@example external_elm_button.edc
411This example create some elementary buttons and do some actions on user click.
412
413@example external_elm_check.edc
414This example show EXTERNAL checkbox in action.
415
416@example external_elm_panes.edc
417This example show EXTERNAL elementary panes in action.
418
419@example external_emotion_elm.edc
420Super-concise video player example using Edje/Emotion/Elementary.
421
422@example lua_script.edc
423This example show the usage of lua scripting to create and animate some
424objects in the canvas.
425
426@example toggle_using_filter.edc
427This example show how to toggle the state of a part using the 'filter'
428param in edje programs
429
430*/
431
432#ifndef _EDJE_H
433#define _EDJE_H
434
435#ifndef _MSC_VER
436# include <stdint.h>
437#endif
438#include <math.h>
439#include <float.h>
440#include <limits.h>
441
442#include <Evas.h>
443
444#ifdef EAPI
445# undef EAPI
446#endif
447
448#ifdef _WIN32
449# ifdef EFL_EDJE_BUILD
450# ifdef DLL_EXPORT
451# define EAPI __declspec(dllexport)
452# else
453# define EAPI
454# endif /* ! DLL_EXPORT */
455# else
456# define EAPI __declspec(dllimport)
457# endif /* ! EFL_EDJE_BUILD */
458#else
459# ifdef __GNUC__
460# if __GNUC__ >= 4
461# define EAPI __attribute__ ((visibility("default")))
462# else
463# define EAPI
464# endif
465# else
466# define EAPI
467# endif
468#endif
469
470#ifdef __cplusplus
471extern "C" {
472#endif
473
474#define EDJE_VERSION_MAJOR 1
475#define EDJE_VERSION_MINOR 0
476
477 typedef struct _Edje_Version
478 {
479 int major;
480 int minor;
481 int micro;
482 int revision;
483 } Edje_Version;
484
485 EAPI extern Edje_Version *edje_version;
486
487/**
488 * @file Edje.h
489 * @brief Edje Graphical Design Library
490 *
491 * These routines are used for Edje.
492 */
493
494/**
495 * Identifiers of Edje message types, which can be sent back and forth
496 * code and a given Edje object's theme file/group.
497 *
498 * @see edje_object_message_send()
499 * @see edje_object_message_handler_set()
500 */
501typedef enum _Edje_Message_Type
502{
503 EDJE_MESSAGE_NONE = 0,
504
505 EDJE_MESSAGE_SIGNAL = 1, /* DONT USE THIS */
506
507 EDJE_MESSAGE_STRING = 2, /**< A message with a string as value. Use #Edje_Message_String structs as message body, for this type. */
508 EDJE_MESSAGE_INT = 3, /**< A message with an integer number as value. Use #Edje_Message_Int structs as message body, for this type. */
509 EDJE_MESSAGE_FLOAT = 4, /**< A message with a floating pointer number as value. Use #Edje_Message_Float structs as message body, for this type. */
510
511 EDJE_MESSAGE_STRING_SET = 5, /**< A message with a list of strings as value. Use #Edje_Message_String_Set structs as message body, for this type. */
512 EDJE_MESSAGE_INT_SET = 6, /**< A message with a list of integer numbers as value. Use #Edje_Message_Int_Set structs as message body, for this type. */
513 EDJE_MESSAGE_FLOAT_SET = 7, /**< A message with a list of floating point numbers as value. Use #Edje_Message_Float_Set structs as message body, for this type. */
514
515 EDJE_MESSAGE_STRING_INT = 8, /**< A message with a struct containing a string and an integer number as value. Use #Edje_Message_String_Int structs as message body, for this type. */
516 EDJE_MESSAGE_STRING_FLOAT = 9, /**< A message with a struct containing a string and a floating point number as value. Use #Edje_Message_String_Float structs as message body, for this type. */
517
518 EDJE_MESSAGE_STRING_INT_SET = 10, /**< A message with a struct containing a string and list of integer numbers as value. Use #Edje_Message_String_Int_Set structs as message body, for this type. */
519 EDJE_MESSAGE_STRING_FLOAT_SET = 11 /**< A message with a struct containing a string and list of floating point numbers as value. Use #Edje_Message_String_Float_Set structs as message body, for this type. */
520} Edje_Message_Type;
521
522typedef enum _Edje_Aspect_Control
523{
524 EDJE_ASPECT_CONTROL_NONE = 0,
525 EDJE_ASPECT_CONTROL_NEITHER = 1,
526 EDJE_ASPECT_CONTROL_HORIZONTAL = 2,
527 EDJE_ASPECT_CONTROL_VERTICAL = 3,
528 EDJE_ASPECT_CONTROL_BOTH = 4
529} Edje_Aspect_Control;
530
531typedef enum _Edje_Object_Table_Homogeneous_Mode
532{
533 EDJE_OBJECT_TABLE_HOMOGENEOUS_NONE = 0,
534 EDJE_OBJECT_TABLE_HOMOGENEOUS_TABLE = 1,
535 EDJE_OBJECT_TABLE_HOMOGENEOUS_ITEM = 2
536} Edje_Object_Table_Homogeneous_Mode;
537
538typedef enum _Edje_Part_Type
539{
540 EDJE_PART_TYPE_NONE = 0,
541 EDJE_PART_TYPE_RECTANGLE = 1,
542 EDJE_PART_TYPE_TEXT = 2,
543 EDJE_PART_TYPE_IMAGE = 3,
544 EDJE_PART_TYPE_SWALLOW = 4,
545 EDJE_PART_TYPE_TEXTBLOCK = 5,
546 EDJE_PART_TYPE_GRADIENT = 6,
547 EDJE_PART_TYPE_GROUP = 7,
548 EDJE_PART_TYPE_BOX = 8,
549 EDJE_PART_TYPE_TABLE = 9,
550 EDJE_PART_TYPE_EXTERNAL = 10,
551 EDJE_PART_TYPE_PROXY = 11,
552 EDJE_PART_TYPE_LAST = 12
553} Edje_Part_Type;
554
555typedef enum _Edje_Text_Effect
556{
557#define EDJE_TEXT_EFFECT_MASK_BASIC 0xf
558#define EDJE_TEXT_EFFECT_BASIC_SET(x, s) \
559 do { x = ((x) & ~EDJE_TEXT_EFFECT_MASK_BASIC) | (s); } while (0)
560 EDJE_TEXT_EFFECT_NONE = 0,
561 EDJE_TEXT_EFFECT_PLAIN = 1,
562 EDJE_TEXT_EFFECT_OUTLINE = 2,
563 EDJE_TEXT_EFFECT_SOFT_OUTLINE = 3,
564 EDJE_TEXT_EFFECT_SHADOW = 4,
565 EDJE_TEXT_EFFECT_SOFT_SHADOW = 5,
566 EDJE_TEXT_EFFECT_OUTLINE_SHADOW = 6,
567 EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW = 7,
568 EDJE_TEXT_EFFECT_FAR_SHADOW = 8,
569 EDJE_TEXT_EFFECT_FAR_SOFT_SHADOW = 9,
570 EDJE_TEXT_EFFECT_GLOW = 10,
571
572 EDJE_TEXT_EFFECT_LAST = 11,
573
574#define EDJE_TEXT_EFFECT_MASK_SHADOW_DIRECTION (0x7 << 4)
575#define EDJE_TEXT_EFFECT_SHADOW_DIRECTION_SET(x, s) \
576 do { x = ((x) & ~EDJE_TEXT_EFFECT_MASK_SHADOW_DIRECTION) | (s); } while (0)
577 EDJE_TEXT_EFFECT_SHADOW_DIRECTION_BOTTOM_RIGHT = (0x0 << 4),
578 EDJE_TEXT_EFFECT_SHADOW_DIRECTION_BOTTOM = (0x1 << 4),
579 EDJE_TEXT_EFFECT_SHADOW_DIRECTION_BOTTOM_LEFT = (0x2 << 4),
580 EDJE_TEXT_EFFECT_SHADOW_DIRECTION_LEFT = (0x3 << 4),
581 EDJE_TEXT_EFFECT_SHADOW_DIRECTION_TOP_LEFT = (0x4 << 4),
582 EDJE_TEXT_EFFECT_SHADOW_DIRECTION_TOP = (0x5 << 4),
583 EDJE_TEXT_EFFECT_SHADOW_DIRECTION_TOP_RIGHT = (0x6 << 4),
584 EDJE_TEXT_EFFECT_SHADOW_DIRECTION_RIGHT = (0x7 << 4)
585} Edje_Text_Effect;
586
587typedef enum _Edje_Action_Type
588{
589 EDJE_ACTION_TYPE_NONE = 0,
590 EDJE_ACTION_TYPE_STATE_SET = 1,
591 EDJE_ACTION_TYPE_ACTION_STOP = 2,
592 EDJE_ACTION_TYPE_SIGNAL_EMIT = 3,
593 EDJE_ACTION_TYPE_DRAG_VAL_SET = 4,
594 EDJE_ACTION_TYPE_DRAG_VAL_STEP = 5,
595 EDJE_ACTION_TYPE_DRAG_VAL_PAGE = 6,
596 EDJE_ACTION_TYPE_SCRIPT = 7,
597 EDJE_ACTION_TYPE_FOCUS_SET = 8,
598 EDJE_ACTION_TYPE_RESERVED00 = 9,
599 EDJE_ACTION_TYPE_FOCUS_OBJECT = 10,
600 EDJE_ACTION_TYPE_PARAM_COPY = 11,
601 EDJE_ACTION_TYPE_PARAM_SET = 12,
602 EDJE_ACTION_TYPE_SOUND_SAMPLE = 13, /**< @since 1.1 */
603 EDJE_ACTION_TYPE_SOUND_TONE = 14, /**< @since 1.1 */
604 EDJE_ACTION_TYPE_LAST = 15
605} Edje_Action_Type;
606
607typedef enum _Edje_Tween_Mode
608{
609 EDJE_TWEEN_MODE_NONE = 0,
610 EDJE_TWEEN_MODE_LINEAR = 1,
611 EDJE_TWEEN_MODE_SINUSOIDAL = 2,
612 EDJE_TWEEN_MODE_ACCELERATE = 3,
613 EDJE_TWEEN_MODE_DECELERATE = 4,
614 EDJE_TWEEN_MODE_ACCELERATE_FACTOR = 5,
615 EDJE_TWEEN_MODE_DECELERATE_FACTOR = 6,
616 EDJE_TWEEN_MODE_SINUSOIDAL_FACTOR = 7,
617 EDJE_TWEEN_MODE_DIVISOR_INTERP = 8,
618 EDJE_TWEEN_MODE_BOUNCE = 9,
619 EDJE_TWEEN_MODE_SPRING = 10,
620 EDJE_TWEEN_MODE_LAST = 11,
621 EDJE_TWEEN_MODE_MASK = 0xff,
622 EDJE_TWEEN_MODE_OPT_FROM_CURRENT = (1 << 31)
623} Edje_Tween_Mode;
624
625typedef enum _Edje_Cursor
626{
627 EDJE_CURSOR_MAIN,
628 EDJE_CURSOR_SELECTION_BEGIN,
629 EDJE_CURSOR_SELECTION_END,
630 EDJE_CURSOR_PREEDIT_START,
631 EDJE_CURSOR_PREEDIT_END,
632 EDJE_CURSOR_USER,
633 EDJE_CURSOR_USER_EXTRA,
634 // more later
635} Edje_Cursor;
636
637struct _Edje_Entry_Change_Info
638{
639 union {
640 struct {
641 const char *content;
642 size_t pos;
643 size_t plain_length; /* Number of cursor positions represented
644 in content. */
645 } insert;
646 struct {
647 const char *content;
648 size_t start, end;
649 } del;
650 } change;
651 Eina_Bool insert : 1; /**< True if the "change" union's "insert" is valid */
652 Eina_Bool merge : 1; /**< True if can be merged with the previous one. Used for example with insertion when something is already selected. */
653};
654
655/**
656 * @since 1.1.0
657 */
658typedef struct _Edje_Entry_Change_Info Edje_Entry_Change_Info;
659
660typedef struct _Edje_Message_String Edje_Message_String;
661typedef struct _Edje_Message_Int Edje_Message_Int;
662typedef struct _Edje_Message_Float Edje_Message_Float;
663typedef struct _Edje_Message_String_Set Edje_Message_String_Set;
664typedef struct _Edje_Message_Int_Set Edje_Message_Int_Set;
665typedef struct _Edje_Message_Float_Set Edje_Message_Float_Set;
666typedef struct _Edje_Message_String_Int Edje_Message_String_Int;
667typedef struct _Edje_Message_String_Float Edje_Message_String_Float;
668typedef struct _Edje_Message_String_Int_Set Edje_Message_String_Int_Set;
669typedef struct _Edje_Message_String_Float_Set Edje_Message_String_Float_Set;
670
671struct _Edje_Message_String
672{
673 char *str; /**< The message's string pointer */
674}; /**< Structure passed as value on #EDJE_MESSAGE_STRING messages. The string in it is automatically freed be Edje if passed to you by Edje */
675
676struct _Edje_Message_Int
677{
678 int val; /**< The message's value */
679}; /**< Structure passed as value on #EDJE_MESSAGE_INT messages */
680
681struct _Edje_Message_Float
682{
683 double val; /**< The message's value */
684}; /**< Structure passed as value on #EDJE_MESSAGE_FLOAT messages */
685
686struct _Edje_Message_String_Set
687{
688 int count; /**< The size of the message's array (may be greater than 1) */
689 char *str[1]; /**< The message's @b array of string pointers */
690}; /**< Structure passed as value on #EDJE_MESSAGE_STRING_SET messages. The array in it is automatically freed be Edje if passed to you by Edje */
691
692struct _Edje_Message_Int_Set
693{
694 int count; /**< The size of the message's array (may be greater than 1) */
695 int val[1]; /**< The message's @b array of integers */
696}; /**< Structure passed as value on #EDJE_MESSAGE_INT_SET messages. The array in it is automatically freed be Edje if passed to you by Edje */
697
698struct _Edje_Message_Float_Set
699{
700 int count; /**< The size of the message's array (may be greater than 1) */
701 double val[1]; /**< The message's @b array of floats */
702}; /**< Structure passed as value on #EDJE_MESSAGE_FLOAT_SET messages. The array in it is automatically freed be Edje if passed to you by Edje */
703
704struct _Edje_Message_String_Int
705{
706 char *str; /**< The message's string value */
707 int val; /**< The message's integer value */
708}; /**< Structure passed as value on #EDJE_MESSAGE_STRING_INT messages. The string in it is automatically freed be Edje if passed to you by Edje */
709
710struct _Edje_Message_String_Float
711{
712 char *str; /**< The message's string value */
713 double val; /**< The message's float value */
714}; /**< Structure passed as value on #EDJE_MESSAGE_STRING_FLOAT messages. The string in it is automatically freed be Edje if passed to you by Edje */
715
716struct _Edje_Message_String_Int_Set
717{
718 char *str; /**< The message's string value */
719 int count; /**< The size of the message's array (may be greater than 1) */
720 int val[1]; /**< The message's @b array of integers */
721}; /**< Structure passed as value on #EDJE_MESSAGE_STRING_INT_SET messages. The array and string in it are automatically freed be Edje if passed to you by Edje */
722
723struct _Edje_Message_String_Float_Set
724{
725 char *str; /**< The message's string value */
726 int count; /**< The size of the message's array (may be greater than 1) */
727 double val[1]; /**< The message's @b array of floats */
728}; /**< Structure passed as value on #EDJE_MESSAGE_STRING_FLOAT_SET messages. The array and string in it are automatically freed be Edje if passed to you by Edje */
729
730typedef enum _Edje_Drag_Dir
731{
732 EDJE_DRAG_DIR_NONE = 0,
733 EDJE_DRAG_DIR_X = 1,
734 EDJE_DRAG_DIR_Y = 2,
735 EDJE_DRAG_DIR_XY = 3
736} Edje_Drag_Dir;
737
738typedef enum _Edje_Load_Error
739{
740 EDJE_LOAD_ERROR_NONE = 0, /**< No error happened, the loading was successful */
741 EDJE_LOAD_ERROR_GENERIC = 1, /**< A generic error happened during the loading */
742 EDJE_LOAD_ERROR_DOES_NOT_EXIST = 2, /**< The file pointed to did not exist */
743 EDJE_LOAD_ERROR_PERMISSION_DENIED = 3, /**< Permission to read the given file was denied */
744 EDJE_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED = 4, /**< Resource allocation failed during the loading */
745 EDJE_LOAD_ERROR_CORRUPT_FILE = 5, /**< The file pointed to was corrupt */
746 EDJE_LOAD_ERROR_UNKNOWN_FORMAT = 6, /**< The file pointed to had an unknown format */
747 EDJE_LOAD_ERROR_INCOMPATIBLE_FILE = 7, /**< The file pointed to is incompatible, i.e., it doesn't match the library's current version's format */
748 EDJE_LOAD_ERROR_UNKNOWN_COLLECTION = 8, /**< The group/collection set to load from was @b not found in the file */
749 EDJE_LOAD_ERROR_RECURSIVE_REFERENCE = 9 /**< The group/collection set to load from had <b>recursive references</b> on its components */
750} Edje_Load_Error; /**< Edje file loading error codes one can get - see edje_load_error_str() too. */
751
752typedef enum _Edje_Text_Filter_Type
753{
754 EDJE_TEXT_FILTER_TEXT = 0,
755 EDJE_TEXT_FILTER_FORMAT = 1,
756 EDJE_TEXT_FILTER_MARKUP = 2
757} Edje_Text_Filter_Type;
758
759typedef enum _Edje_Text_Autocapital_Type
760{
761 EDJE_TEXT_AUTOCAPITAL_TYPE_NONE,
762 EDJE_TEXT_AUTOCAPITAL_TYPE_WORD,
763 EDJE_TEXT_AUTOCAPITAL_TYPE_SENTENCE,
764 EDJE_TEXT_AUTOCAPITAL_TYPE_ALLCHARACTER
765} Edje_Text_Autocapital_Type;
766
767/**
768 * The possible types the parameters of an EXTERNAL part can be.
769 */
770typedef enum _Edje_External_Param_Type
771{
772 EDJE_EXTERNAL_PARAM_TYPE_INT, /**< Parameter value is an integer. */
773 EDJE_EXTERNAL_PARAM_TYPE_DOUBLE, /**< Parameter value is a double. */
774 EDJE_EXTERNAL_PARAM_TYPE_STRING, /**< Paramater value is a string. */
775 EDJE_EXTERNAL_PARAM_TYPE_BOOL, /**< Parameter value is boolean. */
776 EDJE_EXTERNAL_PARAM_TYPE_CHOICE, /**< Parameter value is one of a set of
777 predefined string choices. */
778 EDJE_EXTERNAL_PARAM_TYPE_MAX /**< Sentinel. Don't use. */
779} Edje_External_Param_Type;
780
781/**
782 * Flags that determine how a parameter may be accessed in different
783 * circumstances.
784 */
785typedef enum _Edje_External_Param_Flags
786{
787 EDJE_EXTERNAL_PARAM_FLAGS_NONE = 0, /**< Propery is incapable of operations, this is used to catch bogus flags. */
788 EDJE_EXTERNAL_PARAM_FLAGS_GET = (1 << 0), /**< Property can be read/get. */
789 EDJE_EXTERNAL_PARAM_FLAGS_SET = (1 << 1), /**< Property can be written/set. This only enables edje_object_part_external_param_set() and Embryo scripts. To enable the parameter being set from state description whenever it changes state, use #EDJE_EXTERNAL_PARAM_FLAGS_STATE. */
790 EDJE_EXTERNAL_PARAM_FLAGS_STATE = (1 << 2), /**< Property can be set from state dsecription. */
791 EDJE_EXTERNAL_PARAM_FLAGS_CONSTRUCTOR = (1 << 3), /**< This property is only set once when the object is constructed using its value from "default" 0.0 state description. Setting this overrides #EDJE_EXTERNAL_PARAM_FLAGS_STATE. */
792 EDJE_EXTERNAL_PARAM_FLAGS_REGULAR = (EDJE_EXTERNAL_PARAM_FLAGS_GET |
793 EDJE_EXTERNAL_PARAM_FLAGS_SET |
794 EDJE_EXTERNAL_PARAM_FLAGS_STATE) /**< Convenience flag that sets property as GET, SET and STATE. */
795} Edje_External_Param_Flags;
796
797typedef enum
798{
799 EDJE_INPUT_PANEL_LAYOUT_NORMAL, /**< Default layout */
800 EDJE_INPUT_PANEL_LAYOUT_NUMBER, /**< Number layout */
801 EDJE_INPUT_PANEL_LAYOUT_EMAIL, /**< Email layout */
802 EDJE_INPUT_PANEL_LAYOUT_URL, /**< URL layout */
803 EDJE_INPUT_PANEL_LAYOUT_PHONENUMBER, /**< Phone Number layout */
804 EDJE_INPUT_PANEL_LAYOUT_IP, /**< IP layout */
805 EDJE_INPUT_PANEL_LAYOUT_MONTH, /**< Month layout */
806 EDJE_INPUT_PANEL_LAYOUT_NUMBERONLY, /**< Number Only layout */
807 EDJE_INPUT_PANEL_LAYOUT_INVALID
808} Edje_Input_Panel_Layout;
809
810/**
811 * @brief Converts type identifier to string nicer representation.
812 *
813 * This may be used to debug or other informational purposes.
814 *
815 * @param type the identifier to convert.
816 * @return the string with the string representation, or @c "(unknown)".
817 */
818EAPI const char *edje_external_param_type_str(Edje_External_Param_Type type) EINA_PURE;
819
820/**
821 * Struct that holds parameters for parts of type EXTERNAL.
822 */
823struct _Edje_External_Param
824{
825 const char *name; /**< The name of the parameter. */
826 Edje_External_Param_Type type; /**< The type of the parameter. This defines
827 which of the next three variables holds
828 the value for it. */
829 // XXX these could be in a union, but eet doesn't support them (or does it?)
830 int i; /**< Used by both integer and boolean */
831 double d; /**< Used by double */
832 const char *s; /**< Used by both string and choice */
833};
834/**
835 * Struct that holds parameters for parts of type EXTERNAL.
836 */
837typedef struct _Edje_External_Param Edje_External_Param;
838
839/**
840 * Helper macro to indicate an EXTERNAL's integer parameter is undefined.
841 */
842#define EDJE_EXTERNAL_INT_UNSET INT_MAX
843/**
844 * Helper macro to indicate an EXTERNAL's double parameter is undefined.
845 */
846#define EDJE_EXTERNAL_DOUBLE_UNSET DBL_MAX
847
848/**
849 * Struct holding information about an EXTERNAL part's parameters.
850 *
851 * When creating types to use with EXTERNAL parts, an array of this type is
852 * used to describe the different parameters the object uses.
853 *
854 * This struct holds the name, type and flags that define how and when the
855 * parameter is used, as well as information specific to each type, like the
856 * maximum or minimum value, that can be used by editors to restrict the
857 * range of values to set for each parameter.
858 */
859typedef struct _Edje_External_Param_Info Edje_External_Param_Info;
860/**
861 * Struct holding information about an EXTERNAL part's parameters.
862 *
863 * When creating types to use with EXTERNAL parts, an array of this type is
864 * used to describe the different parameters the object uses.
865 *
866 * This struct holds the name, type and flags that define how and when the
867 * parameter is used, as well as information specific to each type, like the
868 * maximum or minimum value, that can be used by editors to restrict the
869 * range of values to set for each parameter.
870 */
871struct _Edje_External_Param_Info
872{
873 const char *name; /**< Name of the parameter. */
874 Edje_External_Param_Type type; /**< Type of the parameter. */
875 Edje_External_Param_Flags flags; /**< Flags indicating how this parameter is
876 used. */
877 union {
878 struct {
879 int def, /**< Default value for the paramter. */
880 min, /**< Minimum value it can have. */
881 max, /**< Maximum value it can have. */
882 step; /**< Values will be a multiple of this. */
883 } i; /**< Info about integer type parametrs. Use #EDJE_EXTERNAL_INT_UNSET
884 on any of them to indicate they are not defined.*/
885 struct {
886 double def, /**< Default value for the paramter. */
887 min, /**< Minimum value it can have. */
888 max, /**< Maximum value it can have. */
889 step; /**< Values will be a multiple of this. */
890 } d; /**< Info about double type parametrs. Use
891#EDJE_EXTERNAL_DOUBLE_UNSET on any of them to indicate they are not defined.*/
892 struct {
893 const char *def; /**< Default value. */
894 const char *accept_fmt; /**< Not implemented. */
895 const char *deny_fmt; /**< Not implemented */
896 } s; /**< Info about string type parameters. NULL indicates undefined. */
897 struct {
898 int def; /**< Default value. */
899 const char *false_str; /**< String shown by editors to indicate the false state. */
900 const char *true_str; /**< String shown by editors to indicate the true state. */
901 } b; /**< Info about boolean type parameters.*/
902 struct {
903 const char *def; /**< Default value. */
904 const char **choices; /* Array of strings, each represents a
905 valid value for this parameter. The
906 last element of the array must be
907 NULL. */
908 char *(*def_get)(void *data, const Edje_External_Param_Info *info); /** return malloc() memory with the default choice, should be used if def is NULL. First parameter is Edje_External_Type::data */
909 char **(*query)(void *data, const Edje_External_Param_Info *info); /** NULL terminated array of strings, memory is dynamically allocated and should be freed with free() for array and each element. First parameter is Edje_External_Type::data */
910 } c; /**< Info about choice type parameters. */
911 } info;
912};
913
914#define EDJE_EXTERNAL_PARAM_INFO_INT_FULL_FLAGS(name, def, min, max, step, flags) \
915 {name, EDJE_EXTERNAL_PARAM_TYPE_INT, flags, {.i = {def, min, max, step}}}
916#define EDJE_EXTERNAL_PARAM_INFO_DOUBLE_FULL_FLAGS(name, def, min, max, step, flags) \
917 {name, EDJE_EXTERNAL_PARAM_TYPE_DOUBLE, flags, {.d = {def, min, max, step}}}
918#define EDJE_EXTERNAL_PARAM_INFO_STRING_FULL_FLAGS(name, def, accept, deny, flags) \
919 {name, EDJE_EXTERNAL_PARAM_TYPE_STRING, flags, {.s = {def, accept, deny}}}
920#define EDJE_EXTERNAL_PARAM_INFO_BOOL_FULL_FLAGS(name, def, false_str, true_str, flags) \
921 {name, EDJE_EXTERNAL_PARAM_TYPE_BOOL, flags, {.b = {def, false_str, true_str}}}
922#define EDJE_EXTERNAL_PARAM_INFO_CHOICE_FULL_FLAGS(name, def, choices, flags) \
923 {name, EDJE_EXTERNAL_PARAM_TYPE_CHOICE, flags, {.c = {def, choices, NULL, NULL}}}
924#define EDJE_EXTERNAL_PARAM_INFO_CHOICE_DYNAMIC_FULL_FLAGS(name, def_get, query, flags) \
925 {name, EDJE_EXTERNAL_PARAM_TYPE_CHOICE, flags, {.c = {NULL, NULL, def_get, query}}}
926
927#define EDJE_EXTERNAL_PARAM_INFO_INT_FULL(name, def, min, max, step) \
928 EDJE_EXTERNAL_PARAM_INFO_INT_FULL_FLAGS(name, def, min, max, step, EDJE_EXTERNAL_PARAM_FLAGS_REGULAR)
929#define EDJE_EXTERNAL_PARAM_INFO_DOUBLE_FULL(name, def, min, max, step) \
930 EDJE_EXTERNAL_PARAM_INFO_DOUBLE_FULL_FLAGS(name, def, min, max, step, EDJE_EXTERNAL_PARAM_FLAGS_REGULAR)
931#define EDJE_EXTERNAL_PARAM_INFO_STRING_FULL(name, def, accept, deny) \
932 EDJE_EXTERNAL_PARAM_INFO_STRING_FULL_FLAGS(name, def, accept, deny, EDJE_EXTERNAL_PARAM_FLAGS_REGULAR)
933#define EDJE_EXTERNAL_PARAM_INFO_BOOL_FULL(name, def, false_str, true_str) \
934 EDJE_EXTERNAL_PARAM_INFO_BOOL_FULL_FLAGS(name, def, false_str, true_str, EDJE_EXTERNAL_PARAM_FLAGS_REGULAR)
935#define EDJE_EXTERNAL_PARAM_INFO_CHOICE_FULL(name, def, choices) \
936 EDJE_EXTERNAL_PARAM_INFO_CHOICE_FULL_FLAGS(name, def, choices, EDJE_EXTERNAL_PARAM_FLAGS_REGULAR)
937#define EDJE_EXTERNAL_PARAM_INFO_CHOICE_DYNAMIC_FULL(name, def_get, query) \
938 EDJE_EXTERNAL_PARAM_INFO_CHOICE_DYNAMIC_FULL_FLAGS(name, def_get, query, EDJE_EXTERNAL_PARAM_FLAGS_REGULAR)
939
940#define EDJE_EXTERNAL_PARAM_INFO_INT_DEFAULT(name, def) \
941 EDJE_EXTERNAL_PARAM_INFO_INT_FULL(name, def, EDJE_EXTERNAL_INT_UNSET, EDJE_EXTERNAL_INT_UNSET, EDJE_EXTERNAL_INT_UNSET)
942#define EDJE_EXTERNAL_PARAM_INFO_DOUBLE_DEFAULT(name, def) \
943 EDJE_EXTERNAL_PARAM_INFO_DOUBLE_FULL(name, def, EDJE_EXTERNAL_DOUBLE_UNSET, EDJE_EXTERNAL_DOUBLE_UNSET, EDJE_EXTERNAL_DOUBLE_UNSET)
944#define EDJE_EXTERNAL_PARAM_INFO_STRING_DEFAULT(name, def) \
945 EDJE_EXTERNAL_PARAM_INFO_STRING_FULL(name, def, NULL, NULL)
946#define EDJE_EXTERNAL_PARAM_INFO_BOOL_DEFAULT(name, def) \
947 EDJE_EXTERNAL_PARAM_INFO_BOOL_FULL(name, def, "false", "true")
948
949#define EDJE_EXTERNAL_PARAM_INFO_INT_DEFAULT_FLAGS(name, def, flags) \
950 EDJE_EXTERNAL_PARAM_INFO_INT_FULL_FLAGS(name, def, EDJE_EXTERNAL_INT_UNSET, EDJE_EXTERNAL_INT_UNSET, EDJE_EXTERNAL_INT_UNSET, flags)
951#define EDJE_EXTERNAL_PARAM_INFO_DOUBLE_DEFAULT_FLAGS(name, def, flags) \
952 EDJE_EXTERNAL_PARAM_INFO_DOUBLE_FULL_FLAGS(name, def, EDJE_EXTERNAL_DOUBLE_UNSET, EDJE_EXTERNAL_DOUBLE_UNSET, EDJE_EXTERNAL_DOUBLE_UNSET, flags)
953#define EDJE_EXTERNAL_PARAM_INFO_STRING_DEFAULT_FLAGS(name, def, flags) \
954 EDJE_EXTERNAL_PARAM_INFO_STRING_FULL_FLAGS(name, def, NULL, NULL, flags)
955#define EDJE_EXTERNAL_PARAM_INFO_BOOL_DEFAULT_FLAGS(name, def, flags) \
956 EDJE_EXTERNAL_PARAM_INFO_BOOL_FULL_FLAGS(name, def, "false", "true", flags)
957
958#define EDJE_EXTERNAL_PARAM_INFO_INT(name) \
959 EDJE_EXTERNAL_PARAM_INFO_INT_DEFAULT(name, 0)
960#define EDJE_EXTERNAL_PARAM_INFO_DOUBLE(name) \
961 EDJE_EXTERNAL_PARAM_INFO_DOUBLE_DEFAULT(name, 0.0)
962#define EDJE_EXTERNAL_PARAM_INFO_STRING(name) \
963 EDJE_EXTERNAL_PARAM_INFO_STRING_DEFAULT(name, NULL)
964#define EDJE_EXTERNAL_PARAM_INFO_BOOL(name) \
965 EDJE_EXTERNAL_PARAM_INFO_BOOL_DEFAULT(name, 0)
966
967#define EDJE_EXTERNAL_PARAM_INFO_INT_FLAGS(name, flags) \
968 EDJE_EXTERNAL_PARAM_INFO_INT_DEFAULT_FLAGS(name, 0, flags)
969#define EDJE_EXTERNAL_PARAM_INFO_DOUBLE_FLAGS(name, flags) \
970 EDJE_EXTERNAL_PARAM_INFO_DOUBLE_DEFAULT_FLAGS(name, 0.0, flags)
971#define EDJE_EXTERNAL_PARAM_INFO_STRING_FLAGS(name, flags) \
972 EDJE_EXTERNAL_PARAM_INFO_STRING_DEFAULT_FLAGS(name, NULL, flags)
973#define EDJE_EXTERNAL_PARAM_INFO_BOOL_FLAGS(name, flags) \
974 EDJE_EXTERNAL_PARAM_INFO_BOOL_DEFAULT_FLAGS(name, 0, flags)
975
976#define EDJE_EXTERNAL_PARAM_INFO_SENTINEL {NULL, 0, 0, {.s = {NULL, NULL, NULL}}}
977
978/**
979 * @struct _Edje_External_Type
980 *
981 * @brief Information about an external type to be used.
982 *
983 * This structure provides information on how to display and modify a
984 * third party Evas_Object in Edje.
985 *
986 * Some function pointers are not really used by Edje, but provide
987 * means for Edje users to better interact with such objects. For
988 * instance, an editor may use label_get() and icon_get() to list all
989 * registered external types.
990 *
991 * @note The function pointers provided in this structure must check
992 * for errors and invalid or out-of-range values as for
993 * performance reasons Edje will not enforce hints provided as
994 * #Edje_External_Param_Info in the member parameters_info.
995 */
996struct _Edje_External_Type
997{
998#define EDJE_EXTERNAL_TYPE_ABI_VERSION (3)
999 unsigned int abi_version; /**< always use:
1000 * - #EDJE_EXTERNAL_TYPE_ABI_VERSION to declare.
1001 * - edje_external_type_abi_version_get() to check.
1002 */
1003 const char *module; /**< Name of the module that holds these definitions,
1004 as used in the externals {} block of a theme
1005 definition. */
1006 const char *module_name; /**< Canonical name of the module, for displaying
1007 in edition programs, for example. */
1008 Evas_Object *(*add) (void *data, Evas *evas, Evas_Object *parent, const Eina_List *params, const char *part_name); /**< Creates the object to be used by Edje as the part. @p part_name is the name of the part that holds the object and can be used to forward callbacks from the object as signals from Edje. @p params is the list of #Edje_External_Param, not parsed, from the default state of the part. Parameters of type #EDJE_EXTERNAL_PARAM_FLAGS_CONSTRUCTOR should be set on
1009 the object here. */
1010 void (*state_set) (void *data, Evas_Object *obj, const void *from_params, const void *to_params, float pos); /**< Called upon state changes, including the initial "default" 0.0 state. Parameters are the value returned by params_parse(). The @p pos parameter is a value between 0.0 and 1.0 indicating the position in time within the state transition. */
1011 void (*signal_emit) (void *data, Evas_Object *obj, const char *emission, const char *source); /**< Feed a signal emitted with emission originally set as part_name:signal to this object (without the "part_name:" prefix) */
1012 Eina_Bool (*param_set) (void *data, Evas_Object *obj, const Edje_External_Param *param); /**< Dynamically change a parameter of this external, called by scripts and user code. Returns @c EINA_TRUE on success */
1013 Eina_Bool (*param_get) (void *data, const Evas_Object *obj, Edje_External_Param *param); /**< Dynamically fetch a parameter of this external, called by scripts and user code. Returns @c EINA_TRUE on success. (Must check parameter name and type!) */
1014 Evas_Object *(*content_get) (void *data, const Evas_Object *obj, const char *content); /**< Dynamically fetch a sub object of this external, called by scripts and user code. Returns @c Evas_Object * on success. (Must check parameter name and type!) */
1015 void *(*params_parse) (void *data, Evas_Object *obj, const Eina_List *params); /**< Parses the list of parameters, converting into a friendly representation. Used with state_set() */
1016 void (*params_free) (void *params); /**< Free parameters parsed with params_parse() */
1017
1018 /* The following callbacks aren't used by Edje itself, but by UI design
1019 tools instead */
1020 const char *(*label_get) (void *data); /**< Get a label to use to identify this EXTERNAL. (For editors) */
1021 const char *(*description_get) (void *data); /**< Get a user friendly description of this EXTERNAL. (For editors) */
1022 Evas_Object *(*icon_add) (void *data, Evas *e); /**< Get an icon to use to identify this EXTERNAL. (For editors) */
1023 Evas_Object *(*preview_add) (void *data, Evas *e); /**< Get a preview of the EXTERNAL object in use. (For editors) */
1024 const char *(*translate) (void *data, const char *orig); /**< called to translate parameters_info name properties for use in user interfaces that support internationalization (i18n) (For editors) */
1025
1026 Edje_External_Param_Info *parameters_info; /**< An array of #Edje_External_Param_Info describing the different parameters this EXTERNAL may have. The last element in the array must be #EDJE_EXTERNAL_PARAM_INFO_SENTINEL. */
1027 void *data; /**< Private user data that will be passed to all of the class functions. */
1028};
1029typedef struct _Edje_External_Type Edje_External_Type;
1030
1031/**
1032 * Convenience struct used to mass-register types of EXTERNAL objects.
1033 *
1034 * Used with edje_external_type_array_register().
1035 */
1036struct _Edje_External_Type_Info
1037{
1038 const char *name; /**< The name of the type to register. */
1039 const Edje_External_Type *info; /**< The type definition. */
1040};
1041typedef struct _Edje_External_Type_Info Edje_External_Type_Info;
1042
1043typedef void (*Edje_Signal_Cb) (void *data, Evas_Object *obj, const char *emission, const char *source); /**< Edje signal callback functions's prototype definition. @c data will have the auxiliary data pointer set at the time the callback registration. @c obj will be a pointer the Edje object where the signal comes from. @c emission will identify the exact signal's emission string and @c source the exact signal's source one. */
1044typedef void (*Edje_Text_Change_Cb) (void *data, Evas_Object *obj, const char *part);
1045typedef void (*Edje_Message_Handler_Cb) (void *data, Evas_Object *obj, Edje_Message_Type type, int id, void *msg); /**< Edje message handler callback functions's prototype definition. @c data will have the auxiliary data pointer set at the time the callback registration. @c obj will be a pointer the Edje object where the message comes from. @c type will identify the type of the given message and @c msg will be a pointer the message's contents, de facto, which depend on @c type. */
1046typedef void (*Edje_Text_Filter_Cb) (void *data, Evas_Object *obj, const char *part, Edje_Text_Filter_Type type, char **text);
1047typedef Evas_Object *(*Edje_Item_Provider_Cb) (void *data, Evas_Object *obj, const char *part, const char *item);
1048
1049/**
1050 * @brief Initialize the Edje library.
1051 *
1052 * @return The new init count. The initial value is zero.
1053 *
1054 * This function initializes the Ejde library, making the proper calls
1055 * to internal initialization functions. It will also initialize its
1056 * @b dependencies, making calls to @c eina_init(), @c ecore_init(),
1057 * @c embryo_init() and @c eet_init(). So, there is no need to call
1058 * those functions again, in your code. To shutdown Edje there is the
1059 * function edje_shutdown().
1060 *
1061 * @see edje_shutdown()
1062 * @see eina_init()
1063 * @see ecore_init()
1064 * @see embryo_init()
1065 * @see eet_init()
1066 *
1067 */
1068EAPI int edje_init (void);
1069
1070/**
1071 * @brief Shutdown the Edje library.
1072 *
1073 * @return The number of times the library has been initialised
1074 * without being shutdown.
1075 *
1076 * This function shuts down the Edje library. It will also call the
1077 * shutdown functions of its @b dependencies, which are @c
1078 * eina_shutdown(), @c ecore_shutdown(), @c embryo_shutdown() and @c
1079 * eet_shutdown(), so there is no need to call these functions again,
1080 * in your code.
1081 *
1082 * @see edje_init()
1083 * @see eina_shutdown()
1084 * @see ecore_shutdown()
1085 * @see embryo_shutdown()
1086 * @see eet_shutdown()
1087 *
1088 */
1089EAPI int edje_shutdown (void);
1090
1091/**
1092 * @brief Set edje trasitions' frame time.
1093 *
1094 * @param t The frame time, in seconds. Default value is 1/30.
1095 *
1096 * This function sets the edje built-in animations' frame time (thus,
1097 * affecting their resolution) by calling
1098 * ecore_animator_frametime_set(). This frame time can be retrieved
1099 * with edje_frametime_get().
1100 *
1101 * @see edje_frametime_get()
1102 *
1103 */
1104EAPI void edje_frametime_set (double t);
1105
1106/**
1107 * @brief Get edje trasitions' frame time.
1108 *
1109 * @return The frame time, in seconds.
1110 *
1111 * This function returns the edje frame time set by
1112 * edje_frametime_set() or the default value 1/30.
1113 *
1114 * @see edje_frametime_set()
1115 *
1116 */
1117EAPI double edje_frametime_get (void);
1118
1119/**
1120 * @brief Freeze Edje objects.
1121 *
1122 * This function freezes all Edje animations in the current process.
1123 *
1124 * @note: for freeze a specific object @see edje_object_freeze().
1125 *
1126 * @see edje_thaw()
1127 *
1128 */
1129EAPI void edje_freeze (void);
1130
1131/**
1132 * @brief Thaw Edje objects.
1133 *
1134 * This function thaws all Edje animations in the current process.
1135 *
1136 * @note for thaw a specific object @see edje_object_thaw().
1137 *
1138 * @see edje_freeze()
1139 *
1140 */
1141EAPI void edje_thaw (void);
1142
1143/**
1144 * @brief Set the edje append fontset.
1145 *
1146 * @param fonts The fontset to append.
1147 *
1148 * This function sets the edje append fontset.
1149 *
1150 */
1151EAPI void edje_fontset_append_set (const char *fonts);
1152
1153/**
1154 * @brief Get the edje append fontset.
1155 *
1156 * @return The edje append fontset.
1157 *
1158 * This function returns the edje append fontset set by
1159 * edje_fontset_append_set() function.
1160 *
1161 * @see edje_fontset_append_set().
1162 *
1163 */
1164EAPI const char *edje_fontset_append_get (void);
1165
1166/**
1167 * @brief Set Edje's global scaling factor.
1168 *
1169 * @param scale The global scaling factor (the default value is @c 1.0)
1170 *
1171 * Edje allows one to build scalable interfaces. Scaling factors,
1172 * which are set to neutral (@c 1.0) values by default (no scaling,
1173 * actual sizes), are of two types: @b global and @b individual.
1174 * Edje's global scaling factor will affect all its objects which
1175 * hadn't their individual scaling factors altered from the default
1176 * value (which is zero). If they had it set differently, by
1177 * edje_object_scale_set(), that factor will @b override the global
1178 * one.
1179 *
1180 * Scaling affects the values of mininum/maximum @b part sizes, which
1181 * are @b multiplied by it. Font sizes are scaled, too.
1182 *
1183 * @warning Only parts which, at EDC level, had the @c "scale"
1184 * property set to @c 1, will be affected by this function. Check the
1185 * complete @ref edcref "syntax reference" for EDC files.
1186 *
1187 * @see edje_scale_get().
1188 */
1189EAPI void edje_scale_set (double scale);
1190
1191/**
1192 * @brief Retrieve Edje's global scaling factor.
1193 *
1194 * @return The global scaling factor
1195 *
1196 * This function returns Edje's global scaling factor.
1197 *
1198 * @see edje_scale_set() for more details
1199 *
1200 */
1201EAPI double edje_scale_get (void);
1202
1203/**
1204 * @brief Show last character in password mode.
1205 *
1206 * @param password_show_last If TRUE enable last character show in password mode.
1207 *
1208 * This function enables last input to be visible when in password mode for few seconds
1209 * or until the next input is entered.
1210 *
1211 * The time out value is obtained by edje_password_show_last_timeout_set function.
1212 *
1213 * @see edje_password_show_last_timeout_set().
1214 */
1215EAPI void edje_password_show_last_set(Eina_Bool password_show_last);
1216
1217/**
1218 * @brief Set's the timeout value in last show password mode.
1219 *
1220 * @param password_show_last_timeout The timeout value.
1221 *
1222 * This functions sets the time out value for which the last input entered in password
1223 * mode will be visible.
1224 *
1225 * This value can be used only when last show mode is set in password mode.
1226 *
1227 * @see edje_password_show_last_set().
1228 *
1229 */
1230EAPI void edje_password_show_last_timeout_set(double password_show_last_timeout);
1231
1232/**
1233 * @brief Set the scaling factor for a given Edje object.
1234 *
1235 * @param obj A handle to an Edje object
1236 * @param scale The scaling factor (the default value is @c 0.0,
1237 * meaning indivinual scaling @b not set)
1238 *
1239 * This function sets an @b individual scaling factor on the @a obj
1240 * Edje object. This property (or Edje's global scaling factor, when
1241 * applicable), will affect this object's part sizes. If @p scale is
1242 * not zero, than the individual scaling will @b override any global
1243 * scaling set, for the object @p obj's parts. Put it back to zero to
1244 * get the effects of the global scaling again.
1245 *
1246 * @warning Only parts which, at EDC level, had the @c "scale"
1247 * property set to @c 1, will be affected by this function. Check the
1248 * complete @ref edcref "syntax reference" for EDC files.
1249 *
1250 * @see edje_object_scale_get()
1251 * @see edje_scale_get() for more details
1252 */
1253EAPI Eina_Bool edje_object_scale_set (Evas_Object *obj, double scale);
1254
1255/**
1256 * @brief Get a given Edje object's scaling factor.
1257 *
1258 * @param obj A handle to an Edje object
1259 *
1260 * This function returns the @c individual scaling factor set on the
1261 * @a obj Edje object.
1262 *
1263 * @see edje_object_scale_set() for more details
1264 *
1265 */
1266EAPI double edje_object_scale_get (const Evas_Object *obj);
1267
1268/**
1269 * @brief Set the RTL orientation for this object.
1270 *
1271 * @param obj A handle to an Edje object.
1272 * @rtl new value of flag EINA_TRUE/EINA_FALSE
1273 * @since 1.1.0
1274 */
1275EAPI void edje_object_mirrored_set (Evas_Object *obj, Eina_Bool rtl);
1276
1277/**
1278 * @brief Get the RTL orientation for this object.
1279 *
1280 * You can RTL orientation explicitly with edje_object_mirrored_set.
1281 *
1282 * @param obj A handle to an Edje object.
1283 * @return @c EINA_TRUE if the flag is set or @c EINA_FALSE if not.
1284 * @since 1.1.0
1285 */
1286EAPI Eina_Bool edje_object_mirrored_get (const Evas_Object *obj);
1287
1288/**
1289 * Get a list of groups in an edje file
1290 * @param file The path to the edje file
1291 *
1292 * @return The Eina_List of group names (char *)
1293 *
1294 * Note: the list must be freed using edje_file_collection_list_free()
1295 * when you are done with it.
1296 */
1297EAPI Eina_List *edje_file_collection_list (const char *file);
1298
1299/**
1300 * Free file collection list
1301 * @param lst The Eina_List of groups
1302 *
1303 * Frees the list returned by edje_file_collection_list().
1304 */
1305EAPI void edje_file_collection_list_free (Eina_List *lst);
1306
1307/**
1308 * Determine whether a group matching glob exists in an edje file.
1309 * @param file The file path
1310 * @param glob A glob to match on
1311 *
1312 * @return 1 if a match is found, 0 otherwise
1313 */
1314EAPI Eina_Bool edje_file_group_exists (const char *file, const char *glob);
1315
1316/**
1317 * Get data from the file level data block of an edje file
1318 * @param file The path to the .edj file
1319 * @param key The data key
1320 * @return The string value of the data. Must be freed by the user when no
1321 * longer needed.
1322 *
1323 * If an edje file is built from the following edc:
1324 *
1325 * data {
1326 * item: "key1" "value1";
1327 * item: "key2" "value2";
1328 * }
1329 * collections { ... }
1330 *
1331 * Then, edje_file_data_get("key1") will return "value1"
1332 */
1333EAPI char *edje_file_data_get (const char *file, const char *key);
1334
1335/**
1336 * @brief Set the file cache size.
1337 *
1338 * @param count The file cache size in edje file units. Default is 16.
1339 *
1340 * This function sets the file cache size. Edje keeps this cache in
1341 * order to prevent duplicates of edje file entries in memory. The
1342 * file cache size can be retrieved with edje_file_cache_get().
1343 *
1344 * @see edje_file_cache_get()
1345 * @see edje_file_cache_flush()
1346 *
1347 */
1348EAPI void edje_file_cache_set (int count);
1349
1350/**
1351 * @brief Return the file cache size.
1352 *
1353 * @return The file cache size in edje file units. Default is 16.
1354 *
1355 * This function returns the file cache size set by
1356 * edje_file_cache_set().
1357 *
1358 * @see edje_file_cache_set()
1359 * @see edje_file_cache_flush()
1360 *
1361 */
1362EAPI int edje_file_cache_get (void);
1363
1364/**
1365 * @brief Clean the file cache.
1366 *
1367 * This function cleans the file cache entries, but keeps this cache's
1368 * size to the last value set.
1369 *
1370 * @see edje_file_cache_set()
1371 * @see edje_file_cache_get()
1372 *
1373 */
1374EAPI void edje_file_cache_flush (void);
1375
1376/**
1377 * @brief Set the collection cache size.
1378 *
1379 * @param count The collection cache size, in edje object units. Default is 16.
1380 *
1381 * This function sets the collection cache size. Edje keeps this cache
1382 * in order to prevent duplicates of edje {collection,group,part}
1383 * entries in memory. The collection cache size can be retrieved with
1384 * edje_collection_cache_get().
1385 *
1386 * @see edje_collection_cache_get()
1387 * @see edje_collection_cache_flush()
1388 *
1389 */
1390EAPI void edje_collection_cache_set (int count);
1391
1392/**
1393 * @brief Return the collection cache size.
1394 *
1395 * @return The collection cache size, in edje object units. Default is 16.
1396 *
1397 * This function returns the collection cache size set by
1398 * edje_collection_cache_set().
1399 *
1400 * @see edje_collection_cache_set()
1401 * @see edje_collection_cache_flush()
1402 *
1403 */
1404EAPI int edje_collection_cache_get (void);
1405
1406/**
1407 * @brief Clean the collection cache.
1408 *
1409 * This function cleans the collection cache, but keeps this cache's
1410 * size to the last value set.
1411 *
1412 * @see edje_collection_cache_set()
1413 * @see edje_collection_cache_get()
1414 *
1415 */
1416EAPI void edje_collection_cache_flush (void);
1417
1418/**
1419 * @brief Set Edje color class.
1420 *
1421 * @param color_class
1422 * @param r Object Red value
1423 * @param g Object Green value
1424 * @param b Object Blue value
1425 * @param a Object Alpha value
1426 * @param r2 Outline Red value
1427 * @param g2 Outline Green value
1428 * @param b2 Outline Blue value
1429 * @param a2 Outline Alpha value
1430 * @param r3 Shadow Red value
1431 * @param g3 Shadow Green value
1432 * @param b3 Shadow Blue value
1433 * @param a3 Shadow Alpha value
1434 *
1435 * This function sets the color values for a process level color
1436 * class. This will cause all edje parts in the current process that
1437 * have the specified color class to have their colors multiplied by
1438 * these values. (Object level color classes set by
1439 * edje_object_color_class_set() will override the values set by this
1440 * function).
1441 *
1442 * The first color is the object, the second is the text outline, and
1443 * the third is the text shadow. (Note that the second two only apply
1444 * to text parts).
1445 *
1446 * Setting color emits a signal "color_class,set" with source being
1447 * the given color class in all objects.
1448 *
1449 * @see edje_color_class_set().
1450 *
1451 * @note unlike Evas, Edje colors are @b not pre-multiplied. That is,
1452 * half-transparent white is 255 255 255 128.
1453 */
1454EAPI Eina_Bool edje_color_class_set (const char *color_class, int r, int g, int b, int a, int r2, int g2, int b2, int a2, int r3, int g3, int b3, int a3);
1455
1456/**
1457 * @brief Get Edje color class.
1458 *
1459 * @param color_class
1460 * @param r Object Red value
1461 * @param g Object Green value
1462 * @param b Object Blue value
1463 * @param a Object Alpha value
1464 * @param r2 Outline Red value
1465 * @param g2 Outline Green value
1466 * @param b2 Outline Blue value
1467 * @param a2 Outline Alpha value
1468 * @param r3 Shadow Red value
1469 * @param g3 Shadow Green value
1470 * @param b3 Shadow Blue value
1471 * @param a3 Shadow Alpha value
1472 *
1473 * @return EINA_TRUE if found or EINA_FALSE if not found and all
1474 * values are zeroed.
1475 *
1476 * This function gets the color values for a process level color
1477 * class. This value is the globally set and not per-object, that is,
1478 * the value that would be used by objects if they did not override with
1479 * edje_object_color_class_set().
1480 *
1481 * The first color is the object, the second is the text outline, and
1482 * the third is the text shadow. (Note that the second two only apply
1483 * to text parts).
1484 *
1485 * @see edje_color_class_set().
1486 *
1487 * @note unlike Evas, Edje colors are @b not pre-multiplied. That is,
1488 * half-transparent white is 255 255 255 128.
1489 */
1490EAPI Eina_Bool edje_color_class_get (const char *color_class, int *r, int *g, int *b, int *a, int *r2, int *g2, int *b2, int *a2, int *r3, int *g3, int *b3, int *a3);
1491
1492/**
1493 * @brief Delete edje color class.
1494 *
1495 * @param color_class
1496 *
1497 * This function deletes any values at the process level for the
1498 * specified color class.
1499 * @note Deleting the color class will revert it to the
1500 * values defined in the theme file.
1501 *
1502 * Deleting the color class will emit the signal "color_class,del"
1503 * to all the Edje objects in the running program.
1504 */
1505EAPI void edje_color_class_del (const char *color_class);
1506
1507/**
1508 * @brief Lists color classes.
1509 *
1510 * @return A list of color class names (strings). These strings and
1511 * the list must be free()'d by the caller.
1512 *
1513 * This function lists all color classes known about by the current
1514 * process.
1515 *
1516 */
1517EAPI Eina_List *edje_color_class_list (void);
1518
1519/**
1520 * @brief Set the Edje text class.
1521 *
1522 * @param text_class The text class name
1523 * @param font The font name
1524 * @param size The font size
1525 *
1526 * @return @c EINA_TRUE, on success or @c EINA_FALSE, on error
1527 *
1528 * This function updates all Edje members at the process level which
1529 * belong to this text class with the new font attributes.
1530 *
1531 * @see edje_text_class_get().
1532 *
1533 */
1534EAPI Eina_Bool edje_text_class_set (const char *text_class, const char *font, Evas_Font_Size size);
1535
1536/**
1537 * @brief Delete the text class.
1538 *
1539 * @param text_class The text class name string
1540 *
1541 * This function deletes any values at the process level for the
1542 * specified text class.
1543 *
1544 */
1545EAPI void edje_text_class_del (const char *text_class);
1546
1547/**
1548 * @brief List text classes.
1549 *
1550 * @return A list of text class names (strings). These strings are
1551 * stringshares and the list must be free()'d by the caller.
1552 *
1553 * This function lists all text classes known about by the current
1554 * process.
1555 *
1556 */
1557EAPI Eina_List *edje_text_class_list (void);
1558
1559/**
1560 * @brief Set the object minimum size.
1561 *
1562 * @param obj A valid Evas_Object handle
1563 * @param minw The minimum width
1564 * @param minh The minimum height
1565 *
1566 * This sets the minimum size restriction for the object.
1567 */
1568EAPI void edje_extern_object_min_size_set (Evas_Object *obj, Evas_Coord minw, Evas_Coord minh);
1569
1570/**
1571 * @brief Set the object maximum size.
1572 *
1573 * @param obj A valid Evas_Object handle
1574 * @param maxw The maximum width
1575 * @param maxh The maximum height
1576 *
1577 * This sets the maximum size restriction for the object.
1578 */
1579EAPI void edje_extern_object_max_size_set (Evas_Object *obj, Evas_Coord maxw, Evas_Coord maxh);
1580
1581/**
1582 * @brief Set the object aspect size.
1583 *
1584 * @param obj A valid Evas_Object handle
1585 * @param aspect The aspect control axes
1586 * @param aw The aspect radio width
1587 * @param ah The aspect ratio height
1588 *
1589 * This sets the desired aspect ratio to keep an object that will be
1590 * swallowed by Edje. The width and height define a preferred size
1591 * ASPECT and the object may be scaled to be larger or smaller, but
1592 * retaining the relative scale of both aspect width and height.
1593 */
1594EAPI void edje_extern_object_aspect_set (Evas_Object *obj, Edje_Aspect_Control aspect, Evas_Coord aw, Evas_Coord ah);
1595
1596/**
1597 * @brief Registers a custom layout to be used in edje boxes.
1598 *
1599 * @param name The name of the layout
1600 * @param func The function defining the layout
1601 * @param layout_data_get This function gets the custom data pointer
1602 * for func
1603 * @param layout_data_free Passed to func to free its private data
1604 * when needed
1605 * @param free_data Frees data
1606 * @param data Private pointer passed to layout_data_get
1607 *
1608 * This function registers custom layouts that can be referred from
1609 * themes by the registered name. The Evas_Object_Box_Layout
1610 * functions receive two pointers for internal use, one being private
1611 * data, and the other the function to free that data when it's not
1612 * longer needed. From Edje, this private data will be retrieved by
1613 * calling layout_data_get, and layout_data_free will be the free
1614 * function passed to func. layout_data_get will be called with data
1615 * as its parameter, and this one will be freed by free_data whenever
1616 * the layout is unregistered from Edje.
1617 */
1618EAPI void edje_box_layout_register (const char *name, Evas_Object_Box_Layout func, void *(*layout_data_get)(void *), void (*layout_data_free)(void *), void (*free_data)(void *), void *data);
1619
1620/**
1621 * @brief Instantiate a new Edje object
1622 *
1623 * @param evas A valid Evas handle, the canvas to place the new object
1624 * in
1625 * @return A handle to the new object created or @c NULL, on errors.
1626 *
1627 * This function creates a new Edje smart object, returning its @c
1628 * Evas_Object handle. An Edje object is useless without a (source)
1629 * file set to it, so you'd most probably call edje_object_file_set()
1630 * afterwards, like in:
1631 * @code
1632 * Evas_Object *edje;
1633 *
1634 * edje = edje_object_add(canvas);
1635 * if (!edje)
1636 * {
1637 * fprintf(stderr, "could not create edje object!\n");
1638 * return NULL;
1639 * }
1640 *
1641 * if (!edje_object_file_set(edje, "theme.edj", "group_name"))
1642 * {
1643 * int err = edje_object_load_error_get(edje);
1644 * const char *errmsg = edje_load_error_str(err);
1645 * fprintf(stderr, "could not load 'group_name' from theme.edj: %s",
1646 * errmsg);
1647 *
1648 * evas_object_del(edje);
1649 * return NULL;
1650 * }
1651 *
1652 * @endcode
1653 *
1654 * @note before creating the first Edje object in your code, remember
1655 * to initialize the library, with edje_init(), or unexpected behavior
1656 * might occur.
1657 */
1658EAPI Evas_Object *edje_object_add (Evas *evas);
1659
1660/**
1661 * @brief Retrive an <b>EDC data field's value</b> from a given Edje
1662 * object's group.
1663 *
1664 * @param obj A handle to an Edje object
1665 * @param key The data field's key string
1666 * @return The data's value string. Must not be freed.
1667 *
1668 * This function fetches an EDC data field's value, which is declared
1669 * on the objects building EDC file, <b>under its group</b>. EDC data
1670 * blocks are most commonly used to pass arbitrary parameters from an
1671 * application's theme to its code.
1672 *
1673 * They look like the following:
1674 *
1675 * @code
1676 * collections {
1677 * group {
1678 * name: "a_group";
1679 * data {
1680 * item: "key1" "value1";
1681 * item: "key2" "value2";
1682 * }
1683 * }
1684 * }
1685 * @endcode
1686 *
1687 * EDC data fields always hold @b strings as values, hence the return
1688 * type of this function. Check the complete @ref edcref "syntax reference"
1689 * for EDC files.
1690 *
1691 * @warning Do not confuse this call with edje_file_data_get(), which
1692 * queries for a @b global EDC data field on an EDC declaration file.
1693 *
1694 * @see edje_object_file_set()
1695 */
1696EAPI const char *edje_object_data_get (const Evas_Object *obj, const char *key);
1697
1698/**
1699 * @brief Sets the @b EDJ file (and group within it) to load an Edje
1700 * object's contents from
1701 *
1702 * @param obj A handle to an Edje object
1703 * @param file The path to the EDJ file to load @p from
1704 * @param group The name of the group, in @p file, which implements an
1705 * Edje object
1706 * @return @c EINA_TRUE, on success or @c EINA_FALSE, on errors (check
1707 * edje_object_load_error_get() after this call to get errors causes)
1708 *
1709 * Edje expects EDJ files, which are theming objects' descriptions and
1710 * resources packed together in an EET file, to read Edje object
1711 * definitions from. They usually are created with the @c .edj
1712 * extension. EDJ files, in turn, are assembled from @b textual object
1713 * description files, where one describes Edje objects declaratively
1714 * -- the EDC files (see @ref edcref "the syntax" for those files).
1715 *
1716 * Those description files were designed so that many Edje object
1717 * definitions -- also called @b groups (or collections) -- could be
1718 * packed together <b>in the same EDJ file</b>, so that a whole
1719 * application's theme could be packed in one file only. This is the
1720 * reason for the @p group argument.
1721 *
1722 * Use this function after you instantiate a new Edje object, so that
1723 * you can "give him life", telling where to get its contents from.
1724 *
1725 * @see edje_object_add()
1726 * @see edje_object_file_get()
1727 */
1728EAPI Eina_Bool edje_object_file_set (Evas_Object *obj, const char *file, const char *group);
1729
1730/**
1731 * @brief Get the file and group name that a given Edje object is bound to
1732 *
1733 * @param obj A handle to an Edje object
1734 * @param file A pointer to a variable whero to store the <b>file's
1735 * path</b>
1736 * @param group A pointer to a variable where to store the <b>group
1737 * name</b> in
1738 *
1739 * This gets the EDJ file's path, with the respective group set for
1740 * the given Edje object. If @a obj is either not an Edje file, or has
1741 * not had its file/group set previously, by edje_object_file_set(),
1742 * then both @p file and @p group will be set to @c NULL, indicating
1743 * an error.
1744 *
1745 * @see edje_object_file_set()
1746 *
1747 * @note Use @c NULL pointers on the file/group components you're not
1748 * interested in: they'll be ignored by the function.
1749 */
1750EAPI void edje_object_file_get (const Evas_Object *obj, const char **file, const char **group);
1751
1752/**
1753 * @brief Gets the (last) file loading error for a given Edje object
1754 *
1755 * @param obj A handlet to an Edje object
1756 *
1757 * @return The Edje loading error, one of:
1758 * - #EDJE_LOAD_ERROR_NONE
1759 * - #EDJE_LOAD_ERROR_GENERIC
1760 * - #EDJE_LOAD_ERROR_DOES_NOT_EXIST
1761 * - #EDJE_LOAD_ERROR_PERMISSION_DENIED
1762 * - #EDJE_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED
1763 * - #EDJE_LOAD_ERROR_CORRUPT_FILE
1764 * - #EDJE_LOAD_ERROR_UNKNOWN_FORMAT
1765 * - #EDJE_LOAD_ERROR_INCOMPATIBLE_FILE
1766 * - #EDJE_LOAD_ERROR_UNKNOWN_COLLECTION
1767 * - #EDJE_LOAD_ERROR_RECURSIVE_REFERENCE
1768 *
1769 * This function is meant to be used after an Edje EDJ <b>file
1770 * loading</b>, what takes place with the edje_object_file_set()
1771 * function. If that function does not return @c EINA_TRUE, one should
1772 * check for the reason of failure with this one.
1773 *
1774 * @see edje_load_error_str()
1775 */
1776EAPI Edje_Load_Error edje_object_load_error_get (const Evas_Object *obj);
1777
1778/**
1779 * Converts the given Edje file load error code into a string
1780 * describing it in English.
1781 *
1782 * @param error the error code, a value in ::Edje_Load_Error.
1783 * @return Always returns a valid string. If the given @p error is not
1784 * supported, <code>"Unknown error"</code> is returned.
1785 *
1786 * edje_object_file_set() is a function which sets an error value,
1787 * afterwards, which can be fetched with
1788 * edje_object_load_error_get(). The function in question is meant
1789 * to be used in conjunction with the latter, for pretty-printing any
1790 * possible error cause.
1791 */
1792EAPI const char *edje_load_error_str (Edje_Load_Error error);
1793
1794/**
1795 * @brief Preload the images on the Edje Object in the background.
1796 *
1797 * @param obj A handle to an Edje object
1798 * @param cancel @c EINA_FALSE will add it the preloading work queue,
1799 * @c EINA_TRUE will remove it (if it was issued before).
1800 * @return @c EINA_FASLE if obj was not a valid Edje object
1801 * otherwise @c EINA_TRUE
1802 *
1803 * This function requests the preload of all data images (on the given
1804 * object) in the background. The work is queued before being processed
1805 * (because there might be other pending requests of this type).
1806 * It emits a signal "preload,done" when finished.
1807 *
1808 * @note Use @c EINA_TRUE on scenarios where you don't need
1809 * the image data preloaded anymore.
1810 */
1811EAPI Eina_Bool edje_object_preload (Evas_Object *obj, Eina_Bool cancel);
1812
1813/**
1814 * @brief Add a callback for an arriving Edje signal, emitted by
1815 * a given Ejde object.
1816 *
1817 * @param obj A handle to an Edje object
1818 * @param emission The signal's "emission" string
1819 * @param source The signal's "source" string
1820 * @param func The callback function to be executed when the signal is
1821 * emitted.
1822 * @param data A pointer to data to pass in to @p func.
1823 *
1824 * Edje signals are one of the communication interfaces between
1825 * @b code and a given Edje object's @b theme. With signals, one can
1826 * communicate two string values at a time, which are:
1827 * - "emission" value: the name of the signal, in general
1828 * - "source" value: a name for the signal's context, in general
1829 *
1830 * Though there are those common uses for the two strings, one is free
1831 * to use them however they like.
1832 *
1833 * This function adds a callback function to a signal emitted by @a obj, to
1834 * be issued every time an EDC program like the following
1835 * @code
1836 * program {
1837 * name: "emit_example";
1838 * action: SIGNAL_EMIT "a_signal" "a_source";
1839 * }
1840 * @endcode
1841 * is run, if @p emission and @p source are given those same values,
1842 * here.
1843 *
1844 * Signal callback registration is powerful, in the way that @b blobs
1845 * may be used to match <b>multiple signals at once</b>. All the @c
1846 * "*?[\" set of @c fnmatch() operators can be used, both for @p
1847 * emission and @p source.
1848 *
1849 * Edje has @b internal signals it will emit, automatically, on
1850 * various actions taking place on group parts. For example, the mouse
1851 * cursor being moved, pressed, released, etc., over a given part's
1852 * area, all generate individual signals.
1853 *
1854 * By using something like
1855 * @code
1856 * edje_object_signal_callback_add(obj, "mouse,down,*", "button.*",
1857 * signal_cb, NULL);
1858 * @endcode
1859 * being @c "button.*" the pattern for the names of parts implementing
1860 * buttons on an interface, you'd be registering for notifications on
1861 * events of mouse buttons being pressed down on either of those parts
1862 * (those events all have the @c "mouse,down," common prefix on their
1863 * names, with a suffix giving the button number). The actual emisson
1864 * and source strings of an event will be passed in as the @a emission
1865 * and @a source parameters of the callback function (e.g. @c
1866 * "mouse,down,2" and @c "button.close"), for each of those events.
1867 *
1868 * @note See @ref edcref "the syntax" for EDC files
1869 * @see edje_object_signal_emit() on how to emits Edje signals from
1870 * code to a an object
1871 * @see edje_object_signal_callback_del_full()
1872 */
1873EAPI void edje_object_signal_callback_add (Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func, void *data);
1874
1875/**
1876 * @brief Remove a signal-triggered callback from an object.
1877 *
1878 * @param obj A valid Evas_Object handle.
1879 * @param emission The emission string.
1880 * @param source The source string.
1881 * @param func The callback function.
1882 * @return The data pointer
1883 *
1884 * This function removes a callback, previously attached to the
1885 * emittion of a signal, from the object @a obj. The parameters @a
1886 * emission, @a source and @a func must match exactly those passed to
1887 * a previous call to edje_object_signal_callback_add(). The data
1888 * pointer that was passed to this call will be returned.
1889 *
1890 * @see edje_object_signal_callback_add().
1891 * @see edje_object_signal_callback_del_full().
1892 *
1893 */
1894EAPI void *edje_object_signal_callback_del (Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func);
1895
1896/**
1897 * @brief Unregister/delete a callback set for an arriving Edje
1898 * signal, emitted by a given Ejde object.
1899 *
1900 * @param obj A handle to an Edje object
1901 * @param emission The signal's "emission" string
1902 * @param source The signal's "source" string
1903 * @param func The callback function passed on the callback's
1904 * registration
1905 * @param data The pointer given to be passed as data to @p func
1906 * @return @p data, on success or @c NULL, on errors (or if @p data
1907 * had this value)
1908 *
1909 * This function removes a callback, previously attached to the
1910 * emittion of a signal, from the object @a obj. The parameters
1911 * @a emission, @a source, @a func and @a data must match exactly those
1912 * passed to a previous call to edje_object_signal_callback_add(). The
1913 * data pointer that was passed to this call will be returned.
1914 *
1915 * @see edje_object_signal_callback_add().
1916 * @see edje_object_signal_callback_del().
1917 *
1918 */
1919EAPI void *edje_object_signal_callback_del_full(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func, void *data);
1920
1921/**
1922 * @brief Send/emit an Edje signal to a given Edje object
1923 *
1924 * @param obj A handle to an Edje object
1925 * @param emission The signal's "emission" string
1926 * @param source The signal's "source" string
1927 *
1928 * This function sends a signal to the object @a obj. An Edje program,
1929 * at @p obj's EDC specification level, can respond to a signal by
1930 * having declared matching @c 'signal' and @c 'source' fields on its
1931 * block (see @ref edcref "the syntax" for EDC files).
1932 *
1933 * As an example,
1934 * @code
1935 * edje_object_signal_emit(obj, "a_signal", "");
1936 * @endcode
1937 * would trigger a program which had an EDC declaration block like
1938 * @code
1939 * program {
1940 * name: "a_program";
1941 * signal: "a_signal";
1942 * source: "";
1943 * action: ...
1944 * }
1945 * @endcode
1946 *
1947 * @see edje_object_signal_callback_add() for more on Edje signals.
1948 */
1949EAPI void edje_object_signal_emit (Evas_Object *obj, const char *emission, const char *source);
1950
1951/**
1952 * @brief Get extra data passed to callbacks.
1953 *
1954 * @return the extra data for that callback.
1955 *
1956 * Some callbacks pass extra information. This function gives access to that
1957 * extra information. It's somehow like event_info in smart callbacks.
1958 *
1959 * @see edje_object_signal_callback_add() for more on Edje signals.
1960 * @since 1.1.0
1961 */
1962EAPI void * edje_object_signal_callback_extra_data_get(void);
1963
1964/**
1965 * @brief Set the Edje object to playing or paused states.
1966 *
1967 * @param obj A handle to an Edje object.
1968 * @param play Object state (@c EINA_TRUE to playing,
1969 * @c EINA_FALSE to paused).
1970 *
1971 * This function sets the Edje object @a obj to playing or paused
1972 * states, depending on the parameter @a play. This has no effect if
1973 * the object was already at that state.
1974 *
1975 * @see edje_object_play_get().
1976 *
1977 */
1978EAPI void edje_object_play_set (Evas_Object *obj, Eina_Bool play);
1979
1980/**
1981 * @brief Get the Edje object's state.
1982 *
1983 * @param obj A handle to an Edje object.
1984 * @return @c EINA_FALSE if the object is not connected, its @c delete_me flag
1985 * is set, or it is at paused state; @c EINA_TRUE if the object is at playing
1986 * state.
1987 *
1988 * This function tells if an Edje object is playing or not. This state
1989 * is set by edje_object_play_set().
1990 *
1991 * @see edje_object_play_set().
1992 *
1993 */
1994EAPI Eina_Bool edje_object_play_get (const Evas_Object *obj);
1995
1996/**
1997 * @brief Set the object's animation state.
1998 *
1999 * @param obj A handle to an Edje object.
2000 * @param on The animation state. @c EINA_TRUE to starts or
2001 * @c EINA_FALSE to stops.
2002 *
2003 * This function starts or stops an Edje object's animation. The
2004 * information if it's stopped can be retrieved by
2005 * edje_object_animation_get().
2006 *
2007 * @see edje_object_animation_get()
2008 *
2009 */
2010EAPI void edje_object_animation_set (Evas_Object *obj, Eina_Bool on);
2011
2012/**
2013 * @brief Get the Edje object's animation state.
2014 *
2015 * @param obj A handle to an Edje object.
2016 * @return @c EINA_FALSE on error or if object is not animated;
2017 * @c EINA_TRUE if animated.
2018 *
2019 * This function returns if the animation is stopped or not. The
2020 * animation state is set by edje_object_animation_set().
2021 *
2022 * @see edje_object_animation_set().
2023 *
2024 */
2025EAPI Eina_Bool edje_object_animation_get (const Evas_Object *obj);
2026
2027/**
2028 * @brief Freezes the Edje object.
2029 *
2030 * @param obj A handle to an Edje object.
2031 * @return The frozen state or 0 on Error
2032 *
2033 * This function puts all changes on hold. Successive freezes will
2034 * nest, requiring an equal number of thaws.
2035 *
2036 * @see edje_object_thaw()
2037 */
2038EAPI int edje_object_freeze (Evas_Object *obj);
2039
2040/**
2041 * @brief Thaws the Edje object.
2042 *
2043 * @param obj A handle to an Edje object.
2044 * @return The frozen state or 0 if the object is not frozen or on error.
2045 *
2046 * This function thaws the given Edje object.
2047 *
2048 * @note: If sucessives freezes were done, an equal number of
2049 * thaws will be required.
2050 *
2051 * @see edje_object_freeze()
2052 */
2053EAPI int edje_object_thaw (Evas_Object *obj);
2054
2055/**
2056 * @brief Sets the object color class.
2057 *
2058 * @param obj A valid Evas_Object handle
2059 * @param color_class
2060 * @param r Object Red value
2061 * @param g Object Green value
2062 * @param b Object Blue value
2063 * @param a Object Alpha value
2064 * @param r2 Outline Red value
2065 * @param g2 Outline Green value
2066 * @param b2 Outline Blue value
2067 * @param a2 Outline Alpha value
2068 * @param r3 Shadow Red value
2069 * @param g3 Shadow Green value
2070 * @param b3 Shadow Blue value
2071 * @param a3 Shadow Alpha value
2072 *
2073 * This function sets the color values for an object level color
2074 * class. This will cause all edje parts in the specified object that
2075 * have the specified color class to have their colors multiplied by
2076 * these values.
2077 *
2078 * The first color is the object, the second is the text outline, and
2079 * the third is the text shadow. (Note that the second two only apply
2080 * to text parts).
2081 *
2082 * Setting color emits a signal "color_class,set" with source being
2083 * the given color.
2084 *
2085 * @note unlike Evas, Edje colors are @b not pre-multiplied. That is,
2086 * half-transparent white is 255 255 255 128.
2087 */
2088EAPI Eina_Bool edje_object_color_class_set (Evas_Object *obj, const char *color_class, int r, int g, int b, int a, int r2, int g2, int b2, int a2, int r3, int g3, int b3, int a3);
2089
2090/**
2091 * @brief Gets the object color class.
2092 *
2093 * @param o A valid Evas_Object handle
2094 * @param color_class
2095 * @param r Object Red value
2096 * @param g Object Green value
2097 * @param b Object Blue value
2098 * @param a Object Alpha value
2099 * @param r2 Outline Red value
2100 * @param g2 Outline Green value
2101 * @param b2 Outline Blue value
2102 * @param a2 Outline Alpha value
2103 * @param r3 Shadow Red value
2104 * @param g3 Shadow Green value
2105 * @param b3 Shadow Blue value
2106 * @param a3 Shadow Alpha value
2107 *
2108 * @return EINA_TRUE if found or EINA_FALSE if not found and all
2109 * values are zeroed.
2110 *
2111 * This function gets the color values for an object level color
2112 * class. If no explicit object color is set, then global values will
2113 * be used.
2114 *
2115 * The first color is the object, the second is the text outline, and
2116 * the third is the text shadow. (Note that the second two only apply
2117 * to text parts).
2118 *
2119 * @note unlike Evas, Edje colors are @b not pre-multiplied. That is,
2120 * half-transparent white is 255 255 255 128.
2121 */
2122EAPI Eina_Bool edje_object_color_class_get (const Evas_Object *o, const char *color_class, int *r, int *g, int *b, int *a, int *r2, int *g2, int *b2, int *a2, int *r3, int *g3, int *b3, int *a3);
2123
2124/**
2125 * @brief Delete the object color class.
2126 *
2127 * @param obj The edje object's reference.
2128 * @param color_class The color class to be deleted.
2129 *
2130 * This function deletes any values at the object level for the
2131 * specified object and color class.
2132 * @note Deleting the color class will revert it to the values
2133 * defined by edje_color_class_set() or the color class
2134 * defined in the theme file.
2135 *
2136 * Deleting the color class will emit the signal "color_class,del"
2137 * for the given Edje object.
2138 */
2139 EAPI void edje_object_color_class_del (Evas_Object *obj, const char *color_class);
2140
2141/**
2142 * @brief Sets Edje text class.
2143 *
2144 * @param obj A valid Evas_Object handle
2145 * @param text_class The text class name
2146 * @param font Font name
2147 * @param size Font Size
2148 *
2149 * @return @c EINA_TRUE, on success or @c EINA_FALSE, on error
2150 *
2151 * This function sets the text class for the Edje.
2152 *
2153 */
2154EAPI Eina_Bool edje_object_text_class_set (Evas_Object *obj, const char *text_class, const char *font, Evas_Font_Size size);
2155
2156/**
2157 * @brief Get the minimum size specified -- as an EDC property -- for a
2158 * given Edje object
2159 *
2160 * @param obj A handle to an Edje object
2161 * @param minw Pointer to a variable where to store the minimum width
2162 * @param minh Pointer to a variable where to store the minimum height
2163 *
2164 * This function retrieves the @p obj object's minimum size values,
2165 * <b>as declared in its EDC group definition</b>. Minimum size of
2166 * groups have the following syntax
2167 * @code
2168 * collections {
2169 * group {
2170 * name: "a_group";
2171 * min: 100 100;
2172 * }
2173 * }
2174 * @endcode
2175 *
2176 * where one declares a minimum size of 100 pixels both for width and
2177 * height. Those are (hint) values which should be respected when the
2178 * given object/group is to be controlled by a given container object
2179 * (e.g. an Edje object being "swallowed" into a given @c SWALLOW
2180 * typed part, as in edje_object_part_swallow()). Check the complete
2181 * @ref edcref "syntax reference" for EDC files.
2182 *
2183 * @note If the @c min EDC property was not declared for @p obj, this
2184 * call will return the value 0, for each axis.
2185 *
2186 * @note On failure, this function will make all non-@c NULL size
2187 * pointers' pointed variables be set to zero.
2188 *
2189 * @see edje_object_size_max_get()
2190 */
2191EAPI void edje_object_size_min_get (const Evas_Object *obj, Evas_Coord *minw, Evas_Coord *minh);
2192
2193/**
2194 * @brief Get the maximum size specified -- as an EDC property -- for a
2195 * given Edje object
2196 *
2197 * @param obj A handle to an Edje object
2198 * @param maxw Pointer to a variable where to store the maximum width
2199 * @param maxh Pointer to a variable where to store the maximum height
2200 *
2201 * This function retrieves the @p obj object's maximum size values,
2202 * <b>as declared in its EDC group definition</b>. Maximum size of
2203 * groups have the following syntax
2204 * @code
2205 * collections {
2206 * group {
2207 * name: "a_group";
2208 * max: 100 100;
2209 * }
2210 * }
2211 * @endcode
2212 *
2213 * where one declares a maximum size of 100 pixels both for width and
2214 * height. Those are (hint) values which should be respected when the
2215 * given object/group is to be controlled by a given container object
2216 * (e.g. an Edje object being "swallowed" into a given @c SWALLOW
2217 * typed part, as in edje_object_part_swallow()). Check the complete
2218 * @ref edcref "syntax reference" for EDC files.
2219 *
2220 * @note If the @c max EDC property was not declared for @p obj, this
2221 * call will return the maximum size a given Edje object may have, for
2222 * each axis.
2223 *
2224 * @note On failure, this function will make all non-@c NULL size
2225 * pointers' pointed variables be set to zero.
2226 *
2227 * @see edje_object_size_min_get()
2228 */
2229EAPI void edje_object_size_max_get (const Evas_Object *obj, Evas_Coord *maxw, Evas_Coord *maxh);
2230
2231/**
2232 * @brief Force a Size/Geometry calculation.
2233 *
2234 * @param obj A valid Evas_Object handle
2235 *
2236 * Forces the object @p obj to recalculation layout regardless of
2237 * freeze/thaw.
2238 */
2239EAPI void edje_object_calc_force (Evas_Object *obj);
2240
2241/**
2242 * @brief Calculate the minimum required size for a given Edje object.
2243 *
2244 * @param obj A handle to an Edje object
2245 * @param minw Pointer to a variable where to store the minimum
2246 * required width
2247 * @param minh Pointer to a variable where to store the minimum
2248 * required height
2249 *
2250 * This call works exactly as edje_object_size_min_restricted_calc(),
2251 * with the last two arguments set to 0. Please refer to its
2252 * documentation, then.
2253 */
2254EAPI void edje_object_size_min_calc (Evas_Object *obj, Evas_Coord *minw, Evas_Coord *minh);
2255
2256/**
2257 * Calculate the geometry of the region, relative to a given Edje
2258 * object's area, <b>occupied by all parts in the object</b>
2259 *
2260 * @param obj A handle to an Edje object
2261 * @param part The Edje part's name
2262 * @param x A pointer to a variable where to store the parts region's
2263 * x coordinate
2264 * @param y A pointer to a variable where to store the parts region's
2265 * y coordinate
2266 * @param w A pointer to a variable where to store the parts region's
2267 * width
2268 * @param h A pointer to a variable where to store the parts region's
2269 * height
2270 *
2271 * This function gets the geometry of the rectangle equal to the area
2272 * required to group all parts in @p obj's group/collection. The @p x
2273 * and @p y coordinates are relative to the top left corner of the
2274 * whole @p obj object's area. Parts placed out of the group's
2275 * boundaries will also be taken in account, so that @p x and @p y
2276 * <b>may be negative</b>.
2277 *
2278 * @note Use @c NULL pointers on the geometry components you're not
2279 * interested in: they'll be ignored by the function.
2280 *
2281 * @note On failure, this function will make all non-@c NULL geometry
2282 * pointers' pointed variables be set to zero.
2283 */
2284EAPI Eina_Bool edje_object_parts_extends_calc (Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h);
2285
2286/**
2287 * @brief Calculate the minimum required size for a given Edje object.
2288 *
2289 * @param obj A handle to an Edje object
2290 * @param minw Pointer to a variable where to store the minimum
2291 * required width
2292 * @param minh Pointer to a variable where to store the minimum
2293 * required height
2294 * @param restrictedw Do not allow object's calculated (minimum) width
2295 * to be less than this value
2296 * @param restrictedh Do not allow object's calculated (minimum)
2297 * height to be less than this value
2298 *
2299 * This call will trigger an internal recalculation of all parts of
2300 * the @p obj object, in order to return its minimum required
2301 * dimensions for width and height. The user might choose to @b impose
2302 * those minimum sizes, making the resulting calculation to get to values
2303 * equal or bigger than @p restrictedw and @p restrictedh, for width and
2304 * height, respectively.
2305 *
2306 * @note At the end of this call, @p obj @b won't be automatically
2307 * resized to new dimensions, but just return the calculated
2308 * sizes. The caller is the one up to change its geometry or not.
2309 *
2310 * @warning Be advised that invisible parts in @p obj @b will be taken
2311 * into account in this calculation.
2312 */
2313EAPI void edje_object_size_min_restricted_calc(Evas_Object *obj, Evas_Coord *minw, Evas_Coord *minh, Evas_Coord restrictedw, Evas_Coord restrictedh);
2314
2315/**
2316 * @brief Check if an Edje part exists in a given Edje object's group
2317 * definition..
2318 *
2319 * @param obj A handle to an Edje object
2320 * @param part The part's name to check for existence in @p obj's
2321 * group
2322 * @return @c EINA_TRUE, if the Edje part exists in @p obj's group or
2323 * @c EINA_FALSE, otherwise (and on errors)
2324 *
2325 * This function returns if a given part exists in the Edje group
2326 * bound to object @p obj (with edje_object_file_set()).
2327 *
2328 * This call is useful, for example, when one could expect or not a
2329 * given GUI element, depending on the @b theme applied to @p obj.
2330 */
2331EAPI Eina_Bool edje_object_part_exists (const Evas_Object *obj, const char *part);
2332
2333/**
2334 * @brief Get a handle to the Evas object implementing a given Edje
2335 * part, in an Edje object.
2336 *
2337 * @param obj A handle to an Edje object
2338 * @param part The Edje part's name
2339 * @return A pointer to the Evas object implementing the given part,
2340 * or @c NULL on failure (e.g. the given part doesn't exist)
2341 *
2342 * This function gets a pointer the Evas object corresponding to a
2343 * given part in the @p obj object's group.
2344 *
2345 * You should @b never modify the state of the returned object (with
2346 * @c evas_object_move() or @c evas_object_hide() for example),
2347 * because it's meant to be managed be Edje, solely. You are safe to
2348 * query information about its current state (with @c
2349 * evas_object_visible_get() or @c evas_object_color_get() for
2350 * example), though.
2351 */
2352EAPI const Evas_Object *edje_object_part_object_get (const Evas_Object *obj, const char *part);
2353
2354/**
2355 * @brief Retrieve the geometry of a given Edje part, in a given Edje
2356 * object's group definition, <b>relative to the object's area</b>
2357 *
2358 * @param obj A handle to an Edje object
2359 * @param part The Edje part's name
2360 * @param x A pointer to a variable where to store the part's x
2361 * coordinate
2362 * @param y A pointer to a variable where to store the part's y
2363 * coordinate
2364 * @param w A pointer to a variable where to store the part's width
2365 * @param h A pointer to a variable where to store the part's height
2366 *
2367 * This function gets the geometry of an Edje part within its
2368 * group. The @p x and @p y coordinates are relative to the top left
2369 * corner of the whole @p obj object's area.
2370 *
2371 * @note Use @c NULL pointers on the geometry components you're not
2372 * interested in: they'll be ignored by the function.
2373 *
2374 * @note On failure, this function will make all non-@c NULL geometry
2375 * pointers' pointed variables be set to zero.
2376 */
2377EAPI Eina_Bool edje_object_part_geometry_get (const Evas_Object *obj, const char *part, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h);
2378
2379
2380/**
2381 * @brief Set the function that provides item objects for named items in an edje entry text
2382 *
2383 * @param obj A valid Evas Object handle
2384 * @param func The function to call (or NULL to disable) to get item objects
2385 * @param data The data pointer to pass to the @p func callback
2386 *
2387 * Item objects may be deleted any time by Edje, and will be deleted when the
2388 * Edje object is deleted (or file is set to a new file).
2389 */
2390EAPI void edje_object_item_provider_set (Evas_Object *obj, Edje_Item_Provider_Cb func, void *data);
2391
2392
2393/**
2394 * @brief Set the object text callback.
2395 *
2396 * @param obj A valid Evas_Object handle
2397 * @param func The callback function to handle the text change
2398 * @param data The data associated to the callback function.
2399 *
2400 * This function sets the callback to be called when the text changes.
2401 */
2402EAPI void edje_object_text_change_cb_set (Evas_Object *obj, Edje_Text_Change_Cb func, void *data);
2403
2404/**
2405 * @brief Sets the text for an object part
2406 *
2407 * @param obj A valid Evas Object handle
2408 * @param part The part name
2409 * @param text The text string
2410 */
2411EAPI Eina_Bool edje_object_part_text_set (Evas_Object *obj, const char *part, const char *text);
2412
2413/**
2414 * @brief Return the text of the object part.
2415 *
2416 * @param obj A valid Evas_Object handle
2417 * @param part The part name
2418 *
2419 * @return The text string
2420 *
2421 * This function returns the text associated to the object part.
2422 *
2423 * @see edje_object_part_text_set().
2424 */
2425EAPI const char *edje_object_part_text_get (const Evas_Object *obj, const char *part);
2426
2427/**
2428 * @brief Sets the raw (non escaped) text for an object part.
2429 *
2430 * @param obj A valid Evas Object handle
2431 * @param part The part name
2432 * @param text_to_escape The text string
2433 *
2434 * This funciton will not do escape for you if it is a TEXTBLOCK part, that is,
2435 * if text contain tags, these tags will not be interpreted/parsed by TEXTBLOCK.
2436 *
2437 * @see edje_object_part_text_unescaped_get().
2438 */
2439EAPI Eina_Bool edje_object_part_text_unescaped_set (Evas_Object *obj, const char *part, const char *text_to_escape);
2440
2441/**
2442 * @brief Returns the text of the object part, without escaping.
2443 *
2444 * @param obj A valid Evas_Object handle
2445 * @param part The part name
2446 * @return The @b allocated text string without escaping, or NULL on
2447 * problems.
2448 *
2449 * This function is the counterpart of
2450 * edje_object_part_text_unescaped_set(). Please notice that the
2451 * result is newly allocated memory and should be released with free()
2452 * when done.
2453 *
2454 * @see edje_object_part_text_unescaped_set().
2455 */
2456EAPI char *edje_object_part_text_unescaped_get (const Evas_Object *obj, const char *part);
2457
2458/**
2459 * @brief Return the selection text of the object part.
2460 *
2461 * @param obj A valid Evas_Object handle
2462 * @param part The part name
2463 * @return The text string
2464 *
2465 * This function returns selection text of the object part.
2466 *
2467 * @see edje_object_part_text_select_all()
2468 * @see edje_object_part_text_select_none()
2469 */
2470EAPI const char *edje_object_part_text_selection_get (const Evas_Object *obj, const char *part);
2471
2472/**
2473 * @brief Set the selection to be none.
2474 *
2475 * @param obj A valid Evas_Object handle
2476 * @param part The part name
2477 *
2478 * This function sets the selection text to be none.
2479 */
2480EAPI void edje_object_part_text_select_none (const Evas_Object *obj, const char *part);
2481
2482/**
2483 * @brief Set the selection to be everything.
2484 *
2485 * @param obj A valid Evas_Object handle
2486 * @param part The part name
2487 *
2488 * This function selects all text of the object of the part.
2489 */
2490EAPI void edje_object_part_text_select_all (const Evas_Object *obj, const char *part);
2491
2492/**
2493 * @brief Insert text for an object part.
2494 *
2495 * @param obj A valid Evas Object handle
2496 * @param part The part name
2497 * @param text The text string
2498 *
2499 * This function inserts the text for an object part just before the
2500 * cursor position.
2501 *
2502 */
2503EAPI void edje_object_part_text_insert (Evas_Object *obj, const char *part, const char *text);
2504
2505/**
2506 * @brief Insert text for an object part.
2507 *
2508 * @param obj A valid Evas Object handle
2509 * @param part The part name
2510 * @param text The text string
2511 *
2512 * This function inserts the text for an object part at the end; It does not
2513 * move the cursor.
2514 *
2515 * @since 1.1
2516 */
2517EAPI void edje_object_part_text_append(Evas_Object *obj, const char *part, const char *text);
2518
2519/**
2520 * @brief Return a list of char anchor names.
2521 *
2522 * @param obj A valid Evas_Object handle
2523 * @param part The part name
2524 *
2525 * @return The list of anchors (const char *), do not modify!
2526 *
2527 * This function returns a list of char anchor names.
2528 *
2529 */
2530EAPI const Eina_List *edje_object_part_text_anchor_list_get (const Evas_Object *obj, const char *part);
2531
2532/**
2533 * @brief Return a list of Evas_Textblock_Rectangle anchor rectangles.
2534 *
2535 * @param obj A valid Evas_Object handle
2536 * @param part The part name
2537 * @param anchor The anchor name
2538 *
2539 * @return The list of anchor rects (const Evas_Textblock_Rectangle
2540 * *), do not modify! Geometry is relative to entry part.
2541 *
2542 * This function return a list of Evas_Textblock_Rectangle anchor
2543 * rectangles.
2544 *
2545 */
2546EAPI const Eina_List *edje_object_part_text_anchor_geometry_get (const Evas_Object *obj, const char *part, const char *anchor);
2547
2548/**
2549 * @brief Return a list of char item names.
2550 *
2551 * @param obj A valid Evas_Object handle
2552 * @param part The part name
2553 *
2554 * @return The list of items (const char *), do not modify!
2555 *
2556 * This function returns a list of char item names.
2557 *
2558 */
2559EAPI const Eina_List *edje_object_part_text_item_list_get (const Evas_Object *obj, const char *part);
2560
2561/**
2562 * @brief Return item geometry.
2563 *
2564 * @param obj A valid Evas_Object handle
2565 * @param part The part name
2566 * @param item The item name
2567 * @param cx Item x return (relative to entry part)
2568 * @param cy Item y return (relative to entry part)
2569 * @param cw Item width return
2570 * @param ch Item height return
2571 *
2572 * @return 1 if item exists, 0 if not
2573 *
2574 * This function return a list of Evas_Textblock_Rectangle item
2575 * rectangles.
2576 *
2577 */
2578EAPI Eina_Bool edje_object_part_text_item_geometry_get (const Evas_Object *obj, const char *part, const char *item, Evas_Coord *cx, Evas_Coord *cy, Evas_Coord *cw, Evas_Coord *ch);
2579
2580/**
2581 * @brief Returns the cursor geometry of the part relative to the edje
2582 * object.
2583 *
2584 * @param obj A valid Evas_Object handle
2585 * @param part The part name
2586 * @param x Cursor X position
2587 * @param y Cursor Y position
2588 * @param w Cursor width
2589 * @param h Cursor height
2590 *
2591 */
2592EAPI void edje_object_part_text_cursor_geometry_get (const Evas_Object *obj, const char *part, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h);
2593
2594/**
2595 * @brief Enables selection if the entry is an EXPLICIT selection mode
2596 * type.
2597 *
2598 * @param obj A valid Evas_Object handle
2599 * @param part The part name
2600 * @param allow EINA_TRUE to enable, EINA_FALSE otherwise
2601 *
2602 * The default is to @b not allow selection. This function only affects user
2603 * selection, functions such as edje_object_part_text_select_all() and
2604 * edje_object_part_text_select_none() are not affected.
2605 */
2606EAPI void edje_object_part_text_select_allow_set (const Evas_Object *obj, const char *part, Eina_Bool allow);
2607
2608/**
2609 * @brief Aborts any selection action on a part.
2610 *
2611 * @param obj A valid Evas_Object handle
2612 * @param part The part name
2613 */
2614EAPI void edje_object_part_text_select_abort (const Evas_Object *obj, const char *part);
2615
2616/**
2617 * @brief Starts selecting at current cursor position
2618 *
2619 * @param obj A valid Evas_Object handle
2620 * @param part The part name
2621 */
2622EAPI void edje_object_part_text_select_begin (const Evas_Object *obj, const char *part);
2623
2624/**
2625 * @brief Extends the current selection to the current cursor position
2626 *
2627 * @param obj A valid Evas_Object handle
2628 * @param part The part name
2629 */
2630EAPI void edje_object_part_text_select_extend (const Evas_Object *obj, const char *part);
2631
2632
2633/**
2634 * @brief Advances the cursor to the next cursor position.
2635 * @see evas_textblock_cursor_char_next
2636 *
2637 * @param obj A valid Evas_Object handle
2638 * @param part The part name
2639 * @param cur The edje cursor to advance
2640 */
2641EAPI Eina_Bool edje_object_part_text_cursor_next (Evas_Object *obj, const char *part, Edje_Cursor cur);
2642
2643/**
2644 * @brief Moves the cursor to the previous char
2645 * @see evas_textblock_cursor_char_prev
2646 *
2647 * @param obj A valid Evas_Object handle
2648 * @param part The part name
2649 * @param cur the edje cursor to work on
2650 */
2651EAPI Eina_Bool edje_object_part_text_cursor_prev (Evas_Object *obj, const char *part, Edje_Cursor cur);
2652
2653/**
2654 * @brief Move the cursor to the char above the current cursor position.
2655 *
2656 * @param obj A valid Evas_Object handle
2657 * @param part The part name
2658 * @param cur the edje cursor to work on
2659 */
2660EAPI Eina_Bool edje_object_part_text_cursor_up (Evas_Object *obj, const char *part, Edje_Cursor cur);
2661
2662/**
2663 * @brief Moves the cursor to the char below the current cursor position.
2664 *
2665 * @param obj A valid Evas_Object handle
2666 * @param part The part name
2667 * @param cur the edje cursor to work on
2668 */
2669EAPI Eina_Bool edje_object_part_text_cursor_down (Evas_Object *obj, const char *part, Edje_Cursor cur);
2670
2671/**
2672 * @brief Moves the cursor to the beginning of the text part
2673 * @see evas_textblock_cursor_paragraph_first
2674 *
2675 * @param obj A valid Evas_Object handle
2676 * @param part The part name
2677 * @param cur the edje cursor to work on
2678 */
2679EAPI void edje_object_part_text_cursor_begin_set (Evas_Object *obj, const char *part, Edje_Cursor cur);
2680
2681/**
2682 * @brief Moves the cursor to the end of the text part.
2683 * @see evas_textblock_cursor_paragraph_last
2684 *
2685 * @param obj A valid Evas_Object handle
2686 * @param part The part name
2687 * @param cur the edje cursor to work on
2688 */
2689EAPI void edje_object_part_text_cursor_end_set (Evas_Object *obj, const char *part, Edje_Cursor cur);
2690
2691/**
2692 * @brief Copy the cursor to another cursor.
2693 *
2694 * @param obj A valid Evas_Object handle
2695 * @param part The part name
2696 * @param sry the cursor to copy from
2697 * @param dst the cursor to copy to
2698 */
2699EAPI void edje_object_part_text_cursor_copy (Evas_Object *obj, const char *part, Edje_Cursor src, Edje_Cursor dst);
2700
2701/**
2702 * @brief Move the cursor to the beginning of the line.
2703 * @see evas_textblock_cursor_line_char_first
2704 *
2705 * @param obj A valid Evas_Object handle
2706 * @param part The part name
2707 * @param cur the edje cursor to work on
2708 */
2709EAPI void edje_object_part_text_cursor_line_begin_set (Evas_Object *obj, const char *part, Edje_Cursor cur);
2710
2711/**
2712 * @brief Move the cursor to the end of the line.
2713 * @see evas_textblock_cursor_line_char_last
2714 *
2715 * @param obj A valid Evas_Object handle
2716 * @param part The part name
2717 * @param cur the edje cursor to work on
2718 */
2719EAPI void edje_object_part_text_cursor_line_end_set (Evas_Object *obj, const char *part, Edje_Cursor cur);
2720
2721/**
2722 * Position the given cursor to a X,Y position.
2723 *
2724 * This is frequently used with the user cursor.
2725 *
2726 * @param obj An Edje object.
2727 * @param part The part containing the object.
2728 * @param cur The cursor to adjust.
2729 * @param x X Coordinate.
2730 * @param y Y Coordinate.
2731 * @return True on success, false on error.
2732 */
2733EAPI Eina_Bool edje_object_part_text_cursor_coord_set (Evas_Object *obj, const char *part, Edje_Cursor cur, Evas_Coord x, Evas_Coord y);
2734
2735/**
2736 * @brief Returns whether the cursor points to a format.
2737 * @see evas_textblock_cursor_is_format
2738 *
2739 * @param obj A valid Evas_Object handle
2740 * @param part The part name
2741 * @param cur The cursor to adjust.
2742 * @return EINA_TRUE if it's true, EINA_FALSE otherwise.
2743 */
2744EAPI Eina_Bool edje_object_part_text_cursor_is_format_get (const Evas_Object *obj, const char *part, Edje_Cursor cur);
2745
2746/**
2747 * @brief Return true if the cursor points to a visible format
2748 * For example \t, \n, item and etc.
2749 * @see evas_textblock_cursor_format_is_visible_get
2750 *
2751 * @param obj A valid Evas_Object handle
2752 * @param part The part name
2753 * @param cur The cursor to adjust.
2754 */
2755EAPI Eina_Bool edje_object_part_text_cursor_is_visible_format_get(const Evas_Object *obj, const char *part, Edje_Cursor cur);
2756
2757/**
2758 * @brief Returns the content (char) at the cursor position.
2759 * @see evas_textblock_cursor_content_get
2760 *
2761 * @param obj A valid Evas_Object handle
2762 * @param part The part name
2763 * @param cur The cursor to use
2764 */
2765EAPI const char *edje_object_part_text_cursor_content_get (const Evas_Object *obj, const char *part, Edje_Cursor cur);
2766
2767/**
2768 * @brief Sets the cursor position to the given value
2769 *
2770 * @param obj A valid Evas_Object handle
2771 * @param part The part name
2772 * @param cur The cursor to move
2773 * @param pos the position of the cursor
2774 * @since 1.1.0
2775 */
2776EAPI void edje_object_part_text_cursor_pos_set (Evas_Object *obj, const char *part, Edje_Cursor cur, int pos);
2777
2778/**
2779 * @brief Retrieves the current position of the cursor
2780 *
2781 * @param obj A valid Evas_Object handle
2782 * @param part The part name
2783 * @param cur The cursor to get the position
2784 * @return The cursor position
2785 * @since 1.1.0
2786 */
2787EAPI int edje_object_part_text_cursor_pos_get (const Evas_Object *obj, const char *part, Edje_Cursor cur);
2788
2789/**
2790 * @brief Set the layout of the input panel.
2791 *
2792 * The layout of the input panel or virtual keyboard can make it easier or
2793 * harder to enter content. This allows you to hint what kind of input you
2794 * are expecting to enter and thus have the input panel automatically
2795 * come up with the right mode.
2796 *
2797 * @param obj A valid Evas_Object handle
2798 * @param part The part name
2799 * @param layout layout type
2800 * @since 1.1
2801 */
2802EAPI void edje_object_part_text_input_panel_layout_set (const Evas_Object *obj, const char *part, Edje_Input_Panel_Layout layout);
2803
2804/**
2805 * @brief Get the layout of the input panel.
2806 *
2807 * @param obj A valid Evas_Object handle
2808 * @param part The part name
2809 *
2810 * @return Layout type of the input panel
2811 *
2812 * @see edje_object_part_text_input_panel_layout_set
2813 * @since 1.1
2814 */
2815EAPI Edje_Input_Panel_Layout edje_object_part_text_input_panel_layout_get (const Evas_Object *obj, const char *part);
2816
2817/**
2818 * @brief Set the autocapitalization type on the immodule.
2819 *
2820 * @param obj A valid Evas_Object handle
2821 * @param part The part name
2822 * @param autocapital_type The type of autocapitalization
2823 * @since 1.1.0
2824 */
2825EAPI void edje_object_part_text_autocapital_type_set (const Evas_Object *obj, const char *part, Edje_Text_Autocapital_Type autocapital_type);
2826
2827/**
2828 * @brief Retrieves the autocapitalization type
2829 *
2830 * @param obj A valid Evas_Object handle
2831 * @param part The part name
2832 * @return The autocapitalization type
2833 * @since 1.1.0
2834 */
2835EAPI Edje_Text_Autocapital_Type edje_object_part_text_autocapital_type_get (const Evas_Object *obj, const char *part);
2836
2837/**
2838 * @brief Sets the attribute to show the input panel automatically.
2839 *
2840 * @param obj A valid Evas_Object handle
2841 * @param part The part name
2842 * @param enabled If true, the input panel is appeared when entry is clicked or has a focus
2843 * @since 1.1.0
2844 */
2845EAPI void edje_object_part_text_input_panel_enabled_set (const Evas_Object *obj, const char *part, Eina_Bool enabled);
2846
2847/**
2848 * @brief Retrieve the attribute to show the input panel automatically.
2849 * @see edje_object_part_text_input_panel_enabled_set
2850 *
2851 * @param obj A valid Evas_Object handle
2852 * @param part The part name
2853 * @return EINA_TRUE if it supports or EINA_FALSE otherwise
2854 * @since 1.1.0
2855 */
2856EAPI Eina_Bool edje_object_part_text_input_panel_enabled_get (const Evas_Object *obj, const char *part);
2857
2858/**
2859 * Add a filter function for newly inserted text.
2860 *
2861 * Whenever text is inserted (not the same as set) into the given @p part,
2862 * the list of filter functions will be called to decide if and how the new
2863 * text will be accepted.
2864 * There are three types of filters, EDJE_TEXT_FILTER_TEXT,
2865 * EDJE_TEXT_FILTER_FORMAT and EDJE_TEXT_FILTER_MARKUP.
2866 * The text parameter in the @p func filter can be modified by the user and
2867 * it's up to him to free the one passed if he's to change the pointer. If
2868 * doing so, the newly set text should be malloc'ed, as once all the filters
2869 * are called Edje will free it.
2870 * If the text is to be rejected, freeing it and setting the pointer to NULL
2871 * will make Edje break out of the filter cycle and reject the inserted
2872 * text.
2873 *
2874 * @see edje_object_text_insert_filter_callback_del
2875 * @see edje_object_text_insert_filter_callback_del_full
2876 *
2877 * @param obj A valid Evas_Object handle
2878 * @param part The part name
2879 * @param func The callback function that will act as filter
2880 * @param data User provided data to pass to the filter function
2881 */
2882EAPI void edje_object_text_insert_filter_callback_add (Evas_Object *obj, const char *part, Edje_Text_Filter_Cb func, void *data);
2883
2884/**
2885 * Delete a function from the filter list.
2886 *
2887 * Delete the given @p func filter from the list in @p part. Returns
2888 * the user data pointer given when added.
2889 *
2890 * @see edje_object_text_insert_filter_callback_add
2891 * @see edje_object_text_insert_filter_callback_del_full
2892 *
2893 * @param obj A valid Evas_Object handle
2894 * @param part The part name
2895 * @param func The function callback to remove
2896 *
2897 * @return The user data pointer if succesful, or NULL otherwise
2898 */
2899EAPI void *edje_object_text_insert_filter_callback_del (Evas_Object *obj, const char *part, Edje_Text_Filter_Cb func);
2900
2901/**
2902 * Delete a function and matching user data from the filter list.
2903 *
2904 * Delete the given @p func filter and @p data user data from the list
2905 * in @p part.
2906 * Returns the user data pointer given when added.
2907 *
2908 * @see edje_object_text_insert_filter_callback_add
2909 * @see edje_object_text_insert_filter_callback_del
2910 *
2911 * @param obj A valid Evas_Object handle
2912 * @param part The part name
2913 * @param func The function callback to remove
2914 * @param data The data passed to the callback function
2915 *
2916 * @return The same data pointer if succesful, or NULL otherwise
2917 */
2918EAPI void *edje_object_text_insert_filter_callback_del_full (Evas_Object *obj, const char *part, Edje_Text_Filter_Cb func, void *data);
2919
2920/**
2921 * @brief Swallows an object into the edje.
2922 *
2923 * @param obj A valid Evas_Object handle
2924 * @param part The part name
2925 * @param obj_swallow The object to swallow
2926 *
2927 * Swallows the object into the edje part so that all geometry changes
2928 * for the part affect the swallowed object. (e.g. resize, move, show,
2929 * raise/lower, etc.).
2930 *
2931 * If an object has already been swallowed into this part, then it
2932 * will first be unswallowed before the new object is swallowed.
2933 */
2934EAPI Eina_Bool edje_object_part_swallow (Evas_Object *obj, const char *part, Evas_Object *obj_swallow);
2935
2936/**
2937 * @brief Unswallow an object.
2938 *
2939 * @param obj A valid Evas_Object handle
2940 * @param obj_swallow The swallowed object
2941 *
2942 * Causes the edje to regurgitate a previously swallowed object. :)
2943 *
2944 * @note @p obj_swallow will @b not be deleted.
2945 */
2946EAPI void edje_object_part_unswallow (Evas_Object *obj, Evas_Object *obj_swallow);
2947
2948/**
2949 * @brief Get the object currently swallowed by a part.
2950 *
2951 * @param obj A valid Evas_Object handle
2952 * @param part The part name
2953 * @return The swallowed object, or NULL if there is none.
2954 */
2955EAPI Evas_Object *edje_object_part_swallow_get (const Evas_Object *obj, const char *part);
2956
2957/**
2958 * @brief Returns the state of the Edje part.
2959 *
2960 * @param obj A valid Evas_Object handle
2961 * @param part The part name
2962 * @param val_ret
2963 *
2964 * @return The part state:\n
2965 * "default" for the default state\n
2966 * "" for other states
2967 */
2968EAPI const char *edje_object_part_state_get (const Evas_Object *obj, const char *part, double *val_ret);
2969
2970/**
2971 * @brief Determine dragable directions.
2972 *
2973 * @param obj A valid Evas_Object handle
2974 * @param part The part name
2975 *
2976 * The dragable directions are defined in the EDC file, inside the @c dragable
2977 * section, by the attributes @c x and @c y. See the @ref edcref for more
2978 * information.
2979 *
2980 * @return #EDJE_DRAG_DIR_NONE: Not dragable\n
2981 * #EDJE_DRAG_DIR_X: Dragable in X direction\n
2982 * #EDJE_DRAG_DIR_Y: Dragable in Y direction\n
2983 * #EDJE_DRAG_DIR_XY: Dragable in X & Y directions
2984 */
2985EAPI Edje_Drag_Dir edje_object_part_drag_dir_get (const Evas_Object *obj, const char *part);
2986
2987/**
2988 * @brief Set the dragable object location.
2989 *
2990 * @param obj A valid Evas_Object handle
2991 * @param part The part name
2992 * @param dx The x value
2993 * @param dy The y value
2994 *
2995 * Places the dragable object at the given location.
2996 *
2997 * Values for @p dx and @p dy are real numbers that range from 0 to 1,
2998 * representing the relative position to the dragable area on that axis.
2999 *
3000 * This value means, for the vertical axis, that 0.0 will be at the top if the
3001 * first parameter of @c y in the dragable part theme is 1, and at bottom if it
3002 * is -1.
3003 *
3004 * For the horizontal axis, 0.0 means left if the first parameter of @c x in the
3005 * dragable part theme is 1, and right if it is -1.
3006 *
3007 * @see edje_object_part_drag_value_get()
3008 */
3009EAPI Eina_Bool edje_object_part_drag_value_set (Evas_Object *obj, const char *part, double dx, double dy);
3010
3011/**
3012 * @brief Get the dragable object location.
3013 *
3014 * @param obj A valid Evas_Object handle
3015 * @param part The part name
3016 * @param dx The X value pointer
3017 * @param dy The Y value pointer
3018 *
3019 * Values for @p dx and @p dy are real numbers that range from 0 to 1,
3020 * representing the relative position to the dragable area on that axis.
3021 *
3022 * @see edje_object_part_drag_value_set()
3023 *
3024 * Gets the drag location values.
3025 */
3026EAPI Eina_Bool edje_object_part_drag_value_get (const Evas_Object *obj, const char *part, double *dx, double *dy);
3027
3028/**
3029 * @brief Set the dragable object size.
3030 *
3031 * @param obj A valid Evas_Object handle
3032 * @param part The part name
3033 * @param dw The drag width
3034 * @param dh The drag height
3035 *
3036 * Values for @p dw and @p dh are real numbers that range from 0 to 1,
3037 * representing the relative size of the dragable area on that axis.
3038 *
3039 * Sets the size of the dragable object.
3040 *
3041 * @see edje_object_part_drag_size_get()
3042 */
3043EAPI Eina_Bool edje_object_part_drag_size_set (Evas_Object *obj, const char *part, double dw, double dh);
3044
3045/**
3046 * @brief Get the dragable object size.
3047 *
3048 * @param obj A valid Evas_Object handle
3049 * @param part The part name
3050 * @param dw The drag width pointer
3051 * @param dh The drag height pointer
3052 *
3053 * Gets the dragable object size.
3054 *
3055 * @see edje_object_part_drag_size_set()
3056 */
3057EAPI Eina_Bool edje_object_part_drag_size_get (const Evas_Object *obj, const char *part, double *dw, double *dh);
3058
3059/**
3060 * @brief Sets the drag step increment.
3061 *
3062 * @param obj A valid Evas_Object handle
3063 * @param part The part name
3064 * @param dx The x step amount
3065 * @param dy The y step amount
3066 *
3067 * Sets the x,y step increments for a dragable object.
3068 *
3069 * Values for @p dx and @p dy are real numbers that range from 0 to 1,
3070 * representing the relative size of the dragable area on that axis by which the
3071 * part will be moved.
3072 *
3073 * @see edje_object_part_drag_step_get()
3074 */
3075EAPI Eina_Bool edje_object_part_drag_step_set (Evas_Object *obj, const char *part, double dx, double dy);
3076
3077/**
3078 * @brief Gets the drag step increment values.
3079 *
3080 * @param obj A valid Evas_Object handle
3081 * @param part The part
3082 * @param dx The x step increment pointer
3083 * @param dy The y step increment pointer
3084 *
3085 * Gets the x and y step increments for the dragable object.
3086 *
3087 *
3088 * @see edje_object_part_drag_step_set()
3089 */
3090EAPI Eina_Bool edje_object_part_drag_step_get (const Evas_Object *obj, const char *part, double *dx, double *dy);
3091
3092/**
3093 * @brief Sets the page step increments.
3094 *
3095 * @param obj A valid Evas_Object handle
3096 * @param part The part name
3097 * @param dx The x page step increment
3098 * @param dy The y page step increment
3099 *
3100 * Sets the x,y page step increment values.
3101 *
3102 * Values for @p dx and @p dy are real numbers that range from 0 to 1,
3103 * representing the relative size of the dragable area on that axis by which the
3104 * part will be moved.
3105 *
3106 * @see edje_object_part_drag_page_get()
3107 */
3108EAPI Eina_Bool edje_object_part_drag_page_set (Evas_Object *obj, const char *part, double dx, double dy);
3109
3110/**
3111 * @brief Gets the page step increments.
3112 *
3113 * @param obj A valid Evas_Object handle
3114 * @param part The part name
3115 * @param dx The dx page increment pointer
3116 * @param dy The dy page increment pointer
3117 *
3118 * Gets the x,y page step increments for the dragable object.
3119 *
3120 * @see edje_object_part_drag_page_set()
3121 */
3122EAPI Eina_Bool edje_object_part_drag_page_get (const Evas_Object *obj, const char *part, double *dx, double *dy);
3123
3124/**
3125 * @brief Steps the dragable x,y steps.
3126 *
3127 * @param obj A valid Evas_Object handle
3128 * @param part The part name
3129 * @param dx The x step
3130 * @param dy The y step
3131 *
3132 * Steps x,y where the step increment is the amount set by
3133 * edje_object_part_drag_step_set.
3134 *
3135 * Values for @p dx and @p dy are real numbers that range from 0 to 1.
3136 *
3137 * @see edje_object_part_drag_page()
3138 */
3139EAPI Eina_Bool edje_object_part_drag_step (Evas_Object *obj, const char *part, double dx, double dy);
3140
3141/**
3142 * @brief Pages x,y steps.
3143 *
3144 * @param obj A valid Evas_Object handle
3145 * @param part The part name
3146 * @param dx The x step
3147 * @param dy The y step
3148 *
3149 * Pages x,y where the increment is defined by
3150 * edje_object_part_drag_page_set.
3151 *
3152 * Values for @p dx and @p dy are real numbers that range from 0 to 1.
3153 *
3154 * @warning Paging is bugged!
3155 *
3156 * @see edje_object_part_drag_step()
3157 */
3158EAPI Eina_Bool edje_object_part_drag_page (Evas_Object *obj, const char *part, double dx, double dy);
3159
3160
3161/**
3162 * @brief Get the object created by this external part.
3163 *
3164 * Parts of type external creates the part object using information
3165 * provided by external plugins. It's somehow like "swallow"
3166 * (edje_object_part_swallow()), but it's all set automatically.
3167 *
3168 * This function returns the part created by such external plugins and
3169 * being currently managed by this Edje.
3170 *
3171 * @note Almost all swallow rules apply: you should not move, resize,
3172 * hide, show, set the color or clipper of such part. It's a bit
3173 * more restrictive as one must @b never delete this object!
3174 *
3175 * @param obj A valid Evas_Object handle
3176 * @param part The part name
3177 * @return The externally created object, or NULL if there is none or
3178 * part is not an external.
3179 */
3180EAPI Evas_Object *edje_object_part_external_object_get (const Evas_Object *obj, const char *part);
3181
3182/**
3183 * @brief Set the parameter for the external part.
3184 *
3185 * Parts of type external may carry extra properties that have
3186 * meanings defined by the external plugin. For instance, it may be a
3187 * string that defines a button label and setting this property will
3188 * change that label on the fly.
3189 *
3190 * @note external parts have parameters set when they change
3191 * states. Those parameters will never be changed by this
3192 * function. The interpretation of how state_set parameters and
3193 * param_set will interact is up to the external plugin.
3194 *
3195 * @note this function will not check if parameter value is valid
3196 * using #Edje_External_Param_Info minimum, maximum, valid
3197 * choices and others. However these should be checked by the
3198 * underlying implementation provided by the external
3199 * plugin. This is done for performance reasons.
3200 *
3201 * @param obj A valid Evas_Object handle
3202 * @param part The part name
3203 * @param param the parameter details, including its name, type and
3204 * actual value. This pointer should be valid, and the
3205 * parameter must exist in
3206 * #Edje_External_Type::parameters_info, with the exact type,
3207 * otherwise the operation will fail and @c EINA_FALSE will be
3208 * returned.
3209 *
3210 * @return @c EINA_TRUE if everything went fine, @c EINA_FALSE on errors.
3211 */
3212EAPI Eina_Bool edje_object_part_external_param_set (Evas_Object *obj, const char *part, const Edje_External_Param *param);
3213
3214/**
3215 * @brief Get the parameter for the external part.
3216 *
3217 * Parts of type external may carry extra properties that have
3218 * meanings defined by the external plugin. For instance, it may be a
3219 * string that defines a button label. This property can be modifed by
3220 * state parameters, by explicit calls to
3221 * edje_object_part_external_param_set() or getting the actual object
3222 * with edje_object_part_external_object_get() and calling native
3223 * functions.
3224 *
3225 * This function asks the external plugin what is the current value,
3226 * independent on how it was set.
3227 *
3228 * @param obj A valid Evas_Object handle
3229 * @param part The part name
3230
3231 * @param param the parameter details. It is used as both input and
3232 * output variable. This pointer should be valid, and the
3233 * parameter must exist in
3234 * #Edje_External_Type::parameters_info, with the exact type,
3235 * otherwise the operation will fail and @c EINA_FALSE will be
3236 * returned.
3237 *
3238 * @return @c EINA_TRUE if everything went fine and @p param members
3239 * are filled with information, @c EINA_FALSE on errors and @p
3240 * param member values are not set or valid.
3241 */
3242EAPI Eina_Bool edje_object_part_external_param_get (const Evas_Object *obj, const char *part, Edje_External_Param *param);
3243
3244/**
3245 * @brief Get an object contained in an part of type EXTERNAL
3246 *
3247 * The @p content string must not be NULL. Its actual value depends on the
3248 * code providing the EXTERNAL.
3249 *
3250 * @param obj The Edje object
3251 * @param part The name of the part holding the EXTERNAL
3252 * @param content A string identifying which content from the EXTERNAL to get
3253 */
3254EAPI Evas_Object *edje_object_part_external_content_get (const Evas_Object *obj, const char *part, const char *content);
3255
3256/**
3257 * Facility to query the type of the given parameter of the given part.
3258 *
3259 * @param obj A valid Evas_Object handle
3260 * @param part The part name
3261 * @param param the parameter name to use.
3262 *
3263 * @return @c EDJE_EXTERNAL_PARAM_TYPE_MAX on errors, or another value
3264 * from #Edje_External_Param_Type on success.
3265 */
3266EAPI Edje_External_Param_Type edje_object_part_external_param_type_get (const Evas_Object *obj, const char *part, const char *param);
3267
3268
3269/**
3270 * @brief Appends an object to the box.
3271 *
3272 * @param obj A valid Evas_Object handle
3273 * @param part The part name
3274 * @param child The object to append
3275 *
3276 * @return @c EINA_TRUE: Successfully added.\n
3277 * @c EINA_FALSE: An error occurred.
3278 *
3279 * Appends child to the box indicated by part.
3280 *
3281 * @see edje_object_part_box_prepend()
3282 * @see edje_object_part_box_insert_before()
3283 * @see edje_object_part_box_insert_at()
3284 */
3285EAPI Eina_Bool edje_object_part_box_append (Evas_Object *obj, const char *part, Evas_Object *child);
3286
3287/**
3288 * @brief Prepends an object to the box.
3289 *
3290 * @param obj A valid Evas_Object handle
3291 * @param part The part name
3292 * @param child The object to prepend
3293 *
3294 * @return @c EINA_TRUE: Successfully added.\n
3295 * @c EINA_FALSE: An error occurred.
3296 *
3297 * Prepends child to the box indicated by part.
3298 *
3299 * @see edje_object_part_box_append()
3300 * @see edje_object_part_box_insert_before()
3301 * @see edje_object_part_box_insert_at()
3302 */
3303EAPI Eina_Bool edje_object_part_box_prepend (Evas_Object *obj, const char *part, Evas_Object *child);
3304
3305/**
3306 * @brief Adds an object to the box.
3307 *
3308 * @param obj A valid Evas_Object handle
3309 * @param part The part name
3310 * @param child The object to insert
3311 * @param reference The object to be used as reference
3312 *
3313 * @return @c EINA_TRUE: Successfully added.\n
3314 * @c EINA_FALSE: An error occurred.
3315 *
3316 * Inserts child in the box given by part, in the position marked by
3317 * reference.
3318 *
3319 * @see edje_object_part_box_append()
3320 * @see edje_object_part_box_prepend()
3321 * @see edje_object_part_box_insert_at()
3322 */
3323EAPI Eina_Bool edje_object_part_box_insert_before (Evas_Object *obj, const char *part, Evas_Object *child, const Evas_Object *reference);
3324
3325/**
3326 * @brief Inserts an object to the box.
3327 *
3328 * @param obj A valid Evas_Object handle
3329 * @param part The part name
3330 * @param child The object to insert
3331 * @param pos The position where to insert child
3332 *
3333 * @return @c EINA_TRUE: Successfully added.\n
3334 * @c EINA_FALSE: An error occurred.
3335 *
3336 * Adds child to the box indicated by part, in the position given by
3337 * pos.
3338 *
3339 * @see edje_object_part_box_append()
3340 * @see edje_object_part_box_prepend()
3341 * @see edje_object_part_box_insert_before()
3342 */
3343EAPI Eina_Bool edje_object_part_box_insert_at (Evas_Object *obj, const char *part, Evas_Object *child, unsigned int pos);
3344
3345/**
3346 * @brief Removes an object from the box.
3347 *
3348 * @param obj A valid Evas_Object handle
3349 * @param part The part name
3350 * @param child The object to remove
3351 *
3352 * @return Pointer to the object removed, or @c NULL.
3353 *
3354 * Removes child from the box indicated by part.
3355 *
3356 * @see edje_object_part_box_remove_at()
3357 * @see edje_object_part_box_remove_all()
3358 */
3359EAPI Evas_Object *edje_object_part_box_remove (Evas_Object *obj, const char *part, Evas_Object *child);
3360
3361/**
3362 * @brief Removes an object from the box.
3363 *
3364 * @param obj A valid Evas_Object handle
3365 * @param part The part name
3366 * @param pos The position index of the object (starts counting from 0)
3367 *
3368 * @return Pointer to the object removed, or @c NULL.
3369 *
3370 * Removes from the box indicated by part, the object in the position
3371 * pos.
3372 *
3373 * @see edje_object_part_box_remove()
3374 * @see edje_object_part_box_remove_all()
3375 */
3376EAPI Evas_Object *edje_object_part_box_remove_at (Evas_Object *obj, const char *part, unsigned int pos);
3377
3378/**
3379 * @brief Removes all elements from the box.
3380 *
3381 * @param obj A valid Evas_Object handle
3382 * @param part The part name
3383 * @param clear Delete objects on removal
3384 *
3385 * @return 1: Successfully cleared.\n
3386 * 0: An error occurred.
3387 *
3388 * Removes all the external objects from the box indicated by part.
3389 * Elements created from the theme will not be removed.
3390 *
3391 * @see edje_object_part_box_remove()
3392 * @see edje_object_part_box_remove_at()
3393 */
3394EAPI Eina_Bool edje_object_part_box_remove_all (Evas_Object *obj, const char *part, Eina_Bool clear);
3395
3396/**
3397 * @brief Retrieve a child from a table
3398 *
3399 * @param obj A valid Evas_Object handle
3400 * @param part The part name
3401 * @param col The column of the child to get
3402 * @param row The row of the child to get
3403 * @return The child Evas_Object
3404 */
3405EAPI Evas_Object *edje_object_part_table_child_get (Evas_Object *obj, const char *part, unsigned int col, unsigned int row);
3406
3407/**
3408 * @brief Packs an object into the table.
3409 *
3410 * @param obj A valid Evas_Object handle
3411 * @param part The part name
3412 * @param child_obj The object to pack in
3413 * @param col The column to place it in
3414 * @param row The row to place it in
3415 * @param colspan Columns the child will take
3416 * @param rowspan Rows the child will take
3417 *
3418 * @return @c EINA_TRUE object was added, @c EINA_FALSE on failure
3419 *
3420 * Packs an object into the table indicated by part.
3421 */
3422EAPI Eina_Bool edje_object_part_table_pack (Evas_Object *obj, const char *part, Evas_Object *child_obj, unsigned short col, unsigned short row, unsigned short colspan, unsigned short rowspan);
3423
3424/**
3425 * @brief Removes an object from the table.
3426 *
3427 * @param obj A valid Evas_Object handle
3428 * @param part The part name
3429 * @param child_obj The object to pack in
3430 *
3431 * @return @c EINA_TRUE object removed, @c EINA_FALSE on failure
3432 *
3433 * Removes an object from the table indicated by part.
3434 */
3435EAPI Eina_Bool edje_object_part_table_unpack (Evas_Object *obj, const char *part, Evas_Object *child_obj);
3436
3437/**
3438 * @brief Gets the number of columns and rows the table has.
3439 *
3440 * @param obj A valid Evas_Object handle
3441 * @param part The part name
3442 * @param cols Pointer where to store number of columns (can be NULL)
3443 * @param rows Pointer where to store number of rows (can be NULL)
3444 *
3445 * @return @c EINA_TRUE get some data, @c EINA_FALSE on failure
3446 *
3447 * Retrieves the size of the table in number of columns and rows.
3448 */
3449EAPI Eina_Bool edje_object_part_table_col_row_size_get (const Evas_Object *obj, const char *part, int *cols, int *rows);
3450
3451/**
3452 * @brief Removes all object from the table.
3453 *
3454 * @param obj A valid Evas_Object handle
3455 * @param part The part name
3456 * @param clear If set, will delete subobjs on remove
3457 *
3458 * @return @c EINA_TRUE clear the table, @c EINA_FALSE on failure
3459 *
3460 * Removes all object from the table indicated by part, except the
3461 * internal ones set from the theme.
3462 */
3463EAPI Eina_Bool edje_object_part_table_clear (Evas_Object *obj, const char *part, Eina_Bool clear);
3464
3465/**
3466 * @brief Send an (Edje) message to a given Edje object
3467 *
3468 * @param obj A handle to an Edje object
3469 * @param type The type of message to send to @p obj
3470 * @param id A identification number for the message to be sent
3471 * @param msg The message's body, a struct depending on @p type
3472 *
3473 * This function sends an Edje message to @p obj and to all of its
3474 * child objects, if it has any (swallowed objects are one kind of
3475 * child object). @p type and @p msg @b must be matched accordingly,
3476 * as documented in #Edje_Message_Type.
3477 *
3478 * The @p id argument as a form of code and theme defining a common
3479 * interface on message communication. One should define the same IDs
3480 * on both code and EDC declaration (see @ref edcref "the syntax" for
3481 * EDC files), to individualize messages (binding them to a given
3482 * context).
3483 *
3484 * The function to handle messages arriving @b from @b obj is set with
3485 * edje_object_message_handler_set().
3486 */
3487EAPI void edje_object_message_send (Evas_Object *obj, Edje_Message_Type type, int id, void *msg);
3488
3489/**
3490 * @brief Set an Edje message handler function for a given Edje object.
3491 *
3492 * @param obj A handle to an Edje object
3493 * @param func The function to handle messages @b coming from @p obj
3494 * @param data Auxiliary data to be passed to @p func
3495 *
3496 * Edje messages are one of the communication interfaces between
3497 * @b code and a given Edje object's @b theme. With messages, one can
3498 * communicate values beyond strings (which are the subject of Edje
3499 * signals -- see edje_object_signal_emit()), like float and integer
3500 * numbers. Moreover, messages can be identified by integer
3501 * numbers. See #Edje_Message_Type for the full list of message types.
3502 *
3503 * For scriptable programs on an Edje object's defining EDC file which
3504 * send messages with the @c send_message() primitive, one can attach
3505 * <b>handler functions</b>, to be called in the code which creates
3506 * that object (see @ref edcref "the syntax" for EDC files).
3507 *
3508 * This function associates a message handler function and the
3509 * attached data pointer to the object @p obj.
3510 *
3511 * @see edje_object_message_send()
3512 */
3513EAPI void edje_object_message_handler_set (Evas_Object *obj, Edje_Message_Handler_Cb func, void *data);
3514
3515/**
3516 * @brief Process an object's message queue.
3517 *
3518 * @param obj A handle to an Edje object.
3519 *
3520 * This function goes through the object message queue processing the
3521 * pending messages for @b this specific Edje object. Normally they'd
3522 * be processed only at idle time.
3523 *
3524 */
3525EAPI void edje_object_message_signal_process (Evas_Object *obj);
3526
3527
3528/**
3529 * @brief Process all queued up edje messages.
3530 *
3531 * This function triggers the processing of messages addressed to any
3532 * (alive) edje objects.
3533 *
3534 */
3535EAPI void edje_message_signal_process (void);
3536
3537/**
3538 * Register a type to be used by EXTERNAL parts.
3539 *
3540 * Edje supports parts of type EXTERNAL, which will call user defined functions
3541 * to create and manipulate the object that's allocated in that part. This is
3542 * done by expecifying in the @c source property of the part the name of the
3543 * external to use, which must be one registered with this function.
3544 *
3545 * @param type_name name to register and be known by edje's "source:"
3546 * parameter of "type: EXTERNAL" parts.
3547 * @param type_info meta-information describing how to interact with it.
3548 *
3549 * @return @c EINA_TRUE on success, @c EINA_FALSE on failure (like
3550 * type already registered).
3551 *
3552 * @see edje_external_type_array_register()
3553 */
3554EAPI Eina_Bool edje_external_type_register (const char *type_name, const Edje_External_Type *type_info);
3555
3556/**
3557 * Unregister a previously registered EXTERNAL type.
3558 *
3559 * @param type_name name to unregister. It should have been registered with
3560 * edje_external_type_register() before.
3561 *
3562 * @return @c EINA_TRUE on success, @c EINA_FALSE on failure (like
3563 * type_name did not exist).
3564 *
3565 * @see edje_external_type_array_unregister()
3566 */
3567EAPI Eina_Bool edje_external_type_unregister (const char *type_name);
3568
3569/**
3570 * Register a batch of types and their information.
3571 *
3572 * When several types will be registered it is recommended to use this
3573 * function instead of several calls to edje_external_type_register(), as it
3574 * is faster.
3575 *
3576 * @note The contents of the array will be referenced directly for as long as
3577 * the type remains registered, so both the @c name and @c info in the
3578 * @p array must be kept alive during all this period (usually, the entire
3579 * program lifetime). The most common case would be to keep the array as a
3580 * @c static @c const type anyway.
3581 *
3582 * @param array @c NULL terminated array with type name and
3583 * information. Note that type name or information are
3584 * referenced directly, so they must be kept alive after
3585 * this function returns!
3586 *
3587 * @return @c EINA_TRUE on success, @c EINA_FALSE on failure (like
3588 * type already registered).
3589 *
3590 * @see edje_external_type_register()
3591 */
3592EAPI void edje_external_type_array_register (const Edje_External_Type_Info *array);
3593
3594/**
3595 * Unregister a batch of given external type previously registered.
3596 *
3597 * @param array @c NULL terminated array, should be the same as the
3598 * one used to register with edje_external_type_array_register()
3599 *
3600 * @see edje_external_type_unregister()
3601 */
3602EAPI void edje_external_type_array_unregister (const Edje_External_Type_Info *array);
3603
3604/**
3605 * Return the current ABI version for Edje_External_Type structure.
3606 *
3607 * Always check this number before accessing Edje_External_Type in
3608 * your own software. If the number is not the same, your software may
3609 * access invalid memory and crash, or just get garbage values.
3610 *
3611 * @warning @b NEVER, EVER define your own Edje_External_Type using the
3612 * return of this function as it will change as Edje library
3613 * (libedje.so) changes, but your type definition will
3614 * not. Instead, use #EDJE_EXTERNAL_TYPE_ABI_VERSION.
3615 *
3616 * Summary:
3617 * - use edje_external_type_abi_version_get() to check.
3618 * - use #EDJE_EXTERNAL_TYPE_ABI_VERSION to define/declare.
3619 *
3620 * @return The external ABI version the Edje library was compiled with. That
3621 * is, the value #EDJE_EXTERNAL_TYPE_ABI_VERSION had at that moment.
3622 */
3623EAPI unsigned int edje_external_type_abi_version_get (void) EINA_CONST;
3624
3625/**
3626 * Returns an interator of all the registered EXTERNAL types.
3627 *
3628 * Each item in the iterator is an @c Eina_Hash_Tuple which has the type
3629 * of the external in the @c key and #Edje_External_Type as @c data.
3630 *
3631 * @code
3632 * const Eina_Hash_Tuple *tuple;
3633 * Eina_Iterator *itr;
3634 * const Eina_List *l, *modules;
3635 * const char *s;
3636 *
3637 * modules = edje_available_modules_get();
3638 * EINA_LIST_FOREACH(modules, l, s)
3639 * {
3640 * if (!edje_module_load(s))
3641 * printf("Error loading edje module: %s\n", s);
3642 * }
3643 *
3644 * itr = edje_external_iterator_get();
3645 * EINA_ITERATOR_FOREACH(itr, tuple)
3646 * {
3647 * const char *name = tuple->key;
3648 * const Edje_External_Type *type = tuple->data;
3649 *
3650 * if ((!type) ||
3651 * (type->abi_version != edje_external_type_abi_version_get()))
3652 * {
3653 * printf("Error: invalid type %p (abi: %d, expected: %d)\n",
3654 * type, type ? type->abi_version : 0,
3655 * edje_external_type_abi_version_get());
3656 * continue;
3657 * }
3658 *
3659 * printf("%s: %s (%s) label='%s' desc='%s'\n",
3660 * name, type->module, type->module_name,
3661 * type->label_get ? type->label_get(type->data) : "",
3662 * type->description_get ? type->description_get(type->data) : "");
3663 * }
3664 *
3665 * @endcode
3666 */
3667EAPI Eina_Iterator *edje_external_iterator_get (void);
3668
3669/**
3670 * Conevenience function to find a specific parameter in a list of them.
3671 *
3672 * @param params The list of parameters for the external
3673 * @param key The parameter to look for
3674 *
3675 * @return The matching #Edje_External_Param or NULL if it's not found.
3676 */
3677 EAPI Edje_External_Param *edje_external_param_find (const Eina_List *params, const char *key);
3678/**
3679 * Get the value of the given parameter of integer type.
3680 *
3681 * Look for the @p key parameter in the @p params list and return its value in
3682 * @p ret. If the parameter is found and is of type
3683 * #EDJE_EXTERNAL_PARAM_TYPE_INT, its value will be stored in the int pointed
3684 * by @p ret, returning EINA_TRUE. In any other case, the function returns
3685 * EINA_FALSE.
3686 *
3687 * @param params List of parameters where to look
3688 * @param key Name of the parameter to fetch
3689 * @param ret Int pointer where to store the value, must not be NULL.
3690 *
3691 * @return EINA_TRUE if the parameter was found and is of integer type,
3692 * EINA_FALSE otherwise.
3693 */
3694 EAPI Eina_Bool edje_external_param_int_get (const Eina_List *params, const char *key, int *ret);
3695/**
3696 * Get the value of the given parameter of double type.
3697 *
3698 * Look for the @p key parameter in the @p params list and return its value in
3699 * @p ret. If the parameter is found and is of type
3700 * #EDJE_EXTERNAL_PARAM_TYPE_DOUBLE, its value will be stored in the double
3701 * pointed by @p ret, returning EINA_TRUE. In any other case, the function
3702 * returns EINA_FALSE.
3703 *
3704 * @param params List of parameters where to look
3705 * @param key Name of the parameter to fetch
3706 * @param ret Double pointer where to store the value, must not be NULL.
3707 *
3708 * @return EINA_TRUE if the parameter was found and is of double type,
3709 * EINA_FALSE otherwise.
3710 */
3711 EAPI Eina_Bool edje_external_param_double_get (const Eina_List *params, const char *key, double *ret);
3712/**
3713 * Get the value of the given parameter of string type.
3714 *
3715 * Look for the @p key parameter in the @p params list and return its value in
3716 * @p ret. If the parameter is found and is of type
3717 * #EDJE_EXTERNAL_PARAM_TYPE_STRING, its value will be stored in the pointer
3718 * pointed by @p ret, returning EINA_TRUE. In any other case, the function
3719 * returns EINA_FALSE.
3720 *
3721 * The string stored in @p ret must not be freed or modified.
3722 *
3723 * @param params List of parameters where to look
3724 * @param key Name of the parameter to fetch
3725 * @param ret String pointer where to store the value, must not be NULL.
3726 *
3727 * @return EINA_TRUE if the parameter was found and is of string type,
3728 * EINA_FALSE otherwise.
3729 */
3730 EAPI Eina_Bool edje_external_param_string_get (const Eina_List *params, const char *key, const char **ret);
3731/**
3732 * Get the value of the given parameter of boolean type.
3733 *
3734 * Look for the @p key parameter in the @p params list and return its value in
3735 * @p ret. If the parameter is found and is of type
3736 * #EDJE_EXTERNAL_PARAM_TYPE_BOOL, its value will be stored in the Eina_Bool
3737 * pointed by @p ret, returning EINA_TRUE. In any other case, the function
3738 * returns EINA_FALSE.
3739 *
3740 * @param params List of parameters where to look
3741 * @param key Name of the parameter to fetch
3742 * @param ret Eina_Bool pointer where to store the value, must not be NULL.
3743 *
3744 * @return EINA_TRUE if the parameter was found and is of boolean type,
3745 * EINA_FALSE otherwise.
3746 */
3747 EAPI Eina_Bool edje_external_param_bool_get (const Eina_List *params, const char *key, Eina_Bool *ret);
3748/**
3749 * Get the value of the given parameter of choice type.
3750 *
3751 * Look for the @p key parameter in the @p params list and return its value in
3752 * @p ret. If the parameter is found and is of type
3753 * #EDJE_EXTERNAL_PARAM_TYPE_CHOICE, its value will be stored in the string
3754 * pointed by @p ret, returning EINA_TRUE. In any other case, the function
3755 * returns EINA_FALSE.
3756 *
3757 * The string stored in @p ret must not be freed or modified.
3758 *
3759 * @param params List of parameters where to look
3760 * @param key Name of the parameter to fetch
3761 * @param ret String pointer where to store the value, must not be NULL.
3762 *
3763 * @return EINA_TRUE if the parameter was found and is of integer type,
3764 * EINA_FALSE otherwise.
3765 */
3766 EAPI Eina_Bool edje_external_param_choice_get (const Eina_List *params, const char *key, const char **ret);
3767
3768/**
3769 * Get the array of parameters information about a type given its name.
3770 *
3771 * @note the type names and other strings are static, that means they are
3772 * @b NOT translated. One must use
3773 * Edje_External_Type::translate() to translate those.
3774 *
3775 * @return the NULL terminated array, or @c NULL if type is unknown or
3776 * it does not have any parameter information.
3777 *
3778 * @see edje_external_type_get()
3779 */
3780EAPI const Edje_External_Param_Info *edje_external_param_info_get (const char *type_name);
3781
3782/**
3783 * Get the #Edje_External_Type that defines an EXTERNAL type registered with
3784 * the name @p type_name.
3785 */
3786 EAPI const Edje_External_Type *edje_external_type_get (const char *type_name);
3787
3788 EAPI Eina_Bool edje_module_load (const char *module);
3789 EAPI const Eina_List *edje_available_modules_get (void);
3790
3791 /* perspective info for maps inside edje objects */
3792 typedef struct _Edje_Perspective Edje_Perspective;
3793
3794 /**
3795 * Creates a new perspective in the given canvas.
3796 *
3797 * @param e The given canvas (Evas).
3798 * @return An @ref Edje_Perspective object for this canvas, or @c NULL on errors.
3799 *
3800 * This function creates a perspective object that can be set on an Edje
3801 * object, or globally to all Edje objects on this canvas.
3802 *
3803 * @see edje_perspective_set()
3804 * @see edje_perspective_free()
3805 */
3806 EAPI Edje_Perspective *edje_perspective_new (Evas *e);
3807 /**
3808 * Delete the given perspective object.
3809 *
3810 * @param ps A valid perspective object, or @c NULL.
3811 *
3812 * This function will delete the perspective object. If the perspective
3813 * effect was being applied to any Edje object or part, this effect won't be
3814 * applied anymore.
3815 *
3816 * @see edje_perspective_new()
3817 */
3818 EAPI void edje_perspective_free (Edje_Perspective *ps);
3819 /**
3820 * Setup the transform for this perspective object.
3821 *
3822 * This sets the parameters of the perspective transformation. X, Y and Z
3823 * values are used. The px and py points specify the "infinite distance" point
3824 * in the 3D conversion (where all lines converge to like when artists draw
3825 * 3D by hand). The @p z0 value specifis the z value at which there is a 1:1
3826 * mapping between spatial coorinates and screen coordinates. Any points
3827 * on this z value will not have their X and Y values modified in the transform.
3828 * Those further away (Z value higher) will shrink into the distance, and
3829 * those less than this value will expand and become bigger. The @p foc value
3830 * determines the "focal length" of the camera. This is in reality the distance
3831 * between the camera lens plane itself (at or closer than this rendering
3832 * results are undefined) and the "z0" z value. This allows for some "depth"
3833 * control and @p foc must be greater than 0.
3834 *
3835 * @param m map to change.
3836 * @param px The pespective distance X coordinate
3837 * @param py The pespective distance Y coordinate
3838 * @param z0 The "0" z plane value
3839 * @param foc The focal distance
3840 */
3841 EAPI void edje_perspective_set (Edje_Perspective *ps, Evas_Coord px, Evas_Coord py, Evas_Coord z0, Evas_Coord foc);
3842 /**
3843 * Make this perspective object be global for its canvas.
3844 *
3845 * @param ps The given perspective object
3846 * @param global @c EINA_TRUE if the perspective should be global, @c
3847 * EINA_FALSE otherwise.
3848 *
3849 * The canvas which this perspective object is being set as global is the one
3850 * given as argument upon the object creation (the @p evas parameter on the
3851 * function @c edje_perspective_new(evas) ).
3852 *
3853 * There can be only one global perspective object set per canvas, and if
3854 * a perspective object is set to global when there was already another
3855 * global perspective set, the old one will be set as non-global.
3856 *
3857 * A global perspective just affects a part if its Edje object doesn't have a
3858 * perspective object set to it, and if the part doesn't point to another
3859 * part to be used as perspective.
3860 *
3861 * @see edje_object_perspective_set()
3862 * @see edje_perspective_global_get()
3863 * @see edje_perspective_new()
3864 */
3865 EAPI void edje_perspective_global_set (Edje_Perspective *ps, Eina_Bool global);
3866 /**
3867 * Get whether the given perspective object is global or not.
3868 *
3869 * @param ps The given perspective object.
3870 * @return @c EINA_TRUE if this perspective object is global, @c EINA_FALSE
3871 * otherwise.
3872 *
3873 * @see edje_perspective_global_set()
3874 */
3875 EAPI Eina_Bool edje_perspective_global_get (const Edje_Perspective *ps);
3876 /**
3877 * Get the global perspective object set for this canvas.
3878 *
3879 * @param e The given canvas (Evas).
3880 * @return The perspective object set as global for this canvas. Or @c NULL
3881 * if there is no global perspective set and on errors.
3882 *
3883 * This function will return the perspective object that was set as global
3884 * with edje_perspective_global_set().
3885 *
3886 * @see edje_perspective_global_set()
3887 * @see edje_perspective_global_get()
3888 */
3889 EAPI const Edje_Perspective *edje_evas_global_perspective_get(const Evas *e);
3890 /**
3891 * Set the given perspective object on this Edje object.
3892 *
3893 * @param obj The Edje object on the perspective will be set.
3894 * @param ps The perspective object that will be used.
3895 *
3896 * Make the given perspective object be the default perspective for this Edje
3897 * object.
3898 *
3899 * There can be only one perspective object per Edje object, and if a
3900 * previous one was set, it will be removed and the new perspective object
3901 * will be used.
3902 *
3903 * An Edje perspective will only affect a part if it doesn't point to another
3904 * part to be used as perspective.
3905 *
3906 * @see edje_object_perspective_new()
3907 * @see edje_object_perspective_get()
3908 * @see edje_perspective_set()
3909 */
3910 EAPI void edje_object_perspective_set (Evas_Object *obj, Edje_Perspective *ps);
3911 /**
3912 * Get the current perspective used on this Edje object.
3913 *
3914 * @param obj the given Edje object.
3915 * @return The perspective object being used on this Edje object. Or @c NULL
3916 * if there was none, and on errors.
3917 *
3918 * @see edje_object_perspective_set()
3919 */
3920 EAPI const Edje_Perspective *edje_object_perspective_get (const Evas_Object *obj);
3921
3922#ifdef __cplusplus
3923}
3924#endif
3925
3926#endif
diff --git a/libraries/edje/src/lib/Edje_Edit.h b/libraries/edje/src/lib/Edje_Edit.h
new file mode 100644
index 0000000..935d661
--- /dev/null
+++ b/libraries/edje/src/lib/Edje_Edit.h
@@ -0,0 +1,3539 @@
1#ifndef _EDJE_EDIT_H
2#define _EDJE_EDIT_H
3
4#ifndef EDJE_EDIT_IS_UNSTABLE_AND_I_KNOW_ABOUT_IT
5#error "Do not use the Edje_Edit API unless you know what you are doing. It's meant only for writing editors and nothing else."
6#endif
7
8#include <Edje.h>
9
10#ifdef EAPI
11# undef EAPI
12#endif
13
14#ifdef _WIN32
15# ifdef EFL_EDJE_BUILD
16# ifdef DLL_EXPORT
17# define EAPI __declspec(dllexport)
18# else
19# define EAPI
20# endif /* ! DLL_EXPORT */
21# else
22# define EAPI __declspec(dllimport)
23# endif /* ! EFL_EDJE_BUILD */
24#else
25# ifdef __GNUC__
26# if __GNUC__ >= 4
27# define EAPI __attribute__ ((visibility("default")))
28# else
29# define EAPI
30# endif
31# else
32# define EAPI
33# endif
34#endif
35
36
37typedef enum _Edje_Edit_Image_Comp
38{
39 EDJE_EDIT_IMAGE_COMP_RAW,
40 EDJE_EDIT_IMAGE_COMP_USER,
41 EDJE_EDIT_IMAGE_COMP_COMP,
42 EDJE_EDIT_IMAGE_COMP_LOSSY
43} Edje_Edit_Image_Comp;
44
45struct _Edje_Edit_Script_Error
46{
47 const char *program_name; /* null == group shared script */
48 int line;
49 const char *error_str;
50};
51typedef struct _Edje_Edit_Script_Error Edje_Edit_Script_Error;
52
53/**
54 * @file
55 * @brief Functions to deal with edje internal object. Don't use in standard
56 * situations. The use of any of the edje_edit_* functions can break your
57 * theme ability, remember that the program must be separated from the interface!
58 *
59 * This was intended ONLY for use in an actual edje editor program. Unless
60 * you are writing one of these, do NOT use this API here.
61 *
62 * The API can be used to query or set every part of an edje object in real time.
63 * You can manage every aspect of parts, part states, programs, script and whatever
64 * is contained in the edje file. For a reference of what all parameter means
65 * look at the complete @ref edcref.
66 *
67 * Don't forget to free all the strings and the lists returned by any edje_edit_*()
68 * functions using edje_edit_string_free() and edje_edit_string_list_free() when
69 * you don't need anymore.
70 *
71 * Example: print all the part in a loaded edje_object
72 * @code
73 * Eina_List *parts, *l;
74 * char *part;
75 *
76 * parts = edje_edit_parts_list_get(edje_object);
77 * EINA_LIST_FOREACH(parts, l, part)
78 * {
79 * printf("Part: %s\n", part);
80 * }
81 * edje_edit_string_list_free(parts);
82 * @endcode
83 *
84 * Example: Change the color of a rect inside an edje file
85 * @code
86 * Evas_Object *edje;
87 *
88 * edje = edje_edit_object_add(evas);
89 * edje_object_file_set(edje, "edj/file/name", "group to load");
90 * edje_edit_state_color_set(edje, "MyRectName", "default", 0.00, 255, 255, 0, 255);
91 * edje_edit_save(edje);
92 * @endcode
93 *
94*/
95
96
97#ifdef __cplusplus
98extern "C" {
99#endif
100
101/******************************************************************************/
102/************************** GENERAL API ***********************************/
103/******************************************************************************/
104/** @name General API
105 * General functions that don't fit in other cateories.
106 */ //@{
107
108/** Adds an editable Edje object to the canvas.
109 *
110 * An Edje_Edit object is, for the most part, a standard Edje object. Only
111 * difference is you can use the Edje_Edit API on them.
112 *
113 * @param e Evas canvas where to add the object.
114 *
115 * @return An Evas_Object of type Edje_Edit, or NULL if an error occurred.
116 */
117EAPI Evas_Object * edje_edit_object_add(Evas *e);
118
119/** Free a generic Eina_List of (char *) allocated by an edje_edit_*_get() function.
120 *
121 * @param lst List of strings to free.
122 */
123EAPI void edje_edit_string_list_free(Eina_List *lst);
124
125/** Free a generic string (char *) allocated by an edje_edit_*_get() function.
126 *
127 * @param str String to free.
128 */
129EAPI void edje_edit_string_free(const char *str);
130
131/** Get the name of the program that compiled the edje file.
132 * Can be 'edje_cc' or 'edje_edit'
133 *
134 * @param obj Object being edited.
135 *
136 * @return Compiler stored in the Edje file
137 */
138EAPI const char * edje_edit_compiler_get(Evas_Object *obj);
139
140/** Save the modified edje object back to his file.
141 *
142 * Use this function when you are done with your editing, all the change made
143 * to the current loaded group will be saved back to the original file.
144 *
145 * @note Source for the whole file will be auto generated and will overwrite
146 * any previously stored source.
147 *
148 * @param obj Object to save back to the file it was loaded from.
149 *
150 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
151 *
152 * @todo Add a way to check what the error actually was, the way Edje Load does.
153 */
154EAPI Eina_Bool edje_edit_save(Evas_Object *obj);
155
156/** Saves every group back into the file.
157 *
158 * @param obj Object to save.
159 *
160 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
161 *
162 * @see edje_edit_save()
163 */
164EAPI Eina_Bool edje_edit_save_all(Evas_Object *obj);
165
166/** Print on standard output many information about the internal status
167 * of the edje object.
168 *
169 * This is probably only useful to debug.
170 *
171 * @param obj Object being edited.
172 */
173EAPI void edje_edit_print_internal_status(Evas_Object *obj);
174
175
176//@}
177/******************************************************************************/
178/************************** GROUPS API ************************************/
179/******************************************************************************/
180/** @name Groups API
181 * Functions to deal with groups property (see @ref edcref).
182 */ //@{
183
184/** Create a new empty group in the given edje.
185 *
186 * If a group with the same name exist none is created.
187 *
188 * @param obj Object being edited.
189 * @param name Name of the new group.
190 *
191 * @return EINA_TRUE if successfully added the group, EINA_FALSE if an error
192 * occurred or if a group with the same name exists.
193 */
194
195/**
196 * @brief Add an edje (empty) group to an edje object's group set.
197 *
198 * @param obj The pointer to edje object.
199 * @param name The name of the group.
200 *
201 * @return 1 If it could allocate memory to the part group added
202 * or zero if not.
203 *
204 * This function adds, at run time, one more group, which will reside
205 * in memory, to the group set found in the .edj file which @a obj was
206 * loaded with. This group can be manipulated by other API functions,
207 * like @c edje_edit_part_add(), for example. If desired, the new
208 * group can be actually committed the respective .edj by use of @c
209 * edje_edit_save().
210 *
211 */
212EAPI Eina_Bool edje_edit_group_add(Evas_Object *obj, const char *name);
213
214/** Delete the specified group from the given edje.
215 *
216 * You can only delete a currently unused group.
217 * All the parts and the programs inside the group will be deleted as well,
218 * but not image or font embedded in the edje.
219 *
220 * @param obj Object being edited.
221 * @param group_name Name of group to delete.
222 *
223 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
224 */
225
226/**
227 * @brief Delete the specified group from the edje file.
228 *
229 * @param obj The pointer to the edje object.
230 * @param group_name Group to delete.
231 *
232 * @return @c EINA_TRUE on success, @c EINA_FALSE on failure.
233 *
234 * This function deletes the given group from the file @a obj is set to. This
235 * operation can't be undone as all references to the group are removed from
236 * the file.
237 * This function may fail if the group to be deleted is currently in use.
238 *
239 */
240EAPI Eina_Bool edje_edit_group_del(Evas_Object *obj, const char *group_name);
241
242/** Check if a group with the given name exist in the edje.
243 *
244 * @param obj Object being edited.
245 * @param group Group name to check for.
246 *
247 * @return EINA_TRUE if group exists, EINA_FALSE if not.
248 */
249EAPI Eina_Bool edje_edit_group_exist(Evas_Object *obj, const char *group);
250
251/** Set a new name for the current open group.
252 *
253 * You can only rename a group that is currently loaded
254 * Note that the relative getter function don't exist as it doesn't make sense ;)
255 * @param obj Object being edited.
256 * @param new_name New name for the group.
257 *
258 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
259 */
260EAPI Eina_Bool edje_edit_group_name_set(Evas_Object *obj, const char *new_name);
261
262/** Get the group minimum width.
263 *
264 * @param obj Object being edited.
265 *
266 * @return The minimum width set for the group. -1 if an error occurred.
267 */
268EAPI int edje_edit_group_min_w_get(Evas_Object *obj);
269
270/** Set the group minimum width.
271 *
272 * @param obj Object being edited.
273 * @param w New minimum width for the group.
274 */
275EAPI void edje_edit_group_min_w_set(Evas_Object *obj, int w);
276
277/** Get the group minimum height.
278 *
279 * @param obj Object being edited.
280 *
281 * @return The minimum height set for the group. -1 if an error occurred.
282 */
283EAPI int edje_edit_group_min_h_get(Evas_Object *obj);
284
285/** Set the group minimum height.
286 *
287 * @param obj Object being edited.
288 * @param h New minimum height for the group.
289 */
290EAPI void edje_edit_group_min_h_set(Evas_Object *obj, int h);
291
292/** Get the group maximum width.
293 *
294 * @param obj Object being edited.
295 *
296 * @return The maximum width set for the group. -1 if an error occurred.
297 */
298EAPI int edje_edit_group_max_w_get(Evas_Object *obj);
299
300/** Set the group maximum width.
301 *
302 * @param obj Object being edited.
303 * @param w New maximum width for the group.
304 */
305EAPI void edje_edit_group_max_w_set(Evas_Object *obj, int w);
306
307/** Get the group maximum height.
308 *
309 * @param obj Object being edited.
310 *
311 * @return The maximum height set for the group. -1 if an error occurred.
312 */
313EAPI int edje_edit_group_max_h_get(Evas_Object *obj);
314
315/** Set the group maximum height.
316 *
317 * @param obj Object being edited.
318 * @param h New maximum height for the group.
319 */
320EAPI void edje_edit_group_max_h_set(Evas_Object *obj, int h);
321
322
323//@}
324/******************************************************************************/
325/************************** DATA API **************************************/
326/******************************************************************************/
327/** @name Data API
328 * Functions to deal with data embedded in the edje (see @ref edcref).
329 */ //@{
330
331/** Retrieves a list with the item names inside the data block.
332 *
333 * @param obj Object being edited.
334 *
335 * @return List of strings, each being a name entry in the global data block for the file.
336 */
337EAPI Eina_List * edje_edit_data_list_get(Evas_Object *obj);
338
339/** Create a new *global* data object in the given edje file.
340 *
341 * If another data entry with the same name exists, nothing is created and
342 * EINA_FALSE is returned.
343 *
344 * @param obj Object being edited.
345 * @param itemname Name for the new data entry.
346 * @param value Value for the new data entry.
347 *
348 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
349 */
350EAPI Eina_Bool edje_edit_data_add(Evas_Object *obj, const char *itemname, const char *value);
351
352/** Delete the given data object from edje.
353 *
354 * @param obj Object being edited.
355 * @param itemname Data entry to remove from the global data block.
356 *
357 * @return EINA_TRUE on success, EINA_FALSE otherwise.
358 */
359EAPI Eina_Bool edje_edit_data_del(Evas_Object *obj, const char *itemname);
360
361/** Get the data associated with the given itemname.
362 *
363 * @param obj Object being edited.
364 * @param itemname Name of the data entry to fetch the value for.
365 *
366 * @return Value of the given entry, or NULL if not found.
367 */
368EAPI const char * edje_edit_data_value_get(Evas_Object *obj, const char *itemname);
369
370/** Set the data associated with the given itemname.
371 *
372 * @param obj Object being edited.
373 * @param itemname Name of data entry to change the value.
374 * @param value New value for the entry.
375 *
376 * @return EINA_TRUE on success, EINA_FALSE otherwise.
377 */
378EAPI Eina_Bool edje_edit_data_value_set(Evas_Object *obj, const char *itemname, const char *value);
379
380/** Change the name of the given data object.
381 *
382 * @param obj Object being edited.
383 * @param itemname Data entry to rename.
384 * @param newname New name for the data entry.
385 *
386 * @return EINA_TRUE on success, EINA_FALSE otherwise.
387 */
388EAPI Eina_Bool edje_edit_data_name_set(Evas_Object *obj, const char *itemname, const char *newname);
389
390/** Retrieves a list with the item names inside the data block at the group level.
391 *
392 * @param obj Object being edited.
393 *
394 * @return List of strings, each being a name entry in the data block for the group.
395 */
396EAPI Eina_List * edje_edit_group_data_list_get(Evas_Object *obj);
397
398/** Create a new data object in the given edje file *belonging to the current group*.
399 *
400 * If another data entry with the same name exists,
401 * nothing is created and EINA_FALSE is returned.
402 *
403 * @param obj Object being edited.
404 * @param itemname Name for the new data entry.
405 * @param value Value for the new data entry.
406 *
407 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
408 */
409EAPI Eina_Bool edje_edit_group_data_add(Evas_Object *obj, const char *itemname, const char *value);
410
411/** Delete the given data object from the group.
412 *
413 * @param obj Object being edited.
414 * @param itemname Name of the data entry to remove.
415 *
416 * @return EINA_TRUE on success, EINA_FALSE otherwise.
417 */
418EAPI Eina_Bool edje_edit_group_data_del(Evas_Object *obj, const char *itemname);
419
420/** Get the data associated with the given itemname.
421 *
422 * @param obj Object being edited.
423 * @param itemname Name of the data entry.
424 *
425 * @return Value of the data entry or NULL if not found.
426 */
427EAPI const char * edje_edit_group_data_value_get(Evas_Object *obj, const char *itemname);
428
429/** Set the data associated with the given itemname.
430 *
431 * @param obj Object being edited.
432 * @param itemname Name of the data entry to set the value.
433 * @param value Value to set for the data entry.
434 *
435 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
436 */
437EAPI Eina_Bool edje_edit_group_data_value_set(Evas_Object *obj, const char *itemname, const char *value);
438
439/** Change the name of the given data object.
440 *
441 * @param obj Object being edited.
442 * @param itemname Name of the data entry to rename.
443 * @param newname New name for the data entry.
444 *
445 * @return EINA_TRUE on success, EINA_FALSE otherwise.
446 */
447EAPI Eina_Bool edje_edit_group_data_name_set(Evas_Object *obj, const char *itemname, const char *newname);
448
449
450//@}
451/******************************************************************************/
452/*********************** COLOR CLASSES API ********************************/
453/******************************************************************************/
454/** @name Color Classes API
455 * Functions to deal with Color Classes (see @ref edcref).
456 */ //@{
457
458/** Get the list of all the Color Classes in the given edje object.
459 *
460 * @param obj Object being edited.
461 *
462 * @return List of strings, each being one color class.
463 */
464EAPI Eina_List * edje_edit_color_classes_list_get(Evas_Object *obj);
465
466/** Create a new color class object in the given edje.
467 *
468 * If another class with the same name exists nothing is created and EINA_FALSE is returned.
469 *
470 * @param obj Object being edited.
471 * @param name Name for the new color class.
472 *
473 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
474 */
475EAPI Eina_Bool edje_edit_color_class_add(Evas_Object *obj, const char *name);
476
477/** Delete the given class object from edje.
478 *
479 * @param obj Object being edited.
480 * @param name Color class to delete.
481 *
482 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
483 */
484EAPI Eina_Bool edje_edit_color_class_del(Evas_Object *obj, const char *name);
485
486/** Get all the colors that compose the class.
487 *
488 * You can pass NULL to colors you are not intrested in.
489 *
490 * @param obj Object being edited.
491 * @param class_name Color class to fetch values.
492 * @param r Red component of main color.
493 * @param g Green component of main color.
494 * @param b Blue component of main color.
495 * @param a Alpha component of main color.
496 * @param r2 Red component of secondary color.
497 * @param g2 Green component of secondary color.
498 * @param b2 Blue component of secondary color.
499 * @param a2 Alpha component of secondary color.
500 * @param r3 Red component of tertiary color.
501 * @param g3 Green component of tertiary color.
502 * @param b3 Blue component of tertiary color.
503 * @param a3 Alpha component of tertiary color.
504 *
505 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
506 */
507EAPI Eina_Bool edje_edit_color_class_colors_get(Evas_Object *obj, const char *class_name, int *r, int *g, int *b, int *a, int *r2, int *g2, int *b2, int *a2, int *r3, int *g3, int *b3, int *a3);
508
509/** Set the colors for the given color class.
510 *
511 * If you set a color to -1 it will not be touched.
512 *
513 * @param obj Object being edited.
514 * @param class_name Color class to fetch values.
515 * @param r Red component of main color.
516 * @param g Green component of main color.
517 * @param b Blue component of main color.
518 * @param a Alpha component of main color.
519 * @param r2 Red component of secondary color.
520 * @param g2 Green component of secondary color.
521 * @param b2 Blue component of secondary color.
522 * @param a2 Alpha component of secondary color.
523 * @param r3 Red component of tertiary color.
524 * @param g3 Green component of tertiary color.
525 * @param b3 Blue component of tertiary color.
526 * @param a3 Alpha component of tertiary color.
527 *
528 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
529 */
530EAPI Eina_Bool edje_edit_color_class_colors_set(Evas_Object *obj, const char *class_name, int r, int g, int b, int a, int r2, int g2, int b2, int a2, int r3, int g3, int b3, int a3);
531
532/** Change the name of a color class.
533 *
534 * @param obj Object being edited.
535 * @param name Color class to rename.
536 * @param newname New name for the color class.
537 *
538 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
539 */
540EAPI Eina_Bool edje_edit_color_class_name_set(Evas_Object *obj, const char *name, const char *newname);
541
542//@}
543
544
545/******************************************************************************/
546/************************** TEXT STYLES *************************************/
547/******************************************************************************/
548/** @name Text styles API
549 * Functions to deal with text styles (see @ref edcref).
550 */ //@{
551
552/** Get the list of all the text styles in the given edje object.
553 *
554 * @param obj Object being edited.
555 *
556 * @return List of strings, each being the name for a text style.
557 */
558EAPI Eina_List * edje_edit_styles_list_get(Evas_Object *obj);
559
560/** Create a new text style object in the given edje.
561 *
562 * If another style with the same name exists nothing is created and EINA_FALSE is returned.
563 *
564 * @param obj Object being edited.
565 * @param style Name for the new style.
566 *
567 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
568 */
569EAPI Eina_Bool edje_edit_style_add(Evas_Object *obj, const char *style);
570
571/** Delete the given text style and all the child tags.
572 *
573 * @param obj Object being edited.
574 * @param style Style to delete.
575 */
576EAPI void edje_edit_style_del(Evas_Object *obj, const char *style);
577
578/** Get the list of all the tags name in the given text style.
579 *
580 * @param obj Object being edited.
581 * @param style Style to get the tags for.
582 *
583 * @return List of strings, each being one tag in the given style.
584 */
585EAPI Eina_List * edje_edit_style_tags_list_get(Evas_Object *obj, const char *style);
586
587/** Get the value of the given tag.
588 *
589 * @param obj Object being edited.
590 * @param style Style containing the tag being.
591 * @param tag Tag to get the value for.
592 *
593 * @return Value of the given tag.
594 */
595EAPI const char * edje_edit_style_tag_value_get(Evas_Object *obj, const char *style, const char *tag);
596
597/** Set the value of the given tag.
598 *
599 * @param obj Object being edited.
600 * @param style Style containing the tag to change.
601 * @param tag Name of the tag to set the value for.
602 * @param new_value Value for the tag.
603 */
604EAPI void edje_edit_style_tag_value_set(Evas_Object *obj, const char *style, const char *tag, const char *new_value);
605
606/** Set the name of the given tag.
607 *
608 * @param obj Object being edited.
609 * @param style Style containing the tag to rename.
610 * @param tag Tag to rename.
611 * @param new_name New name for the tag.
612 */
613EAPI void edje_edit_style_tag_name_set(Evas_Object *obj, const char *style, const char *tag, const char *new_name);
614
615/** Add a new tag to the given text style.
616 *
617 * If another tag with the same name exists nothing is created and EINA_FALSE is returned.
618 *
619 * @param obj Object being edited.
620 * @param style Style where to add the new tag.
621 * @param tag_name Name for the new tag.
622 *
623 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
624 */
625EAPI Eina_Bool edje_edit_style_tag_add(Evas_Object *obj, const char *style, const char *tag_name);
626
627/** Delete the given tag.
628 *
629 * @param obj Object being edited.
630 * @param style Style from where to remove the tag.
631 * @param tag Tag to delete.
632 */
633EAPI void edje_edit_style_tag_del(Evas_Object *obj, const char *style, const char *tag);
634
635
636//@}
637/******************************************************************************/
638/************************ EXTERNALS API ***********************************/
639/******************************************************************************/
640/** @name Externals API
641 * Functions to deal with list of external modules (see @ref edcref).
642 */ //@{
643
644/** Get the list of all the externals requested in the given edje object.
645 *
646 * @param obj Object being edited.
647 *
648 * @return List of strings, each being an entry in the block of automatically loaded external modules.
649 */
650EAPI Eina_List * edje_edit_externals_list_get(Evas_Object *obj);
651
652/** Add an external module to be requested on edje load.
653 *
654 * @param obj Object being edited.
655 * @param external Name of the external module to add to the list of autoload.
656 *
657 * @return EINA_TRUE on success (or it was already there), EINA_FALSE otherwise.
658 */
659EAPI Eina_Bool edje_edit_external_add(Evas_Object *obj, const char *external);
660
661/** Delete the given external from the list.
662 *
663 * @param obj Object being edited.
664 * @param external Name of the external module to remove from the autoload list.
665 *
666 * @return EINA_TRUE on success, EINA_FALSE otherwise.
667 */
668EAPI Eina_Bool edje_edit_external_del(Evas_Object *obj, const char *external);
669
670
671//@}
672/******************************************************************************/
673/************************** PARTS API *************************************/
674/******************************************************************************/
675/** @name Parts API
676 * Functions to deal with part objects (see @ref edcref).
677 */ //@{
678
679/** Get the list of all the parts in the given edje object.
680 *
681 * @param obj Object being edited.
682 *
683 * @return List of strings, each being the name for a part in the open group.
684 */
685EAPI Eina_List * edje_edit_parts_list_get(Evas_Object *obj);
686
687/** Create a new part in the given edje.
688 *
689 * If another part with the same name just exists nothing is created and EINA_FALSE is returned.
690 * Note that this function also create a default description for the part.
691 *
692 * @param obj Object being edited.
693 * @param name Name for the new part.
694 * @param type Type of the new part. See @ref edcref for more info on this.
695 *
696 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
697 */
698EAPI Eina_Bool edje_edit_part_add(Evas_Object *obj, const char *name, Edje_Part_Type type);
699
700/** Create a new part of type EXTERNAL in the given edje.
701 *
702 * If another part with the same name just exists nothing is created and EINA_FALSE is returned.
703 * Note that this function also create a default description for the part.
704 *
705 * @param obj Object being edited.
706 * @param name Name for the new part.
707 * @param source The registered external type to use for this part.
708 *
709 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
710 */
711EAPI Eina_Bool edje_edit_part_external_add(Evas_Object *obj, const char *name, const char *source);
712
713/** Delete the given part from the edje.
714 *
715 * All the reference to this part will be zeroed.
716 *
717 * @param obj Object being edited.
718 * @param part Name of part to delete.
719 *
720 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
721 */
722EAPI Eina_Bool edje_edit_part_del(Evas_Object *obj, const char *part);
723
724/** Check if a part with the given name exist in the edje object.
725 *
726 * @param obj Object being edited.
727 * @param part Name of part to check for its existence.
728 *
729 * @return EINA_TRUE if the part exists, EINA_FALSE if not.
730 */
731EAPI Eina_Bool edje_edit_part_exist(Evas_Object *obj, const char *part);
732
733/** Get the name of part stacked above the one passed.
734 *
735 * @param obj Object being edited.
736 * @param part Name of part of which to check the one above.
737 *
738 * @return Name of the part above. NULL if an error occurred or if @p part is
739 * the topmost part in the group.
740 */
741EAPI const char * edje_edit_part_above_get(Evas_Object *obj, const char *part);
742
743/** Get the name of part stacked below the one passed.
744 *
745 * @param obj Object being edited.
746 * @param part Name of part of which to check the one below.
747 *
748 * @return Name of the part below. NULL if an error occurred or if @p part is
749 * the bottommost part in the group.
750 */
751EAPI const char * edje_edit_part_below_get(Evas_Object *obj, const char *part);
752
753/** Move the given part below the previous one.
754 *
755 * @param obj Object being edited.
756 * @param part Name of part to move one step below.
757 *
758 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
759 */
760EAPI Eina_Bool edje_edit_part_restack_below(Evas_Object *obj, const char *part);
761
762/** Move the given part above the next one.
763 *
764 * @param obj Object being edited.
765 * @param part Name of part to move one step above.
766 *
767 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
768 */
769EAPI Eina_Bool edje_edit_part_restack_above(Evas_Object *obj, const char *part);
770
771/** Set a new name for part.
772 *
773 * Note that the relative getter function don't exist as it don't make sense ;)
774 *
775 * @param obj Object being edited.
776 * @param part Name of part to rename.
777 * @param new_name New name for the given part.
778 *
779 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
780 */
781EAPI Eina_Bool edje_edit_part_name_set(Evas_Object *obj, const char *part, const char *new_name);
782
783/** Get api's name of a part.
784 *
785 * @param obj Object being edited.
786 * @param part Name of the part.
787 *
788 * @return name of the api if successful, NULL otherwise.
789 */
790EAPI const char * edje_edit_part_api_name_get(Evas_Object *obj, const char *part);
791
792/** Get api's description of a part.
793 *
794 * @param obj Object being edited.
795 * @param part Name of the part.
796 *
797 * @return description of the api if successful, NULL otherwise.
798 */
799EAPI const char * edje_edit_part_api_description_get(Evas_Object *obj, const char *part);
800
801/** Set api's name of a part.
802 *
803 * @param obj Object being edited.
804 * @param part Name of the part.
805 * @param name New name for the api property.
806 *
807 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
808 */
809EAPI Eina_Bool edje_edit_part_api_name_set(Evas_Object *obj, const char *part, const char *name);
810
811/** Set api's description of a part.
812 *
813 * @param obj Object being edited.
814 * @param part Name of part.
815 * @param description New description for the api property.
816 *
817 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
818 */
819EAPI Eina_Bool edje_edit_part_api_description_set(Evas_Object *obj, const char *part, const char *description);
820
821/** Get the type of a part.
822 *
823 * @param obj Object being edited.
824 * @param part Name of part to get the type of.
825 *
826 * @return Type of the part. See @ref edcref for details.
827 */
828EAPI Edje_Part_Type edje_edit_part_type_get(Evas_Object *obj, const char *part);
829
830/** Get the clip_to part.
831 *
832 * @param obj Object being edited.
833 * @param part Name of the part whose clipper to get.
834 *
835 * @return Name of the part @p part is clipped to. NULL is returned on errors and if the part don't have a clip.
836 */
837EAPI const char * edje_edit_part_clip_to_get(Evas_Object *obj, const char *part);
838
839/** Set a part to clip part to.
840 *
841 * @param obj Object being edited.
842 * @param part Part to set the clipper to.
843 * @param clip_to Part to use as clipper, if NULL then the clipping value will be cancelled (unset clipping).
844 *
845 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
846 */
847EAPI Eina_Bool edje_edit_part_clip_to_set(Evas_Object *obj, const char *part, const char *clip_to);
848
849/** Get the source of part.
850 *
851 * The meaning of this parameter varies depending on the type of the part.
852 * For GROUP parts, it's the name of another group in the Edje file which will
853 * be autoloaded and swallowed on this part.
854 * For TEXTBLOCK parts, it's the name of a group to be used for selection
855 * display under the text.
856 * For EXTERNAL parts, it's the name of the registered external widget to load
857 * and swallow on this part.
858 *
859 * @param obj Object being edited.
860 * @param part Part to get the source from.
861 *
862 * @return Content of the source parameter or NULL if nothing set or an error occurred.
863 */
864EAPI const char * edje_edit_part_source_get(Evas_Object *obj, const char *part);
865
866/** Set the source of part.
867 *
868 * @param obj Object being edited.
869 * @param part Part to set the source of.
870 * @param source Value for the source parameter.
871 *
872 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
873 *
874 * @see edje_edit_part_source_get()
875 *
876 * @note You can't change the source for EXTERNAL parts, it's akin to changing
877 * the type of the part.
878 *
879 * NOTE: This is not applied now. You must reload the edje to see the change.
880 */
881EAPI Eina_Bool edje_edit_part_source_set(Evas_Object *obj, const char *part, const char *source);
882
883/** Get the effect for a given part.
884 *
885 * Gets the effect used for parts of type TEXT. See @ref edcref for more details.
886 *
887 * @param obj Object being edited.
888 * @param part Part to get the effect of.
889 *
890 * @return The effect set for the part.
891 */
892EAPI Edje_Text_Effect edje_edit_part_effect_get(Evas_Object *obj, const char *part);
893
894/** Set the effect for a given part.
895 *
896 * @param obj Object being edited.
897 * @param part Part to set the effect to. Only makes sense on type TEXT.
898 * @param effect Effect to set for the part.
899 */
900EAPI void edje_edit_part_effect_set(Evas_Object *obj, const char *part, Edje_Text_Effect effect);
901
902/** Get the current selected state in part.
903 *
904 * @param obj Object being edited.
905 * @param part Part to get the selected state of.
906 * @param value Pointer to a double where the value of the state will be stored.
907 *
908 * @return The name of the currently selected state for the part.
909 */
910EAPI const char * edje_edit_part_selected_state_get(Evas_Object *obj, const char *part, double *value);
911
912/** Set the current state in part.
913 *
914 * @param obj Object being edited.
915 * @param part Part to set the state of.
916 * @param state Name of the state to set.
917 * @param value Value of the state.
918 *
919 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
920 */
921EAPI Eina_Bool edje_edit_part_selected_state_set(Evas_Object *obj, const char *part, const char *state, double value);
922
923/** Get mouse_events for part.
924 *
925 * @param obj Object being edited.
926 * @param part Part to get if the mouse events is accepted.
927 *
928 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
929 */
930EAPI Eina_Bool edje_edit_part_mouse_events_get(Evas_Object *obj, const char *part);
931
932/** Set mouse_events for part.
933 *
934 * @param obj Object being edited.
935 * @param part The part to set if the mouse events is accepted.
936 * @param mouse_events EINA_TRUE if part will accept mouse events, EINA_FALSE otherwise.
937 */
938EAPI void edje_edit_part_mouse_events_set(Evas_Object *obj, const char *part, Eina_Bool mouse_events);
939
940/** Get repeat_events for part.
941 *
942 * @param obj Object being edited.
943 * @param part Part to set if will pass all events to the other parts.
944 *
945 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
946 */
947EAPI Eina_Bool edje_edit_part_repeat_events_get(Evas_Object *obj, const char *part);
948
949/** Set repeat_events for part.
950 *
951 * @param obj Object being edited.
952 * @param part Part to set if will repeat all the received mouse events to other parts.
953 * @param repeat_events EINA_TRUE if the events received will propagate to other parts, EINA_FALSE otherwise
954 */
955EAPI void edje_edit_part_repeat_events_set(Evas_Object *obj, const char *part, Eina_Bool repeat_events);
956
957/** Get ignore_flags for part.
958 *
959 * @param obj Object being edited.
960 * @param part Part to get which event_flags are being ignored.
961 *
962 * @return The Event flags set to the part.
963 */
964EAPI Evas_Event_Flags edje_edit_part_ignore_flags_get(Evas_Object *obj, const char *part);
965
966/** Set ignore_flags for part.
967 *
968 * @param obj Object being edited.
969 * @param part Part to set which event flags will be ignored.
970 * @param ignore_flags The Event flags to be ignored by the part.
971 */
972EAPI void edje_edit_part_ignore_flags_set(Evas_Object *obj, const char *part, Evas_Event_Flags ignore_flags);
973
974/** Set scale property for the part.
975 *
976 * This property tells Edje that the given part should be scaled by the
977 * Edje scale factor.
978 *
979 * @param obj Object being edited.
980 * @param part Part to set scale for.
981 * @param scale Scale value to set.
982 */
983EAPI void edje_edit_part_scale_set(Evas_Object *obj, const char *part, Eina_Bool scale);
984
985/** Get scale for the part.
986 *
987 * @param obj Object being edited.
988 * @param part Part to get the scale value of.
989 *
990 * @return Whether scale is on (EINA_TRUE) or not.
991 */
992EAPI Eina_Bool edje_edit_part_scale_get(Evas_Object *obj, const char *part);
993
994/** Get horizontal dragable state for part.
995 *
996 * @param obj Object being edited.
997 * @param part Part to get if can be dragged horizontally;
998 *
999 * @return 1 (or -1) if the part can be dragged horizontally, 0 otherwise.
1000 */
1001EAPI int edje_edit_part_drag_x_get(Evas_Object *obj, const char *part);
1002
1003/** Set horizontal dragable state for part.
1004 *
1005 * @param obj Object being edited.
1006 * @param part Part to set if should be dragged horizontally.
1007 * @param drag 1 (or -1) if the part should be dragged horizontally, 0 otherwise.
1008 */
1009EAPI void edje_edit_part_drag_x_set(Evas_Object *obj, const char *part, int drag);
1010
1011/** Get vertical dragable state for part.
1012 *
1013 * @param obj Object being edited.
1014 * @param part Part to get if can be dragged vertically.
1015 *
1016 * @return 1 (or - 1) if the part can be dragged vertically, 0 otherwise.
1017 */
1018EAPI int edje_edit_part_drag_y_get(Evas_Object *obj, const char *part);
1019
1020/** Set vertical dragable state for part.
1021 *
1022 * @param obj Object being edited.
1023 * @param part Part to set if should be dragged vertically.
1024 * @param drag 1 (or -1) of the part shpuld be dragged vertically, 0 otherwise.
1025 */
1026EAPI void edje_edit_part_drag_y_set(Evas_Object *obj, const char *part, int drag);
1027
1028/** Get horizontal dragable step for part.
1029 *
1030 * @param obj Object being edited.
1031 * @param part Part to get the drag horizontal step value.
1032 *
1033 * @return The step value.
1034 */
1035EAPI int edje_edit_part_drag_step_x_get(Evas_Object *obj, const char *part);
1036
1037/** Set horizontal dragable state for part.
1038 *
1039 * @param obj Object being edited.
1040 * @param part Part to set the drag horizontal step value.
1041 * @param step The step the will be dragged.
1042 */
1043EAPI void edje_edit_part_drag_step_x_set(Evas_Object *obj, const char *part, int step);
1044
1045/** Get vertical dragable step for part.
1046 *
1047 * @param obj Object being edited.
1048 * @param part Part to get the drag vertical step value.
1049 *
1050 * @return The step value.
1051 */
1052EAPI int edje_edit_part_drag_step_y_get(Evas_Object *obj, const char *part);
1053
1054/** Set vertical dragable state for part.
1055 *
1056 * @param obj Object being edited.
1057 * @param part Part to set the drag vertical step value.
1058 * @param step The step the will be dragged.
1059 */
1060EAPI void edje_edit_part_drag_step_y_set(Evas_Object *obj, const char *part, int step);
1061
1062/** Get horizontal dragable count for part.
1063 *
1064 * @param obj Object being edited.
1065 * @param part Part to get the drag horizontal count value.
1066 */
1067EAPI int edje_edit_part_drag_count_x_get(Evas_Object *obj, const char *part);
1068
1069/** Set horizontal dragable count for part.
1070 *
1071 * @param obj Object being edited.
1072 * @param part Part to set the drag horizontal count value.
1073 * @param count The count value.
1074 */
1075EAPI void edje_edit_part_drag_count_x_set(Evas_Object *obj, const char *part, int count);
1076
1077/** Get vertical dragable count for part.
1078 *
1079 * @param obj Object being edited.
1080 * @param part Part to get the drag vertical count value.
1081 */
1082EAPI int edje_edit_part_drag_count_y_get(Evas_Object *obj, const char *part);
1083
1084/** Set vertical dragable count for part.
1085 *
1086 * @param obj Object being edited.
1087 * @param part Part to set the drag vertical count value.
1088 * @param count The count value.
1089 */
1090EAPI void edje_edit_part_drag_count_y_set(Evas_Object *obj, const char *part, int count);
1091
1092/** Get the name of the part that is used as 'confine' for the given draggies.
1093 *
1094 * @param obj Object being edited.
1095 * @param part Part to get the name that is used as 'confine' for the given draggies.
1096 *
1097 * @return The name of the confine part or NULL (if unset).
1098 */
1099EAPI const char * edje_edit_part_drag_confine_get(Evas_Object *obj, const char *part);
1100
1101/** Set the name of the part that is used as 'confine' for the given draggies.
1102 *
1103 * @param obj Object being edited.
1104 * @param part Part to set the name that is used as 'confine' for the given draggies.
1105 * @param confine The name of the confine part or NULL to unset confine.
1106 */
1107EAPI void edje_edit_part_drag_confine_set(Evas_Object *obj, const char *part, const char *confine);
1108
1109/** Get the name of the part that is used as the receiver of the drag event.
1110 *
1111 * @param obj Object being edited.
1112 * @param part Part to get the name that is used as the receiver of the drag event.
1113 *
1114 * @return The name of the part that will receive events, or NULL (if unset).
1115 */
1116EAPI const char * edje_edit_part_drag_event_get(Evas_Object *obj, const char *part);
1117
1118/** Set the name of the part that will receive events from the given draggies.
1119 *
1120 * @param obj Object being edited.
1121 * @param part Part to set the name that will receive events from the given draggies.
1122 * @param event The name of the part that will receive events, or NULL to unset.
1123 */
1124EAPI void edje_edit_part_drag_event_set(Evas_Object *obj, const char *part, const char *event);
1125
1126
1127//@}
1128/******************************************************************************/
1129/************************** STATES API ************************************/
1130/******************************************************************************/
1131/** @name States API
1132 * Functions to deal with part states (see @ref edcref).
1133 */ //@{
1134
1135/** Get the list of all the states in the given part.
1136 *
1137 * @param obj Object being edited.
1138 * @param part Part to get the states names list.
1139 *
1140 * @return An Eina_List* of string (char *)containing all the states names found
1141 * in part, including the float value (ex: "default 0.00").
1142 *
1143 * Use edje_edit_string_list_free() when you don't need it anymore.
1144 */
1145EAPI Eina_List * edje_edit_part_states_list_get(Evas_Object *obj, const char *part);
1146
1147/** Set a new name for the given state in the given part.
1148 *
1149 * @param obj Object being edited.
1150 * @param part Part that contain state.
1151 * @param state Name of the state to rename.
1152 * @param value Value of the state to rename.
1153 * @param new_name The new name for the state.
1154 * @param new_value The new value for the state.
1155 *
1156 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
1157 */
1158EAPI Eina_Bool edje_edit_state_name_set(Evas_Object *obj, const char *part, const char *state, double value, const char *new_name, double new_value);
1159
1160/** Create a new state to the give part.
1161 *
1162 * @param obj Object being edited.
1163 * @param part Part to set the name of the new state.
1164 * @param name Name for the new state (not including the state value).
1165 * @param value The state value.
1166 *
1167 * @return EINA_TRUE if successfully, EINA_FALSE otherwise.
1168 */
1169EAPI Eina_Bool edje_edit_state_add(Evas_Object *obj, const char *part, const char *name, double value);
1170
1171/** Delete the given part state from the edje.
1172 *
1173 * @param obj Object being edited.
1174 * @param part Part that contain state.
1175 * @param state The current name of the state (not including the state value).
1176 * @param value The state value.
1177 *
1178 * @return EINA_TRUE if successfully, EINA_FALSE otherwise.
1179 */
1180EAPI Eina_Bool edje_edit_state_del(Evas_Object *obj, const char *part, const char *state, double value);
1181
1182/** Check if a part state with the given name exist.
1183 *
1184 * @param obj Object being edited.
1185 * @param part Part that contain state.
1186 * @param state The name of the state to check (not including the state value).
1187 * @param value The state value.
1188 *
1189 * @return EINA_TRUE if the part state exist, EINA_FALSE otherwise.
1190 */
1191EAPI Eina_Bool edje_edit_state_exist(Evas_Object *obj, const char *part, const char *state, double value);
1192
1193/** Copies the state @p from into @p to. If @p to doesn't exist it will be created.
1194 *
1195 * @param obj Object being edited.
1196 * @param part Part that contain state.
1197 * @param from State to copy from (not including state value).
1198 * @param val_from The value of the state to copy from.
1199 * @param to State to copy into (not including state value).
1200 * @param val_to The value of the state to copy into.
1201 *
1202 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
1203 */
1204EAPI Eina_Bool edje_edit_state_copy(Evas_Object *obj, const char *part, const char *from, double val_from, const char *to, double val_to);
1205
1206/** Get the 'rel1 relative X' value of state.
1207 *
1208 * @param obj Object being edited.
1209 * @param part Part that contain state.
1210 * @param state The name of the state to get 'rel1 relative X' (not including the state value).
1211 * @param value The state value.
1212 *
1213 * @return The 'rel1 relative X' value of the part state.
1214 */
1215EAPI double edje_edit_state_rel1_relative_x_get(Evas_Object *obj, const char *part, const char *state, double value);
1216
1217/** Get the 'rel1 relative Y' value of state.
1218 *
1219 * @param obj Object being edited.
1220 * @param part Part that contain state.
1221 * @param state The name of the state to get 'rel1 relative Y' (not including the state value).
1222 * @param value The state value.
1223 *
1224 * @return The 'rel1 relative Y' value of the part state.
1225 */
1226EAPI double edje_edit_state_rel1_relative_y_get(Evas_Object *obj, const char *part, const char *state, double value);
1227
1228/** Get the 'rel2 relative X' value of state.
1229 *
1230 * @param obj Object being edited.
1231 * @param part Part that contain state.
1232 * @param state The name of the state to get 'rel2 relative X' (not including the state value).
1233 * @param value The state value.
1234 *
1235 * @return The 'rel2 relative X' value of the part state.
1236 */
1237EAPI double edje_edit_state_rel2_relative_x_get(Evas_Object *obj, const char *part, const char *state, double value);
1238
1239/** Get the 'rel2 relative Y' value of state.
1240 *
1241 * @param obj Object being edited.
1242 * @param part Part that contain state.
1243 * @param state The name of the state to get 'rel2 relative Y' (not including the state value).
1244 * @param value The state value.
1245 *
1246 * @return The 'rel2 relative Y' value of the part state.
1247 */
1248EAPI double edje_edit_state_rel2_relative_y_get(Evas_Object *obj, const char *part, const char *state, double value);
1249
1250/** Set the 'rel1 relative X' value of state.
1251 *
1252 * @param obj Object being edited.
1253 * @param part Part that contain state.
1254 * @param state The name of the state to set 'rel1 relative X' (not including the state value).
1255 * @param value The state value.
1256 * @param x The new 'rel1 relative X' value to set'.
1257 */
1258EAPI void edje_edit_state_rel1_relative_x_set(Evas_Object *obj, const char *part, const char *state, double value, double x);
1259
1260/** Set the 'rel1 relative Y' value of state.
1261 *
1262 * @param obj Object being edited.
1263 * @param part Part that contain state.
1264 * @param state The name of the state to set 'rel1 relative Y' (not including the state value).
1265 * @param value The state value.
1266 * @param y The new 'rel1 relative Y' value to set'.
1267 */
1268EAPI void edje_edit_state_rel1_relative_y_set(Evas_Object *obj, const char *part, const char *state, double value, double y);
1269
1270/** Set the 'rel2 relative X' value of state.
1271 *
1272 * @param obj Object being edited.
1273 * @param part Part that contain state.
1274 * @param state The name of the state to set 'rel2 relative X' (not including the state value).
1275 * @param value The state value.
1276 * @param x The new 'rel2 relative X' value to set'.
1277 */
1278EAPI void edje_edit_state_rel2_relative_x_set(Evas_Object *obj, const char *part, const char *state, double value, double x);
1279
1280/** Set the 'rel2 relative Y' value of state.
1281 *
1282 * @param obj Object being edited.
1283 * @param part Part that contain state.
1284 * @param state The name of the state to set 'rel2 relative Y' (not including the state value).
1285 * @param value The state value.
1286 * @param y The new 'rel2 relative Y' value to set'.
1287 */
1288EAPI void edje_edit_state_rel2_relative_y_set(Evas_Object *obj, const char *part, const char *state, double value, double y);
1289
1290/** Get the 'rel1 offset X' value of state.
1291 *
1292 * @param obj Object being edited.
1293 * @param part Part that contain state.
1294 * @param state The name of the state to get 'rel1 offset X' (not including the state value).
1295 * @param value The state value.
1296 *
1297 * @return The 'rel1 offset X' value of the part state.
1298 */
1299EAPI int edje_edit_state_rel1_offset_x_get(Evas_Object *obj, const char *part, const char *state, double value);
1300
1301/** Get the 'rel1 offset Y' value of state.
1302 *
1303 * @param obj Object being edited.
1304 * @param part Part that contain state.
1305 * @param state The name of the state to get 'rel1 offset Y' (not including the state value).
1306 * @param value The state value.
1307 *
1308 * @return The 'rel1 offset Y' value of the part state.
1309 */
1310EAPI int edje_edit_state_rel1_offset_y_get(Evas_Object *obj, const char *part, const char *state, double value);
1311
1312/** Get the 'rel2 offset X' value of state.
1313 *
1314 * @param obj Object being edited.
1315 * @param part Part that contain state.
1316 * @param state The name of the state to get 'rel2 offset X' (not including the state value).
1317 * @param value The state value.
1318 *
1319 * @return The 'rel2 offset X' value of the part state.
1320 */
1321EAPI int edje_edit_state_rel2_offset_x_get(Evas_Object *obj, const char *part, const char *state, double value);
1322
1323/** Get the 'rel2 offset Y' value of state.
1324 *
1325 * @param obj Object being edited.
1326 * @param part Part that contain state.
1327 * @param state The name of the state to get 'rel2 offset Y' (not including the state value).
1328 * @param value The state value.
1329 *
1330 * @return The 'rel2 offset Y' value of the part state.
1331 */
1332EAPI int edje_edit_state_rel2_offset_y_get(Evas_Object *obj, const char *part, const char *state, double value);
1333
1334/** Set the 'rel1 offset X' value of state.
1335 *
1336 * @param obj Object being edited.
1337 * @param part Part that contain state.
1338 * @param state The name of the state to set 'rel1 offset X' (not including the state value).
1339 * @param value The state value.
1340 * @param x The new 'rel1 offset X' value to set'.
1341 */
1342EAPI void edje_edit_state_rel1_offset_x_set(Evas_Object *obj, const char *part, const char *state, double value, double x);
1343
1344/** Set the 'rel1 offset Y' value of state.
1345 *
1346 * @param obj Object being edited.
1347 * @param part Part that contain state.
1348 * @param state The name of the state to set 'rel1 offset Y' (not including the state value).
1349 * @param value The state value.
1350 * @param y The new 'rel1 offset Y' value to set'.
1351 */
1352EAPI void edje_edit_state_rel1_offset_y_set(Evas_Object *obj, const char *part, const char *state, double value, double y);
1353
1354/** Set the 'rel2 offset X' value of state.
1355 *
1356 * @param obj Object being edited.
1357 * @param part Part that contain state.
1358 * @param state The name of the state to set 'rel2 offset X' (not including the state value).
1359 * @param value The state value.
1360 * @param x The new 'rel2 offset X' value to set'.
1361 */
1362EAPI void edje_edit_state_rel2_offset_x_set(Evas_Object *obj, const char *part, const char *state, double value, double x);
1363
1364/** Set the 'rel2 offset Y' value of state.
1365 *
1366 * @param obj Object being edited.
1367 * @param part Part that contain state.
1368 * @param state The name of the state to set 'rel2 offset Y' (not including the state value).
1369 * @param value The state value.
1370 * @param y The new 'rel2 offset Y' value to set'.
1371 */
1372EAPI void edje_edit_state_rel2_offset_y_set(Evas_Object *obj, const char *part, const char *state, double value, double y);
1373
1374/** Get the part name rel1x is relative to.
1375 *
1376 * @param obj Object being edited.
1377 * @param part Part that contain state.
1378 * @param state The state that contain which the part name rel1x is relative to (not including the state value).
1379 * @param value The state value.
1380 *
1381 * @return The part name rel1x is relative to or NULL if the part is relative to the whole interface.
1382 */
1383EAPI const char * edje_edit_state_rel1_to_x_get(Evas_Object *obj, const char *part, const char *state, double value);
1384
1385/** Get the part name rel1y is relative to.
1386 *
1387 * @param obj Object being edited.
1388 * @param part Part that contain state.
1389 * @param state The state that contain which the part name rel1y is relative to (not including the state value).
1390 * @param value The state value.
1391 *
1392 * @return The part name rel1y is relative to or NULL if the part is relative to the whole interface.
1393 */
1394EAPI const char * edje_edit_state_rel1_to_y_get(Evas_Object *obj, const char *part, const char *state, double value);
1395
1396/** Get the part name rel2x is relative to.
1397 *
1398 * @param obj Object being edited.
1399 * @param part Part that contain state.
1400 * @param state The state that contain which the part name rel2x is relative to (not including the state value).
1401 * @param value The state value.
1402 *
1403 * @return The part name rel2x is relative to or NULL if the part is relative to the whole interface.
1404 */
1405EAPI const char * edje_edit_state_rel2_to_x_get(Evas_Object *obj, const char *part, const char *state, double value);
1406
1407/** Get the part name rel2y is relative to.
1408 *
1409 * @param obj Object being edited.
1410 * @param part Part that contain state.
1411 * @param state The state that contain which the part name rel2y is relative to (not including the state value).
1412 * @param value The state value.
1413 *
1414 * @return The part name rel2y is relative to or NULL if the part is relative to the whole interface.
1415 */
1416EAPI const char * edje_edit_state_rel2_to_y_get(Evas_Object *obj, const char *part, const char *state, double value);
1417
1418/** Set the part rel1x is relative to.
1419 *
1420 * @param obj Object being edited.
1421 * @param part Part that contain state.
1422 * @param state The name of the state to set rel1x is relative to (not including the state value).
1423 * @param value The state value.
1424 * @param rel_to The name of the part that is used as container/parent (NULL make the part relative to the whole interface).
1425 *
1426 * @return The part name rel1x is relative to or NULL if the part is relative to the whole interface.
1427 */
1428EAPI void edje_edit_state_rel1_to_x_set(Evas_Object *obj, const char *part, const char *state, double value, const char *rel_to);
1429
1430/** Set the part rel1y is relative to.
1431 *
1432 * @param obj Object being edited.
1433 * @param part Part that contain state.
1434 * @param state The name of the state to set rel1y is relative to (not including the state value).
1435 * @param value The state value.
1436 * @param rel_to The name of the part that is used as container/parent (NULL make the part relative to the whole interface).
1437 *
1438 * @return The part name rel1y is relative to or NULL if the part is relative to the whole interface.
1439 */
1440EAPI void edje_edit_state_rel1_to_y_set(Evas_Object *obj, const char *part, const char *state, double value, const char *rel_to);
1441
1442/** Set the part rel2x is relative to.
1443 *
1444 * @param obj Object being edited.
1445 * @param part Part that contain state.
1446 * @param state The name of the state to set rel2x is relative to (not including the state value).
1447 * @param value The state value.
1448 * @param rel_to The name of the part that is used as container/parent (NULL make the part relative to the whole interface).
1449 *
1450 * @return The part name rel2x is relative to or NULL if the part is relative to the whole interface.
1451 */
1452EAPI void edje_edit_state_rel2_to_x_set(Evas_Object *obj, const char *part, const char *state, double value, const char *rel_to);
1453
1454/** Set the part rel2y is relative to.
1455 *
1456 * @param obj Object being edited.
1457 * @param part Part that contain state.
1458 * @param state The name of the state to set rel2y is relative to (not including the state value).
1459 * @param value The state value.
1460 * @param rel_to The name of the part that is used as container/parent (NULL make the part relative to the whole interface).
1461 *
1462 * @return The part name rel2y is relative to or NULL if the part is relative to the whole interface.
1463 */
1464EAPI void edje_edit_state_rel2_to_y_set(Evas_Object *obj, const char *part, const char *state, double value, const char *rel_to);
1465
1466/** Get the color of a part state.
1467 *
1468 * @param obj Object being edited.
1469 * @param part Part that contain state.
1470 * @param state The name of the state to get color (not including the state value).
1471 * @param value The state value.
1472 * @param r A pointer to store the red value.
1473 * @param g A pointer to store the green value.
1474 * @param b A pointer to store the blue value.
1475 * @param a A pointer to store the alpha value.
1476 */
1477EAPI void edje_edit_state_color_get(Evas_Object *obj, const char *part, const char *state, double value, int *r, int *g, int *b, int *a);
1478
1479/** Get the color2 of a part state.
1480 *
1481 * @param obj Object being edited.
1482 * @param part Part that contain state.
1483 * @param state The name of the state to get color (not including the state value).
1484 * @param value The state value.
1485 * @param r A pointer to store the red value.
1486 * @param g A pointer to store the green value.
1487 * @param b A pointer to store the blue value.
1488 * @param a A pointer to store the alpha value.
1489 */
1490EAPI void edje_edit_state_color2_get(Evas_Object *obj, const char *part, const char *state, double value, int *r, int *g, int *b, int *a);
1491
1492/** Get the color3 of a part state.
1493 *
1494 * @param obj Object being edited.
1495 * @param part Part that contain state.
1496 * @param state The name of the state to get color (not including the state value).
1497 * @param value The state value.
1498 * @param r A pointer to store the red value.
1499 * @param g A pointer to store the green value.
1500 * @param b A pointer to store the blue value.
1501 * @param a A pointer to store the alpha value.
1502 */
1503EAPI void edje_edit_state_color3_get(Evas_Object *obj, const char *part, const char *state, double value, int *r, int *g, int *b, int *a);
1504
1505/** Set the color of a part state.
1506 *
1507 * @param obj Object being edited.
1508 * @param part Part that contain state.
1509 * @param state The name of the state to set color (not including the state value).
1510 * @param value The state value.
1511 * @param r The red value of the color.
1512 * @param g The green value of the color.
1513 * @param b The blue value of the color.
1514 * @param a The alpha value of the color.
1515 */
1516EAPI void edje_edit_state_color_set(Evas_Object *obj, const char *part, const char *state, double value, int r, int g, int b, int a);
1517
1518/** Set the color2 of a part state.
1519 *
1520 * @param obj Object being edited.
1521 * @param part Part that contain state.
1522 * @param state The name of the state to set color (not including the state value).
1523 * @param value The state value.
1524 * @param r The red value of the color.
1525 * @param g The green value of the color.
1526 * @param b The blue value of the color.
1527 * @param a The alpha value of the color.
1528 */
1529EAPI void edje_edit_state_color2_set(Evas_Object *obj, const char *part, const char *state, double value, int r, int g, int b, int a);
1530
1531/** Set the color3 of a part state.
1532 *
1533 * @param obj Object being edited.
1534 * @param part Part that contain state.
1535 * @param state The name of the state to set color (not including the state value).
1536 * @param value The state value.
1537 * @param r The red value of the color.
1538 * @param g The green value of the color.
1539 * @param b The blue value of the color.
1540 * @param a The alpha value of the color.
1541 */
1542EAPI void edje_edit_state_color3_set(Evas_Object *obj, const char *part, const char *state, double value, int r, int g, int b, int a);
1543
1544/** Get the horizontal align value of a part state.
1545 *
1546 * @param obj Object being edited.
1547 * @param part Part that contain state.
1548 * @param state The name of the state to get horizontal align (not including the state value).
1549 * @param value The state value.
1550 *
1551 * @return The horizontal align value for the given state
1552 */
1553EAPI double edje_edit_state_align_x_get(Evas_Object *obj, const char *part, const char *state, double value);
1554
1555/** Get the vertical align value of a part state.
1556 *
1557 * @param obj Object being edited.
1558 * @param part Part that contain state.
1559 * @param state The name of the state to get horizontal align (not including the state value).
1560 * @param value The state value.
1561 *
1562 * @return The vertical align value for the given state
1563 */
1564EAPI double edje_edit_state_align_y_get(Evas_Object *obj, const char *part, const char *state, double value);
1565
1566/** Set the horizontal align value of a part state.
1567 *
1568 * @param obj Object being edited.
1569 * @param part Part that contain state.
1570 * @param state The name of the state to get horizontal align (not including the state value).
1571 * @param value The state value.
1572 * @param align The new vertical align value.
1573 */
1574EAPI void edje_edit_state_align_x_set(Evas_Object *obj, const char *part, const char *state, double value, double align);
1575
1576/** Set the vertical align value of a part state.
1577 *
1578 * @param obj Object being edited.
1579 * @param part Part that contain state.
1580 * @param state The name of the state to get vertical align (not including the state value).
1581 * @param value The state value.
1582 * @param align The new vertical align value.
1583 */
1584EAPI void edje_edit_state_align_y_set(Evas_Object *obj, const char *part, const char *state, double value, double align);
1585
1586/** Get the minimum width value of a part state.
1587 *
1588 * @param obj Object being edited.
1589 * @param part Part that contain state.
1590 * @param state The name of the state to get minimum width (not including the state value).
1591 * @param value The state value.
1592 *
1593 * @return The minimum width value.
1594 */
1595EAPI int edje_edit_state_min_w_get(Evas_Object *obj, const char *part, const char *state, double value);
1596
1597/** Set the minimum width value of a part state.
1598 *
1599 * @param obj Object being edited.
1600 * @param part Part that contain state.
1601 * @param state The name of the state to set minimum width (not including the state value).
1602 * @param value The state value.
1603 * @param min_w Minimum width value.
1604 */
1605EAPI void edje_edit_state_min_w_set(Evas_Object *obj, const char *part, const char *state, double value, int min_w);
1606
1607/** Get the minimum height value of a part state.
1608 *
1609 * @param obj Object being edited.
1610 * @param part Part that contain state.
1611 * @param state The name of the state to get minimum height (not including the state value).
1612 * @param value The state value.
1613 *
1614 * @return The minimum height value.
1615 */
1616EAPI int edje_edit_state_min_h_get(Evas_Object *obj, const char *part, const char *state, double value);
1617
1618/** Set the minimum height value of a part state.
1619 *
1620 * @param obj Object being edited.
1621 * @param part Part that contain state.
1622 * @param state The name of the state to set minimum height (not including the state value).
1623 * @param value The state value.
1624 * @param min_h Minimum height value.
1625 */
1626EAPI void edje_edit_state_min_h_set(Evas_Object *obj, const char *part, const char *state, double value, int min_h);
1627
1628/** Get the maximum width value of a part state.
1629 *
1630 * @param obj Object being edited.
1631 * @param part Part that contain state.
1632 * @param state The name of the state to get maximum width (not including the state value).
1633 * @param value The state value.
1634 *
1635 * @return The maximum width value.
1636 */
1637EAPI int edje_edit_state_max_w_get(Evas_Object *obj, const char *part, const char *state, double value);
1638
1639/** Set the maximum width value of a part state.
1640 *
1641 * @param obj Object being edited.
1642 * @param part Part that contain state.
1643 * @param state The name of the state to set maximum width (not including the state value).
1644 * @param value The state value.
1645 * @param max_w Maximum width value.
1646 */
1647EAPI void edje_edit_state_max_w_set(Evas_Object *obj, const char *part, const char *state, double value, int max_w);
1648
1649/** Get the maximum height value of a part state.
1650 *
1651 * @param obj Object being edited.
1652 * @param part Part that contain state.
1653 * @param state The name of the state to get maximum height (not including the state value).
1654 * @param value The state value.
1655 *
1656 * @return The maximum height value.
1657 */
1658EAPI int edje_edit_state_max_h_get(Evas_Object *obj, const char *part, const char *state, double value);
1659
1660/** Set the maximum height value of a part state.
1661 *
1662 * @param obj Object being edited.
1663 * @param part Part that contain state.
1664 * @param state The name of the state to set maximum height (not including the state value).
1665 * @param value The state value.
1666 * @param max_h Maximum height value.
1667 */
1668EAPI void edje_edit_state_max_h_set(Evas_Object *obj, const char *part, const char *state, double value, int max_h);
1669
1670/** Get the minimum aspect value of a part state.
1671 *
1672 * @param obj Object being edited.
1673 * @param part Part that contain state.
1674 * @param state The name of the state to get minimum aspect (not including the state value).
1675 * @param value The state value.
1676 *
1677 * @return The minimum aspect
1678 */
1679EAPI double edje_edit_state_aspect_min_get(Evas_Object *obj, const char *part, const char *state, double value);
1680
1681/** Get the maximum aspect value of a part state.
1682 *
1683 * @param obj Object being edited.
1684 * @param part Part that contain state.
1685 * @param state The name of the state to get maximum aspect (not including the state value).
1686 * @param value The state value.
1687 *
1688 * @return The maximum aspect
1689 */
1690EAPI double edje_edit_state_aspect_max_get(Evas_Object *obj, const char *part, const char *state, double value);
1691
1692/** Set the minimum aspect value of a part state.
1693 *
1694 * @param obj Object being edited.
1695 * @param part Part that contain state.
1696 * @param state The name of the state to set minimum aspect (not including the state value).
1697 * @param value The state value.
1698 * @param aspect Minimum aspect value.
1699 */
1700EAPI void edje_edit_state_aspect_min_set(Evas_Object *obj, const char *part, const char *state, double value, double aspect);
1701
1702/** Set the maximum aspect value of a part state.
1703 *
1704 * @param obj Object being edited.
1705 * @param part Part that contain state.
1706 * @param state The name of the state to set maximum aspect (not including the state value).
1707 * @param value The state value.
1708 * @param aspect Maximum aspect value.
1709 */
1710EAPI void edje_edit_state_aspect_max_set(Evas_Object *obj, const char *part, const char *state, double value, double aspect);
1711
1712/** Get the aspect preference of a part state.
1713 *
1714 * @param obj Object being edited.
1715 * @param part Part that contain state.
1716 * @param state The name of the state to get aspect preference (not including the state value).
1717 * @param value The state value.
1718 *
1719 * @return The aspect preference (0 = None, 1 = Vertical, 2 = Horizontal, 3 = Both)
1720 */
1721EAPI unsigned char edje_edit_state_aspect_pref_get(Evas_Object *obj, const char *part, const char *state, double value);
1722
1723/** Set the aspect preference of a part state.
1724 *
1725 * @param obj Object being edited.
1726 * @param part Part that contain state.
1727 * @param state The name of the state to set aspect preference (not
1728 * including the state value).
1729 * @param value The state value.
1730 * @param pref The aspect preference to set (0 = None, 1 = Vertical, 2
1731 * = Horizontal, 3 = Both)
1732 */
1733EAPI void edje_edit_state_aspect_pref_set(Evas_Object *obj, const char *part, const char *state, double value, unsigned char pref);
1734
1735/** Get the fill horizontal origin relative value of a part state.
1736 *
1737 * @param obj Object being edited.
1738 * @param part Part that contain state.
1739 * @param state The name of the state to get the fill horizontal origin relative to area (not including the state value).
1740 * @param value The state value.
1741 *
1742 * @return The fill horizontal origin relative to area.
1743 */
1744EAPI double edje_edit_state_fill_origin_relative_x_get(Evas_Object *obj, const char *part, const char *state, double value);
1745
1746/** Get the fill vertical origin relative value of a part state.
1747 *
1748 * @param obj Object being edited.
1749 * @param part Part that contain state.
1750 * @param state The name of the state to get fill vertical origin relative to area (not including the state value).
1751 * @param value The state value.
1752 *
1753 * @return The fill vertical origin relative to area.
1754 */
1755EAPI double edje_edit_state_fill_origin_relative_y_get(Evas_Object *obj, const char *part, const char *state, double value);
1756
1757/** Get the fill horizontal origin offset value of a part state.
1758 *
1759 * @param obj Object being edited.
1760 * @param part Part that contain state.
1761 * @param state The name of the state to get fill horizontal origin offset relative to area (not including the state value).
1762 * @param value The state value.
1763 *
1764 * @return The fill horizontal origin offset relative to area.
1765 */
1766EAPI int edje_edit_state_fill_origin_offset_x_get(Evas_Object *obj, const char *part, const char *state, double value);
1767
1768/** Get the fill vertical origin offset value of a part state.
1769 *
1770 * @param obj Object being edited.
1771 * @param part Part that contain state.
1772 * @param state The name of the state to get fill vertical origin offset relative to area (not including the state value).
1773 * @param value The state value.
1774 *
1775 * @return The fill vertical origin offset value.
1776 */
1777EAPI int edje_edit_state_fill_origin_offset_y_get(Evas_Object *obj, const char *part, const char *state, double value);
1778
1779/** Set the fill horizontal origin relative value of a part state.
1780 *
1781 * @param obj Object being edited.
1782 * @param part Part that contain state.
1783 * @param state The name of the state to set fill horizontal origin relative to area (not including the state value).
1784 * @param value The state value.
1785 * @param x The fill horizontal origin value.
1786 */
1787EAPI void edje_edit_state_fill_origin_relative_x_set(Evas_Object *obj, const char *part, const char *state, double value, double x);
1788
1789/** Set the fill horizontal origin relative value of a part state.
1790 *
1791 * @param obj Object being edited.
1792 * @param part Part that contain state.
1793 * @param state The name of the state to set fill vertical origin relative to area (not including the state value).
1794 * @param value The state value.
1795 * @param y The fill vertical origin value.
1796 */
1797EAPI void edje_edit_state_fill_origin_relative_y_set(Evas_Object *obj, const char *part, const char *state, double value, double y);
1798
1799/** Set the fill horizontal origin offset value of a part state.
1800 *
1801 * @param obj Object being edited.
1802 * @param part Part that contain state.
1803 * @param state The name of the state to set fill horizontal origin offset relative to area (not including the state value).
1804 * @param value The state value.
1805 * @param x The fill horizontal origin offset value.
1806 */
1807EAPI void edje_edit_state_fill_origin_offset_x_set(Evas_Object *obj, const char *part, const char *state, double value, double x);
1808
1809/** Set the fill vertical origin offset value of a part state.
1810 *
1811 * @param obj Object being edited.
1812 * @param part Part that contain state.
1813 * @param state The name of the state to set fill vertical origin offset relative to area (not including the state value).
1814 * @param value The state value.
1815 * @param y The fill vertical origin offset value.
1816 */
1817EAPI void edje_edit_state_fill_origin_offset_y_set(Evas_Object *obj, const char *part, const char *state, double value, double y);
1818
1819/** Get the fill horizontal size relative value of a part state.
1820 *
1821 * @param obj Object being edited.
1822 * @param part Part that contain state.
1823 * @param state The name of the state to get fill horizontal size relative to area (not including the state value).
1824 * @param value The state value.
1825 *
1826 * @return The fill horizontal size relative to area.
1827 */
1828EAPI double edje_edit_state_fill_size_relative_x_get(Evas_Object *obj, const char *part, const char *state, double value);
1829
1830/** Get the fill vertical size relative value of a part state.
1831 *
1832 * @param obj Object being edited.
1833 * @param part Part that contain state.
1834 * @param state The name of the state to get fill vertical size relative to area (not including the state value).
1835 * @param value The state value.
1836 *
1837 * @return The fill vertical size relative to area.
1838 */
1839EAPI double edje_edit_state_fill_size_relative_y_get(Evas_Object *obj, const char *part, const char *state, double value);
1840
1841/** Get the fill horizontal size offset value of a part state.
1842 *
1843 * @param obj Object being edited.
1844 * @param part Part that contain state.
1845 * @param state The name of the state to get fill horizontal size
1846 * offset relative to area (not including the state value).
1847 * @param value The state value.
1848 *
1849 * @return The fill horizontal size offset relative to area.
1850 */
1851EAPI int edje_edit_state_fill_size_offset_x_get(Evas_Object *obj, const char *part, const char *state, double value);
1852
1853/** Get the fill vertical size offset value of a part state.
1854 *
1855 * @param obj Object being edited.
1856 * @param part Part that contain state.
1857 * @param state The name of the state to get fill vertical size offset
1858 * relative to area (not including the state value).
1859 * @param value The state value.
1860 *
1861 * @return The fill vertical size offset relative to area.
1862 */
1863EAPI int edje_edit_state_fill_size_offset_y_get(Evas_Object *obj, const char *part, const char *state, double value);
1864
1865/** Set the fill horizontal size relative value of a part state.
1866 *
1867 * @param obj Object being edited.
1868 * @param part Part that contain state.
1869 * @param state The name of the state to set fill horizontal size
1870 * relative value (not including the state value).
1871 * @param value The state value.
1872 * @param x The horizontal size relative value.
1873 */
1874EAPI void edje_edit_state_fill_size_relative_x_set(Evas_Object *obj, const char *part, const char *state, double value, double x);
1875
1876/** Set the fill vertical size relative value of a part state.
1877 *
1878 * @param obj Object being edited.
1879 * @param part Part that contain state.
1880 * @param state The name of the state to set fill vertical size
1881 * relative value (not including the state value).
1882 * @param value The state value.
1883 * @param x The vertical size relative value.
1884 */
1885EAPI void edje_edit_state_fill_size_relative_y_set(Evas_Object *obj, const char *part, const char *state, double value, double x);
1886
1887/** Set the fill horizontal size offset value of a part state.
1888 *
1889 * @param obj Object being edited.
1890 * @param part Part that contain state.
1891 * @param state The name of the state to set fill horizontal size
1892 * offset relative value (not including the state value).
1893 * @param value The state value.
1894 * @param x The horizontal size offset value.
1895 */
1896EAPI void edje_edit_state_fill_size_offset_x_set(Evas_Object *obj, const char *part, const char *state, double value, double x);
1897
1898/** Set the fill vertical size offset value of a part state.
1899 *
1900 * @param obj Object being edited.
1901 * @param part Part that contain state.
1902 * @param state The name of the state to set fill vertical size offset
1903 * relative value (not including the state value).
1904 * @param value The state value.
1905 * @param y The vertical size offset value.
1906 */
1907EAPI void edje_edit_state_fill_size_offset_y_set(Evas_Object *obj, const char *part, const char *state, double value, double y);
1908
1909/** Get the visibility of a part state.
1910 *
1911 * @param obj Object being edited.
1912 * @param part Part that contain state.
1913 * @param state The name of the state to get visibility (not including the state value).
1914 * @param value The state value.
1915 *
1916 * @return EINA_TRUE if the state is visible, EINA_FALSE otherwise.
1917 */
1918EAPI Eina_Bool edje_edit_state_visible_get(Evas_Object *obj, const char *part, const char *state, double value);
1919
1920/** Set the visibility of a part state.
1921 *
1922 * @param obj Object being edited.
1923 * @param part Part that contain state.
1924 * @param state The name of the state to set visibility (not including the state value).
1925 * @param value The state value.
1926 * @param visible To set state visible (EINA_TRUE if the state is visible, EINA_FALSE otherwise)
1927 */
1928EAPI void edje_edit_state_visible_set(Evas_Object *obj, const char *part, const char *state, double value, Eina_Bool visible);
1929
1930/** Get the color class of the given part state.
1931 *
1932 * Remember to free the string with edje_edit_string_free()
1933 *
1934 * @param obj Object being edited.
1935 * @param part Part that contain state.
1936 * @param state The name of the state to get color class (not including the state value).
1937 * @param value The state value.
1938 *
1939 * @return The current color class.
1940 */
1941EAPI const char *edje_edit_state_color_class_get(Evas_Object *obj, const char *part, const char *state, double value);
1942
1943/** Set the color class of the given part state.
1944 *
1945 * @param obj Object being edited.
1946 * @param part Part that contain state.
1947 * @param state The name of the state to set color class (not including the state value).
1948 * @param value The state value.
1949 * @param color_class The color class to assign.
1950 */
1951EAPI void edje_edit_state_color_class_set(Evas_Object *obj, const char *part, const char *state, double value, const char *color_class);
1952
1953/** Get the list of parameters for an external part.
1954 *
1955 * DO NOT FREE THE LIST!
1956 *
1957 * @param obj Object being edited.
1958 * @param part Part that contain state.
1959 * @param state The name of the state to get list of Edje_External_Param (not including the state value).
1960 * @param value The state value.
1961 *
1962 * @return The list of Edje_External_Param.
1963 */
1964EAPI const Eina_List * edje_edit_state_external_params_list_get(Evas_Object *obj, const char *part, const char *state, double value);
1965
1966/** Get the external parameter type and value.
1967 *
1968 * @param obj Object being edited.
1969 * @param part Part that contain state.
1970 * @param state The name of the state to get external parameter (not including the state value).
1971 * @param value The state value.
1972 * @param param The name of the paramter to look for.
1973 * @param type The type of the parameter will be stored here.
1974 * @param val Pointer to value will be stored here - DO NOT FREE IT!
1975 *
1976 * @return EINA_TRUE if the parameter was found, EINA_FALSE otherwise.
1977 */
1978EAPI Eina_Bool edje_edit_state_external_param_get(Evas_Object *obj, const char *part, const char *state, double value, const char *param, Edje_External_Param_Type *type, void **val);
1979
1980/** Get external parameter of type INT.
1981 *
1982 * @param obj Object being edited.
1983 * @param part Part that contain state.
1984 * @param state The name of the state to get external parameter of type INT (not including the state value).
1985 * @param value The state value.
1986 * @param param The name of the paramter.
1987 * @param val The value of the parameter.
1988 *
1989 * @return EINA_TRUE if successful. EINA_FALSE if not found or is of different type.
1990 */
1991EAPI Eina_Bool edje_edit_state_external_param_int_get(Evas_Object *obj, const char *part, const char *state, double value, const char *param, int *val);
1992
1993/** Get external parameter of type BOOL.
1994 *
1995 * @param obj Object being edited.
1996 * @param part Part that contain state.
1997 * @param state The name of the state to get external parameter of type BOOL (not including the state value).
1998 * @param value The state value.
1999 * @param param The name of the paramter.
2000 * @param val The value of the parameter.
2001 *
2002 * @return EINA_TRUE if successful. EINA_FALSE if not found or is of different type.
2003 */
2004EAPI Eina_Bool edje_edit_state_external_param_bool_get(Evas_Object *obj, const char *part, const char *state, double value, const char *param, Eina_Bool *val);
2005
2006/** Get external parameter of type DOUBLE.
2007 *
2008 * @param obj Object being edited.
2009 * @param part Part that contain state.
2010 * @param state The name of the state to get external parameter of type DOUBLE (not including the state value).
2011 * @param value The state value.
2012 * @param param The name of the paramter.
2013 * @param val The value of the parameter.
2014 *
2015 * @return EINA_TRUE if successful. EINA_FALSE if not found or is of different type.
2016 */
2017EAPI Eina_Bool edje_edit_state_external_param_double_get(Evas_Object *obj, const char *part, const char *state, double value, const char *param, double *val);
2018
2019/** Get external parameter of type STRING.
2020 *
2021 * @param obj Object being edited.
2022 * @param part Part that contain state.
2023 * @param state The name of the state to get external parameter of
2024 * type STRING (not including the state value).
2025 * @param value The state value.
2026 * @param param The name of the paramter.
2027 * @param val The value of the parameter.
2028 *
2029 * @return EINA_TRUE if successful. EINA_FALSE if not found or is of
2030 * different type.
2031 */
2032EAPI Eina_Bool edje_edit_state_external_param_string_get(Evas_Object *obj, const char *part, const char *state, double value, const char *param, const char **val);
2033
2034/** Get external parameter of type CHOICE.
2035 *
2036 * @param obj Object being edited.
2037 * @param part Part that contain state.
2038 * @param state The name of the state to get external parameter of
2039 * type CHOICE (not including the state value).
2040 * @param value The state value.
2041 * @param param The name of the paramter.
2042 * @param val The value of the parameter.
2043 *
2044 * @return EINA_TRUE if successful. EINA_FALSE if not found or is of
2045 * different type.
2046 */
2047EAPI Eina_Bool edje_edit_state_external_param_choice_get(Evas_Object *obj, const char *part, const char *state, double value, const char *param, const char **val);
2048
2049/** Set the external parameter type and value, adding it if it didn't
2050 * exist before.
2051 *
2052 * @param obj Object being edited.
2053
2054 * @param part Part that contain state.
2055 * @param state The name of the state to get external parameter (not
2056 * including the state value).
2057 * @param value The state value.
2058 * @param param The name of the paramter set.
2059 * @param type The type of the parameter.
2060 *
2061 * @return EINA_TRUE if it was set, EINA_FALSE otherwise.
2062 */
2063
2064/**
2065 * Arguments should have proper sized values matching their types:
2066 * - EDJE_EXTERNAL_PARAM_TYPE_INT: int
2067 * - EDJE_EXTERNAL_PARAM_TYPE_BOOL: int
2068 * - EDJE_EXTERNAL_PARAM_TYPE_DOUBLE: double
2069 * - EDJE_EXTERNAL_PARAM_TYPE_STRING: char*
2070 * - EDJE_EXTERNAL_PARAM_TYPE_CHOICE: char*
2071 *
2072 * @note: The validation of the parameter will occur only if the part
2073 * is in the same state as the one being modified.
2074 */
2075EAPI Eina_Bool edje_edit_state_external_param_set(Evas_Object *obj, const char *part, const char *state, double value, const char *param, Edje_External_Param_Type type, ...);
2076
2077/** Set external parameter of type INT.
2078 *
2079 * @param obj Object being edited.
2080 * @param part Part that contain state.
2081 * @param state The name of the state to get external parameter of
2082 * type INT (not including the state value).
2083 * @param value The state value.
2084 * @param param The name of the paramter.
2085 * @param val Value will be stored here.
2086 *
2087 * @return EINA_TRUE if it was set, EINA_FALSE otherwise.
2088 */
2089EAPI Eina_Bool edje_edit_state_external_param_int_set(Evas_Object *obj, const char *part, const char *state, double value, const char *param, int val);
2090
2091/** Set external parameter of type BOOL.
2092 *
2093 * @param obj Object being edited.
2094 * @param part Part that contain state.
2095 * @param state The name of the state to get external parameter of type BOOL (not including the state value).
2096 * @param value The state value.
2097 * @param param The name of the paramter.
2098 * @param val Value will be stored here.
2099 *
2100 * @return EINA_TRUE if it was set, EINA_FALSE otherwise.
2101 */
2102EAPI Eina_Bool edje_edit_state_external_param_bool_set(Evas_Object *obj, const char *part, const char *state, double value, const char *param, Eina_Bool val);
2103
2104/** Set external parameter of type DOUBLE.
2105 *
2106 * @param obj Object being edited.
2107 * @param part Part that contain state.
2108 * @param state The name of the state to get external parameter of type DOUBLE (not including the state value).
2109 * @param value The state value.
2110 * @param param The name of the paramter.
2111 * @param val Value will be stored here.
2112 *
2113 * @return EINA_TRUE if it was set, EINA_FALSE otherwise.
2114 */
2115EAPI Eina_Bool edje_edit_state_external_param_double_set(Evas_Object *obj, const char *part, const char *state, double value, const char *param, double val);
2116
2117/** Set external parameter of type STRING.
2118 *
2119 * @param obj Object being edited.
2120 * @param part Part that contain state.
2121 * @param state The name of the state to get external parameter of type STRING (not including the state value).
2122 * @param value The state value.
2123 * @param param The name of the paramter.
2124 * @param val Value will be stored here.
2125 *
2126 * @return EINA_TRUE if it was set, EINA_FALSE otherwise.
2127 */
2128EAPI Eina_Bool edje_edit_state_external_param_string_set(Evas_Object *obj, const char *part, const char *state, double value, const char *param, const char *val);
2129
2130/** Set external parameter of type CHOICE.
2131 *
2132 * @param obj Object being edited.
2133 * @param part Part that contain state.
2134 * @param state The name of the state to get external parameter of type CHOICE (not including the state value).
2135 * @param value The state value.
2136 * @param param The name of the paramter.
2137 * @param val Value will be stored here.
2138 *
2139 * @return EINA_TRUE if it was set, EINA_FALSE otherwise.
2140 */
2141EAPI Eina_Bool edje_edit_state_external_param_choice_set(Evas_Object *obj, const char *part, const char *state, double value, const char *param, const char *val);
2142
2143
2144//@}
2145/******************************************************************************/
2146/************************** TEXT API ************************************/
2147/******************************************************************************/
2148/** @name Text API
2149 * Functions to deal with text objects (see @ref edcref).
2150 */ //@{
2151
2152/** Get the text of a part state.
2153 *
2154 * Remember to free the returned string with edje_edit_string_free().
2155 *
2156 * @param obj Object being edited.
2157 * @param part Part that contain state.
2158 * @param state The name of the state to get text (not including the state value).
2159 * @param value The state value.
2160 *
2161 * @return A newly allocated string containing the text for the given state.
2162 */
2163EAPI const char * edje_edit_state_text_get(Evas_Object *obj, const char *part, const char *state, double value);
2164
2165/** Set the text of a part state.
2166 *
2167 * @param obj Object being edited.
2168 * @param part Part that contain state.
2169 * @param state The name of the state to set text (not including the state value).
2170 * @param value The state value.
2171 * @param text The new text to assign.
2172 */
2173EAPI void edje_edit_state_text_set(Evas_Object *obj, const char *part, const char *state, double value,const char *text);
2174
2175/** Get font name for a given part state.
2176 *
2177 * @param obj Object being edited.
2178 * @param part The name of the part to get the font of.
2179 * @param state The state of the part to get the font of.
2180 * @param value Value of the state.
2181 *
2182 * @return Font used by the part or NULL if error or nothing is set.
2183 */
2184EAPI const char * edje_edit_state_font_get(Evas_Object *obj, const char *part, const char *state, double value);
2185
2186/** Set font name for a given part state.
2187 *
2188 * Font name can be any alias of an internal font in the Edje file and,
2189 * if it doesn't match any, Edje will look for a font with the given name
2190 * in the system fonts.
2191 *
2192 * @param obj Object being edited.
2193 * @param part Part to set the font of.
2194 * @param state State in which the font is set.
2195 * @param value Value of the state.
2196 * @param font The font name to use.
2197 */
2198EAPI void edje_edit_state_font_set(Evas_Object *obj, const char *part, const char *state, double value, const char *font);
2199
2200/** Get the text size of a part state
2201 *
2202 * @param obj Object being edited.
2203 * @param part Part that contain state.
2204 * @param state The name of the state to get text size (not including the state value).
2205 * @param value The state value.
2206 *
2207 * @return The text size or -1 on errors.
2208 */
2209EAPI int edje_edit_state_text_size_get(Evas_Object *obj, const char *part, const char *state, double value);
2210
2211/** Set the text size of a part state.
2212 *
2213 * @param obj Object being edited.
2214 * @param part Part that contain state.
2215 * @param state The name of the state to set text size (not including the state value).
2216 * @param value The state value.
2217 * @param size The new font size to set (in pixel)
2218 */
2219EAPI void edje_edit_state_text_size_set(Evas_Object *obj, const char *part, const char *state, double value, int size);
2220
2221/** Get the text horizontal align of a part state.
2222 *
2223 * The value range is from 0.0(right) to 1.0(left)
2224 *
2225 * @param obj Object being edited.
2226 * @param part Part that contain state.
2227 * @param state The name of the state to get the text horizontal align (not including the state value).
2228 * @param value The state value.
2229 *
2230 * @return The text horizont align value
2231 */
2232EAPI double edje_edit_state_text_align_x_get(Evas_Object *obj, const char *part, const char *state, double value);
2233
2234/** Get the text vertical align of a part state.
2235 *
2236 * The value range is from 0.0(top) to 1.0(bottom)
2237 *
2238 * @param obj Object being edited.
2239 * @param part Part that contain state.
2240 * @param state The name of the state to get the text vertical align (not including the state value).
2241 * @param value The state value.
2242 *
2243 * @return The text horizont align value
2244 */
2245EAPI double edje_edit_state_text_align_y_get(Evas_Object *obj, const char *part, const char *state, double value);
2246
2247/** Set the text horizontal align of a part state.
2248 *
2249 * The value range is from 0.0(right) to 1.0(left)
2250 *
2251 * @param obj Object being edited.
2252 * @param part Part that contain state.
2253 * @param state The name of the state to set the text horizontal align (not including the state value).
2254 * @param value The state value.
2255 * @param align The new text horizontal align value
2256 */
2257EAPI void edje_edit_state_text_align_x_set(Evas_Object *obj, const char *part, const char *state, double value, double align);
2258
2259/** Set the text vertical align of a part state.
2260 *
2261 * The value range is from 0.0(top) to 1.0(bottom)
2262 *
2263 * @param obj Object being edited.
2264 * @param part Part that contain state.
2265 * @param state The name of the state to set the text vertical align (not including the state value).
2266 * @param value The state value.
2267 * @param align The new text vertical align value
2268 */
2269EAPI void edje_edit_state_text_align_y_set(Evas_Object *obj, const char *part, const char *state, double value, double align);
2270
2271/** Get the text elipsis of a part state.
2272 *
2273 * The value range is from 0.0(right) to 1.0(left)
2274 *
2275 * @param obj Object being edited.
2276 * @param part Part that contain state.
2277 * @param state The name of the state to get the text elipses value (not including the state value).
2278 * @param value The state value.
2279 *
2280 * @return The text elipsis value
2281 */
2282EAPI double edje_edit_state_text_elipsis_get(Evas_Object *obj, const char *part, const char *state, double value);
2283
2284/** Set the text vertical align of a part state.
2285 *
2286 * The value range is from 0.0(right) to 1.0(left)
2287 *
2288 * @param obj Object being edited.
2289 * @param part Part that contain state.
2290 * @param state The name of the state to set the text elipses value (not including the state value).
2291 * @param value The state value.
2292 * @param balance The position where to cut the string
2293 */
2294EAPI void edje_edit_state_text_elipsis_set(Evas_Object *obj, const char *part, const char *state, double value, double balance);
2295
2296/** Get if the text part fit it's container horizontally
2297 *
2298 * @param obj Object being edited.
2299 * @param part Part that contain state.
2300 * @param state The name of the state to get the if the text part fit it's container horizontally (not including the state value).
2301 * @param value The state value.
2302 *
2303 * @return EINA_TRUE If the part fit it's container horizontally, EINA_FALSE otherwise.
2304 */
2305EAPI Eina_Bool edje_edit_state_text_fit_x_get(Evas_Object *obj, const char *part, const char *state, double value);
2306
2307/** Set if the text part should fit it's container horizontally
2308 *
2309 * @param obj Object being edited.
2310 * @param part Part that contain state.
2311 * @param state The name of the state to set the if the text part fit it's container horizontally (not including the state value).
2312 * @param value The state value.
2313 * @param fit EINA_TRUE to make the text fit it's container horizontally, EINA_FALSE otherwise.
2314 */
2315EAPI void edje_edit_state_text_fit_x_set(Evas_Object *obj, const char *part, const char *state, double value, Eina_Bool fit);
2316
2317/** Get if the text part fit it's container vertically
2318 *
2319 * @param obj Object being edited.
2320 * @param part Part that contain state.
2321 * @param state The name of the state to get the if the text part fit it's container vertically (not including the state value).
2322 * @param value The state value.
2323 *
2324 * @return EINA_TRUE If the part fit it's container vertically, EINA_FALSE otherwise.
2325 */
2326EAPI Eina_Bool edje_edit_state_text_fit_y_get(Evas_Object *obj, const char *part, const char *state, double value);
2327
2328/** Set if the text part should fit it's container vertically
2329 *
2330 * @param obj Object being edited.
2331 * @param part Part that contain state.
2332 * @param state The name of the state to set the if the text part fit it's container vertically (not including the state value).
2333 * @param value The state value.
2334 * @param fit EINA_TRUE to make the text fit it's container vertically, EINA_FALSE otherwise.
2335 */
2336EAPI void edje_edit_state_text_fit_y_set(Evas_Object *obj, const char *part, const char *state, double value, Eina_Bool fit);
2337
2338/** Get the list of all the fonts in the given edje.
2339 *
2340 * Use edje_edit_string_list_free() when you don't need the list anymore.
2341 *
2342 * @param obj Object being edited.
2343 *
2344 * @return A list containing all the fonts names found in the edje file.
2345 */
2346EAPI Eina_List * edje_edit_fonts_list_get(Evas_Object *obj);
2347
2348/** Add a new font to the edje file.
2349 *
2350 * The newly created font will be available to all the groups in the edje, not only the current one.
2351 *
2352 * @param obj Object being edited.
2353 * @param path The file path to load the font from.
2354 * @param alias The alias for file, or NULL to use filename
2355 *
2356 * @return EINA_TRUE if font cat be loaded, EINA_FALSE otherwise.
2357 */
2358EAPI Eina_Bool edje_edit_font_add(Evas_Object *obj, const char *path, const char* alias);
2359
2360/** Delete font from the edje file.
2361 *
2362 * The font will be removed from all the groups in the edje, not only the current one.
2363 *
2364 * @param obj Object being edited.
2365 * @param alias The font alias
2366 *
2367 * @return EINA_TRUE if successful, EINA_FALSE otherwise (including the
2368 * case when the alias is not valid).
2369 */
2370EAPI Eina_Bool edje_edit_font_del(Evas_Object *obj, const char* alias);
2371
2372/** Get font path for a given font alias.
2373 *
2374 * Remember to free the string with edje_edit_string_free()
2375 *
2376 * @param obj Object being edited.
2377 * @param alias The font alias.
2378 *
2379 * @return The path of the given font alias.
2380 */
2381EAPI const char *edje_edit_font_path_get(Evas_Object *obj, const char *alias);
2382
2383
2384/** Get font name for a given part state.
2385 *
2386 * Remember to free the returned string using edje_edit_string_free().
2387 *
2388 * @param obj Object being edited.
2389 * @param part Part that contain state.
2390 * @param state The name of the state to get the name of the font used (not including the state value).
2391 * @param value The state value.
2392 *
2393 * @return The name of the font used in the given part state.
2394 */
2395EAPI const char * edje_edit_state_font_get(Evas_Object *obj, const char *part, const char *state, double value);
2396
2397/** Set font name for a given part state.
2398 *
2399 * @param obj Object being edited.
2400 * @param part Part that contain state.
2401 * @param state The name of the state to set the name of the font that will be used (not including the state value).
2402 * @param value The state value.
2403 * @param font The name of the font to use in the given part state.
2404 */
2405EAPI void edje_edit_state_font_set(Evas_Object *obj, const char *part, const char *state, double value, const char *font);
2406
2407
2408//@}
2409/******************************************************************************/
2410/************************** IMAGES API ************************************/
2411/******************************************************************************/
2412/** @name Images API
2413 * Functions to deal with image objects (see @ref edcref).
2414 */ //@{
2415
2416/** Get the list of all the images in the given edje.
2417 * Use edje_edit_string_list_free() when you don't need the list anymore.
2418 *
2419 * @param obj Object being edited.
2420 *
2421 * @return A List containing all images names found in the edje file.
2422 */
2423EAPI Eina_List * edje_edit_images_list_get(Evas_Object *obj);
2424
2425/** Add an new image to the image collection
2426 *
2427 * This function add the given image inside the edje. Don't add a new image part
2428 * but only put the image inside the edje file. It actually write directly to
2429 * the file so you don't have to save.
2430 * After you have to create a new image_part that use this image. Note that all
2431 * the parts in the edje share the same image collection, thus you can/must use
2432 * the same image for different part.
2433 *
2434 * The format of the image files that can be loaded depend on the evas engine on your system
2435 *
2436 * @param obj Object being edited.
2437 * @param path The name of the image file to include in the edje.
2438 *
2439 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
2440 */
2441EAPI Eina_Bool edje_edit_image_add(Evas_Object *obj, const char *path);
2442
2443/** Delete an image from the image collection
2444 *
2445 * It actually write directly to the file so you don't have to save.
2446 *
2447 * @param obj Object being edited.
2448 * @param name The name of the image file to include in the edje.
2449 *
2450 * @return EINA_TRUE if successful, EINA_FALSE otherwise (including the
2451 * case when the name is not valid).
2452 */
2453EAPI Eina_Bool edje_edit_image_del(Evas_Object *obj, const char *name);
2454
2455/** Add an image entry to the image collection
2456 *
2457 * This function adds the given image entry to the edje image collection. The
2458 * image needs to be inside the eet already, with key name "images/id". After
2459 * you have to create a new image_part that use this image, referring to it as
2460 * "name". Note that all the parts in the edje share the same image collection,
2461 * thus you can/must use the same image for different part.
2462 *
2463 * @param obj Object being edited.
2464 * @param name The image entry name.
2465 * @param id The image id.
2466 *
2467 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
2468 */
2469EAPI Eina_Bool edje_edit_image_data_add(Evas_Object *obj, const char *name, int id);
2470
2471/** Get normal image name for a given part state.
2472 *
2473 * @param obj Object being edited.
2474 * @param part Part that contain state.
2475 * @param state The name of the state to get the name that is being used (not including the state value).
2476 * @param value The state value.
2477 *
2478 * @return The name of the image used by state.
2479 */
2480EAPI const char * edje_edit_state_image_get(Evas_Object *obj, const char *part, const char *state, double value);
2481
2482/** Set normal image for a given part state.
2483 *
2484 * @param obj Object being edited.
2485 * @param part Part that contain state.
2486 * @param state The name of the state to set the image that will be used (not including the state value).
2487 * @param value The state value.
2488 * @param image The name of the image (must be an image contained in the edje file).
2489 */
2490EAPI void edje_edit_state_image_set(Evas_Object *obj, const char *part, const char *state, double value, const char *image);
2491
2492/** Get image id for a given image name.
2493 *
2494 * @param obj Object being edited.
2495 * @param image_name The image name.
2496 *
2497 * @return The id of the given image name.
2498 */
2499EAPI int edje_edit_image_id_get(Evas_Object *obj, const char *image_name);
2500
2501/** Get compression type for the given image.
2502 *
2503 * @param obj Object being edited.
2504 * @param image The name of the image.
2505 *
2506 * @return One of Image Compression types.
2507 * (EDJE_EDIT_IMAGE_COMP_RAW, EDJE_EDIT_IMAGE_COMP_USER, EDJE_EDIT_IMAGE_COMP_COMP, EDJE_EDIT_IMAGE_COMP_LOSSY).
2508 */
2509EAPI Edje_Edit_Image_Comp edje_edit_image_compression_type_get(Evas_Object *obj, const char *image);
2510
2511/** Get compression rate for the given image.
2512 *
2513 * @param obj Object being edited.
2514 * @param image The name of the image.
2515 *
2516 * @return The compression rate (if the imnage is @c
2517 * EDJE_EDIT_IMAGE_COMP_LOSSY) or < 0, on errors.
2518 */
2519EAPI int edje_edit_image_compression_rate_get(Evas_Object *obj, const char *image);
2520
2521/** Get the image border of a part state.
2522 *
2523 * Pass NULL to any of [r,g,b,a] to get only the others.
2524 *
2525 * @param obj Object being edited.
2526 * @param part Part that contain state.
2527 * @param state The name of the state to get the image border (not
2528 * including the state value).
2529 * @param value The state value.
2530 * @param l A pointer to store the left value
2531 * @param r A pointer to store the right value
2532 * @param t A pointer to store the top value
2533 * @param b A pointer to store the bottom value
2534 */
2535EAPI void edje_edit_state_image_border_get(Evas_Object *obj, const char *part, const char *state, double value, int *l, int *r, int *t, int *b);
2536
2537/** Set the image border of a part state.
2538 *
2539 * Pass -1 to any of [l,r,t,b] to leave the value untouched.
2540 *
2541 * @param obj Object being edited.
2542 * @param part Part that contain state.
2543 * @param state The name of the state to set the image border (not
2544 * including the state value).
2545 * @param value The state value.
2546 * @param l Left border value (or -1).
2547 * @param r Right border value (or -1).
2548 * @param t Top border value (or -1).
2549 * @param b Bottom border value (or -1).
2550 */
2551EAPI void edje_edit_state_image_border_set(Evas_Object *obj, const char *part, const char *state, double value, int l, int r, int t, int b);
2552
2553/** Get if the image center should be draw.
2554 *
2555 * 1 means to draw the center, 0 to don't draw it.
2556 *
2557 * @param obj Object being edited.
2558 * @param part Part that contain state.
2559 * @param state The name of the state to get the image border fill (not including the state value).
2560 * @param value The state value.
2561 *
2562 * @return 1 if the center of the bordered image is draw, 0 otherwise.
2563 */
2564EAPI unsigned char edje_edit_state_image_border_fill_get(Evas_Object *obj, const char *part, const char *state, double value);
2565
2566/** Set if the image center should be draw.
2567 *
2568 * 1 means to draw the center, 0 to don't draw it.
2569 *
2570 * @param obj Object being edited.
2571 * @param part Part that contain state.
2572 * @param state The name of the state to set the image border fill (not including the state value).
2573 * @param value The state value.
2574 * @param fill Fill to be se. 1 if the center of the bordered image is draw, 0 otherwise.
2575 */
2576EAPI void edje_edit_state_image_border_fill_set(Evas_Object *obj, const char *part, const char *state, double value, unsigned char fill);
2577
2578/** Get the list of all the tweens images in the given part state.
2579 *
2580 * Use edje_edit_string_list_free() when you don't need it anymore.
2581 *
2582 * @param obj Object being edited.
2583 * @param part Part that contain state.
2584 * @param state The name of the state to get the list of all the tweens images (not including the state value).
2585 * @param value The state value.
2586 *
2587 * @return A string list containing all the image name that form a tween animation in the given part state.
2588 */
2589EAPI Eina_List * edje_edit_state_tweens_list_get(Evas_Object *obj, const char *part, const char *state, double value);
2590
2591/** Add a new tween frame to the given part state.
2592 *
2593 * The tween param must be the name of an existing image.
2594 *
2595 * @param obj Object being edited.
2596 * @param part Part that contain state.
2597 * @param state The name of the state to add a new tween frame (not including the state value).
2598 * @param value The state value.
2599 * @param tween The name of the image to add.
2600 *
2601 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
2602 */
2603EAPI Eina_Bool edje_edit_state_tween_add(Evas_Object *obj, const char *part, const char *state, double value, const char *tween);
2604
2605/** Remove the first tween with the given name.
2606 *
2607 * The image is not removed from the edje.
2608 *
2609 * @param obj Object being edited.
2610 * @param part Part that contain state.
2611 * @param state The name of the state to del the tween (not including the state value).
2612 * @param value The state value.
2613 * @param tween The name of the image to del.
2614 *
2615 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
2616 */
2617EAPI Eina_Bool edje_edit_state_tween_del(Evas_Object *obj, const char *part, const char *state, double value, const char *tween);
2618
2619
2620//@}
2621/******************************************************************************/
2622/************************* SPECTRUM API ***********************************/
2623/******************************************************************************/
2624/** @name Spectrum API
2625 * Functions to manage spectrum (see @ref edcref).
2626 */ //@{
2627
2628/** Get the list of all the spectrum in the given edje object.
2629 *
2630 * Use edje_edit_string_list_free() when you don't need it anymore.
2631 *
2632 * @param obj Object being edited.
2633 *
2634 * @return A list containing all the spectra names.
2635 */
2636EAPI Eina_List * edje_edit_spectrum_list_get(Evas_Object *obj);
2637
2638/** Add a new spectra in the given edje object.
2639 *
2640 * @param obj Object being edited.
2641 * @param name The name of the spectra to include in the edje.
2642 *
2643 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
2644 */
2645EAPI Eina_Bool edje_edit_spectra_add(Evas_Object *obj, const char *name);
2646
2647/** Delete the given spectra from the edje object.
2648 *
2649 * @param obj Object being edited.
2650 * @param spectra The name of the spectra to delete.
2651 *
2652 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
2653 */
2654EAPI Eina_Bool edje_edit_spectra_del(Evas_Object *obj, const char *spectra);
2655
2656/** Change the name of the given spectra.
2657 *
2658 * @param obj Object being edited.
2659 * @param spectra The name of the current spectra.
2660 * @param name The new name to assign.
2661 *
2662 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
2663 */
2664EAPI Eina_Bool edje_edit_spectra_name_set(Evas_Object *obj, const char *spectra, const char *name);
2665
2666/** Get the number of stops in the given spectra.
2667 *
2668 * @param obj Object being edited.
2669 * @param spectra The name of the spectra.
2670 *
2671 * @return The number of stops (or 0 on errors).
2672 */
2673EAPI int edje_edit_spectra_stop_num_get(Evas_Object *obj, const char *spectra);
2674
2675/** Set the number of stops in the given spectra.
2676 *
2677 * @param obj Object being edited.
2678 * @param spectra The name of the spectra.
2679 * @param num The number of stops you want
2680 *
2681 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
2682 */
2683EAPI Eina_Bool edje_edit_spectra_stop_num_set(Evas_Object *obj, const char *spectra, int num);
2684
2685/** Get the colors of the given stop.
2686 *
2687 * @param obj Object being edited.
2688 * @param spectra The name of the spectra.
2689 * @param stop_number The number of the stop,
2690 * @param r Where to store the red color value,
2691 * @param g Where to store the green color value,
2692 * @param b Where to store the blue color value,
2693 * @param a Where to store the alpha color value,
2694 * @param d Where to store the delta stop value,
2695 *
2696 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
2697 */
2698EAPI Eina_Bool edje_edit_spectra_stop_color_get(Evas_Object *obj, const char *spectra, int stop_number, int *r, int *g, int *b, int *a, int *d);
2699
2700/** Set the colors of the given stop.
2701 *
2702 * @param obj Object being edited.
2703 * @param spectra The name of the spectra.
2704 * @param stop_number The number of the stops,
2705 * @param r The red color value to set,
2706 * @param g The green color value to set,
2707 * @param b The blue color value to set,
2708 * @param a The alpha color value to set,
2709 * @param d The delta stop value to set,
2710 */
2711EAPI Eina_Bool edje_edit_spectra_stop_color_set(Evas_Object *obj, const char *spectra, int stop_number, int r, int g, int b, int a, int d);
2712
2713
2714//@}
2715/******************************************************************************/
2716/************************* GRADIENT API ***********************************/
2717/******************************************************************************/
2718/** @name Gradient API
2719 * Functions to deal with gradient objects (see @ref edcref).
2720 */ //@{
2721
2722/** Get the type of gradient.
2723 *
2724 * Remember to free the string with edje_edit_string_free().
2725 *
2726 * @param obj Object being edited.
2727 * @param part The part that contain state.
2728 * @param state The name of the state to get the gradient type (not including the state value).
2729 * @param value The state value.
2730 *
2731 * @return The type of gradient used in state.
2732 * (linear, linear.diag, linear.codiag, radial, rectangular, angular, sinosoidal)
2733 */
2734EAPI const char * edje_edit_state_gradient_type_get(Evas_Object *obj, const char *part, const char *state, double value);
2735
2736/** Set the type of gradient.
2737 *
2738 * Gradient type can be on of the following: linear, linear.diag, linear.codiag, radial, rectangular, angular, sinusoidal
2739 *
2740 * @param obj Object being edited.
2741 * @param part The part that contain state.
2742 * @param state The name of the state to set the gradient type (not including the state value).
2743 * @param value The state value.
2744 * @param type The type of gradient to use.
2745 *
2746 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
2747 */
2748EAPI Eina_Bool edje_edit_state_gradient_type_set(Evas_Object *obj, const char *part, const char *state, double value, const char *type);
2749
2750/** Get if the current gradient use the fill properties or the gradient_rel as params.
2751 *
2752 * @param obj Object being edited.
2753 * @param part The part that contain state.
2754 * @param state The name of the state to set the gradient type (not including the state value).
2755 * @param value The state value.
2756 *
2757 * @return EINA_TRUE if gradient use the fill properties, EINA_FALSE otherwise.
2758 * */
2759EAPI Eina_Bool edje_edit_state_gradient_use_fill_get(Evas_Object *obj, const char *part, const char *state, double value);
2760
2761/** Get the spectra used by part state.
2762 *
2763 * Remember to free the string with edje_edit_string_free().
2764 *
2765 * @param obj Object being edited.
2766 * @param part The part that contain state.
2767 * @param state The name of the state to get the spectra name used (not including the state value).
2768 * @param value The state value.
2769 *
2770 * @return The spectra name used in state.
2771 */
2772EAPI const char * edje_edit_state_gradient_spectra_get(Evas_Object *obj, const char *part, const char *state, double value);
2773
2774/** Set the spectra used by part state.
2775 *
2776 * @param obj Object being edited.
2777 * @param part The part that contain state.
2778 * @param state The name of the state to set the spectra (not including the state value).
2779 * @param value The state value.
2780 * @param spectra The spectra name to assign
2781 *
2782 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
2783 */
2784EAPI Eina_Bool edje_edit_state_gradient_spectra_set(Evas_Object *obj, const char *part, const char *state, double value, const char *spectra);
2785
2786/** Get the angle of the gradient.
2787 *
2788 * @param obj Object being edited.
2789 * @param part The part that contain state.
2790 * @param state The name of the state to get the angle (not including the state value).
2791 * @param value The state value.
2792 *
2793 * @return The angle of the gradient.
2794 */
2795EAPI int edje_edit_state_gradient_angle_get(Evas_Object *obj, const char *part, const char *state, double value);
2796
2797/** Set the angle of the gradient.
2798 *
2799 * @param obj Object being edited.
2800 * @param part The part that contain state.
2801 * @param state The name of the state to set the angle (not including the state value).
2802 * @param value The state value.
2803 * @param angle The angle to set.
2804 */
2805EAPI void edje_edit_state_gradient_angle_set(Evas_Object *obj, const char *part, const char *state, double value, int angle);
2806
2807/** Get the gradient rel1 horizontal relative value
2808 *
2809 * @param obj Object being edited.
2810 * @param part The part that contain state.
2811 * @param state The name of the state to get rel1 relative x value (not including the state value).
2812 * @param value The state value.
2813 *
2814 * @return The gradient rel1 horizontal relative value.
2815 */
2816EAPI double edje_edit_state_gradient_rel1_relative_x_get(Evas_Object *obj, const char *part, const char *state, double value);
2817
2818/** Get the gradient rel1 vertical relative value
2819 *
2820 * @param obj Object being edited.
2821 * @param part The part that contain state.
2822 * @param state The name of the state to get rel1 relative y value (not including the state value).
2823 * @param value The state value.
2824 *
2825 * @return The gradient rel1 vertical relative value.
2826 */
2827EAPI double edje_edit_state_gradient_rel1_relative_y_get(Evas_Object *obj, const char *part, const char *state, double value);
2828
2829/** Get the gradient rel2 horizontal relative value
2830 *
2831 * @param obj Object being edited.
2832 * @param part The part that contain state.
2833 * @param state The name of the state to get rel2 relative x value (not including the state value).
2834 * @param value The state value.
2835 *
2836 * @return The gradient rel2 horizontal relative value.
2837 */
2838EAPI double edje_edit_state_gradient_rel2_relative_x_get(Evas_Object *obj, const char *part, const char *state, double value);
2839
2840/** Get the gradient rel2 vertical relative value
2841 *
2842 * @param obj Object being edited.
2843 * @param part The part that contain state.
2844 * @param state The name of the state to get rel2 relative y value (not including the state value).
2845 * @param value The state value.
2846 *
2847 * @return The gradient rel2 vertical relative value.
2848 */
2849EAPI double edje_edit_state_gradient_rel2_relative_y_get(Evas_Object *obj, const char *part, const char *state, double value);
2850
2851
2852/** Set the gradient rel1 horizontal relative value
2853 *
2854 * @param obj Object being edited.
2855 * @param part The part that contain state.
2856 * @param state The name of the state to set rel1 relative x value (not including the state value).
2857 * @param value The state value.
2858 * @param val The rel1 relative x to be set,
2859 *
2860 * @return EINA_TRUE if successful, EINA_FALSE otherwise..
2861 */
2862EAPI Eina_Bool edje_edit_state_gradient_rel1_relative_x_set(Evas_Object *obj, const char *part, const char *state, double value, double val);
2863
2864
2865/** Set the gradient rel1 vertical relative value
2866 *
2867 * @param obj Object being edited.
2868 * @param part The part that contain state.
2869 * @param state The name of the state to set rel1 relative y value (not including the state value).
2870 * @param value The state value.
2871 * @param val The rel1 relative y to be set,
2872 *
2873 * @return EINA_TRUE if successful, EINA_FALSE otherwise..
2874 */
2875EAPI Eina_Bool edje_edit_state_gradient_rel1_relative_y_set(Evas_Object *obj, const char *part, const char *state, double value, double val);
2876
2877/** Set the gradient rel2 horizontal relative value
2878 *
2879 * @param obj Object being edited.
2880 * @param part The part that contain state.
2881 * @param state The name of the state to set rel2 relative x value (not including the state value).
2882 * @param value The state value.
2883 * @param val The rel2 relative x to be set,
2884 *
2885 * @return EINA_TRUE if successful, EINA_FALSE otherwise..
2886 */
2887EAPI Eina_Bool edje_edit_state_gradient_rel2_relative_x_set(Evas_Object *obj, const char *part, const char *state, double value, double val);
2888
2889/** Set the gradient rel2 vertical relative value
2890 *
2891 * @param obj Object being edited.
2892 * @param part The part that contain state.
2893 * @param state The name of the state to set rel2 relative y value (not including the state value).
2894 * @param value The state value.
2895 * @param val The rel2 relative y to be set,
2896 *
2897 * @return EINA_TRUE if successful, EINA_FALSE otherwise..
2898 */
2899EAPI Eina_Bool edje_edit_state_gradient_rel2_relative_y_set(Evas_Object *obj, const char *part, const char *state, double value, double val);
2900
2901/** Get the gradient rel1 horizontal offset value
2902 *
2903 * @param obj Object being edited.
2904 * @param part The part that contain state.
2905 * @param state The name of the state to get rel1 offset x value (not including the state value).
2906 * @param value The state value.
2907 *
2908 * @return The gradient rel1 horizontal offset value.
2909 */
2910EAPI int edje_edit_state_gradient_rel1_offset_x_get(Evas_Object *obj, const char *part, const char *state, double value);
2911
2912/** Get the gradient rel1 vertical offset value
2913 *
2914 * @param obj Object being edited.
2915 * @param part The part that contain state.
2916 * @param state The name of the state to get rel1 offset y value (not including the state value).
2917 * @param value The state value.
2918 *
2919 * @return The gradient rel1 vertical offset value.
2920 */
2921EAPI int edje_edit_state_gradient_rel1_offset_y_get(Evas_Object *obj, const char *part, const char *state, double value);
2922
2923/** Get the gradient rel2 horizontal offset value
2924 *
2925 * @param obj Object being edited.
2926 * @param part The part that contain state.
2927 * @param state The name of the state to get rel2 offset x value (not including the state value).
2928 * @param value The state value.
2929 *
2930 * @return The gradient rel2 horizontal offset value.
2931 */
2932EAPI int edje_edit_state_gradient_rel2_offset_x_get(Evas_Object *obj, const char *part, const char *state, double value);
2933
2934/** Get the gradient rel2 vertical offset value
2935 *
2936 * @param obj Object being edited.
2937 * @param part The part that contain state.
2938 * @param state The name of the state to get rel2 offset y value (not including the state value).
2939 * @param value The state value.
2940 *
2941 * @return The gradient rel2 vertical offset value.
2942 */
2943EAPI int edje_edit_state_gradient_rel2_offset_y_get(Evas_Object *obj, const char *part, const char *state, double value);
2944
2945/** Set the gradient rel1 horizontal offset value
2946 *
2947 * @param obj Object being edited.
2948 * @param part The part that contain state.
2949 * @param state The name of the state to set rel1 offset x value (not including the state value).
2950 * @param value The state value.
2951 * @param val The rel1 offset x value.
2952 *
2953 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
2954 */
2955EAPI Eina_Bool edje_edit_state_gradient_rel1_offset_x_set(Evas_Object *obj, const char *part, const char *state, double value, int val);
2956
2957/** Set the gradient rel1 vertical offset value
2958 *
2959 * @param obj Object being edited.
2960 * @param part The part that contain state.
2961 * @param state The name of the state to set rel1 offset y value (not including the state value).
2962 * @param value The state value.
2963 * @param val The rel1 offset y value.
2964 *
2965 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
2966 */
2967EAPI Eina_Bool edje_edit_state_gradient_rel1_offset_y_set(Evas_Object *obj, const char *part, const char *state, double value, int val);
2968
2969/** Set the gradient rel2 horizontal offset value
2970 *
2971 * @param obj Object being edited.
2972 * @param part The part that contain state.
2973 * @param state The name of the state to set rel2 offset x value (not including the state value).
2974 * @param value The state value.
2975 * @param val The rel2 offset x value.
2976 *
2977 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
2978 */
2979EAPI Eina_Bool edje_edit_state_gradient_rel2_offset_x_set(Evas_Object *obj, const char *part, const char *state, double value, int val);
2980
2981/** Set the gradient rel2 vertical offset value
2982 *
2983 * @param obj Object being edited.
2984 * @param part The part that contain state.
2985 * @param state The name of the state to set rel2 offset y value (not including the state value).
2986 * @param value The state value.
2987 * @param val The rel2 offset y value.
2988 *
2989 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
2990 */
2991EAPI Eina_Bool edje_edit_state_gradient_rel2_offset_y_set(Evas_Object *obj, const char *part, const char *state, double value, int val);
2992
2993
2994//@}
2995/******************************************************************************/
2996/************************* PROGRAMS API ***********************************/
2997/******************************************************************************/
2998/** @name Programs API
2999 * Functions to deal with programs (see @ref edcref).
3000 */ //@{
3001
3002/** Get the list of all the programs in the given edje object.
3003 *
3004 * Use edje_edit_string_list_free() when you don't need it anymore.
3005 *
3006 * @param obj Object being edited.
3007 *
3008 * @return A list containing all the program names.
3009 */
3010EAPI Eina_List * edje_edit_programs_list_get(Evas_Object *obj);
3011
3012/** Add a new program to the edje file
3013 *
3014 * If a program with the same name just exist the function will fail.
3015 *
3016 * @param obj Object being edited.
3017 * @param name The name of the new program.
3018 *
3019 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
3020 */
3021EAPI Eina_Bool edje_edit_program_add(Evas_Object *obj, const char *name);
3022
3023/** Remove the given program from the edje file.
3024 *
3025 * @param obj Object being edited.
3026 * @param prog The name of the program to remove.
3027 *
3028 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
3029 */
3030EAPI Eina_Bool edje_edit_program_del(Evas_Object *obj, const char *prog);
3031
3032/** Check if a program with the given name exist in the edje object.
3033 *
3034 * @param obj Object being edited.
3035 * @param prog The prog of the program that will be searched.
3036 *
3037 * @return EINA_TRUE if the program exist, EINA_FALSE otherwise.
3038 */
3039EAPI Eina_Bool edje_edit_program_exist(Evas_Object *obj, const char *prog);
3040
3041/** Run the given program.
3042 *
3043 * @param obj Object being edited.
3044 * @param prog The name of the program to execute.
3045 *
3046 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
3047 */
3048EAPI Eina_Bool edje_edit_program_run(Evas_Object *obj, const char *prog);
3049
3050/** Set a new name for the given program
3051 *
3052 * @param obj Object being edited.
3053 * @param prog The current program name.
3054 * @param new_name The new name to assign.
3055 *
3056 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
3057 */
3058EAPI Eina_Bool edje_edit_program_name_set(Evas_Object *obj, const char *prog, const char *new_name);
3059
3060/** Get source of a given program.
3061 *
3062 * Remember to free the returned string using edje_edit_string_free().
3063 *
3064 * @param obj Object being edited.
3065 * @param prog The name of the program to get source.
3066 *
3067 * @return The source value por program.
3068 */
3069EAPI const char * edje_edit_program_source_get(Evas_Object *obj, const char *prog);
3070
3071/** Set source of the given program.
3072 *
3073 * @param obj Object being edited.
3074 * @param prog The name of the program to set source.
3075 * @param source The new source value.
3076 *
3077 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
3078 */
3079EAPI Eina_Bool edje_edit_program_source_set(Evas_Object *obj, const char *prog, const char *source);
3080
3081/** Get signal of a given program.
3082 *
3083 * Remember to free the returned string using edje_edit_string_free().
3084 *
3085 * @param obj Object being edited.
3086 * @param prog The name of the program to get the signal.
3087 *
3088 * @return The signal value for program.
3089 */
3090EAPI const char * edje_edit_program_signal_get(Evas_Object *obj, const char *prog);
3091
3092/** Set signal of the given program.
3093 *
3094 * @param obj Object being edited.
3095 * @param prog The name of the program to set the signal.
3096 * @param signal The new signal value.
3097 *
3098 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
3099 */
3100EAPI Eina_Bool edje_edit_program_signal_set(Evas_Object *obj, const char *prog, const char *signal);
3101
3102/** Get in.from of a given program.
3103 *
3104 * @param obj Object being edited.
3105 * @param prog The name of the program to get the delay.
3106 *
3107 * @return The delay.
3108 */
3109EAPI double edje_edit_program_in_from_get(Evas_Object *obj, const char *prog);
3110
3111/** Set in.from of a given program.
3112 *
3113 * @param obj Object being edited.
3114 * @param prog The name of the program to set the delay.
3115 * @param seconds Number of seconds to delay the program execution
3116 *
3117 * */
3118EAPI Eina_Bool edje_edit_program_in_from_set(Evas_Object *obj, const char *prog, double seconds);
3119
3120/** Get in.range of a given program.
3121 *
3122 * @param obj Object being edited.
3123 * @param prog The name of the program to get random delay.
3124 *
3125 * @return The delay random.
3126 */
3127EAPI double edje_edit_program_in_range_get(Evas_Object *obj, const char *prog);
3128
3129/** Set in.range of a given program.
3130 *
3131 * @param obj Object being edited.
3132 * @param prog The name of the program to set random delay.
3133 * @param seconds Max random number of seconds to delay.
3134 *
3135 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
3136 */
3137EAPI Eina_Bool edje_edit_program_in_range_set(Evas_Object *obj, const char *prog, double seconds);
3138
3139/** Get the action of a given program.
3140 *
3141 * @param obj Object being edited.
3142 * @param prog The name of the program to get the action.
3143 *
3144 * @return The action type, or -1 on errors.
3145 * Action can be one of EDJE_ACTION_TYPE_NONE, _STATE_SET, ACTION_STOP, SIGNAL_EMIT, DRAG_VAL_SET, _DRAG_VAL_STEP, _DRAG_VAL_PAGE, _SCRIPT
3146 */
3147EAPI Edje_Action_Type edje_edit_program_action_get(Evas_Object *obj, const char *prog);
3148
3149/** Set the action of a given program.
3150 *
3151 * Action can be one of EDJE_ACTION_TYPE_NONE, _STATE_SET, ACTION_STOP, SIGNAL_EMIT, DRAG_VAL_SET, _DRAG_VAL_STEP, _DRAG_VAL_PAGE, _SCRIPT
3152 *
3153 * @param obj Object being edited.
3154 * @param prog The name of the program to set the action.
3155 * @param action The new action type.
3156 *
3157 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
3158 */
3159EAPI Eina_Bool edje_edit_program_action_set(Evas_Object *obj, const char *prog, Edje_Action_Type action);
3160
3161/** Get the list of the targets for the given program.
3162 *
3163 * Use edje_edit_string_list_free() when you don't need it anymore.
3164 *
3165 * @param obj Object being edited.
3166 * @param prog The name of the progrem to get the list of the targets.
3167 *
3168 * @return A list with all the targets names, or NULL on error.
3169 */
3170EAPI Eina_List * edje_edit_program_targets_get(Evas_Object *obj, const char *prog);
3171
3172/** Add a new target program to the list of 'targets' in the given program.
3173 *
3174 * If program action is @c EDJE_ACTION_TYPE_ACTION_STOP, then 'target'
3175 * must be an existing program name. If it's @c
3176 * EDJE_ACTION_TYPE_STATE_SET, then 'target' must be an existing part
3177 * name.
3178 *
3179 * @param obj Object being edited.
3180 * @param prog The name of the program to add a new target.
3181 * @param target The name of the new target itself.
3182 *
3183 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
3184 */
3185EAPI Eina_Bool edje_edit_program_target_add(Evas_Object *obj, const char *prog, const char *target);
3186
3187/** Deletes a target from the list of 'targets' in the given program.
3188 *
3189 * If program action is EDJE_ACTION_TYPE_ACTION_STOP then 'target' must be an existing program name.
3190 * If action is EDJE_ACTION_TYPE_STATE_SET then 'target' must be an existing part name.
3191 *
3192 * @param obj Object being edited.
3193 * @param prog The name of the program to del a target from the list of targets.
3194 * @param target The name of another program or another part.
3195 *
3196 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
3197 */
3198EAPI Eina_Bool edje_edit_program_target_del(Evas_Object *obj, const char *prog, const char *target);
3199
3200/** Clear the 'targets' list of the given program
3201 *
3202 * @param obj Object being edited.
3203 * @param prog The name of the program to cleaar the 'targets' list.
3204 *
3205 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
3206 */
3207EAPI Eina_Bool edje_edit_program_targets_clear(Evas_Object *obj, const char *prog);
3208
3209/** Get the list of action that will be run after the give program
3210 *
3211 * Use edje_edit_string_list_free() when you don't need it anymore.
3212 *
3213 * @param obj Object being edited.
3214 * @param prog The name of the program to get the list of actions
3215 *
3216 * @return A list with all program names. or NULL on error.
3217 */
3218EAPI Eina_List * edje_edit_program_afters_get(Evas_Object *obj, const char *prog);
3219
3220/** Add a new program name to the list of 'afters' in the given program.
3221 *
3222 * All the programs listed in 'afters' will be executed after program execution.
3223 *
3224 * @param obj Object being edited.
3225 * @param prog The name of the program that contains the list of afters
3226 * @param after The name of another program to add to the afters list
3227 *
3228 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
3229 */
3230EAPI Eina_Bool edje_edit_program_after_add(Evas_Object *obj, const char *prog, const char *after);
3231
3232/** Delete the given program from the list of 'afters' of the program.
3233 *
3234 * @param obj Object being edited.
3235 * @param prog The name of the program from where to remove the after.
3236 * @param after The name of the program to remove from the list of afters.
3237 *
3238 * @return EINA_TRUE is successful or not in the list, EINA_FALSE otherwise.
3239 */
3240EAPI Eina_Bool edje_edit_program_after_del(Evas_Object *obj, const char *prog, const char *after);
3241
3242/** Clear the 'afters' list of the given program.
3243 *
3244 * @param obj Object being edited.
3245 * @param prog The name of the program to clear the 'afters' list.
3246 *
3247 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
3248 */
3249EAPI Eina_Bool edje_edit_program_afters_clear(Evas_Object *obj, const char *prog);
3250
3251/** Get the state for the given program
3252 *
3253 * In a STATE_SET action this is the name of state to set.
3254 * In a SIGNAL_EMIT action is the name of the signal to emit.
3255 *
3256 * @param obj Object being edited.
3257 * @param prog The name of the program to get the state.
3258 *
3259 * @return The name of the state.
3260 */
3261EAPI const char * edje_edit_program_state_get(Evas_Object *obj, const char *prog);
3262
3263/** Get api's name of a program.
3264 *
3265 * @param obj Object being edited.
3266 * @param prog Name of program.
3267 *
3268 * @return name of the api if successful, NULL otherwise.
3269 */
3270EAPI const char * edje_edit_program_api_name_get(Evas_Object *obj, const char *prog);
3271
3272/** Get api's description of a program.
3273 *
3274 * @param obj Object being edited.
3275 * @param prog Name of program.
3276 *
3277 * @return description of the api if successful, NULL otherwise.
3278 */
3279EAPI const char * edje_edit_program_api_description_get(Evas_Object *obj, const char *prog);
3280
3281/** Set api's name of a program.
3282 *
3283 * @param obj Object being edited.
3284 * @param prog Name of the part.
3285 * @param name New name for the api property.
3286 *
3287 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
3288 */
3289EAPI Eina_Bool edje_edit_program_api_name_set(Evas_Object *obj, const char *prog, const char *name);
3290
3291/** Set api's description of a program.
3292 *
3293 * @param obj Object being edited.
3294 * @param prog Name of the program.
3295 * @param description New description for the api property.
3296 *
3297 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
3298 */
3299EAPI Eina_Bool edje_edit_program_api_description_set(Evas_Object *obj, const char *prog, const char *description);
3300
3301/** Set the state for the given program
3302 *
3303 * In a STATE_SET action this is the name of state to set.
3304 * In a SIGNAL_EMIT action is the name of the signal to emit.
3305 *
3306 * @param obj Object being edited.
3307 * @param prog The name of the program to set a state.
3308 * @param state The nameo of the state to set (not including the state value)
3309 *
3310 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
3311 */
3312EAPI Eina_Bool edje_edit_program_state_set(Evas_Object *obj, const char *prog, const char *state);
3313
3314/** Get the value of state for the given program.
3315 *
3316 * In a STATE_SET action this is the value of state to set.
3317 * Not used on SIGNAL_EMIT action.
3318 *
3319 * @param obj Object being edited.
3320 * @param prog The name of the program to get the value of state.
3321 *
3322 * @return The value of state for the program.
3323 */
3324EAPI double edje_edit_program_value_get(Evas_Object *obj, const char *prog);
3325
3326/** Set the value of state for the given program.
3327 *
3328 * In a STATE_SET action this is the value of state to set.
3329 * Not used on SIGNAL_EMIT action.
3330 *
3331 * @param obj Object being edited.
3332 * @param prog The name of the program to set the value of state.
3333 * @param value The vale to set.
3334 *
3335 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
3336 */
3337EAPI Eina_Bool edje_edit_program_value_set(Evas_Object *obj, const char *prog, double value);
3338
3339/** Get the state2 for the given program
3340 *
3341 * In a STATE_SET action is not used
3342 * In a SIGNAL_EMIT action is the source of the emitted signal.
3343 *
3344 * @param obj Object being edited.
3345 * @param prog The name of the program to get the state2.
3346 *
3347 * @return The source to emit for the program.
3348 */
3349EAPI const char * edje_edit_program_state2_get(Evas_Object *obj, const char *prog);
3350
3351/** Set the state2 for the given program
3352 *
3353 * In a STATE_SET action is not used
3354 * In a SIGNAL_EMIT action is the source of the emitted signal.
3355 *
3356 * @param obj Object being edited.
3357 * @param prog The name of the program to set the state2.
3358 * @param state2 The name of the state to set.
3359 *
3360 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
3361 */
3362EAPI Eina_Bool edje_edit_program_state2_set(Evas_Object *obj, const char *prog, const char *state2);
3363
3364/** Get the value of state2 for the given program.
3365 *
3366 * @param obj Object being edited.
3367 * @param prog The name of the program to get the state2 value.
3368 *
3369 * @return The vale of the state2 for the program.
3370 */
3371EAPI double edje_edit_program_value2_get(Evas_Object *obj, const char *prog);
3372
3373/** Set the value2 of state for the given program.
3374 *
3375 * This is used in DRAG_ACTION
3376 *
3377 * @param obj Object being edited.
3378 * @param prog The name of the program to set the state2 value.
3379 * @param value The value of the state2 to set.
3380 */
3381EAPI Eina_Bool edje_edit_program_value2_set(Evas_Object *obj, const char *prog, double value);
3382
3383/** Get the type of transition to use when apply animations.
3384 *
3385 * Can be one of: EDJE_TWEEN_MODE_NONE, EDJE_TWEEN_MODE_LINEAR, EDJE_TWEEN_MODE_SINUSOIDAL, EDJE_TWEEN_MODE_ACCELERATE or EDJE_TWEEN_MODE_DECELERATE.
3386 *
3387 * @param obj Object being edited.
3388 * @param prog The name of the program to get the transition.
3389 *
3390 * @return The type of transition used by program.
3391 */
3392EAPI Edje_Tween_Mode edje_edit_program_transition_get(Evas_Object *obj, const char *prog);
3393
3394/** Set the type of transition to use when apply animations.
3395 *
3396 * Can be one of: EDJE_TWEEN_MODE_NONE, EDJE_TWEEN_MODE_LINEAR, EDJE_TWEEN_MODE_SINUSOIDAL, EDJE_TWEEN_MODE_ACCELERATE or EDJE_TWEEN_MODE_DECELERATE.
3397 *
3398 * @param obj Object being edited.
3399 * @param prog The name of the program to set the transition.
3400 * @param transition The transition type to set
3401 *
3402 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
3403 */
3404EAPI Eina_Bool edje_edit_program_transition_set(Evas_Object *obj, const char *prog, Edje_Tween_Mode transition);
3405
3406/** Get the duration of the transition in seconds.
3407 *
3408 * @param obj Object being edited.
3409 * @param prog The name of the program to get the transition time.
3410 *
3411 * @return The duration of the transition.
3412 */
3413EAPI double edje_edit_program_transition_time_get(Evas_Object *obj, const char *prog);
3414
3415/** Set the duration of the transition in seconds.
3416 *
3417 * @param obj Object being edited.
3418 * @param prog The name of the program to set the transition time.
3419 * @param seconds The duration of the transition (in seconds).
3420 *
3421 * @return EINA_TRUE if successful, EINA_FALSE otherwise.
3422 */
3423EAPI Eina_Bool edje_edit_program_transition_time_set(Evas_Object *obj, const char *prog, double seconds);
3424
3425EAPI const char * edje_edit_program_filter_part_get(Evas_Object *obj, const char *prog);
3426EAPI Eina_Bool edje_edit_program_filter_part_set(Evas_Object *obj, const char *prog, const char *filter_part);
3427
3428//@}
3429/******************************************************************************/
3430/************************** SCRIPTS API ***********************************/
3431/******************************************************************************/
3432/** @name Scripts API
3433 * Functions to deal with embryo scripts (see @ref edcref).
3434 */ //@{
3435
3436/**
3437 * Get the Embryo script for the group of the given object.
3438 *
3439 * Get the shared script for the group under edition. Shared script means
3440 * the script {} block for the group, not counting what's in each program.
3441 * It returns a malloc'd duplicate of the code, so users are free to modify
3442 * the contents directly and they should remember to free() it when done.
3443 * NULL will be returned if there's no script or an error occurred.
3444 *
3445 * @param obj Object being edited.
3446 *
3447 * @return The shared script code for this group.
3448 */
3449EAPI char *edje_edit_script_get(Evas_Object *obj);
3450
3451/**
3452 * Set the code for the group script.
3453 *
3454 * Set the Embryo source code for the shared script of the edited group.
3455 * Note that changing the code itself will not update the running VM, you
3456 * need to call edje_edit_script_compile for it to get updated.
3457 *
3458 * @param obj The object being edited
3459 * @param code The Embryo source
3460 */
3461EAPI void edje_edit_script_set(Evas_Object *obj, const char *code);
3462
3463/**
3464 * Get the Embryo script for the given program.
3465 *
3466 * Get the script code for the given program. Like the group script, this
3467 * function returns a duplicate of the code that the user can modify at will
3468 * and must free when done using it.
3469 * NULL will be returned if the program doesn't exist, doesn't have any
3470 * script or is not of type script.
3471 *
3472 * @param obj Object being edited
3473 * @param prog Program name
3474 *
3475 * @return The program script code
3476 */
3477EAPI char *edje_edit_script_program_get(Evas_Object *obj, const char *prog);
3478
3479/**
3480 * Set the Embryo script for the given program.
3481 *
3482 * Set the Embryo source code for the program @p prog. It must be an
3483 * existing program of type EDJE_ACTION_TYPE_SCRIPT, or the function
3484 * will fail and do nothing.
3485 * Note that changing the code itself will not update the running VM, you
3486 * need to call edje_edit_script_compile for it to get updated.
3487 *
3488 * @param obj The object being edited
3489 * @param prog The program name.
3490 * @param code The Embryo source
3491 */
3492EAPI void edje_edit_script_program_set(Evas_Object *obj, const char *prog, const char *code);
3493
3494/**
3495 * Compile the Embryo script for the given object
3496 *
3497 * If required, this function will process all script code for the group and
3498 * build the bytecode, updating the running Embryo VM Program if the build
3499 * is succesful.
3500 *
3501 * @param obj The object being edited
3502 *
3503 */
3504EAPI Eina_Bool edje_edit_script_compile(Evas_Object *obj);
3505
3506/**
3507 * Get the list of errors resulting from the last script build
3508 *
3509 * Get the list of errors that resulted from the last attempt to rebuild
3510 * the Embryo script for the edited group. This will be a standard Eina_List
3511 * with Edje_Edit_Script_Error pointers as its data.
3512 * The user should not do anything else but read the contents of this list.
3513 * These errors can be the output of the embryo compiler, or internal errors
3514 * generated by Edje_Edit if the preprocessing of the scripts failed.
3515 *
3516 * @param obj The object being edited
3517 *
3518 * @return A constant list of Edje_Edit_Script_Error, or NULL if there are none
3519 */
3520EAPI const Eina_List *edje_edit_script_error_list_get(Evas_Object *obj);
3521
3522//@}
3523/******************************************************************************/
3524/************************** ERROR API ***********************************/
3525/******************************************************************************/
3526/** @name Error API
3527 * to deal with error messages (see @ref edcref).
3528 */ //@{
3529
3530EAPI extern Eina_Error EDJE_EDIT_ERROR_GROUP_CURRENTLY_USED;
3531EAPI extern Eina_Error EDJE_EDIT_ERROR_GROUP_REFERENCED;
3532EAPI extern Eina_Error EDJE_EDIT_ERROR_GROUP_DOES_NOT_EXIST;
3533
3534
3535#ifdef __cplusplus
3536}
3537#endif
3538
3539#endif
diff --git a/libraries/edje/src/lib/Makefile.am b/libraries/edje/src/lib/Makefile.am
new file mode 100644
index 0000000..5a76ef3
--- /dev/null
+++ b/libraries/edje/src/lib/Makefile.am
@@ -0,0 +1,140 @@
1
2MAINTAINERCLEANFILES = Makefile.in
3
4AM_CPPFLAGS = \
5-I. \
6-I$(top_srcdir) \
7-I$(top_srcdir)/src/bin \
8-I$(top_srcdir)/src/lib \
9-DPACKAGE_BIN_DIR=\"$(bindir)\" \
10-DPACKAGE_LIB_DIR=\"$(libdir)\" \
11-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \
12@EVIL_CFLAGS@ \
13@EDJE_CFLAGS@ \
14@ECORE_IMF_CFLAGS@ \
15@EFL_EDJE_BUILD@ \
16@REMIX_CFLAGS@ \
17@SNDFILE_CFLAGS@
18
19lib_LTLIBRARIES = libedje.la
20
21includes_HEADERS = Edje.h Edje_Edit.h
22includesdir = $(includedir)/edje-@VMAJ@
23
24base_sources = \
25edje_box_layout.c \
26edje_cache.c \
27edje_calc.c \
28edje_callbacks.c \
29edje_container.c \
30edje_data.c \
31edje_edit.c \
32edje_embryo.c \
33edje_entry.c \
34edje_external.c \
35edje_load.c \
36edje_lua.c \
37edje_lua2.c \
38edje_lua_script_only.c \
39edje_main.c \
40edje_match.c \
41edje_message_queue.c \
42edje_misc.c \
43edje_module.c \
44edje_multisense.c \
45edje_program.c \
46edje_script_only.c \
47edje_smart.c \
48edje_text.c \
49edje_textblock_styles.c \
50edje_util.c \
51edje_var.c
52
53if EDJE_AMALGAMATION
54nodist_libedje_la_SOURCES = edje_amalgamation.c
55
56edje_amalgamation.c: $(base_sources) Makefile
57 -rm -f edje_amalgamation.c
58
59 @echo "#ifdef HAVE_CONFIG_H" >> edje_amalgamation.c
60 @echo "# include \"config.h\"" >> edje_amalgamation.c
61 @echo "#endif" >> edje_amalgamation.c
62
63 @echo "#ifndef _WIN32" >> edje_amalgamation.c
64 @echo "#define _GNU_SOURCE" >> edje_amalgamation.c
65 @echo "#endif" >> edje_amalgamation.c
66
67 @echo "#ifdef HAVE_ALLOCA_H" >> edje_amalgamation.c
68 @echo "# include <alloca.h>" >> edje_amalgamation.c
69 @echo "#elif defined __GNUC__" >> edje_amalgamation.c
70 @echo "# define alloca __builtin_alloca" >> edje_amalgamation.c
71 @echo "#elif defined _AIX" >> edje_amalgamation.c
72 @echo "# define alloca __alloca" >> edje_amalgamation.c
73 @echo "#elif defined _MSC_VER" >> edje_amalgamation.c
74 @echo "# include <malloc.h>" >> edje_amalgamation.c
75 @echo "# define alloca _alloca" >> edje_amalgamation.c
76 @echo "#else" >> edje_amalgamation.c
77 @echo "# include <stddef.h>" >> edje_amalgamation.c
78 @echo "# ifdef __cplusplus" >> edje_amalgamation.c
79 @echo "#extern \"C\"" >> edje_amalgamation.c
80 @echo "# endif" >> edje_amalgamation.c
81 @echo "#void *alloca (size_t);" >> edje_amalgamation.c
82 @echo "#endif" >> edje_amalgamation.c
83
84 @echo "#include <string.h>" >> edje_amalgamation.c
85 @echo "#include <math.h>" >> edje_amalgamation.c
86 @echo "#include <time.h>" >> edje_amalgamation.c
87 @echo "#include <limits.h>" >> edje_amalgamation.c
88 @echo "#include <errno.h>" >> edje_amalgamation.c
89 @echo "#include <sys/stat.h>" >> edje_amalgamation.c
90 @echo "#include <fcntl.h>" >> edje_amalgamation.c
91
92 @echo "#ifndef _MSC_VER" >> edje_amalgamation.c
93 @echo "# include <unistd.h>" >> edje_amalgamation.c
94 @echo "#endif" >> edje_amalgamation.c
95
96 @echo "#ifdef HAVE_LOCALE_H" >> edje_amalgamation.c
97 @echo "# include <locale.h>" >> edje_amalgamation.c
98 @echo "#endif" >> edje_amalgamation.c
99
100 @echo "#include <lua.h>" >> edje_amalgamation.c
101 @echo "#include <lauxlib.h>" >> edje_amalgamation.c
102
103 @echo "#ifdef HAVE_EVIL" >> edje_amalgamation.c
104 @echo "# include <Evil.h>" >> edje_amalgamation.c
105 @echo "#endif" >> edje_amalgamation.c
106
107 @echo "#include <Eina.h>" >> edje_amalgamation.c
108 @echo "#include <Edje.h>" >> edje_amalgamation.c
109 @echo "#include <Evas.h>" >> edje_amalgamation.c
110 @echo "#include <Ecore.h>" >> edje_amalgamation.c
111 @echo "#include <Embryo.h>" >> edje_amalgamation.c
112
113 @echo "#ifdef HAVE_ECORE_IMF" >> edje_amalgamation.c
114 @echo "# include <Ecore_IMF.h>" >> edje_amalgamation.c
115 @echo "#endif" >> edje_amalgamation.c
116
117 @echo "#include <edje_private.h>" >> edje_amalgamation.c
118
119 @for f in $(base_sources); do \
120 if [ `echo $$f | sed -e 's/^...\(.\).*/\1/'` != '/' ]; then \
121 file="$(srcdir)/$$f" ; \
122 else \
123 file="$$f" ; \
124 fi ; \
125 echo "/* file: $$file */" >> edje_amalgamation.c; \
126 grep -v -e '^# *include \+.\(config\|\|Evil\|Eina\|Eet\|Evas\|Ecore\|Embryo\|Ecore_IMF\|string\|math\|limits\|sys/stat\|errno\|time\|unistd\|locale\|lua\|lauxlib\|edje_private\)[.]h.*' $$file >> edje_amalgamation.c; \
127 done
128 @echo "edje_amalgamation.c generated"
129
130else
131libedje_la_SOURCES = $(base_sources)
132endif
133
134libedje_la_LIBADD = @EDJE_LIBS@ @ECORE_IMF_LIBS@ @EVIL_LIBS@ @REMIX_LIBS@ @SNDFILE_LIBS@ -lm
135libedje_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -version-info @version_info@ @release_info@
136
137EXTRA_DIST = edje_private.h edje_container.h edje_convert.h
138
139clean-local:
140 @rm -rf *.gcno edje_amalgamation.c
diff --git a/libraries/edje/src/lib/Makefile.in b/libraries/edje/src/lib/Makefile.in
new file mode 100644
index 0000000..cf73390
--- /dev/null
+++ b/libraries/edje/src/lib/Makefile.in
@@ -0,0 +1,810 @@
1# Makefile.in generated by automake 1.11.1 from Makefile.am.
2# @configure_input@
3
4# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
5# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
6# Inc.
7# This Makefile.in is free software; the Free Software Foundation
8# gives unlimited permission to copy and/or distribute it,
9# with or without modifications, as long as this notice is preserved.
10
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
13# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
14# PARTICULAR PURPOSE.
15
16@SET_MAKE@
17
18
19VPATH = @srcdir@
20pkgdatadir = $(datadir)/@PACKAGE@
21pkgincludedir = $(includedir)/@PACKAGE@
22pkglibdir = $(libdir)/@PACKAGE@
23pkglibexecdir = $(libexecdir)/@PACKAGE@
24am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
25install_sh_DATA = $(install_sh) -c -m 644
26install_sh_PROGRAM = $(install_sh) -c
27install_sh_SCRIPT = $(install_sh) -c
28INSTALL_HEADER = $(INSTALL_DATA)
29transform = $(program_transform_name)
30NORMAL_INSTALL = :
31PRE_INSTALL = :
32POST_INSTALL = :
33NORMAL_UNINSTALL = :
34PRE_UNINSTALL = :
35POST_UNINSTALL = :
36build_triplet = @build@
37host_triplet = @host@
38subdir = src/lib
39DIST_COMMON = $(includes_HEADERS) $(srcdir)/Makefile.am \
40 $(srcdir)/Makefile.in
41ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
42am__aclocal_m4_deps = $(top_srcdir)/m4/ac_attribute.m4 \
43 $(top_srcdir)/m4/efl_binary.m4 \
44 $(top_srcdir)/m4/efl_coverage.m4 \
45 $(top_srcdir)/m4/efl_doxygen.m4 \
46 $(top_srcdir)/m4/efl_path_max.m4 $(top_srcdir)/m4/efl_tests.m4 \
47 $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
48 $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
49 $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
50am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
51 $(ACLOCAL_M4)
52mkinstalldirs = $(install_sh) -d
53CONFIG_HEADER = $(top_builddir)/config.h
54CONFIG_CLEAN_FILES =
55CONFIG_CLEAN_VPATH_FILES =
56am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
57am__vpath_adj = case $$p in \
58 $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
59 *) f=$$p;; \
60 esac;
61am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
62am__install_max = 40
63am__nobase_strip_setup = \
64 srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
65am__nobase_strip = \
66 for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
67am__nobase_list = $(am__nobase_strip_setup); \
68 for p in $$list; do echo "$$p $$p"; done | \
69 sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
70 $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
71 if (++n[$$2] == $(am__install_max)) \
72 { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
73 END { for (dir in files) print dir, files[dir] }'
74am__base_list = \
75 sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
76 sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
77am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includesdir)"
78LTLIBRARIES = $(lib_LTLIBRARIES)
79libedje_la_DEPENDENCIES =
80am__libedje_la_SOURCES_DIST = edje_box_layout.c edje_cache.c \
81 edje_calc.c edje_callbacks.c edje_container.c edje_data.c \
82 edje_edit.c edje_embryo.c edje_entry.c edje_external.c \
83 edje_load.c edje_lua.c edje_lua2.c edje_lua_script_only.c \
84 edje_main.c edje_match.c edje_message_queue.c edje_misc.c \
85 edje_module.c edje_multisense.c edje_program.c \
86 edje_script_only.c edje_smart.c edje_text.c \
87 edje_textblock_styles.c edje_util.c edje_var.c
88am__objects_1 = edje_box_layout.lo edje_cache.lo edje_calc.lo \
89 edje_callbacks.lo edje_container.lo edje_data.lo edje_edit.lo \
90 edje_embryo.lo edje_entry.lo edje_external.lo edje_load.lo \
91 edje_lua.lo edje_lua2.lo edje_lua_script_only.lo edje_main.lo \
92 edje_match.lo edje_message_queue.lo edje_misc.lo \
93 edje_module.lo edje_multisense.lo edje_program.lo \
94 edje_script_only.lo edje_smart.lo edje_text.lo \
95 edje_textblock_styles.lo edje_util.lo edje_var.lo
96@EDJE_AMALGAMATION_FALSE@am_libedje_la_OBJECTS = $(am__objects_1)
97@EDJE_AMALGAMATION_TRUE@nodist_libedje_la_OBJECTS = \
98@EDJE_AMALGAMATION_TRUE@ edje_amalgamation.lo
99libedje_la_OBJECTS = $(am_libedje_la_OBJECTS) \
100 $(nodist_libedje_la_OBJECTS)
101AM_V_lt = $(am__v_lt_$(V))
102am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
103am__v_lt_0 = --silent
104libedje_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
105 $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
106 $(libedje_la_LDFLAGS) $(LDFLAGS) -o $@
107DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
108depcomp = $(SHELL) $(top_srcdir)/depcomp
109am__depfiles_maybe = depfiles
110am__mv = mv -f
111COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
112 $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
113LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
114 $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
115 $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
116 $(AM_CFLAGS) $(CFLAGS)
117AM_V_CC = $(am__v_CC_$(V))
118am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
119am__v_CC_0 = @echo " CC " $@;
120AM_V_at = $(am__v_at_$(V))
121am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
122am__v_at_0 = @
123CCLD = $(CC)
124LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
125 $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
126 $(AM_LDFLAGS) $(LDFLAGS) -o $@
127AM_V_CCLD = $(am__v_CCLD_$(V))
128am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
129am__v_CCLD_0 = @echo " CCLD " $@;
130AM_V_GEN = $(am__v_GEN_$(V))
131am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
132am__v_GEN_0 = @echo " GEN " $@;
133SOURCES = $(libedje_la_SOURCES) $(nodist_libedje_la_SOURCES)
134DIST_SOURCES = $(am__libedje_la_SOURCES_DIST)
135HEADERS = $(includes_HEADERS)
136ETAGS = etags
137CTAGS = ctags
138DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
139ACLOCAL = @ACLOCAL@
140ALLOCA = @ALLOCA@
141ALSA_CFLAGS = @ALSA_CFLAGS@
142ALSA_LIBS = @ALSA_LIBS@
143AMTAR = @AMTAR@
144AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
145AR = @AR@
146AS = @AS@
147AUTOCONF = @AUTOCONF@
148AUTOHEADER = @AUTOHEADER@
149AUTOMAKE = @AUTOMAKE@
150AWK = @AWK@
151CC = @CC@
152CCDEPMODE = @CCDEPMODE@
153CFLAGS = @CFLAGS@
154CHECK_CFLAGS = @CHECK_CFLAGS@
155CHECK_LIBS = @CHECK_LIBS@
156CPP = @CPP@
157CPPFLAGS = @CPPFLAGS@
158CYGPATH_W = @CYGPATH_W@
159DEFS = @DEFS@
160DEPDIR = @DEPDIR@
161DLLTOOL = @DLLTOOL@
162DSYMUTIL = @DSYMUTIL@
163DUMPBIN = @DUMPBIN@
164ECHO_C = @ECHO_C@
165ECHO_N = @ECHO_N@
166ECHO_T = @ECHO_T@
167ECORE_IMF_CFLAGS = @ECORE_IMF_CFLAGS@
168ECORE_IMF_LIBS = @ECORE_IMF_LIBS@
169EDJE_CC_CFLAGS = @EDJE_CC_CFLAGS@
170EDJE_CC_LIBS = @EDJE_CC_LIBS@
171EDJE_CC_PRG = @EDJE_CC_PRG@
172EDJE_CFLAGS = @EDJE_CFLAGS@
173EDJE_DECC_CFLAGS = @EDJE_DECC_CFLAGS@
174EDJE_DECC_LIBS = @EDJE_DECC_LIBS@
175EDJE_DECC_PRG = @EDJE_DECC_PRG@
176EDJE_EXTERNAL_INSPECTOR_CFLAGS = @EDJE_EXTERNAL_INSPECTOR_CFLAGS@
177EDJE_EXTERNAL_INSPECTOR_LIBS = @EDJE_EXTERNAL_INSPECTOR_LIBS@
178EDJE_EXTERNAL_INSPECTOR_PRG = @EDJE_EXTERNAL_INSPECTOR_PRG@
179EDJE_INSPECTOR_CFLAGS = @EDJE_INSPECTOR_CFLAGS@
180EDJE_INSPECTOR_LIBS = @EDJE_INSPECTOR_LIBS@
181EDJE_INSPECTOR_PRG = @EDJE_INSPECTOR_PRG@
182EDJE_LIBS = @EDJE_LIBS@
183EDJE_PLAYER_CFLAGS = @EDJE_PLAYER_CFLAGS@
184EDJE_PLAYER_LIBS = @EDJE_PLAYER_LIBS@
185EDJE_PLAYER_PRG = @EDJE_PLAYER_PRG@
186EDJE_RECC_PRG = @EDJE_RECC_PRG@
187EFL_COVERAGE_CFLAGS = @EFL_COVERAGE_CFLAGS@
188EFL_COVERAGE_LIBS = @EFL_COVERAGE_LIBS@
189EFL_EDJE_BUILD = @EFL_EDJE_BUILD@
190EGREP = @EGREP@
191EVIL_CFLAGS = @EVIL_CFLAGS@
192EVIL_LIBS = @EVIL_LIBS@
193EXEEXT = @EXEEXT@
194FGREP = @FGREP@
195FLAC_CFLAGS = @FLAC_CFLAGS@
196FLAC_LIBS = @FLAC_LIBS@
197GREP = @GREP@
198INSTALL = @INSTALL@
199INSTALL_DATA = @INSTALL_DATA@
200INSTALL_PROGRAM = @INSTALL_PROGRAM@
201INSTALL_SCRIPT = @INSTALL_SCRIPT@
202INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
203LD = @LD@
204LDFLAGS = @LDFLAGS@
205LIBOBJS = @LIBOBJS@
206LIBS = @LIBS@
207LIBTOOL = @LIBTOOL@
208LIPO = @LIPO@
209LN_S = @LN_S@
210LTLIBOBJS = @LTLIBOBJS@
211LUA_CFLAGS = @LUA_CFLAGS@
212LUA_LIBS = @LUA_LIBS@
213MAKEINFO = @MAKEINFO@
214MINIMAL_CFLAGS = @MINIMAL_CFLAGS@
215MINIMAL_LIBS = @MINIMAL_LIBS@
216MKDIR_P = @MKDIR_P@
217MODULE_ARCH = @MODULE_ARCH@
218NM = @NM@
219NMEDIT = @NMEDIT@
220OBJDUMP = @OBJDUMP@
221OBJEXT = @OBJEXT@
222OTOOL = @OTOOL@
223OTOOL64 = @OTOOL64@
224PACKAGE = @PACKAGE@
225PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
226PACKAGE_NAME = @PACKAGE_NAME@
227PACKAGE_STRING = @PACKAGE_STRING@
228PACKAGE_TARNAME = @PACKAGE_TARNAME@
229PACKAGE_URL = @PACKAGE_URL@
230PACKAGE_VERSION = @PACKAGE_VERSION@
231PATH_SEPARATOR = @PATH_SEPARATOR@
232PKG_CONFIG = @PKG_CONFIG@
233PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
234PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
235PYTHON = @PYTHON@
236PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
237PYTHON_PLATFORM = @PYTHON_PLATFORM@
238PYTHON_PREFIX = @PYTHON_PREFIX@
239PYTHON_VERSION = @PYTHON_VERSION@
240RANLIB = @RANLIB@
241REMIX_CFLAGS = @REMIX_CFLAGS@
242REMIX_LIBS = @REMIX_LIBS@
243REMIX_PLUGIN_DIR = @REMIX_PLUGIN_DIR@
244SED = @SED@
245SET_MAKE = @SET_MAKE@
246SHELL = @SHELL@
247SNDFILE_CFLAGS = @SNDFILE_CFLAGS@
248SNDFILE_LIBS = @SNDFILE_LIBS@
249STRIP = @STRIP@
250VERSION = @VERSION@
251VMAJ = @VMAJ@
252VORBISENC_CFLAGS = @VORBISENC_CFLAGS@
253VORBISENC_LIBS = @VORBISENC_LIBS@
254abs_builddir = @abs_builddir@
255abs_srcdir = @abs_srcdir@
256abs_top_builddir = @abs_top_builddir@
257abs_top_srcdir = @abs_top_srcdir@
258ac_ct_CC = @ac_ct_CC@
259ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
260am__include = @am__include@
261am__leading_dot = @am__leading_dot@
262am__quote = @am__quote@
263am__tar = @am__tar@
264am__untar = @am__untar@
265bindir = @bindir@
266build = @build@
267build_alias = @build_alias@
268build_cpu = @build_cpu@
269build_os = @build_os@
270build_vendor = @build_vendor@
271builddir = @builddir@
272datadir = @datadir@
273datarootdir = @datarootdir@
274docdir = @docdir@
275dvidir = @dvidir@
276edje_cc = @edje_cc@
277efl_doxygen = @efl_doxygen@
278efl_have_doxygen = @efl_have_doxygen@
279exec_prefix = @exec_prefix@
280have_lcov = @have_lcov@
281host = @host@
282host_alias = @host_alias@
283host_cpu = @host_cpu@
284host_os = @host_os@
285host_vendor = @host_vendor@
286htmldir = @htmldir@
287includedir = @includedir@
288infodir = @infodir@
289install_sh = @install_sh@
290libdir = @libdir@
291libexecdir = @libexecdir@
292localedir = @localedir@
293localstatedir = @localstatedir@
294lt_ECHO = @lt_ECHO@
295lt_enable_auto_import = @lt_enable_auto_import@
296lua_libs = @lua_libs@
297mandir = @mandir@
298mkdir_p = @mkdir_p@
299oldincludedir = @oldincludedir@
300pdfdir = @pdfdir@
301pkgconfig_requires_private = @pkgconfig_requires_private@
302pkgpyexecdir = @pkgpyexecdir@
303pkgpythondir = @pkgpythondir@
304prefix = @prefix@
305program_transform_name = @program_transform_name@
306psdir = @psdir@
307pyexecdir = @pyexecdir@
308pythondir = @pythondir@
309release_info = @release_info@
310requirement_edje = @requirement_edje@
311sbindir = @sbindir@
312sharedstatedir = @sharedstatedir@
313srcdir = @srcdir@
314sysconfdir = @sysconfdir@
315target_alias = @target_alias@
316top_build_prefix = @top_build_prefix@
317top_builddir = @top_builddir@
318top_srcdir = @top_srcdir@
319version_info = @version_info@
320vimdir = @vimdir@
321MAINTAINERCLEANFILES = Makefile.in
322AM_CPPFLAGS = \
323-I. \
324-I$(top_srcdir) \
325-I$(top_srcdir)/src/bin \
326-I$(top_srcdir)/src/lib \
327-DPACKAGE_BIN_DIR=\"$(bindir)\" \
328-DPACKAGE_LIB_DIR=\"$(libdir)\" \
329-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \
330@EVIL_CFLAGS@ \
331@EDJE_CFLAGS@ \
332@ECORE_IMF_CFLAGS@ \
333@EFL_EDJE_BUILD@ \
334@REMIX_CFLAGS@ \
335@SNDFILE_CFLAGS@
336
337lib_LTLIBRARIES = libedje.la
338includes_HEADERS = Edje.h Edje_Edit.h
339includesdir = $(includedir)/edje-@VMAJ@
340base_sources = \
341edje_box_layout.c \
342edje_cache.c \
343edje_calc.c \
344edje_callbacks.c \
345edje_container.c \
346edje_data.c \
347edje_edit.c \
348edje_embryo.c \
349edje_entry.c \
350edje_external.c \
351edje_load.c \
352edje_lua.c \
353edje_lua2.c \
354edje_lua_script_only.c \
355edje_main.c \
356edje_match.c \
357edje_message_queue.c \
358edje_misc.c \
359edje_module.c \
360edje_multisense.c \
361edje_program.c \
362edje_script_only.c \
363edje_smart.c \
364edje_text.c \
365edje_textblock_styles.c \
366edje_util.c \
367edje_var.c
368
369@EDJE_AMALGAMATION_TRUE@nodist_libedje_la_SOURCES = edje_amalgamation.c
370@EDJE_AMALGAMATION_FALSE@libedje_la_SOURCES = $(base_sources)
371libedje_la_LIBADD = @EDJE_LIBS@ @ECORE_IMF_LIBS@ @EVIL_LIBS@ @REMIX_LIBS@ @SNDFILE_LIBS@ -lm
372libedje_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -version-info @version_info@ @release_info@
373EXTRA_DIST = edje_private.h edje_container.h edje_convert.h
374all: all-am
375
376.SUFFIXES:
377.SUFFIXES: .c .lo .o .obj
378$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
379 @for dep in $?; do \
380 case '$(am__configure_deps)' in \
381 *$$dep*) \
382 ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
383 && { if test -f $@; then exit 0; else break; fi; }; \
384 exit 1;; \
385 esac; \
386 done; \
387 echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/lib/Makefile'; \
388 $(am__cd) $(top_srcdir) && \
389 $(AUTOMAKE) --gnu src/lib/Makefile
390.PRECIOUS: Makefile
391Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
392 @case '$?' in \
393 *config.status*) \
394 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
395 *) \
396 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
397 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
398 esac;
399
400$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
401 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
402
403$(top_srcdir)/configure: $(am__configure_deps)
404 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
405$(ACLOCAL_M4): $(am__aclocal_m4_deps)
406 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
407$(am__aclocal_m4_deps):
408install-libLTLIBRARIES: $(lib_LTLIBRARIES)
409 @$(NORMAL_INSTALL)
410 test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)"
411 @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
412 list2=; for p in $$list; do \
413 if test -f $$p; then \
414 list2="$$list2 $$p"; \
415 else :; fi; \
416 done; \
417 test -z "$$list2" || { \
418 echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \
419 $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \
420 }
421
422uninstall-libLTLIBRARIES:
423 @$(NORMAL_UNINSTALL)
424 @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
425 for p in $$list; do \
426 $(am__strip_dir) \
427 echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \
428 $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \
429 done
430
431clean-libLTLIBRARIES:
432 -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
433 @list='$(lib_LTLIBRARIES)'; for p in $$list; do \
434 dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
435 test "$$dir" != "$$p" || dir=.; \
436 echo "rm -f \"$${dir}/so_locations\""; \
437 rm -f "$${dir}/so_locations"; \
438 done
439libedje.la: $(libedje_la_OBJECTS) $(libedje_la_DEPENDENCIES)
440 $(AM_V_CCLD)$(libedje_la_LINK) -rpath $(libdir) $(libedje_la_OBJECTS) $(libedje_la_LIBADD) $(LIBS)
441
442mostlyclean-compile:
443 -rm -f *.$(OBJEXT)
444
445distclean-compile:
446 -rm -f *.tab.c
447
448@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_amalgamation.Plo@am__quote@
449@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_box_layout.Plo@am__quote@
450@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_cache.Plo@am__quote@
451@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_calc.Plo@am__quote@
452@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_callbacks.Plo@am__quote@
453@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_container.Plo@am__quote@
454@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_data.Plo@am__quote@
455@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_edit.Plo@am__quote@
456@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_embryo.Plo@am__quote@
457@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_entry.Plo@am__quote@
458@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_external.Plo@am__quote@
459@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_load.Plo@am__quote@
460@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_lua.Plo@am__quote@
461@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_lua2.Plo@am__quote@
462@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_lua_script_only.Plo@am__quote@
463@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_main.Plo@am__quote@
464@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_match.Plo@am__quote@
465@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_message_queue.Plo@am__quote@
466@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_misc.Plo@am__quote@
467@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_module.Plo@am__quote@
468@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_multisense.Plo@am__quote@
469@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_program.Plo@am__quote@
470@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_script_only.Plo@am__quote@
471@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_smart.Plo@am__quote@
472@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_text.Plo@am__quote@
473@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_textblock_styles.Plo@am__quote@
474@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_util.Plo@am__quote@
475@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_var.Plo@am__quote@
476
477.c.o:
478@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
479@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
480@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
481@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
482@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
483@am__fastdepCC_FALSE@ $(COMPILE) -c $<
484
485.c.obj:
486@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
487@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
488@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
489@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
490@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
491@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
492
493.c.lo:
494@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
495@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
496@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
497@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
498@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
499@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
500
501mostlyclean-libtool:
502 -rm -f *.lo
503
504clean-libtool:
505 -rm -rf .libs _libs
506install-includesHEADERS: $(includes_HEADERS)
507 @$(NORMAL_INSTALL)
508 test -z "$(includesdir)" || $(MKDIR_P) "$(DESTDIR)$(includesdir)"
509 @list='$(includes_HEADERS)'; test -n "$(includesdir)" || list=; \
510 for p in $$list; do \
511 if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
512 echo "$$d$$p"; \
513 done | $(am__base_list) | \
514 while read files; do \
515 echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includesdir)'"; \
516 $(INSTALL_HEADER) $$files "$(DESTDIR)$(includesdir)" || exit $$?; \
517 done
518
519uninstall-includesHEADERS:
520 @$(NORMAL_UNINSTALL)
521 @list='$(includes_HEADERS)'; test -n "$(includesdir)" || list=; \
522 files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
523 test -n "$$files" || exit 0; \
524 echo " ( cd '$(DESTDIR)$(includesdir)' && rm -f" $$files ")"; \
525 cd "$(DESTDIR)$(includesdir)" && rm -f $$files
526
527ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
528 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
529 unique=`for i in $$list; do \
530 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
531 done | \
532 $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
533 END { if (nonempty) { for (i in files) print i; }; }'`; \
534 mkid -fID $$unique
535tags: TAGS
536
537TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
538 $(TAGS_FILES) $(LISP)
539 set x; \
540 here=`pwd`; \
541 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
542 unique=`for i in $$list; do \
543 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
544 done | \
545 $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
546 END { if (nonempty) { for (i in files) print i; }; }'`; \
547 shift; \
548 if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
549 test -n "$$unique" || unique=$$empty_fix; \
550 if test $$# -gt 0; then \
551 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
552 "$$@" $$unique; \
553 else \
554 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
555 $$unique; \
556 fi; \
557 fi
558ctags: CTAGS
559CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
560 $(TAGS_FILES) $(LISP)
561 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
562 unique=`for i in $$list; do \
563 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
564 done | \
565 $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
566 END { if (nonempty) { for (i in files) print i; }; }'`; \
567 test -z "$(CTAGS_ARGS)$$unique" \
568 || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
569 $$unique
570
571GTAGS:
572 here=`$(am__cd) $(top_builddir) && pwd` \
573 && $(am__cd) $(top_srcdir) \
574 && gtags -i $(GTAGS_ARGS) "$$here"
575
576distclean-tags:
577 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
578
579distdir: $(DISTFILES)
580 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
581 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
582 list='$(DISTFILES)'; \
583 dist_files=`for file in $$list; do echo $$file; done | \
584 sed -e "s|^$$srcdirstrip/||;t" \
585 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
586 case $$dist_files in \
587 */*) $(MKDIR_P) `echo "$$dist_files" | \
588 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
589 sort -u` ;; \
590 esac; \
591 for file in $$dist_files; do \
592 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
593 if test -d $$d/$$file; then \
594 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
595 if test -d "$(distdir)/$$file"; then \
596 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
597 fi; \
598 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
599 cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
600 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
601 fi; \
602 cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
603 else \
604 test -f "$(distdir)/$$file" \
605 || cp -p $$d/$$file "$(distdir)/$$file" \
606 || exit 1; \
607 fi; \
608 done
609check-am: all-am
610check: check-am
611all-am: Makefile $(LTLIBRARIES) $(HEADERS)
612installdirs:
613 for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includesdir)"; do \
614 test -z "$$dir" || $(MKDIR_P) "$$dir"; \
615 done
616install: install-am
617install-exec: install-exec-am
618install-data: install-data-am
619uninstall: uninstall-am
620
621install-am: all-am
622 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
623
624installcheck: installcheck-am
625install-strip:
626 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
627 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
628 `test -z '$(STRIP)' || \
629 echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
630mostlyclean-generic:
631
632clean-generic:
633
634distclean-generic:
635 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
636 -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
637
638maintainer-clean-generic:
639 @echo "This command is intended for maintainers to use"
640 @echo "it deletes files that may require special tools to rebuild."
641 -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
642clean: clean-am
643
644clean-am: clean-generic clean-libLTLIBRARIES clean-libtool clean-local \
645 mostlyclean-am
646
647distclean: distclean-am
648 -rm -rf ./$(DEPDIR)
649 -rm -f Makefile
650distclean-am: clean-am distclean-compile distclean-generic \
651 distclean-tags
652
653dvi: dvi-am
654
655dvi-am:
656
657html: html-am
658
659html-am:
660
661info: info-am
662
663info-am:
664
665install-data-am: install-includesHEADERS
666
667install-dvi: install-dvi-am
668
669install-dvi-am:
670
671install-exec-am: install-libLTLIBRARIES
672
673install-html: install-html-am
674
675install-html-am:
676
677install-info: install-info-am
678
679install-info-am:
680
681install-man:
682
683install-pdf: install-pdf-am
684
685install-pdf-am:
686
687install-ps: install-ps-am
688
689install-ps-am:
690
691installcheck-am:
692
693maintainer-clean: maintainer-clean-am
694 -rm -rf ./$(DEPDIR)
695 -rm -f Makefile
696maintainer-clean-am: distclean-am maintainer-clean-generic
697
698mostlyclean: mostlyclean-am
699
700mostlyclean-am: mostlyclean-compile mostlyclean-generic \
701 mostlyclean-libtool
702
703pdf: pdf-am
704
705pdf-am:
706
707ps: ps-am
708
709ps-am:
710
711uninstall-am: uninstall-includesHEADERS uninstall-libLTLIBRARIES
712
713.MAKE: install-am install-strip
714
715.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
716 clean-libLTLIBRARIES clean-libtool clean-local ctags distclean \
717 distclean-compile distclean-generic distclean-libtool \
718 distclean-tags distdir dvi dvi-am html html-am info info-am \
719 install install-am install-data install-data-am install-dvi \
720 install-dvi-am install-exec install-exec-am install-html \
721 install-html-am install-includesHEADERS install-info \
722 install-info-am install-libLTLIBRARIES install-man install-pdf \
723 install-pdf-am install-ps install-ps-am install-strip \
724 installcheck installcheck-am installdirs maintainer-clean \
725 maintainer-clean-generic mostlyclean mostlyclean-compile \
726 mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
727 tags uninstall uninstall-am uninstall-includesHEADERS \
728 uninstall-libLTLIBRARIES
729
730
731@EDJE_AMALGAMATION_TRUE@edje_amalgamation.c: $(base_sources) Makefile
732@EDJE_AMALGAMATION_TRUE@ -rm -f edje_amalgamation.c
733
734@EDJE_AMALGAMATION_TRUE@ @echo "#ifdef HAVE_CONFIG_H" >> edje_amalgamation.c
735@EDJE_AMALGAMATION_TRUE@ @echo "# include \"config.h\"" >> edje_amalgamation.c
736@EDJE_AMALGAMATION_TRUE@ @echo "#endif" >> edje_amalgamation.c
737
738@EDJE_AMALGAMATION_TRUE@ @echo "#ifndef _WIN32" >> edje_amalgamation.c
739@EDJE_AMALGAMATION_TRUE@ @echo "#define _GNU_SOURCE" >> edje_amalgamation.c
740@EDJE_AMALGAMATION_TRUE@ @echo "#endif" >> edje_amalgamation.c
741
742@EDJE_AMALGAMATION_TRUE@ @echo "#ifdef HAVE_ALLOCA_H" >> edje_amalgamation.c
743@EDJE_AMALGAMATION_TRUE@ @echo "# include <alloca.h>" >> edje_amalgamation.c
744@EDJE_AMALGAMATION_TRUE@ @echo "#elif defined __GNUC__" >> edje_amalgamation.c
745@EDJE_AMALGAMATION_TRUE@ @echo "# define alloca __builtin_alloca" >> edje_amalgamation.c
746@EDJE_AMALGAMATION_TRUE@ @echo "#elif defined _AIX" >> edje_amalgamation.c
747@EDJE_AMALGAMATION_TRUE@ @echo "# define alloca __alloca" >> edje_amalgamation.c
748@EDJE_AMALGAMATION_TRUE@ @echo "#elif defined _MSC_VER" >> edje_amalgamation.c
749@EDJE_AMALGAMATION_TRUE@ @echo "# include <malloc.h>" >> edje_amalgamation.c
750@EDJE_AMALGAMATION_TRUE@ @echo "# define alloca _alloca" >> edje_amalgamation.c
751@EDJE_AMALGAMATION_TRUE@ @echo "#else" >> edje_amalgamation.c
752@EDJE_AMALGAMATION_TRUE@ @echo "# include <stddef.h>" >> edje_amalgamation.c
753@EDJE_AMALGAMATION_TRUE@ @echo "# ifdef __cplusplus" >> edje_amalgamation.c
754@EDJE_AMALGAMATION_TRUE@ @echo "#extern \"C\"" >> edje_amalgamation.c
755@EDJE_AMALGAMATION_TRUE@ @echo "# endif" >> edje_amalgamation.c
756@EDJE_AMALGAMATION_TRUE@ @echo "#void *alloca (size_t);" >> edje_amalgamation.c
757@EDJE_AMALGAMATION_TRUE@ @echo "#endif" >> edje_amalgamation.c
758
759@EDJE_AMALGAMATION_TRUE@ @echo "#include <string.h>" >> edje_amalgamation.c
760@EDJE_AMALGAMATION_TRUE@ @echo "#include <math.h>" >> edje_amalgamation.c
761@EDJE_AMALGAMATION_TRUE@ @echo "#include <time.h>" >> edje_amalgamation.c
762@EDJE_AMALGAMATION_TRUE@ @echo "#include <limits.h>" >> edje_amalgamation.c
763@EDJE_AMALGAMATION_TRUE@ @echo "#include <errno.h>" >> edje_amalgamation.c
764@EDJE_AMALGAMATION_TRUE@ @echo "#include <sys/stat.h>" >> edje_amalgamation.c
765@EDJE_AMALGAMATION_TRUE@ @echo "#include <fcntl.h>" >> edje_amalgamation.c
766
767@EDJE_AMALGAMATION_TRUE@ @echo "#ifndef _MSC_VER" >> edje_amalgamation.c
768@EDJE_AMALGAMATION_TRUE@ @echo "# include <unistd.h>" >> edje_amalgamation.c
769@EDJE_AMALGAMATION_TRUE@ @echo "#endif" >> edje_amalgamation.c
770
771@EDJE_AMALGAMATION_TRUE@ @echo "#ifdef HAVE_LOCALE_H" >> edje_amalgamation.c
772@EDJE_AMALGAMATION_TRUE@ @echo "# include <locale.h>" >> edje_amalgamation.c
773@EDJE_AMALGAMATION_TRUE@ @echo "#endif" >> edje_amalgamation.c
774
775@EDJE_AMALGAMATION_TRUE@ @echo "#include <lua.h>" >> edje_amalgamation.c
776@EDJE_AMALGAMATION_TRUE@ @echo "#include <lauxlib.h>" >> edje_amalgamation.c
777
778@EDJE_AMALGAMATION_TRUE@ @echo "#ifdef HAVE_EVIL" >> edje_amalgamation.c
779@EDJE_AMALGAMATION_TRUE@ @echo "# include <Evil.h>" >> edje_amalgamation.c
780@EDJE_AMALGAMATION_TRUE@ @echo "#endif" >> edje_amalgamation.c
781
782@EDJE_AMALGAMATION_TRUE@ @echo "#include <Eina.h>" >> edje_amalgamation.c
783@EDJE_AMALGAMATION_TRUE@ @echo "#include <Edje.h>" >> edje_amalgamation.c
784@EDJE_AMALGAMATION_TRUE@ @echo "#include <Evas.h>" >> edje_amalgamation.c
785@EDJE_AMALGAMATION_TRUE@ @echo "#include <Ecore.h>" >> edje_amalgamation.c
786@EDJE_AMALGAMATION_TRUE@ @echo "#include <Embryo.h>" >> edje_amalgamation.c
787
788@EDJE_AMALGAMATION_TRUE@ @echo "#ifdef HAVE_ECORE_IMF" >> edje_amalgamation.c
789@EDJE_AMALGAMATION_TRUE@ @echo "# include <Ecore_IMF.h>" >> edje_amalgamation.c
790@EDJE_AMALGAMATION_TRUE@ @echo "#endif" >> edje_amalgamation.c
791
792@EDJE_AMALGAMATION_TRUE@ @echo "#include <edje_private.h>" >> edje_amalgamation.c
793
794@EDJE_AMALGAMATION_TRUE@ @for f in $(base_sources); do \
795@EDJE_AMALGAMATION_TRUE@ if [ `echo $$f | sed -e 's/^...\(.\).*/\1/'` != '/' ]; then \
796@EDJE_AMALGAMATION_TRUE@ file="$(srcdir)/$$f" ; \
797@EDJE_AMALGAMATION_TRUE@ else \
798@EDJE_AMALGAMATION_TRUE@ file="$$f" ; \
799@EDJE_AMALGAMATION_TRUE@ fi ; \
800@EDJE_AMALGAMATION_TRUE@ echo "/* file: $$file */" >> edje_amalgamation.c; \
801@EDJE_AMALGAMATION_TRUE@ grep -v -e '^# *include \+.\(config\|\|Evil\|Eina\|Eet\|Evas\|Ecore\|Embryo\|Ecore_IMF\|string\|math\|limits\|sys/stat\|errno\|time\|unistd\|locale\|lua\|lauxlib\|edje_private\)[.]h.*' $$file >> edje_amalgamation.c; \
802@EDJE_AMALGAMATION_TRUE@ done
803@EDJE_AMALGAMATION_TRUE@ @echo "edje_amalgamation.c generated"
804
805clean-local:
806 @rm -rf *.gcno edje_amalgamation.c
807
808# Tell versions [3.59,3.63) of GNU make to not export all variables.
809# Otherwise a system limit (for SysV at least) may be exceeded.
810.NOEXPORT:
diff --git a/libraries/edje/src/lib/edje_box_layout.c b/libraries/edje/src/lib/edje_box_layout.c
new file mode 100644
index 0000000..3585046
--- /dev/null
+++ b/libraries/edje/src/lib/edje_box_layout.c
@@ -0,0 +1,242 @@
1#include "edje_private.h"
2
3typedef struct _Edje_Transition_Animation_Data Edje_Transition_Animation_Data;
4struct _Edje_Transition_Animation_Data
5{
6 Evas_Object *obj;
7 struct
8 {
9 Evas_Coord x, y, w, h;
10 } start, end;
11};
12
13struct _Edje_Part_Box_Animation
14{
15 struct
16 {
17 Evas_Object_Box_Layout layout;
18 void *data;
19 void(*free_data)(void *data);
20 Edje_Alignment align;
21 Evas_Point padding;
22 } start, end;
23 Eina_List *objs;
24 Eina_Bool recalculate:1;
25 Evas_Object *box;
26 double progress;
27 double start_progress;
28 int box_start_w, box_start_h;
29};
30
31static void
32_edje_box_layout_find_all(const char *name, const char *name_alt, Evas_Object_Box_Layout *cb, void **data, void (**free_data)(void *data))
33{
34 if (!_edje_box_layout_find(name, cb, data, free_data))
35 {
36 if ((!name_alt) ||
37 (!_edje_box_layout_find(name_alt, cb, data, free_data)))
38 {
39 ERR("box layout '%s' (fallback '%s') not available, using horizontal.",
40 name, name_alt);
41 *cb = evas_object_box_layout_horizontal;
42 *free_data = NULL;
43 *data = NULL;
44 }
45 }
46}
47
48static void
49_edje_box_layout_calculate_coords(Evas_Object *obj, Evas_Object_Box_Data *priv, Edje_Part_Box_Animation *anim)
50{
51 Eina_List *l;
52 Edje_Transition_Animation_Data *tad;
53 Evas_Coord x, y;
54
55 evas_object_geometry_get(obj, &x, &y, &anim->box_start_w, &anim->box_start_h);
56 EINA_LIST_FOREACH(anim->objs, l, tad)
57 {
58 evas_object_geometry_get(tad->obj, &tad->start.x, &tad->start.y,
59 &tad->start.w, &tad->start.h);
60 tad->start.x = tad->start.x - x;
61 tad->start.y = tad->start.y - y;
62 }
63 evas_object_box_padding_set(obj, anim->end.padding.x, anim->end.padding.y);
64 evas_object_box_align_set(obj, TO_DOUBLE(anim->end.align.x), TO_DOUBLE(anim->end.align.y));
65 anim->end.layout(obj, priv, anim->end.data);
66 EINA_LIST_FOREACH(anim->objs, l, tad)
67 {
68 evas_object_geometry_get(tad->obj, &tad->end.x, &tad->end.y,
69 &tad->end.w, &tad->end.h);
70 tad->end.x = tad->end.x - x;
71 tad->end.y = tad->end.y - y;
72 }
73}
74
75static void
76_edje_box_layout_exec(Evas_Object *obj, Edje_Part_Box_Animation *anim)
77{
78 Eina_List *l;
79 Edje_Transition_Animation_Data *tad;
80 Evas_Coord x, y, w, h;
81 Evas_Coord cur_x, cur_y, cur_w, cur_h;
82 double progress;
83
84 evas_object_geometry_get(obj, &x, &y, &w, &h);
85 progress = (anim->progress - anim->start_progress) / (1 - anim->start_progress);
86
87 EINA_LIST_FOREACH(anim->objs, l, tad)
88 {
89 cur_x = x + (tad->start.x + ((tad->end.x - tad->start.x) * progress)) * (w / (double)anim->box_start_w);
90 cur_y = y + (tad->start.y + ((tad->end.y - tad->start.y) * progress)) * (h / (double)anim->box_start_h);
91 cur_w = (w / (double)anim->box_start_w) * (tad->start.w + ((tad->end.w - tad->start.w) * progress));
92 cur_h = (h / (double)anim->box_start_h) * (tad->start.h + ((tad->end.h - tad->start.h) * progress));
93 evas_object_move(tad->obj, cur_x, cur_y);
94 evas_object_resize(tad->obj, cur_w, cur_h);
95 }
96}
97
98static void
99_edje_box_layout(Evas_Object *obj, Evas_Object_Box_Data *priv, void *data)
100{
101 Edje_Part_Box_Animation *anim = data;
102 if (anim->progress < 0.01)
103 {
104 if (anim->start.layout)
105 {
106 evas_object_box_padding_set(obj, anim->start.padding.x, anim->start.padding.y);
107 evas_object_box_align_set(obj, TO_DOUBLE(anim->start.align.x), TO_DOUBLE(anim->start.align.y));
108 anim->start.layout(obj, priv, anim->start.data);
109 }
110 return;
111 }
112
113 if (anim->recalculate)
114 {
115 _edje_box_layout_calculate_coords(obj, priv, anim);
116 anim->start_progress = anim->progress;
117 anim->recalculate = EINA_FALSE;
118 }
119
120 if ((anim->progress > 0) && (anim->start_progress < 1))
121 _edje_box_layout_exec(obj, anim);
122}
123
124void
125_edje_box_layout_free_data(void *data)
126{
127 Edje_Transition_Animation_Data *tad;
128 Edje_Part_Box_Animation *anim = data;
129 if (anim->start.free_data && anim->start.data)
130 anim->start.free_data(anim->start.data);
131 if (anim->end.free_data && anim->end.data)
132 anim->end.free_data(anim->end.data);
133 EINA_LIST_FREE(anim->objs, tad)
134 free(tad);
135 free(data);
136}
137
138Edje_Part_Box_Animation *
139_edje_box_layout_anim_new(Evas_Object *box)
140{
141 Edje_Part_Box_Animation *anim = calloc(1, sizeof(Edje_Part_Box_Animation));
142 if (!anim)
143 return NULL;
144
145 anim->box = box;
146 evas_object_box_layout_set(box, _edje_box_layout, anim, NULL);
147
148 return anim;
149}
150
151void
152_edje_box_recalc_apply(Edje *ed __UNUSED__, Edje_Real_Part *ep, Edje_Calc_Params *p3 __UNUSED__, Edje_Part_Description_Box *chosen_desc)
153{
154 Evas_Object_Box_Data *priv;
155#if 0
156 int min_w, min_h;
157#endif
158 if ((ep->param2) && (ep->description_pos != ZERO))
159 {
160 Edje_Part_Description_Box *param2_desc = (Edje_Part_Description_Box *)ep->param2->description;
161 if (ep->anim->end.layout == NULL)
162 {
163 _edje_box_layout_find_all(param2_desc->box.layout, param2_desc->box.alt_layout, &ep->anim->end.layout, &ep->anim->end.data, &ep->anim->end.free_data);
164 ep->anim->end.padding.x = param2_desc->box.padding.x;
165 ep->anim->end.padding.y = param2_desc->box.padding.y;
166 ep->anim->end.align.x = param2_desc->box.align.x;
167 ep->anim->end.align.y = param2_desc->box.align.y;
168
169 priv = evas_object_smart_data_get(ep->object);
170 if (priv == NULL)
171 return;
172
173 evas_object_box_padding_set(ep->object, ep->anim->start.padding.x, ep->anim->start.padding.y);
174 evas_object_box_align_set(ep->object, TO_DOUBLE(ep->anim->start.align.x), TO_DOUBLE(ep->anim->start.align.y));
175 ep->anim->start.layout(ep->object, priv, ep->anim->start.data);
176 _edje_box_layout_calculate_coords(ep->object, priv, ep->anim);
177 ep->anim->start_progress = 0.0;
178 }
179 evas_object_smart_changed(ep->object);
180 }
181 else
182 {
183 ep->anim->end.layout = NULL;
184 }
185
186 if (ep->description_pos < 0.01 || !ep->anim->start.layout)
187 {
188 _edje_box_layout_find_all(chosen_desc->box.layout, chosen_desc->box.alt_layout, &ep->anim->start.layout, &ep->anim->start.data, &ep->anim->start.free_data);
189 ep->anim->start.padding.x = chosen_desc->box.padding.x;
190 ep->anim->start.padding.y = chosen_desc->box.padding.y;
191 ep->anim->start.align.x = chosen_desc->box.align.x;
192 ep->anim->start.align.y = chosen_desc->box.align.y;
193 evas_object_smart_changed(ep->object);
194 }
195
196 ep->anim->progress = ep->description_pos;
197
198 if (evas_object_smart_need_recalculate_get(ep->object))
199 {
200 evas_object_smart_need_recalculate_set(ep->object, 0);
201 evas_object_smart_calculate(ep->object);
202 }
203#if 0 /* Why the hell do we affect part size after resize ??? */
204 evas_object_size_hint_min_get(ep->object, &min_w, &min_h);
205 if (chosen_desc->box.min.h && (p3->w < min_w))
206 p3->w = min_w;
207 if (chosen_desc->box.min.v && (p3->h < min_h))
208 p3->h = min_h;
209#endif
210}
211
212Eina_Bool
213_edje_box_layout_add_child(Edje_Real_Part *rp, Evas_Object *child_obj)
214{
215 Edje_Transition_Animation_Data *tad;
216 tad = calloc(1, sizeof(Edje_Transition_Animation_Data));
217 if (!tad)
218 return EINA_FALSE;
219 tad->obj = child_obj;
220 rp->anim->objs = eina_list_append(rp->anim->objs, tad);
221 rp->anim->recalculate = EINA_TRUE;
222 return EINA_TRUE;
223}
224
225void
226_edje_box_layout_remove_child(Edje_Real_Part *rp, Evas_Object *child_obj)
227{
228 Eina_List *l;
229 Edje_Transition_Animation_Data *tad;
230
231 EINA_LIST_FOREACH(rp->anim->objs, l, tad)
232 {
233 if (tad->obj == child_obj)
234 {
235 free(eina_list_data_get(l));
236 rp->anim->objs = eina_list_remove_list(rp->anim->objs, l);
237 rp->anim->recalculate = EINA_TRUE;
238 break;
239 }
240 }
241 rp->anim->recalculate = EINA_TRUE;
242}
diff --git a/libraries/edje/src/lib/edje_cache.c b/libraries/edje/src/lib/edje_cache.c
new file mode 100644
index 0000000..a8b355f
--- /dev/null
+++ b/libraries/edje/src/lib/edje_cache.c
@@ -0,0 +1,570 @@
1#include "edje_private.h"
2
3
4/**
5 * @cond
6 */
7
8static Eina_Hash *_edje_file_hash = NULL;
9static int _edje_file_cache_size = 16;
10static Eina_List *_edje_file_cache = NULL;
11
12static int _edje_collection_cache_size = 16;
13
14static Edje_Part_Collection *
15_edje_file_coll_open(Edje_File *edf, const char *coll)
16{
17 Edje_Part_Collection *edc = NULL;
18 Edje_Part_Collection_Directory_Entry *ce;
19 int id = -1, size = 0;
20 Eina_List *l;
21 char buf[256];
22 char *buffer;
23 void *data;
24
25 ce = eina_hash_find(edf->collection, coll);
26 if (!ce) return NULL;
27
28 if (ce->ref)
29 {
30 ce->ref->references++;
31 return ce->ref;
32 }
33
34 EINA_LIST_FOREACH(edf->collection_cache, l, edc)
35 {
36 if (!strcmp(edc->part, coll))
37 {
38 edc->references = 1;
39 ce->ref = edc;
40
41 edf->collection_cache = eina_list_remove_list(edf->collection_cache, l);
42 return ce->ref;
43 }
44 }
45
46 id = ce->id;
47 if (id < 0) return NULL;
48
49#define INIT_EMP(Tp, Sz, Ce) \
50 buffer = alloca(strlen(ce->entry) + strlen(#Tp) + 2); \
51 sprintf(buffer, "%s/%s", ce->entry, #Tp); \
52 Ce->mp.Tp = eina_mempool_add("one_big", buffer, NULL, sizeof (Sz), Ce->count.Tp); \
53 _emp_##Tp = Ce->mp.Tp;
54
55#define INIT_EMP_BOTH(Tp, Sz, Ce) \
56 INIT_EMP(Tp, Sz, Ce) \
57 Ce->mp_rtl.Tp = eina_mempool_add("one_big", buffer, NULL, \
58 sizeof (Sz), Ce->count.Tp);
59
60 INIT_EMP_BOTH(RECTANGLE, Edje_Part_Description_Common, ce);
61 INIT_EMP_BOTH(TEXT, Edje_Part_Description_Text, ce);
62 INIT_EMP_BOTH(IMAGE, Edje_Part_Description_Image, ce);
63 INIT_EMP_BOTH(PROXY, Edje_Part_Description_Proxy, ce);
64 INIT_EMP_BOTH(SWALLOW, Edje_Part_Description_Common, ce);
65 INIT_EMP_BOTH(TEXTBLOCK, Edje_Part_Description_Text, ce);
66 INIT_EMP_BOTH(GROUP, Edje_Part_Description_Common, ce);
67 INIT_EMP_BOTH(BOX, Edje_Part_Description_Box, ce);
68 INIT_EMP_BOTH(TABLE, Edje_Part_Description_Table, ce);
69 INIT_EMP_BOTH(EXTERNAL, Edje_Part_Description_External, ce);
70 INIT_EMP(part, Edje_Part, ce);
71
72 snprintf(buf, sizeof(buf), "edje/collections/%i", id);
73 edc = eet_data_read(edf->ef, _edje_edd_edje_part_collection, buf);
74 if (!edc) return NULL;
75
76 edc->references = 1;
77 edc->part = ce->entry;
78
79 /* For Edje file build with Edje 1.0, people expect text.align to be 0.0 0.0 */
80 if (edf->version <= 3 && edf->minor <= 1)
81 {
82 /* This will preserve previous rendering */
83 unsigned int i;
84
85 for (i = 0; i < edc->parts_count; ++i)
86 {
87 if (edc->parts[i]->type == EDJE_PART_TYPE_TEXTBLOCK)
88 {
89 Edje_Part_Description_Text *text;
90 unsigned int j;
91
92 text = (Edje_Part_Description_Text*) edc->parts[i]->default_desc;
93 text->text.align.x = TO_DOUBLE(0.0);
94 text->text.align.y = TO_DOUBLE(0.0);
95
96 for (j = 0; j < edc->parts[i]->other.desc_count; ++j)
97 {
98 text = (Edje_Part_Description_Text*) edc->parts[i]->other.desc[j];
99 text->text.align.x = TO_DOUBLE(0.0);
100 text->text.align.y = TO_DOUBLE(0.0);
101 }
102 }
103 }
104 }
105
106 snprintf(buf, sizeof(buf), "edje/scripts/embryo/compiled/%i", id);
107 data = eet_read(edf->ef, buf, &size);
108
109 if (data)
110 {
111 edc->script = embryo_program_new(data, size);
112 _edje_embryo_script_init(edc);
113 free(data);
114 }
115
116 snprintf(buf, sizeof(buf), "edje/scripts/lua/%i", id);
117 data = eet_read(edf->ef, buf, &size);
118
119 if (data)
120 {
121 _edje_lua2_script_load(edc, data, size);
122 free(data);
123 }
124
125 ce->ref = edc;
126
127 return edc;
128}
129
130static Edje_File *
131_edje_file_open(const char *file, const char *coll, int *error_ret, Edje_Part_Collection **edc_ret)
132{
133 Edje_File *edf;
134 Edje_Part_Collection *edc;
135 Eet_File *ef;
136 struct stat st;
137
138 if (stat(file, &st) != 0)
139 {
140 *error_ret = EDJE_LOAD_ERROR_DOES_NOT_EXIST;
141 return NULL;
142 }
143
144 ef = eet_open(file, EET_FILE_MODE_READ);
145 if (!ef)
146 {
147 *error_ret = EDJE_LOAD_ERROR_UNKNOWN_FORMAT;
148 return NULL;
149 }
150 edf = eet_data_read(ef, _edje_edd_edje_file, "edje/file");
151 if (!edf)
152 {
153 *error_ret = EDJE_LOAD_ERROR_CORRUPT_FILE;
154 eet_close(ef);
155 return NULL;
156 }
157
158 edf->ef = ef;
159 edf->mtime = st.st_mtime;
160
161 if (edf->version != EDJE_FILE_VERSION)
162 {
163 *error_ret = EDJE_LOAD_ERROR_INCOMPATIBLE_FILE;
164 _edje_file_free(edf);
165 return NULL;
166 }
167 if (!edf->collection)
168 {
169 *error_ret = EDJE_LOAD_ERROR_CORRUPT_FILE;
170 _edje_file_free(edf);
171 return NULL;
172 }
173
174 if (edf->minor > EDJE_FILE_MINOR)
175 {
176 WRN("`%s` may use feature from a newer edje and could not show up as expected.", file);
177 }
178
179 edf->path = eina_stringshare_add(file);
180 edf->references = 1;
181
182 /* This should be done at edje generation time */
183 _edje_textblock_style_parse_and_fix(edf);
184
185 if (coll)
186 {
187 edc = _edje_file_coll_open(edf, coll);
188 if (!edc)
189 {
190 *error_ret = EDJE_LOAD_ERROR_UNKNOWN_COLLECTION;
191 }
192 if (edc_ret) *edc_ret = edc;
193 }
194
195 return edf;
196}
197
198static void
199_edje_file_dangling(Edje_File *edf)
200{
201 if (edf->dangling) return;
202 edf->dangling = EINA_TRUE;
203
204 eina_hash_del(_edje_file_hash, edf->path, edf);
205 if (!eina_hash_population(_edje_file_hash))
206 {
207 eina_hash_free(_edje_file_hash);
208 _edje_file_hash = NULL;
209 }
210}
211
212Edje_File *
213_edje_cache_file_coll_open(const char *file, const char *coll, int *error_ret, Edje_Part_Collection **edc_ret)
214{
215 Edje_File *edf;
216 Eina_List *l, *hist;
217 Edje_Part_Collection *edc;
218 Edje_Part *ep;
219 struct stat st;
220
221 if (stat(file, &st) != 0)
222 return NULL;
223
224 if (!_edje_file_hash)
225 {
226 _edje_file_hash = eina_hash_string_small_new(NULL);
227 goto open_new;
228 }
229
230 edf = eina_hash_find(_edje_file_hash, file);
231 if (edf)
232 {
233 if (edf->mtime != st.st_mtime)
234 {
235 _edje_file_dangling(edf);
236 goto open_new;
237 }
238
239 edf->references++;
240 goto open;
241 }
242
243 EINA_LIST_FOREACH(_edje_file_cache, l, edf)
244 {
245 if (!strcmp(edf->path, file))
246 {
247 if (edf->mtime != st.st_mtime)
248 {
249 _edje_file_cache = eina_list_remove_list(_edje_file_cache, l);
250 _edje_file_free(edf);
251 goto open_new;
252 }
253
254 edf->references = 1;
255 _edje_file_cache = eina_list_remove_list(_edje_file_cache, l);
256 eina_hash_add(_edje_file_hash, file, edf);
257 goto open;
258 }
259 }
260
261open_new:
262 if (!_edje_file_hash)
263 _edje_file_hash = eina_hash_string_small_new(NULL);
264
265 edf = _edje_file_open(file, coll, error_ret, edc_ret);
266 if (!edf)
267 return NULL;
268
269 eina_hash_add(_edje_file_hash, file, edf);
270 return edf;
271
272open:
273 if (!coll)
274 return edf;
275
276 edc = _edje_file_coll_open(edf, coll);
277 if (!edc)
278 {
279 *error_ret = EDJE_LOAD_ERROR_UNKNOWN_COLLECTION;
280 }
281 else
282 {
283 if (!edc->checked)
284 {
285 unsigned int j;
286
287 for (j = 0; j < edc->parts_count; ++j)
288 {
289 Edje_Part *ep2;
290
291 ep = edc->parts[j];
292
293 /* Register any color classes in this parts descriptions. */
294 hist = NULL;
295 hist = eina_list_append(hist, ep);
296 ep2 = ep;
297 while (ep2->dragable.confine_id >= 0)
298 {
299 if (ep2->dragable.confine_id >= (int) edc->parts_count)
300 {
301 ERR("confine_to above limit. invalidating it.");
302 ep2->dragable.confine_id = -1;
303 break;
304 }
305
306 ep2 = edc->parts[ep2->dragable.confine_id];
307 if (eina_list_data_find(hist, ep2))
308 {
309 ERR("confine_to loops. invalidating loop.");
310 ep2->dragable.confine_id = -1;
311 break;
312 }
313 hist = eina_list_append(hist, ep2);
314 }
315 eina_list_free(hist);
316 hist = NULL;
317 hist = eina_list_append(hist, ep);
318 ep2 = ep;
319 while (ep2->dragable.event_id >= 0)
320 {
321 Edje_Part* prev;
322
323 if (ep2->dragable.event_id >= (int) edc->parts_count)
324 {
325 ERR("event_id above limit. invalidating it.");
326 ep2->dragable.event_id = -1;
327 break;
328 }
329 prev = ep2;
330
331 ep2 = edc->parts[ep2->dragable.event_id];
332 if (!ep2->dragable.x && !ep2->dragable.y)
333 {
334 prev->dragable.event_id = -1;
335 break;
336 }
337
338 if (eina_list_data_find(hist, ep2))
339 {
340 ERR("events_to loops. invalidating loop.");
341 ep2->dragable.event_id = -1;
342 break;
343 }
344 hist = eina_list_append(hist, ep2);
345 }
346 eina_list_free(hist);
347 hist = NULL;
348 hist = eina_list_append(hist, ep);
349 ep2 = ep;
350 while (ep2->clip_to_id >= 0)
351 {
352 if (ep2->clip_to_id >= (int) edc->parts_count)
353 {
354 ERR("clip_to_id above limit. invalidating it.");
355 ep2->clip_to_id = -1;
356 break;
357 }
358
359 ep2 = edc->parts[ep2->clip_to_id];
360 if (eina_list_data_find(hist, ep2))
361 {
362 ERR("clip_to loops. invalidating loop.");
363 ep2->clip_to_id = -1;
364 break;
365 }
366 hist = eina_list_append(hist, ep2);
367 }
368 eina_list_free(hist);
369 hist = NULL;
370 }
371 edc->checked = 1;
372 }
373 }
374 if (edc_ret) *edc_ret = edc;
375
376 return edf;
377}
378
379void
380_edje_cache_coll_clean(Edje_File *edf)
381{
382 while ((edf->collection_cache) &&
383 (eina_list_count(edf->collection_cache) > (unsigned int) _edje_collection_cache_size))
384 {
385 Edje_Part_Collection_Directory_Entry *ce;
386 Edje_Part_Collection *edc;
387
388 edc = eina_list_data_get(eina_list_last(edf->collection_cache));
389 edf->collection_cache = eina_list_remove_list(edf->collection_cache, eina_list_last(edf->collection_cache));
390
391 ce = eina_hash_find(edf->collection, edc->part);
392 _edje_collection_free(edf, edc, ce);
393 }
394}
395
396void
397_edje_cache_coll_flush(Edje_File *edf)
398{
399 while (edf->collection_cache)
400 {
401 Edje_Part_Collection_Directory_Entry *ce;
402 Edje_Part_Collection *edc;
403 Eina_List *last;
404
405 last = eina_list_last(edf->collection_cache);
406 edc = eina_list_data_get(last);
407 edf->collection_cache = eina_list_remove_list(edf->collection_cache,
408 last);
409
410 ce = eina_hash_find(edf->collection, edc->part);
411 _edje_collection_free(edf, edc, ce);
412 }
413}
414
415void
416_edje_cache_coll_unref(Edje_File *edf, Edje_Part_Collection *edc)
417{
418 Edje_Part_Collection_Directory_Entry *ce;
419
420 edc->references--;
421 if (edc->references != 0) return;
422
423 ce = eina_hash_find(edf->collection, edc->part);
424 if (!ce)
425 {
426 ERR("Something is wrong with reference count of '%s'.", edc->part);
427 }
428 else if (ce->ref)
429 {
430 ce->ref = NULL;
431
432 if (edf->dangling)
433 {
434 /* No need to keep the collection around if the file is dangling */
435 _edje_collection_free(edf, edc, ce);
436 _edje_cache_coll_flush(edf);
437 }
438 else
439 {
440 edf->collection_cache = eina_list_prepend(edf->collection_cache, edc);
441 _edje_cache_coll_clean(edf);
442 }
443 }
444}
445
446static void
447_edje_cache_file_clean(void)
448{
449 int count;
450
451 count = eina_list_count(_edje_file_cache);
452 while ((_edje_file_cache) && (count > _edje_file_cache_size))
453 {
454 Eina_List *last;
455 Edje_File *edf;
456
457 last = eina_list_last(_edje_file_cache);
458 edf = eina_list_data_get(last);
459 _edje_file_cache = eina_list_remove_list(_edje_file_cache, last);
460 _edje_file_free(edf);
461 count = eina_list_count(_edje_file_cache);
462 }
463}
464
465void
466_edje_cache_file_unref(Edje_File *edf)
467{
468 edf->references--;
469 if (edf->references != 0) return;
470
471 if (edf->dangling)
472 {
473 _edje_file_free(edf);
474 return;
475 }
476
477 eina_hash_del(_edje_file_hash, edf->path, edf);
478 if (!eina_hash_population(_edje_file_hash))
479 {
480 eina_hash_free(_edje_file_hash);
481 _edje_file_hash = NULL;
482 }
483 _edje_file_cache = eina_list_prepend(_edje_file_cache, edf);
484 _edje_cache_file_clean();
485}
486
487void
488_edje_file_cache_shutdown(void)
489{
490 edje_file_cache_flush();
491}
492
493
494
495/**
496 * @endcond
497 */
498
499/*============================================================================*
500 * Global *
501 *============================================================================*/
502
503/*============================================================================*
504 * API *
505 *============================================================================*/
506
507
508EAPI void
509edje_file_cache_set(int count)
510{
511 if (count < 0) count = 0;
512 _edje_file_cache_size = count;
513 _edje_cache_file_clean();
514}
515
516
517EAPI int
518edje_file_cache_get(void)
519{
520 return _edje_file_cache_size;
521}
522
523
524EAPI void
525edje_file_cache_flush(void)
526{
527 int ps;
528
529 ps = _edje_file_cache_size;
530 _edje_file_cache_size = 0;
531 _edje_cache_file_clean();
532 _edje_file_cache_size = ps;
533}
534
535
536EAPI void
537edje_collection_cache_set(int count)
538{
539 Eina_List *l;
540 Edje_File *edf;
541
542 if (count < 0) count = 0;
543 _edje_collection_cache_size = count;
544 EINA_LIST_FOREACH(_edje_file_cache, l, edf)
545 _edje_cache_coll_clean(edf);
546 /* FIXME: freach in file hash too! */
547}
548
549
550EAPI int
551edje_collection_cache_get(void)
552{
553 return _edje_collection_cache_size;
554}
555
556
557EAPI void
558edje_collection_cache_flush(void)
559{
560 int ps;
561 Eina_List *l;
562 Edje_File *edf;
563
564 ps = _edje_collection_cache_size;
565 _edje_collection_cache_size = 0;
566 EINA_LIST_FOREACH(_edje_file_cache, l, edf)
567 _edje_cache_coll_flush(edf);
568 /* FIXME: freach in file hash too! */
569 _edje_collection_cache_size = ps;
570}
diff --git a/libraries/edje/src/lib/edje_calc.c b/libraries/edje/src/lib/edje_calc.c
new file mode 100644
index 0000000..d9fd51d
--- /dev/null
+++ b/libraries/edje/src/lib/edje_calc.c
@@ -0,0 +1,2801 @@
1#include "edje_private.h"
2
3static void _edje_part_make_rtl(Edje_Part_Description_Common *desc);
4static Edje_Part_Description_Common *_edje_get_description_by_orientation(Edje *ed, Edje_Part_Description_Common *src, Edje_Part_Description_Common **dst, unsigned char type);
5
6static void _edje_part_recalc_single(Edje *ed, Edje_Real_Part *ep,
7 Edje_Part_Description_Common *desc, Edje_Part_Description_Common *chosen_desc,
8 Edje_Real_Part *center, Edje_Real_Part *light, Edje_Real_Part *persp,
9 Edje_Real_Part *rel1_to_x, Edje_Real_Part *rel1_to_y,
10 Edje_Real_Part *rel2_to_x, Edje_Real_Part *rel2_to_y,
11 Edje_Real_Part *confine_to, Edje_Calc_Params *params);
12
13void
14_edje_part_pos_set(Edje *ed, Edje_Real_Part *ep, int mode, FLOAT_T pos, FLOAT_T v1, FLOAT_T v2)
15{
16 FLOAT_T fp_pos;
17 FLOAT_T npos;
18
19 pos = CLAMP(pos, ZERO, FROM_INT(1));
20
21 fp_pos = pos;
22
23 npos = ZERO;
24#if 0 // old code - easy to enable for comparing float vs fixed point
25 /* take linear pos along timescale and use interpolation method */
26 switch (mode)
27 {
28 case EDJE_TWEEN_MODE_SINUSOIDAL:
29 /* npos = (1.0 - cos(pos * PI)) / 2.0; */
30 npos = DIV2(SUB(FROM_INT(1),
31 COS(MUL(fp_pos,
32 PI))));
33 break;
34 case EDJE_TWEEN_MODE_ACCELERATE:
35 /* npos = 1.0 - sin((PI / 2.0) + (pos * PI / 2.0)); */
36 npos = SUB(FROM_INT(1),
37 SIN(ADD(DIV2(PI),
38 MUL(fp_pos,
39 DIV2(PI)))));
40 break;
41 case EDJE_TWEEN_MODE_DECELERATE:
42 /* npos = sin(pos * PI / 2.0); */
43 npos = SIN(MUL(fp_pos,
44 DIV2(PI)));
45 break;
46 case EDJE_TWEEN_MODE_LINEAR:
47 npos = fp_pos;
48 break;
49 default:
50 npos = fp_pos;
51 break;
52 }
53#else
54 switch (mode & EDJE_TWEEN_MODE_MASK)
55 {
56 case EDJE_TWEEN_MODE_SINUSOIDAL:
57 npos = FROM_DOUBLE(ecore_animator_pos_map(TO_DOUBLE(pos),
58 ECORE_POS_MAP_SINUSOIDAL,
59 0.0, 0.0));
60 break;
61 case EDJE_TWEEN_MODE_ACCELERATE:
62 npos = FROM_DOUBLE(ecore_animator_pos_map(TO_DOUBLE(pos),
63 ECORE_POS_MAP_ACCELERATE,
64 0.0, 0.0));
65 break;
66 case EDJE_TWEEN_MODE_DECELERATE:
67 npos = FROM_DOUBLE(ecore_animator_pos_map(TO_DOUBLE(pos),
68 ECORE_POS_MAP_DECELERATE,
69 0.0, 0.0));
70 break;
71 case EDJE_TWEEN_MODE_LINEAR:
72 npos = fp_pos;
73/* npos = FROM_DOUBLE(ecore_animator_pos_map(TO_DOUBLE(pos),
74 ECORE_POS_MAP_LINEAR,
75 0.0, 0.0));
76 */
77 break;
78 case EDJE_TWEEN_MODE_ACCELERATE_FACTOR:
79 npos = FROM_DOUBLE(ecore_animator_pos_map(TO_DOUBLE(pos),
80 ECORE_POS_MAP_ACCELERATE_FACTOR,
81 TO_DOUBLE(v1), 0.0));
82 break;
83 case EDJE_TWEEN_MODE_DECELERATE_FACTOR:
84 npos = FROM_DOUBLE(ecore_animator_pos_map(TO_DOUBLE(pos),
85 ECORE_POS_MAP_DECELERATE_FACTOR,
86 TO_DOUBLE(v1), 0.0));
87 break;
88 case EDJE_TWEEN_MODE_SINUSOIDAL_FACTOR:
89 npos = FROM_DOUBLE(ecore_animator_pos_map(TO_DOUBLE(pos),
90 ECORE_POS_MAP_SINUSOIDAL_FACTOR,
91 TO_DOUBLE(v1), 0.0));
92 break;
93 case EDJE_TWEEN_MODE_DIVISOR_INTERP:
94 npos = FROM_DOUBLE(ecore_animator_pos_map(TO_DOUBLE(pos),
95 ECORE_POS_MAP_DIVISOR_INTERP,
96 TO_DOUBLE(v1), TO_DOUBLE(v2)));
97 break;
98 case EDJE_TWEEN_MODE_BOUNCE:
99 npos = FROM_DOUBLE(ecore_animator_pos_map(TO_DOUBLE(pos),
100 ECORE_POS_MAP_BOUNCE,
101 TO_DOUBLE(v1), TO_DOUBLE(v2)));
102 break;
103 case EDJE_TWEEN_MODE_SPRING:
104 npos = FROM_DOUBLE(ecore_animator_pos_map(TO_DOUBLE(pos),
105 ECORE_POS_MAP_SPRING,
106 TO_DOUBLE(v1), TO_DOUBLE(v2)));
107 break;
108 default:
109 npos = fp_pos;
110 break;
111 }
112#endif
113 if (npos == ep->description_pos) return;
114
115 ep->description_pos = npos;
116
117 ed->dirty = 1;
118#ifdef EDJE_CALC_CACHE
119 ep->invalidate = 1;
120#endif
121}
122
123
124/**
125 * Returns part description
126 *
127 * @internal
128 *
129 * Converts part description to RTL-desc.
130 *
131 * @param desc Pointer to desc buffer.
132 *
133 **/
134static void
135_edje_part_make_rtl(Edje_Part_Description_Common *desc)
136{
137 double t;
138 int i;
139
140 if(!desc)
141 return;
142
143 /* This makes alignment right-oriented */
144 desc->align.x = 1.0 - desc->align.x;
145
146 /* same as above for relative components */
147 t = desc->rel1.relative_x;
148 desc->rel1.relative_x = 1.0 - desc->rel2.relative_x;
149 desc->rel2.relative_x = 1.0 - t;
150
151 /* +1 and +1 are because how edje works with right
152 * side borders - nothing is printed beyond that limit
153 *
154 * rel2 is now to the left of rel1, and Edje assumes
155 * the opposite so we switch corners on x-axis to define
156 * offset from right to left */
157 i = desc->rel1.offset_x;
158 desc->rel1.offset_x = -(desc->rel2.offset_x + 1);
159 desc->rel2.offset_x = -(i + 1);
160
161 i = desc->rel1.id_x;
162 desc->rel1.id_x = desc->rel2.id_x;
163 desc->rel2.id_x = i;
164}
165
166/**
167 * Returns part description
168 *
169 * @internal
170 *
171 * Returns part description according to object orientation.
172 * When object is in RTL-orientation (RTL flag is set)
173 * this returns the RTL-desc of it.
174 * RTL-desc would be allocated if was not created by a previous call.
175 * The dst pointer is updated in case of an allocation.
176 *
177 * @param ed Edje object.
178 * @param src The Left To Right (LTR), original desc.
179 * @param dst Pointer to Right To Left (RTL) desc-list.
180 * @param type name of dec type. Example: "default".
181 *
182 * @return Edje part description.
183 *
184 **/
185static Edje_Part_Description_Common *
186_edje_get_description_by_orientation(Edje *ed, Edje_Part_Description_Common *src, Edje_Part_Description_Common **dst, unsigned char type)
187{
188 Edje_Part_Description_Common *desc_rtl = NULL;
189 Edje_Part_Collection_Directory_Entry *ce;
190 size_t memsize = 0;
191
192 /* RTL flag is not set, return original description */
193 if(!edje_object_mirrored_get(ed->obj))
194 return src;
195
196 if(*dst)
197 return *dst; /* Was allocated before and we should use it */
198
199#define EDIT_ALLOC_POOL_RTL(Short, Type, Name) \
200 case EDJE_PART_TYPE_##Short: \
201 { \
202 Edje_Part_Description_##Type *Name; \
203 Name = eina_mempool_malloc(ce->mp_rtl.Short, \
204 sizeof (Edje_Part_Description_##Type)); \
205 memset(Name, 0, sizeof(Edje_Part_Description_##Type)); \
206 desc_rtl = &Name->common; \
207 memsize = sizeof(Edje_Part_Description_##Type); \
208 break; \
209 }
210
211 ce = eina_hash_find(ed->file->collection, ed->group);
212
213 switch (type)
214 {
215 case EDJE_PART_TYPE_RECTANGLE:
216 desc_rtl = eina_mempool_malloc(ce->mp_rtl.RECTANGLE,
217 sizeof (Edje_Part_Description_Common));
218 ce->count.RECTANGLE++;
219 memsize = sizeof(Edje_Part_Description_Common);
220 break;
221 case EDJE_PART_TYPE_SWALLOW:
222 desc_rtl = eina_mempool_malloc(ce->mp_rtl.SWALLOW,
223 sizeof (Edje_Part_Description_Common));
224 ce->count.SWALLOW++;
225 memsize = sizeof(Edje_Part_Description_Common);
226 break;
227 case EDJE_PART_TYPE_GROUP:
228 desc_rtl = eina_mempool_malloc(ce->mp_rtl.GROUP,
229 sizeof (Edje_Part_Description_Common));
230 ce->count.GROUP++;
231 memsize = sizeof(Edje_Part_Description_Common);
232 break;
233 EDIT_ALLOC_POOL_RTL(TEXT, Text, text);
234 EDIT_ALLOC_POOL_RTL(TEXTBLOCK, Text, text);
235 EDIT_ALLOC_POOL_RTL(IMAGE, Image, image);
236 EDIT_ALLOC_POOL_RTL(PROXY, Proxy, proxy);
237 EDIT_ALLOC_POOL_RTL(BOX, Box, box);
238 EDIT_ALLOC_POOL_RTL(TABLE, Table, table);
239 EDIT_ALLOC_POOL_RTL(EXTERNAL, External, external_params);
240 }
241
242 if(desc_rtl)
243 memcpy(desc_rtl, src, memsize);
244
245 _edje_part_make_rtl(desc_rtl);
246
247 *dst = desc_rtl;
248 return desc_rtl;
249}
250
251Edje_Part_Description_Common *
252_edje_part_description_find(Edje *ed, Edje_Real_Part *rp, const char *name,
253 double val)
254{
255 Edje_Part *ep = rp->part;
256 Edje_Part_Description_Common *ret = NULL;
257 Edje_Part_Description_Common *d;
258
259 double min_dst = 99999.0;
260 unsigned int i;
261
262 /* RTL flag is set, return RTL description */
263 if(edje_object_mirrored_get(ed->obj))
264 if(!ep->other.desc_rtl)
265 ep->other.desc_rtl = (Edje_Part_Description_Common **)
266 calloc(ep->other.desc_count,
267 sizeof (Edje_Part_Description_Common *));
268
269 if (!strcmp(name, "default") && val == 0.0)
270 return _edje_get_description_by_orientation(ed,
271 ep->default_desc, &ep->default_desc_rtl, ep->type);
272
273 if (!strcmp(name, "custom"))
274 return rp->custom ?
275 _edje_get_description_by_orientation(ed, rp->custom->description,
276 &rp->custom->description_rtl, ep->type) : NULL;
277
278 if (!strcmp(name, "default"))
279 {
280 ret = _edje_get_description_by_orientation(ed, ep->default_desc,
281 &ep->default_desc_rtl, ep->type);
282
283 min_dst = ABS(ep->default_desc->state.value - val);
284 }
285
286 for (i = 0; i < ep->other.desc_count; ++i)
287 {
288 d = ep->other.desc[i];
289
290 if (d->state.name && (d->state.name == name || !strcmp(d->state.name, name)))
291 {
292 double dst;
293
294 dst = ABS(d->state.value - val);
295 if (dst < min_dst)
296 {
297 ret = _edje_get_description_by_orientation(ed, d,
298 &ep->other.desc_rtl[i], ep->type);
299 min_dst = dst;
300 }
301 }
302 }
303
304 return ret;
305}
306
307static void
308_edje_real_part_rel_to_apply(Edje *ed, Edje_Real_Part *ep, Edje_Real_Part_State *state)
309{
310 state->rel1_to_x = state->rel1_to_y = NULL;
311 state->rel2_to_x = state->rel2_to_y = NULL;
312
313 if (state->description)
314 {
315 if (state->description->rel1.id_x >= 0)
316 state->rel1_to_x = ed->table_parts[state->description->rel1.id_x % ed->table_parts_size];
317 if (state->description->rel1.id_y >= 0)
318 state->rel1_to_y = ed->table_parts[state->description->rel1.id_y % ed->table_parts_size];
319 if (state->description->rel2.id_x >= 0)
320 state->rel2_to_x = ed->table_parts[state->description->rel2.id_x % ed->table_parts_size];
321 if (state->description->rel2.id_y >= 0)
322 state->rel2_to_y = ed->table_parts[state->description->rel2.id_y % ed->table_parts_size];
323
324 if (ep->part->type == EDJE_PART_TYPE_EXTERNAL)
325 {
326 Edje_Part_Description_External *external;
327
328 external = (Edje_Part_Description_External*) state->description;
329
330 if (state->external_params)
331 _edje_external_parsed_params_free(ep->swallowed_object, state->external_params);
332 state->external_params = _edje_external_params_parse(ep->swallowed_object, external->external_params);
333 }
334 }
335}
336
337void
338_edje_part_description_apply(Edje *ed, Edje_Real_Part *ep, const char *d1, double v1, const char *d2, double v2)
339{
340 Edje_Part_Description_Common *epd1;
341 Edje_Part_Description_Common *epd2 = NULL;
342 Edje_Part_Description_Common *chosen_desc;
343
344 Edje_Part_Description_Image *epdi;
345
346 if (!d1) d1 = "default";
347
348 epd1 = _edje_part_description_find(ed, ep, d1, v1);
349 if (!epd1)
350 epd1 = ep->part->default_desc; /* never NULL */
351
352 if (d2)
353 epd2 = _edje_part_description_find(ed, ep, d2, v2);
354
355 epdi = (Edje_Part_Description_Image*) epd2;
356
357 /* There is an animation if both description are different or if description is an image with tweens */
358 if (epd2 && (epd1 != epd2 || (ep->part->type == EDJE_PART_TYPE_IMAGE && epdi->image.tweens_count)))
359 {
360 if (!ep->param2)
361 {
362 ep->param2 = eina_mempool_malloc(_edje_real_part_state_mp, sizeof (Edje_Real_Part_State));
363 memset(ep->param2, 0, sizeof (Edje_Real_Part_State));
364 }
365 else if (ep->part->type == EDJE_PART_TYPE_EXTERNAL)
366 _edje_external_parsed_params_free(ep->swallowed_object, ep->param2->external_params);
367 ep->param2->external_params = NULL;
368 }
369 else
370 if (ep->param2)
371 {
372 if (ep->part->type == EDJE_PART_TYPE_EXTERNAL)
373 _edje_external_parsed_params_free(ep->swallowed_object, ep->param2->external_params);
374 if (ep->param2)
375 free(ep->param2->set);
376 eina_mempool_free(_edje_real_part_state_mp, ep->param2);
377 ep->param2 = NULL;
378 }
379
380 chosen_desc = ep->chosen_description;
381 ep->param1.description = epd1;
382 ep->chosen_description = epd1;
383
384 _edje_real_part_rel_to_apply(ed, ep, &ep->param1);
385
386 if (ep->param2)
387 {
388 ep->param2->description = epd2;
389
390 _edje_real_part_rel_to_apply(ed, ep, ep->param2);
391
392 if (ep->description_pos != 0.0)
393 ep->chosen_description = epd2;
394 }
395
396 if (chosen_desc != ep->chosen_description &&
397 ep->part->type == EDJE_PART_TYPE_EXTERNAL)
398 _edje_external_recalc_apply(ed, ep, NULL, chosen_desc);
399
400 ed->dirty = 1;
401#ifdef EDJE_CALC_CACHE
402 ep->invalidate = 1;
403#endif
404}
405
406void
407_edje_recalc(Edje *ed)
408{
409 if ((ed->freeze > 0) || (_edje_freeze_val > 0))
410 {
411 ed->recalc = 1;
412 if (!ed->calc_only)
413 {
414 if (_edje_freeze_val > 0)
415 {
416 if (!ed->freeze_calc)
417 {
418 _edje_freeze_calc_count++;
419 _edje_freeze_calc_list = eina_list_append(_edje_freeze_calc_list, ed);
420 ed->freeze_calc = 1;
421 }
422 }
423 return;
424 }
425 }
426 if (ed->postponed) return;
427 evas_object_smart_changed(ed->obj);
428 ed->postponed = 1;
429}
430
431void
432_edje_recalc_do(Edje *ed)
433{
434 unsigned int i;
435
436 ed->postponed = 0;
437 evas_object_smart_need_recalculate_set(ed->obj, 0);
438 if (!ed->dirty) return;
439 ed->have_mapped_part = 0;
440 ed->dirty = 0;
441 ed->state++;
442 for (i = 0; i < ed->table_parts_size; i++)
443 {
444 Edje_Real_Part *ep;
445
446 ep = ed->table_parts[i];
447 ep->calculated = FLAG_NONE;
448 ep->calculating = FLAG_NONE;
449 }
450 for (i = 0; i < ed->table_parts_size; i++)
451 {
452 Edje_Real_Part *ep;
453
454 ep = ed->table_parts[i];
455 if (ep->calculated != FLAG_XY)
456 _edje_part_recalc(ed, ep, (~ep->calculated) & FLAG_XY, NULL);
457 }
458 if (!ed->calc_only) ed->recalc = 0;
459#ifdef EDJE_CALC_CACHE
460 ed->all_part_change = 0;
461 ed->text_part_change = 0;
462#endif
463}
464
465void
466_edje_part_recalc_1(Edje *ed, Edje_Real_Part *ep)
467{
468 _edje_part_recalc(ed, ep, FLAG_XY, NULL);
469}
470
471int
472_edje_part_dragable_calc(Edje *ed __UNUSED__, Edje_Real_Part *ep, FLOAT_T *x, FLOAT_T *y)
473{
474 if (ep->drag)
475 {
476 if (ep->drag->confine_to)
477 {
478 FLOAT_T dx, dy, dw, dh;
479 int ret = 0;
480
481 if ((ep->part->dragable.x != 0) &&
482 (ep->part->dragable.y != 0 )) ret = 3;
483 else if (ep->part->dragable.x != 0) ret = 1;
484 else if (ep->part->dragable.y != 0) ret = 2;
485
486 dx = FROM_INT(ep->x - ep->drag->confine_to->x);
487 dw = FROM_INT(ep->drag->confine_to->w - ep->w);
488 if (dw != ZERO) dx = DIV(dx, dw);
489 else dx = ZERO;
490
491 dy = FROM_INT(ep->y - ep->drag->confine_to->y);
492 dh = FROM_INT(ep->drag->confine_to->h - ep->h);
493 if (dh != ZERO) dy = DIV(dy, dh);
494 else dy = ZERO;
495
496 if (x) *x = dx;
497 if (y) *y = dy;
498
499 return ret;
500 }
501 else
502 {
503 if (x) *x = ADD(FROM_INT(ep->drag->tmp.x), ep->drag->x);
504 if (y) *y = ADD(FROM_INT(ep->drag->tmp.y), ep->drag->y);
505 return 0;
506 }
507 }
508 if (x) *x = ZERO;
509 if (y) *y = ZERO;
510 return 0;
511}
512
513void
514_edje_dragable_pos_set(Edje *ed, Edje_Real_Part *ep, FLOAT_T x, FLOAT_T y)
515{
516 /* check whether this part is dragable at all */
517 if (!ep->drag) return ;
518
519 /* instead of checking for equality, we really should check that
520 * the difference is greater than foo, but I have no idea what
521 * value we would set foo to, because it would depend on the
522 * size of the dragable...
523 */
524 if (ep->drag->x != x || ep->drag->tmp.x)
525 {
526 ep->drag->x = x;
527 ep->drag->tmp.x = 0;
528 ep->drag->need_reset = 0;
529 ed->dirty = 1;
530 }
531
532 if (ep->drag->y != y || ep->drag->tmp.y)
533 {
534 ep->drag->y = y;
535 ep->drag->tmp.y = 0;
536 ep->drag->need_reset = 0;
537 ed->dirty = 1;
538 }
539
540#ifdef EDJE_CALC_CACHE
541 ep->invalidate = 1;
542#endif
543 _edje_recalc(ed); /* won't do anything if dirty flag isn't set */
544}
545
546static void
547_edje_part_recalc_single_rel(Edje *ed,
548 Edje_Real_Part *ep __UNUSED__,
549 Edje_Part_Description_Common *desc,
550 Edje_Real_Part *rel1_to_x,
551 Edje_Real_Part *rel1_to_y,
552 Edje_Real_Part *rel2_to_x,
553 Edje_Real_Part *rel2_to_y,
554 Edje_Calc_Params *params)
555{
556 FLOAT_T x, w;
557 FLOAT_T y, h;
558
559 if (rel1_to_x)
560 x = ADD(FROM_INT(desc->rel1.offset_x + rel1_to_x->x),
561 SCALE(desc->rel1.relative_x, rel1_to_x->w));
562 else
563 x = ADD(FROM_INT(desc->rel1.offset_x),
564 SCALE(desc->rel1.relative_x, ed->w));
565 params->x = TO_INT(x);
566
567 if (rel2_to_x)
568 w = ADD(SUB(ADD(FROM_INT(desc->rel2.offset_x + rel2_to_x->x),
569 SCALE(desc->rel2.relative_x, rel2_to_x->w)),
570 x),
571 FROM_INT(1));
572 else
573 w = ADD(SUB(ADD(FROM_INT(desc->rel2.offset_x),
574 SCALE(desc->rel2.relative_x, ed->w)),
575 x),
576 FROM_INT(1));
577 params->w = TO_INT(w);
578
579 if (rel1_to_y)
580 y = ADD(FROM_INT(desc->rel1.offset_y + rel1_to_y->y),
581 SCALE(desc->rel1.relative_y, rel1_to_y->h));
582 else
583 y = ADD(FROM_INT(desc->rel1.offset_y),
584 SCALE(desc->rel1.relative_y, ed->h));
585 params->y = TO_INT(y);
586
587 if (rel2_to_y)
588 h = ADD(SUB(ADD(FROM_INT(desc->rel2.offset_y + rel2_to_y->y),
589 SCALE(desc->rel2.relative_y, rel2_to_y->h)),
590 y),
591 FROM_INT(1));
592 else
593 h = ADD(SUB(ADD(FROM_INT(desc->rel2.offset_y),
594 SCALE(desc->rel2.relative_y, ed->h)),
595 y),
596 FROM_INT(1));
597 params->h = TO_INT(h);
598}
599
600static Edje_Internal_Aspect
601_edje_part_recalc_single_aspect(Edje_Real_Part *ep,
602 Edje_Part_Description_Common *desc,
603 Edje_Calc_Params *params,
604 int *minw, int *minh,
605 int *maxw, int *maxh)
606{
607 Edje_Internal_Aspect apref = EDJE_ASPECT_PREFER_NONE;
608 FLOAT_T aspect, amax, amin;
609 FLOAT_T new_w = ZERO, new_h = ZERO, want_x, want_y, want_w, want_h;
610
611 if (params->h <= ZERO) aspect = FROM_INT(999999);
612 else aspect = DIV(FROM_INT(params->w), FROM_INT(params->h));
613 amax = desc->aspect.max;
614 amin = desc->aspect.min;
615 if ((ep->swallow_params.aspect.w > 0) &&
616 (ep->swallow_params.aspect.h > 0))
617 amin = amax =
618 DIV(FROM_INT(ep->swallow_params.aspect.w),
619 FROM_INT(ep->swallow_params.aspect.h));
620 want_x = FROM_INT(params->x);
621 want_w = new_w = FROM_INT(params->w);
622
623 want_y = FROM_INT(params->y);
624 want_h = new_h = FROM_INT(params->h);
625
626 if ((amin > ZERO) && (amax > ZERO))
627 {
628 apref = desc->aspect.prefer;
629 if (ep->swallow_params.aspect.mode > EDJE_ASPECT_CONTROL_NONE)
630 {
631 switch (ep->swallow_params.aspect.mode)
632 {
633 case EDJE_ASPECT_CONTROL_NEITHER:
634 apref = EDJE_ASPECT_PREFER_NONE;
635 break;
636 case EDJE_ASPECT_CONTROL_HORIZONTAL:
637 apref = EDJE_ASPECT_PREFER_HORIZONTAL;
638 break;
639 case EDJE_ASPECT_CONTROL_VERTICAL:
640 apref = EDJE_ASPECT_PREFER_VERTICAL;
641 break;
642 case EDJE_ASPECT_CONTROL_BOTH:
643 apref = EDJE_ASPECT_PREFER_BOTH;
644 break;
645 default:
646 break;
647 }
648 }
649 switch (apref)
650 {
651 case EDJE_ASPECT_PREFER_NONE:
652 /* keep both dimensions in check */
653 /* adjust for min aspect (width / height) */
654 if ((amin > ZERO) && (aspect < amin))
655 {
656 new_h = DIV(FROM_INT(params->w), amin);
657 new_w = SCALE(amin, params->h);
658 }
659 /* adjust for max aspect (width / height) */
660 if ((amax > ZERO) && (aspect > amax))
661 {
662 new_h = DIV(FROM_INT(params->w), amax);
663 new_w = SCALE(amax, params->h);
664 }
665 if ((amax > ZERO) && (new_w < FROM_INT(params->w)))
666 {
667 new_w = FROM_INT(params->w);
668 new_h = DIV(FROM_INT(params->w), amax);
669 }
670 if ((amax > ZERO) && (new_h < FROM_INT(params->h)))
671 {
672 new_w = SCALE(amax, params->h);
673 new_h = FROM_INT(params->h);
674 }
675 break;
676 /* prefer vertical size as determiner */
677 case EDJE_ASPECT_PREFER_VERTICAL:
678 /* keep both dimensions in check */
679 /* adjust for max aspect (width / height) */
680 if ((amax > ZERO) && (aspect > amax))
681 new_w = SCALE(amax, params->h);
682 /* adjust for min aspect (width / height) */
683 if ((amin > ZERO) && (aspect < amin))
684 new_w = SCALE(amin, params->h);
685 break;
686 /* prefer horizontal size as determiner */
687 case EDJE_ASPECT_PREFER_HORIZONTAL:
688 /* keep both dimensions in check */
689 /* adjust for max aspect (width / height) */
690 if ((amax > ZERO) && (aspect > amax))
691 new_h = DIV(FROM_INT(params->w), amax);
692 /* adjust for min aspect (width / height) */
693 if ((amin > ZERO) && (aspect < amin))
694 new_h = DIV(FROM_INT(params->w), amin);
695 break;
696 case EDJE_ASPECT_PREFER_BOTH:
697 /* keep both dimensions in check */
698 /* adjust for max aspect (width / height) */
699 if ((amax > ZERO) && (aspect > amax))
700 {
701 new_w = SCALE(amax, params->h);
702 new_h = DIV(FROM_INT(params->w), amax);
703 }
704 /* adjust for min aspect (width / height) */
705 if ((amin > ZERO) && (aspect < amin))
706 {
707 new_w = SCALE(amin, params->h);
708 new_h = DIV(FROM_INT(params->w), amin);
709 }
710 break;
711 default:
712 break;
713 }
714
715 if (!((amin > ZERO) && (amax > ZERO) && (apref == EDJE_ASPECT_PREFER_NONE)))
716 {
717 if ((*maxw >= 0) && (new_w > FROM_INT(*maxw)))
718 new_w = FROM_INT(*maxw);
719 if (new_w < FROM_INT(*minw))
720 new_w = FROM_INT(*minw);
721
722 if ((FROM_INT(*maxh) >= 0) && (new_h > FROM_INT(*maxh)))
723 new_h = FROM_INT(*maxh);
724 if (new_h < FROM_INT(*minh))
725 new_h = FROM_INT(*minh);
726 }
727
728 /* do real adjustment */
729 if (apref == EDJE_ASPECT_PREFER_BOTH)
730 {
731 if (amin == ZERO) amin = amax;
732 if (amin != ZERO)
733 {
734 /* fix h and vary w */
735 if (new_w > FROM_INT(params->w))
736 {
737 // params->w = new_w;
738 // EXCEEDS BOUNDS in W
739 new_h = DIV(FROM_INT(params->w), amin);
740 new_w = FROM_INT(params->w);
741 if (new_h > FROM_INT(params->h))
742 {
743 new_h = FROM_INT(params->h);
744 new_w = SCALE(amin, params->h);
745 }
746 }
747 /* fix w and vary h */
748 else
749 {
750 // params->h = new_h;
751 // EXCEEDS BOUNDS in H
752 new_h = FROM_INT(params->h);
753 new_w = SCALE(amin, params->h);
754 if (new_w > FROM_INT(params->w))
755 {
756 new_h = DIV(FROM_INT(params->w), amin);
757 new_w = FROM_INT(params->w);
758 }
759 }
760 params->w = TO_INT(new_w);
761 params->h = TO_INT(new_h);
762 }
763 }
764 }
765 if (apref != EDJE_ASPECT_PREFER_BOTH)
766 {
767 if ((amin > 0.0) && (amax > ZERO) && (apref == EDJE_ASPECT_PREFER_NONE))
768 {
769 params->w = TO_INT(new_w);
770 params->h = TO_INT(new_h);
771 }
772 else if ((FROM_INT(params->h) - new_h) > (FROM_INT(params->w) - new_w))
773 {
774 if (params->h < TO_INT(new_h))
775 params->h = TO_INT(new_h);
776 else if (params->h > TO_INT(new_h))
777 params->h = TO_INT(new_h);
778 if (apref == EDJE_ASPECT_PREFER_VERTICAL)
779 params->w = TO_INT(new_w);
780 }
781 else
782 {
783 if (params->w < TO_INT(new_w))
784 params->w = TO_INT(new_w);
785 else if (params->w > TO_INT(new_w))
786 params->w = TO_INT(new_w);
787 if (apref == EDJE_ASPECT_PREFER_HORIZONTAL)
788 params->h = TO_INT(new_h);
789 }
790 }
791 params->x = TO_INT(ADD(want_x,
792 MUL(SUB(want_w, FROM_INT(params->w)),
793 desc->align.x)));
794 params->y = TO_INT(ADD(want_y,
795 MUL(SUB(want_h, FROM_INT(params->h)),
796 desc->align.y)));
797 return apref;
798}
799
800static void
801_edje_part_recalc_single_step(Edje_Part_Description_Common *desc,
802 Edje_Calc_Params *params)
803{
804 if (desc->step.x > 0)
805 {
806 int steps;
807 int new_w;
808
809 steps = params->w / desc->step.x;
810 new_w = desc->step.x * steps;
811 if (params->w > new_w)
812 {
813 params->x += TO_INT(SCALE(desc->align.x, (params->w - new_w)));
814 params->w = new_w;
815 }
816 }
817
818 if (desc->step.y > 0)
819 {
820 int steps;
821 int new_h;
822
823 steps = params->h / desc->step.y;
824 new_h = desc->step.y * steps;
825 if (params->h > new_h)
826 {
827 params->y += TO_INT(SCALE(desc->align.y, (params->h - new_h)));
828 params->h = new_h;
829 }
830 }
831}
832
833static void
834_edje_part_recalc_single_textblock(FLOAT_T sc,
835 Edje *ed,
836 Edje_Real_Part *ep,
837 Edje_Part_Description_Text *chosen_desc,
838 Edje_Calc_Params *params,
839 int *minw, int *minh,
840 int *maxw, int *maxh)
841{
842 if (chosen_desc)
843 {
844 Evas_Coord tw, th, ins_l, ins_r, ins_t, ins_b;
845 const char *text = "";
846 const char *style = "";
847 Edje_Style *stl = NULL;
848 const char *tmp;
849 Eina_List *l;
850
851 if (chosen_desc->text.id_source >= 0)
852 {
853 ep->text.source = ed->table_parts[chosen_desc->text.id_source % ed->table_parts_size];
854
855 tmp = edje_string_get(&((Edje_Part_Description_Text *)ep->text.source->chosen_description)->text.style);
856 if (tmp) style = tmp;
857 }
858 else
859 {
860 ep->text.source = NULL;
861
862 tmp = edje_string_get(&chosen_desc->text.style);
863 if (tmp) style = tmp;
864 }
865
866 if (chosen_desc->text.id_text_source >= 0)
867 {
868 ep->text.text_source = ed->table_parts[chosen_desc->text.id_text_source % ed->table_parts_size];
869 text = edje_string_get(&((Edje_Part_Description_Text*)ep->text.text_source->chosen_description)->text.text);
870
871 if (ep->text.text_source->text.text) text = ep->text.text_source->text.text;
872 }
873 else
874 {
875 ep->text.text_source = NULL;
876 text = edje_string_get(&chosen_desc->text.text);
877 if (ep->text.text) text = ep->text.text;
878 }
879
880 EINA_LIST_FOREACH(ed->file->styles, l, stl)
881 {
882 if ((stl->name) && (!strcmp(stl->name, style))) break;
883 stl = NULL;
884 }
885
886 if (ep->part->scale)
887 evas_object_scale_set(ep->object, TO_DOUBLE(sc));
888
889 if (stl)
890 {
891 const char *ptxt;
892
893 if (evas_object_textblock_style_get(ep->object) != stl->style)
894 evas_object_textblock_style_set(ep->object, stl->style);
895 // FIXME: need to account for editing
896 if (ep->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
897 {
898 // do nothing - should be done elsewhere
899 }
900 else
901 {
902 ptxt = evas_object_textblock_text_markup_get(ep->object);
903 if (((!ptxt) && (text)) ||
904 ((ptxt) && (text) && (strcmp(ptxt, text))) ||
905 ((ptxt) && (!text)))
906 evas_object_textblock_text_markup_set(ep->object, text);
907 }
908 if ((chosen_desc->text.min_x) || (chosen_desc->text.min_y))
909 {
910 int mw = 0, mh = 0;
911
912 tw = th = 0;
913 if (!chosen_desc->text.min_x)
914 {
915 evas_object_resize(ep->object, params->w, params->h);
916 evas_object_textblock_size_formatted_get(ep->object, &tw, &th);
917 }
918 else
919 evas_object_textblock_size_native_get(ep->object, &tw, &th);
920 evas_object_textblock_style_insets_get(ep->object, &ins_l, &ins_r, &ins_t, &ins_b);
921 mw = ins_l + tw + ins_r;
922 mh = ins_t + th + ins_b;
923 if (chosen_desc->text.min_x)
924 {
925 if (mw > *minw) *minw = mw;
926 }
927 if (chosen_desc->text.min_y)
928 {
929 if (mh > *minh) *minh = mh;
930 }
931 }
932 }
933 if ((chosen_desc->text.max_x) || (chosen_desc->text.max_y))
934 {
935 int mw = 0, mh = 0;
936
937 tw = th = 0;
938 if (!chosen_desc->text.max_x)
939 {
940 evas_object_resize(ep->object, params->w, params->h);
941 evas_object_textblock_size_formatted_get(ep->object, &tw, &th);
942 }
943 else
944 evas_object_textblock_size_native_get(ep->object, &tw, &th);
945 evas_object_textblock_style_insets_get(ep->object, &ins_l, &ins_r, &ins_t, &ins_b);
946 mw = ins_l + tw + ins_r;
947 mh = ins_t + th + ins_b;
948 if (chosen_desc->text.max_x)
949 {
950 if (mw > *maxw) *maxw = mw;
951 if (*maxw < *minw) *maxw = *minw;
952 }
953 if (chosen_desc->text.max_y)
954 {
955 if (mh > *maxw) *maxh = mh;
956 if (*maxh < *minh) *maxh = *minh;
957 }
958 }
959 evas_object_textblock_valign_set(ep->object, chosen_desc->text.align.y);
960 }
961}
962
963static void
964_edje_part_recalc_single_text(FLOAT_T sc __UNUSED__,
965 Edje *ed,
966 Edje_Real_Part *ep,
967 Edje_Part_Description_Text *desc,
968 Edje_Part_Description_Text *chosen_desc,
969 Edje_Calc_Params *params,
970 int *minw, int *minh,
971 int *maxw, int *maxh)
972#define RECALC_SINGLE_TEXT_USING_APPLY 1
973#if RECALC_SINGLE_TEXT_USING_APPLY
974/*
975 * XXX TODO NOTE:
976 *
977 * Original _edje_part_recalc_single_text() was not working as
978 * expected since it was not doing size fit, range, ellipsis and so
979 * on.
980 *
981 * The purpose of this function compared with
982 * _edje_text_recalc_apply() is to be faster, not calling Evas update
983 * functions. However for text this is quite difficult given that to
984 * fit we need to set the font, size, style, etc. If it was done
985 * correctly, we'd save some calls to move and some color sets,
986 * however those shouldn't matter much in the overall picture.
987 *
988 * I've changed this to force applying the value, it should be more
989 * correct and not so slow. The previous code is kept below for
990 * reference but should be removed before next release!
991 *
992 * -- Gustavo Barbieri at 20-Aug-2011
993 */
994{
995 int tw, th, mw, mh, l, r, t, b, size;
996 char *sfont = NULL;
997
998 _edje_text_class_font_get(ed, desc, &size, &sfont);
999 free(sfont);
1000 params->type.text.size = size; /* XXX TODO used by further calcs, go inside recalc_apply? */
1001
1002 _edje_text_recalc_apply(ed, ep, params, chosen_desc);
1003
1004 evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th);
1005
1006 if ((!chosen_desc) ||
1007 ((!chosen_desc->text.min_x) && (!chosen_desc->text.min_y) &&
1008 (!chosen_desc->text.max_x) && (!chosen_desc->text.max_y)))
1009 return;
1010
1011 evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th);
1012 evas_object_text_style_pad_get(ep->object, &l, &r, &t, &b);
1013
1014 mw = tw + l + r;
1015 mh = th + t + b;
1016
1017 if (chosen_desc->text.max_x)
1018 {
1019 if ((*maxw < 0) || (mw < *maxw)) *maxw = mw;
1020 }
1021 if (chosen_desc->text.max_y)
1022 {
1023 if ((*maxh < 0) || (mh < *maxh)) *maxh = mh;
1024 }
1025 if (chosen_desc->text.min_x)
1026 {
1027 if (mw > *minw) *minw = mw;
1028 }
1029 if (chosen_desc->text.min_y)
1030 {
1031 if (mh > *minh) *minh = mh;
1032 }
1033}
1034#else
1035{
1036 char *sfont = NULL;
1037 int size;
1038
1039 if (chosen_desc)
1040 {
1041 const char *text;
1042 const char *font;
1043 Evas_Coord tw, th;
1044 int inlined_font = 0;
1045
1046 /* Update a object_text part */
1047
1048 if (chosen_desc->text.id_source >= 0)
1049 ep->text.source = ed->table_parts[chosen_desc->text.id_source % ed->table_parts_size];
1050 else
1051 ep->text.source = NULL;
1052
1053 if (chosen_desc->text.id_text_source >= 0)
1054 ep->text.text_source = ed->table_parts[chosen_desc->text.id_text_source % ed->table_parts_size];
1055 else
1056 ep->text.text_source = NULL;
1057
1058 if (ep->text.text_source)
1059 text = edje_string_get(&(((Edje_Part_Description_Text*)ep->text.text_source->chosen_description)->text.text));
1060 else
1061 text = edje_string_get(&chosen_desc->text.text);
1062
1063 if (ep->text.source)
1064 font = _edje_text_class_font_get(ed, ((Edje_Part_Description_Text*)ep->text.source->chosen_description), &size, &sfont);
1065 else
1066 font = _edje_text_class_font_get(ed, chosen_desc, &size, &sfont);
1067
1068 if (!font) font = "";
1069
1070 if (ep->text.text_source)
1071 {
1072 if (ep->text.text_source->text.text) text = ep->text.text_source->text.text;
1073 }
1074 else
1075 {
1076 if (ep->text.text) text = ep->text.text;
1077 }
1078
1079 if (ep->text.source)
1080 {
1081 if (ep->text.source->text.font) font = ep->text.source->text.font;
1082 if (ep->text.source->text.size > 0) size = ep->text.source->text.size;
1083 }
1084 else
1085 {
1086 if (ep->text.font) font = ep->text.font;
1087 if (ep->text.size > 0) size = ep->text.size;
1088 }
1089 if (!text) text = "";
1090
1091 /* check if the font is embedded in the .eet */
1092 if (ed->file->fonts)
1093 {
1094 Edje_Font_Directory_Entry *fnt;
1095
1096 fnt = eina_hash_find(ed->file->fonts, font);
1097
1098 if (fnt)
1099 {
1100 char *font2;
1101
1102 size_t len = strlen(font) + sizeof("edje/fonts/") + 1;
1103 font2 = alloca(len);
1104 sprintf(font2, "edje/fonts/%s", font);
1105 font = font2;
1106 inlined_font = 1;
1107 }
1108 }
1109 if (ep->part->scale)
1110 evas_object_scale_set(ep->object, TO_DOUBLE(sc));
1111 if (inlined_font)
1112 {
1113 evas_object_text_font_source_set(ep->object, ed->path);
1114 }
1115 else evas_object_text_font_source_set(ep->object, NULL);
1116
1117 if ((_edje_fontset_append) && (font))
1118 {
1119 char *font2;
1120
1121 font2 = malloc(strlen(font) + 1 + strlen(_edje_fontset_append) + 1);
1122 if (font2)
1123 {
1124 strcpy(font2, font);
1125 strcat(font2, ",");
1126 strcat(font2, _edje_fontset_append);
1127 evas_object_text_font_set(ep->object, font2, size);
1128 free(font2);
1129 }
1130 }
1131 else
1132 evas_object_text_font_set(ep->object, font, size);
1133 if ((chosen_desc->text.min_x) || (chosen_desc->text.min_y) ||
1134 (chosen_desc->text.max_x) || (chosen_desc->text.max_y))
1135 {
1136 int mw, mh;
1137 Evas_Text_Style_Type
1138 style = EVAS_TEXT_STYLE_PLAIN,
1139 shadow = EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_RIGHT;
1140 const Evas_Text_Style_Type styles[] = {
1141 EVAS_TEXT_STYLE_PLAIN,
1142 EVAS_TEXT_STYLE_PLAIN,
1143 EVAS_TEXT_STYLE_OUTLINE,
1144 EVAS_TEXT_STYLE_SOFT_OUTLINE,
1145 EVAS_TEXT_STYLE_SHADOW,
1146 EVAS_TEXT_STYLE_SOFT_SHADOW,
1147 EVAS_TEXT_STYLE_OUTLINE_SHADOW,
1148 EVAS_TEXT_STYLE_OUTLINE_SOFT_SHADOW,
1149 EVAS_TEXT_STYLE_FAR_SHADOW,
1150 EVAS_TEXT_STYLE_FAR_SOFT_SHADOW,
1151 EVAS_TEXT_STYLE_GLOW
1152 };
1153 const Evas_Text_Style_Type shadows[] = {
1154 EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_RIGHT,
1155 EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM,
1156 EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_LEFT,
1157 EVAS_TEXT_STYLE_SHADOW_DIRECTION_LEFT,
1158 EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_LEFT,
1159 EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP,
1160 EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_RIGHT,
1161 EVAS_TEXT_STYLE_SHADOW_DIRECTION_RIGHT
1162 };
1163
1164 if ((ep->part->effect & EVAS_TEXT_STYLE_MASK_BASIC)
1165 < EDJE_TEXT_EFFECT_LAST)
1166 style = styles[ep->part->effect];
1167 shadow = shadows
1168 [(ep->part->effect & EDJE_TEXT_EFFECT_MASK_SHADOW_DIRECTION) >> 4];
1169 EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET(style, shadow);
1170
1171 evas_object_text_style_set(ep->object, style);
1172 evas_object_text_text_set(ep->object, text);
1173 evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th);
1174 if (chosen_desc->text.max_x)
1175 {
1176 int l, r;
1177 evas_object_text_style_pad_get(ep->object, &l, &r, NULL, NULL);
1178 mw = tw + l + r;
1179 if ((*maxw < 0) || (mw < *maxw)) *maxw = mw;
1180 }
1181 if (chosen_desc->text.max_y)
1182 {
1183 int t, b;
1184 evas_object_text_style_pad_get(ep->object, NULL, NULL, &t, &b);
1185 mh = th + t + b;
1186 if ((*maxh < 0) || (mh < *maxh)) *maxh = mh;
1187 }
1188 if (chosen_desc->text.min_x)
1189 {
1190 int l, r;
1191 evas_object_text_style_pad_get(ep->object, &l, &r, NULL, NULL);
1192 mw = tw + l + r;
1193 if (mw > *minw) *minw = mw;
1194 }
1195 if (chosen_desc->text.min_y)
1196 {
1197 int t, b;
1198 evas_object_text_style_pad_get(ep->object, NULL, NULL, &t, &b);
1199 mh = th + t + b;
1200 if (mh > *minh) *minh = mh;
1201 }
1202 }
1203 if (sfont) free(sfont);
1204 }
1205
1206 /* FIXME: Do we really need to call it twice if chosen_desc ? */
1207 sfont = NULL;
1208 _edje_text_class_font_get(ed, desc, &size, &sfont);
1209 free(sfont);
1210 params->type.text.size = size;
1211}
1212#endif
1213
1214static void
1215_edje_part_recalc_single_min_length(FLOAT_T align, int *start, int *length, int min)
1216{
1217 if (min >= 0)
1218 {
1219 if (*length < min)
1220 {
1221 *start += TO_INT(SCALE(align, (*length - min)));
1222 *length = min;
1223 }
1224 }
1225}
1226
1227static void
1228_edje_part_recalc_single_min(Edje_Part_Description_Common *desc,
1229 Edje_Calc_Params *params,
1230 int minw, int minh,
1231 Edje_Internal_Aspect aspect)
1232{
1233 int tmp;
1234 int w;
1235 int h;
1236
1237 w = params->w ? params->w : 99999;
1238 h = params->h ? params->h : 99999;
1239
1240 switch (aspect)
1241 {
1242 case EDJE_ASPECT_PREFER_NONE:
1243 break;
1244 case EDJE_ASPECT_PREFER_VERTICAL:
1245 tmp = minh * params->w / h;
1246 if (tmp >= minw)
1247 {
1248 minw = tmp;
1249 break;
1250 }
1251 case EDJE_ASPECT_PREFER_HORIZONTAL:
1252 tmp = minw * params->h / w;
1253 if (tmp >= minh)
1254 {
1255 minh = tmp;
1256 break;
1257 }
1258 case EDJE_ASPECT_PREFER_BOTH:
1259 tmp = minh * params->w / h;
1260 if (tmp >= minw)
1261 {
1262 minw = tmp;
1263 break;
1264 }
1265
1266 tmp = minw * params->h / w;
1267 if (tmp >= minh)
1268 {
1269 minh = tmp;
1270 break;
1271 }
1272
1273 break;
1274 }
1275
1276 _edje_part_recalc_single_min_length(desc->align.x, &params->x, &params->w, minw);
1277 _edje_part_recalc_single_min_length(desc->align.y, &params->y, &params->h, minh);
1278}
1279
1280static void
1281_edje_part_recalc_single_max_length(FLOAT_T align, int *start, int *length, int max)
1282{
1283 if (max >= 0)
1284 {
1285 if (*length > max)
1286 {
1287 *start += TO_INT(SCALE(align, (*length - max)));
1288 *length = max;
1289 }
1290 }
1291}
1292
1293static void
1294_edje_part_recalc_single_max(Edje_Part_Description_Common *desc,
1295 Edje_Calc_Params *params,
1296 int maxw, int maxh,
1297 Edje_Internal_Aspect aspect)
1298{
1299 int tmp;
1300 int w;
1301 int h;
1302
1303 w = params->w ? params->w : 99999;
1304 h = params->h ? params->h : 99999;
1305
1306 switch (aspect)
1307 {
1308 case EDJE_ASPECT_PREFER_NONE:
1309 break;
1310 case EDJE_ASPECT_PREFER_VERTICAL:
1311 tmp = maxh * params->w / h;
1312 if (tmp <= maxw)
1313 {
1314 maxw = tmp;
1315 break;
1316 }
1317 case EDJE_ASPECT_PREFER_HORIZONTAL:
1318 tmp = maxw * params->h / w;
1319 if (tmp <= maxh)
1320 {
1321 maxh = tmp;
1322 break;
1323 }
1324 case EDJE_ASPECT_PREFER_BOTH:
1325 tmp = maxh * params->w / h;
1326 if (tmp <= maxw)
1327 {
1328 maxw = tmp;
1329 break;
1330 }
1331
1332 tmp = maxw * params->h / w;
1333 if (tmp <= maxh)
1334 {
1335 maxh = tmp;
1336 break;
1337 }
1338
1339 break;
1340 }
1341
1342 _edje_part_recalc_single_max_length(desc->align.x, &params->x, &params->w, maxw);
1343 _edje_part_recalc_single_max_length(desc->align.y, &params->y, &params->h, maxh);
1344}
1345
1346static void
1347_edje_part_recalc_single_drag(Edje_Real_Part *ep,
1348 Edje_Real_Part *confine_to,
1349 Edje_Calc_Params *params,
1350 int minw, int minh,
1351 int maxw, int maxh)
1352{
1353 /* confine */
1354 if (confine_to)
1355 {
1356 int offset;
1357 int step;
1358 FLOAT_T v;
1359
1360 /* complex dragable params */
1361 v = SCALE(ep->drag->size.x, confine_to->w);
1362
1363 if ((minw > 0) && (TO_INT(v) < minw)) params->w = minw;
1364 else if ((maxw >= 0) && (TO_INT(v) > maxw)) params->w = maxw;
1365 else params->w = TO_INT(v);
1366
1367 offset = TO_INT(SCALE(ep->drag->x, (confine_to->w - params->w)))
1368 + ep->drag->tmp.x;
1369 if (ep->part->dragable.step_x > 0)
1370 {
1371 params->x = confine_to->x +
1372 ((offset / ep->part->dragable.step_x) * ep->part->dragable.step_x);
1373 }
1374 else if (ep->part->dragable.count_x > 0)
1375 {
1376 step = (confine_to->w - params->w) / ep->part->dragable.count_x;
1377 if (step < 1) step = 1;
1378 params->x = confine_to->x +
1379 ((offset / step) * step);
1380 }
1381 params->req_drag.x = params->x;
1382 params->req_drag.w = params->w;
1383
1384 v = SCALE(ep->drag->size.y, confine_to->h);
1385
1386 if ((minh > 0) && (TO_INT(v) < minh)) params->h = minh;
1387 else if ((maxh >= 0) && (TO_INT(v) > maxh)) params->h = maxh;
1388 else params->h = TO_INT(v);
1389
1390 offset = TO_INT(SCALE(ep->drag->y, (confine_to->h - params->h)))
1391 + ep->drag->tmp.y;
1392 if (ep->part->dragable.step_y > 0)
1393 {
1394 params->y = confine_to->y +
1395 ((offset / ep->part->dragable.step_y) * ep->part->dragable.step_y);
1396 }
1397 else if (ep->part->dragable.count_y > 0)
1398 {
1399 step = (confine_to->h - params->h) / ep->part->dragable.count_y;
1400 if (step < 1) step = 1;
1401 params->y = confine_to->y +
1402 ((offset / step) * step);
1403 }
1404 params->req_drag.y = params->y;
1405 params->req_drag.h = params->h;
1406
1407 /* limit to confine */
1408 if (params->x < confine_to->x)
1409 {
1410 params->x = confine_to->x;
1411 }
1412 if ((params->x + params->w) > (confine_to->x + confine_to->w))
1413 {
1414 params->x = confine_to->x + confine_to->w - params->w;
1415 }
1416 if (params->y < confine_to->y)
1417 {
1418 params->y = confine_to->y;
1419 }
1420 if ((params->y + params->h) > (confine_to->y + confine_to->h))
1421 {
1422 params->y = confine_to->y + confine_to->h - params->h;
1423 }
1424 }
1425 else
1426 {
1427 /* simple dragable params */
1428 params->x += TO_INT(ep->drag->x) + ep->drag->tmp.x;
1429 params->req_drag.x = params->x;
1430 params->req_drag.w = params->w;
1431
1432 params->y += TO_INT(ep->drag->y) + ep->drag->tmp.y;
1433 params->req_drag.y = params->y;
1434 params->req_drag.h = params->h;
1435 }
1436}
1437
1438static void
1439_edje_part_recalc_single_fill(Edje_Real_Part *ep,
1440 Edje_Part_Description_Spec_Fill *fill,
1441 Edje_Calc_Params *params)
1442{
1443 int fw;
1444 int fh;
1445
1446 params->smooth = fill->smooth;
1447
1448 if (fill->type == EDJE_FILL_TYPE_TILE)
1449 evas_object_image_size_get(ep->object, &fw, NULL);
1450 else
1451 fw = params->w;
1452
1453 params->type.common.fill.x = fill->pos_abs_x
1454 + TO_INT(SCALE(fill->pos_rel_x, fw));
1455 params->type.common.fill.w = fill->abs_x
1456 + TO_INT(SCALE(fill->rel_x, fw));
1457
1458 if (fill->type == EDJE_FILL_TYPE_TILE)
1459 evas_object_image_size_get(ep->object, NULL, &fh);
1460 else
1461 fh = params->h;
1462
1463 params->type.common.fill.y = fill->pos_abs_y
1464 + TO_INT(SCALE(fill->pos_rel_y, fh));
1465 params->type.common.fill.h = fill->abs_y
1466 + TO_INT(SCALE(fill->rel_y, fh));
1467
1468 params->type.common.fill.angle = fill->angle;
1469 params->type.common.fill.spread = fill->spread;
1470}
1471
1472static void
1473_edje_part_recalc_single_min_max(FLOAT_T sc,
1474 Edje_Real_Part *ep,
1475 Edje_Part_Description_Common *desc,
1476 int *minw, int *minh,
1477 int *maxw, int *maxh)
1478{
1479 *minw = desc->min.w;
1480 if (ep->part->scale) *minw = TO_INT(SCALE(sc, *minw));
1481 if (ep->swallow_params.min.w > desc->min.w)
1482 *minw = ep->swallow_params.min.w;
1483
1484 /* XXX TODO: remove need of EDJE_INF_MAX_W, see edje_util.c */
1485 if ((ep->swallow_params.max.w <= 0) ||
1486 (ep->swallow_params.max.w == EDJE_INF_MAX_W))
1487 {
1488 *maxw = desc->max.w;
1489 if (*maxw > 0)
1490 {
1491 if (ep->part->scale) *maxw = TO_INT(SCALE(sc, *maxw));
1492 if (*maxw < 1) *maxw = 1;
1493 }
1494 }
1495 else
1496 {
1497 if (desc->max.w <= 0)
1498 *maxw = ep->swallow_params.max.w;
1499 else
1500 {
1501 *maxw = desc->max.w;
1502 if (*maxw > 0)
1503 {
1504 if (ep->part->scale) *maxw = TO_INT(SCALE(sc, *maxw));
1505 if (*maxw < 1) *maxw = 1;
1506 }
1507 if (ep->swallow_params.max.w < *maxw)
1508 *maxw = ep->swallow_params.max.w;
1509 }
1510 }
1511 if (*maxw >= 0)
1512 {
1513 if (*maxw < *minw) *maxw = *minw;
1514 }
1515
1516 *minh = desc->min.h;
1517 if (ep->part->scale) *minh = TO_INT(SCALE(sc, *minh));
1518 if (ep->swallow_params.min.h > desc->min.h)
1519 *minh = ep->swallow_params.min.h;
1520
1521 /* XXX TODO: remove need of EDJE_INF_MAX_H, see edje_util.c */
1522 if ((ep->swallow_params.max.h <= 0) ||
1523 (ep->swallow_params.max.h == EDJE_INF_MAX_H))
1524 {
1525 *maxh = desc->max.h;
1526 if (*maxh > 0)
1527 {
1528 if (ep->part->scale) *maxh = TO_INT(SCALE(sc, *maxh));
1529 if (*maxh < 1) *maxh = 1;
1530 }
1531 }
1532 else
1533 {
1534 if (desc->max.h <= 0)
1535 *maxh = ep->swallow_params.max.h;
1536 else
1537 {
1538 *maxh = desc->max.h;
1539 if (*maxh > 0)
1540 {
1541 if (ep->part->scale) *maxh = TO_INT(SCALE(sc, *maxh));
1542 if (*maxh < 1) *maxh = 1;
1543 }
1544 if (ep->swallow_params.max.h < *maxh)
1545 *maxh = ep->swallow_params.max.h;
1546 }
1547 }
1548 if (*maxh >= 0)
1549 {
1550 if (*maxh < *minh) *maxh = *minh;
1551 }
1552}
1553
1554static void
1555_edje_part_recalc_single_map(Edje *ed,
1556 Edje_Real_Part *ep __UNUSED__,
1557 Edje_Real_Part *center,
1558 Edje_Real_Part *light,
1559 Edje_Real_Part *persp,
1560 Edje_Part_Description_Common *desc,
1561 Edje_Part_Description_Common *chosen_desc,
1562 Edje_Calc_Params *params)
1563{
1564 params->mapped = chosen_desc->map.on;
1565 params->lighted = params->mapped ? !!light : 0;
1566 params->persp_on = params->mapped ? !!persp : 0;
1567
1568 if (!params->mapped) return ;
1569
1570 if (center)
1571 {
1572 params->map.center.x = ed->x + center->x + (center->w / 2);
1573 params->map.center.y = ed->y + center->y + (center->h / 2);
1574 }
1575 else
1576 {
1577 params->map.center.x = ed->x + params->x + (params->w / 2);
1578 params->map.center.y = ed->y + params->y + (params->h / 2);
1579 }
1580 params->map.center.z = 0;
1581
1582 params->map.rotation.x = TO_DOUBLE(desc->map.rot.x);
1583 params->map.rotation.y = TO_DOUBLE(desc->map.rot.y);
1584 params->map.rotation.z = TO_DOUBLE(desc->map.rot.z);
1585
1586 if (light)
1587 {
1588 Edje_Part_Description_Common *light_desc2;
1589 FLOAT_T pos, pos2;
1590
1591 params->map.light.x = ed->x + light->x + (light->w / 2);
1592 params->map.light.y = ed->y + light->y + (light->h / 2);
1593
1594 pos = light->description_pos;
1595 pos2 = (pos < ZERO) ? ZERO : ((pos > FROM_INT(1)) ? FROM_INT(1) : pos);
1596
1597 light_desc2 = light->param2 ? light->param2->description : NULL;
1598
1599 /* take into account CURRENT state also */
1600 if (pos != ZERO && light_desc2)
1601 {
1602 params->map.light.z = light->param1.description->persp.zplane +
1603 TO_INT(SCALE(pos, light_desc2->persp.zplane - light->param1.description->persp.zplane));
1604 params->map.light.r = light->param1.description->color.r +
1605 TO_INT(SCALE(pos2, light_desc2->color.r - light->param1.description->color.r));
1606 params->map.light.g = light->param1.description->color.g +
1607 TO_INT(SCALE(pos2, light_desc2->color.g - light->param1.description->color.g));
1608 params->map.light.b = light->param1.description->color.b +
1609 TO_INT(SCALE(pos2, light_desc2->color.b - light->param1.description->color.b));
1610 params->map.light.ar = light->param1.description->color2.r +
1611 TO_INT(SCALE(pos2, light_desc2->color2.r - light->param1.description->color2.r));
1612 params->map.light.ag = light->param1.description->color2.g +
1613 TO_INT(SCALE(pos2, light_desc2->color2.g - light->param1.description->color2.g));
1614 params->map.light.ab = light->param1.description->color2.b +
1615 TO_INT(SCALE(pos2, light_desc2->color2.b - light->param1.description->color2.b));
1616 }
1617 else
1618 {
1619 params->map.light.z = light->param1.description->persp.zplane;
1620 params->map.light.r = light->param1.description->color.r;
1621 params->map.light.g = light->param1.description->color.g;
1622 params->map.light.b = light->param1.description->color.b;
1623 params->map.light.ar = light->param1.description->color2.r;
1624 params->map.light.ag = light->param1.description->color2.g;
1625 params->map.light.ab = light->param1.description->color2.b;
1626 }
1627 }
1628
1629 if (persp)
1630 {
1631 FLOAT_T pos;
1632
1633 params->map.persp.x = ed->x + persp->x + (persp->w / 2);
1634 params->map.persp.y = ed->y + persp->y + (persp->h / 2);
1635
1636 pos = persp->description_pos;
1637
1638 if (pos != 0 && persp->param2)
1639 {
1640 params->map.persp.z = persp->param1.description->persp.zplane +
1641 TO_INT(SCALE(pos, persp->param2->description->persp.zplane -
1642 persp->param1.description->persp.zplane));
1643 params->map.persp.focal = persp->param1.description->persp.focal +
1644 TO_INT(SCALE(pos, persp->param2->description->persp.focal -
1645 persp->param1.description->persp.focal));
1646 }
1647 else
1648 {
1649 params->map.persp.z = persp->param1.description->persp.zplane;
1650 params->map.persp.focal = persp->param1.description->persp.focal;
1651 }
1652 }
1653}
1654
1655static void
1656_edje_part_recalc_single(Edje *ed,
1657 Edje_Real_Part *ep,
1658 Edje_Part_Description_Common *desc,
1659 Edje_Part_Description_Common *chosen_desc,
1660 Edje_Real_Part *center,
1661 Edje_Real_Part *light,
1662 Edje_Real_Part *persp,
1663 Edje_Real_Part *rel1_to_x,
1664 Edje_Real_Part *rel1_to_y,
1665 Edje_Real_Part *rel2_to_x,
1666 Edje_Real_Part *rel2_to_y,
1667 Edje_Real_Part *confine_to,
1668 Edje_Calc_Params *params)
1669{
1670 Edje_Color_Class *cc = NULL;
1671 Edje_Internal_Aspect apref;
1672 int minw = 0, minh = 0, maxw = 0, maxh = 0;
1673 FLOAT_T sc;
1674
1675 sc = ed->scale;
1676 if (sc == ZERO) sc = _edje_scale;
1677 _edje_part_recalc_single_min_max(sc, ep, desc, &minw, &minh, &maxw, &maxh);
1678
1679 /* relative coords of top left & bottom right */
1680 _edje_part_recalc_single_rel(ed, ep, desc, rel1_to_x, rel1_to_y, rel2_to_x, rel2_to_y, params);
1681
1682 /* aspect */
1683 apref = _edje_part_recalc_single_aspect(ep, desc, params, &minw, &minh, &maxw, &maxh);
1684
1685 /* size step */
1686 _edje_part_recalc_single_step(desc, params);
1687
1688 /* if we have text that wants to make the min size the text size... */
1689 if (ep->part->type == EDJE_PART_TYPE_TEXTBLOCK)
1690 _edje_part_recalc_single_textblock(sc, ed, ep, (Edje_Part_Description_Text*) chosen_desc, params, &minw, &minh, &maxw, &maxh);
1691 else if (ep->part->type == EDJE_PART_TYPE_TEXT)
1692 _edje_part_recalc_single_text(sc, ed, ep, (Edje_Part_Description_Text*) desc, (Edje_Part_Description_Text*) chosen_desc, params, &minw, &minh, &maxw, &maxh);
1693
1694 if ((ep->part->type == EDJE_PART_TYPE_TABLE) &&
1695 (((((Edje_Part_Description_Table *)chosen_desc)->table.min.h) ||
1696 (((Edje_Part_Description_Table *)chosen_desc)->table.min.v))))
1697 {
1698 Evas_Coord lminw = 0, lminh = 0;
1699
1700 evas_object_smart_need_recalculate_set(ep->object, 1);
1701 evas_object_smart_calculate(ep->object);
1702 evas_object_size_hint_min_get(ep->object, &lminw, &lminh);
1703 if (((Edje_Part_Description_Table *)chosen_desc)->table.min.h)
1704 {
1705 if (lminw > minw) minw = lminw;
1706 }
1707 if (((Edje_Part_Description_Table *)chosen_desc)->table.min.v)
1708 {
1709 if (lminh > minh) minh = lminh;
1710 }
1711 }
1712 else if ((ep->part->type == EDJE_PART_TYPE_BOX) &&
1713 ((((Edje_Part_Description_Box *)chosen_desc)->box.min.h) ||
1714 (((Edje_Part_Description_Box *)chosen_desc)->box.min.v)))
1715 {
1716 Evas_Coord lminw = 0, lminh = 0;
1717
1718 evas_object_smart_need_recalculate_set(ep->object, 1);
1719 evas_object_smart_calculate(ep->object);
1720 evas_object_size_hint_min_get(ep->object, &lminw, &lminh);
1721 if (((Edje_Part_Description_Box *)chosen_desc)->box.min.h)
1722 {
1723 if (lminw > minw) minw = lminw;
1724 }
1725 if (((Edje_Part_Description_Box *)chosen_desc)->box.min.v)
1726 {
1727 if (lminh > minh) minh = lminh;
1728 }
1729 }
1730
1731 /* remember what our size is BEFORE we go limit it */
1732 params->req.x = params->x;
1733 params->req.y = params->y;
1734 params->req.w = params->w;
1735 params->req.h = params->h;
1736
1737 /* adjust for min size */
1738 _edje_part_recalc_single_min(desc, params, minw, minh, apref);
1739
1740 /* adjust for max size */
1741 _edje_part_recalc_single_max(desc, params, maxw, maxh, apref);
1742
1743 /* take care of dragable part */
1744 if (ep->drag)
1745 _edje_part_recalc_single_drag(ep, confine_to, params, minw, minh, maxw, maxh);
1746
1747 /* fill */
1748 if (ep->part->type == EDJE_PART_TYPE_IMAGE)
1749 _edje_part_recalc_single_fill(ep, &((Edje_Part_Description_Image *)desc)->image.fill, params);
1750 else if (ep->part->type == EDJE_PART_TYPE_PROXY)
1751 _edje_part_recalc_single_fill(ep, &((Edje_Part_Description_Proxy *)desc)->proxy.fill, params);
1752
1753 /* colors */
1754 if ((desc->color_class) && (*desc->color_class))
1755 cc = _edje_color_class_find(ed, desc->color_class);
1756
1757 if (cc)
1758 {
1759 params->color.r = (((int)cc->r + 1) * desc->color.r) >> 8;
1760 params->color.g = (((int)cc->g + 1) * desc->color.g) >> 8;
1761 params->color.b = (((int)cc->b + 1) * desc->color.b) >> 8;
1762 params->color.a = (((int)cc->a + 1) * desc->color.a) >> 8;
1763 }
1764 else
1765 {
1766 params->color.r = desc->color.r;
1767 params->color.g = desc->color.g;
1768 params->color.b = desc->color.b;
1769 params->color.a = desc->color.a;
1770 }
1771
1772 /* visible */
1773 params->visible = desc->visible;
1774
1775 switch (ep->part->type)
1776 {
1777 case EDJE_PART_TYPE_IMAGE:
1778 {
1779 Edje_Part_Description_Image *img_desc = (Edje_Part_Description_Image*) desc;
1780
1781 /* border */
1782 params->type.common.spec.image.l = img_desc->image.border.l;
1783 params->type.common.spec.image.r = img_desc->image.border.r;
1784
1785 params->type.common.spec.image.t = img_desc->image.border.t;
1786 params->type.common.spec.image.b = img_desc->image.border.b;
1787 break;
1788 }
1789 case EDJE_PART_TYPE_TEXT:
1790 case EDJE_PART_TYPE_TEXTBLOCK:
1791 {
1792 Edje_Part_Description_Text *text_desc = (Edje_Part_Description_Text*) desc;
1793
1794 /* text.align */
1795 params->type.text.align.x = text_desc->text.align.x;
1796 params->type.text.align.y = text_desc->text.align.y;
1797 params->type.text.elipsis = text_desc->text.elipsis;
1798
1799 /* text colors */
1800 if (cc)
1801 {
1802 params->type.text.color2.r = (((int)cc->r2 + 1) * text_desc->common.color2.r) >> 8;
1803 params->type.text.color2.g = (((int)cc->g2 + 1) * text_desc->common.color2.g) >> 8;
1804 params->type.text.color2.b = (((int)cc->b2 + 1) * text_desc->common.color2.b) >> 8;
1805 params->type.text.color2.a = (((int)cc->a2 + 1) * text_desc->common.color2.a) >> 8;
1806 params->type.text.color3.r = (((int)cc->r3 + 1) * text_desc->text.color3.r) >> 8;
1807 params->type.text.color3.g = (((int)cc->g3 + 1) * text_desc->text.color3.g) >> 8;
1808 params->type.text.color3.b = (((int)cc->b3 + 1) * text_desc->text.color3.b) >> 8;
1809 params->type.text.color3.a = (((int)cc->a3 + 1) * text_desc->text.color3.a) >> 8;
1810 }
1811 else
1812 {
1813 params->type.text.color2.r = text_desc->common.color2.r;
1814 params->type.text.color2.g = text_desc->common.color2.g;
1815 params->type.text.color2.b = text_desc->common.color2.b;
1816 params->type.text.color2.a = text_desc->common.color2.a;
1817 params->type.text.color3.r = text_desc->text.color3.r;
1818 params->type.text.color3.g = text_desc->text.color3.g;
1819 params->type.text.color3.b = text_desc->text.color3.b;
1820 params->type.text.color3.a = text_desc->text.color3.a;
1821 }
1822
1823 break;
1824 }
1825 case EDJE_PART_TYPE_RECTANGLE:
1826 case EDJE_PART_TYPE_BOX:
1827 case EDJE_PART_TYPE_TABLE:
1828 case EDJE_PART_TYPE_SWALLOW:
1829 case EDJE_PART_TYPE_GROUP:
1830 case EDJE_PART_TYPE_PROXY:
1831 break;
1832 case EDJE_PART_TYPE_GRADIENT:
1833 /* FIXME: THIS ONE SHOULD NEVER BE TRIGGERED. */
1834 break;
1835 default:
1836 break;
1837 }
1838
1839 _edje_part_recalc_single_map(ed, ep, center, light, persp, desc, chosen_desc, params);
1840}
1841
1842static void
1843_edje_table_recalc_apply(Edje *ed __UNUSED__,
1844 Edje_Real_Part *ep,
1845 Edje_Calc_Params *p3 __UNUSED__,
1846 Edje_Part_Description_Table *chosen_desc)
1847{
1848 evas_object_table_homogeneous_set(ep->object, chosen_desc->table.homogeneous);
1849 evas_object_table_align_set(ep->object, TO_DOUBLE(chosen_desc->table.align.x), TO_DOUBLE(chosen_desc->table.align.y));
1850 evas_object_table_padding_set(ep->object, chosen_desc->table.padding.x, chosen_desc->table.padding.y);
1851 if (evas_object_smart_need_recalculate_get(ep->object))
1852 {
1853 evas_object_smart_need_recalculate_set(ep->object, 0);
1854 evas_object_smart_calculate(ep->object);
1855 }
1856}
1857
1858static int
1859_edje_image_find(Evas_Object *obj, Edje *ed, Edje_Real_Part_Set **eps, Edje_Part_Description_Image *st, Edje_Part_Image_Id *imid)
1860{
1861 Edje_Image_Directory_Set_Entry *entry;
1862 Edje_Image_Directory_Set *set = NULL;
1863 Eina_List *l;
1864 int w = 0;
1865 int h = 0;
1866 int id;
1867
1868 if (!st && !imid)
1869 return -1;
1870
1871 if (st && !st->image.set)
1872 return st->image.id;
1873
1874 if (imid && !imid->set)
1875 return imid->id;
1876
1877 if (imid)
1878 id = imid->id;
1879 else
1880 id = st->image.id;
1881
1882 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
1883
1884 if (eps && *eps)
1885 {
1886 if ((*eps)->id == id)
1887 set = (*eps)->set;
1888
1889 if (set)
1890 if ((*eps)->entry->size.min.w <= w && w <= (*eps)->entry->size.max.w)
1891 if ((*eps)->entry->size.min.h <= h && h <= (*eps)->entry->size.max.h)
1892 return (*eps)->entry->id;
1893 }
1894
1895 if (!set)
1896 set = ed->file->image_dir->sets + id;
1897
1898 EINA_LIST_FOREACH(set->entries, l, entry)
1899 {
1900 if (entry->size.min.w <= w && w <= entry->size.max.w)
1901 if (entry->size.min.h <= h && h <= entry->size.max.h)
1902 {
1903 if (eps)
1904 {
1905 if (!*eps)
1906 *eps = calloc(1, sizeof (Edje_Real_Part_Set));
1907
1908 if (*eps)
1909 {
1910 (*eps)->entry = entry;
1911 (*eps)->set = set;
1912 (*eps)->id = id;
1913 }
1914 }
1915 return entry->id;
1916 }
1917 }
1918
1919 return -1;
1920}
1921
1922static void
1923_edje_proxy_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3, Edje_Part_Description_Proxy *chosen_desc, FLOAT_T pos)
1924{
1925 Edje_Real_Part *pp;
1926 int part_id = -1;
1927
1928 if (pos >= 0.5)
1929 part_id = ((Edje_Part_Description_Proxy*) ep->param2->description)->proxy.id;
1930 else
1931 part_id = chosen_desc->proxy.id;
1932
1933 if ((p3->type.common.fill.w == 0) || (p3->type.common.fill.h == 0) ||
1934 (part_id < 0))
1935 {
1936 evas_object_image_source_set(ep->object, NULL);
1937 return;
1938 }
1939 pp = ed->table_parts[part_id % ed->table_parts_size];
1940
1941 switch (pp->part->type)
1942 {
1943 case EDJE_PART_TYPE_IMAGE:
1944 case EDJE_PART_TYPE_TEXT:
1945 case EDJE_PART_TYPE_TEXTBLOCK:
1946 case EDJE_PART_TYPE_RECTANGLE:
1947 case EDJE_PART_TYPE_BOX:
1948 case EDJE_PART_TYPE_TABLE:
1949 case EDJE_PART_TYPE_PROXY:
1950 evas_object_image_source_set(ep->object, pp->object);
1951 break;
1952 case EDJE_PART_TYPE_GRADIENT:
1953 /* FIXME: THIS ONE SHOULD NEVER BE TRIGGERED. */
1954 break;
1955 case EDJE_PART_TYPE_GROUP:
1956 case EDJE_PART_TYPE_SWALLOW:
1957 case EDJE_PART_TYPE_EXTERNAL:
1958 evas_object_image_source_set(ep->object, pp->swallowed_object);
1959 break;
1960 }
1961
1962 evas_object_image_fill_set(ep->object, p3->type.common.fill.x, p3->type.common.fill.y,
1963 p3->type.common.fill.w, p3->type.common.fill.h);
1964 evas_object_image_smooth_scale_set(ep->object, p3->smooth);
1965}
1966
1967static void
1968_edje_image_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3, Edje_Part_Description_Image *chosen_desc, FLOAT_T pos)
1969{
1970 int image_id;
1971 int image_count, image_num;
1972 FLOAT_T sc;
1973
1974 sc = ed->scale;
1975 if (sc == 0.0) sc = _edje_scale;
1976 evas_object_image_fill_set(ep->object, p3->type.common.fill.x, p3->type.common.fill.y,
1977 p3->type.common.fill.w, p3->type.common.fill.h);
1978 evas_object_image_smooth_scale_set(ep->object, p3->smooth);
1979 if (chosen_desc->image.border.scale)
1980 {
1981 if (chosen_desc->image.border.scale_by > FROM_DOUBLE(0.0))
1982 {
1983 FLOAT_T sc2 = MUL(sc, chosen_desc->image.border.scale_by);
1984 evas_object_image_border_scale_set(ep->object, TO_DOUBLE(sc2));
1985 }
1986 else
1987 evas_object_image_border_scale_set(ep->object, TO_DOUBLE(sc));
1988 }
1989 else
1990 {
1991 if (chosen_desc->image.border.scale_by > FROM_DOUBLE(0.0))
1992 evas_object_image_border_scale_set
1993 (ep->object, TO_DOUBLE(chosen_desc->image.border.scale_by));
1994 else
1995 evas_object_image_border_scale_set(ep->object, 1.0);
1996 }
1997 evas_object_image_border_set(ep->object, p3->type.common.spec.image.l, p3->type.common.spec.image.r,
1998 p3->type.common.spec.image.t, p3->type.common.spec.image.b);
1999 if (chosen_desc->image.border.no_fill == 0)
2000 evas_object_image_border_center_fill_set(ep->object, EVAS_BORDER_FILL_DEFAULT);
2001 else if (chosen_desc->image.border.no_fill == 1)
2002 evas_object_image_border_center_fill_set(ep->object, EVAS_BORDER_FILL_NONE);
2003 else if (chosen_desc->image.border.no_fill == 2)
2004 evas_object_image_border_center_fill_set(ep->object, EVAS_BORDER_FILL_SOLID);
2005
2006 image_id = _edje_image_find(ep->object, ed,
2007 &ep->param1.set,
2008 (Edje_Part_Description_Image*) ep->param1.description,
2009 NULL);
2010 if (image_id < 0)
2011 {
2012 Edje_Image_Directory_Entry *ie;
2013
2014 if (!ed->file->image_dir) ie = NULL;
2015 else ie = ed->file->image_dir->entries + (-image_id) - 1;
2016 if ((ie) &&
2017 (ie->source_type == EDJE_IMAGE_SOURCE_TYPE_EXTERNAL) &&
2018 (ie->entry))
2019 {
2020 evas_object_image_file_set(ep->object, ie->entry, NULL);
2021 }
2022 }
2023 else
2024 {
2025 image_count = 2;
2026 if (ep->param2)
2027 image_count += ((Edje_Part_Description_Image*) ep->param2->description)->image.tweens_count;
2028 image_num = TO_INT(MUL(pos, SUB(FROM_INT(image_count),
2029 FROM_DOUBLE(0.5))));
2030 if (image_num > (image_count - 1))
2031 image_num = image_count - 1;
2032 if (image_num == 0)
2033 {
2034 image_id = _edje_image_find(ep->object, ed,
2035 &ep->param1.set,
2036 (Edje_Part_Description_Image*) ep->param1.description,
2037 NULL);
2038 }
2039 else
2040 if (ep->param2)
2041 {
2042 if (image_num == (image_count - 1))
2043 {
2044 image_id = _edje_image_find(ep->object, ed,
2045 &ep->param2->set,
2046 (Edje_Part_Description_Image*) ep->param2->description,
2047 NULL);
2048 }
2049 else
2050 {
2051 Edje_Part_Image_Id *imid;
2052
2053 imid = ((Edje_Part_Description_Image*) ep->param2->description)->image.tweens[image_num - 1];
2054 image_id = _edje_image_find(ep->object, ed, NULL, NULL, imid);
2055 }
2056 }
2057 if (image_id < 0)
2058 {
2059 ERR("¨Part \"%s\" has description, "
2060 "\"%s\" %3.3f with a missing image id!!!",
2061 ep->part->name,
2062 ep->param1.description->state.name,
2063 ep->param1.description->state.value);
2064 }
2065 else
2066 {
2067 char buf[1024];
2068
2069 /* Replace snprint("edje/images/%i") == memcpy + itoa */
2070#define IMAGES "edje/images/"
2071 memcpy(buf, IMAGES, strlen(IMAGES));
2072 eina_convert_itoa(image_id, buf + strlen(IMAGES)); /* No need to check length as 2³² need only 10 characteres. */
2073
2074 evas_object_image_file_set(ep->object, ed->file->path, buf);
2075 if (evas_object_image_load_error_get(ep->object) != EVAS_LOAD_ERROR_NONE)
2076 {
2077 ERR("Error loading image collection \"%s\" from "
2078 "file \"%s\". Missing EET Evas loader module?",
2079 buf, ed->file->path);
2080 switch (evas_object_image_load_error_get(ep->object))
2081 {
2082 case EVAS_LOAD_ERROR_GENERIC:
2083 ERR("Error type: EVAS_LOAD_ERROR_GENERIC");
2084 break;
2085 case EVAS_LOAD_ERROR_DOES_NOT_EXIST:
2086 ERR("Error type: EVAS_LOAD_ERROR_DOES_NOT_EXIST");
2087 break;
2088 case EVAS_LOAD_ERROR_PERMISSION_DENIED:
2089 ERR("Error type: EVAS_LOAD_ERROR_PERMISSION_DENIED");
2090 break;
2091 case EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED:
2092 ERR("Error type: EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED");
2093 break;
2094 case EVAS_LOAD_ERROR_CORRUPT_FILE:
2095 ERR("Error type: EVAS_LOAD_ERROR_CORRUPT_FILE");
2096 break;
2097 case EVAS_LOAD_ERROR_UNKNOWN_FORMAT:
2098 ERR("Error type: EVAS_LOAD_ERROR_UNKNOWN_FORMAT");
2099 break;
2100 default:
2101 ERR("Error type: ???");
2102 break;
2103 }
2104 }
2105 }
2106 }
2107}
2108
2109static Edje_Real_Part *
2110_edje_real_part_state_get(Edje *ed, Edje_Real_Part *ep, int flags, int id, int *state)
2111{
2112 Edje_Real_Part *result = NULL;
2113
2114 if (id >= 0 && id != ep->part->id)
2115 {
2116 result = ed->table_parts[id % ed->table_parts_size];
2117 if (result)
2118 {
2119 if (!result->calculated) _edje_part_recalc(ed, result, flags, NULL);
2120#ifdef EDJE_CALC_CACHE
2121 if (state) *state = result->state;
2122#else
2123 (void) state;
2124#endif
2125 }
2126 }
2127 return result;
2128}
2129
2130void
2131_edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *state)
2132{
2133#ifdef EDJE_CALC_CACHE
2134 Eina_Bool proxy_invalidate = EINA_FALSE;
2135 int state1 = -1;
2136 int state2 = -1;
2137 int statec = -1;
2138#else
2139 Edje_Calc_Params lp1, lp2;
2140#endif
2141 int statec1 = -1;
2142 int statec2 = -1;
2143 int statel1 = -1;
2144 int statel2 = -1;
2145 int statep1 = -1;
2146 int statep2 = -1;
2147 Edje_Real_Part *center[2] = { NULL, NULL };
2148 Edje_Real_Part *light[2] = { NULL, NULL };
2149 Edje_Real_Part *persp[2] = { NULL, NULL };
2150 Edje_Calc_Params *p1, *pf;
2151 Edje_Part_Description_Common *chosen_desc;
2152 Edje_Real_Part *confine_to = NULL;
2153 FLOAT_T pos = ZERO, pos2;
2154 Edje_Calc_Params lp3;
2155
2156 /* GRADIENT ARE GONE, WE MUST IGNORE IT FROM OLD FILE. */
2157 if (ep->part->type == EDJE_PART_TYPE_GRADIENT)
2158 {
2159 ERR("GRADIENT spotted during recalc ! That should never happen ! Send your edje file to devel ml.");
2160 return;
2161 }
2162
2163 if ((ep->calculated & FLAG_XY) == FLAG_XY && !state)
2164 {
2165 return;
2166 }
2167 if (ep->calculating & flags)
2168 {
2169#if 1
2170 const char *axes = "NONE", *faxes = "NONE";
2171
2172 if ((ep->calculating & FLAG_X) &&
2173 (ep->calculating & FLAG_Y))
2174 axes = "XY";
2175 else if ((ep->calculating & FLAG_X))
2176 axes = "X";
2177 else if ((ep->calculating & FLAG_Y))
2178 axes = "Y";
2179
2180 if ((flags & FLAG_X) &&
2181 (flags & FLAG_Y))
2182 faxes = "XY";
2183 else if ((flags & FLAG_X))
2184 faxes = "X";
2185 else if ((flags & FLAG_Y))
2186 faxes = "Y";
2187 ERR("Circular dependency when calculating part \"%s\". "
2188 "Already calculating %s [%02x] axes. "
2189 "Need to calculate %s [%02x] axes",
2190 ep->part->name,
2191 axes, ep->calculating,
2192 faxes, flags);
2193#endif
2194 return;
2195 }
2196#ifdef EDJE_CALC_CACHE
2197 if (ep->state == ed->state && !state)
2198 return ;
2199#endif
2200
2201 if (flags & FLAG_X)
2202 {
2203 ep->calculating |= flags & FLAG_X;
2204 if (ep->param1.rel1_to_x)
2205 {
2206 _edje_part_recalc(ed, ep->param1.rel1_to_x, FLAG_X, NULL);
2207#ifdef EDJE_CALC_CACHE
2208 state1 = ep->param1.rel1_to_x->state;
2209#endif
2210 }
2211 if (ep->param1.rel2_to_x)
2212 {
2213 _edje_part_recalc(ed, ep->param1.rel2_to_x, FLAG_X, NULL);
2214#ifdef EDJE_CALC_CACHE
2215 if (state1 < ep->param1.rel2_to_x->state)
2216 state1 = ep->param1.rel2_to_x->state;
2217#endif
2218 }
2219 if (ep->param2)
2220 {
2221 if (ep->param2->rel1_to_x)
2222 {
2223 _edje_part_recalc(ed, ep->param2->rel1_to_x, FLAG_X, NULL);
2224#ifdef EDJE_CALC_CACHE
2225 state2 = ep->param2->rel1_to_x->state;
2226#endif
2227 }
2228 if (ep->param2->rel2_to_x)
2229 {
2230 _edje_part_recalc(ed, ep->param2->rel2_to_x, FLAG_X, NULL);
2231#ifdef EDJE_CALC_CACHE
2232 if (state2 < ep->param2->rel2_to_x->state)
2233 state2 = ep->param2->rel2_to_x->state;
2234#endif
2235 }
2236 }
2237 }
2238 if (flags & FLAG_Y)
2239 {
2240 ep->calculating |= flags & FLAG_Y;
2241 if (ep->param1.rel1_to_y)
2242 {
2243 _edje_part_recalc(ed, ep->param1.rel1_to_y, FLAG_Y, NULL);
2244#ifdef EDJE_CALC_CACHE
2245 if (state1 < ep->param1.rel1_to_y->state)
2246 state1 = ep->param1.rel1_to_y->state;
2247#endif
2248 }
2249 if (ep->param1.rel2_to_y)
2250 {
2251 _edje_part_recalc(ed, ep->param1.rel2_to_y, FLAG_Y, NULL);
2252#ifdef EDJE_CALC_CACHE
2253 if (state1 < ep->param1.rel2_to_y->state)
2254 state1 = ep->param1.rel2_to_y->state;
2255#endif
2256 }
2257 if (ep->param2)
2258 {
2259 if (ep->param2->rel1_to_y)
2260 {
2261 _edje_part_recalc(ed, ep->param2->rel1_to_y, FLAG_Y, NULL);
2262#ifdef EDJE_CALC_CACHE
2263 if (state2 < ep->param2->rel1_to_y->state)
2264 state2 = ep->param2->rel1_to_y->state;
2265#endif
2266 }
2267 if (ep->param2->rel2_to_y)
2268 {
2269 _edje_part_recalc(ed, ep->param2->rel2_to_y, FLAG_Y, NULL);
2270#ifdef EDJE_CALC_CACHE
2271 if (state2 < ep->param2->rel2_to_y->state)
2272 state2 = ep->param2->rel2_to_y->state;
2273#endif
2274 }
2275 }
2276 }
2277 if (ep->drag && ep->drag->confine_to)
2278 {
2279 confine_to = ep->drag->confine_to;
2280 _edje_part_recalc(ed, confine_to, flags, NULL);
2281#ifdef EDJE_CALC_CACHE
2282 statec = confine_to->state;
2283#endif
2284 }
2285// if (ep->text.source) _edje_part_recalc(ed, ep->text.source, flags);
2286// if (ep->text.text_source) _edje_part_recalc(ed, ep->text.text_source, flags);
2287
2288 /* actually calculate now */
2289 chosen_desc = ep->chosen_description;
2290 if (!chosen_desc)
2291 {
2292 ep->calculating = FLAG_NONE;
2293 ep->calculated |= flags;
2294 return;
2295 }
2296
2297 if (ep->part->type == EDJE_PART_TYPE_PROXY)
2298 {
2299 Edje_Real_Part *pp;
2300 int part_id = -1;
2301
2302 if (pos >= 0.5)
2303 part_id = ((Edje_Part_Description_Proxy*) ep->param2->description)->proxy.id;
2304 else
2305 part_id = ((Edje_Part_Description_Proxy*) chosen_desc)->proxy.id;
2306
2307 pp = _edje_real_part_state_get(ed, ep, flags, part_id, NULL);
2308 if (pp && pp->invalidate) proxy_invalidate = EINA_TRUE;
2309 }
2310
2311 /* Recalc if needed the map center && light source */
2312 if (ep->param1.description->map.on)
2313 {
2314 center[0] = _edje_real_part_state_get(ed, ep, flags, ep->param1.description->map.rot.id_center, &statec1);
2315 light[0] = _edje_real_part_state_get(ed, ep, flags, ep->param1.description->map.id_light, &statel1);
2316
2317 if (chosen_desc->map.persp_on)
2318 {
2319 persp[0] = _edje_real_part_state_get(ed, ep, flags, ep->param1.description->map.id_persp, &statep1);
2320 }
2321 }
2322
2323 if (ep->param2 && ep->param2->description->map.on)
2324 {
2325 center[1] = _edje_real_part_state_get(ed, ep, flags, ep->param2->description->map.rot.id_center, &statec2);
2326 light[1] = _edje_real_part_state_get(ed, ep, flags, ep->param2->description->map.id_light, &statel2);
2327
2328 if (chosen_desc->map.persp_on)
2329 {
2330 persp[1] = _edje_real_part_state_get(ed, ep, flags, ep->param2->description->map.id_persp, &statep2);
2331 }
2332 }
2333
2334#ifndef EDJE_CALC_CACHE
2335 p1 = &lp1;
2336#else
2337 p1 = &ep->param1.p;
2338#endif
2339
2340 if (ep->param1.description)
2341 {
2342#ifdef EDJE_CALC_CACHE
2343 if (ed->all_part_change ||
2344 ep->invalidate ||
2345 state1 >= ep->param1.state ||
2346 statec >= ep->param1.state ||
2347 statec1 >= ep->param1.state ||
2348 statel1 >= ep->param1.state ||
2349 statep1 >= ep->param1.state ||
2350 proxy_invalidate ||
2351 state ||
2352 ((ep->part->type == EDJE_PART_TYPE_TEXT || ep->part->type == EDJE_PART_TYPE_TEXTBLOCK) && ed->text_part_change))
2353#endif
2354 {
2355 _edje_part_recalc_single(ed, ep, ep->param1.description, chosen_desc, center[0], light[0], persp[0],
2356 ep->param1.rel1_to_x, ep->param1.rel1_to_y, ep->param1.rel2_to_x, ep->param1.rel2_to_y,
2357 confine_to,
2358 p1);
2359
2360#ifdef EDJE_CALC_CACHE
2361 ep->param1.state = ed->state;
2362#endif
2363 }
2364 }
2365 if (ep->param2)
2366 {
2367 int beginning_pos, part_type;
2368 Edje_Calc_Params *p2, *p3;
2369
2370 if (ep->current)
2371 {
2372 /* FIXME: except for text, we don't need in that case to recalc p1 at all*/
2373 memcpy(p1, ep->current, sizeof (Edje_Calc_Params));
2374 p1->x += ed->x;
2375 p1->y += ed->y;
2376 p1->map.center.x += ed->x;
2377 p1->map.center.y += ed->y;
2378 p1->map.light.x += ed->x;
2379 p1->map.light.y += ed->y;
2380 p1->map.persp.x += ed->x;
2381 p1->map.persp.y += ed->y;
2382 }
2383
2384 p3 = &lp3;
2385
2386#ifndef EDJE_CALC_CACHE
2387 p2 = &lp2;
2388#else
2389 p2 = &ep->param2->p;
2390
2391 if (ed->all_part_change ||
2392 ep->invalidate ||
2393 state2 >= ep->param2->state ||
2394 statec >= ep->param2->state ||
2395 statec2 >= ep->param2->state ||
2396 statel2 >= ep->param2->state ||
2397 statep2 >= ep->param2->state ||
2398 proxy_invalidate ||
2399 state ||
2400 ((ep->part->type == EDJE_PART_TYPE_TEXT || ep->part->type == EDJE_PART_TYPE_TEXTBLOCK) && ed->text_part_change))
2401#endif
2402 {
2403 _edje_part_recalc_single(ed, ep, ep->param2->description, chosen_desc, center[1], light[1], persp[1],
2404 ep->param2->rel1_to_x, ep->param2->rel1_to_y, ep->param2->rel2_to_x, ep->param2->rel2_to_y,
2405 confine_to,
2406 p2);
2407#ifdef EDJE_CALC_CACHE
2408 ep->param2->state = ed->state;
2409#endif
2410 }
2411
2412 pos = ep->description_pos;
2413 pos2 = pos;
2414 if (pos2 < ZERO) pos2 = ZERO;
2415 else if (pos2 > FROM_INT(1)) pos2 = FROM_INT(1);
2416 beginning_pos = (pos < FROM_DOUBLE(0.5));
2417 part_type = ep->part->type;
2418
2419 /* visible is special */
2420 if ((p1->visible) && (!p2->visible))
2421 p3->visible = (pos != FROM_INT(1));
2422 else if ((!p1->visible) && (p2->visible))
2423 p3->visible = (pos != ZERO);
2424 else
2425 p3->visible = p1->visible;
2426
2427 p3->smooth = (beginning_pos) ? p1->smooth : p2->smooth;
2428
2429 /* FIXME: do x and y separately base on flag */
2430#define FINTP(_x1, _x2, _p) \
2431 (((_x1) == (_x2)) \
2432 ? FROM_INT((_x1)) \
2433 : ADD(FROM_INT(_x1), \
2434 SCALE((_p), (_x2) - (_x1))))
2435
2436#define FFP(_x1, _x2, _p) \
2437 (((_x1) == (_x2)) \
2438 ? (_x1) \
2439 : ADD(_x1, MUL(_p, SUB(_x2, _x1))));
2440
2441#define INTP(_x1, _x2, _p) TO_INT(FINTP(_x1, _x2, _p))
2442
2443 p3->x = INTP(p1->x, p2->x, pos);
2444 p3->y = INTP(p1->y, p2->y, pos);
2445 p3->w = INTP(p1->w, p2->w, pos);
2446 p3->h = INTP(p1->h, p2->h, pos);
2447
2448 p3->req.x = INTP(p1->req.x, p2->req.x, pos);
2449 p3->req.y = INTP(p1->req.y, p2->req.y, pos);
2450 p3->req.w = INTP(p1->req.w, p2->req.w, pos);
2451 p3->req.h = INTP(p1->req.h, p2->req.h, pos);
2452
2453 if (ep->part->dragable.x)
2454 {
2455 p3->req_drag.x = INTP(p1->req_drag.x, p2->req_drag.x, pos);
2456 p3->req_drag.w = INTP(p1->req_drag.w, p2->req_drag.w, pos);
2457 }
2458 if (ep->part->dragable.y)
2459 {
2460 p3->req_drag.y = INTP(p1->req_drag.y, p2->req_drag.y, pos);
2461 p3->req_drag.h = INTP(p1->req_drag.h, p2->req_drag.h, pos);
2462 }
2463
2464 p3->color.r = INTP(p1->color.r, p2->color.r, pos2);
2465 p3->color.g = INTP(p1->color.g, p2->color.g, pos2);
2466 p3->color.b = INTP(p1->color.b, p2->color.b, pos2);
2467 p3->color.a = INTP(p1->color.a, p2->color.a, pos2);
2468
2469 switch (part_type)
2470 {
2471 case EDJE_PART_TYPE_IMAGE:
2472 p3->type.common.spec.image.l = INTP(p1->type.common.spec.image.l, p2->type.common.spec.image.l, pos);
2473 p3->type.common.spec.image.r = INTP(p1->type.common.spec.image.r, p2->type.common.spec.image.r, pos);
2474 p3->type.common.spec.image.t = INTP(p1->type.common.spec.image.t, p2->type.common.spec.image.t, pos);
2475 p3->type.common.spec.image.b = INTP(p1->type.common.spec.image.b, p2->type.common.spec.image.b, pos);
2476 case EDJE_PART_TYPE_PROXY:
2477 p3->type.common.fill.x = INTP(p1->type.common.fill.x, p2->type.common.fill.x, pos);
2478 p3->type.common.fill.y = INTP(p1->type.common.fill.y, p2->type.common.fill.y, pos);
2479 p3->type.common.fill.w = INTP(p1->type.common.fill.w, p2->type.common.fill.w, pos);
2480 p3->type.common.fill.h = INTP(p1->type.common.fill.h, p2->type.common.fill.h, pos);
2481 break;
2482 case EDJE_PART_TYPE_TEXT:
2483 p3->type.text.size = INTP(p1->type.text.size, p2->type.text.size, pos);
2484 case EDJE_PART_TYPE_TEXTBLOCK:
2485 p3->type.text.color2.r = INTP(p1->type.text.color2.r, p2->type.text.color2.r, pos2);
2486 p3->type.text.color2.g = INTP(p1->type.text.color2.g, p2->type.text.color2.g, pos2);
2487 p3->type.text.color2.b = INTP(p1->type.text.color2.b, p2->type.text.color2.b, pos2);
2488 p3->type.text.color2.a = INTP(p1->type.text.color2.a, p2->type.text.color2.a, pos2);
2489
2490 p3->type.text.color3.r = INTP(p1->type.text.color3.r, p2->type.text.color3.r, pos2);
2491 p3->type.text.color3.g = INTP(p1->type.text.color3.g, p2->type.text.color3.g, pos2);
2492 p3->type.text.color3.b = INTP(p1->type.text.color3.b, p2->type.text.color3.b, pos2);
2493 p3->type.text.color3.a = INTP(p1->type.text.color3.a, p2->type.text.color3.a, pos2);
2494
2495 p3->type.text.align.x = FFP(p1->type.text.align.x, p2->type.text.align.x, pos);
2496 p3->type.text.align.y = FFP(p1->type.text.align.y, p2->type.text.align.y, pos);
2497 p3->type.text.elipsis = TO_DOUBLE(FINTP(p1->type.text.elipsis, p2->type.text.elipsis, pos2));
2498 break;
2499 }
2500
2501 p3->mapped = p1->mapped;
2502 p3->persp_on = p3->mapped ? p1->persp_on | p2->persp_on : 0;
2503 p3->lighted = p3->mapped ? p1->lighted | p2->lighted : 0;
2504 if (p1->mapped)
2505 {
2506 p3->map.center.x = INTP(p1->map.center.x, p2->map.center.x, pos);
2507 p3->map.center.y = INTP(p1->map.center.y, p2->map.center.y, pos);
2508 p3->map.center.z = INTP(p1->map.center.z, p2->map.center.z, pos);
2509 p3->map.rotation.x = FFP(p1->map.rotation.x, p2->map.rotation.x, pos);
2510 p3->map.rotation.y = FFP(p1->map.rotation.y, p2->map.rotation.y, pos);
2511 p3->map.rotation.z = FFP(p1->map.rotation.z, p2->map.rotation.z, pos);
2512
2513#define MIX(P1, P2, P3, pos, info) \
2514 P3->info = P1->info + TO_INT(SCALE(pos, P2->info - P1->info));
2515
2516 if (p1->lighted && p2->lighted)
2517 {
2518 MIX(p1, p2, p3, pos, map.light.x);
2519 MIX(p1, p2, p3, pos, map.light.y);
2520 MIX(p1, p2, p3, pos, map.light.z);
2521 MIX(p1, p2, p3, pos, map.light.r);
2522 MIX(p1, p2, p3, pos, map.light.g);
2523 MIX(p1, p2, p3, pos, map.light.b);
2524 MIX(p1, p2, p3, pos, map.light.ar);
2525 MIX(p1, p2, p3, pos, map.light.ag);
2526 MIX(p1, p2, p3, pos, map.light.ab);
2527 }
2528 else if (p1->lighted)
2529 {
2530 memcpy(&p3->map.light, &p1->map.light, sizeof (p1->map.light));
2531 }
2532 else if (p2->lighted)
2533 {
2534 memcpy(&p3->map.light, &p2->map.light, sizeof (p2->map.light));
2535 }
2536
2537 if (p1->persp_on && p2->persp_on)
2538 {
2539 MIX(p1, p2, p3, pos, map.persp.x);
2540 MIX(p1, p2, p3, pos, map.persp.y);
2541 MIX(p1, p2, p3, pos, map.persp.z);
2542 MIX(p1, p2, p3, pos, map.persp.focal);
2543 }
2544 else if (p1->persp_on)
2545 {
2546 memcpy(&p3->map.persp, &p1->map.persp, sizeof (p1->map.light));
2547 }
2548 else if (p2->persp_on)
2549 {
2550 memcpy(&p3->map.persp, &p2->map.persp, sizeof (p2->map.light));
2551 }
2552 }
2553
2554 pf = p3;
2555 }
2556 else
2557 {
2558 pf = p1;
2559 }
2560
2561 if (!pf->persp_on && chosen_desc->map.persp_on)
2562 {
2563 if (ed->persp)
2564 {
2565 pf->map.persp.x = ed->persp->px;
2566 pf->map.persp.y = ed->persp->py;
2567 pf->map.persp.z = ed->persp->z0;
2568 pf->map.persp.focal = ed->persp->foc;
2569 }
2570 else
2571 {
2572 const Edje_Perspective *ps;
2573
2574 // fixme: a tad inefficient as this is a has lookup
2575 ps = edje_object_perspective_get(ed->obj);
2576 if (!ps)
2577 ps = edje_evas_global_perspective_get(evas_object_evas_get(ed->obj));
2578 if (ps)
2579 {
2580 pf->map.persp.x = ps->px;
2581 pf->map.persp.y = ps->py;
2582 pf->map.persp.z = ps->z0;
2583 pf->map.persp.focal = ps->foc;
2584 }
2585 else
2586 {
2587 pf->map.persp.x = ed->x + (ed->w / 2);
2588 pf->map.persp.y = ed->y + (ed->h / 2);
2589 pf->map.persp.z = 0;
2590 pf->map.persp.focal = 1000;
2591 }
2592 }
2593 }
2594
2595 if (state)
2596 {
2597 memcpy(state, pf, sizeof (Edje_Calc_Params));
2598 }
2599
2600 ep->req = pf->req;
2601
2602 if (ep->drag && ep->drag->need_reset)
2603 {
2604 FLOAT_T dx, dy;
2605
2606 dx = ZERO;
2607 dy = ZERO;
2608 _edje_part_dragable_calc(ed, ep, &dx, &dy);
2609 ep->drag->x = dx;
2610 ep->drag->y = dy;
2611 ep->drag->tmp.x = 0;
2612 ep->drag->tmp.y = 0;
2613 ep->drag->need_reset = 0;
2614 }
2615 if (!ed->calc_only)
2616 {
2617 Evas_Object *mo;
2618
2619 /* Common move, resize and color_set for all part. */
2620 switch (ep->part->type)
2621 {
2622 case EDJE_PART_TYPE_IMAGE:
2623 {
2624 Edje_Part_Description_Image *img_desc = (Edje_Part_Description_Image*) chosen_desc;
2625
2626 evas_object_image_scale_hint_set(ep->object,
2627 img_desc->image.scale_hint);
2628 }
2629 case EDJE_PART_TYPE_PROXY:
2630 case EDJE_PART_TYPE_RECTANGLE:
2631 case EDJE_PART_TYPE_TEXTBLOCK:
2632 case EDJE_PART_TYPE_BOX:
2633 case EDJE_PART_TYPE_TABLE:
2634 evas_object_color_set(ep->object,
2635 (pf->color.r * pf->color.a) / 255,
2636 (pf->color.g * pf->color.a) / 255,
2637 (pf->color.b * pf->color.a) / 255,
2638 pf->color.a);
2639 if (!pf->visible)
2640 {
2641 evas_object_hide(ep->object);
2642 break;
2643 }
2644 evas_object_show(ep->object);
2645 /* move and resize are needed for all previous object => no break here. */
2646 case EDJE_PART_TYPE_SWALLOW:
2647 case EDJE_PART_TYPE_GROUP:
2648 case EDJE_PART_TYPE_EXTERNAL:
2649 /* visibility and color have no meaning on SWALLOW and GROUP part. */
2650 evas_object_move(ep->object, ed->x + pf->x, ed->y + pf->y);
2651 evas_object_resize(ep->object, pf->w, pf->h);
2652 if (ep->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
2653 _edje_entry_real_part_configure(ep);
2654 break;
2655 case EDJE_PART_TYPE_TEXT:
2656 /* This is correctly handle in _edje_text_recalc_apply at the moment. */
2657 break;
2658 case EDJE_PART_TYPE_GRADIENT:
2659 /* FIXME: definitivly remove this code when we switch to new format. */
2660 abort();
2661 break;
2662 }
2663
2664 /* Some object need special recalc. */
2665 switch (ep->part->type)
2666 {
2667 case EDJE_PART_TYPE_TEXT:
2668 _edje_text_recalc_apply(ed, ep, pf, (Edje_Part_Description_Text*) chosen_desc);
2669 break;
2670 case EDJE_PART_TYPE_PROXY:
2671 _edje_proxy_recalc_apply(ed, ep, pf, (Edje_Part_Description_Proxy*) chosen_desc, pos);
2672 break;
2673 case EDJE_PART_TYPE_IMAGE:
2674 _edje_image_recalc_apply(ed, ep, pf, (Edje_Part_Description_Image*) chosen_desc, pos);
2675 break;
2676 case EDJE_PART_TYPE_BOX:
2677 _edje_box_recalc_apply(ed, ep, pf, (Edje_Part_Description_Box*) chosen_desc);
2678 break;
2679 case EDJE_PART_TYPE_TABLE:
2680 _edje_table_recalc_apply(ed, ep, pf, (Edje_Part_Description_Table*) chosen_desc);
2681 break;
2682 case EDJE_PART_TYPE_EXTERNAL:
2683 case EDJE_PART_TYPE_RECTANGLE:
2684 case EDJE_PART_TYPE_SWALLOW:
2685 case EDJE_PART_TYPE_GROUP:
2686 case EDJE_PART_TYPE_TEXTBLOCK:
2687 /* Nothing special to do for this type of object. */
2688 break;
2689 case EDJE_PART_TYPE_GRADIENT:
2690 /* FIXME: definitivly remove this code when we switch to new format. */
2691 abort();
2692 break;
2693 }
2694
2695 if (ep->swallowed_object)
2696 {
2697//// the below really is wrong - swallow color shouldn't affect swallowed object
2698//// color - the edje color as a WHOLE should though - and that should be
2699//// done via the clipper anyway. this created bugs when objects had their
2700//// colro set and were swallowed - then had their color changed.
2701// evas_object_color_set(ep->swallowed_object,
2702// (pf->color.r * pf->color.a) / 255,
2703// (pf->color.g * pf->color.a) / 255,
2704// (pf->color.b * pf->color.a) / 255,
2705// pf->color.a);
2706 if (pf->visible)
2707 {
2708 evas_object_move(ep->swallowed_object, ed->x + pf->x, ed->y + pf->y);
2709 evas_object_resize(ep->swallowed_object, pf->w, pf->h);
2710 evas_object_show(ep->swallowed_object);
2711 }
2712 else evas_object_hide(ep->swallowed_object);
2713 mo = ep->swallowed_object;
2714 }
2715 else mo = ep->object;
2716 if (chosen_desc->map.on)
2717 {
2718 Evas_Map *map;
2719
2720 ed->have_mapped_part = 1;
2721 // create map and populate with part geometry
2722 map = evas_map_new(4);
2723 evas_map_util_points_populate_from_object(map, ep->object);
2724 if (ep->part->type == EDJE_PART_TYPE_IMAGE)
2725 {
2726 int iw = 1, ih = 1;
2727
2728 evas_object_image_size_get(mo, &iw, &ih);
2729 evas_map_point_image_uv_set(map, 0, 0.0, 0.0);
2730 evas_map_point_image_uv_set(map, 1, iw , 0.0);
2731 evas_map_point_image_uv_set(map, 2, iw , ih );
2732 evas_map_point_image_uv_set(map, 3, 0.0, ih );
2733 }
2734
2735 evas_map_util_3d_rotate(map,
2736 pf->map.rotation.x, pf->map.rotation.y, pf->map.rotation.z,
2737 pf->map.center.x, pf->map.center.y, pf->map.center.z);
2738
2739 // calculate light color & position etc. if there is one
2740 if (pf->lighted)
2741 {
2742 evas_map_util_3d_lighting(map,
2743 pf->map.light.x, pf->map.light.y, pf->map.light.z,
2744 pf->map.light.r, pf->map.light.g, pf->map.light.b,
2745 pf->map.light.ar, pf->map.light.ag, pf->map.light.ab);
2746 }
2747
2748 // calculate perspective point
2749 if (chosen_desc->map.persp_on)
2750 {
2751 evas_map_util_3d_perspective(map,
2752 pf->map.persp.x, pf->map.persp.y, pf->map.persp.z,
2753 pf->map.persp.focal);
2754 }
2755
2756 // handle backface culling (object is facing away from view
2757 if (chosen_desc->map.backcull)
2758 {
2759 if (pf->visible)
2760 {
2761 if (evas_map_util_clockwise_get(map))
2762 evas_object_show(mo);
2763 else evas_object_hide(mo);
2764 }
2765 }
2766
2767 // handle smooth
2768 if (chosen_desc->map.smooth) evas_map_smooth_set(map, 1);
2769 else evas_map_smooth_set(map, 0);
2770 // handle alpha
2771 if (chosen_desc->map.alpha) evas_map_alpha_set(map, 1);
2772 else evas_map_alpha_set(map, 0);
2773
2774 evas_object_map_set(mo, map);
2775 evas_object_map_enable_set(mo, 1);
2776 evas_map_free(map);
2777 }
2778 else
2779 {
2780 evas_object_map_enable_set(mo, 0);
2781 evas_object_map_set(mo, NULL);
2782 }
2783 }
2784
2785 ep->x = pf->x;
2786 ep->y = pf->y;
2787 ep->w = pf->w;
2788 ep->h = pf->h;
2789
2790 ep->calculated |= flags;
2791 ep->calculating = FLAG_NONE;
2792
2793#ifdef EDJE_CALC_CACHE
2794 if (ep->calculated == FLAG_XY)
2795 {
2796 ep->state = ed->state;
2797 ep->invalidate = 0;
2798 }
2799#endif
2800
2801}
diff --git a/libraries/edje/src/lib/edje_callbacks.c b/libraries/edje/src/lib/edje_callbacks.c
new file mode 100644
index 0000000..e0b0eae
--- /dev/null
+++ b/libraries/edje/src/lib/edje_callbacks.c
@@ -0,0 +1,546 @@
1#include "edje_private.h"
2
3static void
4_edje_hold_signal_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info)
5{
6 Evas_Event_Hold *ev;
7 Edje *ed;
8 Edje_Real_Part *rp;
9
10 ev = event_info;
11 ed = data;
12 rp = evas_object_data_get(obj, "real_part");
13 if (!rp) return;
14 if (ev->hold)
15 _edje_emit(ed, "hold,on", rp->part->name);
16 else
17 _edje_emit(ed, "hold,off", rp->part->name);
18}
19
20static void
21_edje_focus_in_signal_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
22{
23 Edje *ed;
24 Edje_Real_Part *rp;
25
26 ed = data;
27 rp = evas_object_data_get(obj, "real_part");
28 if ((!rp) || (!ed))
29 return;
30
31 _edje_emit(ed, "focus,part,in", rp->part->name);
32}
33
34static void
35_edje_focus_out_signal_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
36{
37 Edje *ed;
38 Edje_Real_Part *rp;
39
40 ed = data;
41 rp = evas_object_data_get(obj, "real_part");
42 if ((!rp) || (!ed))
43 return;
44
45 _edje_emit(ed, "focus,part,out", rp->part->name);
46}
47
48static void
49_edje_mouse_in_signal_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info)
50{
51 Evas_Event_Mouse_In *ev;
52 Edje *ed;
53 Edje_Real_Part *rp;
54
55 ev = event_info;
56 ed = data;
57 rp = evas_object_data_get(obj, "real_part");
58 if ((!rp) ||
59 ((ev->event_flags) &&
60 (rp->part->ignore_flags & ev->event_flags))) return;
61 _edje_emit(ed, "mouse,in", rp->part->name);
62}
63
64static void
65_edje_mouse_out_signal_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info)
66{
67 Evas_Event_Mouse_Out *ev;
68 Edje *ed;
69 Edje_Real_Part *rp;
70
71 ev = event_info;
72 ed = data;
73 rp = evas_object_data_get(obj, "real_part");
74 if ((!rp) ||
75 ((ev->event_flags) &&
76 (rp->part->ignore_flags & ev->event_flags))) return;
77 _edje_emit(ed, "mouse,out", rp->part->name);
78}
79
80static void
81_edje_mouse_down_signal_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info)
82{
83 Evas_Event_Mouse_Down *ev;
84 Edje *ed;
85 Edje_Real_Part *rp;
86 char buf[256];
87 int ignored;
88
89 ev = event_info;
90 ed = data;
91 rp = evas_object_data_get(obj, "real_part");
92 if (!rp) return;
93
94 ignored = rp->part->ignore_flags & ev->event_flags;
95
96 _edje_ref(ed);
97 _edje_freeze(ed);
98
99 if ((!ev->event_flags) || (!ignored))
100 {
101 if (ev->flags & EVAS_BUTTON_TRIPLE_CLICK)
102 snprintf(buf, sizeof(buf), "mouse,down,%i,triple", ev->button);
103 else if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
104 snprintf(buf, sizeof(buf), "mouse,down,%i,double", ev->button);
105 else
106 snprintf(buf, sizeof(buf), "mouse,down,%i", ev->button);
107 _edje_emit(ed, buf, rp->part->name);
108 }
109
110 if (rp->events_to)
111 {
112 int x = 0, y = 0;
113 Edje_Real_Part *events;
114
115 events = rp->events_to;
116 evas_object_geometry_get(rp->object, &x, &y, NULL, NULL);
117
118 if ((events->part->dragable.x) || (events->part->dragable.y))
119 {
120 if (events->part->dragable.x)
121 {
122 events->drag->down.x = ev->canvas.x;
123 events->drag->tmp.x = 0;
124 }
125 if (events->part->dragable.y)
126 {
127 events->drag->down.y = ev->canvas.y;
128 events->drag->tmp.y = 0;
129 }
130
131 if (!ignored)
132 {
133 snprintf(buf, sizeof(buf), "mouse,down,%i", ev->button);
134 _edje_emit(ed, buf, events->part->name);
135 }
136 ed->dirty = 1;
137#ifdef EDJE_CALC_CACHE
138 rp->invalidate = 1;
139#endif
140 }
141 _edje_recalc_do(ed);
142 /*
143 _edje_thaw(ed);
144 _edje_unref(ed);
145 _edje_ref(ed);
146 _edje_freeze(ed);
147 */
148 rp = events;
149 {
150 FLOAT_T dx = ZERO, dy = ZERO;
151
152 _edje_part_dragable_calc(ed, rp, &dx, &dy);
153
154 if ((dx != rp->drag->val.x) || (dy != rp->drag->val.y))
155 {
156 rp->drag->val.x = dx;
157 rp->drag->val.y = dy;
158 if (!ignored)
159 _edje_emit(ed, "drag", rp->part->name);
160 ed->dirty = 1;
161#ifdef EDJE_CALC_CACHE
162 rp->invalidate = 1;
163#endif
164 rp->drag->need_reset = 1;
165 _edje_recalc_do(ed);
166 }
167 }
168 }
169
170 if (rp->drag)
171 {
172 if (rp->drag->down.count == 0)
173 {
174 if (rp->part->dragable.x)
175 rp->drag->down.x = ev->canvas.x;
176 if (rp->part->dragable.y)
177 rp->drag->down.y = ev->canvas.y;
178 if (!ignored)
179 _edje_emit(ed, "drag,start", rp->part->name);
180 }
181 rp->drag->down.count++;
182 }
183
184 if (rp->clicked_button == 0)
185 {
186 rp->clicked_button = ev->button;
187 if (!(ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD))
188 rp->still_in = 1;
189 }
190// _edje_recalc_do(ed);
191 _edje_thaw(ed);
192 _edje_unref(ed);
193}
194
195static void
196_edje_mouse_up_signal_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info)
197{
198 Evas_Event_Mouse_Up *ev;
199 Edje *ed;
200 Edje_Real_Part *rp;
201 char buf[256];
202 int ignored;
203
204 ev = event_info;
205 ed = data;
206 rp = evas_object_data_get(obj, "real_part");
207 if (!rp) return;
208
209 ignored = rp->part->ignore_flags & ev->event_flags;
210
211 _edje_ref(ed);
212 _edje_freeze(ed);
213
214 if ((!ev->event_flags) || (!ignored))
215 {
216 snprintf(buf, sizeof(buf), "mouse,up,%i", ev->button);
217 _edje_emit(ed, buf, rp->part->name);
218 }
219
220 if (rp->events_to)
221 {
222 rp = rp->events_to;
223 if (!ignored)
224 {
225 snprintf(buf, sizeof(buf), "mouse,up,%i", ev->button);
226 _edje_emit(ed, buf, rp->part->name);
227 }
228 }
229
230 if (rp->drag)
231 {
232 if (rp->drag->down.count > 0)
233 {
234 rp->drag->down.count--;
235 if (rp->drag->down.count == 0)
236 {
237 rp->drag->need_reset = 1;
238 ed->dirty = 1;
239#ifdef EDJE_CALC_CACHE
240 rp->invalidate = 1;
241#endif
242 if (!ignored)
243 _edje_emit(ed, "drag,stop", rp->part->name);
244 }
245 }
246 }
247
248 if ((rp->still_in) && (rp->clicked_button == ev->button) && (!ignored))
249 {
250 snprintf(buf, sizeof(buf), "mouse,clicked,%i", ev->button);
251 _edje_emit(ed, buf, rp->part->name);
252 }
253 rp->clicked_button = 0;
254 rp->still_in = 0;
255
256// _edje_recalc_do(ed);
257 _edje_thaw(ed);
258 _edje_unref(ed);
259}
260
261static void
262_edje_mouse_move_signal_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info)
263{
264 Evas_Event_Mouse_Move *ev;
265 Edje *ed;
266 Edje_Real_Part *rp;
267 int ignored;
268
269 ev = event_info;
270 ed = data;
271 rp = evas_object_data_get(obj, "real_part");
272 if (!rp) return;
273 if (rp->events_to) rp = rp->events_to;
274
275 ignored = rp->part->ignore_flags & ev->event_flags;
276
277 _edje_ref(ed);
278 if ((!ev->event_flags) || (!ignored))
279 _edje_emit(ed, "mouse,move", rp->part->name);
280
281 if (rp->still_in)
282 {
283
284 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
285 rp->still_in = 0;
286 else
287 {
288 Evas_Coord x, y, w, h;
289
290 evas_object_geometry_get(obj, &x, &y, &w, &h);
291 if ((ev->cur.canvas.x < x) || (ev->cur.canvas.y < y) ||
292 (ev->cur.canvas.x >= (x + w)) || (ev->cur.canvas.y >= (y + h)))
293 rp->still_in = 0;
294 }
295 }
296 else
297 {
298 if (!(ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD))
299 {
300 Evas_Coord x, y, w, h;
301
302 evas_object_geometry_get(obj, &x, &y, &w, &h);
303 if ((ev->cur.canvas.x >= x) && (ev->cur.canvas.y >= y) &&
304 (ev->cur.canvas.x < (x + w)) && (ev->cur.canvas.y < (y + h)))
305 rp->still_in = 1;
306 }
307 }
308 _edje_freeze(ed);
309 if (rp->drag)
310 {
311 if (rp->drag->down.count > 0)
312 {
313 if (rp->part->dragable.x)
314 rp->drag->tmp.x = ev->cur.canvas.x - rp->drag->down.x;
315 if (rp->part->dragable.y)
316 rp->drag->tmp.y = ev->cur.canvas.y - rp->drag->down.y;
317 ed->dirty = 1;
318#ifdef EDJE_CALC_CACHE
319 rp->invalidate = 1;
320#endif
321 }
322 _edje_recalc_do(ed);
323
324 if (rp->drag->down.count > 0)
325 {
326 FLOAT_T dx, dy;
327
328 _edje_part_dragable_calc(ed, rp, &dx, &dy);
329 if ((dx != rp->drag->val.x) || (dy != rp->drag->val.y))
330 {
331 rp->drag->val.x = dx;
332 rp->drag->val.y = dy;
333 if (!ignored)
334 _edje_emit(ed, "drag", rp->part->name);
335 ed->dirty = 1;
336#ifdef EDJE_CALC_CACHE
337 rp->invalidate = 1;
338#endif
339 _edje_recalc_do(ed);
340 }
341 }
342 }
343 _edje_unref(ed);
344 _edje_thaw(ed);
345}
346
347static void
348_edje_mouse_wheel_signal_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info)
349{
350 Evas_Event_Mouse_Wheel *ev;
351 Edje *ed;
352 Edje_Real_Part *rp;
353 char buf[256];
354
355 ev = event_info;
356 ed = data;
357 rp = evas_object_data_get(obj, "real_part");
358 if ((!rp) ||
359 ((ev->event_flags) &&
360 (!(rp->part->ignore_flags & ev->event_flags)))) return;
361
362 snprintf(buf, sizeof(buf), "mouse,wheel,%i,%i", ev->direction, (ev->z < 0) ? (-1) : (1));
363 _edje_emit(ed, buf, rp->part->name);
364}
365
366Eina_Bool
367_edje_timer_cb(void *data __UNUSED__)
368{
369 double t;
370 Eina_List *l;
371 Eina_List *animl = NULL;
372 Edje *ed;
373
374 t = ecore_loop_time_get();
375 EINA_LIST_FOREACH(_edje_animators, l, ed)
376 {
377 _edje_ref(ed);
378 animl = eina_list_append(animl, ed);
379 }
380 while (animl)
381 {
382 Eina_List *newl = NULL;
383
384 ed = eina_list_data_get(animl);
385 _edje_block(ed);
386 _edje_freeze(ed);
387 animl = eina_list_remove(animl, eina_list_data_get(animl));
388 if ((!ed->paused) && (!ed->delete_me))
389 {
390 const void *tmp;
391
392 ed->walking_actions = 1;
393 EINA_LIST_FOREACH(ed->actions, l, tmp)
394 newl = eina_list_append(newl, tmp);
395 while (newl)
396 {
397 Edje_Running_Program *runp;
398
399 runp = eina_list_data_get(newl);
400 newl = eina_list_remove(newl, eina_list_data_get(newl));
401 if (!runp->delete_me)
402 _edje_program_run_iterate(runp, t);
403 if (_edje_block_break(ed))
404 {
405 eina_list_free(newl);
406 newl = NULL;
407 goto break_prog;
408 }
409 }
410 EINA_LIST_FOREACH(ed->actions, l, tmp)
411 newl = eina_list_append(newl, tmp);
412 while (newl)
413 {
414 Edje_Running_Program *runp;
415
416 runp = eina_list_data_get(newl);
417 newl = eina_list_remove(newl, eina_list_data_get(newl));
418 if (runp->delete_me)
419 {
420 _edje_anim_count--;
421 runp->edje->actions =
422 eina_list_remove(runp->edje->actions, runp);
423 if (!runp->edje->actions)
424 _edje_animators =
425 eina_list_remove(_edje_animators, runp->edje);
426 free(runp);
427 }
428 }
429 ed->walking_actions = 0;
430 }
431 break_prog:
432 _edje_unblock(ed);
433 _edje_thaw(ed);
434 _edje_unref(ed);
435 }
436 if (_edje_anim_count > 0) return ECORE_CALLBACK_RENEW;
437 _edje_timer = NULL;
438 return ECORE_CALLBACK_CANCEL;
439}
440
441Eina_Bool
442_edje_pending_timer_cb(void *data)
443{
444 Edje_Pending_Program *pp;
445
446 pp = data;
447 pp->edje->pending_actions = eina_list_remove(pp->edje->pending_actions, pp);
448 _edje_program_run(pp->edje, pp->program, 1, "", "");
449 free(pp);
450 return ECORE_CALLBACK_CANCEL;
451}
452
453void
454_edje_callbacks_add(Evas_Object *obj, Edje *ed, Edje_Real_Part *rp)
455{
456 evas_object_event_callback_add(obj,
457 EVAS_CALLBACK_HOLD,
458 _edje_hold_signal_cb,
459 ed);
460 evas_object_event_callback_add(obj,
461 EVAS_CALLBACK_MOUSE_IN,
462 _edje_mouse_in_signal_cb,
463 ed);
464 evas_object_event_callback_add(obj,
465 EVAS_CALLBACK_MOUSE_OUT,
466 _edje_mouse_out_signal_cb,
467 ed);
468 evas_object_event_callback_add(obj,
469 EVAS_CALLBACK_MOUSE_DOWN,
470 _edje_mouse_down_signal_cb,
471 ed);
472 evas_object_event_callback_add(obj,
473 EVAS_CALLBACK_MOUSE_UP,
474 _edje_mouse_up_signal_cb,
475 ed);
476 evas_object_event_callback_add(obj,
477 EVAS_CALLBACK_MOUSE_MOVE,
478 _edje_mouse_move_signal_cb,
479 ed);
480 evas_object_event_callback_add(obj,
481 EVAS_CALLBACK_MOUSE_WHEEL,
482 _edje_mouse_wheel_signal_cb,
483 ed);
484 evas_object_data_set(obj, "real_part", rp);
485}
486
487void
488_edje_callbacks_del(Evas_Object *obj, Edje *ed)
489{
490 evas_object_event_callback_del_full(obj,
491 EVAS_CALLBACK_HOLD,
492 _edje_hold_signal_cb,
493 ed);
494 evas_object_event_callback_del_full(obj,
495 EVAS_CALLBACK_MOUSE_IN,
496 _edje_mouse_in_signal_cb,
497 ed);
498 evas_object_event_callback_del_full(obj,
499 EVAS_CALLBACK_MOUSE_OUT,
500 _edje_mouse_out_signal_cb,
501 ed);
502 evas_object_event_callback_del_full(obj,
503 EVAS_CALLBACK_MOUSE_DOWN,
504 _edje_mouse_down_signal_cb,
505 ed);
506 evas_object_event_callback_del_full(obj,
507 EVAS_CALLBACK_MOUSE_UP,
508 _edje_mouse_up_signal_cb,
509 ed);
510 evas_object_event_callback_del_full(obj,
511 EVAS_CALLBACK_MOUSE_MOVE,
512 _edje_mouse_move_signal_cb,
513 ed);
514 evas_object_event_callback_del_full(obj,
515 EVAS_CALLBACK_MOUSE_WHEEL,
516 _edje_mouse_wheel_signal_cb,
517 ed);
518 evas_object_data_del(obj, "real_part");
519}
520
521void
522_edje_callbacks_focus_add(Evas_Object *obj, Edje *ed, Edje_Real_Part *rp)
523{
524 evas_object_event_callback_add(obj,
525 EVAS_CALLBACK_FOCUS_IN,
526 _edje_focus_in_signal_cb,
527 ed);
528 evas_object_event_callback_add(obj,
529 EVAS_CALLBACK_FOCUS_OUT,
530 _edje_focus_out_signal_cb,
531 ed);
532 evas_object_data_set(obj, "real_part", rp);
533}
534
535void
536_edje_callbacks_focus_del(Evas_Object *obj, Edje *ed)
537{
538 evas_object_event_callback_del_full(obj,
539 EVAS_CALLBACK_FOCUS_IN,
540 _edje_focus_in_signal_cb,
541 ed);
542 evas_object_event_callback_del_full(obj,
543 EVAS_CALLBACK_FOCUS_OUT,
544 _edje_focus_out_signal_cb,
545 ed);
546}
diff --git a/libraries/edje/src/lib/edje_container.c b/libraries/edje/src/lib/edje_container.c
new file mode 100644
index 0000000..357d607
--- /dev/null
+++ b/libraries/edje/src/lib/edje_container.c
@@ -0,0 +1,955 @@
1#include "edje_private.h"
2#include "edje_container.h"
3
4#if 0
5
6static void
7_edje_container_relayout(Smart_Data *sd)
8{
9 Eina_List *l;
10 Evas_Coord x, y, w, h, sw;
11 Edje_Item *ei;
12
13 if (sd->freeze > 0) return;
14 if (!sd->need_layout) return;
15
16 if (sd->w < sd->min_w) sw = sd->min_w;
17 else if (sd->w > sd->max_w) sw = sd->max_w;
18 else sw = sd->w;
19
20 y = 0;
21 x = 0;
22 w = 0;
23 h = 0;
24
25 EINA_LIST_FOREACH(sd->children, l, ei)
26 {
27 if (sd->homogenous) h = sd->min_row_h;
28
29 ei->y = y;
30 ei->h = h;
31// ei->w = w;
32// ei->h = h;
33 }
34
35 sd->need_layout = 0;
36}
37
38static void
39_edje_container_recalc(Smart_Data *sd)
40{
41 Eina_List *l;
42 Edje_Item *ei;
43 int any_max_h = 0, any_max_w = 0;
44 int i;
45
46 if (sd->freeze > 0) return;
47 if (!sd->changed) return;
48
49 sd->min_h = 0;
50 sd->max_h = -1;
51 sd->min_w = 0;
52 sd->max_w = -1;
53 sd->min_row_h = 0;
54 sd->max_row_h = -1;
55 sd->contents_h = 0;
56 sd->contents_w = 0;
57
58 for (i = 0; i < sd->cols; i++)
59 {
60 sd->min_w += sd->colinfo[i].minw;
61 if (sd->colinfo[i].maxw >= 0)
62 {
63 if (sd->max_w >= 0)
64 sd->max_w += sd->colinfo[i].maxw;
65 else
66 sd->max_w = sd->colinfo[i].maxw;
67 }
68 else
69 any_max_w = 1;
70 }
71 if (any_max_w) sd->max_w = -1;
72
73 if (sd->w < sd->min_w)
74 sd->contents_w = sd->min_w;
75 else if ((sd->max_w >= 0) && (sd->w < sd->max_w))
76 sd->w = sd->max_w;
77
78 EINA_LIST_FOREACH(sd->children, l, ei)
79 {
80 if (ei->minh > sd->min_row_h)
81 sd->min_row_h = ei->minh;
82 if (sd->max_row_h >= 0)
83 {
84 if (ei->maxh >= 0)
85 {
86 if (sd->max_row_h > ei->maxh)
87 sd->max_row_h = ei->maxh;
88 }
89 else
90 any_max_h = 1;
91 }
92 sd->min_h += ei->minh;
93 if (ei->maxh >= 0)
94 {
95 if (sd->max_h >= 0)
96 sd->max_h += ei->maxh;
97 else
98 sd->max_h = ei->maxh;
99 }
100 else
101 any_max_h = 1;
102 }
103 if (any_max_h)
104 {
105 sd->max_h = -1;
106 sd->max_row_h = -1;
107 }
108 if (sd->homogenous)
109 {
110 sd->min_h = eina_list_count(sd->children) * sd->min_row_h;
111 }
112
113 sd->changed = 0;
114 sd->change_child = 0;
115 sd->change_child_list = 0;
116 sd->change_cols = 0;
117
118 sd->need_layout = 1;
119 _edje_container_relayout(sd);
120}
121
122static void
123_edje_item_recalc(Edje_Item *ei)
124{
125 int i;
126
127 if (ei->freeze > 0) return;
128 if (!ei->recalc) return;
129 if (!ei->sd) return;
130
131 ei->minh = 0;
132 ei->maxh = -1;
133 for (i = 0; i < ((Smart_Data *)(ei->sd))->cols; i++)
134 {
135 if (ei->cells[i].minh > ei->minh) ei->minh = ei->cells[i].minh;
136 if (ei->cells[i].maxh >= 0)
137 {
138 if (ei->maxh >= 0)
139 {
140 if (ei->cells[i].maxh < ei->maxh)
141 ei->maxh = ei->cells[i].maxh;
142 }
143 else
144 ei->maxh = ei->cells[i].maxh;
145 }
146 if (((Smart_Data *)(ei->sd))->colinfo[i].minw < ei->cells[i].minw)
147 ((Smart_Data *)(ei->sd))->colinfo[i].minw = ei->cells[i].minw;
148 if (((Smart_Data *)(ei->sd))->colinfo[i].maxw >= 0)
149 {
150 if (ei->cells[i].maxw >= 0)
151 {
152 if (((Smart_Data *)(ei->sd))->colinfo[i].maxw > ei->cells[i].maxw)
153 ((Smart_Data *)(ei->sd))->colinfo[i].maxw = ei->cells[i].maxw;
154 }
155 }
156 else
157 ((Smart_Data *)(ei->sd))->colinfo[i].maxw = ei->cells[i].maxw;
158 }
159
160 ei->recalc = 0;
161
162 _edje_container_recalc(ei->sd);
163}
164
165
166/*****************************/
167/**
168 * @endcond
169 */
170
171/*============================================================================*
172 * Global *
173 *============================================================================*/
174
175/*============================================================================*
176 * API *
177 *============================================================================*/
178
179/**
180 * @addtogroup Edje_container_Group Container
181 *
182 * @brief These functions provides an abstraction layer between the application
183 * code and the interface, while allowing extremely flexible dynamic layouts
184 * and animations.
185 *
186 * For more information, you can look at the @ref tutorial_list_page.
187 *
188 * @{
189 */
190
191/**
192 * @brief Create an edje item.
193 *
194 * @param cl The edje item of type Edje_Item_Class.
195 * @param data The edje item data.
196 *
197 * @return The new edje item created.
198 *
199 * This function creates an new edje item. The edje item data can be
200 * retrieved with edje_item_data_get().
201 *
202 * @see edje_item_del()
203 * @see edje_item_data_set()
204 * @see edje_item_data_get()
205 *
206 */
207
208Edje_Item *
209edje_item_add(Edje_Item_Class *cl, void *data)
210{
211 Edje_Item *ei;
212
213 ei = calloc(sizeof(Edje_Item), 1);
214
215 ei->class = cl;
216 ei->class_data = data;
217
218 return ei;
219}
220
221/**
222 * @brief Delete an edje item.
223 *
224 * @param ei The edje item to be deleted.
225 *
226 * This function deletes the edje item from memory.
227 *
228 * @see edje_item_add()
229 * @see edje_item_data_set()
230 * @see edje_item_data_get()
231 *
232 */
233
234void
235edje_item_del(Edje_Item *ei)
236{
237 Smart_Data *sd;
238
239 sd = ei->sd;
240 if (ei->object) evas_object_del(ei->object);
241 if (ei->overlay_object) evas_object_del(ei->overlay_object);
242 free(ei);
243 if (!sd) return;
244 sd->changed = 1;
245 sd->change_child_list = 1;
246 _edje_container_recalc(sd);
247}
248
249/**
250 * @brief Return the smart object of the edje item.
251 *
252 * @param ei The edje item which the smart object of type Evas_Object is get
253 * from.
254 *
255 * This function returns the smart object in the edje item.
256 *
257 */
258
259Evas_Object *
260edje_item_container_get(Edje_Item *ei)
261{
262 if (!ei->sd) return NULL;
263 return ((Smart_Data *)(ei->sd))->smart_obj;
264}
265
266/* an arbitrary data pointer to use to track other data */
267/**
268 * @brief Set the edje item data.
269 *
270 * @param ei The edje item of type Edje_Item_Class.
271 * @param data The edje item data.
272 *
273 * This function set the data of the edje item. The edje item data can be
274 * retrieved with edje_item_data_get().
275 *
276 * @see edje_item_add()
277 * @see edje_item_del()
278 * @see edje_item_data_get()
279 *
280 */
281
282void
283edje_item_data_set(Edje_Item *ei, void *data)
284{
285 ei->data = data;
286}
287
288/**
289 * @brief Get the data of the edje item.
290 *
291 * @param ei The edje item of type Edje_Item_Class.
292 *
293 * This function get the data of the edje item set by edje_item_data_set().
294 *
295 * @see edje_item_data_set()
296 * @see edje_item_add()
297 * @see edje_item_del()
298 *
299 */
300
301void *
302edje_item_data_get(Edje_Item *ei)
303{
304 return ei->data;
305}
306
307/* this object covers the entire item */
308
309void
310edje_item_overlay_object_set(Edje_Item *ei, Evas_Object *obj)
311{
312 if (ei->overlay_object)
313 {
314 /* FIXME: if it changed - remove...*/
315 }
316 ei->overlay_object = obj;
317 if (ei->sd)
318 evas_object_smart_member_add(((Smart_Data *)(ei->sd))->smart_obj, obj);
319}
320
321
322
323Evas_Object *
324edje_item_overlay_object_get(Edje_Item *ei)
325{
326 return ei->overlay_object;
327}
328
329/* this object goes under entire item */
330void
331edje_item_object_set(Edje_Item *ei, Evas_Object *obj)
332{
333 if (ei->object)
334 {
335 /* FIXME: if it changed - remove...*/
336 }
337 ei->object = obj;
338 if (ei->sd)
339 evas_object_smart_member_add(((Smart_Data *)(ei->sd))->smart_obj, obj);
340}
341
342Evas_Object *
343edje_item_object_get(Edje_Item *ei)
344{
345 return ei->object;
346}
347
348/* optionally you can manage each column's object yourself OR let Edje do it */
349void
350edje_item_object_column_set(Edje_Item *ei, int col, Evas_Object *obj)
351{
352 if (ei->cells_num <= (col + 1))
353 {
354 /* FIXME: unsafe realloc */
355 ei->cells = realloc(ei->cells, sizeof(Edje_Item_Cell) * col);
356 ei->cells_num = col + 1;
357 }
358 ei->cells[col].obj = obj;
359}
360
361Evas_Object *
362edje_item_object_column_get(Edje_Item *ei, int col)
363{
364 if (ei->cells_num <= (col + 1)) return NULL;
365 return ei->cells[col].obj;
366}
367
368/* query the item for the items preferred co-ords */
369void
370edje_item_geometry_get(Edje_Item *ei, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
371{
372 if (!ei->sd)
373 {
374 if (x) *x = 0;
375 if (y) *y = 0;
376 if (w) *w = 0;
377 if (h) *h = 0;
378 return;
379 }
380 if (x) *x = ((Smart_Data *)(ei->sd))->x;
381 if (y) *y = ((Smart_Data *)(ei->sd))->y + ei->y;
382 if (w) *w = ((Smart_Data *)(ei->sd))->w;
383 if (h) *h = ei->h;
384}
385
386/* freeze and thaw items if u are about to do a bunch of changes */
387int
388edje_item_freeze(Edje_Item *ei)
389{
390 ei->freeze++;
391 return ei->freeze;
392}
393
394int
395edje_item_thaw(Edje_Item *ei)
396{
397 ei->freeze--;
398 if (ei->freeze > 0) return ei->freeze;
399 if (!ei->sd) return ei->freeze;
400 if (ei->recalc) _edje_item_recalc(ei);
401 return ei->freeze;
402}
403
404/* column info */
405void
406edje_item_column_size_set(Edje_Item *ei, int col, Evas_Coord minw, Evas_Coord maxw, Evas_Coord minh, Evas_Coord maxh)
407{
408 if (ei->cells_num <= (col + 1))
409 {
410 /* FIXME: unsafe realloc */
411 ei->cells = realloc(ei->cells, sizeof(Edje_Item_Cell) * col);
412 ei->cells_num = col + 1;
413 }
414 if ((ei->cells[col].minw == minw) &&
415 (ei->cells[col].minh == minh) &&
416 (ei->cells[col].maxw == maxw) &&
417 (ei->cells[col].maxh == maxh)) return;
418 ei->cells[col].minh = minh;
419 ei->cells[col].maxh = maxh;
420 ei->cells[col].minw = minw;
421 ei->cells[col].maxw = maxw;
422 ei->recalc = 1;
423 if (ei->sd)
424 {
425 ((Smart_Data *)(ei->sd))->changed = 1;
426 ((Smart_Data *)(ei->sd))->change_child = 1;
427 }
428 _edje_item_recalc(ei);
429}
430
431void
432edje_item_column_size_get(Edje_Item *ei, int col, Evas_Coord *minw, Evas_Coord *maxw, Evas_Coord *minh, Evas_Coord *maxh)
433{
434 if (ei->cells_num <= (col + 1))
435 {
436 if (minw) *minw = 0;
437 if (minh) *minh = 0;
438 if (maxw) *maxw = -1;
439 if (maxh) *maxh = -1;
440 }
441 if (minw) *minw = ei->cells[col].minw;
442 if (minh) *minh = ei->cells[col].minh;
443 if (maxw) *maxw = ei->cells[col].maxw;
444 if (maxh) *maxh = ei->cells[col].maxh;
445}
446
447/* selection stuff */
448void
449edje_item_select(Edje_Item *ei)
450{
451 ei->selected = 1;
452 /* FIXME: trigger item to change visually */
453}
454
455void
456edje_item_unselect(Edje_Item *ei)
457{
458 ei->selected = 0;
459 /* FIXME: trigger item to change visually */
460}
461
462/* focus stuff - only 1 can be focuesd */
463void
464edje_item_focus(Edje_Item *ei)
465{
466// ei->focused = 1;
467}
468
469void
470edje_item_unfocus(Edje_Item *ei)
471{
472// ei->focused = 0;
473}
474
475/* disable/enable stuff - stops focus and selection working on these items */
476void
477edje_item_enable(Edje_Item *ei)
478{
479// ei->disabled = 0;
480}
481
482void
483edje_item_disable(Edje_Item *ei)
484{
485// ei->disabled = 1;
486}
487
488/* item utils */
489int
490edje_item_selected_get(Edje_Item *ei)
491{
492 return ei->selected;
493}
494
495int
496edje_item_focused_get(Edje_Item *ei)
497{
498 return ei->focused;
499}
500
501int
502edje_item_disabled_get(Edje_Item *ei)
503{
504 return ei->disabled;
505}
506
507/***** container calls *****/
508
509int
510edje_container_freeze(Evas_Object *obj)
511{
512 Smart_Data *sd;
513
514 sd = evas_object_smart_data_get(obj);
515 if (!sd) return 0;
516 sd->freeze++;
517 return sd->freeze;
518}
519
520int
521edje_container_thaw(Evas_Object *obj)
522{
523 Smart_Data *sd;
524
525 sd = evas_object_smart_data_get(obj);
526 if (!sd) return 0;
527 sd->freeze--;
528 if (sd->freeze <= 0) _edje_container_recalc(sd);
529 return sd->freeze;
530}
531
532void
533edje_container_item_append(Evas_Object *obj, Edje_Item *ei)
534{
535 Smart_Data *sd;
536
537 sd = evas_object_smart_data_get(obj);
538 if (!sd) return;
539 sd->children = eina_list_append(sd->children, ei);
540 sd->changed = 1;
541 sd->change_child_list = 1;
542 sd->rows = eina_list_count(sd->children);
543 _edje_container_recalc(sd);
544}
545
546void
547edje_container_item_prepend(Evas_Object *obj, Edje_Item *ei)
548{
549 Smart_Data *sd;
550
551 sd = evas_object_smart_data_get(obj);
552 if (!sd) return;
553 sd->children = eina_list_prepend(sd->children, ei);
554 sd->changed = 1;
555 sd->change_child_list = 1;
556 sd->rows = eina_list_count(sd->children);
557 _edje_container_recalc(sd);
558}
559
560void
561edje_container_item_append_relative(Evas_Object *obj, Edje_Item *ei, Edje_Item *rel)
562{
563 Smart_Data *sd;
564
565 sd = evas_object_smart_data_get(obj);
566 if (!sd) return;
567 sd->children = eina_list_append_relative(sd->children, ei, rel);
568 sd->changed = 1;
569 sd->change_child_list = 1;
570 sd->rows = eina_list_count(sd->children);
571 _edje_container_recalc(sd);
572}
573
574void
575edje_container_item_prepend_relative(Evas_Object *obj, Edje_Item *ei, Edje_Item *rel)
576{
577 Smart_Data *sd;
578
579 sd = evas_object_smart_data_get(obj);
580 if (!sd) return;
581 sd->children = eina_list_prepend_relative(sd->children, ei, rel);
582 sd->changed = 1;
583 sd->change_child_list = 1;
584 sd->rows = eina_list_count(sd->children);
585 _edje_container_recalc(sd);
586}
587
588void
589edje_container_item_insert(Evas_Object *obj, Edje_Item *ei, int n)
590{
591 Smart_Data *sd;
592 void *rel;
593
594 sd = evas_object_smart_data_get(obj);
595 if (!sd) return;
596 rel = eina_list_nth(sd->children, n);
597 if (!rel)
598 sd->children = eina_list_append(sd->children, ei);
599 else
600 sd->children = eina_list_append_relative(sd->children, ei, rel);
601 sd->changed = 1;
602 sd->change_child_list = 1;
603 sd->rows = eina_list_count(sd->children);
604 _edje_container_recalc(sd);
605}
606
607void
608edje_container_item_remove(Evas_Object *obj, Edje_Item *ei)
609{
610 Smart_Data *sd;
611
612 sd = evas_object_smart_data_get(obj);
613 if (!sd) return;
614 sd->children = eina_list_remove(sd->children, ei);
615 sd->changed = 1;
616 sd->change_child_list = 1;
617 sd->rows = eina_list_count(sd->children);
618 _edje_container_recalc(sd);
619}
620
621void
622edje_container_columns_set(Evas_Object *obj, int cols)
623{
624 Smart_Data *sd;
625
626 sd = evas_object_smart_data_get(obj);
627 if (!sd) return;
628 if (sd->cols == cols) return;
629 sd->colinfo = realloc(sd->colinfo, cols * sizeof(Smart_Data_Colinfo));
630 if (cols > sd->cols)
631 {
632 int i;
633
634 for (i = sd->cols; i < cols; i++)
635 {
636 sd->colinfo[i].minw = 0;
637 sd->colinfo[i].maxw = -1;
638 }
639 }
640 sd->cols = cols;
641 sd->changed = 1;
642 sd->change_cols = 1;
643 _edje_container_recalc(sd);
644}
645
646int
647edje_container_columns_get(Evas_Object *obj)
648{
649 Smart_Data *sd;
650
651 sd = evas_object_smart_data_get(obj);
652 if (!sd) return 0;
653 return sd->cols;
654}
655
656void
657edje_container_min_size_get(Evas_Object *obj, Evas_Coord *minw, Evas_Coord *minh)
658{
659 Smart_Data *sd;
660
661 sd = evas_object_smart_data_get(obj);
662 if (!sd) return;
663 if (sd->changed)
664 {
665 int freeze;
666
667 freeze = sd->freeze;
668 sd->freeze = 0;
669 _edje_container_recalc(sd);
670 sd->freeze = freeze;
671 }
672 if (minw) *minw = sd->min_w;
673 if (minh) *minh = sd->min_h;
674}
675
676void
677edje_container_max_size_get(Evas_Object *obj, Evas_Coord *maxw, Evas_Coord *maxh)
678{
679 Smart_Data *sd;
680
681 sd = evas_object_smart_data_get(obj);
682 if (!sd) return;
683 if (sd->changed)
684 {
685 int freeze;
686
687 freeze = sd->freeze;
688 sd->freeze = 0;
689 _edje_container_recalc(sd);
690 sd->freeze = freeze;
691 }
692 if (maxw) *maxw = sd->max_w;
693 if (maxh) *maxh = sd->max_h;
694}
695
696void
697edje_containter_align_set(Evas_Object *obj, double halign, double valign)
698{
699 Smart_Data *sd;
700
701 sd = evas_object_smart_data_get(obj);
702 if (!sd) return;
703 if ((sd->align_x == halign) && (sd->align_y == valign)) return;
704 sd->align_x = halign;
705 sd->align_y = valign;
706 sd->need_layout = 1;
707 _edje_container_relayout(sd);
708}
709
710void
711edje_container_align_get(Evas_Object *obj, double *halign, double *valign)
712{
713 Smart_Data *sd;
714
715 sd = evas_object_smart_data_get(obj);
716 if (!sd) return;
717 if (halign) *halign = sd->align_x;
718 if (valign) *valign = sd->align_y;
719}
720
721int
722edje_container_count_get(Evas_Object *obj)
723{
724 Smart_Data *sd;
725
726 sd = evas_object_smart_data_get(obj);
727 if (!sd) return 0;
728 return eina_list_count(sd->children);
729}
730
731Edje_Item *
732edje_container_item_first_get(Evas_Object *obj)
733{
734 Smart_Data *sd;
735
736 sd = evas_object_smart_data_get(obj);
737 if (!sd) return NULL;
738 if (!sd->children) return NULL;
739 return eina_list_data_get(sd->children);
740}
741
742Edje_Item *
743edje_container_item_last_get(Evas_Object *obj)
744{
745 Smart_Data *sd;
746
747 sd = evas_object_smart_data_get(obj);
748 if (!sd) return NULL;
749 if (!sd->children) return NULL;
750 return0 eina_list_data_get(eina_list_last(sd->children));
751}
752
753Edje_Item *
754edje_container_item_nth_get(Evas_Object *obj, int n)
755{
756 Smart_Data *sd;
757
758 sd = evas_object_smart_data_get(obj);
759 if (!sd) return NULL;
760 return eina_list_nth(sd->children, n);
761}
762
763void
764edje_container_homogenous_size_set(Evas_Object *obj, int homog)
765{
766 Smart_Data *sd;
767
768 sd = evas_object_smart_data_get(obj);
769 if (!sd) return;
770 if (((homog) && (sd->homogenous)) ||
771 ((!homog) && (!sd->homogenous))) return;
772 sd->homogenous = homog;
773 sd->changed = 1;
774 sd->change_child = 1;
775 _edje_container_recalc(sd);
776}
777
778int
779edje_container_homogenous_size_get(Evas_Object *obj)
780{
781 Smart_Data *sd;
782
783 sd = evas_object_smart_data_get(obj);
784 if (!sd) return 0;
785 return sd->homogenous;
786}
787
788void
789edje_container_scroll_set(Evas_Object *obj, double pos, double shift)
790{
791 Smart_Data *sd;
792
793 sd = evas_object_smart_data_get(obj);
794 if (!sd) return;
795 if ((sd->scroll_y == pos) && (sd->scroll_x == shift)) return;
796 sd->scroll_y = pos;
797 sd->scroll_x = shift;
798 sd->need_layout = 1;
799 _edje_container_relayout(sd);
800}
801
802void
803edje_container_scroll_get(Evas_Object *obj, double *pos, double *shift)
804{
805 Smart_Data *sd;
806
807 sd = evas_object_smart_data_get(obj);
808 if (!sd) return;
809 if (pos) *pos = sd->scroll_y;
810 if (shift) *shift = sd->scroll_x;
811}
812
813static void _smart_init(void);
814static void _smart_add(Evas_Object * obj);
815static void _smart_del(Evas_Object * obj);
816static void _smart_move(Evas_Object * obj, Evas_Coord x, Evas_Coord y);
817static void _smart_resize(Evas_Object * obj, Evas_Coord w, Evas_Coord h);
818static void _smart_show(Evas_Object * obj);
819static void _smart_hide(Evas_Object * obj);
820static void _smart_color_set(Evas_Object * obj, int r, int g, int b, int a);
821static void _smart_clip_set(Evas_Object * obj, Evas_Object * clip);
822static void _smart_clip_unset(Evas_Object * obj);
823
824static Evas_Smart *smart = NULL;
825
826Evas_Object *
827edje_container_object_add(Evas *evas)
828{
829 _smart_init();
830 return evas_object_smart_add(evas, smart);
831}
832
833/*******************************************/
834/* Internal smart object required routines */
835/*******************************************/
836static void
837_smart_init(void)
838{
839 if (smart) return;
840 {
841 static const Evas_Smart_Class sc =
842 {
843 E_OBJ_NAME,
844 _smart_add,
845 _smart_del,
846 _smart_move,
847 _smart_resize,
848 _smart_show,
849 _smart_hide,
850 _smart_color_set,
851 _smart_clip_set,
852 _smart_clip_unset,
853 NULL,
854 NULL,
855 NULL
856 };
857 smart = evas_smart_class_new(&sc);
858 }
859}
860
861static void
862_smart_add(Evas_Object *obj)
863{
864 Smart_Data *sd;
865
866 sd = calloc(1, sizeof(Smart_Data));
867 if (!sd) return;
868// evas_object_smart_member_add(sd->obj, obj);
869 evas_object_smart_data_set(obj, sd);
870 sd->smart_obj = obj;
871}
872
873static void
874_smart_del(Evas_Object *obj)
875{
876 Smart_Data *sd;
877
878 sd = evas_object_smart_data_get(obj);
879 if (!sd) return;
880 if (sd->colinfo) free(sd->colinfo);
881// evas_object_del(sd->obj);
882 free(sd);
883}
884
885static void
886_smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
887{
888 Smart_Data *sd;
889
890 sd = evas_object_smart_data_get(obj);
891 if (!sd) return;
892// evas_object_move(sd->obj, x, y);
893}
894
895static void
896_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
897{
898 Smart_Data *sd;
899
900 sd = evas_object_smart_data_get(obj);
901 if (!sd) return;
902// evas_object_resize(sd->obj, w, h);
903}
904
905static void
906_smart_show(Evas_Object *obj)
907{
908 Smart_Data *sd;
909
910 sd = evas_object_smart_data_get(obj);
911 if (!sd) return;
912// evas_object_show(sd->obj);
913}
914
915static void
916_smart_hide(Evas_Object *obj)
917{
918 Smart_Data *sd;
919
920 sd = evas_object_smart_data_get(obj);
921 if (!sd) return;
922// evas_object_hide(sd->obj);
923}
924
925static void
926_smart_color_set(Evas_Object *obj, int r, int g, int b, int a)
927{
928 Smart_Data *sd;
929
930 sd = evas_object_smart_data_get(obj);
931 if (!sd) return;
932// evas_object_color_set(sd->obj, r, g, b, a);
933}
934
935static void
936_smart_clip_set(Evas_Object *obj, Evas_Object *clip)
937{
938 Smart_Data *sd;
939
940 sd = evas_object_smart_data_get(obj);
941 if (!sd) return;
942// evas_object_clip_set(sd->obj, clip);
943}
944
945static void
946_smart_clip_unset(Evas_Object *obj)
947{
948 Smart_Data *sd;
949
950 sd = evas_object_smart_data_get(obj);
951 if (!sd) return;
952// evas_object_clip_unset(sd->obj);
953}
954
955#endif
diff --git a/libraries/edje/src/lib/edje_container.h b/libraries/edje/src/lib/edje_container.h
new file mode 100644
index 0000000..0fba62c
--- /dev/null
+++ b/libraries/edje/src/lib/edje_container.h
@@ -0,0 +1,165 @@
1#include "edje_private.h"
2
3
4#define E_SMART_OBJ_GET(smart, o, type) \
5 { \
6 char *_e_smart_str; \
7 \
8 if (!o) return; \
9 smart = evas_object_smart_data_get(o); \
10 if (!smart) return; \
11 _e_smart_str = (char *)evas_object_type_get(o); \
12 if (!_e_smart_str) return; \
13 if (strcmp(_e_smart_str, type)) return; \
14 }
15
16#define E_SMART_OBJ_GET_RETURN(smart, o, type, ret) \
17 { \
18 char *_e_smart_str; \
19 \
20 if (!o) return ret; \
21 smart = evas_object_smart_data_get(o); \
22 if (!smart) return ret; \
23 _e_smart_str = (char *)evas_object_type_get(o); \
24 if (!_e_smart_str) return ret; \
25 if (strcmp(_e_smart_str, type)) return ret; \
26 }
27
28#define E_OBJ_NAME "edje_container_object"
29
30typedef struct _Smart_Data Smart_Data;
31typedef struct _Smart_Data_Colinfo Smart_Data_Colinfo;
32
33struct _Smart_Data
34{
35 Evas_Coord x, y, w, h;
36 Eina_List *children;
37 Evas_Object *smart_obj;
38 int cols, rows;
39
40 Evas_Coord contents_w, contents_h;
41 Evas_Coord min_row_h, max_row_h;
42 Evas_Coord min_w, max_w, min_h, max_h;
43
44 Smart_Data_Colinfo *colinfo;
45
46 int freeze;
47
48 double scroll_x, scroll_y;
49 double align_x, align_y;
50
51 unsigned char changed : 1;
52 unsigned char change_child : 1;
53 unsigned char change_child_list : 1;
54 unsigned char change_cols : 1;
55 unsigned char change_scroll : 1;
56
57 unsigned char need_layout : 1;
58
59 unsigned char homogenous : 1;
60};
61
62struct _Smart_Data_Colinfo
63{
64 Evas_Coord minw, maxw;
65};
66
67/* All items are virtual constructs that provide Evas_Objects at some point.
68 * Edje may move, resize, show, hide, clip, unclip, raise, lower etc. this
69 * item AFTER it calls the item's add() method and before it calls the del()
70 * method. Edje may call add() and del() at any time as often items may not
71 * be visible and so may not need to exist at all - they are merely information
72 * used for layout, and nothing more. this helps save cpu and memory keeping
73 * things responsive for BIG lists of items. you create an item from an item
74 * class then ask that item to be appended/prepended etc. to the container.
75 */
76typedef struct _Edje_Item Edje_Item;
77typedef struct _Edje_Item_Cell Edje_Item_Cell;
78typedef struct _Edje_Item_Class Edje_Item_Class;
79
80struct _Edje_Item_Class
81{
82 Evas_Object *(*add) (Edje_Item *ei);
83 void (*del) (Edje_Item *ei);
84 void (*select) (Edje_Item *ei);
85 void (*deselect) (Edje_Item *ei);
86 void (*focus) (Edje_Item *ei);
87 void (*unfocus) (Edje_Item *ei);
88};
89
90/* private */
91struct _Edje_Item
92{
93 Edje_Item_Class *class;
94 void *class_data;
95
96 void *sd;
97
98 void *data;
99
100 Evas_Object *object;
101 Evas_Object *overlay_object;
102 int freeze;
103 Evas_Coord y, h;
104
105 Evas_Coord minh, maxh;
106
107 int cells_num;
108 Edje_Item_Cell *cells;
109
110 unsigned char accessible : 1;
111
112 unsigned char recalc : 1;
113 unsigned char selected : 1;
114 unsigned char disabled : 1;
115 unsigned char focused : 1;
116};
117
118struct _Edje_Item_Cell
119{
120 Evas_Object *obj;
121 Evas_Coord x, w;
122 Evas_Coord minw, minh, maxw, maxh;
123};
124
125/* here is an item for a vertical list - with 1 or more columns. this has 3 */
126/* just rotate for a horizontal list */
127
128/*
129 * COL 0 COL 1 COL 2
130 *
131 * +-----------------------------+ +-------+ +----------------+
132 * | pad_top | | | | |
133 * | pad_left OBJECT pad_right | | OBJ | | OBJECT | ROW 0
134 * | pad_bottom | | | | |
135 * +-----------------------------+ +-------+ +----------------+
136 * /\ /|\
137 * space_row || +-- space_col
138 * \/
139 * +-----------------------------+ +-------+ +----------------+
140 * | | | | | |
141 * | | | | | | ROW 1
142 * | | | | | |
143 * +-----------------------------+ +-------+ +----------------+
144 *
145 * spacer object:
146 * 1 Edje object goes in-between each row as a spacer object (opt)
147 * 1 Edje object goes in-between each column as a spacer object (opt)
148 *
149 * surround object:
150 * 1 Edje object goes around each item - item swallowed into "item" part (opt)
151 * if no "item" part then just underlay it
152 * on select send "select" "" signal
153 * on unselect send "unselect" "" signal
154 * on focus send "focus" "" signal
155 * on unfocus send "unfocus" signal
156 *
157 * if any list item/cell is an Edje object emit this to them too.
158 *
159 * also call callbacks.
160 * if a surround object emits such a signal itself then call callbacks too
161 *
162 * only 1 or 0 items can be focused
163 * disabled items cannot be focused or selected/deselected
164 *
165 */
diff --git a/libraries/edje/src/lib/edje_convert.h b/libraries/edje/src/lib/edje_convert.h
new file mode 100644
index 0000000..fcc2781
--- /dev/null
+++ b/libraries/edje/src/lib/edje_convert.h
@@ -0,0 +1,143 @@
1#ifndef EDJE_CONVERT_H__
2# define EDJE_CONVERT_H__
3
4typedef struct _Old_Edje_Image_Directory Old_Edje_Image_Directory;
5typedef struct _Old_Edje_Font_Directory Old_Edje_Font_Directory;
6typedef struct _Old_Edje_External_Directory Old_Edje_External_Directory;
7typedef struct _Old_Edje_Part Old_Edje_Part;
8typedef struct _Old_Edje_Part_Collection Old_Edje_Part_Collection;
9typedef struct _Old_Edje_Part_Description Old_Edje_Part_Description;
10typedef struct _Old_Edje_Part_Description_Spec_Image Old_Edje_Part_Description_Spec_Image;
11typedef struct _Edje_Data Edje_Data;
12
13struct _Edje_Data
14{
15 const char *key;
16 char *value;
17};
18
19/*----------*/
20
21struct _Old_Edje_Font_Directory
22{
23 Eina_List *entries; /* a list of Edje_Font_Directory_Entry */
24};
25
26struct _Old_Edje_Image_Directory
27{
28 Eina_List *entries; /* a list of Edje_Image_Directory_Entry */
29 Eina_List *sets; /* a list of Edje_Image_Directory_Set */
30};
31
32struct _Old_Edje_External_Directory
33{
34 Eina_List *entries; /* a list of Edje_External_Directory_Entry */
35};
36
37struct _Old_Edje_File
38{
39 const char *path;
40 time_t mtime;
41
42 Old_Edje_External_Directory *external_dir;
43 Old_Edje_Font_Directory *font_dir;
44 Old_Edje_Image_Directory *image_dir;
45 Edje_Part_Collection_Directory *collection_dir;
46 Eina_List *data;
47 Eina_List *styles;
48 Eina_List *color_classes;
49
50 const char *compiler;
51 int version;
52 int feature_ver;
53};
54
55struct _Old_Edje_Part_Collection
56{
57 Eina_List *programs; /* a list of Edje_Program */
58 Eina_List *parts; /* a list of Edje_Part */
59 Eina_List *data;
60
61 int id; /* the collection id */
62
63 Eina_Hash *alias; /* aliasing part*/
64
65 struct {
66 Edje_Size min, max;
67 } prop;
68
69 int references;
70#ifdef EDJE_PROGRAM_CACHE
71 struct {
72 Eina_Hash *no_matches;
73 Eina_Hash *matches;
74 } prog_cache;
75#endif
76
77 Embryo_Program *script; /* all the embryo script code for this group */
78 const char *part;
79
80 unsigned char script_only;
81
82 unsigned char lua_script_only;
83
84 unsigned char checked : 1;
85};
86
87struct _Old_Edje_Part
88{
89 const char *name; /* the name if any of the part */
90 Old_Edje_Part_Description *default_desc; /* the part descriptor for default */
91 Eina_List *other_desc; /* other possible descriptors */
92 const char *source, *source2, *source3, *source4, *source5, *source6;
93 int id; /* its id number */
94 int clip_to_id; /* the part id to clip this one to */
95 Edje_Part_Dragable dragable;
96 Eina_List *items; /* packed items for box and table */
97 unsigned char type; /* what type (image, rect, text) */
98 unsigned char effect; /* 0 = plain... */
99 unsigned char mouse_events; /* it will affect/respond to mouse events */
100 unsigned char repeat_events; /* it will repeat events to objects below */
101 Evas_Event_Flags ignore_flags;
102 unsigned char scale; /* should certain properties scale with edje scale factor? */
103 unsigned char precise_is_inside;
104 unsigned char use_alternate_font_metrics;
105 unsigned char pointer_mode;
106 unsigned char entry_mode;
107 unsigned char select_mode;
108 unsigned char multiline;
109 Edje_Part_Api api;
110};
111
112struct _Old_Edje_Part_Description_Spec_Image
113{
114 Eina_List *tween_list; /* list of Edje_Part_Image_Id */
115 int id; /* the image id to use */
116 int scale_hint; /* evas scale hint */
117 Eina_Bool set; /* if image condition it's content */
118
119 Edje_Part_Description_Spec_Border border;
120 Edje_Part_Description_Spec_Fill fill;
121};
122
123struct _Old_Edje_Part_Description
124{
125 Edje_Part_Description_Common common;
126 Old_Edje_Part_Description_Spec_Image image;
127 Edje_Part_Description_Spec_Text text;
128 Edje_Part_Description_Spec_Box box;
129 Edje_Part_Description_Spec_Table table;
130
131 Eina_List *external_params; /* parameters for external objects */
132};
133
134Edje_File *_edje_file_convert(Eet_File *file, Old_Edje_File *oedf);
135Edje_Part_Collection *_edje_collection_convert(Edje_File *file,
136 Old_Edje_Part_Collection *oedc);
137Edje_Part_Description_Common *_edje_description_convert(int type,
138 Edje_Part_Collection_Directory_Entry *ce,
139 Old_Edje_Part_Description *oed);
140const Edje_File *_edje_file_get(void);
141void _edje_file_set(const Edje_File *edf);
142
143#endif
diff --git a/libraries/edje/src/lib/edje_data.c b/libraries/edje/src/lib/edje_data.c
new file mode 100644
index 0000000..6b7b395
--- /dev/null
+++ b/libraries/edje/src/lib/edje_data.c
@@ -0,0 +1,877 @@
1#include "edje_private.h"
2
3EAPI Eet_Data_Descriptor *_edje_edd_edje_file = NULL;
4EAPI Eet_Data_Descriptor *_edje_edd_edje_part_collection = NULL;
5
6Eet_Data_Descriptor *_edje_edd_edje_string = NULL;
7Eet_Data_Descriptor *_edje_edd_edje_style = NULL;
8Eet_Data_Descriptor *_edje_edd_edje_style_tag = NULL;
9Eet_Data_Descriptor *_edje_edd_edje_color_class = NULL;
10Eet_Data_Descriptor *_edje_edd_edje_external_directory = NULL;
11Eet_Data_Descriptor *_edje_edd_edje_external_directory_entry = NULL;
12Eet_Data_Descriptor *_edje_edd_edje_font_directory_entry = NULL;
13Eet_Data_Descriptor *_edje_edd_edje_image_directory = NULL;
14Eet_Data_Descriptor *_edje_edd_edje_image_directory_entry = NULL;
15Eet_Data_Descriptor *_edje_edd_edje_image_directory_set = NULL;
16Eet_Data_Descriptor *_edje_edd_edje_image_directory_set_entry = NULL;
17Eet_Data_Descriptor *_edje_edd_edje_limit = NULL;
18Eet_Data_Descriptor *_edje_edd_edje_limit_pointer = NULL;
19Eet_Data_Descriptor *_edje_edd_edje_sound_sample = NULL;
20Eet_Data_Descriptor *_edje_edd_edje_sound_tone = NULL;
21Eet_Data_Descriptor *_edje_edd_edje_sound_directory = NULL;
22Eet_Data_Descriptor *_edje_edd_edje_program = NULL;
23Eet_Data_Descriptor *_edje_edd_edje_program_pointer = NULL;
24Eet_Data_Descriptor *_edje_edd_edje_program_target = NULL;
25Eet_Data_Descriptor *_edje_edd_edje_program_after = NULL;
26Eet_Data_Descriptor *_edje_edd_edje_part_collection_directory_entry = NULL;
27Eet_Data_Descriptor *_edje_edd_edje_pack_element = NULL;
28Eet_Data_Descriptor *_edje_edd_edje_pack_element_pointer = NULL;
29Eet_Data_Descriptor *_edje_edd_edje_part = NULL;
30Eet_Data_Descriptor *_edje_edd_edje_part_pointer = NULL;
31Eet_Data_Descriptor *_edje_edd_edje_part_description_variant = NULL;
32Eet_Data_Descriptor *_edje_edd_edje_part_description_rectangle = NULL;
33Eet_Data_Descriptor *_edje_edd_edje_part_description_swallow = NULL;
34Eet_Data_Descriptor *_edje_edd_edje_part_description_group = NULL;
35Eet_Data_Descriptor *_edje_edd_edje_part_description_image = NULL;
36Eet_Data_Descriptor *_edje_edd_edje_part_description_proxy = NULL;
37Eet_Data_Descriptor *_edje_edd_edje_part_description_text = NULL;
38Eet_Data_Descriptor *_edje_edd_edje_part_description_textblock = NULL;
39Eet_Data_Descriptor *_edje_edd_edje_part_description_box = NULL;
40Eet_Data_Descriptor *_edje_edd_edje_part_description_table = NULL;
41Eet_Data_Descriptor *_edje_edd_edje_part_description_external = NULL;
42Eet_Data_Descriptor *_edje_edd_edje_part_description_variant_list = NULL;
43Eet_Data_Descriptor *_edje_edd_edje_part_description_rectangle_pointer = NULL;
44Eet_Data_Descriptor *_edje_edd_edje_part_description_swallow_pointer = NULL;
45Eet_Data_Descriptor *_edje_edd_edje_part_description_group_pointer = NULL;
46Eet_Data_Descriptor *_edje_edd_edje_part_description_image_pointer = NULL;
47Eet_Data_Descriptor *_edje_edd_edje_part_description_proxy_pointer = NULL;
48Eet_Data_Descriptor *_edje_edd_edje_part_description_text_pointer = NULL;
49Eet_Data_Descriptor *_edje_edd_edje_part_description_textblock_pointer = NULL;
50Eet_Data_Descriptor *_edje_edd_edje_part_description_box_pointer = NULL;
51Eet_Data_Descriptor *_edje_edd_edje_part_description_table_pointer = NULL;
52Eet_Data_Descriptor *_edje_edd_edje_part_description_external_pointer = NULL;
53Eet_Data_Descriptor *_edje_edd_edje_part_image_id = NULL;
54Eet_Data_Descriptor *_edje_edd_edje_part_image_id_pointer = NULL;
55Eet_Data_Descriptor *_edje_edd_edje_external_param = NULL;
56
57#define EMP(Type, Minus) \
58 Eina_Mempool *_emp_##Type = NULL; \
59 \
60 static void * \
61 mem_alloc_##Minus(size_t size) \
62 { \
63 void *data; \
64 \
65 data = eina_mempool_malloc(_emp_##Type, size); \
66 memset(data, 0, size); \
67 return data; \
68 } \
69 \
70 static void \
71 mem_free_##Minus(void *data) \
72 { \
73 eina_mempool_free(_emp_##Type, data); \
74 }
75
76EMP(RECTANGLE, rectangle);
77EMP(TEXT, text);
78EMP(IMAGE, image);
79EMP(PROXY, proxy);
80EMP(SWALLOW, swallow);
81EMP(TEXTBLOCK, textblock);
82EMP(GROUP, group);
83EMP(BOX, box);
84EMP(TABLE, table);
85EMP(EXTERNAL, external);
86EMP(part, part);
87
88#define FREED(eed) \
89 if (eed) \
90 { \
91 eet_data_descriptor_free((eed)); \
92 (eed) = NULL; \
93 }
94
95struct {
96 Edje_Part_Type type;
97 const char *name;
98} variant_convertion[] = {
99 { EDJE_PART_TYPE_RECTANGLE, "rectangle" },
100 { EDJE_PART_TYPE_SWALLOW, "swallow" },
101 { EDJE_PART_TYPE_GROUP, "group" },
102 { EDJE_PART_TYPE_IMAGE, "image" },
103 { EDJE_PART_TYPE_TEXT, "text" },
104 { EDJE_PART_TYPE_TEXTBLOCK, "textblock" },
105 { EDJE_PART_TYPE_BOX, "box" },
106 { EDJE_PART_TYPE_TABLE, "table" },
107 { EDJE_PART_TYPE_EXTERNAL, "external" },
108 { EDJE_PART_TYPE_PROXY, "proxy" }
109};
110
111static const char *
112_edje_description_variant_type_get(const void *data, Eina_Bool *unknow __UNUSED__)
113{
114 const unsigned char *type;
115 unsigned int i;
116
117 type = data;
118
119 for (i = 0; i < (sizeof (variant_convertion) / sizeof (variant_convertion[0])); ++i)
120 if (*type == variant_convertion[i].type)
121 return variant_convertion[i].name;
122
123 return NULL;
124}
125
126static Eina_Bool
127_edje_description_variant_type_set(const char *type, void *data, Eina_Bool unknow __UNUSED__)
128{
129 unsigned char *dt;
130 unsigned int i;
131
132 dt = data;
133
134 for (i = 0; i < (sizeof (variant_convertion) / sizeof (variant_convertion[0])); ++i)
135 if (!strcmp(variant_convertion[i].name, type))
136 {
137 *dt = variant_convertion[i].type;
138 return EINA_TRUE;
139 }
140
141 return EINA_FALSE;
142}
143
144static Eina_Hash *
145_edje_eina_hash_add_alloc(Eina_Hash *hash,
146 const char *key,
147 void *data)
148{
149 if (!hash)
150 hash = eina_hash_string_small_new(free);
151
152 if (!hash)
153 return NULL;
154
155 eina_hash_add(hash, key, data);
156 return hash;
157}
158
159// FIXME: remove EAPI when edje_convert goes
160EAPI void
161_edje_edd_shutdown(void)
162{
163 FREED(_edje_edd_edje_file);
164 FREED(_edje_edd_edje_string);
165 FREED(_edje_edd_edje_style);
166 FREED(_edje_edd_edje_style_tag);
167 FREED(_edje_edd_edje_color_class);
168 FREED(_edje_edd_edje_external_directory);
169 FREED(_edje_edd_edje_external_directory_entry);
170 FREED(_edje_edd_edje_font_directory_entry);
171 FREED(_edje_edd_edje_image_directory);
172 FREED(_edje_edd_edje_image_directory_entry);
173 FREED(_edje_edd_edje_limit);
174 FREED(_edje_edd_edje_limit_pointer);
175 FREED(_edje_edd_edje_sound_sample);
176 FREED(_edje_edd_edje_sound_tone);
177 FREED(_edje_edd_edje_sound_directory);
178 FREED(_edje_edd_edje_program);
179 FREED(_edje_edd_edje_program_pointer);
180 FREED(_edje_edd_edje_program_target);
181 FREED(_edje_edd_edje_program_after);
182 FREED(_edje_edd_edje_part_collection_directory_entry);
183 FREED(_edje_edd_edje_pack_element);
184 FREED(_edje_edd_edje_pack_element_pointer);
185 FREED(_edje_edd_edje_part_collection);
186 FREED(_edje_edd_edje_part);
187 FREED(_edje_edd_edje_part_pointer);
188 FREED(_edje_edd_edje_part_description_variant);
189 FREED(_edje_edd_edje_part_description_rectangle);
190 FREED(_edje_edd_edje_part_description_swallow);
191 FREED(_edje_edd_edje_part_description_group);
192 FREED(_edje_edd_edje_part_description_image);
193 FREED(_edje_edd_edje_part_description_proxy);
194 FREED(_edje_edd_edje_part_description_text);
195 FREED(_edje_edd_edje_part_description_textblock);
196 FREED(_edje_edd_edje_part_description_box);
197 FREED(_edje_edd_edje_part_description_table);
198 FREED(_edje_edd_edje_part_description_external);
199 FREED(_edje_edd_edje_part_description_variant_list);
200 FREED(_edje_edd_edje_part_description_rectangle_pointer);
201 FREED(_edje_edd_edje_part_description_swallow_pointer);
202 FREED(_edje_edd_edje_part_description_group_pointer);
203 FREED(_edje_edd_edje_part_description_image_pointer);
204 FREED(_edje_edd_edje_part_description_proxy_pointer);
205 FREED(_edje_edd_edje_part_description_text_pointer);
206 FREED(_edje_edd_edje_part_description_textblock_pointer);
207 FREED(_edje_edd_edje_part_description_box_pointer);
208 FREED(_edje_edd_edje_part_description_table_pointer);
209 FREED(_edje_edd_edje_part_description_external_pointer);
210 FREED(_edje_edd_edje_part_image_id);
211 FREED(_edje_edd_edje_part_image_id_pointer);
212 FREED(_edje_edd_edje_external_param);
213 FREED(_edje_edd_edje_image_directory_set);
214 FREED(_edje_edd_edje_image_directory_set_entry);
215}
216
217#define EDJE_DEFINE_POINTER_TYPE(Type, Name) \
218 { \
219 typedef struct _Edje_##Type##_Pointer Edje_##Type##_Pointer; \
220 struct _Edje_##Type##_Pointer \
221 { \
222 Edje_##Type *pointer; \
223 }; \
224 \
225 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_##Type##_Pointer); \
226 _edje_edd_edje_##Name##_pointer = \
227 eet_data_descriptor_file_new(&eddc); \
228 EET_DATA_DESCRIPTOR_ADD_SUB(_edje_edd_edje_##Name##_pointer, Edje_##Type##_Pointer, "pointer", pointer, _edje_edd_edje_##Name); \
229 }
230
231// FIXME: remove EAPI when edje_convert goes
232EAPI void
233_edje_edd_init(void)
234{
235 Eet_Data_Descriptor_Class eddc;
236
237 /* localisable string */
238 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_String);
239 _edje_edd_edje_string = eet_data_descriptor_file_new(&eddc);
240 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_string, Edje_String, "str", str, EET_T_STRING);
241 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_string, Edje_String, "id", id, EET_T_UINT);
242
243 /* external directory */
244 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_External_Directory_Entry);
245 _edje_edd_edje_external_directory_entry =
246 eet_data_descriptor_file_new(&eddc);
247 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_external_directory_entry, Edje_External_Directory_Entry, "entry", entry, EET_T_STRING);
248
249 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_External_Directory);
250 _edje_edd_edje_external_directory =
251 eet_data_descriptor_file_new(&eddc);
252 EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_edje_edd_edje_external_directory, Edje_External_Directory, "entries", entries, _edje_edd_edje_external_directory_entry);
253
254 /* font directory */
255 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Font_Directory_Entry);
256 _edje_edd_edje_font_directory_entry =
257 eet_data_descriptor_file_new(&eddc);
258 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_font_directory_entry, Edje_Font_Directory_Entry, "entry", entry, EET_T_STRING);
259 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_font_directory_entry, Edje_Font_Directory_Entry, "file", file, EET_T_STRING);
260
261 /* image directory */
262 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Image_Directory_Entry);
263 _edje_edd_edje_image_directory_entry =
264 eet_data_descriptor_file_new(&eddc);
265 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_image_directory_entry, Edje_Image_Directory_Entry, "entry", entry, EET_T_STRING);
266 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_image_directory_entry, Edje_Image_Directory_Entry, "source_type", source_type, EET_T_INT);
267 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_image_directory_entry, Edje_Image_Directory_Entry, "source_param", source_param, EET_T_INT);
268 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_image_directory_entry, Edje_Image_Directory_Entry, "id", id, EET_T_INT);
269
270 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Image_Directory_Set_Entry);
271 _edje_edd_edje_image_directory_set_entry =
272 eet_data_descriptor_file_new(&eddc);
273 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_image_directory_set_entry, Edje_Image_Directory_Set_Entry, "name", name, EET_T_STRING);
274 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_image_directory_set_entry, Edje_Image_Directory_Set_Entry, "id", id, EET_T_INT);
275 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_image_directory_set_entry, Edje_Image_Directory_Set_Entry, "min.w", size.min.w, EET_T_INT);
276 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_image_directory_set_entry, Edje_Image_Directory_Set_Entry, "min.h", size.min.h, EET_T_INT);
277 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_image_directory_set_entry, Edje_Image_Directory_Set_Entry, "max.w", size.max.w, EET_T_INT);
278 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_image_directory_set_entry, Edje_Image_Directory_Set_Entry, "max.h", size.max.h, EET_T_INT);
279
280 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Image_Directory_Set);
281 _edje_edd_edje_image_directory_set =
282 eet_data_descriptor_file_new(&eddc);
283 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_image_directory_set, Edje_Image_Directory_Set, "name", name, EET_T_STRING);
284 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_image_directory_set, Edje_Image_Directory_Set, "id", id, EET_T_INT);
285 EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_edje_image_directory_set, Edje_Image_Directory_Set, "entries", entries, _edje_edd_edje_image_directory_set_entry);
286
287 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Image_Directory);
288 _edje_edd_edje_image_directory =
289 eet_data_descriptor_file_new(&eddc);
290 EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_edje_edd_edje_image_directory, Edje_Image_Directory, "entries", entries, _edje_edd_edje_image_directory_entry);
291 EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_edje_edd_edje_image_directory, Edje_Image_Directory, "sets", sets, _edje_edd_edje_image_directory_set);
292
293 /* Sound */
294 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Sound_Sample);
295 _edje_edd_edje_sound_sample =
296 eet_data_descriptor_file_new(&eddc);
297 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_sound_sample, Edje_Sound_Sample, "name", name, EET_T_STRING);
298 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_sound_sample, Edje_Sound_Sample, "snd_src", snd_src, EET_T_STRING);
299 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_sound_sample, Edje_Sound_Sample, "compression", compression, EET_T_INT);
300 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_sound_sample, Edje_Sound_Sample, "mode", mode, EET_T_INT);
301 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_sound_sample, Edje_Sound_Sample, "quality", quality, EET_T_DOUBLE);
302 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_sound_sample, Edje_Sound_Sample, "id", id, EET_T_INT);
303 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Sound_Tone);
304 _edje_edd_edje_sound_tone =
305 eet_data_descriptor_file_new(&eddc);
306 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_sound_tone, Edje_Sound_Tone, "name", name, EET_T_STRING);
307 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_sound_tone, Edje_Sound_Tone, "value", value, EET_T_INT);
308 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_sound_tone, Edje_Sound_Tone, "id", id, EET_T_INT);
309
310 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Sound_Directory);
311 _edje_edd_edje_sound_directory =
312 eet_data_descriptor_file_new(&eddc);
313 EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_edje_edd_edje_sound_directory, Edje_Sound_Directory, "samples", samples, _edje_edd_edje_sound_sample);
314 EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_edje_edd_edje_sound_directory, Edje_Sound_Directory, "tones", tones, _edje_edd_edje_sound_tone);
315
316 /* collection directory */
317 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part_Collection_Directory_Entry);
318 _edje_edd_edje_part_collection_directory_entry =
319 eet_data_descriptor_file_new(&eddc);
320 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "entry", entry, EET_T_STRING);
321 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "id", id, EET_T_INT);
322 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "count.RECTANGLE", count.RECTANGLE, EET_T_INT);
323 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "count.TEXT", count.TEXT, EET_T_INT);
324 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "count.IMAGE", count.IMAGE, EET_T_INT);
325 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "count.PROXY", count.PROXY, EET_T_INT);
326 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "count.SWALLOW", count.SWALLOW, EET_T_INT);
327 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "count.TEXTBLOCK", count.TEXTBLOCK, EET_T_INT);
328 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "count.GROUP", count.GROUP, EET_T_INT);
329 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "count.BOX", count.BOX, EET_T_INT);
330 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "count.TABLE", count.TABLE, EET_T_INT);
331 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "count.EXTERNAL", count.EXTERNAL, EET_T_INT);
332 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "count.part", count.part, EET_T_INT);
333
334 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Style_Tag);
335 _edje_edd_edje_style_tag =
336 eet_data_descriptor_file_new(&eddc);
337 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_style_tag, Edje_Style_Tag, "key", key, EET_T_STRING);
338 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_style_tag, Edje_Style_Tag, "value", value, EET_T_STRING);
339
340 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Style);
341 _edje_edd_edje_style =
342 eet_data_descriptor_file_new(&eddc);
343 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_style, Edje_Style, "name", name, EET_T_STRING);
344 EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_edje_style, Edje_Style, "tags", tags, _edje_edd_edje_style_tag);
345
346 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Color_Class);
347 _edje_edd_edje_color_class =
348 eet_data_descriptor_file_new(&eddc);
349 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_color_class, Edje_Color_Class, "name", name, EET_T_STRING);
350 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_color_class, Edje_Color_Class, "r", r, EET_T_UCHAR);
351 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_color_class, Edje_Color_Class, "g", g, EET_T_UCHAR);
352 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_color_class, Edje_Color_Class, "b", b, EET_T_UCHAR);
353 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_color_class, Edje_Color_Class, "a", a, EET_T_UCHAR);
354 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_color_class, Edje_Color_Class, "r2", r2, EET_T_UCHAR);
355 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_color_class, Edje_Color_Class, "g2", g2, EET_T_UCHAR);
356 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_color_class, Edje_Color_Class, "b2", b2, EET_T_UCHAR);
357 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_color_class, Edje_Color_Class, "a2", a2, EET_T_UCHAR);
358 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_color_class, Edje_Color_Class, "r3", r3, EET_T_UCHAR);
359 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_color_class, Edje_Color_Class, "g3", g3, EET_T_UCHAR);
360 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_color_class, Edje_Color_Class, "b3", b3, EET_T_UCHAR);
361 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_color_class, Edje_Color_Class, "a3", a3, EET_T_UCHAR);
362
363 /* the main file directory */
364 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_File);
365 eddc.func.hash_add = (void * (*)(void *, const char *, void *)) _edje_eina_hash_add_alloc;
366 _edje_edd_edje_file = eet_data_descriptor_file_new(&eddc);
367 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_file, Edje_File, "compiler", compiler, EET_T_STRING);
368 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_file, Edje_File, "version", version, EET_T_INT);
369 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_file, Edje_File, "minor", minor, EET_T_INT);
370 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_file, Edje_File, "feature_ver", feature_ver, EET_T_INT);
371 EET_DATA_DESCRIPTOR_ADD_SUB(_edje_edd_edje_file, Edje_File, "external_dir", external_dir, _edje_edd_edje_external_directory);
372 EET_DATA_DESCRIPTOR_ADD_SUB(_edje_edd_edje_file, Edje_File, "image_dir", image_dir, _edje_edd_edje_image_directory);
373 EET_DATA_DESCRIPTOR_ADD_SUB(_edje_edd_edje_file, Edje_File, "sound_dir", sound_dir, _edje_edd_edje_sound_directory);
374 EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_edje_file, Edje_File, "styles", styles, _edje_edd_edje_style);
375 EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_edje_file, Edje_File, "color_classes", color_classes, _edje_edd_edje_color_class);
376 EET_DATA_DESCRIPTOR_ADD_HASH(_edje_edd_edje_file, Edje_File, "data", data, _edje_edd_edje_string);
377 EET_DATA_DESCRIPTOR_ADD_HASH(_edje_edd_edje_file, Edje_File, "fonts", fonts, _edje_edd_edje_font_directory_entry);
378 EET_DATA_DESCRIPTOR_ADD_HASH(_edje_edd_edje_file, Edje_File, "collection", collection, _edje_edd_edje_part_collection_directory_entry);
379
380 /* parts & limit & programs - loaded induvidually */
381 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Limit);
382 _edje_edd_edje_limit = eet_data_descriptor_file_new(&eddc);
383 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_limit, Edje_Limit, "name", name, EET_T_STRING);
384 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_limit, Edje_Limit, "value", value, EET_T_INT);
385
386 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Program_Target);
387 _edje_edd_edje_program_target =
388 eet_data_descriptor_file_new(&eddc);
389 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program_target, Edje_Program_Target, "id", id, EET_T_INT);
390
391 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Program_After);
392 _edje_edd_edje_program_after =
393 eet_data_descriptor_file_new(&eddc);
394 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program_after,
395 Edje_Program_After, "id", id, EET_T_INT);
396
397 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Program);
398 _edje_edd_edje_program =
399 eet_data_descriptor_file_new(&eddc);
400 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "id", id, EET_T_INT);
401 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "name", name, EET_T_STRING);
402 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "signal", signal, EET_T_STRING);
403 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "source", source, EET_T_STRING);
404 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "filter_part", filter.part, EET_T_STRING);
405 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "filter_state", filter.state, EET_T_STRING);
406 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "in.from", in.from, EET_T_DOUBLE);
407 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "in.range", in.range, EET_T_DOUBLE);
408 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "action", action, EET_T_INT);
409
410 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "sample_name", sample_name, EET_T_STRING);
411 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "tone_name", tone_name, EET_T_STRING);
412 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program ,"duration", duration, EET_T_DOUBLE);
413 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program ,"speed", speed, EET_T_DOUBLE);
414 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "state", state, EET_T_STRING);
415 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "state2", state2, EET_T_STRING);
416 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "value", value, EET_T_DOUBLE);
417 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "value2", value2, EET_T_DOUBLE);
418 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "tween.mode", tween.mode, EET_T_INT);
419 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "tween.time", tween.time, EDJE_T_FLOAT);
420 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "v1", tween.v1, EDJE_T_FLOAT);
421 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "v2", tween.v2, EDJE_T_FLOAT);
422 EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_edje_program, Edje_Program, "targets", targets, _edje_edd_edje_program_target);
423 EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_edje_program, Edje_Program, "after", after, _edje_edd_edje_program_after);
424 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "api.name", api.name, EET_T_STRING);
425 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "api.description", api.description, EET_T_STRING);
426
427 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "param.src", param.src, EET_T_INT);
428 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "param.dst", param.dst, EET_T_INT);
429
430 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part_Image_Id);
431 _edje_edd_edje_part_image_id =
432 eet_data_descriptor_file_new(&eddc);
433 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_image_id, Edje_Part_Image_Id, "id", id, EET_T_INT);
434 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_image_id, Edje_Part_Image_Id, "set", set, EET_T_UCHAR);
435
436 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_External_Param);
437 _edje_edd_edje_external_param =
438 eet_data_descriptor_file_new(&eddc);
439 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_external_param, Edje_External_Param, "name", name, EET_T_STRING);
440 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_external_param, Edje_External_Param, "type", type, EET_T_INT);
441 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_external_param, Edje_External_Param, "i", i, EET_T_INT);
442 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_external_param, Edje_External_Param, "d", d, EET_T_DOUBLE);
443 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_external_param, Edje_External_Param, "s", s, EET_T_STRING);
444
445#define EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON(Edd, Type) \
446 { \
447 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "state.name", state.name, EET_T_STRING); \
448 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "state.value", state.value, EET_T_DOUBLE); \
449 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "visible", visible, EET_T_CHAR); \
450 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "align.x", align.x, EDJE_T_FLOAT); \
451 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "align.y", align.y, EDJE_T_FLOAT); \
452 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "fixed.w", fixed.w, EET_T_UCHAR); \
453 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "fixed.h", fixed.h, EET_T_UCHAR); \
454 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "min.w", min.w, EET_T_INT); \
455 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "min.h", min.h, EET_T_INT); \
456 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "max.w", max.w, EET_T_INT); \
457 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "max.h", max.h, EET_T_INT); \
458 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "step.x", step.x, EET_T_INT); \
459 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "step.y", step.y, EET_T_INT); \
460 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "aspect.min", aspect.min, EDJE_T_FLOAT); \
461 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "aspect.max", aspect.max, EDJE_T_FLOAT); \
462 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "aspect.prefer", aspect.prefer, EET_T_CHAR); \
463 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "rel1.relative_x", rel1.relative_x, EDJE_T_FLOAT); \
464 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "rel1.relative_y", rel1.relative_y, EDJE_T_FLOAT); \
465 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "rel1.offset_x", rel1.offset_x, EET_T_INT); \
466 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "rel1.offset_y", rel1.offset_y, EET_T_INT); \
467 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "rel1.id_x", rel1.id_x, EET_T_INT); \
468 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "rel1.id_y", rel1.id_y, EET_T_INT); \
469 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "rel2.relative_x", rel2.relative_x, EDJE_T_FLOAT); \
470 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "rel2.relative_y", rel2.relative_y, EDJE_T_FLOAT); \
471 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "rel2.offset_x", rel2.offset_x, EET_T_INT); \
472 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "rel2.offset_y", rel2.offset_y, EET_T_INT); \
473 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "rel2.id_x", rel2.id_x, EET_T_INT); \
474 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "rel2.id_y", rel2.id_y, EET_T_INT); \
475 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "color_class", color_class, EET_T_STRING); \
476 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "color.r", color.r, EET_T_UCHAR); \
477 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "color.g", color.g, EET_T_UCHAR); \
478 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "color.b", color.b, EET_T_UCHAR); \
479 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "color.a", color.a, EET_T_UCHAR); \
480 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "color2.r", color2.r, EET_T_UCHAR); \
481 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "color2.g", color2.g, EET_T_UCHAR); \
482 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "color2.b", color2.b, EET_T_UCHAR); \
483 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "color2.a", color2.a, EET_T_UCHAR); \
484 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.id_persp", map.id_persp, EET_T_INT); \
485 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.id_light", map.id_light, EET_T_INT); \
486 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.rot.id_center", map.rot.id_center, EET_T_INT); \
487 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.rot.x", map.rot.x, EDJE_T_FLOAT); \
488 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.rot.y", map.rot.y, EDJE_T_FLOAT); \
489 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.rot.z", map.rot.z, EDJE_T_FLOAT); \
490 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.on", map.on, EET_T_UCHAR); \
491 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.smooth", map.smooth, EET_T_UCHAR); \
492 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.alpha", map.alpha, EET_T_UCHAR); \
493 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.persp_on", map.persp_on, EET_T_UCHAR); \
494 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.backcull", map.backcull, EET_T_UCHAR); \
495 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "persp.zplane", persp.zplane, EET_T_INT); \
496 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "persp.focal", persp.focal, EET_T_INT); \
497 }
498
499#define EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON_SUB(Edd, Type, Dec) \
500 { \
501 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "state.name", Dec.state.name, EET_T_STRING); \
502 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "state.value", Dec.state.value, EET_T_DOUBLE); \
503 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "visible", Dec.visible, EET_T_CHAR); \
504 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "align.x", Dec.align.x, EDJE_T_FLOAT); \
505 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "align.y", Dec.align.y, EDJE_T_FLOAT); \
506 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "fixed.w", Dec.fixed.w, EET_T_UCHAR); \
507 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "fixed.h", Dec.fixed.h, EET_T_UCHAR); \
508 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "min.w", Dec.min.w, EET_T_INT); \
509 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "min.h", Dec.min.h, EET_T_INT); \
510 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "max.w", Dec.max.w, EET_T_INT); \
511 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "max.h", Dec.max.h, EET_T_INT); \
512 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "step.x", Dec.step.x, EET_T_INT); \
513 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "step.y", Dec.step.y, EET_T_INT); \
514 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "aspect.min", Dec.aspect.min, EDJE_T_FLOAT); \
515 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "aspect.max", Dec.aspect.max, EDJE_T_FLOAT); \
516 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "aspect.prefer", Dec.aspect.prefer, EET_T_CHAR); \
517 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "rel1.relative_x", Dec.rel1.relative_x, EDJE_T_FLOAT); \
518 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "rel1.relative_y", Dec.rel1.relative_y, EDJE_T_FLOAT); \
519 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "rel1.offset_x", Dec.rel1.offset_x, EET_T_INT); \
520 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "rel1.offset_y", Dec.rel1.offset_y, EET_T_INT); \
521 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "rel1.id_x", Dec.rel1.id_x, EET_T_INT); \
522 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "rel1.id_y", Dec.rel1.id_y, EET_T_INT); \
523 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "rel2.relative_x", Dec.rel2.relative_x, EDJE_T_FLOAT); \
524 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "rel2.relative_y", Dec.rel2.relative_y, EDJE_T_FLOAT); \
525 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "rel2.offset_x", Dec.rel2.offset_x, EET_T_INT); \
526 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "rel2.offset_y", Dec.rel2.offset_y, EET_T_INT); \
527 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "rel2.id_x", Dec.rel2.id_x, EET_T_INT); \
528 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "rel2.id_y", Dec.rel2.id_y, EET_T_INT); \
529 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "color_class", Dec.color_class, EET_T_STRING); \
530 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "color.r", Dec.color.r, EET_T_UCHAR); \
531 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "color.g", Dec.color.g, EET_T_UCHAR); \
532 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "color.b", Dec.color.b, EET_T_UCHAR); \
533 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "color.a", Dec.color.a, EET_T_UCHAR); \
534 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "color2.r", Dec.color2.r, EET_T_UCHAR); \
535 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "color2.g", Dec.color2.g, EET_T_UCHAR); \
536 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "color2.b", Dec.color2.b, EET_T_UCHAR); \
537 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "color2.a", Dec.color2.a, EET_T_UCHAR); \
538 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.id_persp", Dec.map.id_persp, EET_T_INT); \
539 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.id_light", Dec.map.id_light, EET_T_INT); \
540 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.rot.id_center", Dec.map.rot.id_center, EET_T_INT); \
541 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.rot.x", Dec.map.rot.x, EDJE_T_FLOAT); \
542 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.rot.y", Dec.map.rot.y, EDJE_T_FLOAT); \
543 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.rot.z", Dec.map.rot.z, EDJE_T_FLOAT); \
544 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.on", Dec.map.on, EET_T_UCHAR); \
545 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.smooth", Dec.map.smooth, EET_T_UCHAR); \
546 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.alpha", Dec.map.alpha, EET_T_UCHAR); \
547 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.persp_on", Dec.map.persp_on, EET_T_UCHAR); \
548 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.backcull", Dec.map.backcull, EET_T_UCHAR); \
549 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "persp.zplane", Dec.persp.zplane, EET_T_INT); \
550 EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "persp.focal", Dec.persp.focal, EET_T_INT); \
551 }
552
553 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part_Description_Common);
554 eddc.func.mem_free = mem_free_rectangle;
555 eddc.func.mem_alloc = mem_alloc_rectangle;
556 _edje_edd_edje_part_description_rectangle =
557 eet_data_descriptor_file_new(&eddc);
558 EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON(_edje_edd_edje_part_description_rectangle, Edje_Part_Description_Common);
559
560 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part_Description_Common);
561 eddc.func.mem_free = mem_free_swallow;
562 eddc.func.mem_alloc = mem_alloc_swallow;
563 _edje_edd_edje_part_description_swallow =
564 eet_data_descriptor_file_new(&eddc);
565 EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON(_edje_edd_edje_part_description_swallow, Edje_Part_Description_Common);
566
567 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part_Description_Common);
568 eddc.func.mem_free = mem_free_group;
569 eddc.func.mem_alloc = mem_alloc_group;
570 _edje_edd_edje_part_description_group =
571 eet_data_descriptor_file_new(&eddc);
572 EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON(_edje_edd_edje_part_description_group, Edje_Part_Description_Common);
573
574 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part_Description_Image);
575 eddc.func.mem_free = mem_free_image;
576 eddc.func.mem_alloc = mem_alloc_image;
577 _edje_edd_edje_part_description_image =
578 eet_data_descriptor_file_new(&eddc);
579 EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON_SUB(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, common);
580
581 EDJE_DEFINE_POINTER_TYPE(Part_Image_Id, part_image_id);
582 EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, "image.tweens", image.tweens, _edje_edd_edje_part_image_id_pointer);
583
584 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, "image.id", image.id, EET_T_INT);
585 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, "image.set", image.set, EET_T_UCHAR);
586 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, "image.border.l", image.border.l, EET_T_INT);
587 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, "image.border.r", image.border.r, EET_T_INT);
588 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, "image.border.t", image.border.t, EET_T_INT);
589 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, "image.border.b", image.border.b, EET_T_INT);
590 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, "image.border.no_fill", image.border.no_fill, EET_T_UCHAR);
591 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, "image.border.scale", image.border.scale, EET_T_UCHAR);
592 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, "image.border.scale_by", image.border.scale_by, EDJE_T_FLOAT);
593 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, "image.fill.smooth", image.fill.smooth, EET_T_CHAR);
594 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, "image.fill.pos_rel_x", image.fill.pos_rel_x, EDJE_T_FLOAT);
595 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, "image.fill.pos_abs_x", image.fill.pos_abs_x, EET_T_INT);
596 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, "image.fill.rel_x", image.fill.rel_x, EDJE_T_FLOAT);
597 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, "image.fill.abs_x", image.fill.abs_x, EET_T_INT);
598 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, "image.fill.pos_rel_y", image.fill.pos_rel_y, EDJE_T_FLOAT);
599 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, "image.fill.pos_abs_y", image.fill.pos_abs_y, EET_T_INT);
600 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, "image.fill.rel_y", image.fill.rel_y, EDJE_T_FLOAT);
601 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, "image.fill.abs_y", image.fill.abs_y, EET_T_INT);
602 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, "image.fill.angle", image.fill.angle, EET_T_INT);
603 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, "image.fill.spread", image.fill.spread, EET_T_INT);
604 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, "image.fill.type", image.fill.type, EET_T_CHAR);
605
606 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part_Description_Proxy);
607 eddc.func.mem_free = mem_free_proxy;
608 eddc.func.mem_alloc = mem_alloc_proxy;
609 _edje_edd_edje_part_description_proxy =
610 eet_data_descriptor_file_new(&eddc);
611 EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON_SUB(_edje_edd_edje_part_description_proxy, Edje_Part_Description_Proxy, common);
612
613 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_proxy, Edje_Part_Description_Proxy, "proxy.id", proxy.id, EET_T_INT);
614 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_proxy, Edje_Part_Description_Proxy, "proxy.fill.smooth", proxy.fill.smooth, EET_T_CHAR);
615 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_proxy, Edje_Part_Description_Proxy, "proxy.fill.pos_rel_x", proxy.fill.pos_rel_x, EDJE_T_FLOAT);
616 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_proxy, Edje_Part_Description_Proxy, "proxy.fill.pos_abs_x", proxy.fill.pos_abs_x, EET_T_INT);
617 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_proxy, Edje_Part_Description_Proxy, "proxy.fill.rel_x", proxy.fill.rel_x, EDJE_T_FLOAT);
618 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_proxy, Edje_Part_Description_Proxy, "proxy.fill.abs_x", proxy.fill.abs_x, EET_T_INT);
619 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_proxy, Edje_Part_Description_Proxy, "proxy.fill.pos_rel_y", proxy.fill.pos_rel_y, EDJE_T_FLOAT);
620 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_proxy, Edje_Part_Description_Proxy, "proxy.fill.pos_abs_y", proxy.fill.pos_abs_y, EET_T_INT);
621 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_proxy, Edje_Part_Description_Proxy, "proxy.fill.rel_y", proxy.fill.rel_y, EDJE_T_FLOAT);
622 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_proxy, Edje_Part_Description_Proxy, "proxy.fill.abs_y", proxy.fill.abs_y, EET_T_INT);
623 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_proxy, Edje_Part_Description_Proxy, "proxy.fill.angle", proxy.fill.angle, EET_T_INT);
624 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_proxy, Edje_Part_Description_Proxy, "proxy.fill.spread", proxy.fill.spread, EET_T_INT);
625 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_proxy, Edje_Part_Description_Proxy, "proxy.fill.type", proxy.fill.type, EET_T_CHAR);
626
627 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part_Description_Text);
628 eddc.func.mem_free = mem_free_text;
629 eddc.func.mem_alloc = mem_alloc_text;
630 _edje_edd_edje_part_description_text =
631 eet_data_descriptor_file_new(&eddc);
632 EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON_SUB(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, common);
633 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.color3.r", text.color3.r, EET_T_UCHAR);
634 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.color3.g", text.color3.g, EET_T_UCHAR);
635 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.color3.b", text.color3.b, EET_T_UCHAR);
636 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.color3.a", text.color3.a, EET_T_UCHAR);
637 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.text", text.text, EET_T_STRING);
638 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.text_class", text.text_class, EET_T_STRING);
639 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.style", text.style, EET_T_STRING);
640 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.font", text.font, EET_T_STRING);
641 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.size_range_min", text.size_range_min, EET_T_INT);
642 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.size_range_max", text.size_range_max, EET_T_INT);
643 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.repch", text.repch, EET_T_STRING);
644 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.size", text.size, EET_T_INT);
645 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.fit_x", text.fit_x, EET_T_UCHAR);
646 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.fit_y", text.fit_y, EET_T_UCHAR);
647 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.min_x", text.min_x, EET_T_UCHAR);
648 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.min_y", text.min_y, EET_T_UCHAR);
649 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.max_x", text.max_x, EET_T_UCHAR);
650 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.max_y", text.max_y, EET_T_UCHAR);
651 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.align.x", text.align.x, EDJE_T_FLOAT);
652 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.align.y", text.align.y, EDJE_T_FLOAT);
653 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.id_source", text.id_source, EET_T_INT);
654 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.id_text_source", text.id_text_source, EET_T_INT);
655 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.elipsis", text.elipsis, EET_T_DOUBLE);
656
657 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part_Description_Text);
658 eddc.func.mem_free = mem_free_textblock;
659 eddc.func.mem_alloc = mem_alloc_textblock;
660 _edje_edd_edje_part_description_textblock =
661 eet_data_descriptor_file_new(&eddc);
662 EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON_SUB(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, common);
663 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.color3.r", text.color3.r, EET_T_UCHAR);
664 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.color3.g", text.color3.g, EET_T_UCHAR);
665 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.color3.b", text.color3.b, EET_T_UCHAR);
666 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.color3.a", text.color3.a, EET_T_UCHAR);
667 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.text", text.text, EET_T_STRING);
668 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.text_class", text.text_class, EET_T_STRING);
669 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.style", text.style, EET_T_STRING);
670 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.font", text.font, EET_T_STRING);
671 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.repch", text.repch, EET_T_STRING);
672 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.size", text.size, EET_T_INT);
673 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.size_range_min", text.size_range_min, EET_T_INT);
674 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.size_range_max", text.size_range_max, EET_T_INT);
675 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.fit_x", text.fit_x, EET_T_UCHAR);
676 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.fit_y", text.fit_y, EET_T_UCHAR);
677 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.min_x", text.min_x, EET_T_UCHAR);
678 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.min_y", text.min_y, EET_T_UCHAR);
679 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.max_x", text.max_x, EET_T_UCHAR);
680 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.max_y", text.max_y, EET_T_UCHAR);
681 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.align.x", text.align.x, EDJE_T_FLOAT);
682 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.align.y", text.align.y, EDJE_T_FLOAT);
683 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.id_source", text.id_source, EET_T_INT);
684 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.id_text_source", text.id_text_source, EET_T_INT);
685 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.elipsis", text.elipsis, EET_T_DOUBLE);
686
687 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part_Description_Box);
688 eddc.func.mem_free = mem_free_box;
689 eddc.func.mem_alloc = mem_alloc_box;
690 _edje_edd_edje_part_description_box =
691 eet_data_descriptor_file_new(&eddc);
692 EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON_SUB(_edje_edd_edje_part_description_box, Edje_Part_Description_Box, common);
693 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_box, Edje_Part_Description_Box, "box.layout", box.layout, EET_T_STRING);
694 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_box, Edje_Part_Description_Box, "box.alt_layout", box.alt_layout, EET_T_STRING);
695 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_box, Edje_Part_Description_Box, "box.align.x", box.align.x, EDJE_T_FLOAT);
696 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_box, Edje_Part_Description_Box, "box.align.y", box.align.y, EDJE_T_FLOAT);
697 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_box, Edje_Part_Description_Box, "box.padding.x", box.padding.x, EET_T_INT);
698 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_box, Edje_Part_Description_Box, "box.padding.y", box.padding.y, EET_T_INT);
699 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_box, Edje_Part_Description_Box, "box.min.h", box.min.h, EET_T_UCHAR);
700 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_box, Edje_Part_Description_Box, "box.min.v", box.min.v, EET_T_UCHAR);
701
702 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part_Description_Table);
703 eddc.func.mem_free = mem_free_table;
704 eddc.func.mem_alloc = mem_alloc_table;
705 _edje_edd_edje_part_description_table =
706 eet_data_descriptor_file_new(&eddc);
707 EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON_SUB(_edje_edd_edje_part_description_table, Edje_Part_Description_Table, common);
708 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_table, Edje_Part_Description_Table, "table.homogeneous", table.homogeneous, EET_T_UCHAR);
709 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_table, Edje_Part_Description_Table, "table.align.x", table.align.x, EDJE_T_FLOAT);
710 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_table, Edje_Part_Description_Table, "table.align.y", table.align.y, EDJE_T_FLOAT);
711 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_table, Edje_Part_Description_Table, "table.padding.x", table.padding.x, EET_T_INT);
712 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_table, Edje_Part_Description_Table, "table.padding.y", table.padding.y, EET_T_INT);
713 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_table, Edje_Part_Description_Table, "table.min.h", table.min.h, EET_T_UCHAR);
714 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_table, Edje_Part_Description_Table, "table.min.v", table.min.v, EET_T_UCHAR);
715
716 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part_Description_External);
717 eddc.func.mem_free = mem_free_external;
718 eddc.func.mem_alloc = mem_alloc_external;
719 _edje_edd_edje_part_description_external =
720 eet_data_descriptor_file_new(&eddc);
721 EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON_SUB(_edje_edd_edje_part_description_external, Edje_Part_Description_External, common);
722 EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_edje_part_description_external, Edje_Part_Description_External, "external_params", external_params, _edje_edd_edje_external_param);
723
724 EDJE_DEFINE_POINTER_TYPE(Part_Description_Common, part_description_rectangle);
725 EDJE_DEFINE_POINTER_TYPE(Part_Description_Common, part_description_swallow);
726 EDJE_DEFINE_POINTER_TYPE(Part_Description_Common, part_description_group);
727 EDJE_DEFINE_POINTER_TYPE(Part_Description_Image, part_description_image);
728 EDJE_DEFINE_POINTER_TYPE(Part_Description_Proxy, part_description_proxy);
729 EDJE_DEFINE_POINTER_TYPE(Part_Description_Text, part_description_text);
730 EDJE_DEFINE_POINTER_TYPE(Part_Description_Text, part_description_textblock);
731 EDJE_DEFINE_POINTER_TYPE(Part_Description_Box, part_description_box);
732 EDJE_DEFINE_POINTER_TYPE(Part_Description_Table, part_description_table);
733 EDJE_DEFINE_POINTER_TYPE(Part_Description_External, part_description_external);
734
735 eddc.version = EET_DATA_DESCRIPTOR_CLASS_VERSION;
736 eddc.func.type_get = _edje_description_variant_type_get;
737 eddc.func.type_set = _edje_description_variant_type_set;
738 _edje_edd_edje_part_description_variant = eet_data_descriptor_file_new(&eddc);
739
740 EET_DATA_DESCRIPTOR_ADD_MAPPING(_edje_edd_edje_part_description_variant, "rectangle", _edje_edd_edje_part_description_rectangle);
741 EET_DATA_DESCRIPTOR_ADD_MAPPING(_edje_edd_edje_part_description_variant, "swallow", _edje_edd_edje_part_description_swallow);
742 EET_DATA_DESCRIPTOR_ADD_MAPPING(_edje_edd_edje_part_description_variant, "group", _edje_edd_edje_part_description_group);
743 EET_DATA_DESCRIPTOR_ADD_MAPPING(_edje_edd_edje_part_description_variant, "image", _edje_edd_edje_part_description_image);
744 EET_DATA_DESCRIPTOR_ADD_MAPPING(_edje_edd_edje_part_description_variant, "proxy", _edje_edd_edje_part_description_proxy);
745 EET_DATA_DESCRIPTOR_ADD_MAPPING(_edje_edd_edje_part_description_variant, "text", _edje_edd_edje_part_description_text);
746 EET_DATA_DESCRIPTOR_ADD_MAPPING(_edje_edd_edje_part_description_variant, "textblock", _edje_edd_edje_part_description_textblock);
747 EET_DATA_DESCRIPTOR_ADD_MAPPING(_edje_edd_edje_part_description_variant, "box", _edje_edd_edje_part_description_box);
748 EET_DATA_DESCRIPTOR_ADD_MAPPING(_edje_edd_edje_part_description_variant, "table", _edje_edd_edje_part_description_table);
749 EET_DATA_DESCRIPTOR_ADD_MAPPING(_edje_edd_edje_part_description_variant, "external", _edje_edd_edje_part_description_external);
750
751#define EDJE_ADD_ARRAY_MAPPING(Variant, Type, Minus) \
752 { \
753 Edje_Part_Description_List tmp; \
754 \
755 eet_data_descriptor_element_add(Variant, Type, \
756 EET_T_UNKNOW, EET_G_VAR_ARRAY, \
757 0, (char*)(&tmp.desc_count) - (char*)(&tmp), \
758 NULL, \
759 _edje_edd_edje_part_description_##Minus##_pointer); \
760 }
761
762 _edje_edd_edje_part_description_variant_list = eet_data_descriptor_file_new(&eddc);
763
764 EDJE_ADD_ARRAY_MAPPING(_edje_edd_edje_part_description_variant_list, "rectangle", rectangle);
765 EDJE_ADD_ARRAY_MAPPING(_edje_edd_edje_part_description_variant_list, "swallow", swallow);
766 EDJE_ADD_ARRAY_MAPPING(_edje_edd_edje_part_description_variant_list, "group", group);
767 EDJE_ADD_ARRAY_MAPPING(_edje_edd_edje_part_description_variant_list, "image", image);
768 EDJE_ADD_ARRAY_MAPPING(_edje_edd_edje_part_description_variant_list, "proxy", proxy);
769 EDJE_ADD_ARRAY_MAPPING(_edje_edd_edje_part_description_variant_list, "text", text);
770 EDJE_ADD_ARRAY_MAPPING(_edje_edd_edje_part_description_variant_list, "textblock", textblock);
771 EDJE_ADD_ARRAY_MAPPING(_edje_edd_edje_part_description_variant_list, "box", box);
772 EDJE_ADD_ARRAY_MAPPING(_edje_edd_edje_part_description_variant_list, "table", table);
773 EDJE_ADD_ARRAY_MAPPING(_edje_edd_edje_part_description_variant_list, "external", external);
774
775 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Pack_Element);
776 _edje_edd_edje_pack_element =
777 eet_data_descriptor_file_new(&eddc);
778 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "type", type, EET_T_UCHAR);
779 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "name", name, EET_T_STRING);
780 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "source", source, EET_T_STRING);
781 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "min.w", min.w, EET_T_INT);
782 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "min.h", min.h, EET_T_INT);
783 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "prefer.w", prefer.w, EET_T_INT);
784 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "prefer.h", prefer.h, EET_T_INT);
785 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "max.w", max.w, EET_T_INT);
786 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "max.h", max.h, EET_T_INT);
787 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "padding.l", padding.l, EET_T_INT);
788 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "padding.r", padding.r, EET_T_INT);
789 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "padding.t", padding.t, EET_T_INT);
790 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "padding.b", padding.b, EET_T_INT);
791 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "align.x", align.x, EDJE_T_FLOAT);
792 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "align.y", align.y, EDJE_T_FLOAT);
793 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "weight.x", weight.x, EDJE_T_FLOAT);
794 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "weight.y", weight.y, EDJE_T_FLOAT);
795 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "aspect.w", aspect.w, EET_T_INT);
796 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "aspect.h", aspect.h, EET_T_INT);
797 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "aspect.mode", aspect.mode, EET_T_UCHAR);
798 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "options", options, EET_T_STRING);
799 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "col", col, EET_T_INT);
800 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "row", row, EET_T_INT);
801 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "colspan", colspan, EET_T_USHORT);
802 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "rowspan", rowspan, EET_T_USHORT);
803
804 EDJE_DEFINE_POINTER_TYPE(Pack_Element, pack_element);
805
806 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part);
807 eddc.func.mem_free = mem_free_part;
808 eddc.func.mem_alloc = mem_alloc_part;
809 _edje_edd_edje_part =
810 eet_data_descriptor_file_new(&eddc);
811 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "name", name, EET_T_STRING);
812 EET_DATA_DESCRIPTOR_ADD_VARIANT(_edje_edd_edje_part, Edje_Part, "default_desc", default_desc, type, _edje_edd_edje_part_description_variant);
813 EET_DATA_DESCRIPTOR_ADD_VARIANT(_edje_edd_edje_part, Edje_Part, "other", other, type, _edje_edd_edje_part_description_variant_list);
814 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "source", source, EET_T_STRING);
815 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "source2", source2, EET_T_STRING);
816 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "source3", source3, EET_T_STRING);
817 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "source4", source4, EET_T_STRING);
818 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "source5", source5, EET_T_STRING);
819 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "source6", source6, EET_T_STRING);
820 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "id", id, EET_T_INT);
821 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "clip_to_id", clip_to_id, EET_T_INT);
822 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "dragable.x", dragable.x, EET_T_CHAR);
823 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "dragable.step_x", dragable.step_x, EET_T_INT);
824 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "dragable.count_x", dragable.count_x, EET_T_INT);
825 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "dragable.y", dragable.y, EET_T_CHAR);
826 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "dragable.step_y", dragable.step_y, EET_T_INT);
827 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "dragable.count_y", dragable.count_y, EET_T_INT);
828 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "dragable.counfine_id", dragable.confine_id, EET_T_INT);
829 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "dragable.events_id", dragable.event_id, EET_T_INT);
830 EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_edje_edd_edje_part, Edje_Part, "items", items, _edje_edd_edje_pack_element_pointer);
831 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "type", type, EET_T_UCHAR);
832 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "effect", effect, EET_T_UCHAR);
833 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "mouse_events", mouse_events, EET_T_UCHAR);
834 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "repeat_events", repeat_events, EET_T_UCHAR);
835 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "ignore_flags", ignore_flags, EET_T_INT);
836 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "scale", scale, EET_T_UCHAR);
837 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "precise_is_inside", precise_is_inside, EET_T_UCHAR);
838 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "use_alternate_font_metrics", use_alternate_font_metrics, EET_T_UCHAR);
839 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "pointer_mode", pointer_mode, EET_T_UCHAR);
840 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "entry_mode", entry_mode, EET_T_UCHAR);
841 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "select_mode", select_mode, EET_T_UCHAR);
842 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "cursor_mode", cursor_mode, EET_T_UCHAR);
843 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "multiline", multiline, EET_T_UCHAR);
844 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "api.name", api.name, EET_T_STRING);
845 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "api.description", api.description, EET_T_STRING);
846
847 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part_Collection);
848 _edje_edd_edje_part_collection =
849 eet_data_descriptor_file_new(&eddc);
850
851 EDJE_DEFINE_POINTER_TYPE(Program, program);
852 EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_edje_edd_edje_part_collection, Edje_Part_Collection, "programs.fnmatch", programs.fnmatch, _edje_edd_edje_program_pointer);
853 EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_edje_edd_edje_part_collection, Edje_Part_Collection, "programs.strcmp", programs.strcmp, _edje_edd_edje_program_pointer);
854 EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_edje_edd_edje_part_collection, Edje_Part_Collection, "programs.strncmp", programs.strncmp, _edje_edd_edje_program_pointer);
855 EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_edje_edd_edje_part_collection, Edje_Part_Collection, "programs.strrncmp", programs.strrncmp, _edje_edd_edje_program_pointer);
856 EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_edje_edd_edje_part_collection, Edje_Part_Collection, "programs.nocmp", programs.nocmp, _edje_edd_edje_program_pointer);
857
858 EDJE_DEFINE_POINTER_TYPE(Part, part);
859 EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_edje_edd_edje_part_collection, Edje_Part_Collection, "parts", parts, _edje_edd_edje_part_pointer);
860
861 EDJE_DEFINE_POINTER_TYPE(Limit, limit);
862 EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_edje_edd_edje_part_collection, Edje_Part_Collection, "limits.vertical", limits.vertical, _edje_edd_edje_limit_pointer);
863 EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_edje_edd_edje_part_collection, Edje_Part_Collection, "limits.horizontal", limits.horizontal, _edje_edd_edje_limit_pointer);
864
865 EET_DATA_DESCRIPTOR_ADD_HASH(_edje_edd_edje_part_collection, Edje_Part_Collection, "data", data, _edje_edd_edje_string);
866 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "id", id, EET_T_INT);
867 EET_DATA_DESCRIPTOR_ADD_HASH_STRING(_edje_edd_edje_part_collection, Edje_Part_Collection, "alias", alias);
868 EET_DATA_DESCRIPTOR_ADD_HASH_STRING(_edje_edd_edje_part_collection, Edje_Part_Collection, "aliased", aliased);
869 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "prop.min.w", prop.min.w, EET_T_INT);
870 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "prop.min.h", prop.min.h, EET_T_INT);
871 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "prop.max.w", prop.max.w, EET_T_INT);
872 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "prop.max.h", prop.max.h, EET_T_INT);
873 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "part", part, EET_T_STRING);
874 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "script_only", script_only, EET_T_UCHAR);
875 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "lua_script_only", lua_script_only, EET_T_UCHAR);
876 EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "prop.orientation", prop.orientation, EET_T_INT);
877}
diff --git a/libraries/edje/src/lib/edje_edit.c b/libraries/edje/src/lib/edje_edit.c
new file mode 100644
index 0000000..901a1b1
--- /dev/null
+++ b/libraries/edje/src/lib/edje_edit.c
@@ -0,0 +1,7829 @@
1/*
2 * TODO
3 * -----------------------------------------------------------------
4 * Add LUA Support :)
5 * Remove images/fonts
6 * Clean the saving routines
7 *
8 */
9
10#include "edje_private.h"
11
12#define EDJE_EDIT_IS_UNSTABLE_AND_I_KNOW_ABOUT_IT
13#include "Edje_Edit.h"
14
15static const char EDJE_EDIT_ERROR_GROUP_CURRENTLY_USED_STR[] = "Current group cannot be deleted";
16static const char EDJE_EDIT_ERROR_GROUP_REFERENCED_STR[] = "Group still in use";
17static const char EDJE_EDIT_ERROR_GROUP_DOES_NOT_EXIST_STR[] = "Group does not exist";
18
19EAPI Eina_Error EDJE_EDIT_ERROR_GROUP_CURRENTLY_USED = 0 ;
20EAPI Eina_Error EDJE_EDIT_ERROR_GROUP_REFERENCED = 0;
21EAPI Eina_Error EDJE_EDIT_ERROR_GROUP_DOES_NOT_EXIST = 0;
22
23/* Get ed(Edje*) from obj(Evas_Object*) */
24#define GET_ED_OR_RETURN(RET) \
25 Edje *ed; \
26 Edje_Edit *eed; \
27 if (!evas_object_smart_type_check_ptr(obj, _edje_edit_type)) \
28 return RET; \
29 eed = evas_object_smart_data_get(obj); \
30 if (!eed) return RET; \
31 ed = (Edje *)eed;
32
33/* Get rp(Edje_Real_Part*) from obj(Evas_Object*) and part(char*) */
34#define GET_RP_OR_RETURN(RET) \
35 Edje *ed; \
36 Edje_Edit *eed; \
37 Edje_Real_Part *rp; \
38 if (!evas_object_smart_type_check_ptr(obj, _edje_edit_type)) \
39 return RET; \
40 eed = evas_object_smart_data_get(obj); \
41 if (!eed) return RET; \
42 ed = (Edje *)eed; \
43 rp = _edje_real_part_get(ed, part); \
44 if (!rp) return RET;
45
46/* Get pd(Edje_Part_Description*) from obj(Evas_Object*), part(char*) and state (char*) */
47#define GET_PD_OR_RETURN(RET) \
48 Edje *ed; \
49 Edje_Edit *eed; \
50 Edje_Real_Part *rp; \
51 Edje_Part_Description_Common *pd; \
52 if (!evas_object_smart_type_check_ptr(obj, _edje_edit_type)) \
53 return RET; \
54 eed = evas_object_smart_data_get(obj); \
55 if (!eed) return RET; \
56 ed = (Edje *)eed; \
57 rp = _edje_real_part_get(ed, part); \
58 if (!rp) return RET; \
59 pd = _edje_part_description_find_byname(eed, part, state, value); \
60 if (!pd) return RET;
61
62/* Get epr(Edje_Program*) from obj(Evas_Object*) and prog(char*)*/
63#define GET_EPR_OR_RETURN(RET) \
64 Edje_Program *epr; \
65 if (!evas_object_smart_type_check_ptr(obj, _edje_edit_type)) \
66 return RET; \
67 epr = _edje_program_get_byname(obj, prog); \
68 if (!epr) return RET;
69
70static void *
71_alloc(size_t size)
72{
73 void *mem;
74
75 mem = calloc(1, size);
76 if (mem) return mem;
77 ERR("Edje_Edit: Error. memory allocation of %i bytes failed. %s",
78 (int)size, strerror(errno));
79 return NULL;
80}
81
82/*************/
83/* INTERNALS */
84/*************/
85
86/* Edje_Edit smart! Overloads the edje one adding some more control stuff */
87static const char _edje_edit_type[] = "edje_edit";
88
89typedef struct _Edje_Edit Edje_Edit;
90struct _Edje_Edit
91{
92 Edje base;
93
94 void *bytecode;
95 int bytecode_size;
96
97 char *embryo_source;
98 char *embryo_processed;
99 Eina_Hash *program_scripts;
100
101 Eina_List *errors;
102
103 Eina_Bool bytecode_dirty:1;
104 Eina_Bool embryo_source_dirty:1;
105 Eina_Bool all_dirty:1;
106 Eina_Bool script_need_recompile:1;
107};
108
109typedef struct _Program_Script Program_Script;
110struct _Program_Script
111{
112 int id;
113 char *code;
114 char *processed;
115 Eina_Bool dirty:1;
116 Eina_Bool delete_me:1;
117};
118
119static void _edje_edit_smart_add(Evas_Object *obj);
120static void _edje_edit_smart_del(Evas_Object *obj);
121
122static Eina_Bool _edje_edit_smart_file_set(Evas_Object *obj, const char *file, const char *group);
123static Eina_Bool _edje_edit_edje_file_save(Eet_File *eetf, Edje_File *ef);
124
125EVAS_SMART_SUBCLASS_NEW(_edje_edit_type, _edje_edit, Edje_Smart_Api,
126 Edje_Smart_Api, _edje_object_smart_class_get, NULL)
127
128static void
129_edje_edit_smart_set_user(Edje_Smart_Api *sc)
130{
131 sc->base.add = _edje_edit_smart_add;
132 sc->base.del = _edje_edit_smart_del;
133 sc->file_set = _edje_edit_smart_file_set;
134}
135
136static void
137_edje_edit_smart_add(Evas_Object *obj)
138{
139 Edje_Edit *eed;
140
141 eed = evas_object_smart_data_get(obj);
142 if (!eed)
143 {
144 const Evas_Smart *smart;
145 const Evas_Smart_Class *sc;
146
147 eed = calloc(1, sizeof(Edje_Edit));
148 if (!eed) return;
149
150 smart = evas_object_smart_smart_get(obj);
151 sc = evas_smart_class_get(smart);
152 eed->base.api = (const Edje_Smart_Api *)sc;
153
154 evas_object_smart_data_set(obj, eed);
155 }
156
157 _edje_edit_parent_sc->base.add(obj);
158}
159
160static void
161_edje_edit_data_clean(Edje_Edit *eed)
162{
163 Edje_Edit_Script_Error *se;
164
165 free(eed->bytecode);
166 free(eed->embryo_source);
167 free(eed->embryo_processed);
168
169 if (eed->program_scripts)
170 eina_hash_free(eed->program_scripts);
171
172 EINA_LIST_FREE(eed->errors, se)
173 {
174 eina_stringshare_del(se->program_name);
175 eina_stringshare_del(se->error_str);
176 free(se);
177 }
178
179 eed->bytecode = NULL;
180 eed->embryo_source = NULL;
181 eed->embryo_processed = NULL;
182 eed->program_scripts = NULL;
183 eed->bytecode_size = 0;
184 eed->bytecode_dirty = EINA_FALSE;
185 eed->embryo_source_dirty = EINA_FALSE;
186 eed->all_dirty = EINA_FALSE;
187 eed->script_need_recompile = EINA_FALSE;
188}
189
190static void
191_edje_edit_smart_del(Evas_Object *obj)
192{
193 Edje_Edit *eed;
194
195 eed = evas_object_smart_data_get(obj);
196
197 _edje_edit_data_clean(eed);
198
199 _edje_edit_parent_sc->base.del(obj);
200}
201
202static void
203_edje_edit_program_script_free(Program_Script *ps)
204{
205 free(ps->code);
206 free(ps->processed);
207 free(ps);
208}
209
210static Eina_Bool
211_edje_edit_smart_file_set(Evas_Object *obj, const char *file, const char *group)
212{
213 Edje_Edit *eed;
214 Eet_File *ef;
215 char **keys, buf[64];
216 int count, i;
217 int len = strlen("edje/scripts/embryo/source/");
218
219 eed = evas_object_smart_data_get(obj);
220
221 _edje_edit_data_clean(eed);
222
223 /* TODO and maybes:
224 * * The whole point of this thing is keep track of stuff such as
225 * strings to free and who knows what, so we need to take care
226 * of those if the file/group changes.
227 * * Maybe have the possibility to open just files, not always with
228 * a group given.
229 * * A way to skip the cache? Could help avoid some issues when editing
230 * a group being used by the application in some other way, or multiple
231 * opens of the same file.
232 * * Here we probably want to allow opening groups with broken references
233 * (GROUP parts or BOX/TABLE items pointing to non-existent/renamed
234 * groups).
235 */
236 if (!_edje_edit_parent_sc->file_set(obj, file, group))
237 return EINA_FALSE;
238
239 eed->program_scripts = eina_hash_int32_new((Eina_Free_Cb)_edje_edit_program_script_free);
240
241 ef = eet_open(file, EET_FILE_MODE_READ);
242
243 snprintf(buf, sizeof(buf), "edje/scripts/embryo/source/%i",
244 eed->base.collection->id);
245 eed->embryo_source = eet_read(ef, buf, &count);
246
247 snprintf(buf, sizeof(buf), "edje/scripts/embryo/source/%i/*",
248 eed->base.collection->id);
249 keys = eet_list(ef, buf, &count);
250 for (i = 0; i < count; i++)
251 {
252 Program_Script *ps;
253 int size;
254
255 ps = calloc(1, sizeof(Program_Script));
256
257 sscanf(keys[i] + len, "%*i/%i", &ps->id);
258 ps->code = eet_read(ef, keys[i], &size);
259 eina_hash_add(eed->program_scripts, &ps->id, ps);
260 }
261 if (keys) free(keys);
262 return EINA_TRUE;
263}
264
265static void
266_edje_edit_error_register(void)
267{
268 EDJE_EDIT_ERROR_GROUP_DOES_NOT_EXIST =
269 eina_error_msg_static_register(EDJE_EDIT_ERROR_GROUP_DOES_NOT_EXIST_STR);
270 EDJE_EDIT_ERROR_GROUP_CURRENTLY_USED =
271 eina_error_msg_static_register(EDJE_EDIT_ERROR_GROUP_CURRENTLY_USED_STR);
272 EDJE_EDIT_ERROR_GROUP_REFERENCED =
273 eina_error_msg_static_register(EDJE_EDIT_ERROR_GROUP_REFERENCED_STR);
274}
275
276EAPI Evas_Object *
277edje_edit_object_add(Evas *e)
278{
279 eina_error_set(0);
280
281 if (!EDJE_EDIT_ERROR_GROUP_DOES_NOT_EXIST)
282 _edje_edit_error_register();
283
284 return evas_object_smart_add(e, _edje_edit_smart_class_new());
285}
286/* End of Edje_Edit smart stuff */
287
288static Edje_Part_Description_Common *
289_edje_part_description_find_byname(Edje_Edit *eed, const char *part, const char *state, double value)
290{
291 Edje_Real_Part *rp;
292 Edje_Part_Description_Common *pd;
293
294 if (!eed || !part || !state) return NULL;
295
296 rp = _edje_real_part_get((Edje *)eed, part);
297 if (!rp) return NULL;
298
299 pd = _edje_part_description_find((Edje *)eed, rp, state, value);
300
301 return pd;
302}
303
304static int
305_edje_image_id_find(Edje_Edit *eed, const char *image_name)
306{
307 unsigned int i;
308
309 if (!eed->base.file) return -1;
310 if (!eed->base.file->image_dir) return -1;
311
312 //printf("SEARCH IMAGE %s\n", image_name);
313
314 for (i = 0; i < eed->base.file->image_dir->entries_count; ++i)
315 if (eed->base.file->image_dir->entries[i].entry
316 && !strcmp(image_name, eed->base.file->image_dir->entries[i].entry))
317 return i;
318
319 return -1;
320}
321
322static const char *
323_edje_image_name_find(Edje_Edit *eed, int image_id)
324{
325 if (!eed->base.file) return NULL;
326 if (!eed->base.file->image_dir) return NULL;
327
328 /* Special case for external image */
329 if (image_id < 0) image_id = -image_id - 1;
330
331 //printf("SEARCH IMAGE ID %d\n", image_id);
332 if ((unsigned int) image_id >= eed->base.file->image_dir->entries_count)
333 return NULL;
334 return eed->base.file->image_dir->entries[image_id].entry;
335}
336
337static void
338_edje_real_part_free(Edje_Real_Part *rp)
339{
340 if (!rp) return;
341
342 if (rp->object)
343 {
344 _edje_callbacks_del(rp->object, rp->edje);
345 evas_object_del(rp->object);
346 }
347
348 if (rp->swallowed_object)
349 {
350 evas_object_smart_member_del(rp->swallowed_object);
351 evas_object_event_callback_del(rp->swallowed_object,
352 EVAS_CALLBACK_FREE,
353 _edje_object_part_swallow_free_cb);
354 evas_object_clip_unset(rp->swallowed_object);
355 evas_object_data_del(rp->swallowed_object, "\377 edje.swallowing_part");
356 if (rp->part->mouse_events)
357 _edje_callbacks_del(rp->swallowed_object, rp->edje);
358
359 if (rp->part->type == EDJE_PART_TYPE_GROUP ||
360 rp->part->type == EDJE_PART_TYPE_EXTERNAL)
361 evas_object_del(rp->swallowed_object);
362
363 rp->swallowed_object = NULL;
364 }
365
366 if (rp->text.text) eina_stringshare_del(rp->text.text);
367 if (rp->text.font) eina_stringshare_del(rp->text.font);
368 if (rp->text.cache.in_str) eina_stringshare_del(rp->text.cache.in_str);
369 if (rp->text.cache.out_str) eina_stringshare_del(rp->text.cache.out_str);
370
371 if (rp->custom)
372 {
373 _edje_collection_free_part_description_clean(rp->part->type, rp->custom->description, 0);
374 if (rp->custom) free(rp->custom->set);
375 eina_mempool_free(_edje_real_part_state_mp, rp->custom);
376 rp->custom = NULL;
377 }
378
379 free(rp->drag);
380
381 if (rp->param2) free(rp->param2->set);
382 eina_mempool_free(_edje_real_part_state_mp, rp->param2);
383
384 _edje_unref(rp->edje);
385 eina_mempool_free(_edje_real_part_mp, rp);
386}
387
388static Eina_Bool
389_edje_import_font_file(Edje *ed, const char *path, const char *entry)
390{
391 void *fdata = NULL;
392 long fsize = 0;
393
394 /* Read font data from file */
395 {
396 FILE *f = fopen(path, "rb");
397 if (!f)
398 {
399 ERR("Unable to open font file \"%s\"", path);
400 return EINA_FALSE;
401 }
402
403 fseek(f, 0, SEEK_END);
404 fsize = ftell(f);
405 rewind(f);
406 fdata = malloc(fsize);
407 if (!fdata)
408 {
409 ERR("Unable to alloc font file \"%s\"", path);
410 fclose(f);
411 return EINA_FALSE;
412 }
413 if (fread(fdata, fsize, 1, f) != 1)
414 {
415 free(fdata);
416 fclose(f);
417 ERR("Unable to read all of font file \"%s\"", path);
418 return EINA_FALSE;
419 }
420 fclose(f);
421 }
422
423 /* Write font to edje file */
424 {
425 /* open the eet file */
426 Eet_File *eetf = eet_open(ed->path, EET_FILE_MODE_READ_WRITE);
427 if (!eetf)
428 {
429 ERR("Unable to open \"%s\" for writing output", ed->path);
430 free(fdata);
431 return EINA_FALSE;
432 }
433
434 if (eet_write(eetf, entry, fdata, fsize, 1) <= 0)
435 {
436 ERR("Unable to write font part \"%s\" as \"%s\" part entry",
437 path, entry);
438 eet_close(eetf);
439 free(fdata);
440 return EINA_FALSE;
441 }
442
443 free(fdata);
444
445 /* write the edje_file */
446 if (!_edje_edit_edje_file_save(eetf, ed->file))
447 {
448 eet_delete(eetf, entry);
449 eet_close(eetf);
450 return EINA_FALSE;
451 }
452
453 eet_close(eetf);
454 }
455
456 return EINA_TRUE;
457}
458
459
460static Eina_Bool
461_edje_import_image_file(Edje *ed, const char *path, int id)
462{
463 char entry[PATH_MAX];
464 Evas_Object *im;
465 Eet_File *eetf;
466 void *im_data;
467 int im_w, im_h;
468 int im_alpha;
469 int bytes;
470
471 /* Try to load the file */
472 im = evas_object_image_add(ed->base.evas);
473 if (!im) return EINA_FALSE;
474
475 evas_object_image_file_set(im, path, NULL);
476 if (evas_object_image_load_error_get(im) != EVAS_LOAD_ERROR_NONE)
477 {
478 ERR("Edje_Edit: unable to load image \"%s\"."
479 "Missing PNG or JPEG loader modules for Evas or "
480 "file does not exist, or is not readable.", path);
481 evas_object_del(im);
482 im = NULL;
483 return EINA_FALSE;
484 }
485
486 /* Write the loaded image to the edje file */
487
488 evas_object_image_size_get(im, &im_w, &im_h);
489 im_alpha = evas_object_image_alpha_get(im);
490 im_data = evas_object_image_data_get(im, 0);
491 if ((!im_data) || !(im_w > 0) || !(im_h > 0))
492 {
493 evas_object_del(im);
494 return EINA_FALSE;
495 }
496
497 /* open the eet file */
498 eetf = eet_open(ed->path, EET_FILE_MODE_READ_WRITE);
499 if (!eetf)
500 {
501 ERR("Unable to open \"%s\" for writing output", ed->path);
502 evas_object_del(im);
503 return EINA_FALSE;
504 }
505
506 snprintf(entry, sizeof(entry), "edje/images/%i", id);
507
508 /* write the image data */
509 bytes = eet_data_image_write(eetf, entry,
510 im_data, im_w, im_h,
511 im_alpha,
512 0, 100, 1);
513 if (bytes <= 0)
514 {
515 ERR("Unable to write image part \"%s\" part entry to %s",
516 entry, ed->path);
517 eet_close(eetf);
518 evas_object_del(im);
519 return EINA_FALSE;
520 }
521
522 evas_object_del(im);
523
524 /* write the edje_file */
525 if (!_edje_edit_edje_file_save(eetf, ed->file))
526 {
527 eet_delete(eetf, entry);
528 eet_close(eetf);
529 return EINA_FALSE;
530 }
531
532 eet_close(eetf);
533 return EINA_TRUE;
534}
535
536static int
537_edje_part_id_find(Edje *ed, const char *part)
538{
539 unsigned int id;
540
541 for (id = 0; id < ed->table_parts_size; id++)
542 {
543 Edje_Real_Part *rp = ed->table_parts[id];
544
545 if (!strcmp(rp->part->name, part))
546 return id;
547 }
548 return -1;
549}
550
551static void
552_edje_part_description_id_set(int type, Edje_Part_Description_Common *c, int old_id, int new_id)
553{
554 if (c->rel1.id_x == old_id) c->rel1.id_x = new_id;
555 if (c->rel1.id_y == old_id) c->rel1.id_y = new_id;
556 if (c->rel2.id_x == old_id) c->rel2.id_x = new_id;
557 if (c->rel2.id_y == old_id) c->rel2.id_y = new_id;
558
559 if (type == EDJE_PART_TYPE_TEXT
560 || type == EDJE_PART_TYPE_TEXTBLOCK)
561 {
562 Edje_Part_Description_Text *t;
563
564 t = (Edje_Part_Description_Text *) c;
565
566 if (t->text.id_source == old_id) t->text.id_source = new_id;
567 if (t->text.id_text_source == old_id) t->text.id_text_source = new_id;
568 }
569}
570
571static void
572_edje_part_program_id_set(Edje_Program *epr, int old_id, int new_id)
573{
574 Edje_Program_Target *pt;
575 Eina_List *ll, *l_next;
576
577 if (epr->action != EDJE_ACTION_TYPE_STATE_SET)
578 return;
579
580 EINA_LIST_FOREACH_SAFE(epr->targets, ll, l_next, pt)
581 {
582 if (pt->id == old_id)
583 {
584 if (new_id == -1)
585 epr->targets = eina_list_remove_list(epr->targets, ll);
586 else
587 pt->id = new_id;
588 }
589 }
590}
591
592static void
593_edje_part_id_set(Edje *ed, Edje_Real_Part *rp, int new_id)
594{
595 /* This function change the id of a given real_part.
596 * All the depedency will be updated too.
597 * Also the table_parts is updated, and the current *rp in the table
598 * is lost.
599 * If new Id = -1 then all the depencies will be deleted
600 */
601 Edje_Part *part;
602 unsigned int j;
603 int old_id;
604
605 part = rp->part;
606
607 if (!part) return;
608 //printf("CHANGE ID OF PART %s TO %d\n", part->name, new_id);
609
610 if (!ed || new_id < -1) return;
611
612 if (part->id == new_id) return;
613
614 old_id = part->id;
615 part->id = new_id;
616
617 /* Fix all the dependecies in all parts... */
618 for (j = 0; j < ed->collection->parts_count; ++j)
619 {
620 Edje_Part *p;
621 unsigned int k;
622
623 p = ed->collection->parts[j];
624
625 //printf(" search id: %d in %s\n", old_id, p->name);
626 if (p->clip_to_id == old_id) p->clip_to_id = new_id;
627 if (p->dragable.confine_id == old_id) p->dragable.confine_id = new_id;
628
629 /* ...in default description */
630 _edje_part_description_id_set(p->type, p->default_desc, old_id, new_id);
631
632 /* ...and in all other descriptions */
633 for (k = 0; k < p->other.desc_count; ++k)
634 _edje_part_description_id_set(p->type, p->other.desc[k], old_id, new_id);
635 }
636
637 /*...and also in programs targets */
638#define EDJE_EDIT_PROGRAM_ID_SET(Array, Ed, It, Old, New) \
639 for (It = 0; It < Ed->collection->programs.Array##_count; ++It) \
640 _edje_part_program_id_set(Ed->collection->programs.Array[It], Old, New);
641
642 EDJE_EDIT_PROGRAM_ID_SET(fnmatch, ed, j, old_id, new_id);
643 EDJE_EDIT_PROGRAM_ID_SET(strcmp, ed, j, old_id, new_id);
644 EDJE_EDIT_PROGRAM_ID_SET(strncmp, ed, j, old_id, new_id);
645 EDJE_EDIT_PROGRAM_ID_SET(strrncmp, ed, j, old_id, new_id);
646 EDJE_EDIT_PROGRAM_ID_SET(nocmp, ed, j, old_id, new_id);
647
648 /* Adjust table_parts */
649 if (new_id >= 0)
650 ed->table_parts[new_id] = rp;
651}
652
653static void
654_edje_part_description_id_switch(int type, Edje_Part_Description_Common *c, int id1, int id2)
655{
656 if (c->rel1.id_x == id1) c->rel1.id_x = id2;
657 else if (c->rel1.id_x == id2) c->rel1.id_x = id1;
658 if (c->rel1.id_y == id1) c->rel1.id_y = id2;
659 else if (c->rel1.id_y == id2) c->rel1.id_y = id1;
660 if (c->rel2.id_x == id1) c->rel2.id_x = id2;
661 else if (c->rel2.id_x == id2) c->rel2.id_x = id1;
662 if (c->rel2.id_y == id1) c->rel2.id_y = id2;
663 else if (c->rel2.id_y == id2) c->rel2.id_y = id1;
664
665 if (type == EDJE_PART_TYPE_TEXT
666 || type == EDJE_PART_TYPE_TEXTBLOCK)
667 {
668 Edje_Part_Description_Text *t;
669
670 t = (Edje_Part_Description_Text *) c;
671
672 if (t->text.id_source == id1) t->text.id_source = id2;
673 else if (t->text.id_source == id2) t->text.id_source = id1;
674 if (t->text.id_text_source == id1) t->text.id_text_source = id2;
675 else if (t->text.id_text_source == id2) t->text.id_text_source = id2;
676 }
677}
678
679static void
680_edje_part_program_id_switch(Edje_Program *epr, int id1, int id2)
681{
682 Edje_Program_Target *pt;
683 Eina_List *ll;
684
685 if (epr->action != EDJE_ACTION_TYPE_STATE_SET)
686 return;
687
688 EINA_LIST_FOREACH(epr->targets, ll, pt)
689 {
690 if (pt->id == id1) pt->id = id2;
691 else if (pt->id == id2) pt->id = id1;
692 }
693}
694
695static void
696_edje_parts_id_switch(Edje *ed, Edje_Real_Part *rp1, Edje_Real_Part *rp2)
697{
698 /* This function switch the id of two parts.
699 * All the depedency will be updated too.
700 * Also the table_parts is updated,
701 * The parts list isn't touched
702 */
703 int id1;
704 int id2;
705 unsigned int i;
706
707 //printf("SWITCH ID OF PART %d AND %d\n", rp1->part->id, rp2->part->id);
708
709 if (!ed || !rp1 || !rp2) return;
710 if (rp1 == rp2) return;
711
712 id1 = rp1->part->id;
713 id2 = rp2->part->id;
714
715 /* Switch ids */
716 rp1->part->id = id2;
717 rp2->part->id = id1;
718
719 /* adjust table_parts */
720 ed->table_parts[id1] = rp2;
721 ed->table_parts[id2] = rp1;
722
723 // Fix all the dependecies in all parts...
724 for (i = 0; i < ed->collection->parts_count; ++i)
725 {
726 unsigned int j;
727 Edje_Part *p;
728
729 p = ed->collection->parts[i];
730
731 //printf(" search id: %d in %s\n", old_id, p->name);
732 if (p->clip_to_id == id1) p->clip_to_id = id2;
733 else if (p->clip_to_id == id2) p->clip_to_id = id1;
734 if (p->dragable.confine_id == id1) p->dragable.confine_id = id2;
735 else if (p->dragable.confine_id == id2) p->dragable.confine_id = id1;
736
737 // ...in default description
738 _edje_part_description_id_switch(p->type, p->default_desc, id1, id2);
739
740 // ...and in all other descriptions
741 for (j = 0; j < p->other.desc_count; ++j)
742 _edje_part_description_id_switch(p->type, p->other.desc[j], id1, id2);
743 }
744
745 //...and also in programs targets
746#define EDJE_EDIT_PROGRAM_SWITCH(Array, Ed, It, Id1, Id2) \
747 for (It = 0; It < Ed->collection->programs.Array##_count; ++It) \
748 _edje_part_program_id_switch(Ed->collection->programs.Array[i], Id1, Id2);
749
750 EDJE_EDIT_PROGRAM_SWITCH(fnmatch, ed, i, id1, id2);
751 EDJE_EDIT_PROGRAM_SWITCH(strcmp, ed, i, id1, id2);
752 EDJE_EDIT_PROGRAM_SWITCH(strncmp, ed, i, id1, id2);
753 EDJE_EDIT_PROGRAM_SWITCH(strrncmp, ed, i, id1, id2);
754 EDJE_EDIT_PROGRAM_SWITCH(nocmp, ed, i, id1, id2);
755 //TODO Real part dependencies are ok?
756}
757
758static void
759_edje_fix_parts_id(Edje *ed)
760{
761 /* We use this to clear the id hole leaved when a part is removed.
762 * After the execution of this function all parts will have a right
763 * (uniqe & ordered) id. The table_parts is also updated.
764 */
765 unsigned int i;
766 int correct_id;
767 unsigned int count;
768
769 //printf("FIXING PARTS ID \n");
770
771 //TODO order the list first to be more robust
772
773 /* Give a correct id to all the parts */
774 correct_id = 0;
775 for (i = 0; i < ed->collection->parts_count; ++i)
776 {
777 Edje_Part *p;
778
779 p = ed->collection->parts[i];
780
781 //printf(" [%d]Checking part: %s id: %d\n", correct_id, p->name, p->id);
782 if (p->id != correct_id)
783 if (ed->table_parts[p->id])
784 _edje_part_id_set(ed, ed->table_parts[p->id], correct_id);
785
786 correct_id++;
787 }
788
789 /* If we have removed some parts realloc table_parts */
790 count = ed->collection->parts_count;
791 if (count != ed->table_parts_size)
792 {
793 ed->table_parts = realloc(ed->table_parts, sizeof(Edje_Real_Part *) * count);
794 ed->table_parts_size = count;
795 }
796
797 //printf("\n");
798}
799
800static void
801_edje_if_string_free(Edje *ed, const char *str)
802{
803 Eet_Dictionary *dict;
804
805 if (!ed || !str) return;
806
807 dict = eet_dictionary_get(ed->file->ef);
808 if (eet_dictionary_string_check(dict, str)) return;
809 eina_stringshare_del(str);
810 str = NULL;
811}
812
813static Edje_Style *
814_edje_edit_style_get(Edje *ed, const char *name)
815{
816 Eina_List *l;
817 Edje_Style *s;
818
819 if (!ed || !ed->file || !ed->file->styles || !name)
820 return NULL;
821
822 EINA_LIST_FOREACH(ed->file->styles, l, s)
823 if (s->name && !strcmp(s->name, name))
824 return s;
825
826 return NULL;
827}
828
829static Edje_Style_Tag *
830_edje_edit_style_tag_get(Edje *ed, const char *style, const char *name)
831{
832 Eina_List *l;
833 Edje_Style *s;
834 Edje_Style_Tag *t;
835
836 if (!ed || !ed->file || !ed->file->styles || !name)
837 return NULL;
838
839 s = _edje_edit_style_get(ed, style);
840
841 EINA_LIST_FOREACH(s->tags, l, t)
842 if (t->key && !strcmp(t->key, name))
843 return t;
844
845 return NULL;
846}
847
848static Edje_External_Directory_Entry *
849_edje_edit_external_get(Edje *ed, const char *name)
850{
851 unsigned int i;
852
853 if (!ed || !ed->file || !ed->file->external_dir || !name)
854 return NULL;
855
856 for (i = 0; i < ed->file->external_dir->entries_count; ++i)
857 if (ed->file->external_dir->entries[i].entry
858 && !strcmp(ed->file->external_dir->entries[i].entry, name))
859 return ed->file->external_dir->entries + i;
860
861 return NULL;
862}
863
864static void
865_edje_edit_group_references_update(Evas_Object *obj, const char *old_group_name, const char *new_group_name)
866{
867 Eina_Iterator *i;
868 Eina_List *pll, *pl;
869// Edje_Part_Collection *pc;
870 Edje_Part_Collection_Directory_Entry *pce;
871 char *part_name;
872 const char *source, *old;
873 Edje_Part_Type type;
874 Evas_Object *part_obj;
875
876 GET_ED_OR_RETURN();
877
878// pc = ed->collection;
879
880 part_obj = edje_edit_object_add(ed->base.evas);
881
882 old = eina_stringshare_add(old_group_name);
883
884 i = eina_hash_iterator_data_new(ed->file->collection);
885
886 EINA_ITERATOR_FOREACH(i, pce)
887 {
888 edje_object_file_set(part_obj, ed->file->path, pce->entry);
889
890 pl = edje_edit_parts_list_get(part_obj);
891
892 EINA_LIST_FOREACH(pl, pll, part_name)
893 {
894 source = edje_edit_part_source_get(part_obj, part_name);
895 type = edje_edit_part_type_get(part_obj, part_name);
896
897 if (type == EDJE_PART_TYPE_GROUP && source == old)
898 edje_edit_part_source_set(part_obj, part_name, new_group_name);
899
900 if (source)
901 eina_stringshare_del(source);
902 }
903 }
904
905 eina_iterator_free(i);
906
907 eina_stringshare_del(old);
908
909 evas_object_del(part_obj);
910}
911
912static void
913_edje_edit_flag_script_dirty(Edje_Edit *eed, Eina_Bool all)
914{
915 eed->script_need_recompile = EINA_TRUE;
916 if (all)
917 eed->all_dirty = EINA_TRUE;
918}
919
920/*****************/
921/* GENERAL API */
922/*****************/
923
924EAPI void
925edje_edit_string_list_free(Eina_List *lst)
926{
927 eina_error_set(0);
928 //printf("FREE LIST: \n");
929 while (lst)
930 {
931 if (eina_list_data_get(lst)) eina_stringshare_del(eina_list_data_get(lst));
932 //printf("FREE: %s\n", eina_list_data_get(lst));
933 lst = eina_list_remove(lst, eina_list_data_get(lst));
934 }
935}
936
937EAPI void
938edje_edit_string_free(const char *str)
939{
940 eina_error_set(0);
941
942 if (str) eina_stringshare_del(str);
943}
944
945EAPI const char*
946edje_edit_compiler_get(Evas_Object *obj)
947{
948 eina_error_set(0);
949
950 GET_ED_OR_RETURN(0);
951 return eina_stringshare_add(ed->file->compiler);
952}
953
954/****************/
955/* GROUPS API */
956/****************/
957
958EAPI Eina_Bool
959edje_edit_group_add(Evas_Object *obj, const char *name)
960{
961 Edje_Part_Collection_Directory_Entry *de;
962 Edje_Part_Collection_Directory_Entry *d;
963 Edje_Part_Collection *pc;
964 int id;
965 int search;
966 //Code *cd;
967
968 eina_error_set(0);
969
970 GET_ED_OR_RETURN(EINA_FALSE);
971
972 //printf("ADD GROUP: %s \n", name);
973
974 /* check if a group with the same name already exists */
975 if (eina_hash_find(ed->file->collection, name))
976 return EINA_FALSE;
977
978 /* Create structs */
979 de = _alloc(sizeof(Edje_Part_Collection_Directory_Entry));
980 if (!de) return EINA_FALSE;
981
982 pc = _alloc(sizeof(Edje_Part_Collection));
983 if (!pc)
984 {
985 free(de);
986 return EINA_FALSE;
987 }
988
989 /* Search first free id */
990 id = -1;
991 search = 0;
992 while (id == -1)
993 {
994 Eina_Iterator *i;
995 Eina_Bool found = 0;
996
997 i = eina_hash_iterator_data_new(ed->file->collection);
998
999 EINA_ITERATOR_FOREACH(i, d)
1000 {
1001 // printf("search if %d is free [id %d]\n", search, d->id);
1002 if (search == d->id)
1003 {
1004 found = 1;
1005 break;
1006 }
1007 }
1008
1009 eina_iterator_free(i);
1010
1011 if (!found) id = search;
1012 else search++;
1013 }
1014
1015 /* Init Edje_Part_Collection_Directory_Entry */
1016 //printf(" new id: %d\n", id);
1017 de->id = id;
1018 de->entry = eina_stringshare_add(name);
1019 eina_hash_direct_add(ed->file->collection, de->entry, de);
1020
1021 /* Init Edje_Part_Collection */
1022 pc->id = id;
1023 pc->references = 0;
1024 memset(&pc->programs, 0, sizeof (pc->programs));
1025 pc->parts = NULL;
1026 pc->data = NULL;
1027 pc->script = NULL;
1028 pc->part = eina_stringshare_add(name);
1029
1030 //cd = _alloc(sizeof(Code));
1031 //codes = eina_list_append(codes, cd);
1032#define EDIT_EMN(Tp, Sz, Ce) \
1033 Ce->mp.Tp = eina_mempool_add("chained_mempool", #Tp, NULL, sizeof (Sz), 10);
1034
1035 EDIT_EMN(RECTANGLE, Edje_Part_Description_Common, de);
1036 EDIT_EMN(TEXT, Edje_Part_Description_Text, de);
1037 EDIT_EMN(IMAGE, Edje_Part_Description_Image, de);
1038 EDIT_EMN(SWALLOW, Edje_Part_Description_Common, de);
1039 EDIT_EMN(TEXTBLOCK, Edje_Part_Description_Text, de);
1040 EDIT_EMN(GROUP, Edje_Part_Description_Common, de);
1041 EDIT_EMN(BOX, Edje_Part_Description_Box, de);
1042 EDIT_EMN(TABLE, Edje_Part_Description_Table, de);
1043 EDIT_EMN(EXTERNAL, Edje_Part_Description_External, de);
1044 EDIT_EMN(part, Edje_Part, de);
1045
1046 ed->file->collection_cache = eina_list_prepend(ed->file->collection_cache, pc);
1047 _edje_cache_coll_clean(ed->file);
1048
1049 return EINA_TRUE;
1050}
1051
1052EAPI Eina_Bool
1053edje_edit_group_del(Evas_Object *obj, const char *group_name)
1054{
1055 Edje_Part_Collection_Directory_Entry *e;
1056 Edje_Part_Collection *die = NULL;
1057 Edje_Part_Collection *g;
1058 Eina_List *l;
1059 Eet_File *eetf;
1060 char buf[64], **keys;
1061 int count;
1062
1063 eina_error_set(0);
1064
1065 GET_ED_OR_RETURN(EINA_FALSE);
1066
1067 /* if (eina_hash_find(ed->file->collection_hash, group_name)) */
1068 /* return EINA_FALSE; */
1069
1070 if (strcmp(ed->group, group_name) == 0)
1071 {
1072 eina_error_set(EDJE_EDIT_ERROR_GROUP_CURRENTLY_USED);
1073 return EINA_FALSE;
1074 }
1075
1076 e = eina_hash_find(ed->file->collection, group_name);
1077 if (!e)
1078 {
1079 eina_error_set(EDJE_EDIT_ERROR_GROUP_DOES_NOT_EXIST);
1080 return EINA_FALSE;
1081 }
1082
1083 if (e->id == ed->collection->id)
1084 {
1085 eina_error_set(EDJE_EDIT_ERROR_GROUP_CURRENTLY_USED);
1086 return EINA_FALSE;
1087 }
1088
1089 if (e->ref)
1090 {
1091 eina_error_set(EDJE_EDIT_ERROR_GROUP_REFERENCED);
1092 return EINA_FALSE;
1093 }
1094
1095 _edje_edit_group_references_update(obj, group_name, NULL);
1096
1097 EINA_LIST_FOREACH(ed->file->collection_cache, l, g)
1098 if (g->id == e->id)
1099 {
1100 ed->file->collection_cache =
1101 eina_list_remove_list(ed->file->collection_cache, l);
1102 die = g;
1103 break;
1104 }
1105
1106 /* Remove collection/id from eet file */
1107 eetf = eet_open(ed->file->path, EET_FILE_MODE_READ_WRITE);
1108 if (!eetf)
1109 {
1110 ERR("Edje_Edit: Error. unable to open \"%s\" "
1111 "for writing output", ed->file->path);
1112 return EINA_FALSE;
1113 }
1114 snprintf(buf, sizeof(buf), "edje/collections/%d", e->id);
1115 eet_delete(eetf, buf);
1116 snprintf(buf, sizeof(buf), "edje/scripts/embryo/compiled/%d", e->id);
1117 eet_delete(eetf, buf);
1118 snprintf(buf, sizeof(buf), "edje/scripts/embryo/source/%d", e->id);
1119 eet_delete(eetf, buf);
1120 snprintf(buf, sizeof(buf), "edje/scripts/embryo/source/%d/*", e->id);
1121 keys = eet_list(eetf, buf, &count);
1122 if (keys)
1123 {
1124 do
1125 {
1126 count--;
1127 eet_delete(eetf, keys[count]);
1128 }
1129 while(count);
1130 free(keys);
1131 }
1132 eet_close(eetf);
1133
1134 /* Free Group */
1135 if (die) _edje_collection_free(ed->file, die, e);
1136 eina_hash_del(ed->file->collection, group_name, e);
1137
1138 /* we need to save everything to make sure the file won't have broken
1139 * references the next time is loaded */
1140 edje_edit_save_all(obj);
1141
1142 return EINA_TRUE;
1143}
1144
1145EAPI Eina_Bool
1146edje_edit_group_exist(Evas_Object *obj, const char *group)
1147{
1148 eina_error_set(0);
1149
1150 GET_ED_OR_RETURN(EINA_FALSE);
1151
1152 if (eina_hash_find(ed->file->collection, group))
1153 return EINA_TRUE;
1154 return EINA_FALSE;
1155}
1156
1157EAPI Eina_Bool
1158edje_edit_group_name_set(Evas_Object *obj, const char *new_name)
1159{
1160 Edje_Part_Collection_Directory_Entry *pce;
1161 Edje_Part_Collection *pc;
1162
1163 eina_error_set(0);
1164
1165 GET_ED_OR_RETURN(EINA_FALSE);
1166
1167 if (!new_name) return EINA_FALSE;
1168
1169 pc = ed->collection;
1170
1171 if (!strcmp(pc->part, new_name)) return EINA_TRUE;
1172
1173 if (edje_edit_group_exist(obj, new_name)) return EINA_FALSE;
1174
1175 _edje_edit_group_references_update(obj, pc->part, new_name);
1176
1177 //printf("Set name of current group: %s [id: %d][new name: %s]\n",
1178 // pc->part, pc->id, new_name);
1179
1180 //if (pc->part && ed->file->free_strings) eina_stringshare_del(pc->part); TODO FIXME
1181 pce = eina_hash_find(ed->file->collection, pc->part);
1182
1183 eina_hash_move(ed->file->collection, pce->entry, new_name);
1184
1185 pce->entry = eina_stringshare_add(new_name);
1186 pc->part = pce->entry;
1187 eina_stringshare_replace(&ed->group, new_name);
1188
1189 return EINA_TRUE;
1190}
1191
1192#define FUNC_GROUP_ACCESSOR(Class, Value) \
1193 EAPI int \
1194 edje_edit_group_##Class##_##Value##_get(Evas_Object *obj) \
1195 { \
1196 eina_error_set(0); \
1197 GET_ED_OR_RETURN(-1); \
1198 if (!ed->collection) return -1; \
1199 return ed->collection->prop.Class.Value; \
1200 } \
1201 EAPI void \
1202 edje_edit_group_##Class##_##Value##_set(Evas_Object *obj, int v) \
1203 { \
1204 eina_error_set(0); \
1205 GET_ED_OR_RETURN(); \
1206 ed->collection->prop.Class.Value = v; \
1207 }
1208
1209FUNC_GROUP_ACCESSOR(min, w);
1210FUNC_GROUP_ACCESSOR(min, h);
1211FUNC_GROUP_ACCESSOR(max, w);
1212FUNC_GROUP_ACCESSOR(max, h);
1213
1214/***************/
1215/* DATA API */
1216/***************/
1217
1218EAPI Eina_List *
1219edje_edit_group_data_list_get(Evas_Object * obj)
1220{
1221 Eina_Iterator *it;
1222 Eina_List *datas = NULL;
1223 const char *key;
1224
1225 eina_error_set(0);
1226
1227 GET_ED_OR_RETURN(NULL);
1228
1229 if (!ed->file || !ed->collection || !ed->collection->data)
1230 return NULL;
1231
1232 it = eina_hash_iterator_key_new(ed->collection->data);
1233 if (!it) return NULL;
1234
1235 EINA_ITERATOR_FOREACH(it, key)
1236 datas = eina_list_append(datas, eina_stringshare_add(key));
1237
1238 eina_iterator_free(it);
1239
1240 return datas;
1241}
1242
1243EAPI Eina_List *
1244edje_edit_data_list_get(Evas_Object * obj)
1245{
1246 Eina_Iterator *i;
1247 Eina_List *datas = NULL;
1248 const char *key;
1249
1250 eina_error_set(0);
1251
1252 GET_ED_OR_RETURN(NULL);
1253
1254 if (!ed->file || !ed->file->data)
1255 return NULL;
1256
1257 i = eina_hash_iterator_key_new(ed->file->data);
1258
1259 EINA_ITERATOR_FOREACH(i, key)
1260 datas = eina_list_append(datas, eina_stringshare_add(key));
1261
1262 eina_iterator_free(i);
1263
1264 return datas;
1265}
1266
1267EAPI Eina_Bool
1268edje_edit_group_data_add(Evas_Object *obj, const char *key, const char *value)
1269{
1270 Edje_String *es;
1271
1272 eina_error_set(0);
1273
1274 GET_ED_OR_RETURN(EINA_FALSE);
1275
1276 if (!key || !ed->file || !ed->collection)
1277 return EINA_FALSE;
1278
1279 if (!ed->collection->data)
1280 ed->collection->data = eina_hash_string_small_new(NULL);
1281
1282 if (eina_hash_find(ed->collection->data, key))
1283 return EINA_FALSE;
1284
1285 es = calloc(1, sizeof(Edje_String));
1286 if (!es)
1287 return EINA_FALSE;
1288 es->str = eina_stringshare_add(value);
1289
1290 if (!eina_hash_add(ed->collection->data, key, es))
1291 {
1292 eina_stringshare_del(es->str);
1293 free(es);
1294 return EINA_FALSE;
1295 }
1296 return EINA_TRUE;
1297}
1298
1299EAPI Eina_Bool
1300edje_edit_data_add(Evas_Object *obj, const char *itemname, const char *value)
1301{
1302 Edje_String *es;
1303
1304 eina_error_set(0);
1305
1306 GET_ED_OR_RETURN(EINA_FALSE);
1307
1308 if (!itemname || !ed->file)
1309 return EINA_FALSE;
1310
1311 if (eina_hash_find(ed->file->data, itemname))
1312 return EINA_FALSE;
1313
1314 es = calloc(1, sizeof(Edje_String));
1315 if (!es)
1316 return EINA_FALSE;
1317 es->str = eina_stringshare_add(value);
1318
1319 if (!eina_hash_add(ed->file->data, itemname, es))
1320 {
1321 eina_stringshare_del(es->str);
1322 free(es);
1323 return EINA_FALSE;
1324 }
1325 return EINA_TRUE;
1326}
1327
1328EAPI Eina_Bool
1329edje_edit_group_data_del(Evas_Object *obj, const char *key)
1330{
1331 Edje_String *value;
1332
1333 eina_error_set(0);
1334
1335 GET_ED_OR_RETURN(EINA_FALSE);
1336
1337 if (!key || !ed->file || !ed->collection)
1338 return EINA_FALSE;
1339
1340 value = eina_hash_find(ed->collection->data, key);
1341 if (!value) return EINA_FALSE;
1342
1343 eina_hash_del(ed->collection->data, key, value);
1344 _edje_if_string_free(ed, value->str);
1345 free(value);
1346
1347 return EINA_TRUE;
1348}
1349
1350EAPI Eina_Bool
1351edje_edit_data_del(Evas_Object *obj, const char *itemname)
1352{
1353 Edje_String *value;
1354
1355 eina_error_set(0);
1356
1357 GET_ED_OR_RETURN(EINA_FALSE);
1358
1359 if (!itemname || !ed->file || !ed->file->data)
1360 return 0;
1361
1362 value = eina_hash_find(ed->file->data, itemname);
1363 if (!value)
1364 return EINA_FALSE;
1365
1366 eina_hash_del(ed->file->data, itemname, value);
1367 _edje_if_string_free(ed, value->str);
1368 free(value);
1369
1370 return EINA_TRUE;
1371}
1372
1373EAPI const char *
1374edje_edit_group_data_value_get(Evas_Object * obj, const char *key)
1375{
1376 Edje_String *value;
1377
1378 eina_error_set(0);
1379
1380 GET_ED_OR_RETURN(NULL);
1381
1382 if (!key || !ed->file || !ed->collection)
1383 return NULL;
1384
1385 value = eina_hash_find(ed->collection->data, key);
1386 if (!value)
1387 return NULL;
1388
1389 return eina_stringshare_add(edje_string_get(value));
1390}
1391
1392EAPI const char *
1393edje_edit_data_value_get(Evas_Object * obj, const char *itemname)
1394{
1395 Edje_String *value;
1396
1397 eina_error_set(0);
1398
1399 GET_ED_OR_RETURN(NULL);
1400
1401 if (!itemname || !ed->file || !ed->file->data)
1402 return NULL;
1403
1404 value = eina_hash_find(ed->file->data, itemname);
1405 if (!value)
1406 return NULL;
1407
1408 return eina_stringshare_add(edje_string_get(value));
1409}
1410
1411EAPI Eina_Bool
1412edje_edit_group_data_value_set(Evas_Object *obj, const char *key, const char *value)
1413{
1414 Edje_String *es;
1415
1416 eina_error_set(0);
1417
1418 GET_ED_OR_RETURN(EINA_FALSE);
1419
1420 if (!key || !value || !ed->file || !ed->collection)
1421 return EINA_FALSE;
1422
1423 es = eina_hash_find(ed->collection->data, key);
1424 if (es)
1425 {
1426 _edje_if_string_free(ed, es->str);
1427 es->str = eina_stringshare_add(value);
1428 es->id = 0;
1429 return EINA_TRUE;
1430 }
1431
1432 return EINA_FALSE;
1433}
1434
1435EAPI Eina_Bool
1436edje_edit_data_value_set(Evas_Object *obj, const char *itemname, const char *value)
1437{
1438 Edje_String *es;
1439
1440 eina_error_set(0);
1441
1442 GET_ED_OR_RETURN(EINA_FALSE);
1443
1444 if (!itemname || !value || !ed->file || !ed->file->data)
1445 return EINA_FALSE;
1446
1447 es = eina_hash_find(ed->file->data, itemname);
1448 if (es)
1449 {
1450 _edje_if_string_free(ed, es->str);
1451 es->str = eina_stringshare_add(value);
1452 es->id = 0;
1453 return EINA_TRUE;
1454 }
1455 return EINA_FALSE;
1456}
1457
1458EAPI Eina_Bool
1459edje_edit_group_data_name_set(Evas_Object *obj, const char *key, const char *new_key)
1460{
1461
1462 eina_error_set(0);
1463
1464 GET_ED_OR_RETURN(EINA_FALSE);
1465
1466 if (!key || !new_key || !ed->file || !ed->collection) {
1467 return EINA_FALSE;
1468 }
1469
1470 return eina_hash_move(ed->collection->data, key, new_key);
1471}
1472
1473EAPI Eina_Bool
1474edje_edit_data_name_set(Evas_Object *obj, const char *itemname, const char *newname)
1475{
1476
1477 eina_error_set(0);
1478
1479 GET_ED_OR_RETURN(EINA_FALSE);
1480
1481 if (!itemname || !newname || !ed->file || !ed->file->data)
1482 return EINA_FALSE;
1483
1484 return eina_hash_move(ed->file->data, itemname, newname);
1485}
1486
1487/***********************/
1488/* COLOR CLASSES API */
1489/***********************/
1490
1491EAPI Eina_List *
1492edje_edit_color_classes_list_get(Evas_Object * obj)
1493{
1494 Eina_List *classes = NULL;
1495 Eina_List *l;
1496 Edje_Color_Class *cc;
1497
1498 eina_error_set(0);
1499
1500 GET_ED_OR_RETURN(NULL);
1501
1502 if (!ed->file || !ed->file->color_classes)
1503 return NULL;
1504 //printf("GET CLASSES LIST %d %d\n", eina_list_count(ed->color_classes), eina_list_count(ed->file->color_classes));
1505 EINA_LIST_FOREACH(ed->file->color_classes, l, cc)
1506 classes = eina_list_append(classes, eina_stringshare_add(cc->name));
1507
1508 return classes;
1509}
1510
1511EAPI Eina_Bool
1512edje_edit_color_class_colors_get(Evas_Object *obj, const char *class_name, int *r, int *g, int *b, int *a, int *r2, int *g2, int *b2, int *a2, int *r3, int *g3, int *b3, int *a3)
1513{
1514 Eina_List *l;
1515 Edje_Color_Class *cc;
1516
1517 eina_error_set(0);
1518
1519 GET_ED_OR_RETURN(EINA_FALSE);
1520
1521 if (!ed->file || !ed->file->color_classes)
1522 return EINA_FALSE;
1523
1524 EINA_LIST_FOREACH(ed->file->color_classes, l, cc)
1525 if (!strcmp(cc->name, class_name))
1526 {
1527 if (r) *r = cc->r;
1528 if (g) *g = cc->g;
1529 if (b) *b = cc->b;
1530 if (a) *a = cc->a;
1531
1532 if (r2) *r2 = cc->r2;
1533 if (g2) *g2 = cc->g2;
1534 if (b2) *b2 = cc->b2;
1535 if (a2) *a2 = cc->a2;
1536
1537 if (r3) *r3 = cc->r3;
1538 if (g3) *g3 = cc->g3;
1539 if (b3) *b3 = cc->b3;
1540 if (a3) *a3 = cc->a3;
1541
1542 return EINA_TRUE;
1543 }
1544 return EINA_FALSE;
1545}
1546
1547EAPI Eina_Bool
1548edje_edit_color_class_colors_set(Evas_Object *obj, const char *class_name, int r, int g, int b, int a, int r2, int g2, int b2, int a2, int r3, int g3, int b3, int a3)
1549{
1550 Eina_List *l;
1551 Edje_Color_Class *cc;
1552
1553 eina_error_set(0);
1554
1555 GET_ED_OR_RETURN(EINA_FALSE);
1556
1557 if (!ed->file || !ed->file->color_classes)
1558 return EINA_FALSE;
1559
1560 EINA_LIST_FOREACH(ed->file->color_classes, l, cc)
1561 if (!strcmp(cc->name, class_name))
1562 {
1563 if (r > -1) cc->r = r;
1564 if (g > -1) cc->g = g;
1565 if (b > -1) cc->b = b;
1566 if (a > -1) cc->a = a;
1567
1568 if (r2 > -1) cc->r2 = r2;
1569 if (g2 > -1) cc->g2 = g2;
1570 if (b2 > -1) cc->b2 = b2;
1571 if (a2 > -1) cc->a2 = a2;
1572
1573 if (r3 > -1) cc->r3 = r3;
1574 if (g3 > -1) cc->g3 = g3;
1575 if (b3 > -1) cc->b3 = b3;
1576 if (a3 > -1) cc->a3 = a3;
1577
1578 return EINA_TRUE;
1579 }
1580 return EINA_FALSE;
1581}
1582
1583EAPI Eina_Bool
1584edje_edit_color_class_add(Evas_Object *obj, const char *name)
1585{
1586 Eina_List *l;
1587 Edje_Color_Class *c;
1588 Edje_Color_Class *cc;
1589
1590 eina_error_set(0);
1591
1592 GET_ED_OR_RETURN(EINA_FALSE);
1593
1594 if (!name || !ed->file)
1595 return EINA_FALSE;
1596
1597 EINA_LIST_FOREACH(ed->file->color_classes, l, cc)
1598 if (strcmp(cc->name, name) == 0)
1599 return EINA_FALSE;
1600
1601 c = _alloc(sizeof(Edje_Color_Class));
1602 if (!c) return EINA_FALSE;
1603
1604 c->name = (char*)eina_stringshare_add(name);
1605 c->r = c->g = c->b = c->a = 255;
1606 c->r2 = c->g2 = c->b2 = c->a2 = 255;
1607 c->r3 = c->g3 = c->b3 = c->a3 = 255;
1608
1609 ed->file->color_classes = eina_list_append(ed->file->color_classes, c);
1610
1611 return EINA_TRUE;
1612}
1613
1614EAPI Eina_Bool
1615edje_edit_color_class_del(Evas_Object *obj, const char *name)
1616{
1617 Eina_List *l;
1618 Edje_Color_Class *cc;
1619
1620 eina_error_set(0);
1621
1622 GET_ED_OR_RETURN(EINA_FALSE);
1623
1624 if (!name || !ed->file || !ed->file->color_classes)
1625 return EINA_FALSE;
1626
1627 EINA_LIST_FOREACH(ed->file->color_classes, l, cc)
1628 if (strcmp(cc->name, name) == 0)
1629 {
1630 _edje_if_string_free(ed, cc->name);
1631 ed->file->color_classes = eina_list_remove(ed->file->color_classes, cc);
1632 free(cc);
1633 return EINA_TRUE;
1634 }
1635 return EINA_FALSE;
1636}
1637
1638EAPI Eina_Bool
1639edje_edit_color_class_name_set(Evas_Object *obj, const char *name, const char *newname)
1640{
1641 Eina_List *l;
1642 Edje_Color_Class *cc;
1643
1644 eina_error_set(0);
1645
1646 GET_ED_OR_RETURN(EINA_FALSE);
1647
1648 if (!ed->file || !ed->file->color_classes)
1649 return EINA_FALSE;
1650
1651 EINA_LIST_FOREACH(ed->file->color_classes, l, cc)
1652 if (!strcmp(cc->name, name))
1653 {
1654 _edje_if_string_free(ed, cc->name);
1655 cc->name = (char*)eina_stringshare_add(newname);
1656 return EINA_TRUE;
1657 }
1658
1659 return EINA_FALSE;
1660}
1661
1662
1663
1664/*********************/
1665/* TEXT STYLES API */
1666/*********************/
1667
1668EAPI Eina_List *
1669edje_edit_styles_list_get(Evas_Object * obj)
1670{
1671 Eina_List *styles = NULL;
1672 Eina_List *l;
1673 Edje_Style *s;
1674
1675 eina_error_set(0);
1676
1677 GET_ED_OR_RETURN(NULL);
1678
1679 if (!ed->file || !ed->file->styles)
1680 return NULL;
1681 //printf("GET STYLES LIST %d\n", eina_list_count(ed->file->styles));
1682 EINA_LIST_FOREACH(ed->file->styles, l, s)
1683 styles = eina_list_append(styles, eina_stringshare_add(s->name));
1684
1685 return styles;
1686}
1687
1688EAPI Eina_Bool
1689edje_edit_style_add(Evas_Object * obj, const char* style)
1690{
1691 Edje_Style *s;
1692
1693 eina_error_set(0);
1694
1695 GET_ED_OR_RETURN(EINA_FALSE);
1696 //printf("ADD STYLE '%s'\n", style);
1697
1698 s = _edje_edit_style_get(ed, style);
1699 if (s) return EINA_FALSE;
1700
1701 s = _alloc(sizeof(Edje_Style));
1702 if (!s) return EINA_FALSE;
1703 s->name = (char*)eina_stringshare_add(style);
1704 s->tags = NULL;
1705 s->style = NULL;
1706
1707 ed->file->styles = eina_list_append(ed->file->styles, s);
1708 return EINA_TRUE;
1709}
1710
1711EAPI void
1712edje_edit_style_del(Evas_Object * obj, const char* style)
1713{
1714 Edje_Style *s;
1715
1716 eina_error_set(0);
1717
1718 GET_ED_OR_RETURN();
1719 //printf("DEL STYLE '%s'\n", style);
1720
1721 s = _edje_edit_style_get(ed, style);
1722 if (!s) return;
1723
1724 ed->file->styles = eina_list_remove(ed->file->styles, s);
1725
1726 _edje_if_string_free(ed, s->name);
1727 //~ //s->style HOWTO FREE ???
1728 while (s->tags)
1729 {
1730 Edje_Style_Tag *t;
1731
1732 t = s->tags->data;
1733
1734 s->tags = eina_list_remove(s->tags, t);
1735 _edje_if_string_free(ed, t->key);
1736 _edje_if_string_free(ed, t->value);
1737 _edje_if_string_free(ed, t->font);
1738 _edje_if_string_free(ed, t->text_class);
1739 free(t);
1740 t = NULL;
1741 }
1742 free(s);
1743 s = NULL;
1744 s = NULL;
1745}
1746
1747
1748EAPI Eina_List *
1749edje_edit_style_tags_list_get(Evas_Object * obj, const char* style)
1750{
1751 Eina_List *tags = NULL;
1752 Eina_List *l;
1753 Edje_Style *s;
1754 Edje_Style_Tag *t;
1755
1756 eina_error_set(0);
1757
1758 GET_ED_OR_RETURN(NULL);
1759 if (!ed->file || !ed->file->styles || !style)
1760 return NULL;
1761
1762 s = _edje_edit_style_get(ed, style);
1763
1764 //printf("GET STYLE TAG LIST %d\n", eina_list_count(s->tags));
1765 EINA_LIST_FOREACH(s->tags, l, t)
1766 tags = eina_list_append(tags, eina_stringshare_add(t->key));
1767
1768 return tags;
1769}
1770
1771EAPI void
1772edje_edit_style_tag_name_set(Evas_Object * obj, const char* style, const char* tag, const char*new_name)
1773{
1774 Edje_Style_Tag *t;
1775
1776 eina_error_set(0);
1777
1778 GET_ED_OR_RETURN();
1779 //printf("SET TAG NAME for '%s' FOR STYLE '%s'\n", tag, style);
1780
1781 if (!ed->file || !ed->file->styles || !style || !tag)
1782 return;
1783
1784 t = _edje_edit_style_tag_get(ed, style, tag);
1785 if (!t) return;
1786 _edje_if_string_free(ed, t->key);
1787 t->key = eina_stringshare_add(new_name);
1788}
1789
1790EAPI const char*
1791edje_edit_style_tag_value_get(Evas_Object * obj, const char* style, const char* tag)
1792{
1793 Edje_Style_Tag *t;
1794
1795 eina_error_set(0);
1796
1797 GET_ED_OR_RETURN(NULL);
1798 //printf("GET TAG '%s' FOR STYLE '%s'\n", tag, style);
1799
1800 if (!ed->file || !ed->file->styles || !style || !tag)
1801 return NULL;
1802
1803 t = _edje_edit_style_tag_get(ed, style, tag);
1804 if (t && t->value)
1805 return eina_stringshare_add(t->value);
1806
1807 return NULL;
1808}
1809
1810EAPI void
1811edje_edit_style_tag_value_set(Evas_Object * obj, const char* style, const char* tag, const char*new_value)
1812{
1813 Edje_Style_Tag *t;
1814
1815 eina_error_set(0);
1816
1817 GET_ED_OR_RETURN();
1818 //printf("SET TAG VALUE for '%s' FOR STYLE '%s'\n", tag, style);
1819
1820 if (!ed->file || !ed->file->styles || !style || !tag)
1821 return;
1822
1823 t = _edje_edit_style_tag_get(ed, style, tag);
1824 if (!t) return;
1825 _edje_if_string_free(ed, t->value);
1826 t->value = eina_stringshare_add(new_value);
1827}
1828
1829EAPI Eina_Bool
1830edje_edit_style_tag_add(Evas_Object * obj, const char* style, const char* tag_name)
1831{
1832 Edje_Style *s;
1833 Edje_Style_Tag *t;
1834
1835 eina_error_set(0);
1836
1837 GET_ED_OR_RETURN(EINA_FALSE);
1838 //printf("ADD TAG '%s' IN STYLE '%s'\n", tag_name, style);
1839
1840 t = _edje_edit_style_tag_get(ed, style, tag_name);
1841 if (t) return EINA_FALSE;
1842 s = _edje_edit_style_get(ed, style);
1843 if (!s) return EINA_FALSE;
1844
1845 t = _alloc(sizeof(Edje_Style_Tag));
1846 if (!t) return EINA_FALSE;
1847 t->key = eina_stringshare_add(tag_name);
1848 t->value = NULL;
1849 t->font = NULL;
1850 t->text_class = NULL;
1851
1852 s->tags = eina_list_append(s->tags, t);
1853 return EINA_TRUE;
1854}
1855
1856EAPI void
1857edje_edit_style_tag_del(Evas_Object * obj, const char* style, const char* tag)
1858{
1859 Edje_Style *s;
1860 Edje_Style_Tag *t;
1861
1862 eina_error_set(0);
1863
1864 GET_ED_OR_RETURN();
1865 //printf("DEL TAG '%s' IN STYLE '%s'\n", tag, style);
1866
1867 s = _edje_edit_style_get(ed, style);
1868 t = _edje_edit_style_tag_get(ed, style, tag);
1869
1870 s->tags = eina_list_remove(s->tags, t);
1871 _edje_if_string_free(ed, t->key);
1872 _edje_if_string_free(ed, t->value);
1873 _edje_if_string_free(ed, t->font);
1874 _edje_if_string_free(ed, t->text_class);
1875 free(t);
1876 t = NULL;
1877}
1878
1879/*******************/
1880/* EXTERNALS API */
1881/*******************/
1882
1883EAPI Eina_List *
1884edje_edit_externals_list_get(Evas_Object *obj)
1885{
1886 Eina_List *externals = NULL;
1887 unsigned int i;
1888
1889 eina_error_set(0);
1890
1891 GET_ED_OR_RETURN(NULL);
1892
1893 if (!ed->file || !ed->file->external_dir)
1894 return NULL;
1895 //printf("GET STYLES LIST %d\n", eina_list_count(ed->file->styles));
1896 for (i = 0; i < ed->file->external_dir->entries_count; ++i)
1897 externals = eina_list_append(externals,
1898 eina_stringshare_add(ed->file->external_dir->entries[i].entry));
1899
1900 return externals;
1901}
1902
1903EAPI Eina_Bool
1904edje_edit_external_add(Evas_Object *obj, const char *external)
1905{
1906 Edje_External_Directory_Entry *e;
1907 unsigned int freeid;
1908 unsigned int i;
1909
1910 eina_error_set(0);
1911
1912 GET_ED_OR_RETURN(EINA_FALSE);
1913
1914 e = _edje_edit_external_get(ed, external);
1915 if (e) return EINA_FALSE;
1916
1917 if (!ed->file->external_dir)
1918 ed->file->external_dir = _alloc(sizeof(Edje_External_Directory));
1919
1920 for (i = 0; i < ed->file->external_dir->entries_count; ++i)
1921 if (!ed->file->external_dir->entries[i].entry)
1922 break ;
1923
1924 if (i == ed->file->external_dir->entries_count)
1925 {
1926 Edje_External_Directory_Entry *tmp;
1927 unsigned int max;
1928
1929 max = ed->file->external_dir->entries_count + 1;
1930 tmp = realloc(ed->file->external_dir->entries,
1931 sizeof (Edje_External_Directory_Entry) * max);
1932
1933 if (!tmp) return EINA_FALSE;
1934
1935 ed->file->external_dir->entries = tmp;
1936 freeid = ed->file->external_dir->entries_count;
1937 ed->file->external_dir->entries_count = max;
1938 }
1939 else
1940 freeid = i;
1941
1942 ed->file->external_dir->entries[freeid].entry = (char*)eina_stringshare_add(external);
1943
1944 return EINA_TRUE;
1945}
1946
1947EAPI Eina_Bool
1948edje_edit_external_del(Evas_Object *obj, const char *external)
1949{
1950 Edje_External_Directory_Entry *e;
1951
1952 eina_error_set(0);
1953
1954 GET_ED_OR_RETURN(EINA_FALSE);
1955
1956 e = _edje_edit_external_get(ed, external);
1957 if (!e) return EINA_FALSE;
1958
1959 _edje_if_string_free(ed, e->entry);
1960 e->entry = NULL;
1961
1962 return EINA_TRUE;
1963}
1964
1965/***************/
1966/* PARTS API */
1967/***************/
1968
1969EAPI Eina_List *
1970edje_edit_parts_list_get(Evas_Object *obj)
1971{
1972 Eina_List *parts = NULL;
1973 unsigned int i;
1974
1975 eina_error_set(0);
1976
1977 GET_ED_OR_RETURN(NULL);
1978
1979 //printf("EE: Found %d parts\n", ed->table_parts_size);
1980
1981 parts = NULL;
1982 for (i = 0; i < ed->table_parts_size; i++)
1983 {
1984 Edje_Real_Part *rp;
1985
1986 rp = ed->table_parts[i];
1987 parts = eina_list_append(parts, eina_stringshare_add(rp->part->name));
1988 }
1989
1990 return parts;
1991}
1992
1993EAPI Eina_Bool
1994edje_edit_part_name_set(Evas_Object *obj, const char* part, const char* new_name)
1995{
1996 eina_error_set(0);
1997
1998 GET_RP_OR_RETURN(EINA_FALSE);
1999
2000 if (!new_name) return EINA_FALSE;
2001 if (!strcmp(part, new_name)) return EINA_TRUE;
2002 if (_edje_real_part_get(ed, new_name)) return EINA_FALSE;
2003
2004 //printf("Set name of part: %s [new name: %s]\n", part, new_name);
2005
2006 _edje_if_string_free(ed, rp->part->name);
2007 rp->part->name = (char *)eina_stringshare_add(new_name);
2008
2009 _edje_edit_flag_script_dirty(eed, EINA_TRUE);
2010
2011 return EINA_TRUE;
2012}
2013
2014#define FUNC_PART_API_STRING(Value) \
2015 EAPI const char * \
2016 edje_edit_part_api_##Value##_get(Evas_Object *obj, const char *part) \
2017 { \
2018 eina_error_set(0); \
2019 GET_RP_OR_RETURN(NULL); \
2020 return eina_stringshare_add(rp->part->api.Value); \
2021 } \
2022 EAPI Eina_Bool \
2023 edje_edit_part_api_##Value##_set(Evas_Object *obj, const char *part, const char *s) \
2024 { \
2025 eina_error_set(0); \
2026 GET_RP_OR_RETURN(EINA_FALSE); \
2027 _edje_if_string_free(ed, rp->part->api.Value); \
2028 rp->part->api.Value = eina_stringshare_add(s); \
2029 return EINA_TRUE; \
2030 }
2031
2032FUNC_PART_API_STRING(name);
2033FUNC_PART_API_STRING(description);
2034
2035static Eina_Bool
2036_edje_edit_real_part_add(Evas_Object *obj, const char *name, Edje_Part_Type type, const char *source)
2037{
2038 Edje_Part_Collection_Directory_Entry *ce;
2039 Edje_Part_Collection *pc;
2040 Edje_Part **tmp;
2041 Edje_Part *ep;
2042 Edje_Real_Part *rp;
2043 int id;
2044
2045 GET_ED_OR_RETURN(EINA_FALSE);
2046
2047 //printf("ADD PART: %s [type: %d]\n", name, type);
2048
2049 /* Check if part already exists */
2050 if (_edje_real_part_get(ed, name))
2051 return EINA_FALSE;
2052
2053 ce = eina_hash_find(ed->file->collection, ed->group);
2054
2055 /* Alloc Edje_Part or return */
2056 ep = eina_mempool_malloc(ce->mp.part, sizeof(Edje_Part));
2057 if (!ep) return EINA_FALSE;
2058 memset(ep, 0, sizeof(Edje_Part));
2059
2060 /* Alloc Edje_Real_Part or return */
2061 rp = eina_mempool_malloc(_edje_real_part_mp, sizeof(Edje_Real_Part));
2062 if (!rp)
2063 {
2064 eina_mempool_free(ce->mp.part, ep);
2065 return EINA_FALSE;
2066 }
2067 memset(rp, 0, sizeof(Edje_Real_Part));
2068
2069 /* Init Edje_Part */
2070 pc = ed->collection;
2071
2072 tmp = realloc(pc->parts, (pc->parts_count + 1) * sizeof (Edje_Part *));
2073 if (!tmp)
2074 {
2075 eina_mempool_free(ce->mp.part, ep);
2076 eina_mempool_free(_edje_real_part_mp, rp);
2077 return EINA_FALSE;
2078 }
2079
2080 id = pc->parts_count++;
2081
2082 pc->parts = tmp;
2083 pc->parts[id] = ep;
2084
2085 ep->id = id;
2086 ep->type = type;
2087 ep->name = eina_stringshare_add(name);
2088 ep->mouse_events = 1;
2089 ep->repeat_events = 0;
2090 ep->ignore_flags = EVAS_EVENT_FLAG_NONE;
2091 ep->pointer_mode = EVAS_OBJECT_POINTER_MODE_AUTOGRAB;
2092 ep->precise_is_inside = 0;
2093 ep->use_alternate_font_metrics = 0;
2094 ep->clip_to_id = -1;
2095 ep->dragable.confine_id = -1;
2096 ep->dragable.event_id = -1;
2097 if (source)
2098 ep->source = eina_stringshare_add(source);
2099
2100 ep->default_desc = NULL;
2101 ep->other.desc = NULL;
2102 ep->other.desc_count = 0;
2103
2104 /* Init Edje_Real_Part */
2105 rp->edje = ed;
2106 _edje_ref(rp->edje);
2107 rp->part = ep;
2108
2109 if (ep->type == EDJE_PART_TYPE_RECTANGLE)
2110 rp->object = evas_object_rectangle_add(ed->base.evas);
2111 else if (ep->type == EDJE_PART_TYPE_IMAGE || ep->type == EDJE_PART_TYPE_PROXY)
2112 rp->object = evas_object_image_add(ed->base.evas);
2113 else if (ep->type == EDJE_PART_TYPE_TEXT)
2114 {
2115 _edje_text_part_on_add(ed, rp);
2116 rp->object = evas_object_text_add(ed->base.evas);
2117 evas_object_text_font_source_set(rp->object, ed->path);
2118 }
2119 else if (ep->type == EDJE_PART_TYPE_SWALLOW ||
2120 ep->type == EDJE_PART_TYPE_GROUP ||
2121 ep->type == EDJE_PART_TYPE_EXTERNAL)
2122 {
2123 rp->object = evas_object_rectangle_add(ed->base.evas);
2124 evas_object_color_set(rp->object, 0, 0, 0, 0);
2125 evas_object_pass_events_set(rp->object, 1);
2126 evas_object_pointer_mode_set(rp->object, EVAS_OBJECT_POINTER_MODE_NOGRAB);
2127 }
2128 else if (ep->type == EDJE_PART_TYPE_TEXTBLOCK)
2129 rp->object = evas_object_textblock_add(ed->base.evas);
2130 else
2131 ERR("wrong part type %i!", ep->type);
2132 if (rp->object)
2133 {
2134 evas_object_show(rp->object);
2135 evas_object_smart_member_add(rp->object, ed->obj);
2136 evas_object_layer_set(rp->object, evas_object_layer_get(ed->obj));
2137 if (ep->type != EDJE_PART_TYPE_SWALLOW && ep->type != EDJE_PART_TYPE_GROUP)
2138 {
2139 if (ep->mouse_events)
2140 {
2141 _edje_callbacks_add(rp->object, ed, rp);
2142 if (ep->repeat_events)
2143 evas_object_repeat_events_set(rp->object, 1);
2144
2145 if (ep->pointer_mode != EVAS_OBJECT_POINTER_MODE_AUTOGRAB)
2146 evas_object_pointer_mode_set(rp->object, ep->pointer_mode);
2147 }
2148 else
2149 {
2150 evas_object_pass_events_set(rp->object, 1);
2151 evas_object_pointer_mode_set(rp->object,
2152 EVAS_OBJECT_POINTER_MODE_NOGRAB);
2153 }
2154 if (ep->precise_is_inside)
2155 evas_object_precise_is_inside_set(rp->object, 1);
2156 }
2157 if (ep->type == EDJE_PART_TYPE_EXTERNAL)
2158 {
2159 Evas_Object *child;
2160 child = _edje_external_type_add(source, evas_object_evas_get(ed->obj), ed->obj, NULL, name);
2161 if (child)
2162 _edje_real_part_swallow(rp, child, EINA_TRUE);
2163 }
2164 evas_object_clip_set(rp->object, ed->base.clipper);
2165 evas_object_show(ed->base.clipper);
2166 }
2167
2168 /* Update table_parts */
2169 ed->table_parts_size++;
2170 ed->table_parts = realloc(ed->table_parts,
2171 sizeof(Edje_Real_Part *) * ed->table_parts_size);
2172
2173 ed->table_parts[ep->id % ed->table_parts_size] = rp;
2174
2175 /* Create default description */
2176 if (!edje_edit_state_add(obj, name, "default", 0.0))
2177 {
2178 _edje_if_string_free(ed, ep->name);
2179 if (source)
2180 _edje_if_string_free(ed, ep->source);
2181 eina_mempool_free(ce->mp.part, ep);
2182 eina_mempool_free(_edje_real_part_mp, rp);
2183 return EINA_FALSE;
2184 }
2185 edje_edit_part_selected_state_set(obj, name, "default", 0.0);
2186
2187 ce->count.part++;
2188
2189 return EINA_TRUE;
2190}
2191
2192EAPI Eina_Bool
2193edje_edit_part_add(Evas_Object *obj, const char *name, Edje_Part_Type type)
2194{
2195 eina_error_set(0);
2196
2197 if (type == EDJE_PART_TYPE_EXTERNAL)
2198 return EINA_FALSE;
2199 return _edje_edit_real_part_add(obj, name, type, NULL);
2200}
2201
2202EAPI Eina_Bool
2203edje_edit_part_external_add(Evas_Object *obj, const char *name, const char *source)
2204{
2205 eina_error_set(0);
2206
2207 if (!source)
2208 return EINA_FALSE;
2209 return _edje_edit_real_part_add(obj, name, EDJE_PART_TYPE_EXTERNAL, source);
2210}
2211
2212EAPI Eina_Bool
2213edje_edit_part_del(Evas_Object *obj, const char* part)
2214{
2215 Edje_Part_Collection_Directory_Entry *ce;
2216 Edje_Part_Collection *pc;
2217 Edje_Part *ep;
2218 unsigned int k;
2219 unsigned int id;
2220 unsigned int i;
2221
2222 eina_error_set(0);
2223
2224 GET_RP_OR_RETURN(EINA_FALSE);
2225
2226 //printf("REMOVE PART: %s\n", part);
2227
2228 ep = rp->part;
2229 id = ep->id;
2230
2231 /* Unlik Edje_Real_Parts that link to the removed one */
2232 for (i = 0; i < ed->table_parts_size; i++)
2233 {
2234 Edje_Real_Part *real;
2235
2236 if (i == id) continue; //don't check the deleted id
2237 real = ed->table_parts[i];
2238
2239 if (real->text.source == rp) real->text.source = NULL;
2240 if (real->text.text_source == rp) real->text.text_source = NULL;
2241
2242 if (real->param1.rel1_to_x == rp) real->param1.rel1_to_x = NULL;
2243 if (real->param1.rel1_to_y == rp) real->param1.rel1_to_y = NULL;
2244 if (real->param1.rel2_to_x == rp) real->param1.rel2_to_x = NULL;
2245 if (real->param1.rel2_to_y == rp) real->param1.rel2_to_y = NULL;
2246
2247 if (real->param2)
2248 {
2249 if (real->param2->rel1_to_x == rp) real->param2->rel1_to_x = NULL;
2250 if (real->param2->rel1_to_y == rp) real->param2->rel1_to_y = NULL;
2251 if (real->param2->rel2_to_x == rp) real->param2->rel2_to_x = NULL;
2252 if (real->param2->rel2_to_y == rp) real->param2->rel2_to_y = NULL;
2253 }
2254
2255 if (real->custom)
2256 {
2257 if (real->custom->rel1_to_x == rp) real->custom->rel1_to_x = NULL;
2258 if (real->custom->rel1_to_y == rp) real->custom->rel1_to_y = NULL;
2259 if (real->custom->rel2_to_x == rp) real->custom->rel2_to_x = NULL;
2260 if (real->custom->rel2_to_y == rp) real->custom->rel2_to_y = NULL;
2261 }
2262
2263 if (real->clip_to == rp)
2264 {
2265 evas_object_clip_set(real->object, ed->base.clipper);
2266 real->clip_to = NULL;
2267 }
2268 if (real->drag && real->drag->confine_to == rp)
2269 real->drag->confine_to = NULL;
2270 }
2271
2272 /* Unlink all the parts and descriptions that refer to id */
2273 _edje_part_id_set(ed, rp, -1);
2274
2275 /* Remove part from parts list */
2276 pc = ed->collection;
2277 pc->parts_count--;
2278 if (id < pc->parts_count) /* Forward parts */
2279 {
2280 int mcount = (pc->parts_count - id) * sizeof(Edje_Part *);
2281 memmove(&pc->parts[id], &pc->parts[id+1], mcount);
2282 }
2283 pc->parts[pc->parts_count] = NULL;
2284 _edje_fix_parts_id(ed);
2285
2286 /* Free Edje_Part and all descriptions */
2287 ce = eina_hash_find(ed->file->collection, ed->group);
2288
2289 _edje_if_string_free(ed, ep->name);
2290 if (ep->default_desc)
2291 {
2292 _edje_collection_free_part_description_free(ep->type, ep->default_desc, ce, 0);
2293 ep->default_desc = NULL;
2294 }
2295
2296 for (k = 0; k < ep->other.desc_count; ++k)
2297 _edje_collection_free_part_description_free(ep->type, ep->other.desc[k], ce, 0);
2298
2299 free(ep->other.desc);
2300 eina_mempool_free(ce->mp.part, ep);
2301
2302 /* Free Edje_Real_Part */
2303 _edje_real_part_free(rp);
2304
2305 /* if all parts are gone, hide the clipper */
2306 if (ed->table_parts_size == 0)
2307 evas_object_hide(ed->base.clipper);
2308
2309 edje_object_calc_force(obj);
2310
2311 ce->count.part--;
2312
2313 _edje_edit_flag_script_dirty(eed, EINA_TRUE);
2314
2315 return EINA_TRUE;
2316}
2317
2318EAPI Eina_Bool
2319edje_edit_part_exist(Evas_Object *obj, const char *part)
2320{
2321 eina_error_set(0);
2322
2323 GET_RP_OR_RETURN(EINA_FALSE);
2324 return EINA_TRUE;
2325}
2326
2327EAPI const char*
2328edje_edit_part_below_get(Evas_Object *obj, const char* part)
2329{
2330 Edje_Real_Part *prev;
2331
2332 eina_error_set(0);
2333
2334 GET_RP_OR_RETURN(0);
2335
2336 if (rp->part->id < 1) return NULL;
2337
2338 prev = ed->table_parts[(rp->part->id - 1) % ed->table_parts_size];
2339
2340 return eina_stringshare_add(prev->part->name);
2341}
2342
2343EAPI const char*
2344edje_edit_part_above_get(Evas_Object *obj, const char* part)
2345{
2346 Edje_Real_Part *next;
2347
2348 eina_error_set(0);
2349
2350 GET_RP_OR_RETURN(0);
2351
2352 if ((unsigned int) rp->part->id >= ed->table_parts_size - 1) return 0;
2353
2354 next = ed->table_parts[(rp->part->id + 1) % ed->table_parts_size];
2355
2356 return eina_stringshare_add(next->part->name);
2357}
2358
2359EAPI Eina_Bool
2360edje_edit_part_restack_below(Evas_Object *obj, const char* part)
2361{
2362 Edje_Part_Collection *group;
2363 Edje_Real_Part *prev;
2364 Edje_Part *swap;
2365
2366 eina_error_set(0);
2367
2368 GET_RP_OR_RETURN(EINA_FALSE);
2369
2370 //printf("RESTACK PART: %s BELOW\n", part);
2371
2372 if (rp->part->id < 1) return EINA_FALSE;
2373 group = ed->collection;
2374
2375 /* update parts list */
2376 prev = ed->table_parts[(rp->part->id - 1) % ed->table_parts_size];
2377
2378 swap = group->parts[rp->part->id];
2379 group->parts[rp->part->id] = group->parts[prev->part->id];
2380 group->parts[prev->part->id] = swap;
2381
2382 _edje_parts_id_switch(ed, rp, prev);
2383
2384 evas_object_stack_below(rp->object, prev->object);
2385 if (rp->swallowed_object)
2386 evas_object_stack_above(rp->swallowed_object, rp->object);
2387
2388 _edje_edit_flag_script_dirty(eed, EINA_TRUE);
2389
2390 return EINA_TRUE;
2391}
2392
2393EAPI Eina_Bool
2394edje_edit_part_restack_above(Evas_Object *obj, const char* part)
2395{
2396 Edje_Part_Collection *group;
2397 Edje_Real_Part *next;
2398 Edje_Part *swap;
2399
2400 eina_error_set(0);
2401
2402 GET_RP_OR_RETURN(EINA_FALSE);
2403
2404 //printf("RESTACK PART: %s ABOVE\n", part);
2405
2406 if ((unsigned int) rp->part->id >= ed->table_parts_size - 1) return EINA_FALSE;
2407
2408 group = ed->collection;
2409
2410 /* update parts list */
2411 next = ed->table_parts[(rp->part->id + 1) % ed->table_parts_size];
2412
2413 swap = group->parts[rp->part->id];
2414 group->parts[rp->part->id] = group->parts[next->part->id];
2415 group->parts[next->part->id] = swap;
2416
2417 /* update ids */
2418 _edje_parts_id_switch(ed, rp, next);
2419
2420 evas_object_stack_above(rp->object, next->object);
2421 if (rp->swallowed_object)
2422 evas_object_stack_above(rp->swallowed_object, rp->object);
2423
2424 _edje_edit_flag_script_dirty(eed, EINA_TRUE);
2425
2426 return EINA_TRUE;
2427}
2428
2429EAPI Edje_Part_Type
2430edje_edit_part_type_get(Evas_Object *obj, const char *part)
2431{
2432
2433 eina_error_set(0);
2434
2435 GET_RP_OR_RETURN(0);
2436
2437 return rp->part->type;
2438}
2439
2440EAPI const char *
2441edje_edit_part_selected_state_get(Evas_Object *obj, const char *part, double *value)
2442{
2443 eina_error_set(0);
2444
2445 GET_RP_OR_RETURN(NULL);
2446
2447 if (!rp->chosen_description)
2448 {
2449 if (value) *value = 0.0; // FIXME: Make sure edje_edit supports correctly the default having any value
2450 return eina_stringshare_add("default");
2451 }
2452
2453 if (value) *value = rp->chosen_description->state.value;
2454 return eina_stringshare_add(rp->chosen_description->state.name);
2455}
2456
2457EAPI Eina_Bool
2458edje_edit_part_selected_state_set(Evas_Object *obj, const char *part, const char *state, double value)
2459{
2460 Edje_Part_Description_Common *pd;
2461
2462 eina_error_set(0);
2463
2464 GET_RP_OR_RETURN(EINA_FALSE);
2465
2466 pd = _edje_part_description_find_byname(eed, part, state, value);
2467 if (!pd) return EINA_FALSE;
2468
2469 //printf("EDJE: Set state: %s %f\n", pd->state.name, pd->state.value);
2470 _edje_part_description_apply(ed, rp, pd->state.name, pd->state.value, NULL, 0.0);
2471
2472 edje_object_calc_force(obj);
2473 return EINA_TRUE;
2474}
2475
2476EAPI const char *
2477edje_edit_part_clip_to_get(Evas_Object *obj, const char *part)
2478{
2479 Edje_Real_Part *clip = NULL;
2480
2481 eina_error_set(0);
2482
2483 GET_RP_OR_RETURN(NULL);
2484
2485 //printf("Get clip_to for part: %s [to_id: %d]\n", part, rp->part->clip_to_id);
2486 if (rp->part->clip_to_id < 0) return NULL;
2487
2488 clip = ed->table_parts[rp->part->clip_to_id % ed->table_parts_size];
2489 if (!clip || !clip->part || !clip->part->name) return NULL;
2490
2491 return eina_stringshare_add(clip->part->name);
2492}
2493
2494EAPI Eina_Bool
2495edje_edit_part_clip_to_set(Evas_Object *obj, const char *part, const char *clip_to)
2496{
2497 Edje_Real_Part *clip;
2498 Evas_Object *o, *oo;
2499
2500 eina_error_set(0);
2501
2502 GET_RP_OR_RETURN(EINA_FALSE);
2503
2504 /* unset clipping */
2505 if (!clip_to)
2506 {
2507 //printf("UnSet clip_to for part: %s\n", part);
2508
2509 if (rp->clip_to && rp->clip_to->object)
2510 {
2511 evas_object_pointer_mode_set(rp->clip_to->object,
2512 EVAS_OBJECT_POINTER_MODE_AUTOGRAB);
2513 evas_object_clip_unset(rp->object);
2514 }
2515
2516 evas_object_clip_set(rp->object, ed->base.clipper);
2517 if (rp->swallowed_object)
2518 evas_object_clip_set(rp->swallowed_object, ed->base.clipper);
2519
2520 rp->part->clip_to_id = -1;
2521 rp->clip_to = NULL;
2522
2523 edje_object_calc_force(obj);
2524
2525 return EINA_TRUE;
2526 }
2527
2528 /* set clipping */
2529 //printf("Set clip_to for part: %s [to: %s]\n", part, clip_to);
2530 clip = _edje_real_part_get(ed, clip_to);
2531 if (!clip || !clip->part) return EINA_FALSE;
2532 o = clip->object;
2533 while ((oo = evas_object_clip_get(o)))
2534 {
2535 if (o == rp->object)
2536 return EINA_FALSE;
2537 o = oo;
2538 }
2539
2540 rp->part->clip_to_id = clip->part->id;
2541 rp->clip_to = clip;
2542
2543 evas_object_pass_events_set(rp->clip_to->object, 1);
2544 evas_object_pointer_mode_set(rp->clip_to->object, EVAS_OBJECT_POINTER_MODE_NOGRAB);
2545 evas_object_clip_set(rp->object, rp->clip_to->object);
2546 if (rp->swallowed_object)
2547 evas_object_clip_set(rp->swallowed_object, rp->clip_to->object);
2548
2549 edje_object_calc_force(obj);
2550
2551 return EINA_TRUE;
2552}
2553
2554EAPI Eina_Bool
2555edje_edit_part_mouse_events_get(Evas_Object *obj, const char *part)
2556{
2557 eina_error_set(0);
2558
2559 GET_RP_OR_RETURN(EINA_FALSE);
2560 //printf("Get mouse_events for part: %s [%d]\n", part, rp->part->mouse_events);
2561 return rp->part->mouse_events;
2562}
2563
2564EAPI void
2565edje_edit_part_mouse_events_set(Evas_Object *obj, const char *part, Eina_Bool mouse_events)
2566{
2567 eina_error_set(0);
2568
2569 GET_RP_OR_RETURN();
2570
2571 if (!rp->object) return;
2572
2573 //printf("Set mouse_events for part: %s [%d]\n", part, mouse_events);
2574
2575 rp->part->mouse_events = mouse_events ? 1 : 0;
2576
2577 if (mouse_events)
2578 {
2579 evas_object_pass_events_set(rp->object, 0);
2580 _edje_callbacks_add(rp->object, ed, rp);
2581 }
2582 else
2583 {
2584 evas_object_pass_events_set(rp->object, 1);
2585 _edje_callbacks_del(rp->object, ed);
2586 }
2587}
2588
2589EAPI Eina_Bool
2590edje_edit_part_repeat_events_get(Evas_Object *obj, const char *part)
2591{
2592 eina_error_set(0);
2593
2594 GET_RP_OR_RETURN(EINA_FALSE);
2595
2596 //printf("Get repeat_events for part: %s [%d]\n", part, rp->part->repeat_events);
2597 return rp->part->repeat_events;
2598}
2599
2600EAPI void
2601edje_edit_part_repeat_events_set(Evas_Object *obj, const char *part, Eina_Bool repeat_events)
2602{
2603 eina_error_set(0);
2604
2605 GET_RP_OR_RETURN();
2606
2607 if (!rp->object) return;
2608
2609 //printf("Set repeat_events for part: %s [%d]\n", part, repeat_events);
2610
2611 rp->part->repeat_events = repeat_events ? 1 : 0;
2612
2613 if (repeat_events)
2614 evas_object_repeat_events_set(rp->object, 1);
2615 else
2616 evas_object_repeat_events_set(rp->object, 0);
2617}
2618
2619EAPI Evas_Event_Flags
2620edje_edit_part_ignore_flags_get(Evas_Object *obj, const char *part)
2621{
2622 eina_error_set(0);
2623
2624 GET_RP_OR_RETURN(0);
2625
2626 return rp->part->ignore_flags;
2627}
2628
2629EAPI void
2630edje_edit_part_ignore_flags_set(Evas_Object *obj, const char *part, Evas_Event_Flags ignore_flags)
2631{
2632 eina_error_set(0);
2633
2634 GET_RP_OR_RETURN();
2635
2636 if (!rp->object) return;
2637 //printf("Set ignore_flags for part: %s [%#x]\n", part, ignore_flags);
2638
2639 rp->part->ignore_flags = ignore_flags;
2640}
2641
2642EAPI void
2643edje_edit_part_scale_set(Evas_Object *obj, const char *part, Eina_Bool scale)
2644{
2645 eina_error_set(0);
2646
2647 GET_RP_OR_RETURN();
2648
2649 rp->part->scale = scale;
2650 edje_object_calc_force(obj);
2651}
2652
2653EAPI Eina_Bool
2654edje_edit_part_scale_get(Evas_Object *obj, const char *part)
2655{
2656 eina_error_set(0);
2657
2658 GET_RP_OR_RETURN(EINA_FALSE);
2659
2660 return rp->part->scale;
2661}
2662
2663EAPI const char *
2664edje_edit_part_source_get(Evas_Object *obj, const char *part)
2665{
2666 //Edje_Real_Part *clip = NULL;
2667 eina_error_set(0);
2668
2669 GET_RP_OR_RETURN(NULL);
2670
2671 //printf("Get source for part: %s\n", part);
2672 if (!rp->part->source) return NULL;
2673
2674 return eina_stringshare_add(rp->part->source);
2675}
2676
2677EAPI Eina_Bool
2678edje_edit_part_source_set(Evas_Object *obj, const char *part, const char *source)
2679{
2680 eina_error_set(0);
2681
2682 GET_RP_OR_RETURN(EINA_FALSE);
2683
2684 Evas_Object *child_obj;
2685 //printf("Set source for part: %s [source: %s]\n", part, source);
2686
2687 if (rp->part->type == EDJE_PART_TYPE_EXTERNAL)
2688 return EINA_FALSE;
2689
2690 _edje_if_string_free(ed, rp->part->source);
2691
2692 if (rp->swallowed_object)
2693 {
2694 _edje_real_part_swallow_clear(rp);
2695 evas_object_del(rp->swallowed_object);
2696 rp->swallowed_object = NULL;
2697 }
2698 if (source)
2699 {
2700 rp->part->source = eina_stringshare_add(source);
2701 child_obj = edje_object_add(ed->base.evas);
2702 edje_object_file_set(child_obj, ed->file->path, source);
2703 _edje_real_part_swallow(rp, child_obj, EINA_TRUE);
2704 }
2705 else
2706 rp->part->source = NULL;
2707 return EINA_TRUE;
2708}
2709
2710EAPI int
2711edje_edit_part_drag_x_get(Evas_Object *obj, const char *part)
2712{
2713 eina_error_set(0);
2714
2715 GET_RP_OR_RETURN(0);
2716 //printf("Get dragX for part: %s\n", part);
2717 return rp->part->dragable.x;
2718}
2719
2720EAPI void
2721edje_edit_part_drag_x_set(Evas_Object *obj, const char *part, int drag)
2722{
2723 eina_error_set(0);
2724
2725 GET_RP_OR_RETURN();
2726 //printf("Set dragX for part: %s\n", part);
2727 rp->part->dragable.x = drag;
2728
2729 if (!drag && !rp->part->dragable.y)
2730 {
2731 free(rp->drag);
2732 rp->drag = NULL;
2733 return ;
2734 }
2735
2736 if (rp->drag) return;
2737
2738 rp->drag = _alloc(sizeof (Edje_Real_Part_Drag));
2739 if (!rp->drag) return;
2740
2741 rp->drag->step.x = rp->part->dragable.step_x;
2742 rp->drag->step.y = rp->part->dragable.step_y;
2743}
2744
2745EAPI int
2746edje_edit_part_drag_y_get(Evas_Object *obj, const char *part)
2747{
2748 eina_error_set(0);
2749
2750 GET_RP_OR_RETURN(0);
2751 //printf("Get dragY for part: %s\n", part);
2752 return rp->part->dragable.y;
2753}
2754
2755EAPI void
2756edje_edit_part_drag_y_set(Evas_Object *obj, const char *part, int drag)
2757{
2758 eina_error_set(0);
2759
2760 GET_RP_OR_RETURN();
2761 //printf("Set dragY for part: %s\n", part);
2762 rp->part->dragable.y = drag;
2763
2764 if (!drag && !rp->part->dragable.x)
2765 {
2766 free(rp->drag);
2767 rp->drag = NULL;
2768 return ;
2769 }
2770
2771 if (rp->drag) return;
2772
2773 rp->drag = _alloc(sizeof (Edje_Real_Part_Drag));
2774 if (!rp->drag) return;
2775
2776 rp->drag->step.x = rp->part->dragable.step_x;
2777 rp->drag->step.y = rp->part->dragable.step_y;
2778}
2779
2780#define FUNC_PART_DRAG_INT(Class, Value) \
2781 EAPI int \
2782 edje_edit_part_drag_##Class##_##Value##_get(Evas_Object *obj, const char *part) \
2783 { \
2784 eina_error_set(0); \
2785 GET_RP_OR_RETURN(0); \
2786 return rp->part->dragable.Class##_##Value; \
2787 } \
2788 EAPI void \
2789 edje_edit_part_drag_##Class##_##Value##_set(Evas_Object *obj, const char *part, int v) \
2790 { \
2791 eina_error_set(0); \
2792 GET_RP_OR_RETURN(); \
2793 rp->part->dragable.Class##_##Value = v; \
2794 }
2795
2796FUNC_PART_DRAG_INT(step, x);
2797FUNC_PART_DRAG_INT(step, y);
2798FUNC_PART_DRAG_INT(count, x);
2799FUNC_PART_DRAG_INT(count, y);
2800
2801#define FUNC_PART_DRAG_ID(Id) \
2802 EAPI const char* \
2803 edje_edit_part_drag_##Id##_get(Evas_Object *obj, const char *part) \
2804 { \
2805 Edje_Real_Part *p; \
2806 \
2807 eina_error_set(0); \
2808 \
2809 GET_RP_OR_RETURN(NULL); \
2810 \
2811 if (rp->part->dragable.Id##_id < 0) \
2812 return NULL; \
2813 \
2814 p = ed->table_parts[rp->part->dragable.Id##_id]; \
2815 return eina_stringshare_add(p->part->name); \
2816 } \
2817 EAPI void \
2818 edje_edit_part_drag_##Id##_set(Evas_Object *obj, const char *part, const char *e) \
2819 { \
2820 Edje_Real_Part *e_part; \
2821 \
2822 eina_error_set(0); \
2823 \
2824 GET_RP_OR_RETURN(); \
2825 if (!e) \
2826 { \
2827 rp->part->dragable.Id##_id = -1; \
2828 return ; \
2829 } \
2830 \
2831 e_part = _edje_real_part_get(ed, e); \
2832 rp->part->dragable.Id##_id = e_part->part->id; \
2833 }
2834
2835FUNC_PART_DRAG_ID(confine);
2836FUNC_PART_DRAG_ID(event);
2837
2838/*********************/
2839/* PART STATES API */
2840/*********************/
2841EAPI Eina_List *
2842edje_edit_part_states_list_get(Evas_Object *obj, const char *part)
2843{
2844 char state_name[PATH_MAX];
2845 Eina_List *states = NULL;
2846 unsigned int i;
2847
2848 eina_error_set(0);
2849
2850 GET_RP_OR_RETURN(NULL);
2851
2852 //Is there a better place to put this? maybe edje_edit_init() ?
2853#ifdef HAVE_LOCALE_H
2854 setlocale(LC_NUMERIC, "C");
2855#endif
2856
2857 states = NULL;
2858
2859 //append default state
2860 snprintf(state_name, PATH_MAX,
2861 "%s %.2f",
2862 rp->part->default_desc->state.name,
2863 rp->part->default_desc->state.value);
2864 states = eina_list_append(states, eina_stringshare_add(state_name));
2865 //printf("NEW STATE def: %s\n", state->state.name);
2866
2867 //append other states
2868 for (i = 0; i < rp->part->other.desc_count; ++i)
2869 {
2870 snprintf(state_name, sizeof(state_name),
2871 "%s %.2f",
2872 rp->part->other.desc[i]->state.name,
2873 rp->part->other.desc[i]->state.value);
2874 states = eina_list_append(states, eina_stringshare_add(state_name));
2875 //printf("NEW STATE: %s\n", state_name);
2876 }
2877 return states;
2878}
2879
2880EAPI Eina_Bool
2881edje_edit_state_name_set(Evas_Object *obj, const char *part, const char *state, double value, const char *new_name, double new_value)
2882{
2883 int part_id;
2884 int i;
2885
2886 eina_error_set(0);
2887
2888 GET_PD_OR_RETURN(EINA_FALSE);
2889 //printf("Set name of state: %s in part: %s [new name: %s]\n",
2890 // part, state, new_name);
2891
2892 if (!new_name) return EINA_FALSE;
2893
2894 /* update programs */
2895 /* update the 'state' field in all programs. update only if program has
2896 a single target */
2897 part_id = _edje_part_id_find(ed, part);
2898 for (i = 0; i < ed->table_programs_size; i++)
2899 {
2900 Edje_Program *epr = ed->table_programs[i];
2901
2902 if (eina_list_count(epr->targets) == 1)
2903 {
2904 Edje_Program_Target *t = eina_list_data_get(epr->targets);
2905
2906 if (t->id == part_id &&
2907 !strcmp(epr->state, pd->state.name) &&
2908 pd->state.value == epr->value)
2909 {
2910 _edje_if_string_free(ed, epr->state);
2911 epr->state = eina_stringshare_add(new_name);
2912 epr->value = value;
2913 }
2914 }
2915 }
2916
2917 /* set name */
2918 _edje_if_string_free(ed, pd->state.name);
2919 pd->state.name = (char *)eina_stringshare_add(new_name);
2920 /* set value */
2921 pd->state.value = new_value;
2922
2923 return EINA_TRUE;
2924}
2925
2926EAPI Eina_Bool
2927edje_edit_state_del(Evas_Object *obj, const char *part, const char *state, double value)
2928{
2929 Edje_Part_Collection_Directory_Entry *ce;
2930 Edje_Part_Description_Common *pd;
2931 unsigned int i;
2932
2933 eina_error_set(0);
2934
2935 GET_RP_OR_RETURN(EINA_FALSE);
2936
2937 if (!edje_edit_state_exist(obj, part, state, value))
2938 return EINA_FALSE;
2939
2940 pd = _edje_part_description_find_byname(eed, part, state, value);
2941 if (!pd) return EINA_FALSE;
2942
2943 /* Don't allow to delete default state, for now at least; */
2944 if (pd == rp->part->default_desc)
2945 return EINA_FALSE;
2946
2947 /* And if we are deleting the current state, go back to default first */
2948 if (pd == rp->chosen_description)
2949 _edje_part_description_apply(ed, rp, "default", 0.0, NULL, 0.0);
2950
2951 ce = eina_hash_find(ed->file->collection, ed->group);
2952
2953 for (i = 0; i < rp->part->other.desc_count; ++i)
2954 if (pd == rp->part->other.desc[i])
2955 {
2956 memmove(rp->part->other.desc + i,
2957 rp->part->other.desc + i + 1,
2958 sizeof (Edje_Part_Description_Common*) * (rp->part->other.desc_count - i - 1));
2959 rp->part->other.desc_count--;
2960 break;
2961 }
2962
2963 _edje_collection_free_part_description_free(rp->part->type, pd, ce, 0);
2964 return EINA_TRUE;
2965}
2966
2967static Edje_Part_Description_Common *
2968_edje_edit_state_alloc(int type, Edje *ed)
2969{
2970 Edje_Part_Collection_Directory_Entry *ce;
2971 Edje_Part_Description_Common *pd = NULL;
2972
2973 ce = eina_hash_find(ed->file->collection, ed->group);
2974
2975 switch (type)
2976 {
2977 case EDJE_PART_TYPE_RECTANGLE:
2978 pd = eina_mempool_malloc(ce->mp.RECTANGLE, sizeof (Edje_Part_Description_Common));
2979 ce->count.RECTANGLE++;
2980 break;
2981 case EDJE_PART_TYPE_SWALLOW:
2982 pd = eina_mempool_malloc(ce->mp.SWALLOW, sizeof (Edje_Part_Description_Common));
2983 ce->count.SWALLOW++;
2984 break;
2985 case EDJE_PART_TYPE_GROUP:
2986 pd = eina_mempool_malloc(ce->mp.GROUP, sizeof (Edje_Part_Description_Common));
2987 ce->count.GROUP++;
2988 break;
2989
2990#define EDIT_ALLOC_POOL(Short, Type, Name) \
2991 case EDJE_PART_TYPE_##Short: \
2992 { \
2993 Edje_Part_Description_##Type *Name; \
2994 \
2995 Name = eina_mempool_malloc(ce->mp.Short, \
2996 sizeof (Edje_Part_Description_##Type)); \
2997 memset(Name, 0, sizeof(Edje_Part_Description_##Type)); \
2998 pd = &Name->common; \
2999 ce->count.Short++; \
3000 break; \
3001 }
3002
3003 EDIT_ALLOC_POOL(IMAGE, Image, image);
3004 EDIT_ALLOC_POOL(TEXT, Text, text);
3005 EDIT_ALLOC_POOL(TEXTBLOCK, Text, text);
3006 EDIT_ALLOC_POOL(BOX, Box, box);
3007 EDIT_ALLOC_POOL(TABLE, Table, table);
3008 EDIT_ALLOC_POOL(EXTERNAL, External, external_params);
3009 }
3010
3011 return pd;
3012}
3013
3014EAPI Eina_Bool
3015edje_edit_state_add(Evas_Object *obj, const char *part, const char *name, double value)
3016{
3017 Edje_Part_Description_Common *pd;
3018
3019 GET_RP_OR_RETURN(EINA_FALSE);
3020
3021 if (edje_edit_state_exist(obj, part, name, value))
3022 return EINA_FALSE;
3023
3024 //printf("ADD STATE: %s TO PART: %s\n", name , part);
3025 pd = _edje_edit_state_alloc(rp->part->type, ed);
3026 if (!pd) return EINA_FALSE;
3027
3028 if (!rp->part->default_desc)
3029 {
3030 rp->part->default_desc = pd;
3031 }
3032 else
3033 {
3034 Edje_Part_Description_Common **tmp;
3035
3036 tmp = realloc(rp->part->other.desc,
3037 sizeof (Edje_Part_Description_Common *) * (rp->part->other.desc_count + 1));
3038 if (!tmp)
3039 {
3040 free(pd);
3041 return EINA_FALSE;
3042 }
3043 rp->part->other.desc = tmp;
3044 rp->part->other.desc[rp->part->other.desc_count++] = pd;
3045 }
3046
3047 memset(pd, 0, sizeof (*pd));
3048
3049 pd->state.name = eina_stringshare_add(name);
3050 pd->state.value = value;
3051 pd->visible = 1;
3052 pd->align.x = 0.5;
3053 pd->align.y = 0.5;
3054 pd->min.w = 0;
3055 pd->min.h = 0;
3056 pd->fixed.w = 0;
3057 pd->fixed.h = 0;
3058 pd->max.w = -1;
3059 pd->max.h = -1;
3060 pd->rel1.relative_x = 0.0;
3061 pd->rel1.relative_y = 0.0;
3062 pd->rel1.offset_x = 0;
3063 pd->rel1.offset_y = 0;
3064 pd->rel1.id_x = -1;
3065 pd->rel1.id_y = -1;
3066 pd->rel2.relative_x = 1.0;
3067 pd->rel2.relative_y = 1.0;
3068 pd->rel2.offset_x = -1;
3069 pd->rel2.offset_y = -1;
3070 pd->rel2.id_x = -1;
3071 pd->rel2.id_y = -1;
3072 pd->color_class = NULL;
3073 pd->color.r = 255;
3074 pd->color.g = 255;
3075 pd->color.b = 255;
3076 pd->color.a = 255;
3077 pd->color2.r = 0;
3078 pd->color2.g = 0;
3079 pd->color2.b = 0;
3080 pd->color2.a = 255;
3081 pd->map.id_persp = -1;
3082 pd->map.id_light = -1;
3083 pd->map.rot.id_center = -1;
3084 pd->map.rot.x = FROM_DOUBLE(0.0);
3085 pd->map.rot.y = FROM_DOUBLE(0.0);
3086 pd->map.rot.z = FROM_DOUBLE(0.0);
3087 pd->map.on = 0;
3088 pd->map.smooth = 1;
3089 pd->map.alpha = 1;
3090 pd->map.backcull = 0;
3091 pd->map.persp_on = 0;
3092 pd->persp.zplane = 0;
3093 pd->persp.focal = 1000;
3094
3095 if (rp->part->type == EDJE_PART_TYPE_TEXT
3096 || rp->part->type == EDJE_PART_TYPE_TEXTBLOCK)
3097 {
3098 Edje_Part_Description_Text *text;
3099
3100 text = (Edje_Part_Description_Text*) pd;
3101
3102 memset(&text->text, 0, sizeof (text->text));
3103
3104 text->text.color3.r = 0;
3105 text->text.color3.g = 0;
3106 text->text.color3.b = 0;
3107 text->text.color3.a = 128;
3108 text->text.align.x = 0.5;
3109 text->text.align.y = 0.5;
3110 text->text.id_source = -1;
3111 text->text.id_text_source = -1;
3112 }
3113 else if (rp->part->type == EDJE_PART_TYPE_IMAGE)
3114 {
3115 Edje_Part_Description_Image *img;
3116
3117 img = (Edje_Part_Description_Image*) pd;
3118
3119 memset(&img->image, 0, sizeof (img->image));
3120
3121 img->image.id = -1;
3122 img->image.fill.smooth = 1;
3123 img->image.fill.pos_rel_x = 0.0;
3124 img->image.fill.pos_abs_x = 0;
3125 img->image.fill.rel_x = 1.0;
3126 img->image.fill.abs_x = 0;
3127 img->image.fill.pos_rel_y = 0.0;
3128 img->image.fill.pos_abs_y = 0;
3129 img->image.fill.rel_y = 1.0;
3130 img->image.fill.abs_y = 0;
3131 img->image.fill.angle = 0;
3132 img->image.fill.spread = 0;
3133 img->image.fill.type = EDJE_FILL_TYPE_SCALE;
3134 }
3135 else if (rp->part->type == EDJE_PART_TYPE_PROXY)
3136 {
3137 Edje_Part_Description_Proxy *pro;
3138
3139 pro = (Edje_Part_Description_Proxy*) pd;
3140
3141 memset(&pro->proxy, 0, sizeof (pro->proxy));
3142
3143 pro->proxy.id = -1;
3144 pro->proxy.fill.smooth = 1;
3145 pro->proxy.fill.pos_rel_x = 0.0;
3146 pro->proxy.fill.pos_abs_x = 0;
3147 pro->proxy.fill.rel_x = 1.0;
3148 pro->proxy.fill.abs_x = 0;
3149 pro->proxy.fill.pos_rel_y = 0.0;
3150 pro->proxy.fill.pos_abs_y = 0;
3151 pro->proxy.fill.rel_y = 1.0;
3152 pro->proxy.fill.abs_y = 0;
3153 pro->proxy.fill.angle = 0;
3154 pro->proxy.fill.spread = 0;
3155 pro->proxy.fill.type = EDJE_FILL_TYPE_SCALE;
3156 }
3157 else if (rp->part->type == EDJE_PART_TYPE_EXTERNAL)
3158 {
3159 Edje_Part_Description_External *external;
3160 Edje_External_Param_Info *pi;
3161
3162 external = (Edje_Part_Description_External*) pd;
3163
3164 external->external_params = NULL;
3165
3166 if (rp->part->source)
3167 {
3168 pi = (Edje_External_Param_Info *)edje_external_param_info_get(rp->part->source);
3169 while (pi && pi->name)
3170 {
3171 Edje_External_Param *p;
3172 p = _alloc(sizeof(Edje_External_Param));
3173 /* error checking.. meh */
3174 p->name = eina_stringshare_add(pi->name);
3175 p->type = pi->type;
3176 switch(p->type)
3177 {
3178 case EDJE_EXTERNAL_PARAM_TYPE_INT:
3179 case EDJE_EXTERNAL_PARAM_TYPE_BOOL:
3180 if (pi->info.i.def != EDJE_EXTERNAL_INT_UNSET)
3181 p->i = pi->info.i.def;
3182 break;
3183 case EDJE_EXTERNAL_PARAM_TYPE_DOUBLE:
3184 if (pi->info.d.def != EDJE_EXTERNAL_DOUBLE_UNSET)
3185 p->d = pi->info.d.def;
3186 break;
3187 case EDJE_EXTERNAL_PARAM_TYPE_CHOICE:
3188 if (pi->info.c.def)
3189 p->s = eina_stringshare_add(pi->info.c.def);
3190 break;
3191 case EDJE_EXTERNAL_PARAM_TYPE_STRING:
3192 if (pi->info.s.def)
3193 p->s = eina_stringshare_add(pi->info.s.def);
3194 break;
3195 default:
3196 ERR("unknown external parameter type '%d'", p->type);
3197 }
3198 external->external_params = eina_list_append(external->external_params, p);
3199 pi++;
3200 }
3201 if (external->external_params)
3202 rp->param1.external_params = _edje_external_params_parse(rp->swallowed_object, external->external_params);
3203 }
3204 }
3205 else if (rp->part->type == EDJE_PART_TYPE_BOX)
3206 {
3207 Edje_Part_Description_Box *box;
3208
3209 box = (Edje_Part_Description_Box*) pd;
3210 memset(&box->box, 0, sizeof (box->box));
3211 }
3212 else if (rp->part->type == EDJE_PART_TYPE_TABLE)
3213 {
3214 Edje_Part_Description_Table *table;
3215
3216 table = (Edje_Part_Description_Table*) pd;
3217 memset(&table->table, 0, sizeof (table->table));
3218 }
3219
3220 return EINA_TRUE;
3221}
3222
3223EAPI Eina_Bool
3224edje_edit_state_exist(Evas_Object *obj, const char *part, const char *state, double value)
3225{
3226 eina_error_set(0);
3227
3228 GET_PD_OR_RETURN(EINA_FALSE);
3229 return EINA_TRUE;
3230}
3231
3232EAPI Eina_Bool
3233edje_edit_state_copy(Evas_Object *obj, const char *part, const char *from, double val_from, const char *to, double val_to)
3234{
3235 Edje_Part_Description_Common *pdfrom, *pdto;
3236 Edje_External_Param *p;
3237
3238 eina_error_set(0);
3239
3240 GET_RP_OR_RETURN(EINA_FALSE);
3241
3242 pdfrom = _edje_part_description_find_byname(eed, part, from, val_from);
3243 if (!pdfrom)
3244 return EINA_FALSE;
3245
3246 pdto = _edje_part_description_find_byname(eed, part, to, val_to);
3247 if (!pdto)
3248 {
3249 Edje_Part_Description_Common **tmp;
3250
3251 pdto = _edje_edit_state_alloc(rp->part->type, ed);
3252 if (!pdto) return EINA_FALSE;
3253 /* No need to check for default desc, at this point it must exist */
3254
3255 tmp = realloc(rp->part->other.desc,
3256 sizeof (Edje_Part_Description_Common *) * (rp->part->other.desc_count + 1));
3257 if (!tmp)
3258 {
3259 free(pdto);
3260 return EINA_FALSE;
3261 }
3262 rp->part->other.desc = tmp;
3263 rp->part->other.desc[rp->part->other.desc_count++] = pdto;
3264 }
3265
3266#define PD_STRING_COPY(To, From, _x) \
3267 _edje_if_string_free(ed, To->_x); \
3268 To->_x = (char *)eina_stringshare_add(From->_x);
3269
3270 /* Copy all value */
3271 *pdto = *pdfrom;
3272 /* Keeping the pdto state name and value */
3273 pdto->state.name = eina_stringshare_add(to);
3274 pdto->state.value = val_to;
3275 /* Update pointer. */
3276 PD_STRING_COPY(pdto, pdfrom, color_class);
3277
3278 switch (rp->part->type)
3279 {
3280 case EDJE_PART_TYPE_PROXY:
3281 {
3282 Edje_Part_Description_Proxy *pro_to = (Edje_Part_Description_Proxy*) pdto;
3283 Edje_Part_Description_Proxy *pro_from = (Edje_Part_Description_Proxy*) pdfrom;
3284
3285 pro_to->proxy = pro_from->proxy;
3286
3287 break;
3288 }
3289 case EDJE_PART_TYPE_IMAGE:
3290 {
3291 Edje_Part_Description_Image *img_to = (Edje_Part_Description_Image*) pdto;
3292 Edje_Part_Description_Image *img_from = (Edje_Part_Description_Image*) pdfrom;
3293 unsigned int i;
3294
3295 img_to->image = img_from->image;
3296
3297 /* Update pointers. */
3298 for (i = 0; i < img_to->image.tweens_count; ++i)
3299 free(img_to->image.tweens[i]);
3300 if (img_to->image.tweens_count > 0)
3301 free(img_to->image.tweens);
3302
3303 img_to->image.tweens_count = img_from->image.tweens_count;
3304 img_to->image.tweens = calloc(img_to->image.tweens_count,
3305 sizeof (Edje_Part_Image_Id*));
3306 if (!img_to->image.tweens)
3307 break;
3308
3309 for (i = 0; i < img_to->image.tweens_count; ++i)
3310 {
3311 Edje_Part_Image_Id *new_i;
3312 new_i = _alloc(sizeof(Edje_Part_Image_Id));
3313 if (!new_i) continue ;
3314
3315 *new_i = *img_from->image.tweens[i];
3316
3317 img_to->image.tweens[i] = new_i;
3318 }
3319 break;
3320 }
3321 case EDJE_PART_TYPE_TEXT:
3322 case EDJE_PART_TYPE_TEXTBLOCK:
3323 {
3324 Edje_Part_Description_Text *text_to = (Edje_Part_Description_Text*) pdto;
3325 Edje_Part_Description_Text *text_from = (Edje_Part_Description_Text*) pdfrom;
3326
3327 text_to->text = text_from->text;
3328
3329 /* Update pointers. */
3330 PD_STRING_COPY(text_to, text_from, text.text.str);
3331 PD_STRING_COPY(text_to, text_from, text.text_class);
3332 PD_STRING_COPY(text_to, text_from, text.style.str);
3333 PD_STRING_COPY(text_to, text_from, text.font.str);
3334 PD_STRING_COPY(text_to, text_from, text.repch.str);
3335 break;
3336 }
3337 case EDJE_PART_TYPE_BOX:
3338 {
3339 Edje_Part_Description_Box *box_to = (Edje_Part_Description_Box*) pdto;
3340 Edje_Part_Description_Box *box_from = (Edje_Part_Description_Box*) pdfrom;
3341
3342 box_to->box = box_from->box;
3343
3344 PD_STRING_COPY(box_to, box_from, box.layout);
3345 PD_STRING_COPY(box_to, box_from, box.alt_layout);
3346 break;
3347 }
3348 case EDJE_PART_TYPE_TABLE:
3349 {
3350 Edje_Part_Description_Table *table_to = (Edje_Part_Description_Table*) pdto;
3351 Edje_Part_Description_Table *table_from = (Edje_Part_Description_Table*) pdfrom;
3352
3353 table_to->table = table_from->table;
3354 break;
3355 }
3356 case EDJE_PART_TYPE_EXTERNAL:
3357 {
3358 Edje_Part_Description_External *ext_to = (Edje_Part_Description_External*) pdto;
3359 Edje_Part_Description_External *ext_from = (Edje_Part_Description_External*) pdfrom;
3360 Eina_List *l;
3361
3362 /* XXX: optimize this, most likely we don't need to remove and add */
3363 EINA_LIST_FREE(ext_to->external_params, p)
3364 {
3365 _edje_if_string_free(ed, p->name);
3366 if (p->s)
3367 _edje_if_string_free(ed, p->s);
3368 free(p);
3369 }
3370 EINA_LIST_FOREACH(ext_from->external_params, l, p)
3371 {
3372 Edje_External_Param *new_p;
3373 new_p = _alloc(sizeof(Edje_External_Param));
3374 new_p->name = eina_stringshare_add(p->name);
3375 new_p->type = p->type;
3376 switch (p->type)
3377 {
3378 case EDJE_EXTERNAL_PARAM_TYPE_INT:
3379 new_p->i = p->i;
3380 break;
3381 case EDJE_EXTERNAL_PARAM_TYPE_DOUBLE:
3382 new_p->d = p->d;
3383 break;
3384 case EDJE_EXTERNAL_PARAM_TYPE_CHOICE:
3385 case EDJE_EXTERNAL_PARAM_TYPE_STRING:
3386 new_p->s = eina_stringshare_add(p->s);
3387 break;
3388 default:
3389 break;
3390 }
3391 ext_to->external_params = eina_list_append(ext_to->external_params, new_p);
3392 }
3393 break;
3394 }
3395 }
3396
3397#undef PD_STRING_COPY
3398
3399 return EINA_TRUE;
3400}
3401
3402#define FUNC_STATE_RELATIVE_DOUBLE(Sub, Value) \
3403 EAPI double \
3404 edje_edit_state_##Sub##_relative_##Value##_get(Evas_Object *obj, const char *part, const char *state, double value) \
3405 { \
3406 eina_error_set(0); \
3407 GET_PD_OR_RETURN(0); \
3408 return TO_DOUBLE(pd->Sub.relative_##Value); \
3409 } \
3410 EAPI void \
3411 edje_edit_state_##Sub##_relative_##Value##_set(Evas_Object *obj, const char *part, const char *state, double value, double v) \
3412 { \
3413 eina_error_set(0); \
3414 GET_PD_OR_RETURN(); \
3415 pd->Sub.relative_##Value = FROM_DOUBLE(v); \
3416 edje_object_calc_force(obj); \
3417 }
3418
3419FUNC_STATE_RELATIVE_DOUBLE(rel1, x);
3420FUNC_STATE_RELATIVE_DOUBLE(rel1, y);
3421FUNC_STATE_RELATIVE_DOUBLE(rel2, x);
3422FUNC_STATE_RELATIVE_DOUBLE(rel2, y);
3423
3424#define FUNC_STATE_OFFSET_INT(Sub, Value) \
3425 EAPI int \
3426 edje_edit_state_##Sub##_offset_##Value##_get(Evas_Object *obj, const char *part, const char *state, double value) \
3427 { \
3428 eina_error_set(0); \
3429 GET_PD_OR_RETURN(0); \
3430 return pd->Sub.offset_##Value; \
3431 } \
3432 EAPI void \
3433 edje_edit_state_##Sub##_offset_##Value##_set(Evas_Object *obj, const char *part, const char *state, double value, double v) \
3434 { \
3435 eina_error_set(0); \
3436 GET_PD_OR_RETURN(); \
3437 pd->Sub.offset_##Value = TO_INT(FROM_DOUBLE(v)); \
3438 edje_object_calc_force(obj); \
3439 }
3440
3441FUNC_STATE_OFFSET_INT(rel1, x);
3442FUNC_STATE_OFFSET_INT(rel1, y);
3443FUNC_STATE_OFFSET_INT(rel2, x);
3444FUNC_STATE_OFFSET_INT(rel2, y);
3445
3446#define FUNC_STATE_REL(Sub, Value) \
3447 EAPI const char * \
3448 edje_edit_state_##Sub##_to_##Value##_get(Evas_Object *obj, const char *part, const char *state, double value) \
3449 { \
3450 Edje_Real_Part *rel; \
3451 \
3452 eina_error_set(0); \
3453 \
3454 GET_PD_OR_RETURN(NULL); \
3455 \
3456 if (pd->Sub.id_##Value == -1) return NULL; \
3457 \
3458 rel = ed->table_parts[pd->Sub.id_##Value % ed->table_parts_size]; \
3459 \
3460 if (rel->part->name) return eina_stringshare_add(rel->part->name); \
3461 return NULL; \
3462 } \
3463 EAPI void \
3464 edje_edit_state_##Sub##_to_##Value##_set(Evas_Object *obj, const char *part, const char *state, double value, const char *to) \
3465 { \
3466 Edje_Real_Part *relp; \
3467 \
3468 eina_error_set(0); \
3469 \
3470 GET_PD_OR_RETURN(); \
3471 \
3472 if (to) \
3473 { \
3474 relp = _edje_real_part_get(ed, to); \
3475 if (!relp) return; \
3476 pd->Sub.id_##Value = relp->part->id; \
3477 } \
3478 else \
3479 pd->Sub.id_##Value = -1; \
3480 \
3481 }
3482//note after this call edje_edit_part_selected_state_set() to update !! need to fix this
3483//_edje_part_description_apply(ed, rp, pd->state.name, pd->state.value, "state", 0.1); //Why segfault??
3484// edje_object_calc_force(obj);//don't work for redraw
3485
3486FUNC_STATE_REL(rel1, x);
3487FUNC_STATE_REL(rel1, y);
3488FUNC_STATE_REL(rel2, x);
3489FUNC_STATE_REL(rel2, y);
3490
3491//colors
3492#define FUNC_COLOR(Code) \
3493 EAPI void \
3494 edje_edit_state_##Code##_get(Evas_Object *obj, const char *part, const char *state, double value, int *r, int *g, int *b, int *a) \
3495 { \
3496 eina_error_set(0); \
3497 GET_PD_OR_RETURN(); \
3498 \
3499 if (r) *r = pd->Code.r; \
3500 if (g) *g = pd->Code.g; \
3501 if (b) *b = pd->Code.b; \
3502 if (a) *a = pd->Code.a; \
3503 } \
3504 EAPI void \
3505 edje_edit_state_##Code##_set(Evas_Object *obj, const char *part, const char *state, double value, int r, int g, int b, int a) \
3506 { \
3507 eina_error_set(0); \
3508 GET_PD_OR_RETURN(); \
3509 \
3510 if (r > -1 && r < 256) pd->Code.r = r; \
3511 if (g > -1 && g < 256) pd->Code.g = g; \
3512 if (b > -1 && b < 256) pd->Code.b = b; \
3513 if (a > -1 && a < 256) pd->Code.a = a; \
3514 \
3515 edje_object_calc_force(obj); \
3516 }
3517
3518FUNC_COLOR(color);
3519FUNC_COLOR(color2);
3520
3521EAPI void
3522edje_edit_state_color3_get(Evas_Object *obj, const char *part, const char *state, double value, int *r, int *g, int *b, int *a)
3523{
3524 Edje_Part_Description_Text *txt;
3525
3526 eina_error_set(0);
3527
3528 GET_PD_OR_RETURN();
3529
3530 if ((rp->part->type != EDJE_PART_TYPE_TEXT) &&
3531 (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK))
3532 {
3533 if (r) *r = 0;
3534 if (g) *g = 0;
3535 if (b) *b = 0;
3536 if (a) *a = 0;
3537 return;
3538 }
3539
3540 txt = (Edje_Part_Description_Text*) pd;
3541
3542 if (r) *r = txt->text.color3.r;
3543 if (g) *g = txt->text.color3.g;
3544 if (b) *b = txt->text.color3.b;
3545 if (a) *a = txt->text.color3.a;
3546}
3547
3548EAPI void
3549edje_edit_state_color3_set(Evas_Object *obj, const char *part, const char *state, double value, int r, int g, int b, int a)
3550{
3551 Edje_Part_Description_Text *txt;
3552
3553 eina_error_set(0);
3554
3555 GET_PD_OR_RETURN();
3556
3557 if ((rp->part->type != EDJE_PART_TYPE_TEXT) &&
3558 (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK))
3559 return;
3560
3561 txt = (Edje_Part_Description_Text*) pd;
3562
3563 if (r > -1 && r < 256) txt->text.color3.r = r;
3564 if (g > -1 && g < 256) txt->text.color3.g = g;
3565 if (b > -1 && b < 256) txt->text.color3.b = b;
3566 if (a > -1 && a < 256) txt->text.color3.a = a;
3567
3568 edje_object_calc_force(obj);
3569}
3570
3571#define FUNC_STATE_DOUBLE(Class, Value) \
3572 EAPI double \
3573 edje_edit_state_##Class##_##Value##_get(Evas_Object *obj, const char *part, const char *state, double value) \
3574 { \
3575 eina_error_set(0); \
3576 GET_PD_OR_RETURN(0); \
3577 return TO_DOUBLE(pd->Class.Value); \
3578 } \
3579 EAPI void \
3580 edje_edit_state_##Class##_##Value##_set(Evas_Object *obj, const char *part, const char *state, double value, double v) \
3581 { \
3582 eina_error_set(0); \
3583 GET_PD_OR_RETURN(); \
3584 pd->Class.Value = FROM_DOUBLE(v); \
3585 edje_object_calc_force(obj); \
3586 }
3587
3588#define FUNC_STATE_INT(Class, Value) \
3589 EAPI int \
3590 edje_edit_state_##Class##_##Value##_get(Evas_Object *obj, const char *part, const char *state, double value) \
3591 { \
3592 eina_error_set(0); \
3593 GET_PD_OR_RETURN(0); \
3594 return pd->Class.Value; \
3595 } \
3596 EAPI void \
3597 edje_edit_state_##Class##_##Value##_set(Evas_Object *obj, const char *part, const char *state, double value, int v) \
3598 { \
3599 eina_error_set(0); \
3600 GET_PD_OR_RETURN(); \
3601 pd->Class.Value = v; \
3602 edje_object_calc_force(obj); \
3603 }
3604
3605FUNC_STATE_DOUBLE(align, x);
3606FUNC_STATE_DOUBLE(align, y);
3607FUNC_STATE_INT(min, w);
3608FUNC_STATE_INT(min, h);
3609FUNC_STATE_INT(max, w);
3610FUNC_STATE_INT(max, h);
3611FUNC_STATE_DOUBLE(aspect, min);
3612FUNC_STATE_DOUBLE(aspect, max);
3613
3614#define FUNC_STATE_DOUBLE_FILL(Class, Type, Value) \
3615 EAPI double \
3616 edje_edit_state_fill_##Type##_relative_##Value##_get(Evas_Object *obj, const char *part, const char *state, double value) \
3617 { \
3618 eina_error_set(0); \
3619 \
3620 GET_PD_OR_RETURN(0); \
3621 \
3622 switch (rp->part->type) \
3623 { \
3624 case EDJE_PART_TYPE_IMAGE: \
3625 { \
3626 Edje_Part_Description_Image *img; \
3627 \
3628 img = (Edje_Part_Description_Image*) pd; \
3629 \
3630 return TO_DOUBLE(img->image.fill.Class##rel_##Value); \
3631 } \
3632 case EDJE_PART_TYPE_PROXY: \
3633 { \
3634 Edje_Part_Description_Proxy *pro; \
3635 \
3636 pro = (Edje_Part_Description_Proxy*) pd; \
3637 \
3638 return TO_DOUBLE(pro->proxy.fill.Class##rel_##Value); \
3639 } \
3640 } \
3641 \
3642 return 0; \
3643 } \
3644 EAPI void \
3645 edje_edit_state_fill_##Type##_relative_##Value##_set(Evas_Object *obj, const char *part, const char *state, double value, double v) \
3646 { \
3647 eina_error_set(0); \
3648 \
3649 GET_PD_OR_RETURN(); \
3650 \
3651 switch (rp->part->type) \
3652 { \
3653 case EDJE_PART_TYPE_IMAGE: \
3654 { \
3655 Edje_Part_Description_Image *img; \
3656 \
3657 img = (Edje_Part_Description_Image*) pd; \
3658 \
3659 img->image.fill.Class##rel_##Value = FROM_DOUBLE(v); \
3660 \
3661 break; \
3662 } \
3663 case EDJE_PART_TYPE_PROXY: \
3664 { \
3665 Edje_Part_Description_Proxy *pro; \
3666 \
3667 pro = (Edje_Part_Description_Proxy*) pd; \
3668 \
3669 pro->proxy.fill.Class##rel_##Value = FROM_DOUBLE(v); \
3670 \
3671 break; \
3672 } \
3673 default: \
3674 return; \
3675 } \
3676 \
3677 edje_object_calc_force(obj); \
3678 }
3679
3680#define FUNC_STATE_INT_FILL(Class, Type, Value) \
3681 EAPI int \
3682 edje_edit_state_fill_##Type##_offset_##Value##_get(Evas_Object *obj, const char *part, const char *state, double value) \
3683 { \
3684 eina_error_set(0); \
3685 \
3686 GET_PD_OR_RETURN(0); \
3687 \
3688 switch (rp->part->type) \
3689 { \
3690 case EDJE_PART_TYPE_IMAGE: \
3691 { \
3692 Edje_Part_Description_Image *img; \
3693 \
3694 img = (Edje_Part_Description_Image*) pd; \
3695 \
3696 return img->image.fill.Class##abs_##Value; \
3697 } \
3698 case EDJE_PART_TYPE_PROXY: \
3699 { \
3700 Edje_Part_Description_Proxy *pro; \
3701 \
3702 pro = (Edje_Part_Description_Proxy*) pd; \
3703 \
3704 return pro->proxy.fill.Class##abs_##Value; \
3705 } \
3706 } \
3707 return 0; \
3708 } \
3709 EAPI void \
3710 edje_edit_state_fill_##Type##_offset_##Value##_set(Evas_Object *obj, const char *part, const char *state, double value, double v) \
3711 { \
3712 eina_error_set(0); \
3713 \
3714 GET_PD_OR_RETURN(); \
3715 \
3716 switch (rp->part->type) \
3717 { \
3718 case EDJE_PART_TYPE_IMAGE: \
3719 { \
3720 Edje_Part_Description_Image *img; \
3721 \
3722 img = (Edje_Part_Description_Image*) pd; \
3723 \
3724 img->image.fill.Class##abs_##Value = FROM_DOUBLE(v); \
3725 return; \
3726 } \
3727 case EDJE_PART_TYPE_PROXY: \
3728 { \
3729 Edje_Part_Description_Proxy *pro; \
3730 \
3731 pro = (Edje_Part_Description_Proxy*) pd; \
3732 \
3733 pro->proxy.fill.Class##abs_##Value = FROM_DOUBLE(v); \
3734 return; \
3735 } \
3736 default: \
3737 return; \
3738 } \
3739 \
3740 edje_object_calc_force(obj); \
3741 }
3742
3743FUNC_STATE_DOUBLE_FILL(pos_, origin, x);
3744FUNC_STATE_DOUBLE_FILL(pos_, origin, y);
3745FUNC_STATE_INT_FILL(pos_, origin, x);
3746FUNC_STATE_INT_FILL(pos_, origin, y);
3747
3748FUNC_STATE_DOUBLE_FILL(, size, x);
3749FUNC_STATE_DOUBLE_FILL(, size, y);
3750FUNC_STATE_INT_FILL(, size, x);
3751FUNC_STATE_INT_FILL(, size, y);
3752
3753EAPI Eina_Bool
3754edje_edit_state_visible_get(Evas_Object *obj, const char *part, const char *state, double value)
3755{
3756 eina_error_set(0);
3757
3758 GET_PD_OR_RETURN(EINA_FALSE);
3759
3760 //printf("Get state visible flag of part: %s state: %s\n", part, state);
3761 return pd->visible;
3762}
3763
3764EAPI void
3765edje_edit_state_visible_set(Evas_Object *obj, const char *part, const char *state, double value, Eina_Bool visible)
3766{
3767 eina_error_set(0);
3768
3769 GET_PD_OR_RETURN();
3770 //printf("Set state visible flag of part: %s state: %s to: %d\n", part, state, visible);
3771 if (visible) pd->visible = 1;
3772 else pd->visible = 0;
3773 edje_object_calc_force(obj);
3774}
3775
3776EAPI unsigned char
3777edje_edit_state_aspect_pref_get(Evas_Object *obj, const char *part, const char *state, double value)
3778{
3779 eina_error_set(0);
3780
3781 GET_PD_OR_RETURN(0);
3782
3783 //printf("GET ASPECT_PREF of state '%s' [%d]\n", state, pd->aspect.prefer);
3784 return pd->aspect.prefer;
3785}
3786
3787EAPI void
3788edje_edit_state_aspect_pref_set(Evas_Object *obj, const char *part, const char *state, double value, unsigned char pref)
3789{
3790 eina_error_set(0);
3791
3792 GET_PD_OR_RETURN();
3793
3794 //printf("SET ASPECT_PREF of state '%s' [to: %d]\n", state, pref);
3795 pd->aspect.prefer = pref;
3796}
3797
3798EAPI const char*
3799edje_edit_state_color_class_get(Evas_Object *obj, const char *part, const char *state, double value)
3800{
3801 eina_error_set(0);
3802
3803 GET_PD_OR_RETURN(NULL);
3804 //printf("Get ColorClass of part: %s state: %s\n", part, state);
3805 return eina_stringshare_add(pd->color_class);
3806}
3807
3808EAPI void
3809edje_edit_state_color_class_set(Evas_Object *obj, const char *part, const char *state, double value, const char *color_class)
3810{
3811 eina_error_set(0);
3812
3813 GET_PD_OR_RETURN();
3814 //printf("Set ColorClass of part: %s state: %s [to: %s]\n", part, state, color_class);
3815 _edje_if_string_free(ed, pd->color_class);
3816 pd->color_class = (char*)eina_stringshare_add(color_class);
3817}
3818
3819EAPI const Eina_List *
3820edje_edit_state_external_params_list_get(Evas_Object *obj, const char *part, const char *state, double value)
3821{
3822 Edje_Part_Description_External *external;
3823
3824 eina_error_set(0);
3825
3826 GET_PD_OR_RETURN(NULL);
3827
3828 if (rp->part->type != EDJE_PART_TYPE_EXTERNAL)
3829 return NULL;
3830
3831 external = (Edje_Part_Description_External *) pd;
3832
3833 return external->external_params;
3834}
3835
3836EAPI Eina_Bool
3837edje_edit_state_external_param_get(Evas_Object *obj, const char *part, const char *state, double value, const char *param, Edje_External_Param_Type *type, void **val)
3838{
3839 Edje_Part_Description_External *external;
3840 Edje_External_Param *p;
3841 Eina_List *l;
3842
3843 eina_error_set(0);
3844
3845 GET_PD_OR_RETURN(EINA_FALSE);
3846
3847 if (rp->part->type != EDJE_PART_TYPE_EXTERNAL)
3848 return EINA_FALSE;
3849
3850 external = (Edje_Part_Description_External *) pd;
3851
3852 EINA_LIST_FOREACH(external->external_params, l, p)
3853 if (!strcmp(p->name, param))
3854 {
3855 if (type) *type = p->type;
3856 if (val)
3857 switch (p->type)
3858 {
3859 case EDJE_EXTERNAL_PARAM_TYPE_INT:
3860 case EDJE_EXTERNAL_PARAM_TYPE_BOOL:
3861 *val = &p->i;
3862 break;
3863 case EDJE_EXTERNAL_PARAM_TYPE_DOUBLE:
3864 *val = &p->d;
3865 break;
3866 case EDJE_EXTERNAL_PARAM_TYPE_CHOICE:
3867 case EDJE_EXTERNAL_PARAM_TYPE_STRING:
3868 *val = (void *)p->s;
3869 break;
3870 default:
3871 ERR("unknown external parameter type '%d'", p->type);
3872 }
3873 return EINA_TRUE;
3874 }
3875
3876 return EINA_FALSE;
3877}
3878
3879EAPI Eina_Bool
3880edje_edit_state_external_param_int_get(Evas_Object *obj, const char *part, const char *state, double value, const char *param, int *val)
3881{
3882 Edje_Part_Description_External *external;
3883 Edje_External_Param *p;
3884 Eina_List *l;
3885
3886 eina_error_set(0);
3887
3888 GET_PD_OR_RETURN(EINA_FALSE);
3889
3890 if (rp->part->type != EDJE_PART_TYPE_EXTERNAL)
3891 {
3892 if (val) *val = 0;
3893 return EINA_FALSE;
3894 }
3895
3896 external = (Edje_Part_Description_External *) pd;
3897
3898 EINA_LIST_FOREACH(external->external_params, l, p)
3899 if (!strcmp(p->name, param))
3900 {
3901 if (p->type != EDJE_EXTERNAL_PARAM_TYPE_INT)
3902 return EINA_FALSE;
3903 if (val)
3904 *val = p->i;
3905 return EINA_TRUE;
3906 }
3907
3908 return EINA_FALSE;
3909}
3910
3911EAPI Eina_Bool
3912edje_edit_state_external_param_bool_get(Evas_Object *obj, const char *part, const char *state, double value, const char *param, Eina_Bool *val)
3913{
3914 Edje_Part_Description_External *external;
3915 Edje_External_Param *p;
3916 Eina_List *l;
3917
3918 eina_error_set(0);
3919
3920 GET_PD_OR_RETURN(EINA_FALSE);
3921
3922 if (rp->part->type != EDJE_PART_TYPE_EXTERNAL)
3923 {
3924 if (val) *val = 0;
3925 return EINA_FALSE;
3926 }
3927
3928 external = (Edje_Part_Description_External *) pd;
3929
3930 EINA_LIST_FOREACH(external->external_params, l, p)
3931 if (!strcmp(p->name, param))
3932 {
3933 if (p->type != EDJE_EXTERNAL_PARAM_TYPE_BOOL)
3934 return EINA_FALSE;
3935 if (val)
3936 *val = p->i;
3937 return EINA_TRUE;
3938 }
3939
3940 return EINA_FALSE;
3941}
3942
3943EAPI Eina_Bool
3944edje_edit_state_external_param_double_get(Evas_Object *obj, const char *part, const char *state, double value, const char *param, double *val)
3945{
3946 Edje_Part_Description_External *external;
3947 Edje_External_Param *p;
3948 Eina_List *l;
3949
3950 eina_error_set(0);
3951
3952 GET_PD_OR_RETURN(EINA_FALSE);
3953
3954 if (rp->part->type != EDJE_PART_TYPE_EXTERNAL)
3955 {
3956 if (val) *val = 0;
3957 return EINA_FALSE;
3958 }
3959
3960 external = (Edje_Part_Description_External *) pd;
3961
3962 EINA_LIST_FOREACH(external->external_params, l, p)
3963 if (!strcmp(p->name, param))
3964 {
3965 if (p->type != EDJE_EXTERNAL_PARAM_TYPE_DOUBLE)
3966 return EINA_FALSE;
3967 if (val)
3968 *val = p->d;
3969 return EINA_TRUE;
3970 }
3971
3972 return EINA_FALSE;
3973}
3974
3975EAPI Eina_Bool
3976edje_edit_state_external_param_string_get(Evas_Object *obj, const char *part, const char *state, double value, const char *param, const char **val)
3977{
3978 Edje_Part_Description_External *external;
3979 Edje_External_Param *p;
3980 Eina_List *l;
3981
3982 eina_error_set(0);
3983
3984 GET_PD_OR_RETURN(EINA_FALSE);
3985
3986 if (rp->part->type != EDJE_PART_TYPE_EXTERNAL)
3987 {
3988 if (val) *val = NULL;
3989 return EINA_FALSE;
3990 }
3991
3992 external = (Edje_Part_Description_External *) pd;
3993
3994 EINA_LIST_FOREACH(external->external_params, l, p)
3995 if (!strcmp(p->name, param))
3996 {
3997 if (p->type != EDJE_EXTERNAL_PARAM_TYPE_STRING)
3998 return EINA_FALSE;
3999 if (val)
4000 *val = p->s;
4001 return EINA_TRUE;
4002 }
4003
4004 return EINA_FALSE;
4005}
4006
4007EAPI Eina_Bool
4008edje_edit_state_external_param_choice_get(Evas_Object *obj, const char *part, const char *state, double value, const char *param, const char **val)
4009{
4010 Edje_Part_Description_External *external;
4011 Edje_External_Param *p;
4012 Eina_List *l;
4013
4014 eina_error_set(0);
4015
4016 GET_PD_OR_RETURN(EINA_FALSE);
4017
4018 if (rp->part->type != EDJE_PART_TYPE_EXTERNAL)
4019 {
4020 if (val) *val = NULL;
4021 return EINA_FALSE;
4022 }
4023
4024 external = (Edje_Part_Description_External *) pd;
4025
4026 EINA_LIST_FOREACH(external->external_params, l, p)
4027 if (!strcmp(p->name, param))
4028 {
4029 if (p->type != EDJE_EXTERNAL_PARAM_TYPE_CHOICE)
4030 return EINA_FALSE;
4031 if (val)
4032 *val = p->s;
4033 return EINA_TRUE;
4034 }
4035
4036 return EINA_FALSE;
4037}
4038
4039EAPI Eina_Bool
4040edje_edit_state_external_param_set(Evas_Object *obj, const char *part, const char *state, double value, const char *param, Edje_External_Param_Type type, ...)
4041{
4042 va_list ap;
4043 Eina_List *l;
4044 Edje_Part_Description_External *external;
4045 Edje_External_Param *p = NULL, old_p = { 0, 0, 0, 0, 0 };
4046 int found = 0;
4047
4048 eina_error_set(0);
4049
4050 GET_PD_OR_RETURN(EINA_FALSE);
4051
4052 if (rp->part->type != EDJE_PART_TYPE_EXTERNAL)
4053 return EINA_FALSE;
4054
4055 external = (Edje_Part_Description_External *) pd;
4056
4057 va_start(ap, type);
4058
4059 EINA_LIST_FOREACH(external->external_params, l, p)
4060 if (!strcmp(p->name, param))
4061 {
4062 found = 1;
4063 old_p = *p;
4064 break;
4065 }
4066
4067 if (!found)
4068 {
4069 p = _alloc(sizeof(Edje_External_Param));
4070 if (!p)
4071 {
4072 va_end(ap);
4073 return EINA_FALSE;
4074 }
4075 p->name = eina_stringshare_add(param);
4076 }
4077
4078 p->type = type;
4079 p->i = 0;
4080 p->d = 0;
4081 _edje_if_string_free(ed, p->s);
4082 p->s = NULL;
4083
4084 switch (type)
4085 {
4086 case EDJE_EXTERNAL_PARAM_TYPE_INT:
4087 case EDJE_EXTERNAL_PARAM_TYPE_BOOL:
4088 p->i = (int)va_arg(ap, int);
4089 break;
4090 case EDJE_EXTERNAL_PARAM_TYPE_DOUBLE:
4091 p->d = (double)va_arg(ap, double);
4092 break;
4093 case EDJE_EXTERNAL_PARAM_TYPE_CHOICE:
4094 case EDJE_EXTERNAL_PARAM_TYPE_STRING:
4095 p->s = eina_stringshare_add((const char *)va_arg(ap, char *));
4096 break;
4097 default:
4098 ERR("unknown external parameter type '%d'", type);
4099 va_end(ap);
4100 if (!found) free(p);
4101 else *p = old_p;
4102 return EINA_FALSE;
4103 }
4104
4105 va_end(ap);
4106
4107 //FIXME:
4108 //For now, we're just setting the value if the state is the selected state.
4109 //This is a conceptual error and is incoherent with the rest of the API!
4110 {
4111 const char *sname;
4112 double svalue;
4113 sname = edje_edit_part_selected_state_get(obj, part, &svalue);
4114 if (!strcmp(state, sname) && svalue == value)
4115 if (!edje_object_part_external_param_set(obj, part, p))
4116 if ((type == EDJE_EXTERNAL_PARAM_TYPE_CHOICE) ||
4117 (type == EDJE_EXTERNAL_PARAM_TYPE_STRING))
4118 {
4119 _edje_if_string_free(ed, p->s);
4120 if (!found) free(p);
4121 else *p = old_p;
4122 eina_stringshare_del(sname);
4123 return EINA_FALSE;
4124 }
4125 eina_stringshare_del(sname);
4126 }
4127
4128 if (!found)
4129 external->external_params = eina_list_append(external->external_params, p);
4130
4131 _edje_external_parsed_params_free(rp->swallowed_object,
4132 rp->param1.external_params);
4133 rp->param1.external_params = \
4134 _edje_external_params_parse(rp->swallowed_object,
4135 external->external_params);
4136
4137
4138 return EINA_TRUE;
4139}
4140
4141EAPI Eina_Bool
4142edje_edit_state_external_param_int_set(Evas_Object *obj, const char *part, const char *state, double value, const char *param, int val)
4143{
4144 eina_error_set(0);
4145 return edje_edit_state_external_param_set(obj, part, state, value, param, EDJE_EXTERNAL_PARAM_TYPE_INT, val);
4146}
4147
4148EAPI Eina_Bool
4149edje_edit_state_external_param_bool_set(Evas_Object *obj, const char *part, const char *state, double value, const char *param, Eina_Bool val)
4150{
4151 eina_error_set(0);
4152 return edje_edit_state_external_param_set(obj, part, state, value, param, EDJE_EXTERNAL_PARAM_TYPE_BOOL, (int)val);
4153}
4154
4155EAPI Eina_Bool
4156edje_edit_state_external_param_double_set(Evas_Object *obj, const char *part, const char *state, double value, const char *param, double val)
4157{
4158 eina_error_set(0);
4159 return edje_edit_state_external_param_set(obj, part, state, value, param, EDJE_EXTERNAL_PARAM_TYPE_DOUBLE, val);
4160}
4161
4162EAPI Eina_Bool
4163edje_edit_state_external_param_string_set(Evas_Object *obj, const char *part, const char *state, double value, const char *param, const char *val)
4164{
4165 eina_error_set(0);
4166 return edje_edit_state_external_param_set(obj, part, state, value, param, EDJE_EXTERNAL_PARAM_TYPE_STRING, val);
4167}
4168
4169EAPI Eina_Bool
4170edje_edit_state_external_param_choice_set(Evas_Object *obj, const char *part, const char *state, double value, const char *param, const char *val)
4171{
4172 eina_error_set(0);
4173 return edje_edit_state_external_param_set(obj, part, state, value, param, EDJE_EXTERNAL_PARAM_TYPE_CHOICE, val);
4174}
4175
4176/**************/
4177/* TEXT API */
4178/**************/
4179
4180EAPI const char *
4181edje_edit_state_text_get(Evas_Object *obj, const char *part, const char *state, double value)
4182{
4183 Edje_Part_Description_Text *txt;
4184
4185 eina_error_set(0);
4186
4187 GET_PD_OR_RETURN(NULL);
4188
4189 if ((rp->part->type != EDJE_PART_TYPE_TEXT) &&
4190 (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK))
4191 return NULL;
4192
4193 txt = (Edje_Part_Description_Text *) pd;
4194 //printf("GET TEXT of state: %s\n", state);
4195
4196 return eina_stringshare_add(edje_string_get(&txt->text.text));
4197}
4198
4199EAPI void
4200edje_edit_state_text_set(Evas_Object *obj, const char *part, const char *state, double value, const char *text)
4201{
4202 Edje_Part_Description_Text *txt;
4203
4204 eina_error_set(0);
4205
4206 GET_PD_OR_RETURN();
4207
4208 //printf("SET TEXT of state: %s\n", state);
4209
4210 if (!text) return;
4211
4212 if ((rp->part->type != EDJE_PART_TYPE_TEXT) &&
4213 (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK))
4214 return;
4215
4216 txt = (Edje_Part_Description_Text *) pd;
4217
4218 _edje_if_string_free(ed, txt->text.text.str);
4219 txt->text.text.str = (char *)eina_stringshare_add(text);
4220 txt->text.text.id = 0;
4221
4222 edje_object_calc_force(obj);
4223}
4224
4225EAPI int
4226edje_edit_state_text_size_get(Evas_Object *obj, const char *part, const char *state, double value)
4227{
4228 Edje_Part_Description_Text *txt;
4229
4230 eina_error_set(0);
4231
4232 GET_PD_OR_RETURN(-1);
4233
4234 if ((rp->part->type != EDJE_PART_TYPE_TEXT) &&
4235 (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK))
4236 return -1;
4237
4238 txt = (Edje_Part_Description_Text *) pd;
4239 //printf("GET TEXT_SIZE of state: %s [%d]\n", state, pd->text.size);
4240 return txt->text.size;
4241}
4242
4243EAPI void
4244edje_edit_state_text_size_set(Evas_Object *obj, const char *part, const char *state, double value, int size)
4245{
4246 Edje_Part_Description_Text *txt;
4247
4248 eina_error_set(0);
4249
4250 GET_PD_OR_RETURN();
4251
4252 //printf("SET TEXT_SIZE of state: %s [%d]\n", state, size);
4253
4254 if (size < 0) return;
4255
4256 if ((rp->part->type != EDJE_PART_TYPE_TEXT) &&
4257 (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK))
4258 return;
4259
4260 txt = (Edje_Part_Description_Text *) pd;
4261
4262 txt->text.size = size;
4263
4264 edje_object_calc_force(obj);
4265}
4266
4267#define FUNC_TEXT_DOUBLE(Name, Value) \
4268 EAPI double \
4269 edje_edit_state_text_##Name##_get(Evas_Object *obj, const char *part, const char *state, double value) \
4270 { \
4271 Edje_Part_Description_Text *txt; \
4272 \
4273 eina_error_set(0); \
4274 \
4275 GET_PD_OR_RETURN(0); \
4276 \
4277 if ((rp->part->type != EDJE_PART_TYPE_TEXT) && \
4278 (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) \
4279 return 0; \
4280 \
4281 txt = (Edje_Part_Description_Text *) pd; \
4282 return TO_DOUBLE(txt->text.Value); \
4283 } \
4284 EAPI void \
4285 edje_edit_state_text_##Name##_set(Evas_Object *obj, const char *part, const char *state, double value, double v) \
4286 { \
4287 Edje_Part_Description_Text *txt; \
4288 \
4289 eina_error_set(0); \
4290 \
4291 GET_PD_OR_RETURN(); \
4292 \
4293 if ((rp->part->type != EDJE_PART_TYPE_TEXT) && \
4294 (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) \
4295 return; \
4296 \
4297 txt = (Edje_Part_Description_Text *) pd; \
4298 txt->text.Value = FROM_DOUBLE(v); \
4299 edje_object_calc_force(obj); \
4300 } \
4301
4302FUNC_TEXT_DOUBLE(align_x, align.x);
4303FUNC_TEXT_DOUBLE(align_y, align.y);
4304FUNC_TEXT_DOUBLE(elipsis, elipsis);
4305
4306#define FUNC_TEXT_BOOL_FIT(Value) \
4307 EAPI Eina_Bool \
4308 edje_edit_state_text_fit_##Value##_get(Evas_Object *obj, const char *part, const char *state, double value) \
4309 { \
4310 Edje_Part_Description_Text *txt; \
4311 \
4312 eina_error_set(0); \
4313 \
4314 GET_PD_OR_RETURN(EINA_FALSE); \
4315 \
4316 if ((rp->part->type != EDJE_PART_TYPE_TEXT) && \
4317 (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) \
4318 return EINA_FALSE; \
4319 \
4320 txt = (Edje_Part_Description_Text *) pd; \
4321 return txt->text.fit_##Value; \
4322 } \
4323 EAPI void \
4324 edje_edit_state_text_fit_##Value##_set(Evas_Object *obj, const char *part, const char *state, double value, Eina_Bool fit) \
4325 { \
4326 Edje_Part_Description_Text *txt; \
4327 \
4328 GET_PD_OR_RETURN(); \
4329 \
4330 if ((rp->part->type != EDJE_PART_TYPE_TEXT) && \
4331 (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) \
4332 return; \
4333 \
4334 txt = (Edje_Part_Description_Text *) pd; \
4335 txt->text.fit_##Value = fit ? 1 : 0; \
4336 edje_object_calc_force(obj); \
4337 }
4338
4339FUNC_TEXT_BOOL_FIT(x);
4340FUNC_TEXT_BOOL_FIT(y);
4341
4342EAPI Eina_List *
4343edje_edit_fonts_list_get(Evas_Object *obj)
4344{
4345 Eina_Iterator *it;
4346 Eina_List *fonts = NULL;
4347 Edje_Font_Directory_Entry *f;
4348
4349 eina_error_set(0);
4350
4351 GET_ED_OR_RETURN(NULL);
4352
4353 if (!ed->file || !ed->file->fonts) return NULL;
4354
4355 it = eina_hash_iterator_data_new(ed->file->fonts);
4356 if (!it) return NULL;
4357
4358 EINA_ITERATOR_FOREACH(it, f)
4359 fonts = eina_list_append(fonts, eina_stringshare_add(f->entry));
4360
4361 eina_iterator_free(it);
4362
4363 return fonts;
4364}
4365
4366EAPI Eina_Bool
4367edje_edit_font_add(Evas_Object *obj, const char* path, const char* alias)
4368{
4369 char entry[PATH_MAX];
4370 char *new_path;
4371 struct stat st;
4372 Edje_Font_Directory_Entry *fnt;
4373
4374 eina_error_set(0);
4375
4376 GET_ED_OR_RETURN(EINA_FALSE);
4377
4378 INF("ADD FONT: %s", path);
4379
4380 if (!path) return EINA_FALSE;
4381 if (stat(path, &st) || !S_ISREG(st.st_mode)) return EINA_FALSE;
4382 if (!ed->file) return EINA_FALSE;
4383 if (!ed->path) return EINA_FALSE;
4384
4385 /* Alias */
4386 if (alias)
4387 {
4388 if ((new_path = strrchr(path, '/'))) new_path ++;
4389 else new_path = (char *)path;
4390 }
4391 else
4392 {
4393 if ((alias = strrchr(path, '/'))) alias ++;
4394 else alias = (char *)path;
4395 new_path = (char *)alias;
4396 }
4397 snprintf(entry, sizeof(entry), "edje/fonts/%s", alias);
4398
4399 /* Initializing a new font hash, if no exist */
4400 if (!ed->file->fonts)
4401 {
4402 ed->file->fonts = eina_hash_string_small_new(NULL);
4403 if (!ed->file->fonts) return EINA_FALSE;
4404 }
4405
4406 /* Check if exists */
4407 fnt = eina_hash_find(ed->file->fonts, alias);
4408 if (fnt)
4409 return EINA_FALSE;
4410
4411 /* Create Edje_Font_Directory_Entry */
4412 fnt = _alloc(sizeof(Edje_Font_Directory_Entry));
4413 if (!fnt)
4414 {
4415 ERR("Unable to alloc font entry part \"%s\"", alias);
4416 return EINA_FALSE;
4417 }
4418 fnt->file = eina_stringshare_add(new_path);
4419 fnt->entry = eina_stringshare_add(alias);
4420
4421 eina_hash_direct_add(ed->file->fonts, fnt->entry, fnt);
4422
4423 /* Import font */
4424 if (!_edje_import_font_file(ed, path, entry))
4425 {
4426 eina_hash_del(ed->file->fonts, fnt->entry, fnt);
4427 eina_stringshare_del(fnt->file);
4428 eina_stringshare_del(fnt->entry);
4429 return EINA_FALSE;
4430 }
4431
4432 return EINA_TRUE;
4433}
4434
4435EAPI Eina_Bool
4436edje_edit_font_del(Evas_Object *obj, const char* alias)
4437{
4438 Edje_Font_Directory_Entry *fnt;
4439
4440 eina_error_set(0);
4441
4442 GET_ED_OR_RETURN(EINA_FALSE);
4443
4444 INF("DEL FONT: %s", alias);
4445
4446 if (!alias) return EINA_FALSE;
4447 if (!ed->file) return EINA_FALSE;
4448 if (!ed->path) return EINA_FALSE;
4449
4450 fnt = eina_hash_find(ed->file->fonts, alias);
4451 if (!fnt)
4452 {
4453 WRN("Unable to find font entry part \"%s\"", alias);
4454 return EINA_FALSE;
4455 }
4456
4457 /* Erase font to edje file */
4458 {
4459 char entry[PATH_MAX];
4460 Eet_File *eetf;
4461
4462 /* open the eet file */
4463 eetf = eet_open(ed->path, EET_FILE_MODE_READ_WRITE);
4464 if (!eetf)
4465 {
4466 ERR("Unable to open \"%s\" for writing output", ed->path);
4467 return EINA_FALSE;
4468 }
4469
4470 snprintf(entry, sizeof(entry), "edje/fonts/%s", alias);
4471
4472 if (eet_delete(eetf, entry) <= 0)
4473 {
4474 ERR("Unable to delete \"%s\" font entry", entry);
4475 eet_close(eetf);
4476 return EINA_FALSE;
4477 }
4478
4479 /* write the edje_file */
4480 if (!_edje_edit_edje_file_save(eetf, ed->file))
4481 {
4482 eet_close(eetf);
4483 return EINA_FALSE;
4484 }
4485 eet_close(eetf);
4486 }
4487
4488 eina_hash_del(ed->file->fonts, alias, fnt);
4489
4490 return EINA_TRUE;
4491}
4492
4493EAPI const char *
4494edje_edit_font_path_get(Evas_Object *obj, const char *alias)
4495{
4496 Eina_Iterator *it;
4497 Edje_Font_Directory_Entry *f;
4498 const char *str = NULL;
4499
4500 eina_error_set(0);
4501
4502 if (!alias) return NULL;
4503 GET_ED_OR_RETURN(NULL);
4504
4505 if (!ed->file || !ed->file->fonts) return NULL;
4506
4507 it = eina_hash_iterator_data_new(ed->file->fonts);
4508 if (!it) return NULL;
4509
4510 EINA_ITERATOR_FOREACH(it, f)
4511 if (!strcmp(f->entry, alias))
4512 {
4513 str = f->file;
4514 break;
4515 }
4516
4517 eina_iterator_free(it);
4518 return eina_stringshare_add(str);
4519}
4520
4521EAPI const char *
4522edje_edit_state_font_get(Evas_Object *obj, const char *part, const char *state, double value)
4523{
4524 Edje_Part_Description_Text *txt;
4525
4526 eina_error_set(0);
4527
4528 GET_PD_OR_RETURN(NULL);
4529
4530 if ((rp->part->type != EDJE_PART_TYPE_TEXT) &&
4531 (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK))
4532 return NULL;
4533
4534 txt = (Edje_Part_Description_Text*) pd;
4535
4536 return eina_stringshare_add(edje_string_get(&txt->text.font));
4537}
4538
4539EAPI void
4540edje_edit_state_font_set(Evas_Object *obj, const char *part, const char *state, double value, const char *font)
4541{
4542 Edje_Part_Description_Text *txt;
4543
4544 eina_error_set(0);
4545
4546 GET_PD_OR_RETURN();
4547
4548 if ((rp->part->type != EDJE_PART_TYPE_TEXT) &&
4549 (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK))
4550 return;
4551
4552 txt = (Edje_Part_Description_Text*) pd;
4553
4554 _edje_if_string_free(ed, txt->text.font.str);
4555 txt->text.font.str = (char *)eina_stringshare_add(font);
4556 txt->text.font.id = 0;
4557
4558 edje_object_calc_force(obj);
4559}
4560
4561EAPI Edje_Text_Effect
4562edje_edit_part_effect_get(Evas_Object *obj, const char *part)
4563{
4564 eina_error_set(0);
4565
4566 GET_RP_OR_RETURN(0);
4567
4568 //printf("GET EFFECT of part: %s\n", part);
4569 return rp->part->effect;
4570}
4571
4572EAPI void
4573edje_edit_part_effect_set(Evas_Object *obj, const char *part, Edje_Text_Effect effect)
4574{
4575 eina_error_set(0);
4576
4577 GET_RP_OR_RETURN();
4578
4579 //printf("SET EFFECT of part: %s [%d]\n", part, effect);
4580 rp->part->effect = effect;
4581
4582 edje_object_calc_force(obj);
4583}
4584
4585/****************/
4586/* IMAGES API */
4587/****************/
4588
4589EAPI Eina_List *
4590edje_edit_images_list_get(Evas_Object *obj)
4591{
4592 Eina_List *images = NULL;
4593 unsigned int i;
4594
4595 eina_error_set(0);
4596
4597 GET_ED_OR_RETURN(NULL);
4598
4599 if (!ed->file) return NULL;
4600 if (!ed->file->image_dir) return NULL;
4601
4602 //printf("GET IMAGES LIST for %s\n", ed->file->path);
4603 for (i = 0; i < ed->file->image_dir->entries_count; ++i)
4604 images = eina_list_append(images,
4605 eina_stringshare_add(ed->file->image_dir->entries[i].entry));
4606
4607 return images;
4608}
4609
4610EAPI Eina_Bool
4611edje_edit_image_add(Evas_Object *obj, const char* path)
4612{
4613 Edje_Image_Directory_Entry *de;
4614 unsigned int i;
4615 int free_id = -1;
4616 char *name;
4617
4618 eina_error_set(0);
4619
4620 GET_ED_OR_RETURN(EINA_FALSE);
4621
4622 if (!path) return EINA_FALSE;
4623 if (!ed->file) return EINA_FALSE;
4624 if (!ed->path) return EINA_FALSE;
4625
4626 /* Create Image_Directory if not exist */
4627 if (!ed->file->image_dir)
4628 {
4629 ed->file->image_dir = _alloc(sizeof(Edje_Image_Directory));
4630 if (!ed->file->image_dir) return EINA_FALSE;
4631 }
4632
4633 /* Image name */
4634 if ((name = strrchr(path, '/'))) name++;
4635 else name = (char *)path;
4636
4637 /* Loop trough image directory to find if image exist */
4638 for (i = 0; i < ed->file->image_dir->entries_count; ++i)
4639 {
4640 de = ed->file->image_dir->entries + i;
4641
4642 if (!de->entry)
4643 free_id = i;
4644 else if (!strcmp(name, de->entry))
4645 return EINA_FALSE;
4646 }
4647
4648 if (free_id == -1)
4649 {
4650 Edje_Image_Directory_Entry *tmp;
4651 unsigned int count;
4652
4653 count = ed->file->image_dir->entries_count + 1;
4654
4655 tmp = realloc(ed->file->image_dir->entries,
4656 sizeof (Edje_Image_Directory_Entry) * count);
4657 if (!tmp) return EINA_FALSE;
4658
4659 ed->file->image_dir->entries = tmp;
4660 free_id = ed->file->image_dir->entries_count;
4661 ed->file->image_dir->entries_count = count;
4662 }
4663
4664 /* Set Image Entry */
4665 de = ed->file->image_dir->entries + free_id;
4666 de->entry = eina_stringshare_add(name);
4667 de->id = free_id;
4668 de->source_type = 1;
4669 de->source_param = 1;
4670
4671 /* Import image */
4672 if (!_edje_import_image_file(ed, path, free_id))
4673 {
4674 eina_stringshare_del(de->entry);
4675 de->entry = NULL;
4676 return EINA_FALSE;
4677 }
4678
4679 return EINA_TRUE;
4680}
4681
4682EAPI Eina_Bool
4683edje_edit_image_del(Evas_Object *obj, const char* name)
4684{
4685 Edje_Image_Directory_Entry *de;
4686 unsigned int i;
4687
4688 eina_error_set(0);
4689
4690 GET_ED_OR_RETURN(EINA_FALSE);
4691
4692 if (!name) return EINA_FALSE;
4693 if (!ed->file) return EINA_FALSE;
4694 if (!ed->path) return EINA_FALSE;
4695
4696 /* Create Image_Directory if not exist */
4697 if (!ed->file->image_dir)
4698 goto invalid_image;
4699
4700 return EINA_TRUE;
4701
4702 for (i = 0; i < ed->file->image_dir->entries_count; ++i)
4703 {
4704 de = ed->file->image_dir->entries + i;
4705
4706 if (de->entry
4707 && !strcmp(name, de->entry))
4708 break;
4709 }
4710
4711 if (i == ed->file->image_dir->entries_count)
4712 goto invalid_image;
4713
4714 {
4715 char entry[PATH_MAX];
4716 Eet_File *eetf;
4717
4718 /* open the eet file */
4719 eetf = eet_open(ed->path, EET_FILE_MODE_READ_WRITE);
4720 if (!eetf)
4721 {
4722 ERR("Unable to open \"%s\" for writing output", ed->path);
4723 return EINA_FALSE;
4724 }
4725
4726 snprintf(entry, sizeof(entry), "edje/images/%i", de->id);
4727
4728 if (eet_delete(eetf, entry) <= 0)
4729 {
4730 ERR("Unable to delete \"%s\" font entry", entry);
4731 eet_close(eetf);
4732 return EINA_FALSE;
4733 }
4734
4735 /* write the edje_file */
4736 if (!_edje_edit_edje_file_save(eetf, ed->file))
4737 {
4738 eet_close(eetf);
4739 return EINA_FALSE;
4740 }
4741
4742 eet_close(eetf);
4743 }
4744
4745 _edje_if_string_free(ed, de->entry);
4746 de->entry = NULL;
4747
4748 _edje_edit_flag_script_dirty(eed, EINA_TRUE);
4749
4750 return EINA_TRUE;
4751
4752invalid_image:
4753 WRN("Unable to find image entry part \"%s\"", name);
4754 return EINA_FALSE;
4755}
4756
4757EAPI Eina_Bool
4758edje_edit_image_data_add(Evas_Object *obj, const char *name, int id)
4759{
4760 Edje_Image_Directory_Entry *de;
4761
4762 eina_error_set(0);
4763
4764 GET_ED_OR_RETURN(EINA_FALSE);
4765
4766 if (!name) return EINA_FALSE;
4767 if (!ed->file) return EINA_FALSE;
4768 if (!ed->path) return EINA_FALSE;
4769
4770 /* Create Image_Directory if not exist */
4771 if (!ed->file->image_dir)
4772 {
4773 ed->file->image_dir = _alloc(sizeof(Edje_Image_Directory));
4774 if (!ed->file->image_dir) return EINA_FALSE;
4775 }
4776
4777 /* Loop trough image directory to find if image exist */
4778 if (id < 0) id = - id - 1;
4779 if ((unsigned int) id >= ed->file->image_dir->entries_count) return EINA_FALSE;
4780
4781 de = ed->file->image_dir->entries + id;
4782 eina_stringshare_replace(&de->entry, name);
4783 de->source_type = 1;
4784 de->source_param = 1;
4785
4786 return EINA_TRUE;
4787}
4788
4789EAPI int
4790edje_edit_image_id_get(Evas_Object *obj, const char *image_name)
4791{
4792 eina_error_set(0);
4793
4794 GET_ED_OR_RETURN(-1);
4795
4796 return _edje_image_id_find(eed, image_name);
4797}
4798
4799EAPI Edje_Edit_Image_Comp
4800edje_edit_image_compression_type_get(Evas_Object *obj, const char *image)
4801{
4802 Edje_Image_Directory_Entry *de = NULL;
4803 unsigned int i;
4804
4805 eina_error_set(0);
4806
4807 GET_ED_OR_RETURN(-1);
4808
4809 if (!ed->file) return -1;
4810 if (!ed->file->image_dir) return -1;
4811
4812 for (i = 0; i < ed->file->image_dir->entries_count; ++i)
4813 {
4814 de = ed->file->image_dir->entries + i;
4815
4816 if (de->entry
4817 && !strcmp(image, de->entry))
4818 break;
4819 }
4820
4821 if (i == ed->file->image_dir->entries_count) return -1;
4822
4823 switch(de->source_type)
4824 {
4825 case EDJE_IMAGE_SOURCE_TYPE_INLINE_PERFECT:
4826 if (de->source_param == 0) // RAW
4827 return EDJE_EDIT_IMAGE_COMP_RAW;
4828 else // COMP
4829 return EDJE_EDIT_IMAGE_COMP_COMP;
4830 break;
4831 case EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY: // LOSSY
4832 return EDJE_EDIT_IMAGE_COMP_LOSSY;
4833 break;
4834 case EDJE_IMAGE_SOURCE_TYPE_EXTERNAL: // USER
4835 return EDJE_EDIT_IMAGE_COMP_USER;
4836 break;
4837 }
4838
4839 return -1;
4840}
4841
4842EAPI int
4843edje_edit_image_compression_rate_get(Evas_Object *obj, const char *image)
4844{
4845 Edje_Image_Directory_Entry *de;
4846 unsigned int i;
4847
4848 eina_error_set(0);
4849
4850 GET_ED_OR_RETURN(-1);
4851
4852 // Gets the Image Entry
4853 for (i = 0; i < ed->file->image_dir->entries_count; ++i)
4854 {
4855 de = ed->file->image_dir->entries + i;
4856 if (de->entry
4857 && !strcmp(de->entry, image))
4858 break;
4859 }
4860
4861 if (i == ed->file->image_dir->entries_count) return -1;
4862 if (de->source_type != EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY) return -2;
4863
4864 return de->source_param;
4865}
4866
4867EAPI const char *
4868edje_edit_state_image_get(Evas_Object *obj, const char *part, const char *state, double value)
4869{
4870 Edje_Part_Description_Image *img;
4871 const char *image;
4872
4873 eina_error_set(0);
4874
4875 GET_PD_OR_RETURN(NULL);
4876
4877 if (rp->part->type != EDJE_PART_TYPE_IMAGE)
4878 return NULL;
4879
4880 img = (Edje_Part_Description_Image *) pd;
4881
4882 image = _edje_image_name_find(eed, img->image.id);
4883 if (!image) return NULL;
4884
4885 //printf("GET IMAGE for %s [%s]\n", state, image);
4886 return eina_stringshare_add(image);
4887}
4888
4889EAPI void
4890edje_edit_state_image_set(Evas_Object *obj, const char *part, const char *state, double value, const char *image)
4891{
4892 Edje_Part_Description_Image *img;
4893 int id;
4894
4895 eina_error_set(0);
4896
4897 GET_PD_OR_RETURN();
4898
4899 if (!image) return;
4900
4901 if (rp->part->type != EDJE_PART_TYPE_IMAGE)
4902 return;
4903
4904 id = _edje_image_id_find(eed, image);
4905 //printf("SET IMAGE for %s [%s]\n", state, image);
4906
4907 img = (Edje_Part_Description_Image *) pd;
4908
4909 if (id > -1) img->image.id = id;
4910
4911 edje_object_calc_force(obj);
4912}
4913
4914EAPI Eina_List *
4915edje_edit_state_tweens_list_get(Evas_Object *obj, const char *part, const char *state, double value)
4916{
4917 Edje_Part_Description_Image *img;
4918 Eina_List *tweens = NULL;
4919 const char *name;
4920 unsigned int i;
4921
4922 eina_error_set(0);
4923
4924 GET_PD_OR_RETURN(NULL);
4925
4926 if (rp->part->type != EDJE_PART_TYPE_IMAGE)
4927 return NULL;
4928
4929 img = (Edje_Part_Description_Image *) pd;
4930
4931 for (i = 0; i < img->image.tweens_count; ++i)
4932 {
4933 name = _edje_image_name_find(eed, img->image.tweens[i]->id);
4934 //printf(" t: %s\n", name);
4935 tweens = eina_list_append(tweens, eina_stringshare_add(name));
4936 }
4937
4938 return tweens;
4939}
4940
4941EAPI Eina_Bool
4942edje_edit_state_tween_add(Evas_Object *obj, const char *part, const char *state, double value, const char *tween)
4943{
4944 Edje_Part_Description_Image *img;
4945 Edje_Part_Image_Id **tmp;
4946 Edje_Part_Image_Id *i;
4947 int id;
4948
4949 eina_error_set(0);
4950
4951 GET_PD_OR_RETURN(EINA_FALSE);
4952
4953 if (rp->part->type != EDJE_PART_TYPE_IMAGE)
4954 return EINA_FALSE;
4955
4956 id = _edje_image_id_find(eed, tween);
4957 if (id < EINA_FALSE) return 0;
4958
4959 /* alloc Edje_Part_Image_Id */
4960 i = _alloc(sizeof(Edje_Part_Image_Id));
4961 if (!i) return EINA_FALSE;
4962 i->id = id;
4963
4964 img = (Edje_Part_Description_Image *) pd;
4965
4966 /* add to tween list */
4967 tmp = realloc(img->image.tweens,
4968 sizeof (Edje_Part_Image_Id*) * img->image.tweens_count);
4969 if (!tmp)
4970 {
4971 free(i);
4972 return EINA_FALSE;
4973 }
4974
4975 tmp[img->image.tweens_count++] = i;
4976 img->image.tweens = tmp;
4977
4978 return EINA_TRUE;
4979}
4980
4981EAPI Eina_Bool
4982edje_edit_state_tween_del(Evas_Object *obj, const char *part, const char *state, double value, const char *tween)
4983{
4984 Edje_Part_Description_Image *img;
4985 unsigned int i;
4986 int search;
4987
4988 eina_error_set(0);
4989
4990 GET_PD_OR_RETURN(EINA_FALSE);
4991
4992 if (rp->part->type != EDJE_PART_TYPE_IMAGE)
4993 return EINA_FALSE;
4994
4995 img = (Edje_Part_Description_Image *) pd;
4996
4997 if (!img->image.tweens_count) return EINA_FALSE;
4998
4999 search = _edje_image_id_find(eed, tween);
5000 if (search < 0) return EINA_FALSE;
5001
5002 for (i = 0; i < img->image.tweens_count; ++i)
5003 {
5004 if (img->image.tweens[i]->id == search)
5005 {
5006 img->image.tweens_count--;
5007 free(img->image.tweens[i]);
5008 memmove(img->image.tweens + i,
5009 img->image.tweens + i + 1,
5010 sizeof (Edje_Part_Description_Image*) * (img->image.tweens_count - i));
5011 return EINA_TRUE;
5012 }
5013 }
5014 return EINA_FALSE;
5015}
5016
5017EAPI void
5018edje_edit_state_image_border_get(Evas_Object *obj, const char *part, const char *state, double value, int *l, int *r, int *t, int *b)
5019{
5020 Edje_Part_Description_Image *img;
5021
5022 eina_error_set(0);
5023
5024 GET_PD_OR_RETURN();
5025
5026 if (rp->part->type != EDJE_PART_TYPE_IMAGE)
5027 {
5028 if (l) *l = 0;
5029 if (r) *r = 0;
5030 if (t) *t = 0;
5031 if (b) *b = 0;
5032 return;
5033 }
5034
5035 img = (Edje_Part_Description_Image *) pd;
5036
5037 //printf("GET IMAGE_BORDER of state '%s'\n", state);
5038
5039 if (l) *l = img->image.border.l;
5040 if (r) *r = img->image.border.r;
5041 if (t) *t = img->image.border.t;
5042 if (b) *b = img->image.border.b;
5043}
5044
5045EAPI void
5046edje_edit_state_image_border_set(Evas_Object *obj, const char *part, const char *state, double value, int l, int r, int t, int b)
5047{
5048 Edje_Part_Description_Image *img;
5049
5050 eina_error_set(0);
5051
5052 GET_PD_OR_RETURN();
5053
5054 if (rp->part->type != EDJE_PART_TYPE_IMAGE)
5055 return;
5056
5057 img = (Edje_Part_Description_Image *) pd;
5058
5059 //printf("SET IMAGE_BORDER of state '%s'\n", state);
5060
5061 if (l > -1) img->image.border.l = l;
5062 if (r > -1) img->image.border.r = r;
5063 if (t > -1) img->image.border.t = t;
5064 if (b > -1) img->image.border.b = b;
5065
5066 edje_object_calc_force(obj);
5067}
5068
5069EAPI unsigned char
5070edje_edit_state_image_border_fill_get(Evas_Object *obj, const char *part, const char *state, double value)
5071{
5072 Edje_Part_Description_Image *img;
5073
5074 eina_error_set(0);
5075
5076 GET_PD_OR_RETURN(0);
5077
5078 if (rp->part->type != EDJE_PART_TYPE_IMAGE)
5079 return 0;
5080
5081 img = (Edje_Part_Description_Image *) pd;
5082
5083 if (img->image.border.no_fill == 0) return 1;
5084 else if (img->image.border.no_fill == 1) return 0;
5085 else if (img->image.border.no_fill == 2) return 2;
5086 return 0;
5087}
5088
5089EAPI void
5090edje_edit_state_image_border_fill_set(Evas_Object *obj, const char *part, const char *state, double value, unsigned char fill)
5091{
5092 Edje_Part_Description_Image *img;
5093
5094 eina_error_set(0);
5095
5096 GET_PD_OR_RETURN();
5097
5098 if (rp->part->type != EDJE_PART_TYPE_IMAGE)
5099 return;
5100
5101 img = (Edje_Part_Description_Image *) pd;
5102
5103 if (fill == 0) img->image.border.no_fill = 1;
5104 else if (fill == 1) img->image.border.no_fill = 0;
5105 else if (fill == 2) img->image.border.no_fill = 2;
5106
5107 edje_object_calc_force(obj);
5108}
5109
5110/******************/
5111/* PROGRAMS API */
5112/******************/
5113static int
5114_edje_program_id_find(Edje_Edit *eed, const char *program)
5115{
5116 Edje_Program *epr;
5117 int i;
5118
5119 for (i = 0; i < eed->base.table_programs_size; i++)
5120 {
5121 epr = eed->base.table_programs[i];
5122 if (epr->name && !strcmp(epr->name, program))
5123 return epr->id;
5124 }
5125 return -1;
5126}
5127
5128static Edje_Program *
5129_edje_program_get_byname(Evas_Object *obj, const char *prog_name)
5130{
5131 Edje_Program *epr;
5132 int i;
5133
5134 GET_ED_OR_RETURN(NULL);
5135
5136 if (!prog_name) return NULL;
5137
5138 for (i = 0; i < ed->table_programs_size; i++)
5139 {
5140 epr = ed->table_programs[i];
5141 if ((epr->name) && (strcmp(epr->name, prog_name) == 0))
5142 return epr;
5143 }
5144 return NULL;
5145}
5146
5147EAPI Eina_List *
5148edje_edit_programs_list_get(Evas_Object *obj)
5149{
5150 Eina_List *progs = NULL;
5151 int i;
5152
5153 eina_error_set(0);
5154
5155 GET_ED_OR_RETURN(NULL);
5156
5157 //printf("EE: Found %d programs\n", ed->table_programs_size);
5158
5159 for (i = 0; i < ed->table_programs_size; i++)
5160 {
5161 Edje_Program *epr;
5162
5163 epr = ed->table_programs[i];
5164 /* XXX: bad, we miss programs this way, but since you can't access
5165 * them in any way without a name, better ignore them. */
5166 if (!epr->name) continue;
5167 progs = eina_list_append(progs, eina_stringshare_add(epr->name));
5168 }
5169
5170 return progs;
5171}
5172
5173EAPI Eina_Bool
5174edje_edit_program_add(Evas_Object *obj, const char *name)
5175{
5176 Edje_Program *epr;
5177 Edje_Part_Collection *pc;
5178
5179 eina_error_set(0);
5180
5181 GET_ED_OR_RETURN(EINA_FALSE);
5182
5183 //printf("ADD PROGRAM [new name: %s]\n", name);
5184
5185 //Check if program already exists
5186 if (_edje_program_get_byname(obj, name))
5187 return EINA_FALSE;
5188
5189 //Alloc Edje_Program or return
5190 epr = _alloc(sizeof(Edje_Program));
5191 if (!epr) return EINA_FALSE;
5192
5193 //Add program to group
5194 pc = ed->collection;
5195
5196 /* By default, source and signal are empty, so they fill in nocmp category */
5197 ed->collection->programs.nocmp = realloc(ed->collection->programs.nocmp,
5198 sizeof (Edje_Program*) * (ed->collection->programs.nocmp_count + 1));
5199 ed->collection->programs.nocmp[ed->collection->programs.nocmp_count++] = epr;
5200
5201 //Init Edje_Program
5202 epr->id = ed->table_programs_size;
5203 epr->name = eina_stringshare_add(name);
5204 epr->signal = NULL;
5205 epr->source = NULL;
5206 epr->filter.part = NULL;
5207 epr->filter.state = NULL;
5208 epr->in.from = 0.0;
5209 epr->in.range = 0.0;
5210 epr->action = 0;
5211 epr->state = NULL;
5212 epr->value = 0.0;
5213 epr->state2 = NULL;
5214 epr->value2 = 0.0;
5215 epr->tween.mode = 1;
5216 epr->tween.time = ZERO;
5217 epr->targets = NULL;
5218 epr->after = NULL;
5219
5220
5221 //Update table_programs
5222 ed->table_programs_size++;
5223 ed->table_programs = realloc(ed->table_programs,
5224 sizeof(Edje_Program *) * ed->table_programs_size);
5225 ed->table_programs[epr->id % ed->table_programs_size] = epr;
5226
5227 //Update patterns
5228 _edje_programs_patterns_clean(ed);
5229 _edje_programs_patterns_init(ed);
5230
5231 return EINA_TRUE;
5232}
5233
5234EAPI Eina_Bool
5235edje_edit_program_del(Evas_Object *obj, const char *prog)
5236{
5237 Eina_List *l, *l_next;
5238 Edje_Program_Target *prt;
5239 Edje_Program_After *pa;
5240 Edje_Part_Collection *pc;
5241 Edje_Program *p;
5242 Program_Script *ps, *old_ps;
5243 int id, i;
5244 int old_id = -1;
5245
5246 eina_error_set(0);
5247
5248 GET_ED_OR_RETURN(EINA_FALSE);
5249 GET_EPR_OR_RETURN(EINA_FALSE);
5250
5251 pc = ed->collection;
5252
5253 //Remove program from programs list
5254 id = epr->id;
5255 _edje_program_remove(ed->collection, epr);
5256
5257 /* fix table program */
5258 if (epr->id != ed->table_programs_size - 1)
5259 {
5260 /* If the removed program is not the last in the list/table,
5261 * put the last one in its place and update references to it later */
5262 ed->table_programs[epr->id] = ed->table_programs[ed->table_programs_size - 1];
5263 old_id = ed->table_programs_size - 1;
5264 ed->table_programs[epr->id]->id = epr->id;
5265 }
5266
5267 ps = eina_hash_find(eed->program_scripts, &id);
5268 old_ps = eina_hash_find(eed->program_scripts, &old_id);
5269 if (old_ps)
5270 {
5271 if (!ps)
5272 {
5273 ps = _alloc(sizeof(Program_Script));
5274 ps->id = id;
5275 eina_hash_add(eed->program_scripts, &id, ps);
5276 }
5277 else
5278 {
5279 free(ps->code);
5280 free(ps->processed);
5281 ps->processed = NULL;
5282 ps->delete_me = EINA_FALSE;
5283 }
5284 ps->code = old_ps->code;
5285 old_ps->code = NULL;
5286 free(old_ps->processed);
5287 old_ps->processed = NULL;
5288 ps->dirty = EINA_TRUE;
5289 old_ps->dirty = EINA_FALSE;
5290 old_ps->delete_me = EINA_TRUE;
5291 }
5292 else if (ps)
5293 {
5294 ps->dirty = EINA_FALSE;
5295 ps->delete_me = EINA_TRUE;
5296 }
5297
5298 //Free Edje_Program
5299 _edje_if_string_free(ed, epr->name);
5300 _edje_if_string_free(ed, epr->signal);
5301 _edje_if_string_free(ed, epr->source);
5302 _edje_if_string_free(ed, epr->filter.part);
5303 _edje_if_string_free(ed, epr->filter.state);
5304 _edje_if_string_free(ed, epr->state);
5305 _edje_if_string_free(ed, epr->state2);
5306
5307 EINA_LIST_FREE(epr->targets, prt)
5308 free(prt);
5309 EINA_LIST_FREE(epr->after, pa)
5310 free(pa);
5311 free(epr);
5312
5313 ed->table_programs_size--;
5314 ed->table_programs = realloc(ed->table_programs,
5315 sizeof(Edje_Program *) * ed->table_programs_size);
5316
5317 //We also update all other programs that point to old_id and id
5318 for (i = 0; i < ed->table_programs_size; i++)
5319 {
5320 p = ed->table_programs[i];
5321
5322 /* check in afters */
5323 EINA_LIST_FOREACH_SAFE(p->after, l, l_next, pa)
5324 {
5325 if (pa->id == old_id)
5326 pa->id = id;
5327 else if (pa->id == id)
5328 {
5329 p->after = eina_list_remove_list(p->after, l);
5330 free(pa);
5331 }
5332 }
5333 /* check in targets */
5334 if (p->action == EDJE_ACTION_TYPE_ACTION_STOP)
5335 {
5336 Edje_Program_Target *pt;
5337
5338 EINA_LIST_FOREACH_SAFE(p->targets, l, l_next, pt)
5339 {
5340 if (pt->id == old_id)
5341 pt->id = id;
5342 else if (pt->id == id)
5343 {
5344 p->targets = eina_list_remove_list(p->targets, l);
5345 free(pt);
5346 }
5347 }
5348 }
5349 }
5350
5351 _edje_edit_flag_script_dirty(eed, EINA_TRUE);
5352
5353 return EINA_TRUE;
5354}
5355
5356EAPI Eina_Bool
5357edje_edit_program_exist(Evas_Object *obj, const char *prog)
5358{
5359 eina_error_set(0);
5360
5361 GET_EPR_OR_RETURN(EINA_FALSE);
5362
5363 return EINA_TRUE;
5364}
5365
5366EAPI Eina_Bool
5367edje_edit_program_run(Evas_Object *obj, const char *prog)
5368{
5369 eina_error_set(0);
5370
5371 GET_ED_OR_RETURN(EINA_FALSE);
5372 GET_EPR_OR_RETURN(EINA_FALSE);
5373
5374 _edje_program_run(ed, epr, 0, "", "");
5375 return EINA_TRUE;
5376}
5377
5378EAPI Eina_Bool
5379edje_edit_program_name_set(Evas_Object *obj, const char *prog, const char* new_name)
5380{
5381 eina_error_set(0);
5382
5383 GET_ED_OR_RETURN(EINA_FALSE);
5384 GET_EPR_OR_RETURN(EINA_FALSE);
5385
5386 if (!new_name) return EINA_FALSE;
5387
5388 if (_edje_program_get_byname(obj, new_name)) return EINA_FALSE;
5389
5390 //printf("SET NAME for program: %s [new name: %s]\n", prog, new_name);
5391
5392 _edje_if_string_free(ed, epr->name);
5393 epr->name = eina_stringshare_add(new_name);
5394
5395 _edje_edit_flag_script_dirty(eed, EINA_TRUE);
5396
5397 return EINA_TRUE;
5398}
5399
5400EAPI const char *
5401edje_edit_program_source_get(Evas_Object *obj, const char *prog)
5402{
5403 eina_error_set(0);
5404
5405 GET_EPR_OR_RETURN(NULL);
5406
5407 if (!epr->source) return NULL;
5408 //printf("GET SOURCE for program: %s [%s]\n", prog, epr->source);
5409 return eina_stringshare_add(epr->source);
5410}
5411
5412EAPI Eina_Bool
5413edje_edit_program_source_set(Evas_Object *obj, const char *prog, const char *source)
5414{
5415 eina_error_set(0);
5416
5417 GET_ED_OR_RETURN(EINA_FALSE);
5418 GET_EPR_OR_RETURN(EINA_FALSE);
5419
5420 if (!source) return EINA_FALSE;
5421
5422 /* Remove from program array */
5423 _edje_program_remove(ed->collection, epr);
5424 _edje_if_string_free(ed, epr->source);
5425
5426 /* Insert it back */
5427 epr->source = eina_stringshare_add(source);
5428 _edje_program_insert(ed->collection, epr);
5429
5430 //Update patterns
5431 _edje_programs_patterns_clean(ed);
5432 _edje_programs_patterns_init(ed);
5433
5434 return EINA_TRUE;
5435}
5436
5437EAPI const char *
5438edje_edit_program_filter_part_get(Evas_Object *obj, const char *prog)
5439{
5440 eina_error_set(0);
5441
5442 GET_EPR_OR_RETURN(NULL);
5443
5444 if (!epr->filter.part) return NULL;
5445 return eina_stringshare_add(epr->filter.part);
5446}
5447
5448EAPI Eina_Bool
5449edje_edit_program_filter_part_set(Evas_Object *obj, const char *prog, const char *filter_part)
5450{
5451 eina_error_set(0);
5452
5453 GET_ED_OR_RETURN(EINA_FALSE);
5454 GET_EPR_OR_RETURN(EINA_FALSE);
5455
5456 if (!filter_part) return EINA_FALSE;
5457
5458 _edje_if_string_free(ed, epr->filter.part);
5459 epr->filter.part = eina_stringshare_add(filter_part);
5460
5461 return EINA_TRUE;
5462}
5463
5464EAPI const char *
5465edje_edit_program_filter_state_get(Evas_Object *obj, const char *prog)
5466{
5467 eina_error_set(0);
5468
5469 GET_EPR_OR_RETURN(NULL);
5470
5471 if (!epr->filter.state) return NULL;
5472 return eina_stringshare_add(epr->filter.state);
5473}
5474
5475EAPI Eina_Bool
5476edje_edit_program_filter_state_set(Evas_Object *obj, const char *prog, const char *filter_state)
5477{
5478 eina_error_set(0);
5479
5480 GET_ED_OR_RETURN(EINA_FALSE);
5481 GET_EPR_OR_RETURN(EINA_FALSE);
5482
5483 if (!filter_state) return EINA_FALSE;
5484
5485 _edje_if_string_free(ed, epr->filter.state);
5486 epr->filter.state = eina_stringshare_add(filter_state);
5487
5488 return EINA_TRUE;
5489}
5490
5491EAPI const char *
5492edje_edit_program_signal_get(Evas_Object *obj, const char *prog)
5493{
5494 eina_error_set(0);
5495
5496 GET_EPR_OR_RETURN(NULL);
5497
5498 if (!epr->signal) return NULL;
5499 //printf("GET SIGNAL for program: %s [%s]\n", prog, epr->signal);
5500 return eina_stringshare_add(epr->signal);
5501}
5502
5503EAPI Eina_Bool
5504edje_edit_program_signal_set(Evas_Object *obj, const char *prog, const char *sig)
5505{
5506 eina_error_set(0);
5507
5508 GET_ED_OR_RETURN(EINA_FALSE);
5509 GET_EPR_OR_RETURN(EINA_FALSE);
5510
5511 if (!sig) return EINA_FALSE;
5512
5513 /* Remove from program array */
5514 _edje_program_remove(ed->collection, epr);
5515 _edje_if_string_free(ed, epr->signal);
5516
5517 /* Insert it back */
5518 epr->signal = eina_stringshare_add(sig);
5519 _edje_program_insert(ed->collection, epr);
5520
5521 //Update patterns
5522 _edje_programs_patterns_clean(ed);
5523 _edje_programs_patterns_init(ed);
5524
5525 return EINA_TRUE;
5526}
5527
5528EAPI const char *
5529edje_edit_program_state_get(Evas_Object *obj, const char *prog)
5530{
5531 eina_error_set(0);
5532
5533 GET_EPR_OR_RETURN(NULL);
5534
5535 if (!epr->state) return NULL;
5536 //printf("GET STATE for program: %s [%s %.2f]\n", prog, epr->state, epr->value);
5537 return eina_stringshare_add(epr->state);
5538}
5539
5540EAPI Eina_Bool
5541edje_edit_program_state_set(Evas_Object *obj, const char *prog, const char *state)
5542{
5543 eina_error_set(0);
5544
5545 GET_ED_OR_RETURN(EINA_FALSE);
5546 GET_EPR_OR_RETURN(EINA_FALSE);
5547
5548 //printf("SET STATE for program: %s\n", prog);
5549
5550 _edje_if_string_free(ed, epr->state);
5551 epr->state = eina_stringshare_add(state);
5552
5553 return EINA_TRUE;
5554}
5555
5556EAPI const char *
5557edje_edit_program_state2_get(Evas_Object *obj, const char *prog)
5558{
5559 eina_error_set(0);
5560
5561 GET_EPR_OR_RETURN(NULL);
5562
5563 if (!epr->state2) return NULL;
5564 //printf("GET STATE2 for program: %s [%s %.2f]\n", prog, epr->state2, epr->value2);
5565 return eina_stringshare_add(epr->state2);
5566}
5567
5568EAPI Eina_Bool
5569edje_edit_program_state2_set(Evas_Object *obj, const char *prog, const char *state2)
5570{
5571 eina_error_set(0);
5572
5573 GET_ED_OR_RETURN(EINA_FALSE);
5574 GET_EPR_OR_RETURN(EINA_FALSE);
5575
5576 //printf("SET STATE2 for program: %s\n", prog);
5577
5578 _edje_if_string_free(ed, epr->state2);
5579 epr->state2 = eina_stringshare_add(state2);
5580
5581 return EINA_TRUE;
5582}
5583
5584EAPI double
5585edje_edit_program_value_get(Evas_Object *obj, const char *prog)
5586{
5587 eina_error_set(0);
5588
5589 GET_EPR_OR_RETURN(-1);
5590
5591 //printf("GET VALUE for program: %s [%s %.2f]\n", prog, epr->state, epr->value);
5592 return epr->value;
5593}
5594
5595EAPI Eina_Bool
5596edje_edit_program_value_set(Evas_Object *obj, const char *prog, double value)
5597{
5598 eina_error_set(0);
5599
5600 GET_EPR_OR_RETURN(EINA_FALSE);
5601
5602 //printf("SET VALUE for program: %s [%.2f]\n", prog, value);
5603 epr->value = value;
5604 return EINA_TRUE;
5605}
5606
5607EAPI double
5608edje_edit_program_value2_get(Evas_Object *obj, const char *prog)
5609{
5610 eina_error_set(0);
5611
5612 GET_EPR_OR_RETURN(-1);
5613
5614 //printf("GET VALUE2 for program: %s [%s %.2f]\n", prog, epr->state2, epr->value2);
5615 return epr->value2;
5616}
5617
5618EAPI Eina_Bool
5619edje_edit_program_value2_set(Evas_Object *obj, const char *prog, double value)
5620{
5621 eina_error_set(0);
5622
5623 GET_EPR_OR_RETURN(EINA_FALSE);
5624
5625 //printf("SET VALUE for program: %s [%.2f]\n", prog, value);
5626 epr->value2 = value;
5627 return EINA_TRUE;
5628}
5629
5630EAPI double
5631edje_edit_program_in_from_get(Evas_Object *obj, const char *prog)
5632{
5633 eina_error_set(0);
5634
5635 GET_EPR_OR_RETURN(0);
5636
5637 //printf("GET IN.FROM for program: %s [%f]\n", prog, epr->in.from);
5638 return epr->in.from;
5639}
5640
5641EAPI Eina_Bool
5642edje_edit_program_in_from_set(Evas_Object *obj, const char *prog, double seconds)
5643{
5644 eina_error_set(0);
5645
5646 GET_EPR_OR_RETURN(EINA_FALSE);
5647
5648 //printf("SET IN.FROM for program: %s [%f]\n", prog, epr->in.from);
5649 epr->in.from = seconds;
5650 return EINA_TRUE;
5651}
5652
5653EAPI double
5654edje_edit_program_in_range_get(Evas_Object *obj, const char *prog)
5655{
5656 eina_error_set(0);
5657
5658 GET_EPR_OR_RETURN(0);
5659
5660 //printf("GET IN.RANGE for program: %s [%f]\n", prog, epr->in.range);
5661 return epr->in.range;
5662}
5663
5664EAPI Eina_Bool
5665edje_edit_program_in_range_set(Evas_Object *obj, const char *prog, double seconds)
5666{
5667 eina_error_set(0);
5668
5669 GET_EPR_OR_RETURN(EINA_FALSE);
5670
5671 //printf("SET IN.RANGE for program: %s [%f]\n", prog, epr->in.range);
5672 epr->in.range = seconds;
5673 return EINA_TRUE;
5674}
5675
5676EAPI Edje_Tween_Mode
5677edje_edit_program_transition_get(Evas_Object *obj, const char *prog)
5678{
5679 eina_error_set(0);
5680
5681 GET_EPR_OR_RETURN(-1);
5682
5683 //printf("GET TRANSITION for program: %s [%d]\n", prog, epr->tween.mode);
5684 return epr->tween.mode;
5685}
5686
5687EAPI Eina_Bool
5688edje_edit_program_transition_set(Evas_Object *obj, const char *prog, Edje_Tween_Mode transition)
5689{
5690 eina_error_set(0);
5691
5692 GET_EPR_OR_RETURN(EINA_FALSE);
5693
5694 //printf("GET TRANSITION for program: %s [%d]\n", prog, epr->tween.mode);
5695 epr->tween.mode = transition;
5696 return EINA_TRUE;
5697}
5698
5699EAPI double
5700edje_edit_program_transition_time_get(Evas_Object *obj, const char *prog)
5701{
5702 eina_error_set(0);
5703
5704 GET_EPR_OR_RETURN(-1);
5705
5706 //printf("GET TRANSITION_TIME for program: %s [%.4f]\n", prog, epr->tween.time);
5707 return TO_DOUBLE(epr->tween.time);
5708}
5709
5710EAPI Eina_Bool
5711edje_edit_program_transition_time_set(Evas_Object *obj, const char *prog, double seconds)
5712{
5713 eina_error_set(0);
5714
5715 GET_EPR_OR_RETURN(EINA_FALSE);
5716
5717 //printf("GET TRANSITION_TIME for program: %s [%.4f]\n", prog, epr->tween.time);
5718 epr->tween.time = FROM_DOUBLE(seconds);
5719 return EINA_TRUE;
5720}
5721
5722EAPI Edje_Action_Type
5723edje_edit_program_action_get(Evas_Object *obj, const char *prog)
5724{
5725 eina_error_set(0);
5726
5727 GET_EPR_OR_RETURN(-1);
5728
5729 //printf("GET ACTION for program: %s [%d]\n", prog, epr->action);
5730 return epr->action;
5731}
5732
5733EAPI Eina_Bool
5734edje_edit_program_action_set(Evas_Object *obj, const char *prog, Edje_Action_Type action)
5735{
5736 Program_Script *ps;
5737
5738 eina_error_set(0);
5739
5740 GET_ED_OR_RETURN(EINA_FALSE);
5741 GET_EPR_OR_RETURN(EINA_FALSE);
5742
5743 //printf("SET ACTION for program: %s [%d]\n", prog, action);
5744 if (action >= EDJE_ACTION_TYPE_LAST) return EINA_FALSE;
5745
5746 if ((Edje_Action_Type)epr->action == action)
5747 return EINA_TRUE;
5748
5749 if (action == EDJE_ACTION_TYPE_SCRIPT)
5750 {
5751 ps = eina_hash_find(eed->program_scripts, &epr->id);
5752 if (!ps)
5753 {
5754 ps = _alloc(sizeof(Program_Script));
5755 if (!ps)
5756 return EINA_FALSE;
5757 }
5758 ps->id = epr->id;
5759 ps->code = strdup("");
5760 ps->dirty = EINA_TRUE;
5761 ps->delete_me = EINA_FALSE;
5762 eina_hash_set(eed->program_scripts, &ps->id, ps);
5763 _edje_edit_flag_script_dirty(eed, EINA_FALSE);
5764 }
5765 if (epr->action == EDJE_ACTION_TYPE_SCRIPT)
5766 {
5767 ps = eina_hash_find(eed->program_scripts, &epr->id);
5768 if (ps)
5769 {
5770 free(ps->code);
5771 free(ps->processed);
5772 ps->code = ps->processed = NULL;
5773 ps->dirty = EINA_FALSE;
5774 ps->delete_me = EINA_TRUE;
5775 _edje_edit_flag_script_dirty(eed, EINA_FALSE);
5776 }
5777 }
5778
5779 epr->action = action;
5780 return EINA_TRUE;
5781}
5782
5783EAPI Eina_List *
5784edje_edit_program_targets_get(Evas_Object *obj, const char *prog)
5785{
5786 Eina_List *l, *targets = NULL;
5787 Edje_Program_Target *t;
5788
5789 eina_error_set(0);
5790
5791 GET_ED_OR_RETURN(NULL);
5792 GET_EPR_OR_RETURN(NULL);
5793
5794 //printf("GET TARGETS for program: %s [count: %d]\n", prog, eina_list_count(epr->targets));
5795 EINA_LIST_FOREACH(epr->targets, l, t)
5796 {
5797 if (epr->action == EDJE_ACTION_TYPE_STATE_SET)
5798 {
5799 /* the target is a part */
5800 Edje_Real_Part *p = NULL;
5801
5802 p = ed->table_parts[t->id % ed->table_parts_size];
5803 if (p && p->part && p->part->name)
5804 targets = eina_list_append(targets,
5805 eina_stringshare_add(p->part->name));
5806 }
5807 else if (epr->action == EDJE_ACTION_TYPE_ACTION_STOP)
5808 {
5809 /* the target is a program */
5810 Edje_Program *p;
5811
5812 p = ed->table_programs[t->id % ed->table_programs_size];
5813 if (p && p->name)
5814 targets = eina_list_append(targets,
5815 eina_stringshare_add(p->name));
5816 }
5817 }
5818 return targets;
5819}
5820
5821EAPI Eina_Bool
5822edje_edit_program_targets_clear(Evas_Object *obj, const char *prog)
5823{
5824 eina_error_set(0);
5825
5826 GET_EPR_OR_RETURN(EINA_FALSE);
5827
5828 while (epr->targets)
5829 {
5830 Edje_Program_Target *prt;
5831
5832 prt = eina_list_data_get(epr->targets);
5833 epr->targets = eina_list_remove_list(epr->targets, epr->targets);
5834 free(prt);
5835 }
5836
5837 return EINA_TRUE;
5838}
5839
5840EAPI Eina_Bool
5841edje_edit_program_target_add(Evas_Object *obj, const char *prog, const char *target)
5842{
5843 int id;
5844 Edje_Program_Target *t;
5845
5846 eina_error_set(0);
5847
5848 GET_ED_OR_RETURN(EINA_FALSE);
5849 GET_EPR_OR_RETURN(EINA_FALSE);
5850
5851 if (epr->action == EDJE_ACTION_TYPE_STATE_SET)
5852 {
5853 /* the target is a part */
5854 Edje_Real_Part *rp;
5855
5856 rp = _edje_real_part_get(ed, target);
5857 if (!rp) return EINA_FALSE;
5858 id = rp->part->id;
5859 }
5860 else if (epr->action == EDJE_ACTION_TYPE_ACTION_STOP)
5861 {
5862 /* the target is a program */
5863 Edje_Program *tar;
5864
5865 tar = _edje_program_get_byname(obj, target);
5866 if (!tar) return EINA_FALSE;
5867 id = tar->id;
5868 }
5869 else
5870 return EINA_FALSE;
5871
5872 t = _alloc(sizeof(Edje_Program_Target));
5873 if (!t) return EINA_FALSE;
5874
5875 t->id = id;
5876 epr->targets = eina_list_append(epr->targets, t);
5877
5878 return EINA_TRUE;
5879}
5880
5881EAPI Eina_Bool
5882edje_edit_program_target_del(Evas_Object *obj, const char *prog, const char *target)
5883{
5884 int id;
5885 Eina_List *l;
5886 Edje_Program_Target *t;
5887
5888 eina_error_set(0);
5889
5890 GET_ED_OR_RETURN(EINA_FALSE);
5891 GET_EPR_OR_RETURN(EINA_FALSE);
5892
5893 if (epr->action == EDJE_ACTION_TYPE_STATE_SET)
5894 {
5895 /* the target is a part */
5896 Edje_Real_Part *rp;
5897
5898 rp = _edje_real_part_get(ed, target);
5899 if (!rp) return EINA_FALSE;
5900 id = rp->part->id;
5901 }
5902 else if (epr->action == EDJE_ACTION_TYPE_ACTION_STOP)
5903 {
5904 /* the target is a program */
5905 Edje_Program *tar;
5906
5907 tar = _edje_program_get_byname(obj, target);
5908 if (!tar) return EINA_FALSE;
5909 id = tar->id;
5910 }
5911 else
5912 return EINA_FALSE;
5913
5914 EINA_LIST_FOREACH(epr->targets, l, t)
5915 if (t->id == id)
5916 break;
5917 epr->targets = eina_list_remove_list(epr->targets, l);
5918 free(t);
5919
5920 return EINA_TRUE;
5921}
5922
5923EAPI Eina_List *
5924edje_edit_program_afters_get(Evas_Object *obj, const char *prog)
5925{
5926 Eina_List *l, *afters = NULL;
5927 Edje_Program_After *a;
5928
5929 eina_error_set(0);
5930
5931 GET_ED_OR_RETURN(NULL);
5932 GET_EPR_OR_RETURN(NULL);
5933
5934 // printf("GET AFTERS for program: %s [count: %d]\n", prog, eina_list_count(epr->after));
5935 EINA_LIST_FOREACH(epr->after, l, a)
5936 {
5937 Edje_Program *p = NULL;
5938
5939 p = ed->table_programs[a->id % ed->table_programs_size];
5940 if (p && p->name)
5941 {
5942 //printf(" a: %d name: %s\n", a->id, p->name);
5943 afters = eina_list_append(afters, eina_stringshare_add(p->name));
5944 }
5945 }
5946 return afters;
5947}
5948
5949EAPI Eina_Bool
5950edje_edit_program_afters_clear(Evas_Object *obj, const char *prog)
5951{
5952 eina_error_set(0);
5953
5954 GET_EPR_OR_RETURN(EINA_FALSE);
5955
5956 while (epr->after)
5957 {
5958 Edje_Program_After *pa;
5959
5960 pa = eina_list_data_get(epr->after);
5961 epr->after = eina_list_remove_list(epr->after, epr->after);
5962 free(pa);
5963 }
5964
5965 return EINA_TRUE;
5966}
5967
5968EAPI Eina_Bool
5969edje_edit_program_after_add(Evas_Object *obj, const char *prog, const char *after)
5970{
5971 Edje_Program *af;
5972 Edje_Program_After *a;
5973
5974 eina_error_set(0);
5975
5976 GET_EPR_OR_RETURN(EINA_FALSE);
5977
5978 af = _edje_program_get_byname(obj, after);
5979 if (!af) return EINA_FALSE;
5980
5981 a = _alloc(sizeof(Edje_Program_After));
5982 if (!a) return EINA_FALSE;
5983
5984 a->id = af->id;
5985
5986 epr->after = eina_list_append(epr->after, a);
5987
5988 return EINA_TRUE;
5989}
5990
5991EAPI Eina_Bool
5992edje_edit_program_after_del(Evas_Object *obj, const char *prog, const char *after)
5993{
5994 Edje_Program *af;
5995 Edje_Program_After *a;
5996 Eina_List *l;
5997
5998 eina_error_set(0);
5999
6000 GET_EPR_OR_RETURN(EINA_FALSE);
6001
6002 af = _edje_program_get_byname(obj, after);
6003 if (!af) return EINA_FALSE;
6004
6005 EINA_LIST_FOREACH(epr->after, l, a)
6006 if (a->id == af->id)
6007 {
6008 epr->after = eina_list_remove_list(epr->after, l);
6009 break;
6010 }
6011
6012 return EINA_TRUE;
6013}
6014
6015EAPI const char *
6016edje_edit_program_api_name_get(Evas_Object *obj, const char *prog)
6017{
6018 eina_error_set(0);
6019
6020 GET_EPR_OR_RETURN(NULL);
6021
6022 return eina_stringshare_add(epr->api.name);
6023}
6024
6025EAPI const char *
6026edje_edit_program_api_description_get(Evas_Object *obj, const char *prog)
6027{
6028 eina_error_set(0);
6029
6030 GET_EPR_OR_RETURN(NULL);
6031
6032 return eina_stringshare_add(epr->api.description);
6033}
6034
6035EAPI Eina_Bool
6036edje_edit_program_api_name_set(Evas_Object *obj, const char *prog, const char* name)
6037{
6038 eina_error_set(0);
6039
6040 GET_ED_OR_RETURN(EINA_FALSE);
6041 GET_EPR_OR_RETURN(EINA_FALSE);
6042
6043 _edje_if_string_free(ed, epr->api.name);
6044 epr->api.name = eina_stringshare_add(name);
6045
6046 return EINA_TRUE;
6047}
6048
6049EAPI Eina_Bool
6050edje_edit_program_api_description_set(Evas_Object *obj, const char *prog, const char *description)
6051{
6052 eina_error_set(0);
6053
6054 GET_ED_OR_RETURN(EINA_FALSE);
6055 GET_EPR_OR_RETURN(EINA_FALSE);
6056
6057 _edje_if_string_free(ed, epr->api.description);
6058 epr->api.description = eina_stringshare_add(description);
6059
6060 return EINA_TRUE;
6061}
6062
6063/*************************/
6064/* EMBRYO SCRIPTS API */
6065/*************************/
6066EAPI char *
6067edje_edit_script_get(Evas_Object *obj)
6068{
6069 eina_error_set(0);
6070
6071 GET_ED_OR_RETURN(NULL);
6072
6073 if (!ed->collection) return NULL;
6074 if (!eed->embryo_source) return NULL;
6075
6076 return strdup(eed->embryo_source);
6077}
6078
6079EAPI void
6080edje_edit_script_set(Evas_Object *obj, const char *code)
6081{
6082 eina_error_set(0);
6083
6084 GET_ED_OR_RETURN();
6085
6086 free(eed->embryo_source);
6087 free(eed->embryo_processed);
6088
6089 if (code)
6090 eed->embryo_source = strdup(code);
6091 else
6092 eed->embryo_source = NULL;
6093 eed->embryo_processed = NULL;
6094
6095 eed->embryo_source_dirty = EINA_TRUE;
6096
6097 _edje_edit_flag_script_dirty(eed, EINA_FALSE);
6098}
6099
6100EAPI char *
6101edje_edit_script_program_get(Evas_Object *obj, const char *prog)
6102{
6103 Program_Script *ps;
6104
6105 eina_error_set(0);
6106
6107 GET_ED_OR_RETURN(NULL);
6108 GET_EPR_OR_RETURN(NULL);
6109
6110 if (epr->action != EDJE_ACTION_TYPE_SCRIPT)
6111 return NULL;
6112
6113 ps = eina_hash_find(eed->program_scripts, prog);
6114 if (!ps) /* mmm? it should be there, even if empty */
6115 return NULL;
6116
6117 return ps->code ? strdup(ps->code) : NULL;
6118}
6119
6120EAPI void
6121edje_edit_script_program_set(Evas_Object *obj, const char *prog, const char *code)
6122{
6123 Program_Script *ps;
6124
6125 eina_error_set(0);
6126
6127 GET_ED_OR_RETURN();
6128 GET_EPR_OR_RETURN();
6129
6130 if (epr->action != EDJE_ACTION_TYPE_SCRIPT)
6131 return;
6132
6133 ps = eina_hash_find(eed->program_scripts, prog);
6134 if (!ps) /* ???? how so? */
6135 return;
6136
6137 free(ps->code);
6138 free(ps->processed);
6139
6140 if (code)
6141 ps->code = strdup(code);
6142 else
6143 ps->code = NULL;
6144 ps->processed = NULL;
6145 ps->dirty = EINA_TRUE;
6146
6147 _edje_edit_flag_script_dirty(eed, EINA_FALSE);
6148}
6149
6150static int
6151__part_replace(Edje_Edit *eed, char *pcode, char *name)
6152{
6153 int id;
6154
6155 id = _edje_part_id_find((Edje *)eed, name);
6156 if (id < 0)
6157 return 0;
6158 return eina_convert_itoa(id, pcode);
6159}
6160
6161static int
6162__program_replace(Edje_Edit *eed, char *pcode, char *name)
6163{
6164 int id;
6165
6166 id = _edje_program_id_find(eed, name);
6167 if (id < 0)
6168 return 0;
6169 return eina_convert_itoa(id, pcode);
6170}
6171
6172static int
6173__group_replace(Edje_Edit *eed __UNUSED__, char *pcode, char *name)
6174{
6175 strcpy(pcode, name);
6176 return strlen(name) + 1;
6177}
6178
6179static int
6180__image_replace(Edje_Edit *eed, char *pcode, char *name)
6181{
6182 int id;
6183
6184 id = _edje_image_id_find(eed, name);
6185 if (id < 0)
6186 return 0;
6187 return eina_convert_itoa(id, pcode);
6188}
6189
6190static char *
6191_edje_edit_script_process(Edje_Edit *eed, const char *progname, char *code)
6192{
6193 char *pcode, *psrc, *pdst;
6194 int codesize, pcodesize;
6195 int quoted = 0, escaped = 0;
6196 int line = 1;
6197 Eina_Bool success = EINA_TRUE;
6198
6199 codesize = strlen(code);
6200 pcode = malloc(codesize + 1);
6201 if (!pcode)
6202 return NULL;
6203
6204 pcodesize = 0;
6205 psrc = code;
6206 pdst = pcode;
6207 while (*psrc)
6208 {
6209 if (!quoted)
6210 {
6211 char *ptr = NULL;
6212 const char *what = NULL;
6213 int (*func)(Edje_Edit *, char *, char *);
6214
6215 if (*psrc == 'P')
6216 {
6217 if (!strncmp(psrc, "PART:\"", 6))
6218 {
6219 psrc += 6;
6220 ptr = psrc;
6221 func = __part_replace;
6222 what = "part";
6223 }
6224 else if (!strncmp(psrc, "PROGRAM:\"", 9))
6225 {
6226 psrc += 9;
6227 ptr = psrc;
6228 func = __program_replace;
6229 what = "program";
6230 }
6231 }
6232 else if (*psrc == 'G')
6233 {
6234 if (!strncmp(psrc, "GROUP:\"", 7))
6235 {
6236 psrc += 7;
6237 ptr = psrc;
6238 func = __group_replace;
6239 what = "group";
6240 }
6241 }
6242 else if (*psrc == 'I')
6243 {
6244 if (!strncmp(psrc, "IMAGE:\"", 7))
6245 {
6246 psrc += 7;
6247 ptr = psrc;
6248 func = __image_replace;
6249 what = "image";
6250 }
6251 }
6252 else if (*psrc == '#')
6253 {
6254 while (*psrc)
6255 if (*psrc == '\n')
6256 break;
6257 line++;
6258 continue;
6259 }
6260 else if (*psrc == '\"')
6261 quoted = 1;
6262 else if (*psrc == '\n')
6263 line++;
6264
6265 if (ptr)
6266 {
6267 int i = 0, inesc = 0;
6268 char *name;
6269 while (*psrc)
6270 {
6271 if (!inesc)
6272 {
6273 if (*psrc == '\\')
6274 inesc = 1;
6275 else if (*psrc == '\"')
6276 {
6277 /* string concatenation as in "foo""bar" */
6278 if (*(psrc + 1) != '\"')
6279 {
6280 psrc++;
6281 break;
6282 }
6283 else
6284 psrc++;
6285 }
6286 }
6287 else
6288 inesc = 0;
6289 psrc++;
6290 }
6291 name = alloca(psrc - ptr);
6292 inesc = 0;
6293 while (*ptr)
6294 {
6295 if (!inesc)
6296 {
6297 if (*ptr == '\\')
6298 inesc = 1;
6299 else if (*ptr == '\"')
6300 {
6301 if (*(ptr + 1) == '\"')
6302 ptr++;
6303 else
6304 {
6305 name[i] = 0;
6306 break;
6307 }
6308 }
6309 else
6310 {
6311 name[i] = *ptr;
6312 name[i + 1] = 0;
6313 i++;
6314 }
6315 }
6316 else
6317 inesc = 0;
6318 ptr++;
6319 }
6320 i = func(eed, pdst, name);
6321 if (!i)
6322 {
6323 Edje_Edit_Script_Error *se;
6324 se = malloc(sizeof(Edje_Edit_Script_Error));
6325 se->program_name = progname ?
6326 eina_stringshare_add(progname) : NULL;
6327 se->line = line;
6328 se->error_str = eina_stringshare_printf(
6329 "Referenced %s '%s' could not be found in object.",
6330 what, name);
6331 eed->errors = eina_list_append(eed->errors, se);
6332 success = EINA_FALSE;
6333 }
6334 else
6335 {
6336 pcodesize += i;
6337 pdst += i;
6338 }
6339 /* replaced reference for the right value, now go
6340 * to the next iteration */
6341 continue;
6342 }
6343 }
6344 else
6345 {
6346 if (!escaped)
6347 {
6348 if (*psrc == '\"')
6349 quoted = 0;
6350 else if (*psrc == '\\')
6351 escaped = 1;
6352 }
6353 else if (escaped)
6354 escaped = 0;
6355 }
6356 *pdst = *psrc;
6357 pdst++;
6358 psrc++;
6359 pcodesize++;
6360 }
6361
6362 if (!success)
6363 {
6364 free(pcode);
6365 return NULL;
6366 }
6367
6368 if (pcodesize < codesize)
6369 pcode = realloc(pcode, pcodesize + 1);
6370 pcode[pcodesize] = 0;
6371
6372 return pcode;
6373}
6374
6375static Eina_Bool
6376_edje_edit_embryo_rebuild(Edje_Edit *eed)
6377{
6378 FILE *f;
6379 int fd, size, ret;
6380 const char *tmp_dir;
6381 char tmp_in[PATH_MAX];
6382 char tmp_out[PATH_MAX];
6383 char buf[4096];
6384 Eina_Iterator *it;
6385 Program_Script *ps;
6386 Edje_Part_Collection *edc;
6387 Eina_Bool success = EINA_TRUE; /* we are optimists! */
6388 Edje_Edit_Script_Error *se;
6389
6390 EINA_LIST_FREE(eed->errors, se)
6391 {
6392 eina_stringshare_del(se->program_name);
6393 eina_stringshare_del(se->error_str);
6394 free(se);
6395 }
6396
6397#ifdef HAVE_EVIL
6398 tmp_dir = evil_tmpdir_get();
6399#else
6400 tmp_dir = "/tmp";
6401#endif
6402
6403 snprintf(tmp_in, sizeof(tmp_in), "%s/edje_edit.sma-tmp-XXXXXX", tmp_dir);
6404 snprintf(tmp_out, sizeof(tmp_out), "%s/edje_edit.amx-tmp-XXXXXX", tmp_dir);
6405
6406 fd = mkstemp(tmp_in);
6407 if (fd < 0)
6408 return EINA_FALSE; /* FIXME: report something */
6409
6410 f = fdopen(fd, "w");
6411 if (!f)
6412 {
6413 close(fd);
6414 unlink(tmp_in);
6415 return EINA_FALSE;
6416 }
6417
6418 fprintf(f, "#include <edje>\n");
6419 if (eed->embryo_source)
6420 {
6421 if (eed->all_dirty)
6422 {
6423 free(eed->embryo_processed);
6424 eed->embryo_processed = NULL;
6425 }
6426 if (!eed->embryo_processed)
6427 eed->embryo_processed = _edje_edit_script_process(eed, NULL,
6428 eed->embryo_source);
6429 if (!eed->embryo_processed)
6430 {
6431 /* oops.. an error finding references parts or something.
6432 * we could flag it and do some lighter processing of the
6433 * rest of the scripts, in order to find all the errors of
6434 * this kind and report them at once, but knowing already
6435 * that the script will not compile we can avoid some work
6436 */
6437 success = EINA_FALSE;
6438 }
6439 else
6440 fprintf(f, "%s", eed->embryo_processed);
6441 }
6442
6443 it = eina_hash_iterator_data_new(eed->program_scripts);
6444 EINA_ITERATOR_FOREACH(it, ps)
6445 {
6446 Edje_Program *epr;
6447
6448 if (ps->delete_me)
6449 continue;
6450 if (eed->all_dirty)
6451 {
6452 free(ps->processed);
6453 ps->processed = NULL;
6454 }
6455 epr = eed->base.table_programs[ps->id];
6456 if (!ps->processed)
6457 ps->processed = _edje_edit_script_process(eed, epr->name, ps->code);
6458 if (!ps->processed)
6459 {
6460 /* oops.. an error finding references parts or something.
6461 * we could flag it and do some lighter processing of the
6462 * rest of the scripts, in order to find all the errors of
6463 * this kind and report them at once, but knowing already
6464 * that the script will not compile we can avoid some work
6465 */
6466 success = EINA_FALSE;
6467 continue;
6468 }
6469 fprintf(f, "public _p%i(sig[], src[]) {\n", ps->id);
6470 fprintf(f, "%s", ps->processed);
6471 fprintf(f, "}\n");
6472 }
6473 eina_iterator_free(it);
6474
6475 fclose(f);
6476
6477 if (!success)
6478 goto almost_out;
6479
6480 fd = mkstemp(tmp_out);
6481 if (fd < 0)
6482 {
6483 success = EINA_FALSE;
6484 goto almost_out;
6485 }
6486
6487 snprintf(buf, sizeof(buf), "embryo_cc -i %s/include -o %s %s",
6488 PACKAGE_DATA_DIR, tmp_out, tmp_in);
6489 ret = system(buf);
6490
6491 if ((ret < 0) || (ret > 1))
6492 {
6493 success = EINA_FALSE;
6494 close(fd);
6495 goto the_doorway;
6496 }
6497
6498 f = fdopen(fd, "rb");
6499 if (!f)
6500 {
6501 success = EINA_FALSE;
6502 close(fd);
6503 goto the_doorway;
6504 }
6505
6506 fseek(f, 0, SEEK_END);
6507 size = ftell(f);
6508 rewind(f);
6509
6510 free(eed->bytecode);
6511 if (size > 0)
6512 {
6513 eed->bytecode = malloc(size);
6514 if (!eed->bytecode)
6515 {
6516 success = EINA_FALSE;
6517 goto the_way_out;
6518 }
6519 if (fread(eed->bytecode, size, 1, f) != 1)
6520 {
6521 success = EINA_FALSE;
6522 goto the_way_out;
6523 }
6524 }
6525 else
6526 eed->bytecode = NULL; /* correctness mostly, I don't see why we
6527 would get a 0 sized program */
6528
6529 eed->bytecode_size = size;
6530 eed->bytecode_dirty = EINA_TRUE;
6531 eed->script_need_recompile = EINA_FALSE;
6532 eed->all_dirty = EINA_FALSE;
6533
6534 edc = eed->base.collection;
6535 embryo_program_free(edc->script);
6536 edc->script = embryo_program_new(eed->bytecode, eed->bytecode_size);
6537 _edje_embryo_script_init(edc);
6538 _edje_var_init((Edje *)eed);
6539
6540the_way_out:
6541 fclose(f);
6542the_doorway:
6543 unlink(tmp_out);
6544almost_out:
6545 unlink(tmp_in);
6546
6547 return success;
6548}
6549
6550EAPI Eina_Bool
6551edje_edit_script_compile(Evas_Object *obj)
6552{
6553 GET_ED_OR_RETURN(EINA_FALSE);
6554
6555 if (!eed->script_need_recompile)
6556 return EINA_TRUE;
6557
6558 return _edje_edit_embryo_rebuild(eed);
6559}
6560
6561EAPI const Eina_List *
6562edje_edit_script_error_list_get(Evas_Object *obj)
6563{
6564 GET_ED_OR_RETURN(NULL);
6565 return eed->errors;
6566}
6567
6568/***************************/
6569/* EDC SOURCE GENERATION */
6570/***************************/
6571#define I0 ""
6572#define I1 " "
6573#define I2 " "
6574#define I3 " "
6575#define I4 " "
6576#define I5 " "
6577#define I6 " "
6578#define I7 " "
6579
6580#define BUF_APPEND(STR) \
6581 ret &= eina_strbuf_append(buf, STR)
6582
6583#define BUF_APPENDF(FMT, ...) \
6584 ret &= eina_strbuf_append_printf(buf, FMT, ##__VA_ARGS__)
6585
6586static const char *types[] = {"NONE", "RECT", "TEXT", "IMAGE", "SWALLOW", "TEXTBLOCK", "GRADIENT", "GROUP", "BOX", "TABLE", "EXTERNAL"};
6587static const char *effects[] = {"NONE", "PLAIN", "OUTLINE", "SOFT_OUTLINE", "SHADOW", "SOFT_SHADOW", "OUTLINE_SHADOW", "OUTLINE_SOFT_SHADOW ", "FAR_SHADOW ", "FAR_SOFT_SHADOW", "GLOW"};
6588static const char *prefers[] = {"NONE", "VERTICAL", "HORIZONTAL", "BOTH"};
6589
6590 static Eina_Bool
6591_edje_generate_source_of_colorclass(Edje * ed, const char *name, Eina_Strbuf *buf)
6592{
6593 Eina_List *l;
6594 Edje_Color_Class *cc;
6595 Eina_Bool ret = EINA_TRUE;
6596
6597 EINA_LIST_FOREACH(ed->file->color_classes, l, cc)
6598 if (!strcmp(cc->name, name))
6599 {
6600 BUF_APPENDF(I1 "color_class { name: \"%s\";\n", cc->name);
6601 BUF_APPENDF(I2 "color: %d %d %d %d;\n", cc->r, cc->g, cc->b, cc->a);
6602 BUF_APPENDF(I2 "color2: %d %d %d %d;\n", cc->r2, cc->g2, cc->b2, cc->a2);
6603 BUF_APPENDF(I2 "color3: %d %d %d %d;\n", cc->r3, cc->g3, cc->b3, cc->a3);
6604 BUF_APPEND(I1 "}\n");
6605 }
6606 return ret;
6607}
6608
6609 static Eina_Bool
6610_edje_generate_source_of_style(Edje * ed, const char *name, Eina_Strbuf *buf)
6611{
6612 Eina_List *l, *ll;
6613 Edje_Style *s;
6614 Edje_Style_Tag *t;
6615 Eina_Bool ret = EINA_TRUE;
6616
6617 EINA_LIST_FOREACH(ed->file->styles, l, s)
6618 if (!strcmp(s->name, name))
6619 {
6620 t = s->tags ? s->tags->data : NULL;
6621 BUF_APPENDF(I1 "style { name:\"%s\";\n", s->name);
6622 if (t && t->value)
6623 BUF_APPENDF(I2 "base: \"%s\";\n", t->value);
6624
6625 EINA_LIST_FOREACH(s->tags, ll, t)
6626 if (ll->prev && t && t->value)
6627 BUF_APPENDF(I2 "tag: \"%s\" \"%s\";\n", t->key,
6628 t->value);
6629 BUF_APPEND(I1 "}\n");
6630 return ret;
6631 }
6632 return EINA_FALSE;
6633}
6634
6635static Eina_Bool
6636_edje_generate_source_of_program(Evas_Object *obj, const char *program, Eina_Strbuf *buf)
6637{
6638 Eina_List *l, *ll;
6639 const char *s, *s2;
6640 double db, db2;
6641 char *data;
6642 Eina_Bool ret = EINA_TRUE;
6643 const char *api_name, *api_description;
6644 Edje_Program *epr;
6645
6646 GET_ED_OR_RETURN(EINA_FALSE);
6647
6648 epr = _edje_program_get_byname(obj, program);
6649
6650 BUF_APPENDF(I3"program { name: \"%s\";\n", program);
6651
6652 /* Signal */
6653 if ((s = edje_edit_program_signal_get(obj, program)))
6654 {
6655 BUF_APPENDF(I4"signal: \"%s\";\n", s);
6656 edje_edit_string_free(s);
6657 }
6658
6659 /* Source */
6660 if ((s = edje_edit_program_source_get(obj, program)))
6661 {
6662 BUF_APPENDF(I4"source: \"%s\";\n", s);
6663 edje_edit_string_free(s);
6664 }
6665
6666 /* Action */
6667 switch (edje_edit_program_action_get(obj, program))
6668 {
6669 case EDJE_ACTION_TYPE_ACTION_STOP:
6670 BUF_APPEND(I4"action: ACTION_STOP;\n");
6671 break;
6672 case EDJE_ACTION_TYPE_STATE_SET:
6673 if ((s = edje_edit_program_state_get(obj, program)))
6674 {
6675 BUF_APPENDF(I4"action: STATE_SET \"%s\" %.2f;\n", s,
6676 edje_edit_program_value_get(obj, program));
6677 edje_edit_string_free(s);
6678 }
6679 break;
6680 case EDJE_ACTION_TYPE_SIGNAL_EMIT:
6681 s = edje_edit_program_state_get(obj, program);
6682 s2 = edje_edit_program_state2_get(obj, program);
6683 if (s && s2)
6684 {
6685 BUF_APPENDF(I4"action: SIGNAL_EMIT \"%s\" \"%s\";\n", s, s2);
6686 edje_edit_string_free(s);
6687 edje_edit_string_free(s2);
6688 }
6689 break;
6690 case EDJE_ACTION_TYPE_SCRIPT:
6691 {
6692 Program_Script *ps;
6693
6694 ps = eina_hash_find(eed->program_scripts, &epr->id);
6695 if (ps && !ps->delete_me)
6696 {
6697 BUF_APPEND(I4"script {\n");
6698 BUF_APPEND(ps->code);
6699 BUF_APPEND(I4"}\n");
6700 }
6701 }
6702 break;
6703 //TODO Support Drag
6704 //~ case EDJE_ACTION_TYPE_DRAG_VAL_SET:
6705 //~ eina_strbuf_append(buf, I4"action: DRAG_VAL_SET TODO;\n");
6706 //~ break;
6707 //~ case EDJE_ACTION_TYPE_DRAG_VAL_STEP:
6708 //~ eina_strbuf_append(buf, I4"action: DRAG_VAL_STEP TODO;\n");
6709 //~ break;
6710 //~ case EDJE_ACTION_TYPE_DRAG_VAL_PAGE:
6711 //~ eina_strbuf_append(buf, I4"action: DRAG_VAL_PAGE TODO;\n");
6712 //~ break;
6713 default:
6714 break;
6715 }
6716
6717 /* Transition */
6718 db = edje_edit_program_transition_time_get(obj, program);
6719 switch (edje_edit_program_transition_get(obj, program))
6720 {
6721 case EDJE_TWEEN_MODE_LINEAR:
6722 if (db)
6723 BUF_APPENDF(I4"transition: LINEAR %.5f;\n", db);
6724 break;
6725 case EDJE_TWEEN_MODE_ACCELERATE:
6726 BUF_APPENDF(I4"transition: ACCELERATE %.5f;\n", db);
6727 break;
6728 case EDJE_TWEEN_MODE_DECELERATE:
6729 BUF_APPENDF(I4"transition: DECELERATE %.5f;\n", db);
6730 break;
6731 case EDJE_TWEEN_MODE_SINUSOIDAL:
6732 BUF_APPENDF(I4"transition: SINUSOIDAL %.5f;\n", db);
6733 break;
6734 default:
6735 break;
6736 }
6737
6738 /* In */
6739 db = edje_edit_program_in_from_get(obj, program);
6740 db2 = edje_edit_program_in_range_get(obj, program);
6741 if (db || db2)
6742 BUF_APPENDF(I4"in: %.5f %.5f;\n", db, db2);
6743
6744 /* Targets */
6745 if ((ll = edje_edit_program_targets_get(obj, program)))
6746 {
6747 EINA_LIST_FOREACH(ll, l, data)
6748 BUF_APPENDF(I4"target: \"%s\";\n", data);
6749 edje_edit_string_list_free(ll);
6750 }
6751
6752 /* Afters */
6753 if ((ll = edje_edit_program_afters_get(obj, program)))
6754 {
6755 EINA_LIST_FOREACH(ll, l, data)
6756 BUF_APPENDF(I4"after: \"%s\";\n", data);
6757 edje_edit_string_list_free(ll);
6758 }
6759
6760 // TODO Support script {}
6761 /* api */
6762 api_name = edje_edit_program_api_name_get(obj, program);
6763 api_description = edje_edit_program_api_description_get(obj, program);
6764
6765 if (api_name || api_description)
6766 {
6767 if (api_name && api_description)
6768 {
6769 BUF_APPENDF(I4"api: \"%s\" \"%s\";\n", api_name, api_description);
6770 edje_edit_string_free(api_name);
6771 edje_edit_string_free(api_description);
6772 }
6773 else
6774 if (api_name)
6775 {
6776 BUF_APPENDF(I4"api: \"%s\" \"\";\n", api_name);
6777 edje_edit_string_free(api_name);
6778 }
6779 else
6780 {
6781 BUF_APPENDF(I4"api: \"\" \"%s\";\n", api_description);
6782 edje_edit_string_free(api_description);
6783 }
6784 }
6785
6786 BUF_APPEND(I3 "}\n");
6787 return ret;
6788}
6789
6790static Eina_Bool
6791_edje_generate_source_of_state(Evas_Object *obj, const char *part, const char *state, double value, Eina_Strbuf *buf)
6792{
6793 Eina_List *l, *ll;
6794 Eina_Bool ret = EINA_TRUE;
6795
6796 GET_PD_OR_RETURN(EINA_FALSE);
6797
6798 BUF_APPENDF(I4"description { state: \"%s\" %g;\n", pd->state.name, pd->state.value);
6799 //TODO Support inherit
6800
6801 if (!pd->visible)
6802 BUF_APPEND(I5"visible: 0;\n");
6803
6804 if (pd->align.x != 0.5 || pd->align.y != 0.5)
6805 BUF_APPENDF(I5"align: %g %g;\n", TO_DOUBLE(pd->align.x), TO_DOUBLE(pd->align.y));
6806
6807 //TODO Support fixed
6808
6809 if (pd->min.w || pd->min.h)
6810 BUF_APPENDF(I5"min: %d %d;\n", pd->min.w, pd->min.h);
6811 if (pd->max.w != -1 || pd->max.h != -1)
6812 BUF_APPENDF(I5"max: %d %d;\n", pd->max.w, pd->max.h);
6813
6814 //TODO Support step
6815
6816 if (pd->aspect.min || pd->aspect.max)
6817 BUF_APPENDF(I5"aspect: %g %g;\n", TO_DOUBLE(pd->aspect.min), TO_DOUBLE(pd->aspect.max));
6818 if (pd->aspect.prefer)
6819 BUF_APPENDF(I5"aspect_preference: %s;\n", prefers[pd->aspect.prefer]);
6820
6821 if (pd->color_class)
6822 BUF_APPENDF(I5"color_class: \"%s\";\n", pd->color_class);
6823
6824 if (pd->color.r != 255 || pd->color.g != 255 ||
6825 pd->color.b != 255 || pd->color.a != 255)
6826 BUF_APPENDF(I5"color: %d %d %d %d;\n",
6827 pd->color.r, pd->color.g, pd->color.b, pd->color.a);
6828 if (pd->color2.r != 0 || pd->color2.g != 0 ||
6829 pd->color2.b != 0 || pd->color2.a != 255)
6830 BUF_APPENDF(I5"color2: %d %d %d %d;\n",
6831 pd->color2.r, pd->color2.g, pd->color2.b, pd->color2.a);
6832
6833 if (rp->part->type == EDJE_PART_TYPE_TEXT
6834 || rp->part->type == EDJE_PART_TYPE_TEXTBLOCK)
6835 {
6836 Edje_Part_Description_Text *txt;
6837
6838 txt = (Edje_Part_Description_Text *) pd;
6839
6840 if (txt->text.color3.r != 0 || txt->text.color3.g != 0 ||
6841 txt->text.color3.b != 0 || txt->text.color3.a != 128)
6842 BUF_APPENDF(I5"color3: %d %d %d %d;\n",
6843 txt->text.color3.r, txt->text.color3.g, txt->text.color3.b, txt->text.color3.a);
6844 }
6845
6846 //Rel1
6847 if (pd->rel1.relative_x || pd->rel1.relative_y || pd->rel1.offset_x ||
6848 pd->rel1.offset_y || pd->rel1.id_x != -1 || pd->rel1.id_y != -1)
6849 {
6850 BUF_APPEND(I5"rel1 {\n");
6851 if (pd->rel1.relative_x || pd->rel1.relative_y)
6852 BUF_APPENDF(I6"relative: %g %g;\n", TO_DOUBLE(pd->rel1.relative_x), TO_DOUBLE(pd->rel1.relative_y));
6853 if (pd->rel1.offset_x || pd->rel1.offset_y)
6854 BUF_APPENDF(I6"offset: %d %d;\n", pd->rel1.offset_x, pd->rel1.offset_y);
6855 if (pd->rel1.id_x != -1 && pd->rel1.id_x == pd->rel1.id_y)
6856 BUF_APPENDF(I6"to: \"%s\";\n", ed->table_parts[pd->rel1.id_x]->part->name);
6857 else
6858 {
6859 if (pd->rel1.id_x != -1)
6860 BUF_APPENDF(I6"to_x: \"%s\";\n", ed->table_parts[pd->rel1.id_x]->part->name);
6861 if (pd->rel1.id_y != -1)
6862 BUF_APPENDF(I6"to_y: \"%s\";\n", ed->table_parts[pd->rel1.id_y]->part->name);
6863 }
6864 BUF_APPEND(I5"}\n");//rel1
6865 }
6866
6867 //Rel2
6868 if (pd->rel2.relative_x != 1.0 || pd->rel2.relative_y != 1.0 ||
6869 pd->rel2.offset_x != -1 || pd->rel2.offset_y != -1 ||
6870 pd->rel2.id_x != -1 || pd->rel2.id_y != -1)
6871 {
6872 BUF_APPEND(I5"rel2 {\n");
6873 if (TO_DOUBLE(pd->rel2.relative_x) != 1.0 || TO_DOUBLE(pd->rel2.relative_y) != 1.0)
6874 BUF_APPENDF(I6"relative: %g %g;\n", TO_DOUBLE(pd->rel2.relative_x), TO_DOUBLE(pd->rel2.relative_y));
6875 if (pd->rel2.offset_x != -1 || pd->rel2.offset_y != -1)
6876 BUF_APPENDF(I6"offset: %d %d;\n", pd->rel2.offset_x, pd->rel2.offset_y);
6877 if (pd->rel2.id_x != -1 && pd->rel2.id_x == pd->rel2.id_y)
6878 BUF_APPENDF(I6"to: \"%s\";\n", ed->table_parts[pd->rel2.id_x]->part->name);
6879 else
6880 {
6881 if (pd->rel2.id_x != -1)
6882 BUF_APPENDF(I6"to_x: \"%s\";\n", ed->table_parts[pd->rel2.id_x]->part->name);
6883 if (pd->rel2.id_y != -1)
6884 BUF_APPENDF(I6"to_y: \"%s\";\n", ed->table_parts[pd->rel2.id_y]->part->name);
6885 }
6886 BUF_APPEND(I5"}\n");//rel2
6887 }
6888
6889 //Image
6890 if (rp->part->type == EDJE_PART_TYPE_IMAGE)
6891 {
6892 char *data;
6893 const char *image_name;
6894
6895 Edje_Part_Description_Image *img;
6896
6897 img = (Edje_Part_Description_Image *) pd;
6898
6899 BUF_APPEND(I5"image {\n");
6900
6901 image_name = _edje_image_name_find(eed, img->image.id);
6902 if (image_name)
6903 BUF_APPENDF(I6"normal: \"%s\";\n", image_name);
6904
6905 ll = edje_edit_state_tweens_list_get(obj, part, state, value);
6906 EINA_LIST_FOREACH(ll, l, data)
6907 BUF_APPENDF(I6"tween: \"%s\";\n", data);
6908 edje_edit_string_list_free(ll);
6909
6910 if (img->image.border.l || img->image.border.r || img->image.border.t || img->image.border.b)
6911 BUF_APPENDF(I6"border: %d %d %d %d;\n", img->image.border.l, img->image.border.r, img->image.border.t, img->image.border.b);
6912 if (img->image.border.no_fill == 1)
6913 BUF_APPEND(I6"middle: NONE;\n");
6914 else if (img->image.border.no_fill == 0)
6915 BUF_APPEND(I6"middle: DEFAULT;\n");
6916 else if (img->image.border.no_fill == 2)
6917 BUF_APPEND(I6"middle: SOLID;\n");
6918
6919 BUF_APPEND(I5"}\n");//image
6920
6921 //Fill
6922
6923 BUF_APPEND(I5"fill {\n");
6924 if (!img->image.fill.smooth)
6925 BUF_APPEND(I6"smooth: 0;\n");
6926 //TODO Support spread
6927
6928 if (img->image.fill.pos_rel_x || img->image.fill.pos_rel_y ||
6929 img->image.fill.pos_abs_x || img->image.fill.pos_abs_y)
6930 {
6931 BUF_APPEND(I6"origin {\n");
6932 if (img->image.fill.pos_rel_x || img->image.fill.pos_rel_y)
6933 BUF_APPENDF(I7"relative: %g %g;\n", TO_DOUBLE(img->image.fill.pos_rel_x), TO_DOUBLE(img->image.fill.pos_rel_y));
6934 if (img->image.fill.pos_abs_x || img->image.fill.pos_abs_y)
6935 BUF_APPENDF(I7"offset: %d %d;\n", img->image.fill.pos_abs_x, img->image.fill.pos_abs_y);
6936 BUF_APPEND(I6"}\n");
6937 }
6938
6939 if (TO_DOUBLE(img->image.fill.rel_x) != 1.0 || TO_DOUBLE(img->image.fill.rel_y) != 1.0 ||
6940 img->image.fill.abs_x || img->image.fill.abs_y)
6941 {
6942 BUF_APPEND(I6"size {\n");
6943 if (img->image.fill.rel_x != 1.0 || img->image.fill.rel_y != 1.0)
6944 BUF_APPENDF(I7"relative: %g %g;\n", TO_DOUBLE(img->image.fill.rel_x), TO_DOUBLE(img->image.fill.rel_y));
6945 if (img->image.fill.abs_x || img->image.fill.abs_y)
6946 BUF_APPENDF(I7"offset: %d %d;\n", img->image.fill.abs_x, img->image.fill.abs_y);
6947 BUF_APPEND(I6"}\n");
6948 }
6949
6950 BUF_APPEND(I5"}\n");
6951 }
6952
6953 if (rp->part->type == EDJE_PART_TYPE_PROXY)
6954 {
6955 Edje_Part_Description_Proxy *pro;
6956
6957 pro = (Edje_Part_Description_Proxy *) pd;
6958
6959 //Fill
6960
6961 BUF_APPEND(I5"fill {\n");
6962 if (!pro->proxy.fill.smooth)
6963 BUF_APPEND(I6"smooth: 0;\n");
6964 //TODO Support spread
6965 //TODO Support source
6966
6967 if (pro->proxy.fill.pos_rel_x || pro->proxy.fill.pos_rel_y ||
6968 pro->proxy.fill.pos_abs_x || pro->proxy.fill.pos_abs_y)
6969 {
6970 BUF_APPEND(I6"origin {\n");
6971 if (pro->proxy.fill.pos_rel_x || pro->proxy.fill.pos_rel_y)
6972 BUF_APPENDF(I7"relative: %g %g;\n", TO_DOUBLE(pro->proxy.fill.pos_rel_x), TO_DOUBLE(pro->proxy.fill.pos_rel_y));
6973 if (pro->proxy.fill.pos_abs_x || pro->proxy.fill.pos_abs_y)
6974 BUF_APPENDF(I7"offset: %d %d;\n", pro->proxy.fill.pos_abs_x, pro->proxy.fill.pos_abs_y);
6975 BUF_APPEND(I6"}\n");
6976 }
6977
6978 if (TO_DOUBLE(pro->proxy.fill.rel_x) != 1.0 || TO_DOUBLE(pro->proxy.fill.rel_y) != 1.0 ||
6979 pro->proxy.fill.abs_x || pro->proxy.fill.abs_y)
6980 {
6981 BUF_APPEND(I6"size {\n");
6982 if (pro->proxy.fill.rel_x != 1.0 || pro->proxy.fill.rel_y != 1.0)
6983 BUF_APPENDF(I7"relative: %g %g;\n", TO_DOUBLE(pro->proxy.fill.rel_x), TO_DOUBLE(pro->proxy.fill.rel_y));
6984 if (pro->proxy.fill.abs_x || pro->proxy.fill.abs_y)
6985 BUF_APPENDF(I7"offset: %d %d;\n", pro->proxy.fill.abs_x, pro->proxy.fill.abs_y);
6986 BUF_APPEND(I6"}\n");
6987 }
6988
6989 BUF_APPEND(I5"}\n");
6990 }
6991
6992 //Text
6993 if (rp->part->type == EDJE_PART_TYPE_TEXT)
6994 {
6995 Edje_Part_Description_Text *txt;
6996
6997 txt = (Edje_Part_Description_Text *) pd;
6998
6999 BUF_APPEND(I5"text {\n");
7000 if (edje_string_get(&txt->text.text))
7001 {
7002 if (txt->text.text.id)
7003 BUF_APPENDF(I6"text: _(\"%s\");\n", edje_string_id_get(&txt->text.text));
7004 else
7005 BUF_APPENDF(I6"text: \"%s\";\n", edje_string_get(&txt->text.text));
7006 }
7007 if (edje_string_get(&txt->text.font))
7008 {
7009 if (txt->text.font.id)
7010 BUF_APPENDF(I6"font: _(\"%s\");\n", edje_string_id_get(&txt->text.font));
7011 else
7012 BUF_APPENDF(I6"font: \"%s\";\n", edje_string_get(&txt->text.font));
7013 }
7014 if (txt->text.size)
7015 BUF_APPENDF(I6"size: %d;\n", txt->text.size);
7016 if (txt->text.text_class)
7017 BUF_APPENDF(I6"text_class: \"%s\";\n", txt->text.text_class);
7018 if (txt->text.fit_x || txt->text.fit_y)
7019 BUF_APPENDF(I6"fit: %d %d;\n", txt->text.fit_x, txt->text.fit_y);
7020 //TODO Support min & max
7021 if (TO_DOUBLE(txt->text.align.x) != 0.5 || TO_DOUBLE(txt->text.align.y) != 0.5)
7022 BUF_APPENDF(I6"align: %g %g;\n", TO_DOUBLE(txt->text.align.x), TO_DOUBLE(txt->text.align.y));
7023 //TODO Support source
7024 //TODO Support text_source
7025 if (txt->text.elipsis)
7026 BUF_APPENDF(I6"elipsis: %g;\n", txt->text.elipsis);
7027 BUF_APPEND(I5"}\n");
7028 }
7029
7030 //External
7031 if (rp->part->type == EDJE_PART_TYPE_EXTERNAL)
7032 {
7033 if ((ll = (Eina_List *)edje_edit_state_external_params_list_get(obj, part, state, value)))
7034 {
7035 Edje_External_Param *p;
7036
7037 BUF_APPEND(I5"params {\n");
7038 EINA_LIST_FOREACH(ll, l, p)
7039 {
7040 switch (p->type)
7041 {
7042 case EDJE_EXTERNAL_PARAM_TYPE_INT:
7043 BUF_APPENDF(I6"int: \"%s\" \"%d\";\n", p->name, p->i);
7044 break;
7045 case EDJE_EXTERNAL_PARAM_TYPE_DOUBLE:
7046 BUF_APPENDF(I6"double: \"%s\" \"%g\";\n", p->name, p->d);
7047 break;
7048 case EDJE_EXTERNAL_PARAM_TYPE_STRING:
7049 if (p->s)
7050 BUF_APPENDF(I6"string: \"%s\" \"%s\";\n", p->name,
7051 p->s);
7052 break;
7053 case EDJE_EXTERNAL_PARAM_TYPE_BOOL:
7054 BUF_APPENDF(I6"bool: \"%s\" \"%d\";\n", p->name, p->i);
7055 break;
7056 case EDJE_EXTERNAL_PARAM_TYPE_CHOICE:
7057 if (p->s)
7058 BUF_APPENDF(I6"choice: \"%s\" \"%s\";\n", p->name,
7059 p->s);
7060 break;
7061 default:
7062 break;
7063 }
7064 }
7065 BUF_APPEND(I5"}\n");
7066 }
7067 }
7068
7069 BUF_APPEND(I4"}\n");//description
7070 return ret;
7071}
7072
7073static Eina_Bool
7074_edje_generate_source_of_part(Evas_Object *obj, Edje_Part *ep, Eina_Strbuf *buf)
7075{
7076 const char *part = ep->name;
7077 const char *str;
7078 Eina_List *l, *ll;
7079 char *data;
7080 Eina_Bool ret = EINA_TRUE;
7081 const char *api_name, *api_description;
7082
7083 BUF_APPENDF(I3"part { name: \"%s\";\n", part);
7084 BUF_APPENDF(I4"type: %s;\n", types[edje_edit_part_type_get(obj, part)]);
7085 if (!edje_edit_part_mouse_events_get(obj, part))
7086 BUF_APPEND(I4"mouse_events: 0;\n");
7087 if (edje_edit_part_repeat_events_get(obj, part))
7088 BUF_APPEND(I4"repeat_events: 1;\n");
7089 if (edje_edit_part_scale_get(obj, part))
7090 BUF_APPEND(I4"scale: 1;\n");
7091 //TODO Support ignore_flags
7092 //TODO Support pointer_mode
7093 //TODO Support precise_is_inside
7094 //TODO Support use_alternate_font_metrics
7095 if ((str = edje_edit_part_clip_to_get(obj, part)))
7096 {
7097 BUF_APPENDF(I4"clip_to: \"%s\";\n", str);
7098 edje_edit_string_free(str);
7099 }
7100 if ((str = edje_edit_part_source_get(obj, part)))
7101 {
7102 BUF_APPENDF(I4"source: \"%s\";\n", str);
7103 edje_edit_string_free(str);
7104 }
7105 if (edje_edit_part_effect_get(obj, part))
7106 BUF_APPENDF(I4"effect: %s;\n",
7107 effects[edje_edit_part_effect_get(obj, part)]);
7108
7109 //Dragable
7110 if (edje_edit_part_drag_x_get(obj, part) ||
7111 edje_edit_part_drag_y_get(obj, part))
7112 {
7113 BUF_APPEND(I4"dragable {\n");
7114 BUF_APPENDF(I5"x: %d %d %d;\n",
7115 edje_edit_part_drag_x_get(obj, part),
7116 edje_edit_part_drag_step_x_get(obj, part),
7117 edje_edit_part_drag_count_x_get(obj, part));
7118 BUF_APPENDF(I5"y: %d %d %d;\n",
7119 edje_edit_part_drag_y_get(obj, part),
7120 edje_edit_part_drag_step_y_get(obj, part),
7121 edje_edit_part_drag_count_y_get(obj, part));
7122 if ((str = edje_edit_part_drag_confine_get(obj, part)))
7123 {
7124 BUF_APPENDF(I5"confine: \"%s\";\n", str);
7125 edje_edit_string_free(str);
7126 }
7127 if ((str = edje_edit_part_drag_event_get(obj, part)))
7128 {
7129 BUF_APPENDF(I5"events: \"%s\";\n", str);
7130 edje_edit_string_free(str);
7131 }
7132 BUF_APPEND(I4"}\n");
7133 }
7134
7135 //Descriptions
7136 ll = edje_edit_part_states_list_get(obj, part);
7137 EINA_LIST_FOREACH(ll, l, data)
7138 {
7139 char state[512], *delim;
7140 double value;
7141 strncpy(state, data, sizeof(state) - 1); /* if we go over it, too bad.. the list of states may need to change to provide name and value separated */
7142 delim = strchr(state, ' ');
7143 *delim = '\0';
7144 delim++;
7145 value = strtod(delim, NULL);
7146 ret &= _edje_generate_source_of_state(obj, part, state, value, buf);
7147 }
7148 edje_edit_string_list_free(ll);
7149
7150 api_name = edje_edit_part_api_name_get(obj, part);
7151 api_description = edje_edit_part_api_description_get(obj, part);
7152
7153 if (api_name || api_description)
7154 {
7155 if (api_name && api_description)
7156 {
7157 BUF_APPENDF(I4"api: \"%s\" \"%s\";\n", api_name, api_description);
7158 edje_edit_string_free(api_name);
7159 edje_edit_string_free(api_description);
7160 }
7161 else
7162 if (api_name)
7163 {
7164 BUF_APPENDF(I4"api: \"%s\" \"\";\n", api_name);
7165 edje_edit_string_free(api_name);
7166 }
7167 else
7168 {
7169 BUF_APPENDF(I4"api: \"\" \"%s\";\n", api_description);
7170 edje_edit_string_free(api_description);
7171 }
7172 }
7173
7174 BUF_APPEND(I3"}\n");//part
7175 return ret;
7176}
7177
7178static Eina_Bool
7179_edje_generate_source_of_group(Edje *ed, Edje_Part_Collection_Directory_Entry *pce, Eina_Strbuf *buf)
7180{
7181 Edje_Edit *eed;
7182 Eet_File *ef;
7183 Evas_Object *obj;
7184 Eina_List *l, *ll;
7185 unsigned int i;
7186 int w, h;
7187 char *data;
7188 const char *group = pce->entry;
7189 Edje_Part_Collection *pc;
7190 Eina_Bool ret = EINA_TRUE;
7191
7192 obj = edje_edit_object_add(ed->base.evas);
7193 if (!edje_object_file_set(obj, ed->file->path, group)) return EINA_FALSE;
7194
7195 ef = eet_open(ed->file->path, EET_FILE_MODE_READ);
7196 if (!ef)
7197 {
7198 evas_object_del(obj);
7199 return EINA_FALSE;
7200 }
7201
7202 eed = evas_object_smart_data_get(obj);
7203 pc = eed->base.collection;
7204
7205 BUF_APPENDF(I1"group { name: \"%s\";\n", group);
7206 //TODO Support alias:
7207 w = edje_edit_group_min_w_get(obj);
7208 h = edje_edit_group_min_h_get(obj);
7209 if ((w > 0) || (h > 0))
7210 BUF_APPENDF(I2"min: %d %d;\n", w, h);
7211 w = edje_edit_group_max_w_get(obj);
7212 h = edje_edit_group_max_h_get(obj);
7213 if ((w > 0) || (h > 0))
7214 BUF_APPENDF(I2"max: %d %d;\n", w, h);
7215
7216 /* Data */
7217 if (pc->data)
7218 {
7219 Eina_Iterator *it;
7220 Eina_Hash_Tuple *tuple;
7221 BUF_APPEND(I2"data {\n");
7222
7223 it = eina_hash_iterator_tuple_new(pc->data);
7224
7225 if (!it)
7226 {
7227 ERR("Generating EDC for Group[%s] data.", group);
7228 return EINA_FALSE;
7229 }
7230
7231 EINA_ITERATOR_FOREACH(it, tuple)
7232 BUF_APPENDF(I3"item: \"%s\" \"%s\";\n", (char *)tuple->key,
7233 edje_string_get(tuple->data));
7234
7235 eina_iterator_free(it);
7236 BUF_APPEND(I2"}\n");
7237 }
7238
7239 if (eed->embryo_source)
7240 {
7241 BUF_APPEND(I2"script {\n");
7242 BUF_APPEND(eed->embryo_source);
7243 BUF_APPEND(I2"}\n");
7244 }
7245
7246 /* Parts */
7247 BUF_APPEND(I2"parts {\n");
7248 for (i = 0; i < pc->parts_count; i++)
7249 {
7250 Edje_Part *ep;
7251 ep = pc->parts[i];
7252 ret &= _edje_generate_source_of_part(obj, ep, buf);
7253 }
7254 BUF_APPEND(I2"}\n");//parts
7255
7256 if (!ret)
7257 {
7258 ERR("Generating EDC for Group[%s] Parts.", group);
7259 return EINA_FALSE;
7260 }
7261
7262 /* Programs */
7263 if ((ll = edje_edit_programs_list_get(obj)))
7264 {
7265 BUF_APPEND(I2 "programs {\n");
7266 EINA_LIST_FOREACH(ll, l, data)
7267 ret &= _edje_generate_source_of_program(obj, data, buf);
7268 BUF_APPEND(I2 "}\n");
7269 edje_edit_string_list_free(ll);
7270 }
7271 BUF_APPEND(I1"}\n");//group
7272
7273 if (!ret)
7274 {
7275 ERR("Generating EDC for Group[%s] Programs.", group);
7276 evas_object_del(obj);
7277 return EINA_FALSE;
7278 }
7279
7280 eet_close(ef);
7281 evas_object_del(obj);
7282 return ret;
7283}
7284
7285static Eina_Strbuf*
7286_edje_generate_source(Evas_Object *obj)
7287{
7288 Eina_Strbuf *buf;
7289
7290 Eina_List *l, *ll;
7291 Edje_Font_Directory_Entry *fnt;
7292
7293 char *entry;
7294 Eina_Bool ret = EINA_TRUE;
7295
7296 GET_ED_OR_RETURN(NULL);
7297
7298 /* Open a str buffer */
7299
7300 buf = eina_strbuf_new();
7301 if (!buf) return NULL;
7302
7303 /* Write edc into file */
7304 //TODO Probably we need to save the file before generation
7305
7306 /* Images */
7307 if ((ll = edje_edit_images_list_get(obj)))
7308 {
7309 BUF_APPEND(I0"images {\n");
7310
7311 EINA_LIST_FOREACH(ll, l, entry)
7312 {
7313 int comp = edje_edit_image_compression_type_get(obj, entry);
7314 if (comp < 0) continue;
7315
7316 BUF_APPENDF(I1"image: \"%s\" ", entry);
7317
7318 if (comp == EDJE_EDIT_IMAGE_COMP_LOSSY)
7319 BUF_APPENDF("LOSSY %d;\n",
7320 edje_edit_image_compression_rate_get(obj, entry));
7321 else if (comp == EDJE_EDIT_IMAGE_COMP_RAW)
7322 BUF_APPEND("RAW;\n");
7323 else if (comp == EDJE_EDIT_IMAGE_COMP_USER)
7324 BUF_APPEND("USER;\n");
7325 else
7326 BUF_APPEND("COMP;\n");
7327 }
7328 BUF_APPEND(I0"}\n\n");
7329 edje_edit_string_list_free(ll);
7330
7331 if (!ret)
7332 {
7333 ERR("Generating EDC for Images");
7334 eina_strbuf_free(buf);
7335 return NULL;
7336 }
7337 }
7338
7339 /* Fonts */
7340 if (ed->file->fonts)
7341 {
7342 Eina_Iterator *it;
7343
7344 it = eina_hash_iterator_data_new(ed->file->fonts);
7345 if (it)
7346 {
7347 BUF_APPEND(I0"fonts {\n");
7348
7349 EINA_ITERATOR_FOREACH(it, fnt)
7350 BUF_APPENDF(I1"font: \"%s\" \"%s\";\n", fnt->file,
7351 fnt->entry);
7352
7353 BUF_APPEND(I0"}\n\n");
7354 eina_iterator_free(it);
7355
7356 if (!ret)
7357 {
7358 ERR("Generating EDC for Fonts");
7359 eina_strbuf_free(buf);
7360 return NULL;
7361 }
7362 }
7363 }
7364
7365 /* Data */
7366 if ((ll = edje_edit_data_list_get(obj)))
7367 {
7368 BUF_APPEND(I0 "data {\n");
7369
7370 EINA_LIST_FOREACH(ll, l, entry)
7371 BUF_APPENDF(I1 "item: \"%s\" \"%s\";\n", entry,
7372 edje_edit_data_value_get(obj, entry));
7373
7374 BUF_APPEND(I0 "}\n\n");
7375 edje_edit_string_list_free(ll);
7376
7377 if (!ret)
7378 {
7379 ERR("Generating EDC for Data");
7380 eina_strbuf_free(buf);
7381 return NULL;
7382 }
7383 }
7384
7385 /* Color Classes */
7386 if ((ll = edje_edit_color_classes_list_get(obj)))
7387 {
7388 BUF_APPEND(I0 "color_classes {\n");
7389
7390 EINA_LIST_FOREACH(ll, l, entry)
7391 _edje_generate_source_of_colorclass(ed, entry, buf);
7392
7393 BUF_APPEND(I0 "}\n\n");
7394 edje_edit_string_list_free(ll);
7395
7396 if (!ret)
7397 {
7398 ERR("Generating EDC for Color Classes");
7399 eina_strbuf_free(buf);
7400 return NULL;
7401 }
7402 }
7403
7404 /* Styles */
7405 if ((ll = edje_edit_styles_list_get(obj)))
7406 {
7407 BUF_APPEND(I0 "styles {\n");
7408 EINA_LIST_FOREACH(ll, l, entry)
7409 _edje_generate_source_of_style(ed, entry, buf);
7410 BUF_APPEND(I0 "}\n\n");
7411 edje_edit_string_list_free(ll);
7412
7413 if (!ret)
7414 {
7415 ERR("Generating EDC for Styles");
7416 eina_strbuf_free(buf);
7417 return NULL;
7418 }
7419 }
7420
7421 /* Externals */
7422 if ((ll = edje_edit_externals_list_get(obj)))
7423 {
7424 BUF_APPEND(I0 "externals {\n");
7425 EINA_LIST_FOREACH(ll, l, entry)
7426 BUF_APPENDF(I1 "external: \"%s\";\n", entry);
7427
7428 BUF_APPEND(I0 "}\n\n");
7429 edje_edit_string_list_free(ll);
7430
7431 if (!ret)
7432 {
7433 ERR("Generating EDC for Externals");
7434 eina_strbuf_free(buf);
7435 return NULL;
7436 }
7437 }
7438
7439 /* Collections */
7440 if (ed->file->collection)
7441 {
7442 Eina_Iterator *it;
7443 Edje_Part_Collection_Directory_Entry *pce;
7444 BUF_APPEND("collections {\n");
7445
7446 it = eina_hash_iterator_data_new(ed->file->collection);
7447
7448 if (!it)
7449 {
7450 ERR("Generating EDC for Collections");
7451 eina_strbuf_free(buf);
7452 return NULL;
7453 }
7454
7455 EINA_ITERATOR_FOREACH(it, pce)
7456 {
7457 ret &= _edje_generate_source_of_group(ed, pce, buf);
7458 }
7459
7460 eina_iterator_free(it);
7461 BUF_APPEND("}\n\n");
7462 }
7463
7464 return buf;
7465}
7466
7467
7468
7469/*********************/
7470/* SAVING ROUTINES */
7471/*********************/
7472////////////////////////////////////////
7473typedef struct _SrcFile SrcFile;
7474typedef struct _SrcFile_List SrcFile_List;
7475
7476struct _SrcFile
7477{
7478 char *name;
7479 const char *file;
7480};
7481
7482struct _SrcFile_List
7483{
7484 Eina_List *list;
7485};
7486
7487static Eet_Data_Descriptor *_srcfile_edd = NULL;
7488static Eet_Data_Descriptor *_srcfile_list_edd = NULL;
7489
7490static void
7491source_edd(void)
7492{
7493 Eet_Data_Descriptor_Class eddc;
7494
7495 if (_srcfile_edd) return;
7496
7497 eet_eina_stream_data_descriptor_class_set(&eddc, sizeof (eddc), "srcfile", sizeof(SrcFile));
7498 _srcfile_edd = eet_data_descriptor_stream_new(&eddc);
7499 EET_DATA_DESCRIPTOR_ADD_BASIC(_srcfile_edd, SrcFile, "name", name, EET_T_INLINED_STRING);
7500 EET_DATA_DESCRIPTOR_ADD_BASIC(_srcfile_edd, SrcFile, "file", file, EET_T_INLINED_STRING);
7501
7502 eet_eina_stream_data_descriptor_class_set(&eddc, sizeof (eddc), "srcfile_list", sizeof(SrcFile_List));
7503 _srcfile_list_edd = eet_data_descriptor_stream_new(&eddc);
7504 EET_DATA_DESCRIPTOR_ADD_LIST(_srcfile_list_edd, SrcFile_List, "list", list, _srcfile_edd);
7505}
7506/////////////////////////////////////////
7507
7508static Eina_Bool
7509_edje_edit_edje_file_save(Eet_File *eetf, Edje_File *ef)
7510{
7511 /* Write Edje_File structure */
7512 INF("** Writing Edje_File* ed->file");
7513 if (eet_data_write(eetf, _edje_edd_edje_file, "edje/file", ef, 1) <= 0)
7514 {
7515 ERR("Error. unable to write \"edje_file\" entry to \"%s\"", ef->path);
7516 return EINA_FALSE;
7517 }
7518 return EINA_TRUE;
7519}
7520
7521static Eina_Bool
7522_edje_edit_collection_save(Eet_File *eetf, Edje_Part_Collection *epc)
7523{
7524 char buf[256];
7525
7526 snprintf(buf, sizeof(buf), "edje/collections/%i", epc->id);
7527
7528 if (eet_data_write(eetf, _edje_edd_edje_part_collection, buf, epc, 1) > 0)
7529 return EINA_TRUE;
7530
7531 ERR("Error. unable to write \"%s\" part entry", buf);
7532 return EINA_FALSE;
7533}
7534
7535static Eina_Bool
7536_edje_edit_source_save(Eet_File *eetf, Evas_Object *obj)
7537{
7538 SrcFile *sf;
7539 SrcFile_List *sfl;
7540 Eina_Strbuf *source_file;
7541 Eina_Bool ret = EINA_TRUE;
7542
7543 source_file = _edje_generate_source(obj);
7544 if (!source_file)
7545 {
7546 ERR("Can't create edc source");
7547 return EINA_FALSE;
7548 }
7549
7550 //open the temp file and put the contents in SrcFile
7551 sf = _alloc(sizeof(SrcFile));
7552 if (!sf)
7553 {
7554 ERR("Unable to create source file struct");
7555 ret = EINA_FALSE;
7556 goto save_free_source;
7557 }
7558 sf->name = strdup("generated_source.edc");
7559 if (!sf->name)
7560 {
7561 ERR("Unable to alloc filename");
7562 ret = EINA_FALSE;
7563 goto save_free_sf;
7564 }
7565
7566 sf->file = eina_strbuf_string_get(source_file);
7567
7568 //create the needed list of source files (only one)
7569 sfl = _alloc(sizeof(SrcFile_List));
7570 if (!sfl)
7571 {
7572 ERR("Unable to create file list");
7573 ret = EINA_FALSE;
7574 goto save_free_filename;
7575 }
7576 sfl->list = NULL;
7577 sfl->list = eina_list_append(sfl->list, sf);
7578 if (!sfl->list)
7579 {
7580 ERR("Error. unable to append file in list");
7581 ret = EINA_FALSE;
7582 goto save_free_sfl;
7583 }
7584
7585 // write the sources list to the eet file
7586 source_edd();
7587 if (eet_data_write(eetf, _srcfile_list_edd, "edje_sources", sfl, 1) <= 0)
7588 {
7589 ERR("Unable to write edc source");
7590 ret = EINA_FALSE;
7591 }
7592
7593 /* Clear stuff */
7594 eina_list_free(sfl->list);
7595save_free_sfl:
7596 free(sfl);
7597save_free_filename:
7598 free(sf->name);
7599save_free_sf:
7600 free(sf);
7601save_free_source:
7602 eina_strbuf_free(source_file);
7603 return ret;
7604}
7605
7606Eina_Bool
7607_edje_edit_internal_save(Evas_Object *obj, int current_only)
7608{
7609 Edje_File *ef;
7610 Eet_File *eetf;
7611
7612 GET_ED_OR_RETURN(EINA_FALSE);
7613
7614 ef = ed->file;
7615 if (!ef) return EINA_FALSE;
7616
7617 INF("*********** Saving file ******************");
7618 INF("** path: %s", ef->path);
7619
7620 /* Open the eet file */
7621 eetf = eet_open(ef->path, EET_FILE_MODE_READ_WRITE);
7622 if (!eetf)
7623 {
7624 ERR("Error. unable to open \"%s\" for writing output",
7625 ef->path);
7626 return EINA_FALSE;
7627 }
7628
7629 /* Set compiler name */
7630 if (strcmp(ef->compiler, "edje_edit"))
7631 {
7632 _edje_if_string_free(ed, ef->compiler);
7633 ef->compiler = (char *)eina_stringshare_add("edje_edit");
7634 }
7635
7636 if (!_edje_edit_edje_file_save(eetf, ef))
7637 {
7638 eet_close(eetf);
7639 return EINA_FALSE;
7640 }
7641
7642 if (current_only)
7643 {
7644 if (ed->collection)
7645 {
7646 INF("** Writing Edje_Part_Collection* ed->collection "
7647 "[id: %d]", ed->collection->id);
7648 if (!_edje_edit_collection_save(eetf, ed->collection))
7649 {
7650 eet_close(eetf);
7651 return EINA_FALSE;
7652 }
7653 }
7654 }
7655 else
7656 {
7657 Eina_List *l;
7658 Edje_Part_Collection *edc;
7659 Edje_Part_Collection_Directory_Entry *ce;
7660 Eina_Iterator *it;
7661
7662 INF("** Writing all collections");
7663
7664 it = eina_hash_iterator_data_new(ef->collection);
7665 while (eina_iterator_next(it, (void **)&ce))
7666 {
7667 if (ce->ref)
7668 {
7669 INF("** Writing hash Edje_Part_Collection* ed->collection "
7670 "[id: %d]", ce->id);
7671 if(!_edje_edit_collection_save(eetf, ce->ref))
7672 {
7673 eet_close(eetf);
7674 return EINA_FALSE;
7675 }
7676 }
7677 }
7678 eina_iterator_free(it);
7679
7680 EINA_LIST_FOREACH(ef->collection_cache, l, edc)
7681 {
7682 INF("** Writing cache Edje_Part_Collection* ed->collection "
7683 "[id: %d]", edc->id);
7684 if(!_edje_edit_collection_save(eetf, edc))
7685 {
7686 eet_close(eetf);
7687 return EINA_FALSE;
7688 }
7689 }
7690 }
7691
7692 if (eed->bytecode_dirty || eed->script_need_recompile)
7693 {
7694 char buf[64];
7695 Eina_Iterator *it;
7696 Program_Script *ps;
7697 Eina_List *deathnote = NULL;
7698
7699 if (eed->bytecode_dirty)
7700 {
7701 snprintf(buf, sizeof(buf), "edje/scripts/embryo/compiled/%i",
7702 ed->collection->id);
7703 eet_write(eetf, buf, eed->bytecode, eed->bytecode_size, 1);
7704 free(eed->bytecode);
7705 eed->bytecode = NULL;
7706 eed->bytecode_size = 0;
7707 eed->bytecode_dirty = EINA_FALSE;
7708 }
7709
7710 if (eed->embryo_source_dirty)
7711 {
7712 snprintf(buf, sizeof(buf), "edje/scripts/embryo/source/%i",
7713 ed->collection->id);
7714 eet_write(eetf, buf, eed->embryo_source,
7715 strlen(eed->embryo_source) +1, 1);
7716 eed->embryo_source_dirty = EINA_FALSE;
7717 }
7718
7719 it = eina_hash_iterator_data_new(eed->program_scripts);
7720 EINA_ITERATOR_FOREACH(it, ps)
7721 {
7722 if (ps->dirty)
7723 {
7724 snprintf(buf, sizeof(buf), "edje/scripts/embryo/source/%i/%i",
7725 ed->collection->id, ps->id);
7726 eet_write(eetf, buf, ps->code, strlen(ps->code) + 1, 1);
7727 ps->dirty = EINA_FALSE;
7728 }
7729 else if (ps->delete_me)
7730 {
7731 snprintf(buf, sizeof(buf), "edje/scripts/embryo/source/%i/%i",
7732 ed->collection->id, ps->id);
7733 eet_delete(eetf, buf);
7734 deathnote = eina_list_append(deathnote, ps);
7735 }
7736 }
7737 eina_iterator_free(it);
7738
7739 EINA_LIST_FREE(deathnote, ps)
7740 eina_hash_del(eed->program_scripts, &ps->id, ps);
7741 }
7742
7743 if (!_edje_edit_source_save(eetf, obj))
7744 {
7745 eet_close(eetf);
7746 return EINA_FALSE;
7747 }
7748
7749 eet_close(eetf);
7750
7751 /* Update mtime */
7752 {
7753 struct stat st;
7754 if (stat(ed->path, &st) != 0)
7755 return EINA_FALSE;
7756 ef->mtime = st.st_mtime;
7757 }
7758
7759 INF("*********** Saving DONE ******************");
7760 return EINA_TRUE;
7761}
7762
7763EAPI Eina_Bool
7764edje_edit_save(Evas_Object *obj)
7765{
7766 eina_error_set(0);
7767
7768 return _edje_edit_internal_save(obj, 1);
7769}
7770
7771EAPI Eina_Bool
7772edje_edit_save_all(Evas_Object *obj)
7773{
7774 eina_error_set(0);
7775
7776 return _edje_edit_internal_save(obj, 0);
7777}
7778
7779EAPI void
7780edje_edit_print_internal_status(Evas_Object *obj)
7781{
7782/*
7783 Edje_Program *epr;
7784 unsigned int i;
7785 int j;
7786*/
7787 eina_error_set(0);
7788
7789 GET_ED_OR_RETURN();
7790
7791 _edje_generate_source(obj);
7792/*
7793 INF("****** CHECKIN' INTERNAL STRUCTS STATUS *********");
7794
7795 INF("path: '%s', group: '%s', parent: '%s'",
7796 ed->path, ed->group, ed->parent);
7797
7798 INF("Parts [table:%d list:%d]", ed->table_parts_size,
7799 ed->collection->parts_count);
7800 for (i = 0; i < ed->collection->parts_count; ++i)
7801 {
7802 Edje_Real_Part *rp;
7803 Edje_Part *p;
7804
7805 p = ed->collection->parts[i];
7806
7807 rp = ed->table_parts[p->id % ed->table_parts_size];
7808 printf("part[%d]: '%s' ", p->id, p->name);
7809 if (p == rp->part)
7810 printf("OK!\n");
7811 else
7812 printf("WRONG (table[%d]->name = '%s')\n", p->id, rp->part->name);
7813 }
7814
7815 INF("Programs [table:%d list:%d,%d,%d,%d,%d]", ed->table_programs_size,
7816 ed->collection->programs.fnmatch_count,
7817 ed->collection->programs.strcmp_count,
7818 ed->collection->programs.strncmp_count,
7819 ed->collection->programs.strrncmp_count,
7820 ed->collection->programs.nocmp_count);
7821 for(j = 0; j < ed->table_programs_size; ++j)
7822 {
7823 epr = ed->table_programs[i % ed->table_programs_size];
7824 printf("program[%d]: '%s'\n", epr->id, epr->name);
7825 }
7826
7827 INF("****************** END ************************");
7828 */
7829}
diff --git a/libraries/edje/src/lib/edje_embryo.c b/libraries/edje/src/lib/edje_embryo.c
new file mode 100644
index 0000000..c89a4f4
--- /dev/null
+++ b/libraries/edje/src/lib/edje_embryo.c
@@ -0,0 +1,3179 @@
1#include "edje_private.h"
2
3/*
4 * ALREADY EXPORTED BY EMBRYO:
5 *
6 * enum Float_Round_Method {
7 * ROUND, FLOOR, CEIL, TOZERO
8 * };
9 * enum Float_Angle_Mode {
10 * RADIAN, DEGREES, GRADES
11 * };
12 *
13 * numargs();
14 * getarg(arg, index=0);
15 * setarg(arg, index=0, value);
16 *
17 * Float:atof(string[]);
18 * Float:fract(Float:value);
19 * round(Float:value, Float_Round_Method:method=ROUND);
20 * Float:sqrt(Float:value);
21 * Float:pow(Float:value, Float:exponent);
22 * Float:log(Float:value, Float:base=10.0);
23 * Float:sin(Float:value, Float_Angle_Mode:mode=RADIAN);
24 * Float:cos(Float:value, Float_Angle_Mode:mode=RADIAN);
25 * Float:tan(Float:value, Float_Angle_Mode:mode=RADIAN);
26 * Float:abs(Float:value);
27 * atoi(str[]);
28 * fnmatch(glob[], str[]);
29 * strcmp(str1[], str2[]);
30 * strncmp(str1[], str2[]);
31 * strcpy(dst[], src[]);
32 * strncpy(dst[], src[], n);
33 * strlen(str[]);
34 * strcat(dst[], src[]);
35 * strncat(dst[], src[], n);
36 * strprep(dst[], src[]);
37 * strnprep(dst[], src[], n);
38 * strcut(dst[], str[], n, n2);
39 * snprintf(dst[], dstn, fmt[], ...);
40 * strstr(str[], ndl[]);
41 * strchr(str[], ch[]);
42 * strrchr(str[], ch[]);
43 * rand();
44 * Float:randf();
45 * Float:seconds();
46 * date(&year, &month, &day, &yearday, &weekday, &hr, &min, &Float:sec);
47 *
48 */
49
50/* EDJE...
51 *
52 * implemented so far as examples:
53 *
54 * enum Msg_Type {
55 * MSG_NONE, MSG_STRING, MSG_INT, MSG_FLOAT, MSG_STRING_SET, MSG_INT_SET,
56 * MSG_FLOAT_SET, MSG_STRING_INT, MSG_INT_FLOAT, MSG_STRING_INT_SET,
57 * MSG_INT_FLOAT_SET
58 * };
59 *
60 * get_int(id)
61 * set_int(id, v)
62 * Float:get_float (id)
63 * set_float(id, Float:v)
64 * get_strlen(id)
65 * get_str(id, dst[], maxlen)
66 * set_str(id, str[])
67 * timer(Float:in, fname[], val)
68 * cancel_timer(id)
69 * anim(Float:len, fname[], val)
70 * cancel_anim(id)
71 * emit(sig[], src[])
72 * set_state(part_id, state[], Float:state_val)
73 * get_state(part_id, dst[], maxlen, &Float:val)
74 * set_tween_state(part_id, Float:tween, state1[], Float:state1_val, state2[], Float:state2_val)
75 * play_sample(sample_name, speed)
76 * play_tone(tone_name, duration)
77 * run_program(program_id)
78 * Direction:get_drag_dir(part_id)
79 * get_drag(part_id, &Float:dx, &Float:&dy)
80 * set_drag(part_id, Float:dx, Float:dy)
81 * get_drag_size(part_id, &Float:dx, &Float:&dy)
82 * set_drag_size(part_id, Float:dx, Float:dy)
83 * set_text(part_id, str[])
84 * get_text(part_id, dst[], maxlen)
85 * get_min_size(w, h)
86 * get_max_size(w, h)
87 * set_color_class(class[], r, g, b, a)
88 * get_color_class(class[], &r, &g, &b, &a)
89 * set_text_class(class[], font[], Float:size)
90 * get_text_class(class[], font[], &Float:size)
91 * get_drag_step(part_id, &Float:dx, &Float:&dy)
92 * set_drag_step(part_id, Float:dx, Float:dy)
93 * get_drag_page(part_id, &Float:dx, &Float:&dy)
94 * set_drag_page(part_id, Float:dx, Float:dy)
95 * get_geometry(part_id, &Float:x, &Float:y, &Float:w, &Float:h)
96 * get_mouse(&x, &y)
97 * stop_program(program_id)
98 * stop_programs_on(part_id)
99 * set_min_size(w, h)
100 * set_max_size(w, h)
101 * send_message(Msg_Type:type, id, ...)
102 *
103 * count(id)
104 * remove(id, n)
105 *
106 * append_int(id, v)
107 * prepend_int(id, v)
108 * insert_int(id, n, v)
109 * replace_int(id, n, v)
110 * fetch_int(id, n)
111 *
112 * append_str(id, str[])
113 * prepend_str(id, str[])
114 * insert_str(id, n, str[])
115 * replace_str(id, n, str[])
116 * fetch_str(id, n, dst[], maxlen)
117 *
118 * append_float(id, Float:v)
119 * prepend_float(id, Float:v)
120 * insert_float(id, n, Float:v)
121 * replace_float(id, n, Float:v)
122 * Float:fetch_float(id, n)
123 *
124 * custom_state(part_id, state[], Float:state_val = 0.0)
125 * set_state_val(part_id, State_Param:param, ...)
126 * get_state_val(part_id, State_Param:param, ...)
127 *
128 * Supported parameters:
129 * align[Float:x, Float:y]
130 * min[w, h]
131 * max[w, h]
132 * step[x,y]
133 * aspect[Float:min, Float:max]
134 * color[r,g,b,a]
135 * color2[r,g,b,a]
136 * color3[r,g,b,a]
137 * aspect_preference
138 * rel1[relx,rely]
139 * rel1[part_id,part_id]
140 * rel1[offx,offy]
141 * rel2[relx,relyr]
142 * rel2[part_id,part_id]
143 * rel2[offx,offy]
144 * image[image_id] <- all images have an Id not name in the edje
145 * border[l,r,t,b]
146 * fill[smooth]
147 * fill[pos_relx,pos_rely,pos_offx,pos_offy]
148 * fill[sz_relx,sz_rely,sz_offx,sz_offy]
149 * color_class
150 * text[text]
151 * text[text_class]
152 * text[font]
153 * text[size]
154 * text[style]
155 * text[fit_x,fit_y]
156 * text[min_x,min_y]
157 * text[align_x,align_y]
158 * visible[on]
159 * map_on[on]
160 * map_persp[part_id]
161 * map_light[part_id]
162 * map_rot_center[part_id]
163 * map_rot_x[deg]
164 * map_rot_y[deg]
165 * map_rot_z[deg]
166 * map_back_cull[on]
167 * map_persp_on[on]
168 * persp_zplane[z]
169 * persp_focal[z]
170 *
171 * ** part_id and program_id need to be able to be "found" from strings
172 *
173 * get_drag_count(part_id, &Float:dx, &Float:&dy)
174 * set_drag_count(part_id, Float:dx, Float:dy)
175 * set_drag_confine(part_id, confine_part_id)
176 * get_size(&w, &h);
177 * resize_request(w, h)
178 * get_mouse_buttons()
179 * //set_type(part_id, Type:type)
180 * //set_effect(part_id, Effect:fx)
181 * set_mouse_events(part_id, ev)
182 * get_mouse_events(part_id)
183 * set_repeat_events(part_id, rep)
184 * get_repeat_events(part_id)
185 * set_clip(part_id, clip_part_id)
186 * get_clip(part_id)
187 *
188 * part_swallow(part_id, group_name)
189 *
190 * external_param_get_int(id, param_name[])
191 * external_param_set_int(id, param_name[], value)
192 * Float:external_param_get_float(id, param_name[])
193 * external_param_set_float(id, param_name[], Float:value)
194 * external_param_get_strlen(id, param_name[])
195 * external_param_get_str(id, param_name[], value[], value_maxlen)
196 * external_param_set_str(id, param_name[], value[])
197 * external_param_get_choice_len(id, param_name[])
198 * external_param_get_choice(id, param_name[], value[], value_maxlen)
199 * external_param_set_choice(id, param_name[], value[])
200 * external_param_get_bool(id, param_name[])
201 * external_param_set_bool(id, param_name[], value)
202 *
203 * ADD/DEL CUSTOM OBJECTS UNDER SOLE EMBRYO SCRIPT CONTROL
204 *
205 */
206
207/* get_int(id) */
208static Embryo_Cell
209_edje_embryo_fn_get_int(Embryo_Program *ep, Embryo_Cell *params)
210{
211 Edje *ed;
212
213 CHKPARAM(1);
214 ed = embryo_program_data_get(ep);
215 return (Embryo_Cell)_edje_var_int_get(ed, (int)params[1]);
216}
217
218/* set_int(id, v) */
219static Embryo_Cell
220_edje_embryo_fn_set_int(Embryo_Program *ep, Embryo_Cell *params)
221{
222 Edje *ed;
223
224 CHKPARAM(2);
225 ed = embryo_program_data_get(ep);
226 _edje_var_int_set(ed, (int)params[1], (int)params[2]);
227 return 0;
228}
229
230/* get_float(id) */
231static Embryo_Cell
232_edje_embryo_fn_get_float(Embryo_Program *ep, Embryo_Cell *params)
233{
234 Edje *ed;
235 float v;
236
237 CHKPARAM(1);
238 ed = embryo_program_data_get(ep);
239 v = (float)_edje_var_float_get(ed, params[1]);
240 return EMBRYO_FLOAT_TO_CELL(v);
241}
242
243/* set_float(id, v) */
244static Embryo_Cell
245_edje_embryo_fn_set_float(Embryo_Program *ep, Embryo_Cell *params)
246{
247 Edje *ed;
248 float v;
249
250 CHKPARAM(2);
251 ed = embryo_program_data_get(ep);
252 v = EMBRYO_CELL_TO_FLOAT(params[2]);
253 _edje_var_float_set(ed, (int)params[1], (double)v);
254 return 0;
255}
256
257/* get_str(id, dst[], maxlen) */
258static Embryo_Cell
259_edje_embryo_fn_get_str(Embryo_Program *ep, Embryo_Cell *params)
260{
261 Edje *ed;
262 char *s;
263
264 CHKPARAM(3);
265 if (params[3] < 1) return 0;
266 ed = embryo_program_data_get(ep);
267 s = (char *)_edje_var_str_get(ed, (int)params[1]);
268 if (s)
269 {
270 if ((int) strlen(s) < params[3])
271 {
272 SETSTR(s, params[2]);
273 }
274 else
275 {
276 char *ss;
277
278 ss = alloca(strlen(s) + 1);
279 strcpy(ss, s);
280 ss[params[3] - 1] = 0;
281 SETSTR(ss, params[2]);
282 }
283 }
284 else
285 {
286 SETSTR("", params[2]);
287 }
288 return 0;
289}
290
291/* get_strlen(id) */
292static Embryo_Cell
293_edje_embryo_fn_get_strlen(Embryo_Program *ep, Embryo_Cell *params)
294{
295 Edje *ed;
296 char *s;
297
298 CHKPARAM(1);
299 ed = embryo_program_data_get(ep);
300 s = (char *)_edje_var_str_get(ed, (int)params[1]);
301 if (s)
302 {
303 return strlen(s);
304 }
305 return 0;
306}
307
308/* set_str(id, str[]) */
309static Embryo_Cell
310_edje_embryo_fn_set_str(Embryo_Program *ep, Embryo_Cell *params)
311{
312 Edje *ed;
313 char *s;
314
315 CHKPARAM(2);
316 ed = embryo_program_data_get(ep);
317 GETSTR(s, params[2]);
318 if (s)
319 {
320 _edje_var_str_set(ed, (int)params[1], s);
321 }
322 return 0;
323}
324
325/* count(id) */
326static Embryo_Cell
327_edje_embryo_fn_count(Embryo_Program *ep, Embryo_Cell *params)
328{
329 Edje *ed = embryo_program_data_get(ep);
330
331 CHKPARAM(1);
332
333 return (Embryo_Cell)_edje_var_list_count_get(ed, (int) params[1]);
334}
335
336/* remove(id, n) */
337static Embryo_Cell
338_edje_embryo_fn_remove(Embryo_Program *ep, Embryo_Cell *params)
339{
340 Edje *ed = embryo_program_data_get(ep);
341
342 CHKPARAM(2);
343
344 _edje_var_list_remove_nth(ed, (int) params[1], (int) params[2]);
345
346 return 0;
347}
348
349/* append_int(id, var) */
350static Embryo_Cell
351_edje_embryo_fn_append_int(Embryo_Program *ep, Embryo_Cell *params)
352{
353 Edje *ed = embryo_program_data_get(ep);
354
355 CHKPARAM(2);
356
357 _edje_var_list_int_append(ed, (int) params[1], (int) params[2]);
358
359 return 0;
360}
361
362/* prepend_int(id, var) */
363static Embryo_Cell
364_edje_embryo_fn_prepend_int(Embryo_Program *ep, Embryo_Cell *params)
365{
366 Edje *ed = embryo_program_data_get(ep);
367
368 CHKPARAM(2);
369
370 _edje_var_list_int_prepend(ed, (int) params[1], (int) params[2]);
371
372 return 0;
373}
374
375/* insert_int(id, pos, var) */
376static Embryo_Cell
377_edje_embryo_fn_insert_int(Embryo_Program *ep, Embryo_Cell *params)
378{
379 Edje *ed = embryo_program_data_get(ep);
380
381 CHKPARAM(3);
382
383 _edje_var_list_int_insert(ed, (int) params[1], (int) params[2],
384 (int) params[3]);
385
386 return 0;
387}
388
389/* replace_int(id, pos, var) */
390static Embryo_Cell
391_edje_embryo_fn_replace_int(Embryo_Program *ep, Embryo_Cell *params)
392{
393 Edje *ed = embryo_program_data_get(ep);
394
395 CHKPARAM(3);
396
397 _edje_var_list_nth_int_set(ed, (int) params[1], (int) params[2],
398 (int) params[3]);
399
400 return 0;
401}
402
403/* fetch_int(id, pos) */
404static Embryo_Cell
405_edje_embryo_fn_fetch_int(Embryo_Program *ep, Embryo_Cell *params)
406{
407 Edje *ed = embryo_program_data_get(ep);
408
409 CHKPARAM(2);
410
411 return _edje_var_list_nth_int_get(ed, (int) params[1],
412 (int) params[2]);
413}
414
415/* append_str(id, str[]) */
416static Embryo_Cell
417_edje_embryo_fn_append_str(Embryo_Program *ep, Embryo_Cell *params)
418{
419 Edje *ed = embryo_program_data_get(ep);
420 char *s;
421
422 CHKPARAM(2);
423
424 GETSTR(s, params[2]);
425 if (s)
426 _edje_var_list_str_append(ed, (int) params[1], s);
427
428 return 0;
429}
430
431/* prepend_str(id, str[]) */
432static Embryo_Cell
433_edje_embryo_fn_prepend_str(Embryo_Program *ep, Embryo_Cell *params)
434{
435 Edje *ed = embryo_program_data_get(ep);
436 char *s;
437
438 CHKPARAM(2);
439
440 GETSTR(s, params[2]);
441 if (s)
442 _edje_var_list_str_prepend(ed, (int) params[1], s);
443
444 return 0;
445}
446
447/* insert_str(id, pos, str[]) */
448static Embryo_Cell
449_edje_embryo_fn_insert_str(Embryo_Program *ep, Embryo_Cell *params)
450{
451 Edje *ed = embryo_program_data_get(ep);
452 char *s;
453
454 CHKPARAM(3);
455
456 GETSTR(s, params[3]);
457 if (s)
458 _edje_var_list_str_insert(ed, (int) params[1], (int) params[2], s);
459
460 return 0;
461}
462
463/* replace_str(id, pos, str[]) */
464static Embryo_Cell
465_edje_embryo_fn_replace_str(Embryo_Program *ep, Embryo_Cell *params)
466{
467 Edje *ed = embryo_program_data_get(ep);
468 char *s;
469
470 CHKPARAM(3);
471
472 GETSTR(s, params[3]);
473 if (s)
474 _edje_var_list_nth_str_set(ed, (int) params[1], (int) params[2], s);
475
476 return 0;
477}
478
479
480/* fetch_str(id, pos, dst[], maxlen) */
481static Embryo_Cell
482_edje_embryo_fn_fetch_str(Embryo_Program *ep, Embryo_Cell *params)
483{
484 Edje *ed = embryo_program_data_get(ep);
485 char *s;
486
487 CHKPARAM(4);
488
489 s = (char *) _edje_var_list_nth_str_get(ed, (int) params[1],
490 (int) params[2]);
491 if (s)
492 {
493 if ((int) strlen(s) < params[4])
494 {
495 SETSTR(s, params[3]);
496 }
497 else
498 {
499 char *ss;
500
501 ss = alloca(strlen(s) + 1);
502 strcpy(ss, s);
503 ss[params[4] - 1] = 0;
504 SETSTR(ss, params[3]);
505 }
506 }
507 else
508 {
509 SETSTR("", params[3]);
510 }
511
512 return 0;
513}
514
515/* append_float(id, Float:f) */
516static Embryo_Cell
517_edje_embryo_fn_append_float(Embryo_Program *ep, Embryo_Cell *params)
518{
519 Edje *ed = embryo_program_data_get(ep);
520 float f;
521
522 CHKPARAM(2);
523
524 f = EMBRYO_CELL_TO_FLOAT(params[2]);
525 _edje_var_list_float_append(ed, (int) params[1], f);
526
527 return 0;
528}
529
530/* prepend_float(id, Float:f) */
531static Embryo_Cell
532_edje_embryo_fn_prepend_float(Embryo_Program *ep, Embryo_Cell *params)
533{
534 Edje *ed = embryo_program_data_get(ep);
535 float f;
536
537 CHKPARAM(2);
538
539 f = EMBRYO_CELL_TO_FLOAT(params[2]);
540 _edje_var_list_float_prepend(ed, (int) params[1], f);
541
542 return 0;
543}
544
545/* insert_float(id, pos, Float:f) */
546static Embryo_Cell
547_edje_embryo_fn_insert_float(Embryo_Program *ep, Embryo_Cell *params)
548{
549 Edje *ed = embryo_program_data_get(ep);
550 float f;
551
552 CHKPARAM(3);
553
554 f = EMBRYO_CELL_TO_FLOAT(params[3]);
555 _edje_var_list_float_insert(ed, (int) params[1], (int) params[2], f);
556
557 return 0;
558}
559
560/* replace_float(id, pos, Float:f) */
561static Embryo_Cell
562_edje_embryo_fn_replace_float(Embryo_Program *ep, Embryo_Cell *params)
563{
564 Edje *ed = embryo_program_data_get(ep);
565
566 CHKPARAM(3);
567
568 _edje_var_list_nth_float_set(ed, (int) params[1], (int) params[2],
569 EMBRYO_CELL_TO_FLOAT(params[3]));
570
571 return 0;
572}
573
574/* Float:fetch_float(id, pos) */
575static Embryo_Cell
576_edje_embryo_fn_fetch_float(Embryo_Program *ep, Embryo_Cell *params)
577{
578 Edje *ed = embryo_program_data_get(ep);
579 float f;
580
581 CHKPARAM(2);
582
583 f = _edje_var_list_nth_float_get(ed, (int) params[1], (int) params[2]);
584
585 return EMBRYO_FLOAT_TO_CELL(f);
586}
587
588/* timer(Float:in, fname[], val) */
589static Embryo_Cell
590_edje_embryo_fn_timer(Embryo_Program *ep, Embryo_Cell *params)
591{
592 Edje *ed;
593 char *fname = NULL;
594 float f;
595 double in;
596 int val;
597
598 CHKPARAM(3);
599 ed = embryo_program_data_get(ep);
600 GETSTR(fname, params[2]);
601 if ((!fname)) return 0;
602 f = EMBRYO_CELL_TO_FLOAT(params[1]);
603 in = (double)f;
604 val = params[3];
605 return _edje_var_timer_add(ed, in, fname, val);
606}
607
608/* cancel_timer(id) */
609static Embryo_Cell
610_edje_embryo_fn_cancel_timer(Embryo_Program *ep, Embryo_Cell *params)
611{
612 Edje *ed;
613 int id;
614
615 CHKPARAM(1);
616 ed = embryo_program_data_get(ep);
617 id = params[1];
618 if (id <= 0) return 0;
619 _edje_var_timer_del(ed, id);
620 return 0;
621}
622
623/* anim(Float:len, fname[], val) */
624static Embryo_Cell
625_edje_embryo_fn_anim(Embryo_Program *ep, Embryo_Cell *params)
626{
627 Edje *ed;
628 char *fname = NULL;
629 float f;
630 double len;
631 int val;
632
633 CHKPARAM(3);
634 ed = embryo_program_data_get(ep);
635 GETSTR(fname, params[2]);
636 if ((!fname)) return 0;
637 f = EMBRYO_CELL_TO_FLOAT(params[1]);
638 len = (double)f;
639 val = params[3];
640 return _edje_var_anim_add(ed, len, fname, val);
641}
642
643/* cancel_anim(id) */
644static Embryo_Cell
645_edje_embryo_fn_cancel_anim(Embryo_Program *ep, Embryo_Cell *params)
646{
647 Edje *ed;
648 int id;
649
650 CHKPARAM(1);
651 ed = embryo_program_data_get(ep);
652 id = params[1];
653 if (id <= 0) return 0;
654 _edje_var_anim_del(ed, id);
655 return 0;
656}
657
658/* set_min_size(Float:w, Float:h) */
659static Embryo_Cell
660_edje_embryo_fn_set_min_size(Embryo_Program *ep, Embryo_Cell *params)
661{
662 Edje *ed;
663 float f = 0.0;
664 double w = 0.0, h = 0.0;
665
666 CHKPARAM(2);
667 ed = embryo_program_data_get(ep);
668 f = EMBRYO_CELL_TO_FLOAT(params[1]);
669 w = (double)f;
670 f = EMBRYO_CELL_TO_FLOAT(params[2]);
671 h = (double)f;
672
673 if (w < 0.0) w = 0.0;
674 if (h < 0.0) h = 0.0;
675 ed->collection->prop.min.w = w;
676 ed->collection->prop.min.h = h;
677 ed->dirty = 1;
678#ifdef EDJE_CALC_CACHE
679 ed->all_part_change = 1;
680#endif
681 _edje_recalc(ed);
682 return 0;
683}
684
685/* set_max_size(Float:w, Float:h) */
686static Embryo_Cell
687_edje_embryo_fn_set_max_size(Embryo_Program *ep, Embryo_Cell *params)
688{
689 Edje *ed;
690 float f = 0.0;
691 double w = 0.0, h = 0.0;
692
693 CHKPARAM(2);
694 ed = embryo_program_data_get(ep);
695 f = EMBRYO_CELL_TO_FLOAT(params[1]);
696 w = (double)f;
697 f = EMBRYO_CELL_TO_FLOAT(params[2]);
698 h = (double)f;
699
700 if (w < 0.0) w = 0.0;
701 if (h < 0.0) h = 0.0;
702 ed->collection->prop.max.w = w;
703 ed->collection->prop.max.h = h;
704 ed->dirty = 1;
705#ifdef EDJE_CALC_CACHE
706 ed->all_part_change = 1;
707#endif
708 _edje_recalc(ed);
709
710 return 0;
711}
712
713/* stop_program(program_id) */
714static Embryo_Cell
715_edje_embryo_fn_stop_program(Embryo_Program *ep, Embryo_Cell *params)
716{
717 Edje *ed;
718 int program_id = 0;
719 Edje_Running_Program *runp;
720 Eina_List *l;
721
722 CHKPARAM(1);
723 ed = embryo_program_data_get(ep);
724 program_id = params[1];
725 if (program_id < 0) return 0;
726
727 ed->walking_actions = 1;
728
729 EINA_LIST_FOREACH(ed->actions, l, runp)
730 if (program_id == runp->program->id)
731 _edje_program_end(ed, runp);
732
733 ed->walking_actions = 0;
734
735 return 0;
736}
737
738/* stop_programs_on(part_id) */
739static Embryo_Cell
740_edje_embryo_fn_stop_programs_on(Embryo_Program *ep, Embryo_Cell *params)
741{
742 Edje *ed;
743
744 int part_id = 0;
745 Edje_Real_Part *rp;
746
747 CHKPARAM(1);
748 ed = embryo_program_data_get(ep);
749 part_id = params[1];
750 if (part_id < 0) return 0;
751 rp = ed->table_parts[part_id % ed->table_parts_size];
752 if (rp)
753 {
754 /* there is only ever 1 program acting on a part at any time */
755 if (rp->program) _edje_program_end(ed, rp->program);
756 }
757 return 0;
758}
759
760/* get_mouse(&x, &y) */
761static Embryo_Cell
762_edje_embryo_fn_get_mouse(Embryo_Program *ep, Embryo_Cell *params)
763{
764 Edje *ed;
765 Evas_Coord x = 0, y = 0;
766
767 CHKPARAM(2);
768 ed = embryo_program_data_get(ep);
769 evas_pointer_canvas_xy_get(ed->base.evas, &x, &y);
770 x -= ed->x;
771 y -= ed->y;
772 SETINT((int)x, params[1]);
773 SETINT((int)y, params[2]);
774 return 0;
775}
776
777/* get_mouse_buttons() */
778static Embryo_Cell
779_edje_embryo_fn_get_mouse_buttons(Embryo_Program *ep, Embryo_Cell *params)
780{
781 Edje *ed;
782
783 CHKPARAM(0);
784 ed = embryo_program_data_get(ep);
785 return evas_pointer_button_down_mask_get(ed->base.evas);
786}
787
788/* emit(sig[], src[]) */
789static Embryo_Cell
790_edje_embryo_fn_emit(Embryo_Program *ep, Embryo_Cell *params)
791{
792 Edje *ed;
793 char *sig = NULL, *src = NULL;
794
795 CHKPARAM(2);
796 ed = embryo_program_data_get(ep);
797 GETSTR(sig, params[1]);
798 GETSTR(src, params[2]);
799 if ((!sig) || (!src)) return 0;
800 _edje_emit(ed, sig, src);
801 return 0;
802}
803
804/* get_part_id(part[]) */
805static Embryo_Cell
806_edje_embryo_fn_get_part_id(Embryo_Program *ep, Embryo_Cell *params)
807{
808 Edje *ed;
809 Edje_Part_Collection *col;
810 Edje_Part **part;
811 char *p;
812 unsigned int i;
813
814 CHKPARAM(1);
815 ed = embryo_program_data_get(ep);
816 GETSTR(p, params[1]);
817 if (!p) return -1;
818 col = ed->collection;
819 if (!col) return -1;
820 part = col->parts;
821 for (i = 0; i < col->parts_count; i++, part++)
822 {
823 if (!(*part)->name) continue;
824 if (!strcmp((*part)->name, p)) return (*part)->id;
825 }
826 return -1;
827}
828
829static Embryo_Cell
830_edje_embryo_fn_play_sample(Embryo_Program *ep, Embryo_Cell *params)
831{
832 Edje *ed;
833 char *sample_name = NULL;
834 float speed = 1.0;
835
836 CHKPARAM(1);
837 ed = embryo_program_data_get(ep);
838 GETSTR(sample_name, params[1]);
839 if ((!sample_name)) return 0;
840 speed = EMBRYO_CELL_TO_FLOAT(params[2]);
841 _edje_multisense_internal_sound_sample_play(ed, sample_name, (double)speed);
842 return 0;
843}
844
845static Embryo_Cell
846_edje_embryo_fn_play_tone(Embryo_Program *ep, Embryo_Cell *params)
847{
848 Edje *ed;
849 char *tone_name = NULL;
850 float duration = 0.1;
851
852 CHKPARAM(2);
853 ed = embryo_program_data_get(ep);
854 GETSTR(tone_name, params[1]);
855 if ((!tone_name)) return 0;
856 duration = EMBRYO_CELL_TO_FLOAT(params[2]);
857 _edje_multisense_internal_sound_tone_play(ed, tone_name, (double) duration);
858 return 0;
859}
860
861/* set_state(part_id, state[], Float:state_val) */
862static Embryo_Cell
863_edje_embryo_fn_set_state(Embryo_Program *ep, Embryo_Cell *params)
864{
865 Edje *ed;
866 char *state = NULL;
867 int part_id = 0;
868 float f = 0.0;
869 double value = 0.0;
870 Edje_Real_Part *rp;
871
872 CHKPARAM(3);
873 ed = embryo_program_data_get(ep);
874 GETSTR(state, params[2]);
875 if ((!state)) return 0;
876 part_id = params[1];
877 if (part_id < 0) return 0;
878 f = EMBRYO_CELL_TO_FLOAT(params[3]);
879 value = (double)f;
880 rp = ed->table_parts[part_id % ed->table_parts_size];
881 if (rp)
882 {
883 if (rp->program) _edje_program_end(ed, rp->program);
884 _edje_part_description_apply(ed, rp, state, value, NULL, 0.0);
885 _edje_part_pos_set(ed, rp, EDJE_TWEEN_MODE_LINEAR, ZERO, ZERO, ZERO);
886 _edje_recalc(ed);
887 }
888 return 0;
889}
890
891/* get_state(part_id, dst[], maxlen, &Float:val) */
892static Embryo_Cell
893_edje_embryo_fn_get_state(Embryo_Program *ep, Embryo_Cell *params)
894{
895 Edje *ed;
896 int part_id = 0;
897 Edje_Real_Part *rp;
898 const char *s;
899
900 CHKPARAM(4);
901 ed = embryo_program_data_get(ep);
902 part_id = params[1];
903 if (part_id < 0) return 0;
904 rp = ed->table_parts[part_id % ed->table_parts_size];
905 if (rp->chosen_description)
906 {
907 SETFLOAT(rp->chosen_description->state.value, params[4]);
908 s = rp->chosen_description->state.name;
909 if (s)
910 {
911 if ((int) strlen(s) < params[3])
912 {
913 SETSTR(s, params[2]);
914 }
915 else
916 {
917 char *ss;
918
919 ss = alloca(strlen(s) + 1);
920 strcpy(ss, s);
921 ss[params[3] - 1] = 0;
922 SETSTR(ss, params[2]);
923 }
924 }
925 else
926 {
927 SETSTR("", params[2]);
928 }
929 }
930 else
931 {
932 SETFLOAT(0.0, params[4]);
933 SETSTR("", params[2]);
934 }
935 return 0;
936}
937
938/* set_tween_state(part_id, Float:tween, state1[], Float:state1_val, state2[], Float:state2_val) */
939static Embryo_Cell
940_edje_embryo_fn_set_tween_state(Embryo_Program *ep, Embryo_Cell *params)
941{
942 Edje *ed;
943 char *state1 = NULL, *state2 = NULL;
944 int part_id = 0;
945 float f = 0.0;
946 double tween = 0.0, value1 = 0.0, value2 = 0.0;
947 Edje_Real_Part *rp;
948
949 CHKPARAM(6);
950 ed = embryo_program_data_get(ep);
951 GETSTR(state1, params[3]);
952 GETSTR(state2, params[5]);
953 if ((!state1) || (!state2)) return 0;
954 part_id = params[1];
955 if (part_id < 0) return 0;
956 f = EMBRYO_CELL_TO_FLOAT(params[2]);
957 tween = (double)f;
958 f = EMBRYO_CELL_TO_FLOAT(params[4]);
959 value1 = (double)f;
960 f = EMBRYO_CELL_TO_FLOAT(params[6]);
961 value2 = (double)f;
962 rp = ed->table_parts[part_id % ed->table_parts_size];
963 if (rp)
964 {
965 if (rp->program) _edje_program_end(ed, rp->program);
966 _edje_part_description_apply(ed, rp, state1, value1, state2, value2);
967 _edje_part_pos_set(ed, rp, EDJE_TWEEN_MODE_LINEAR, FROM_DOUBLE(tween), ZERO, ZERO);
968 _edje_recalc(ed);
969 }
970 return 0;
971}
972
973/* run_program(program_id) */
974static Embryo_Cell
975_edje_embryo_fn_run_program(Embryo_Program *ep, Embryo_Cell *params)
976{
977 Edje *ed;
978 int program_id = 0;
979 Edje_Program *pr;
980
981 CHKPARAM(1);
982 ed = embryo_program_data_get(ep);
983 program_id = params[1];
984 if (program_id < 0) return 0;
985 pr = ed->table_programs[program_id % ed->table_programs_size];
986 if (pr)
987 {
988 _edje_program_run(ed, pr, 0, "", "");
989 }
990 return 0;
991}
992
993/* get_drag_dir(part_id) */
994static Embryo_Cell
995_edje_embryo_fn_get_drag_dir(Embryo_Program *ep, Embryo_Cell *params)
996{
997 Edje *ed;
998 int part_id = 0;
999 Edje_Real_Part *rp;
1000
1001 CHKPARAM(1);
1002 ed = embryo_program_data_get(ep);
1003 part_id = params[1];
1004 if (part_id < 0) return 0;
1005 rp = ed->table_parts[part_id % ed->table_parts_size];
1006 return edje_object_part_drag_dir_get(ed->obj, rp->part->name);
1007}
1008
1009/* get_drag(part_id, &Float:dx, &Float:dy) */
1010static Embryo_Cell
1011_edje_embryo_fn_get_drag(Embryo_Program *ep, Embryo_Cell *params)
1012{
1013 Edje *ed;
1014 int part_id = 0;
1015 Edje_Real_Part *rp;
1016 double dx = 0.0, dy = 0.0;
1017
1018 CHKPARAM(3);
1019 ed = embryo_program_data_get(ep);
1020 part_id = params[1];
1021 if (part_id < 0) return 0;
1022 rp = ed->table_parts[part_id % ed->table_parts_size];
1023 edje_object_part_drag_value_get(ed->obj, rp->part->name, &dx, &dy);
1024 SETFLOAT(dx, params[2]);
1025 SETFLOAT(dy, params[3]);
1026
1027 return 0;
1028}
1029
1030/* set_drag(part_id, Float:dx, Float:dy) */
1031static Embryo_Cell
1032_edje_embryo_fn_set_drag(Embryo_Program *ep, Embryo_Cell *params)
1033{
1034 Edje *ed;
1035 int part_id = 0;
1036 Edje_Real_Part *rp;
1037
1038 CHKPARAM(3);
1039 ed = embryo_program_data_get(ep);
1040 part_id = params[1];
1041 if (part_id < 0) return 0;
1042 rp = ed->table_parts[part_id % ed->table_parts_size];
1043 edje_object_part_drag_value_set(ed->obj, rp->part->name,
1044 (double)EMBRYO_CELL_TO_FLOAT(params[2]),
1045 (double)EMBRYO_CELL_TO_FLOAT(params[3]));
1046 return(0);
1047}
1048
1049/* get_drag_size(part_id, &Float:dx, &Float:dy) */
1050static Embryo_Cell
1051_edje_embryo_fn_get_drag_size(Embryo_Program *ep, Embryo_Cell *params)
1052{
1053 Edje *ed;
1054 int part_id = 0;
1055 Edje_Real_Part *rp;
1056 double dx = 0.0, dy = 0.0;
1057
1058 CHKPARAM(3);
1059 ed = embryo_program_data_get(ep);
1060 part_id = params[1];
1061 if (part_id < 0) return 0;
1062 rp = ed->table_parts[part_id % ed->table_parts_size];
1063 edje_object_part_drag_size_get(ed->obj, rp->part->name, &dx, &dy);
1064 SETFLOAT(dx, params[2]);
1065 SETFLOAT(dy, params[3]);
1066
1067 return 0;
1068}
1069
1070/* set_drag_size(part_id, Float:dx, Float:dy) */
1071static Embryo_Cell
1072_edje_embryo_fn_set_drag_size(Embryo_Program *ep, Embryo_Cell *params)
1073{
1074 Edje *ed;
1075 int part_id = 0;
1076 Edje_Real_Part *rp;
1077
1078 CHKPARAM(3);
1079 ed = embryo_program_data_get(ep);
1080 part_id = params[1];
1081 if (part_id < 0) return 0;
1082 rp = ed->table_parts[part_id % ed->table_parts_size];
1083 edje_object_part_drag_size_set(ed->obj, rp->part->name,
1084 (double)EMBRYO_CELL_TO_FLOAT(params[2]),
1085 (double)EMBRYO_CELL_TO_FLOAT(params[3]));
1086 return(0);
1087}
1088
1089/* set_text(part_id, str[]) */
1090static Embryo_Cell
1091_edje_embryo_fn_set_text(Embryo_Program *ep, Embryo_Cell *params)
1092{
1093 Edje *ed;
1094 int part_id = 0;
1095 Edje_Real_Part *rp;
1096 char *s;
1097
1098 CHKPARAM(2);
1099 ed = embryo_program_data_get(ep);
1100 part_id = params[1];
1101 if (part_id < 0) return 0;
1102 rp = ed->table_parts[part_id % ed->table_parts_size];
1103 GETSTR(s, params[2]);
1104 if (s){
1105 edje_object_part_text_set(ed->obj, rp->part->name, s);
1106 }
1107 return(0);
1108}
1109
1110/* get_text(part_id, dst[], maxlen) */
1111static Embryo_Cell
1112_edje_embryo_fn_get_text(Embryo_Program *ep, Embryo_Cell *params)
1113{
1114 Edje *ed;
1115 int part_id = 0;
1116 Edje_Real_Part *rp;
1117 char *s;
1118
1119 CHKPARAM(3);
1120 ed = embryo_program_data_get(ep);
1121 part_id = params[1];
1122 if (part_id < 0) return 0;
1123 rp = ed->table_parts[part_id % ed->table_parts_size];
1124 s = (char *)edje_object_part_text_get(ed->obj, rp->part->name);
1125 if (s)
1126 {
1127 if ((int) strlen(s) < params[3])
1128 {
1129 SETSTR(s, params[2]);
1130 }
1131 else
1132 {
1133 char *ss;
1134
1135 ss = alloca(strlen(s) + 1);
1136 strcpy(ss, s);
1137 ss[params[3] - 1] = 0;
1138 SETSTR(ss, params[2]);
1139 }
1140 }
1141 else
1142 {
1143 SETSTR("", params[2]);
1144 }
1145 return 0;
1146}
1147
1148/* get_min_size(&w, &h) */
1149static Embryo_Cell
1150_edje_embryo_fn_get_min_size(Embryo_Program *ep, Embryo_Cell *params)
1151{
1152 Edje *ed;
1153 Evas_Coord w = 0, h = 0;
1154
1155 CHKPARAM(2);
1156 ed = embryo_program_data_get(ep);
1157 edje_object_size_min_get(ed->obj, &w, &h);
1158 SETINT(w, params[1]);
1159 SETINT(h, params[2]);
1160 return 0;
1161}
1162
1163/* get_max_size(&w, &h) */
1164static Embryo_Cell
1165_edje_embryo_fn_get_max_size(Embryo_Program *ep, Embryo_Cell *params)
1166{
1167 Edje *ed;
1168 Evas_Coord w = 0, h = 0;
1169
1170 CHKPARAM(2);
1171 ed = embryo_program_data_get(ep);
1172 edje_object_size_max_get(ed->obj, &w, &h);
1173 SETINT(w, params[1]);
1174 SETINT(h, params[2]);
1175 return 0;
1176
1177}
1178
1179/* get_color_class(class[], &r, &g, &b, &a) */
1180static Embryo_Cell
1181_edje_embryo_fn_get_color_class(Embryo_Program *ep, Embryo_Cell *params)
1182{
1183 Edje *ed;
1184 Edje_Color_Class *c_class;
1185 char *class;
1186
1187 CHKPARAM(5);
1188 ed = embryo_program_data_get(ep);
1189 GETSTR(class, params[1]);
1190 if (!class) return 0;
1191 c_class = _edje_color_class_find(ed, class);
1192 if (!c_class) return 0;
1193 SETINT(c_class->r, params[2]);
1194 SETINT(c_class->g, params[3]);
1195 SETINT(c_class->b, params[4]);
1196 SETINT(c_class->a, params[5]);
1197 return 0;
1198}
1199
1200/* set_color_class(class[], r, g, b, a) */
1201static Embryo_Cell
1202_edje_embryo_fn_set_color_class(Embryo_Program *ep, Embryo_Cell *params)
1203{
1204 Edje *ed;
1205 char *class;
1206
1207 CHKPARAM(5);
1208 ed = embryo_program_data_get(ep);
1209 GETSTR(class, params[1]);
1210 if (!class) return 0;
1211 edje_object_color_class_set(ed->obj, class, params[2], params[3], params[4], params[5],
1212 params[2], params[3], params[4], params[5],
1213 params[2], params[3], params[4], params[5]);
1214 return 0;
1215}
1216
1217/* set_text_class(class[], font[], Float:size) */
1218static Embryo_Cell
1219_edje_embryo_fn_set_text_class(Embryo_Program *ep, Embryo_Cell *params)
1220{
1221 Edje *ed;
1222 char *class, *font;
1223 Evas_Font_Size fsize;
1224
1225 CHKPARAM(3);
1226 ed = embryo_program_data_get(ep);
1227 GETSTR(class, params[1]);
1228 GETSTR(font, params[2]);
1229 if( !class || !font ) return 0;
1230 fsize = (Evas_Font_Size) EMBRYO_CELL_TO_FLOAT(params[3]);
1231 edje_object_text_class_set(ed->obj, class, font, fsize);
1232 return 0;
1233}
1234
1235/* get_text_class(class[], font[], &Float:size) */
1236static Embryo_Cell
1237_edje_embryo_fn_get_text_class(Embryo_Program *ep, Embryo_Cell *params)
1238{
1239 Edje *ed;
1240 char *class;
1241 Edje_Text_Class *t_class;
1242
1243 CHKPARAM(3);
1244 ed = embryo_program_data_get(ep);
1245 GETSTR(class, params[1]);
1246 if (!class) return 0;
1247 t_class = _edje_text_class_find(ed, class);
1248 if (!t_class) return 0;
1249 SETSTR((char *)t_class->font, params[2]);
1250 SETFLOAT(t_class->size, params[3]);
1251 return 0;
1252}
1253
1254/* get_drag_step(part_id, &Float:dx, &Float:&dy) */
1255static Embryo_Cell
1256_edje_embryo_fn_get_drag_step(Embryo_Program *ep, Embryo_Cell *params)
1257{
1258 Edje *ed;
1259 int part_id = 0;
1260 Edje_Real_Part *rp;
1261 double dx = 0.0, dy = 0.0;
1262
1263 CHKPARAM(3);
1264 ed = embryo_program_data_get(ep);
1265 part_id = params[1];
1266 if (part_id < 0) return 0;
1267 rp = ed->table_parts[part_id % ed->table_parts_size];
1268 edje_object_part_drag_step_get(ed->obj, rp->part->name, &dx, &dy);
1269 SETFLOAT(dx, params[2]);
1270 SETFLOAT(dy, params[3]);
1271
1272 return 0;
1273}
1274
1275/* set_drag_step(part_id, Float:dx, Float:dy) */
1276static Embryo_Cell
1277_edje_embryo_fn_set_drag_step(Embryo_Program *ep, Embryo_Cell *params)
1278{
1279 Edje *ed;
1280 int part_id = 0;
1281 Edje_Real_Part *rp;
1282
1283 CHKPARAM(3);
1284 ed = embryo_program_data_get(ep);
1285 part_id = params[1];
1286 if (part_id < 0) return 0;
1287 rp = ed->table_parts[part_id % ed->table_parts_size];
1288 edje_object_part_drag_step_set(ed->obj, rp->part->name,
1289 (double)EMBRYO_CELL_TO_FLOAT(params[2]),
1290 (double)EMBRYO_CELL_TO_FLOAT(params[3]));
1291 return(0);
1292}
1293
1294/* get_drag_page(part_id, &Float:dx, &Float:&dy) */
1295static Embryo_Cell
1296_edje_embryo_fn_get_drag_page(Embryo_Program *ep, Embryo_Cell *params)
1297{
1298 Edje *ed;
1299 int part_id = 0;
1300 Edje_Real_Part *rp;
1301 double dx = 0.0, dy = 0.0;
1302
1303 CHKPARAM(3);
1304 ed = embryo_program_data_get(ep);
1305 part_id = params[1];
1306 if (part_id < 0) return 0;
1307 rp = ed->table_parts[part_id % ed->table_parts_size];
1308 edje_object_part_drag_page_get(ed->obj, rp->part->name, &dx, &dy);
1309 SETFLOAT(dx, params[2]);
1310 SETFLOAT(dy, params[3]);
1311
1312 return 0;
1313}
1314
1315/* get_geometry(pard_id, &x, &y, &w, &h) */
1316static Embryo_Cell
1317_edje_embryo_fn_get_geometry(Embryo_Program *ep, Embryo_Cell *params)
1318{
1319 Edje *ed;
1320 int part_id = 0;
1321 Edje_Real_Part *rp;
1322 Evas_Coord x = 0.0, y = 0.0, w = 0.0, h = 0.0;
1323
1324 CHKPARAM(5);
1325 ed = embryo_program_data_get(ep);
1326 part_id = params[1];
1327 if (part_id < 0) return 0;
1328 rp = ed->table_parts[part_id % ed->table_parts_size];
1329 edje_object_part_geometry_get(ed->obj, rp->part->name, &x, &y, &w, &h);
1330 SETINT(x, params[2]);
1331 SETINT(y, params[3]);
1332 SETINT(w, params[4]);
1333 SETINT(h, params[5]);
1334
1335 return 0;
1336}
1337
1338/* set_drag_page(part_id, Float:dx, Float:dy) */
1339static Embryo_Cell
1340_edje_embryo_fn_set_drag_page(Embryo_Program *ep, Embryo_Cell *params)
1341{
1342 Edje *ed;
1343 int part_id = 0;
1344 Edje_Real_Part *rp;
1345
1346 CHKPARAM(3);
1347 ed = embryo_program_data_get(ep);
1348 part_id = params[1];
1349 if (part_id < 0) return 0;
1350 rp = ed->table_parts[part_id % ed->table_parts_size];
1351 edje_object_part_drag_page_set(ed->obj, rp->part->name,
1352 (double)EMBRYO_CELL_TO_FLOAT(params[2]),
1353 (double)EMBRYO_CELL_TO_FLOAT(params[3]));
1354 return(0);
1355}
1356
1357/* send_message(Msg_Type:type, id,...); */
1358static Embryo_Cell
1359_edje_embryo_fn_send_message(Embryo_Program *ep, Embryo_Cell *params)
1360{
1361 Edje *ed;
1362 Edje_Message_Type type;
1363 int id, i, n;
1364 Embryo_Cell *ptr;
1365
1366 if (params[0] < (int) (sizeof(Embryo_Cell) * (2))) return 0;
1367 ed = embryo_program_data_get(ep);
1368 type = params[1];
1369 id = params[2];
1370 switch (type)
1371 {
1372 case EDJE_MESSAGE_NONE:
1373 _edje_message_send(ed, EDJE_QUEUE_APP, type, id, NULL);
1374 break;
1375 case EDJE_MESSAGE_SIGNAL:
1376 break;
1377 case EDJE_MESSAGE_STRING:
1378 {
1379 Embryo_Cell *cptr;
1380
1381 cptr = embryo_data_address_get(ep, params[3]);
1382 if (cptr)
1383 {
1384 Edje_Message_String *emsg;
1385 int l;
1386 char *s;
1387
1388 l = embryo_data_string_length_get(ep, cptr);
1389 s = alloca(l + 1);
1390 s[0] = 0;
1391 embryo_data_string_get(ep, cptr, s);
1392 emsg = alloca(sizeof(Edje_Message_String));
1393 emsg->str = s;
1394 _edje_message_send(ed, EDJE_QUEUE_APP, type, id, emsg);
1395 }
1396 }
1397 break;
1398 case EDJE_MESSAGE_INT:
1399 {
1400 Edje_Message_Int *emsg;
1401
1402 emsg = alloca(sizeof(Edje_Message_Int));
1403 ptr = embryo_data_address_get(ep, params[3]);
1404 if (ptr) emsg->val = (int)*ptr;
1405 else emsg->val = 0;
1406 _edje_message_send(ed, EDJE_QUEUE_APP, type, id, emsg);
1407 }
1408 break;
1409 case EDJE_MESSAGE_FLOAT:
1410 {
1411 Edje_Message_Float *emsg;
1412 float f;
1413
1414 emsg = alloca(sizeof(Edje_Message_Float));
1415 ptr = embryo_data_address_get(ep, params[3]);
1416 if (ptr)
1417 {
1418 f = EMBRYO_CELL_TO_FLOAT(*ptr);
1419 emsg->val = (double)f;
1420 }
1421 else
1422 emsg->val = 0.0;
1423 _edje_message_send(ed, EDJE_QUEUE_APP, type, id, emsg);
1424 }
1425 break;
1426 case EDJE_MESSAGE_STRING_SET:
1427 {
1428 Edje_Message_String_Set *emsg;
1429
1430 n = (params[0] / sizeof(Embryo_Cell)) + 1;
1431 emsg = alloca(sizeof(Edje_Message_String_Set) + ((n - 3 - 1) * sizeof(char *)));
1432 emsg->count = n - 3;
1433 for (i = 3; i < n; i++)
1434 {
1435 Embryo_Cell *cptr;
1436
1437 cptr = embryo_data_address_get(ep, params[i]);
1438 if (cptr)
1439 {
1440 int l;
1441 char *s;
1442
1443 l = embryo_data_string_length_get(ep, cptr);
1444 s = alloca(l + 1);
1445 s[0] = 0;
1446 embryo_data_string_get(ep, cptr, s);
1447 emsg->str[i - 3] = s;
1448 }
1449 }
1450 _edje_message_send(ed, EDJE_QUEUE_APP, type, id, emsg);
1451 }
1452 break;
1453 case EDJE_MESSAGE_INT_SET:
1454 {
1455 Edje_Message_Int_Set *emsg;
1456
1457 n = (params[0] / sizeof(Embryo_Cell)) + 1;
1458 emsg = alloca(sizeof(Edje_Message_Int_Set) + ((n - 3 - 1) * sizeof(int)));
1459 emsg->count = n - 3;
1460 for (i = 3; i < n; i++)
1461 {
1462 ptr = embryo_data_address_get(ep, params[i]);
1463 if (ptr) emsg->val[i - 3] = (int)*ptr;
1464 else emsg->val[i - 3] = 0;
1465 }
1466 _edje_message_send(ed, EDJE_QUEUE_APP, type, id, emsg);
1467 }
1468 break;
1469 case EDJE_MESSAGE_FLOAT_SET:
1470 {
1471 Edje_Message_Float_Set *emsg;
1472
1473 n = (params[0] / sizeof(Embryo_Cell)) + 1;
1474 emsg = alloca(sizeof(Edje_Message_Float_Set) + ((n - 3 - 1) * sizeof(double)));
1475 emsg->count = n - 3;
1476 for (i = 3; i < n; i++)
1477 {
1478 float f;
1479
1480 ptr = embryo_data_address_get(ep, params[i]);
1481 if (ptr)
1482 {
1483 f = EMBRYO_CELL_TO_FLOAT(*ptr);
1484 emsg->val[i - 3] = (double)f;
1485 }
1486 else
1487 emsg->val[i - 3] = 0.0;
1488 }
1489 _edje_message_send(ed, EDJE_QUEUE_APP, type, id, emsg);
1490 }
1491 break;
1492 case EDJE_MESSAGE_STRING_INT:
1493 {
1494 Edje_Message_String_Int *emsg;
1495 Embryo_Cell *cptr;
1496
1497 cptr = embryo_data_address_get(ep, params[3]);
1498 if (cptr)
1499 {
1500 int l;
1501 char *s;
1502
1503 l = embryo_data_string_length_get(ep, cptr);
1504 s = alloca(l + 1);
1505 s[0] = 0;
1506 embryo_data_string_get(ep, cptr, s);
1507 emsg = alloca(sizeof(Edje_Message_String_Int));
1508 emsg->str = s;
1509 ptr = embryo_data_address_get(ep, params[4]);
1510 if (ptr) emsg->val = (int)*ptr;
1511 else emsg->val = 0;
1512 _edje_message_send(ed, EDJE_QUEUE_APP, type, id, emsg);
1513 }
1514 }
1515 break;
1516 case EDJE_MESSAGE_STRING_FLOAT:
1517 {
1518 Edje_Message_String_Float *emsg;
1519 Embryo_Cell *cptr;
1520
1521 cptr = embryo_data_address_get(ep, params[3]);
1522 if (cptr)
1523 {
1524 int l;
1525 char *s;
1526 float f;
1527
1528 l = embryo_data_string_length_get(ep, cptr);
1529 s = alloca(l + 1);
1530 s[0] = 0;
1531 embryo_data_string_get(ep, cptr, s);
1532 emsg = alloca(sizeof(Edje_Message_String_Float));
1533 emsg->str = s;
1534 ptr = embryo_data_address_get(ep, params[4]);
1535 if (ptr)
1536 {
1537 f = EMBRYO_CELL_TO_FLOAT(*ptr);
1538 emsg->val = (double)f;
1539 }
1540 else
1541 emsg->val = 0.0;
1542 _edje_message_send(ed, EDJE_QUEUE_APP, type, id, emsg);
1543 }
1544 }
1545 break;
1546 case EDJE_MESSAGE_STRING_INT_SET:
1547 {
1548 Edje_Message_String_Int_Set *emsg;
1549 Embryo_Cell *cptr;
1550
1551 cptr = embryo_data_address_get(ep, params[3]);
1552 if (cptr)
1553 {
1554 int l;
1555 char *s;
1556
1557 l = embryo_data_string_length_get(ep, cptr);
1558 s = alloca(l + 1);
1559 s[0] = 0;
1560 embryo_data_string_get(ep, cptr, s);
1561 n = (params[0] / sizeof(Embryo_Cell)) + 1;
1562 emsg = alloca(sizeof(Edje_Message_String_Int_Set) + ((n - 4 - 1) * sizeof(int)));
1563 emsg->str = s;
1564 emsg->count = n - 4;
1565 for (i = 4; i < n; i++)
1566 {
1567 ptr = embryo_data_address_get(ep, params[i]);
1568 if (ptr) emsg->val[i - 4] = (int)*ptr;
1569 else emsg->val[i - 4] = 0;
1570 }
1571 _edje_message_send(ed, EDJE_QUEUE_APP, type, id, emsg);
1572 }
1573 }
1574 break;
1575 case EDJE_MESSAGE_STRING_FLOAT_SET:
1576 {
1577 Edje_Message_String_Float_Set *emsg;
1578 Embryo_Cell *cptr;
1579
1580 cptr = embryo_data_address_get(ep, params[3]);
1581 if (cptr)
1582 {
1583 int l;
1584 char *s;
1585
1586 l = embryo_data_string_length_get(ep, cptr);
1587 s = alloca(l + 1);
1588 s[0] = 0;
1589 embryo_data_string_get(ep, cptr, s);
1590 n = (params[0] / sizeof(Embryo_Cell)) + 1;
1591 emsg = alloca(sizeof(Edje_Message_String_Float_Set) + ((n - 4 - 1) * sizeof(double)));
1592 emsg->str = s;
1593 emsg->count = n - 4;
1594 for (i = 4; i < n; i++)
1595 {
1596 float f;
1597
1598 ptr = embryo_data_address_get(ep, params[i]);
1599 if (ptr)
1600 {
1601 f = EMBRYO_CELL_TO_FLOAT(*ptr);
1602 emsg->val[i - 4] = (double)f;
1603 }
1604 else
1605 emsg->val[i - 4] = 0.0;
1606 }
1607 _edje_message_send(ed, EDJE_QUEUE_APP, type, id, emsg);
1608 }
1609 }
1610 break;
1611 default:
1612 break;
1613 }
1614 return(0);
1615}
1616
1617/* custom_state(part_id, state[], Float:state_val = 0.0) */
1618static Embryo_Cell
1619_edje_embryo_fn_custom_state(Embryo_Program *ep, Embryo_Cell *params)
1620{
1621 Edje *ed = embryo_program_data_get(ep);
1622 Edje_Real_Part *rp;
1623 Edje_Part_Description_Common *parent, *d = NULL;
1624 char *name;
1625 float val;
1626
1627 CHKPARAM(3);
1628
1629 if (params[1] < 0)
1630 return 0;
1631
1632 if (!(rp = ed->table_parts[params[1] % ed->table_parts_size]))
1633 return 0;
1634
1635 /* check whether this part already has a "custom" state */
1636 if (rp->custom)
1637 return 0;
1638
1639 GETSTR(name, params[2]);
1640 if (!name)
1641 return 0;
1642
1643 val = EMBRYO_CELL_TO_FLOAT(params[3]);
1644
1645 if (!(parent = _edje_part_description_find(ed, rp, name, val)))
1646 return 0;
1647
1648 /* now create the custom state */
1649 switch (rp->part->type)
1650 {
1651#define ALLOC_DESC(Short, Type, To) \
1652 case EDJE_PART_TYPE_##Short: To = calloc(1, sizeof (Edje_Part_Description_##Type)); break;
1653
1654#define ALLOC_COPY_DESC(Short, Type, To, Spec) \
1655 case EDJE_PART_TYPE_##Short: \
1656 { \
1657 Edje_Part_Description_##Type *tmp; \
1658 Edje_Part_Description_##Type *new; \
1659 \
1660 tmp = (Edje_Part_Description_##Type *) parent; \
1661 \
1662 new = calloc(1, sizeof (Edje_Part_Description_##Type)); \
1663 new->Spec = tmp->Spec; \
1664 d = &new->common; \
1665 break; \
1666 }
1667
1668 ALLOC_DESC(RECTANGLE, Common, d);
1669 ALLOC_DESC(SWALLOW, Common, d);
1670 ALLOC_DESC(GROUP, Common, d);
1671
1672 ALLOC_COPY_DESC(IMAGE, Image, d, image);
1673 ALLOC_COPY_DESC(TEXT, Text, d, text);
1674 ALLOC_COPY_DESC(TEXTBLOCK, Text, d, text);
1675 ALLOC_COPY_DESC(BOX, Box, d, box);
1676 ALLOC_COPY_DESC(TABLE, Table, d, table);
1677 ALLOC_COPY_DESC(EXTERNAL, External, d, external_params);
1678 }
1679
1680 if (!d) return 0;
1681
1682 rp->custom = eina_mempool_malloc(_edje_real_part_state_mp, sizeof (Edje_Real_Part_State));
1683 if (!rp->custom)
1684 {
1685 free(d);
1686 return 0;
1687 }
1688
1689 memset(rp->custom, 0, sizeof (Edje_Real_Part_State));
1690
1691 *d = *parent;
1692
1693 d->state.name = (char *)eina_stringshare_add("custom");
1694 d->state.value = 0.0;
1695
1696 /* make sure all the allocated memory is getting copied,
1697 * not just referenced
1698 */
1699 if (rp->part->type == EDJE_PART_TYPE_IMAGE)
1700 {
1701 Edje_Part_Description_Image *img_desc;
1702 Edje_Part_Description_Image *parent_img_desc;
1703
1704 img_desc = (Edje_Part_Description_Image*) d;
1705 parent_img_desc = (Edje_Part_Description_Image*) parent;
1706
1707 img_desc->image.tweens_count = parent_img_desc->image.tweens_count;
1708 img_desc->image.tweens = calloc(img_desc->image.tweens_count,
1709 sizeof(Edje_Part_Image_Id*));
1710 if (img_desc->image.tweens)
1711 {
1712 unsigned int i;
1713
1714 for (i = 0; i < parent_img_desc->image.tweens_count; ++i)
1715 {
1716 Edje_Part_Image_Id *iid_new;
1717
1718 iid_new = calloc(1, sizeof(Edje_Part_Image_Id));
1719 if (!iid_new) continue;
1720
1721 *iid_new = *parent_img_desc->image.tweens[i];
1722
1723 img_desc->image.tweens[i] = iid_new;
1724 }
1725 }
1726 }
1727
1728#define DUP(x) x ? (char *)eina_stringshare_add(x) : NULL
1729 d->color_class = DUP(d->color_class);
1730
1731 if (rp->part->type == EDJE_PART_TYPE_TEXT
1732 || rp->part->type == EDJE_PART_TYPE_TEXTBLOCK)
1733 {
1734 Edje_Part_Description_Text *text_desc;
1735
1736 text_desc = (Edje_Part_Description_Text*) d;
1737
1738 text_desc->text.text_class = DUP(text_desc->text.text_class);
1739 text_desc->text.text.str = DUP(edje_string_get(&text_desc->text.text));
1740 text_desc->text.text.id = 0;
1741 text_desc->text.font.str = DUP(edje_string_get(&text_desc->text.font));
1742 text_desc->text.font.id = 0;
1743 text_desc->text.style.str = DUP(edje_string_get(&text_desc->text.style));
1744 text_desc->text.style.id = 0;
1745 }
1746#undef DUP
1747
1748 rp->custom->description = d;
1749
1750 return 0;
1751}
1752
1753/* set_state_val(part_id, State_Param:p, ...) */
1754static Embryo_Cell
1755_edje_embryo_fn_set_state_val(Embryo_Program *ep, Embryo_Cell *params)
1756{
1757 Edje *ed = embryo_program_data_get(ep);
1758 Edje_Real_Part *rp;
1759 char *s;
1760
1761 /* we need at least 3 arguments */
1762 if (params[0] < (int) (sizeof(Embryo_Cell) * 3))
1763 return 0;
1764
1765 if (params[1] < 0)
1766 return 0;
1767
1768 if (!(rp = ed->table_parts[params[1] % ed->table_parts_size]))
1769 return 0;
1770
1771 /* check whether this part has a "custom" state */
1772 if (!rp->custom)
1773 return 0;
1774
1775 switch (params[2])
1776 {
1777 case EDJE_STATE_PARAM_ALIGNMENT:
1778 CHKPARAM(4);
1779
1780 GETFLOAT_T(rp->custom->description->align.x, params[3]);
1781 GETFLOAT_T(rp->custom->description->align.y, params[4]);
1782
1783 break;
1784 case EDJE_STATE_PARAM_MIN:
1785 CHKPARAM(4);
1786
1787 GETINT(rp->custom->description->min.w, params[3]);
1788 GETINT(rp->custom->description->min.h, params[4]);
1789
1790 break;
1791 case EDJE_STATE_PARAM_MAX:
1792 CHKPARAM(4);
1793
1794 GETINT(rp->custom->description->max.w, params[3]);
1795 GETINT(rp->custom->description->max.h, params[4]);
1796
1797 break;
1798 case EDJE_STATE_PARAM_STEP:
1799 CHKPARAM(4);
1800
1801 GETINT(rp->custom->description->step.x, params[3]);
1802 GETINT(rp->custom->description->step.y, params[4]);
1803
1804 break;
1805 case EDJE_STATE_PARAM_ASPECT:
1806 CHKPARAM(4);
1807
1808 GETFLOAT_T(rp->custom->description->aspect.min, params[3]);
1809 GETFLOAT_T(rp->custom->description->aspect.max, params[4]);
1810
1811 break;
1812 case EDJE_STATE_PARAM_ASPECT_PREF:
1813 CHKPARAM(3);
1814
1815 GETINT(rp->custom->description->aspect.prefer, params[3]);
1816
1817 break;
1818 case EDJE_STATE_PARAM_COLOR:
1819 CHKPARAM(6);
1820
1821 GETINT(rp->custom->description->color.r, params[3]);
1822 GETINT(rp->custom->description->color.g, params[4]);
1823 GETINT(rp->custom->description->color.b, params[5]);
1824 GETINT(rp->custom->description->color.a, params[6]);
1825
1826 break;
1827 case EDJE_STATE_PARAM_COLOR2:
1828 CHKPARAM(6);
1829
1830 GETINT(rp->custom->description->color2.r, params[3]);
1831 GETINT(rp->custom->description->color2.g, params[4]);
1832 GETINT(rp->custom->description->color2.b, params[5]);
1833 GETINT(rp->custom->description->color2.a, params[6]);
1834
1835 break;
1836 case EDJE_STATE_PARAM_COLOR3:
1837 {
1838 Edje_Part_Description_Text *text;
1839
1840 if ( (rp->part->type != EDJE_PART_TYPE_TEXT) &&
1841 (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK))
1842 return 0;
1843
1844 CHKPARAM(6);
1845
1846 text = (Edje_Part_Description_Text*) rp->custom->description;
1847
1848 GETINT(text->text.color3.r, params[3]);
1849 GETINT(text->text.color3.g, params[4]);
1850 GETINT(text->text.color3.b, params[5]);
1851 GETINT(text->text.color3.a, params[6]);
1852 break;
1853 }
1854 case EDJE_STATE_PARAM_COLOR_CLASS:
1855 CHKPARAM(3);
1856
1857 GETSTR(s, params[3]);
1858 GETSTREVAS(s, rp->custom->description->color_class);
1859
1860 break;
1861 case EDJE_STATE_PARAM_REL1:
1862 CHKPARAM(4);
1863
1864 GETFLOAT_T(rp->custom->description->rel1.relative_x, params[3]);
1865 GETFLOAT_T(rp->custom->description->rel1.relative_y, params[4]);
1866
1867 break;
1868 case EDJE_STATE_PARAM_REL1_TO:
1869 CHKPARAM(4);
1870
1871 GETINT(rp->custom->description->rel1.id_x, params[3]);
1872 GETINT(rp->custom->description->rel1.id_y, params[4]);
1873
1874 if (rp->param1.description->rel1.id_x >= 0)
1875 rp->param1.rel1_to_x = ed->table_parts[rp->param1.description->rel1.id_x % ed->table_parts_size];
1876 if (rp->param1.description->rel1.id_y >= 0)
1877 rp->param1.rel1_to_y = ed->table_parts[rp->param1.description->rel1.id_y % ed->table_parts_size];
1878
1879 break;
1880 case EDJE_STATE_PARAM_REL1_OFFSET:
1881 CHKPARAM(4);
1882
1883 GETINT(rp->custom->description->rel1.offset_x, params[3]);
1884 GETINT(rp->custom->description->rel1.offset_y, params[4]);
1885
1886 break;
1887 case EDJE_STATE_PARAM_REL2:
1888 CHKPARAM(4);
1889
1890 GETFLOAT_T(rp->custom->description->rel2.relative_x, params[3]);
1891 GETFLOAT_T(rp->custom->description->rel2.relative_y, params[4]);
1892
1893 break;
1894 case EDJE_STATE_PARAM_REL2_TO:
1895 CHKPARAM(4);
1896
1897 GETINT(rp->custom->description->rel2.id_x, params[3]);
1898 GETINT(rp->custom->description->rel2.id_y, params[4]);
1899
1900 if (rp->param1.description->rel2.id_x >= 0)
1901 rp->param1.rel2_to_x = ed->table_parts[rp->param1.description->rel2.id_x % ed->table_parts_size];
1902 if (rp->param1.description->rel2.id_y >= 0)
1903 rp->param1.rel2_to_y = ed->table_parts[rp->param1.description->rel2.id_y % ed->table_parts_size];
1904
1905 break;
1906 case EDJE_STATE_PARAM_REL2_OFFSET:
1907 CHKPARAM(4);
1908
1909 GETINT(rp->custom->description->rel2.offset_x, params[3]);
1910 GETINT(rp->custom->description->rel2.offset_y, params[4]);
1911
1912 break;
1913 case EDJE_STATE_PARAM_IMAGE:
1914 {
1915 Edje_Part_Description_Image *img;
1916
1917 if ( (rp->part->type != EDJE_PART_TYPE_IMAGE) ) return 0;
1918 CHKPARAM(3);
1919
1920 img = (Edje_Part_Description_Image*) rp->custom->description;
1921 GETINT(img->image.id, params[3]);
1922
1923 break;
1924 }
1925 case EDJE_STATE_PARAM_BORDER:
1926 {
1927 Edje_Part_Description_Image *img;
1928
1929 if ( (rp->part->type != EDJE_PART_TYPE_IMAGE) ) return 0;
1930 CHKPARAM(6);
1931
1932 img = (Edje_Part_Description_Image*) rp->custom->description;
1933
1934 GETINT(img->image.border.l, params[3]);
1935 GETINT(img->image.border.r, params[4]);
1936 GETINT(img->image.border.t, params[5]);
1937 GETINT(img->image.border.b, params[6]);
1938
1939 break;
1940 }
1941 case EDJE_STATE_PARAM_FILL_SMOOTH:
1942 {
1943 Edje_Part_Description_Image *img;
1944
1945 if ( (rp->part->type != EDJE_PART_TYPE_IMAGE) ) return 0;
1946 CHKPARAM(3);
1947
1948 img = (Edje_Part_Description_Image*) rp->custom->description;
1949
1950 GETINT(img->image.fill.smooth, params[3]);
1951
1952 break;
1953 }
1954 case EDJE_STATE_PARAM_FILL_POS:
1955 {
1956 Edje_Part_Description_Image *img;
1957
1958 if ( (rp->part->type != EDJE_PART_TYPE_IMAGE) ) return 0;
1959 CHKPARAM(6);
1960
1961 img = (Edje_Part_Description_Image*) rp->custom->description;
1962
1963 GETFLOAT_T(img->image.fill.pos_rel_x, params[3]);
1964 GETFLOAT_T(img->image.fill.pos_rel_y, params[4]);
1965 GETINT(img->image.fill.pos_abs_x, params[5]);
1966 GETINT(img->image.fill.pos_abs_y, params[6]);
1967
1968 break;
1969 }
1970 case EDJE_STATE_PARAM_FILL_SIZE:
1971 {
1972 Edje_Part_Description_Image *img;
1973
1974 if ( (rp->part->type != EDJE_PART_TYPE_IMAGE) ) return 0;
1975 CHKPARAM(6);
1976
1977 img = (Edje_Part_Description_Image*) rp->custom->description;
1978
1979 GETFLOAT_T(img->image.fill.rel_x, params[3]);
1980 GETFLOAT_T(img->image.fill.rel_y, params[4]);
1981 GETINT(img->image.fill.abs_x, params[5]);
1982 GETINT(img->image.fill.abs_y, params[6]);
1983
1984 break;
1985 }
1986 case EDJE_STATE_PARAM_TEXT:
1987 {
1988 Edje_Part_Description_Text *text;
1989
1990 if ( (rp->part->type != EDJE_PART_TYPE_TEXT) &&
1991 (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK))
1992 return 0;
1993 CHKPARAM(3);
1994
1995 GETSTR(s, params[3]);
1996
1997 text = (Edje_Part_Description_Text*) rp->custom->description;
1998 GETSTREVAS(s, text->text.text.str);
1999
2000 break;
2001 }
2002 case EDJE_STATE_PARAM_TEXT_CLASS:
2003 {
2004 Edje_Part_Description_Text *text;
2005
2006 if ( (rp->part->type != EDJE_PART_TYPE_TEXT) &&
2007 (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK))
2008 return 0;
2009 CHKPARAM(3);
2010
2011 GETSTR(s, params[3]);
2012
2013 text = (Edje_Part_Description_Text*) rp->custom->description;
2014 GETSTREVAS(s, text->text.text_class);
2015
2016 break;
2017 }
2018 case EDJE_STATE_PARAM_TEXT_FONT:
2019 {
2020 Edje_Part_Description_Text *text;
2021
2022 if ((rp->part->type != EDJE_PART_TYPE_TEXT)) return 0;
2023 CHKPARAM(3);
2024
2025 GETSTR(s, params[3]);
2026
2027 text = (Edje_Part_Description_Text*) rp->custom->description;
2028 GETSTREVAS(s, text->text.font.str);
2029
2030 break;
2031 }
2032 case EDJE_STATE_PARAM_TEXT_STYLE:
2033 {
2034 Edje_Part_Description_Text *text;
2035
2036 if ((rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) return 0;
2037 CHKPARAM(3);
2038
2039 GETSTR(s, params[3]);
2040
2041 text = (Edje_Part_Description_Text*) rp->custom->description;
2042 GETSTREVAS(s, text->text.style.str);
2043
2044 break;
2045 }
2046 case EDJE_STATE_PARAM_TEXT_SIZE:
2047 {
2048 Edje_Part_Description_Text *text;
2049
2050 if ((rp->part->type != EDJE_PART_TYPE_TEXT)) return 0;
2051 CHKPARAM(3);
2052
2053 text = (Edje_Part_Description_Text*) rp->custom->description;
2054 GETINT(text->text.size, params[3]);
2055
2056 break;
2057 }
2058 case EDJE_STATE_PARAM_TEXT_FIT:
2059 {
2060 Edje_Part_Description_Text *text;
2061
2062 if ((rp->part->type != EDJE_PART_TYPE_TEXT)) return 0;
2063 CHKPARAM(4);
2064
2065 text = (Edje_Part_Description_Text*) rp->custom->description;
2066
2067 GETINT(text->text.fit_x, params[3]);
2068 GETINT(text->text.fit_y, params[4]);
2069
2070 break;
2071 }
2072 case EDJE_STATE_PARAM_TEXT_MIN:
2073 {
2074 Edje_Part_Description_Text *text;
2075
2076 if ( (rp->part->type != EDJE_PART_TYPE_TEXT) &&
2077 (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK))
2078 return 0;
2079 CHKPARAM(4);
2080
2081 text = (Edje_Part_Description_Text*) rp->custom->description;
2082
2083 GETINT(text->text.min_x, params[3]);
2084 GETINT(text->text.min_y, params[4]);
2085
2086 break;
2087 }
2088 case EDJE_STATE_PARAM_TEXT_MAX:
2089 {
2090 Edje_Part_Description_Text *text;
2091
2092 if ( (rp->part->type != EDJE_PART_TYPE_TEXT) &&
2093 (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK))
2094 return 0;
2095 CHKPARAM(4);
2096
2097 text = (Edje_Part_Description_Text*) rp->custom->description;
2098
2099 GETINT(text->text.max_x, params[3]);
2100 GETINT(text->text.max_y, params[4]);
2101
2102 break;
2103 }
2104 case EDJE_STATE_PARAM_TEXT_ALIGN:
2105 {
2106 Edje_Part_Description_Text *text;
2107
2108 if ((rp->part->type != EDJE_PART_TYPE_TEXT)) return 0;
2109 CHKPARAM(4);
2110
2111 text = (Edje_Part_Description_Text*) rp->custom->description;
2112
2113 GETFLOAT_T(text->text.align.x, params[3]);
2114 GETFLOAT_T(text->text.align.y, params[4]);
2115
2116 break;
2117 }
2118 case EDJE_STATE_PARAM_VISIBLE:
2119 CHKPARAM(3);
2120
2121 GETINT(rp->custom->description->visible, params[3]);
2122
2123 break;
2124 case EDJE_STATE_PARAM_MAP_OM:
2125 CHKPARAM(3);
2126
2127 GETINT(rp->custom->description->map.on, params[3]);
2128
2129 break;
2130 case EDJE_STATE_PARAM_MAP_PERSP:
2131 CHKPARAM(3);
2132
2133 GETINT(rp->custom->description->map.id_persp, params[3]);
2134
2135 break;
2136 case EDJE_STATE_PARAM_MAP_LIGNT:
2137 CHKPARAM(3);
2138
2139 GETINT(rp->custom->description->map.id_light, params[3]);
2140
2141 break;
2142 case EDJE_STATE_PARAM_MAP_ROT_CENTER:
2143 CHKPARAM(3);
2144
2145 GETINT(rp->custom->description->map.rot.id_center, params[3]);
2146
2147 break;
2148 case EDJE_STATE_PARAM_MAP_ROT_X:
2149 CHKPARAM(3);
2150
2151 GETFLOAT_T(rp->custom->description->map.rot.x, params[3]);
2152
2153 break;
2154 case EDJE_STATE_PARAM_MAP_ROT_Y:
2155 CHKPARAM(3);
2156
2157 GETFLOAT_T(rp->custom->description->map.rot.y, params[3]);
2158
2159 break;
2160 case EDJE_STATE_PARAM_MAP_ROT_Z:
2161 CHKPARAM(3);
2162
2163 GETFLOAT_T(rp->custom->description->map.rot.z, params[3]);
2164
2165 break;
2166 case EDJE_STATE_PARAM_MAP_BACK_CULL:
2167 CHKPARAM(3);
2168
2169 GETINT(rp->custom->description->map.backcull, params[3]);
2170
2171 break;
2172 case EDJE_STATE_PARAM_MAP_PERSP_ON:
2173 CHKPARAM(3);
2174
2175 GETINT(rp->custom->description->map.persp_on, params[3]);
2176
2177 break;
2178 case EDJE_STATE_PARAM_PERSP_ZPLANE:
2179 CHKPARAM(3);
2180
2181 GETINT(rp->custom->description->persp.zplane, params[3]);
2182
2183 break;
2184 case EDJE_STATE_PARAM_PERSP_FOCAL:
2185 CHKPARAM(3);
2186
2187 GETINT(rp->custom->description->persp.focal, params[3]);
2188
2189 break;
2190 default:
2191 break;
2192 }
2193
2194#ifdef EDJE_CALC_CACHE
2195 rp->invalidate = 1;
2196#endif
2197 ed->dirty=1;
2198 return 0;
2199}
2200
2201/* get_state_val(part_id, State_Param:p, ...) */
2202static Embryo_Cell
2203_edje_embryo_fn_get_state_val(Embryo_Program *ep, Embryo_Cell *params)
2204{
2205 Edje *ed = embryo_program_data_get(ep);
2206 Edje_Real_Part *rp;
2207 char *s;
2208
2209 /* we need at least 3 arguments */
2210 if (params[0] < (int) (sizeof(Embryo_Cell) * 3))
2211 return 0;
2212
2213 if (params[1] < 0)
2214 return 0;
2215
2216 if (!(rp = ed->table_parts[params[1] % ed->table_parts_size]))
2217 return 0;
2218
2219 /* check whether this part has a "custom" state */
2220 if (!rp->custom)
2221 return 0;
2222
2223 switch (params[2])
2224 {
2225 case EDJE_STATE_PARAM_ALIGNMENT:
2226 CHKPARAM(4);
2227
2228 SETFLOAT_T(rp->custom->description->align.x, params[3]);
2229 SETFLOAT_T(rp->custom->description->align.y, params[4]);
2230
2231 break;
2232 case EDJE_STATE_PARAM_MIN:
2233 CHKPARAM(4);
2234
2235 SETINT(rp->custom->description->min.w, params[3]);
2236 SETINT(rp->custom->description->min.h, params[4]);
2237
2238 break;
2239 case EDJE_STATE_PARAM_MAX:
2240 CHKPARAM(4);
2241
2242 SETINT(rp->custom->description->max.w, params[3]);
2243 SETINT(rp->custom->description->max.h, params[4]);
2244
2245 break;
2246 case EDJE_STATE_PARAM_STEP:
2247 CHKPARAM(4);
2248
2249 SETINT(rp->custom->description->step.x, params[3]);
2250 SETINT(rp->custom->description->step.y, params[4]);
2251
2252 break;
2253 case EDJE_STATE_PARAM_ASPECT:
2254 CHKPARAM(4);
2255
2256 SETFLOAT_T(rp->custom->description->aspect.min, params[3]);
2257 SETFLOAT_T(rp->custom->description->aspect.max, params[4]);
2258
2259 break;
2260 case EDJE_STATE_PARAM_ASPECT_PREF:
2261 CHKPARAM(3);
2262
2263 SETINT(rp->custom->description->aspect.prefer, params[3]);
2264
2265 break;
2266 case EDJE_STATE_PARAM_COLOR:
2267 CHKPARAM(6);
2268
2269 SETINT(rp->custom->description->color.r, params[3]);
2270 SETINT(rp->custom->description->color.g, params[4]);
2271 SETINT(rp->custom->description->color.b, params[5]);
2272 SETINT(rp->custom->description->color.a, params[6]);
2273
2274 break;
2275 case EDJE_STATE_PARAM_COLOR2:
2276 CHKPARAM(6);
2277
2278 SETINT(rp->custom->description->color2.r, params[3]);
2279 SETINT(rp->custom->description->color2.g, params[4]);
2280 SETINT(rp->custom->description->color2.b, params[5]);
2281 SETINT(rp->custom->description->color2.a, params[6]);
2282
2283 break;
2284 case EDJE_STATE_PARAM_COLOR3:
2285 {
2286 Edje_Part_Description_Text *text;
2287
2288 if (rp->part->type == EDJE_PART_TYPE_TEXT
2289 || rp->part->type == EDJE_PART_TYPE_TEXTBLOCK)
2290 return 0;
2291
2292 CHKPARAM(6);
2293
2294 text = (Edje_Part_Description_Text*) rp->custom->description;
2295
2296 SETINT(text->text.color3.r, params[3]);
2297 SETINT(text->text.color3.g, params[4]);
2298 SETINT(text->text.color3.b, params[5]);
2299 SETINT(text->text.color3.a, params[6]);
2300
2301 break;
2302 }
2303 case EDJE_STATE_PARAM_COLOR_CLASS:
2304 CHKPARAM(4);
2305
2306 s = rp->custom->description->color_class;
2307 SETSTRALLOCATE(s);
2308
2309 break;
2310 case EDJE_STATE_PARAM_REL1:
2311 CHKPARAM(4);
2312
2313 SETFLOAT_T(rp->custom->description->rel1.relative_x, params[3]);
2314 SETFLOAT_T(rp->custom->description->rel1.relative_y, params[4]);
2315
2316 break;
2317 case EDJE_STATE_PARAM_REL1_TO:
2318 CHKPARAM(4);
2319
2320 SETINT(rp->custom->description->rel1.id_x, params[3]);
2321 SETINT(rp->custom->description->rel1.id_y, params[4]);
2322
2323 break;
2324 case EDJE_STATE_PARAM_REL1_OFFSET:
2325 CHKPARAM(4);
2326
2327 SETINT(rp->custom->description->rel1.offset_x, params[3]);
2328 SETINT(rp->custom->description->rel1.offset_y, params[4]);
2329
2330 break;
2331 case EDJE_STATE_PARAM_REL2:
2332 CHKPARAM(4);
2333
2334 SETFLOAT_T(rp->custom->description->rel2.relative_x, params[3]);
2335 SETFLOAT_T(rp->custom->description->rel2.relative_y, params[4]);
2336
2337 break;
2338 case EDJE_STATE_PARAM_REL2_TO:
2339 CHKPARAM(4);
2340
2341 SETINT(rp->custom->description->rel2.id_x, params[3]);
2342 SETINT(rp->custom->description->rel2.id_y, params[4]);
2343
2344 break;
2345 case EDJE_STATE_PARAM_REL2_OFFSET:
2346 CHKPARAM(4);
2347
2348 SETINT(rp->custom->description->rel2.offset_x, params[3]);
2349 SETINT(rp->custom->description->rel2.offset_y, params[4]);
2350
2351 break;
2352 case EDJE_STATE_PARAM_IMAGE:
2353 {
2354 Edje_Part_Description_Image *img;
2355
2356 if ( (rp->part->type != EDJE_PART_TYPE_IMAGE) ) return 0;
2357 CHKPARAM(3);
2358
2359 img = (Edje_Part_Description_Image*) rp->custom->description;
2360
2361 SETINT(img->image.id, params[3]);
2362
2363 break;
2364 }
2365 case EDJE_STATE_PARAM_BORDER:
2366 {
2367 Edje_Part_Description_Image *img;
2368
2369 if ( (rp->part->type != EDJE_PART_TYPE_IMAGE) ) return 0;
2370 CHKPARAM(6);
2371
2372 img = (Edje_Part_Description_Image*) rp->custom->description;
2373
2374 SETINT(img->image.border.l, params[3]);
2375 SETINT(img->image.border.r, params[4]);
2376 SETINT(img->image.border.t, params[5]);
2377 SETINT(img->image.border.b, params[6]);
2378
2379 break;
2380 }
2381 case EDJE_STATE_PARAM_FILL_SMOOTH:
2382 {
2383 Edje_Part_Description_Image *img;
2384
2385 if ( (rp->part->type != EDJE_PART_TYPE_IMAGE) ) return 0;
2386 CHKPARAM(3);
2387
2388 img = (Edje_Part_Description_Image*) rp->custom->description;
2389
2390 SETINT(img->image.fill.smooth, params[3]);
2391
2392 break;
2393 }
2394 case EDJE_STATE_PARAM_FILL_POS:
2395 {
2396 Edje_Part_Description_Image *img;
2397
2398 if ( (rp->part->type != EDJE_PART_TYPE_IMAGE) ) return 0;
2399 CHKPARAM(6);
2400
2401 img = (Edje_Part_Description_Image*) rp->custom->description;
2402
2403 SETFLOAT_T(img->image.fill.pos_rel_x, params[3]);
2404 SETFLOAT_T(img->image.fill.pos_rel_y, params[4]);
2405 SETINT(img->image.fill.pos_abs_x, params[5]);
2406 SETINT(img->image.fill.pos_abs_y, params[6]);
2407
2408 break;
2409 }
2410 case EDJE_STATE_PARAM_FILL_SIZE:
2411 {
2412 Edje_Part_Description_Image *img;
2413
2414 if ( (rp->part->type != EDJE_PART_TYPE_IMAGE) ) return 0;
2415 CHKPARAM(6);
2416
2417 img = (Edje_Part_Description_Image*) rp->custom->description;
2418
2419 SETFLOAT_T(img->image.fill.rel_x, params[3]);
2420 SETFLOAT_T(img->image.fill.rel_y, params[4]);
2421 SETINT(img->image.fill.abs_x, params[5]);
2422 SETINT(img->image.fill.abs_y, params[6]);
2423
2424 break;
2425 }
2426 case EDJE_STATE_PARAM_TEXT:
2427 {
2428 Edje_Part_Description_Text *text;
2429
2430 if (rp->part->type == EDJE_PART_TYPE_TEXT
2431 || rp->part->type == EDJE_PART_TYPE_TEXTBLOCK)
2432 return 0;
2433
2434 CHKPARAM(4);
2435
2436 text = (Edje_Part_Description_Text*) rp->custom->description;
2437
2438 s = (char *)text->text.text.str;
2439 SETSTRALLOCATE(s);
2440
2441 break;
2442 }
2443 case EDJE_STATE_PARAM_TEXT_CLASS:
2444 {
2445 Edje_Part_Description_Text *text;
2446
2447 if ( (rp->part->type != EDJE_PART_TYPE_TEXT) &&
2448 (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK))
2449 return 0;
2450
2451 CHKPARAM(4);
2452
2453 text = (Edje_Part_Description_Text*) rp->custom->description;
2454
2455 s = text->text.text_class;
2456 SETSTRALLOCATE(s);
2457
2458 break;
2459 }
2460 case EDJE_STATE_PARAM_TEXT_FONT:
2461 {
2462 Edje_Part_Description_Text *text;
2463
2464 if ((rp->part->type != EDJE_PART_TYPE_TEXT)) return 0;
2465
2466 CHKPARAM(4);
2467
2468 text = (Edje_Part_Description_Text*) rp->custom->description;
2469
2470 s = (char *)text->text.font.str;
2471 SETSTRALLOCATE(s);
2472
2473 break;
2474 }
2475 case EDJE_STATE_PARAM_TEXT_STYLE:
2476 {
2477 Edje_Part_Description_Text *text;
2478
2479 if ((rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) return 0;
2480
2481 CHKPARAM(4);
2482
2483 text = (Edje_Part_Description_Text*) rp->custom->description;
2484
2485 s = (char *)text->text.style.str;
2486 SETSTRALLOCATE(s);
2487
2488 break;
2489 }
2490 case EDJE_STATE_PARAM_TEXT_SIZE:
2491 {
2492 Edje_Part_Description_Text *text;
2493
2494 if ((rp->part->type != EDJE_PART_TYPE_TEXT)) return 0;
2495
2496 CHKPARAM(3);
2497
2498 text = (Edje_Part_Description_Text*) rp->custom->description;
2499
2500 SETINT(text->text.size, params[3]);
2501
2502 break;
2503 }
2504 case EDJE_STATE_PARAM_TEXT_FIT:
2505 {
2506 Edje_Part_Description_Text *text;
2507
2508 if ((rp->part->type != EDJE_PART_TYPE_TEXT)) return 0;
2509 CHKPARAM(4);
2510
2511 text = (Edje_Part_Description_Text*) rp->custom->description;
2512
2513 SETINT(text->text.fit_x, params[3]);
2514 SETINT(text->text.fit_y, params[4]);
2515
2516 break;
2517 }
2518 case EDJE_STATE_PARAM_TEXT_MIN:
2519 {
2520 Edje_Part_Description_Text *text;
2521
2522 if ( (rp->part->type != EDJE_PART_TYPE_TEXT) &&
2523 (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK))
2524 return 0;
2525
2526 CHKPARAM(4);
2527
2528 text = (Edje_Part_Description_Text*) rp->custom->description;
2529
2530 SETINT(text->text.min_x, params[3]);
2531 SETINT(text->text.min_y, params[4]);
2532
2533 break;
2534 }
2535 case EDJE_STATE_PARAM_TEXT_MAX:
2536 {
2537 Edje_Part_Description_Text *text;
2538
2539 if ( (rp->part->type != EDJE_PART_TYPE_TEXT) &&
2540 (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK))
2541 return 0;
2542
2543 CHKPARAM(4);
2544
2545 text = (Edje_Part_Description_Text*) rp->custom->description;
2546
2547 SETINT(text->text.max_x, params[3]);
2548 SETINT(text->text.max_y, params[4]);
2549
2550 break;
2551 }
2552 case EDJE_STATE_PARAM_TEXT_ALIGN:
2553 {
2554 Edje_Part_Description_Text *text;
2555
2556 if ((rp->part->type != EDJE_PART_TYPE_TEXT)) return 0;
2557
2558 CHKPARAM(4);
2559
2560 text = (Edje_Part_Description_Text*) rp->custom->description;
2561
2562 SETFLOAT_T(text->text.align.x, params[3]);
2563 SETFLOAT_T(text->text.align.y, params[4]);
2564
2565 break;
2566 }
2567 case EDJE_STATE_PARAM_VISIBLE:
2568 CHKPARAM(3);
2569
2570 SETINT(rp->custom->description->visible, params[3]);
2571
2572 break;
2573 default:
2574 break;
2575 }
2576
2577 return 0;
2578}
2579
2580/* part_swallow(part_id, group_name) */
2581static Embryo_Cell
2582_edje_embryo_fn_part_swallow(Embryo_Program *ep, Embryo_Cell *params)
2583{
2584 int part_id = 0;
2585 char* group_name = 0;
2586 Edje *ed;
2587 Edje_Real_Part *rp;
2588 Evas_Object *new_obj;
2589
2590 CHKPARAM(2);
2591
2592 part_id = params[1];
2593 if (part_id < 0) return 0;
2594
2595 GETSTR(group_name, params[2]);
2596 if (!group_name) return 0;
2597
2598 ed = embryo_program_data_get(ep);
2599
2600 rp = ed->table_parts[part_id % ed->table_parts_size];
2601 if (!rp) return 0;
2602
2603 new_obj = edje_object_add(ed->base.evas);
2604 if (!new_obj) return 0;
2605
2606 if (!edje_object_file_set(new_obj, ed->file->path, group_name))
2607 {
2608 evas_object_del(new_obj);
2609 return 0;
2610 }
2611 edje_object_part_swallow(ed->obj, rp->part->name, new_obj);
2612 _edje_subobj_register(ed, new_obj);
2613
2614 return 0;
2615}
2616
2617/* external_param_get_int(id, param_name[]) */
2618static Embryo_Cell
2619_edje_embryo_fn_external_param_get_int(Embryo_Program *ep, Embryo_Cell *params)
2620{
2621 Edje *ed;
2622 int part_id;
2623 Edje_Real_Part *rp;
2624 Edje_External_Param eep;
2625 char *param_name;
2626
2627 CHKPARAM(2);
2628 ed = embryo_program_data_get(ep);
2629
2630 part_id = params[1];
2631 if (part_id < 0) return 0;
2632 rp = ed->table_parts[part_id % ed->table_parts_size];
2633
2634 GETSTR(param_name, params[2]);
2635 if (!param_name) return 0;
2636 eep.name = param_name;
2637 eep.type = EDJE_EXTERNAL_PARAM_TYPE_INT;
2638 eep.i = 0;
2639 _edje_external_param_get(NULL, rp, &eep);
2640 return eep.i;
2641}
2642
2643/* external_param_set_int(id, param_name[], val) */
2644static Embryo_Cell
2645_edje_embryo_fn_external_param_set_int(Embryo_Program *ep, Embryo_Cell *params)
2646{
2647 Edje *ed;
2648 int part_id;
2649 Edje_Real_Part *rp;
2650 Edje_External_Param eep;
2651 char *param_name;
2652
2653 CHKPARAM(3);
2654 ed = embryo_program_data_get(ep);
2655
2656 part_id = params[1];
2657 if (part_id < 0) return 0;
2658 rp = ed->table_parts[part_id % ed->table_parts_size];
2659
2660 GETSTR(param_name, params[2]);
2661 if (!param_name) return 0;
2662 eep.name = param_name;
2663 eep.type = EDJE_EXTERNAL_PARAM_TYPE_INT;
2664 eep.i = params[3];
2665 return _edje_external_param_set(NULL, rp, &eep);
2666}
2667
2668/* Float:external_param_get_float(id, param_name[]) */
2669static Embryo_Cell
2670_edje_embryo_fn_external_param_get_float(Embryo_Program *ep, Embryo_Cell *params)
2671{
2672 Edje *ed;
2673 int part_id;
2674 Edje_Real_Part *rp;
2675 Edje_External_Param eep;
2676 char *param_name;
2677 float v;
2678
2679 CHKPARAM(2);
2680 ed = embryo_program_data_get(ep);
2681
2682 part_id = params[1];
2683 if (part_id < 0) return 0;
2684 rp = ed->table_parts[part_id % ed->table_parts_size];
2685
2686 GETSTR(param_name, params[2]);
2687 if (!param_name) return 0;
2688 eep.name = param_name;
2689 eep.type = EDJE_EXTERNAL_PARAM_TYPE_DOUBLE;
2690 eep.d = 0.0;
2691 _edje_external_param_get(NULL, rp, &eep);
2692 v = eep.d;
2693 return EMBRYO_FLOAT_TO_CELL(v);
2694}
2695
2696/* external_param_set_float(id, param_name[], Float:val) */
2697static Embryo_Cell
2698_edje_embryo_fn_external_param_set_float(Embryo_Program *ep, Embryo_Cell *params)
2699{
2700 Edje *ed;
2701 int part_id;
2702 Edje_Real_Part *rp;
2703 Edje_External_Param eep;
2704 char *param_name;
2705
2706 CHKPARAM(3);
2707 ed = embryo_program_data_get(ep);
2708
2709 part_id = params[1];
2710 if (part_id < 0) return 0;
2711 rp = ed->table_parts[part_id % ed->table_parts_size];
2712
2713 GETSTR(param_name, params[2]);
2714 if (!param_name) return 0;
2715 eep.name = param_name;
2716 eep.type = EDJE_EXTERNAL_PARAM_TYPE_DOUBLE;
2717 eep.d = EMBRYO_CELL_TO_FLOAT(params[3]);
2718 return _edje_external_param_set(NULL, rp, &eep);
2719}
2720
2721/* external_param_get_strlen(id, param_name[]) */
2722static Embryo_Cell
2723_edje_embryo_fn_external_param_get_strlen(Embryo_Program *ep, Embryo_Cell *params)
2724{
2725 Edje *ed;
2726 int part_id;
2727 Edje_Real_Part *rp;
2728 Edje_External_Param eep;
2729 char *param_name;
2730
2731 CHKPARAM(2);
2732 ed = embryo_program_data_get(ep);
2733
2734 part_id = params[1];
2735 if (part_id < 0) return 0;
2736 rp = ed->table_parts[part_id % ed->table_parts_size];
2737
2738 GETSTR(param_name, params[2]);
2739 if (!param_name) return 0;
2740 eep.name = param_name;
2741 eep.type = EDJE_EXTERNAL_PARAM_TYPE_STRING;
2742 eep.s = NULL;
2743 _edje_external_param_get(NULL, rp, &eep);
2744 if (!eep.s) return 0;
2745 return strlen(eep.s);
2746}
2747
2748/* external_param_get_str(id, param_name[], val[], val_maxlen) */
2749static Embryo_Cell
2750_edje_embryo_fn_external_param_get_str(Embryo_Program *ep, Embryo_Cell *params)
2751{
2752 Edje *ed;
2753 int part_id;
2754 Edje_Real_Part *rp;
2755 Edje_External_Param eep;
2756 char *param_name;
2757 size_t src_len, dst_len;
2758
2759 CHKPARAM(4);
2760 dst_len = params[4];
2761 if (dst_len < 1) goto error;
2762
2763 ed = embryo_program_data_get(ep);
2764
2765 part_id = params[1];
2766 if (part_id < 0) goto error;
2767 rp = ed->table_parts[part_id % ed->table_parts_size];
2768
2769 GETSTR(param_name, params[2]);
2770 if (!param_name) return 0;
2771 eep.name = param_name;
2772 eep.type = EDJE_EXTERNAL_PARAM_TYPE_STRING;
2773 eep.s = NULL;
2774 _edje_external_param_get(NULL, rp, &eep);
2775 if (!eep.s) goto error;
2776 src_len = strlen(eep.s);
2777 if (src_len < dst_len)
2778 {
2779 SETSTR(eep.s, params[3]);
2780 }
2781 else
2782 {
2783 char *tmp = alloca(dst_len);
2784 memcpy(tmp, eep.s, dst_len - 1);
2785 tmp[dst_len] = '\0';
2786 SETSTR(tmp, params[3]);
2787 }
2788 return 1;
2789
2790 error:
2791 SETSTR("", params[3]);
2792 return 0;
2793}
2794
2795/* external_param_set_str(id, param_name[], val[]) */
2796static Embryo_Cell
2797_edje_embryo_fn_external_param_set_str(Embryo_Program *ep, Embryo_Cell *params)
2798{
2799 Edje *ed;
2800 int part_id;
2801 Edje_Real_Part *rp;
2802 Edje_External_Param eep;
2803 char *param_name, *val;
2804
2805 CHKPARAM(3);
2806 ed = embryo_program_data_get(ep);
2807
2808 part_id = params[1];
2809 if (part_id < 0) return 0;
2810 rp = ed->table_parts[part_id % ed->table_parts_size];
2811
2812 GETSTR(param_name, params[2]);
2813 if (!param_name) return 0;
2814 eep.name = param_name;
2815 eep.type = EDJE_EXTERNAL_PARAM_TYPE_STRING;
2816 GETSTR(val, params[3]);
2817 if (!val) return 0;
2818 eep.s = val;
2819 return _edje_external_param_set(NULL, rp, &eep);
2820}
2821
2822/* external_param_get_choice_len(id, param_name[]) */
2823static Embryo_Cell
2824_edje_embryo_fn_external_param_get_choice_len(Embryo_Program *ep, Embryo_Cell *params)
2825{
2826 Edje *ed;
2827 int part_id;
2828 Edje_Real_Part *rp;
2829 Edje_External_Param eep;
2830 char *param_name;
2831
2832 CHKPARAM(2);
2833 ed = embryo_program_data_get(ep);
2834
2835 part_id = params[1];
2836 if (part_id < 0) return 0;
2837 rp = ed->table_parts[part_id % ed->table_parts_size];
2838
2839 GETSTR(param_name, params[2]);
2840 if (!param_name) return 0;
2841 eep.name = param_name;
2842 eep.type = EDJE_EXTERNAL_PARAM_TYPE_CHOICE;
2843 eep.s = NULL;
2844 _edje_external_param_get(NULL, rp, &eep);
2845 if (!eep.s) return 0;
2846 return strlen(eep.s);
2847}
2848
2849/* external_param_get_choice(id, param_name[], val[], val_maxlen) */
2850static Embryo_Cell
2851_edje_embryo_fn_external_param_get_choice(Embryo_Program *ep, Embryo_Cell *params)
2852{
2853 Edje *ed;
2854 int part_id;
2855 Edje_Real_Part *rp;
2856 Edje_External_Param eep;
2857 char *param_name;
2858 size_t src_len, dst_len;
2859
2860 CHKPARAM(4);
2861 dst_len = params[4];
2862 if (dst_len < 1) goto error;
2863
2864 ed = embryo_program_data_get(ep);
2865
2866 part_id = params[1];
2867 if (part_id < 0) goto error;
2868 rp = ed->table_parts[part_id % ed->table_parts_size];
2869
2870 GETSTR(param_name, params[2]);
2871 if (!param_name) return 0;
2872 eep.name = param_name;
2873 eep.type = EDJE_EXTERNAL_PARAM_TYPE_CHOICE;
2874 eep.s = NULL;
2875 _edje_external_param_get(NULL, rp, &eep);
2876 if (!eep.s) goto error;
2877 src_len = strlen(eep.s);
2878 if (src_len < dst_len)
2879 {
2880 SETSTR(eep.s, params[3]);
2881 }
2882 else
2883 {
2884 char *tmp = alloca(dst_len);
2885 memcpy(tmp, eep.s, dst_len - 1);
2886 tmp[dst_len] = '\0';
2887 SETSTR(tmp, params[3]);
2888 }
2889 return 1;
2890
2891 error:
2892 SETSTR("", params[3]);
2893 return 0;
2894}
2895
2896/* external_param_set_choice(id, param_name[], val[]) */
2897static Embryo_Cell
2898_edje_embryo_fn_external_param_set_choice(Embryo_Program *ep, Embryo_Cell *params)
2899{
2900 Edje *ed;
2901 int part_id;
2902 Edje_Real_Part *rp;
2903 Edje_External_Param eep;
2904 char *param_name, *val;
2905
2906 CHKPARAM(3);
2907 ed = embryo_program_data_get(ep);
2908
2909 part_id = params[1];
2910 if (part_id < 0) return 0;
2911 rp = ed->table_parts[part_id % ed->table_parts_size];
2912
2913 GETSTR(param_name, params[2]);
2914 if (!param_name) return 0;
2915 eep.name = param_name;
2916 eep.type = EDJE_EXTERNAL_PARAM_TYPE_CHOICE;
2917 GETSTR(val, params[3]);
2918 if (!val) return 0;
2919 eep.s = val;
2920 return _edje_external_param_set(NULL, rp, &eep);
2921}
2922
2923/* external_param_get_bool(id, param_name[]) */
2924static Embryo_Cell
2925_edje_embryo_fn_external_param_get_bool(Embryo_Program *ep, Embryo_Cell *params)
2926{
2927 Edje *ed;
2928 int part_id;
2929 Edje_Real_Part *rp;
2930 Edje_External_Param eep;
2931 char *param_name;
2932
2933 CHKPARAM(2);
2934 ed = embryo_program_data_get(ep);
2935
2936 part_id = params[1];
2937 if (part_id < 0) return 0;
2938 rp = ed->table_parts[part_id % ed->table_parts_size];
2939
2940 GETSTR(param_name, params[2]);
2941 if (!param_name) return 0;
2942 eep.name = param_name;
2943 eep.type = EDJE_EXTERNAL_PARAM_TYPE_BOOL;
2944 eep.i = 0;
2945 _edje_external_param_get(NULL, rp, &eep);
2946 return eep.i;
2947}
2948
2949/* external_param_set_bool(id, param_name[], val) */
2950static Embryo_Cell
2951_edje_embryo_fn_external_param_set_bool(Embryo_Program *ep, Embryo_Cell *params)
2952{
2953 Edje *ed;
2954 int part_id;
2955 Edje_Real_Part *rp;
2956 Edje_External_Param eep;
2957 char *param_name;
2958
2959 CHKPARAM(3);
2960 ed = embryo_program_data_get(ep);
2961
2962 part_id = params[1];
2963 if (part_id < 0) return 0;
2964 rp = ed->table_parts[part_id % ed->table_parts_size];
2965
2966 GETSTR(param_name, params[2]);
2967 if (!param_name) return 0;
2968 eep.name = param_name;
2969 eep.type = EDJE_EXTERNAL_PARAM_TYPE_BOOL;
2970 eep.i = params[3];
2971 return _edje_external_param_set(NULL, rp, &eep);
2972}
2973
2974void
2975_edje_embryo_script_init(Edje_Part_Collection *edc)
2976{
2977 Embryo_Program *ep;
2978
2979 if (!edc) return;
2980 if (!edc->script) return;
2981
2982 ep = edc->script;
2983 /* first advertise all the edje "script" calls */
2984 embryo_program_native_call_add(ep, "get_int", _edje_embryo_fn_get_int);
2985 embryo_program_native_call_add(ep, "set_int", _edje_embryo_fn_set_int);
2986 embryo_program_native_call_add(ep, "get_float", _edje_embryo_fn_get_float);
2987 embryo_program_native_call_add(ep, "set_float", _edje_embryo_fn_set_float);
2988 embryo_program_native_call_add(ep, "get_str", _edje_embryo_fn_get_str);
2989 embryo_program_native_call_add(ep, "get_strlen", _edje_embryo_fn_get_strlen);
2990 embryo_program_native_call_add(ep, "set_str", _edje_embryo_fn_set_str);
2991 embryo_program_native_call_add(ep, "count", _edje_embryo_fn_count);
2992 embryo_program_native_call_add(ep, "remove", _edje_embryo_fn_remove);
2993 embryo_program_native_call_add(ep, "append_int", _edje_embryo_fn_append_int);
2994 embryo_program_native_call_add(ep, "prepend_int", _edje_embryo_fn_prepend_int);
2995 embryo_program_native_call_add(ep, "insert_int", _edje_embryo_fn_insert_int);
2996 embryo_program_native_call_add(ep, "replace_int", _edje_embryo_fn_replace_int);
2997 embryo_program_native_call_add(ep, "fetch_int", _edje_embryo_fn_fetch_int);
2998 embryo_program_native_call_add(ep, "append_str", _edje_embryo_fn_append_str);
2999 embryo_program_native_call_add(ep, "prepend_str", _edje_embryo_fn_prepend_str);
3000 embryo_program_native_call_add(ep, "insert_str", _edje_embryo_fn_insert_str);
3001 embryo_program_native_call_add(ep, "replace_str", _edje_embryo_fn_replace_str);
3002 embryo_program_native_call_add(ep, "fetch_str", _edje_embryo_fn_fetch_str);
3003 embryo_program_native_call_add(ep, "append_float", _edje_embryo_fn_append_float);
3004 embryo_program_native_call_add(ep, "prepend_float", _edje_embryo_fn_prepend_float);
3005 embryo_program_native_call_add(ep, "insert_float", _edje_embryo_fn_insert_float);
3006 embryo_program_native_call_add(ep, "replace_float", _edje_embryo_fn_replace_float);
3007 embryo_program_native_call_add(ep, "fetch_float", _edje_embryo_fn_fetch_float);
3008
3009 embryo_program_native_call_add(ep, "timer", _edje_embryo_fn_timer);
3010 embryo_program_native_call_add(ep, "cancel_timer", _edje_embryo_fn_cancel_timer);
3011
3012 embryo_program_native_call_add(ep, "anim", _edje_embryo_fn_anim);
3013 embryo_program_native_call_add(ep, "cancel_anim", _edje_embryo_fn_cancel_anim);
3014
3015 embryo_program_native_call_add(ep, "emit", _edje_embryo_fn_emit);
3016 embryo_program_native_call_add(ep, "get_part_id", _edje_embryo_fn_get_part_id);
3017 embryo_program_native_call_add(ep, "set_state", _edje_embryo_fn_set_state);
3018 embryo_program_native_call_add(ep, "get_state", _edje_embryo_fn_get_state);
3019 embryo_program_native_call_add(ep, "set_tween_state", _edje_embryo_fn_set_tween_state);
3020 embryo_program_native_call_add(ep, "run_program", _edje_embryo_fn_run_program);
3021 embryo_program_native_call_add(ep, "get_drag_dir", _edje_embryo_fn_get_drag_dir);
3022 embryo_program_native_call_add(ep, "get_drag", _edje_embryo_fn_get_drag);
3023 embryo_program_native_call_add(ep, "set_drag", _edje_embryo_fn_set_drag);
3024 embryo_program_native_call_add(ep, "get_drag_size", _edje_embryo_fn_get_drag_size);
3025 embryo_program_native_call_add(ep, "set_drag_size", _edje_embryo_fn_set_drag_size);
3026 embryo_program_native_call_add(ep, "set_text", _edje_embryo_fn_set_text);
3027 embryo_program_native_call_add(ep, "get_text", _edje_embryo_fn_get_text);
3028 embryo_program_native_call_add(ep, "get_min_size", _edje_embryo_fn_get_min_size);
3029 embryo_program_native_call_add(ep, "get_max_size", _edje_embryo_fn_get_max_size);
3030 embryo_program_native_call_add(ep, "get_color_class", _edje_embryo_fn_get_color_class);
3031 embryo_program_native_call_add(ep, "set_color_class", _edje_embryo_fn_set_color_class);
3032 embryo_program_native_call_add(ep, "set_text_class", _edje_embryo_fn_set_text_class);
3033 embryo_program_native_call_add(ep, "get_text_class", _edje_embryo_fn_get_text_class);
3034 embryo_program_native_call_add(ep, "get_drag_step", _edje_embryo_fn_get_drag_step);
3035 embryo_program_native_call_add(ep, "set_drag_step", _edje_embryo_fn_set_drag_step);
3036 embryo_program_native_call_add(ep, "get_drag_page", _edje_embryo_fn_get_drag_page);
3037 embryo_program_native_call_add(ep, "set_drag_page", _edje_embryo_fn_set_drag_page);
3038 embryo_program_native_call_add(ep, "get_mouse", _edje_embryo_fn_get_mouse);
3039 embryo_program_native_call_add(ep, "get_mouse_buttons", _edje_embryo_fn_get_mouse_buttons);
3040 embryo_program_native_call_add(ep, "stop_program", _edje_embryo_fn_stop_program);
3041 embryo_program_native_call_add(ep, "stop_programs_on", _edje_embryo_fn_stop_programs_on);
3042 embryo_program_native_call_add(ep, "set_min_size", _edje_embryo_fn_set_min_size);
3043 embryo_program_native_call_add(ep, "set_max_size", _edje_embryo_fn_set_max_size);
3044 embryo_program_native_call_add(ep, "play_sample", _edje_embryo_fn_play_sample);
3045 embryo_program_native_call_add(ep, "play_tone", _edje_embryo_fn_play_tone);
3046 embryo_program_native_call_add(ep, "send_message", _edje_embryo_fn_send_message);
3047 embryo_program_native_call_add(ep, "get_geometry", _edje_embryo_fn_get_geometry);
3048 embryo_program_native_call_add(ep, "custom_state", _edje_embryo_fn_custom_state);
3049 embryo_program_native_call_add(ep, "set_state_val", _edje_embryo_fn_set_state_val);
3050 embryo_program_native_call_add(ep, "get_state_val", _edje_embryo_fn_get_state_val);
3051
3052 embryo_program_native_call_add(ep, "part_swallow", _edje_embryo_fn_part_swallow);
3053
3054 embryo_program_native_call_add(ep, "external_param_get_int", _edje_embryo_fn_external_param_get_int);
3055 embryo_program_native_call_add(ep, "external_param_set_int", _edje_embryo_fn_external_param_set_int);
3056 embryo_program_native_call_add(ep, "external_param_get_float", _edje_embryo_fn_external_param_get_float);
3057 embryo_program_native_call_add(ep, "external_param_set_float", _edje_embryo_fn_external_param_set_float);
3058 embryo_program_native_call_add(ep, "external_param_get_strlen", _edje_embryo_fn_external_param_get_strlen);
3059 embryo_program_native_call_add(ep, "external_param_get_str", _edje_embryo_fn_external_param_get_str);
3060 embryo_program_native_call_add(ep, "external_param_set_str", _edje_embryo_fn_external_param_set_str);
3061 embryo_program_native_call_add(ep, "external_param_get_choice_len", _edje_embryo_fn_external_param_get_choice_len);
3062 embryo_program_native_call_add(ep, "external_param_get_choice", _edje_embryo_fn_external_param_get_choice);
3063 embryo_program_native_call_add(ep, "external_param_set_choice", _edje_embryo_fn_external_param_set_choice);
3064 embryo_program_native_call_add(ep, "external_param_get_bool", _edje_embryo_fn_external_param_get_bool);
3065 embryo_program_native_call_add(ep, "external_param_set_bool", _edje_embryo_fn_external_param_set_bool);
3066}
3067
3068void
3069_edje_embryo_script_shutdown(Edje_Part_Collection *edc)
3070{
3071 if (!edc) return;
3072 if (!edc->script) return;
3073 if (embryo_program_recursion_get(edc->script) > 0) return;
3074 embryo_program_free(edc->script);
3075 edc->script = NULL;
3076}
3077
3078void
3079_edje_embryo_script_reset(Edje *ed)
3080{
3081 if (!ed) return;
3082 if (!ed->collection) return;
3083 if (!ed->collection->script) return;
3084 if (embryo_program_recursion_get(ed->collection->script) > 0) return;
3085 embryo_program_vm_reset(ed->collection->script);
3086 _edje_embryo_globals_init(ed);
3087}
3088
3089/* this may change in future - thus "test_run" is its name */
3090void
3091_edje_embryo_test_run(Edje *ed, const char *fname, const char *sig, const char *src)
3092{
3093 Embryo_Function fn;
3094
3095 if (!ed) return;
3096 if (!ed->collection) return;
3097 if (!ed->collection->script) return;
3098 embryo_program_vm_push(ed->collection->script);
3099 _edje_embryo_globals_init(ed);
3100
3101 // _edje_embryo_script_reset(ed);
3102 fn = embryo_program_function_find(ed->collection->script, (char *)fname);
3103 if (fn != EMBRYO_FUNCTION_NONE)
3104 {
3105 void *pdata;
3106 int ret;
3107
3108 embryo_parameter_string_push(ed->collection->script, (char *)sig);
3109 embryo_parameter_string_push(ed->collection->script, (char *)src);
3110 pdata = embryo_program_data_get(ed->collection->script);
3111 embryo_program_data_set(ed->collection->script, ed);
3112 /* 5 million instructions is an arbitrary number. on my p4-2.6 here */
3113 /* IF embryo is ONLY running embryo stuff and NO native calls thats */
3114 /* about 0.016 seconds, and longer on slower cpu's. if a simple */
3115 /* embryo script snippet hasn't managed to do its work in 5 MILLION */
3116 /* embryo virtual machine instructions - something is wrong, or */
3117 /* embryo is simply being mis-used. Embryo is meant to be minimal */
3118 /* logic enhancment - not entire applications. this cycle count */
3119 /* does NOT include time spent in native function calls, that the */
3120 /* script may call to do the REAL work, so in terms of time this */
3121 /* will likely end up being much longer than 0.016 seconds - more */
3122 /* like 0.03 - 0.05 seconds or even more */
3123 embryo_program_max_cycle_run_set(ed->collection->script, 5000000);
3124 ret = embryo_program_run(ed->collection->script, fn);
3125 if (ret == EMBRYO_PROGRAM_FAIL)
3126 {
3127 ERR("ERROR with embryo script. "
3128 "OBJECT NAME: '%s', "
3129 "OBJECT FILE: '%s', "
3130 "ENTRY POINT: '%s', "
3131 "SIGNAL: '%s', "
3132 "SOURCE: '%s', "
3133 "ERROR: '%s'",
3134 ed->collection->part,
3135 ed->file->path,
3136 fname,
3137 sig, src,
3138 embryo_error_string_get(embryo_program_error_get(ed->collection->script)));
3139 }
3140 else if (ret == EMBRYO_PROGRAM_TOOLONG)
3141 {
3142 ERR("ERROR with embryo script. "
3143 "OBJECT NAME: '%s', "
3144 "OBJECT FILE: '%s', "
3145 "ENTRY POINT: '%s', "
3146 "SIGNAL: '%s', "
3147 "SOURCE: '%s', "
3148 "ERROR: 'Script exceeded maximum allowed cycle count of %i'",
3149 ed->collection->part,
3150 ed->file->path,
3151 fname,
3152 sig, src,
3153 embryo_program_max_cycle_run_get(ed->collection->script));
3154 }
3155 embryo_program_data_set(ed->collection->script, pdata);
3156 }
3157 embryo_program_vm_pop(ed->collection->script);
3158}
3159
3160void
3161_edje_embryo_globals_init(Edje *ed)
3162{
3163 int n, i;
3164 Embryo_Program *ep;
3165
3166 ep = ed->collection->script;
3167 n = embryo_program_variable_count_get(ep);
3168 for (i = 0; i < n; i++)
3169 {
3170 Embryo_Cell cell, *cptr;
3171
3172 cell = embryo_program_variable_get(ep, i);
3173 if (cell != EMBRYO_CELL_NONE)
3174 {
3175 cptr = embryo_data_address_get(ep, cell);
3176 if (cptr) *cptr = EDJE_VAR_MAGIC_BASE + i;
3177 }
3178 }
3179}
diff --git a/libraries/edje/src/lib/edje_entry.c b/libraries/edje/src/lib/edje_entry.c
new file mode 100644
index 0000000..e25397a
--- /dev/null
+++ b/libraries/edje/src/lib/edje_entry.c
@@ -0,0 +1,3110 @@
1#include "edje_private.h"
2
3#ifdef HAVE_ECORE_IMF
4static Eina_Bool _edje_entry_imf_retrieve_surrounding_cb(void *data, Ecore_IMF_Context *ctx, char **text, int *cursor_pos);
5static Eina_Bool _edje_entry_imf_event_commit_cb(void *data, int type, void *event);
6static Eina_Bool _edje_entry_imf_event_preedit_changed_cb(void *data, int type, void *event);
7static Eina_Bool _edje_entry_imf_event_delete_surrounding_cb(void *data, int type, void *event);
8#endif
9
10typedef struct _Entry Entry;
11typedef struct _Sel Sel;
12typedef struct _Anchor Anchor;
13
14static void _edje_entry_imf_cursor_info_set(Entry *en);
15static void _edje_entry_imf_context_reset(Entry *en);
16
17struct _Entry
18{
19 Edje_Real_Part *rp;
20 Evas_Object *cursor_bg;
21 Evas_Object *cursor_fg;
22 Evas_Textblock_Cursor *cursor;
23 Evas_Textblock_Cursor *sel_start, *sel_end;
24 Evas_Textblock_Cursor *cursor_user, *cursor_user_extra;
25 Evas_Textblock_Cursor *preedit_start, *preedit_end;
26 Ecore_Timer *pw_timer;
27 Eina_List *sel;
28 Eina_List *anchors;
29 Eina_List *anchorlist;
30 Eina_List *itemlist;
31 char *selection;
32 Eina_Bool selecting : 1;
33 Eina_Bool have_selection : 1;
34 Eina_Bool select_allow : 1;
35 Eina_Bool select_mod_start : 1;
36 Eina_Bool select_mod_end : 1;
37 Eina_Bool had_sel : 1;
38
39#ifdef HAVE_ECORE_IMF
40 Eina_Bool have_preedit : 1;
41 Ecore_IMF_Context *imf_context;
42
43 Ecore_Event_Handler *imf_ee_handler_commit;
44 Ecore_Event_Handler *imf_ee_handler_delete;
45 Ecore_Event_Handler *imf_ee_handler_changed;
46#endif
47};
48
49struct _Sel
50{
51 Evas_Textblock_Rectangle rect;
52 Evas_Object *obj_fg, *obj_bg, *obj, *sobj;
53};
54
55struct _Anchor
56{
57 Entry *en;
58 char *name;
59 Evas_Textblock_Cursor *start, *end;
60 Eina_List *sel;
61 Eina_Bool item : 1;
62};
63
64#ifdef HAVE_ECORE_IMF
65static void
66_preedit_clear(Entry *en)
67{
68 if (en->preedit_start)
69 {
70 evas_textblock_cursor_free(en->preedit_start);
71 en->preedit_start = NULL;
72 }
73
74 if (en->preedit_end)
75 {
76 evas_textblock_cursor_free(en->preedit_end);
77 en->preedit_end = NULL;
78 }
79
80 en->have_preedit = EINA_FALSE;
81}
82
83static void
84_preedit_del(Entry *en)
85{
86 if (!en || !en->have_preedit) return;
87 if (!en->preedit_start || !en->preedit_end) return;
88 if (!evas_textblock_cursor_compare(en->preedit_start, en->preedit_end)) return;
89
90 /* delete the preedit characters */
91 evas_textblock_cursor_range_delete(en->preedit_start, en->preedit_end);
92}
93
94static void
95_edje_entry_focus_in_cb(void *data, Evas_Object *o __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
96{
97 Edje_Real_Part *rp;
98 Entry *en;
99
100 rp = data;
101 if (!rp || !rp->entry_data || !rp->edje || !rp->edje->obj) return;
102
103 en = rp->entry_data;
104 if (!en || !en->imf_context) return;
105
106 if (evas_object_focus_get(rp->edje->obj))
107 {
108 ecore_imf_context_reset(en->imf_context);
109 ecore_imf_context_focus_in(en->imf_context);
110 _edje_entry_imf_cursor_info_set(en);
111 }
112}
113
114static void
115_edje_entry_focus_out_cb(void *data, Evas_Object *o __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
116{
117 Edje_Real_Part *rp;
118 Entry *en;
119
120 rp = data;
121 if (!rp || !rp->entry_data) return;
122
123 en = rp->entry_data;
124 if (!en || !en->imf_context) return;
125
126 ecore_imf_context_reset(en->imf_context);
127 _edje_entry_imf_cursor_info_set(en);
128 ecore_imf_context_focus_out(en->imf_context);
129}
130#endif
131
132static void
133_edje_focus_in_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
134{
135 Edje *ed = data;
136#ifdef HAVE_ECORE_IMF
137 Edje_Real_Part *rp;
138 Entry *en;
139#endif
140
141 _edje_emit(ed, "focus,in", "");
142#ifdef HAVE_ECORE_IMF
143 rp = ed->focused_part;
144 if (!rp) return;
145
146 en = rp->entry_data;
147 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
148 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_EDITABLE))
149 return;
150
151 if (!en->imf_context) return;
152
153 ecore_imf_context_reset(en->imf_context);
154 ecore_imf_context_focus_in(en->imf_context);
155 _edje_entry_imf_cursor_info_set(en);
156#endif
157}
158
159static void
160_edje_focus_out_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
161{
162 Edje *ed = data;
163#ifdef HAVE_ECORE_IMF
164 Edje_Real_Part *rp = ed->focused_part;
165 Entry *en;
166#endif
167
168 _edje_emit(ed, "focus,out", "");
169
170#ifdef HAVE_ECORE_IMF
171 if (!rp) return;
172 en = rp->entry_data;
173 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
174 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_EDITABLE))
175 return;
176
177 if (!en->imf_context) return;
178
179 ecore_imf_context_reset(en->imf_context);
180 _edje_entry_imf_cursor_info_set(en);
181 ecore_imf_context_focus_out(en->imf_context);
182#endif
183}
184
185static void
186_text_filter_text_prepend(Entry *en, Evas_Textblock_Cursor *c, const char *text)
187{
188 char *text2;
189 Edje_Text_Insert_Filter_Callback *cb;
190 Eina_List *l;
191
192 text2 = strdup(text);
193 EINA_LIST_FOREACH(en->rp->edje->text_insert_filter_callbacks, l, cb)
194 {
195 if (!strcmp(cb->part, en->rp->part->name))
196 {
197 cb->func(cb->data, en->rp->edje->obj, cb->part, EDJE_TEXT_FILTER_TEXT, &text2);
198 if (!text2) break;
199 }
200 }
201 if (text2)
202 {
203 evas_textblock_cursor_text_prepend(c, text2);
204 free(text2);
205 }
206}
207
208static void
209_text_filter_format_prepend(Entry *en, Evas_Textblock_Cursor *c, const char *text)
210{
211 char *text2;
212 Edje_Text_Insert_Filter_Callback *cb;
213 Eina_List *l;
214
215 text2 = strdup(text);
216 EINA_LIST_FOREACH(en->rp->edje->text_insert_filter_callbacks, l, cb)
217 {
218 if (!strcmp(cb->part, en->rp->part->name))
219 {
220 cb->func(cb->data, en->rp->edje->obj, cb->part, EDJE_TEXT_FILTER_FORMAT, &text2);
221 if (!text2) break;
222 }
223 }
224 if (text2)
225 {
226 evas_textblock_cursor_format_prepend(c, text2);
227 free(text2);
228 }
229}
230
231static void
232_text_filter_markup_prepend(Entry *en, Evas_Textblock_Cursor *c, const char *text)
233{
234 char *text2;
235 Edje_Text_Insert_Filter_Callback *cb;
236 Eina_List *l;
237
238 text2 = strdup(text);
239 EINA_LIST_FOREACH(en->rp->edje->text_insert_filter_callbacks, l, cb)
240 {
241 if (!strcmp(cb->part, en->rp->part->name))
242 {
243 cb->func(cb->data, en->rp->edje->obj, cb->part, EDJE_TEXT_FILTER_MARKUP, &text2);
244 if (!text2) break;
245 }
246 }
247 if (text2)
248 {
249 evas_object_textblock_text_markup_prepend(c, text2);
250 free(text2);
251 }
252}
253
254static void
255_curs_update_from_curs(Evas_Textblock_Cursor *c, Evas_Object *o __UNUSED__, Entry *en, Evas_Coord *cx, Evas_Coord *cy)
256{
257 Evas_Coord cw, ch;
258 Evas_Textblock_Cursor_Type cur_type;
259 if (c != en->cursor) return;
260 switch (en->rp->part->cursor_mode)
261 {
262 case EDJE_ENTRY_CURSOR_MODE_BEFORE:
263 cur_type = EVAS_TEXTBLOCK_CURSOR_BEFORE;
264 break;
265 case EDJE_ENTRY_CURSOR_MODE_UNDER:
266 /* no break for a resaon */
267 default:
268 cur_type = EVAS_TEXTBLOCK_CURSOR_UNDER;
269 }
270 evas_textblock_cursor_geometry_get(c, cx, cy, &cw, &ch, NULL, cur_type);
271 *cx += (cw / 2);
272 *cy += (ch / 2);
273}
274
275static void
276_curs_back(Evas_Textblock_Cursor *c, Evas_Object *o __UNUSED__,
277 Entry *en __UNUSED__)
278{
279 evas_textblock_cursor_char_prev(c);
280}
281
282static void
283_curs_next(Evas_Textblock_Cursor *c, Evas_Object *o __UNUSED__,
284 Entry *en __UNUSED__)
285{
286 evas_textblock_cursor_char_next(c);
287}
288
289static int
290_curs_line_last_get(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o, Entry *en __UNUSED__)
291{
292 Evas_Textblock_Cursor *cc;
293 int ln;
294
295 cc = evas_object_textblock_cursor_new(o);
296 evas_textblock_cursor_paragraph_last(cc);
297 ln = evas_textblock_cursor_line_geometry_get(cc, NULL, NULL, NULL, NULL);
298 evas_textblock_cursor_free(cc);
299 return ln;
300}
301
302static void
303_curs_lin_start(Evas_Textblock_Cursor *c, Evas_Object *o __UNUSED__,
304 Entry *en __UNUSED__)
305{
306 evas_textblock_cursor_line_char_first(c);
307}
308
309static void
310_curs_lin_end(Evas_Textblock_Cursor *c, Evas_Object *o __UNUSED__,
311 Entry *en __UNUSED__)
312{
313 evas_textblock_cursor_line_char_last(c);
314}
315
316static void
317_curs_start(Evas_Textblock_Cursor *c, Evas_Object *o __UNUSED__,
318 Entry *en __UNUSED__)
319{
320 evas_textblock_cursor_paragraph_first(c);
321}
322
323static void
324_curs_end(Evas_Textblock_Cursor *c, Evas_Object *o __UNUSED__, Entry *en __UNUSED__)
325{
326 evas_textblock_cursor_paragraph_last(c);
327}
328
329static void
330_curs_jump_line(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en, int ln)
331{
332 Evas_Coord cx, cy;
333 Evas_Coord lx, ly, lw, lh;
334 int last = _curs_line_last_get(c, o, en);
335
336 if (ln < 0) ln = 0;
337 else
338 {
339 if (ln > last) ln = last;
340 }
341
342 _curs_update_from_curs(c, o, en, &cx, &cy);
343
344 if (!evas_object_textblock_line_number_geometry_get(o, ln, &lx, &ly, &lw, &lh))
345 return;
346 if (evas_textblock_cursor_char_coord_set(c, cx, ly + (lh / 2)))
347 return;
348 evas_textblock_cursor_line_set(c, ln);
349 if (cx < (lx + (lw / 2)))
350 {
351 if (ln == last) _curs_end(c, o, en);
352 _curs_lin_start(c, o, en);
353 }
354 else
355 {
356 if (ln == last)
357 _curs_end(c, o, en);
358 else
359 _curs_lin_end(c, o, en);
360 }
361}
362
363static void
364_curs_jump_line_by(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en, int by)
365{
366 int ln;
367
368 ln = evas_textblock_cursor_line_geometry_get(c, NULL, NULL, NULL, NULL) + by;
369 _curs_jump_line(c, o, en, ln);
370}
371
372static void
373_curs_up(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
374{
375 _curs_jump_line_by(c, o, en, -1);
376}
377
378static void
379_curs_down(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
380{
381 _curs_jump_line_by(c, o, en, 1);
382}
383
384static void
385_sel_start(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
386{
387 if (en->sel_start) return;
388 en->sel_start = evas_object_textblock_cursor_new(o);
389 evas_textblock_cursor_copy(c, en->sel_start);
390 en->sel_end = evas_object_textblock_cursor_new(o);
391 evas_textblock_cursor_copy(c, en->sel_end);
392
393 en->have_selection = EINA_FALSE;
394 if (en->selection)
395 {
396 free(en->selection);
397 en->selection = NULL;
398 }
399}
400
401static void
402_sel_enable(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o __UNUSED__, Entry *en)
403{
404 if (en->have_selection) return;
405 en->have_selection = EINA_TRUE;
406 if (en->selection)
407 {
408 free(en->selection);
409 en->selection = NULL;
410 }
411 _edje_emit(en->rp->edje, "selection,start", en->rp->part->name);
412}
413
414static void
415_sel_extend(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
416{
417 if (!en->sel_end) return;
418 _sel_enable(c, o, en);
419 if (!evas_textblock_cursor_compare(c, en->sel_end)) return;
420 evas_textblock_cursor_copy(c, en->sel_end);
421 if (en->selection)
422 {
423 free(en->selection);
424 en->selection = NULL;
425 }
426 _edje_emit(en->rp->edje, "selection,changed", en->rp->part->name);
427 _edje_entry_imf_context_reset(en);
428}
429
430static void
431_sel_preextend(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
432{
433 if (!en->sel_end) return;
434 _sel_enable(c, o, en);
435 if (!evas_textblock_cursor_compare(c, en->sel_start)) return;
436 evas_textblock_cursor_copy(c, en->sel_start);
437 if (en->selection)
438 {
439 free(en->selection);
440 en->selection = NULL;
441 }
442 _edje_emit(en->rp->edje, "selection,changed", en->rp->part->name);
443 _edje_entry_imf_context_reset(en);
444}
445
446static void
447_sel_clear(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o __UNUSED__, Entry *en)
448{
449 en->had_sel = EINA_FALSE;
450 if (en->sel_start)
451 {
452 evas_textblock_cursor_free(en->sel_start);
453 evas_textblock_cursor_free(en->sel_end);
454 en->sel_start = NULL;
455 en->sel_end = NULL;
456 }
457 if (en->selection)
458 {
459 free(en->selection);
460 en->selection = NULL;
461 }
462 while (en->sel)
463 {
464 Sel *sel;
465
466 sel = en->sel->data;
467 if (sel->obj_bg) evas_object_del(sel->obj_bg);
468 if (sel->obj_fg) evas_object_del(sel->obj_fg);
469 free(sel);
470 en->sel = eina_list_remove_list(en->sel, en->sel);
471 }
472 if (en->have_selection)
473 {
474 en->have_selection = EINA_FALSE;
475 _edje_emit(en->rp->edje, "selection,cleared", en->rp->part->name);
476 }
477}
478
479static void
480_sel_update(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o, Entry *en)
481{
482 Eina_List *range = NULL, *l;
483 Sel *sel;
484 Evas_Coord x, y, w, h;
485 Evas_Object *smart, *clip;
486
487 smart = evas_object_smart_parent_get(o);
488 clip = evas_object_clip_get(o);
489 if (en->sel_start)
490 range = evas_textblock_cursor_range_geometry_get(en->sel_start, en->sel_end);
491 else
492 return;
493 if (eina_list_count(range) != eina_list_count(en->sel))
494 {
495 while (en->sel)
496 {
497 sel = en->sel->data;
498 if (sel->obj_bg) evas_object_del(sel->obj_bg);
499 if (sel->obj_fg) evas_object_del(sel->obj_fg);
500 free(sel);
501 en->sel = eina_list_remove_list(en->sel, en->sel);
502 }
503 if (en->have_selection)
504 {
505 for (l = range; l; l = eina_list_next(l))
506 {
507 Evas_Object *ob;
508
509 sel = calloc(1, sizeof(Sel));
510 en->sel = eina_list_append(en->sel, sel);
511 ob = edje_object_add(en->rp->edje->base.evas);
512 edje_object_file_set(ob, en->rp->edje->path, en->rp->part->source);
513 evas_object_smart_member_add(ob, smart);
514 evas_object_stack_below(ob, o);
515 evas_object_clip_set(ob, clip);
516 evas_object_pass_events_set(ob, EINA_TRUE);
517 evas_object_show(ob);
518 sel->obj_bg = ob;
519 _edje_subobj_register(en->rp->edje, sel->obj_bg);
520
521 ob = edje_object_add(en->rp->edje->base.evas);
522 edje_object_file_set(ob, en->rp->edje->path, en->rp->part->source2);
523 evas_object_smart_member_add(ob, smart);
524 evas_object_stack_above(ob, o);
525 evas_object_clip_set(ob, clip);
526 evas_object_pass_events_set(ob, EINA_TRUE);
527 evas_object_show(ob);
528 sel->obj_fg = ob;
529 _edje_subobj_register(en->rp->edje, sel->obj_fg);
530 }
531 }
532 }
533 x = y = w = h = -1;
534 evas_object_geometry_get(o, &x, &y, &w, &h);
535 if (en->have_selection)
536 {
537 EINA_LIST_FOREACH(en->sel, l, sel)
538 {
539 Evas_Textblock_Rectangle *r;
540
541 r = range->data;
542 if (sel->obj_bg)
543 {
544 evas_object_move(sel->obj_bg, x + r->x, y + r->y);
545 evas_object_resize(sel->obj_bg, r->w, r->h);
546 }
547 if (sel->obj_fg)
548 {
549 evas_object_move(sel->obj_fg, x + r->x, y + r->y);
550 evas_object_resize(sel->obj_fg, r->w, r->h);
551 }
552 *(&(sel->rect)) = *r;
553 range = eina_list_remove_list(range, range);
554 free(r);
555 }
556 }
557 else
558 {
559 while (range)
560 {
561 free(range->data);
562 range = eina_list_remove_list(range, range);
563 }
564 }
565}
566
567static void
568_edje_anchor_mouse_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
569{
570 Anchor *an = data;
571 Evas_Event_Mouse_Down *ev = event_info;
572 Edje_Real_Part *rp = an->en->rp;
573 char *buf, *n;
574 size_t len;
575 int ignored;
576 Entry *en;
577
578 en = rp->entry_data;
579 if ((rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT) &&
580 (en->select_allow))
581 return;
582 ignored = rp->part->ignore_flags & ev->event_flags;
583 if ((!ev->event_flags) || (!ignored))
584 {
585 n = an->name;
586 if (!n) n = "";
587 len = 200 + strlen(n);
588 buf = alloca(len);
589 if (ev->flags & EVAS_BUTTON_TRIPLE_CLICK)
590 snprintf(buf, len, "anchor,mouse,down,%i,%s,triple", ev->button, n);
591 else if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
592 snprintf(buf, len, "anchor,mouse,down,%i,%s,double", ev->button, n);
593 else
594 snprintf(buf, len, "anchor,mouse,down,%i,%s", ev->button, n);
595 _edje_emit(rp->edje, buf, rp->part->name);
596 }
597}
598
599static void
600_edje_anchor_mouse_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
601{
602 Anchor *an = data;
603 Evas_Event_Mouse_Up *ev = event_info;
604 Edje_Real_Part *rp = an->en->rp;
605 char *buf, *n;
606 size_t len;
607 int ignored;
608 Entry *en;
609
610 en = rp->entry_data;
611 ignored = rp->part->ignore_flags & ev->event_flags;
612 if ((rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT) &&
613 (en->select_allow))
614 return;
615 n = an->name;
616 if (!n) n = "";
617 len = 200 + strlen(n);
618 buf = alloca(len);
619 if ((!ev->event_flags) || (!ignored))
620 {
621 snprintf(buf, len, "anchor,mouse,up,%i,%s", ev->button, n);
622 _edje_emit(rp->edje, buf, rp->part->name);
623 }
624 if ((rp->still_in) && (rp->clicked_button == ev->button) && (!ignored))
625 {
626 snprintf(buf, len, "anchor,mouse,clicked,%i,%s", ev->button, n);
627 _edje_emit(rp->edje, buf, rp->part->name);
628 }
629}
630
631static void
632_edje_anchor_mouse_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
633{
634 Anchor *an = data;
635 Evas_Event_Mouse_Move *ev = event_info;
636 Edje_Real_Part *rp = an->en->rp;
637 char *buf, *n;
638 size_t len;
639 int ignored;
640 Entry *en;
641
642 en = rp->entry_data;
643 if ((rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT) &&
644 (en->select_allow))
645 return;
646 ignored = rp->part->ignore_flags & ev->event_flags;
647 if ((!ev->event_flags) || (!ignored))
648 {
649 n = an->name;
650 if (!n) n = "";
651 len = 200 + strlen(n);
652 buf = alloca(len);
653 snprintf(buf, len, "anchor,mouse,move,%s", n);
654 _edje_emit(rp->edje, buf, rp->part->name);
655 }
656}
657
658static void
659_edje_anchor_mouse_in_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
660{
661 Anchor *an = data;
662 Evas_Event_Mouse_In *ev = event_info;
663 Edje_Real_Part *rp = an->en->rp;
664 char *buf, *n;
665 size_t len;
666 int ignored;
667
668 ignored = rp->part->ignore_flags & ev->event_flags;
669 if ((!ev->event_flags) || (!ignored))
670 {
671 n = an->name;
672 if (!n) n = "";
673 len = 200 + strlen(n);
674 buf = alloca(len);
675 snprintf(buf, len, "anchor,mouse,in,%s", n);
676 _edje_emit(rp->edje, buf, rp->part->name);
677 }
678}
679
680static void
681_edje_anchor_mouse_out_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
682{
683 Anchor *an = data;
684 Evas_Event_Mouse_Out *ev = event_info;
685 Edje_Real_Part *rp = an->en->rp;
686 char *buf, *n;
687 size_t len;
688 int ignored;
689
690 ignored = rp->part->ignore_flags & ev->event_flags;
691 if ((!ev->event_flags) || (!ignored))
692 {
693 n = an->name;
694 if (!n) n = "";
695 len = 200 + strlen(n);
696 buf = alloca(len);
697 snprintf(buf, len, "anchor,mouse,out,%s", n);
698 _edje_emit(rp->edje, buf, rp->part->name);
699 }
700}
701
702static void
703_anchors_update(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o, Entry *en)
704{
705 Eina_List *l, *ll, *range = NULL;
706 Evas_Coord x, y, w, h;
707 Evas_Object *smart, *clip;
708 Sel *sel;
709 Anchor *an;
710
711 smart = evas_object_smart_parent_get(o);
712 clip = evas_object_clip_get(o);
713 x = y = w = h = -1;
714 evas_object_geometry_get(o, &x, &y, &w, &h);
715 EINA_LIST_FOREACH(en->anchors, l, an)
716 {
717 // for item anchors
718 if (an->item)
719 {
720 Evas_Object *ob;
721
722 if (!an->sel)
723 {
724 while (an->sel)
725 {
726 sel = an->sel->data;
727 if (sel->obj_bg) evas_object_del(sel->obj_bg);
728 if (sel->obj_fg) evas_object_del(sel->obj_fg);
729 if (sel->obj) evas_object_del(sel->obj);
730 free(sel);
731 an->sel = eina_list_remove_list(an->sel, an->sel);
732 }
733
734 sel = calloc(1, sizeof(Sel));
735 an->sel = eina_list_append(an->sel, sel);
736
737 if (en->rp->edje->item_provider.func)
738 {
739 ob = en->rp->edje->item_provider.func
740 (en->rp->edje->item_provider.data, smart,
741 en->rp->part->name, an->name);
742 evas_object_smart_member_add(ob, smart);
743 evas_object_stack_above(ob, o);
744 evas_object_clip_set(ob, clip);
745 evas_object_pass_events_set(ob, EINA_TRUE);
746 evas_object_show(ob);
747 sel->obj = ob;
748 }
749 }
750 }
751 // for link anchors
752 else
753 {
754 range =
755 evas_textblock_cursor_range_geometry_get(an->start, an->end);
756 if (eina_list_count(range) != eina_list_count(an->sel))
757 {
758 while (an->sel)
759 {
760 sel = an->sel->data;
761 if (sel->obj_bg) evas_object_del(sel->obj_bg);
762 if (sel->obj_fg) evas_object_del(sel->obj_fg);
763 if (sel->obj) evas_object_del(sel->obj);
764 free(sel);
765 an->sel = eina_list_remove_list(an->sel, an->sel);
766 }
767 for (ll = range; ll; ll = eina_list_next(ll))
768 {
769 Evas_Object *ob;
770
771 sel = calloc(1, sizeof(Sel));
772 an->sel = eina_list_append(an->sel, sel);
773 ob = edje_object_add(en->rp->edje->base.evas);
774 edje_object_file_set(ob, en->rp->edje->path, en->rp->part->source5);
775 evas_object_smart_member_add(ob, smart);
776 evas_object_stack_below(ob, o);
777 evas_object_clip_set(ob, clip);
778 evas_object_pass_events_set(ob, EINA_TRUE);
779 evas_object_show(ob);
780 sel->obj_bg = ob;
781 _edje_subobj_register(en->rp->edje, sel->obj_bg);
782
783 ob = edje_object_add(en->rp->edje->base.evas);
784 edje_object_file_set(ob, en->rp->edje->path, en->rp->part->source6);
785 evas_object_smart_member_add(ob, smart);
786 evas_object_stack_above(ob, o);
787 evas_object_clip_set(ob, clip);
788 evas_object_pass_events_set(ob, EINA_TRUE);
789 evas_object_show(ob);
790 sel->obj_fg = ob;
791 _edje_subobj_register(en->rp->edje, sel->obj_fg);
792
793 ob = evas_object_rectangle_add(en->rp->edje->base.evas);
794 evas_object_color_set(ob, 0, 0, 0, 0);
795 evas_object_smart_member_add(ob, smart);
796 evas_object_stack_above(ob, o);
797 evas_object_clip_set(ob, clip);
798 evas_object_repeat_events_set(ob, EINA_TRUE);
799 evas_object_event_callback_add(ob, EVAS_CALLBACK_MOUSE_DOWN, _edje_anchor_mouse_down_cb, an);
800 evas_object_event_callback_add(ob, EVAS_CALLBACK_MOUSE_UP, _edje_anchor_mouse_up_cb, an);
801 evas_object_event_callback_add(ob, EVAS_CALLBACK_MOUSE_MOVE, _edje_anchor_mouse_move_cb, an);
802 evas_object_event_callback_add(ob, EVAS_CALLBACK_MOUSE_IN, _edje_anchor_mouse_in_cb, an);
803 evas_object_event_callback_add(ob, EVAS_CALLBACK_MOUSE_OUT, _edje_anchor_mouse_out_cb, an);
804 evas_object_show(ob);
805 sel->obj = ob;
806 }
807 }
808 }
809 EINA_LIST_FOREACH(an->sel, ll, sel)
810 {
811 if (an->item)
812 {
813 Evas_Coord cx, cy, cw, ch;
814
815 if (!evas_textblock_cursor_format_item_geometry_get
816 (an->start, &cx, &cy, &cw, &ch))
817 continue;
818 evas_object_move(sel->obj, x + cx, y + cy);
819 evas_object_resize(sel->obj, cw, ch);
820 }
821 else
822 {
823 Evas_Textblock_Rectangle *r;
824
825 r = range->data;
826 *(&(sel->rect)) = *r;
827 if (sel->obj_bg)
828 {
829 evas_object_move(sel->obj_bg, x + r->x, y + r->y);
830 evas_object_resize(sel->obj_bg, r->w, r->h);
831 }
832 if (sel->obj_fg)
833 {
834 evas_object_move(sel->obj_fg, x + r->x, y + r->y);
835 evas_object_resize(sel->obj_fg, r->w, r->h);
836 }
837 if (sel->obj)
838 {
839 evas_object_move(sel->obj, x + r->x, y + r->y);
840 evas_object_resize(sel->obj, r->w, r->h);
841 }
842 range = eina_list_remove_list(range, range);
843 free(r);
844 }
845 }
846 }
847}
848
849static void
850_anchors_clear(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o __UNUSED__, Entry *en)
851{
852 while (en->anchorlist)
853 {
854 free(en->anchorlist->data);
855 en->anchorlist = eina_list_remove_list(en->anchorlist, en->anchorlist);
856 }
857 while (en->itemlist)
858 {
859 free(en->itemlist->data);
860 en->itemlist = eina_list_remove_list(en->itemlist, en->itemlist);
861 }
862 while (en->anchors)
863 {
864 Anchor *an = en->anchors->data;
865
866 evas_textblock_cursor_free(an->start);
867 evas_textblock_cursor_free(an->end);
868 while (an->sel)
869 {
870 Sel *sel = an->sel->data;
871 if (sel->obj_bg) evas_object_del(sel->obj_bg);
872 if (sel->obj_fg) evas_object_del(sel->obj_fg);
873 if (sel->obj) evas_object_del(sel->obj);
874 free(sel);
875 an->sel = eina_list_remove_list(an->sel, an->sel);
876 }
877 free(an->name);
878 free(an);
879 en->anchors = eina_list_remove_list(en->anchors, en->anchors);
880 }
881}
882
883static void
884_anchors_get(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en)
885{
886 const Eina_List *anchors_a, *anchors_item;
887 Anchor *an = NULL;
888 _anchors_clear(c, o, en);
889
890 anchors_a = evas_textblock_node_format_list_get(o, "a");
891 anchors_item = evas_textblock_node_format_list_get(o, "item");
892
893 if (anchors_a)
894 {
895 const Evas_Object_Textblock_Node_Format *node;
896 const Eina_List *itr;
897 EINA_LIST_FOREACH(anchors_a, itr, node)
898 {
899 const char *s = evas_textblock_node_format_text_get(node);
900 char *p;
901 an = calloc(1, sizeof(Anchor));
902 if (!an)
903 break;
904
905 an->en = en;
906 p = strstr(s, "href=");
907 if (p)
908 {
909 an->name = strdup(p + 5);
910 }
911 en->anchors = eina_list_append(en->anchors, an);
912 an->start = evas_object_textblock_cursor_new(o);
913 an->end = evas_object_textblock_cursor_new(o);
914 evas_textblock_cursor_at_format_set(an->start, node);
915 evas_textblock_cursor_copy(an->start, an->end);
916
917 /* Close the anchor, if the anchor was without text,
918 * free it as well */
919 node = evas_textblock_node_format_next_get(node);
920 for (; node; node = evas_textblock_node_format_next_get(node))
921 {
922 s = evas_textblock_node_format_text_get(node);
923 if ((!strcmp(s, "- a")) || (!strcmp(s, "-a")))
924 break;
925 }
926
927 if (node)
928 {
929 evas_textblock_cursor_at_format_set(an->end, node);
930 }
931 else if (!evas_textblock_cursor_compare(an->start, an->end))
932 {
933 if (an->name) free(an->name);
934 evas_textblock_cursor_free(an->start);
935 evas_textblock_cursor_free(an->end);
936 en->anchors = eina_list_remove(en->anchors, an);
937 free(an);
938 }
939 an = NULL;
940 }
941 }
942
943 if (anchors_item)
944 {
945 const Evas_Object_Textblock_Node_Format *node;
946 const Eina_List *itr;
947 EINA_LIST_FOREACH(anchors_item, itr, node)
948 {
949 const char *s = evas_textblock_node_format_text_get(node);
950 char *p;
951 an = calloc(1, sizeof(Anchor));
952 if (!an)
953 break;
954
955 an->en = en;
956 an->item = 1;
957 p = strstr(s, "href=");
958 if (p)
959 {
960 an->name = strdup(p + 5);
961 }
962 en->anchors = eina_list_append(en->anchors, an);
963 an->start = evas_object_textblock_cursor_new(o);
964 an->end = evas_object_textblock_cursor_new(o);
965 evas_textblock_cursor_at_format_set(an->start, node);
966 evas_textblock_cursor_copy(an->start, an->end);
967 /* Although needed in textblock, don't bother with finding the end
968 * here cause it doesn't really matter. */
969 }
970 }
971}
972
973static void
974_free_entry_change_info(void *_info)
975{
976 Edje_Entry_Change_Info *info = (Edje_Entry_Change_Info *) _info;
977 if (info->insert)
978 {
979 eina_stringshare_del(info->change.insert.content);
980 }
981 else
982 {
983 eina_stringshare_del(info->change.del.content);
984 }
985 free(info);
986}
987
988static void
989_range_del_emit(Edje *ed, Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o __UNUSED__, Entry *en)
990{
991 size_t start, end;
992 char *tmp;
993 Edje_Entry_Change_Info *info = calloc(1, sizeof(*info));
994 info->insert = EINA_FALSE;
995 start = evas_textblock_cursor_pos_get(en->sel_start);
996 end = evas_textblock_cursor_pos_get(en->sel_end);
997 info->change.del.start = start;
998 info->change.del.end = end;
999
1000 tmp = evas_textblock_cursor_range_text_get(en->sel_start, en->sel_end, EVAS_TEXTBLOCK_TEXT_MARKUP);
1001 info->change.del.content = eina_stringshare_add(tmp);
1002 if (tmp) free(tmp);
1003 evas_textblock_cursor_range_delete(en->sel_start, en->sel_end);
1004 _edje_emit(ed, "entry,changed", en->rp->part->name);
1005 _edje_emit_full(ed, "entry,changed,user", en->rp->part->name, info,
1006 _free_entry_change_info);
1007}
1008
1009static void
1010_range_del(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o __UNUSED__, Entry *en)
1011{
1012 evas_textblock_cursor_range_delete(en->sel_start, en->sel_end);
1013}
1014
1015static void
1016_delete_emit(Edje *ed, Evas_Textblock_Cursor *c, Entry *en, size_t pos,
1017 Eina_Bool backspace)
1018{
1019 if (!evas_textblock_cursor_char_next(c))
1020 {
1021 return;
1022 }
1023 evas_textblock_cursor_char_prev(c);
1024
1025 Edje_Entry_Change_Info *info = calloc(1, sizeof(*info));
1026 char *tmp = evas_textblock_cursor_content_get(c);
1027
1028 info->insert = EINA_FALSE;
1029 if (backspace)
1030 {
1031 info->change.del.start = pos - 1;
1032 info->change.del.end = pos;
1033 }
1034 else
1035 {
1036 info->change.del.start = pos + 1;
1037 info->change.del.end = pos;
1038 }
1039
1040 info->change.del.content = eina_stringshare_add(tmp);
1041 if (tmp) free(tmp);
1042
1043 evas_textblock_cursor_char_delete(c);
1044 _edje_emit(ed, "entry,changed", en->rp->part->name);
1045 _edje_emit_full(ed, "entry,changed,user", en->rp->part->name,
1046 info, _free_entry_change_info);
1047}
1048
1049static void
1050_edje_entry_hide_visible_password(Edje_Real_Part *rp)
1051{
1052 const Evas_Object_Textblock_Node_Format *node;
1053 node = evas_textblock_node_format_first_get(rp->object);
1054 for (; node; node = evas_textblock_node_format_next_get(node))
1055 {
1056 const char *text = evas_textblock_node_format_text_get(node);
1057 if (text)
1058 {
1059 if (!strcmp(text, "+ password=off"))
1060 {
1061 evas_textblock_node_format_remove_pair(rp->object,
1062 (Evas_Object_Textblock_Node_Format *) node);
1063 break;
1064 }
1065 }
1066 }
1067 _edje_entry_real_part_configure(rp);
1068 _edje_emit(rp->edje, "entry,changed", rp->part->name);
1069}
1070
1071static Eina_Bool
1072_password_timer_cb(void *data)
1073{
1074 Entry *en = (Entry *)data;
1075 _edje_entry_hide_visible_password(en->rp);
1076 en->pw_timer = NULL;
1077 return ECORE_CALLBACK_CANCEL;
1078}
1079
1080static void
1081_edje_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1082{
1083 Edje *ed = data;
1084 Evas_Event_Key_Down *ev = event_info;
1085 Edje_Real_Part *rp = ed->focused_part;
1086 Entry *en;
1087 Eina_Bool control, alt, shift;
1088 Eina_Bool multiline;
1089 Eina_Bool cursor_changed;
1090 int old_cur_pos;
1091 if (!rp) return;
1092 en = rp->entry_data;
1093 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
1094 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_EDITABLE))
1095 return;
1096 if (!ev->key) return;
1097
1098#ifdef HAVE_ECORE_IMF
1099 if (en->imf_context)
1100 {
1101 Ecore_IMF_Event_Key_Down ecore_ev;
1102 ecore_imf_evas_event_key_down_wrap(ev, &ecore_ev);
1103 if (ecore_imf_context_filter_event(en->imf_context,
1104 ECORE_IMF_EVENT_KEY_DOWN,
1105 (Ecore_IMF_Event *)&ecore_ev))
1106 return;
1107 }
1108#endif
1109
1110 old_cur_pos = evas_textblock_cursor_pos_get(en->cursor);
1111
1112 control = evas_key_modifier_is_set(ev->modifiers, "Control");
1113 alt = evas_key_modifier_is_set(ev->modifiers, "Alt");
1114 shift = evas_key_modifier_is_set(ev->modifiers, "Shift");
1115 multiline = rp->part->multiline;
1116 cursor_changed = EINA_FALSE;
1117 if (!strcmp(ev->key, "Escape"))
1118 {
1119 // dead keys here. Escape for now (should emit these)
1120 _edje_emit(ed, "entry,key,escape", rp->part->name);
1121 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1122 }
1123 else if (!strcmp(ev->key, "Up") || !strcmp(ev->key, "KP_Up"))
1124 {
1125 if (multiline)
1126 {
1127 if (en->select_allow)
1128 {
1129 if (shift) _sel_start(en->cursor, rp->object, en);
1130 else _sel_clear(en->cursor, rp->object, en);
1131 }
1132 _curs_up(en->cursor, rp->object, en);
1133 if (en->select_allow)
1134 {
1135 if (shift) _sel_extend(en->cursor, rp->object, en);
1136 }
1137 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1138 }
1139 _sel_clear(en->cursor, rp->object, en);
1140 _edje_emit(ed, "entry,key,up", rp->part->name);
1141 }
1142 else if (!strcmp(ev->key, "Down") || !strcmp(ev->key, "KP_Down"))
1143 {
1144 if (multiline)
1145 {
1146 if (en->select_allow)
1147 {
1148 if (shift) _sel_start(en->cursor, rp->object, en);
1149 else _sel_clear(en->cursor, rp->object, en);
1150 }
1151 _curs_down(en->cursor, rp->object, en);
1152 if (en->select_allow)
1153 {
1154 if (shift) _sel_extend(en->cursor, rp->object, en);
1155 }
1156 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1157 }
1158 _sel_clear(en->cursor, rp->object, en);
1159 _edje_emit(ed, "entry,key,down", rp->part->name);
1160 }
1161 else if (!strcmp(ev->key, "Left") || !strcmp(ev->key, "KP_Left"))
1162 {
1163 if (en->select_allow)
1164 {
1165 if (shift) _sel_start(en->cursor, rp->object, en);
1166 else _sel_clear(en->cursor, rp->object, en);
1167 }
1168 _curs_back(en->cursor, rp->object, en);
1169 if (en->select_allow)
1170 {
1171 if (shift) _sel_extend(en->cursor, rp->object, en);
1172 }
1173 _sel_clear(en->cursor, rp->object, en);
1174 _edje_emit(ed, "entry,key,left", rp->part->name);
1175 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1176 }
1177 else if (!strcmp(ev->key, "Right") || !strcmp(ev->key, "KP_Right"))
1178 {
1179 if (en->select_allow)
1180 {
1181 if (shift) _sel_start(en->cursor, rp->object, en);
1182 else _sel_clear(en->cursor, rp->object, en);
1183 }
1184 _curs_next(en->cursor, rp->object, en);
1185 if (en->select_allow)
1186 {
1187 if (shift) _sel_extend(en->cursor, rp->object, en);
1188 }
1189 _sel_clear(en->cursor, rp->object, en);
1190 _edje_emit(ed, "entry,key,right", rp->part->name);
1191 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1192 }
1193 else if (!strcmp(ev->key, "BackSpace"))
1194 {
1195 if (control)
1196 {
1197 // del to start of previous word
1198 }
1199 else if ((alt) && (shift))
1200 {
1201 // undo last action
1202 }
1203 else
1204 {
1205 if (en->have_selection)
1206 {
1207 _range_del_emit(ed, en->cursor, rp->object, en);
1208 }
1209 else
1210 {
1211 if (evas_textblock_cursor_char_prev(en->cursor))
1212 {
1213 _delete_emit(ed, en->cursor, en, old_cur_pos, EINA_TRUE);
1214 }
1215 }
1216 }
1217 _sel_clear(en->cursor, rp->object, en);
1218 _anchors_get(en->cursor, rp->object, en);
1219 _edje_emit(ed, "entry,key,backspace", rp->part->name);
1220 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1221 }
1222 else if (!strcmp(ev->key, "Delete") || !strcmp(ev->key, "KP_Delete"))
1223 {
1224 if (control)
1225 {
1226 // del to end of next word
1227 }
1228 else if (shift)
1229 {
1230 // cut
1231 }
1232 else
1233 {
1234 if (en->have_selection)
1235 {
1236 _range_del_emit(ed, en->cursor, rp->object, en);
1237 }
1238 else
1239 {
1240 _delete_emit(ed, en->cursor, en, old_cur_pos, EINA_FALSE);
1241 }
1242 }
1243 _sel_clear(en->cursor, rp->object, en);
1244 _anchors_get(en->cursor, rp->object, en);
1245 _edje_emit(ed, "entry,key,delete", rp->part->name);
1246 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1247 }
1248 else if (!strcmp(ev->key, "Home") || !strcmp(ev->key, "KP_Home"))
1249 {
1250 if (en->select_allow)
1251 {
1252 if (shift) _sel_start(en->cursor, rp->object, en);
1253 else _sel_clear(en->cursor, rp->object, en);
1254 }
1255 if ((control) && (multiline))
1256 _curs_start(en->cursor, rp->object, en);
1257 else
1258 _curs_lin_start(en->cursor, rp->object, en);
1259 if (en->select_allow)
1260 {
1261 if (shift) _sel_extend(en->cursor, rp->object, en);
1262 }
1263 _edje_emit(ed, "entry,key,home", rp->part->name);
1264 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1265 }
1266 else if (!strcmp(ev->key, "End") || !strcmp(ev->key, "KP_End"))
1267 {
1268 if (en->select_allow)
1269 {
1270 if (shift) _sel_start(en->cursor, rp->object, en);
1271 else _sel_clear(en->cursor, rp->object, en);
1272 }
1273 if ((control) && (multiline))
1274 _curs_end(en->cursor, rp->object, en);
1275 else
1276 _curs_lin_end(en->cursor, rp->object, en);
1277 if (en->select_allow)
1278 {
1279 if (shift) _sel_extend(en->cursor, rp->object, en);
1280 }
1281 _edje_emit(ed, "entry,key,end", rp->part->name);
1282 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1283 }
1284 else if (!strcmp(ev->key, "Shift_L") || !strcmp(ev->key, "Shift_R"))
1285 {
1286 return;
1287 }
1288 else if ((control) && (!strcmp(ev->key, "v")))
1289 {
1290 _edje_emit(ed, "entry,paste,request", rp->part->name);
1291 _edje_emit(ed, "entry,paste,request,3", rp->part->name);
1292 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1293 }
1294 else if ((control) && (!strcmp(ev->key, "a")))
1295 {
1296 _edje_emit(ed, "entry,selection,all,request", rp->part->name);
1297 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1298 }
1299 else if ((control) && (!strcmp(ev->key, "A")))
1300 {
1301 _edje_emit(ed, "entry,selection,none,request", rp->part->name);
1302 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1303 }
1304 else if ((control) && ((!strcmp(ev->key, "c") || (!strcmp(ev->key, "Insert")))))
1305 {
1306 // FIXME: copy - save selection
1307 _edje_emit(ed, "entry,copy,notify", rp->part->name);
1308 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1309 }
1310 else if ((control) && ((!strcmp(ev->key, "x") || (!strcmp(ev->key, "m")))))
1311 {
1312 // FIXME: cut - save selection, delete seletion
1313 _edje_emit(ed, "entry,cut,notify", rp->part->name);
1314 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1315 }
1316 else if ((control) && (!strcmp(ev->key, "z")))
1317 {
1318 if (shift)
1319 {
1320 // redo
1321 _edje_emit(ed, "entry,redo,request", rp->part->name);
1322 }
1323 else
1324 {
1325 // undo
1326 _edje_emit(ed, "entry,undo,request", rp->part->name);
1327 }
1328 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1329 }
1330 else if ((control) && (!strcmp(ev->key, "y")))
1331 {
1332 // redo
1333 _edje_emit(ed, "entry,redo,request", rp->part->name);
1334 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1335 }
1336 else if ((control) && (!strcmp(ev->key, "w")))
1337 {
1338 _sel_clear(en->cursor, rp->object, en);
1339 // select current word
1340 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1341 }
1342 else if (!strcmp(ev->key, "Tab"))
1343 {
1344 if (multiline)
1345 {
1346 if (shift)
1347 {
1348 // remove a tab
1349 }
1350 else
1351 {
1352 Edje_Entry_Change_Info *info = calloc(1, sizeof(*info));
1353 info->insert = EINA_TRUE;
1354 info->change.insert.plain_length = 1;
1355
1356 if (en->have_selection)
1357 {
1358 _range_del_emit(ed, en->cursor, rp->object, en);
1359 info->merge = EINA_TRUE;
1360 }
1361 _sel_clear(en->cursor, rp->object, en);
1362 info->change.insert.pos =
1363 evas_textblock_cursor_pos_get(en->cursor);
1364 info->change.insert.content = eina_stringshare_add("<\t>");
1365 //yy
1366// evas_textblock_cursor_format_prepend(en->cursor, "\t");
1367 _text_filter_format_prepend(en, en->cursor, "\t");
1368 _anchors_get(en->cursor, rp->object, en);
1369 _edje_emit(ed, "entry,changed", rp->part->name);
1370 _edje_emit_full(ed, "entry,changed,user", rp->part->name,
1371 info, _free_entry_change_info);
1372 }
1373 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1374 }
1375 _edje_emit(ed, "entry,key,tab", rp->part->name);
1376 }
1377 else if ((!strcmp(ev->key, "ISO_Left_Tab")) && (multiline))
1378 {
1379 // remove a tab
1380 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1381 }
1382 else if (!strcmp(ev->key, "Prior") || !strcmp(ev->key, "KP_Prior"))
1383 {
1384 if (en->select_allow)
1385 {
1386 if (shift) _sel_start(en->cursor, rp->object, en);
1387 else _sel_clear(en->cursor, rp->object, en);
1388 }
1389 _curs_jump_line_by(en->cursor, rp->object, en, -10);
1390 if (en->select_allow)
1391 {
1392 if (shift) _sel_extend(en->cursor, rp->object, en);
1393 }
1394 _sel_clear(en->cursor, rp->object, en);
1395 _edje_emit(ed, "entry,key,pgup", rp->part->name);
1396 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1397 }
1398 else if (!strcmp(ev->key, "Next") || !strcmp(ev->key, "KP_Next"))
1399 {
1400 if (en->select_allow)
1401 {
1402 if (shift) _sel_start(en->cursor, rp->object, en);
1403 else _sel_clear(en->cursor, rp->object, en);
1404 }
1405 _curs_jump_line_by(en->cursor, rp->object, en, 10);
1406 if (en->select_allow)
1407 {
1408 if (shift) _sel_extend(en->cursor, rp->object, en);
1409 }
1410 _sel_clear(en->cursor, rp->object, en);
1411 _edje_emit(ed, "entry,key,pgdn", rp->part->name);
1412 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1413 }
1414 else if ((!strcmp(ev->key, "Return")) || (!strcmp(ev->key, "KP_Enter")))
1415 {
1416 if (multiline)
1417 {
1418 Edje_Entry_Change_Info *info = calloc(1, sizeof(*info));
1419 info->insert = EINA_TRUE;
1420 info->change.insert.plain_length = 1;
1421 if (en->have_selection)
1422 {
1423 _range_del_emit(ed, en->cursor, rp->object, en);
1424 info->merge = EINA_TRUE;
1425 }
1426 _sel_clear(en->cursor, rp->object, en);
1427
1428 info->change.insert.pos =
1429 evas_textblock_cursor_pos_get(en->cursor);
1430 if (shift)
1431 {
1432 //yy
1433// evas_textblock_cursor_format_prepend(en->cursor, "\n");
1434 _text_filter_format_prepend(en, en->cursor, "\n");
1435 info->change.insert.content = eina_stringshare_add("<\n>");
1436 }
1437 else
1438 {
1439 //yy
1440// evas_textblock_cursor_format_prepend(en->cursor, "ps");
1441 _text_filter_format_prepend(en, en->cursor, "ps");
1442 info->change.insert.content = eina_stringshare_add("<ps>");
1443 }
1444 _anchors_get(en->cursor, rp->object, en);
1445 _edje_emit(ed, "entry,changed", rp->part->name);
1446 _edje_emit_full(ed, "entry,changed,user", rp->part->name,
1447 info, _free_entry_change_info);
1448 _edje_emit(ed, "cursor,changed", rp->part->name);
1449 cursor_changed = EINA_TRUE;
1450 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1451 }
1452 _edje_emit(ed, "entry,key,enter", rp->part->name);
1453 }
1454 else
1455 {
1456 if (ev->string)
1457 {
1458 Edje_Entry_Change_Info *info = calloc(1, sizeof(*info));
1459 info->insert = EINA_TRUE;
1460 info->change.insert.plain_length = 1;
1461 info->change.insert.content = eina_stringshare_add(ev->string);
1462
1463 if (en->have_selection)
1464 {
1465 _range_del_emit(ed, en->cursor, rp->object, en);
1466 info->merge = EINA_TRUE;
1467 }
1468 _sel_clear(en->cursor, rp->object, en);
1469
1470 info->change.insert.pos =
1471 evas_textblock_cursor_pos_get(en->cursor);
1472 // if PASSWORD_SHOW_LAST mode, appending text with password=off tag
1473 if ((rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD) &&
1474 _edje_password_show_last)
1475 {
1476 _edje_entry_hide_visible_password(en->rp);
1477 _text_filter_format_prepend(en, en->cursor, "+ password=off");
1478 _text_filter_text_prepend(en, en->cursor, ev->string);
1479 _text_filter_format_prepend(en, en->cursor, "- password");
1480 if (en->pw_timer)
1481 {
1482 ecore_timer_del(en->pw_timer);
1483 en->pw_timer = NULL;
1484 }
1485 en->pw_timer = ecore_timer_add(_edje_password_show_last_timeout,
1486 _password_timer_cb, en);
1487 }
1488 else
1489 _text_filter_text_prepend(en, en->cursor, ev->string);
1490 _anchors_get(en->cursor, rp->object, en);
1491 _edje_emit(ed, "entry,changed", rp->part->name);
1492 _edje_emit_full(ed, "entry,changed,user", rp->part->name,
1493 info, _free_entry_change_info);
1494 _edje_emit(ed, "cursor,changed", rp->part->name);
1495 cursor_changed = EINA_TRUE;
1496 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1497 }
1498 }
1499 if (!cursor_changed && (old_cur_pos != evas_textblock_cursor_pos_get(en->cursor)))
1500 _edje_emit(ed, "cursor,changed", rp->part->name);
1501
1502 _edje_entry_imf_context_reset(en);
1503 _edje_entry_imf_cursor_info_set(en);
1504 _edje_entry_real_part_configure(rp);
1505}
1506
1507static void
1508_edje_key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1509{
1510 Edje *ed = data;
1511 Edje_Real_Part *rp = ed->focused_part;
1512 Entry *en;
1513
1514 if (!rp) return;
1515 en = rp->entry_data;
1516 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
1517 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_EDITABLE))
1518 return;
1519
1520#ifdef HAVE_ECORE_IMF
1521 if (en->imf_context)
1522 {
1523 Evas_Event_Key_Up *ev = event_info;
1524 Ecore_IMF_Event_Key_Up ecore_ev;
1525
1526 ecore_imf_evas_event_key_up_wrap(ev, &ecore_ev);
1527 if (ecore_imf_context_filter_event(en->imf_context,
1528 ECORE_IMF_EVENT_KEY_UP,
1529 (Ecore_IMF_Event *)&ecore_ev))
1530 return;
1531 }
1532#else
1533 (void) event_info;
1534#endif
1535}
1536
1537static void
1538_edje_part_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1539{
1540 Edje_Real_Part *rp = data;
1541 Entry *en;
1542 if (!rp) return;
1543 en = rp->entry_data;
1544 if (!en) return;
1545 _edje_entry_imf_cursor_info_set(en);
1546}
1547
1548static void
1549_edje_part_mouse_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1550{
1551 Evas_Coord cx, cy;
1552 Edje_Real_Part *rp = data;
1553 Evas_Event_Mouse_Down *ev = event_info;
1554 Entry *en;
1555 Evas_Coord x, y, w, h;
1556 // Eina_Bool multiline;
1557 Evas_Textblock_Cursor *tc;
1558 Eina_Bool dosel = EINA_FALSE;
1559 if (!rp) return;
1560 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1561 en = rp->entry_data;
1562 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
1563 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
1564 return;
1565 if ((ev->button != 1) && (ev->button != 2)) return;
1566
1567#ifdef HAVE_ECORE_IMF
1568 if (en->imf_context)
1569 {
1570 Ecore_IMF_Event_Mouse_Down ecore_ev;
1571 ecore_imf_evas_event_mouse_down_wrap(ev, &ecore_ev);
1572 if (ecore_imf_context_filter_event(en->imf_context,
1573 ECORE_IMF_EVENT_MOUSE_DOWN,
1574 (Ecore_IMF_Event *)&ecore_ev))
1575 return;
1576 }
1577#endif
1578
1579 en->select_mod_start = EINA_FALSE;
1580 en->select_mod_end = EINA_FALSE;
1581 if (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_DEFAULT)
1582 dosel = EINA_TRUE;
1583 else if (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT)
1584 {
1585 if (en->select_allow) dosel = EINA_TRUE;
1586 }
1587 if (ev->button == 2) dosel = EINA_FALSE;
1588 if (dosel)
1589 {
1590 // double click -> select word
1591 // triple click -> select line
1592 }
1593 tc = evas_object_textblock_cursor_new(rp->object);
1594 evas_textblock_cursor_copy(en->cursor, tc);
1595 // multiline = rp->part->multiline;
1596 evas_object_geometry_get(rp->object, &x, &y, &w, &h);
1597 cx = ev->canvas.x - x;
1598 cy = ev->canvas.y - y;
1599 if (!evas_textblock_cursor_char_coord_set(en->cursor, cx, cy))
1600 {
1601 Evas_Coord lx, ly, lw, lh;
1602 int line;
1603
1604 line = evas_textblock_cursor_line_coord_set(en->cursor, cy);
1605 if (line == -1)
1606 {
1607 if (rp->part->multiline)
1608 _curs_end(en->cursor, rp->object, en);
1609 else
1610 {
1611 evas_textblock_cursor_paragraph_first(en->cursor);
1612 evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh);
1613 if (!evas_textblock_cursor_char_coord_set(en->cursor, cx, ly + (lh / 2)))
1614 _curs_end(en->cursor, rp->object, en);
1615 }
1616 }
1617 else
1618 {
1619 int lnum;
1620
1621 lnum = evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh);
1622 if (lnum < 0)
1623 {
1624 _curs_lin_start(en->cursor, rp->object, en);
1625 }
1626 else
1627 {
1628 if (cx <= lx)
1629 _curs_lin_start(en->cursor, rp->object, en);
1630 else
1631 _curs_lin_end(en->cursor, rp->object, en);
1632 }
1633 }
1634 }
1635 if (dosel)
1636 {
1637 if ((en->have_selection) &&
1638 (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT))
1639 {
1640 Eina_List *first, *last;
1641 FLOAT_T sc;
1642
1643 first = en->sel;
1644 last = eina_list_last(en->sel);
1645 if (first && last)
1646 {
1647 Evas_Textblock_Rectangle *r1, *r2;
1648 Evas_Coord d, d1, d2;
1649
1650 r1 = first->data;
1651 r2 = last->data;
1652 d = r1->x - cx;
1653 d1 = d * d;
1654 d = (r1->y + (r1->h / 2)) - cy;
1655 d1 += d * d;
1656 d = r2->x + r2->w - 1 - cx;
1657 d2 = d * d;
1658 d = (r2->y + (r2->h / 2)) - cy;
1659 d2 += d * d;
1660 sc = rp->edje->scale;
1661 if (sc == ZERO) sc = _edje_scale;
1662 d = (Evas_Coord)MUL(FROM_INT(20), sc); // FIXME: maxing number!
1663 d = d * d;
1664 if (d1 < d2)
1665 {
1666 if (d1 <= d)
1667 {
1668 en->select_mod_start = EINA_TRUE;
1669 en->selecting = EINA_TRUE;
1670 }
1671 }
1672 else
1673 {
1674 if (d2 <= d)
1675 {
1676 en->select_mod_end = EINA_TRUE;
1677 en->selecting = EINA_TRUE;
1678 }
1679 }
1680 }
1681 }
1682 else
1683 {
1684 en->selecting = EINA_TRUE;
1685 _sel_clear(en->cursor, rp->object, en);
1686 if (en->select_allow)
1687 {
1688 _sel_start(en->cursor, rp->object, en);
1689 }
1690 }
1691 }
1692 if (evas_textblock_cursor_compare(tc, en->cursor))
1693 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
1694 evas_textblock_cursor_free(tc);
1695
1696 _edje_entry_imf_context_reset(en);
1697 _edje_entry_imf_cursor_info_set(en);
1698
1699 _edje_entry_real_part_configure(rp);
1700 if (ev->button == 2)
1701 {
1702 _edje_emit(rp->edje, "entry,paste,request", rp->part->name);
1703 _edje_emit(rp->edje, "entry,paste,request,1", rp->part->name);
1704 }
1705}
1706
1707static void
1708_edje_part_mouse_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1709{
1710 Evas_Coord cx, cy;
1711 Edje_Real_Part *rp = data;
1712 Evas_Event_Mouse_Up *ev = event_info;
1713 Entry *en;
1714 Evas_Coord x, y, w, h;
1715 Evas_Textblock_Cursor *tc;
1716 if (ev->button != 1) return;
1717 if (!rp) return;
1718 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1719 en = rp->entry_data;
1720 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
1721 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
1722 return;
1723
1724#ifdef HAVE_ECORE_IMF
1725 if (en->imf_context)
1726 {
1727 Ecore_IMF_Event_Mouse_Up ecore_ev;
1728 ecore_imf_evas_event_mouse_up_wrap(ev, &ecore_ev);
1729 if (ecore_imf_context_filter_event(en->imf_context,
1730 ECORE_IMF_EVENT_MOUSE_UP,
1731 (Ecore_IMF_Event *)&ecore_ev))
1732 return;
1733 }
1734#endif
1735
1736 tc = evas_object_textblock_cursor_new(rp->object);
1737 evas_textblock_cursor_copy(en->cursor, tc);
1738 evas_object_geometry_get(rp->object, &x, &y, &w, &h);
1739 cx = ev->canvas.x - x;
1740 cy = ev->canvas.y - y;
1741 if (!evas_textblock_cursor_char_coord_set(en->cursor, cx, cy))
1742 {
1743 Evas_Coord lx, ly, lw, lh;
1744 int line;
1745
1746 line = evas_textblock_cursor_line_coord_set(en->cursor, cy);
1747 if (line == -1)
1748 {
1749 if (rp->part->multiline)
1750 _curs_end(en->cursor, rp->object, en);
1751 else
1752 {
1753 evas_textblock_cursor_paragraph_first(en->cursor);
1754 evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh);
1755 if (!evas_textblock_cursor_char_coord_set(en->cursor, cx, ly + (lh / 2)))
1756 _curs_end(en->cursor, rp->object, en);
1757 }
1758 }
1759 else
1760 {
1761 int lnum;
1762
1763 lnum = evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh);
1764 if (lnum < 0)
1765 {
1766 _curs_lin_start(en->cursor, rp->object, en);
1767 }
1768 else
1769 {
1770 if (cx <= lx)
1771 _curs_lin_start(en->cursor, rp->object, en);
1772 else
1773 _curs_lin_end(en->cursor, rp->object, en);
1774 }
1775 }
1776 }
1777 if (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT)
1778 {
1779 if (en->select_allow)
1780 {
1781 if (en->had_sel)
1782 {
1783 if (en->select_mod_end)
1784 _sel_extend(en->cursor, rp->object, en);
1785 else if (en->select_mod_start)
1786 _sel_preextend(en->cursor, rp->object, en);
1787 }
1788 else
1789 _sel_extend(en->cursor, rp->object, en);
1790 //evas_textblock_cursor_copy(en->cursor, en->sel_end);
1791 }
1792 }
1793 else
1794 evas_textblock_cursor_copy(en->cursor, en->sel_end);
1795 if (en->selecting)
1796 {
1797 if (en->have_selection)
1798 en->had_sel = EINA_TRUE;
1799 en->selecting = EINA_FALSE;
1800 }
1801 if (evas_textblock_cursor_compare(tc, en->cursor))
1802 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
1803 evas_textblock_cursor_free(tc);
1804
1805 _edje_entry_imf_context_reset(en);
1806 _edje_entry_imf_cursor_info_set(en);
1807 _edje_entry_real_part_configure(rp);
1808}
1809
1810static void
1811_edje_part_mouse_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1812{
1813 Evas_Coord cx, cy;
1814 Edje_Real_Part *rp = data;
1815 Evas_Event_Mouse_Move *ev = event_info;
1816 Entry *en;
1817 Evas_Coord x, y, w, h;
1818 Evas_Textblock_Cursor *tc;
1819 if (!rp) return;
1820 en = rp->entry_data;
1821 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
1822 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
1823 return;
1824
1825#ifdef HAVE_ECORE_IMF
1826 if (en->imf_context)
1827 {
1828 Ecore_IMF_Event_Mouse_Move ecore_ev;
1829 ecore_imf_evas_event_mouse_move_wrap(ev, &ecore_ev);
1830 if (ecore_imf_context_filter_event(en->imf_context,
1831 ECORE_IMF_EVENT_MOUSE_MOVE,
1832 (Ecore_IMF_Event *)&ecore_ev))
1833 return;
1834 }
1835#endif
1836
1837 if (en->selecting)
1838 {
1839 tc = evas_object_textblock_cursor_new(rp->object);
1840 evas_textblock_cursor_copy(en->cursor, tc);
1841 evas_object_geometry_get(rp->object, &x, &y, &w, &h);
1842 cx = ev->cur.canvas.x - x;
1843 cy = ev->cur.canvas.y - y;
1844 if (!evas_textblock_cursor_char_coord_set(en->cursor, cx, cy))
1845 {
1846 Evas_Coord lx, ly, lw, lh;
1847
1848 if (evas_textblock_cursor_line_coord_set(en->cursor, cy) < 0)
1849 {
1850 if (rp->part->multiline)
1851 _curs_end(en->cursor, rp->object, en);
1852 else
1853 {
1854 evas_textblock_cursor_paragraph_first(en->cursor);
1855 evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh);
1856 if (!evas_textblock_cursor_char_coord_set(en->cursor, cx, ly + (lh / 2)))
1857 _curs_end(en->cursor, rp->object, en);
1858 }
1859 }
1860 else
1861 {
1862 evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh);
1863 if (cx <= lx)
1864 _curs_lin_start(en->cursor, rp->object, en);
1865 else
1866 _curs_lin_end(en->cursor, rp->object, en);
1867 }
1868 }
1869 if (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT)
1870 {
1871 if (en->select_allow)
1872 {
1873 if (en->had_sel)
1874 {
1875 if (en->select_mod_end)
1876 _sel_extend(en->cursor, rp->object, en);
1877 else if (en->select_mod_start)
1878 _sel_preextend(en->cursor, rp->object, en);
1879 }
1880 else
1881 _sel_extend(en->cursor, rp->object, en);
1882 }
1883 }
1884 else
1885 {
1886 _sel_extend(en->cursor, rp->object, en);
1887 }
1888 if (en->select_allow)
1889 {
1890 if (evas_textblock_cursor_compare(en->sel_start, en->sel_end) != 0)
1891 _sel_enable(en->cursor, rp->object, en);
1892 if (en->have_selection)
1893 _sel_update(en->cursor, rp->object, en);
1894 }
1895 if (evas_textblock_cursor_compare(tc, en->cursor))
1896 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
1897 evas_textblock_cursor_free(tc);
1898
1899 _edje_entry_imf_context_reset(en);
1900 _edje_entry_imf_cursor_info_set(en);
1901
1902 _edje_entry_real_part_configure(rp);
1903 }
1904}
1905
1906static void
1907_evas_focus_in_cb(void *data, Evas *e, __UNUSED__ void *event_info)
1908{
1909 Edje *ed = (Edje *)data;
1910
1911 if (evas_focus_get(e) == ed->obj)
1912 {
1913 _edje_focus_in_cb(data, NULL, NULL, NULL);
1914 }
1915}
1916
1917static void
1918_evas_focus_out_cb(void *data, Evas *e, __UNUSED__ void *event_info)
1919{
1920 Edje *ed = (Edje *)data;
1921
1922 if (evas_focus_get(e) == ed->obj)
1923 {
1924 _edje_focus_out_cb(data, NULL, NULL, NULL);
1925 }
1926}
1927
1928/***************************************************************/
1929void
1930_edje_entry_init(Edje *ed)
1931{
1932 if (!ed->has_entries)
1933 return;
1934 if (ed->entries_inited)
1935 return;
1936 ed->entries_inited = EINA_TRUE;
1937
1938 evas_object_event_callback_add(ed->obj, EVAS_CALLBACK_FOCUS_IN, _edje_focus_in_cb, ed);
1939 evas_object_event_callback_add(ed->obj, EVAS_CALLBACK_FOCUS_OUT, _edje_focus_out_cb, ed);
1940 evas_object_event_callback_add(ed->obj, EVAS_CALLBACK_KEY_DOWN, _edje_key_down_cb, ed);
1941 evas_object_event_callback_add(ed->obj, EVAS_CALLBACK_KEY_UP, _edje_key_up_cb, ed);
1942 evas_event_callback_add(ed->base.evas, EVAS_CALLBACK_CANVAS_FOCUS_IN, _evas_focus_in_cb, ed);
1943 evas_event_callback_add(ed->base.evas, EVAS_CALLBACK_CANVAS_FOCUS_OUT, _evas_focus_out_cb, ed);
1944}
1945
1946void
1947_edje_entry_shutdown(Edje *ed)
1948{
1949 if (!ed->has_entries)
1950 return;
1951 if (!ed->entries_inited)
1952 return;
1953 ed->entries_inited = EINA_FALSE;
1954
1955 evas_object_event_callback_del(ed->obj, EVAS_CALLBACK_FOCUS_IN, _edje_focus_in_cb);
1956 evas_object_event_callback_del(ed->obj, EVAS_CALLBACK_FOCUS_OUT, _edje_focus_out_cb);
1957 evas_object_event_callback_del(ed->obj, EVAS_CALLBACK_KEY_DOWN, _edje_key_down_cb);
1958 evas_object_event_callback_del(ed->obj, EVAS_CALLBACK_KEY_UP, _edje_key_up_cb);
1959 if (evas_event_callback_del_full(ed->base.evas, EVAS_CALLBACK_CANVAS_FOCUS_IN, _evas_focus_in_cb, ed) != ed)
1960 ERR("could not unregister EVAS_CALLBACK_FOCUS_IN");
1961 if (evas_event_callback_del_full(ed->base.evas, EVAS_CALLBACK_CANVAS_FOCUS_OUT, _evas_focus_out_cb, ed) != ed)
1962 ERR("could not unregister EVAS_CALLBACK_FOCUS_OUT");
1963}
1964
1965void
1966_edje_entry_real_part_init(Edje_Real_Part *rp)
1967{
1968 Entry *en;
1969#ifdef HAVE_ECORE_IMF
1970 const char *ctx_id;
1971 const Ecore_IMF_Context_Info *ctx_info;
1972#endif
1973
1974 en = calloc(1, sizeof(Entry));
1975 if (!en) return;
1976 rp->entry_data = en;
1977 en->rp = rp;
1978
1979 evas_object_event_callback_add(rp->object, EVAS_CALLBACK_MOVE, _edje_part_move_cb, rp);
1980
1981 evas_object_event_callback_add(rp->object, EVAS_CALLBACK_MOUSE_DOWN, _edje_part_mouse_down_cb, rp);
1982 evas_object_event_callback_add(rp->object, EVAS_CALLBACK_MOUSE_UP, _edje_part_mouse_up_cb, rp);
1983 evas_object_event_callback_add(rp->object, EVAS_CALLBACK_MOUSE_MOVE, _edje_part_mouse_move_cb, rp);
1984
1985 if (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_DEFAULT)
1986 en->select_allow = EINA_TRUE;
1987
1988 if (rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD)
1989 {
1990 Edje_Part_Description_Text *txt;
1991
1992 txt = (Edje_Part_Description_Text *)rp->chosen_description;
1993
1994 en->select_allow = EINA_FALSE;
1995 if (txt && edje_string_get(&txt->text.repch))
1996 evas_object_textblock_replace_char_set(rp->object, edje_string_get(&txt->text.repch));
1997 else
1998 evas_object_textblock_replace_char_set(rp->object, "*");
1999 }
2000
2001 en->cursor_bg = edje_object_add(rp->edje->base.evas);
2002 edje_object_file_set(en->cursor_bg, rp->edje->path, rp->part->source3);
2003 evas_object_smart_member_add(en->cursor_bg, rp->edje->obj);
2004 evas_object_stack_below(en->cursor_bg, rp->object);
2005 evas_object_clip_set(en->cursor_bg, evas_object_clip_get(rp->object));
2006 evas_object_pass_events_set(en->cursor_bg, EINA_TRUE);
2007 _edje_subobj_register(en->rp->edje, en->cursor_bg);
2008
2009 en->cursor_fg = edje_object_add(rp->edje->base.evas);
2010 edje_object_file_set(en->cursor_fg, rp->edje->path, rp->part->source4);
2011 evas_object_smart_member_add(en->cursor_fg, rp->edje->obj);
2012 evas_object_stack_above(en->cursor_fg, rp->object);
2013 evas_object_clip_set(en->cursor_fg, evas_object_clip_get(rp->object));
2014 evas_object_pass_events_set(en->cursor_fg, EINA_TRUE);
2015 _edje_subobj_register(en->rp->edje, en->cursor_fg);
2016
2017 if (rp->part->entry_mode >= EDJE_ENTRY_EDIT_MODE_EDITABLE)
2018 {
2019 evas_object_show(en->cursor_bg);
2020 evas_object_show(en->cursor_fg);
2021#ifdef HAVE_ECORE_IMF
2022 ecore_imf_init();
2023
2024 edje_object_signal_callback_add(rp->edje->obj, "focus,part,in", rp->part->name, _edje_entry_focus_in_cb, rp);
2025 edje_object_signal_callback_add(rp->edje->obj, "focus,part,out", rp->part->name, _edje_entry_focus_out_cb, rp);
2026
2027 ctx_id = ecore_imf_context_default_id_get();
2028 if (ctx_id)
2029 {
2030 ctx_info = ecore_imf_context_info_by_id_get(ctx_id);
2031 if (!ctx_info->canvas_type ||
2032 strcmp(ctx_info->canvas_type, "evas") == 0)
2033 {
2034 en->imf_context = ecore_imf_context_add(ctx_id);
2035 }
2036 else
2037 {
2038 ctx_id = ecore_imf_context_default_id_by_canvas_type_get("evas");
2039 if (ctx_id)
2040 {
2041 en->imf_context = ecore_imf_context_add(ctx_id);
2042 }
2043 }
2044 }
2045 else
2046 en->imf_context = NULL;
2047
2048 if (!en->imf_context) goto done;
2049
2050 ecore_imf_context_client_window_set
2051 (en->imf_context,
2052 (void *)ecore_evas_window_get
2053 (ecore_evas_ecore_evas_get(rp->edje->base.evas)));
2054 ecore_imf_context_client_canvas_set(en->imf_context, rp->edje->base.evas);
2055
2056 ecore_imf_context_retrieve_surrounding_callback_set(en->imf_context,
2057 _edje_entry_imf_retrieve_surrounding_cb, rp->edje);
2058 en->imf_ee_handler_commit = ecore_event_handler_add(ECORE_IMF_EVENT_COMMIT, _edje_entry_imf_event_commit_cb, rp->edje);
2059 en->imf_ee_handler_delete = ecore_event_handler_add(ECORE_IMF_EVENT_DELETE_SURROUNDING, _edje_entry_imf_event_delete_surrounding_cb, rp->edje);
2060 en->imf_ee_handler_changed = ecore_event_handler_add(ECORE_IMF_EVENT_PREEDIT_CHANGED, _edje_entry_imf_event_preedit_changed_cb, rp->edje);
2061 ecore_imf_context_input_mode_set(en->imf_context,
2062 rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD ?
2063 ECORE_IMF_INPUT_MODE_INVISIBLE : ECORE_IMF_INPUT_MODE_FULL);
2064#endif
2065 }
2066#ifdef HAVE_ECORE_IMF
2067done:
2068#endif
2069 en->cursor = (Evas_Textblock_Cursor *)evas_object_textblock_cursor_get(rp->object);
2070}
2071
2072void
2073_edje_entry_real_part_shutdown(Edje_Real_Part *rp)
2074{
2075 Entry *en = rp->entry_data;
2076 if (!en) return;
2077 rp->entry_data = NULL;
2078 _sel_clear(en->cursor, rp->object, en);
2079 _anchors_clear(en->cursor, rp->object, en);
2080#ifdef HAVE_ECORE_IMF
2081 _preedit_clear(en);
2082#endif
2083 evas_object_del(en->cursor_bg);
2084 evas_object_del(en->cursor_fg);
2085
2086 if (en->pw_timer)
2087 {
2088 ecore_timer_del(en->pw_timer);
2089 en->pw_timer = NULL;
2090 }
2091
2092#ifdef HAVE_ECORE_IMF
2093 if (rp->part->entry_mode >= EDJE_ENTRY_EDIT_MODE_EDITABLE)
2094 {
2095 if (en->imf_context)
2096 {
2097 if (en->imf_ee_handler_commit)
2098 {
2099 ecore_event_handler_del(en->imf_ee_handler_commit);
2100 en->imf_ee_handler_commit = NULL;
2101 }
2102
2103 if (en->imf_ee_handler_delete)
2104 {
2105 ecore_event_handler_del(en->imf_ee_handler_delete);
2106 en->imf_ee_handler_delete = NULL;
2107 }
2108
2109 if (en->imf_ee_handler_changed)
2110 {
2111 ecore_event_handler_del(en->imf_ee_handler_changed);
2112 en->imf_ee_handler_changed = NULL;
2113 }
2114
2115 ecore_imf_context_del(en->imf_context);
2116 en->imf_context = NULL;
2117 }
2118
2119 edje_object_signal_callback_del(rp->edje->obj, "focus,part,in", rp->part->name, _edje_entry_focus_in_cb);
2120 edje_object_signal_callback_del(rp->edje->obj, "focus,part,out", rp->part->name, _edje_entry_focus_out_cb);
2121 ecore_imf_shutdown();
2122 }
2123#endif
2124
2125 free(en);
2126}
2127
2128void
2129_edje_entry_real_part_configure(Edje_Real_Part *rp)
2130{
2131 Evas_Coord x, y, w, h, xx, yy, ww, hh;
2132 Entry *en = rp->entry_data;
2133 Evas_Textblock_Cursor_Type cur_type;
2134 if (!en) return;
2135 switch (rp->part->cursor_mode)
2136 {
2137 case EDJE_ENTRY_CURSOR_MODE_BEFORE:
2138 cur_type = EVAS_TEXTBLOCK_CURSOR_BEFORE;
2139 break;
2140 case EDJE_ENTRY_CURSOR_MODE_UNDER:
2141 /* no break for a resaon */
2142 default:
2143 cur_type = EVAS_TEXTBLOCK_CURSOR_UNDER;
2144 }
2145
2146 _sel_update(en->cursor, rp->object, en);
2147 _anchors_update(en->cursor, rp->object, en);
2148 x = y = w = h = -1;
2149 xx = yy = ww = hh = -1;
2150 evas_object_geometry_get(rp->object, &x, &y, &w, &h);
2151 evas_textblock_cursor_geometry_get(en->cursor, &xx, &yy, &ww, &hh, NULL, cur_type);
2152 if (ww < 1) ww = 1;
2153 if (hh < 1) hh = 1;
2154 if (en->cursor_bg)
2155 {
2156 evas_object_move(en->cursor_bg, x + xx, y + yy);
2157 evas_object_resize(en->cursor_bg, ww, hh);
2158 }
2159 if (en->cursor_fg)
2160 {
2161 evas_object_move(en->cursor_fg, x + xx, y + yy);
2162 evas_object_resize(en->cursor_fg, ww, hh);
2163 }
2164}
2165
2166const char *
2167_edje_entry_selection_get(Edje_Real_Part *rp)
2168{
2169 Entry *en = rp->entry_data;
2170 if (!en) return NULL;
2171 // get selection - convert to markup
2172 if ((!en->selection) && (en->have_selection))
2173 en->selection = evas_textblock_cursor_range_text_get
2174 (en->sel_start, en->sel_end, EVAS_TEXTBLOCK_TEXT_MARKUP);
2175 return en->selection;
2176}
2177
2178const char *
2179_edje_entry_text_get(Edje_Real_Part *rp)
2180{
2181 Entry *en = rp->entry_data;
2182 if (!en) return NULL;
2183 // get text - convert to markup
2184 return evas_object_textblock_text_markup_get(rp->object);
2185}
2186
2187void
2188_edje_entry_text_markup_set(Edje_Real_Part *rp, const char *text)
2189{
2190 Entry *en = rp->entry_data;
2191 if (!en) return;
2192
2193 // set text as markup
2194 _sel_clear(en->cursor, rp->object, en);
2195 evas_object_textblock_text_markup_set(rp->object, text);
2196 _edje_entry_set_cursor_start(rp);
2197
2198 _anchors_get(en->cursor, rp->object, en);
2199 _edje_emit(rp->edje, "entry,changed", rp->part->name);
2200 _edje_entry_imf_cursor_info_set(en);
2201#if 0
2202 /* Don't emit cursor changed cause it didn't. It's just init to 0. */
2203 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
2204#endif
2205}
2206
2207void
2208_edje_entry_text_markup_append(Edje_Real_Part *rp, const char *text)
2209{
2210 Entry *en = rp->entry_data;
2211 Evas_Textblock_Cursor *end_cur;
2212 if (!en) return;
2213 end_cur = evas_object_textblock_cursor_new(rp->object);
2214 evas_textblock_cursor_paragraph_last(end_cur);
2215
2216 _text_filter_markup_prepend(en, end_cur, text);
2217 evas_textblock_cursor_free(end_cur);
2218
2219 /* We are updating according to the real cursor on purpose */
2220 _anchors_get(en->cursor, rp->object, en);
2221 _edje_emit(rp->edje, "entry,changed", rp->part->name);
2222
2223 _edje_entry_real_part_configure(rp);
2224}
2225
2226void
2227_edje_entry_text_markup_insert(Edje_Real_Part *rp, const char *text)
2228{
2229 Entry *en = rp->entry_data;
2230 if (!en) return;
2231 // prepend markup @ cursor pos
2232 if (en->have_selection)
2233 _range_del(en->cursor, rp->object, en);
2234 _sel_clear(en->cursor, rp->object, en);
2235 //xx
2236// evas_object_textblock_text_markup_prepend(en->cursor, text);
2237 _text_filter_markup_prepend(en, en->cursor, text);
2238 _anchors_get(en->cursor, rp->object, en);
2239 _edje_emit(rp->edje, "entry,changed", rp->part->name);
2240 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
2241
2242 _edje_entry_imf_context_reset(en);
2243 _edje_entry_imf_cursor_info_set(en);
2244
2245 _edje_entry_real_part_configure(rp);
2246}
2247
2248void
2249_edje_entry_set_cursor_start(Edje_Real_Part *rp)
2250{
2251 Entry *en = rp->entry_data;
2252 if (!en) return;
2253 _curs_start(en->cursor, rp->object, en);
2254
2255 _edje_entry_imf_cursor_info_set(en);
2256}
2257
2258void
2259_edje_entry_set_cursor_end(Edje_Real_Part *rp)
2260{
2261 Entry *en = rp->entry_data;
2262 if (!en) return;
2263 _curs_end(en->cursor, rp->object, en);
2264
2265 _edje_entry_imf_cursor_info_set(en);
2266}
2267
2268void
2269_edje_entry_select_none(Edje_Real_Part *rp)
2270{
2271 Entry *en = rp->entry_data;
2272 if (!en) return;
2273 _sel_clear(en->cursor, rp->object, en);
2274}
2275
2276void
2277_edje_entry_select_all(Edje_Real_Part *rp)
2278{
2279 Entry *en = rp->entry_data;
2280 if (!en) return;
2281 _sel_clear(en->cursor, rp->object, en);
2282 _curs_start(en->cursor, rp->object, en);
2283 _sel_enable(en->cursor, rp->object, en);
2284 _sel_start(en->cursor, rp->object, en);
2285 _curs_end(en->cursor, rp->object, en);
2286 _sel_extend(en->cursor, rp->object, en);
2287
2288 _edje_entry_imf_context_reset(en);
2289 _edje_entry_imf_cursor_info_set(en);
2290 _edje_entry_real_part_configure(rp);
2291}
2292
2293void
2294_edje_entry_select_begin(Edje_Real_Part *rp)
2295{
2296 Entry *en = rp->entry_data;
2297 if (!en) return;
2298 _sel_clear(en->cursor, rp->object, en);
2299 _sel_enable(en->cursor, rp->object, en);
2300 _sel_start(en->cursor, rp->object, en);
2301 _sel_extend(en->cursor, rp->object, en);
2302
2303 _edje_entry_imf_context_reset(en);
2304 _edje_entry_imf_cursor_info_set(en);
2305
2306 _edje_entry_real_part_configure(rp);
2307}
2308
2309void
2310_edje_entry_select_extend(Edje_Real_Part *rp)
2311{
2312 Entry *en = rp->entry_data;
2313 if (!en) return;
2314 _sel_extend(en->cursor, rp->object, en);
2315
2316 _edje_entry_imf_context_reset(en);
2317 _edje_entry_imf_cursor_info_set(en);
2318
2319 _edje_entry_real_part_configure(rp);
2320}
2321
2322const Eina_List *
2323_edje_entry_anchor_geometry_get(Edje_Real_Part *rp, const char *anchor)
2324{
2325 Entry *en = rp->entry_data;
2326 Eina_List *l;
2327 Anchor *an;
2328
2329 if (!en) return NULL;
2330 EINA_LIST_FOREACH(en->anchors, l, an)
2331 {
2332 if (an->item) continue;
2333 if (!strcmp(anchor, an->name))
2334 return an->sel;
2335 }
2336 return NULL;
2337}
2338
2339const Eina_List *
2340_edje_entry_anchors_list(Edje_Real_Part *rp)
2341{
2342 Entry *en = rp->entry_data;
2343 Eina_List *l, *anchors = NULL;
2344 Anchor *an;
2345
2346 if (!en) return NULL;
2347 if (!en->anchorlist)
2348 {
2349 EINA_LIST_FOREACH(en->anchors, l, an)
2350 {
2351 const char *n = an->name;
2352 if (an->item) continue;
2353 if (!n) n = "";
2354 anchors = eina_list_append(anchors, strdup(n));
2355 }
2356 en->anchorlist = anchors;
2357 }
2358 return en->anchorlist;
2359}
2360
2361Eina_Bool
2362_edje_entry_item_geometry_get(Edje_Real_Part *rp, const char *item, Evas_Coord *cx, Evas_Coord *cy, Evas_Coord *cw, Evas_Coord *ch)
2363{
2364 Entry *en = rp->entry_data;
2365 Eina_List *l;
2366 Anchor *an;
2367
2368 if (!en) return EINA_FALSE;
2369 EINA_LIST_FOREACH(en->anchors, l, an)
2370 {
2371 if (an->item) continue;
2372 if (!strcmp(item, an->name))
2373 {
2374 evas_textblock_cursor_format_item_geometry_get(an->start, cx, cy, cw, ch);
2375 return EINA_TRUE;
2376 }
2377 }
2378 return EINA_FALSE;
2379}
2380
2381const Eina_List *
2382_edje_entry_items_list(Edje_Real_Part *rp)
2383{
2384 Entry *en = rp->entry_data;
2385 Eina_List *l, *items = NULL;
2386 Anchor *an;
2387
2388 if (!en) return NULL;
2389 if (!en->itemlist)
2390 {
2391 EINA_LIST_FOREACH(en->anchors, l, an)
2392 {
2393 const char *n = an->name;
2394 if (an->item) continue;
2395 if (!n) n = "";
2396 items = eina_list_append(items, strdup(n));
2397 }
2398 en->itemlist = items;
2399 }
2400 return en->itemlist;
2401}
2402
2403void
2404_edje_entry_cursor_geometry_get(Edje_Real_Part *rp, Evas_Coord *cx, Evas_Coord *cy, Evas_Coord *cw, Evas_Coord *ch)
2405{
2406 Evas_Coord x, y, w, h, xx, yy, ww, hh;
2407 Entry *en = rp->entry_data;
2408 Evas_Textblock_Cursor_Type cur_type;
2409 if (!en) return;
2410 switch (rp->part->cursor_mode)
2411 {
2412 case EDJE_ENTRY_CURSOR_MODE_BEFORE:
2413 cur_type = EVAS_TEXTBLOCK_CURSOR_BEFORE;
2414 break;
2415 case EDJE_ENTRY_CURSOR_MODE_UNDER:
2416 /* no break for a resaon */
2417 default:
2418 cur_type = EVAS_TEXTBLOCK_CURSOR_UNDER;
2419 }
2420
2421 x = y = w = h = -1;
2422 xx = yy = ww = hh = -1;
2423 evas_object_geometry_get(rp->object, &x, &y, &w, &h);
2424 evas_textblock_cursor_geometry_get(en->cursor, &xx, &yy, &ww, &hh, NULL, cur_type);
2425 if (ww < 1) ww = 1;
2426 if (rp->part->cursor_mode == EDJE_ENTRY_CURSOR_MODE_BEFORE)
2427 edje_object_size_min_restricted_calc(en->cursor_fg, &ww, NULL, ww, 0);
2428 if (hh < 1) hh = 1;
2429 if (cx) *cx = x + xx;
2430 if (cy) *cy = y + yy;
2431 if (cw) *cw = ww;
2432 if (ch) *ch = hh;
2433}
2434
2435void
2436_edje_entry_select_allow_set(Edje_Real_Part *rp, Eina_Bool allow)
2437{
2438 Entry *en = rp->entry_data;
2439 if (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_DEFAULT)
2440 return;
2441 en->select_allow = allow;
2442}
2443
2444Eina_Bool
2445_edje_entry_select_allow_get(const Edje_Real_Part *rp)
2446{
2447 const Entry *en = rp->entry_data;
2448 return en->select_allow;
2449}
2450
2451void
2452_edje_entry_select_abort(Edje_Real_Part *rp)
2453{
2454 Entry *en = rp->entry_data;
2455 if (en->selecting)
2456 {
2457 en->selecting = EINA_FALSE;
2458
2459 _edje_entry_imf_context_reset(en);
2460 _edje_entry_imf_cursor_info_set(en);
2461 _edje_entry_real_part_configure(rp);
2462 }
2463}
2464
2465void
2466_edje_entry_autocapital_type_set(Edje_Real_Part *rp, Edje_Text_Autocapital_Type autocapital_type)
2467{
2468 Entry *en = rp->entry_data;
2469 if (!en) return;
2470
2471 if (rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD)
2472 autocapital_type = EDJE_TEXT_AUTOCAPITAL_TYPE_NONE;
2473
2474#ifdef HAVE_ECORE_IMF
2475 if (en->imf_context)
2476 ecore_imf_context_autocapital_type_set(en->imf_context, autocapital_type);
2477#endif
2478}
2479
2480Edje_Text_Autocapital_Type
2481_edje_entry_autocapital_type_get(Edje_Real_Part *rp)
2482{
2483 Entry *en = rp->entry_data;
2484 if (!en) return EDJE_TEXT_AUTOCAPITAL_TYPE_NONE;
2485
2486#ifdef HAVE_ECORE_IMF
2487 if (en->imf_context)
2488 return ecore_imf_context_autocapital_type_get(en->imf_context);
2489#endif
2490
2491 return EDJE_TEXT_AUTOCAPITAL_TYPE_NONE;
2492}
2493
2494void
2495_edje_entry_input_panel_enabled_set(Edje_Real_Part *rp, Eina_Bool enabled)
2496{
2497 Entry *en = rp->entry_data;
2498
2499 if (!en) return;
2500#ifdef HAVE_ECORE_IMF
2501 if (en->imf_context)
2502 ecore_imf_context_input_panel_enabled_set(en->imf_context, enabled);
2503#else
2504 (void) enabled;
2505#endif
2506}
2507
2508Eina_Bool
2509_edje_entry_input_panel_enabled_get(Edje_Real_Part *rp)
2510{
2511 Entry *en = rp->entry_data;
2512 if (!en) return EINA_FALSE;
2513#ifdef HAVE_ECORE_IMF
2514 if (en->imf_context)
2515 return ecore_imf_context_input_panel_enabled_get(en->imf_context);
2516#endif
2517
2518 return EINA_FALSE;
2519}
2520
2521static Evas_Textblock_Cursor *
2522_cursor_get(Edje_Real_Part *rp, Edje_Cursor cur)
2523{
2524 Entry *en = rp->entry_data;
2525 if (!en) return NULL;
2526
2527 switch (cur)
2528 {
2529 case EDJE_CURSOR_MAIN:
2530 return en->cursor;
2531 case EDJE_CURSOR_SELECTION_BEGIN:
2532 return en->sel_start;
2533 case EDJE_CURSOR_SELECTION_END:
2534 return en->sel_end;
2535 case EDJE_CURSOR_PREEDIT_START:
2536 if (!en->preedit_start)
2537 en->preedit_start = evas_object_textblock_cursor_new(rp->object);
2538 return en->preedit_start;
2539 case EDJE_CURSOR_PREEDIT_END:
2540 if (!en->preedit_end)
2541 en->preedit_end = evas_object_textblock_cursor_new(rp->object);
2542 return en->preedit_end;
2543 case EDJE_CURSOR_USER:
2544 if (!en->cursor_user)
2545 en->cursor_user = evas_object_textblock_cursor_new(rp->object);
2546 return en->cursor_user;
2547 case EDJE_CURSOR_USER_EXTRA:
2548 if (!en->cursor_user_extra)
2549 en->cursor_user_extra = evas_object_textblock_cursor_new(rp->object);
2550 return en->cursor_user_extra;
2551 default:
2552 break;
2553 }
2554 return NULL;
2555}
2556
2557Eina_Bool
2558_edje_entry_cursor_next(Edje_Real_Part *rp, Edje_Cursor cur)
2559{
2560 Entry *en = rp->entry_data;
2561 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
2562 if (!c) return EINA_FALSE;
2563 if (!evas_textblock_cursor_char_next(c))
2564 {
2565 return EINA_FALSE;
2566 }
2567 _sel_update(c, rp->object, rp->entry_data);
2568
2569 _edje_entry_imf_context_reset(en);
2570 _edje_entry_imf_cursor_info_set(en);
2571
2572 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
2573 _edje_entry_real_part_configure(rp);
2574 return EINA_TRUE;
2575}
2576
2577Eina_Bool
2578_edje_entry_cursor_prev(Edje_Real_Part *rp, Edje_Cursor cur)
2579{
2580 Entry *en = rp->entry_data;
2581 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
2582 if (!c) return EINA_FALSE;
2583 if (!evas_textblock_cursor_char_prev(c))
2584 {
2585 if (evas_textblock_cursor_paragraph_prev(c)) goto ok;
2586 else return EINA_FALSE;
2587 }
2588ok:
2589 _sel_update(c, rp->object, rp->entry_data);
2590
2591 _edje_entry_imf_context_reset(en);
2592 _edje_entry_imf_cursor_info_set(en);
2593
2594 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
2595 _edje_entry_real_part_configure(rp);
2596 return EINA_TRUE;
2597}
2598
2599Eina_Bool
2600_edje_entry_cursor_up(Edje_Real_Part *rp, Edje_Cursor cur)
2601{
2602 Entry *en = rp->entry_data;
2603 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
2604 Evas_Coord lx, ly, lw, lh, cx, cy, cw, ch;
2605 int ln;
2606 if (!c) return EINA_FALSE;
2607 ln = evas_textblock_cursor_line_geometry_get(c, NULL, NULL, NULL, NULL);
2608 ln--;
2609 if (ln < 0) return EINA_FALSE;
2610 if (!evas_object_textblock_line_number_geometry_get(rp->object, ln,
2611 &lx, &ly, &lw, &lh))
2612 return EINA_FALSE;
2613 evas_textblock_cursor_char_geometry_get(c, &cx, &cy, &cw, &ch);
2614 if (!evas_textblock_cursor_char_coord_set(c, cx, ly + (lh / 2)))
2615 {
2616 if (cx < (lx + (lw / 2)))
2617 evas_textblock_cursor_line_char_last(c);
2618 else
2619 evas_textblock_cursor_line_char_last(c);
2620 }
2621 _sel_update(c, rp->object, rp->entry_data);
2622
2623 _edje_entry_imf_context_reset(en);
2624 _edje_entry_imf_cursor_info_set(en);
2625
2626 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
2627 _edje_entry_real_part_configure(rp);
2628 return EINA_TRUE;
2629}
2630
2631Eina_Bool
2632_edje_entry_cursor_down(Edje_Real_Part *rp, Edje_Cursor cur)
2633{
2634 Entry *en = rp->entry_data;
2635 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
2636 Evas_Coord lx, ly, lw, lh, cx, cy, cw, ch;
2637 int ln;
2638 if (!c) return EINA_FALSE;
2639 ln = evas_textblock_cursor_line_geometry_get(c, NULL, NULL, NULL, NULL);
2640 ln++;
2641 if (!evas_object_textblock_line_number_geometry_get(rp->object, ln,
2642 &lx, &ly, &lw, &lh))
2643 return EINA_FALSE;
2644 evas_textblock_cursor_char_geometry_get(c, &cx, &cy, &cw, &ch);
2645 if (!evas_textblock_cursor_char_coord_set(c, cx, ly + (lh / 2)))
2646 {
2647 if (cx < (lx + (lw / 2)))
2648 evas_textblock_cursor_line_char_last(c);
2649 else
2650 evas_textblock_cursor_line_char_last(c);
2651 }
2652 _sel_update(c, rp->object, rp->entry_data);
2653
2654 _edje_entry_imf_context_reset(en);
2655 _edje_entry_imf_cursor_info_set(en);
2656 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
2657 _edje_entry_real_part_configure(rp);
2658 return EINA_TRUE;
2659}
2660
2661void
2662_edje_entry_cursor_begin(Edje_Real_Part *rp, Edje_Cursor cur)
2663{
2664 Entry *en = rp->entry_data;
2665 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
2666 if (!c) return;
2667 evas_textblock_cursor_paragraph_first(c);
2668 _sel_update(c, rp->object, rp->entry_data);
2669
2670 _edje_entry_imf_context_reset(en);
2671 _edje_entry_imf_cursor_info_set(en);
2672 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
2673 _edje_entry_real_part_configure(rp);
2674}
2675
2676void
2677_edje_entry_cursor_end(Edje_Real_Part *rp, Edje_Cursor cur)
2678{
2679 Entry *en = rp->entry_data;
2680 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
2681 if (!c) return;
2682 _curs_end(c, rp->object, rp->entry_data);
2683 _sel_update(c, rp->object, rp->entry_data);
2684
2685 _edje_entry_imf_context_reset(en);
2686 _edje_entry_imf_cursor_info_set(en);
2687
2688 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
2689 _edje_entry_real_part_configure(rp);
2690}
2691
2692void
2693_edje_entry_cursor_copy(Edje_Real_Part *rp, Edje_Cursor cur, Edje_Cursor dst)
2694{
2695 Entry *en = rp->entry_data;
2696 Evas_Textblock_Cursor *c;
2697 Evas_Textblock_Cursor *d;
2698
2699 c = _cursor_get(rp, cur);
2700 if (!c) return;
2701 d = _cursor_get(rp, dst);
2702 if (!d) return;
2703 evas_textblock_cursor_copy(c, d);
2704 _sel_update(c, rp->object, rp->entry_data);
2705
2706 _edje_entry_imf_context_reset(en);
2707 _edje_entry_imf_cursor_info_set(en);
2708 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
2709 _edje_entry_real_part_configure(rp);
2710}
2711
2712void
2713_edje_entry_cursor_line_begin(Edje_Real_Part *rp, Edje_Cursor cur)
2714{
2715 Entry *en = rp->entry_data;
2716 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
2717 if (!c) return;
2718 evas_textblock_cursor_line_char_first(c);
2719 _sel_update(c, rp->object, rp->entry_data);
2720
2721 _edje_entry_imf_context_reset(en);
2722 _edje_entry_imf_cursor_info_set(en);
2723
2724 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
2725 _edje_entry_real_part_configure(rp);
2726}
2727
2728void
2729_edje_entry_cursor_line_end(Edje_Real_Part *rp, Edje_Cursor cur)
2730{
2731 Entry *en = rp->entry_data;
2732 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
2733 if (!c) return;
2734 evas_textblock_cursor_line_char_last(c);
2735 _sel_update(c, rp->object, rp->entry_data);
2736
2737 _edje_entry_imf_context_reset(en);
2738 _edje_entry_imf_cursor_info_set(en);
2739 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
2740 _edje_entry_real_part_configure(rp);
2741}
2742
2743Eina_Bool
2744_edje_entry_cursor_coord_set(Edje_Real_Part *rp, Edje_Cursor cur,
2745 Evas_Coord x, Evas_Coord y)
2746{
2747 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
2748 if (!c) return EINA_FALSE;
2749 return evas_textblock_cursor_char_coord_set(c, x, y);
2750}
2751
2752Eina_Bool
2753_edje_entry_cursor_is_format_get(Edje_Real_Part *rp, Edje_Cursor cur)
2754{
2755 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
2756 if (!c) return EINA_FALSE;
2757 if (evas_textblock_cursor_is_format(c)) return EINA_TRUE;
2758 return EINA_FALSE;
2759}
2760
2761Eina_Bool
2762_edje_entry_cursor_is_visible_format_get(Edje_Real_Part *rp, Edje_Cursor cur)
2763{
2764 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
2765 if (!c) return EINA_FALSE;
2766 return evas_textblock_cursor_format_is_visible_get(c);
2767}
2768
2769const char *
2770_edje_entry_cursor_content_get(Edje_Real_Part *rp, Edje_Cursor cur)
2771{
2772 static char *s = NULL;
2773 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
2774
2775 if (!c) return NULL;
2776 if (s)
2777 {
2778 free(s);
2779 s = NULL;
2780 }
2781
2782 s = evas_textblock_cursor_content_get(c);
2783 return s;
2784}
2785
2786void
2787_edje_entry_cursor_pos_set(Edje_Real_Part *rp, Edje_Cursor cur, int pos)
2788{
2789 Entry *en = rp->entry_data;
2790 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
2791 if (!c) return;
2792 /* Abort if cursor position didn't really change */
2793 if (evas_textblock_cursor_pos_get(c) == pos)
2794 return;
2795
2796 evas_textblock_cursor_pos_set(c, pos);
2797 _sel_update(c, rp->object, rp->entry_data);
2798
2799 _edje_entry_imf_context_reset(en);
2800 _edje_entry_imf_cursor_info_set(en);
2801 _edje_emit(rp->edje, "cursor,changed", rp->part->name);
2802 _edje_entry_real_part_configure(rp);
2803}
2804
2805int
2806_edje_entry_cursor_pos_get(Edje_Real_Part *rp, Edje_Cursor cur)
2807{
2808 Evas_Textblock_Cursor *c = _cursor_get(rp, cur);
2809 if (!c) return 0;
2810 return evas_textblock_cursor_pos_get(c);
2811}
2812
2813void
2814_edje_entry_input_panel_layout_set(Edje_Real_Part *rp, Edje_Input_Panel_Layout layout)
2815{
2816 Entry *en = rp->entry_data;
2817 if (!en) return;
2818#ifdef HAVE_ECORE_IMF
2819 if (en->imf_context)
2820 ecore_imf_context_input_panel_layout_set(en->imf_context, layout);
2821#else
2822 (void) layout;
2823#endif
2824}
2825
2826Edje_Input_Panel_Layout
2827_edje_entry_input_panel_layout_get(Edje_Real_Part *rp)
2828{
2829 Entry *en = rp->entry_data;
2830 if (!en) return EDJE_INPUT_PANEL_LAYOUT_INVALID;
2831#ifdef HAVE_ECORE_IMF
2832 if (en->imf_context)
2833 return ecore_imf_context_input_panel_layout_get(en->imf_context);
2834#endif
2835
2836 return EDJE_INPUT_PANEL_LAYOUT_INVALID;
2837}
2838
2839static void
2840_edje_entry_imf_context_reset(Entry *en)
2841{
2842#ifdef HAVE_ECORE_IMF
2843 if (en->imf_context)
2844 ecore_imf_context_reset(en->imf_context);
2845#else
2846 (void) en;
2847#endif
2848}
2849
2850static void
2851_edje_entry_imf_cursor_info_set(Entry *en)
2852{
2853#ifdef HAVE_ECORE_IMF
2854 Evas_Coord cx, cy, cw, ch;
2855 if (!en || !en->rp || !en->imf_context) return;
2856
2857 _edje_entry_cursor_geometry_get(en->rp, &cx, &cy, &cw, &ch);
2858
2859 ecore_imf_context_cursor_position_set(en->imf_context,
2860 evas_textblock_cursor_pos_get(en->cursor));
2861 ecore_imf_context_cursor_location_set(en->imf_context, cx, cy, cw, ch);
2862#else
2863 (void) en;
2864#endif
2865}
2866
2867#ifdef HAVE_ECORE_IMF
2868static Eina_Bool
2869_edje_entry_imf_retrieve_surrounding_cb(void *data, Ecore_IMF_Context *ctx __UNUSED__, char **text, int *cursor_pos)
2870{
2871 Edje *ed = data;
2872 Edje_Real_Part *rp = ed->focused_part;
2873 Entry *en;
2874 const char *str;
2875
2876 if (!rp) return EINA_FALSE;
2877 en = rp->entry_data;
2878 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
2879 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
2880 return EINA_FALSE;
2881
2882 if (text)
2883 {
2884 str = _edje_entry_text_get(rp);
2885 *text = str ? strdup(str) : strdup("");
2886 }
2887
2888 if (cursor_pos)
2889 *cursor_pos = evas_textblock_cursor_pos_get(en->cursor);
2890
2891 return EINA_TRUE;
2892}
2893
2894static Eina_Bool
2895_edje_entry_imf_event_commit_cb(void *data, int type __UNUSED__, void *event)
2896{
2897 Edje *ed = data;
2898 Edje_Real_Part *rp = ed->focused_part;
2899 Entry *en;
2900 Ecore_IMF_Event_Commit *ev = event;
2901 Evas_Textblock_Cursor *tc;
2902 Eina_Bool cursor_move = EINA_FALSE;
2903
2904 if ((!rp) || (!ev) || (!ev->str)) return ECORE_CALLBACK_PASS_ON;
2905
2906 en = rp->entry_data;
2907 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
2908 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
2909 return ECORE_CALLBACK_PASS_ON;
2910
2911 if (!en->imf_context) return ECORE_CALLBACK_PASS_ON;
2912 if (en->imf_context != ev->ctx) return ECORE_CALLBACK_PASS_ON;
2913
2914 if (en->have_selection)
2915 {
2916 if (strcmp(ev->str, ""))
2917 {
2918 /* delete selected characters */
2919 _range_del(en->cursor, rp->object, en);
2920 _sel_clear(en->cursor, rp->object, en);
2921 }
2922 }
2923
2924 tc = evas_object_textblock_cursor_new(rp->object);
2925
2926 /* calculate the cursor position to insert commit string */
2927 if (en->preedit_start)
2928 evas_textblock_cursor_copy(en->preedit_start, tc);
2929 else
2930 evas_textblock_cursor_copy(en->cursor, tc);
2931
2932#ifdef HAVE_ECORE_IMF
2933 /* delete preedit characters */
2934 _preedit_del(en);
2935 _preedit_clear(en);
2936#endif
2937
2938 if (evas_textblock_cursor_compare(en->cursor, tc))
2939 cursor_move = EINA_TRUE;
2940 if ((rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD) &&
2941 _edje_password_show_last)
2942 _edje_entry_hide_visible_password(en->rp);
2943 if ((rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD) &&
2944 _edje_password_show_last && (!en->preedit_start))
2945 {
2946 _text_filter_format_prepend(en, tc, "+ password=off");
2947 _text_filter_markup_prepend(en, tc, ev->str);
2948 _text_filter_format_prepend(en, tc, "- password");
2949 if (en->pw_timer)
2950 {
2951 ecore_timer_del(en->pw_timer);
2952 en->pw_timer = NULL;
2953 }
2954 en->pw_timer = ecore_timer_add(_edje_password_show_last_timeout,
2955 _password_timer_cb, en);
2956 }
2957 else
2958 _text_filter_text_prepend(en, tc, ev->str);
2959
2960 if (!cursor_move)
2961 {
2962 /* move cursor to the end of commit string */
2963 evas_textblock_cursor_copy(tc, en->cursor);
2964 }
2965
2966 evas_textblock_cursor_free(tc);
2967
2968 _edje_entry_imf_cursor_info_set(en);
2969 _anchors_get(en->cursor, rp->object, en);
2970 _edje_emit(rp->edje, "entry,changed", rp->part->name);
2971 _edje_emit(ed, "entry,changed,user", rp->part->name);
2972 _edje_emit(ed, "cursor,changed", rp->part->name);
2973
2974 return ECORE_CALLBACK_DONE;
2975}
2976
2977static Eina_Bool
2978_edje_entry_imf_event_preedit_changed_cb(void *data, int type __UNUSED__, void *event)
2979{
2980 Edje *ed = data;
2981 Edje_Real_Part *rp = ed->focused_part;
2982 Entry *en;
2983 Ecore_IMF_Event_Preedit_Changed *ev = event;
2984 int cursor_pos;
2985 int preedit_start_pos, preedit_end_pos;
2986 char *preedit_string;
2987 int i;
2988 Eina_Bool preedit_end_state = EINA_FALSE;
2989
2990 if ((!rp) || (!ev)) return ECORE_CALLBACK_PASS_ON;
2991
2992 en = rp->entry_data;
2993 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
2994 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
2995 return ECORE_CALLBACK_PASS_ON;
2996
2997 if (!en->imf_context) return ECORE_CALLBACK_PASS_ON;
2998
2999 if (en->imf_context != ev->ctx) return ECORE_CALLBACK_PASS_ON;
3000
3001 ecore_imf_context_preedit_string_get(en->imf_context, &preedit_string, &cursor_pos);
3002 if (!preedit_string) return ECORE_CALLBACK_PASS_ON;
3003
3004 if (!strcmp(preedit_string, ""))
3005 preedit_end_state = EINA_TRUE;
3006
3007 if (en->have_selection && !preedit_end_state)
3008 {
3009 /* delete selected characters */
3010 _range_del(en->cursor, rp->object, en);
3011 _sel_clear(en->cursor, rp->object, en);
3012 }
3013
3014 /* delete preedit characters */
3015 _preedit_del(en);
3016
3017 preedit_start_pos = evas_textblock_cursor_pos_get(en->cursor);
3018
3019 /* insert preedit character(s) */
3020 if ((rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD) &&
3021 _edje_password_show_last)
3022 {
3023 _text_filter_format_prepend(en, en->cursor, "+ password=off");
3024 _text_filter_markup_prepend(en, en->cursor, preedit_string);
3025 _text_filter_format_prepend(en, en->cursor, "- password");
3026 if (en->pw_timer)
3027 {
3028 ecore_timer_del(en->pw_timer);
3029 en->pw_timer = NULL;
3030 }
3031 en->pw_timer = ecore_timer_add(_edje_password_show_last_timeout,
3032 _password_timer_cb, en);
3033 }
3034 else
3035 {
3036 _text_filter_markup_prepend(en, en->cursor, preedit_string);
3037 }
3038
3039 if (!preedit_end_state)
3040 {
3041 /* set preedit start cursor */
3042 if (!en->preedit_start)
3043 en->preedit_start = evas_object_textblock_cursor_new(rp->object);
3044 evas_textblock_cursor_copy(en->cursor, en->preedit_start);
3045
3046 /* set preedit end cursor */
3047 if (!en->preedit_end)
3048 en->preedit_end = evas_object_textblock_cursor_new(rp->object);
3049 evas_textblock_cursor_copy(en->cursor, en->preedit_end);
3050
3051 preedit_end_pos = evas_textblock_cursor_pos_get(en->cursor);
3052
3053 for (i = 0; i < (preedit_end_pos - preedit_start_pos); i++)
3054 {
3055 evas_textblock_cursor_char_prev(en->preedit_start);
3056 }
3057
3058 en->have_preedit = EINA_TRUE;
3059
3060 /* set cursor position */
3061 evas_textblock_cursor_pos_set(en->cursor, preedit_start_pos + cursor_pos);
3062 }
3063
3064 _edje_entry_imf_cursor_info_set(en);
3065 _anchors_get(en->cursor, rp->object, en);
3066 _edje_emit(rp->edje, "preedit,changed", rp->part->name);
3067 _edje_emit(ed, "cursor,changed", rp->part->name);
3068
3069 free(preedit_string);
3070
3071 return ECORE_CALLBACK_DONE;
3072}
3073
3074static Eina_Bool
3075_edje_entry_imf_event_delete_surrounding_cb(void *data, int type __UNUSED__, void *event)
3076{
3077 Edje *ed = data;
3078 Edje_Real_Part *rp = ed->focused_part;
3079 Entry *en;
3080 Ecore_IMF_Event_Delete_Surrounding *ev = event;
3081 Evas_Textblock_Cursor *del_start, *del_end;
3082 int cursor_pos;
3083
3084 if ((!rp) || (!ev)) return ECORE_CALLBACK_PASS_ON;
3085 en = rp->entry_data;
3086 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
3087 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
3088 return ECORE_CALLBACK_PASS_ON;
3089
3090 if (!en->imf_context) return ECORE_CALLBACK_PASS_ON;
3091 if (en->imf_context != ev->ctx) return ECORE_CALLBACK_PASS_ON;
3092
3093 cursor_pos = evas_textblock_cursor_pos_get(en->cursor);
3094
3095 del_start = evas_object_textblock_cursor_new(en->rp->object);
3096 evas_textblock_cursor_pos_set(del_start, cursor_pos + ev->offset);
3097
3098 del_end = evas_object_textblock_cursor_new(en->rp->object);
3099 evas_textblock_cursor_pos_set(del_end, cursor_pos + ev->offset + ev->n_chars);
3100
3101 evas_textblock_cursor_range_delete(del_start, del_end);
3102
3103 evas_textblock_cursor_free(del_start);
3104 evas_textblock_cursor_free(del_end);
3105
3106 return ECORE_CALLBACK_DONE;
3107}
3108#endif
3109
3110/* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/
diff --git a/libraries/edje/src/lib/edje_external.c b/libraries/edje/src/lib/edje_external.c
new file mode 100644
index 0000000..8bf6256
--- /dev/null
+++ b/libraries/edje/src/lib/edje_external.c
@@ -0,0 +1,559 @@
1#include "edje_private.h"
2
3static Eina_Hash *type_registry = NULL;
4static int init_count = 0;
5
6EAPI const char *
7edje_external_param_type_str(Edje_External_Param_Type type)
8{
9 switch (type)
10 {
11 case EDJE_EXTERNAL_PARAM_TYPE_INT:
12 return "INT";
13 case EDJE_EXTERNAL_PARAM_TYPE_DOUBLE:
14 return "DOUBLE";
15 case EDJE_EXTERNAL_PARAM_TYPE_STRING:
16 return "STRING";
17 case EDJE_EXTERNAL_PARAM_TYPE_BOOL:
18 return "BOOL";
19 case EDJE_EXTERNAL_PARAM_TYPE_CHOICE:
20 return "CHOICE";
21 default:
22 return "(unknown)";
23 }
24}
25
26EAPI Evas_Object *
27edje_object_part_external_object_get(const Evas_Object *obj, const char *part)
28{
29 Edje *ed;
30 Edje_Real_Part *rp;
31
32 ed = _edje_fetch(obj);
33 if ((!ed) || (!part)) return NULL;
34
35 /* Need to recalc before providing the object. */
36 _edje_recalc_do(ed);
37
38 rp = _edje_real_part_recursive_get(ed, (char *)part);
39 if (!rp)
40 {
41 ERR("no part '%s'", part);
42 return NULL;
43 }
44 if (rp->part->type != EDJE_PART_TYPE_EXTERNAL)
45 {
46 ERR("cannot get external object of a part '%s' that is not EXTERNAL",
47 rp->part->name);
48 return NULL;
49 }
50 return rp->swallowed_object;
51}
52
53EAPI Eina_Bool
54edje_object_part_external_param_set(Evas_Object *obj, const char *part, const Edje_External_Param *param)
55{
56 Edje *ed;
57 Edje_Real_Part *rp;
58
59 if ((!param) || (!param->name)) return EINA_FALSE;
60
61 ed = _edje_fetch(obj);
62 if ((!ed) || (!part)) return EINA_FALSE;
63
64 rp = _edje_real_part_recursive_get(ed, (char *)part);
65 if (!rp)
66 {
67 ERR("no part '%s'", part);
68 return EINA_FALSE;
69 }
70
71 return _edje_external_param_set(obj, rp, param);
72}
73
74EAPI Eina_Bool
75edje_object_part_external_param_get(const Evas_Object *obj, const char *part, Edje_External_Param *param)
76{
77 Edje *ed;
78 Edje_Real_Part *rp;
79
80 if ((!param) || (!param->name)) return EINA_FALSE;
81
82 ed = _edje_fetch(obj);
83 if ((!ed) || (!part)) return EINA_FALSE;
84
85 rp = _edje_real_part_recursive_get(ed, (char *)part);
86 if (!rp)
87 {
88 ERR("no part '%s'", part);
89 return EINA_FALSE;
90 }
91
92 return _edje_external_param_get(obj, rp, param);
93}
94
95
96
97EAPI Evas_Object *
98edje_object_part_external_content_get(const Evas_Object *obj, const char *part, const char *content)
99{
100 Edje *ed;
101 Edje_Real_Part *rp;
102
103 if (!content) return EINA_FALSE;
104
105 ed = _edje_fetch(obj);
106 if ((!ed) || (!part)) return EINA_FALSE;
107
108 rp = _edje_real_part_recursive_get(ed, (char *)part);
109 if (!rp)
110 {
111 ERR("no part '%s'", part);
112 return EINA_FALSE;
113 }
114
115 return _edje_external_content_get(rp->swallowed_object, content);
116}
117
118EAPI Edje_External_Param_Type
119edje_object_part_external_param_type_get(const Evas_Object *obj, const char *part, const char *param)
120{
121 Edje *ed;
122 Edje_Real_Part *rp;
123 Edje_External_Type *type;
124 Edje_External_Param_Info *info;
125
126 ed = _edje_fetch(obj);
127 if ((!ed) || (!part)) return EDJE_EXTERNAL_PARAM_TYPE_MAX;
128
129 rp = _edje_real_part_recursive_get(ed, (char *)part);
130 if (!rp)
131 {
132 ERR("no part '%s'", part);
133 return EDJE_EXTERNAL_PARAM_TYPE_MAX;
134 }
135 type = evas_object_data_get(rp->swallowed_object, "Edje_External_Type");
136 if (!type)
137 {
138 ERR("no external type for object %p", obj);
139 return EDJE_EXTERNAL_PARAM_TYPE_MAX;
140 }
141 if (!type->parameters_info)
142 {
143 ERR("no parameters information for external type '%s'",
144 type->module_name);
145 return EDJE_EXTERNAL_PARAM_TYPE_MAX;
146 }
147 for (info = type->parameters_info; info->name; info++)
148 if (strcmp(info->name, param) == 0)
149 return info->type;
150
151 ERR("no parameter '%s' external type '%s'", param, type->module_name);
152 return EDJE_EXTERNAL_PARAM_TYPE_MAX;
153}
154
155
156EAPI Eina_Bool
157edje_external_type_register(const char *type_name, const Edje_External_Type *type_info)
158{
159 if (!type_name)
160 return EINA_FALSE;
161 if (!type_info)
162 return EINA_FALSE;
163
164 if (type_info->abi_version != EDJE_EXTERNAL_TYPE_ABI_VERSION)
165 {
166 ERR("external type '%s' (%p) has incorrect abi version. "
167 "got %#x where %#x was expected.",
168 type_name, type_info,
169 type_info->abi_version, EDJE_EXTERNAL_TYPE_ABI_VERSION);
170 return EINA_FALSE;
171 }
172
173 if (eina_hash_find(type_registry, type_name))
174 {
175 ERR("External type '%s' already registered", type_name);
176 return EINA_FALSE;
177 }
178 return eina_hash_add(type_registry, type_name, type_info);
179}
180
181EAPI Eina_Bool
182edje_external_type_unregister(const char *type_name)
183{
184 if (!type_name)
185 return EINA_FALSE;
186 return eina_hash_del_by_key(type_registry, type_name);
187}
188
189EAPI void
190edje_external_type_array_register(const Edje_External_Type_Info *array)
191{
192 const Edje_External_Type_Info *itr;
193
194 if (!array)
195 return;
196
197 for (itr = array; itr->name; itr++)
198 {
199 if (itr->info->abi_version != EDJE_EXTERNAL_TYPE_ABI_VERSION)
200 {
201 ERR("external type '%s' (%p) has incorrect abi "
202 "version. got %#x where %#x was expected.",
203 itr->name, itr->info,
204 itr->info->abi_version, EDJE_EXTERNAL_TYPE_ABI_VERSION);
205 continue;
206 }
207
208 eina_hash_direct_add(type_registry, itr->name, itr->info);
209 }
210}
211
212EAPI void
213edje_external_type_array_unregister(const Edje_External_Type_Info *array)
214{
215 const Edje_External_Type_Info *itr;
216
217 if (!array)
218 return;
219
220 for (itr = array; itr->name; itr++)
221 eina_hash_del(type_registry, itr->name, itr->info);
222}
223
224EAPI unsigned int
225edje_external_type_abi_version_get(void)
226{
227 return EDJE_EXTERNAL_TYPE_ABI_VERSION;
228}
229
230EAPI Eina_Iterator *
231edje_external_iterator_get(void)
232{
233 return eina_hash_iterator_tuple_new(type_registry);
234}
235
236EAPI Edje_External_Param *
237edje_external_param_find(const Eina_List *params, const char *key)
238{
239 const Eina_List *l;
240 Edje_External_Param *param;
241
242 EINA_LIST_FOREACH(params, l, param)
243 if (!strcmp(param->name, key)) return param;
244
245 return NULL;
246}
247
248EAPI Eina_Bool
249edje_external_param_int_get(const Eina_List *params, const char *key, int *ret)
250{
251 Edje_External_Param *param;
252
253 if (!params) return EINA_FALSE;
254 param = edje_external_param_find(params, key);
255
256 if (param && param->type == EDJE_EXTERNAL_PARAM_TYPE_INT && ret)
257 {
258 *ret = param->i;
259 return EINA_TRUE;
260 }
261
262 return EINA_FALSE;
263}
264
265EAPI Eina_Bool
266edje_external_param_double_get(const Eina_List *params, const char *key, double *ret)
267{
268 Edje_External_Param *param;
269
270 if (!params) return EINA_FALSE;
271 param = edje_external_param_find(params, key);
272
273 if (param && param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE && ret)
274 {
275 *ret = param->d;
276 return EINA_TRUE;
277 }
278
279 return EINA_FALSE;
280}
281
282EAPI Eina_Bool
283edje_external_param_string_get(const Eina_List *params, const char *key, const char **ret)
284{
285 Edje_External_Param *param;
286
287 if (!params) return EINA_FALSE;
288 param = edje_external_param_find(params, key);
289
290 if (param && param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING && ret)
291 {
292 *ret = param->s;
293 return EINA_TRUE;
294 }
295
296 return EINA_FALSE;
297}
298
299EAPI Eina_Bool
300edje_external_param_bool_get(const Eina_List *params, const char *key, Eina_Bool *ret)
301{
302 Edje_External_Param *param;
303
304 if (!params) return EINA_FALSE;
305 param = edje_external_param_find(params, key);
306
307 if (param && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL && ret)
308 {
309 *ret = param->i;
310 return EINA_TRUE;
311 }
312
313 return EINA_FALSE;
314}
315
316EAPI Eina_Bool
317edje_external_param_choice_get(const Eina_List *params, const char *key, const char **ret)
318{
319 Edje_External_Param *param;
320
321 if (!params) return EINA_FALSE;
322 param = edje_external_param_find(params, key);
323
324 if (param && param->type == EDJE_EXTERNAL_PARAM_TYPE_CHOICE && ret)
325 {
326 *ret = param->s;
327 return EINA_TRUE;
328 }
329
330 return EINA_FALSE;
331}
332
333EAPI const Edje_External_Param_Info *
334edje_external_param_info_get(const char *type_name)
335{
336 Edje_External_Type *type;
337
338 type = eina_hash_find(type_registry, type_name);
339 if (!type)
340 return NULL;
341 return type->parameters_info;
342}
343
344EAPI const Edje_External_Type *
345edje_external_type_get(const char *type_name)
346{
347 return eina_hash_find(type_registry, type_name);
348}
349
350void
351_edje_external_init()
352{
353 if (!type_registry)
354 type_registry = eina_hash_string_superfast_new(NULL);
355
356 init_count++;
357}
358
359void
360_edje_external_shutdown()
361{
362 if (--init_count == 0)
363 {
364 eina_hash_free(type_registry);
365 type_registry = NULL;
366 }
367}
368
369Evas_Object *
370_edje_external_type_add(const char *type_name, Evas *evas, Evas_Object *parent, const Eina_List *params, const char *part_name)
371{
372 Edje_External_Type *type;
373 Evas_Object *obj;
374
375 type = eina_hash_find(type_registry, type_name);
376 if (!type)
377 {
378 ERR("external type '%s' not registered", type_name);
379 return NULL;
380 }
381
382 obj = type->add(type->data, evas, parent, params, part_name);
383 if (!obj)
384 {
385 ERR("External type '%s' returned NULL from constructor", type_name);
386 return NULL;
387 }
388
389 evas_object_data_set(obj, "Edje_External_Type", type);
390
391 return obj;
392}
393
394void
395_edje_external_signal_emit(Evas_Object *obj, const char *emission, const char *source)
396{
397 Edje_External_Type *type;
398
399 type = evas_object_data_get(obj, "Edje_External_Type");
400 if (!type)
401 {
402 ERR("External type data not found.");
403 return;
404 }
405
406 type->signal_emit(type->data, obj, emission, source);
407}
408
409Eina_Bool
410_edje_external_param_set(Evas_Object *obj, Edje_Real_Part *rp, const Edje_External_Param *param)
411{
412 Evas_Object *swallowed_object = rp->swallowed_object;
413 Edje_External_Type *type = evas_object_data_get(swallowed_object, "Edje_External_Type");
414 if (!type)
415 {
416 if ((rp->part->type == EDJE_PART_TYPE_TEXT) ||
417 (rp->part->type == EDJE_PART_TYPE_TEXTBLOCK))
418 {
419 if ((param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING) &&
420 (!strcmp (param->name, "text")) && (obj))
421 {
422 return edje_object_part_text_set(obj, rp->part->name, param->s);
423 }
424 }
425
426 ERR("no external type for object %p", swallowed_object);
427 return EINA_FALSE;
428 }
429 if (!type->param_set)
430 {
431 ERR("external type '%s' from module '%s' does not provide param_set()",
432 type->module_name, type->module);
433 return EINA_FALSE;
434 }
435 return type->param_set(type->data, swallowed_object, param);
436}
437
438Eina_Bool
439_edje_external_param_get(const Evas_Object *obj, Edje_Real_Part *rp, Edje_External_Param *param)
440{
441 Evas_Object *swallowed_object = rp->swallowed_object;
442 Edje_External_Type *type = evas_object_data_get(swallowed_object, "Edje_External_Type");
443 if (!type)
444 {
445 if ((rp->part->type == EDJE_PART_TYPE_TEXT) ||
446 (rp->part->type == EDJE_PART_TYPE_TEXTBLOCK))
447 {
448 const char *text;
449 param->type = EDJE_EXTERNAL_PARAM_TYPE_STRING;
450 param->name = "text";
451 text = edje_object_part_text_get(obj, rp->part->name);
452 param->s = text;
453 return EINA_TRUE;
454 }
455
456 ERR("no external type for object %p", swallowed_object);
457 return EINA_FALSE;
458 }
459 if (!type->param_get)
460 {
461 ERR("external type '%s' from module '%s' does not provide param_get()",
462 type->module_name, type->module);
463 return EINA_FALSE;
464 }
465 return type->param_get(type->data, swallowed_object, param);
466}
467
468Evas_Object*
469_edje_external_content_get(const Evas_Object *obj, const char *content)
470{
471 Edje_External_Type *type = evas_object_data_get(obj, "Edje_External_Type");
472 if (!type)
473 {
474 ERR("no external type for object %p", obj);
475 return EINA_FALSE;
476 }
477 if (!type->content_get)
478 {
479 ERR("external type '%s' from module '%s' does not provide content_get()",
480 type->module_name, type->module);
481 return EINA_FALSE;
482 }
483 return type->content_get(type->data, obj, content);
484}
485
486void
487_edje_external_params_free(Eina_List *external_params, Eina_Bool free_strings)
488{
489 Edje_External_Param *param;
490
491 EINA_LIST_FREE(external_params, param)
492 {
493 if (free_strings)
494 {
495 if (param->name) eina_stringshare_del(param->name);
496 if (param->s) eina_stringshare_del(param->s);
497 }
498 free(param);
499 }
500}
501
502void
503_edje_external_recalc_apply(Edje *ed __UNUSED__, Edje_Real_Part *ep,
504 Edje_Calc_Params *params __UNUSED__,
505 Edje_Part_Description_Common *chosen_desc __UNUSED__)
506{
507 Edje_External_Type *type;
508 Edje_Part_Description_External *ext;
509 void *params1, *params2 = NULL;
510
511 if (!ep->swallowed_object) return;
512 type = evas_object_data_get(ep->swallowed_object, "Edje_External_Type");
513
514 if ((!type) || (!type->state_set)) return;
515
516 ext = (Edje_Part_Description_External*) ep->param1.description;
517
518 params1 = ep->param1.external_params ?
519 ep->param1.external_params : ext->external_params;
520
521 if (ep->param2 && ep->param2->description)
522 {
523 ext = (Edje_Part_Description_External*) ep->param2->description;
524
525 params2 = ep->param2->external_params ?
526 ep->param2->external_params : ext->external_params;
527 }
528
529 type->state_set(type->data, ep->swallowed_object,
530 params1, params2, ep->description_pos);
531}
532
533void *
534_edje_external_params_parse(Evas_Object *obj, const Eina_List *params)
535{
536 Edje_External_Type *type;
537
538 type = evas_object_data_get(obj, "Edje_External_Type");
539 if (!type) return NULL;
540
541 if (!type->params_parse) return NULL;
542
543 return type->params_parse(type->data, obj, params);
544}
545
546void
547_edje_external_parsed_params_free(Evas_Object *obj, void *params)
548{
549 Edje_External_Type *type;
550
551 if (!params) return;
552
553 type = evas_object_data_get(obj, "Edje_External_Type");
554 if (!type) return;
555
556 if (!type->params_free) return;
557
558 type->params_free(params);
559}
diff --git a/libraries/edje/src/lib/edje_load.c b/libraries/edje/src/lib/edje_load.c
new file mode 100644
index 0000000..644bb7c
--- /dev/null
+++ b/libraries/edje/src/lib/edje_load.c
@@ -0,0 +1,1525 @@
1#include "edje_private.h"
2
3#ifdef EDJE_PROGRAM_CACHE
4static Eina_Bool _edje_collection_free_prog_cache_matches_free_cb(const Eina_Hash *hash, const void *key, void *data, void *fdata);
5#endif
6static void _edje_object_pack_item_hints_set(Evas_Object *obj, Edje_Pack_Element *it);
7static void _cb_signal_repeat(void *data, Evas_Object *obj, const char *signal, const char *source);
8
9static Eina_List *_edje_swallows_collect(Edje *ed);
10
11/************************** API Routines **************************/
12
13EAPI Eina_Bool
14edje_object_file_set(Evas_Object *obj, const char *file, const char *group)
15{
16 Eina_Bool ret;
17 Edje *ed;
18
19 ed = _edje_fetch(obj);
20 if (!ed)
21 return EINA_FALSE;
22 ret = ed->api->file_set(obj, file, group);
23 _edje_object_orientation_inform(obj);
24 return ret;
25}
26
27EAPI void
28edje_object_file_get(const Evas_Object *obj, const char **file, const char **group)
29{
30 Edje *ed;
31
32 ed = _edje_fetch(obj);
33 if (!ed)
34 {
35 if (file) *file = NULL;
36 if (group) *group = NULL;
37 return;
38 }
39 if (file) *file = ed->path;
40 if (group) *group = ed->group;
41}
42
43EAPI Edje_Load_Error
44edje_object_load_error_get(const Evas_Object *obj)
45{
46 Edje *ed;
47
48 ed = _edje_fetch(obj);
49 if (!ed) return EDJE_LOAD_ERROR_NONE;
50 return ed->load_error;
51}
52
53EAPI const char *
54edje_load_error_str(Edje_Load_Error error)
55{
56 switch (error)
57 {
58 case EDJE_LOAD_ERROR_NONE:
59 return "No Error";
60 case EDJE_LOAD_ERROR_GENERIC:
61 return "Generic Error";
62 case EDJE_LOAD_ERROR_DOES_NOT_EXIST:
63 return "File Does Not Exist";
64 case EDJE_LOAD_ERROR_PERMISSION_DENIED:
65 return "Permission Denied";
66 case EDJE_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED:
67 return "Resource Allocation Failed";
68 case EDJE_LOAD_ERROR_CORRUPT_FILE:
69 return "Corrupt File";
70 case EDJE_LOAD_ERROR_UNKNOWN_FORMAT:
71 return "Unknown Format";
72 case EDJE_LOAD_ERROR_INCOMPATIBLE_FILE:
73 return "Incompatible File";
74 case EDJE_LOAD_ERROR_UNKNOWN_COLLECTION:
75 return "Unknown Collection";
76 case EDJE_LOAD_ERROR_RECURSIVE_REFERENCE:
77 return "Recursive Reference";
78 default:
79 return "Unknown Error";
80 }
81}
82
83
84EAPI Eina_List *
85edje_file_collection_list(const char *file)
86{
87 Eina_List *lst = NULL;
88 Edje_File *edf;
89 int error_ret = 0;
90
91 if ((!file) || (!*file)) return NULL;
92 edf = _edje_cache_file_coll_open(file, NULL, &error_ret, NULL);
93 if (edf)
94 {
95 Eina_Iterator *i;
96 const char *key;
97
98 i = eina_hash_iterator_key_new(edf->collection);
99
100 EINA_ITERATOR_FOREACH(i, key)
101 lst = eina_list_append(lst, eina_stringshare_add(key));
102
103 eina_iterator_free(i);
104
105 _edje_cache_file_unref(edf);
106 }
107 return lst;
108}
109
110EAPI void
111edje_file_collection_list_free(Eina_List *lst)
112{
113 while (lst)
114 {
115 if (eina_list_data_get(lst)) eina_stringshare_del(eina_list_data_get(lst));
116 lst = eina_list_remove(lst, eina_list_data_get(lst));
117 }
118}
119
120EAPI Eina_Bool
121edje_file_group_exists(const char *file, const char *glob)
122{
123 Edje_File *edf;
124 int error_ret = 0;
125 Eina_Bool succeed = EINA_FALSE;
126 Eina_Bool is_glob = EINA_FALSE;
127 const char *p;
128
129 if ((!file) || (!*file))
130 return EINA_FALSE;
131
132 edf = _edje_cache_file_coll_open(file, NULL, &error_ret, NULL);
133 if (!edf)
134 return EINA_FALSE;
135
136 for (p = glob; *p; p++)
137 {
138 if ((*p == '*') || (*p == '?') || (*p == '['))
139 {
140 is_glob = EINA_TRUE;
141 break;
142 }
143 }
144
145 if (is_glob)
146 {
147 if (!edf->collection_patterns)
148 {
149 Edje_Part_Collection_Directory_Entry *ce;
150 Eina_Iterator *i;
151 Eina_List *l = NULL;
152
153 i = eina_hash_iterator_data_new(edf->collection);
154
155 EINA_ITERATOR_FOREACH(i, ce)
156 l = eina_list_append(l, ce);
157
158 eina_iterator_free(i);
159
160 edf->collection_patterns = edje_match_collection_dir_init(l);
161 eina_list_free(l);
162 }
163
164 succeed = edje_match_collection_dir_exec(edf->collection_patterns, glob);
165 if (edf->collection_patterns)
166 {
167 edje_match_patterns_free(edf->collection_patterns);
168 edf->collection_patterns = NULL;
169 }
170 }
171 else
172 {
173 if (eina_hash_find(edf->collection, glob)) succeed = EINA_TRUE;
174 }
175 _edje_cache_file_unref(edf);
176
177 INF("edje_file_group_exists: '%s', '%s': %i\n", file, glob, succeed);
178
179 return succeed;
180}
181
182
183EAPI char *
184edje_file_data_get(const char *file, const char *key)
185{
186 Edje_File *edf;
187 char *str = NULL;
188 int error_ret = 0;
189
190 if (key)
191 {
192 edf = _edje_cache_file_coll_open(file, NULL, &error_ret, NULL);
193 if (edf)
194 {
195 str = (char*) edje_string_get(eina_hash_find(edf->data, key));
196
197 if (str) str = strdup(str);
198
199 _edje_cache_file_unref(edf);
200 }
201 }
202 return str;
203}
204
205void
206_edje_programs_patterns_clean(Edje *ed)
207{
208 _edje_signals_sources_patterns_clean(&ed->patterns.programs);
209
210 eina_rbtree_delete(ed->patterns.programs.exact_match,
211 EINA_RBTREE_FREE_CB(edje_match_signal_source_free),
212 NULL);
213 ed->patterns.programs.exact_match = NULL;
214
215 free(ed->patterns.programs.u.programs.globing);
216 ed->patterns.programs.u.programs.globing = NULL;
217}
218
219void
220_edje_programs_patterns_init(Edje *ed)
221{
222 Edje_Signals_Sources_Patterns *ssp = &ed->patterns.programs;
223 Edje_Program **all;
224 unsigned int i, j;
225
226 if (ssp->signals_patterns)
227 return;
228
229 edje_match_program_hash_build(ed->collection->programs.strcmp,
230 ed->collection->programs.strcmp_count,
231 &ssp->exact_match);
232
233 j = ed->collection->programs.strncmp_count
234 + ed->collection->programs.strrncmp_count
235 + ed->collection->programs.fnmatch_count
236 + ed->collection->programs.nocmp_count;
237 if (j == 0) return ;
238
239 all = malloc(sizeof (Edje_Program *) * j);
240 if (!all) return ;
241 j = 0;
242
243 /* FIXME: Build specialized data type for each case */
244#define EDJE_LOAD_PROGRAMS_ADD(Array, Ed, It, Git, All) \
245 for (It = 0; It < Ed->collection->programs.Array##_count; ++It, ++Git) \
246 All[Git] = Ed->collection->programs.Array[It];
247
248 EDJE_LOAD_PROGRAMS_ADD(fnmatch, ed, i, j, all);
249 EDJE_LOAD_PROGRAMS_ADD(strncmp, ed, i, j, all);
250 EDJE_LOAD_PROGRAMS_ADD(strrncmp, ed, i, j, all);
251 /* FIXME: Do a special pass for that one */
252 EDJE_LOAD_PROGRAMS_ADD(nocmp, ed, i, j, all);
253
254 ssp->u.programs.globing = all;
255 ssp->u.programs.count = j;
256 ssp->signals_patterns = edje_match_programs_signal_init(all, j);
257 ssp->sources_patterns = edje_match_programs_source_init(all, j);
258}
259
260int
261_edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *group, const char *parent, Eina_List *group_path)
262{
263 Edje *ed;
264 Evas *tev;
265 Eina_List *old_swallows;
266 unsigned int n;
267 Eina_List *parts = NULL;
268 int group_path_started = 0;
269
270 ed = _edje_fetch(obj);
271 if (!ed) return 0;
272 if (!file) file = "";
273 if (!group) group = "";
274 if (((ed->path) && (!strcmp(file, ed->path))) &&
275 (ed->group) && (!strcmp(group, ed->group)))
276 return 1;
277
278 tev = evas_object_evas_get(obj);
279 evas_event_freeze(tev);
280 old_swallows = _edje_swallows_collect(ed);
281
282 if (_edje_script_only(ed)) _edje_script_only_shutdown(ed);
283 if (_edje_lua_script_only(ed)) _edje_lua_script_only_shutdown(ed);
284 _edje_file_del(ed);
285
286 eina_stringshare_replace(&ed->path, file);
287 eina_stringshare_replace(&ed->group, group);
288
289 ed->parent = eina_stringshare_add(parent);
290
291 ed->load_error = EDJE_LOAD_ERROR_NONE;
292 _edje_file_add(ed);
293
294 if (ed->file && ed->file->external_dir)
295 {
296 unsigned int i;
297
298 for (i = 0; i < ed->file->external_dir->entries_count; ++i)
299 edje_module_load(ed->file->external_dir->entries[i].entry);
300 }
301
302 _edje_textblock_styles_add(ed);
303 _edje_textblock_style_all_update(ed);
304
305 ed->has_entries = EINA_FALSE;
306
307 if (ed->collection)
308 {
309 if (ed->collection->prop.orientation != EDJE_ORIENTATION_AUTO)
310 ed->is_rtl = (ed->collection->prop.orientation ==
311 EDJE_ORIENTATION_RTL);
312
313 if (ed->collection->script_only)
314 {
315 ed->load_error = EDJE_LOAD_ERROR_NONE;
316 _edje_script_only_init(ed);
317 }
318 else if (ed->collection->lua_script_only)
319 {
320 ed->load_error = EDJE_LOAD_ERROR_NONE;
321 _edje_lua_script_only_init(ed);
322 }
323 else
324 {
325 unsigned int i;
326 int errors = 0;
327
328 /* colorclass stuff */
329 for (i = 0; i < ed->collection->parts_count; ++i)
330 {
331 Edje_Part *ep;
332 unsigned int k;
333
334 ep = ed->collection->parts[i];
335
336 if (errors)
337 break;
338 /* Register any color classes in this parts descriptions. */
339 if ((ep->default_desc) && (ep->default_desc->color_class))
340 _edje_color_class_member_add(ed, ep->default_desc->color_class);
341
342 for (k = 0; k < ep->other.desc_count; k++)
343 {
344 Edje_Part_Description_Common *desc;
345
346 desc = ep->other.desc[k];
347
348 if (desc->color_class)
349 _edje_color_class_member_add(ed, desc->color_class);
350 }
351 }
352 /* build real parts */
353 for (n = 0; n < ed->collection->parts_count; n++)
354 {
355 Edje_Part *ep;
356 Edje_Real_Part *rp;
357
358 ep = ed->collection->parts[n];
359 rp = eina_mempool_malloc(_edje_real_part_mp, sizeof(Edje_Real_Part));
360 if (!rp)
361 {
362 ed->load_error = EDJE_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
363 evas_event_thaw(tev);
364 evas_event_thaw_eval(tev);
365 return 0;
366 }
367
368 memset(rp, 0, sizeof (Edje_Real_Part));
369
370 if ((ep->dragable.x != 0) || (ep->dragable.y != 0))
371 {
372 rp->drag = calloc(1, sizeof (Edje_Real_Part_Drag));
373 if (!rp->drag)
374 {
375 ed->load_error = EDJE_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
376 free(rp);
377 evas_event_thaw(tev);
378 evas_event_thaw_eval(tev);
379 return 0;
380 }
381
382 rp->drag->step.x = FROM_INT(ep->dragable.step_x);
383 rp->drag->step.y = FROM_INT(ep->dragable.step_y);
384 }
385
386 rp->edje = ed;
387 _edje_ref(rp->edje);
388 rp->part = ep;
389 parts = eina_list_append(parts, rp);
390 rp->param1.description =
391 _edje_part_description_find(ed, rp, "default", 0.0);
392 rp->chosen_description = rp->param1.description;
393 if (!rp->param1.description)
394 ERR("no default part description!");
395
396 switch (ep->type)
397 {
398 case EDJE_PART_TYPE_RECTANGLE:
399 rp->object = evas_object_rectangle_add(ed->base.evas);
400 break;
401 case EDJE_PART_TYPE_PROXY:
402 case EDJE_PART_TYPE_IMAGE:
403 rp->object = evas_object_image_add(ed->base.evas);
404 break;
405 case EDJE_PART_TYPE_TEXT:
406 _edje_text_part_on_add(ed, rp);
407 rp->object = evas_object_text_add(ed->base.evas);
408 evas_object_text_font_source_set(rp->object, ed->path);
409 break;
410 case EDJE_PART_TYPE_SWALLOW:
411 case EDJE_PART_TYPE_GROUP:
412 case EDJE_PART_TYPE_EXTERNAL:
413 rp->object = evas_object_rectangle_add(ed->base.evas);
414 evas_object_color_set(rp->object, 0, 0, 0, 0);
415 evas_object_pass_events_set(rp->object, 1);
416 evas_object_pointer_mode_set(rp->object, EVAS_OBJECT_POINTER_MODE_NOGRAB);
417 _edje_callbacks_focus_add(rp->object, ed, rp);
418 break;
419 case EDJE_PART_TYPE_TEXTBLOCK:
420 rp->object = evas_object_textblock_add(ed->base.evas);
421 break;
422 case EDJE_PART_TYPE_BOX:
423 rp->object = evas_object_box_add(ed->base.evas);
424 rp->anim = _edje_box_layout_anim_new(rp->object);
425 break;
426 case EDJE_PART_TYPE_TABLE:
427 rp->object = evas_object_table_add(ed->base.evas);
428 break;
429 case EDJE_PART_TYPE_GRADIENT:
430 ERR("SPANK ! SPANK ! SPANK ! YOU ARE USING GRADIENT IN PART %s FROM GROUP %s INSIDE FILE %s !! THEY ARE NOW REMOVED !",
431 ep->name, group, file);
432 default:
433 ERR("wrong part type %i!", ep->type);
434 break;
435 }
436
437 if (rp->object)
438 {
439 evas_object_smart_member_add(rp->object, ed->obj);
440// evas_object_layer_set(rp->object, evas_object_layer_get(ed->obj));
441 if (ep->type != EDJE_PART_TYPE_SWALLOW && ep->type != EDJE_PART_TYPE_GROUP && ep->type != EDJE_PART_TYPE_EXTERNAL)
442 {
443 if (ep->mouse_events)
444 {
445 _edje_callbacks_add(rp->object, ed, rp);
446 if (ep->repeat_events)
447 evas_object_repeat_events_set(rp->object, 1);
448
449 if (ep->pointer_mode != EVAS_OBJECT_POINTER_MODE_AUTOGRAB)
450 evas_object_pointer_mode_set(rp->object, ep->pointer_mode);
451 }
452 else
453 {
454 evas_object_pass_events_set(rp->object, 1);
455 evas_object_pointer_mode_set(rp->object, EVAS_OBJECT_POINTER_MODE_NOGRAB);
456 }
457 if (ep->precise_is_inside)
458 evas_object_precise_is_inside_set(rp->object, 1);
459 }
460 if (rp->part->clip_to_id < 0)
461 evas_object_clip_set(rp->object, ed->base.clipper);
462 }
463 }
464 if (n > 0)
465 {
466 Edje_Real_Part *rp;
467 Eina_List *l;
468
469 ed->table_parts = malloc(sizeof(Edje_Real_Part *) * n);
470 ed->table_parts_size = n;
471 /* FIXME: check malloc return */
472 n = 0;
473 EINA_LIST_FOREACH(parts, l, rp)
474 {
475 ed->table_parts[n] = rp;
476 n++;
477 }
478 eina_list_free(parts);
479 for (i = 0; i < ed->table_parts_size; i++)
480 {
481 rp = ed->table_parts[i];
482 if (rp->param1.description) /* FIXME: prevent rel to gone radient part to go wrong. You may
483 be able to remove this when all theme are correctly rewritten. */
484 {
485 if (rp->param1.description->rel1.id_x >= 0)
486 rp->param1.rel1_to_x = ed->table_parts[rp->param1.description->rel1.id_x % ed->table_parts_size];
487 if (rp->param1.description->rel1.id_y >= 0)
488 rp->param1.rel1_to_y = ed->table_parts[rp->param1.description->rel1.id_y % ed->table_parts_size];
489 if (rp->param1.description->rel2.id_x >= 0)
490 rp->param1.rel2_to_x = ed->table_parts[rp->param1.description->rel2.id_x % ed->table_parts_size];
491 if (rp->param1.description->rel2.id_y >= 0)
492 rp->param1.rel2_to_y = ed->table_parts[rp->param1.description->rel2.id_y % ed->table_parts_size];
493 }
494 if (rp->part->clip_to_id >= 0)
495 {
496 rp->clip_to = ed->table_parts[rp->part->clip_to_id % ed->table_parts_size];
497 if (rp->clip_to)
498 {
499 evas_object_pass_events_set(rp->clip_to->object, 1);
500 evas_object_pointer_mode_set(rp->clip_to->object, EVAS_OBJECT_POINTER_MODE_NOGRAB);
501 evas_object_clip_set(rp->object, rp->clip_to->object);
502 }
503 }
504 if (rp->drag)
505 {
506 if (rp->part->dragable.confine_id >= 0)
507 rp->drag->confine_to = ed->table_parts[rp->part->dragable.confine_id % ed->table_parts_size];
508 }
509
510 /* replay events for dragable */
511 if (rp->part->dragable.event_id >= 0)
512 {
513 rp->events_to =
514 ed->table_parts[rp->part->dragable.event_id % ed->table_parts_size];
515 /* events_to may be used only with dragable */
516 if (!rp->events_to->part->dragable.x &&
517 !rp->events_to->part->dragable.y)
518 rp->events_to = NULL;
519 }
520
521 rp->swallow_params.min.w = 0;
522 rp->swallow_params.min.w = 0;
523 rp->swallow_params.max.w = -1;
524 rp->swallow_params.max.h = -1;
525
526 if (rp->part->type == EDJE_PART_TYPE_TEXT
527 || rp->part->type == EDJE_PART_TYPE_TEXTBLOCK)
528 {
529 Edje_Part_Description_Text *text;
530
531 text = (Edje_Part_Description_Text *) rp->param1.description;
532
533 if (ed->file->feature_ver < 1)
534 {
535 text->text.id_source = -1;
536 text->text.id_text_source = -1;
537 }
538
539 if (text->text.id_source >= 0)
540 rp->text.source = ed->table_parts[text->text.id_source % ed->table_parts_size];
541 if (text->text.id_text_source >= 0)
542 rp->text.text_source = ed->table_parts[text->text.id_text_source % ed->table_parts_size];
543 if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
544 {
545 _edje_entry_real_part_init(rp);
546 if (!ed->has_entries)
547 ed->has_entries = EINA_TRUE;
548 }
549 }
550 }
551 }
552
553 _edje_programs_patterns_init(ed);
554
555 n = ed->collection->programs.fnmatch_count +
556 ed->collection->programs.strcmp_count +
557 ed->collection->programs.strncmp_count +
558 ed->collection->programs.strrncmp_count +
559 ed->collection->programs.nocmp_count;
560 if (n > 0)
561 {
562 Edje_Program *pr;
563
564 ed->table_programs = malloc(sizeof(Edje_Program *) * n);
565 if (ed->table_programs)
566 {
567 ed->table_programs_size = n;
568
569#define EDJE_LOAD_BUILD_TABLE(Array, Ed, It, Tmp) \
570 for (It = 0; It < Ed->collection->programs.Array##_count; ++It) \
571 { \
572 Tmp = Ed->collection->programs.Array[It]; \
573 Ed->table_programs[Tmp->id] = Tmp; \
574 }
575
576 EDJE_LOAD_BUILD_TABLE(fnmatch, ed, i, pr);
577 EDJE_LOAD_BUILD_TABLE(strcmp, ed, i, pr);
578 EDJE_LOAD_BUILD_TABLE(strncmp, ed, i, pr);
579 EDJE_LOAD_BUILD_TABLE(strrncmp, ed, i, pr);
580 EDJE_LOAD_BUILD_TABLE(nocmp, ed, i, pr);
581 }
582 }
583 _edje_ref(ed);
584 _edje_block(ed);
585 _edje_freeze(ed);
586// if (ed->collection->script) _edje_embryo_script_init(ed);
587 _edje_var_init(ed);
588 for (i = 0; i < ed->table_parts_size; i++)
589 {
590 Edje_Real_Part *rp;
591
592 rp = ed->table_parts[i];
593 evas_object_show(rp->object);
594 if (_edje_block_break(ed)) break;
595 if (rp->drag)
596 {
597 if (rp->part->dragable.x < 0) rp->drag->val.x = FROM_DOUBLE(1.0);
598 if (rp->part->dragable.y < 0) rp->drag->val.x = FROM_DOUBLE(1.0);
599 _edje_dragable_pos_set(ed, rp, rp->drag->val.x, rp->drag->val.y);
600 }
601 }
602 ed->dirty = 1;
603#ifdef EDJE_CALC_CACHE
604 ed->all_part_change = 1;
605#endif
606 if ((evas_object_clipees_get(ed->base.clipper)) &&
607 (evas_object_visible_get(obj)))
608 evas_object_show(ed->base.clipper);
609
610 /* instantiate 'internal swallows' */
611 for (i = 0; i < ed->table_parts_size; i++)
612 {
613 Edje_Real_Part *rp;
614 /* XXX: curr_item and pack_it don't require to be NULL since
615 * XXX: they are just used when source != NULL and type == BOX,
616 * XXX: and they're always set in this case, but GCC fails to
617 * XXX: notice that, so let's shut it up
618 */
619 Edje_Pack_Element **curr_item = NULL;
620 unsigned int item_count = 0;
621 Edje_Pack_Element *pack_it = NULL;
622 const char *source = NULL;
623
624 rp = ed->table_parts[i];
625
626 switch (rp->part->type)
627 {
628 case EDJE_PART_TYPE_GROUP:
629 source = rp->part->source;
630 break;
631 case EDJE_PART_TYPE_BOX:
632 case EDJE_PART_TYPE_TABLE:
633 if (rp->part->items)
634 {
635 curr_item = rp->part->items;
636 item_count = rp->part->items_count;
637 if (item_count > 0)
638 {
639 pack_it = *curr_item;
640 source = pack_it->source;
641 item_count--;
642 curr_item++;
643 }
644 }
645 break;
646 case EDJE_PART_TYPE_EXTERNAL:
647 {
648 Edje_Part_Description_External *external;
649 Evas_Object *child_obj;
650
651 external = (Edje_Part_Description_External *) rp->part->default_desc;
652 child_obj = _edje_external_type_add(rp->part->source,
653 evas_object_evas_get(ed->obj), ed->obj,
654 external->external_params, rp->part->name);
655 if (child_obj)
656 {
657 _edje_real_part_swallow(rp, child_obj, EINA_TRUE);
658 rp->param1.external_params = _edje_external_params_parse(child_obj,
659 external->external_params);
660 _edje_external_recalc_apply(ed, rp, NULL, rp->chosen_description);
661 }
662 }
663 continue;
664 default:
665 continue;
666 }
667
668 while (source)
669 {
670 Eina_List *l;
671 Evas_Object *child_obj;
672 const char *group_path_entry = eina_stringshare_add(source);
673 const char *data;
674
675 if (!group_path)
676 {
677 group_path = eina_list_append(NULL, eina_stringshare_add(group));
678 group_path_started = 1;
679 }
680 /* make sure that this group isn't already in the tree of parents */
681 EINA_LIST_FOREACH(group_path, l, data)
682 {
683 if (data == group_path_entry)
684 {
685 _edje_thaw(ed);
686 _edje_unblock(ed);
687 _edje_unref(ed);
688 _edje_file_del(ed);
689 eina_stringshare_del(group_path_entry);
690 if (group_path_started)
691 {
692 eina_stringshare_del(eina_list_data_get(group_path));
693 eina_list_free(group_path);
694 }
695 ed->load_error = EDJE_LOAD_ERROR_RECURSIVE_REFERENCE;
696 evas_event_thaw(tev);
697 evas_event_thaw_eval(tev);
698 return 0;
699 }
700 }
701
702 child_obj = edje_object_add(ed->base.evas);
703 group_path = eina_list_append(group_path, group_path_entry);
704 if (rp->part->type == EDJE_PART_TYPE_GROUP)
705 {
706 _edje_real_part_swallow(rp, child_obj, EINA_FALSE);
707 }
708
709 if (!_edje_object_file_set_internal(child_obj, file, source, rp->part->name, group_path))
710 {
711 _edje_thaw(ed);
712 _edje_unblock(ed);
713 _edje_unref(ed);
714 _edje_file_del(ed);
715
716 if (group_path_started)
717 {
718 while (group_path)
719 {
720 eina_stringshare_del(eina_list_data_get(group_path));
721 group_path = eina_list_remove_list(group_path, group_path);
722 }
723 }
724 ed->load_error = edje_object_load_error_get(child_obj);
725 evas_object_del(child_obj);
726 evas_event_thaw(tev);
727 evas_event_thaw_eval(tev);
728 return 0;
729 }
730
731 group_path = eina_list_remove(group_path, group_path_entry);
732 eina_stringshare_del(group_path_entry);
733
734 edje_object_propagate_callback_add(child_obj,
735 _cb_signal_repeat,
736 obj);
737 if (rp->part->type == EDJE_PART_TYPE_GROUP)
738 {
739 _edje_real_part_swallow(rp, child_obj, EINA_TRUE);
740 _edje_subobj_register(ed, child_obj);
741 source = NULL;
742 }
743 else
744 {
745 pack_it->parent = rp;
746
747 _edje_object_pack_item_hints_set(child_obj, pack_it);
748 if (pack_it->name)
749 evas_object_name_set(child_obj, pack_it->name);
750
751 if (rp->part->type == EDJE_PART_TYPE_BOX)
752 {
753 _edje_real_part_box_append(rp, child_obj);
754 evas_object_data_set(child_obj, "\377 edje.box_item", pack_it);
755 }
756 else if (rp->part->type == EDJE_PART_TYPE_TABLE)
757 {
758 _edje_real_part_table_pack(rp, child_obj, pack_it->col, pack_it->row, pack_it->colspan, pack_it->rowspan);
759 evas_object_data_set(child_obj, "\377 edje.table_item", pack_it);
760 }
761 _edje_subobj_register(ed, child_obj);
762 evas_object_show(child_obj);
763 rp->items = eina_list_append(rp->items, child_obj);
764
765 if (item_count > 0)
766 {
767 pack_it = *curr_item;
768 source = pack_it->source;
769 curr_item++;
770 item_count--;
771 }
772 else
773 {
774 source = NULL;
775 curr_item = NULL;
776 pack_it = NULL;
777 }
778 }
779 }
780 }
781
782 if (group_path_started)
783 {
784 const char *str;
785
786 EINA_LIST_FREE(group_path, str)
787 eina_stringshare_del(str);
788 }
789
790 /* reswallow any swallows that existed before setting the file */
791 if (old_swallows)
792 {
793 while (old_swallows)
794 {
795 const char *name;
796 Evas_Object *swallow;
797
798 name = eina_list_data_get(old_swallows);
799 old_swallows = eina_list_remove_list(old_swallows, old_swallows);
800
801 swallow = eina_list_data_get(old_swallows);
802 old_swallows = eina_list_remove_list(old_swallows, old_swallows);
803
804 edje_object_part_swallow(obj, name, swallow);
805 eina_stringshare_del(name);
806 }
807 }
808
809 _edje_recalc(ed);
810 _edje_thaw(ed);
811 _edje_unblock(ed);
812 _edje_unref(ed);
813 ed->load_error = EDJE_LOAD_ERROR_NONE;
814 _edje_emit(ed, "load", NULL);
815 /* instantiate 'internal swallows' */
816 for (i = 0; i < ed->table_parts_size; i++)
817 {
818 Edje_Real_Part *rp;
819
820 rp = ed->table_parts[i];
821 if ((rp->part->type == EDJE_PART_TYPE_TEXTBLOCK) &&
822 (rp->part->default_desc))
823 {
824 Edje_Part_Description_Text *text;
825 Edje_Style *stl = NULL;
826 const char *style;
827
828 text = (Edje_Part_Description_Text *) rp->part->default_desc;
829 style = edje_string_get(&text->text.style);
830 if (style)
831 {
832 Eina_List *l;
833
834 EINA_LIST_FOREACH(ed->file->styles, l, stl)
835 {
836 if ((stl->name) && (!strcmp(stl->name, style))) break;
837 stl = NULL;
838 }
839 }
840 if (stl)
841 {
842 if (evas_object_textblock_style_get(rp->object) != stl->style)
843 evas_object_textblock_style_set(rp->object, stl->style);
844 }
845 }
846 }
847 }
848 _edje_entry_init(ed);
849 evas_event_thaw(tev);
850 evas_event_thaw_eval(tev);
851 return 1;
852 }
853 else
854 {
855 evas_event_thaw(tev);
856 evas_event_thaw_eval(tev);
857 return 0;
858 }
859 ed->load_error = EDJE_LOAD_ERROR_NONE;
860 _edje_entry_init(ed);
861 evas_event_thaw(tev);
862 evas_event_thaw_eval(tev);
863 return 1;
864}
865
866void
867_edje_file_add(Edje *ed)
868{
869 if (!_edje_edd_edje_file) return;
870 ed->file = _edje_cache_file_coll_open(ed->path, ed->group,
871 &(ed->load_error),
872 &(ed->collection));
873
874 if (!ed->collection)
875 {
876 if (ed->file)
877 {
878 _edje_cache_file_unref(ed->file);
879 ed->file = NULL;
880 }
881 }
882}
883
884static Eina_List *
885_edje_swallows_collect(Edje *ed)
886{
887 Eina_List *swallows = NULL;
888 unsigned int i;
889
890 if (!ed->file || !ed->table_parts) return NULL;
891 for (i = 0; i < ed->table_parts_size; i++)
892 {
893 Edje_Real_Part *rp;
894
895 rp = ed->table_parts[i];
896 if (rp->part->type != EDJE_PART_TYPE_SWALLOW || !rp->swallowed_object) continue;
897 swallows = eina_list_append(swallows, eina_stringshare_add(rp->part->name));
898 swallows = eina_list_append(swallows, rp->swallowed_object);
899 }
900 return swallows;
901}
902
903void
904_edje_file_del(Edje *ed)
905{
906 Evas *tev = evas_object_evas_get(ed->obj);
907
908 evas_event_freeze(tev);
909 if (ed->freeze_calc)
910 {
911 _edje_freeze_calc_list = eina_list_remove(_edje_freeze_calc_list, ed);
912 ed->freeze_calc = 0;
913 _edje_freeze_calc_count--;
914 }
915 _edje_entry_shutdown(ed);
916 _edje_message_del(ed);
917 _edje_block_violate(ed);
918 _edje_var_shutdown(ed);
919 _edje_programs_patterns_clean(ed);
920// if (ed->collection)
921// {
922// if (ed->collection->script) _edje_embryo_script_shutdown(ed);
923// }
924
925 if (!((ed->file) && (ed->collection)))
926 {
927 evas_event_thaw(tev);
928 evas_event_thaw_eval(tev);
929 return;
930 }
931 if (ed->table_parts)
932 {
933 unsigned int i;
934 for (i = 0; i < ed->table_parts_size; i++)
935 {
936 Edje_Real_Part *rp;
937
938 rp = ed->table_parts[i];
939 if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
940 _edje_entry_real_part_shutdown(rp);
941 if (rp->object)
942 {
943 _edje_callbacks_del(rp->object, ed);
944 _edje_callbacks_focus_del(rp->object, ed);
945 evas_object_del(rp->object);
946 }
947 if (rp->swallowed_object)
948 {
949 _edje_real_part_swallow_clear(rp);
950 /* Objects swallowed by the app do not get deleted,
951 but those internally swallowed (GROUP type) do. */
952 switch (rp->part->type)
953 {
954 case EDJE_PART_TYPE_EXTERNAL:
955 _edje_external_parsed_params_free(rp->swallowed_object, rp->param1.external_params);
956 if (rp->param2)
957 _edje_external_parsed_params_free(rp->swallowed_object, rp->param2->external_params);
958 case EDJE_PART_TYPE_GROUP:
959 evas_object_del(rp->swallowed_object);
960 default:
961 break;
962 }
963 rp->swallowed_object = NULL;
964 }
965 if (rp->items)
966 {
967 /* evas_box/table handles deletion of objects */
968 rp->items = eina_list_free(rp->items);
969 }
970 if (rp->anim)
971 {
972 _edje_box_layout_free_data(rp->anim);
973 rp->anim = NULL;
974 }
975 if (rp->text.text) eina_stringshare_del(rp->text.text);
976 if (rp->text.font) eina_stringshare_del(rp->text.font);
977 if (rp->text.cache.in_str) eina_stringshare_del(rp->text.cache.in_str);
978 if (rp->text.cache.out_str) eina_stringshare_del(rp->text.cache.out_str);
979
980 if (rp->custom)
981 {
982 // xxx: lua2
983 _edje_collection_free_part_description_clean(rp->part->type,
984 rp->custom->description,
985 ed->file->free_strings);
986 free(rp->custom->description);
987 rp->custom->description = NULL;
988 }
989
990 /* Cleanup optional part. */
991 free(rp->drag);
992 free(rp->param1.set);
993
994 if (rp->param2)
995 free(rp->param2->set);
996 eina_mempool_free(_edje_real_part_state_mp, rp->param2);
997
998 if (rp->custom)
999 free(rp->custom->set);
1000 eina_mempool_free(_edje_real_part_state_mp, rp->custom);
1001
1002 _edje_unref(rp->edje);
1003 eina_mempool_free(_edje_real_part_mp, rp);
1004 }
1005 }
1006 if ((ed->file) && (ed->collection))
1007 {
1008 Edje_Part *ep;
1009 unsigned int i;
1010
1011 _edje_textblock_styles_del(ed);
1012 for (i = 0; i < ed->collection->parts_count; ++i)
1013 {
1014 ep = ed->collection->parts[i];
1015
1016 _edje_text_part_on_del(ed, ep);
1017 _edje_color_class_on_del(ed, ep);
1018 }
1019
1020 _edje_cache_coll_unref(ed->file, ed->collection);
1021 ed->collection = NULL;
1022 }
1023 if (ed->file)
1024 {
1025 _edje_cache_file_unref(ed->file);
1026 ed->file = NULL;
1027 }
1028 if (ed->actions)
1029 {
1030 Edje_Running_Program *runp;
1031
1032 EINA_LIST_FREE(ed->actions, runp)
1033 {
1034 _edje_anim_count--;
1035 free(runp);
1036 }
1037 }
1038 _edje_animators = eina_list_remove(_edje_animators, ed);
1039 if (ed->pending_actions)
1040 {
1041 Edje_Pending_Program *pp;
1042
1043 EINA_LIST_FREE(ed->pending_actions, pp)
1044 {
1045 ecore_timer_del(pp->timer);
1046 free(pp);
1047 }
1048 }
1049 if (ed->L) _edje_lua2_script_shutdown(ed);
1050 while (ed->subobjs) evas_object_del(ed->subobjs->data);
1051 if (ed->table_parts) free(ed->table_parts);
1052 ed->table_parts = NULL;
1053 ed->table_parts_size = 0;
1054 if (ed->table_programs) free(ed->table_programs);
1055 ed->table_programs = NULL;
1056 ed->table_programs_size = 0;
1057 ed->focused_part = NULL;
1058 evas_event_thaw(tev);
1059 evas_event_thaw_eval(tev);
1060}
1061
1062void
1063_edje_file_free(Edje_File *edf)
1064{
1065 Edje_Color_Class *ecc;
1066
1067#define HASH_FREE(Hash) \
1068 if (Hash) eina_hash_free(Hash); \
1069 Hash = NULL;
1070
1071 /* Clean cache before cleaning memory pool */
1072 if (edf->collection_cache) _edje_cache_coll_flush(edf);
1073
1074 HASH_FREE(edf->fonts);
1075 HASH_FREE(edf->collection);
1076 HASH_FREE(edf->data);
1077
1078 if (edf->image_dir)
1079 {
1080 unsigned int i;
1081
1082 if (edf->free_strings)
1083 {
1084 for (i = 0; i < edf->image_dir->entries_count; ++i)
1085 eina_stringshare_del(edf->image_dir->entries[i].entry);
1086 }
1087
1088 /* Sets have been added after edje received eet dictionnary support */
1089 for (i = 0; i < edf->image_dir->sets_count; ++i)
1090 {
1091 Edje_Image_Directory_Set_Entry *se;
1092
1093 EINA_LIST_FREE(edf->image_dir->sets[i].entries, se)
1094 free(se);
1095
1096 }
1097
1098 free(edf->image_dir->entries);
1099 free(edf->image_dir->sets);
1100 free(edf->image_dir);
1101 }
1102 if (edf->sound_dir)
1103 {
1104 unsigned int i;
1105
1106 if (edf->free_strings)
1107 {
1108 for (i = 0; i < edf->sound_dir->samples_count; ++i)
1109 {
1110 eina_stringshare_del(edf->sound_dir->samples[i].name);
1111 eina_stringshare_del(edf->sound_dir->samples[i].snd_src);
1112 }
1113
1114 for (i = 0; i < edf->sound_dir->tones_count; ++i)
1115 eina_stringshare_del(edf->sound_dir->tones[i].name);
1116 }
1117 free(edf->sound_dir->samples);
1118 free(edf->sound_dir->tones);
1119 free(edf->sound_dir);
1120 }
1121
1122 if (edf->external_dir)
1123 {
1124 if (edf->external_dir->entries) free(edf->external_dir->entries);
1125 free(edf->external_dir);
1126 }
1127
1128 EINA_LIST_FREE(edf->color_classes, ecc)
1129 {
1130 if (edf->free_strings && ecc->name) eina_stringshare_del(ecc->name);
1131 free(ecc);
1132 }
1133
1134 if (edf->collection_patterns) edje_match_patterns_free(edf->collection_patterns);
1135 if (edf->path) eina_stringshare_del(edf->path);
1136 if (edf->free_strings && edf->compiler) eina_stringshare_del(edf->compiler);
1137 _edje_textblock_style_cleanup(edf);
1138 if (edf->ef) eet_close(edf->ef);
1139 free(edf);
1140}
1141
1142static void
1143_edje_program_free(Edje_Program *pr, Eina_Bool free_strings)
1144{
1145 Edje_Program_Target *prt;
1146 Edje_Program_After *pa;
1147
1148 if (free_strings)
1149 {
1150 if (pr->name) eina_stringshare_del(pr->name);
1151 if (pr->signal) eina_stringshare_del(pr->signal);
1152 if (pr->source) eina_stringshare_del(pr->source);
1153 if (pr->filter.part) eina_stringshare_del(pr->filter.part);
1154 if (pr->filter.state) eina_stringshare_del(pr->filter.state);
1155 if (pr->state) eina_stringshare_del(pr->state);
1156 if (pr->state2) eina_stringshare_del(pr->state2);
1157 if (pr->sample_name) eina_stringshare_del(pr->sample_name);
1158 if (pr->tone_name) eina_stringshare_del(pr->tone_name);
1159 }
1160 EINA_LIST_FREE(pr->targets, prt)
1161 free(prt);
1162 EINA_LIST_FREE(pr->after, pa)
1163 free(pa);
1164 free(pr);
1165}
1166
1167void
1168_edje_collection_free(Edje_File *edf, Edje_Part_Collection *ec, Edje_Part_Collection_Directory_Entry *ce)
1169{
1170 unsigned int i;
1171
1172 _edje_embryo_script_shutdown(ec);
1173
1174#define EDJE_LOAD_PROGRAM_FREE(Array, Ec, It, FreeStrings) \
1175 for (It = 0; It < Ec->programs.Array##_count; ++It) \
1176 _edje_program_free(Ec->programs.Array[It], FreeStrings); \
1177 free(Ec->programs.Array);
1178
1179 EDJE_LOAD_PROGRAM_FREE(fnmatch, ec, i, edf->free_strings);
1180 EDJE_LOAD_PROGRAM_FREE(strcmp, ec, i, edf->free_strings);
1181 EDJE_LOAD_PROGRAM_FREE(strncmp, ec, i, edf->free_strings);
1182 EDJE_LOAD_PROGRAM_FREE(strrncmp, ec, i, edf->free_strings);
1183 EDJE_LOAD_PROGRAM_FREE(nocmp, ec, i, edf->free_strings);
1184
1185 for (i = 0; i < ec->parts_count; ++i)
1186 {
1187 Edje_Part *ep;
1188 unsigned int j;
1189
1190 ep = ec->parts[i];
1191
1192 if (edf->free_strings && ep->name) eina_stringshare_del(ep->name);
1193 if (ep->default_desc)
1194 {
1195 _edje_collection_free_part_description_clean(ep->type, ep->default_desc, edf->free_strings);
1196 ep->default_desc = NULL;
1197 }
1198 for (j = 0; j < ep->other.desc_count; ++j)
1199 _edje_collection_free_part_description_clean(ep->type, ep->other.desc[j], edf->free_strings);
1200
1201 free(ep->other.desc);
1202 /* Alloc for RTL objects in edje_calc.c:_edje_part_description_find() */
1203 if(ep->other.desc_rtl)
1204 free(ep->other.desc_rtl);
1205
1206 free(ep->items);
1207// technically need this - but we ASSUME we use "one_big" so everything gets
1208// freed in one go lower down when we del the mempool... but what if pool goes
1209// "over"?
1210 eina_mempool_free(ce->mp.part, ep);
1211 }
1212 free(ec->parts);
1213 ec->parts = NULL;
1214
1215 if (ec->data)
1216 {
1217 Eina_Iterator *it;
1218 Edje_String *es;
1219
1220 it = eina_hash_iterator_data_new(ec->data);
1221 EINA_ITERATOR_FOREACH(it, es)
1222 free(es);
1223 eina_iterator_free(it);
1224
1225 eina_hash_free(ec->data);
1226 }
1227#ifdef EDJE_PROGRAM_CACHE
1228 if (ec->prog_cache.no_matches) eina_hash_free(ec->prog_cache.no_matches);
1229 if (ec->prog_cache.matches)
1230 {
1231 eina_hash_foreach(ec->prog_cache.matches,
1232 _edje_collection_free_prog_cache_matches_free_cb,
1233 NULL);
1234 eina_hash_free(ec->prog_cache.matches);
1235 }
1236#endif
1237 if (ec->script) embryo_program_free(ec->script);
1238 _edje_lua2_script_unload(ec);
1239
1240 /* Destroy all part and description. */
1241 eina_mempool_del(ce->mp.RECTANGLE);
1242 eina_mempool_del(ce->mp.TEXT);
1243 eina_mempool_del(ce->mp.IMAGE);
1244 eina_mempool_del(ce->mp.PROXY);
1245 eina_mempool_del(ce->mp.SWALLOW);
1246 eina_mempool_del(ce->mp.TEXTBLOCK);
1247 eina_mempool_del(ce->mp.GROUP);
1248 eina_mempool_del(ce->mp.BOX);
1249 eina_mempool_del(ce->mp.TABLE);
1250 eina_mempool_del(ce->mp.EXTERNAL);
1251 eina_mempool_del(ce->mp.part);
1252 memset(&ce->mp, 0, sizeof (ce->mp));
1253
1254 eina_mempool_del(ce->mp_rtl.RECTANGLE);
1255 eina_mempool_del(ce->mp_rtl.TEXT);
1256 eina_mempool_del(ce->mp_rtl.IMAGE);
1257 eina_mempool_del(ce->mp_rtl.PROXY);
1258 eina_mempool_del(ce->mp_rtl.SWALLOW);
1259 eina_mempool_del(ce->mp_rtl.TEXTBLOCK);
1260 eina_mempool_del(ce->mp_rtl.GROUP);
1261 eina_mempool_del(ce->mp_rtl.BOX);
1262 eina_mempool_del(ce->mp_rtl.TABLE);
1263 eina_mempool_del(ce->mp_rtl.EXTERNAL);
1264 memset(&ce->mp_rtl, 0, sizeof (ce->mp_rtl));
1265 free(ec);
1266 ce->ref = NULL;
1267}
1268
1269void
1270_edje_collection_free_part_description_clean(int type, Edje_Part_Description_Common *desc, Eina_Bool free_strings)
1271{
1272 if (free_strings && desc->color_class) eina_stringshare_del(desc->color_class);
1273
1274 switch (type)
1275 {
1276 case EDJE_PART_TYPE_IMAGE:
1277 {
1278 Edje_Part_Description_Image *img;
1279 unsigned int i;
1280
1281 img = (Edje_Part_Description_Image *) desc;
1282
1283 for (i = 0; i < img->image.tweens_count; ++i)
1284 free(img->image.tweens[i]);
1285 free(img->image.tweens);
1286 break;
1287 }
1288 case EDJE_PART_TYPE_EXTERNAL:
1289 {
1290 Edje_Part_Description_External *external;
1291
1292 external = (Edje_Part_Description_External *) desc;
1293
1294 if (external->external_params)
1295 _edje_external_params_free(external->external_params, free_strings);
1296 break;
1297 }
1298 case EDJE_PART_TYPE_TEXT:
1299 case EDJE_PART_TYPE_TEXTBLOCK:
1300 if (free_strings)
1301 {
1302 Edje_Part_Description_Text *text;
1303
1304 text = (Edje_Part_Description_Text *) desc;
1305
1306 if (text->text.text.str) eina_stringshare_del(text->text.text.str);
1307 if (text->text.text_class) eina_stringshare_del(text->text.text_class);
1308 if (text->text.style.str) eina_stringshare_del(text->text.style.str);
1309 if (text->text.font.str) eina_stringshare_del(text->text.font.str);
1310 }
1311 break;
1312 }
1313}
1314
1315void
1316_edje_collection_free_part_description_free(int type,
1317 Edje_Part_Description_Common *desc,
1318 Edje_Part_Collection_Directory_Entry *ce,
1319 Eina_Bool free_strings)
1320{
1321#define FREE_POOL(Type, Ce, Desc) \
1322 case EDJE_PART_TYPE_##Type: eina_mempool_free(Ce->mp.Type, Desc); \
1323 ce->count.Type--; \
1324 break;
1325
1326 _edje_collection_free_part_description_clean(type, desc, free_strings);
1327
1328 switch (type)
1329 {
1330 FREE_POOL(RECTANGLE, ce, desc);
1331 FREE_POOL(TEXT, ce, desc);
1332 FREE_POOL(IMAGE, ce, desc);
1333 FREE_POOL(PROXY, ce, desc);
1334 FREE_POOL(SWALLOW, ce, desc);
1335 FREE_POOL(TEXTBLOCK, ce, desc);
1336 FREE_POOL(GROUP, ce, desc);
1337 FREE_POOL(BOX, ce, desc);
1338 FREE_POOL(TABLE, ce, desc);
1339 FREE_POOL(EXTERNAL, ce, desc);
1340 }
1341}
1342
1343#ifdef EDJE_PROGRAM_CACHE
1344static Eina_Bool
1345_edje_collection_free_prog_cache_matches_free_cb(const Eina_Hash *hash, const void *key, void *data, void *fdata)
1346{
1347 eina_list_free((Eina_List *)data);
1348 return EINA_TRUE;
1349 key = NULL;
1350 hash = NULL;
1351 fdata = NULL;
1352}
1353#endif
1354
1355static void
1356_edje_object_pack_item_hints_set(Evas_Object *obj, Edje_Pack_Element *it)
1357{
1358 Evas_Coord w = 0, h = 0, minw, minh;
1359
1360 minw = it->min.w;
1361 minh = it->min.h;
1362
1363 if ((minw <= 0) && (minh <= 0))
1364 {
1365 edje_object_size_min_get(obj, &w, &h);
1366 if ((w <= 0) && (h <= 0))
1367 edje_object_size_min_calc(obj, &w, &h);
1368 }
1369 else
1370 {
1371 w = minw;
1372 h = minh;
1373 }
1374 if (((minw <= 0) && (minh <= 0)) && ((w > 0) || (h > 0)))
1375 evas_object_size_hint_min_set(obj, w, h);
1376 else
1377 evas_object_size_hint_min_set(obj, minw, minh);
1378
1379 evas_object_size_hint_request_set(obj, it->prefer.w, it->prefer.h);
1380 evas_object_size_hint_max_set(obj, it->max.w, it->max.h);
1381 evas_object_size_hint_padding_set(obj, it->padding.l, it->padding.r, it->padding.t, it->padding.b);
1382 evas_object_size_hint_align_set(obj, it->align.x, it->align.y);
1383 evas_object_size_hint_weight_set(obj, it->weight.x, it->weight.y);
1384 evas_object_size_hint_aspect_set(obj, it->aspect.mode, it->aspect.w, it->aspect.h);
1385
1386 evas_object_resize(obj, w, h);
1387}
1388
1389static const char *
1390_edje_find_alias(Eina_Hash *aliased, char *src, int *length)
1391{
1392 const char *alias;
1393 char *search;
1394
1395 *length = strlen(src);
1396 if (*length == 0) return NULL;
1397
1398 alias = eina_hash_find(aliased, src);
1399 if (alias) return alias;
1400
1401 search = strrchr(src, EDJE_PART_PATH_SEPARATOR);
1402 if (search == NULL) return NULL;
1403
1404 *search = '\0';
1405 alias = _edje_find_alias(aliased, src, length);
1406 *search = EDJE_PART_PATH_SEPARATOR;
1407
1408 return alias;
1409}
1410
1411static void
1412_cb_signal_repeat(void *data, Evas_Object *obj, const char *sig, const char *source)
1413{
1414 Edje_Pack_Element *pack_it;
1415 Evas_Object *parent;
1416 Edje *ed;
1417 Edje *ed_parent;
1418 char new_src[4096]; /* XXX is this max reasonable? */
1419 size_t length_parent = 0;
1420 size_t length_index = 0;
1421 size_t length_source;
1422 int i = 0;
1423 const char *alias = NULL;
1424 Edje_Message_Signal emsg;
1425
1426 parent = data;
1427 ed = _edje_fetch(obj);
1428 if (!ed) return;
1429
1430 pack_it = evas_object_data_get(obj, "\377 edje.box_item");
1431 if (!pack_it) pack_it = evas_object_data_get(obj, "\377 edje.table_item");
1432 if (pack_it)
1433 {
1434 if (!pack_it->name)
1435 {
1436 Eina_List *child = NULL;
1437 Evas_Object *o;
1438
1439 if (pack_it->parent->part->type == EDJE_PART_TYPE_BOX)
1440 {
1441 child = evas_object_box_children_get(pack_it->parent->object);
1442 }
1443 else if (pack_it->parent->part->type == EDJE_PART_TYPE_TABLE)
1444 {
1445 child = evas_object_table_children_get(pack_it->parent->object);
1446 }
1447
1448 EINA_LIST_FREE(child, o)
1449 {
1450 if (o == obj) break;
1451 i++;
1452 }
1453
1454 eina_list_free(child);
1455
1456 length_index = 12;
1457 }
1458 else
1459 {
1460 length_index = strlen(pack_it->name) + 2;
1461 }
1462 }
1463
1464 /* Replace snprint("%s%c%s") == memcpy + *new_src + memcat */
1465 if (ed->parent)
1466 length_parent = strlen(ed->parent);
1467 length_source = strlen(source);
1468 if (length_source + length_parent + 2 + length_index > sizeof(new_src))
1469 return;
1470
1471 if (ed->parent)
1472 memcpy(new_src, ed->parent, length_parent);
1473 if (ed->parent && length_index)
1474 {
1475 new_src[length_parent++] = EDJE_PART_PATH_SEPARATOR_INDEXL;
1476 if (length_index == 12)
1477 length_parent += eina_convert_itoa(i, new_src + length_parent);
1478 else
1479 {
1480 memcpy(new_src + length_parent, pack_it->name, length_index);
1481 length_parent += length_index - 2;
1482 }
1483 new_src[length_parent++] = EDJE_PART_PATH_SEPARATOR_INDEXR;
1484 }
1485
1486 new_src[length_parent] = EDJE_PART_PATH_SEPARATOR;
1487 memcpy(new_src + length_parent + 1, source, length_source + 1);
1488
1489 /* Handle alias renaming */
1490 ed_parent = _edje_fetch(parent);
1491 if (ed_parent && ed_parent->collection && ed_parent->collection->aliased)
1492 {
1493 int length;
1494
1495 alias = _edje_find_alias(ed_parent->collection->aliased, new_src, &length);
1496
1497 if (alias)
1498 {
1499 int origin;
1500
1501 /* Add back the end of the source */
1502 origin = strlen(new_src);
1503 length ++; /* Remove the trailing ':' from the count */
1504 if (origin > length)
1505 {
1506 char *tmp;
1507 size_t alias_length;
1508
1509 alias_length = strlen(alias);
1510 tmp = alloca(alias_length + origin - length + 2);
1511 memcpy(tmp, alias, alias_length);
1512 tmp[alias_length] = EDJE_PART_PATH_SEPARATOR;
1513 memcpy(tmp + alias_length + 1, new_src + length, origin - length + 1);
1514
1515 alias = tmp;
1516 }
1517 }
1518 }
1519
1520 emsg.sig = sig;
1521 emsg.src = alias ? alias : new_src;
1522 emsg.data = NULL;
1523 _edje_message_send(ed_parent, EDJE_QUEUE_SCRIPT,
1524 EDJE_MESSAGE_SIGNAL, 0, &emsg);
1525}
diff --git a/libraries/edje/src/lib/edje_lua.c b/libraries/edje/src/lib/edje_lua.c
new file mode 100644
index 0000000..d431d75
--- /dev/null
+++ b/libraries/edje/src/lib/edje_lua.c
@@ -0,0 +1,5150 @@
1#include "edje_private.h"
2
3#if 0
4/////////////////////////////////////////////////////////////////////////////
5// the below is deprecated and here for reference only until removed. look
6// at edje_lua2.c for the active workign code
7/////////////////////////////////////////////////////////////////////////////
8
9#include <lauxlib.h>
10#include <lualib.h>
11
12#define EDJE_LUA_GET 1
13#define EDJE_LUA_SET 2
14#define EDJE_LUA_FN 3
15
16typedef struct _Edje_Lua_Alloc Edje_Lua_Alloc;
17
18typedef struct _Edje_Lua_Ref Edje_Lua_Ref;
19
20typedef struct _Edje_Lua_Reg Edje_Lua_Reg;
21
22typedef struct _Edje_Lua_Timer Edje_Lua_Timer;
23
24typedef struct _Edje_Lua_Animator Edje_Lua_Animator;
25
26typedef struct _Edje_Lua_Poller Edje_Lua_Poller;
27
28typedef struct _Edje_Lua_Transform Edje_Lua_Transform;
29
30typedef struct _Edje_Lua_Transition Edje_Lua_Transition;
31
32typedef struct _Edje_Lua_Evas_Object Edje_Lua_Evas_Object;
33
34typedef struct _Edje_Lua_Edje_Part_Object Edje_Lua_Edje_Part_Object;
35
36typedef struct _Edje_Lua_Edje_Part_Description Edje_Lua_Edje_Part_Description;
37
38struct _Edje_Lua_Alloc
39{
40 size_t max, cur; /* maximal and current memory used by Lua */
41};
42
43struct _Edje_Lua_Ref
44{
45 int id;
46 lua_State *L;
47};
48
49struct _Edje_Lua_Reg
50{
51 const luaL_Reg *mt, *get, *set, *fn;
52};
53
54struct _Edje_Lua_Timer
55{
56 lua_State *L;
57 Ecore_Timer *et;
58 Edje_Lua_Ref *cb;
59};
60
61struct _Edje_Lua_Animator
62{
63 lua_State *L;
64 Ecore_Animator *ea;
65 Edje_Lua_Ref *cb;
66};
67
68struct _Edje_Lua_Poller
69{
70 lua_State *L;
71 Ecore_Poller *ep;
72 Edje_Lua_Ref *cb;
73};
74
75struct _Edje_Lua_Transform
76{
77 lua_State *L;
78 Evas_Transform et;
79};
80
81struct _Edje_Lua_Transition
82{
83 lua_State *L;
84 Ecore_Timer *et;
85 Edje_Lua_Ref *trans;
86 Edje_Lua_Ref *cb;
87 Edje_Lua_Ref *ref;
88 double dur;
89};
90
91struct _Edje_Lua_Evas_Object
92{
93 lua_State *L;
94 Edje *ed;
95 Evas_Object *eo;
96 Eina_Bool mouse_events;
97 Eina_List *cb;
98};
99
100struct _Edje_Lua_Edje_Part_Object
101{
102 lua_State *L;
103 Edje *ed;
104 Evas_Object *eo;
105 Edje_Real_Part *rp;
106 const char *key;
107};
108
109struct _Edje_Lua_Edje_Part_Description
110{
111 lua_State *L;
112 Edje *ed;
113 Evas_Object *eo;
114 Edje_Real_Part *rp;
115 Edje_Part_Description *pd;
116};
117
118jmp_buf _edje_lua_panic_jmp;
119
120static int
121_edje_lua_custom_panic(__UNUSED__ lua_State *L)
122{
123 CRITICAL("PANIC");
124 longjmp(_edje_lua_panic_jmp, 1);
125 return 1; /* longjmp() never returns, but this keep gcc happy */
126}
127
128void
129__edje_lua_error(const char *file, const char *fnc, int line, lua_State *L, int err_code)
130{
131 char *err_type;
132
133 switch (err_code)
134 {
135 case LUA_ERRRUN:
136 err_type = "runtime";
137 break;
138 case LUA_ERRSYNTAX:
139 err_type = "syntax";
140 break;
141 case LUA_ERRMEM:
142 err_type = "memory allocation";
143 break;
144 case LUA_ERRERR:
145 err_type = "error handler";
146 break;
147 default:
148 err_type = "unknown";
149 break;
150 }
151 eina_log_print
152 (_edje_default_log_dom, EINA_LOG_LEVEL_ERR, file, fnc, line,
153 "Lua %s error: %s", err_type, lua_tostring(L, -1));
154 // don't exit. this is BAD. lua script bugs will cause thngs like e to
155 // exit mysteriously ending your x session. bad!
156 // exit(-1);
157}
158
159lua_State *
160_edje_lua_new_thread(Edje *ed, lua_State *L)
161{
162#if 1 // newlua
163 lua_newtable(L);
164 ed->lua_ref = luaL_ref(L, LUA_REGISTRYINDEX);
165 /* inherit new environment from global environment */
166 lua_createtable(L, 1, 0);
167 lua_pushvalue(L, LUA_GLOBALSINDEX);
168 lua_setfield(L, -2, "__index");
169 lua_setmetatable(L, -2);
170 lua_setfenv(L, -2);
171 return L;
172#else
173 /* create new thread */
174 lua_State *thread = lua_newthread(L);
175 //printf ("new thread %d->%d\n", L, thread);
176 /* create new environment for new thread */
177 lua_newtable(L);
178 /* inherit new environment from global environment */
179 lua_createtable(L, 1, 0);
180 lua_pushvalue(L, LUA_GLOBALSINDEX);
181 lua_setfield(L, -2, "__index");
182 lua_setmetatable(L, -2);
183 lua_setfenv(L, -2);
184 return thread;
185#endif
186}
187
188void
189_edje_lua_free_thread(Edje *ed, lua_State *L)
190{
191#if 1 // newlua
192 luaL_unref(L, LUA_REGISTRYINDEX, ed->lua_ref);
193 lua_gc(L, LUA_GCCOLLECT, 0);
194#else
195 lua_pushthread(L);
196 lua_getfenv(L, -1);
197 lua_pushnil(L);
198 while (lua_next(L, -2))
199 {
200 // key at -2, value at -1
201 lua_pop(L, 1);
202 lua_pushvalue(L, -1);
203 lua_pushnil(L);
204 lua_rawset(L, -4);
205 }
206 lua_settop(L, 0);
207 lua_gc(L, LUA_GCCOLLECT, 0);
208#endif
209}
210
211/*
212 * only for debug, returns number of objects in registry
213 */
214static int
215_edje_lua_reg_count (lua_State *L)
216{
217 int count = 0;
218 lua_pushvalue(L, LUA_REGISTRYINDEX);
219 lua_pushnil(L);
220 while (lua_next(L, -2))
221 {
222 // key at -2, value at -1
223 lua_pop(L, 1);
224 count++;
225 }
226 lua_pop(L, 1);
227 return count;
228}
229
230static Edje_Lua_Ref *
231_edje_lua_new_ref(lua_State *L, int index)
232{
233 lua_pushvalue(L, index);
234 Edje_Lua_Ref *ref = malloc(sizeof(Edje_Lua_Ref));
235 ref->id = luaL_ref(L, LUA_REGISTRYINDEX);
236 ref->L = L;
237 return ref;
238}
239
240static void
241_edje_lua_get_ref(lua_State *L, Edje_Lua_Ref *ref)
242{
243 lua_rawgeti(L, LUA_REGISTRYINDEX, ref->id);
244}
245
246static void
247_edje_lua_free_ref(lua_State *L, Edje_Lua_Ref *ref)
248{
249 //printf ("_edje_lua_free_ref %d %d %d\n", L, lua_objlen(L, LUA_REGISTRYINDEX), _edje_lua_reg_count(L));
250 luaL_unref(L, LUA_REGISTRYINDEX, ref->id);
251 free(ref);
252 lua_gc(L, LUA_GCCOLLECT, 0);
253}
254
255void
256_edje_lua_new_reg(lua_State *L, int index, void *ptr)
257{
258 //printf ("_edje_lua_new_reg %d %d %d\n", L, ptr, _edje_lua_reg_count(L));
259 lua_pushvalue(L, index);
260 lua_pushlightuserdata(L, ptr);
261 lua_insert(L, -2);
262 lua_rawset(L, LUA_REGISTRYINDEX); /* freed in _edje_lua_free_reg */
263}
264
265void
266_edje_lua_get_reg(lua_State *L, void *ptr)
267{
268 //printf ("_edje_lua_get_reg %d %d\n", L, ptr);
269 lua_pushlightuserdata(L, ptr);
270 lua_rawget(L, LUA_REGISTRYINDEX);
271}
272
273void
274_edje_lua_free_reg(lua_State *L, void *ptr)
275{
276 //printf ("_edje_lua_free_reg %d %d %d\n", L, ptr, _edje_lua_reg_count(L));
277 lua_pushlightuserdata(L, ptr);
278 lua_pushnil(L);
279 lua_rawset(L, LUA_REGISTRYINDEX); /* created in _edje_lua_new_reg */
280 lua_gc(L, LUA_GCCOLLECT, 0);
281}
282
283static void
284_edje_lua_rawsetfield(lua_State *L, int index, const char *key)
285{
286 lua_pushstring(L, key);
287 lua_insert(L, -2);
288 if (index < 0)
289 lua_rawset(L, index - 1);
290 else
291 lua_rawset(L, index);
292}
293
294static void
295_edje_lua_rawgetfield(lua_State *L, int index, const char *key)
296{
297 lua_pushstring(L, key);
298 if (index < 0)
299 lua_rawget(L, index - 1);
300 else
301 lua_rawget(L, index);
302}
303
304static void
305_edje_lua_new_const(lua_State *L, const char *id, int val)
306{
307 lua_pushnumber(L, val);
308 lua_setglobal(L, id);
309}
310
311static void
312_edje_lua_new_metatable(lua_State *L, const Edje_Lua_Reg ** class)
313{
314 lua_newtable(L);
315 lua_pushlightuserdata(L, class);
316 lua_pushvalue(L, -2);
317 lua_rawset(L, LUA_REGISTRYINDEX); /* freed in _edje_lua_free_metatable */
318 lua_pushvalue(L, -1);
319 lua_pushlightuserdata(L, class);
320 lua_rawset(L, LUA_REGISTRYINDEX); /* freed in _edje_lua_free_metatable */
321}
322
323static void
324_edje_lua_get_metatable(lua_State *L, const Edje_Lua_Reg ** class)
325{
326 lua_pushlightuserdata(L, class);
327 lua_rawget(L, LUA_REGISTRYINDEX);
328}
329
330static void
331_edje_lua_free_metatable(lua_State *L, const Edje_Lua_Reg ** class)
332{
333 lua_pushlightuserdata(L, class);
334 lua_rawget(L, LUA_REGISTRYINDEX);
335 lua_pushnil(L);
336 lua_rawset(L, LUA_REGISTRYINDEX); /* created in _edje_lua_new_metatable */
337 lua_pushlightuserdata(L, class);
338 lua_pushnil(L);
339 lua_rawset(L, LUA_REGISTRYINDEX); /* created in _edje_lua_new_metatable */
340 lua_gc(L, LUA_GCCOLLECT, 0);
341}
342
343static void *
344_edje_lua_checkudata(lua_State *L, int pos, const Edje_Lua_Reg * module)
345{
346 luaL_checktype(L, pos, LUA_TUSERDATA);
347 lua_getmetatable(L, pos);
348 lua_rawget(L, LUA_REGISTRYINDEX);
349 Edje_Lua_Reg **class = lua_touserdata(L, -1);
350 lua_pop(L, 1); // class
351 int flag = 0;
352 int ptr = 0;
353 while (class[ptr] && !flag)
354 if (class[ptr++] == module)
355 flag = 1;
356 if (!flag)
357 {
358 lua_pushstring(L, "class type mismatch");
359 lua_error(L);
360 }
361 return lua_touserdata(L, pos);
362}
363
364static void
365_edje_lua_new_class(lua_State *L, const Edje_Lua_Reg ** class)
366{
367 int n = 0;
368 _edje_lua_new_metatable(L, class);
369 while (class && (class[n] != NULL))
370 {
371 luaL_register(L, NULL, class[n]->mt);
372 lua_pushstring(L, "hands off, it's none of your business!");
373 _edje_lua_rawsetfield(L, -2, "__metatable");
374
375 if (n == 0)
376 {
377 lua_newtable(L);
378 luaL_register(L, NULL, class[n]->set);
379 lua_rawseti (L, -2, EDJE_LUA_SET);
380
381 lua_newtable(L);
382 luaL_register(L, NULL, class[n]->get);
383 lua_rawseti (L, -2, EDJE_LUA_GET);
384
385 lua_newtable(L);
386 luaL_register(L, NULL, class[n]->fn);
387 lua_rawseti (L, -2, EDJE_LUA_FN);
388 }
389 else
390 {
391 lua_rawgeti(L, -1, EDJE_LUA_SET);
392 luaL_register(L, NULL, class[n]->set);
393 lua_pop(L, 1);
394
395 lua_rawgeti(L, -1, EDJE_LUA_GET);
396 luaL_register(L, NULL, class[n]->get);
397 lua_pop(L, 1);
398
399 lua_rawgeti(L, -1, EDJE_LUA_FN);
400 luaL_register(L, NULL, class[n]->fn);
401 lua_pop(L, 1);
402 }
403 n += 1;
404 }
405}
406
407static void
408_edje_lua_set_class(lua_State *L, int index, const Edje_Lua_Reg ** class)
409{
410 lua_newtable(L);
411 if (index < 0)
412 lua_setfenv(L, index - 1);
413 else
414 lua_setfenv(L, index);
415
416 _edje_lua_get_metatable(L, class);
417 if (index < 0)
418 lua_setmetatable(L, index - 1);
419 else
420 lua_setmetatable(L, index);
421}
422
423static int
424_edje_lua_look_fn(lua_State *L)
425{
426 lua_rawgeti(L, -1, EDJE_LUA_FN);
427 lua_pushvalue(L, 2); // key
428 lua_rawget(L, -2); // .fn[key]
429 if (lua_iscfunction(L, -1))
430 return 1;
431 else
432 {
433 lua_pop(L, 2); // .fn[key], .fn
434 return 0;
435 }
436}
437
438static int
439_edje_lua_look_get(lua_State *L)
440{
441 lua_rawgeti(L, -1, EDJE_LUA_GET);
442 lua_pushvalue(L, 2); // key
443 lua_rawget(L, -2); // .get[key]
444 if (lua_iscfunction(L, -1))
445 {
446 int err_code;
447
448 lua_pushvalue(L, 1);
449
450 if ((err_code = lua_pcall(L, 1, 1, 0)))
451 _edje_lua_error(L, err_code);
452 return 1;
453 }
454 else
455 {
456 lua_pop(L, 2); // .get[key], .get
457 return 0;
458 }
459}
460
461static int
462_edje_lua_look_set(lua_State *L)
463{
464 lua_rawgeti(L, -1, EDJE_LUA_SET);
465 lua_pushvalue(L, 2); // key
466 lua_rawget(L, -2); // .set[key]
467 if (lua_iscfunction(L, -1))
468 {
469 int err_code;
470
471 lua_pushvalue(L, 1); // obj
472 lua_pushvalue(L, 3); // value
473
474 if ((err_code = lua_pcall(L, 2, 0, 0))) // .set[key](obj,key,value)
475 _edje_lua_error(L, err_code);
476 return 1;
477 }
478 else
479 {
480 lua_pop(L, 2); // .set[key], .set
481 return 0;
482 }
483}
484
485/*
486 * Lua Class bindings
487 */
488
489const luaL_Reg lNil[] = {
490 {NULL, NULL} // sentinel
491};
492
493const luaL_Reg lClass_mt[];
494
495const luaL_Reg lClass_fn[];
496
497const Edje_Lua_Reg mClass = {
498 lClass_mt,
499 lNil,
500 lNil,
501 lClass_fn
502};
503
504static int
505_edje_lua_class_mt_index(lua_State *L)
506{
507 _edje_lua_checkudata(L, 1, &mClass);
508 lua_getmetatable(L, 1);
509 if (!_edje_lua_look_fn(L)) // look in lClass_fn
510 if (!_edje_lua_look_get(L)) // look in lClass_get
511 { // look in obj ref hash
512 lua_getfenv(L, 1);
513 lua_pushvalue(L, 2); // key
514 lua_rawget(L, -2);
515 }
516 return 1;
517}
518
519static int
520_edje_lua_class_mt_newindex(lua_State *L)
521{
522 _edje_lua_checkudata(L, 1, &mClass);
523 lua_getmetatable(L, 1);
524 if (!_edje_lua_look_set(L)) // look in lClass_set
525 { // look in obj ref hash
526 lua_getfenv(L, 1);
527 lua_pushvalue(L, 2);
528 lua_pushvalue(L, 3);
529 lua_rawset(L, -3);
530 }
531 return 0;
532}
533
534static int
535_edje_lua_class_mt_gc(lua_State *L)
536{
537 _edje_lua_checkudata(L, 1, &mClass);
538 //printf("_edje_lua_class_mt_gc\n");
539 /* FIXME has to be commented to not raise an error, solve differently
540 lua_getfield(L, 1, "del");
541 if (!lua_isnil(L, -1))
542 {
543 lua_pushvalue(L, 1);
544 int err_code;
545
546 if (err_code = lua_pcall(L, 1, 0, 0))
547 _edje_lua_error(L, err_code);
548 }
549 lua_pop(L, 1);
550 */
551 return 0;
552}
553
554static int
555_edje_lua_class_fn_set(lua_State *L)
556{
557 _edje_lua_checkudata(L, 1, &mClass);
558 /*
559 * for k,v in pairs(table) do
560 * obj[k] = v
561 * end
562 */
563 lua_pushnil(L);
564 while (lua_next(L, 2))
565 {
566 // key at -2, value at -1
567 lua_pushvalue(L, -2);
568 lua_insert(L, -2);
569 lua_settable(L, 1);
570 }
571 return 0;
572}
573
574static int
575_edje_lua_class_fn_get(lua_State *L)
576{
577 _edje_lua_checkudata(L, 1, &mClass);
578 /*
579 * res = {}
580 * mtG = getmetatable(obj)['.get']
581 * for k,v in pairs(mtG) do
582 * res[k] = obj[k]
583 * end
584 */
585 lua_newtable(L); // res
586 lua_getmetatable(L, 1); // mt
587 lua_getfield(L, -1, ".get");
588 lua_remove(L, -2); // mt
589
590 lua_pushnil(L);
591 while (lua_next(L, -2))
592 {
593 // key at -2, value at -1
594 lua_pop(L, 1); // value = cfunction
595 lua_pushvalue(L, -1); // key
596 lua_pushvalue(L, -1); // key
597 lua_gettable(L, 1); // obj[key]
598 lua_settable(L, 2); // res[key]
599 }
600 lua_pop(L, 1); // .get
601 return 1;
602}
603
604static int
605_edje_lua_class_itr_call(lua_State *L, int id)
606{
607 int err_code;
608
609 _edje_lua_checkudata(L, 1, &mClass);
610 lua_getmetatable(L, 1); // mt
611 lua_rawgeti(L, -1, id);
612 lua_remove(L, -2); // mt
613 lua_getglobal(L, "pairs");
614 lua_insert(L, -2);
615
616 if ((err_code = lua_pcall(L, 1, 3, 0)))
617 _edje_lua_error(L, err_code);
618 return 3;
619}
620
621static int
622_edje_lua_class_fn_gpairs(lua_State *L)
623{
624 _edje_lua_checkudata(L, 1, &mClass);
625 return _edje_lua_class_itr_call(L, EDJE_LUA_GET);
626}
627
628static int
629_edje_lua_class_fn_spairs(lua_State *L)
630{
631 _edje_lua_checkudata(L, 1, &mClass);
632 return _edje_lua_class_itr_call(L, EDJE_LUA_SET);
633}
634
635static int
636_edje_lua_class_fn_fpairs(lua_State *L)
637{
638 _edje_lua_checkudata(L, 1, &mClass);
639 return _edje_lua_class_itr_call(L, EDJE_LUA_FN);
640}
641
642static int
643_edje_lua_class_fn_pairs(lua_State *L)
644{
645 int err_code;
646
647 _edje_lua_checkudata(L, 1, &mClass);
648 lua_getfenv(L, 1);
649 lua_getglobal(L, "pairs");
650 lua_insert(L, -2);
651
652 if ((err_code = lua_pcall(L, 1, 3, 0)))
653 _edje_lua_error(L, err_code);
654 return 3;
655}
656
657static int
658_edje_lua_class_fn_ipairs(lua_State *L)
659{
660 int err_code;
661
662 _edje_lua_checkudata(L, 1, &mClass);
663 lua_getfenv(L, 1);
664 lua_getglobal(L, "ipairs");
665 lua_insert(L, -2);
666
667 if ((err_code = lua_pcall(L, 1, 3, 0)))
668 _edje_lua_error(L, err_code);
669 return 3;
670}
671
672const luaL_Reg lClass_mt[] = {
673 {"__index", _edje_lua_class_mt_index},
674 {"__newindex", _edje_lua_class_mt_newindex},
675 {"__gc", _edje_lua_class_mt_gc},
676 {NULL, NULL} // sentinel
677};
678
679const luaL_Reg lClass_fn[] = {
680 {"get", _edje_lua_class_fn_get},
681 {"set", _edje_lua_class_fn_set},
682 {"gpairs", _edje_lua_class_fn_gpairs},
683 {"spairs", _edje_lua_class_fn_spairs},
684 {"fpairs", _edje_lua_class_fn_fpairs},
685 {"pairs", _edje_lua_class_fn_pairs},
686 {"ipairs", _edje_lua_class_fn_ipairs},
687 {NULL, NULL} // sentinel
688};
689
690
691const luaL_Reg lTimer_get[];
692
693const luaL_Reg lTimer_set[];
694
695const luaL_Reg lTimer_fn[];
696
697const Edje_Lua_Reg mTimer = {
698 lNil,
699 lTimer_get,
700 lTimer_set,
701 lTimer_fn
702};
703
704const Edje_Lua_Reg *cTimer[] = {
705 &mClass,
706 &mTimer,
707 NULL // sentinel
708};
709
710static Eina_Bool
711_edje_lua_timer_cb(void *data)
712{
713 Edje_Lua_Timer *obj = data;
714 lua_State *L = obj->L;
715 int err_code;
716 Eina_Bool res;
717
718 _edje_lua_get_ref(L, obj->cb); // callback function
719 _edje_lua_get_reg(L, obj);
720
721 if ((err_code = lua_pcall(L, 1, 1, 0)))
722 {
723 _edje_lua_error(L, err_code);
724 return ECORE_CALLBACK_CANCEL;
725 }
726
727 res = luaL_optint(L, -1, ECORE_CALLBACK_CANCEL);
728 lua_pop(L, 1); // -- res
729
730/*
731 if (_edje_lua_panic_here())
732 printf("blahc\n");
733 else
734 lua_pop(L, 1); // -- res
735 */
736 if (res == ECORE_CALLBACK_CANCEL)
737 {
738 // delete object
739 _edje_lua_get_reg(L, obj);
740 lua_pushvalue(L, -1);
741 lua_pushstring(L, "del");
742 lua_gettable(L, -2);
743 lua_insert(L, -2);
744 if ((err_code = lua_pcall(L, 1, 0, 0)))
745 _edje_lua_error(L, err_code);
746 }
747 return res;
748}
749
750static int
751_edje_lua_timer_get_pending(lua_State *L)
752{
753 Edje_Lua_Timer *obj = _edje_lua_checkudata(L, 1, &mTimer);
754 if (obj->et)
755 lua_pushnumber(L, ecore_timer_pending_get(obj->et));
756 else
757 lua_pushnil(L);
758 return 1;
759}
760
761static int
762_edje_lua_timer_get_precision(lua_State *L)
763{
764 Edje_Lua_Timer *obj = _edje_lua_checkudata(L, 1, &mTimer);
765
766 if (obj->et)
767 lua_pushnumber(L, ecore_timer_precision_get());
768 else
769 lua_pushnil(L);
770
771 return 1;
772}
773
774static int
775_edje_lua_timer_get_interval(lua_State *L)
776{
777 Edje_Lua_Timer *obj = _edje_lua_checkudata(L, 1, &mTimer);
778
779 if (obj->et)
780 lua_pushnumber(L, ecore_timer_interval_get(obj->et));
781 else
782 lua_pushnil(L);
783
784 return 1;
785}
786
787const luaL_Reg lTimer_get[] = {
788 {"pending", _edje_lua_timer_get_pending},
789 {"precision", _edje_lua_timer_get_precision},
790 {"interval", _edje_lua_timer_get_interval},
791 {NULL, NULL} // sentinel
792};
793
794static int
795_edje_lua_timer_set_interval(lua_State *L)
796{
797 Edje_Lua_Timer *obj = _edje_lua_checkudata(L, 1, &mTimer);
798 if (obj->et)
799 ecore_timer_interval_set(obj->et, luaL_checknumber(L, 2));
800 return 0;
801}
802
803const luaL_Reg lTimer_set[] = {
804 {"interval", _edje_lua_timer_set_interval},
805 {NULL, NULL} // sentinel
806};
807
808static int
809_edje_lua_timer_fn_del(lua_State *L)
810{
811 Edje_Lua_Timer *obj = _edje_lua_checkudata(L, 1, &mTimer);
812 if (obj->et)
813 {
814 ecore_timer_del(obj->et);
815 obj->et = NULL;
816 }
817 if (obj->cb)
818 {
819 _edje_lua_free_ref(L, obj->cb); // created in _edje_lua_group_fn_timer
820 obj->cb = NULL;
821 }
822 _edje_lua_free_reg(L, obj); // created in _edje_lua_group_fn_timer
823 return 0;
824}
825
826static int
827_edje_lua_timer_fn_freeze(lua_State *L)
828{
829 Edje_Lua_Timer *obj = _edje_lua_checkudata(L, 1, &mTimer);
830 if (obj->et)
831 ecore_timer_freeze(obj->et);
832 return 0;
833}
834
835static int
836_edje_lua_timer_fn_thaw(lua_State *L)
837{
838 Edje_Lua_Timer *obj = _edje_lua_checkudata(L, 1, &mTimer);
839 if (obj->et)
840 ecore_timer_thaw(obj->et);
841 return 0;
842}
843
844static int
845_edje_lua_timer_fn_delay(lua_State *L)
846{
847 Edje_Lua_Timer *obj = _edje_lua_checkudata(L, 1, &mTimer);
848 if (obj->et)
849 ecore_timer_delay(obj->et, luaL_checknumber(L, 2));
850 return 0;
851}
852
853const luaL_Reg lTimer_fn[] = {
854 {"del", _edje_lua_timer_fn_del},
855 {"freeze", _edje_lua_timer_fn_freeze},
856 {"thaw", _edje_lua_timer_fn_thaw},
857 {"delay", _edje_lua_timer_fn_delay},
858 {NULL, NULL} // sentinel
859};
860
861const luaL_Reg lAnimator_get[];
862
863const luaL_Reg lAnimator_fn[];
864
865const Edje_Lua_Reg mAnimator = {
866 lNil,
867 lAnimator_get,
868 lNil,
869 lAnimator_fn
870};
871
872const Edje_Lua_Reg *cAnimator[] = {
873 &mClass,
874 &mAnimator,
875 NULL // sentinel
876};
877
878static Eina_Bool
879_edje_lua_animator_cb(void *data)
880{
881 Eina_Bool res;
882 int err;
883 Edje_Lua_Animator *obj = data;
884 lua_State *L = obj->L;
885
886 _edje_lua_get_ref(L, obj->cb);
887 _edje_lua_get_reg(L, obj);
888
889 if ((err = lua_pcall(L, 1, 1, 0)))
890 {
891 _edje_lua_error(L, err);
892 return ECORE_CALLBACK_CANCEL;
893 }
894
895 res = luaL_checkint(L, -1);
896 lua_pop(L, 1); // Pop res off the stack
897 if (res == ECORE_CALLBACK_CANCEL)
898 {
899 /* delete animator */
900 _edje_lua_get_reg(L, obj);
901 lua_pushvalue(L, -1);
902 lua_pushstring(L, "del");
903 lua_gettable(L, -2);
904 lua_insert(L, -2);
905 if ((err = lua_pcall(L, 1, 0, 0)))
906 _edje_lua_error(L, err);
907 }
908
909 return res;
910}
911
912static int
913_edje_lua_animator_get_frametime(lua_State *L)
914{
915 Edje_Lua_Animator *obj = _edje_lua_checkudata(L, 1, &mAnimator);
916
917 if (obj->ea)
918 lua_pushnumber(L, ecore_animator_frametime_get());
919 else
920 lua_pushnil(L);
921
922 return 1;
923}
924
925const luaL_Reg lAnimator_get[] = {
926 {"frametime", _edje_lua_animator_get_frametime},
927 {NULL, NULL}
928};
929
930static int
931_edje_lua_animator_fn_del(lua_State *L)
932{
933 Edje_Lua_Animator *obj = _edje_lua_checkudata(L, 1, &mAnimator);
934 if (obj->ea)
935 {
936 ecore_animator_del(obj->ea);
937 obj->ea = NULL;
938 }
939 if (obj->cb)
940 {
941 _edje_lua_free_ref(L, obj->cb); // created in _edje_lua_group_fn_animator
942 obj->cb = NULL;
943 }
944 _edje_lua_free_reg(L, obj); // created in _edje_lua_group_fn_animator
945 return 0;
946}
947
948const luaL_Reg lAnimator_fn[] = {
949 {"del", _edje_lua_animator_fn_del},
950 {NULL, NULL} // sentinel
951};
952
953const luaL_Reg lPoller_get[];
954
955const luaL_Reg lPoller_fn[];
956
957const Edje_Lua_Reg mPoller = {
958 lNil,
959 lPoller_get,
960 lNil,
961 lPoller_fn
962};
963
964const Edje_Lua_Reg *cPoller[] = {
965 &mClass,
966 &mPoller,
967 NULL // sentinel
968};
969
970static Eina_Bool
971_edje_lua_poller_cb(void *data)
972{
973 Eina_Bool res;
974 int err;
975 Edje_Lua_Poller *obj = data;
976 lua_State *L = obj->L;
977
978 _edje_lua_get_ref(L, obj->cb);
979 _edje_lua_get_reg(L, obj);
980
981 if ((err = lua_pcall(L, 1, 1, 0)))
982 {
983 _edje_lua_error(L, err);
984 return ECORE_CALLBACK_CANCEL;
985 }
986
987 res = luaL_checkint(L, -1);
988 lua_pop(L, 1); // Pop res off the stack
989 if (res == ECORE_CALLBACK_CANCEL)
990 {
991 /* delete poller */
992 _edje_lua_get_reg(L, obj);
993 lua_pushvalue(L, -1);
994 lua_pushstring(L, "del");
995 lua_gettable(L, -2);
996 lua_insert(L, -2);
997 if ((err = lua_pcall(L, 1, 0, 0)))
998 _edje_lua_error(L, err);
999 }
1000
1001 return res;
1002}
1003
1004static int
1005_edje_lua_poller_get_interval(lua_State *L)
1006{
1007 Edje_Lua_Poller *obj = _edje_lua_checkudata(L, 1, &mPoller);
1008
1009 if (obj->ep)
1010 lua_pushnumber(L, ecore_poller_poll_interval_get(ECORE_POLLER_CORE));
1011 else
1012 lua_pushnil(L);
1013
1014 return 1;
1015}
1016
1017const luaL_Reg lPoller_get[] = {
1018 {"interval", _edje_lua_poller_get_interval},
1019 {NULL, NULL}
1020};
1021
1022static int
1023_edje_lua_poller_fn_del(lua_State *L)
1024{
1025 Edje_Lua_Poller *obj = _edje_lua_checkudata(L, 1, &mPoller);
1026 if (obj->ep)
1027 {
1028 ecore_poller_del(obj->ep);
1029 obj->ep = NULL;
1030 }
1031
1032 if (obj->cb)
1033 {
1034 _edje_lua_free_ref(L, obj->cb); // created in _edje_lua_group_fn_poller
1035 obj->cb = NULL;
1036 }
1037 _edje_lua_free_reg(L, obj); // created in _edje_lua_group_fn_poller
1038
1039 return 0;
1040}
1041
1042const luaL_Reg lPoller_fn[] = {
1043 {"del", _edje_lua_poller_fn_del},
1044 {NULL, NULL}
1045};
1046
1047/*
1048 * Lua Edje Transform bindings
1049 */
1050
1051const luaL_Reg lTransform_get[];
1052
1053const luaL_Reg lTransform_set[];
1054
1055const luaL_Reg lTransform_fn[];
1056
1057const Edje_Lua_Reg mTransform = {
1058 lNil,
1059 lTransform_get,
1060 lTransform_set,
1061 lTransform_fn
1062};
1063
1064const Edje_Lua_Reg *cTransform[] = {
1065 &mClass,
1066 &mTransform,
1067 NULL // sentinel
1068};
1069
1070static int
1071_edje_lua_transform_get_matrix(lua_State *L)
1072{
1073 Edje_Lua_Transform *obj = _edje_lua_checkudata(L, 1, &mTransform);
1074 lua_createtable(L, 3, 0);
1075 lua_createtable(L, 3, 0);
1076 lua_pushnumber(L, obj->et.mxx); lua_rawseti(L, -2, 1);
1077 lua_pushnumber(L, obj->et.mxy); lua_rawseti(L, -2, 2);
1078 lua_pushnumber(L, obj->et.mxz); lua_rawseti(L, -2, 3);
1079 lua_rawseti(L, -2, 1);
1080 lua_createtable(L, 3, 0);
1081 lua_pushnumber(L, obj->et.myx); lua_rawseti(L, -2, 1);
1082 lua_pushnumber(L, obj->et.myy); lua_rawseti(L, -2, 2);
1083 lua_pushnumber(L, obj->et.myz); lua_rawseti(L, -2, 3);
1084 lua_rawseti(L, -2, 2);
1085 lua_createtable(L, 3, 0);
1086 lua_pushnumber(L, obj->et.mzx); lua_rawseti(L, -2, 1);
1087 lua_pushnumber(L, obj->et.mzy); lua_rawseti(L, -2, 2);
1088 lua_pushnumber(L, obj->et.mzz); lua_rawseti(L, -2, 3);
1089 lua_rawseti(L, -2, 3);
1090 return 1;
1091}
1092
1093const luaL_Reg lTransform_get[] = {
1094 {"matrix", _edje_lua_transform_get_matrix},
1095 {NULL, NULL} // sentinel
1096};
1097
1098static int
1099_edje_lua_transform_set_matrix(lua_State *L)
1100{
1101 Edje_Lua_Transform *obj = _edje_lua_checkudata(L, 1, &mTransform);
1102 luaL_checktype(L, 2, LUA_TTABLE);
1103 lua_rawgeti(L, 2, 1);
1104 luaL_checktype(L, -1, LUA_TTABLE);
1105 lua_rawgeti(L, -1, 1); obj->et.mxx = luaL_checknumber(L, -1); lua_pop(L, 1);
1106 lua_rawgeti(L, -1, 2); obj->et.mxy = luaL_checknumber(L, -1); lua_pop(L, 1);
1107 lua_rawgeti(L, -1, 3); obj->et.mxz = luaL_checknumber(L, -1); lua_pop(L, 1);
1108 lua_pop(L, 1);
1109 lua_rawgeti(L, 2, 2);
1110 luaL_checktype(L, -1, LUA_TTABLE);
1111 lua_rawgeti(L, -1, 1); obj->et.myx = luaL_checknumber(L, -1); lua_pop(L, 1);
1112 lua_rawgeti(L, -1, 2); obj->et.myy = luaL_checknumber(L, -1); lua_pop(L, 1);
1113 lua_rawgeti(L, -1, 3); obj->et.myz = luaL_checknumber(L, -1); lua_pop(L, 1);
1114 lua_pop(L, 1);
1115 lua_rawgeti(L, 2, 3);
1116 luaL_checktype(L, -1, LUA_TTABLE);
1117 lua_rawgeti(L, -1, 1); obj->et.mzx = luaL_checknumber(L, -1); lua_pop(L, 1);
1118 lua_rawgeti(L, -1, 2); obj->et.mzy = luaL_checknumber(L, -1); lua_pop(L, 1);
1119 lua_rawgeti(L, -1, 3); obj->et.mzz = luaL_checknumber(L, -1); lua_pop(L, 1);
1120 lua_pop(L, 1);
1121 return 0;
1122}
1123
1124const luaL_Reg lTransform_set[] = {
1125 {"matrix", _edje_lua_transform_set_matrix},
1126 {NULL, NULL} // sentinel
1127};
1128
1129static int
1130_edje_lua_transform_fn_identity(lua_State *L)
1131{
1132 Edje_Lua_Transform *obj = _edje_lua_checkudata(L, 1, &mTransform);
1133 evas_transform_identity_set(&(obj->et));
1134 return 0;
1135}
1136
1137static int
1138_edje_lua_transform_fn_rotate(lua_State *L)
1139{
1140 Edje_Lua_Transform *obj = _edje_lua_checkudata(L, 1, &mTransform);
1141 evas_transform_rotate(luaL_checknumber(L, 2), &(obj->et));
1142 return 0;
1143}
1144
1145static int
1146_edje_lua_transform_fn_translate(lua_State *L)
1147{
1148 Edje_Lua_Transform *obj = _edje_lua_checkudata(L, 1, &mTransform);
1149 evas_transform_translate(luaL_checknumber(L, 2), luaL_checknumber(L, 3), &(obj->et));
1150 return 0;
1151}
1152
1153static int
1154_edje_lua_transform_fn_scale(lua_State *L)
1155{
1156 Edje_Lua_Transform *obj = _edje_lua_checkudata(L, 1, &mTransform);
1157 evas_transform_scale(luaL_checknumber(L, 2), luaL_checknumber(L, 3), &(obj->et));
1158 return 0;
1159}
1160
1161static int
1162_edje_lua_transform_fn_shear(lua_State *L)
1163{
1164 Edje_Lua_Transform *obj = _edje_lua_checkudata(L, 1, &mTransform);
1165 evas_transform_shear(luaL_checknumber(L, 2), luaL_checknumber(L, 3), &(obj->et));
1166 return 0;
1167}
1168
1169static int
1170_edje_lua_transform_fn_compose(lua_State *L)
1171{
1172 Edje_Lua_Transform *obj = _edje_lua_checkudata(L, 1, &mTransform);
1173 Edje_Lua_Transform *tar = _edje_lua_checkudata(L, 2, &mTransform);
1174 evas_transform_compose(&(tar->et), &(obj->et));
1175 return 0;
1176}
1177
1178const luaL_Reg lTransform_fn[] = {
1179 {"identity", _edje_lua_transform_fn_identity},
1180 {"rotate", _edje_lua_transform_fn_rotate},
1181 {"translate", _edje_lua_transform_fn_translate},
1182 {"scale", _edje_lua_transform_fn_scale},
1183 {"shear", _edje_lua_transform_fn_shear},
1184 {"compose", _edje_lua_transform_fn_compose},
1185 {NULL, NULL} // sentinel
1186};
1187
1188/*
1189 * Lua Edje Transition bindings
1190 */
1191
1192const luaL_Reg lTransition_get[];
1193
1194const luaL_Reg lTransition_set[];
1195
1196const luaL_Reg lTransition_fn[];
1197
1198const Edje_Lua_Reg mTransition = {
1199 lNil,
1200 lTransition_get,
1201 lTransition_set,
1202 lTransition_fn
1203};
1204
1205const Edje_Lua_Reg *cTransition[] = {
1206 &mClass,
1207 &mTransition,
1208 NULL // sentinel
1209};
1210
1211const luaL_Reg lTransition_get[] = {
1212 {NULL, NULL} // sentinel
1213};
1214
1215const luaL_Reg lTransition_set[] = {
1216 {NULL, NULL} // sentinel
1217};
1218
1219const luaL_Reg lTransition_fn[] = {
1220 {NULL, NULL} // sentinel
1221};
1222
1223const luaL_Reg lObject_get[];
1224
1225const luaL_Reg lObject_set[];
1226
1227const luaL_Reg lObject_fn[];
1228
1229const Edje_Lua_Reg mObject = {
1230 lNil,
1231 lObject_get,
1232 lObject_set,
1233 lObject_fn
1234};
1235
1236static void
1237_edje_lua_object_del_cb(void *data, __UNUSED__ Evas * e, Evas_Object * obj, __UNUSED__ void *event_info)
1238{
1239 //printf("_edje_lua_object_delete_cb\n");
1240 lua_State *L = data;
1241 _edje_lua_get_reg(L, obj);
1242 Edje_Lua_Evas_Object *udata = _edje_lua_checkudata(L, -1, &mObject);
1243 lua_pop(L, 1);
1244 _edje_lua_free_reg(L, udata); // created in EDJE_LUA_SCRIPT_FN_ADD
1245 _edje_lua_free_reg(L, obj); // created in EDJE_LUA_SCRIPT_FN_ADD
1246
1247 Edje_Lua_Ref *ref;
1248 EINA_LIST_FREE(udata->cb, ref)
1249 _edje_lua_free_ref(L, ref);
1250}
1251
1252static int
1253_edje_lua_object_fn_del(lua_State *L)
1254{
1255 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1256
1257 if (obj->eo)
1258 {
1259 evas_object_del(obj->eo);
1260 obj->eo = NULL;
1261 obj->ed = NULL;
1262 }
1263 return 0;
1264}
1265
1266static int
1267_edje_lua_object_fn_show(lua_State *L)
1268{
1269 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1270 evas_object_show(obj->eo);
1271 return 0;
1272}
1273
1274static int
1275_edje_lua_object_fn_hide(lua_State *L)
1276{
1277 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1278 evas_object_hide(obj->eo);
1279 return 0;
1280}
1281
1282static int
1283_edje_lua_object_fn_move(lua_State *L)
1284{
1285 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1286 //printf ("%i %i %i %i\n", obj->ed->x, obj->ed->y, luaL_checkint (L, 2), luaL_checkint (L, 3));
1287 evas_object_move(obj->eo,
1288 obj->ed->x + luaL_checkint(L, 2),
1289 obj->ed->y + luaL_checkint(L, 3));
1290 return 0;
1291}
1292
1293static int
1294_edje_lua_object_fn_resize(lua_State *L)
1295{
1296 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1297 evas_object_resize(obj->eo, luaL_checkint(L, 2), luaL_checkint(L, 3));
1298 return 0;
1299}
1300
1301static int
1302_edje_lua_object_fn_raise(lua_State *L)
1303{
1304 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1305 evas_object_raise(obj->eo);
1306 return 0;
1307}
1308
1309static int
1310_edje_lua_object_fn_lower(lua_State *L)
1311{
1312 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1313 evas_object_lower(obj->eo);
1314 return 0;
1315}
1316
1317static int
1318_edje_lua_object_fn_stack_above(lua_State *L)
1319{
1320 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1321 Edje_Lua_Evas_Object *tar = _edje_lua_checkudata(L, 2, &mObject);
1322 evas_object_stack_above(obj->eo, tar->eo);
1323 return 0;
1324}
1325
1326static int
1327_edje_lua_object_fn_stack_below(lua_State *L)
1328{
1329 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1330 Edje_Lua_Evas_Object *tar = _edje_lua_checkudata(L, 2, &mObject);
1331 evas_object_stack_below(obj->eo, tar->eo);
1332 return 0;
1333}
1334
1335static int
1336_edje_lua_object_fn_clip_unset(lua_State *L)
1337{
1338 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1339 evas_object_clip_unset(obj->eo);
1340 return 0;
1341}
1342
1343const luaL_Reg lObject_fn[] = {
1344 {"del", _edje_lua_object_fn_del},
1345 {"show", _edje_lua_object_fn_show},
1346 {"hide", _edje_lua_object_fn_hide},
1347 {"move", _edje_lua_object_fn_move},
1348 {"resize", _edje_lua_object_fn_resize},
1349 {"raise", _edje_lua_object_fn_raise},
1350 {"lower", _edje_lua_object_fn_lower},
1351 {"stack_above", _edje_lua_object_fn_stack_above},
1352 {"stack_below", _edje_lua_object_fn_stack_below},
1353 {"clip_unset", _edje_lua_object_fn_clip_unset},
1354 {NULL, NULL} // sentinel
1355};
1356
1357static int
1358_edje_lua_object_get_name(lua_State *L)
1359{
1360 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1361 lua_pushstring(L, evas_object_name_get(obj->eo));
1362 return 1;
1363}
1364
1365static int
1366_edje_lua_object_get_geometry(lua_State *L)
1367{
1368 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1369 int x, y, w, h;
1370 evas_object_geometry_get(obj->eo, &x, &y, &w, &h);
1371 lua_createtable(L, 4, 0);
1372 lua_pushnumber(L, x);
1373 lua_rawseti(L, -2, 1);
1374 lua_pushnumber(L, y);
1375 lua_rawseti(L, -2, 2);
1376 lua_pushnumber(L, w);
1377 lua_rawseti(L, -2, 3);
1378 lua_pushnumber(L, h);
1379 lua_rawseti(L, -2, 4);
1380 return 1;
1381}
1382
1383static int
1384_edje_lua_object_get_type(lua_State *L)
1385{
1386 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1387 lua_pushstring(L, evas_object_type_get(obj->eo));
1388 return 1;
1389}
1390
1391static int
1392_edje_lua_object_get_layer(lua_State *L)
1393{
1394 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1395 lua_pushnumber(L, evas_object_layer_get(obj->eo));
1396 return 1;
1397}
1398
1399static int
1400_edje_lua_object_get_above(lua_State *L)
1401{
1402 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1403 Evas_Object *above = evas_object_above_get(obj->eo);
1404 _edje_lua_get_reg(L, above);
1405 // TODO create object if it does not already exist?
1406 return 1;
1407}
1408
1409static int
1410_edje_lua_object_get_below(lua_State *L)
1411{
1412 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1413 Evas_Object *below = evas_object_below_get(obj->eo);
1414 _edje_lua_get_reg(L, below);
1415 // TODO create object if it does not already exist?
1416 return 1;
1417}
1418
1419static int
1420_edje_lua_object_get_size_hint_min(lua_State *L)
1421{
1422 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1423 int w, h;
1424 evas_object_size_hint_min_get(obj->eo, &w, &h);
1425 lua_createtable(L, 2, 0);
1426 lua_pushnumber(L, w);
1427 lua_rawseti(L, -2, 1);
1428 lua_pushnumber(L, h);
1429 lua_rawseti(L, -2, 2);
1430 return 1;
1431}
1432
1433static int
1434_edje_lua_object_get_size_hint_max(lua_State *L)
1435{
1436 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1437 int w, h;
1438 evas_object_size_hint_max_get(obj->eo, &w, &h);
1439 lua_createtable(L, 2, 0);
1440 lua_pushnumber(L, w);
1441 lua_rawseti(L, -2, 1);
1442 lua_pushnumber(L, h);
1443 lua_rawseti(L, -2, 2);
1444 return 1;
1445}
1446
1447static int
1448_edje_lua_object_get_size_hint_request(lua_State *L)
1449{
1450 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1451 int w, h;
1452 evas_object_size_hint_request_get(obj->eo, &w, &h);
1453 lua_createtable(L, 2, 0);
1454 lua_pushnumber(L, w);
1455 lua_rawseti(L, -2, 1);
1456 lua_pushnumber(L, h);
1457 lua_rawseti(L, -2, 2);
1458 return 1;
1459}
1460
1461static int
1462_edje_lua_object_get_size_hint_aspect(lua_State *L)
1463{
1464 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1465 Evas_Aspect_Control a;
1466 int w, h;
1467 evas_object_size_hint_aspect_get(obj->eo, &a, &w, &h);
1468 lua_createtable(L, 3, 0);
1469 lua_pushnumber(L, a);
1470 lua_rawseti(L, -2, 1);
1471 lua_pushnumber(L, w);
1472 lua_rawseti(L, -2, 2);
1473 lua_pushnumber(L, h);
1474 lua_rawseti(L, -2, 3);
1475 return 1;
1476}
1477
1478static int
1479_edje_lua_object_get_size_hint_align(lua_State *L)
1480{
1481 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1482 double w, h;
1483 evas_object_size_hint_align_get(obj->eo, &w, &h);
1484 lua_createtable(L, 2, 0);
1485 lua_pushnumber(L, w);
1486 lua_rawseti(L, -2, 1);
1487 lua_pushnumber(L, h);
1488 lua_rawseti(L, -2, 2);
1489 return 1;
1490}
1491
1492static int
1493_edje_lua_object_get_size_hint_weight(lua_State *L)
1494{
1495 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1496 double w, h;
1497 evas_object_size_hint_weight_get(obj->eo, &w, &h);
1498 lua_createtable(L, 2, 0);
1499 lua_pushnumber(L, w);
1500 lua_rawseti(L, -2, 1);
1501 lua_pushnumber(L, h);
1502 lua_rawseti(L, -2, 2);
1503 return 1;
1504}
1505
1506static int
1507_edje_lua_object_get_size_hint_padding(lua_State *L)
1508{
1509 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1510 int l, r, t, b;
1511 evas_object_size_hint_padding_get(obj->eo, &l, &r, &t, &b);
1512 lua_createtable(L, 4, 0);
1513 lua_pushnumber(L, l);
1514 lua_rawseti(L, -2, 1);
1515 lua_pushnumber(L, r);
1516 lua_rawseti(L, -2, 2);
1517 lua_pushnumber(L, t);
1518 lua_rawseti(L, -2, 3);
1519 lua_pushnumber(L, b);
1520 lua_rawseti(L, -2, 4);
1521 return 1;
1522}
1523
1524static int
1525_edje_lua_object_get_visible(lua_State *L)
1526{
1527 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1528 lua_pushboolean(L, evas_object_visible_get(obj->eo));
1529 return 1;
1530}
1531
1532static int
1533_edje_lua_object_get_render_op(lua_State *L)
1534{
1535 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1536 lua_pushnumber(L, evas_object_render_op_get(obj->eo));
1537 return 1;
1538}
1539
1540static int
1541_edje_lua_object_get_anti_alias(lua_State *L)
1542{
1543 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1544 lua_pushboolean(L, evas_object_anti_alias_get(obj->eo));
1545 return 1;
1546}
1547
1548static int
1549_edje_lua_object_get_scale(lua_State *L)
1550{
1551 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1552 lua_pushnumber(L, evas_object_scale_get(obj->eo));
1553 return 1;
1554}
1555
1556static int
1557_edje_lua_object_get_color(lua_State *L)
1558{
1559 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1560 int r, g, b, a;
1561 evas_object_color_get(obj->eo, &r, &g, &b, &a);
1562 lua_createtable(L, 4, 0);
1563 lua_pushnumber(L, r);
1564 lua_rawseti(L, -2, 1);
1565 lua_pushnumber(L, g);
1566 lua_rawseti(L, -2, 2);
1567 lua_pushnumber(L, b);
1568 lua_rawseti(L, -2, 3);
1569 lua_pushnumber(L, a);
1570 lua_rawseti(L, -2, 4);
1571 return 1;
1572}
1573
1574static int
1575_edje_lua_object_get_color_interpolation(lua_State *L)
1576{
1577 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1578 lua_pushnumber(L, evas_object_color_interpolation_get(obj->eo));
1579 return 1;
1580}
1581
1582static int
1583_edje_lua_object_get_clip(lua_State *L)
1584{
1585 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1586 Evas_Object *clip = evas_object_clip_get(obj->eo);
1587 _edje_lua_get_reg(L, clip);
1588 // TODO create object if it does not already exist?
1589 return 1;
1590}
1591
1592static int
1593_edje_lua_object_get_clipees(lua_State *L)
1594{
1595 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1596 Eina_List *clipees = (Eina_List *) evas_object_clipees_get(obj->eo);
1597 Eina_List *l;
1598 Evas_Object *clip;
1599 int i = 1;
1600 lua_createtable(L, eina_list_count(clipees), 0);
1601 EINA_LIST_FOREACH(clipees, l, clip)
1602 {
1603 _edje_lua_get_reg(L, clip);
1604 // TODO create object if it does not already exist?
1605 lua_rawseti(L, -2, i++);
1606 }
1607 return 1;
1608}
1609
1610static int
1611_edje_lua_object_get_evas(lua_State *L)
1612{
1613 //Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1614 lua_pushnil(L);
1615 // FIXME implement Evas class in the first place?
1616 return 1;
1617}
1618
1619static int
1620_edje_lua_object_get_pass_events(lua_State *L)
1621{
1622 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1623 lua_pushboolean(L, evas_object_pass_events_get(obj->eo));
1624 return 1;
1625}
1626
1627static int
1628_edje_lua_object_get_repeat_events(lua_State *L)
1629{
1630 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1631 lua_pushboolean(L, evas_object_repeat_events_get(obj->eo));
1632 return 1;
1633}
1634
1635static int
1636_edje_lua_object_get_propagate_events(lua_State *L)
1637{
1638 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1639 lua_pushboolean(L, evas_object_propagate_events_get(obj->eo));
1640 return 1;
1641}
1642
1643static int
1644_edje_lua_object_get_focus(lua_State *L)
1645{
1646 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1647 lua_pushboolean(L, evas_object_focus_get(obj->eo));
1648 return 1;
1649}
1650
1651static int
1652_edje_lua_object_get_pointer_mode(lua_State *L)
1653{
1654 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1655 lua_pushnumber(L, evas_object_pointer_mode_get(obj->eo));
1656 return 1;
1657}
1658
1659static int
1660_edje_lua_object_get_precise_is_inside(lua_State *L)
1661{
1662 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1663 lua_pushboolean(L, evas_object_precise_is_inside_get(obj->eo));
1664 return 1;
1665}
1666
1667static int
1668_edje_lua_object_get_mouse_events(lua_State *L)
1669{
1670 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1671 lua_pushboolean(L, obj->mouse_events);
1672 return 1;
1673}
1674
1675const luaL_Reg lObject_get[] = {
1676 {"name", _edje_lua_object_get_name},
1677 {"geometry", _edje_lua_object_get_geometry},
1678 {"type", _edje_lua_object_get_type},
1679 {"layer", _edje_lua_object_get_layer},
1680 {"above", _edje_lua_object_get_above},
1681 {"below", _edje_lua_object_get_below},
1682 {"size_hint_min", _edje_lua_object_get_size_hint_min},
1683 {"size_hint_max", _edje_lua_object_get_size_hint_max},
1684 {"size_hint_request", _edje_lua_object_get_size_hint_request},
1685 {"size_hint_aspect", _edje_lua_object_get_size_hint_aspect},
1686 {"size_hint_align", _edje_lua_object_get_size_hint_align},
1687 {"size_hint_weight", _edje_lua_object_get_size_hint_weight},
1688 {"size_hint_padding", _edje_lua_object_get_size_hint_padding},
1689 {"visible", _edje_lua_object_get_visible},
1690 {"render_op", _edje_lua_object_get_render_op},
1691 {"anti_alias", _edje_lua_object_get_anti_alias},
1692 {"scale", _edje_lua_object_get_scale},
1693 {"color", _edje_lua_object_get_color},
1694 {"color_interpolation", _edje_lua_object_get_color_interpolation},
1695 {"clip", _edje_lua_object_get_clip},
1696 {"clipees", _edje_lua_object_get_clipees},
1697 {"evas", _edje_lua_object_get_evas},
1698 {"pass_events", _edje_lua_object_get_pass_events},
1699 {"repeat_events", _edje_lua_object_get_repeat_events},
1700 {"propagate_events", _edje_lua_object_get_propagate_events},
1701 {"focus", _edje_lua_object_get_focus},
1702 {"pointer_mode", _edje_lua_object_get_pointer_mode},
1703 {"precise_is_inside", _edje_lua_object_get_precise_is_inside},
1704 {"mouse_events", _edje_lua_object_get_mouse_events},
1705 {NULL, NULL} // sentinel
1706};
1707
1708static int
1709_edje_lua_object_set_name(lua_State *L)
1710{
1711 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1712 evas_object_name_set(obj->eo, luaL_checkstring(L, 2));
1713 return 0;
1714}
1715
1716static int
1717_edje_lua_object_set_layer(lua_State *L)
1718{
1719 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1720 evas_object_layer_set(obj->eo, luaL_checkint(L, 2));
1721 return 0;
1722}
1723
1724static int
1725_edje_lua_object_set_size_hint_min(lua_State *L)
1726{
1727 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1728 luaL_checktype(L, 2, LUA_TTABLE);
1729 lua_rawgeti(L, 2, 1);
1730 lua_rawgeti(L, 2, 2);
1731 evas_object_size_hint_min_set(obj->eo,
1732 luaL_checkint(L, -2),
1733 luaL_checkint(L, -1));
1734 return 0;
1735}
1736
1737static int
1738_edje_lua_object_set_size_hint_max(lua_State *L)
1739{
1740 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1741 luaL_checktype(L, 2, LUA_TTABLE);
1742 lua_rawgeti(L, 2, 1);
1743 lua_rawgeti(L, 2, 2);
1744 evas_object_size_hint_max_set(obj->eo,
1745 luaL_checkint(L, -2),
1746 luaL_checkint(L, -1));
1747 return 0;
1748}
1749
1750static int
1751_edje_lua_object_set_size_hint_request(lua_State *L)
1752{
1753 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1754 luaL_checktype(L, 2, LUA_TTABLE);
1755 lua_rawgeti(L, 2, 1);
1756 lua_rawgeti(L, 2, 2);
1757 evas_object_size_hint_request_set(obj->eo,
1758 luaL_checkint(L, -2),
1759 luaL_checkint(L, -1));
1760 return 0;
1761}
1762
1763static int
1764_edje_lua_object_set_size_hint_aspect(lua_State *L)
1765{
1766 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1767 luaL_checktype(L, 2, LUA_TTABLE);
1768 lua_rawgeti(L, 2, 1);
1769 lua_rawgeti(L, 2, 2);
1770 lua_rawgeti(L, 2, 3);
1771 evas_object_size_hint_aspect_set(obj->eo,
1772 luaL_checkint(L, -3),
1773 luaL_checkint(L, -2),
1774 luaL_checkint(L, -1));
1775 return 0;
1776}
1777
1778static int
1779_edje_lua_object_set_size_hint_align(lua_State *L)
1780{
1781 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1782 luaL_checktype(L, 2, LUA_TTABLE);
1783 lua_rawgeti(L, 2, 1);
1784 lua_rawgeti(L, 2, 2);
1785 evas_object_size_hint_align_set(obj->eo,
1786 luaL_checknumber(L, -2),
1787 luaL_checknumber(L, -1));
1788 return 0;
1789}
1790
1791static int
1792_edje_lua_object_set_size_hint_weight(lua_State *L)
1793{
1794 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1795 luaL_checktype(L, 2, LUA_TTABLE);
1796 lua_rawgeti(L, 2, 1);
1797 lua_rawgeti(L, 2, 2);
1798 evas_object_size_hint_weight_set(obj->eo,
1799 luaL_checknumber(L, -2),
1800 luaL_checknumber(L, -1));
1801 return 0;
1802}
1803
1804static int
1805_edje_lua_object_set_size_hint_padding(lua_State *L)
1806{
1807 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1808 luaL_checktype(L, 2, LUA_TTABLE);
1809 lua_rawgeti(L, 2, 1);
1810 lua_rawgeti(L, 2, 2);
1811 lua_rawgeti(L, 2, 3);
1812 lua_rawgeti(L, 2, 4);
1813 evas_object_size_hint_padding_set(obj->eo,
1814 luaL_checknumber(L, -4),
1815 luaL_checknumber(L, -3),
1816 luaL_checknumber(L, -2),
1817 luaL_checknumber(L, -1));
1818 return 0;
1819}
1820
1821static int
1822_edje_lua_object_set_render_op(lua_State *L)
1823{
1824 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1825 evas_object_render_op_set(obj->eo, luaL_checkint(L, 2));
1826 return 0;
1827}
1828
1829static int
1830_edje_lua_object_set_anti_alias(lua_State *L)
1831{
1832 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1833 evas_object_anti_alias_set(obj->eo, lua_toboolean(L, 2));
1834 return 0;
1835}
1836
1837static int
1838_edje_lua_object_set_scale(lua_State *L)
1839{
1840 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1841 evas_object_scale_set(obj->eo, luaL_checknumber(L, 2));
1842 return 0;
1843}
1844
1845static int
1846_edje_lua_object_set_color(lua_State *L)
1847{
1848 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1849 luaL_checktype(L, 2, LUA_TTABLE);
1850 lua_rawgeti(L, 2, 1);
1851 lua_rawgeti(L, 2, 2);
1852 lua_rawgeti(L, 2, 3);
1853 lua_rawgeti(L, 2, 4);
1854 evas_object_color_set(obj->eo,
1855 luaL_checkint(L, -4),
1856 luaL_checkint(L, -3),
1857 luaL_checkint(L, -2),
1858 luaL_checkint(L, -1));
1859 return 0;
1860}
1861
1862static int
1863_edje_lua_object_set_color_interpolation(lua_State *L)
1864{
1865 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1866 evas_object_color_interpolation_set(obj->eo, luaL_checkint(L, 2));
1867 return 0;
1868}
1869
1870static int
1871_edje_lua_object_set_clip(lua_State *L)
1872{
1873 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1874 Edje_Lua_Evas_Object *clip = _edje_lua_checkudata(L, 2, &mObject);
1875 evas_object_clip_set(obj->eo, clip->eo);
1876 return 0;
1877}
1878
1879static int
1880_edje_lua_object_set_pass_events(lua_State *L)
1881{
1882 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1883 evas_object_pass_events_set(obj->eo, lua_toboolean(L, 2));
1884 return 0;
1885}
1886
1887static int
1888_edje_lua_object_set_repeat_events(lua_State *L)
1889{
1890 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1891 evas_object_repeat_events_set(obj->eo, lua_toboolean(L, 2));
1892 return 0;
1893}
1894
1895static int
1896_edje_lua_object_set_propagate_events(lua_State *L)
1897{
1898 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1899 evas_object_propagate_events_set(obj->eo, lua_toboolean(L, 2));
1900 return 0;
1901}
1902
1903static int
1904_edje_lua_object_set_focus(lua_State *L)
1905{
1906 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1907 evas_object_focus_set(obj->eo, lua_toboolean(L, 2));
1908 return 0;
1909}
1910
1911static int
1912_edje_lua_object_set_pointer_mode(lua_State *L)
1913{
1914 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1915 evas_object_pointer_mode_set(obj->eo, luaL_checkint(L, 2));
1916 return 0;
1917}
1918
1919static int
1920_edje_lua_object_set_precise_is_inside(lua_State *L)
1921{
1922 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
1923 evas_object_precise_is_inside_set(obj->eo, lua_toboolean(L, 2));
1924 return 0;
1925}
1926
1927#define OBJECT_CB_MACRO(KEY) \
1928 lua_State *L = data; \
1929 _edje_lua_get_reg(L, obj); \
1930 lua_getfield(L, -1, KEY); \
1931 if (lua_type(L, -1) != LUA_TFUNCTION) \
1932 { \
1933 lua_pop(L, 2); \
1934 return; \
1935 } \
1936 lua_insert(L, -2);
1937
1938static void
1939_edje_lua_object_cb_mouse_in(void *data, __UNUSED__ Evas * e, Evas_Object * obj,
1940 void *event_info)
1941{
1942 OBJECT_CB_MACRO("mouse_in");
1943 Evas_Event_Mouse_In * ev = event_info;
1944 int err_code;
1945
1946 lua_pushnumber(L, ev->output.x);
1947 lua_pushnumber(L, ev->output.y);
1948 lua_pushnumber(L, ev->canvas.x);
1949 lua_pushnumber(L, ev->canvas.y);
1950
1951 if ((err_code = lua_pcall(L, 5, 0, 0)))
1952 _edje_lua_error(L, err_code);
1953}
1954
1955static void
1956_edje_lua_object_cb_mouse_out(void *data, __UNUSED__ Evas * e, Evas_Object * obj,
1957 void *event_info)
1958{
1959 OBJECT_CB_MACRO("mouse_out");
1960 Evas_Event_Mouse_In * ev = event_info;
1961 int err_code;
1962
1963 lua_pushnumber(L, ev->output.x);
1964 lua_pushnumber(L, ev->output.y);
1965 lua_pushnumber(L, ev->canvas.x);
1966 lua_pushnumber(L, ev->canvas.y);
1967
1968 if ((err_code = lua_pcall(L, 5, 0, 0)))
1969 _edje_lua_error(L, err_code);
1970}
1971
1972static void
1973_edje_lua_object_cb_mouse_down(void *data, __UNUSED__ Evas * e, Evas_Object * obj,
1974 void *event_info)
1975{
1976 OBJECT_CB_MACRO("mouse_down");
1977 Evas_Event_Mouse_Down * ev = event_info;
1978 int err_code;
1979
1980 lua_pushnumber(L, ev->button);
1981 lua_pushnumber(L, ev->output.x);
1982 lua_pushnumber(L, ev->output.y);
1983 lua_pushnumber(L, ev->canvas.x);
1984 lua_pushnumber(L, ev->canvas.y);
1985
1986 if ((err_code = lua_pcall(L, 6, 0, 0)))
1987 _edje_lua_error(L, err_code);
1988}
1989
1990static void
1991_edje_lua_object_cb_mouse_up(void *data, __UNUSED__ Evas * e, Evas_Object * obj,
1992 void *event_info)
1993{
1994 OBJECT_CB_MACRO("mouse_up");
1995 Evas_Event_Mouse_Up * ev = event_info;
1996 int err_code;
1997
1998 lua_pushnumber(L, ev->button);
1999 lua_pushnumber(L, ev->output.x);
2000 lua_pushnumber(L, ev->output.y);
2001 lua_pushnumber(L, ev->canvas.x);
2002 lua_pushnumber(L, ev->canvas.y);
2003
2004 if ((err_code = lua_pcall(L, 6, 0, 0)))
2005 _edje_lua_error(L, err_code);
2006}
2007
2008static void
2009_edje_lua_object_cb_mouse_move(void *data, __UNUSED__ Evas * e, Evas_Object * obj,
2010 void *event_info)
2011{
2012 OBJECT_CB_MACRO("mouse_move");
2013 Evas_Event_Mouse_Move * ev = event_info;
2014 int err_code;
2015
2016 lua_pushnumber(L, ev->buttons);
2017 lua_pushnumber(L, ev->cur.output.x);
2018 lua_pushnumber(L, ev->cur.output.y);
2019 lua_pushnumber(L, ev->cur.canvas.x);
2020 lua_pushnumber(L, ev->cur.canvas.y);
2021
2022 if ((err_code = lua_pcall(L, 6, 0, 0)))
2023 _edje_lua_error(L, err_code);
2024}
2025
2026static void
2027_edje_lua_object_cb_mouse_wheel(void *data, __UNUSED__ Evas * e, Evas_Object * obj,
2028 void *event_info)
2029{
2030 OBJECT_CB_MACRO("mouse_wheel");
2031 Evas_Event_Mouse_Wheel * ev = event_info;
2032 int err_code;
2033
2034 lua_pushnumber(L, ev->z);
2035 lua_pushnumber(L, ev->output.x);
2036 lua_pushnumber(L, ev->output.y);
2037 lua_pushnumber(L, ev->canvas.x);
2038 lua_pushnumber(L, ev->canvas.y);
2039
2040 if ((err_code = lua_pcall(L, 6, 0, 0)))
2041 _edje_lua_error(L, err_code);
2042}
2043
2044static int
2045_edje_lua_object_set_mouse_events(lua_State *L)
2046{
2047 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
2048 obj->mouse_events = lua_toboolean(L, 2);
2049 if (obj->mouse_events)
2050 {
2051 // add all mouse events
2052 evas_object_event_callback_add(obj->eo, EVAS_CALLBACK_MOUSE_IN, _edje_lua_object_cb_mouse_in, L);
2053 evas_object_event_callback_add(obj->eo, EVAS_CALLBACK_MOUSE_OUT, _edje_lua_object_cb_mouse_out, L);
2054 evas_object_event_callback_add(obj->eo, EVAS_CALLBACK_MOUSE_DOWN, _edje_lua_object_cb_mouse_down, L);
2055 evas_object_event_callback_add(obj->eo, EVAS_CALLBACK_MOUSE_UP, _edje_lua_object_cb_mouse_up, L);
2056 evas_object_event_callback_add(obj->eo, EVAS_CALLBACK_MOUSE_MOVE, _edje_lua_object_cb_mouse_move, L);
2057 evas_object_event_callback_add(obj->eo, EVAS_CALLBACK_MOUSE_WHEEL, _edje_lua_object_cb_mouse_wheel, L);
2058 }
2059 else
2060 {
2061 // delete all mouse events
2062 evas_object_event_callback_del(obj->eo, EVAS_CALLBACK_MOUSE_IN, _edje_lua_object_cb_mouse_in);
2063 evas_object_event_callback_del(obj->eo, EVAS_CALLBACK_MOUSE_OUT, _edje_lua_object_cb_mouse_out);
2064 evas_object_event_callback_del(obj->eo, EVAS_CALLBACK_MOUSE_DOWN, _edje_lua_object_cb_mouse_down);
2065 evas_object_event_callback_del(obj->eo, EVAS_CALLBACK_MOUSE_UP, _edje_lua_object_cb_mouse_up);
2066 evas_object_event_callback_del(obj->eo, EVAS_CALLBACK_MOUSE_MOVE, _edje_lua_object_cb_mouse_move);
2067 evas_object_event_callback_del(obj->eo, EVAS_CALLBACK_MOUSE_WHEEL, _edje_lua_object_cb_mouse_wheel);
2068 }
2069 return 0;
2070}
2071
2072const luaL_Reg lObject_set[] = {
2073 {"name", _edje_lua_object_set_name},
2074 {"layer", _edje_lua_object_set_layer},
2075 {"size_hint_min", _edje_lua_object_set_size_hint_min},
2076 {"size_hint_max", _edje_lua_object_set_size_hint_max},
2077 {"size_hint_request", _edje_lua_object_set_size_hint_request},
2078 {"size_hint_aspect", _edje_lua_object_set_size_hint_aspect},
2079 {"size_hint_align", _edje_lua_object_set_size_hint_align},
2080 {"size_hint_weight", _edje_lua_object_set_size_hint_weight},
2081 {"size_hint_padding", _edje_lua_object_set_size_hint_padding},
2082 {"render_op", _edje_lua_object_set_render_op},
2083 {"anti_alias", _edje_lua_object_set_anti_alias},
2084 {"scale", _edje_lua_object_set_scale},
2085 {"color", _edje_lua_object_set_color},
2086 {"color_interpolation", _edje_lua_object_set_color_interpolation},
2087 {"clip", _edje_lua_object_set_clip},
2088 {"pass_events", _edje_lua_object_set_pass_events},
2089 {"repeat_events", _edje_lua_object_set_repeat_events},
2090 {"propagate_events", _edje_lua_object_set_propagate_events},
2091 {"focus", _edje_lua_object_set_focus},
2092 {"pointer_mode", _edje_lua_object_get_pointer_mode},
2093 {"precise_is_inside", _edje_lua_object_get_precise_is_inside},
2094 {"mouse_events", _edje_lua_object_set_mouse_events},
2095 {NULL, NULL} // sentinel
2096};
2097
2098const Edje_Lua_Reg *cRectangle[] = {
2099 &mClass,
2100 &mObject,
2101 NULL // sentinel
2102};
2103
2104const luaL_Reg lImage_get[];
2105
2106const luaL_Reg lImage_set[];
2107
2108const Edje_Lua_Reg mImage = {
2109 lNil,
2110 lImage_get,
2111 lImage_set,
2112 lNil
2113};
2114
2115const Edje_Lua_Reg *cImage[] = {
2116 &mClass,
2117 &mObject,
2118 &mImage,
2119 NULL // sentinel
2120};
2121
2122static int
2123_edje_lua_image_get_size(lua_State *L)
2124{
2125 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mImage);
2126 int w, h;
2127 evas_object_image_size_get(obj->eo, &w, &h);
2128 lua_createtable(L, 2, 0);
2129 lua_pushnumber(L, w);
2130 lua_rawseti(L, -2, 1);
2131 lua_pushnumber(L, h);
2132 lua_rawseti(L, -2, 2);
2133 return 1;
2134};
2135
2136const luaL_Reg lImage_get[] = {
2137 {"size", _edje_lua_image_get_size},
2138 {NULL, NULL} // sentinel
2139};
2140
2141static int
2142_edje_lua_image_set_file(lua_State *L)
2143{
2144 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mImage);
2145 int id = edje_edit_image_id_get(obj->ed->obj, luaL_checkstring(L, 2));
2146 char buf[256];
2147 sprintf(buf, "edje/images/%i", id);
2148 evas_object_image_file_set(obj->eo, obj->ed->path, buf);
2149 return 0;
2150}
2151
2152static int
2153_edje_lua_image_set_fill(lua_State *L)
2154{
2155 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mImage);
2156 luaL_checktype(L, 2, LUA_TTABLE);
2157 lua_rawgeti(L, 2, 1);
2158 lua_rawgeti(L, 2, 2);
2159 lua_rawgeti(L, 2, 3);
2160 lua_rawgeti(L, 2, 4);
2161 evas_object_image_fill_set(obj->eo,
2162 luaL_checkint(L, -4),
2163 luaL_checkint(L, -3),
2164 luaL_checkint(L, -2), luaL_checkint(L, -1));
2165 return 0;
2166}
2167
2168static int
2169_edje_lua_image_set_fill_transform(lua_State *L)
2170{
2171 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mImage);
2172 Edje_Lua_Transform *tar = _edje_lua_checkudata(L, 2, &mTransform);
2173 evas_object_image_fill_transform_set(obj->eo, &(tar->et));
2174 return 0;
2175}
2176
2177static int
2178_edje_lua_image_set_alpha(lua_State *L)
2179{
2180 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject);
2181 evas_object_image_alpha_set(obj->eo, lua_toboolean(L, 2));
2182 return 0;
2183}
2184
2185const luaL_Reg lImage_set[] = {
2186 {"file", _edje_lua_image_set_file},
2187 {"fill", _edje_lua_image_set_fill},
2188 {"fill_transform", _edje_lua_image_set_fill_transform},
2189 {"alpha", _edje_lua_image_set_alpha},
2190 {NULL, NULL} // sentinel
2191};
2192
2193const luaL_Reg lLine_get[];
2194const luaL_Reg lLine_set[];
2195
2196const Edje_Lua_Reg mLine = {
2197 lNil,
2198 lLine_get,
2199 lLine_set,
2200 lNil
2201};
2202
2203const Edje_Lua_Reg *cLine[] = {
2204 &mClass,
2205 &mObject,
2206 &mLine,
2207 NULL // sentinel
2208};
2209
2210static int
2211_edje_lua_line_get_xy(lua_State *L)
2212{
2213 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mLine);
2214 int x1, y1, x2, y2;
2215 evas_object_line_xy_get(obj->eo, &x1, &y1, &x2, &y2);
2216 lua_createtable(L, 4, 0);
2217 lua_pushnumber(L, x1); lua_rawseti(L, -2, 1);
2218 lua_pushnumber(L, y1); lua_rawseti(L, -2, 2);
2219 lua_pushnumber(L, x2); lua_rawseti(L, -2, 3);
2220 lua_pushnumber(L, y2); lua_rawseti(L, -2, 4);
2221 return 1;
2222}
2223
2224const luaL_Reg lLine_get[] = {
2225 {"xy", _edje_lua_line_get_xy},
2226 {NULL, NULL} // sentinel
2227};
2228
2229static int
2230_edje_lua_line_set_xy(lua_State *L)
2231{
2232 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mLine);
2233 luaL_checktype(L, 2, LUA_TTABLE);
2234 lua_rawgeti(L, 2, 1);
2235 lua_rawgeti(L, 2, 2);
2236 lua_rawgeti(L, 2, 3);
2237 lua_rawgeti(L, 2, 4);
2238 evas_object_line_xy_set(obj->eo,
2239 luaL_checkint(L, -4),
2240 luaL_checkint(L, -3),
2241 luaL_checkint(L, -2),
2242 luaL_checkint(L, -1));
2243 return 0;
2244}
2245
2246const luaL_Reg lLine_set[] = {
2247 {"xy", _edje_lua_line_set_xy},
2248 {NULL, NULL} // sentinel
2249};
2250
2251const luaL_Reg lPolygon_fn[];
2252
2253const Edje_Lua_Reg mPolygon = {
2254 lNil,
2255 lNil,
2256 lNil,
2257 lPolygon_fn
2258};
2259
2260const Edje_Lua_Reg *cPolygon[] = {
2261 &mClass,
2262 &mObject,
2263 &mPolygon,
2264 NULL // sentinel
2265};
2266
2267static int
2268_edje_lua_polygon_fn_point_add(lua_State *L)
2269{
2270 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mPolygon);
2271 evas_object_polygon_point_add(obj->eo,
2272 luaL_checknumber(L, 2),
2273 luaL_checknumber(L, 3));
2274 return 0;
2275}
2276
2277static int
2278_edje_lua_polygon_fn_points_clear(lua_State *L)
2279{
2280 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mPolygon);
2281 evas_object_polygon_points_clear(obj->eo);
2282 return 0;
2283}
2284
2285const luaL_Reg lPolygon_fn[] = {
2286 {"point_add", _edje_lua_polygon_fn_point_add},
2287 {"points_clear", _edje_lua_polygon_fn_points_clear},
2288 {NULL, NULL} // sentinel
2289};
2290
2291const luaL_Reg lTable_get[];
2292
2293const luaL_Reg lTable_set[];
2294
2295const luaL_Reg lTable_fn[];
2296
2297const Edje_Lua_Reg mTable = {
2298 lNil,
2299 lTable_get,
2300 lTable_set,
2301 lTable_fn
2302};
2303
2304const Edje_Lua_Reg *cTable[] = {
2305 &mClass,
2306 &mObject,
2307 &mTable,
2308 NULL // sentinel
2309};
2310
2311static int
2312_edje_lua_table_get_homogeneous(lua_State *L)
2313{
2314 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mTable);
2315 lua_pushnumber(L, evas_object_table_homogeneous_get(obj->eo));
2316 return 1;
2317}
2318
2319static int
2320_edje_lua_table_get_padding(lua_State *L)
2321{
2322 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mTable);
2323 int x, y;
2324 evas_object_table_padding_get(obj->eo, &x, &y);
2325 lua_createtable(L, 2, 0);
2326 lua_pushnumber(L, x);
2327 lua_rawseti(L, -2, 1);
2328 lua_pushnumber(L, y);
2329 lua_rawseti(L, -2, 2);
2330 return 1;
2331}
2332
2333static int
2334_edje_lua_table_get_align(lua_State *L)
2335{
2336 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mTable);
2337 double x, y;
2338 evas_object_table_align_get(obj->eo, &x, &y);
2339 lua_createtable(L, 2, 0);
2340 lua_pushnumber(L, x);
2341 lua_rawseti(L, -2, 1);
2342 lua_pushnumber(L, y);
2343 lua_rawseti(L, -2, 2);
2344 return 1;
2345}
2346
2347static int
2348_edje_lua_table_get_col_row_size(lua_State *L)
2349{
2350 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mTable);
2351 int x, y;
2352 evas_object_table_col_row_size_get(obj->eo, &x, &y);
2353 lua_createtable(L, 2, 0);
2354 lua_pushnumber(L, x);
2355 lua_rawseti(L, -2, 1);
2356 lua_pushnumber(L, y);
2357 lua_rawseti(L, -2, 2);
2358 return 1;
2359}
2360
2361static int
2362_edje_lua_table_get_children(lua_State *L)
2363{
2364 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mTable);
2365 Eina_List *children = (Eina_List *) evas_object_table_children_get(obj->eo);
2366 Eina_List *l;
2367 Evas_Object *child;
2368 int i = 1;
2369 lua_createtable(L, eina_list_count(children), 0);
2370 EINA_LIST_FOREACH(children, l, child)
2371 {
2372 _edje_lua_get_reg(L, child);
2373 // TODO create object if it does not already exist?
2374 lua_rawseti(L, -2, i++);
2375 }
2376 return 1;
2377}
2378
2379const luaL_Reg lTable_get[] = {
2380 {"homogeneous", _edje_lua_table_get_homogeneous},
2381 {"padding", _edje_lua_table_get_padding},
2382 {"align", _edje_lua_table_get_align},
2383 {"col_row_size", _edje_lua_table_get_col_row_size},
2384 {"children", _edje_lua_table_get_children},
2385 {NULL, NULL} // sentinel
2386};
2387
2388static int
2389_edje_lua_table_set_homogeneous(lua_State *L)
2390{
2391 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mTable);
2392 evas_object_table_homogeneous_set(obj->eo,
2393 luaL_checkint(L, 2));
2394 return 0;
2395}
2396
2397static int
2398_edje_lua_table_set_padding(lua_State *L)
2399{
2400 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mTable);
2401 luaL_checktype(L, 2, LUA_TTABLE);
2402 lua_rawgeti(L, 2, 1);
2403 lua_rawgeti(L, 2, 2);
2404 evas_object_table_padding_set(obj->eo,
2405 luaL_checkint(L, -2),
2406 luaL_checkint(L, -1));
2407 return 0;
2408}
2409
2410static int
2411_edje_lua_table_set_align(lua_State *L)
2412{
2413 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mTable);
2414 luaL_checktype(L, 2, LUA_TTABLE);
2415 lua_rawgeti(L, 2, 1);
2416 lua_rawgeti(L, 2, 2);
2417 evas_object_table_align_set(obj->eo,
2418 luaL_checknumber(L, -2),
2419 luaL_checknumber(L, -1));
2420 return 0;
2421}
2422
2423const luaL_Reg lTable_set[] = {
2424 {"homogeneous", _edje_lua_table_set_homogeneous},
2425 {"padding", _edje_lua_table_set_padding},
2426 {"align", _edje_lua_table_set_align},
2427 {NULL, NULL} // sentinel
2428};
2429
2430static int
2431_edje_lua_table_fn_pack(lua_State *L)
2432{
2433 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mTable);
2434 Edje_Lua_Evas_Object *tar = _edje_lua_checkudata(L, 2, &mObject);
2435 lua_pushboolean(L,
2436 evas_object_table_pack(obj->eo, tar->eo,
2437 luaL_checkint(L, 3),
2438 luaL_checkint(L, 4),
2439 luaL_checkint(L, 5),
2440 luaL_checkint(L, 6)));
2441 return 1;
2442}
2443
2444static int
2445_edje_lua_table_fn_unpack(lua_State *L)
2446{
2447 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mTable);
2448 Edje_Lua_Evas_Object *tar = _edje_lua_checkudata(L, 2, &mObject);
2449 lua_pushboolean(L,
2450 evas_object_table_unpack(obj->eo, tar->eo));
2451 return 1;
2452}
2453
2454static int
2455_edje_lua_table_fn_clear(lua_State *L)
2456{
2457 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mTable);
2458 evas_object_table_clear(obj->eo, lua_toboolean(L, 2));
2459 return 0;
2460}
2461
2462const luaL_Reg lTable_fn[] = {
2463 {"pack", _edje_lua_table_fn_pack},
2464 {"unpack", _edje_lua_table_fn_unpack},
2465 {"clear", _edje_lua_table_fn_clear},
2466 {NULL, NULL} // sentinel
2467};
2468
2469const luaL_Reg lDescription_get[];
2470
2471const luaL_Reg lDescription_set[];
2472
2473const Edje_Lua_Reg mDescription = {
2474 lNil,
2475 lDescription_get,
2476 lDescription_set,
2477 lNil
2478};
2479
2480const Edje_Lua_Reg *cDescription[] = {
2481 &mClass,
2482 &mObject,
2483 &mDescription,
2484 NULL // sentinel
2485};
2486
2487static int
2488_edje_lua_description_get_alignment(lua_State *L)
2489{
2490 Edje_Lua_Edje_Part_Description *obj =
2491 _edje_lua_checkudata(L, 1, &mDescription);
2492 if (!obj->rp->custom) return 0;
2493 lua_createtable(L, 2, 0);
2494 lua_pushnumber(L, TO_DOUBLE(obj->rp->custom->description->align.x));
2495 lua_rawseti(L, -2, 1);
2496 lua_pushnumber(L, TO_DOUBLE(obj->rp->custom->description->align.y));
2497 lua_rawseti(L, -2, 1);
2498 return 1;
2499}
2500
2501static int
2502_edje_lua_description_get_min(lua_State *L)
2503{
2504 Edje_Lua_Edje_Part_Description *obj =
2505 _edje_lua_checkudata(L, 1, &mDescription);
2506 if (!obj->rp->custom) return 0;
2507 lua_createtable(L, 2, 0);
2508 lua_pushnumber(L, obj->rp->custom->description->min.w);
2509 lua_rawseti(L, -2, 1);
2510 lua_pushnumber(L, obj->rp->custom->description->min.h);
2511 lua_rawseti(L, -2, 1);
2512 return 1;
2513}
2514
2515static int
2516_edje_lua_description_get_max(lua_State *L)
2517{
2518 Edje_Lua_Edje_Part_Description *obj =
2519 _edje_lua_checkudata(L, 1, &mDescription);
2520 if (!obj->rp->custom) return 0;
2521 lua_createtable(L, 2, 0);
2522 lua_pushnumber(L, obj->rp->custom->description->max.w);
2523 lua_rawseti(L, -2, 1);
2524 lua_pushnumber(L, obj->rp->custom->description->max.h);
2525 lua_rawseti(L, -2, 1);
2526 return 1;
2527}
2528
2529static int
2530_edje_lua_description_get_step(lua_State *L)
2531{
2532 Edje_Lua_Edje_Part_Description *obj =
2533 _edje_lua_checkudata(L, 1, &mDescription);
2534 if (!obj->rp->custom) return 0;
2535 lua_createtable(L, 2, 0);
2536 lua_pushnumber(L, obj->rp->custom->description->step.x);
2537 lua_rawseti(L, -2, 1);
2538 lua_pushnumber(L, obj->rp->custom->description->step.y);
2539 lua_rawseti(L, -2, 1);
2540 return 1;
2541}
2542
2543static int
2544_edje_lua_description_get_aspect(lua_State *L)
2545{
2546 Edje_Lua_Edje_Part_Description *obj =
2547 _edje_lua_checkudata(L, 1, &mDescription);
2548 if (!obj->rp->custom) return 0;
2549 lua_createtable(L, 2, 0);
2550 lua_pushnumber(L, TO_DOUBLE(obj->rp->custom->description->aspect.min));
2551 lua_rawseti(L, -2, 1);
2552 lua_pushnumber(L, TO_DOUBLE(obj->rp->custom->description->aspect.max));
2553 lua_rawseti(L, -2, 1);
2554 return 1;
2555}
2556
2557static int
2558_edje_lua_description_get_aspect_pref(lua_State *L)
2559{
2560 Edje_Lua_Edje_Part_Description *obj =
2561 _edje_lua_checkudata(L, 1, &mDescription);
2562 if (!obj->rp->custom) return 0;
2563 lua_pushnumber(L, obj->rp->custom->description->aspect.prefer);
2564 return 1;
2565}
2566
2567static int
2568_edje_lua_description_get_color(lua_State *L)
2569{
2570 Edje_Lua_Edje_Part_Description *obj =
2571 _edje_lua_checkudata(L, 1, &mDescription);
2572 /* check whether this part has a "custom" state */
2573 if (!obj->rp->custom) return 0;
2574 lua_createtable(L, 4, 0);
2575 lua_pushnumber(L, obj->rp->custom->description->color.r);
2576 lua_rawseti(L, -2, 1);
2577 lua_pushnumber(L, obj->rp->custom->description->color.g);
2578 lua_rawseti(L, -2, 2);
2579 lua_pushnumber(L, obj->rp->custom->description->color.b);
2580 lua_rawseti(L, -2, 3);
2581 lua_pushnumber(L, obj->rp->custom->description->color.a);
2582 lua_rawseti(L, -2, 4);
2583 return 1;
2584}
2585
2586static int
2587_edje_lua_description_get_color2(lua_State *L)
2588{
2589 Edje_Lua_Edje_Part_Description *obj =
2590 _edje_lua_checkudata(L, 1, &mDescription);
2591 if (!obj->rp->custom) return 0;
2592 lua_createtable(L, 4, 0);
2593 lua_pushnumber(L, obj->rp->custom->description->color2.r);
2594 lua_rawseti(L, -2, 1);
2595 lua_pushnumber(L, obj->rp->custom->description->color2.g);
2596 lua_rawseti(L, -2, 2);
2597 lua_pushnumber(L, obj->rp->custom->description->color2.b);
2598 lua_rawseti(L, -2, 3);
2599 lua_pushnumber(L, obj->rp->custom->description->color2.a);
2600 lua_rawseti(L, -2, 4);
2601 return 1;
2602}
2603
2604static int
2605_edje_lua_description_get_color3(lua_State *L)
2606{
2607 Edje_Lua_Edje_Part_Description *obj =
2608 _edje_lua_checkudata(L, 1, &mDescription);
2609 if (!obj->rp->custom) return 0;
2610 lua_createtable(L, 4, 0);
2611 lua_pushnumber(L, obj->rp->custom->description->color3.r);
2612 lua_rawseti(L, -2, 1);
2613 lua_pushnumber(L, obj->rp->custom->description->color3.g);
2614 lua_rawseti(L, -2, 2);
2615 lua_pushnumber(L, obj->rp->custom->description->color3.b);
2616 lua_rawseti(L, -2, 3);
2617 lua_pushnumber(L, obj->rp->custom->description->color3.a);
2618 lua_rawseti(L, -2, 4);
2619 return 1;
2620}
2621
2622static int
2623_edje_lua_description_get_color_class(lua_State *L)
2624{
2625 Edje_Lua_Edje_Part_Description *obj =
2626 _edje_lua_checkudata(L, 1, &mDescription);
2627 if (!obj->rp->custom) return 0;
2628 lua_pushstring(L, obj->rp->custom->description->color_class);
2629 return 1;
2630}
2631
2632static int
2633_edje_lua_description_get_rel1(lua_State *L)
2634{
2635 Edje_Lua_Edje_Part_Description *obj =
2636 _edje_lua_checkudata(L, 1, &mDescription);
2637 if (!obj->rp->custom) return 0;
2638 lua_createtable(L, 2, 0);
2639 lua_pushnumber(L, TO_DOUBLE(obj->rp->custom->description->rel1.relative_x));
2640 lua_rawseti(L, -2, 1);
2641 lua_pushnumber(L, TO_DOUBLE(obj->rp->custom->description->rel1.relative_y));
2642 lua_rawseti(L, -2, 2);
2643 return 1;
2644}
2645
2646static int
2647_edje_lua_description_get_rel1_to(lua_State *L)
2648{
2649 Edje_Lua_Edje_Part_Description *obj =
2650 _edje_lua_checkudata(L, 1, &mDescription);
2651 if (!obj->rp->custom) return 0;
2652 lua_createtable(L, 2, 0);
2653 lua_pushnumber(L, obj->rp->custom->description->rel1.id_x);
2654 lua_rawseti(L, -2, 1);
2655 lua_pushnumber(L, obj->rp->custom->description->rel1.id_y);
2656 lua_rawseti(L, -2, 2);
2657 return 1;
2658}
2659
2660static int
2661_edje_lua_description_get_rel1_offset(lua_State *L)
2662{
2663 Edje_Lua_Edje_Part_Description *obj =
2664 _edje_lua_checkudata(L, 1, &mDescription);
2665 if (!obj->rp->custom) return 0;
2666 lua_createtable(L, 2, 0);
2667 lua_pushnumber(L, obj->rp->custom->description->rel1.offset_x);
2668 lua_rawseti(L, -2, 1);
2669 lua_pushnumber(L, obj->rp->custom->description->rel1.offset_y);
2670 lua_rawseti(L, -2, 2);
2671 return 1;
2672}
2673
2674static int
2675_edje_lua_description_get_rel2(lua_State *L)
2676{
2677 Edje_Lua_Edje_Part_Description *obj =
2678 _edje_lua_checkudata(L, 1, &mDescription);
2679 if (!obj->rp->custom) return 0;
2680 lua_createtable(L, 2, 0);
2681 lua_pushnumber(L, TO_DOUBLE(obj->rp->custom->description->rel2.relative_x));
2682 lua_rawseti(L, -2, 1);
2683 lua_pushnumber(L, TO_DOUBLE(obj->rp->custom->description->rel2.relative_y));
2684 lua_rawseti(L, -2, 2);
2685 return 1;
2686}
2687
2688static int
2689_edje_lua_description_get_rel2_to(lua_State *L)
2690{
2691 Edje_Lua_Edje_Part_Description *obj =
2692 _edje_lua_checkudata(L, 1, &mDescription);
2693 if (!obj->rp->custom) return 0;
2694 lua_createtable(L, 2, 0);
2695 lua_pushnumber(L, obj->rp->custom->description->rel2.id_x);
2696 lua_rawseti(L, -2, 1);
2697 lua_pushnumber(L, obj->rp->custom->description->rel2.id_y);
2698 lua_rawseti(L, -2, 2);
2699 return 1;
2700}
2701
2702static int
2703_edje_lua_description_get_rel2_offset(lua_State *L)
2704{
2705 Edje_Lua_Edje_Part_Description *obj =
2706 _edje_lua_checkudata(L, 1, &mDescription);
2707 if (!obj->rp->custom) return 0;
2708 lua_createtable(L, 2, 0);
2709 lua_pushnumber(L, obj->rp->custom->description->rel2.offset_x);
2710 lua_rawseti(L, -2, 1);
2711 lua_pushnumber(L, obj->rp->custom->description->rel2.offset_y);
2712 lua_rawseti(L, -2, 2);
2713 return 1;
2714}
2715
2716static int
2717_edje_lua_description_get_image(lua_State *L)
2718{
2719 Edje_Lua_Edje_Part_Description *obj =
2720 _edje_lua_checkudata(L, 1, &mDescription);
2721 if (!obj->rp->custom) return 0;
2722 if ((obj->rp->part->type != EDJE_PART_TYPE_IMAGE))
2723 return 0;
2724 // TODO
2725 return 0;
2726}
2727
2728static int
2729_edje_lua_description_get_border(lua_State *L)
2730{
2731 Edje_Lua_Edje_Part_Description *obj =
2732 _edje_lua_checkudata(L, 1, &mDescription);
2733 if ((obj->rp->part->type != EDJE_PART_TYPE_IMAGE))
2734 return 0;
2735 if (!obj->rp->custom) return 0;
2736 lua_createtable(L, 4, 0);
2737 lua_pushnumber(L, obj->rp->custom->description->border.l);
2738 lua_rawseti(L, -2, 1);
2739 lua_pushnumber(L, obj->rp->custom->description->border.r);
2740 lua_rawseti(L, -2, 2);
2741 lua_pushnumber(L, obj->rp->custom->description->border.t);
2742 lua_rawseti(L, -2, 3);
2743 lua_pushnumber(L, obj->rp->custom->description->border.b);
2744 lua_rawseti(L, -2, 4);
2745 return 1;
2746}
2747
2748static int
2749_edje_lua_description_get_fill_smooth(lua_State *L)
2750{
2751 Edje_Lua_Edje_Part_Description *obj =
2752 _edje_lua_checkudata(L, 1, &mDescription);
2753 if ((obj->rp->part->type != EDJE_PART_TYPE_IMAGE))
2754 return 0;
2755 if (!obj->rp->custom) return 0;
2756 lua_pushboolean(L, obj->rp->custom->description->fill.smooth);
2757 return 1;
2758}
2759
2760static int
2761_edje_lua_description_get_fill_pos(lua_State *L)
2762{
2763 Edje_Lua_Edje_Part_Description *obj =
2764 _edje_lua_checkudata(L, 1, &mDescription);
2765 if ((obj->rp->part->type != EDJE_PART_TYPE_IMAGE))
2766 return 0;
2767 if (!obj->rp->custom) return 0;
2768 lua_createtable(L, 4, 0);
2769 lua_pushnumber(L, TO_DOUBLE(obj->rp->custom->description->fill.pos_rel_x));
2770 lua_rawseti(L, -2, 1);
2771 lua_pushnumber(L, TO_DOUBLE(obj->rp->custom->description->fill.pos_rel_y));
2772 lua_rawseti(L, -2, 2);
2773 lua_pushnumber(L, obj->rp->custom->description->fill.pos_abs_x);
2774 lua_rawseti(L, -2, 3);
2775 lua_pushnumber(L, obj->rp->custom->description->fill.pos_abs_y);
2776 lua_rawseti(L, -2, 4);
2777 return 1;
2778}
2779
2780static int
2781_edje_lua_description_get_fill_size(lua_State *L)
2782{
2783 Edje_Lua_Edje_Part_Description *obj =
2784 _edje_lua_checkudata(L, 1, &mDescription);
2785 if ((obj->rp->part->type != EDJE_PART_TYPE_IMAGE))
2786 return 0;
2787 if (!obj->rp->custom) return 0;
2788 lua_createtable(L, 4, 0);
2789 lua_pushnumber(L, TO_DOUBLE(obj->rp->custom->description->fill.rel_x));
2790 lua_rawseti(L, -2, 1);
2791 lua_pushnumber(L, TO_DOUBLE(obj->rp->custom->description->fill.rel_y));
2792 lua_rawseti(L, -2, 2);
2793 lua_pushnumber(L, obj->rp->custom->description->fill.abs_x);
2794 lua_rawseti(L, -2, 3);
2795 lua_pushnumber(L, obj->rp->custom->description->fill.abs_y);
2796 lua_rawseti(L, -2, 4);
2797 return 1;
2798}
2799
2800static int
2801_edje_lua_description_get_text(lua_State *L)
2802{
2803 Edje_Lua_Edje_Part_Description *obj =
2804 _edje_lua_checkudata(L, 1, &mDescription);
2805 if ((obj->rp->part->type != EDJE_PART_TYPE_TEXT)
2806 && (obj->rp->part->type != EDJE_PART_TYPE_TEXTBLOCK))
2807 return 0;
2808 if (!obj->rp->custom) return 0;
2809 lua_pushstring(L, obj->rp->custom->description->text.text);
2810 return 1;
2811}
2812
2813static int
2814_edje_lua_description_get_text_class(lua_State *L)
2815{
2816 Edje_Lua_Edje_Part_Description *obj =
2817 _edje_lua_checkudata(L, 1, &mDescription);
2818 if ((obj->rp->part->type != EDJE_PART_TYPE_TEXT)
2819 && (obj->rp->part->type != EDJE_PART_TYPE_TEXTBLOCK))
2820 return 0;
2821 if (!obj->rp->custom) return 0;
2822 lua_pushstring(L, obj->rp->custom->description->text.text_class);
2823 return 1;
2824}
2825
2826static int
2827_edje_lua_description_get_text_font(lua_State *L)
2828{
2829 Edje_Lua_Edje_Part_Description *obj =
2830 _edje_lua_checkudata(L, 1, &mDescription);
2831 if ((obj->rp->part->type != EDJE_PART_TYPE_TEXT))
2832 return 0;
2833 if (!obj->rp->custom) return 0;
2834 lua_pushstring(L, obj->rp->custom->description->text.text_class);
2835 return 1;
2836}
2837
2838static int
2839_edje_lua_description_get_text_style(lua_State *L)
2840{
2841 Edje_Lua_Edje_Part_Description *obj =
2842 _edje_lua_checkudata(L, 1, &mDescription);
2843 if ((obj->rp->part->type != EDJE_PART_TYPE_TEXTBLOCK))
2844 return 0;
2845 if (!obj->rp->custom) return 0;
2846 lua_pushstring(L, obj->rp->custom->description->text.style);
2847 return 1;
2848}
2849
2850static int
2851_edje_lua_description_get_text_size(lua_State *L)
2852{
2853 Edje_Lua_Edje_Part_Description *obj =
2854 _edje_lua_checkudata(L, 1, &mDescription);
2855 if ((obj->rp->part->type != EDJE_PART_TYPE_TEXT))
2856 return 0;
2857 if (!obj->rp->custom) return 0;
2858 lua_pushnumber(L, obj->rp->custom->description->text.size);
2859 return 1;
2860}
2861
2862static int
2863_edje_lua_description_get_text_fit(lua_State *L)
2864{
2865 Edje_Lua_Edje_Part_Description *obj =
2866 _edje_lua_checkudata(L, 1, &mDescription);
2867 if ((obj->rp->part->type != EDJE_PART_TYPE_TEXT))
2868 return 0;
2869 if (!obj->rp->custom) return 0;
2870 lua_createtable(L, 2, 0);
2871 lua_pushboolean(L, obj->rp->custom->description->text.fit_x);
2872 lua_rawseti(L, -2, 1);
2873 lua_pushboolean(L, obj->rp->custom->description->text.fit_y);
2874 lua_rawseti(L, -2, 2);
2875 return 1;
2876}
2877
2878static int
2879_edje_lua_description_get_text_min(lua_State *L)
2880{
2881 Edje_Lua_Edje_Part_Description *obj =
2882 _edje_lua_checkudata(L, 1, &mDescription);
2883 if ((obj->rp->part->type != EDJE_PART_TYPE_TEXT)
2884 && (obj->rp->part->type != EDJE_PART_TYPE_TEXTBLOCK))
2885 return 0;
2886 if (!obj->rp->custom) return 0;
2887 lua_createtable(L, 2, 0);
2888 lua_pushnumber(L, obj->rp->custom->description->text.min_x);
2889 lua_rawseti(L, -2, 1);
2890 lua_pushnumber(L, obj->rp->custom->description->text.min_y);
2891 lua_rawseti(L, -2, 2);
2892 return 1;
2893}
2894
2895static int
2896_edje_lua_description_get_text_max(lua_State *L)
2897{
2898 Edje_Lua_Edje_Part_Description *obj =
2899 _edje_lua_checkudata(L, 1, &mDescription);
2900 if ((obj->rp->part->type != EDJE_PART_TYPE_TEXT)
2901 && (obj->rp->part->type != EDJE_PART_TYPE_TEXTBLOCK))
2902 return 0;
2903 if (!obj->rp->custom) return 0;
2904 lua_createtable(L, 2, 0);
2905 lua_pushnumber(L, obj->rp->custom->description->text.max_x);
2906 lua_rawseti(L, -2, 1);
2907 lua_pushnumber(L, obj->rp->custom->description->text.max_y);
2908 lua_rawseti(L, -2, 2);
2909 return 1;
2910}
2911
2912static int
2913_edje_lua_description_get_text_align(lua_State *L)
2914{
2915 Edje_Lua_Edje_Part_Description *obj =
2916 _edje_lua_checkudata(L, 1, &mDescription);
2917 if ((obj->rp->part->type != EDJE_PART_TYPE_TEXT))
2918 return 0;
2919 if (!obj->rp->custom) return 0;
2920 lua_createtable(L, 2, 0);
2921 lua_pushnumber(L, TO_DOUBLE(obj->rp->custom->description->text.align.x));
2922 lua_rawseti(L, -2, 1);
2923 lua_pushnumber(L, TO_DOUBLE(obj->rp->custom->description->text.align.y));
2924 lua_rawseti(L, -2, 2);
2925 return 1;
2926}
2927
2928static int
2929_edje_lua_description_get_visible(lua_State *L)
2930{
2931 Edje_Lua_Edje_Part_Description *obj =
2932 _edje_lua_checkudata(L, 1, &mDescription);
2933 if (!obj->rp->custom) return 0;
2934 lua_pushboolean(L, obj->rp->custom->description->visible);
2935 return 1;
2936}
2937
2938const luaL_Reg lDescription_get[] = {
2939 {"alignment", _edje_lua_description_get_alignment},
2940 {"min", _edje_lua_description_get_min},
2941 {"max", _edje_lua_description_get_max},
2942 {"step", _edje_lua_description_get_step},
2943 {"aspect", _edje_lua_description_get_aspect},
2944 {"aspect_pref", _edje_lua_description_get_aspect_pref},
2945 {"color", _edje_lua_description_get_color},
2946 {"color2", _edje_lua_description_get_color2},
2947 {"color3", _edje_lua_description_get_color3},
2948 {"color_class", _edje_lua_description_get_color_class},
2949 {"rel1", _edje_lua_description_get_rel1},
2950 {"rel1_to", _edje_lua_description_get_rel1_to},
2951 {"rel1_offset", _edje_lua_description_get_rel1_offset},
2952 {"rel2", _edje_lua_description_get_rel2},
2953 {"rel2_to", _edje_lua_description_get_rel2_to},
2954 {"rel2_offset", _edje_lua_description_get_rel2_offset},
2955 {"image", _edje_lua_description_get_image},
2956 {"border", _edje_lua_description_get_border},
2957 {"fill_smooth", _edje_lua_description_get_fill_smooth},
2958 {"fill_pos", _edje_lua_description_get_fill_pos},
2959 {"fill_size", _edje_lua_description_get_fill_size},
2960 {"text", _edje_lua_description_get_text},
2961 {"text_class", _edje_lua_description_get_text_class},
2962 {"text_font", _edje_lua_description_get_text_font},
2963 {"text_style", _edje_lua_description_get_text_style},
2964 {"text_size", _edje_lua_description_get_text_size},
2965 {"text_fit", _edje_lua_description_get_text_fit},
2966 {"text_min", _edje_lua_description_get_text_min},
2967 {"text_max", _edje_lua_description_get_text_max},
2968 {"text_align", _edje_lua_description_get_text_align},
2969 {"visible", _edje_lua_description_get_visible},
2970 {NULL, NULL} // sentinel
2971};
2972
2973static int
2974_edje_lua_description_set_alignment(lua_State *L)
2975{
2976 Edje_Lua_Edje_Part_Description *obj =
2977 _edje_lua_checkudata(L, 1, &mDescription);
2978 if (!obj->rp->custom) return 0;
2979 luaL_checktype(L, 2, LUA_TTABLE);
2980 lua_rawgeti(L, 2, 1);
2981 lua_rawgeti(L, 2, 2);
2982 obj->rp->custom->description->align.x = FROM_DOUBLE(luaL_checknumber(L, -2));
2983 obj->rp->custom->description->align.y = FROM_DOUBLE(luaL_checknumber(L, -1));
2984 return 0;
2985}
2986
2987static int
2988_edje_lua_description_set_min(lua_State *L)
2989{
2990 Edje_Lua_Edje_Part_Description *obj =
2991 _edje_lua_checkudata(L, 1, &mDescription);
2992 if (!obj->rp->custom) return 0;
2993 lua_rawgeti(L, 2, 1);
2994 lua_rawgeti(L, 2, 2);
2995 obj->rp->custom->description->min.w = luaL_checkint(L, -2);
2996 obj->rp->custom->description->min.h = luaL_checkint(L, -1);
2997 return 0;
2998}
2999
3000static int
3001_edje_lua_description_set_max(lua_State *L)
3002{
3003 Edje_Lua_Edje_Part_Description *obj =
3004 _edje_lua_checkudata(L, 1, &mDescription);
3005 if (!obj->rp->custom) return 0;
3006 lua_rawgeti(L, 2, 1);
3007 lua_rawgeti(L, 2, 2);
3008 obj->rp->custom->description->max.w = luaL_checkint(L, -2);
3009 obj->rp->custom->description->max.h = luaL_checkint(L, -1);
3010 return 0;
3011}
3012
3013static int
3014_edje_lua_description_set_step(lua_State *L)
3015{
3016 Edje_Lua_Edje_Part_Description *obj =
3017 _edje_lua_checkudata(L, 1, &mDescription);
3018 if (!obj->rp->custom) return 0;
3019 lua_rawgeti(L, 2, 1);
3020 lua_rawgeti(L, 2, 2);
3021 obj->rp->custom->description->step.x = luaL_checkint(L, -2);
3022 obj->rp->custom->description->step.y = luaL_checkint(L, -1);
3023 return 0;
3024}
3025
3026static int
3027_edje_lua_description_set_aspect(lua_State *L)
3028{
3029 Edje_Lua_Edje_Part_Description *obj =
3030 _edje_lua_checkudata(L, 1, &mDescription);
3031 if (!obj->rp->custom) return 0;
3032 lua_rawgeti(L, 2, 1);
3033 lua_rawgeti(L, 2, 2);
3034 obj->rp->custom->description->aspect.min = FROM_DOUBLE(luaL_checknumber(L, -2));
3035 obj->rp->custom->description->aspect.max = FROM_DOUBLE(luaL_checknumber(L, -1));
3036 return 0;
3037
3038}
3039
3040static int
3041_edje_lua_description_set_aspect_pref(lua_State *L)
3042{
3043 Edje_Lua_Edje_Part_Description *obj =
3044 _edje_lua_checkudata(L, 1, &mDescription);
3045 if (!obj->rp->custom) return 0;
3046 obj->rp->custom->description->aspect.prefer = luaL_checknumber(L, 2);
3047 return 0;
3048
3049}
3050
3051static int
3052_edje_lua_description_set_color(lua_State *L)
3053{
3054 Edje_Lua_Edje_Part_Description *obj =
3055 _edje_lua_checkudata(L, 1, &mDescription);
3056 if (!obj->rp->custom) return 0;
3057 luaL_checktype(L, 2, LUA_TTABLE);
3058 lua_rawgeti(L, 2, 1);
3059 lua_rawgeti(L, 2, 2);
3060 lua_rawgeti(L, 2, 3);
3061 lua_rawgeti(L, 2, 4);
3062 obj->rp->custom->description->color.r = luaL_checkint(L, -4);
3063 obj->rp->custom->description->color.g = luaL_checkint(L, -3);
3064 obj->rp->custom->description->color.b = luaL_checkint(L, -2);
3065 obj->rp->custom->description->color.a = luaL_checkint(L, -1);
3066 return 0;
3067}
3068
3069static int
3070_edje_lua_description_set_color2(lua_State *L)
3071{
3072 Edje_Lua_Edje_Part_Description *obj =
3073 _edje_lua_checkudata(L, 1, &mDescription);
3074 if (!obj->rp->custom) return 0;
3075 luaL_checktype(L, 2, LUA_TTABLE);
3076 lua_rawgeti(L, 2, 1);
3077 lua_rawgeti(L, 2, 2);
3078 lua_rawgeti(L, 2, 3);
3079 lua_rawgeti(L, 2, 4);
3080 obj->rp->custom->description->color2.r = luaL_checkint(L, -4);
3081 obj->rp->custom->description->color2.g = luaL_checkint(L, -3);
3082 obj->rp->custom->description->color2.b = luaL_checkint(L, -2);
3083 obj->rp->custom->description->color2.a = luaL_checkint(L, -1);
3084 return 0;
3085}
3086
3087static int
3088_edje_lua_description_set_color3(lua_State *L)
3089{
3090 Edje_Lua_Edje_Part_Description *obj =
3091 _edje_lua_checkudata(L, 1, &mDescription);
3092 if (!obj->rp->custom) return 0;
3093 luaL_checktype(L, 2, LUA_TTABLE);
3094 lua_rawgeti(L, 2, 1);
3095 lua_rawgeti(L, 2, 2);
3096 lua_rawgeti(L, 2, 3);
3097 lua_rawgeti(L, 2, 4);
3098 obj->rp->custom->description->color3.r = luaL_checkint(L, -4);
3099 obj->rp->custom->description->color3.g = luaL_checkint(L, -3);
3100 obj->rp->custom->description->color3.b = luaL_checkint(L, -2);
3101 obj->rp->custom->description->color3.a = luaL_checkint(L, -1);
3102 return 0;
3103}
3104
3105static int
3106_edje_lua_description_set_color_class(lua_State *L)
3107{
3108 Edje_Lua_Edje_Part_Description *obj =
3109 _edje_lua_checkudata(L, 1, &mDescription);
3110 if (!obj->rp->custom) return 0;
3111 obj->rp->custom->description->color_class = (char *)luaL_checkstring(L, 2);
3112 return 0;
3113}
3114
3115static int
3116_edje_lua_description_set_rel1(lua_State *L)
3117{
3118 Edje_Lua_Edje_Part_Description *obj =
3119 _edje_lua_checkudata(L, 1, &mDescription);
3120 if (!obj->rp->custom) return 0;
3121 luaL_checktype(L, 2, LUA_TTABLE);
3122 lua_rawgeti(L, 2, 1);
3123 lua_rawgeti(L, 2, 2);
3124 obj->rp->custom->description->rel1.relative_x = FROM_DOUBLE(luaL_checknumber(L, -2));
3125 obj->rp->custom->description->rel1.relative_y = FROM_DOUBLE(luaL_checknumber(L, -1));
3126 return 0;
3127}
3128
3129static int
3130_edje_lua_description_set_rel1_to(lua_State *L)
3131{
3132 Edje_Lua_Edje_Part_Description *obj =
3133 _edje_lua_checkudata(L, 1, &mDescription);
3134 if (!obj->rp->custom) return 0;
3135 luaL_checktype(L, 2, LUA_TTABLE);
3136 lua_rawgeti(L, 2, 1);
3137 lua_rawgeti(L, 2, 2);
3138 obj->rp->custom->description->rel1.id_x = luaL_checknumber(L, -2);
3139 obj->rp->custom->description->rel1.id_y = luaL_checknumber(L, -1);
3140 if (obj->rp->param1.description->rel1.id_x >= 0)
3141 obj->rp->param1.rel1_to_x = obj->ed->table_parts[obj->rp->param1.description->rel1.id_x % obj->ed->table_parts_size];
3142 if (obj->rp->param1.description->rel1.id_y >= 0)
3143 obj->rp->param1.rel1_to_y = obj->ed->table_parts[obj->rp->param1.description->rel1.id_y % obj->ed->table_parts_size];
3144 return 0;
3145}
3146
3147static int
3148_edje_lua_description_set_rel1_offset(lua_State *L)
3149{
3150 Edje_Lua_Edje_Part_Description *obj =
3151 _edje_lua_checkudata(L, 1, &mDescription);
3152 if (!obj->rp->custom) return 0;
3153 luaL_checktype(L, 2, LUA_TTABLE);
3154 lua_rawgeti(L, 2, 1);
3155 lua_rawgeti(L, 2, 2);
3156 obj->rp->custom->description->rel1.offset_x = luaL_checkint(L, -2);
3157 obj->rp->custom->description->rel1.offset_y = luaL_checkint(L, -1);
3158 return 0;
3159}
3160
3161static int
3162_edje_lua_description_set_rel2(lua_State *L)
3163{
3164 Edje_Lua_Edje_Part_Description *obj =
3165 _edje_lua_checkudata(L, 1, &mDescription);
3166 if (!obj->rp->custom) return 0;
3167 luaL_checktype(L, 2, LUA_TTABLE);
3168 lua_rawgeti(L, 2, 1);
3169 lua_rawgeti(L, 2, 2);
3170 obj->rp->custom->description->rel2.relative_x = FROM_DOUBLE(luaL_checknumber(L, -2));
3171 obj->rp->custom->description->rel2.relative_y = FROM_DOUBLE(luaL_checknumber(L, -1));
3172 return 0;
3173}
3174
3175static int
3176_edje_lua_description_set_rel2_to(lua_State *L)
3177{
3178 Edje_Lua_Edje_Part_Description *obj =
3179 _edje_lua_checkudata(L, 1, &mDescription);
3180 if (!obj->rp->custom) return 0;
3181 luaL_checktype(L, 2, LUA_TTABLE);
3182 lua_rawgeti(L, 2, 1);
3183 lua_rawgeti(L, 2, 2);
3184 obj->rp->custom->description->rel2.id_x = luaL_checknumber(L, -2);
3185 obj->rp->custom->description->rel2.id_y = luaL_checknumber(L, -1);
3186 if (obj->rp->param1.description->rel2.id_x >= 0)
3187 obj->rp->param1.rel2_to_x = obj->ed->table_parts[obj->rp->param1.description->rel2.id_x % obj->ed->table_parts_size];
3188 if (obj->rp->param1.description->rel2.id_y >= 0)
3189 obj->rp->param1.rel2_to_y = obj->ed->table_parts[obj->rp->param1.description->rel2.id_y % obj->ed->table_parts_size];
3190 return 0;
3191}
3192
3193static int
3194_edje_lua_description_set_rel2_offset(lua_State *L)
3195{
3196 Edje_Lua_Edje_Part_Description *obj =
3197 _edje_lua_checkudata(L, 1, &mDescription);
3198 if (!obj->rp->custom) return 0;
3199 luaL_checktype(L, 2, LUA_TTABLE);
3200 lua_rawgeti(L, 2, 1);
3201 lua_rawgeti(L, 2, 2);
3202 obj->rp->custom->description->rel2.offset_x = luaL_checkint(L, -2);
3203 obj->rp->custom->description->rel2.offset_y = luaL_checkint(L, -1);
3204 return 0;
3205}
3206
3207static int
3208_edje_lua_description_set_image(lua_State *L)
3209{
3210 Edje_Lua_Edje_Part_Description *obj =
3211 _edje_lua_checkudata(L, 1, &mDescription);
3212 if (!obj->rp->custom) return 0;
3213 if ((obj->rp->part->type != EDJE_PART_TYPE_IMAGE))
3214 return 0;
3215 obj->rp->custom->description->image.id =
3216 edje_edit_image_id_get(obj->ed->obj, (char *)luaL_checkstring(L, 2));
3217 return 0;
3218}
3219
3220static int
3221_edje_lua_description_set_border(lua_State *L)
3222{
3223 Edje_Lua_Edje_Part_Description *obj =
3224 _edje_lua_checkudata(L, 1, &mDescription);
3225 if ((obj->rp->part->type != EDJE_PART_TYPE_IMAGE))
3226 return 0;
3227 if (!obj->rp->custom) return 0;
3228 luaL_checktype(L, 2, LUA_TTABLE);
3229 lua_rawgeti(L, 2, 1);
3230 lua_rawgeti(L, 2, 2);
3231 lua_rawgeti(L, 2, 3);
3232 lua_rawgeti(L, 2, 4);
3233 obj->rp->custom->description->border.l = luaL_checkint(L, -2);
3234 obj->rp->custom->description->border.r = luaL_checkint(L, -1);
3235 obj->rp->custom->description->border.t = luaL_checkint(L, -2);
3236 obj->rp->custom->description->border.b = luaL_checkint(L, -1);
3237 return 0;
3238}
3239
3240static int
3241_edje_lua_description_set_fill_smooth(lua_State *L)
3242{
3243 Edje_Lua_Edje_Part_Description *obj =
3244 _edje_lua_checkudata(L, 1, &mDescription);
3245 if ((obj->rp->part->type != EDJE_PART_TYPE_IMAGE))
3246 return 0;
3247 if (!obj->rp->custom) return 0;
3248 obj->rp->custom->description->fill.smooth = lua_toboolean(L, 2);
3249 return 0;
3250}
3251
3252static int
3253_edje_lua_description_set_fill_pos(lua_State *L)
3254{
3255 Edje_Lua_Edje_Part_Description *obj =
3256 _edje_lua_checkudata(L, 1, &mDescription);
3257 if ((obj->rp->part->type != EDJE_PART_TYPE_IMAGE))
3258 return 0;
3259 if (!obj->rp->custom) return 0;
3260 luaL_checktype(L, 2, LUA_TTABLE);
3261 lua_rawgeti(L, 2, 1);
3262 lua_rawgeti(L, 2, 2);
3263 lua_rawgeti(L, 2, 3);
3264 lua_rawgeti(L, 2, 4);
3265 obj->rp->custom->description->fill.pos_rel_x = luaL_checkint(L, -2);
3266 obj->rp->custom->description->fill.pos_rel_y = luaL_checkint(L, -1);
3267 obj->rp->custom->description->fill.pos_abs_x = luaL_checkint(L, -2);
3268 obj->rp->custom->description->fill.pos_abs_y = luaL_checkint(L, -1);
3269 return 0;
3270}
3271
3272static int
3273_edje_lua_description_set_fill_size(lua_State *L)
3274{
3275 Edje_Lua_Edje_Part_Description *obj =
3276 _edje_lua_checkudata(L, 1, &mDescription);
3277 if ((obj->rp->part->type != EDJE_PART_TYPE_IMAGE))
3278 return 0;
3279 if (!obj->rp->custom) return 0;
3280 luaL_checktype(L, 2, LUA_TTABLE);
3281 lua_rawgeti(L, 2, 1);
3282 lua_rawgeti(L, 2, 2);
3283 lua_rawgeti(L, 2, 3);
3284 lua_rawgeti(L, 2, 4);
3285 obj->rp->custom->description->fill.rel_x = luaL_checkint(L, -2);
3286 obj->rp->custom->description->fill.rel_y = luaL_checkint(L, -1);
3287 obj->rp->custom->description->fill.abs_x = luaL_checkint(L, -2);
3288 obj->rp->custom->description->fill.abs_y = luaL_checkint(L, -1);
3289 return 0;
3290}
3291
3292static int
3293_edje_lua_description_set_text(lua_State *L)
3294{
3295 Edje_Lua_Edje_Part_Description *obj =
3296 _edje_lua_checkudata(L, 1, &mDescription);
3297 if ((obj->rp->part->type != EDJE_PART_TYPE_TEXT)
3298 && (obj->rp->part->type != EDJE_PART_TYPE_TEXTBLOCK))
3299 return 0;
3300 if (!obj->rp->custom) return 0;
3301 obj->rp->custom->description->text.text = (char *)luaL_checkstring(L, 2);
3302 return 0;
3303}
3304
3305static int
3306_edje_lua_description_set_text_class(lua_State *L)
3307{
3308 Edje_Lua_Edje_Part_Description *obj =
3309 _edje_lua_checkudata(L, 1, &mDescription);
3310 if ((obj->rp->part->type != EDJE_PART_TYPE_TEXT)
3311 && (obj->rp->part->type != EDJE_PART_TYPE_TEXTBLOCK))
3312 return 0;
3313 if (!obj->rp->custom) return 0;
3314 obj->rp->custom->description->text.text_class =
3315 (char *)luaL_checkstring(L, 2);
3316 return 0;
3317}
3318
3319static int
3320_edje_lua_description_set_text_font(lua_State *L)
3321{
3322 Edje_Lua_Edje_Part_Description *obj =
3323 _edje_lua_checkudata(L, 1, &mDescription);
3324 if ((obj->rp->part->type != EDJE_PART_TYPE_TEXT))
3325 return 0;
3326 if (!obj->rp->custom) return 0;
3327 obj->rp->custom->description->text.font = (char *)luaL_checkstring(L, 2);
3328 return 0;
3329}
3330
3331static int
3332_edje_lua_description_set_text_style(lua_State *L)
3333{
3334 Edje_Lua_Edje_Part_Description *obj =
3335 _edje_lua_checkudata(L, 1, &mDescription);
3336 if ((obj->rp->part->type != EDJE_PART_TYPE_TEXTBLOCK))
3337 return 0;
3338 if (!obj->rp->custom) return 0;
3339 obj->rp->custom->description->text.style = (char *)luaL_checkstring(L, 2);
3340 return 0;
3341}
3342
3343static int
3344_edje_lua_description_set_text_size(lua_State *L)
3345{
3346 Edje_Lua_Edje_Part_Description *obj =
3347 _edje_lua_checkudata(L, 1, &mDescription);
3348 if ((obj->rp->part->type != EDJE_PART_TYPE_TEXT))
3349 return 0;
3350 if (!obj->rp->custom) return 0;
3351 obj->rp->custom->description->text.size = luaL_checkint(L, 2);
3352 return 0;
3353}
3354
3355static int
3356_edje_lua_description_set_text_fit(lua_State *L)
3357{
3358 Edje_Lua_Edje_Part_Description *obj =
3359 _edje_lua_checkudata(L, 1, &mDescription);
3360 if (!obj->rp->custom) return 0;
3361 luaL_checktype(L, 2, LUA_TTABLE);
3362 lua_rawgeti(L, 2, 1);
3363 lua_rawgeti(L, 2, 2);
3364 obj->rp->custom->description->text.fit_x = lua_toboolean(L, -2);
3365 obj->rp->custom->description->text.fit_y = lua_toboolean(L, -1);
3366 return 0;
3367}
3368
3369static int
3370_edje_lua_description_set_text_min(lua_State *L)
3371{
3372 Edje_Lua_Edje_Part_Description *obj =
3373 _edje_lua_checkudata(L, 1, &mDescription);
3374 if ((obj->rp->part->type != EDJE_PART_TYPE_TEXT)
3375 && (obj->rp->part->type != EDJE_PART_TYPE_TEXTBLOCK))
3376 return 0;
3377 if (!obj->rp->custom) return 0;
3378 luaL_checktype(L, 2, LUA_TTABLE);
3379 lua_rawgeti(L, 2, 1);
3380 lua_rawgeti(L, 2, 2);
3381 obj->rp->custom->description->text.min_x = luaL_checkint(L, -2);
3382 obj->rp->custom->description->text.min_y = luaL_checkint(L, -1);
3383 return 0;
3384}
3385
3386static int
3387_edje_lua_description_set_text_max(lua_State *L)
3388{
3389 Edje_Lua_Edje_Part_Description *obj =
3390 _edje_lua_checkudata(L, 1, &mDescription);
3391 if ((obj->rp->part->type != EDJE_PART_TYPE_TEXT)
3392 && (obj->rp->part->type != EDJE_PART_TYPE_TEXTBLOCK))
3393 return 0;
3394 if (!obj->rp->custom) return 0;
3395 luaL_checktype(L, 2, LUA_TTABLE);
3396 lua_rawgeti(L, 2, 1);
3397 lua_rawgeti(L, 2, 2);
3398 obj->rp->custom->description->text.max_x = luaL_checkint(L, -2);
3399 obj->rp->custom->description->text.max_y = luaL_checkint(L, -1);
3400 return 0;
3401}
3402
3403static int
3404_edje_lua_description_set_text_align(lua_State *L)
3405{
3406 Edje_Lua_Edje_Part_Description *obj =
3407 _edje_lua_checkudata(L, 1, &mDescription);
3408 if ((obj->rp->part->type != EDJE_PART_TYPE_TEXT))
3409 return 0;
3410 if (!obj->rp->custom) return 0;
3411 luaL_checktype(L, 2, LUA_TTABLE);
3412 lua_rawgeti(L, 2, 1);
3413 lua_rawgeti(L, 2, 2);
3414 obj->rp->custom->description->text.align.x = FROM_DOUBLE(luaL_checknumber(L, -2));
3415 obj->rp->custom->description->text.align.y = FROM_DOUBLE(luaL_checknumber(L, -1));
3416 return 0;
3417}
3418
3419static int
3420_edje_lua_description_set_visible(lua_State *L)
3421{
3422 Edje_Lua_Edje_Part_Description *obj =
3423 _edje_lua_checkudata(L, 1, &mDescription);
3424 if (!obj->rp->custom) return 0;
3425 obj->rp->custom->description->visible = lua_toboolean(L, 2);
3426 return 0;
3427}
3428
3429const luaL_Reg lDescription_set[] = {
3430 {"alignment", _edje_lua_description_set_alignment},
3431 {"min", _edje_lua_description_set_min},
3432 {"max", _edje_lua_description_set_max},
3433 {"step", _edje_lua_description_set_step},
3434 {"aspect", _edje_lua_description_set_aspect},
3435 {"aspect_pref", _edje_lua_description_set_aspect_pref},
3436 {"color", _edje_lua_description_set_color},
3437 {"color2", _edje_lua_description_set_color2},
3438 {"color3", _edje_lua_description_set_color3},
3439 {"color_class", _edje_lua_description_set_color_class},
3440 {"rel1", _edje_lua_description_set_rel1},
3441 {"rel1_to", _edje_lua_description_set_rel1_to},
3442 {"rel1_offset", _edje_lua_description_set_rel1_offset},
3443 {"rel2", _edje_lua_description_set_rel2},
3444 {"rel2_to", _edje_lua_description_set_rel2_to},
3445 {"rel2_offset", _edje_lua_description_set_rel2_offset},
3446 {"image", _edje_lua_description_set_image},
3447 {"border", _edje_lua_description_set_border},
3448 {"fill_smooth", _edje_lua_description_set_fill_smooth},
3449 {"fill_pos", _edje_lua_description_set_fill_pos},
3450 {"fill_size", _edje_lua_description_set_fill_size},
3451 {"text", _edje_lua_description_set_text},
3452 {"text_class", _edje_lua_description_set_text_class},
3453 {"text_font", _edje_lua_description_set_text_font},
3454 {"text_style", _edje_lua_description_set_text_style},
3455 {"text_size", _edje_lua_description_set_text_size},
3456 {"text_fit", _edje_lua_description_set_text_fit},
3457 {"text_min", _edje_lua_description_set_text_min},
3458 {"text_max", _edje_lua_description_set_text_max},
3459 {"text_align", _edje_lua_description_set_text_align},
3460 {"visible", _edje_lua_description_set_visible},
3461 {NULL, NULL} // sentinel
3462};
3463
3464const luaL_Reg lPart_get[];
3465
3466const luaL_Reg lPart_set[];
3467
3468const luaL_Reg lPart_fn[];
3469
3470const Edje_Lua_Reg mPart = {
3471 lNil,
3472 lPart_get,
3473 lPart_set,
3474 lPart_fn
3475};
3476
3477static void
3478_edje_lua_edje_part_del_cb(void *data, __UNUSED__ Evas * e, Evas_Object * obj,
3479 __UNUSED__ void *event_info)
3480{
3481 //printf("_edje_lua_object_delete_cb\n");
3482 lua_State *L = data;
3483 _edje_lua_get_reg(L, obj);
3484 Edje_Lua_Edje_Part_Object *udata = _edje_lua_checkudata(L, -1, &mPart);
3485 lua_pop(L, 1);
3486 _edje_lua_free_reg(L, udata); // created in _edje_lua_group_mt_index
3487 _edje_lua_free_reg(L, obj); // created in _edje_lua_group_mt_index
3488}
3489
3490const Edje_Lua_Reg *cPart[] = {
3491 &mClass,
3492 &mObject,
3493 &mPart,
3494 NULL // sentinel
3495};
3496
3497static int
3498_edje_lua_part_get_swallow(lua_State *L)
3499{
3500 Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart);
3501 Evas_Object *swa = edje_object_part_swallow_get(obj->ed->obj, obj->key);
3502 _edje_lua_get_reg(L, swa);
3503 // TODO create object if it does not already exist?
3504 return 1;
3505}
3506
3507static int
3508_edje_lua_part_get_type(lua_State *L)
3509{
3510 Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart);
3511 lua_pushnumber(L, edje_edit_part_type_get(obj->ed->obj, obj->key));
3512 return 1;
3513}
3514
3515static int
3516_edje_lua_part_get_effect(lua_State *L)
3517{
3518 Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart);
3519 lua_pushnumber(L, edje_edit_part_effect_get(obj->ed->obj, obj->key));
3520 return 1;
3521}
3522
3523static int
3524_edje_lua_part_get_mouse_events(lua_State *L)
3525{
3526 Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart);
3527 lua_pushboolean(L, edje_edit_part_mouse_events_get(obj->ed->obj, obj->key));
3528 return 1;
3529}
3530
3531static int
3532_edje_lua_part_get_repeat_events(lua_State *L)
3533{
3534 Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart);
3535 lua_pushboolean(L, edje_edit_part_repeat_events_get(obj->ed->obj, obj->key));
3536 return 1;
3537}
3538
3539static int
3540_edje_lua_part_get_states_list(lua_State *L)
3541{
3542 Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart);
3543 Eina_List *slist = edje_edit_part_states_list_get(obj->ed->obj, obj->key);
3544 Eina_List *ilist;
3545 lua_newtable(L);
3546 int i = 1;
3547 for (ilist = slist; ilist; ilist = eina_list_next(ilist))
3548 {
3549 lua_pushstring(L, eina_list_data_get(ilist));
3550 lua_rawseti(L, -2, i++);
3551 }
3552 edje_edit_string_list_free(slist);
3553 return 1;
3554};
3555
3556static int
3557_edje_lua_part_get_state(lua_State *L)
3558{
3559 Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart);
3560 const char *state;
3561 double val;
3562 state = edje_object_part_state_get(obj->ed->obj, obj->key, &val);
3563 lua_createtable(L, 2, 0);
3564 lua_pushstring(L, state);
3565 lua_rawseti(L, -2, 1);
3566 lua_pushnumber(L, val);
3567 lua_rawseti(L, -2, 2);
3568 return 1;
3569};
3570
3571static int
3572_edje_lua_part_get_text(lua_State *L)
3573{
3574 Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart);
3575 lua_pushstring(L, edje_object_part_text_get(obj->ed->obj, obj->key));
3576 return 1;
3577};
3578
3579static int
3580_edje_lua_part_get_text_selection(lua_State *L)
3581{
3582 Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart);
3583 lua_pushstring(L,
3584 edje_object_part_text_selection_get(obj->ed->obj, obj->key));
3585 return 1;
3586};
3587
3588static int
3589_edje_lua_part_get_drag_dir(lua_State *L)
3590{
3591 Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart);
3592 lua_pushnumber(L, edje_object_part_drag_dir_get(obj->ed->obj, obj->key));
3593 return 1;
3594}
3595
3596static int
3597_edje_lua_part_get_drag_value(lua_State *L)
3598{
3599 Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart);
3600 double dx, dy;
3601 edje_object_part_drag_value_get(obj->ed->obj, obj->key, &dx, &dy);
3602 lua_createtable(L, 2, 0);
3603 lua_pushnumber(L, dx);
3604 lua_rawseti(L, -2, 1);
3605 lua_pushnumber(L, dy);
3606 lua_rawseti(L, -2, 2);
3607 return 1;
3608}
3609
3610static int
3611_edje_lua_part_get_drag_size(lua_State *L)
3612{
3613 Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart);
3614 double dx, dy;
3615 edje_object_part_drag_size_get(obj->ed->obj, obj->key, &dx, &dy);
3616 lua_createtable(L, 2, 0);
3617 lua_pushnumber(L, dx);
3618 lua_rawseti(L, -2, 1);
3619 lua_pushnumber(L, dy);
3620 lua_rawseti(L, -2, 2);
3621 return 1;
3622}
3623
3624static int
3625_edje_lua_part_get_drag_step(lua_State *L)
3626{
3627 Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart);
3628 double dx, dy;
3629 edje_object_part_drag_step_get(obj->ed->obj, obj->key, &dx, &dy);
3630 lua_createtable(L, 2, 0);
3631 lua_pushnumber(L, dx);
3632 lua_rawseti(L, -2, 1);
3633 lua_pushnumber(L, dy);
3634 lua_rawseti(L, -2, 2);
3635 return 1;
3636}
3637
3638static int
3639_edje_lua_part_get_drag_page(lua_State *L)
3640{
3641 Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart);
3642 double dx, dy;
3643 edje_object_part_drag_page_get(obj->ed->obj, obj->key, &dx, &dy);
3644 lua_createtable(L, 2, 0);
3645 lua_pushnumber(L, dx);
3646 lua_rawseti(L, -2, 1);
3647 lua_pushnumber(L, dy);
3648 lua_rawseti(L, -2, 2);
3649 return 1;
3650}
3651
3652static int
3653_edje_lua_part_get_text_cursor_geometry(lua_State *L)
3654{
3655 Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart);
3656 Evas_Coord x, y, w, h;
3657 edje_object_part_text_cursor_geometry_get(obj->ed->obj, obj->key,
3658 &x, &y, &w, &h);
3659 lua_createtable(L, 4, 0);
3660 lua_pushnumber(L, x);
3661 lua_rawseti(L, -2, 1);
3662 lua_pushnumber(L, y);
3663 lua_rawseti(L, -2, 2);
3664 lua_pushnumber(L, w);
3665 lua_rawseti(L, -2, 3);
3666 lua_pushnumber(L, h);
3667 lua_rawseti(L, -2, 4);
3668 return 1;
3669}
3670
3671static int
3672_edje_lua_part_get_geometry(lua_State *L)
3673{
3674 Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart);
3675 Evas_Coord x, y, w, h;
3676 edje_object_part_geometry_get(obj->ed->obj, obj->key, &x, &y, &w, &h);
3677 lua_createtable(L, 4, 0);
3678 lua_pushnumber(L, x);
3679 lua_rawseti(L, -2, 1);
3680 lua_pushnumber(L, y);
3681 lua_rawseti(L, -2, 2);
3682 lua_pushnumber(L, w);
3683 lua_rawseti(L, -2, 3);
3684 lua_pushnumber(L, h);
3685 lua_rawseti(L, -2, 4);
3686 return 1;
3687}
3688
3689static int
3690_edje_lua_part_get_table_col_row_size(lua_State *L)
3691{
3692 Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart);
3693 int cols, rows;
3694 edje_object_part_table_col_row_size_get(obj->ed->obj, obj->key, &cols, &rows);
3695 lua_createtable(L, 2, 0);
3696 lua_pushnumber(L, cols); lua_rawseti(L, -2, 1);
3697 lua_pushnumber(L, rows); lua_rawseti(L, -2, 2);
3698 return 1;
3699}
3700
3701static int _edje_lua_part_fn_custom_state(lua_State *L);
3702
3703const luaL_Reg lPart_get[] = {
3704 {"custom_state", _edje_lua_part_fn_custom_state},
3705 {"Swallow", _edje_lua_part_get_swallow}, //TODO it the capital S correct?
3706
3707 {"drag_dir", _edje_lua_part_get_drag_dir},
3708 {"drag_value", _edje_lua_part_get_drag_value},
3709 {"drag_size", _edje_lua_part_get_drag_size},
3710 {"drag_step", _edje_lua_part_get_drag_step},
3711 {"drag_page", _edje_lua_part_get_drag_page},
3712
3713 {"type", _edje_lua_part_get_type},
3714 {"effect", _edje_lua_part_get_effect},
3715 {"mouse_events", _edje_lua_part_get_mouse_events},
3716 {"repeat_events", _edje_lua_part_get_repeat_events},
3717 {"states_list", _edje_lua_part_get_states_list},
3718 {"state", _edje_lua_part_get_state},
3719
3720 {"text", _edje_lua_part_get_text},
3721 {"text_selection", _edje_lua_part_get_text_selection},
3722 {"text_cursor_geometry", _edje_lua_part_get_text_cursor_geometry},
3723
3724 {"geometry", _edje_lua_part_get_geometry},
3725 {"part_col_row_size", _edje_lua_part_get_table_col_row_size},
3726 {NULL, NULL} // sentinel
3727};
3728
3729static int
3730_edje_lua_part_set_effect(lua_State *L)
3731{
3732 Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart);
3733 edje_edit_part_effect_set(obj->ed->obj, obj->key, luaL_checkint(L, 2));
3734 return 0;
3735}
3736
3737static int
3738_edje_lua_part_set_mouse_events(lua_State *L)
3739{
3740 Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart);
3741 edje_edit_part_mouse_events_set(obj->ed->obj, obj->key, lua_toboolean(L, 2));
3742 return 0;
3743}
3744
3745static int
3746_edje_lua_part_set_repeat_events(lua_State *L)
3747{
3748 Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart);
3749 edje_edit_part_repeat_events_set(obj->ed->obj, obj->key,
3750 lua_toboolean(L, 2));
3751 return 0;
3752}
3753
3754static int
3755_edje_lua_part_set_state(lua_State *L)
3756{
3757 Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart);
3758 luaL_checktype(L, 2, LUA_TTABLE);
3759 lua_rawgeti(L, 2, 1);
3760 lua_rawgeti(L, 2, 2);
3761 _edje_part_description_apply(obj->ed, obj->rp,
3762 luaL_checkstring(L, -2), luaL_checknumber(L, -1),
3763 NULL, 0.0);
3764 _edje_part_pos_set(obj->ed, obj->rp, EDJE_TWEEN_MODE_LINEAR, ZERO, ZERO, ZERO);
3765 _edje_recalc(obj->ed);
3766 return 0;
3767}
3768
3769static int
3770_edje_lua_part_set_tween_state(lua_State *L)
3771{
3772 Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart);
3773 luaL_checktype(L, 2, LUA_TTABLE);
3774 lua_rawgeti(L, 2, 1);
3775 lua_rawgeti(L, 2, 2);
3776 lua_rawgeti(L, 2, 3);
3777 lua_rawgeti(L, 2, 4);
3778 lua_rawgeti(L, 2, 5);
3779 _edje_part_description_apply(obj->ed, obj->rp,
3780 luaL_checkstring(L, -4), luaL_checknumber(L, -3),
3781 luaL_checkstring(L, -2), luaL_checknumber(L, -1));
3782 _edje_part_pos_set(obj->ed, obj->rp, EDJE_TWEEN_MODE_LINEAR,
3783 FROM_DOUBLE(luaL_checknumber(L, -5)), ZERO, ZERO);
3784 _edje_recalc(obj->ed);
3785 return 0;
3786}
3787
3788static int
3789_edje_lua_part_set_text(lua_State *L)
3790{
3791 Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart);
3792 edje_object_part_text_set(obj->ed->obj, obj->key, luaL_checkstring(L, 2));
3793 return 0;
3794}
3795
3796static int
3797_edje_lua_part_set_drag_value(lua_State *L)
3798{
3799 Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart);
3800 lua_rawgeti(L, 2, 1);
3801 lua_rawgeti(L, 2, 2);
3802 edje_object_part_drag_value_set(obj->ed->obj, obj->key,
3803 luaL_checknumber(L, -2),
3804 luaL_checknumber(L, -1));
3805 return 0;
3806}
3807
3808static int
3809_edje_lua_part_set_drag_size(lua_State *L)
3810{
3811 Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart);
3812 lua_rawgeti(L, 2, 1);
3813 lua_rawgeti(L, 2, 2);
3814 edje_object_part_drag_size_set(obj->ed->obj, obj->key,
3815 luaL_checknumber(L, -2),
3816 luaL_checknumber(L, -1));
3817 return 0;
3818}
3819
3820static int
3821_edje_lua_part_set_drag_step(lua_State *L)
3822{
3823 Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart);
3824 lua_rawgeti(L, 2, 1);
3825 lua_rawgeti(L, 2, 2);
3826 edje_object_part_drag_step_set(obj->ed->obj, obj->key,
3827 luaL_checknumber(L, -2),
3828 luaL_checknumber(L, -1));
3829 return 0;
3830}
3831
3832static int
3833_edje_lua_part_set_drag_page(lua_State *L)
3834{
3835 Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart);
3836 lua_rawgeti(L, 2, 1);
3837 lua_rawgeti(L, 2, 2);
3838 edje_object_part_drag_page_set(obj->ed->obj, obj->key,
3839 luaL_checknumber(L, -2),
3840 luaL_checknumber(L, -1));
3841 return 0;
3842}
3843
3844const luaL_Reg lPart_set[] = {
3845 {"drag_value", _edje_lua_part_set_drag_value},
3846 {"drag_size", _edje_lua_part_set_drag_size},
3847 {"drag_step", _edje_lua_part_set_drag_step},
3848 {"drag_page", _edje_lua_part_set_drag_page},
3849
3850 {"effect", _edje_lua_part_set_effect},
3851 {"mouse_events", _edje_lua_part_set_mouse_events},
3852 {"repeat_events", _edje_lua_part_set_repeat_events},
3853 {"state", _edje_lua_part_set_state},
3854 {"tween_state", _edje_lua_part_set_tween_state},
3855 {"text", _edje_lua_part_set_text},
3856 {NULL, NULL} // sentinel
3857};
3858
3859static int
3860_edje_lua_part_fn_swallow(lua_State *L)
3861{
3862 Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart);
3863 Edje_Lua_Evas_Object *swa = _edje_lua_checkudata(L, 2, &mObject);
3864 edje_object_part_swallow(obj->ed->obj, obj->key, swa->eo);
3865 return 0;
3866}
3867
3868static int
3869_edje_lua_part_fn_unswallow(lua_State *L)
3870{
3871 Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart);
3872 edje_object_part_unswallow(obj->ed->obj, obj->eo);
3873 return 0;
3874}
3875
3876static int
3877_edje_lua_part_fn_text_select_none(lua_State *L)
3878{
3879 Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart);
3880 edje_object_part_text_select_none(obj->ed->obj, obj->key);
3881 return 0;
3882}
3883
3884static int
3885_edje_lua_part_fn_text_select_all(lua_State *L)
3886{
3887 Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart);
3888 edje_object_part_text_select_all(obj->ed->obj, obj->key);
3889 return 0;
3890}
3891
3892static int
3893_edje_lua_part_fn_text_insert(lua_State *L)
3894{
3895 Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart);
3896 edje_object_part_text_insert(obj->ed->obj, obj->key, luaL_checkstring(L, 2));
3897 return 0;
3898}
3899
3900static int
3901_edje_lua_part_fn_custom_state(lua_State *L)
3902{
3903 char *name;
3904 float val;
3905 Edje_Part_Description *parent;
3906 Edje_Part_Image_Id *iid;
3907 Eina_List *l;
3908 Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart);
3909 /* check whether this part already has a "custom" state */
3910 if (obj->rp->custom)
3911 {
3912 _edje_lua_get_reg(L, obj->rp->custom->description);
3913 return 1;
3914 }
3915
3916 name = (char *)luaL_checkstring(L, 2); // state name
3917 val = luaL_checknumber(L, 3); // state val
3918 if (!(parent = _edje_part_description_find(obj->ed, obj->rp, name, val)))
3919 {
3920 lua_pushnil(L);
3921 return 1;
3922 }
3923 /* now create the custom state */
3924 Edje_Lua_Edje_Part_Description *tar =
3925 lua_newuserdata(L, sizeof(Edje_Lua_Edje_Part_Description));
3926 tar->rp = obj->rp;
3927 _edje_lua_set_class(L, -1, cDescription);
3928 _edje_lua_new_reg(L, -1, tar); // freed in edje_load.c::_edje_file_del
3929 if (!(tar->pd = calloc(1, sizeof(Edje_Part_Description))))
3930 {
3931 lua_pushnil(L);
3932 return 1;
3933 }
3934
3935 obj->rp->custom = eina_mempool_malloc(_edje_real_part_state_mp, sizeof (Edje_Real_Part_State));
3936 if (!obj->rp->custom)
3937 {
3938 free(tar->pd);
3939 tar->pd = NULL;
3940 lua_pushnil(L);
3941 return 1;
3942 }
3943
3944 *(tar->pd) = *parent;
3945 tar->pd->state.name = (char *)eina_stringshare_add("custom");
3946 tar->pd->state.value = 0.0;
3947 /*
3948 * make sure all the allocated memory is getting copied,
3949 * not just referenced
3950 */
3951 tar->pd->image.tween_list = NULL;
3952 EINA_LIST_FOREACH(parent->image.tween_list, l, iid)
3953 {
3954 Edje_Part_Image_Id *iid_new;
3955 iid_new = calloc(1, sizeof(Edje_Part_Image_Id));
3956 iid_new->id = iid->id;
3957
3958 tar->pd->image.tween_list =
3959 eina_list_append(tar->pd->image.tween_list, iid_new);
3960 }
3961#define DUP(x) x ? (char *)eina_stringshare_add(x) : NULL
3962 tar->pd->color_class = DUP(tar->pd->color_class);
3963 tar->pd->text.text = DUP(tar->pd->text.text);
3964 tar->pd->text.text_class = DUP(tar->pd->text.text_class);
3965 tar->pd->text.font = DUP(tar->pd->text.font);
3966 tar->pd->text.style = DUP(tar->pd->text.style);
3967#undef DUP
3968 obj->rp->custom->description = tar->pd;
3969 _edje_lua_new_reg(L, -1, obj->rp->custom->description); // freed in edje_load.c::_edje_file_del
3970 return 1;
3971}
3972
3973static int
3974_edje_lua_part_fn_table_pack(lua_State *L)
3975{
3976 Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart);
3977 Edje_Lua_Evas_Object *tar = _edje_lua_checkudata(L, 2, &mObject);
3978 lua_pushboolean(L,
3979 edje_object_part_table_pack(obj->ed->obj, obj->key, tar->eo,
3980 luaL_checkint(L, 3),
3981 luaL_checkint(L, 4),
3982 luaL_checkint(L, 5),
3983 luaL_checkint(L, 6)));
3984 return 1;
3985}
3986
3987static int
3988_edje_lua_part_fn_table_unpack(lua_State *L)
3989{
3990 Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart);
3991 Edje_Lua_Evas_Object *tar = _edje_lua_checkudata(L, 2, &mObject);
3992 lua_pushboolean(L,
3993 edje_object_part_table_unpack(obj->ed->obj, obj->key, tar->eo));
3994 return 1;
3995}
3996
3997static int
3998_edje_lua_part_fn_table_clear(lua_State *L)
3999{
4000 Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart);
4001 lua_pushboolean(L,
4002 edje_object_part_table_clear(obj->ed->obj, obj->key, lua_toboolean(L, 2)));
4003 return 1;
4004}
4005
4006static int
4007_edje_lua_part_fn_box_append(lua_State *L)
4008{
4009 Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart);
4010 Edje_Lua_Evas_Object *tar = _edje_lua_checkudata(L, 2, &mObject);
4011 lua_pushboolean(L,
4012 edje_object_part_box_append(obj->ed->obj, obj->key, tar->eo));
4013 return 1;
4014}
4015
4016static int
4017_edje_lua_part_fn_box_prepend(lua_State *L)
4018{
4019 Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart);
4020 Edje_Lua_Evas_Object *tar = _edje_lua_checkudata(L, 2, &mObject);
4021 lua_pushboolean(L,
4022 edje_object_part_box_prepend(obj->ed->obj, obj->key, tar->eo));
4023 return 1;
4024}
4025
4026static int
4027_edje_lua_part_fn_box_insert_before(lua_State *L)
4028{
4029 Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart);
4030 Edje_Lua_Evas_Object *tar = _edje_lua_checkudata(L, 2, &mObject);
4031 Edje_Lua_Evas_Object *ref = _edje_lua_checkudata(L, 3, &mObject);
4032 lua_pushboolean(L,
4033 edje_object_part_box_insert_before(obj->ed->obj, obj->key, tar->eo, ref->eo));
4034 return 1;
4035}
4036
4037static int
4038_edje_lua_part_fn_box_insert_at(lua_State *L)
4039{
4040 Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart);
4041 Edje_Lua_Evas_Object *tar = _edje_lua_checkudata(L, 2, &mObject);
4042 lua_pushboolean(L,
4043 edje_object_part_box_insert_at(obj->ed->obj, obj->key, tar->eo, luaL_checkint(L, 3)));
4044 return 1;
4045}
4046
4047static int
4048_edje_lua_part_fn_box_remove(lua_State *L)
4049{
4050 Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart);
4051 Edje_Lua_Evas_Object *tar = _edje_lua_checkudata(L, 2, &mObject);
4052 edje_object_part_box_remove(obj->ed->obj, obj->key, tar->eo);
4053 lua_pushvalue(L, 2);
4054 return 1;
4055}
4056
4057static int
4058_edje_lua_part_fn_box_remove_at(lua_State *L)
4059{
4060 Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart);
4061 _edje_lua_get_reg(L, edje_object_part_box_remove_at(obj->ed->obj, obj->key, luaL_checkint(L, 2)));
4062 return 1;
4063}
4064
4065static int
4066_edje_lua_part_fn_box_remove_all(lua_State *L)
4067{
4068 Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart);
4069 lua_pushboolean(L,
4070 edje_object_part_box_remove_all(obj->ed->obj, obj->key, lua_toboolean(L, 2)));
4071 return 1;
4072}
4073
4074const luaL_Reg lPart_fn[] = {
4075 {"swallow", _edje_lua_part_fn_swallow},
4076 {"unswallow", _edje_lua_part_fn_unswallow},
4077
4078 {"custom_state", _edje_lua_part_fn_custom_state},
4079
4080 {"text_select_none", _edje_lua_part_fn_text_select_none},
4081 {"text_select_all", _edje_lua_part_fn_text_select_all},
4082 {"text_insert", _edje_lua_part_fn_text_insert},
4083
4084 {"table_pack", _edje_lua_part_fn_table_pack},
4085 {"table_unpack", _edje_lua_part_fn_table_unpack},
4086 {"table_clear", _edje_lua_part_fn_table_clear},
4087
4088 {"box_append", _edje_lua_part_fn_box_append},
4089 {"box_prepend", _edje_lua_part_fn_box_prepend},
4090 {"box_insert_before", _edje_lua_part_fn_box_insert_before},
4091 {"box_insert_at", _edje_lua_part_fn_box_insert_at},
4092 {"box_remove", _edje_lua_part_fn_box_remove},
4093 {"box_remove_at", _edje_lua_part_fn_box_remove_at},
4094 {"box_remove_all", _edje_lua_part_fn_box_remove_all},
4095 {NULL, NULL} // sentinel
4096};
4097
4098const luaL_Reg lGroup_mt[];
4099
4100const luaL_Reg lGroup_get[];
4101
4102const luaL_Reg lGroup_set[];
4103
4104const luaL_Reg lGroup_fn[];
4105
4106const Edje_Lua_Reg mGroup = {
4107 lGroup_mt,
4108 lGroup_get,
4109 lGroup_set,
4110 lGroup_fn
4111};
4112
4113const Edje_Lua_Reg *cGroup[] = {
4114 &mClass,
4115 &mObject,
4116 &mGroup,
4117 NULL // sentinel
4118};
4119
4120static int
4121_edje_lua_group_mt_index(lua_State *L)
4122{
4123 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup);
4124 lua_getmetatable(L, 1);
4125 if (!_edje_lua_look_fn(L))
4126 {
4127 // look in lGroup_fn
4128 if (!_edje_lua_look_get(L))
4129 {
4130 // look in lGroup_get
4131 const char *key = luaL_checkstring(L, 2);
4132 Edje *ed = _edje_fetch(obj->eo);
4133 Edje_Real_Part *rp = _edje_real_part_recursive_get(ed, key);
4134 if (rp)
4135 {
4136 // check if lua userdata exists
4137 Evas_Object *part = (Evas_Object *) edje_object_part_object_get(obj->eo, key);
4138 _edje_lua_get_reg(L, part);
4139 if (lua_isnil(L, -1))
4140 {
4141 // create it
4142 lua_pop(L, 1);
4143 Edje_Lua_Edje_Part_Object *tar =
4144 lua_newuserdata(L, sizeof(Edje_Lua_Edje_Part_Object));
4145 tar->eo = part;
4146 tar->ed = ed;
4147 tar->key = key;
4148 tar->L = L;
4149 tar->rp = rp;
4150 _edje_lua_set_class(L, -1, cPart);
4151 _edje_lua_new_reg(L, -1, tar); // freed in _edje_lua_edje_part_del_cb
4152 _edje_lua_new_reg(L, -1, part); // freed in _edje_lua_edje_part_del_cb
4153 evas_object_event_callback_add(tar->eo,
4154 EVAS_CALLBACK_DEL,
4155 _edje_lua_edje_part_del_cb,
4156 L);
4157 }
4158 }
4159 else
4160 {
4161 // look in obj environment table
4162 lua_getfenv(L, 1);
4163 lua_pushvalue(L, 2); // key
4164 lua_rawget(L, -2);
4165 }
4166 }
4167 }
4168 return 1;
4169}
4170
4171const luaL_Reg lGroup_mt[] = {
4172 {"__index", _edje_lua_group_mt_index},
4173 {NULL, NULL} // sentinel
4174};
4175
4176static int
4177_edje_lua_group_get_group(lua_State *L)
4178{
4179 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup);
4180 const char *file, *group;
4181 edje_object_file_get(obj->eo, &file, &group);
4182 lua_pushstring(L, group);
4183 return 1;
4184}
4185
4186static int
4187_edje_lua_group_get_mouse(lua_State *L)
4188{
4189 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup);
4190 int x, y;
4191 evas_pointer_canvas_xy_get(evas_object_evas_get(obj->eo), &x, &y);
4192 x -= obj->ed->x;
4193 y -= obj->ed->y;
4194 lua_createtable(L, 2, 0);
4195 lua_pushnumber(L, x);
4196 lua_rawseti(L, -2, 1);
4197 lua_pushnumber(L, y);
4198 lua_rawseti(L, -2, 2);
4199 return 1;
4200}
4201
4202static int
4203_edje_lua_group_get_mouse_buttons(lua_State *L)
4204{
4205 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup);
4206 lua_pushnumber(L, evas_pointer_button_down_mask_get(obj->ed->evas));
4207 return 1;
4208}
4209
4210static int
4211_edje_lua_group_get_size_min(lua_State *L)
4212{
4213 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup);
4214 int w, h;
4215 edje_object_size_min_get(obj->eo, &w, &h);
4216 lua_createtable(L, 2, 0);
4217 lua_pushnumber(L, w);
4218 lua_rawseti(L, -2, 1);
4219 lua_pushnumber(L, h);
4220 lua_rawseti(L, -2, 2);
4221 return 1;
4222}
4223
4224static int
4225_edje_lua_group_get_size_max(lua_State *L)
4226{
4227 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup);
4228 int w, h;
4229 edje_object_size_max_get(obj->eo, &w, &h);
4230 lua_createtable(L, 2, 0);
4231 lua_pushnumber(L, w);
4232 lua_rawseti(L, -2, 1);
4233 lua_pushnumber(L, h);
4234 lua_rawseti(L, -2, 2);
4235 return 1;
4236}
4237
4238static int
4239_edje_lua_group_get_scale(lua_State *L)
4240{
4241 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup);
4242 lua_pushnumber(L, edje_object_scale_get(obj->eo));
4243 return 1;
4244}
4245
4246static int
4247_edje_lua_group_get_load_error(lua_State *L)
4248{
4249 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup);
4250 lua_pushnumber(L, edje_object_load_error_get(obj->eo));
4251 return 1;
4252}
4253
4254static int
4255_edje_lua_group_get_load_error_str(lua_State *L)
4256{
4257 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup);
4258 lua_pushstring(L, edje_load_error_str(edje_object_load_error_get(obj->eo)));
4259 return 1;
4260}
4261
4262static int
4263_edje_lua_group_get_play(lua_State *L)
4264{
4265 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup);
4266 lua_pushboolean(L, edje_object_play_get(obj->eo));
4267 return 1;
4268}
4269
4270static int
4271_edje_lua_group_get_animation(lua_State *L)
4272{
4273 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup);
4274 lua_pushboolean(L, edje_object_animation_get(obj->eo));
4275 return 1;
4276}
4277
4278static int
4279_edje_lua_group_get_frametime(lua_State *L)
4280{
4281 lua_pushnumber(L, edje_frametime_get());
4282 return 1;
4283}
4284
4285const luaL_Reg lGroup_get[] = {
4286 {"group", _edje_lua_group_get_group},
4287 {"mouse", _edje_lua_group_get_mouse},
4288 {"mouse_buttons", _edje_lua_group_get_mouse_buttons},
4289 {"size_min", _edje_lua_group_get_size_min},
4290 {"size_max", _edje_lua_group_get_size_max},
4291 {"scale", _edje_lua_group_get_scale},
4292 {"load_error", _edje_lua_group_get_load_error},
4293 {"load_error_str", _edje_lua_group_get_load_error_str},
4294 {"play", _edje_lua_group_get_play},
4295 {"animation", _edje_lua_group_get_animation},
4296 {"frametime", _edje_lua_group_get_frametime},
4297 {NULL, NULL} // sentinel
4298};
4299
4300static int
4301_edje_lua_group_set_group(lua_State *L)
4302{
4303 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup);
4304 edje_object_file_set(obj->eo, obj->ed->file->path, luaL_checkstring(L, 2));
4305 return 0;
4306}
4307
4308static int
4309_edje_lua_group_set_size_min(lua_State *L)
4310{
4311 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup);
4312
4313 luaL_checktype(L, 2, LUA_TTABLE);
4314 lua_rawgeti(L, 2, 1);
4315 lua_rawgeti(L, 2, 2);
4316 obj->ed->collection->prop.min.w = luaL_checkint(L, -2);
4317 obj->ed->collection->prop.min.h = luaL_checkint(L, -1);
4318 obj->ed->dirty = 1;
4319 _edje_recalc(obj->ed);
4320 return 0;
4321}
4322
4323static int
4324_edje_lua_group_set_size_max(lua_State *L)
4325{
4326 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup);
4327 luaL_checktype(L, 2, LUA_TTABLE);
4328 lua_rawgeti(L, 2, 1);
4329 lua_rawgeti(L, 2, 2);
4330 obj->ed->collection->prop.max.w = luaL_checkint(L, -2);
4331 obj->ed->collection->prop.max.h = luaL_checkint(L, -1);
4332 obj->ed->dirty = 1;
4333 _edje_recalc(obj->ed);
4334 return 0;
4335}
4336
4337static int
4338_edje_lua_group_set_scale(lua_State *L)
4339{
4340 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup);
4341 edje_object_scale_set(obj->eo, luaL_checknumber(L, 2));
4342 return 0;
4343}
4344
4345static int
4346_edje_lua_group_set_play(lua_State *L)
4347{
4348 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup);
4349 edje_object_play_set(obj->eo, lua_toboolean(L, 2));
4350 return 0;
4351}
4352
4353static int
4354_edje_lua_group_set_animation(lua_State *L)
4355{
4356 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup);
4357 edje_object_animation_set(obj->eo, lua_toboolean(L, 2));
4358 return 0;
4359}
4360
4361static void
4362_edje_lua_group_text_change_cb(void* data, Evas_Object *obj, const char* part)
4363{
4364 Edje_Lua_Ref *ref = data;
4365 lua_State *L = ref->L;
4366 int err_code;
4367
4368 _edje_lua_get_ref(L, ref);
4369 _edje_lua_get_reg(L, obj);
4370 lua_pushstring(L, part);
4371
4372 if ((err_code = lua_pcall(L, 2, 0, 0)))
4373 _edje_lua_error(L, err_code);
4374}
4375
4376static int
4377_edje_lua_group_set_text_change_cb(lua_State *L)
4378{
4379 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup);
4380 edje_object_text_change_cb_set(obj->eo, _edje_lua_group_text_change_cb, _edje_lua_new_ref(L, 2));
4381 return 0;
4382}
4383
4384static int
4385_edje_lua_group_set_frametime(lua_State *L)
4386{
4387 edje_frametime_set(luaL_checknumber(L, 2));
4388 return 0;
4389}
4390const luaL_Reg lGroup_set[] = {
4391 {"group", _edje_lua_group_set_group},
4392 {"size_min", _edje_lua_group_set_size_min},
4393 {"size_max", _edje_lua_group_set_size_max},
4394 {"scale", _edje_lua_group_set_scale},
4395 {"play", _edje_lua_group_set_play},
4396 {"animation", _edje_lua_group_set_animation},
4397 {"text_change_cb", _edje_lua_group_set_text_change_cb},
4398 {"frametime", _edje_lua_group_set_frametime},
4399 {NULL, NULL} // sentinel
4400};
4401
4402static int
4403_edje_lua_group_fn_timer(lua_State *L)
4404{
4405 Edje_Lua_Timer *tar = lua_newuserdata(L, sizeof(Edje_Lua_Timer));
4406
4407 _edje_lua_set_class(L, -1, cTimer);
4408 /* ^^^^^^^^^^^^^^^^(L, index, class)
4409 lua_newtable(L);
4410 if (index < 0)
4411 lua_setfenv(L, index - 1);
4412 else
4413 lua_setfenv(L, index);
4414
4415 _edje_lua_get_metatable(L, class);
4416 if (index < 0)
4417 lua_setmetatable(L, index - 1);
4418 else
4419 lua_setmetatable(L, index);
4420 */
4421
4422 tar->et = ecore_timer_add(luaL_checknumber(L, 2), _edje_lua_timer_cb, tar);
4423 tar->L = L;
4424
4425 _edje_lua_new_reg(L, -1, tar); // freed in _edje_lua_timer_cb/del
4426 /* ^^^^^^^^^^^^^^(L, index, ptr)
4427 lua_pushvalue(L, index);
4428 lua_pushlightuserdata(L, ptr);
4429 lua_insert(L, -2);
4430 lua_rawset(L, LUA_REGISTRYINDEX); // freed in _edje_lua_free_reg
4431 */
4432
4433 tar->cb = _edje_lua_new_ref(L, 3); // freed in _edje_lua_timer_cb/del
4434 /* ^^^^^^^^^^^^^^^^^^^^^^^^(L, index)
4435 lua_pushvalue(L, index);
4436 Edje_Lua_Ref *ref = malloc(sizeof(Edje_Lua_Ref));
4437 ref->id = luaL_ref(L, LUA_REGISTRYINDEX);
4438 ref->L = L;
4439 return ref;
4440 */
4441 return 1;
4442}
4443
4444static int
4445_edje_lua_group_fn_animator(lua_State *L)
4446{
4447 Edje_Lua_Animator *tar = lua_newuserdata(L, sizeof(Edje_Lua_Animator));
4448 _edje_lua_set_class(L, -1, cAnimator);
4449 tar->ea = ecore_animator_add(_edje_lua_animator_cb, tar);
4450 tar->L = L;
4451 _edje_lua_new_reg(L, -1, tar); // freed in _edje_lua_animator_cb/del
4452 tar->cb = _edje_lua_new_ref(L, 2); // freed in _edje_lua_animator_cb/del
4453 return 1;
4454}
4455
4456static int
4457_edje_lua_group_fn_poller(lua_State *L)
4458{
4459 int interval;
4460 Edje_Lua_Poller *tar;
4461 tar = lua_newuserdata(L, sizeof(Edje_Lua_Poller));
4462 _edje_lua_set_class(L, -1, cPoller);
4463
4464 interval = luaL_checknumber(L, 2);
4465 if ((interval <= 0) || ((interval & 1) != 0))
4466 {
4467 return 0;
4468 }
4469
4470 // Only 1 type of poller currently implemented in ecore
4471 tar->ep = ecore_poller_add(ECORE_POLLER_CORE, interval,
4472 _edje_lua_poller_cb, tar);
4473 tar->L = L;
4474 _edje_lua_new_reg(L, -1, tar); // freed in _edje_lua_poller_cb/del
4475 tar->cb = _edje_lua_new_ref(L, 3); // freed in _edje_lua_poller_cb/del
4476
4477 return 1;
4478}
4479
4480static int
4481_edje_lua_group_fn_transform(lua_State *L)
4482{
4483 Edje_Lua_Transform *tar = lua_newuserdata(L, sizeof(Edje_Lua_Transform));
4484 evas_transform_identity_set (&(tar->et));
4485 _edje_lua_set_class(L, -1, cTransform);
4486 tar->L = L;
4487 return 1;
4488}
4489
4490static int
4491_edje_lua_group_fn_signal_emit(lua_State *L)
4492{
4493 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup);
4494 edje_object_signal_emit(obj->eo,
4495 luaL_checkstring(L, 2), luaL_checkstring(L, 3));
4496 return 0;
4497}
4498
4499static Edje_Program *
4500_edje_lua_program_get_byname(Evas_Object * obj, const char *prog_name)
4501{
4502 Edje_Program *epr;
4503 int i;
4504 Edje *ed;
4505 ed = _edje_fetch(obj);
4506 if (!ed)
4507 return NULL;
4508 if (!prog_name)
4509 return NULL;
4510 for (i = 0; i < ed->table_programs_size; i++)
4511 {
4512 epr = ed->table_programs[i];
4513 if ((epr->name) && (strcmp(epr->name, prog_name) == 0))
4514 return epr;
4515 }
4516 return NULL;
4517}
4518
4519static int
4520_edje_lua_group_fn_program_run(lua_State *L)
4521{
4522 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup);
4523 Edje_Program *pr =
4524 _edje_lua_program_get_byname(obj->eo, luaL_checkstring(L, 2));
4525 if (pr)
4526 _edje_program_run(obj->ed, pr, 0, "", "");
4527 return 0;
4528}
4529
4530static int
4531_edje_lua_group_fn_program_stop(lua_State *L)
4532{
4533 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup);
4534 Edje_Program *pr =
4535 _edje_lua_program_get_byname(obj->eo, luaL_checkstring(L, 2));
4536 int program_id = pr->id;
4537 Edje_Running_Program *runp;
4538 Eina_List *l;
4539 obj->ed->walking_actions = 1;
4540 EINA_LIST_FOREACH(obj->ed->actions, l, runp)
4541 if (program_id == runp->program->id)
4542 _edje_program_end(obj->ed, runp);
4543 obj->ed->walking_actions = 0;
4544 return 0;
4545}
4546
4547static int
4548_edje_lua_group_fn_message_send(lua_State *L)
4549{
4550 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup);
4551 int type = luaL_checkint(L, 2);
4552 void *msg = NULL;
4553 int i;
4554 int size;
4555 switch (type)
4556 {
4557 case EDJE_MESSAGE_NONE:
4558 break;
4559 case EDJE_MESSAGE_SIGNAL:
4560 break;
4561 case EDJE_MESSAGE_STRING:
4562 {
4563 Edje_Message_String *msg_string =
4564 malloc(sizeof(Edje_Message_String));
4565 msg_string->str = (char *)luaL_checkstring(L, 4);
4566 msg = msg_string;
4567 }
4568 break;
4569 case EDJE_MESSAGE_INT:
4570 {
4571 Edje_Message_Int *msg_int = malloc(sizeof(Edje_Message_Int));
4572
4573 msg_int->val = luaL_checkint(L, 4);
4574 msg = msg_int;
4575 }
4576 break;
4577 case EDJE_MESSAGE_FLOAT:
4578 {
4579 Edje_Message_Float *msg_float = malloc(sizeof(Edje_Message_Float));
4580
4581 msg_float->val = luaL_checknumber(L, 4);
4582 msg = msg_float;
4583 }
4584 break;
4585 case EDJE_MESSAGE_STRING_SET:
4586 {
4587 if (lua_type(L, 4) != LUA_TTABLE)
4588 break;
4589 size = lua_objlen(L, 4);
4590 Edje_Message_String_Set *msg_string_set =
4591 malloc(sizeof(Edje_Message_String_Set) +
4592 (size - 1) * sizeof(char *));
4593 msg_string_set->count = size;
4594 for (i = 0; i < size; i++)
4595 {
4596 lua_rawgeti(L, 4, i + 1);
4597 msg_string_set->str[i] = (char *)luaL_checkstring(L, -1);
4598 lua_pop(L, 1);
4599 }
4600 msg = msg_string_set;
4601 }
4602 break;
4603 case EDJE_MESSAGE_INT_SET:
4604 {
4605 if (lua_type(L, 4) != LUA_TTABLE)
4606 break;
4607 size = lua_objlen(L, 4);
4608 Edje_Message_Int_Set *msg_int_set =
4609 malloc(sizeof(Edje_Message_Int_Set) + (size - 1) * sizeof(int));
4610 msg_int_set->count = size;
4611 for (i = 0; i < size; i++)
4612 {
4613 lua_rawgeti(L, 4, i + 1);
4614 msg_int_set->val[i] = luaL_checkint(L, -1);
4615 lua_pop(L, 1);
4616 }
4617 msg = msg_int_set;
4618 }
4619 break;
4620 case EDJE_MESSAGE_FLOAT_SET:
4621 {
4622 if (lua_type(L, 4) != LUA_TTABLE)
4623 break;
4624 size = lua_objlen(L, 4);
4625 Edje_Message_Float_Set *msg_float_set =
4626 malloc(sizeof(Edje_Message_Float_Set) +
4627 (size - 1) * sizeof(double));
4628 msg_float_set->count = size;
4629 for (i = 0; i < size; i++)
4630 {
4631 lua_rawgeti(L, 4, i + 1);
4632 msg_float_set->val[i] = luaL_checknumber(L, -1);
4633 lua_pop(L, 1);
4634 }
4635 msg = msg_float_set;
4636 }
4637 break;
4638 case EDJE_MESSAGE_STRING_INT:
4639 {
4640 Edje_Message_String_Int *msg_string_int =
4641 malloc(sizeof(Edje_Message_String_Int));
4642 msg_string_int->str = (char *)luaL_checkstring(L, 4);
4643 msg_string_int->val = luaL_checkint(L, 5);
4644 msg = msg_string_int;
4645 }
4646 break;
4647 case EDJE_MESSAGE_STRING_FLOAT:
4648 {
4649 Edje_Message_String_Float *msg_string_float =
4650 malloc(sizeof(Edje_Message_String_Float));
4651 msg_string_float->str = (char *)luaL_checkstring(L, 4);
4652 msg_string_float->val = luaL_checknumber(L, 5);
4653 msg = msg_string_float;
4654 }
4655 break;
4656 case EDJE_MESSAGE_STRING_INT_SET:
4657 {
4658 if (lua_type(L, 5) != LUA_TTABLE)
4659 break;
4660 size = lua_objlen(L, 5);
4661 Edje_Message_String_Int_Set *msg_string_int_set =
4662 malloc(sizeof(Edje_Message_String_Int_Set) +
4663 (size - 1) * sizeof(int));
4664 msg_string_int_set->str = (char *)luaL_checkstring(L, 4);
4665 msg_string_int_set->count = size;
4666 for (i = 0; i < size; i++)
4667 {
4668 lua_rawgeti(L, 5, i + 1);
4669 msg_string_int_set->val[i] = luaL_checkint(L, -1);
4670 lua_pop(L, 1);
4671 }
4672 msg = msg_string_int_set;
4673 }
4674 break;
4675 case EDJE_MESSAGE_STRING_FLOAT_SET:
4676 {
4677 if (lua_type(L, 5) != LUA_TTABLE)
4678 break;
4679 size = lua_objlen(L, 5);
4680 Edje_Message_String_Float_Set *msg_string_float_set =
4681 malloc(sizeof(Edje_Message_String_Float_Set) +
4682 (size - 1) * sizeof(double));
4683 msg_string_float_set->str = (char *)luaL_checkstring(L, 4);
4684 msg_string_float_set->count = size;
4685 for (i = 0; i < size; i++)
4686 {
4687 lua_rawgeti(L, 5, i + 1);
4688 msg_string_float_set->val[i] = luaL_checknumber(L, -1);
4689 lua_pop(L, 1);
4690 }
4691 msg = msg_string_float_set;
4692 }
4693 break;
4694 default:
4695 break;
4696 }
4697
4698 if (msg)
4699 {
4700 edje_object_message_send(obj->eo, type, luaL_checkint(L, 3), msg);
4701 free(msg);
4702 }
4703
4704 return 0;
4705}
4706
4707static void
4708_edje_lua_group_signal_callback(void *data, Evas_Object * edj,
4709 const char *signal, const char *source)
4710{
4711 Edje_Lua_Ref *cb = data;
4712 lua_State *L = cb->L;
4713 _edje_lua_get_ref(L, cb); // signal callback function
4714 if (lua_isfunction(L, -1))
4715 {
4716 int err_code;
4717
4718 _edje_lua_get_reg(L, edj);
4719 lua_pushstring(L, signal); // signal
4720 lua_pushstring(L, source); // source
4721
4722 if ((err_code = lua_pcall(L, 3, 0, 0)))
4723 _edje_lua_error(L, err_code);
4724 }
4725}
4726
4727static int
4728_edje_lua_group_fn_signal_callback_add(lua_State *L)
4729{
4730 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup);
4731 if (lua_type(L, 4) == LUA_TFUNCTION)
4732 {
4733 Edje_Lua_Ref *ref = _edje_lua_new_ref(L, 4);
4734 obj->cb = eina_list_append(obj->cb, ref);
4735 edje_object_signal_callback_add(obj->eo,
4736 luaL_checkstring(L, 2),
4737 luaL_checkstring(L, 3),
4738 _edje_lua_group_signal_callback,
4739 ref); // freed in _edje_lua_group_fn_signal_callback_del
4740 }
4741 return 0;
4742}
4743
4744static int
4745_edje_lua_group_fn_signal_callback_del(lua_State *L)
4746{
4747 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup);
4748 Edje_Lua_Ref *ref = edje_object_signal_callback_del(obj->eo,
4749 luaL_checkstring(L, 2),
4750 luaL_checkstring(L, 3),
4751 _edje_lua_group_signal_callback);
4752 obj->cb = eina_list_remove(obj->cb, ref);
4753 _edje_lua_free_ref(L, ref); // created in _edje_lua_group_fn_signal_callback_add
4754 return 0;
4755}
4756
4757static int
4758_edje_lua_group_fn_freeze(lua_State *L)
4759{
4760 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup);
4761 edje_object_freeze(obj->eo);
4762 return 0;
4763}
4764
4765static int
4766_edje_lua_group_fn_thaw(lua_State *L)
4767{
4768 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup);
4769 edje_object_thaw(obj->eo);
4770 return 0;
4771}
4772
4773const luaL_Reg lGroup_fn[] = {
4774 {"timer", _edje_lua_group_fn_timer},
4775 {"animator", _edje_lua_group_fn_animator},
4776 {"poller", _edje_lua_group_fn_poller},
4777 {"transform", _edje_lua_group_fn_transform},
4778 {"signal_emit", _edje_lua_group_fn_signal_emit},
4779 {"message_send", _edje_lua_group_fn_message_send},
4780 {"program_run", _edje_lua_group_fn_program_run},
4781 {"program_stop", _edje_lua_group_fn_program_stop},
4782 {"signal_callback_add", _edje_lua_group_fn_signal_callback_add},
4783 {"signal_callback_del", _edje_lua_group_fn_signal_callback_del},
4784 {"freeze", _edje_lua_group_fn_freeze},
4785 {"thaw", _edje_lua_group_fn_thaw},
4786 {NULL, NULL} // sentinel
4787};
4788
4789/*
4790 * Lua bindings
4791 */
4792
4793const luaL_Reg lScript_get[];
4794
4795const luaL_Reg lScript_set[];
4796
4797const luaL_Reg lScript_fn[];
4798
4799const Edje_Lua_Reg mScript = {
4800 lNil,
4801 lScript_get,
4802 lScript_set,
4803 lScript_fn
4804};
4805
4806const Edje_Lua_Reg *cScript[] = {
4807 &mClass,
4808 &mObject,
4809 &mGroup,
4810 &mScript,
4811 NULL // sentinel
4812};
4813
4814/*
4815 * macro for adding an evas_object in the lua_script_only object
4816 */
4817#define _EDJE_LUA_SCRIPT_FN_ADD(DEF, CLASS, FUNC) \
4818 static int \
4819 DEF (lua_State *L) \
4820 { \
4821 int set = lua_gettop (L) == 2; \
4822 Edje_Lua_Evas_Object *obj = _edje_lua_checkudata (L, 1, &mScript); \
4823 Edje_Lua_Evas_Object *tar = lua_newuserdata (L, sizeof (Edje_Lua_Evas_Object)); \
4824 _edje_lua_set_class (L, -1, CLASS); \
4825 tar->eo = FUNC (obj->ed->evas); \
4826 tar->ed = obj->ed; \
4827 tar->L = L; \
4828 tar->cb = NULL; \
4829 evas_object_move (tar->eo, obj->ed->x, obj->ed->y); \
4830 _edje_lua_new_reg (L, -1, tar); /* freed in _edje_lua_object_del_cb */ \
4831 _edje_lua_new_reg (L, -1, tar->eo); /* freed in _edje_lua_object_del_cb */ \
4832 evas_object_smart_member_add (tar->eo, obj->eo); \
4833 evas_object_clip_set (tar->eo, obj->ed->clipper); \
4834 evas_object_event_callback_add (tar->eo, EVAS_CALLBACK_DEL, _edje_lua_object_del_cb, L); \
4835 if (set) \
4836 { \
4837 int err_code; \
4838 lua_getfield (L, -1, "set"); \
4839 lua_pushvalue (L, -2); \
4840 lua_pushvalue (L, 2); \
4841 if ((err_code = lua_pcall (L, 2, 0, 0))) \
4842 _edje_lua_error (L, err_code); \
4843 } \
4844 return 1; \
4845 }
4846
4847_EDJE_LUA_SCRIPT_FN_ADD(_edje_lua_script_fn_rectangle,
4848 cRectangle,
4849 evas_object_rectangle_add)
4850_EDJE_LUA_SCRIPT_FN_ADD(_edje_lua_script_fn_image,
4851 cImage,
4852 evas_object_image_add)
4853_EDJE_LUA_SCRIPT_FN_ADD(_edje_lua_script_fn_table,
4854 cTable,
4855 evas_object_table_add)
4856_EDJE_LUA_SCRIPT_FN_ADD(_edje_lua_script_fn_line,
4857 cLine,
4858 evas_object_line_add)
4859_EDJE_LUA_SCRIPT_FN_ADD(_edje_lua_script_fn_polygon,
4860 cPolygon,
4861 evas_object_polygon_add)
4862_EDJE_LUA_SCRIPT_FN_ADD(_edje_lua_script_fn_group, cGroup, edje_object_add)
4863
4864const luaL_Reg lScript_fn[] = {
4865 {"rectangle", _edje_lua_script_fn_rectangle},
4866 {"image", _edje_lua_script_fn_image},
4867 {"table", _edje_lua_script_fn_table},
4868 {"line", _edje_lua_script_fn_line},
4869 {"polygon", _edje_lua_script_fn_polygon},
4870 {"group", _edje_lua_script_fn_group},
4871 {NULL, NULL} // sentinel
4872};
4873
4874const luaL_Reg lScript_get[] = {
4875 {NULL, NULL} // sentinel
4876};
4877
4878const luaL_Reg lScript_set[] = {
4879 {NULL, NULL} // sentinel
4880};
4881
4882/*
4883 * creates and exports a lua_script_only object
4884 */
4885void
4886_edje_lua_script_fn_new(Edje * ed)
4887{
4888 lua_State *L = ed->L;
4889 Edje_Lua_Evas_Object *tar = lua_newuserdata(L, sizeof(Edje_Lua_Evas_Object));
4890 _edje_lua_set_class(L, -1, cScript);
4891 tar->eo = ed->obj;
4892 tar->ed = ed;
4893 tar->L = L;
4894 tar->cb = NULL;
4895 _edje_lua_new_reg(L, -1, tar); // freed in _edje_lua_object_del_cb
4896 _edje_lua_new_reg(L, -1, ed); // freed in edje_load.c::_edje_file_del
4897 _edje_lua_new_reg(L, -1, ed->obj); // freed in _edje_lua_object_del_cb
4898 evas_object_event_callback_add(tar->eo, EVAS_CALLBACK_DEL,
4899 _edje_lua_object_del_cb, L);
4900}
4901
4902/*
4903 * creates and exports an Edje group with associated Lua scripts in the parts and programs sections
4904 */
4905void
4906_edje_lua_group_fn_new(Edje * ed)
4907{
4908 lua_State *L = ed->L;
4909 Edje_Lua_Evas_Object *tar = lua_newuserdata(L, sizeof(Edje_Lua_Evas_Object));
4910 _edje_lua_set_class(L, -1, cGroup);
4911 tar->eo = ed->obj;
4912 tar->ed = ed;
4913 tar->L = L;
4914 tar->cb = NULL;
4915 _edje_lua_new_reg(L, -1, tar); // freed in _edje_lua_object_del_cb
4916 _edje_lua_new_reg(L, -1, ed); // freed in edje_load.c::_edje_file_del
4917 _edje_lua_new_reg(L, -1, ed->obj); // freed in _edje_lua_object_del_cb
4918 evas_object_event_callback_add(tar->eo, EVAS_CALLBACK_DEL,
4919 _edje_lua_object_del_cb, L);
4920}
4921
4922/*
4923 * this function loads all the Lua bindings into the global Lua state
4924 */
4925static void
4926_edje_lua_open(lua_State *L)
4927{
4928 /*
4929 * export classes
4930 */
4931 _edje_lua_new_class(L, cTimer);
4932 _edje_lua_new_class(L, cAnimator);
4933 _edje_lua_new_class(L, cPoller);
4934 _edje_lua_new_class(L, cTransform);
4935 _edje_lua_new_class(L, cRectangle);
4936 _edje_lua_new_class(L, cImage);
4937 _edje_lua_new_class(L, cTable);
4938 _edje_lua_new_class(L, cLine);
4939 _edje_lua_new_class(L, cPolygon);
4940 _edje_lua_new_class(L, cGroup);
4941 _edje_lua_new_class(L, cDescription);
4942 _edje_lua_new_class(L, cPart);
4943 _edje_lua_new_class(L, cScript);
4944
4945 /*
4946 * export constants
4947 */
4948 _edje_lua_new_const(L, "MESSAGE_NONE", EDJE_MESSAGE_NONE);
4949 _edje_lua_new_const(L, "MESSAGE_SIGNAL", EDJE_MESSAGE_SIGNAL);
4950 _edje_lua_new_const(L, "MESSAGE_STRING", EDJE_MESSAGE_STRING);
4951 _edje_lua_new_const(L, "MESSAGE_INT", EDJE_MESSAGE_INT);
4952 _edje_lua_new_const(L, "MESSAGE_FLOAT", EDJE_MESSAGE_FLOAT);
4953 _edje_lua_new_const(L, "MESSAGE_STRING_SET", EDJE_MESSAGE_STRING_SET);
4954 _edje_lua_new_const(L, "MESSAGE_INT_SET", EDJE_MESSAGE_INT_SET);
4955 _edje_lua_new_const(L, "MESSAGE_FLOAT_SET", EDJE_MESSAGE_FLOAT_SET);
4956 _edje_lua_new_const(L, "MESSAGE_STRING_INT", EDJE_MESSAGE_STRING_INT);
4957 _edje_lua_new_const(L, "MESSAGE_STRING_FLOAT", EDJE_MESSAGE_STRING_FLOAT);
4958 _edje_lua_new_const(L, "MESSAGE_STRING_INT_SET", EDJE_MESSAGE_STRING_INT_SET);
4959 _edje_lua_new_const(L, "MESSAGE_STRING_FLOAT_SET", EDJE_MESSAGE_STRING_FLOAT_SET);
4960
4961 _edje_lua_new_const(L, "PART_TYPE_NONE", EDJE_PART_TYPE_NONE);
4962 _edje_lua_new_const(L, "PART_TYPE_RECTANGLE", EDJE_PART_TYPE_RECTANGLE);
4963 _edje_lua_new_const(L, "PART_TYPE_TEXT", EDJE_PART_TYPE_TEXT);
4964 _edje_lua_new_const(L, "PART_TYPE_IMAGE", EDJE_PART_TYPE_IMAGE);
4965 _edje_lua_new_const(L, "PART_TYPE_SWALLOW", EDJE_PART_TYPE_SWALLOW);
4966 _edje_lua_new_const(L, "PART_TYPE_TEXTBLOCK", EDJE_PART_TYPE_TEXTBLOCK);
4967 _edje_lua_new_const(L, "PART_TYPE_GRADIENT", EDJE_PART_TYPE_GRADIENT);
4968 _edje_lua_new_const(L, "PART_TYPE_GROUP", EDJE_PART_TYPE_GROUP);
4969 _edje_lua_new_const(L, "PART_TYPE_BOX", EDJE_PART_TYPE_BOX);
4970
4971 _edje_lua_new_const(L, "TEXT_EFFECT_NONE", EDJE_TEXT_EFFECT_NONE);
4972 _edje_lua_new_const(L, "TEXT_EFFECT_PLAIN", EDJE_TEXT_EFFECT_PLAIN);
4973 _edje_lua_new_const(L, "TEXT_EFFECT_OUTLINE", EDJE_TEXT_EFFECT_OUTLINE);
4974 _edje_lua_new_const(L, "TEXT_EFFECT_OTLINE", EDJE_TEXT_EFFECT_SOFT_OUTLINE);
4975 _edje_lua_new_const(L, "TEXT_EFFECT_SHADOW", EDJE_TEXT_EFFECT_SHADOW);
4976 _edje_lua_new_const(L, "TEXT_EFFECT_SOFT_SHADOW", EDJE_TEXT_EFFECT_SOFT_SHADOW);
4977 _edje_lua_new_const(L, "TEXT_EFFECT_OUTLINE_SHADOW", EDJE_TEXT_EFFECT_OUTLINE_SHADOW);
4978 _edje_lua_new_const(L, "TEXT_EFFECT_OUTLINE_SOFT_SHADOW", EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW);
4979 _edje_lua_new_const(L, "TEXT_EFFECT_FAR_SHADOW", EDJE_TEXT_EFFECT_FAR_SHADOW);
4980 _edje_lua_new_const(L, "TEXT_EFFECT_FAR_SOFT_SHADOW", EDJE_TEXT_EFFECT_FAR_SOFT_SHADOW);
4981 _edje_lua_new_const(L, "TEXT_EFFECT_GLOW", EDJE_TEXT_EFFECT_GLOW);
4982
4983 _edje_lua_new_const(L, "RENDER_BLEND", EVAS_RENDER_BLEND);
4984 _edje_lua_new_const(L, "RENDER_BLEND_REL", EVAS_RENDER_BLEND_REL);
4985 _edje_lua_new_const(L, "RENDER_COPY", EVAS_RENDER_COPY);
4986 _edje_lua_new_const(L, "RENDER_COPY_REL", EVAS_RENDER_COPY_REL);
4987 _edje_lua_new_const(L, "RENDER_ADD", EVAS_RENDER_ADD);
4988 _edje_lua_new_const(L, "RENDER_ADD_REL", EVAS_RENDER_ADD_REL);
4989 _edje_lua_new_const(L, "RENDER_SUB", EVAS_RENDER_SUB);
4990 _edje_lua_new_const(L, "RENDER_SUB_REL", EVAS_RENDER_SUB_REL);
4991 _edje_lua_new_const(L, "RENDER_TINT", EVAS_RENDER_TINT);
4992 _edje_lua_new_const(L, "RENDER_TINT_REL", EVAS_RENDER_TINT_REL);
4993 _edje_lua_new_const(L, "RENDER_MASK", EVAS_RENDER_MASK);
4994 _edje_lua_new_const(L, "RENDER_MUL", EVAS_RENDER_MUL);
4995
4996 _edje_lua_new_const(L, "BORDER_FILL_NONE", EVAS_BORDER_FILL_NONE);
4997 _edje_lua_new_const(L, "BORDER_FILL_DEFAULT", EVAS_BORDER_FILL_DEFAULT);
4998 _edje_lua_new_const(L, "BORDER_FILL_SOLID", EVAS_BORDER_FILL_SOLID);
4999
5000 _edje_lua_new_const(L, "POINTER_MODE_AUTOGRAB", EVAS_OBJECT_POINTER_MODE_AUTOGRAB);
5001 _edje_lua_new_const(L, "POINTER_MODE_NOGRAB", EVAS_OBJECT_POINTER_MODE_NOGRAB);
5002
5003 _edje_lua_new_const(L, "ASPECT_CONTROL_NEITHER", EVAS_ASPECT_CONTROL_NEITHER);
5004 _edje_lua_new_const(L, "ASPECT_CONTROL_HORIZONTAL", EVAS_ASPECT_CONTROL_HORIZONTAL);
5005 _edje_lua_new_const(L, "ASPECT_CONTROL_VERTICAL", EVAS_ASPECT_CONTROL_VERTICAL);
5006 _edje_lua_new_const(L, "ASPECT_CONTROL_BOTH", EVAS_ASPECT_CONTROL_BOTH);
5007
5008 _edje_lua_new_const(L, "CALLBACK_RENEW", ECORE_CALLBACK_RENEW);
5009 _edje_lua_new_const(L, "CALLBACK_CANCEL", ECORE_CALLBACK_CANCEL);
5010}
5011
5012/*
5013 * main Lua state
5014 * created by edje_init ()
5015 * closed by edje_shutdown ()
5016 * any other private Lua state inherits from this global state
5017 */
5018static lua_State *Ledje = NULL;
5019
5020lua_State *
5021_edje_lua_state_get ()
5022{
5023 return Ledje;
5024}
5025
5026/*
5027 * custom memory allocation function
5028 * raises an error, if memory usage is above the given maximum
5029 */
5030static void *
5031_edje_lua_alloc(void *ud, void *ptr, size_t osize, size_t nsize)
5032{
5033 Edje_Lua_Alloc *ela = ud;
5034 void *ptr2;
5035
5036 ela->cur += nsize - osize;
5037 if (ela->cur > ela->max)
5038 {
5039 ERR("Edje Lua memory limit of %zu bytes reached (%zu allocated)",
5040 ela->max, ela->cur);
5041 return NULL;
5042 }
5043 if (nsize == 0)
5044 {
5045 free(ptr); /* ANSI requires that free(NULL) has no effect */
5046 return NULL;
5047 }
5048
5049 /* ANSI requires that realloc(NULL, size) == malloc(size) */
5050 ptr2 = realloc(ptr, nsize);
5051 if (ptr2) return ptr2;
5052 ERR("Edje Lua cannot re-allocate %zu bytes", nsize);
5053 return ptr2;
5054}
5055
5056void
5057_edje_lua_init()
5058{
5059 if (Ledje != NULL) return;
5060 /*
5061 * create main Lua state with the custom memory allocation function
5062 */
5063 static Edje_Lua_Alloc ela = { 1e7, 0 }; // TODO make the memory limit configurable?
5064 Ledje = lua_newstate(_edje_lua_alloc, &ela);
5065 if (!Ledje)
5066 {
5067 ERR("Lua error: Lua state could not be initialized");
5068 exit(-1);
5069 }
5070
5071 lua_atpanic(Ledje, _edje_lua_custom_panic);
5072
5073 /*
5074 * configure Lua garbage collector
5075 * TODO optimize garbage collector for typical edje use or make it configurable
5076 */
5077 lua_gc(Ledje, LUA_GCSETPAUSE, 200);
5078 lua_gc(Ledje, LUA_GCSETSTEPMUL, 200);
5079
5080 /*
5081 * sandbox Lua
5082 * no access to io, os and package routines
5083 * no loading and execution of files
5084 * no loading and execution of strings
5085 * no access to the OS environment
5086 */
5087 luaopen_base(Ledje);
5088 luaopen_table(Ledje);
5089 luaopen_string(Ledje);
5090 luaopen_math(Ledje);
5091 luaopen_os(Ledje);
5092
5093 /*
5094 * FIXME
5095 * this is just for debug purposes
5096 * remove it in the final version
5097 */
5098 lua_pushnil(Ledje);
5099 lua_setglobal(Ledje, "load");
5100 lua_pushnil(Ledje);
5101 lua_setglobal(Ledje, "loadfile");
5102 lua_pushnil(Ledje);
5103 lua_setglobal(Ledje, "loadstring");
5104 lua_pushnil(Ledje);
5105 lua_setglobal(Ledje, "dofile");
5106 lua_pushnil(Ledje);
5107 lua_setglobal(Ledje, "dostring");
5108
5109 lua_getglobal(Ledje, "os");
5110 lua_pushnil(Ledje);
5111 lua_setfield(Ledje, -2, "exit");
5112 lua_pushnil(Ledje);
5113 lua_setfield(Ledje, -2, "setlocale");
5114 lua_pushnil(Ledje);
5115 lua_setfield(Ledje, -2, "getenv");
5116 lua_pushnil(Ledje);
5117 lua_setfield(Ledje, -2, "remove");
5118 lua_pushnil(Ledje);
5119 lua_setfield(Ledje, -2, "tmpname");
5120 lua_pushnil(Ledje);
5121 lua_setfield(Ledje, -2, "rename");
5122 lua_pushnil(Ledje);
5123 lua_setfield(Ledje, -2, "execute");
5124 lua_pushnil(Ledje);
5125
5126 /*
5127 * we need a weak value registry
5128 * so that deleted and unused objects can be garbage collected
5129 */
5130 lua_createtable(Ledje, 1, 0);
5131 //lua_pushstring(Ledje, "v");
5132 lua_pushstring(Ledje, "");
5133 lua_setfield(Ledje, -2, "__mode");
5134 lua_setmetatable(Ledje, LUA_REGISTRYINDEX);
5135
5136 /*
5137 * load Lua Evas/Edje bindings
5138 */
5139 _edje_lua_open(Ledje);
5140}
5141
5142void
5143_edje_lua_shutdown()
5144{
5145 if (Ledje == NULL) return;
5146 lua_close(Ledje);
5147 Ledje = NULL;
5148}
5149
5150#endif
diff --git a/libraries/edje/src/lib/edje_lua2.c b/libraries/edje/src/lib/edje_lua2.c
new file mode 100644
index 0000000..2318af9
--- /dev/null
+++ b/libraries/edje/src/lib/edje_lua2.c
@@ -0,0 +1,4129 @@
1// FIXME: Some error checking would be nice.
2
3
4#include "edje_private.h"
5#include <ctype.h>
6
7#define RASTER_FORGOT_WHY "this is here."
8
9#ifdef _WIN32
10# define FMT_SIZE_T "%Iu"
11#else
12# define FMT_SIZE_T "%zu"
13#endif
14
15//--------------------------------------------------------------------------//
16#define MAX_LUA_MEM (4 * (1024 * 1024))
17#define ELO "|-ELO"
18
19#define LC(...) EINA_LOG_DOM_CRIT(_log_domain, __VA_ARGS__)
20#define LE(...) EINA_LOG_DOM_ERR(_log_domain, __VA_ARGS__)
21#define LW(...) EINA_LOG_DOM_WARN(_log_domain, __VA_ARGS__)
22#define LI(...) EINA_LOG_DOM_INFO(_log_domain, __VA_ARGS__)
23#define LD(...) EINA_LOG_DOM_DBG(_log_domain, __VA_ARGS__)
24
25/**
26@page luaref Edje Lua scripting
27
28@section intro Introduction
29
30Lua is intended for script-only objects at this point (with embryo left
31for augmenting standard programs). Since script-only objects effectively
32define objects entirely via Lua script (resize handling, event handling
33etc. etc.) this places many more demands on them, and thus a more powerful
34language is in order. Lua is that language.
35
36To get you started, here's an example that uses most of this lua API:
37@ref lua_script.edc
38
39Most of these lua functions are wrappers around various evas, ecore, and edje C
40functions. Refer to their documentation for more in depth details and up to
41date documentation. A lot of this documentation is simple copied from the C
42functions it wraps.
43
44@section args Lua function argument and return syntax
45
46Some of the lua functions can accept a table as well as separate arguments.
47Some of them return tables.
48
49@section classes Lua classes
50
51*/
52
53/*
54Lua functions stack usage.
55
56In the definition of the lua functions provided, always mention the stack usage,
57using the same notation that is used in the Lua 5.1 Reference Manual.
58http://www.lua.org/manual/5.1/manual.html#3.7 describes that notation.
59
60On the other hand, lua discards excess stack entries when control passes back to
61it, but it's good to maintain proper discipline.
62
63Should do the same for the support functions. These ARE more important to check.
64*/
65
66//--------------------------------------------------------------------------//
67typedef struct _Edje_Lua_Alloc Edje_Lua_Alloc;
68typedef struct _Edje_Lua_Obj Edje_Lua_Obj;
69typedef struct _Edje_Lua_Animator Edje_Lua_Animator;
70typedef struct _Edje_Lua_Timer Edje_Lua_Timer;
71typedef struct _Edje_Lua_Transition Edje_Lua_Transition;
72typedef struct _Edje_Lua_Evas_Object Edje_Lua_Evas_Object;
73typedef struct _Edje_Lua_Map Edje_Lua_Map;
74
75struct _Edje_Lua_Alloc
76{
77 size_t max, cur;
78};
79
80struct _Edje_Lua_Obj
81{
82 EINA_INLIST;
83
84 Edje *ed;
85 void (*free_func) (void *obj);
86 const char *meta;
87};
88
89struct _Edje_Lua_Animator
90{
91 Edje_Lua_Obj obj;
92 Ecore_Animator *animator;
93 int fn_ref;
94};
95
96struct _Edje_Lua_Timer
97{
98 Edje_Lua_Obj obj;
99 Ecore_Timer *timer;
100 int fn_ref;
101};
102
103struct _Edje_Lua_Transition
104{
105 Edje_Lua_Obj obj;
106 Ecore_Animator *animator;
107 double transition, start;
108 int fn_ref;
109};
110
111struct _Edje_Lua_Evas_Object
112{
113 Edje_Lua_Obj obj;
114 Evas_Object *evas_obj;
115 int x, y;
116};
117
118struct _Edje_Lua_Map
119{
120 Edje_Lua_Obj obj;
121 Evas_Map *map;
122};
123
124
125static void _elua_add_functions(lua_State *L, const char *api, const luaL_Reg *funcs, const char *meta, const char *parent, const char *base);
126static Eina_Bool _elua_isa(Edje_Lua_Obj *obj, const char *type);
127
128//--------------------------------------------------------------------------//
129#ifndef RASTER_FORGOT_WHY
130static lua_State *lstate = NULL;
131#endif
132static const char *_elua_key = "key";
133static const char *_elua_objs = "objs";
134/* This is not needed, pcalls don't longjmp(), that's why they are protected.
135static jmp_buf panic_jmp;
136*/
137static int panics = 0;
138static int _log_domain = -1;
139static int _log_count = 0;
140
141// FIXME: methods lua script can provide that edje will call (not done yet):
142// // scale set
143// // key down
144// // key up
145// // get dragable pos
146// // set dragable pos
147// // set drag size, step, page
148// // get drag size, step, page
149// // dragable step
150// // dragable page
151// // get part text
152// // set part text
153// // get swallow part
154// // set swallow part
155// // unswallow part
156// // textclass change
157// // colorclass change
158// // min size get <- ?? maybe set fn
159// // max size get <- ?? maybe set fn
160// // min size caclc (min/max restriction)
161// // preload
162// // preload cancel
163// // play set
164// // animation set
165// // parts extends calc
166// // part object get
167// // part geometry get
168//
169// // LATER: all the entry calls
170// // LATER: box and table calls
171// // LATER: perspective stuff change
172//
173
174// Grumble, pre-declare these.
175static const char *_elua_edje_meta = "edje_meta";
176static const char *_elua_evas_meta = "evas_meta";
177static const char *_elua_evas_edje_meta = "evas_edje_meta";
178static const char *_elua_evas_image_meta = "evas_image_meta";
179static const char *_elua_evas_line_meta = "evas_line_meta";
180static const char *_elua_evas_map_meta = "evas_map_meta";
181static const char *_elua_evas_polygon_meta = "evas_polygon_meta";
182static const char *_elua_evas_text_meta = "evas_text_meta";
183static const char *_elua_ecore_animator_meta = "ecore_animator_meta";
184static const char *_elua_ecore_timer_meta = "ecore_timer_meta";
185
186static int _elua_obj_gc(lua_State *L);
187
188static const struct luaL_reg _elua_edje_gc_funcs [] =
189{
190 {"__gc", _elua_obj_gc}, // garbage collector func for edje objects
191
192 {NULL, NULL} // end
193};
194
195static const luaL_Reg _elua_libs[] =
196{
197 {"", luaopen_base},
198// {LUA_LOADLIBNAME, luaopen_package}, // disable this lib - don't want
199 {LUA_TABLIBNAME, luaopen_table},
200// {LUA_IOLIBNAME, luaopen_io}, // disable this lib - don't want
201// {LUA_OSLIBNAME, luaopen_os}, // FIXME: audit os lib - maybe not provide or only provide specific calls
202 {LUA_STRLIBNAME, luaopen_string},
203 {LUA_MATHLIBNAME, luaopen_math},
204// {LUA_DBLIBNAME, luaopen_debug}, // disable this lib - don't want
205
206 {NULL, NULL} // end
207};
208
209//--------------------------------------------------------------------------//
210static void *
211_elua_alloc(void *ud, void *ptr, size_t osize, size_t nsize)
212{
213 Edje_Lua_Alloc *ela = ud;
214 void *ptr2;
215
216 ela->cur += nsize - osize;
217 if (ela->cur > ela->max)
218 {
219 ERR("Lua memory limit of " FMT_SIZE_T " bytes reached (" FMT_SIZE_T " allocated)",
220 ela->max, ela->cur);
221 return NULL;
222 }
223 if (nsize == 0)
224 {
225 free(ptr);
226 return NULL;
227 }
228
229 ptr2 = realloc(ptr, nsize);
230 if (ptr2) return ptr2;
231 ERR("Lua cannot re-allocate " FMT_SIZE_T " bytes", nsize);
232 return ptr2;
233}
234
235static int
236_elua_custom_panic(lua_State *L) // Stack usage [-0, +0, m]
237{
238 // If we somehow manage to have multiple panics, it's likely due to being out
239 // of memory in the following lua_tostring() call.
240 panics++;
241 if (panics)
242 {
243 EINA_LOG_DOM_CRIT(_edje_default_log_dom, "Lua PANICS!!!!!");
244 }
245 else
246 {
247 EINA_LOG_DOM_CRIT(_edje_default_log_dom,
248 "Lua PANIC!!!!!: %s", lua_tostring(L, -1)); // Stack usage [-0, +0, m]
249 }
250 // The docs say that this will cause an exit(EXIT_FAILURE) if we return,
251 // and that we we should long jump some where to avoid that. This is only
252 // called for things not called from a protected environment. We always
253 // use pcalls though, except for the library load calls. If we can't load
254 // the standard libraries, then perhaps a crash is the right thing.
255 return 0;
256}
257
258// Really only used to manage the pointer to our edje.
259static void
260_elua_table_ptr_set(lua_State *L, const void *key, const void *val) // Stack usage [-2, +2, e]
261{
262 lua_pushlightuserdata(L, (void *)key); // Stack usage [-0, +1, -]
263 lua_pushlightuserdata(L, (void *)val); // Stack usage [-0, +1, -]
264 lua_settable(L, LUA_REGISTRYINDEX); // Stack usage [-2, +0, e]
265}
266
267static const void *
268_elua_table_ptr_get(lua_State *L, const void *key) // Stack usage [-2, +2, e]
269{
270 const void *ptr;
271 lua_pushlightuserdata(L, (void *)key); // Stack usage [-0, +1, -]
272 lua_gettable(L, LUA_REGISTRYINDEX); // Stack usage [-1, +1, e]
273 ptr = lua_topointer(L, -1); // Stack usage [-0, +0, -]
274 lua_pop(L, 1); // Stack usage [-n, +0, -]
275 return ptr;
276}
277
278/* XXX: not used
279static void
280_elua_table_ptr_del(lua_State *L, const void *key) // Stack usage [-2, +2, e]
281{
282 lua_pushlightuserdata(L, (void *)key); // Stack usage [-0, +1, -]
283 lua_pushnil(L); // Stack usage [-0, +1, -]
284 lua_settable(L, LUA_REGISTRYINDEX); // Stack usage [-2, +0, e]
285}
286*/
287
288/*
289 * Cori: Assumes object to be saved on top of stack
290 */
291static void
292_elua_ref_set(lua_State *L, void *key) // Stack usage [-4, +4, m]
293{
294 lua_pushlightuserdata(L, &_elua_objs); // Stack usage [-0, +1, -]
295 lua_rawget(L, LUA_REGISTRYINDEX); // Stack usage [-1, +1, -]
296 lua_pushlightuserdata(L, key); // Stack usage [-0, +1, -]
297 lua_pushvalue(L,-3); // Stack usage [-0, +1, -]
298 lua_rawset(L, -3); // Stack usage [-2, +0, m]
299 lua_pop(L, 1); // Stack usage [-n, +0, -]
300}
301
302/*
303 * Cori: Get an object from the object table
304 */
305static void *
306_elua_ref_get(lua_State *L, void *key) // Stack usage [-3, +4, -]
307{
308 lua_pushlightuserdata(L, &_elua_objs); // Stack usage [-0, +1, -]
309 lua_rawget(L, LUA_REGISTRYINDEX); // Stack usage [-1, +1, -]
310 lua_pushlightuserdata(L, key); // Stack usage [-0, +1, -]
311 lua_rawget(L, -2); // Stack usage [-1, +1, -]
312 lua_remove(L, -2); // Stack usage [-1, +0, -]
313 return lua_touserdata(L, -2); // Stack usage [-0, +0, -]
314}
315
316static Edje_Lua_Obj *
317_elua_obj_new(lua_State *L, Edje *ed, int size, const char *metatable) // Stack usage [-5, +6, m]
318{
319 Edje_Lua_Obj *obj;
320
321 obj = (Edje_Lua_Obj *)lua_newuserdata(L, size); // Stack usage [-0, +1, m]
322 memset(obj, 0, size);
323 ed->lua_objs = eina_inlist_append(ed->lua_objs, EINA_INLIST_GET(obj));
324
325 luaL_getmetatable(L, metatable); // Stack usage [-0, +1, -]
326 lua_setmetatable(L, -2); // Stack usage [-1, +0, -]
327 obj->ed = ed;
328 obj->meta = metatable;
329
330 _elua_ref_set(L, obj); // Stack usage [-4, +4, m]
331 return obj;
332}
333
334static void
335_elua_obj_free(lua_State *L __UNUSED__, Edje_Lua_Obj *obj)
336{
337 if (!obj->free_func) return;
338 obj->free_func(obj);
339 obj->ed->lua_objs = eina_inlist_remove(obj->ed->lua_objs, EINA_INLIST_GET(obj));
340 obj->free_func = NULL;
341 obj->ed = NULL;
342}
343
344static int
345_elua_obj_gc(lua_State *L) // Stack usage [-0, +0, -]
346{
347 Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -]
348 if (!obj) return 0;
349 _elua_obj_free(L, obj);
350 return 0;
351}
352
353static int
354_elua_obj_del(lua_State *L) // Stack usage [-0, +0, -]
355{
356 return _elua_obj_gc(L); // Stack usage [-0, +0, -]
357}
358
359static void
360_elua_gc(lua_State *L) // Stack usage [-0, +0, e]
361{
362 lua_gc(L, LUA_GCCOLLECT, 0); // Stack usage [-0, +0, e]
363}
364
365// These are what the various symbols are for each type -
366// int %
367// num #
368// str $
369// bool !
370// FIXME: Still to do, if we ever use them -
371// func &
372// userdata +
373// lightuserdata *
374// table @
375// thread ^
376// nil ~
377
378static char *
379_elua_push_name(lua_State *L, char *q, int index) // Stack usage [-0, +1, e or m]
380{
381 char *p = q;
382 char temp = '\0';
383
384 // A simplistic scan through an identifier, it's wrong, but it's quick,
385 // and we don't mind that it's wrong, coz this is only internal.
386 while (isalnum((int)*q))
387 q++;
388 temp = *q;
389 *q = '\0';
390 if (index > 0)
391 lua_getfield(L, index, p); // Stack usage [-0, +1, e]
392 else
393 lua_pushstring(L, p); // Stack usage [-0, +1, m]
394 *q = temp;
395
396 return q;
397}
398
399static int
400_elua_scan_params(lua_State *L, int i, char *params, ...) // Stack usage -
401 // if i is a table
402 // [-n, +n, e]
403 // else
404 // [-0, +0, -]
405{
406 va_list vl;
407 char *f = strdup(params);
408 char *p = f;
409 int n = 0, j = i, count = 0;
410 Eina_Bool table = EINA_FALSE;
411
412 if (!f) return -1;
413 va_start(vl, params);
414
415 if (lua_istable(L, i)) // Stack usage [-0, +0, -]
416 {
417 j = -1;
418 table = EINA_TRUE;
419 }
420
421 while (*p)
422 {
423 char *q;
424 Eina_Bool get = EINA_TRUE;
425
426 while (isspace((int)*p))
427 p++;
428 q = p + 1;
429 switch (*p)
430 {
431 case '%':
432 {
433 if (table)
434 {
435 q = _elua_push_name(L, q, i); // Stack usage [-0, +1, e]
436 }
437 if (lua_isnumber(L, j)) // Stack usage [-0, +0, -]
438 {
439 int *v = va_arg(vl, int *);
440 *v = lua_tointeger(L, j); // Stack usage [-0, +0, -]
441 n++;
442 }
443 break;
444 }
445 case '#':
446 {
447 if (table)
448 {
449 q = _elua_push_name(L, q, i); // Stack usage [-0, +1, e]
450 }
451 if (lua_isnumber(L, j)) // Stack usage [-0, +0, -]
452 {
453 double *v = va_arg(vl, double *);
454 *v = lua_tonumber(L, j); // Stack usage [-0, +0, -]
455 n++;
456 }
457 break;
458 }
459 case '$':
460 {
461 if (table)
462 {
463 q = _elua_push_name(L, q, i); // Stack usage [-0, +1, e]
464 }
465 if (lua_isstring(L, j)) // Stack usage [-0, +0, -]
466 {
467 char **v = va_arg(vl, char **);
468 size_t len;
469 char *temp = (char *) lua_tolstring(L, j, &len); // Stack usage [-0, +0, m]
470
471 len++; // Cater for the null at the end.
472 *v = malloc(len);
473 if (*v)
474 {
475 memcpy(*v, temp, len);
476 n++;
477 }
478 }
479 break;
480 }
481 case '!':
482 {
483 if (table)
484 {
485 q = _elua_push_name(L, q, i); // Stack usage [-0, +1, e]
486 }
487 if (lua_isboolean(L, j)) // Stack usage [-0, +0, -]
488 {
489 int *v = va_arg(vl, int *);
490 *v = lua_toboolean(L, j); // Stack usage [-0, +0, -]
491 n++;
492 }
493 break;
494 }
495 default:
496 {
497 get = EINA_FALSE;
498 break;
499 }
500 }
501
502 if (get)
503 {
504 if (table)
505 {
506 // If this is a table, then we pushed a value on the stack, pop it off.
507 lua_pop(L, 1); // Stack usage [-n, +0, -]
508 }
509 else
510 j++;
511 count++;
512 }
513 p = q;
514 }
515
516 free(f);
517 va_end(vl);
518 if (count > n)
519 n = 0;
520 else if (table)
521 n = 1;
522 return n;
523}
524
525static int
526_elua_ret(lua_State *L, char *params, ...) // Stack usage [-(2*n), +(2*n+1), em]
527{
528 va_list vl;
529 char *f = strdup(params);
530 char *p = f;
531 int n = 0;
532
533 if (!f) return -1;
534
535 lua_newtable(L); // Stack usage [-0, +1, m]
536 va_start(vl, params);
537
538 while (*p)
539 {
540 char *q;
541 Eina_Bool set = EINA_TRUE;
542
543 while (isspace((int)*p))
544 p++;
545 q = p + 1;
546 switch (*p)
547 {
548 case '%':
549 {
550 q = _elua_push_name(L, q, -1); // Stack usage [-0, +1, m]
551 lua_pushinteger(L, va_arg(vl, int)); // Stack usage [-0, +1, -]
552 break;
553 }
554 case '#':
555 {
556 q = _elua_push_name(L, q, -1); // Stack usage [-0, +1, m]
557 lua_pushnumber(L, va_arg(vl, double)); // Stack usage [-0, +1, -]
558 break;
559 }
560 case '$':
561 {
562 q = _elua_push_name(L, q, -1); // Stack usage [-0, +1, m]
563 lua_pushstring(L, va_arg(vl, char *)); // Stack usage [-0, +1, m]
564 break;
565 }
566 case '!':
567 {
568 q = _elua_push_name(L, q, -1); // Stack usage [-0, +1, m]
569 lua_pushboolean(L, va_arg(vl, int)); // Stack usage [-0, +1, -]
570 break;
571 }
572 default:
573 {
574 set = EINA_FALSE;
575 break;
576 }
577 }
578
579 if (set)
580 {
581 lua_settable(L, -3); // Stack usage [-2, +0, e]
582 n++;
583 }
584 p = q;
585 }
586
587 free(f);
588 va_end(vl);
589 return n;
590}
591
592static void
593_elua_color_fix(int *r, int *g, int *b, int *a)
594{
595 if (*r > *a) *r = *a;
596 if (*g > *a) *g = *a;
597 if (*b > *a) *b = *a;
598}
599
600//--------------------------------------------------------------------------//
601
602/**
603@page luaref
604@subsection edje Edje class.
605
606The lua edje class includes functions for dealing with the lua script only group
607as an edje object, basic functions, and functions to create other objects.
608
609In the following, "edje" is the actual global table used to access these edje functions.
610*/
611
612static int _elua_echo(lua_State *L);
613
614static int _elua_date(lua_State *L);
615static int _elua_looptime(lua_State *L);
616static int _elua_seconds(lua_State *L);
617
618static int _elua_objgeom(lua_State *L);
619static int _elua_objpos(lua_State *L);
620static int _elua_objsize(lua_State *L);
621
622static int _elua_emit(lua_State *L);
623static int _elua_messagesend(lua_State *L);
624
625static int _elua_animator(lua_State *L);
626static int _elua_timer(lua_State *L);
627static int _elua_transition(lua_State *L);
628
629static int _elua_color_class(lua_State *L);
630static int _elua_text_class(lua_State *L);
631
632static int _elua_edje(lua_State *L);
633static int _elua_image(lua_State *L);
634static int _elua_line(lua_State *L);
635static int _elua_map(lua_State *L);
636static int _elua_polygon(lua_State *L);
637static int _elua_rect(lua_State *L);
638static int _elua_text(lua_State *L);
639//static int _elua_textblock(lua_State *L); /* XXX: disabled until there are enough textblock functions implemented to make it actually useful
640
641static const char *_elua_edje_api = "edje";
642static const struct luaL_reg _elua_edje_funcs [] =
643{
644 // add an echo too to make it more shelly
645 {"echo", _elua_echo}, // test func - echo (i know we have print. test)
646 // FIXME: add logging functions here, probably to it's own domain, or even a script defined domain.
647
648 // system information (time, date blah blah)
649 {"date", _elua_date}, // get date in a table
650 {"looptime", _elua_looptime}, // get loop time
651 {"seconds", _elua_seconds}, // get seconds
652
653 // query edje - size, pos
654 {"geom", _elua_objgeom}, // get while edje object geometry in canvas
655 {"pos", _elua_objpos}, // get while edje object pos in canvas
656 {"size", _elua_objsize}, // get while edje object pos in canvas
657
658 // talk to application/caller
659 {"emit", _elua_emit}, // emit signal + src
660 {"messagesend", _elua_messagesend}, // send a structured message
661
662 // time based "callback" systems
663 {"animator", _elua_animator}, // add animator
664 {"timer", _elua_timer}, // add timer
665 {"transition", _elua_transition}, // add transition
666 // FIXME: need poller
667
668 // set and query color / text class
669 {"color_class", _elua_color_class},
670 {"text_class", _elua_text_class},
671
672 // create new objects
673 {"edje", _elua_edje},
674 {"image", _elua_image}, // defaults to a filled image.
675 {"line", _elua_line},
676 {"map", _elua_map},
677 {"polygon", _elua_polygon},
678 {"rect", _elua_rect},
679 {"text", _elua_text},
680// {"textblock", _elua_textblock}, /* XXX: disabled until there are enough textblock functions implemented to make it actually useful
681
682 // FIXME: add the new sound stuff.
683
684 {NULL, NULL} // end
685};
686
687/**
688@page luaref
689@subsubsection edje_echo edje:echo(text)
690
691Make lua a bit shelly. Prints a string to the console
692
693@param text The string to print.
694*/
695static int
696_elua_echo(lua_State *L) // Stack usage [-0, +0, v]
697{
698 const char *string = luaL_checkstring(L, 1); // Stack usage [-0, +0, v]
699 LD("%s\n", string);
700 return 0;
701}
702
703//-------------
704/**
705@page luaref
706@subsubsection edje_date edje:date()
707
708Retrieves the current time and date.
709
710Wraps gettimeofday(), as passed through localtime().
711
712@return A table with these fields:
713 - integer year: Year.
714 - integer month: Month of the year.
715 - integer day: Day of the month.
716 - integer yearday: Day of the year.
717 - integer weekday: Day of the week.
718 - integer hour: Hour of the day (24 hour format).
719 - integer min: Minute of the hour.
720 - number sec: Seconds as a number.
721
722*/
723static int
724_elua_date(lua_State *L) // Stack usage [-16, +17, em]
725{
726 static time_t last_tzset = 0;
727 struct timeval timev;
728 struct tm *tm;
729 time_t tt;
730
731 gettimeofday(&timev, NULL);
732 tt = (time_t)(timev.tv_sec);
733 if ((tt > (last_tzset + 1)) || (tt < (last_tzset - 1)))
734 {
735 last_tzset = tt;
736 tzset();
737 }
738 tm = localtime(&tt);
739 if (tm)
740 { // Stack usage [-16, +17, em]
741 _elua_ret(L, "%year %month %day %yearday %weekday %hour %min #sec",
742 (int)(tm->tm_year + 1900),
743 (int)(tm->tm_mon + 1),
744 (int)(tm->tm_mday),
745 (int)(tm->tm_yday),
746 (int)((tm->tm_wday + 6) % 7),
747 (int)(tm->tm_hour),
748 (int)(tm->tm_min),
749 (double)((double)tm->tm_sec + (((double)timev.tv_usec) / 1000000))
750 );
751
752
753 }
754 return 1;
755}
756
757/**
758@page luaref
759@subsubsection edje_looptime edje:looptime()
760
761Retrieves the time at which the last loop stopped waiting for timeouts or events.
762
763This gets the time that the main loop ceased waiting for timouts and/or events
764to come in or for signals or any other interrupt source. This should be
765considered a reference point for all time based activity that should calculate
766its timepoint from the return of edje:looptime(). Use this UNLESS you absolutely
767must get the current actual timepoint - then use edje:seconds(). Note that this
768time is meant to be used as relative to other times obtained on this run.
769
770Wraps ecore_loop_time_get().
771
772@returns A number of seconds.
773*/
774static int
775_elua_looptime(lua_State *L) // Stack usage [-0, +1, -]
776{
777 double t = ecore_loop_time_get();
778 lua_pushnumber(L, t); // Stack usage [-0, +1, -]
779 return 1;
780}
781
782/**
783@page luaref
784@subsubsection edje_seconds edje:seconds()
785
786Retrieves the current system time as a floating point value in seconds.
787
788This uses a monotonic clock and thus never goes back in time while machine is
789live (even if user changes time or timezone changes, however it may be reset
790whenever the machine is restarted).
791
792Wraps ecore_time_get().
793
794@returns A number of seconds.
795*/
796static int
797_elua_seconds(lua_State *L) // Stack usage [-0, +1, -]
798{
799 double t = ecore_time_get();
800 lua_pushnumber(L, t); // Stack usage [-0, +1, -]
801 return 1;
802}
803
804//-------------
805/**
806@page luaref
807@subsubsection edje_geom edje:geom()
808
809Retrieves the position and size of the edje object that this lua group is in.
810
811@returns A table with these fields:
812 - integer x: The edjes X position.
813 - integer y: The edjes Y position.
814 - integer w: The edjes width.
815 - integer h: The edjes height.
816*/
817static int
818_elua_objgeom(lua_State *L) // Stack usage [-10, +11, em]
819{
820 Edje *ed = (Edje *)_elua_table_ptr_get(L, _elua_key); // Stack usage [-2, +2, e]
821 _elua_ret(L, "%x %y %w %h", ed->x, ed->y, ed->w, ed->h); // Stack usage [-8, +9, em]
822 return 1;
823}
824
825/**
826@page luaref
827@subsubsection edje_pos edje:pos()
828
829
830Retrieves the position of the edje object that this lua group is in.
831
832@returns A table with these fields:
833 - integer x: The edjes X position.
834 - integer y: The edjes Y position.
835*/
836static int
837_elua_objpos(lua_State *L) // Stack usage [-6, +7, em]
838{
839 Edje *ed = (Edje *)_elua_table_ptr_get(L, _elua_key); // Stack usage [-2, +2, e]
840 _elua_ret(L, "%x %y", ed->x, ed->y); // Stack usage [-4, +5, em]
841 return 1;
842}
843
844/**
845@page luaref
846@subsubsection edje_size edje:size()
847
848
849Retrieves the size of the edje object that this lua group is in.
850
851@returns A table with these fields:
852 - integer w: The edjes width.
853 - integer h: The edjes height.
854*/
855static int
856_elua_objsize(lua_State *L) // Stack usage [-6, +7, em]
857{
858 Edje *ed = (Edje *)_elua_table_ptr_get(L, _elua_key); // Stack usage [-2, +2, e]
859 _elua_ret(L, "%w %h", ed->w, ed->h); // Stack usage [-4, +5, em]
860 return 1;
861}
862
863//-------------
864/**
865@page luaref
866@subsubsection edje_emit edje:emit(signal, source)
867
868Emit a signal.
869
870Wraps edje_object_signal_emit().
871
872@param signal The signal string to send.
873@param source The source string of the signal.
874
875NOTE: The source string will have a name and a colon prepended to in when it is
876delivered to things that are not this edje, like C and other edje groups.
877If this edje is a top level edje, then it will be the name of the group (I think).
878If this edje is swallowed into some other part, then it will be the name of the
879part:
880
881 group_name:source
882
883FIXME: I actually have no idea what happens if it's swallowed into another lua
884edje group.
885*/
886static int
887_elua_emit(lua_State *L) // Stack usage [-2, +2, ev]
888{
889 Edje *ed = (Edje *)_elua_table_ptr_get(L, _elua_key); // Stack usage [-2, +2, e]
890 const char *sig = luaL_checkstring(L, 1); // Stack usage [-0, +0, v]
891 const char *src = luaL_checkstring(L, 2); // Stack usage [-0, +0, v]
892 if ((!sig) || (!src)) return 0;
893 _edje_emit(ed, sig, src);
894 return 0;
895}
896
897/**
898@page luaref
899@subsubsection edje_message_send edje:messagesend(id, type, ...)
900
901Send a message to this edje, and all it's child objects.
902
903Wraps edje_object_message_send().
904
905@param id An identification integer for the message.
906@param type The type of message to send.
907@param ... Zero or more things to send as part of the message, depending on the type.
908
909The type can be one of:
910 - none: No msg.
911 - sig: The msg is two strings (signal, source), sent as a signal.
912 - str: The msg is a C string.
913 - int: The message is a C integer.
914 - float: The message is a C float.
915 - strset: The message is an array of C strings.
916 - intset: The message is an array of C integers.
917 - floatset: The message is an array of C floats.
918 - strint: The message is a C stnring and a C integer.
919 - strfloat: The message is a C string and a C float.
920 - strintset: The message is a C string and an array of C integers.
921 - strfloatset: The message is a G string and an array of C floats.
922
923For the array types, the lua caller passes a table.
924*/
925static int
926_elua_messagesend(lua_State *L) // Stack usage [-2, +2, ev] plus [-2, +2] for every element if it's an array message.
927{
928 Edje *ed = (Edje *)_elua_table_ptr_get(L, _elua_key); // Stack usage [-2, +2, e]
929 int id = luaL_checkinteger(L, 1); // Stack usage [-0, +0, v]
930 const char *type = luaL_checkstring(L, 2); // Stack usage [-0, +0, v]
931 if (!type) return 0;
932 if (!strcmp(type, "none"))
933 {
934 _edje_message_send(ed, EDJE_QUEUE_APP, EDJE_MESSAGE_NONE, id, NULL);
935 }
936 else if (!strcmp(type, "sig"))
937 {
938 const char *sig = luaL_checkstring(L, 3); // Stack usage [-0, +0, v]
939 const char *src = luaL_checkstring(L, 4); // Stack usage [-0, +0, v]
940 _edje_emit(ed, sig, src);
941 }
942 else if (!strcmp(type, "str"))
943 {
944 Edje_Message_String *emsg;
945 const char *str = luaL_checkstring(L, 3); // Stack usage [-0, +0, v]
946 emsg = alloca(sizeof(Edje_Message_String));
947 emsg->str = (char *)str;
948 _edje_message_send(ed, EDJE_QUEUE_APP, EDJE_MESSAGE_STRING, id, emsg);
949 }
950 else if (!strcmp(type, "int"))
951 {
952 Edje_Message_Int *emsg;
953 int val = luaL_checkinteger(L, 3); // Stack usage [-0, +0, v]
954 emsg = alloca(sizeof(Edje_Message_Int));
955 emsg->val = val;
956 _edje_message_send(ed, EDJE_QUEUE_APP, EDJE_MESSAGE_INT, id, emsg);
957 }
958 else if (!strcmp(type, "float"))
959 {
960 Edje_Message_Float *emsg;
961 float val = luaL_checknumber(L, 3); // Stack usage [-0, +0, v]
962 emsg = alloca(sizeof(Edje_Message_Float));
963 emsg->val = val;
964 _edje_message_send(ed, EDJE_QUEUE_APP, EDJE_MESSAGE_FLOAT, id, emsg);
965 }
966 else if (!strcmp(type, "strset"))
967 {
968 Edje_Message_String_Set *emsg;
969 int i, n;
970 const char *str;
971 luaL_checktype(L, 3, LUA_TTABLE); // Stack usage [-0, +0, v]
972 n = lua_objlen(L, 3); // Stack usage [-0, +0, -]
973 emsg = alloca(sizeof(Edje_Message_String_Set) + ((n - 1) * sizeof(char *)));
974 emsg->count = n;
975 for (i = 1; i <= n; i ++)
976 {
977 lua_pushinteger(L, i); // Stack usage [-0, +1, -]
978 lua_gettable(L, 3); // Stack usage [-1, +1, e]
979 str = lua_tostring(L, -1); // Stack usage [-0, +0, m]
980 lua_pop(L, 1); // Stack usage [-n, +0, -]
981 emsg->str[i - 1] = (char *)str;
982 }
983 _edje_message_send(ed, EDJE_QUEUE_APP, EDJE_MESSAGE_STRING_SET, id, emsg);
984 }
985 else if (!strcmp(type, "intset"))
986 {
987 Edje_Message_Int_Set *emsg;
988 int i, n;
989 luaL_checktype(L, 3, LUA_TTABLE); // Stack usage [-0, +0, v]
990 n = lua_objlen(L, 3); // Stack usage [-0, +0, -]
991 emsg = alloca(sizeof(Edje_Message_Int_Set) + ((n - 1) * sizeof(int)));
992 emsg->count = n;
993 for (i = 1; i <= n; i ++)
994 {
995 lua_pushinteger(L, i); // Stack usage [-0, +1, -]
996 lua_gettable(L, 3); // Stack usage [-1, +1, e]
997 emsg->val[i - 1] = lua_tointeger(L, -1); // Stack usage [-0, +0, -]
998 lua_pop(L, 1); // Stack usage [-n, +0, -]
999 }
1000 _edje_message_send(ed, EDJE_QUEUE_APP, EDJE_MESSAGE_INT_SET, id, emsg);
1001 }
1002 else if (!strcmp(type, "floatset"))
1003 {
1004 Edje_Message_Float_Set *emsg;
1005 int i, n;
1006 luaL_checktype(L, 3, LUA_TTABLE); // Stack usage [-0, +0, v]
1007 n = lua_objlen(L, 3); // Stack usage [-0, +0, -]
1008 emsg = alloca(sizeof(Edje_Message_Float_Set) + ((n - 1) * sizeof(double)));
1009 emsg->count = n;
1010 for (i = 1; i <= n; i ++)
1011 {
1012 lua_pushinteger(L, i); // Stack usage [-0, +1, -]
1013 lua_gettable(L, 3); // Stack usage [-1, +1, e]
1014 emsg->val[i - 1] = lua_tonumber(L, -1); // Stack usage [-0, +0, -]
1015 lua_pop(L, 1); // Stack usage [-n, +0, -]
1016 }
1017 _edje_message_send(ed, EDJE_QUEUE_APP, EDJE_MESSAGE_FLOAT_SET, id, emsg);
1018 }
1019 else if (!strcmp(type, "strint"))
1020 {
1021 Edje_Message_String_Int *emsg;
1022 const char *str = luaL_checkstring(L, 3); // Stack usage [-0, +0, v]
1023 emsg = alloca(sizeof(Edje_Message_String_Int));
1024 emsg->str = (char *)str;
1025 emsg->val = luaL_checkinteger(L, 4); // Stack usage [-0, +0, v]
1026 _edje_message_send(ed, EDJE_QUEUE_APP, EDJE_MESSAGE_STRING_INT, id, emsg);
1027 }
1028 else if (!strcmp(type, "strfloat"))
1029 {
1030 Edje_Message_String_Float *emsg;
1031 const char *str = luaL_checkstring(L, 3); // Stack usage [-0, +0, v]
1032 emsg = alloca(sizeof(Edje_Message_String_Float));
1033 emsg->str = (char *)str;
1034 emsg->val = luaL_checknumber(L, 4); // Stack usage [-0, +0, v]
1035 _edje_message_send(ed, EDJE_QUEUE_APP, EDJE_MESSAGE_STRING_FLOAT, id, emsg);
1036 }
1037 else if (!strcmp(type, "strintset"))
1038 {
1039 Edje_Message_String_Int_Set *emsg;
1040 int i, n;
1041 const char *str = luaL_checkstring(L, 3); // Stack usage [-0, +0, v]
1042 if (!str) return 0;
1043 luaL_checktype(L, 4, LUA_TTABLE); // Stack usage [-0, +0, v]
1044 n = lua_objlen(L, 4); // Stack usage [-0, +0, -]
1045 emsg = alloca(sizeof(Edje_Message_String_Int_Set) + ((n - 1) * sizeof(int)));
1046 emsg->str = (char *)str;
1047 emsg->count = n;
1048 for (i = 1; i <= n; i ++)
1049 {
1050 lua_pushinteger(L, i); // Stack usage [-0, +1, -]
1051 lua_gettable(L, 4); // Stack usage [-1, +1, e]
1052 emsg->val[i - 1] = lua_tointeger(L, -1); // Stack usage [-0, +0, -]
1053 lua_pop(L, 1); // Stack usage [-n, +0, -]
1054 }
1055 _edje_message_send(ed, EDJE_QUEUE_APP, EDJE_MESSAGE_STRING_INT_SET, id, emsg);
1056 }
1057 else if (!strcmp(type, "strfloatset"))
1058 {
1059 Edje_Message_String_Float_Set *emsg;
1060 int i, n;
1061 const char *str = luaL_checkstring(L, 3); // Stack usage [-0, +0, v]
1062 if (!str) return 0;
1063 luaL_checktype(L, 4, LUA_TTABLE); // Stack usage [-0, +0, v]
1064 n = lua_objlen(L, 4);
1065 emsg = alloca(sizeof(Edje_Message_String_Float_Set) + ((n - 1) * sizeof(double)));
1066 emsg->str = (char *)str;
1067 emsg->count = n;
1068 for (i = 1; i <= n; i ++)
1069 {
1070 lua_pushinteger(L, i); // Stack usage [-0, +1, -]
1071 lua_gettable(L, 4); // Stack usage [-1, +1, e]
1072 emsg->val[i - 1] = lua_tonumber(L, -1); // Stack usage [-0, +0, -]
1073 lua_pop(L, 1); // Stack usage [-n, +0, -]
1074 }
1075 _edje_message_send(ed, EDJE_QUEUE_APP, EDJE_MESSAGE_STRING_FLOAT_SET, id, emsg);
1076 }
1077 return 0;
1078}
1079
1080//-------------
1081static Eina_Bool
1082_elua_animator_cb(void *data) // Stack usage [-2, +2, em]
1083{
1084 Edje_Lua_Animator *ela = data;
1085 lua_State *L;
1086 int ret = 0, err = 0;
1087
1088 if (!ela->obj.ed) return 0;
1089 L = ela->obj.ed->L;
1090 if (!L) return 0;
1091 /* This is not needed, pcalls don't longjmp(), that's why they are protected.
1092 if (setjmp(panic_jmp) == 1)
1093 {
1094 LE("Animator callback panic");
1095 _edje_lua2_error(L, err); // Stack usage [-0, +0, m]
1096 _elua_obj_free(L, (Edje_Lua_Obj *)ela);
1097 _elua_gc(L); // Stack usage [-0, +0, e]
1098 return 0;
1099 }
1100 */
1101 lua_rawgeti(L, LUA_REGISTRYINDEX, ela->fn_ref); // Stack usage [-0, +1, -]
1102 if ((err = lua_pcall(L, 0, 1, 0))) // Stack usage [-1, +1, -]
1103 {
1104 _edje_lua2_error(L, err); // Stack usage [-0, +0, m]
1105 _elua_obj_free(L, (Edje_Lua_Obj *)ela);
1106 _elua_gc(L); // Stack usage [-0, +0, e]
1107 return 0;
1108 }
1109 ret = lua_toboolean(L, -1); // Stack usage [-0, +0, -]
1110 lua_pop(L, 1); // Stack usage [-n, +0, -]
1111 if (ret == 0) _elua_obj_free(L, (Edje_Lua_Obj *)ela);
1112 _elua_gc(L); // Stack usage [-0, +0, e]
1113 return ret;
1114}
1115
1116static void
1117_elua_animator_free(void *obj) // Stack usage [-0, +0, -]
1118{
1119 Edje_Lua_Animator *ela = obj;
1120 lua_State *L;
1121 if (!ela->obj.ed) return;
1122 L = ela->obj.ed->L;
1123 luaL_unref(L, LUA_REGISTRYINDEX, ela->fn_ref); // Stack usage [-0, +0, -]
1124 ela->fn_ref = 0;
1125 ecore_animator_del(ela->animator);
1126 ela->animator = NULL;
1127}
1128
1129/**
1130@page luaref
1131@subsubsection edje_animator edje:animator(func)
1132
1133This function adds an animator and returns its handle on success and NULL on
1134failure. The function func will be called every frame tick. Note that setting
1135the frame tick is not available as a lua function, so has to be done from C.
1136The default tick is 1/30 second.
1137
1138When the animator func is called, it must return a value of either true or false.
1139If it returns true it will be called again at the next tick, or if it returns
1140false it will be deleted automatically making any references/handles for it
1141invalid.
1142
1143Wraps ecore_animator_add().
1144
1145@param func The function to call when the animator triggers.
1146
1147@returns A userdata that is an ecore animator.
1148*/
1149static int
1150_elua_animator(lua_State *L) // Stack usage [-8, +9, emv]
1151{
1152 Edje *ed = (Edje *)_elua_table_ptr_get(L, _elua_key); // Stack usage [-2, +2, e]
1153 Edje_Lua_Animator *ela;
1154
1155 luaL_checkany(L, 1); // Stack usage [-0, +0, v]
1156
1157 // FIXME: Allow lua to set a data to be sent back with the callback.
1158 ela = (Edje_Lua_Animator *)_elua_obj_new(L, ed, sizeof(Edje_Lua_Animator), _elua_ecore_animator_meta);
1159 // Stack usage [-5, +6, m]
1160 ela->obj.free_func = _elua_animator_free;
1161 ela->animator = ecore_animator_add(_elua_animator_cb, ela);
1162 lua_pushvalue(L, 1); // Stack usage [-0, +1, -]
1163 ela->fn_ref = luaL_ref(L, LUA_REGISTRYINDEX); // Stack usage [-1, +0, m]
1164 _elua_gc(L); // Stack usage [-0, +0, e]
1165 return 1;
1166}
1167
1168static Eina_Bool
1169_elua_timer_cb(void *data) // Stack usage [-2, +2, em]
1170{
1171 Edje_Lua_Timer *elt = data;
1172 lua_State *L;
1173 int ret = 0, err = 0;
1174
1175 if (!elt->obj.ed) return 0;
1176 L = elt->obj.ed->L;
1177 if (!L) return 0;
1178 /* This is not needed, pcalls don't longjmp(), that's why they are protected.
1179 if (setjmp(panic_jmp) == 1)
1180 {
1181 LE("Timer callback panic");
1182 _edje_lua2_error(L, err); // Stack usage [-0, +0, m]
1183 _elua_obj_free(L, (Edje_Lua_Obj *)elt);
1184 _elua_gc(L); // Stack usage [-0, +0, e]
1185 return 0;
1186 }
1187 */
1188 lua_rawgeti(L, LUA_REGISTRYINDEX, elt->fn_ref); // Stack usage [-0, +1, -]
1189 if ((err = lua_pcall(L, 0, 1, 0))) // Stack usage [-1, +1, -]
1190 {
1191 _edje_lua2_error(L, err);
1192 _elua_obj_free(L, (Edje_Lua_Obj *)elt); // Stack usage [-0, +0, m]
1193 _elua_gc(L); // Stack usage [-0, +0, e]
1194 return 0;
1195 }
1196 ret = lua_toboolean(L, -1); // Stack usage [-0, +0, -]
1197 lua_pop(L, 1); // Stack usage [-n, +0, -]
1198 if (ret == 0) _elua_obj_free(L, (Edje_Lua_Obj *)elt);
1199 _elua_gc(L); // Stack usage [-0, +0, e]
1200 return ret;
1201}
1202
1203static void
1204_elua_timer_free(void *obj) // Stack usage [-0, +0, -]
1205{
1206 Edje_Lua_Timer *elt = obj;
1207 lua_State *L;
1208 if (!elt->obj.ed) return;
1209 L = elt->obj.ed->L;
1210 luaL_unref(L, LUA_REGISTRYINDEX, elt->fn_ref); // Stack usage [-0, +0, -]
1211 elt->fn_ref = 0;
1212 ecore_timer_del(elt->timer);
1213 elt->timer = NULL;
1214}
1215
1216/**
1217@page luaref
1218@subsubsection edje_timer edje:timer(tick, func)
1219
1220This function adds a timer and returns its handle on success and NULL on failure.
1221The function func will be called every tick seconds.
1222
1223When the timer func is called, it must return a value of either true or false.
1224If it returns true, it will be called again at the next tick, or if it returns
1225false it will be deleted automatically making any references/handles for it
1226invalid.
1227
1228Wraps ecore_timer_add().
1229
1230@param tick How often, in seconds, to call the function.
1231@param func The function to call when the timer triggers.
1232
1233@returns A userdata that is an ecore timer.
1234*/
1235static int
1236_elua_timer(lua_State *L) // Stack usage [-8, +9, emv]
1237{
1238 Edje *ed = (Edje *)_elua_table_ptr_get(L, _elua_key); // Stack usage [-2, +2, e]
1239 Edje_Lua_Timer *elt;
1240 double val;
1241
1242 val = luaL_checknumber(L, 1); // Stack usage [-0, +0, v]
1243 luaL_checkany(L, 2); // Stack usage [-0, +0, v]
1244
1245 elt = (Edje_Lua_Timer *)_elua_obj_new(L, ed, sizeof(Edje_Lua_Timer), _elua_ecore_timer_meta);
1246 // Stack usage [-5, +6, m]
1247 elt->obj.free_func = _elua_timer_free;
1248 elt->timer = ecore_timer_add(val, _elua_timer_cb, elt);
1249 lua_pushvalue(L, 2); // Stack usage [-0, +1, -]
1250 elt->fn_ref = luaL_ref(L, LUA_REGISTRYINDEX); // Stack usage [-1, +0, m]
1251 _elua_gc(L); // Stack usage [-0, +0, e]
1252 return 1;
1253}
1254
1255static Eina_Bool
1256_elua_transition_cb(void *data) // Stack usage [-3, +3, em]
1257{
1258 Edje_Lua_Transition *elt = data;
1259 lua_State *L;
1260 int ret = 0, err = 0;
1261 double t;
1262
1263 if (!elt->obj.ed) return 0;
1264 L = elt->obj.ed->L;
1265 if (!L) return 0;
1266 t = (ecore_loop_time_get() - elt->start) / elt->transition;
1267 if (t > 1.0) t = 1.0;
1268 /* This is not needed, pcalls don't longjmp(), that's why they are protected.
1269 if (setjmp(panic_jmp) == 1)
1270 {
1271 LE("Transition callback panic");
1272 _edje_lua2_error(L, err); // Stack usage [-0, +0, m]
1273 _elua_obj_free(L, (Edje_Lua_Obj *)elt);
1274 _elua_gc(L); // Stack usage [-0, +0, e]
1275 return 0;
1276 }
1277 */
1278 lua_rawgeti(L, LUA_REGISTRYINDEX, elt->fn_ref); // Stack usage [-0, +1, -]
1279 lua_pushnumber(L, t); // Stack usage [-0, +1, -]
1280 if ((err = lua_pcall(L, 1, 1, 0))) // Stack usage [-2, +1, -]
1281 {
1282 _edje_lua2_error(L, err);
1283 _elua_obj_free(L, (Edje_Lua_Obj *)elt); // Stack usage [-0, +0, m]
1284 _elua_gc(L); // Stack usage [-0, +0, e]
1285 return 0;
1286 }
1287 ret = lua_toboolean(L, -1); // Stack usage [-0, +0, -]
1288 lua_pop(L, 1); // Stack usage [-n, +0, -]
1289 if (t >= 1.0) ret = 0;
1290 if (ret == 0) _elua_obj_free(L, (Edje_Lua_Obj *)elt);
1291 _elua_gc(L); // Stack usage [-0, +0, e]
1292 return ret;
1293}
1294
1295static void
1296_elua_transition_free(void *obj) // Stack usage [-0, +0, -]
1297{
1298 Edje_Lua_Transition *elt = obj;
1299 lua_State *L;
1300 if (!elt->obj.ed) return;
1301 L = elt->obj.ed->L;
1302 luaL_unref(L, LUA_REGISTRYINDEX, elt->fn_ref); // Stack usage [-0, +0, -]
1303 elt->fn_ref = 0;
1304 ecore_animator_del(elt->animator);
1305 elt->animator = NULL;
1306}
1307
1308/**
1309@page luaref
1310@subsubsection edje_transition edje:transition(div, func)
1311
1312Just like edje:animator(), except that the callback function gets called with an
1313argument. The argument is the amount of time since the transition was created,
1314divided by the div parameter.
1315
1316@param div A number to divide the time since creation by.
1317@param func The function to call when the transition triggers.
1318
1319@returns A userdata that is a transition (ecore animator, plus other info).
1320*/
1321static int
1322_elua_transition(lua_State *L) // Stack usage [-8, +9, emv]
1323{
1324 Edje *ed = (Edje *)_elua_table_ptr_get(L, _elua_key); // Stack usage [-2, +2, e]
1325 Edje_Lua_Transition *elt;
1326 double val;
1327
1328 val = luaL_checknumber(L, 1); // Stack usage [-0, +0, v]
1329 luaL_checkany(L, 2); // Stack usage [-0, +0, v]
1330
1331 elt = (Edje_Lua_Transition *)_elua_obj_new(L, ed, sizeof(Edje_Lua_Transition), _elua_ecore_animator_meta);
1332 // Stack usage [-5, +6, m]
1333 elt->obj.free_func = _elua_transition_free;
1334 elt->animator = ecore_animator_add(_elua_transition_cb, elt);
1335 if (val < 0.0000001) val = 0.0000001;
1336 elt->transition = val;
1337 elt->start = ecore_loop_time_get();
1338 lua_pushvalue(L, 2); // Stack usage [-0, +1, -]
1339 elt->fn_ref = luaL_ref(L, LUA_REGISTRYINDEX); // Stack usage [-1, +0, m]
1340 _elua_gc(L); // Stack usage [-0, +0, e]
1341 return 1;
1342}
1343
1344//-------------
1345/**
1346@page luaref
1347@subsubsection edje_colour_class edje:color_class(class, r, g, b, a)
1348
1349Gets, (and optionally sets) the colours for a color class.
1350
1351Wraps edje_object_color_class_set().
1352
1353@param class A color class name.
1354@param r The new red value.
1355@param g The new green value.
1356@param b The new blue value.
1357@param a The new alpha value.
1358
1359Note that the r, g, b, and a arguments are optional, without them this function
1360just queries the current values. The r, g, b, and a arguments can be separate
1361values, or named fields in a table.
1362
1363@return A table with these fields:
1364 - integer r: The red value.
1365 - integer g: The green value.
1366 - integer b: The blue value.
1367 - integer a: The alpha value.
1368
1369@since 1.1.0
1370*/
1371static int
1372_elua_color_class(lua_State *L) // Stack usage [-(10|14), +(11|15), ?]
1373{
1374 Edje *ed = (Edje *)_elua_table_ptr_get(L, _elua_key); // Stack usage [-2, +2, e]
1375 Edje_Color_Class *c_class;
1376 const char *class = luaL_checkstring(L, 1); // Stack usage [-0, +0, v]
1377 int r, g, b, a;
1378
1379 if (!class) return 0;
1380
1381 if (_elua_scan_params(L, 2, "%r %g %b %a", &r, &g, &b, &a) > 0)
1382 { // Stack usage [-0, +0, m] unless it's in a table [-4, +4, e]
1383 _elua_color_fix(&r, &g, &b, &a);
1384 // This is the way that embryo does it -
1385 //edje_object_color_class_set(ed->obj, class, r, g, b, a, r, g, b, a, r, g, b, a);
1386 // But that deals with object scope, which is currently useless in lua,
1387 // since we have no objects that can use color_class yet.
1388 // So we do it at global scope instead.
1389 // LATER - Should do both?
1390 edje_color_class_set(class, r, g, b, a, r, g, b, a, r, g, b, a);
1391 }
1392
1393 c_class = _edje_color_class_find(ed, class);
1394 if (!c_class) return 0;
1395
1396 _elua_ret(L, "%r %g %b %a", c_class->r, c_class->g, c_class->b, c_class->a);
1397 // Stack usage [-8, +9, em]
1398 return 1;
1399}
1400
1401/**
1402@page luaref
1403@subsubsection edje_text_class edje:text_class(class, font, size)
1404
1405Gets, (and optionally sets) the details for a text class.
1406
1407Wraps edje_object_text_class_set().
1408
1409@param class A text class name.
1410@param font The new font name.
1411@param size The new font size.
1412
1413Note that the font and size arguments are optional, without them this function
1414just queries the current values. The font and size arguments can be separate
1415values, or named fields in a table. The font name can refer to a font in the
1416edje file, or an external font.
1417
1418@return A table with these fields:
1419 - string font: The font name.
1420 - integer size: The font size.
1421
1422@since 1.1.0
1423*/
1424static int
1425_elua_text_class(lua_State *L) // Stack usage [-(6|8), +(7|9), emv]
1426{
1427 Edje *ed = (Edje *)_elua_table_ptr_get(L, _elua_key); // Stack usage [-2, +2, e]
1428 Edje_Text_Class *t_class;
1429 const char *class = luaL_checkstring(L, 1); // Stack usage [-0, +0, v]
1430 char *font = NULL;
1431 Evas_Font_Size size = 0;
1432
1433 if (!class) return 0;
1434
1435 // Just like color_class above, this does things differently from embryo,
1436 // for the same reason.
1437 if (_elua_scan_params(L, 2, "$font %size", &font, &size) > 0)
1438 // Stack usage [-0, +0, m] unless it's in a table [-2, +2, e]
1439 edje_text_class_set(class, font, size);
1440
1441 t_class = _edje_text_class_find(ed, class);
1442 if (!t_class) return 0;
1443
1444 _elua_ret(L, "$font %size", t_class->font, t_class->size);
1445 // Stack usage [-4, +5, em]
1446 return 1;
1447}
1448
1449//-------------
1450static void
1451_elua_evas_obj_free(void *obj)
1452{
1453 Edje_Lua_Evas_Object *elo = obj;
1454
1455 if (!elo->obj.ed) return;
1456 evas_object_del(elo->evas_obj);
1457 elo->evas_obj = NULL;
1458}
1459
1460// Stack usage [-7, +8, em]
1461#define _ELUA_PLANT_EVAS_OBJECT(type, meta, free) \
1462 Edje *ed = (Edje *)_elua_table_ptr_get(L, _elua_key); \
1463 type *elo; \
1464 elo = (type *)_elua_obj_new(L, ed, sizeof(type), meta); \
1465 elo->obj.free_func = free;
1466// Stack usage [-2, +2, e]
1467// Stack usage [-5, +6, m]
1468
1469static void
1470_elua_polish_evas_object(Edje *ed, Edje_Lua_Evas_Object *elo)
1471{
1472 evas_object_smart_member_add(elo->evas_obj, ed->obj);
1473 evas_object_clip_set(elo->evas_obj, ed->base.clipper);
1474 evas_object_move(elo->evas_obj, ed->x, ed->y);
1475 evas_object_resize(elo->evas_obj, 0, 0);
1476 evas_object_data_set(elo->evas_obj, ELO, elo);
1477}
1478
1479/**
1480@page luaref
1481@subsubsection edje_edje edje:edje()
1482
1483Create an edje object, and add it to the edje.
1484
1485Wraps edje_object_add().
1486
1487@returns A userdata that is an edje object.
1488
1489@since 1.1.0
1490*/
1491static int
1492_elua_edje(lua_State *L) // Stack usage [-7, +8, em]
1493{
1494 _ELUA_PLANT_EVAS_OBJECT(Edje_Lua_Evas_Object, _elua_evas_edje_meta, _elua_evas_obj_free)
1495 // Stack usage [-7, +8, em]
1496 elo->evas_obj = edje_object_add(evas_object_evas_get(ed->obj));
1497 _edje_subobj_register(ed, elo->evas_obj);
1498 _elua_polish_evas_object(ed, elo);
1499 return 1;
1500}
1501
1502/**
1503@page luaref
1504@subsubsection edje_image edje:image()
1505
1506Create an evas image, and add it to the edje.
1507
1508Wraps evas_object_image_add().
1509
1510@returns A userdata that is an evas image.
1511
1512@since 1.1.0
1513*/
1514static int
1515_elua_image(lua_State *L) // Stack usage [-7, +8, em]
1516{
1517 _ELUA_PLANT_EVAS_OBJECT(Edje_Lua_Evas_Object, _elua_evas_image_meta, _elua_evas_obj_free)
1518 // Stack usage [-7, +8, em]
1519 elo->evas_obj = evas_object_image_filled_add(evas_object_evas_get(ed->obj));
1520 _elua_polish_evas_object(ed, elo);
1521 return 1;
1522}
1523
1524/**
1525@page luaref
1526@subsubsection edje_line edje:line()
1527
1528Create an evas line, and add it to the edje.
1529
1530Wraps evas_object_line_add().
1531
1532@returns A userdata that is an evas line.
1533
1534@since 1.1.0
1535*/
1536static int
1537_elua_line(lua_State *L) // Stack usage [-7, +8, em]
1538{
1539 _ELUA_PLANT_EVAS_OBJECT(Edje_Lua_Evas_Object, _elua_evas_line_meta, _elua_evas_obj_free)
1540 // Stack usage [-7, +8, em]
1541 elo->evas_obj = evas_object_line_add(evas_object_evas_get(ed->obj));
1542 _elua_polish_evas_object(ed, elo);
1543 return 1;
1544}
1545
1546static void
1547_elua_map_free(void *obj)
1548{
1549 Edje_Lua_Map *elm = obj;
1550 if (!elm->obj.ed) return;
1551 evas_map_free(elm->map);
1552 elm->map = NULL;
1553}
1554
1555/**
1556@page luaref
1557@subsubsection edje_map edje:map()
1558
1559Create an evas map.
1560
1561Wraps evas_map_new().
1562
1563@returns A userdata that is an evas map.
1564
1565@since 1.1.0
1566*/
1567static int
1568_elua_map(lua_State *L) // Stack usage [-7, +8, emv]
1569{
1570 _ELUA_PLANT_EVAS_OBJECT(Edje_Lua_Map, _elua_evas_map_meta, _elua_map_free)
1571 // Stack usage [-7, +8, em]
1572 elo->map = evas_map_new(luaL_checkinteger(L, 1)); // Stack usage [-0, +0, v]
1573 return 1;
1574}
1575
1576/**
1577@page luaref
1578@subsubsection edje_polygon edje:polygon()
1579
1580Create an evas polygon, and add it to the edje.
1581
1582Wraps evas_object_polygon_add().
1583
1584@returns A userdata that is an evas polygon.
1585
1586@since 1.1.0
1587*/
1588static int
1589_elua_polygon(lua_State *L) // Stack usage [-7, +8, em]
1590{
1591 _ELUA_PLANT_EVAS_OBJECT(Edje_Lua_Evas_Object, _elua_evas_polygon_meta, _elua_evas_obj_free)
1592 // Stack usage [-7, +8, em]
1593 elo->evas_obj = evas_object_polygon_add(evas_object_evas_get(ed->obj));
1594 _elua_polish_evas_object(ed, elo);
1595 return 1;
1596}
1597
1598/**
1599@page luaref
1600@subsubsection edje_rect edje:rect()
1601
1602Create an evas rectangle, and add it to the edje.
1603
1604Wraps evas_object_rectangle_add().
1605
1606@returns A userdata that is an evas rectangle.
1607*/
1608static int
1609_elua_rect(lua_State *L) // Stack usage [-7, +8, em]
1610{
1611 _ELUA_PLANT_EVAS_OBJECT(Edje_Lua_Evas_Object, _elua_evas_meta, _elua_evas_obj_free)
1612 // Stack usage [-7, +8, em]
1613 elo->evas_obj = evas_object_rectangle_add(evas_object_evas_get(ed->obj));
1614 _elua_polish_evas_object(ed, elo);
1615 return 1;
1616}
1617
1618/**
1619@page luaref
1620@subsubsection edje_text edje:text()
1621
1622Create an evas text object, and add it to the edje.
1623
1624Wraps evas_object_text_add().
1625
1626@returns A userdata that is an evas text object.
1627
1628@since 1.1.0
1629*/
1630static int
1631_elua_text(lua_State *L) // Stack usage [-7, +8, em]
1632{
1633 _ELUA_PLANT_EVAS_OBJECT(Edje_Lua_Evas_Object, _elua_evas_text_meta, _elua_evas_obj_free)
1634 // Stack usage [-7, +8, em]
1635 elo->evas_obj = evas_object_text_add(evas_object_evas_get(ed->obj));
1636 _elua_polish_evas_object(ed, elo);
1637 return 1;
1638}
1639
1640/* XXX: disabled until there are enough textblock functions implemented to make it actually useful
1641_elua_textblock(lua_State *L) // Stack usage [-7, +8, em]
1642{
1643 _ELUA_PLANT_EVAS_OBJECT(Edje_Lua_Evas_Object, _elua_evas_textblock_meta, _elua_evas_obj_free)
1644 // Stack usage [-7, +8, em]
1645 elo->evas_obj = evas_object_textblock_add(evas_object_evas_get(ed->obj));
1646 _elua_polish_evas_object(ed, elo);
1647 return 1;
1648}
1649*/
1650
1651//-------------
1652//-------------
1653
1654/**
1655@page luaref
1656@subsection evas Evas class.
1657
1658The lua evas class includes functions for dealing with evas objects. The evas
1659objects must have been previously created by lua using one of the lua ezas
1660object creation functions from the lua edje class.
1661
1662In the following, "evas_object" is a place holder for any lua variable that
1663holds a reference to an evas object.
1664*/
1665
1666static int _elua_obj_del(lua_State *L);
1667
1668static int _elua_hide(lua_State *L);
1669static int _elua_show(lua_State *L);
1670static int _elua_visible(lua_State *L);
1671
1672static int _elua_above(lua_State *L);
1673static int _elua_below(lua_State *L);
1674static int _elua_bottom(lua_State *L);
1675static int _elua_lower(lua_State *L);
1676static int _elua_raise(lua_State *L);
1677static int _elua_top(lua_State *L);
1678
1679static int _elua_geom(lua_State *L);
1680static int _elua_move(lua_State *L);
1681static int _elua_pos(lua_State *L);
1682static int _elua_resize(lua_State *L);
1683static int _elua_size(lua_State *L);
1684
1685static int _elua_clip(lua_State *L);
1686static int _elua_clipees(lua_State *L);
1687static int _elua_unclip(lua_State *L);
1688
1689static int _elua_type(lua_State *L);
1690
1691static int _elua_pass(lua_State *L);
1692static int _elua_precise(lua_State *L);
1693static int _elua_repeat(lua_State *L);
1694
1695static int _elua_color(lua_State *L);
1696
1697static int _elua_obj_map(lua_State *L);
1698static int _elua_obj_map_enable(lua_State *L);
1699static int _elua_obj_map_source(lua_State *L);
1700
1701static const char *_elua_evas_api = "evas";
1702static const struct luaL_reg _elua_evas_funcs [] =
1703{
1704 {"del", _elua_obj_del}, // generic del any object created for edje (evas objects, timers, animators, transitions... everything)
1705
1706 {"hide", _elua_hide}, // hide, return current visibility
1707 {"show", _elua_show}, // show, return current visibility
1708 {"visible", _elua_visible}, // get object visibility
1709
1710 {"above", _elua_above}, // get object above or stack obj above given obj
1711 {"below", _elua_below}, // get object below or stack obj below given obj
1712 {"bottom", _elua_bottom}, // get bottom
1713 {"lower", _elua_lower}, // lower to bottom
1714 {"raise", _elua_raise}, // raise to top
1715 {"top", _elua_top}, // get top
1716
1717 {"geom", _elua_geom}, // move and resize and return current geometry
1718 {"move", _elua_move}, // move, return current position
1719 {"pos", _elua_pos}, // move, return current position
1720 {"resize", _elua_resize}, // resize, return current size
1721 {"size", _elua_size}, // resize, return current size
1722
1723 {"clip", _elua_clip}, // set clip obj, return clip object
1724 {"clipees", _elua_clipees}, // get clip children
1725 {"unclip", _elua_unclip}, // clear clip obj
1726
1727 {"type", _elua_type}, // get object type
1728
1729 {"pass", _elua_pass}, // set pass events, get pass events
1730 {"precise", _elua_precise}, // set precise inside flag, get precise
1731 {"repeat", _elua_repeat}, // set repeat events, get repeat events
1732
1733 {"color", _elua_color}, // set color, return color
1734// {"color_class", _elua_object_color_class}, // get or set object color class
1735
1736 // FIXME: set callbacks (mouse down, up, blah blah blah)
1737 //
1738 // FIXME: set scale (explicit value)
1739 // FIXME: need to set auto-scale (same as scale: 1)
1740
1741 // FIXME: later - set render op, anti-alias, pointer mode (autograb, nograb)
1742
1743 // map api here
1744 {"map", _elua_obj_map},
1745 {"map_enable", _elua_obj_map_enable},
1746 {"map_source", _elua_obj_map_source},
1747
1748 {NULL, NULL} // end
1749};
1750
1751//-------------
1752/**
1753@page luaref
1754@subsubsection evas_hide evas_object:hide()
1755
1756Hides the object.
1757
1758Wraps evas_object_hide().
1759
1760@returns A boolean representing the current visibility.
1761*/
1762static int
1763_elua_hide(lua_State *L) // Stack usage [-0, +1, -]
1764{
1765 Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -]
1766 Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj;
1767 if (!_elua_isa(obj, _elua_evas_meta)) return 0;
1768 evas_object_hide(elo->evas_obj);
1769 lua_pushboolean(L, evas_object_visible_get(elo->evas_obj)); // Stack usage [-0, +1, -]
1770 return 1;
1771}
1772
1773/**
1774@page luaref
1775@subsubsection evas_show evas_object:show()
1776
1777Shows the object.
1778
1779Wraps evas_object_show().
1780
1781@returns A boolean representing the current visibility.
1782*/
1783static int
1784_elua_show(lua_State *L) // Stack usage [-0, +1, -]
1785{
1786 Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -]
1787 Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj;
1788 if (!_elua_isa(obj, _elua_evas_meta)) return 0;
1789 evas_object_show(elo->evas_obj);
1790 lua_pushboolean(L, evas_object_visible_get(elo->evas_obj)); // Stack usage [-0, +1, -]
1791 return 1;
1792}
1793
1794/**
1795@page luaref
1796@subsubsection evas_visible evas_object:visible(visibility)
1797
1798Gets (and optionally sets) this objects visibility.
1799
1800Wraps evas_object_hide() or evas_object_show().
1801
1802@param visibility The new visibility you want to change it to.
1803
1804Note that the argument is optional, without it this function just queries the
1805current value.
1806
1807@returns A boolean representing the current visibility.
1808*/
1809static int
1810_elua_visible(lua_State *L) // Stack usage [-0, +1, -]
1811{
1812 Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -]
1813 Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj;
1814 int n;
1815 if (!_elua_isa(obj, _elua_evas_meta)) return 0;
1816 n = lua_gettop(L); // Stack usage [-0, +0, -]
1817 if (n == 2)
1818 {
1819 if (lua_isboolean(L, 2)) // Stack usage [-0, +0, -]
1820 {
1821 if (lua_toboolean(L, 2)) evas_object_show(elo->evas_obj);
1822 // Stack usage [-0, +0, -]
1823 else evas_object_hide(elo->evas_obj);
1824 }
1825 }
1826 lua_pushboolean(L, evas_object_visible_get(elo->evas_obj)); // Stack usage [-0, +1, -]
1827 return 1;
1828}
1829
1830//-------------
1831/**
1832@page luaref
1833@subsubsection evas_above evas_object:above()
1834
1835Figure out what, if anything, is above us.
1836
1837Wraps evas_object_above_get().
1838
1839Note that it may not return any value.
1840
1841@returns A reference to the object above this one.
1842*/
1843static int
1844_elua_above(lua_State *L) // Stack usage [-3, +4, -]
1845{
1846 Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -]
1847 Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj;
1848 Edje_Lua_Evas_Object *elo2;
1849 Evas_Object *o;
1850 if (!_elua_isa(obj, _elua_evas_meta)) return 0;
1851 if (!(o = evas_object_above_get(elo->evas_obj))) return 0;
1852 if (!(elo2 = evas_object_data_get(o, ELO))) return 0;
1853 _elua_ref_get(L, elo2); // Stack usage [-3, +4, -]
1854 return 1;
1855}
1856
1857/**
1858@page luaref
1859@subsubsection evas_below evas_object:below()
1860
1861Figure out what, if anything, is below us.
1862
1863Wraps evas_object_below_get().
1864
1865Note that it may not return any value.
1866
1867@returns A reference to the object below this one.
1868*/
1869static int
1870_elua_below(lua_State *L) // Stack usage [-3, +4, -]
1871{
1872 Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -]
1873 Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj;
1874 Edje_Lua_Evas_Object *elo2;
1875 Evas_Object *o;
1876 if (!_elua_isa(obj, _elua_evas_meta)) return 0;
1877 if (!(o = evas_object_below_get(elo->evas_obj))) return 0;
1878 if (!(elo2 = evas_object_data_get(o, ELO))) return 0;
1879 _elua_ref_get(L, elo2); // Stack usage [-3, +4, -]
1880 return 1;
1881}
1882
1883/**
1884@page luaref
1885@subsubsection evas_bottom evas_object:bottom()
1886
1887Figure out what, if anything, is waaaay below us.
1888
1889Note that it may not return any value.
1890
1891@returns A reference to the object at the bottom.
1892*/
1893static int
1894_elua_bottom(lua_State *L) // Stack usage [-(0|3), +(0|4), -]
1895{
1896 Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -]
1897 Edje_Lua_Evas_Object *elo2;
1898 Evas_Object *o;
1899 Eina_List *list, *l;
1900 if (!_elua_isa(obj, _elua_evas_meta)) return 0;
1901 if (!(list = (Eina_List *)evas_object_smart_members_get(obj->ed->obj))) return 0;
1902 for (l = list; l; l = l->next)
1903 {
1904 o = l->data;
1905 if ((elo2 = evas_object_data_get(o, ELO)))
1906 {
1907 _elua_ref_get(L, elo2); // Stack usage [-3, +4, -]
1908 return 1;
1909 }
1910 }
1911 return 0;
1912}
1913
1914/**
1915@page luaref
1916@subsubsection evas_lower evas_object:lower()
1917
1918Lower this object to the bottom.
1919
1920Wraps evas_object_lower().
1921*/
1922static int
1923_elua_lower(lua_State *L) // Stack usage [-0, +0, -]
1924{
1925 Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -]
1926 Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj;
1927 if (!_elua_isa(obj, _elua_evas_meta)) return 0;
1928 evas_object_lower(elo->evas_obj);
1929 return 0;
1930}
1931
1932/**
1933@page luaref
1934@subsubsection evas_raise evas_object:raise()
1935
1936Raise this object to the top.
1937
1938Wraps evas_object_raise().
1939*/
1940static int
1941_elua_raise(lua_State *L) // Stack usage [-0, +0, -]
1942{
1943 Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -]
1944 Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj;
1945 if (!_elua_isa(obj, _elua_evas_meta)) return 0;
1946 evas_object_raise(elo->evas_obj);
1947 return 0;
1948}
1949
1950/**
1951@page luaref
1952@subsubsection evas_top evas_object:top()
1953
1954Figure out what, if anything, is waaaay above us.
1955
1956Note that it may not return any value.
1957
1958@returns A reference to the object at the top.
1959*/
1960static int
1961_elua_top(lua_State *L) // Stack usage [-(0|3), +(0|4), -]
1962{
1963 Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-(0, +0, -]
1964 Edje_Lua_Evas_Object *elo2;
1965 Evas_Object *o;
1966 Eina_List *list, *l;
1967 if (!_elua_isa(obj, _elua_evas_meta)) return 0;
1968 if (!(list = (Eina_List *)evas_object_smart_members_get(obj->ed->obj))) return 0;
1969 if (!list) return 0;
1970 for (l = eina_list_last(list); l; l = l->prev)
1971 {
1972 o = l->data;
1973 if ((elo2 = evas_object_data_get(o, ELO)))
1974 {
1975 _elua_ref_get(L, elo2); // Stack usage [-3, +4, -]
1976 return 1;
1977 }
1978 }
1979 return 0;
1980}
1981
1982//-------------
1983/**
1984@page luaref
1985@subsubsection evas_geom evas_object:geom(x, y, w, h)
1986
1987Gets (and optionally sets) this objects geometry.
1988
1989Wraps evas_object_move() and evas_object_resize.
1990
1991@param x The new X coordinate.
1992@param y The new Y coordinate.
1993@param w The new width.
1994@param h The new height.
1995
1996Note that the arguments are optional, without them this function just queries
1997the current values. The arguments can be separate values, or named fields in a
1998table.
1999
2000@return A table with these fields:
2001 - integer x: X coordinate.
2002 - integer x: Y coordinate.
2003 - integer w: Width.
2004 - integer w: Height.
2005*/
2006static int
2007_elua_geom(lua_State *L) // Stack usage [-(8|12), +(9|13), em]
2008{
2009 Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -]
2010 Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj;
2011 Evas_Coord ox, oy, ow, oh;
2012 int x, y, w, h;
2013
2014 if (!_elua_isa(obj, _elua_evas_meta)) return 0;
2015 evas_object_geometry_get(elo->evas_obj, &ox, &oy, &ow, &oh);
2016 if (_elua_scan_params(L, 2, "%x %y %w %h", &x, &y, &w, &h) > 0)
2017 { // Stack usage [-0, +0, m] unless it's in a table [-4, +4, e]
2018 if ((x != (ox - obj->ed->x)) || (y != (oy - obj->ed->y)))
2019 {
2020 evas_object_move(elo->evas_obj,
2021 obj->ed->x + x,
2022 obj->ed->y + y);
2023 }
2024 if ((w != ow) || (h != oh))
2025 {
2026 evas_object_resize(elo->evas_obj, w, h);
2027 }
2028 evas_object_geometry_get(elo->evas_obj, &ox, &oy, &ow, &oh);
2029 elo->x = ox - obj->ed->x;
2030 elo->y = oy - obj->ed->y;
2031 }
2032 _elua_ret(L, "%x %y %w %h", elo->x, elo->y, ow, oh);
2033 // Stack usage [-8, +9, em]
2034 return 1;
2035}
2036
2037/**
2038@page luaref
2039@subsubsection evas_move evas_object:move(x, y)
2040
2041Gets (and optionally sets) this objects position.
2042
2043Wraps evas_object_move().
2044
2045@param x The new X coordinate.
2046@param y The new Y coordinate.
2047
2048Note that the arguments are optional, without them this function just queries
2049the current values. The arguments can be separate values, or named fields in a
2050table.
2051
2052@return A table with these fields:
2053 - integer x: X coordinate.
2054 - integer x: Y coordinate.
2055*/
2056static int
2057_elua_move(lua_State *L) // Stack usage [-(4|6), +(5|7), em]
2058{
2059 Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -]
2060 Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj;
2061 Evas_Coord ox, oy;
2062 int x, y;
2063
2064 if (!_elua_isa(obj, _elua_evas_meta)) return 0;
2065 evas_object_geometry_get(elo->evas_obj, &ox, &oy, NULL, NULL);
2066 if (_elua_scan_params(L, 2, "%x %y", &x, &y) > 0)
2067 { // Stack usage [-0, +0, m] unless it's in a table [-2, +2, e]
2068 if ((x != (ox - obj->ed->x)) || (y != (oy - obj->ed->y)))
2069 {
2070 evas_object_move(elo->evas_obj,
2071 obj->ed->x + x,
2072 obj->ed->y + y);
2073 evas_object_geometry_get(elo->evas_obj, &ox, &oy, NULL, NULL);
2074 }
2075 elo->x = ox - obj->ed->x;
2076 elo->y = oy - obj->ed->y;
2077 }
2078 _elua_ret(L, "%x %y", elo->x, elo->y);
2079 // Stack usage [-4, +5, em]
2080 return 1;
2081}
2082
2083/**
2084@page luaref
2085@subsubsection evas_pos evas_object:pos(x, y)
2086
2087An alias for evas_object:move().
2088*/
2089static int
2090_elua_pos(lua_State *L) // Stack usage [-(4|6), +(5|7), em]
2091{
2092 return _elua_move(L);
2093}
2094
2095/**
2096@page luaref
2097@subsubsection evas_resize evas_object:resize(w, h)
2098
2099Gets (and optionally sets) this objects size.
2100
2101Wraps evas_object_resize().
2102
2103@param w The new width.
2104@param h The new height.
2105
2106Note that the arguments are optional, without them this function just queries
2107the current values. The arguments can be separate values, or named fields in a
2108table.
2109
2110@return A table with these fields:
2111 - integer w: Width.
2112 - integer w: Height.
2113*/
2114static int
2115_elua_resize(lua_State *L) // Stack usage [-(4|6), +(5|7), em]
2116{
2117 Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -]
2118 Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj;
2119 Evas_Coord ow, oh;
2120 int w, h;
2121
2122 if (!_elua_isa(obj, _elua_evas_meta)) return 0;
2123 evas_object_geometry_get(elo->evas_obj, NULL, NULL, &ow, &oh);
2124 if (_elua_scan_params(L, 2, "%w %h", &w, &h) > 0)
2125 { // Stack usage [-0, +0, m] unless it's in a table [-2, +2, e]
2126 if ((w != ow) || (h != oh))
2127 {
2128 evas_object_resize(elo->evas_obj, w, h);
2129 evas_object_geometry_get(elo->evas_obj, NULL, NULL, &ow, &oh);
2130 }
2131 }
2132 _elua_ret(L, "%w %h", ow, oh);
2133 // Stack usage [-4, +5, em]
2134 return 1;
2135}
2136
2137/**
2138@page luaref
2139@subsubsection evas_size evas_object:size()
2140
2141An alias for evas_object:resize().
2142*/
2143static int
2144_elua_size(lua_State *L) // Stack usage [-(4|6), +(5|7), em]
2145{
2146 return _elua_resize(L);
2147}
2148
2149//-------------
2150/**
2151@page luaref
2152@subsubsection evas_clip evas_object:clip(evas_object2)
2153
2154Get (and optionally set) the object that clips this object.
2155
2156Note that the argument is optional, without it this function just queries the
2157current value.
2158
2159Wraps evas_object_clip_set().
2160
2161@param evas_object2 A reference to the object to clip this object with.
2162
2163@returns A reference to the object clipping this object, if any.
2164*/
2165static int
2166_elua_clip(lua_State *L) // Stack usage [-3, +4, -]
2167{
2168 Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -]
2169 Edje_Lua_Evas_Object *elo2, *elo = (Edje_Lua_Evas_Object *)obj;
2170 Evas_Object *o;
2171 int n;
2172 if (!_elua_isa(obj, _elua_evas_meta)) return 0;
2173 n = lua_gettop(L); // Stack usage [-0, +0, -]
2174 if (n == 2)
2175 {
2176 Edje_Lua_Obj *obj2 = (Edje_Lua_Obj *)lua_touserdata(L, 2); // Stack usage [-0, +0, -]
2177 elo2 = (Edje_Lua_Evas_Object *)obj2;
2178 if (!_elua_isa(obj2, _elua_evas_meta)) return 0;
2179 evas_object_clip_set(elo->evas_obj, elo2->evas_obj);
2180 }
2181 o = evas_object_clip_get(elo->evas_obj);
2182 if (!o) return 0;
2183 if (!(elo2 = evas_object_data_get(o, ELO))) return 0;
2184 _elua_ref_get(L, elo2); // Stack usage [-3, +4, -]
2185 return 1;
2186}
2187
2188/**
2189@page luaref
2190@subsubsection evas_clipees evas_object:clipees()
2191
2192Gets the list of objects this objects clips.
2193
2194Wraps evas_object_clipees_get().
2195
2196@return A table, that holds all the objects this clips, if any,
2197 otherwise an empty table.
2198*/
2199static int
2200_elua_clipees(lua_State *L) // Stack usage [-0, +1, me] plus [-5, +5] for each clipee.
2201{
2202 Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -]
2203 Edje_Lua_Evas_Object *elo2, *elo = (Edje_Lua_Evas_Object *)obj;
2204 Eina_List *list, *l;
2205 Evas_Object *o;
2206 int n = 0;
2207 if (!_elua_isa(obj, _elua_evas_meta)) return 0;
2208 list = (Eina_List *)evas_object_clipees_get(elo->evas_obj);
2209 lua_newtable(L); // Stack usage [-0, +1, m]
2210 EINA_LIST_FOREACH(list, l, o)
2211 {
2212 if (!(elo2 = evas_object_data_get(o, ELO))) continue;
2213 lua_pushinteger(L, n + 1); // Stack usage [-0, +1, -]
2214 _elua_ref_get(L, elo2); // Stack usage [-3, +4, -]
2215 lua_settable(L, -3); // Stack usage [-2, +0, e]
2216 n++;
2217 }
2218 return 1;
2219}
2220
2221/**
2222@page luaref
2223@subsubsection evas_unclip evas_object:unclip()
2224
2225Remove any clipping on this object.
2226
2227Wraps evas_object_clip_unset().
2228*/
2229static int
2230_elua_unclip(lua_State *L) // Stack usage [-0, +0, -]
2231{
2232 Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -]
2233 Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj;
2234 if (!_elua_isa(obj, _elua_evas_meta)) return 0;
2235 evas_object_clip_unset(elo->evas_obj);
2236 return 0;
2237}
2238
2239//-------------
2240/**
2241@page luaref
2242@subsubsection evas_type evas_object:type()
2243
2244Get the type of this object. See the documentation of the evas_object_type_get()
2245C function for details.
2246
2247Wraps evas_object_type_get().
2248
2249@return A string with this objects type in it.
2250*/
2251static int
2252_elua_type(lua_State *L) // Stack usage [-0, +1, m]
2253{
2254 Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -]
2255 Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj;
2256 const char *t;
2257 if (!_elua_isa(obj, _elua_evas_meta)) return 0;
2258 t = evas_object_type_get(elo->evas_obj);
2259 if (!t) return 0;
2260 lua_pushstring(L, t); // Stack usage [-0, +1, m]
2261 return 1;
2262}
2263
2264//-------------
2265/**
2266@page luaref
2267@subsubsection evas_pass evas_object:pass(pass)
2268
2269Get (and optionally set) whether this object ignores events, passing them to the
2270next object underneath it.
2271
2272Wraps evas_object_pass_events_set().
2273
2274@param pass A boolean saying if this object passes events.
2275
2276Note that the argument is optional, without it this function just queries the
2277current value.
2278
2279@return A boolean saying if this object passes events.
2280*/
2281static int
2282_elua_pass(lua_State *L) // Stack usage [-0, +1, -]
2283{
2284 Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -]
2285 Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj;
2286 int n;
2287 if (!_elua_isa(obj, _elua_evas_meta)) return 0;
2288 n = lua_gettop(L); // Stack usage [-0, +0, -]
2289 if (n == 2)
2290 {
2291 if (lua_isboolean(L, 2)) // Stack usage [-0, +0, -]
2292 {
2293 evas_object_pass_events_set(elo->evas_obj, lua_toboolean(L, 2));
2294 // Stack usage [-0, +0, -]
2295 }
2296 }
2297 lua_pushboolean(L, evas_object_pass_events_get(elo->evas_obj));
2298 // Stack usage [-0, +1, -]
2299 return 1;
2300}
2301
2302/**
2303@page luaref
2304@subsubsection evas_precise evas_object:precise(precise)
2305
2306Get (and optionally set) whether to use precise (usually expensive) point
2307collision detection for this object.
2308
2309Wraps evas_object_precise_is_inside_set().
2310
2311@param precise A boolean saying if this object is precisely detected.
2312
2313Note that the argument is optional, without it this function just queries the
2314current value.
2315
2316@return A boolean saying if this object is precisely detected.
2317*/
2318static int
2319_elua_precise(lua_State *L) // Stack usage [-0, +1, -]
2320{
2321 Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -]
2322 Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj;
2323 int n;
2324 if (!_elua_isa(obj, _elua_evas_meta)) return 0;
2325 n = lua_gettop(L); // Stack usage [-0, +0, -]
2326 if (n == 2)
2327 {
2328 if (lua_isboolean(L, 2)) // Stack usage [-0, +0, -]
2329 {
2330 evas_object_precise_is_inside_set(elo->evas_obj, lua_toboolean(L, 2));
2331 // Stack usage [-0, +0, -]
2332 }
2333 }
2334 lua_pushboolean(L, evas_object_precise_is_inside_get(elo->evas_obj));
2335 // Stack usage [-0, +1, -]
2336 return 1;
2337}
2338
2339/**
2340@page luaref
2341@subsubsection evas_repeat evas_object:repeat(repeat)
2342
2343Get (and optionally set) whether this object repeats events.
2344
2345Wraps evas_object_repeat_events_set().
2346
2347@param repeat A boolean saying if this object repeats events to lower objects.
2348
2349Note that the argument is optional, without it this function just queries the
2350current value.
2351
2352@return A boolean saying if this object repeats events.
2353*/
2354static int
2355_elua_repeat(lua_State *L) // Stack usage [-0, +1, -]
2356{
2357 Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -]
2358 Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj;
2359 int n;
2360 if (!_elua_isa(obj, _elua_evas_meta)) return 0;
2361 n = lua_gettop(L); // Stack usage [-0, +0, -]
2362 if (n == 2)
2363 {
2364 if (lua_isboolean(L, 2)) // Stack usage [-0, +0, -]
2365 {
2366 evas_object_repeat_events_set(elo->evas_obj, lua_toboolean(L, 2));
2367 // Stack usage [-0, +0, -]
2368 }
2369 }
2370 lua_pushboolean(L, evas_object_repeat_events_get(elo->evas_obj));
2371 // Stack usage [-0, +1, -]
2372 return 1;
2373}
2374
2375//-------------
2376/**
2377@page luaref
2378@subsubsection evas_colour evas_object:color(r, g, b, a)
2379
2380Gets (and optionally sets) this objects colour.
2381
2382Wraps evas_object_color_set().
2383
2384@param r The new red value.
2385@param g The new green value.
2386@param b The new blue value.
2387@param a The new alpha value.
2388
2389Note that the arguments are optional, without them this function just queries
2390the current values. The arguments can be separate values, or named fields in a
2391table.
2392
2393@return A table with these fields:
2394 - integer r: The red value.
2395 - integer g: The green value.
2396 - integer b: The blue value.
2397 - integer a: The alpha value.
2398*/
2399static int
2400_elua_color(lua_State *L) // Stack usage [-(8|12), +(9|13), em]
2401{
2402 Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -]
2403 Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj;
2404 int r, g, b, a;
2405
2406 if (!_elua_isa(obj, _elua_evas_meta)) return 0;
2407 if (_elua_scan_params(L, 2, "%r %g %b %a", &r, &g, &b, &a) > 0)
2408 { // Stack usage [-0, +0, m] unless it's in a table [-4, +4, e]
2409 _elua_color_fix(&r, &g, &b, &a);
2410 evas_object_color_set(elo->evas_obj, r, g, b, a);
2411 }
2412 evas_object_color_get(elo->evas_obj, &r, &g, &b, &a);
2413 _elua_ret(L, "%r %g %b %a", r, g, b, a);
2414 // Stack usage [-8, +9, em]
2415 return 1;
2416}
2417
2418//-------------
2419/**
2420@page luaref
2421@subsubsection evas_map evas_object:map(map)
2422
2423Attach a map to this object.
2424
2425Wraps evas_object_map_set().
2426
2427@param map The map to attach.
2428
2429@since 1.1.0
2430*/
2431static int
2432_elua_obj_map(lua_State *L) // Stack usage [-0, +0, -]
2433{
2434 Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -]
2435 Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj;
2436 Edje_Lua_Obj *obj2 = (Edje_Lua_Obj *)lua_touserdata(L, 2); // Stack usage [-0, +0, -]
2437 Edje_Lua_Map *elm = (Edje_Lua_Map *)obj2;
2438 if (!_elua_isa(obj, _elua_evas_meta)) return 0;
2439 if (!_elua_isa(obj2, _elua_evas_map_meta)) return 0;
2440
2441 evas_object_map_set(elo->evas_obj, elm->map);
2442
2443 return 0;
2444}
2445
2446/**
2447@page luaref
2448@subsubsection evas_map_enable evas_object:map_enable(enable)
2449
2450Enable or disable the map attached to this object.
2451
2452Wraps evas_object_map_enable_set().
2453
2454@param enable A booleon that controls if the attached map is enabled or not.
2455
2456@return A boolean reflecting the map enabled status of this object.
2457
2458@since 1.1.0
2459*/
2460static int
2461_elua_obj_map_enable(lua_State *L) // Stack usage [-0, +1, -]
2462{
2463 Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -]
2464 Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj;
2465 int n;
2466 if (!_elua_isa(obj, _elua_evas_meta)) return 0;
2467
2468 n = lua_gettop(L); // Stack usage [-0, +0, -]
2469 if (n == 2)
2470 {
2471 evas_object_map_enable_set(elo->evas_obj, lua_toboolean(L, 2));
2472 // Stack usage [-0, +0, -]
2473 }
2474 lua_pushboolean(L, evas_object_map_enable_get(elo->evas_obj));
2475 // Stack usage [-0, +1, -]
2476 return 1;
2477}
2478
2479/**
2480@page luaref
2481@subsubsection evas_map_source evas_object:map_source(object)
2482
2483Sets the object as the map source for this object.
2484
2485Wraps evas_object_map_source_set().
2486
2487@param object The map source object.
2488
2489@return A userdata reference to the current map source object.
2490
2491@since 1.1.0
2492*/
2493static int
2494_elua_obj_map_source(lua_State *L) // Stack usage [-3, +4, -]
2495{
2496 Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -]
2497 Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj;
2498 Evas_Object *o;
2499 Edje_Lua_Evas_Object *elo2;
2500 int n;
2501
2502 if (!_elua_isa(obj, _elua_evas_meta)) return 0;
2503
2504 n = lua_gettop(L); // Stack usage [-0, +0, -]
2505 if (n == 2)
2506 {
2507 Edje_Lua_Obj *obj2 = (Edje_Lua_Obj *)lua_touserdata(L, 2); // Stack usage [-0, +0, -]
2508 const Edje_Lua_Evas_Object *source = (Edje_Lua_Evas_Object *)obj2;
2509
2510 if (!_elua_isa(obj2, _elua_evas_meta)) return 0;
2511 evas_object_map_source_set(elo->evas_obj, source->evas_obj);
2512 }
2513
2514 if (!(o = evas_object_map_source_get(elo->evas_obj))) return 0;
2515 if (!(elo2 = evas_object_data_get(o, ELO))) return 0;
2516 _elua_ref_get(L, elo2); // Stack usage [-3, +4, -]
2517
2518 return 1;
2519}
2520
2521//-------------
2522//-------------
2523/**
2524@page luaref
2525@subsection ecore_animator Ecore animator class.
2526
2527The lua ecore animator class includes functions for dealing with ecore animator objects.
2528The ecore animator objects must have been previously created by lua using the lua
2529edje object creation function edje:animator() or edje:transition().
2530
2531In the following, "animator_object" is a place holder for any lua variable that
2532holds a reference to an ecore animator object.
2533*/
2534static const char *_elua_ecore_animator_api = "ecore_animator";
2535static const struct luaL_reg _elua_ecore_animator_funcs [] =
2536{
2537 {NULL, NULL} // end
2538};
2539
2540//-------------
2541//-------------
2542/**
2543@page luaref
2544@subsection ecore_timer Ecore timer class.
2545
2546The lua ecore timer class includes functions for dealing with ecore timer objects.
2547The ecore timer objects must have been previously created by lua using the lua
2548edje object creation function edje:timer().
2549
2550In the following, "timer_object" is a place holder for any lua variable that
2551holds a reference to an ecore timer object.
2552*/
2553
2554static const char *_elua_ecore_timer_api = "ecore_timer";
2555static const struct luaL_reg _elua_ecore_timer_funcs [] =
2556{
2557 {NULL, NULL} // end
2558};
2559
2560//-------------
2561//-------------
2562/**
2563@page luaref
2564@subsection evas_edje Evas edje class.
2565
2566The lua evas edje class includes functions for dealing with evas edje objects.
2567The evas edje objects must have been previously created by lua using the lua
2568edje object creation function edje:edje().
2569
2570In the following, "edje_object" is a place holder for any lua variable that
2571holds a reference to an evas edje object. NOT the edje class specified earlier
2572though.
2573
2574@since 1.1.0
2575*/
2576
2577static int _elua_edje_file(lua_State *L);
2578
2579static const char *_elua_evas_edje_api = "evas_edje";
2580static const char *_elua_evas_edje_parent = "evas_edje_parent";
2581static const struct luaL_reg _elua_evas_edje_funcs [] =
2582{
2583 {"file", _elua_edje_file}, // get or set edje file and group
2584
2585 {NULL, NULL} // end
2586};
2587
2588/**
2589@page luaref
2590@subsubsection edje_file edje_object:file(file, group)
2591
2592Load an edje group into this edje object.
2593
2594Wraps edje_object_file_set().
2595
2596@param file An edje file name (ignored, sandboxed to the file this lua script is in).
2597@param group The group within the edje file to be loaded.
2598
2599Note that the arguments are optional, without them this function just queries
2600the current values. The arguments can be separate values, or named fields in a
2601table. The file argument is optional, and ignored anyway.
2602
2603@return A table with these fields:
2604 - string file: The name of the edje file this edje's group is loaded from.
2605 - string group: The name of the group this edje is loaded from.
2606
2607@since 1.1.0
2608*/
2609static int
2610_elua_edje_file(lua_State *L) // Stack usage [-(4|6), +(5|7), em]
2611{
2612 Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -]
2613 Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj;
2614 const char *file = NULL, *group = NULL;
2615 int n = lua_gettop(L); // Stack usage [-0, +0, -]
2616
2617 if (!_elua_isa(obj, _elua_evas_edje_meta)) return 0;
2618
2619 n = _elua_scan_params(L, 2, "$file $group", &file, &group);
2620 // Stack usage [-0, +0, m] unless it's in a table [-2, +2, e]
2621 if (0 >= n)
2622 {
2623 file = (char *) obj->ed->file->path;
2624 group = (char *) lua_tostring(L, 2); // Stack usage [-0, +0, m]
2625 n = 2;
2626 }
2627
2628 if (1 < n)
2629 {
2630 // Sandbox lua - Only allow access to groups within the same file.
2631 // By the simple expedient of completely ignoring what file was requested.
2632 file = (char *) obj->ed->file->path;
2633 if (!edje_object_file_set(elo->evas_obj, file, group))
2634 {
2635 Edje_Load_Error err = edje_object_load_error_get(elo->evas_obj);
2636
2637 switch (err)
2638 {
2639 case EDJE_LOAD_ERROR_NONE : LE("Edje file loading errer %s %s - no error happened, but you should not see this.\n", obj->ed->file->path, group); break;
2640 case EDJE_LOAD_ERROR_GENERIC : LE("Edje file loading errer %s %s - generic error.\n", obj->ed->file->path, group); break;
2641 case EDJE_LOAD_ERROR_DOES_NOT_EXIST : LE("Edje file loading errer %s %s - file does not exist.\n", obj->ed->file->path, group); break;
2642 case EDJE_LOAD_ERROR_PERMISSION_DENIED : LE("Edje file loading errer %s %s - permission denied reading the file.\n", obj->ed->file->path, group); break;
2643 case EDJE_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED : LE("Edje file loading errer %s %s - resource allocation failed.\n", obj->ed->file->path, group); break;
2644 case EDJE_LOAD_ERROR_CORRUPT_FILE : LE("Edje file loading errer %s %s - corrupt file.\n", obj->ed->file->path, group); break;
2645 case EDJE_LOAD_ERROR_UNKNOWN_FORMAT : LE("Edje file loading errer %s %s - unknown file format.\n", obj->ed->file->path, group); break;
2646 case EDJE_LOAD_ERROR_INCOMPATIBLE_FILE : LE("Edje file loading errer %s %s - incompatible file.\n", obj->ed->file->path, group); break;
2647 case EDJE_LOAD_ERROR_UNKNOWN_COLLECTION : LE("Edje file loading errer %s %s - unknown group.\n", obj->ed->file->path, group); break;
2648 case EDJE_LOAD_ERROR_RECURSIVE_REFERENCE : LE("Edje file loading errer %s %s - recursive reference in group.\n", obj->ed->file->path, group); break;
2649 }
2650 }
2651 }
2652 edje_object_file_get(elo->evas_obj, &file, &group);
2653 _elua_ret(L, "$file $group", file, group);
2654 // Stack usage [-4, +5, em]
2655 return 1;
2656}
2657
2658//-------------
2659//-------------
2660/**
2661@page luaref
2662@subsection evas_image Evas image class.
2663
2664The lua evas image class includes functions for dealing with evas image objects.
2665The evas image objects must have been previously created by lua using the lua
2666image object creation function edje:image().
2667
2668In the following, "image_object" is a place holder for any lua variable that
2669holds a reference to an evas image object.
2670
2671@since 1.1.0
2672*/
2673
2674static int _elua_image_fill(lua_State *L);
2675static int _elua_image_filled(lua_State *L);
2676static int _elua_image_image(lua_State *L);
2677
2678static const char *_elua_evas_image_api = "evas_image";
2679static const char *_elua_evas_image_parent = "evas_image_parent";
2680static const struct luaL_reg _elua_evas_image_funcs [] =
2681{
2682 {"fill", _elua_image_fill}, // get or set the fill parameters
2683 {"filled", _elua_image_filled}, // get or set the filled state (overrides fill())
2684 {"image", _elua_image_image}, // get or set image
2685
2686 {NULL, NULL} // end
2687};
2688
2689/**
2690@page luaref
2691@subsubsection image_fill image_object:fill(x, y, w, h)
2692
2693Gets (and optionally sets) how to fill this image's drawing rectangle given the
2694(real) image bound to it.
2695
2696Wraps evas_object_image_fill_set().
2697
2698@param x The x coordinate (from the top left corner of the bound image) to start drawing from.
2699@param y The y coordinate (from the top left corner of the bound image) to start drawing from.
2700@param w The width the bound image will be displayed at.
2701@param h The height the bound image will be displayed at.
2702
2703Note that the arguments are optional, without them this function just queries
2704the current values. The arguments can be separate values, or named fields in a
2705table.
2706
2707@return A table with these fields:
2708 - integer x: The x coordinate (from the top left corner of the bound image) to start drawing from.
2709 - integer y: The y coordinate (from the top left corner of the bound image) to start drawing from.
2710 - integer w: The width the bound image will be displayed at.
2711 - integer h: The height the bound image will be displayed at.
2712
2713@since 1.1.0
2714*/
2715static int
2716_elua_image_fill(lua_State *L) // Stack usage [-(8|12), +(9|13), em]
2717{
2718 Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -]
2719 Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj;
2720 Evas_Coord x, y, w, h;
2721
2722 if (!_elua_isa(obj, _elua_evas_image_meta)) return 0;
2723
2724 if (_elua_scan_params(L, 2, "%x %y %w %h", &x, &y, &w, &h) > 0)
2725 { // Stack usage [-0, +0, m] unless it's in a table [-4, +4, e]
2726 evas_object_image_fill_set(elo->evas_obj, x, y, w, h);
2727 }
2728 evas_object_image_fill_get(elo->evas_obj, &x, &y, &w, &h);
2729 _elua_ret(L, "%x %y %w %h", x, y, w, h);
2730 // Stack usage [-8, +9, em]
2731 return 1;
2732}
2733
2734/**
2735@page luaref
2736@subsubsection image_filled image_object:filled(filled)
2737
2738Get (and optionally set) whether this image fills the object.
2739
2740Wraps evas_object_image_filled_set().
2741
2742@param filled A boolean saying if this image fills the object.
2743
2744Note that the argument is optional, without it this function just queries the
2745current value.
2746
2747@return A boolean saying if this image fills the object.
2748
2749@since 1.1.0
2750*/
2751static int
2752_elua_image_filled(lua_State *L) // Stack usage [-0, +0, -]
2753{
2754 Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -]
2755 Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj;
2756 int n;
2757
2758 if (!_elua_isa(obj, _elua_evas_image_meta)) return 0;
2759
2760 n = lua_gettop(L); // Stack usage [-0, +0, -]
2761 if (n == 2)
2762 {
2763 evas_object_image_filled_set(elo->evas_obj, lua_toboolean(L, 2));
2764 // Stack usage [-0, +0, -]
2765 }
2766 lua_pushboolean(L, evas_object_image_filled_get(elo->evas_obj));
2767 // Stack usage [-0, +0, -]
2768 return 1;
2769}
2770
2771/**
2772@page luaref
2773@subsubsection image_image image_object:image(file, key)
2774
2775Load an image into this edje object.
2776
2777Wraps evas_object_image_file_set().
2778
2779@param file An edje file name (ignored, sandboxed to the file this lua script is in).
2780@param group The name of an image.
2781
2782Note that the arguments are optional, without them this function just queries
2783the current values. The arguments can be separate values, or named fields in a
2784table. The file argument is optional, and ignored anyway.
2785
2786@return A table with these fields:
2787 - string file: The name of the edje file the image is loaded from.
2788 - string key: The name of the image within the edje file.
2789
2790@since 1.1.0
2791*/
2792static int
2793_elua_image_image(lua_State *L) // Stack usage [-(4|6), +(5|7), em]
2794{
2795 Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -]
2796 Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj;
2797 const char *file = NULL, *key = NULL;
2798 int n, id = -1;
2799
2800 if (!_elua_isa(obj, _elua_evas_image_meta)) return 0;
2801
2802 n = _elua_scan_params(L, 2, "$file $key", &file, &key);
2803 // Stack usage [-0, +0, m] unless it's in a table [-2, +2, e]
2804 if (0 >= n)
2805 {
2806 file = (char *) obj->ed->file->path;
2807 key = (char *) lua_tostring(L, 2); // Stack usage [-0, +0, m]
2808 n = 2;
2809 }
2810
2811 if (1 < n)
2812 {
2813 if (obj->ed->file->image_dir)
2814 {
2815 Edje_Image_Directory_Entry *de;
2816 unsigned int i;
2817 char *name;
2818
2819 /* Image name */
2820 if ((name = strrchr(key, '/'))) name++;
2821 else name = (char *)key;
2822
2823 /* Loop through image directory to find if image exists */
2824 for (i = 0; i < obj->ed->file->image_dir->entries_count; ++i)
2825 {
2826 de = obj->ed->file->image_dir->entries + i;
2827
2828 if (de->entry)
2829 {
2830 if (strcmp(name, de->entry) == 0)
2831 {
2832 char buf[32];
2833
2834 id = i;
2835 // This is copied from _edje_image_recalc_apply()), dunno if it provides any benefit over sprintf().
2836 /* Replace snprint("edje/images/%i") == memcpy + itoa */
2837#define IMAGES "edje/images/"
2838 memcpy(buf, IMAGES, strlen(IMAGES));
2839 eina_convert_itoa(id, buf + strlen(IMAGES)); /* No need to check length as 2³² need only 10 characters. */
2840 evas_object_image_file_set(elo->evas_obj, obj->ed->file->path, buf);
2841 break;
2842 }
2843 }
2844 }
2845 }
2846
2847 /* Sandbox lua - Only allow access to images within the same edje file. I'm not so sure we need this level of sandboxing though. So leaving it here, just in case.
2848 if (-1 == id)
2849 {
2850 LI("Image %s not found in our edje file, trying external image file %s.\n", key, file);
2851 evas_object_image_file_set(elo->evas_obj, file, key);
2852 }
2853 */
2854 }
2855 evas_object_image_file_get(elo->evas_obj, &file, &key);
2856 _elua_ret(L, "$file $key", file, key);
2857 // Stack usage [-4, +5, em]
2858 return 1;
2859}
2860
2861//-------------
2862//-------------
2863/**
2864@page luaref
2865@subsection evas_line Evas line class.
2866
2867The lua evas line class includes functions for dealing with evas line objects.
2868The evas line objects must have been previously created by lua using the lua
2869line object creation function edje:line().
2870
2871In the following, "line_object" is a place holder for any lua variable that
2872holds a reference to an evas line object.
2873
2874@since 1.1.0
2875*/
2876
2877static int _elua_line_xy(lua_State *L);
2878
2879static const char *_elua_evas_line_api = "evas_line";
2880static const char *_elua_evas_line_parent = "evas_line_parent";
2881static const struct luaL_reg _elua_evas_line_funcs [] =
2882{
2883 {"xy", _elua_line_xy}, // get or set line coords
2884
2885 {NULL, NULL} // end
2886};
2887
2888/**
2889@page luaref
2890@subsubsection line_xy line_object:xy(x1, y1, x2, y2)
2891
2892Sets the end points of this line.
2893
2894Wraps evas_object_line_xy_set().
2895
2896@param x1 The X coordinate of the first line end.
2897@param y1 The Y coordinate of the first line end.
2898@param x2 The X coordinate of the other line end.
2899@param y2 The Y coordinate of the other line end.
2900
2901Note that the arguments are optional, without them this function just queries
2902the current values. The arguments can be separate values, or named fields in a
2903table.
2904
2905@return A table with these fields:
2906 - integer x1: The X coordinate of the first line end.
2907 - integer y1: The Y coordinate of the first line end.
2908 - integer x2: The X coordinate of the other line end.
2909 - integer y2: The Y coordinate of the other line end.
2910
2911@since 1.1.0
2912*/
2913static int _elua_line_xy(lua_State *L) // Stack usage [-(8|12), +(9|13), em]
2914{
2915 Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -]
2916 Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj;
2917 Evas_Coord x1, y1, x2, y2;
2918
2919 if (!_elua_isa(obj, _elua_evas_line_meta)) return 0;
2920
2921 if (_elua_scan_params(L, 2, "%x1 %y1 %x2 %y2", &x1, &y1, &x2, &y2) > 0)
2922 { // Stack usage [-0, +0, m] unless it's in a table [-4, +4, e]
2923 evas_object_line_xy_set(elo->evas_obj, x1, y1, x2, y2);
2924 }
2925 evas_object_line_xy_get(elo->evas_obj, &x1, &y1, &x2, &y2);
2926 _elua_ret(L, "%x1 %y1 %x2 %y2", x1, y1, x2, y2);
2927 // Stack usage [-8, +9, em]
2928 return 1;
2929}
2930
2931//-------------
2932//-------------
2933/**
2934@page luaref
2935@subsection evas_object_map Evas map class.
2936
2937The lua evas map class includes functions for dealing with evas map objects.
2938The evas map objects must have been previously created by lua using the lua
2939map object creation function edje:map().
2940
2941In the following, "map_object" is a place holder for any lua variable that
2942holds a reference to an evas map object.
2943
2944@since 1.1.0
2945*/
2946
2947static int _elua_map_alpha(lua_State *L);
2948static int _elua_map_clockwise(lua_State *L);
2949static int _elua_map_colour(lua_State *L);
2950static int _elua_map_coord(lua_State *L);
2951static int _elua_map_lighting(lua_State *L);
2952static int _elua_map_perspective(lua_State *L);
2953static int _elua_map_populate(lua_State *L);
2954static int _elua_map_rotate(lua_State *L);
2955static int _elua_map_rotate3d(lua_State *L);
2956static int _elua_map_smooth(lua_State *L);
2957static int _elua_map_uv(lua_State *L);
2958static int _elua_map_zoom(lua_State *L);
2959
2960static const char *_elua_evas_map_api = "ewas_map";
2961static const struct luaL_reg _elua_evas_map_funcs [] =
2962{
2963 {"alpha", _elua_map_alpha},
2964// {"dup", _elua_map_dup}, // not sure of proper api for this.
2965 {"clockwise", _elua_map_clockwise},
2966 {"color", _elua_map_colour},
2967 {"coord", _elua_map_coord},
2968 {"lighting", _elua_map_lighting},
2969 {"perspective", _elua_map_perspective},
2970 {"populate", _elua_map_populate},
2971 {"rotate", _elua_map_rotate},
2972 {"rotate3d", _elua_map_rotate3d},
2973// {"size", _elua_map_size}, // not sure of proper API for this
2974 {"smooth", _elua_map_smooth},
2975 {"uv", _elua_map_uv},
2976 {"zoom", _elua_map_zoom},
2977
2978 {NULL, NULL} // end
2979};
2980
2981/**
2982@page luaref
2983@subsubsection map_alpha map_object:alpha()
2984
2985
2986@since 1.1.0
2987*/
2988static int
2989_elua_map_alpha(lua_State *L) // Stack usage [-0, +1, -]
2990{
2991 Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -]
2992 Edje_Lua_Map *elm = (Edje_Lua_Map *)obj;
2993 int n;
2994
2995 if (!_elua_isa(obj, _elua_evas_map_meta)) return 0;
2996
2997 n = lua_gettop(L); // Stack usage [-0, +0, -]
2998 if (n == 2)
2999 {
3000 evas_map_alpha_set(elm->map, lua_toboolean(L, 2));
3001 // Stack usage [-0, +0, -]
3002 }
3003 lua_pushboolean(L, evas_map_alpha_get(elm->map)); // Stack usage [-0, +1, -]
3004 return 1;
3005}
3006
3007/**
3008@page luaref
3009@subsubsection map_clockwise map_object:clockwise()
3010
3011
3012@since 1.1.0
3013*/
3014static int
3015_elua_map_clockwise(lua_State *L) // Stack usage [-0, +1, -]
3016{
3017 Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -]
3018 Edje_Lua_Map *elm = (Edje_Lua_Map *)obj;
3019
3020 if (!_elua_isa(obj, _elua_evas_map_meta)) return 0;
3021
3022 lua_pushboolean(L, evas_map_util_clockwise_get(elm->map)); // Stack usage [-0, +1, -]
3023 return 1;
3024}
3025
3026/**
3027@page luaref
3028@subsubsection map_colour map_object:colour()
3029
3030
3031@since 1.1.0
3032*/
3033static int
3034_elua_map_colour(lua_State *L) // Stack usage [-(8|12), +(9|13), em]
3035{
3036 Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -]
3037 Edje_Lua_Map *elm = (Edje_Lua_Map *)obj;
3038 int r, g, b, a;
3039 int n;
3040
3041 if (!_elua_isa(obj, _elua_evas_map_meta)) return 0;
3042 n = lua_gettop(L); // Stack usage [-0, +0, -]
3043
3044 switch (n)
3045 {
3046 case 5 :
3047 {
3048 if (_elua_scan_params(L, 2, "%r %g %b %a", &r, &g, &b, &a) > 0)
3049 { // Stack usage [-0, +0, m] unless it's in a table [-4, +4, e]
3050 evas_map_util_points_color_set(elm->map, r, g, b, a);
3051 }
3052 break;
3053 }
3054
3055 case 1 :
3056 case 6 :
3057 {
3058 if (_elua_scan_params(L, 3, "%r %g %b %a", &r, &g, &b, &a) > 0)
3059 { // Stack usage [-0, +0, m] unless it's in a table [-4, +4, e]
3060 evas_map_point_color_set(elm->map, lua_tointeger(L, 2), r, g, b, a);
3061 // Stack usage [-0, +0, -]
3062 }
3063 evas_map_point_color_get(elm->map, lua_tointeger(L, 2), &r, &g, &b, &a);
3064 // Stack usage [-0, +0, -]
3065 _elua_ret(L, "%r %g %b %a", r, g, b, a);
3066 // Stack usage [-8, +9, em]
3067 return 1;
3068 }
3069 }
3070
3071 return 0;
3072}
3073
3074/**
3075@page luaref
3076@subsubsection map_coord map_object:coord()
3077
3078
3079@since 1.1.0
3080*/
3081static int
3082_elua_map_coord(lua_State *L) // Stack usage [-(6|9), +(7|10), em]
3083{
3084 Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -]
3085 Edje_Lua_Map *elm = (Edje_Lua_Map *)obj;
3086 Evas_Coord x, y, z;
3087 int n;
3088
3089 if (!_elua_isa(obj, _elua_evas_map_meta)) return 0;
3090 n = lua_gettop(L); // Stack usage [-0, +0, -]
3091 if (2 > n) return 0;
3092
3093 if (_elua_scan_params(L, 2, "%x %y %z", &x, &y, &z) > 0)
3094 { // Stack usage [-0, +0, m] unless it's in a table [-3, +3, e]
3095 evas_map_point_coord_set(elm->map, lua_tointeger(L, 2), x, y, z);
3096 // Stack usage [-0, +0, -]
3097 }
3098 evas_map_point_coord_get(elm->map, lua_tointeger(L, 2), &x, &y, &z);
3099 // Stack usage [-0, +0, -]
3100 _elua_ret(L, "%x %y %z", x, y, z);
3101 // Stack usage [-6, +7, em]
3102 return 1;
3103}
3104
3105/**
3106@page luaref
3107@subsubsection map_lighting map_object:lighting()
3108
3109
3110@since 1.1.0
3111*/
3112static int
3113_elua_map_lighting(lua_State *L) // Stack usage [-(0|9), +(0|9), e]
3114{
3115 Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -]
3116 Edje_Lua_Map *elm = (Edje_Lua_Map *)obj;
3117 Evas_Coord x, y, z;
3118 int r, g, b, r1, g1, b1;
3119 int n;
3120
3121 if (!_elua_isa(obj, _elua_evas_map_meta)) return 0;
3122
3123 if ((n = _elua_scan_params(L, 2, "%x %y %z", &x, &y, &z)) > 0)
3124 // Stack usage [-0, +0, m] unless it's in a table [-3, +3, e]
3125 if (n += _elua_scan_params(L, 2 + n, "%r %g %b", &r, &g, &b) > 0)
3126 // Stack usage [-0, +0, m] unless it's in a table [-3, +3, e]
3127 if (_elua_scan_params(L, 2 + n, "%r %g %b", &r1, &g1, &b1) > 0)
3128 { // Stack usage [-0, +0, m] unless it's in a table [-3, +3, e]
3129 evas_map_util_3d_lighting(elm->map, x, y, z, r, g, b, r1, g1, b1);
3130 }
3131 return 0;
3132}
3133
3134/**
3135@page luaref
3136@subsubsection map_perspective map_object:perspective()
3137
3138
3139@since 1.1.0
3140*/
3141static int
3142_elua_map_perspective(lua_State *L) // Stack usage [-(0|4), +(0|4), e]
3143{
3144 Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -]
3145 Edje_Lua_Map *elm = (Edje_Lua_Map *)obj;
3146 Evas_Coord x, y, z, f;
3147
3148 if (!_elua_isa(obj, _elua_evas_map_meta)) return 0;
3149
3150 if (_elua_scan_params(L, 2, "%x %y %z %f", &x, &y, &z, &f) > 0)
3151 { // Stack usage [-0, +0, m] unless it's in a table [-4, +4, e]
3152 evas_map_util_3d_perspective(elm->map, x, y, z, f);
3153 }
3154 return 0;
3155}
3156
3157/**
3158@page luaref
3159@subsubsection map_populate map_object:populate()
3160
3161
3162@since 1.1.0
3163*/
3164static int
3165_elua_map_populate(lua_State *L) // Stack usage [-(0|4), +(0|4), e]
3166{
3167 Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -]
3168 Edje_Lua_Map *elm = (Edje_Lua_Map *)obj;
3169 int n;
3170
3171 if (!_elua_isa(obj, _elua_evas_map_meta)) return 0;
3172 n = lua_gettop(L); // Stack usage [-0, +0, -]
3173
3174 switch (n)
3175 {
3176 case 2 :
3177 {
3178 Edje_Lua_Obj *obj2 = (Edje_Lua_Obj *)lua_touserdata(L, 2); // Stack usage [-0, +0, -]
3179 const Edje_Lua_Evas_Object *source = (Edje_Lua_Evas_Object *)obj2;
3180
3181 if (!_elua_isa(obj2, _elua_evas_meta)) return 0;
3182 evas_map_util_points_populate_from_object(elm->map, source->evas_obj);
3183 break;
3184 }
3185
3186 case 3 :
3187 {
3188 Edje_Lua_Obj *obj2 = (Edje_Lua_Obj *)lua_touserdata(L, 2); // Stack usage [-0, +0, -]
3189 const Edje_Lua_Evas_Object *source = (Edje_Lua_Evas_Object *)obj2;
3190 Evas_Coord z = lua_tointeger(L, 3);
3191
3192 if (!_elua_isa(obj2, _elua_evas_meta)) return 0;
3193 evas_map_util_points_populate_from_object_full(elm->map, source->evas_obj, z);
3194 break;
3195 }
3196
3197 case 6 :
3198 {
3199 Evas_Coord x, y, w, h;
3200
3201 if ((n = _elua_scan_params(L, 2, "%x %y %w %h", &x, &y, &w, &h)) > 0)
3202 { // Stack usage [-0, +0, m] unless it's in a table [-4, +4, e]
3203 evas_map_util_points_populate_from_geometry(elm->map, x, y, w, h, lua_tointeger(L, 2 + n));
3204 }
3205 break;
3206 }
3207 }
3208 return 0;
3209}
3210
3211/**
3212@page luaref
3213@subsubsection map_rotate map_object:rotate()
3214
3215
3216@since 1.1.0
3217*/
3218static int
3219_elua_map_rotate(lua_State *L) // Stack usage [-(0|2), +(0|2), e]
3220{
3221 Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -]
3222 Edje_Lua_Map *elm = (Edje_Lua_Map *)obj;
3223 double degrees;
3224 Evas_Coord x, y;
3225 int n;
3226
3227 if (!_elua_isa(obj, _elua_evas_map_meta)) return 0;
3228 n = lua_gettop(L); // Stack usage [-0, +0, -]
3229 if (4 != n) return 0;
3230
3231 degrees = lua_tonumber(L, 2);
3232 if (_elua_scan_params(L, 3, "%x %y", &x, &y) > 0)
3233 { // Stack usage [-0, +0, m] unless it's in a table [-2, +2, e]
3234 evas_map_util_rotate(elm->map, degrees, x, y);
3235 }
3236 return 0;
3237}
3238
3239/**
3240@page luaref
3241@subsubsection map_rotate3d map_object:rotate3d()
3242
3243
3244@since 1.1.0
3245*/
3246static int
3247_elua_map_rotate3d(lua_State *L) // Stack usage [-(0|6), +(0|6), e]
3248{
3249 Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -]
3250 Edje_Lua_Map *elm = (Edje_Lua_Map *)obj;
3251 double zx, zy, zz;
3252 Evas_Coord x, y, z;
3253 int n;
3254
3255 if (!_elua_isa(obj, _elua_evas_map_meta)) return 0;
3256
3257 if ((n = _elua_scan_params(L, 2, "#x #y #z", &zx, &zy, &zz)) > 0)
3258 // Stack usage [-0, +0, m] unless it's in a table [-3, +3, e]
3259 if (_elua_scan_params(L, 2 + n, "%x %y %z", &x, &y, &z) > 0)
3260 { // Stack usage [-0, +0, m] unless it's in a table [-3, +3, e]
3261 evas_map_util_3d_rotate(elm->map, zx, zy, zz, x, y, z);
3262 }
3263 return 0;
3264}
3265
3266/**
3267@page luaref
3268@subsubsection map_smooth map_object:smooth()
3269
3270
3271@since 1.1.0
3272*/
3273static int
3274_elua_map_smooth(lua_State *L) // Stack usage [-0, +1, -]
3275{
3276 Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -]
3277 Edje_Lua_Map *elm = (Edje_Lua_Map *)obj;
3278 int n;
3279
3280 if (!_elua_isa(obj, _elua_evas_map_meta)) return 0;
3281
3282 n = lua_gettop(L); // Stack usage [-0, +0, -]
3283 if (n == 2)
3284 {
3285 evas_map_smooth_set(elm->map, lua_toboolean(L, 2));
3286 // Stack usage [-0, +0, -]
3287 }
3288 lua_pushboolean(L, evas_map_smooth_get(elm->map)); // Stack usage [-0, +1, -]
3289 return 1;
3290}
3291
3292/**
3293@page luaref
3294@subsubsection map_uv map_object:uv()
3295
3296
3297@since 1.1.0
3298*/
3299static int
3300_elua_map_uv(lua_State *L) // Stack usage [-(4|6), +(5|7), em]
3301{
3302 Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -]
3303 Edje_Lua_Map *elm = (Edje_Lua_Map *)obj;
3304 double u, v;
3305 int n;
3306
3307 if (!_elua_isa(obj, _elua_evas_map_meta)) return 0;
3308 n = lua_gettop(L); // Stack usage [-0, +0, -]
3309 if (2 > n) return 0;
3310
3311 if (_elua_scan_params(L, 3, "#u #v", &u, &v) > 0)
3312 { // Stack usage [-0, +0, m] unless it's in a table [-2, +2, e]
3313 evas_map_point_image_uv_set(elm->map, lua_tonumber(L, 2), u, v);
3314 // Stack usage [-0, +0, -]
3315 }
3316 evas_map_point_image_uv_get(elm->map, lua_tonumber(L, 2), &u, &v);
3317 // Stack usage [-0, +0, -]
3318 _elua_ret(L, "#u #v", u, v);
3319 // Stack usage [-4, +5, em]
3320 return 1;
3321}
3322
3323/**
3324@page luaref
3325@subsubsection map_zoom map_object:zoom()
3326
3327
3328@since 1.1.0
3329*/
3330static int
3331_elua_map_zoom(lua_State *L) // Stack usage [-(0|4), +(0|4), e]
3332{
3333 Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -]
3334 Edje_Lua_Map *elm = (Edje_Lua_Map *)obj;
3335 double zx, zy;
3336 Evas_Coord x, y;
3337 int n;
3338
3339 if (!_elua_isa(obj, _elua_evas_map_meta)) return 0;
3340
3341 if ((n = _elua_scan_params(L, 2, "#x #y", &zx, &zy)) > 0)
3342 // Stack usage [-0, +0, m] unless it's in a table [-2, +2, e]
3343 if (_elua_scan_params(L, 2 + n, "%x %y", &x, &y) > 0)
3344 { // Stack usage [-0, +0, m] unless it's in a table [-2, +2, e]
3345 evas_map_util_zoom(elm->map, zx, zy, x, y);
3346 }
3347 return 0;
3348}
3349
3350//-------------
3351//-------------
3352/**
3353@page luaref
3354@subsection evas_polygon Evas polygon class.
3355
3356The lua evas polygon class includes functions for dealing with evas polygon objects.
3357The evas polygon objects must have been previously created by lua using the lua
3358polygon object creation function edje:polygon().
3359
3360In the following, "polygon_object" is a place holder for any lua variable that
3361holds a reference to an evas polygon object.
3362
3363@since 1.1.0
3364*/
3365
3366static int _elua_polygon_clear(lua_State *L);
3367static int _elua_polygon_point(lua_State *L);
3368
3369static const char *_elua_evas_polygon_api = "evas_polygon";
3370static const char *_elua_evas_polygon_parent = "evas_polygon_parent";
3371static const struct luaL_reg _elua_evas_polygon_funcs [] =
3372{
3373 {"clear", _elua_polygon_clear}, // clear all polygon points
3374 {"point", _elua_polygon_point}, // add a polygon point
3375
3376 {NULL, NULL} // end
3377};
3378
3379/**
3380@page luaref
3381@subsubsection polygon_clear polygon_object:clear()
3382
3383Clears all points from the polygon.
3384
3385Wraps evas_object_polygon_points_clear(),
3386
3387@since 1.1.0
3388*/
3389static int
3390_elua_polygon_clear(lua_State *L) // Stack usage [-0, +0, -]
3391{
3392 Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -]
3393 Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj;
3394
3395 if (!_elua_isa(obj, _elua_evas_polygon_meta)) return 0;
3396 evas_object_polygon_points_clear(elo->evas_obj);
3397 return 0;
3398}
3399
3400/**
3401@page luaref
3402@subsubsection polygon_point polygon_object:point(x, y)
3403
3404Adds a point to this polygon.
3405
3406Wraps evas_object_polygon_point_add().
3407
3408@param x The X coordinate of the point.
3409@param y The Y coordinate of the point.
3410
3411@since 1.1.0
3412*/
3413static int
3414_elua_polygon_point(lua_State *L) // Stack usage [-(0|2), +(0|2), e]
3415{
3416 Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -]
3417 Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj;
3418 Evas_Coord x, y;
3419
3420 if (!_elua_isa(obj, _elua_evas_polygon_meta)) return 0;
3421
3422 if (_elua_scan_params(L, 2, "%x %y", &x, &y) > 0)
3423 { // Stack usage [-0, +0, m] unless it's in a table [-2, +2, e]
3424 evas_object_polygon_point_add(elo->evas_obj, x, y);
3425 }
3426
3427 return 0;
3428}
3429
3430//-------------
3431//-------------
3432/**
3433@page luaref
3434@subsection evas_text Evas text class.
3435
3436The lua evas text class includes functions for dealing with evas text objects.
3437The evas text objects must have been previously created by lua using the lua
3438text object creation function edje:text().
3439
3440In the following, "text_object" is a place holder for any lua variable that
3441holds a reference to an evas text object.
3442
3443@since 1.1.0
3444*/
3445
3446static int _elua_text_font(lua_State *L);
3447static int _elua_text_text(lua_State *L);
3448
3449static const char *_elua_evas_text_api = "evas_text";
3450static const char *_elua_evas_text_parent = "evas_text_parent";
3451static const struct luaL_reg _elua_evas_text_funcs [] =
3452{
3453 {"font", _elua_text_font}, // get or set text font
3454 {"text", _elua_text_text}, // get or set text
3455// {"text_class", _elua_object_text_class}, // get or set object text class
3456
3457 {NULL, NULL} // end
3458};
3459
3460/**
3461@page luaref
3462@subsubsection text_font text_object:font(font, size)
3463
3464Gets, (and optionally sets) the font for this text object.
3465
3466Wraps evas_object_text_font_set().
3467
3468@param font The new font name.
3469@param size The new font size.
3470
3471Note that the font and size arguments are optional, without them this function
3472just queries the current values. The font and size arguments can be separate
3473values, or named fields in a table. The font name can refer to a font in the
3474edje file, or an external font.
3475
3476@return A table with these fields:
3477 - string font: The font name.
3478 - integer size: The font size.
3479
3480@since 1.1.0
3481*/
3482static int
3483_elua_text_font(lua_State *L) // Stack usage [-(4|6), +(5|7), em]
3484{
3485 Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -]
3486 Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj;
3487 char *font, *font2 = NULL;
3488 Evas_Font_Size size;
3489 int inlined_font = 0;
3490
3491 if (!_elua_isa(obj, _elua_evas_text_meta)) return 0;
3492
3493 if (_elua_scan_params(L, 2, "$font %size", &font, &size) > 0)
3494 { // Stack usage [-0, +0, m] unless it's in a table [-2, +2, e]
3495 /* Check if the font is embedded in the .edj
3496 * This is a simple check.
3497 * There is a much more complicated version in edje_text.c _edje_text_recalc_apply().
3498 * If we need to get more complicated, we can do that later,
3499 * and maybe refactor things.
3500 */
3501 if (obj->ed->file->fonts)
3502 {
3503 Edje_Font_Directory_Entry *fnt = eina_hash_find(obj->ed->file->fonts, font);
3504
3505 if (fnt)
3506 {
3507 size_t len = strlen(font) + sizeof("edje/fonts/") + 1;
3508 font2 = alloca(len);
3509 sprintf(font2, "edje/fonts/%s", font);
3510 font = font2;
3511 inlined_font = 1;
3512 font2 = NULL;
3513 }
3514 }
3515
3516 if (inlined_font) evas_object_text_font_source_set(elo->evas_obj, obj->ed->path);
3517 else evas_object_text_font_source_set(elo->evas_obj, NULL);
3518
3519 evas_object_text_font_set(elo->evas_obj, font, size);
3520 }
3521
3522 // When one external API says it's gotta be const, and another one says not, then one of them's gotta be cast. :-P
3523 evas_object_text_font_get(elo->evas_obj, (const char **) &font, &size);
3524 _elua_ret(L, "$font %size", font, size);
3525 // Stack usage [-4, +5, em]
3526 return 1;
3527}
3528
3529/**
3530@page luaref
3531@subsubsection text_text text_object:text(text)
3532
3533Get (and optionally set) the actual tetx for this text object.
3534
3535Wraps evas_object_text_text_set().
3536
3537@param text The text to set for this text object.
3538
3539Note that the argument is optional, without it this function just queries the
3540current value.
3541
3542@return A string of the text on this text object.
3543
3544@since 1.1.0
3545*/
3546static int
3547_elua_text_text(lua_State *L) // Stack usage [-0, +1, m]
3548{
3549 Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -]
3550 Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj;
3551 int n;
3552
3553 if (!_elua_isa(obj, _elua_evas_text_meta)) return 0;
3554 n = lua_gettop(L); // Stack usage [-0, +0, -]
3555 if (n == 2)
3556 {
3557 if (lua_isstring(L, 2))
3558 {
3559 const char *str;
3560
3561 if ((str = lua_tostring(L, 2))) // Extra parenthesis, coz Mikes compiler has a lisp.
3562 // Stack usage [-0, +0, m]
3563 evas_object_text_text_set(elo->evas_obj, str);
3564 }
3565 }
3566 lua_pushstring(L, evas_object_text_text_get(elo->evas_obj)); // Stack usage [-0, +1, m]
3567 return 1;
3568}
3569
3570
3571//--------------------------------------------------------------------------//
3572// Brain dead inheritance thingy, built for speed. Kinda. Part 1.
3573static void
3574_elua_add_functions(lua_State *L, const char *api, const luaL_Reg *funcs, const char *meta, const char *parent, const char *base) // Stack usage [-3, +5, m] if inheriting [-6, +11, em]
3575{
3576 luaL_register(L, api, funcs); // Stack usage [-0, +1, m]
3577 luaL_newmetatable(L, meta); // Stack usage [-0, +1, m]
3578 luaL_register(L, 0, _elua_edje_gc_funcs); // Stack usage [-1, +1, m]
3579 lua_pushliteral(L, "__index"); // Stack usage [-0, +1, m]
3580 lua_pushvalue(L, -3); // Stack usage [-0, +1, -]
3581 lua_rawset(L, -3); // Stack usage [-2, +0, m]
3582
3583 if (base && parent)
3584 {
3585 // Inherit from base
3586 lua_getglobal(L, base); // Stack usage [-0, +1, e]
3587 luaL_newmetatable(L, parent); // Stack usage [-0, +1, m]
3588 lua_pushliteral(L, "__index"); // Stack usage [-0, +1, m]
3589 lua_pushvalue(L, -3); // Stack usage [-0, +1, -]
3590 lua_rawset(L, -3); // Stack usage [-2, +0, m]
3591 lua_getglobal(L, api); // Stack usage [-0, +1, e]
3592 luaL_getmetatable(L, parent); // Stack usage [-0, +1, -]
3593 lua_setmetatable(L, -2); // Stack usage [-1, +0, -]
3594 }
3595}
3596
3597// Brain dead inheritance thingy, built for speed. Kinda. Part 2.
3598static Eina_Bool
3599_elua_isa(Edje_Lua_Obj *obj, const char *type)
3600{
3601 Eina_Bool isa = EINA_FALSE;
3602
3603 if (!obj) return isa;
3604 if (obj->meta == type)
3605 isa = EINA_TRUE;
3606 if (_elua_evas_meta == type)
3607 {
3608 if (obj->meta == _elua_evas_image_meta)
3609 isa = EINA_TRUE;
3610 else if (obj->meta == _elua_evas_text_meta)
3611 isa = EINA_TRUE;
3612 else if (obj->meta == _elua_evas_edje_meta)
3613 isa = EINA_TRUE;
3614 else if (obj->meta == _elua_evas_line_meta)
3615 isa = EINA_TRUE;
3616 else if (obj->meta == _elua_evas_polygon_meta)
3617 isa = EINA_TRUE;
3618 }
3619 return isa;
3620}
3621
3622#ifndef RASTER_FORGOT_WHY
3623static void
3624_elua_init(void) // Stack usage [-16, +20, em]
3625{
3626 static Edje_Lua_Alloc ela = { MAX_LUA_MEM, 0 };
3627 const luaL_Reg *l;
3628 lua_State *L;
3629
3630 if (lstate) return;
3631
3632 lstate = L = lua_newstate(_elua_alloc, &ela); // Stack usage [-0, +0, -]
3633 lua_atpanic(L, _elua_custom_panic); // Stack usage [-0, +0, -]
3634
3635// FIXME: figure out optimal gc settings later
3636// lua_gc(L, LUA_GCSETPAUSE, 200); // Stack usage [-0, +0, e]
3637// lua_gc(L, LUA_GCSETSTEPMUL, 200); // Stack usage [-0, +0, e]
3638
3639 for (l = _elua_libs; l->func; l++) // Currently * 4
3640 {
3641 lua_pushcfunction(L, l->func); // Stack usage [-0, +1, m]
3642 lua_pushstring(L, l->name); // Stack usage [-0, +1, m]
3643 lua_call(L, 1, 0); // Stack usage [-2, +0, e]
3644 }
3645
3646 luaL_register(L, _elua_edje_api, _elua_edje_funcs); // Stack usage [-0, +1, m]
3647 luaL_newmetatable(L, _elua_edje_meta); // Stack usage [-0, +1, m]
3648 luaL_register(L, 0, _elua_edje_gc_funcs); // Stack usage [-1, +1, m]
3649
3650 _elua_add_functions(L, _elua_evas_api, _elua_evas_funcs, _elua_evas_meta, NULL, NULL); // Stack usage [-3, +5, m]
3651
3652 // weak table for our objects
3653 lua_pushlightuserdata(L, &_elua_objs); // Stack usage [-0, +1, -]
3654 lua_newtable(L); // Stack usage [-0, +1, m]
3655 lua_pushstring(L, "__mode"); // Stack usage [-0, +1, m]
3656 lua_pushstring(L, "v"); // Stack usage [-0, +1, m]
3657 lua_rawset(L, -3); // Stack usage [-2, +0, m]
3658 lua_rawset(L, LUA_REGISTRYINDEX); // Stack usage [-2, +0, m]
3659}
3660#endif
3661
3662void
3663_edje_lua2_script_init(Edje *ed) // Stack usage [-63, +99, em]
3664{
3665 static Edje_Lua_Alloc ela = { MAX_LUA_MEM, 0 };
3666 const luaL_Reg *l;
3667 char buf[256];
3668 void *data;
3669 int size;
3670 lua_State *L;
3671
3672 if (ed->L) return;
3673 if (0 > _log_domain)
3674 _log_domain = eina_log_domain_register("lua", NULL);
3675 if (0 <= _log_domain)
3676 {
3677 _log_count++;
3678 eina_log_domain_level_set("lua", EINA_LOG_LEVEL_WARN);
3679 }
3680
3681#ifndef RASTER_FORGOT_WHY
3682 _elua_init(); // This is actually truly pointless, even if raster remembers.
3683#endif
3684 L = ed->L = lua_newstate(_elua_alloc, &ela); // Stack usage [-0, +0, -]
3685 lua_atpanic(L, _elua_custom_panic); // Stack usage [-0, +0, -]
3686
3687// FIXME: figure out optimal gc settings later
3688// lua_gc(L, LUA_GCSETPAUSE, 200); // Stack usage [-0, +0, e]
3689// lua_gc(L, LUA_GCSETSTEPMUL, 200); // Stack usage [-0, +0, e]
3690
3691 for (l = _elua_libs; l->func; l++) // Currently * 4
3692 {
3693 lua_pushcfunction(L, l->func); // Stack usage [-0, +1, m]
3694 lua_pushstring(L, l->name); // Stack usage [-0, +1, m]
3695 lua_call(L, 1, 0); // Stack usage [-2, +0, m]
3696 }
3697
3698 luaL_register(L, _elua_edje_api, _elua_edje_funcs); // Stack usage [-0, +1, m]
3699 luaL_newmetatable(L, _elua_edje_meta); // Stack usage [-0, +1, m]
3700 luaL_register(L, 0, _elua_edje_gc_funcs); // Stack usage [-1, +1, m]
3701
3702 lua_pop(L, 2); // Stack usage [-n, +0, -]
3703
3704 _elua_add_functions(L, _elua_evas_api, _elua_evas_funcs, _elua_evas_meta, NULL, NULL);
3705 // Stack usage [-3, +5, m]
3706 _elua_add_functions(L, _elua_ecore_timer_api, _elua_ecore_timer_funcs, _elua_ecore_timer_meta, NULL, NULL);
3707 // Stack usage [-3, +5, m]
3708 _elua_add_functions(L, _elua_ecore_animator_api, _elua_ecore_animator_funcs, _elua_ecore_animator_meta, NULL, NULL);
3709 // Stack usage [-6, +11, m]
3710 _elua_add_functions(L, _elua_evas_edje_api, _elua_evas_edje_funcs, _elua_evas_edje_meta, _elua_evas_edje_parent, _elua_evas_api);
3711 // Stack usage [-6, +11, em]
3712 _elua_add_functions(L, _elua_evas_image_api, _elua_evas_image_funcs, _elua_evas_image_meta, _elua_evas_image_parent, _elua_evas_api);
3713 // Stack usage [-6, +11, em]
3714 _elua_add_functions(L, _elua_evas_line_api, _elua_evas_line_funcs, _elua_evas_line_meta, _elua_evas_line_parent, _elua_evas_api);
3715 // Stack usage [-6, +11, em]
3716 _elua_add_functions(L, _elua_evas_map_api, _elua_evas_map_funcs, _elua_evas_map_meta, NULL, NULL);
3717 // Stack usage [-3, +5, m]
3718 _elua_add_functions(L, _elua_evas_polygon_api, _elua_evas_polygon_funcs, _elua_evas_polygon_meta, _elua_evas_polygon_parent, _elua_evas_api);
3719 // Stack usage [-6, +11, em]
3720 _elua_add_functions(L, _elua_evas_text_api, _elua_evas_text_funcs, _elua_evas_text_meta, _elua_evas_text_parent, _elua_evas_api);
3721 // Stack usage [-6, +11, em]
3722
3723 // weak table for our objects
3724 lua_pushlightuserdata(L, &_elua_objs); // Stack usage [-0, +1, -]
3725 lua_newtable(L); // Stack usage [-0, +1, m]
3726 lua_pushstring(L, "__mode"); // Stack usage [-0, +1, m]
3727 lua_pushstring(L, "v"); // Stack usage [-0, +1, m]
3728 lua_rawset(L, -3); // Stack usage [-2, +0, m]
3729 lua_rawset(L, LUA_REGISTRYINDEX); // Stack usage [-2, +0, m]
3730
3731 _elua_table_ptr_set(L, _elua_key, ed); // Stack usage [-2, +2, e]
3732
3733 snprintf(buf, sizeof(buf), "edje/scripts/lua/%i", ed->collection->id);
3734 data = eet_read(ed->file->ef, buf, &size);
3735
3736 if (data)
3737 {
3738 int err;
3739
3740 err = luaL_loadbuffer(L, data, size, "edje_lua_script"); // Stack usage [-0, +1, m]
3741 if (err)
3742 {
3743 if (err == LUA_ERRSYNTAX)
3744 ERR("Lua load syntax error: %s",
3745 lua_tostring(L, -1)); // Stack usage [-0, +0, m]
3746 else if (err == LUA_ERRMEM)
3747 ERR("Lua load memory allocation error: %s",
3748 lua_tostring(L, -1)); // Stack usage [-0, +0, m]
3749 }
3750 free(data);
3751 /* This is not needed, pcalls don't longjmp(), that's why they are protected.
3752 if (setjmp(panic_jmp) == 1)
3753 {
3754 ERR("Lua script init panic");
3755 return;
3756 }
3757 */
3758 if ((err = lua_pcall(L, 0, 0, 0))) // Stack usage [-1, +0, -]
3759 _edje_lua2_error(L, err); // Stack usage [-0, +0, m]
3760 }
3761}
3762
3763void
3764_edje_lua2_script_shutdown(Edje *ed)
3765{
3766 if (!ed->L) return;
3767 lua_close(ed->L); // Stack usage irrelevant, as it's all gone now.
3768 ed->L = NULL;
3769 while (ed->lua_objs)
3770 {
3771 Edje_Lua_Obj *obj = (Edje_Lua_Obj *)ed->lua_objs;
3772 if (obj->free_func)
3773 {
3774 ERR("uncollected Lua object %p", obj);
3775 ed->lua_objs = eina_inlist_remove(ed->lua_objs, ed->lua_objs);
3776 }
3777 else
3778 {
3779 ERR("dangling Lua object %p", obj);
3780 ed->lua_objs = eina_inlist_remove(ed->lua_objs, ed->lua_objs);
3781 }
3782 }
3783
3784 if (0 <= _log_domain)
3785 {
3786 _log_count--;
3787 if (0 >= _log_count)
3788 {
3789 eina_log_domain_unregister(_log_domain);
3790 _log_domain = -1;
3791 }
3792 }
3793}
3794
3795void
3796_edje_lua2_script_load(Edje_Part_Collection *edc __UNUSED__, void *data __UNUSED__, int size __UNUSED__) // Stack usage [-16, +20, em]
3797{
3798#ifndef RASTER_FORGOT_WHY
3799 _elua_init(); // Stack usage [-16, +20, em]
3800#endif
3801}
3802
3803void
3804_edje_lua2_script_unload(Edje_Part_Collection *edc __UNUSED__) // Stack usage [-0, +0, e]
3805{
3806#ifndef RASTER_FORGOT_WHY
3807 lua_State *L;
3808
3809 if (!lstate) return;
3810 L = lstate;
3811 lua_gc(L, LUA_GCCOLLECT, 0); // Stack usage [-0, +0, e]
3812#endif
3813}
3814
3815void
3816_edje_lua2_error_full(const char *file, const char *fnc, int line,
3817 lua_State *L, int err_code) // Stack usage [-0, +0, m]
3818{
3819 const char *err_type;
3820
3821 switch (err_code)
3822 {
3823 case LUA_ERRRUN:
3824 err_type = "runtime";
3825 break;
3826 case LUA_ERRSYNTAX:
3827 err_type = "syntax";
3828 break;
3829 case LUA_ERRMEM:
3830 err_type = "memory allocation";
3831 break;
3832 case LUA_ERRERR:
3833 err_type = "error handler";
3834 break;
3835 default:
3836 err_type = "unknown";
3837 break;
3838 }
3839 eina_log_print
3840 (_edje_default_log_dom, EINA_LOG_LEVEL_ERR, file, fnc, line,
3841 "Lua %s error: %s", err_type, lua_tostring(L, -1)); // Stack usage [-0, +0, m]
3842}
3843
3844/**
3845@page luaref
3846@section callbacks Lua callbacks
3847
3848These are lua functions that are called by the lua edje system when certain
3849events occur. If the functions don't exist in the lua group, they don't get
3850called.
3851
3852 */
3853
3854/**
3855@page luaref
3856@subsection edje_shutdown Edje shutdown() callback.
3857
3858If a function called "shutdown" exists in a lua edje group, then it is called when
3859that edje gets deleted.
3860*/
3861void
3862_edje_lua2_script_func_shutdown(Edje *ed) // Stack usage [-1, +1, em]
3863{
3864 int err;
3865
3866 lua_getglobal(ed->L, "shutdown"); // Stack usage [-0, +1, e]
3867 if (!lua_isnil(ed->L, -1)) // Stack usage [-0, +0, -]
3868 {
3869 if ((err = lua_pcall(ed->L, 0, 0, 0))) // Stack usage [-1, +0, -]
3870 _edje_lua2_error(ed->L, err); // Stack usage [-0, +0, m]
3871 }
3872 else
3873 lua_pop(ed->L, 1); // Stack usage [-n, +0, -]
3874 _edje_lua2_script_shutdown(ed);
3875}
3876
3877/**
3878@page luaref
3879@subsection edje_show Edje show() callback.
3880
3881If a function called "show" exists in a lua edje group, then it is called when
3882that edje gets shown.
3883*/
3884void
3885_edje_lua2_script_func_show(Edje *ed) // Stack usage [-1, +1, e]
3886{
3887 int err;
3888
3889 lua_getglobal(ed->L, "show");
3890 if (!lua_isnil(ed->L, -1))
3891 {
3892 if ((err = lua_pcall(ed->L, 0, 0, 0)))
3893 _edje_lua2_error(ed->L, err);
3894 }
3895 else
3896 lua_pop(ed->L, 1);
3897}
3898
3899/**
3900@page luaref
3901@subsection edje_hide Edje hide() callback.
3902
3903If a function called "hide" exists in a lua edje group, then it is called when
3904that edje gets hidden.
3905*/
3906void
3907_edje_lua2_script_func_hide(Edje *ed) // Stack usage [-1, +1, e]
3908{
3909 int err;
3910
3911 lua_getglobal(ed->L, "hide");
3912 if (!lua_isnil(ed->L, -1))
3913 {
3914 if ((err = lua_pcall(ed->L, 0, 0, 0)))
3915 _edje_lua2_error(ed->L, err);
3916 }
3917 else
3918 lua_pop(ed->L, 1);
3919}
3920
3921/**
3922@page luaref
3923@subsection edje_move Edje move(x, y) callback.
3924
3925If a function called "move" exists in a lua edje group, then it is called when
3926that edje gets moved, with the new position passed to it.
3927*/
3928void
3929_edje_lua2_script_func_move(Edje *ed) // Stack usage [-3, +3, e] or [-1, +1, e] if no matching function.
3930{
3931 int err;
3932
3933 // FIXME: move all objects created by script
3934 lua_getglobal(ed->L, "move"); // Stack usage [-0, +1, e]
3935 if (!lua_isnil(ed->L, -1)) // Stack usage [-0, +0, -]
3936 {
3937 lua_pushinteger(ed->L, ed->x); // Stack usage [-0, +1, -]
3938 lua_pushinteger(ed->L, ed->y); // Stack usage [-0, +1, -]
3939 if ((err = lua_pcall(ed->L, 2, 0, 0))) // Stack usage [-3, +0, -]
3940 _edje_lua2_error(ed->L, err);
3941 }
3942 else
3943 lua_pop(ed->L, 1); // Stack usage [-n, +0, -]
3944}
3945
3946/**
3947@page luaref
3948@subsection edje_resize Edje resize(w, h) callback.
3949
3950If a function called "resize" exists in a lua edje group, then it is called when
3951that edje gets resized, with the new size passed to it.
3952*/
3953void
3954_edje_lua2_script_func_resize(Edje *ed) // Stack usage [-3, +3, e] or [-1, +1, e] if no matching function.
3955{
3956 int err;
3957
3958 lua_getglobal(ed->L, "resize");
3959 if (!lua_isnil(ed->L, -1))
3960 {
3961 lua_pushinteger(ed->L, ed->w);
3962 lua_pushinteger(ed->L, ed->h);
3963 if ((err = lua_pcall(ed->L, 2, 0, 0)))
3964 _edje_lua2_error(ed->L, err);
3965 }
3966 else
3967 lua_pop(ed->L, 1);
3968}
3969
3970/**
3971@page luaref
3972@subsection edje_message Edje message(id, type, ...) callback.
3973
3974If a function called "message" exists in a lua edje group, then it is called when
3975that edje gets gets a message sent to it, with the message details passed to it.
3976See edje:messagesend() for details of what each type means. The arrays are
3977passed as a table.
3978*/
3979void
3980_edje_lua2_script_func_message(Edje *ed, Edje_Message *em) // Stack usage [-?, +?, em] It's complicated, but it's even at least.
3981{
3982 int err, n, c, i;
3983
3984 lua_getglobal(ed->L, "message"); // Stack usage [-0, +1, e]
3985 if (!lua_isnil(ed->L, -1)) // Stack usage [-0, +0, -]
3986 {
3987 n = 2;
3988 lua_pushinteger(ed->L, em->id); // Stack usage [-0, +1, -]
3989 switch (em->type)
3990 {
3991 case EDJE_MESSAGE_NONE:
3992 lua_pushstring(ed->L, "none"); // Stack usage [-0, +1, m]
3993 break;
3994 case EDJE_MESSAGE_SIGNAL:
3995 break;
3996 case EDJE_MESSAGE_STRING:
3997 lua_pushstring(ed->L, "str"); // Stack usage [-0, +1, m]
3998 lua_pushstring(ed->L, ((Edje_Message_String *)em->msg)->str);
3999 // Stack usage [-0, +1, m]
4000 n += 1;
4001 break;
4002 case EDJE_MESSAGE_INT:
4003 lua_pushstring(ed->L, "int"); // Stack usage [-0, +1, m]
4004 lua_pushinteger(ed->L, ((Edje_Message_Int *)em->msg)->val);
4005 // Stack usage [-0, +1, -]
4006 n += 1;
4007 break;
4008 case EDJE_MESSAGE_FLOAT:
4009 lua_pushstring(ed->L, "float"); // Stack usage [-0, +1, m]
4010 lua_pushnumber(ed->L, ((Edje_Message_Float *)em->msg)->val);
4011 // Stack usage [-0, +1, -]
4012 n += 1;
4013 break;
4014 case EDJE_MESSAGE_STRING_SET:
4015 lua_pushstring(ed->L, "strset"); // Stack usage [-0, +1, m]
4016 c = ((Edje_Message_String_Set *)em->msg)->count;
4017 lua_createtable(ed->L, c, 0); // Stack usage [-0, +1, m]
4018 for (i = 0; i < c; i++)
4019 {
4020 lua_pushstring(ed->L, ((Edje_Message_String_Set *)em->msg)->str[i]);
4021 // Stack usage [-0, +1, m]
4022 // It's OK to bypass the metatable in these cases,
4023 // we create the table, and know there is no metatable. B-)
4024 lua_rawseti(ed->L, -2, i + 1); // Stack usage [-1, +0, m]
4025 }
4026 n += 1;
4027 break;
4028 case EDJE_MESSAGE_INT_SET:
4029 lua_pushstring(ed->L, "intset"); // Stack usage [-0, +1, m]
4030 c = ((Edje_Message_Int_Set *)em->msg)->count;
4031 lua_createtable(ed->L, c, 0); // Stack usage [-0, +1, m]
4032 for (i = 0; i < c; i++)
4033 {
4034 lua_pushinteger(ed->L, ((Edje_Message_Int_Set *)em->msg)->val[i]);
4035 // Stack usage [-0, +1, -]
4036 lua_rawseti(ed->L, -2, i + 1); // Stack usage [-1, +0, m]
4037 }
4038 n += 1;
4039 break;
4040 case EDJE_MESSAGE_FLOAT_SET:
4041 lua_pushstring(ed->L, "floatset"); // Stack usage [-0, +1, m]
4042 c = ((Edje_Message_Float_Set *)em->msg)->count;
4043 lua_createtable(ed->L, c, 0); // Stack usage [-0, +1, m]
4044 for (i = 0; i < c; i++)
4045 {
4046 lua_pushnumber(ed->L, ((Edje_Message_Float_Set *)em->msg)->val[i]);
4047 // Stack usage [-0, +1, -]
4048 lua_rawseti(ed->L, -2, i + 1); // Stack usage [-1, +0, m]
4049 }
4050 n += 1;
4051 break;
4052 case EDJE_MESSAGE_STRING_INT:
4053 lua_pushstring(ed->L, "strint"); // Stack usage [-0, +1, m]
4054 lua_pushstring(ed->L, ((Edje_Message_String_Int *)em->msg)->str);
4055 // Stack usage [-0, +1, m]
4056 lua_pushinteger(ed->L, ((Edje_Message_String_Int *)em->msg)->val);
4057 // Stack usage [-0, +1, -]
4058 n += 2;
4059 break;
4060 case EDJE_MESSAGE_STRING_FLOAT:
4061 lua_pushstring(ed->L, "strfloat"); // Stack usage [-0, +1, m]
4062 lua_pushstring(ed->L, ((Edje_Message_String_Float *)em->msg)->str);
4063 // Stack usage [-0, +1, m]
4064 lua_pushnumber(ed->L, ((Edje_Message_String_Float *)em->msg)->val);
4065 // Stack usage [-0, +1, -]
4066 n += 2;
4067 break;
4068 case EDJE_MESSAGE_STRING_INT_SET:
4069 lua_pushstring(ed->L, "strintset"); // Stack usage [-0, +1, m]
4070 lua_pushstring(ed->L, ((Edje_Message_String_Int_Set *)em->msg)->str);
4071 // Stack usage [-0, +1, m]
4072 c = ((Edje_Message_String_Int_Set *)em->msg)->count;
4073 lua_createtable(ed->L, c, 0); // Stack usage [-0, +1, m]
4074 for (i = 0; i < c; i++)
4075 {
4076 lua_pushinteger(ed->L, ((Edje_Message_String_Int_Set *)em->msg)->val[i]);
4077 // Stack usage [-0, +1, -]
4078 lua_rawseti(ed->L, -2, i + 1); // Stack usage [-1, +0, m]
4079 }
4080 n += 2;
4081 break;
4082 case EDJE_MESSAGE_STRING_FLOAT_SET:
4083 lua_pushstring(ed->L, "strfloatset"); // Stack usage [-0, +1, m]
4084 lua_pushstring(ed->L, ((Edje_Message_String_Float_Set *)em->msg)->str);
4085 // Stack usage [-0, +1, m]
4086 c = ((Edje_Message_String_Float_Set *)em->msg)->count;
4087 lua_createtable(ed->L, c, 0); // Stack usage [-0, +1, m]
4088 for (i = 0; i < c; i++)
4089 {
4090 lua_pushnumber(ed->L, ((Edje_Message_String_Float_Set *)em->msg)->val[i]);
4091 // Stack usage [-0, +1, -]
4092 lua_rawseti(ed->L, -2, i + 1); // Stack usage [-1, +0, m]
4093 }
4094 n += 2;
4095 break;
4096 default:
4097 break;
4098 }
4099 if ((err = lua_pcall(ed->L, n, 0, 0))) // Stack usage [-n+1, +0, -]
4100 _edje_lua2_error(ed->L, err);
4101 }
4102 else
4103 lua_pop(ed->L, 1); // Stack usage [-n, +0, -]
4104}
4105
4106/**
4107@page luaref
4108@subsection edje_signal Edje signal(signal, source) callback.
4109
4110If a function called "signal" exists in a lua edje group, then it is called when
4111ever a signal arrives, with the signal details passed to it.
4112
4113*/
4114void
4115_edje_lua2_script_func_signal(Edje *ed, const char *sig, const char *src) // Stack usage [-3, +3, em] or [-1, +1, e] if no matching function.
4116{
4117 int err;
4118
4119 lua_getglobal(ed->L, "signal");
4120 if (!lua_isnil(ed->L, -1))
4121 {
4122 lua_pushstring(ed->L, sig);
4123 lua_pushstring(ed->L, src);
4124 if ((err = lua_pcall(ed->L, 2, 0, 0)))
4125 _edje_lua2_error(ed->L, err);
4126 }
4127 else
4128 lua_pop(ed->L, 1);
4129}
diff --git a/libraries/edje/src/lib/edje_lua_script_only.c b/libraries/edje/src/lib/edje_lua_script_only.c
new file mode 100644
index 0000000..e283c83
--- /dev/null
+++ b/libraries/edje/src/lib/edje_lua_script_only.c
@@ -0,0 +1,59 @@
1#include "edje_private.h"
2
3Eina_Bool
4_edje_lua_script_only(Edje *ed)
5{
6 if ((ed->collection) && (ed->collection->lua_script_only))
7 return EINA_TRUE;
8 return EINA_FALSE;
9}
10
11void
12_edje_lua_script_only_init(Edje *ed)
13{
14 if (ed->collection)
15 _edje_lua2_script_init(ed);
16}
17
18void
19_edje_lua_script_only_shutdown(Edje *ed)
20{
21 if (ed->collection && ed->L)
22 _edje_lua2_script_func_shutdown(ed);
23}
24
25void
26_edje_lua_script_only_show(Edje * ed)
27{
28 if (ed->collection && ed->L)
29 _edje_lua2_script_func_show(ed);
30}
31
32void
33_edje_lua_script_only_hide(Edje * ed)
34{
35 if (ed->collection && ed->L)
36 _edje_lua2_script_func_hide(ed);
37}
38
39void
40_edje_lua_script_only_move(Edje * ed)
41{
42 if (ed->collection && ed->L)
43 _edje_lua2_script_func_move(ed);
44}
45
46void
47_edje_lua_script_only_resize(Edje * ed)
48{
49 if (ed->collection && ed->L)
50 _edje_lua2_script_func_resize(ed);
51}
52
53void
54_edje_lua_script_only_message(Edje * ed, Edje_Message * em)
55{
56 if (ed->collection && ed->L)
57 _edje_lua2_script_func_message(ed, em);
58}
59
diff --git a/libraries/edje/src/lib/edje_main.c b/libraries/edje/src/lib/edje_main.c
new file mode 100644
index 0000000..cf443c7
--- /dev/null
+++ b/libraries/edje/src/lib/edje_main.c
@@ -0,0 +1,274 @@
1#include "edje_private.h"
2
3static Edje_Version _version = { VMAJ, VMIN, VMIC, VREV };
4EAPI Edje_Version *edje_version = &_version;
5
6static int _edje_init_count = 0;
7int _edje_default_log_dom = -1;
8Eina_Mempool *_edje_real_part_mp = NULL;
9Eina_Mempool *_edje_real_part_state_mp = NULL;
10
11/*============================================================================*
12 * API *
13 *============================================================================*/
14
15
16EAPI int
17edje_init(void)
18{
19 if (++_edje_init_count != 1)
20 return _edje_init_count;
21
22 srand(time(NULL));
23
24 if (!eina_init())
25 {
26 fprintf(stderr, "Edje: Eina init failed");
27 return --_edje_init_count;
28 }
29
30 _edje_default_log_dom = eina_log_domain_register
31 ("edje", EDJE_DEFAULT_LOG_COLOR);
32 if (_edje_default_log_dom < 0)
33 {
34 EINA_LOG_ERR("Edje Can not create a general log domain.");
35 goto shutdown_eina;
36 }
37
38 if (!ecore_init())
39 {
40 ERR("Ecore init failed");
41 goto unregister_log_domain;
42 }
43
44 if (!embryo_init())
45 {
46 ERR("Embryo init failed");
47 goto shutdown_ecore;
48 }
49
50 if (!eet_init())
51 {
52 ERR("Eet init failed");
53 goto shutdown_embryo;
54 }
55
56 _edje_scale = FROM_DOUBLE(1.0);
57
58 _edje_edd_init();
59 _edje_text_init();
60 _edje_box_init();
61 _edje_external_init();
62 _edje_module_init();
63 _edje_message_init();
64 _edje_multisense_init();
65
66 _edje_real_part_mp = eina_mempool_add("chained_mempool",
67 "Edje_Real_Part", NULL,
68 sizeof (Edje_Real_Part), 128);
69 if (!_edje_real_part_mp)
70 {
71 ERR("Mempool for Edje_Real_Part cannot be allocated.");
72 goto shutdown_eet;
73 }
74
75 _edje_real_part_state_mp = eina_mempool_add("chained_mempool",
76 "Edje_Real_Part_State", NULL,
77 sizeof (Edje_Real_Part_State), 256);
78 if (!_edje_real_part_state_mp)
79 {
80 ERR("Mempool for Edje_Real_Part_State cannot be allocated.");
81 goto shutdown_eet;
82 }
83
84 return _edje_init_count;
85
86 shutdown_eet:
87 eina_mempool_del(_edje_real_part_state_mp);
88 eina_mempool_del(_edje_real_part_mp);
89 _edje_real_part_state_mp = NULL;
90 _edje_real_part_mp = NULL;
91 _edje_message_shutdown();
92 _edje_module_shutdown();
93 _edje_external_shutdown();
94 _edje_box_shutdown();
95 _edje_text_class_members_free();
96 _edje_text_class_hash_free();
97 _edje_edd_shutdown();
98 eet_shutdown();
99 shutdown_embryo:
100 embryo_shutdown();
101 shutdown_ecore:
102 ecore_shutdown();
103 unregister_log_domain:
104 eina_log_domain_unregister(_edje_default_log_dom);
105 _edje_default_log_dom = -1;
106 shutdown_eina:
107 eina_shutdown();
108 return --_edje_init_count;
109}
110
111static int _edje_users = 0;
112
113static void
114_edje_shutdown_core(void)
115{
116 if (_edje_users > 0) return;
117
118 _edje_file_cache_shutdown();
119 _edje_color_class_members_free();
120 _edje_color_class_hash_free();
121
122 eina_mempool_del(_edje_real_part_state_mp);
123 eina_mempool_del(_edje_real_part_mp);
124 _edje_real_part_state_mp = NULL;
125 _edje_real_part_mp = NULL;
126
127 _edje_multisense_shutdown();
128 _edje_message_shutdown();
129 _edje_module_shutdown();
130 _edje_external_shutdown();
131 _edje_box_shutdown();
132 _edje_text_class_members_free();
133 _edje_text_class_hash_free();
134 _edje_edd_shutdown();
135
136 eet_shutdown();
137 embryo_shutdown();
138 ecore_shutdown();
139 eina_log_domain_unregister(_edje_default_log_dom);
140 _edje_default_log_dom = -1;
141 eina_shutdown();
142}
143
144void
145_edje_lib_ref(void)
146{
147 _edje_users++;
148}
149
150void
151_edje_lib_unref(void)
152{
153 _edje_users--;
154 if (_edje_users != 0) return;
155 if (_edje_init_count == 0) _edje_shutdown_core();
156}
157
158EAPI int
159edje_shutdown(void)
160{
161 if (--_edje_init_count != 0)
162 return _edje_init_count;
163
164 if (_edje_timer)
165 ecore_animator_del(_edje_timer);
166 _edje_timer = NULL;
167
168 _edje_shutdown_core();
169
170 return _edje_init_count;
171}
172
173/* Private Routines */
174static Eina_Bool
175_class_member_free(const Eina_Hash *hash __UNUSED__,
176 const void *key,
177 void *data,
178 void *fdata)
179{
180 void (*_edje_class_member_direct_del)(const char *class, void *l) = fdata;
181
182 _edje_class_member_direct_del(key, data);
183 return EINA_TRUE;
184}
185
186void
187_edje_del(Edje *ed)
188{
189 Edje_Running_Program *runp;
190 Edje_Pending_Program *pp;
191 Edje_Signal_Callback *escb;
192 Edje_Color_Class *cc;
193 Edje_Text_Class *tc;
194 Edje_Text_Insert_Filter_Callback *cb;
195
196 if (ed->processing_messages)
197 {
198 ed->delete_me = 1;
199 return;
200 }
201 _edje_message_del(ed);
202 _edje_callbacks_patterns_clean(ed);
203 _edje_file_del(ed);
204 if (ed->path) eina_stringshare_del(ed->path);
205 if (ed->group) eina_stringshare_del(ed->group);
206 if (ed->parent) eina_stringshare_del(ed->parent);
207 ed->path = NULL;
208 ed->group = NULL;
209 if ((ed->actions) || (ed->pending_actions))
210 {
211 _edje_animators = eina_list_remove(_edje_animators, ed);
212 }
213 EINA_LIST_FREE(ed->actions, runp)
214 free(runp);
215 EINA_LIST_FREE(ed->pending_actions, pp)
216 free(pp);
217 EINA_LIST_FREE(ed->callbacks, escb)
218 {
219 if (escb->signal) eina_stringshare_del(escb->signal);
220 if (escb->source) eina_stringshare_del(escb->source);
221 free(escb);
222 }
223 EINA_LIST_FREE(ed->color_classes, cc)
224 {
225 if (cc->name) eina_stringshare_del(cc->name);
226 free(cc);
227 }
228 EINA_LIST_FREE(ed->text_classes, tc)
229 {
230 if (tc->name) eina_stringshare_del(tc->name);
231 if (tc->font) eina_stringshare_del(tc->font);
232 free(tc);
233 }
234 EINA_LIST_FREE(ed->text_insert_filter_callbacks, cb)
235 {
236 eina_stringshare_del(cb->part);
237 free(cb);
238 }
239
240 if (ed->members.text_class)
241 {
242 eina_hash_foreach(ed->members.text_class, _class_member_free, _edje_text_class_member_direct_del);
243 eina_hash_free(ed->members.text_class);
244 }
245 if (ed->members.color_class)
246 {
247 eina_hash_foreach(ed->members.color_class, _class_member_free, _edje_color_class_member_direct_del);
248 eina_hash_free(ed->members.color_class);
249 }
250 free(ed);
251}
252
253void
254_edje_clean_objects(Edje *ed)
255{
256 evas_object_del(ed->base.clipper);
257 ed->base.evas = NULL;
258 ed->obj = NULL;
259 ed->base.clipper = NULL;
260}
261
262void
263_edje_ref(Edje *ed)
264{
265 if (ed->references <= 0) return;
266 ed->references++;
267}
268
269void
270_edje_unref(Edje *ed)
271{
272 ed->references--;
273 if (ed->references == 0) _edje_del(ed);
274}
diff --git a/libraries/edje/src/lib/edje_match.c b/libraries/edje/src/lib/edje_match.c
new file mode 100644
index 0000000..f113f7b
--- /dev/null
+++ b/libraries/edje/src/lib/edje_match.c
@@ -0,0 +1,814 @@
1#include "edje_private.h"
2
3/* States manipulations. */
4
5typedef struct _Edje_State Edje_State;
6struct _Edje_State
7{
8 size_t idx;
9 size_t pos;
10};
11
12struct _Edje_States
13{
14 size_t size;
15 Edje_State *states;
16 Eina_Bool *has;
17};
18
19static void
20_edje_match_states_free(Edje_States *states,
21 size_t states_size)
22{
23 (void) states_size;
24 free(states);
25}
26
27#define ALIGN(Size) \
28 { \
29 Size--; \
30 Size |= sizeof (void*) - 1; \
31 Size++; \
32 };
33
34static int
35_edje_match_states_alloc(Edje_Patterns *ppat, int n)
36{
37 Edje_States *l;
38
39 const size_t patterns_size = ppat->patterns_size;
40 const size_t patterns_max_length = ppat->max_length;
41
42 const size_t array_len = (patterns_max_length + 1) * patterns_size;
43
44 size_t states_size;
45 size_t has_size;
46 size_t states_has_size;
47 size_t struct_size;
48
49 unsigned char *states;
50 unsigned char *has;
51
52 int i;
53
54 states_size = sizeof (*l->states) * array_len;
55 ALIGN(states_size);
56
57 has_size = sizeof (*l->has) * array_len;
58 ALIGN(has_size);
59
60 states_has_size = states_size + has_size;
61
62 struct_size = sizeof (*l);
63 ALIGN(struct_size);
64 struct_size += states_has_size;
65
66 l = malloc(n * struct_size);
67 if (!l) return 0;
68
69 ppat->states = l;
70 ppat->states->size = 0;
71
72 states = (unsigned char *) (l + n);
73 has = states + states_size;
74
75 for (i = 0; i < n; ++i)
76 {
77 l[i].states = (Edje_State *) states;
78 l[i].has = (Eina_Bool *) has;
79 l[i].size = 0;
80
81 memset(l[i].has, 0, has_size);
82
83 states += states_has_size;
84 has += states_has_size;
85 }
86
87 return 1;
88}
89
90static void
91_edje_match_states_insert(Edje_States *list,
92 size_t patterns_max_length,
93 size_t idx,
94 size_t pos)
95{
96 size_t i;
97
98 i = (idx * (patterns_max_length + 1)) + pos;
99
100 if (i < list->size)
101 {
102 if (list->has[i]) return;
103 }
104 list->has[i] = 1;
105
106 i = list->size;
107 list->states[i].idx = idx;
108 list->states[i].pos = pos;
109 list->has[i] = 0;
110 list->size++;
111}
112
113static void
114_edje_match_states_clear(Edje_States *list,
115 __UNUSED__ size_t patterns_size,
116 __UNUSED__ size_t patterns_max_length)
117{
118 list->size = 0;
119}
120
121/* Token manipulation. */
122
123enum status
124{
125 patterns_not_found = 0,
126 patterns_found = 1,
127 patterns_syntax_error = 2
128};
129
130static size_t
131_edje_match_patterns_exec_class_token(enum status *status,
132 const char *cl_tok,
133 char c)
134{
135 if (! *cl_tok)
136 {
137 *status = patterns_syntax_error;
138 return 0;
139 }
140 else if (cl_tok[1] == '-' && cl_tok[2] != ']')
141 {
142 if (*cl_tok <= c && c <= cl_tok[2])
143 *status = patterns_found;
144 return 3;
145 }
146 else
147 {
148 if (c == *cl_tok)
149 *status = patterns_found;
150 return 1;
151 }
152}
153
154static Edje_Match_Error
155_edje_match_patterns_exec_class_complement(const char *cl_tok, size_t *ret)
156{
157 switch (*cl_tok)
158 {
159 case 0:
160 return EDJE_MATCH_SYNTAX_ERROR;
161
162 case '!':
163 *ret = 1;
164 return EDJE_MATCH_OK;
165
166 default:
167 *ret = 0;
168 return EDJE_MATCH_OK;
169 }
170}
171
172static Edje_Match_Error
173_edje_match_patterns_exec_class(const char *cl,
174 char c,
175 size_t *ret)
176{
177 enum status status = patterns_not_found;
178 int pos = 1;
179 size_t neg;
180
181 if (_edje_match_patterns_exec_class_complement(cl + 1, &neg) != EDJE_MATCH_OK)
182 return EDJE_MATCH_SYNTAX_ERROR;
183
184 pos += neg;
185
186 do
187 {
188 pos += _edje_match_patterns_exec_class_token(&status, cl + pos, c);
189 }
190 while (cl[pos] && cl[pos] != ']');
191
192 if (status == patterns_syntax_error || ! cl[pos])
193 return EDJE_MATCH_SYNTAX_ERROR;
194
195 if (status == patterns_found)
196 *ret = neg ? 0 : pos + 1;
197 else
198 *ret = neg ? pos + 1 : 0;
199
200 return EDJE_MATCH_OK;
201}
202
203static Edje_Match_Error
204_edje_match_patterns_exec_token(const char *tok,
205 char c,
206 size_t *ret)
207{
208 switch (*tok)
209 {
210 case '\\':
211 if (tok[1])
212 {
213 *ret = tok[1] == c ? 2 : 0;
214 return EDJE_MATCH_OK;
215 }
216 return EDJE_MATCH_SYNTAX_ERROR;
217
218 case '?':
219 *ret = 1;
220 return EDJE_MATCH_OK;
221
222 case '[':
223 return _edje_match_patterns_exec_class(tok, c, ret);
224
225 default:
226 *ret = *tok == c ? 1 : 0;
227 return EDJE_MATCH_OK;
228 }
229}
230
231static void
232_edje_match_patterns_exec_init_states(Edje_States *states,
233 size_t patterns_size,
234 size_t patterns_max_length)
235{
236 size_t i;
237
238 states->size = patterns_size;
239
240 for (i = 0; i < patterns_size; ++i)
241 {
242 states->states[i].idx = i;
243 states->states[i].pos = 0;
244 states->has[i * (patterns_max_length + 1)] = 1;
245 }
246}
247
248/* Exported function. */
249
250#define EDJE_MATCH_INIT_LIST(Func, Type, Source, Show) \
251 Edje_Patterns* \
252 Func(const Eina_List *lst) \
253 { \
254 Edje_Patterns *r; \
255 size_t i; \
256 \
257 if (!lst || eina_list_count(lst) <= 0) \
258 return NULL; \
259 \
260 r = malloc(sizeof (Edje_Patterns) + \
261 eina_list_count(lst) \
262 * sizeof(*r->finals) \
263 * sizeof(*r->patterns)); \
264 if (!r) return NULL; \
265 \
266 r->ref = 1; \
267 r->delete_me = 0; \
268 r->patterns_size = eina_list_count(lst); \
269 r->max_length = 0; \
270 r->patterns = (const char **) r->finals + r->patterns_size + 1; \
271 \
272 for (i = 0; lst; ++i) \
273 { \
274 const char *str; \
275 Type *data; \
276 size_t j; \
277 int special = 0; \
278 \
279 data = eina_list_data_get(lst); \
280 if (!data) \
281 { \
282 free(r); \
283 return NULL; \
284 } \
285 \
286 str = data->Source; \
287 if (!str) str = ""; \
288 r->patterns[i] = str; \
289 \
290 if (Show) \
291 INF("%lu [%s]", (unsigned long)i, str); \
292 \
293 r->finals[i] = 0; \
294 for (j = 0; str[j]; ++j) \
295 if (str[j] != '*') \
296 { \
297 r->finals[i] = j + 1; \
298 special++; \
299 } \
300 j += special ? special + 1 : 0; \
301 \
302 if (j > r->max_length) \
303 r->max_length = j; \
304 \
305 lst = eina_list_next(lst); \
306 } \
307 \
308 if (!_edje_match_states_alloc(r, 2)) \
309 { \
310 free(r); \
311 return NULL; \
312 } \
313 \
314 return r; \
315 }
316
317#define EDJE_MATCH_INIT_ARRAY(Func, Type, Source, Show) \
318 Edje_Patterns* \
319 Func(Type * const *lst, unsigned int count) \
320 { \
321 Edje_Patterns *r; \
322 size_t i; \
323 \
324 if (!lst || count == 0) \
325 return NULL; \
326 \
327 r = malloc(sizeof (Edje_Patterns) + \
328 count \
329 * sizeof(*r->finals) \
330 * sizeof(*r->patterns)); \
331 if (!r) return NULL; \
332 \
333 r->ref = 1; \
334 r->delete_me = 0; \
335 r->patterns_size = count; \
336 r->max_length = 0; \
337 r->patterns = (const char **) r->finals + r->patterns_size + 1; \
338 \
339 for (i = 0; i < count; ++i) \
340 { \
341 const char *str; \
342 size_t j; \
343 int special = 0; \
344 \
345 if (!lst[i]) \
346 { \
347 free(r); \
348 return NULL; \
349 } \
350 \
351 str = lst[i]->Source; \
352 if (!str) str = ""; \
353 r->patterns[i] = str; \
354 \
355 if (Show) \
356 INF("%lu [%s]", (unsigned long)i, str); \
357 \
358 r->finals[i] = 0; \
359 for (j = 0; str[j]; ++j) \
360 if (str[j] != '*') \
361 { \
362 r->finals[i] = j + 1; \
363 special++; \
364 } \
365 j += special ? special + 1 : 0; \
366 \
367 if (j > r->max_length) \
368 r->max_length = j; \
369 } \
370 \
371 if (!_edje_match_states_alloc(r, 2)) \
372 { \
373 free(r); \
374 return NULL; \
375 } \
376 \
377 return r; \
378 }
379
380EDJE_MATCH_INIT_LIST(edje_match_collection_dir_init,
381 Edje_Part_Collection_Directory_Entry,
382 entry, 0);
383EDJE_MATCH_INIT_ARRAY(edje_match_programs_signal_init,
384 Edje_Program,
385 signal, 0);
386EDJE_MATCH_INIT_ARRAY(edje_match_programs_source_init,
387 Edje_Program,
388 source, 0);
389EDJE_MATCH_INIT_LIST(edje_match_callback_signal_init,
390 Edje_Signal_Callback,
391 signal, 0);
392EDJE_MATCH_INIT_LIST(edje_match_callback_source_init,
393 Edje_Signal_Callback,
394 source, 0);
395
396static Eina_Bool
397_edje_match_collection_dir_exec_finals(const size_t *finals,
398 const Edje_States *states)
399{
400 size_t i;
401
402 for (i = 0; i < states->size; ++i)
403 {
404 if (states->states[i].pos >= finals[states->states[i].idx])
405 return EINA_TRUE;
406 }
407 return EINA_FALSE;
408}
409
410static Eina_Bool
411edje_match_programs_exec_check_finals(const size_t *signal_finals,
412 const size_t *source_finals,
413 const Edje_States *signal_states,
414 const Edje_States *source_states,
415 Edje_Program **programs,
416 Eina_Bool (*func)(Edje_Program *pr, void *data),
417 void *data,
418 Eina_Bool prop __UNUSED__)
419{
420 size_t i;
421 size_t j;
422
423 /* when not enought memory, they could be NULL */
424 if (!signal_finals || !source_finals) return EINA_TRUE;
425
426 for (i = 0; i < signal_states->size; ++i)
427 {
428 if (signal_states->states[i].pos >= signal_finals[signal_states->states[i].idx])
429 {
430 for (j = 0; j < source_states->size; ++j)
431 {
432 if (signal_states->states[i].idx == source_states->states[j].idx
433 && source_states->states[j].pos >= source_finals[source_states->states[j].idx])
434 {
435 Edje_Program *pr;
436
437 pr = programs[signal_states->states[i].idx];
438 if (pr)
439 {
440 if (func(pr, data))
441 return EINA_FALSE;
442 }
443 }
444 }
445 }
446 }
447
448 return EINA_TRUE;
449}
450
451static int
452edje_match_callback_exec_check_finals(const Edje_Patterns *singal_ppat,
453 const Edje_Patterns *source_ppat,
454 const size_t *signal_finals,
455 const size_t *source_finals,
456 const Edje_States *signal_states,
457 const Edje_States *source_states,
458 const char *sig,
459 const char *source,
460 Eina_List *callbacks,
461 Edje *ed,
462 Eina_Bool prop
463 )
464{
465 size_t i;
466 size_t j;
467 int r = 1;
468
469 for (i = 0; i < signal_states->size; ++i)
470 {
471 if (signal_states->states[i].pos >= signal_finals[signal_states->states[i].idx])
472 {
473 for (j = 0; j < source_states->size; ++j)
474 {
475 if (signal_states->states[i].idx == source_states->states[j].idx
476 && source_states->states[j].pos >= source_finals[source_states->states[j].idx])
477 {
478 Edje_Signal_Callback *escb;
479
480 escb = eina_list_nth(callbacks, signal_states->states[i].idx);
481 if (escb)
482 {
483 if ((prop) && (escb->propagate)) continue;
484 if ((!escb->just_added)
485 && (!escb->delete_me))
486 {
487 escb->func(escb->data, ed->obj, sig, source);
488 r = 2;
489 }
490 if (_edje_block_break(ed))
491 return 0;
492 if ((singal_ppat->delete_me) || (source_ppat->delete_me))
493 return 0;
494 }
495 }
496 }
497 }
498 }
499
500 return r;
501}
502
503
504static Edje_States*
505_edje_match_fn(const Edje_Patterns *ppat,
506 const char *string,
507 Edje_States *states)
508{
509 Edje_States *new_states = states + 1;
510 const char *c;
511
512 for (c = string; *c && states->size; ++c)
513 {
514 size_t i;
515
516 _edje_match_states_clear(new_states, ppat->patterns_size, ppat->max_length);
517
518 for (i = 0; i < states->size; ++i)
519 {
520 const size_t idx = states->states[i].idx;
521 const size_t pos = states->states[i].pos;
522
523 if (!ppat->patterns[idx][pos])
524 continue;
525 else if (ppat->patterns[idx][pos] == '*')
526 {
527 _edje_match_states_insert(states, ppat->max_length, idx, pos + 1);
528 _edje_match_states_insert(new_states, ppat->max_length, idx, pos);
529 }
530 else
531 {
532 size_t m;
533
534 if (_edje_match_patterns_exec_token(ppat->patterns[idx] + pos,
535 *c,
536 &m) != EDJE_MATCH_OK)
537 return NULL;
538
539 if (m)
540 _edje_match_states_insert(new_states, ppat->max_length, idx, pos + m);
541 }
542 }
543 {
544 Edje_States *tmp = states;
545
546 states = new_states;
547 new_states = tmp;
548 }
549 }
550
551 return states;
552}
553
554Eina_Bool
555edje_match_collection_dir_exec(const Edje_Patterns *ppat,
556 const char *string)
557{
558 Edje_States *result;
559 Eina_Bool r = EINA_FALSE;
560
561 /* under high memory presure, it could be NULL */
562 if (!ppat) return EINA_FALSE;
563
564 _edje_match_patterns_exec_init_states(ppat->states, ppat->patterns_size, ppat->max_length);
565
566 result = _edje_match_fn(ppat, string, ppat->states);
567
568 if (result)
569 r = _edje_match_collection_dir_exec_finals(ppat->finals, result);
570
571 return r;
572}
573
574Eina_Bool
575edje_match_programs_exec(const Edje_Patterns *ppat_signal,
576 const Edje_Patterns *ppat_source,
577 const char *sig,
578 const char *source,
579 Edje_Program **programs,
580 Eina_Bool (*func)(Edje_Program *pr, void *data),
581 void *data,
582 Eina_Bool prop)
583{
584 Edje_States *signal_result;
585 Edje_States *source_result;
586 Eina_Bool r = EINA_FALSE;
587
588 /* under high memory presure, they could be NULL */
589 if (!ppat_source || !ppat_signal) return EINA_FALSE;
590
591 _edje_match_patterns_exec_init_states(ppat_signal->states,
592 ppat_signal->patterns_size,
593 ppat_signal->max_length);
594 _edje_match_patterns_exec_init_states(ppat_source->states,
595 ppat_source->patterns_size,
596 ppat_source->max_length);
597
598 signal_result = _edje_match_fn(ppat_signal, sig, ppat_signal->states);
599 source_result = _edje_match_fn(ppat_source, source, ppat_source->states);
600
601 if (signal_result && source_result)
602 r = edje_match_programs_exec_check_finals(ppat_signal->finals,
603 ppat_source->finals,
604 signal_result,
605 source_result,
606 programs,
607 func,
608 data,
609 prop);
610 return r;
611}
612
613int
614edje_match_callback_exec(Edje_Patterns *ppat_signal,
615 Edje_Patterns *ppat_source,
616 const char *sig,
617 const char *source,
618 Eina_List *callbacks,
619 Edje *ed,
620 Eina_Bool prop
621 )
622{
623 Edje_States *signal_result;
624 Edje_States *source_result;
625 int r = 0;
626
627 /* under high memory presure, they could be NULL */
628 if (!ppat_source || !ppat_signal) return 0;
629
630 ppat_signal->ref++;
631 ppat_source->ref++;
632 _edje_match_patterns_exec_init_states(ppat_signal->states,
633 ppat_signal->patterns_size,
634 ppat_signal->max_length);
635 _edje_match_patterns_exec_init_states(ppat_source->states,
636 ppat_source->patterns_size,
637 ppat_source->max_length);
638
639 signal_result = _edje_match_fn(ppat_signal, sig, ppat_signal->states);
640 source_result = _edje_match_fn(ppat_source, source, ppat_source->states);
641
642 if (signal_result && source_result)
643 r = edje_match_callback_exec_check_finals(ppat_signal,
644 ppat_source,
645 ppat_signal->finals,
646 ppat_source->finals,
647 signal_result,
648 source_result,
649 sig,
650 source,
651 callbacks,
652 ed,
653 prop);
654 ppat_signal->ref--;
655 ppat_source->ref--;
656 if (ppat_signal->ref <= 0) edje_match_patterns_free(ppat_signal);
657 if (ppat_source->ref <= 0) edje_match_patterns_free(ppat_source);
658 return r;
659}
660
661void
662edje_match_patterns_free(Edje_Patterns *ppat)
663{
664 if (!ppat) return ;
665
666 ppat->delete_me = 1;
667 ppat->ref--;
668 if (ppat->ref > 0) return;
669 _edje_match_states_free(ppat->states, 2);
670 free(ppat);
671}
672
673void
674_edje_signals_sources_patterns_clean(Edje_Signals_Sources_Patterns *ssp)
675{
676 if (!ssp->signals_patterns)
677 return;
678
679 edje_match_patterns_free(ssp->signals_patterns);
680 edje_match_patterns_free(ssp->sources_patterns);
681 ssp->signals_patterns = NULL;
682 ssp->sources_patterns = NULL;
683}
684
685static Eina_Rbtree_Direction
686_edje_signal_source_node_cmp(const Edje_Signal_Source_Char *n1,
687 const Edje_Signal_Source_Char *n2,
688 __UNUSED__ void *data)
689{
690 int cmp;
691
692 cmp = strcmp(n1->signal, n2->signal);
693 if (cmp) return cmp < 0 ? EINA_RBTREE_LEFT : EINA_RBTREE_RIGHT;
694
695 return strcmp(n1->source, n2->source) < 0 ? EINA_RBTREE_LEFT : EINA_RBTREE_RIGHT;
696}
697
698static int
699_edje_signal_source_key_cmp(const Edje_Signal_Source_Char *node,
700 const char *sig,
701 __UNUSED__ int length,
702 const char *source)
703{
704 int cmp;
705
706 cmp = strcmp(node->signal, sig);
707 if (cmp) return cmp;
708
709 return strcmp(node->source, source);
710}
711
712
713Eina_List *
714edje_match_program_hash_build(Edje_Program * const *programs,
715 unsigned int count,
716 Eina_Rbtree **tree)
717{
718 Eina_List *result = NULL;
719 Eina_Rbtree *new = NULL;
720 unsigned int i;
721
722 for (i = 0; i < count; ++i)
723 {
724 if (programs[i]->signal && !strpbrk(programs[i]->signal, "*?[\\")
725 && programs[i]->source && !strpbrk(programs[i]->source, "*?[\\"))
726 {
727 Edje_Signal_Source_Char *item;
728
729 item = (Edje_Signal_Source_Char*) eina_rbtree_inline_lookup(new, programs[i]->signal, 0,
730 EINA_RBTREE_CMP_KEY_CB(_edje_signal_source_key_cmp), programs[i]->source);
731 if (!item)
732 {
733 item = malloc(sizeof (Edje_Signal_Source_Char));
734 if (!item) continue;
735
736 item->signal = programs[i]->signal;
737 item->source = programs[i]->source;
738 item->list = NULL;
739
740 new = eina_rbtree_inline_insert(new, EINA_RBTREE_GET(item),
741 EINA_RBTREE_CMP_NODE_CB(_edje_signal_source_node_cmp), NULL);
742 }
743
744 item->list = eina_list_prepend(item->list, programs[i]);
745 }
746 else
747 result = eina_list_prepend(result, programs[i]);
748 }
749
750 *tree = new;
751 return result;
752}
753
754Eina_List *
755edje_match_callback_hash_build(const Eina_List *callbacks,
756 Eina_Rbtree **tree)
757{
758 Eina_List *result = NULL;
759 Eina_Rbtree *new = NULL;
760 Edje_Signal_Callback *callback;
761 const Eina_List *l;
762
763 EINA_LIST_FOREACH(callbacks, l, callback)
764 {
765 if (callback->signal && !strpbrk(callback->signal, "*?[\\")
766 && callback->source && !strpbrk(callback->source, "*?[\\"))
767 {
768 Edje_Signal_Source_Char *item;
769
770 item = (Edje_Signal_Source_Char*) eina_rbtree_inline_lookup(new, callback->signal, 0,
771 EINA_RBTREE_CMP_KEY_CB(_edje_signal_source_key_cmp), callback->source);
772 if (!item)
773 {
774 item = malloc(sizeof (Edje_Signal_Source_Char));
775 if (!item) continue;
776
777 item->signal = callback->signal;
778 item->source = callback->source;
779 item->list = NULL;
780
781 new = eina_rbtree_inline_insert(new, EINA_RBTREE_GET(item),
782 EINA_RBTREE_CMP_NODE_CB(_edje_signal_source_node_cmp), NULL);
783 }
784
785 item->list = eina_list_prepend(item->list, callback);
786 }
787 else
788 result = eina_list_prepend(result, callback);
789 }
790
791 *tree = new;
792 return result;
793}
794
795const Eina_List *
796edje_match_signal_source_hash_get(const char *sig,
797 const char *source,
798 const Eina_Rbtree *tree)
799{
800 Edje_Signal_Source_Char *lookup;
801
802 lookup = (Edje_Signal_Source_Char*) eina_rbtree_inline_lookup(tree, sig, 0,
803 EINA_RBTREE_CMP_KEY_CB(_edje_signal_source_key_cmp), source);
804
805 if (lookup) return lookup->list;
806 return NULL;
807}
808
809void
810edje_match_signal_source_free(Edje_Signal_Source_Char *key, __UNUSED__ void *data)
811{
812 eina_list_free(key->list);
813 free(key);
814}
diff --git a/libraries/edje/src/lib/edje_message_queue.c b/libraries/edje/src/lib/edje_message_queue.c
new file mode 100644
index 0000000..1a313a5
--- /dev/null
+++ b/libraries/edje/src/lib/edje_message_queue.c
@@ -0,0 +1,865 @@
1#include "edje_private.h"
2
3static void _edje_object_message_popornot_send(Evas_Object *obj, Edje_Message_Type type, int id, void *msg, Eina_Bool prop);
4
5static int _injob = 0;
6static Ecore_Job *_job = NULL;
7static Ecore_Timer *_job_loss_timer = NULL;
8
9static Eina_List *msgq = NULL;
10static Eina_List *tmp_msgq = NULL;
11static int tmp_msgq_processing = 0;
12static int tmp_msgq_restart = 0;
13
14/*============================================================================*
15 * API *
16 *============================================================================*/
17
18static void
19_edje_object_message_popornot_send(Evas_Object *obj, Edje_Message_Type type, int id, void *msg, Eina_Bool prop)
20{
21 Edje *ed;
22 Eina_List *l;
23 Evas_Object *o;
24
25 ed = _edje_fetch(obj);
26 if (!ed) return;
27 _edje_message_propornot_send(ed, EDJE_QUEUE_SCRIPT, type, id, msg, prop);
28 EINA_LIST_FOREACH(ed->subobjs, l, o)
29 {
30 _edje_object_message_popornot_send(o, type, id, msg, EINA_TRUE);
31 }
32}
33
34EAPI void
35edje_object_message_send(Evas_Object *obj, Edje_Message_Type type, int id, void *msg)
36{
37 _edje_object_message_popornot_send(obj, type, id, msg, EINA_FALSE);
38}
39
40
41EAPI void
42edje_object_message_handler_set(Evas_Object *obj, Edje_Message_Handler_Cb func, void *data)
43{
44 Edje *ed;
45
46 ed = _edje_fetch(obj);
47 if (!ed) return;
48 _edje_message_cb_set(ed, func, data);
49}
50
51
52EAPI void
53edje_object_message_signal_process(Evas_Object *obj)
54{
55 Eina_List *l, *ln, *tmpq = NULL;
56 Edje *ed;
57 Edje_Message *em;
58 int gotos = 0;
59
60 ed = _edje_fetch(obj);
61 if (!ed) return;
62
63 for (l = msgq; l; )
64 {
65 ln = l->next;
66 em = l->data;
67 if (em->edje == ed)
68 {
69 tmpq = eina_list_append(tmpq, em);
70 msgq = eina_list_remove_list(msgq, l);
71 }
72 l = ln;
73 }
74 /* a temporary message queue */
75 if (tmp_msgq)
76 {
77 while (tmpq)
78 {
79 tmp_msgq = eina_list_append(tmp_msgq, tmpq->data);
80 tmpq = eina_list_remove_list(tmpq, tmpq);
81 }
82 }
83 else
84 {
85 tmp_msgq = tmpq;
86 tmpq = NULL;
87 }
88
89 tmp_msgq_processing++;
90again:
91 EINA_LIST_FOREACH_SAFE(tmp_msgq, l, ln, em)
92 {
93 if (em->edje != ed) continue;
94 tmp_msgq = eina_list_remove_list(tmp_msgq, l);
95 if (!ed->delete_me)
96 {
97 ed->processing_messages++;
98 _edje_message_process(em);
99 _edje_message_free(em);
100 ed->processing_messages--;
101 }
102 else
103 _edje_message_free(em);
104 if (ed->processing_messages == 0)
105 {
106 if (ed->delete_me) _edje_del(ed);
107 }
108 // if some child callback in _edje_message_process called
109 // edje_object_message_signal_process() or
110 // edje_message_signal_process() then those will mark the restart
111 // flag when they finish - it mabsicammyt means tmp_msgq and
112 // any item in it has potentially become invalid - so that means l
113 // and ln could be rogue pointers, so start again from the beginning
114 // and skip anything that is not this object and process only what is.
115 // to avoid self-feeding loops allow a max of 1024 loops.
116 if (tmp_msgq_restart)
117 {
118 tmp_msgq_restart = 0;
119 gotos++;
120 if (gotos < 1024) goto again;
121 else
122 {
123 WRN("Edje is in a self-feeding message loop (> 1024 gotos needed in a row)");
124 goto end;
125 }
126 }
127 }
128end:
129 tmp_msgq_processing--;
130 if (tmp_msgq_processing == 0)
131 tmp_msgq_restart = 0;
132 else
133 tmp_msgq_restart = 1;
134}
135
136
137EAPI void
138edje_message_signal_process(void)
139{
140 _edje_message_queue_process();
141}
142
143
144static Eina_Bool
145_edje_dummy_timer(void *data __UNUSED__)
146{
147 return ECORE_CALLBACK_CANCEL;
148}
149
150static void
151_edje_job(void *data __UNUSED__)
152{
153 if (_job_loss_timer)
154 {
155 ecore_timer_del(_job_loss_timer);
156 _job_loss_timer = NULL;
157 }
158 _job = NULL;
159 _injob++;
160 _edje_message_queue_process();
161 _injob--;
162}
163
164static Eina_Bool
165_edje_job_loss_timer(void *data __UNUSED__)
166{
167 _job_loss_timer = NULL;
168 if (!_job)
169 {
170 _job = ecore_job_add(_edje_job, NULL);
171 }
172 return ECORE_CALLBACK_CANCEL;
173}
174
175void
176_edje_message_init(void)
177{
178}
179
180void
181_edje_message_shutdown(void)
182{
183 _edje_message_queue_clear();
184 if (_job_loss_timer)
185 {
186 ecore_timer_del(_job_loss_timer);
187 _job_loss_timer = NULL;
188 }
189 if (_job)
190 {
191 ecore_job_del(_job);
192 _job = NULL;
193 }
194}
195
196void
197_edje_message_cb_set(Edje *ed, void (*func) (void *data, Evas_Object *obj, Edje_Message_Type type, int id, void *msg), void *data)
198{
199 Eina_List *l;
200 Evas_Object *o;
201
202 ed->message.func = func;
203 ed->message.data = data;
204 EINA_LIST_FOREACH(ed->subobjs, l, o)
205 {
206 Edje *edj2 = _edje_fetch(o);
207 if (!edj2) continue;
208 _edje_message_cb_set(edj2, func, data);
209 }
210}
211
212Edje_Message *
213_edje_message_new(Edje *ed, Edje_Queue queue, Edje_Message_Type type, int id)
214{
215 Edje_Message *em;
216
217 em = calloc(1, sizeof(Edje_Message));
218 if (!em) return NULL;
219 em->edje = ed;
220 em->queue = queue;
221 em->type = type;
222 em->id = id;
223 em->edje->message.num++;
224 return em;
225}
226
227void
228_edje_message_free(Edje_Message *em)
229{
230 if (em->msg)
231 {
232 int i;
233
234 switch (em->type)
235 {
236 case EDJE_MESSAGE_STRING:
237 {
238 Edje_Message_String *emsg;
239
240 emsg = (Edje_Message_String *)em->msg;
241 free(emsg->str);
242 free(emsg);
243 }
244 break;
245 case EDJE_MESSAGE_INT:
246 {
247 Edje_Message_Int *emsg;
248
249 emsg = (Edje_Message_Int *)em->msg;
250 free(emsg);
251 }
252 break;
253 case EDJE_MESSAGE_FLOAT:
254 {
255 Edje_Message_Float *emsg;
256
257 emsg = (Edje_Message_Float *)em->msg;
258 free(emsg);
259 }
260 break;
261 case EDJE_MESSAGE_INT_SET:
262 {
263 Edje_Message_Int_Set *emsg;
264
265 emsg = (Edje_Message_Int_Set *)em->msg;
266 free(emsg);
267 }
268 break;
269 case EDJE_MESSAGE_FLOAT_SET:
270 {
271 Edje_Message_Float_Set *emsg;
272
273 emsg = (Edje_Message_Float_Set *)em->msg;
274 free(emsg);
275 }
276 break;
277 case EDJE_MESSAGE_STRING_FLOAT:
278 {
279 Edje_Message_String_Float *emsg;
280
281 emsg = (Edje_Message_String_Float *)em->msg;
282 free(emsg->str);
283 free(emsg);
284 }
285 break;
286 case EDJE_MESSAGE_STRING_INT:
287 {
288 Edje_Message_String_Int *emsg;
289
290 emsg = (Edje_Message_String_Int *)em->msg;
291 free(emsg->str);
292 free(emsg);
293 }
294 break;
295 case EDJE_MESSAGE_STRING_FLOAT_SET:
296 {
297 Edje_Message_String_Float_Set *emsg;
298
299 emsg = (Edje_Message_String_Float_Set *)em->msg;
300 free(emsg->str);
301 free(emsg);
302 }
303 break;
304 case EDJE_MESSAGE_STRING_INT_SET:
305 {
306 Edje_Message_String_Int_Set *emsg;
307
308 emsg = (Edje_Message_String_Int_Set *)em->msg;
309 free(emsg->str);
310 free(emsg);
311 }
312 break;
313 case EDJE_MESSAGE_SIGNAL:
314 {
315 Edje_Message_Signal *emsg;
316
317 emsg = (Edje_Message_Signal *)em->msg;
318 if (emsg->sig) eina_stringshare_del(emsg->sig);
319 if (emsg->src) eina_stringshare_del(emsg->src);
320 if (emsg->data && (--(emsg->data->ref) == 0))
321 {
322 if (emsg->data->free_func)
323 {
324 emsg->data->free_func(emsg->data->data);
325 }
326 free(emsg->data);
327 }
328 free(emsg);
329 }
330 break;
331 case EDJE_MESSAGE_STRING_SET:
332 {
333 Edje_Message_String_Set *emsg;
334
335 emsg = (Edje_Message_String_Set *)em->msg;
336 for (i = 0; i < emsg->count; i++)
337 free(emsg->str[i]);
338 free(emsg);
339 }
340 break;
341 case EDJE_MESSAGE_NONE:
342 default:
343 break;
344 }
345 }
346 free(em);
347}
348
349void
350_edje_message_propornot_send(Edje *ed, Edje_Queue queue, Edje_Message_Type type, int id, void *emsg, Eina_Bool prop)
351{
352 /* FIXME: check all malloc & strdup fails and gracefully unroll and exit */
353 Edje_Message *em;
354 int i;
355 unsigned char *msg = NULL;
356
357 em = _edje_message_new(ed, queue, type, id);
358 if (!em) return;
359 em->propagated = prop;
360 if (_job)
361 {
362 ecore_job_del(_job);
363 _job = NULL;
364 }
365 if (_injob > 0)
366 {
367 if (_job_loss_timer) ecore_timer_del(_job_loss_timer);
368 _job_loss_timer = ecore_timer_add(0.001, _edje_job_loss_timer, NULL);
369 }
370 else
371 {
372 if (!_job)
373 {
374 _job = ecore_job_add(_edje_job, NULL);
375 }
376 if (_job_loss_timer)
377 {
378 ecore_timer_del(_job_loss_timer);
379 _job_loss_timer = NULL;
380 }
381 }
382 switch (em->type)
383 {
384 case EDJE_MESSAGE_NONE:
385 break;
386 case EDJE_MESSAGE_SIGNAL:
387 {
388 Edje_Message_Signal *emsg2, *emsg3;
389
390 emsg2 = (Edje_Message_Signal *)emsg;
391 emsg3 = calloc(1, sizeof(Edje_Message_Signal));
392 if (emsg2->sig) emsg3->sig = eina_stringshare_add(emsg2->sig);
393 if (emsg2->src) emsg3->src = eina_stringshare_add(emsg2->src);
394 if (emsg2->data)
395 {
396 emsg3->data = emsg2->data;
397 emsg3->data->ref++;
398 }
399 msg = (unsigned char *)emsg3;
400 }
401 break;
402 case EDJE_MESSAGE_STRING:
403 {
404 Edje_Message_String *emsg2, *emsg3;
405
406 emsg2 = (Edje_Message_String *)emsg;
407
408 emsg3 = malloc(sizeof(Edje_Message_String));
409 emsg3->str = strdup(emsg2->str);
410 msg = (unsigned char *)emsg3;
411 }
412 break;
413 case EDJE_MESSAGE_INT:
414 {
415 Edje_Message_Int *emsg2, *emsg3;
416
417 emsg2 = (Edje_Message_Int *)emsg;
418 emsg3 = malloc(sizeof(Edje_Message_Int));
419 emsg3->val = emsg2->val;
420 msg = (unsigned char *)emsg3;
421 }
422 break;
423 case EDJE_MESSAGE_FLOAT:
424 {
425 Edje_Message_Float *emsg2, *emsg3;
426
427 emsg2 = (Edje_Message_Float *)emsg;
428 emsg3 = malloc(sizeof(Edje_Message_Float));
429 emsg3->val = emsg2->val;
430 msg = (unsigned char *)emsg3;
431 }
432 break;
433 case EDJE_MESSAGE_STRING_SET:
434 {
435 Edje_Message_String_Set *emsg2, *emsg3;
436
437 emsg2 = (Edje_Message_String_Set *)emsg;
438 emsg3 = malloc(sizeof(Edje_Message_String_Set) + ((emsg2->count - 1) * sizeof(char *)));
439 emsg3->count = emsg2->count;
440 for (i = 0; i < emsg3->count; i++)
441 emsg3->str[i] = strdup(emsg2->str[i]);
442 msg = (unsigned char *)emsg3;
443 }
444 break;
445 case EDJE_MESSAGE_INT_SET:
446 {
447 Edje_Message_Int_Set *emsg2, *emsg3;
448
449 emsg2 = (Edje_Message_Int_Set *)emsg;
450 emsg3 = malloc(sizeof(Edje_Message_Int_Set) + ((emsg2->count - 1) * sizeof(int)));
451 emsg3->count = emsg2->count;
452 for (i = 0; i < emsg3->count; i++)
453 emsg3->val[i] = emsg2->val[i];
454 msg = (unsigned char *)emsg3;
455 }
456 break;
457 case EDJE_MESSAGE_FLOAT_SET:
458 {
459 Edje_Message_Float_Set *emsg2, *emsg3;
460
461 emsg2 = (Edje_Message_Float_Set *)emsg;
462 emsg3 = malloc(sizeof(Edje_Message_Float_Set) + ((emsg2->count - 1) * sizeof(double)));
463 emsg3->count = emsg2->count;
464 for (i = 0; i < emsg3->count; i++)
465 emsg3->val[i] = emsg2->val[i];
466 msg = (unsigned char *)emsg3;
467 }
468 break;
469 case EDJE_MESSAGE_STRING_INT:
470 {
471 Edje_Message_String_Int *emsg2, *emsg3;
472
473 emsg2 = (Edje_Message_String_Int *)emsg;
474 emsg3 = malloc(sizeof(Edje_Message_String_Int));
475 emsg3->str = strdup(emsg2->str);
476 emsg3->val = emsg2->val;
477 msg = (unsigned char *)emsg3;
478 }
479 break;
480 case EDJE_MESSAGE_STRING_FLOAT:
481 {
482 Edje_Message_String_Float *emsg2, *emsg3;
483
484 emsg2 = (Edje_Message_String_Float *)emsg;
485 emsg3 = malloc(sizeof(Edje_Message_String_Float));
486 emsg3->str = strdup(emsg2->str);
487 emsg3->val = emsg2->val;
488 msg = (unsigned char *)emsg3;
489 }
490 break;
491 case EDJE_MESSAGE_STRING_INT_SET:
492 {
493 Edje_Message_String_Int_Set *emsg2, *emsg3;
494
495 emsg2 = (Edje_Message_String_Int_Set *)emsg;
496 emsg3 = malloc(sizeof(Edje_Message_String_Int_Set) + ((emsg2->count - 1) * sizeof(int)));
497 emsg3->str = strdup(emsg2->str);
498 emsg3->count = emsg2->count;
499 for (i = 0; i < emsg3->count; i++)
500 emsg3->val[i] = emsg2->val[i];
501 msg = (unsigned char *)emsg3;
502 }
503 break;
504 case EDJE_MESSAGE_STRING_FLOAT_SET:
505 {
506 Edje_Message_String_Float_Set *emsg2, *emsg3;
507
508 emsg2 = (Edje_Message_String_Float_Set *)emsg;
509 emsg3 = malloc(sizeof(Edje_Message_String_Float_Set) + ((emsg2->count - 1) * sizeof(double)));
510 emsg3->str = strdup(emsg2->str);
511 emsg3->count = emsg2->count;
512 for (i = 0; i < emsg3->count; i++)
513 emsg3->val[i] = emsg2->val[i];
514 msg = (unsigned char *)emsg3;
515 }
516 break;
517 default:
518 break;
519 }
520
521 em->msg = msg;
522 msgq = eina_list_append(msgq, em);
523}
524
525void
526_edje_message_send(Edje *ed, Edje_Queue queue, Edje_Message_Type type, int id, void *emsg)
527{
528 _edje_message_propornot_send(ed, queue, type, id, emsg, EINA_FALSE);
529}
530
531void
532_edje_message_parameters_push(Edje_Message *em)
533{
534 int i;
535
536 /* these params ALWAYS go on */
537 /* first param is the message type - always */
538 embryo_parameter_cell_push(em->edje->collection->script,
539 (Embryo_Cell)em->type);
540 /* 2nd param is the integer of the event id - always there */
541 embryo_parameter_cell_push(em->edje->collection->script,
542 (Embryo_Cell)em->id);
543 /* the rest is varags of whatever is in the msg */
544 switch (em->type)
545 {
546 case EDJE_MESSAGE_NONE:
547 break;
548 case EDJE_MESSAGE_STRING:
549 embryo_parameter_string_push(em->edje->collection->script,
550 ((Edje_Message_String *)em->msg)->str);
551 break;
552 case EDJE_MESSAGE_INT:
553 {
554 Embryo_Cell v;
555
556 v = (Embryo_Cell)((Edje_Message_Int *)em->msg)->val;
557 embryo_parameter_cell_array_push(em->edje->collection->script, &v, 1);
558 }
559 break;
560 case EDJE_MESSAGE_FLOAT:
561 {
562 Embryo_Cell v;
563 float fv;
564
565 fv = ((Edje_Message_Float *)em->msg)->val;
566 v = EMBRYO_FLOAT_TO_CELL(fv);
567 embryo_parameter_cell_array_push(em->edje->collection->script, &v, 1);
568 }
569 break;
570 case EDJE_MESSAGE_STRING_SET:
571 for (i = 0; i < ((Edje_Message_String_Set *)em->msg)->count; i++)
572 embryo_parameter_string_push(em->edje->collection->script,
573 ((Edje_Message_String_Set *)em->msg)->str[i]);
574 break;
575 case EDJE_MESSAGE_INT_SET:
576 for (i = 0; i < ((Edje_Message_Int_Set *)em->msg)->count; i++)
577 {
578 Embryo_Cell v;
579
580 v = (Embryo_Cell)((Edje_Message_Int_Set *)em->msg)->val[i];
581 embryo_parameter_cell_array_push(em->edje->collection->script, &v, 1);
582 }
583 break;
584 case EDJE_MESSAGE_FLOAT_SET:
585 for (i = 0; i < ((Edje_Message_Float_Set *)em->msg)->count; i++)
586 {
587 Embryo_Cell v;
588 float fv;
589
590 fv = ((Edje_Message_Float_Set *)em->msg)->val[i];
591 v = EMBRYO_FLOAT_TO_CELL(fv);
592 embryo_parameter_cell_array_push(em->edje->collection->script, &v, 1);
593 }
594 break;
595 case EDJE_MESSAGE_STRING_INT:
596 embryo_parameter_string_push(em->edje->collection->script,
597 ((Edje_Message_String_Int *)em->msg)->str);
598 {
599 Embryo_Cell v;
600
601 v = (Embryo_Cell)((Edje_Message_String_Int *)em->msg)->val;
602 embryo_parameter_cell_array_push(em->edje->collection->script, &v, 1);
603 }
604 break;
605 case EDJE_MESSAGE_STRING_FLOAT:
606 embryo_parameter_string_push(em->edje->collection->script,
607 ((Edje_Message_String_Float *)em->msg)->str);
608 {
609 Embryo_Cell v;
610 float fv;
611
612 fv = ((Edje_Message_String_Float *)em->msg)->val;
613 v = EMBRYO_FLOAT_TO_CELL(fv);
614 embryo_parameter_cell_array_push(em->edje->collection->script, &v, 1);
615 }
616 break;
617 case EDJE_MESSAGE_STRING_INT_SET:
618 embryo_parameter_string_push(em->edje->collection->script,
619 ((Edje_Message_String_Int_Set *)em->msg)->str);
620 for (i = 0; i < ((Edje_Message_String_Int_Set *)em->msg)->count; i++)
621 {
622 Embryo_Cell v;
623
624 v = (Embryo_Cell)((Edje_Message_String_Int_Set *)em->msg)->val[i];
625 embryo_parameter_cell_array_push(em->edje->collection->script, &v, 1);
626 }
627 break;
628 case EDJE_MESSAGE_STRING_FLOAT_SET:
629 embryo_parameter_string_push(em->edje->collection->script,
630 ((Edje_Message_String_Float_Set *)em->msg)->str);
631 for (i = 0; i < ((Edje_Message_String_Float_Set *)em->msg)->count; i++)
632 {
633 Embryo_Cell v;
634 float fv;
635
636 fv = ((Edje_Message_String_Float_Set *)em->msg)->val[i];
637 v = EMBRYO_FLOAT_TO_CELL(fv);
638 embryo_parameter_cell_array_push(em->edje->collection->script, &v, 1);
639 }
640 break;
641 default:
642 break;
643 }
644}
645
646void
647_edje_message_process(Edje_Message *em)
648{
649 Embryo_Function fn;
650 void *pdata;
651 int ret;
652
653 /* signals are only handled one way */
654 if (em->type == EDJE_MESSAGE_SIGNAL)
655 {
656 _edje_emit_handle(em->edje,
657 ((Edje_Message_Signal *)em->msg)->sig,
658 ((Edje_Message_Signal *)em->msg)->src,
659 ((Edje_Message_Signal *)em->msg)->data,
660 em->propagated);
661 return;
662 }
663 /* if this has been queued up for the app then just call the callback */
664 if (em->queue == EDJE_QUEUE_APP)
665 {
666 if (em->edje->message.func)
667 em->edje->message.func(em->edje->message.data, em->edje->obj,
668 em->type, em->id, em->msg);
669 return;
670 }
671 /* now this message is destined for the script message handler fn */
672 if (!(em->edje->collection)) return;
673 if ((em->edje->collection->script) && _edje_script_only (em->edje))
674 {
675 _edje_script_only_message(em->edje, em);
676 return;
677 }
678 if (em->edje->L)
679 {
680 _edje_lua_script_only_message(em->edje, em);
681 return;
682 }
683 fn = embryo_program_function_find(em->edje->collection->script, "message");
684 if (fn == EMBRYO_FUNCTION_NONE) return;
685 /* reset the engine */
686 _edje_embryo_script_reset(em->edje);
687
688 _edje_message_parameters_push(em);
689
690 embryo_program_vm_push(em->edje->collection->script);
691 _edje_embryo_globals_init(em->edje);
692 pdata = embryo_program_data_get(em->edje->collection->script);
693 embryo_program_data_set(em->edje->collection->script, em->edje);
694 embryo_program_max_cycle_run_set(em->edje->collection->script, 5000000);
695 ret = embryo_program_run(em->edje->collection->script, fn);
696 if (ret == EMBRYO_PROGRAM_FAIL)
697 {
698 ERR("ERROR with embryo script. "
699 "OBJECT NAME: '%s', "
700 "OBJECT FILE: '%s', "
701 "ENTRY POINT: '%s', "
702 "ERROR: '%s'",
703 em->edje->collection->part,
704 em->edje->file->path,
705 "message",
706 embryo_error_string_get(embryo_program_error_get(em->edje->collection->script)));
707 }
708 else if (ret == EMBRYO_PROGRAM_TOOLONG)
709 {
710 ERR("ERROR with embryo script. "
711 "OBJECT NAME: '%s', "
712 "OBJECT FILE: '%s', "
713 "ENTRY POINT: '%s', "
714 "ERROR: 'Script exceeded maximum allowed cycle count of %i'",
715 em->edje->collection->part,
716 em->edje->file->path,
717 "message",
718 embryo_program_max_cycle_run_get(em->edje->collection->script));
719 }
720
721 embryo_program_data_set(em->edje->collection->script, pdata);
722 embryo_program_vm_pop(em->edje->collection->script);
723}
724
725void
726_edje_message_queue_process(void)
727{
728 int i;
729
730 if (!msgq) return;
731
732 /* allow the message queue to feed itself up to 8 times before forcing */
733 /* us to go back to normal processing and let a 0 timeout deal with it */
734 for (i = 0; (i < 8) && (msgq); i++)
735 {
736 /* a temporary message queue */
737 if (tmp_msgq)
738 {
739 while (msgq)
740 {
741 tmp_msgq = eina_list_append(tmp_msgq, msgq->data);
742 msgq = eina_list_remove_list(msgq, msgq);
743 }
744 }
745 else
746 {
747 tmp_msgq = msgq;
748 msgq = NULL;
749 }
750
751 tmp_msgq_processing++;
752 while (tmp_msgq)
753 {
754 Edje_Message *em;
755 Edje *ed;
756
757 em = tmp_msgq->data;
758 ed = em->edje;
759 tmp_msgq = eina_list_remove_list(tmp_msgq, tmp_msgq);
760 em->edje->message.num--;
761 if (!ed->delete_me)
762 {
763 ed->processing_messages++;
764 _edje_message_process(em);
765 _edje_message_free(em);
766 ed->processing_messages--;
767 }
768 else
769 _edje_message_free(em);
770 if (ed->processing_messages == 0)
771 {
772 if (ed->delete_me) _edje_del(ed);
773 }
774 }
775 tmp_msgq_processing--;
776 if (tmp_msgq_processing == 0)
777 tmp_msgq_restart = 0;
778 else
779 tmp_msgq_restart = 1;
780 }
781
782 /* if the message queue filled again set a timer to expire in 0.0 sec */
783 /* to get the idle enterer to be run again */
784 if (msgq)
785 {
786 static int self_feed_debug = -1;
787
788 if (self_feed_debug == -1)
789 {
790 const char *s = getenv("EDJE_SELF_FEED_DEBUG");
791 if (s) self_feed_debug = atoi(s);
792 else self_feed_debug = 0;
793 }
794 if (self_feed_debug)
795 {
796 WRN("Edje is in a self-feeding message loop (> 8 loops needed)");
797 }
798 ecore_timer_add(0.0, _edje_dummy_timer, NULL);
799 }
800}
801
802void
803_edje_message_queue_clear(void)
804{
805 while (msgq)
806 {
807 Edje_Message *em;
808
809 em = msgq->data;
810 msgq = eina_list_remove_list(msgq, msgq);
811 em->edje->message.num--;
812 _edje_message_free(em);
813 }
814 while (tmp_msgq)
815 {
816 Edje_Message *em;
817
818 em = tmp_msgq->data;
819 tmp_msgq = eina_list_remove_list(tmp_msgq, tmp_msgq);
820 em->edje->message.num--;
821 _edje_message_free(em);
822 }
823}
824
825void
826_edje_message_del(Edje *ed)
827{
828 Eina_List *l;
829
830 if (ed->message.num <= 0) return;
831 /* delete any messages on the main queue for this edje object */
832 for (l = msgq; l; )
833 {
834 Edje_Message *em;
835 Eina_List *lp;
836
837 em = eina_list_data_get(l);
838 lp = l;
839 l = eina_list_next(l);
840 if (em->edje == ed)
841 {
842 msgq = eina_list_remove_list(msgq, lp);
843 em->edje->message.num--;
844 _edje_message_free(em);
845 }
846 if (ed->message.num <= 0) return;
847 }
848 /* delete any on the processing queue */
849 for (l = tmp_msgq; l; )
850 {
851 Edje_Message *em;
852 Eina_List *lp;
853
854 em = eina_list_data_get(l);
855 lp = l;
856 l = eina_list_next(l);
857 if (em->edje == ed)
858 {
859 tmp_msgq = eina_list_remove_list(tmp_msgq, lp);
860 em->edje->message.num--;
861 _edje_message_free(em);
862 }
863 if (ed->message.num <= 0) return;
864 }
865}
diff --git a/libraries/edje/src/lib/edje_misc.c b/libraries/edje/src/lib/edje_misc.c
new file mode 100644
index 0000000..32a4dd1
--- /dev/null
+++ b/libraries/edje/src/lib/edje_misc.c
@@ -0,0 +1 @@
#include "edje_private.h"
diff --git a/libraries/edje/src/lib/edje_module.c b/libraries/edje/src/lib/edje_module.c
new file mode 100644
index 0000000..effcee1
--- /dev/null
+++ b/libraries/edje/src/lib/edje_module.c
@@ -0,0 +1,154 @@
1#include "edje_private.h"
2
3Eina_Hash *_registered_modules = NULL;
4Eina_List *_modules_paths = NULL;
5
6Eina_List *_modules_found = NULL;
7
8#if defined(__CEGCC__) || defined(__MINGW32CE__)
9# define EDJE_MODULE_NAME "edje_%s.dll"
10# define EDJE_EXTRA_MODULE_NAME 1
11#elif _WIN32
12# define EDJE_MODULE_NAME "module.dll"
13#else
14# define EDJE_MODULE_NAME "module.so"
15#endif
16
17EAPI Eina_Bool
18edje_module_load(const char *module)
19{
20 if (_edje_module_handle_load(module)) return EINA_TRUE;
21 return EINA_FALSE;
22}
23
24Eina_Module *
25_edje_module_handle_load(const char *module)
26{
27 const char *path;
28 Eina_List *l;
29 Eina_Module *em = NULL;
30
31 EINA_SAFETY_ON_NULL_RETURN_VAL(module, NULL);
32
33 em = (Eina_Module *)eina_hash_find(_registered_modules, module);
34 if (em) return em;
35
36 EINA_LIST_FOREACH(_modules_paths, l, path)
37 {
38 char tmp[PATH_MAX];
39
40 snprintf(tmp, sizeof (tmp), "%s/%s/%s/" EDJE_MODULE_NAME, path, module, MODULE_ARCH
41#ifdef EDJE_EXTRA_MODULE_NAME
42 , module
43#endif
44 );
45 em = eina_module_new(tmp);
46 if (!em) continue;
47
48 if (!eina_module_load(em))
49 {
50 eina_module_free(em);
51 continue;
52 }
53 if (eina_hash_add(_registered_modules, module, em))
54 return em;
55 }
56
57 return NULL;
58}
59
60void
61_edje_module_init(void)
62{
63 char *paths[4] = { NULL, NULL, NULL, NULL };
64 unsigned int i;
65 unsigned int j;
66
67 _registered_modules = eina_hash_string_small_new(EINA_FREE_CB(eina_module_free));
68
69 /* 1. ~/.edje/modules/ */
70 paths[0] = eina_module_environment_path_get("HOME", "/.edje/modules");
71 /* 2. $(EDJE_MODULE_DIR)/edje/modules/ */
72 paths[1] = eina_module_environment_path_get("EDJE_MODULES_DIR", "/edje/modules");
73 /* 3. libedje.so/../edje/modules/ */
74 paths[2] = eina_module_symbol_path_get(_edje_module_init, "/edje/modules");
75 /* 4. PREFIX/edje/modules/ */
76#ifndef _MSC_VER
77 paths[3] = strdup(PACKAGE_LIB_DIR "/edje/modules");
78#endif
79
80 for (j = 0; j < ((sizeof (paths) / sizeof (char*)) - 1); ++j)
81 for (i = j + 1; i < sizeof (paths) / sizeof (char*); ++i)
82 if (paths[i] && paths[j] && !strcmp(paths[i], paths[j]))
83 {
84 free(paths[i]);
85 paths[i] = NULL;
86 }
87
88 for (i = 0; i < sizeof (paths) / sizeof (char*); ++i)
89 if (paths[i])
90 _modules_paths = eina_list_append(_modules_paths, paths[i]);
91}
92
93void
94_edje_module_shutdown(void)
95{
96 char *path;
97
98 if (_registered_modules)
99 {
100 eina_hash_free(_registered_modules);
101 _registered_modules = NULL;
102 }
103
104 EINA_LIST_FREE(_modules_paths, path)
105 free(path);
106
107 EINA_LIST_FREE(_modules_found, path)
108 eina_stringshare_del(path);
109}
110
111EAPI const Eina_List *
112edje_available_modules_get(void)
113{
114 Eina_File_Direct_Info *info;
115 Eina_Iterator *it;
116 Eina_List *l;
117 const char *path;
118 Eina_List *result = NULL;
119
120 /* FIXME: Stat each possible dir and check if they did change, before starting a huge round of readdir/stat */
121 if (_modules_found)
122 {
123 EINA_LIST_FREE(_modules_found, path)
124 eina_stringshare_del(path);
125 }
126
127 EINA_LIST_FOREACH(_modules_paths, l, path)
128 {
129 it = eina_file_direct_ls(path);
130
131 if (it)
132 {
133 EINA_ITERATOR_FOREACH(it, info)
134 {
135 char tmp[PATH_MAX];
136
137 snprintf(tmp, sizeof (tmp), "%s/%s/" EDJE_MODULE_NAME, info->path, MODULE_ARCH
138#ifdef EDJE_EXTRA_MODULE_NAME
139 , ecore_file_file_get(info->path)
140#endif
141 );
142
143 if (ecore_file_exists(tmp))
144 result = eina_list_append(result, eina_stringshare_add(ecore_file_file_get(info->path)));
145 }
146
147 eina_iterator_free(it);
148 }
149 }
150
151 _modules_found = result;
152
153 return result;
154}
diff --git a/libraries/edje/src/lib/edje_multisense.c b/libraries/edje/src/lib/edje_multisense.c
new file mode 100644
index 0000000..f9c7f91
--- /dev/null
+++ b/libraries/edje/src/lib/edje_multisense.c
@@ -0,0 +1,408 @@
1#include "config.h"
2#include <string.h>
3#include <fcntl.h>
4#include <Eina.h>
5#include <Edje.h>
6#include "edje_private.h"
7
8typedef struct _Multisense_Data
9{
10 Edje_Multisense_Env *msenv;
11#ifdef HAVE_LIBREMIX
12 RemixDeck *deck;
13 RemixTrack *track;
14 RemixLayer *snd_layer, *player_layer;
15 RemixBase *player;
16 RemixBase *player_snd;
17 int remaining;
18 int offset;
19 Eina_List *snd_src_list;
20
21 MULTISENSE_SOUND_PLAYER_GET_FUNC multisense_sound_player_get;
22#endif
23}Multisense_Data;
24
25#define BUF_LEN 64
26#define SND_PROCESS_LENGTH 2048
27
28#ifdef HAVE_LIBREMIX
29static Ecore_Thread *player_thread = NULL;
30static int command_pipe[2];
31static Eina_Bool pipe_initialized = EINA_FALSE;
32#endif
33
34typedef enum _Edje_Sound_Action_Type
35{
36 EDJE_PLAY_SAMPLE = 0,
37 EDJE_PLAY_TONE,
38 /*
39 EDJE_PLAY_PATTERN,
40 EDJE_PLAY_INSTRUMENT,
41 EDJE_PLAY_SONG,
42 */
43 EDJE_SOUND_LAST
44} Edje_Sound_Action_Type;
45
46typedef struct _Edje_Sample_Action Edje_Sample_Action;
47typedef struct _Edje_Tone_Action Edje_Tone_Action;
48typedef struct _Edje_Multisense_Sound_Action Edje_Multisense_Sound_Action;
49
50struct _Edje_Sample_Action
51{
52 char sample_name[BUF_LEN];
53 double speed;
54};
55
56struct _Edje_Tone_Action
57{
58 char tone_name[BUF_LEN];
59 double duration;
60};
61
62struct _Edje_Multisense_Sound_Action
63{
64 Edje *ed;
65 Edje_Sound_Action_Type action;
66 union {
67 Edje_Sample_Action sample;
68 Edje_Tone_Action tone;
69 } type;
70};
71
72#ifdef HAVE_LIBREMIX
73static Multisense_Data *
74init_multisense_environment(void)
75{
76 Multisense_Data *msdata;
77 char ms_factory[BUF_LEN];
78 char *ms_factory_env;
79 Eina_Module *m = NULL;
80 MULTISENSE_FACTORY_INIT_FUNC multisense_factory_init;
81
82 msdata = calloc(1, sizeof(Multisense_Data));
83 if (!msdata) goto err;
84
85 msdata->msenv = calloc(1, sizeof(Edje_Multisense_Env));
86 if (!msdata->msenv) goto err;
87
88 ms_factory_env = getenv("MULTISENSE_FACTORY");
89 if (ms_factory_env)
90 strncpy(ms_factory, ms_factory_env, BUF_LEN);
91 else
92 strcpy(ms_factory, "multisense_factory");
93
94 m = _edje_module_handle_load(ms_factory);
95 if (!m) goto err;
96
97 msdata->msenv->remixenv = remix_init();
98
99 multisense_factory_init =
100 eina_module_symbol_get(m, "multisense_factory_init");
101 if (multisense_factory_init) multisense_factory_init(msdata->msenv);
102
103 msdata->multisense_sound_player_get =
104 eina_module_symbol_get(m, "multisense_sound_player_get");
105 if (!msdata->multisense_sound_player_get) goto err;
106
107 msdata->deck = remix_deck_new(msdata->msenv->remixenv);
108 msdata->track = remix_track_new(msdata->msenv->remixenv, msdata->deck);
109 msdata->snd_layer = remix_layer_new_ontop(msdata->msenv->remixenv,
110 msdata->track,
111 REMIX_TIME_SAMPLES);
112 msdata->player_layer = remix_layer_new_ontop(msdata->msenv->remixenv,
113 msdata->track,
114 REMIX_TIME_SAMPLES);
115 msdata->player = msdata->multisense_sound_player_get(msdata->msenv);
116 if (!msdata->player) goto err;
117 msdata->player_snd = remix_sound_new(msdata->msenv->remixenv,
118 msdata->player, msdata->player_layer,
119 REMIX_SAMPLES(0),
120 REMIX_SAMPLES(REMIX_COUNT_INFINITE));
121 return msdata;
122
123err:
124 if (msdata)
125 {
126 if (msdata->deck) remix_destroy(msdata->msenv->remixenv, msdata->deck);
127 if (msdata->msenv->remixenv) remix_purge(msdata->msenv->remixenv);
128 if (msdata->msenv) free(msdata->msenv);
129 free(msdata);
130 }
131 return NULL;
132}
133#endif
134
135#ifdef HAVE_LIBREMIX
136static RemixBase *
137eet_sound_reader_get(Edje_Multisense_Env *msenv, const char *path, const char *sound_id, const double speed)
138{
139 RemixPlugin *sf_plugin = NULL;
140 RemixBase * eet_snd_reader = NULL;
141 int sf_path_key = 0;
142 int sf_sound_id_key = 0;
143 int sf_speed_key = 0;
144 CDSet *sf_parms = NULL;
145 RemixEnv *env = msenv->remixenv;
146
147 if (sf_plugin == NULL)
148 {
149 sf_plugin = remix_find_plugin(env, "eet_sndfile_reader");
150 if (sf_plugin == NULL)
151 {
152 ERR ("Multisense EET Sound reader plugin NULL\n");
153 return NULL;
154 }
155
156 sf_path_key = remix_get_init_parameter_key(env, sf_plugin, "path");
157 sf_sound_id_key = remix_get_init_parameter_key(env, sf_plugin, "sound_id");
158 sf_speed_key = remix_get_init_parameter_key(env, sf_plugin, "speed");
159 }
160 sf_parms = cd_set_replace(env, sf_parms, sf_path_key, CD_STRING(path));
161 sf_parms = cd_set_replace(env, sf_parms, sf_sound_id_key, CD_STRING(sound_id));
162 sf_parms = cd_set_replace(env, sf_parms, sf_speed_key, CD_DOUBLE(speed));
163 eet_snd_reader = remix_new(env, sf_plugin, sf_parms);
164
165 return eet_snd_reader;
166}
167
168
169static RemixBase *
170edje_remix_sample_create(Multisense_Data *msdata, Edje*ed, Edje_Sample_Action *action)
171{
172 RemixBase *remix_snd = NULL;
173 Edje_Sound_Sample *sample;
174 int i;
175 char snd_id_str[16];
176
177 if ((!ed) || (!ed->file) || (!ed->file->sound_dir))
178 return NULL;
179
180 for (i = 0; i < (int)ed->file->sound_dir->samples_count; i++)
181 {
182 sample = &ed->file->sound_dir->samples[i];
183 if (!strcmp(sample->name, action->sample_name))
184 {
185 snprintf(snd_id_str, sizeof(snd_id_str), "edje/sounds/%i", sample->id);
186 remix_snd = eet_sound_reader_get(msdata->msenv, ed->file->path,
187 snd_id_str, action->speed);
188 break;
189 }
190 }
191 return remix_snd;
192}
193
194static RemixBase *
195edje_remix_tone_create(Multisense_Data *msdata, Edje*ed, Edje_Tone_Action *action)
196{
197 Edje_Sound_Tone *tone;
198 RemixSquareTone *square = NULL;
199 unsigned int i;
200
201 if ((!ed) || (!ed->file) || (!ed->file->sound_dir))
202 return NULL;
203
204 for (i = 0; i < ed->file->sound_dir->tones_count; i++)
205 {
206 tone = &ed->file->sound_dir->tones[i];
207 if (!strcmp(tone->name, action->tone_name))
208 {
209 square = remix_squaretone_new (msdata->msenv->remixenv, tone->value);
210 break;
211 }
212 }
213 return square;
214}
215
216static void
217sound_command_handler(Multisense_Data *msdata)
218{
219 RemixCount length;
220 Edje_Multisense_Sound_Action command;
221 RemixBase *base = NULL;
222 RemixBase *sound;
223
224 if (read(command_pipe[0], &command, sizeof(command)) <= 0) return;
225 switch (command.action)
226 {
227 case EDJE_PLAY_SAMPLE:
228 base = edje_remix_sample_create(msdata, command.ed,
229 &command.type.sample);
230 length = remix_length(msdata->msenv->remixenv, base);
231 break;
232 case EDJE_PLAY_TONE:
233 base = edje_remix_tone_create(msdata, command.ed, &command.type.tone);
234 length = (command.type.tone.duration *
235 remix_get_samplerate(msdata->msenv->remixenv));
236 break;
237 default:
238 ERR("Invalid Sound Play Command\n");
239 break;
240 }
241 if (base)
242 {
243 sound = remix_sound_new(msdata->msenv->remixenv, base, msdata->snd_layer,
244 REMIX_SAMPLES(msdata->offset),
245 REMIX_SAMPLES(length));
246 if (msdata->remaining < length) msdata->remaining = length;
247 msdata->snd_src_list = eina_list_append(msdata->snd_src_list, sound);
248 msdata->snd_src_list = eina_list_append(msdata->snd_src_list, base);
249 }
250}
251#endif
252
253#ifdef HAVE_LIBREMIX
254// msdata outside of thread due to thread issues in dlsym etc.
255static Multisense_Data *msdata = NULL;
256
257static void
258_msdata_free(void)
259{
260 // cleanup msdata outside of thread due to thread issues in dlsym etc.
261 if (!msdata) return;
262 //cleanup Remix stuffs
263 remix_destroy(msdata->msenv->remixenv, msdata->player);
264 remix_destroy(msdata->msenv->remixenv, msdata->deck);
265 remix_purge(msdata->msenv->remixenv);
266
267 free(msdata->msenv);
268 free(msdata);
269 msdata = NULL;
270}
271
272static void
273_player_job(void *data __UNUSED__, Ecore_Thread *th)
274{
275 fd_set wait_fds;
276 RemixBase *sound;
277 RemixCount process_len;
278// disable and move outside of thread due to dlsym etc. thread issues
279// Multisense_Data * msdata = init_multisense_environment();
280
281 if (!msdata) return;
282
283 fcntl(command_pipe[0], F_SETFL, O_NONBLOCK);
284 FD_ZERO(&wait_fds);
285 FD_SET(command_pipe[0], &wait_fds);
286
287 while (!ecore_thread_check(th))
288 {
289 if (!msdata->remaining)
290 {
291 //Cleanup already played sound sources
292 EINA_LIST_FREE(msdata->snd_src_list, sound)
293 {
294 remix_destroy(msdata->msenv->remixenv, sound);
295 }
296 //wait for new sound
297 select(command_pipe[0] + 1, &wait_fds, NULL, NULL, 0);
298 }
299 //read sound command , if any
300 sound_command_handler(msdata);
301 process_len = MIN(msdata->remaining, SND_PROCESS_LENGTH);
302 remix_process(msdata->msenv->remixenv, msdata->deck, process_len,
303 RemixNone, RemixNone);
304 msdata->offset += process_len;
305 msdata->remaining -= process_len;
306 }
307
308 //Cleanup last played sound sources
309 EINA_LIST_FREE(msdata->snd_src_list, sound)
310 {
311 remix_destroy(msdata->msenv->remixenv, sound);
312 }
313
314 close(command_pipe[0]);
315 close(command_pipe[1]);
316}
317#endif
318
319#ifdef HAVE_LIBREMIX
320static void
321_player_cancel(void *data __UNUSED__, Ecore_Thread *th __UNUSED__)
322{
323 // cleanup msdata outside of thread due to thread issues in dlsym etc.
324 _msdata_free();
325 player_thread = NULL;
326}
327#endif
328
329#ifdef HAVE_LIBREMIX
330static void
331_player_end(void *data __UNUSED__, Ecore_Thread *th __UNUSED__)
332{
333 // cleanup msdata outside of thread due to thread issues in dlsym etc.
334 _msdata_free();
335 player_thread = NULL;
336}
337#endif
338
339Eina_Bool
340_edje_multisense_internal_sound_sample_play(Edje *ed, const char *sample_name, const double speed)
341{
342 ssize_t size = 0;
343#ifdef ENABLE_MULTISENSE
344 Edje_Multisense_Sound_Action command;
345
346 if ((!pipe_initialized) && (!player_thread)) return EINA_FALSE;
347
348 command.action = EDJE_PLAY_SAMPLE;
349 command.ed = ed;
350 strncpy(command.type.sample.sample_name, sample_name, BUF_LEN);
351 command.type.sample.speed = speed;
352 size = write(command_pipe[1], &command, sizeof(command));
353#else
354 ed = NULL; // warning shh
355 if (speed > 0) sample_name = NULL; // warning shh
356#endif
357 return (size == sizeof(Edje_Multisense_Sound_Action));
358}
359
360Eina_Bool
361_edje_multisense_internal_sound_tone_play(Edje *ed, const char *tone_name, const double duration)
362{
363 ssize_t size = 0;
364#ifdef ENABLE_MULTISENSE
365 Edje_Multisense_Sound_Action command;
366
367 if ((!pipe_initialized) && (!player_thread)) return EINA_FALSE;
368 command.action = EDJE_PLAY_TONE;
369 command.ed = ed;
370 strncpy(command.type.tone.tone_name, tone_name, BUF_LEN);
371 command.type.tone.duration = duration;
372 size = write(command_pipe[1], &command, sizeof(command));
373#else
374 ed = NULL; // warning shh
375 if (duration > 0) tone_name = NULL; // warning shh
376#endif
377 return (size == sizeof(Edje_Multisense_Sound_Action));
378
379}
380
381/* Initialize the modules in main thread. to avoid dlopen issue in the Threads */
382void
383_edje_multisense_init(void)
384{
385#ifdef ENABLE_MULTISENSE
386 if (!pipe_initialized && (pipe(command_pipe) != -1))
387 pipe_initialized = EINA_TRUE;
388
389 // init msdata outside of thread due to thread issues in dlsym etc.
390 if (!msdata) msdata = init_multisense_environment();
391
392 if (!player_thread)
393 player_thread = ecore_thread_run(_player_job, _player_end, _player_cancel, NULL);
394#endif
395}
396
397void
398_edje_multisense_shutdown(void)
399{
400#ifdef ENABLE_MULTISENSE
401 if (pipe_initialized)
402 {
403 close(command_pipe[1]);
404 close(command_pipe[0]);
405 }
406 if (player_thread) ecore_thread_cancel(player_thread);
407#endif
408}
diff --git a/libraries/edje/src/lib/edje_private.h b/libraries/edje/src/lib/edje_private.h
new file mode 100644
index 0000000..cbb3e03
--- /dev/null
+++ b/libraries/edje/src/lib/edje_private.h
@@ -0,0 +1,2028 @@
1#ifndef _EDJE_PRIVATE_H
2#define _EDJE_PRIVATE_H
3
4#ifdef HAVE_CONFIG_H
5# include <config.h>
6#endif
7
8#ifndef _WIN32
9# define _GNU_SOURCE
10#endif
11
12#ifdef HAVE_ALLOCA_H
13# include <alloca.h>
14#elif defined __GNUC__
15# define alloca __builtin_alloca
16#elif defined _AIX
17# define alloca __alloca
18#elif defined _MSC_VER
19# include <malloc.h>
20# define alloca _alloca
21#else
22# include <stddef.h>
23void *alloca (size_t);
24#endif
25
26#include <string.h>
27#include <limits.h>
28#include <sys/stat.h>
29#include <time.h>
30#include <sys/time.h>
31#include <errno.h>
32
33#ifndef _MSC_VER
34# include <libgen.h>
35# include <unistd.h>
36#endif
37
38#include <lua.h>
39#include <lualib.h>
40#include <lauxlib.h>
41#include <setjmp.h>
42
43#ifdef HAVE_LOCALE_H
44# include <locale.h>
45#endif
46
47#ifdef HAVE_EVIL
48# include <Evil.h>
49#endif
50
51#include <Eina.h>
52#include <Eet.h>
53#include <Evas.h>
54#include <Ecore.h>
55#include <Ecore_Evas.h>
56#include <Ecore_File.h>
57#ifdef HAVE_ECORE_IMF
58# include <Ecore_IMF.h>
59# include <Ecore_IMF_Evas.h>
60#endif
61#include <Embryo.h>
62
63#include "Edje.h"
64
65EAPI extern int _edje_default_log_dom ;
66
67#ifdef EDJE_DEFAULT_LOG_COLOR
68# undef EDJE_DEFAULT_LOG_COLOR
69#endif
70#define EDJE_DEFAULT_LOG_COLOR EINA_COLOR_CYAN
71#ifdef ERR
72# undef ERR
73#endif
74#define ERR(...) EINA_LOG_DOM_ERR(_edje_default_log_dom, __VA_ARGS__)
75#ifdef INF
76# undef INF
77#endif
78#define INF(...) EINA_LOG_DOM_INFO(_edje_default_log_dom, __VA_ARGS__)
79#ifdef WRN
80# undef WRN
81#endif
82#define WRN(...) EINA_LOG_DOM_WARN(_edje_default_log_dom, __VA_ARGS__)
83#ifdef CRIT
84# undef CRIT
85#endif
86#define CRIT(...) EINA_LOG_DOM_CRIT(_edje_default_log_dom, __VA_ARGS__)
87#ifdef __GNUC__
88# if __GNUC__ >= 4
89// BROKEN in gcc 4 on amd64
90//# pragma GCC visibility push(hidden)
91# endif
92#endif
93
94#ifndef ABS
95#define ABS(x) ((x) < 0 ? -(x) : (x))
96#endif
97
98#ifndef CLAMP
99#define CLAMP(x, min, max) (((x) > (max)) ? (max) : (((x) < (min)) ? (min) : (x)))
100#endif
101
102#ifndef MIN
103#define MIN(a, b) (((a) < (b)) ? (a) : (b))
104#endif
105
106
107#ifdef BUILD_EDJE_FP
108
109#define FLOAT_T Eina_F32p32
110#define EDJE_T_FLOAT EET_T_F32P32
111#define MUL(a, b) eina_f32p32_mul(a, b)
112#define SCALE(a, b) eina_f32p32_scale(a, b)
113#define DIV(a, b) eina_f32p32_div(a, b)
114#define DIV2(a) ((a) >> 1)
115#define ADD(a, b) eina_f32p32_add(a, b)
116#define SUB(a, b) eina_f32p32_sub(a, b)
117#define SQRT(a) eina_f32p32_sqrt(a)
118#define TO_DOUBLE(a) eina_f32p32_double_to(a)
119#define FROM_DOUBLE(a) eina_f32p32_double_from(a)
120#define FROM_INT(a) eina_f32p32_int_from(a)
121#define TO_INT(a) eina_f32p32_int_to(a)
122#define ZERO 0
123#define COS(a) eina_f32p32_cos(a)
124#define SIN(a) eina_f32p32_sin(a)
125#define PI EINA_F32P32_PI
126
127#else
128
129#define FLOAT_T double
130#define EDJE_T_FLOAT EET_T_DOUBLE
131#define MUL(a, b) ((a) * (b))
132#define SCALE(a, b) ((a) * (double)(b))
133#define DIV(a, b) ((a) / (b))
134#define DIV2(a) ((a) / 2.0)
135#define ADD(a, b) ((a) + (b))
136#define SUB(a, b) ((a) - (b))
137#define SQRT(a) sqrt(a)
138#define TO_DOUBLE(a) (double)(a)
139#define FROM_DOUBLE(a) (a)
140#define FROM_INT(a) (double)(a)
141#define TO_INT(a) (int)(a)
142#define ZERO 0.0
143#define COS(a) cos(a)
144#define SIN(a) sin(a)
145#define PI 3.14159265358979323846
146
147#endif
148
149/* Inheritable Edje Smart API. For now private so only Edje Edit makes
150 * use of this, but who knows what will be possible in the future */
151#define EDJE_SMART_API_VERSION 1
152
153typedef struct _Edje_Smart_Api Edje_Smart_Api;
154
155struct _Edje_Smart_Api
156{
157 Evas_Smart_Class base;
158 int version;
159 Eina_Bool (*file_set)(Evas_Object *obj, const char *file, const char *group);
160};
161
162/* Basic macro to init the Edje Smart API */
163#define EDJE_SMART_API_INIT(smart_class_init) {smart_class_init, EDJE_SMART_API_VERSION, NULL}
164
165#define EDJE_SMART_API_INIT_NULL EDJE_SMART_API_INIT(EVAS_SMART_CLASS_INIT_NULL)
166#define EDJE_SMART_API_INIT_VERSION EDJE_SMART_API_INIT(EVAS_SMART_CLASS_INIT_VERSION)
167#define EDJE_SMART_API_INIT_NAME_VERSION(name) EDJE_SMART_API_INIT(EVAS_SMART_CLASS_INIT_NAME_VERSION(name))
168
169/* increment this when the EET data descriptors have changed and old
170 * EETs cannot be loaded/used correctly anymore.
171 */
172#define EDJE_FILE_VERSION 3
173/* increment this when you add new feature to edje file format without
174 * breaking backward compatibility.
175 */
176#define EDJE_FILE_MINOR 2
177
178/* FIXME:
179 *
180 * More example Edje files
181 *
182 * ? programs can do multiple actions from one signal
183 * ? add containering (hbox, vbox, table, wrapping multi-line hbox & vbox)
184 * ? text entry widget (single line only)
185 *
186 * ? recursions, unsafe callbacks outside Edje etc. with freeze, ref/unref and block/unblock and break_programs needs to be redesigned & fixed
187 * ? all unsafe calls that may result in callbacks must be marked and dealt with
188 */
189
190typedef enum
191{
192 EDJE_ASPECT_PREFER_NONE,
193 EDJE_ASPECT_PREFER_VERTICAL,
194 EDJE_ASPECT_PREFER_HORIZONTAL,
195 EDJE_ASPECT_PREFER_BOTH
196} Edje_Internal_Aspect;
197
198struct _Edje_Perspective
199{
200 Evas_Object *obj;
201 Evas *e;
202 Evas_Coord px, py, z0, foc;
203 Eina_List *users;
204 Eina_Bool global : 1;
205};
206
207struct _Edje_Position_Scale
208{
209 FLOAT_T x, y;
210};
211
212struct _Edje_Position
213{
214 int x, y;
215};
216
217struct _Edje_Size
218{
219 int w, h;
220};
221
222struct _Edje_Rectangle
223{
224 int x, y, w, h;
225};
226
227struct _Edje_Color
228{
229 unsigned char r, g, b, a;
230};
231
232struct _Edje_Aspect_Prefer
233{
234 FLOAT_T min, max;
235 Edje_Internal_Aspect prefer;
236};
237
238struct _Edje_Aspect
239{
240 int w, h;
241 Edje_Aspect_Control mode;
242};
243
244struct _Edje_String
245{
246 const char *str;
247 unsigned int id;
248};
249
250typedef struct _Edje_Position_Scale Edje_Alignment;
251typedef struct _Edje_Position_Scale Edje_Position_Scale;
252typedef struct _Edje_Position Edje_Position;
253typedef struct _Edje_Size Edje_Size;
254typedef struct _Edje_Rectangle Edje_Rectangle;
255typedef struct _Edje_Color Edje_Color;
256typedef struct _Edje_Aspect_Prefer Edje_Aspect_Prefer;
257typedef struct _Edje_Aspect Edje_Aspect;
258typedef struct _Edje_String Edje_String;
259
260typedef struct _Edje_File Edje_File;
261typedef struct _Edje_Style Edje_Style;
262typedef struct _Edje_Style_Tag Edje_Style_Tag;
263typedef struct _Edje_External_Directory Edje_External_Directory;
264typedef struct _Edje_External_Directory_Entry Edje_External_Directory_Entry;
265typedef struct _Edje_Font_Directory_Entry Edje_Font_Directory_Entry;
266typedef struct _Edje_Image_Directory Edje_Image_Directory;
267typedef struct _Edje_Image_Directory_Entry Edje_Image_Directory_Entry;
268typedef struct _Edje_Image_Directory_Set Edje_Image_Directory_Set;
269typedef struct _Edje_Image_Directory_Set_Entry Edje_Image_Directory_Set_Entry;
270typedef struct _Edje_Limit Edje_Limit;
271typedef struct _Edje_Sound_Sample Edje_Sound_Sample;
272typedef struct _Edje_Sound_Tone Edje_Sound_Tone;
273typedef struct _Edje_Sound_Directory Edje_Sound_Directory;
274typedef struct _Edje_Program Edje_Program;
275typedef struct _Edje_Program_Target Edje_Program_Target;
276typedef struct _Edje_Program_After Edje_Program_After;
277typedef struct _Edje_Part_Collection_Directory_Entry Edje_Part_Collection_Directory_Entry;
278typedef struct _Edje_Pack_Element Edje_Pack_Element;
279typedef struct _Edje_Part_Collection Edje_Part_Collection;
280typedef struct _Edje_Part Edje_Part;
281typedef struct _Edje_Part_Api Edje_Part_Api;
282typedef struct _Edje_Part_Dragable Edje_Part_Dragable;
283typedef struct _Edje_Part_Image_Id Edje_Part_Image_Id;
284typedef struct _Edje_Part_Description_Image Edje_Part_Description_Image;
285typedef struct _Edje_Part_Description_Proxy Edje_Part_Description_Proxy;
286typedef struct _Edje_Part_Description_Text Edje_Part_Description_Text;
287typedef struct _Edje_Part_Description_Box Edje_Part_Description_Box;
288typedef struct _Edje_Part_Description_Table Edje_Part_Description_Table;
289typedef struct _Edje_Part_Description_External Edje_Part_Description_External;
290typedef struct _Edje_Part_Description_Common Edje_Part_Description_Common;
291typedef struct _Edje_Part_Description_Spec_Fill Edje_Part_Description_Spec_Fill;
292typedef struct _Edje_Part_Description_Spec_Border Edje_Part_Description_Spec_Border;
293typedef struct _Edje_Part_Description_Spec_Image Edje_Part_Description_Spec_Image;
294typedef struct _Edje_Part_Description_Spec_Proxy Edje_Part_Description_Spec_Proxy;
295typedef struct _Edje_Part_Description_Spec_Text Edje_Part_Description_Spec_Text;
296typedef struct _Edje_Part_Description_Spec_Box Edje_Part_Description_Spec_Box;
297typedef struct _Edje_Part_Description_Spec_Table Edje_Part_Description_Spec_Table;
298typedef struct _Edje_Patterns Edje_Patterns;
299typedef struct _Edje_Part_Box_Animation Edje_Part_Box_Animation;
300
301typedef struct _Edje Edje;
302typedef struct _Edje_Real_Part_State Edje_Real_Part_State;
303typedef struct _Edje_Real_Part_Drag Edje_Real_Part_Drag;
304typedef struct _Edje_Real_Part_Set Edje_Real_Part_Set;
305typedef struct _Edje_Real_Part Edje_Real_Part;
306typedef struct _Edje_Running_Program Edje_Running_Program;
307typedef struct _Edje_Signal_Callback Edje_Signal_Callback;
308typedef struct _Edje_Calc_Params Edje_Calc_Params;
309typedef struct _Edje_Pending_Program Edje_Pending_Program;
310typedef struct _Edje_Text_Style Edje_Text_Style;
311typedef struct _Edje_Color_Class Edje_Color_Class;
312typedef struct _Edje_Text_Class Edje_Text_Class;
313typedef struct _Edje_Var Edje_Var;
314typedef struct _Edje_Var_Int Edje_Var_Int;
315typedef struct _Edje_Var_Float Edje_Var_Float;
316typedef struct _Edje_Var_String Edje_Var_String;
317typedef struct _Edje_Var_List Edje_Var_List;
318typedef struct _Edje_Var_Hash Edje_Var_Hash;
319typedef struct _Edje_Var_Animator Edje_Var_Animator;
320typedef struct _Edje_Var_Timer Edje_Var_Timer;
321typedef struct _Edje_Var_Pool Edje_Var_Pool;
322typedef struct _Edje_Signal_Source_Char Edje_Signal_Source_Char;
323typedef struct _Edje_Text_Insert_Filter_Callback Edje_Text_Insert_Filter_Callback;
324
325#define EDJE_INF_MAX_W 100000
326#define EDJE_INF_MAX_H 100000
327
328#define EDJE_IMAGE_SOURCE_TYPE_NONE 0
329#define EDJE_IMAGE_SOURCE_TYPE_INLINE_PERFECT 1
330#define EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY 2
331#define EDJE_IMAGE_SOURCE_TYPE_EXTERNAL 3
332#define EDJE_IMAGE_SOURCE_TYPE_LAST 4
333
334#define EDJE_SOUND_SOURCE_TYPE_NONE 0
335#define EDJE_SOUND_SOURCE_TYPE_INLINE_RAW 1
336#define EDJE_SOUND_SOURCE_TYPE_INLINE_COMP 2
337#define EDJE_SOUND_SOURCE_TYPE_INLINE_LOSSY 3
338#define EDJE_SOUND_SOURCE_TYPE_INLINE_AS_IS 4
339
340#define EDJE_VAR_NONE 0
341#define EDJE_VAR_INT 1
342#define EDJE_VAR_FLOAT 2
343#define EDJE_VAR_STRING 3
344#define EDJE_VAR_LIST 4
345#define EDJE_VAR_HASH 5
346
347#define EDJE_VAR_MAGIC_BASE 0x12fe84ba
348
349#define EDJE_STATE_PARAM_NONE 0
350#define EDJE_STATE_PARAM_ALIGNMENT 1
351#define EDJE_STATE_PARAM_MIN 2
352#define EDJE_STATE_PARAM_MAX 3
353#define EDJE_STATE_PARAM_STEP 4
354#define EDJE_STATE_PARAM_ASPECT 5
355#define EDJE_STATE_PARAM_ASPECT_PREF 6
356#define EDJE_STATE_PARAM_COLOR 7
357#define EDJE_STATE_PARAM_COLOR2 8
358#define EDJE_STATE_PARAM_COLOR3 9
359#define EDJE_STATE_PARAM_COLOR_CLASS 10
360#define EDJE_STATE_PARAM_REL1 11
361#define EDJE_STATE_PARAM_REL1_TO 12
362#define EDJE_STATE_PARAM_REL1_OFFSET 13
363#define EDJE_STATE_PARAM_REL2 14
364#define EDJE_STATE_PARAM_REL2_TO 15
365#define EDJE_STATE_PARAM_REL2_OFFSET 16
366#define EDJE_STATE_PARAM_IMAGE 17
367#define EDJE_STATE_PARAM_BORDER 18
368#define EDJE_STATE_PARAM_FILL_SMOOTH 19
369#define EDJE_STATE_PARAM_FILL_POS 20
370#define EDJE_STATE_PARAM_FILL_SIZE 21
371#define EDJE_STATE_PARAM_TEXT 22
372#define EDJE_STATE_PARAM_TEXT_CLASS 23
373#define EDJE_STATE_PARAM_TEXT_FONT 24
374#define EDJE_STATE_PARAM_TEXT_STYLE 25
375#define EDJE_STATE_PARAM_TEXT_SIZE 26
376#define EDJE_STATE_PARAM_TEXT_FIT 27
377#define EDJE_STATE_PARAM_TEXT_MIN 28
378#define EDJE_STATE_PARAM_TEXT_MAX 29
379#define EDJE_STATE_PARAM_TEXT_ALIGN 30
380#define EDJE_STATE_PARAM_VISIBLE 31
381#define EDJE_STATE_PARAM_MAP_OM 32
382#define EDJE_STATE_PARAM_MAP_PERSP 33
383#define EDJE_STATE_PARAM_MAP_LIGNT 34
384#define EDJE_STATE_PARAM_MAP_ROT_CENTER 35
385#define EDJE_STATE_PARAM_MAP_ROT_X 36
386#define EDJE_STATE_PARAM_MAP_ROT_Y 37
387#define EDJE_STATE_PARAM_MAP_ROT_Z 38
388#define EDJE_STATE_PARAM_MAP_BACK_CULL 39
389#define EDJE_STATE_PARAM_MAP_PERSP_ON 40
390#define EDJE_STATE_PARAM_PERSP_ZPLANE 41
391#define EDJE_STATE_PARAM_PERSP_FOCAL 42
392#define EDJE_STATE_PARAM_LAST 43
393
394#define EDJE_ENTRY_EDIT_MODE_NONE 0
395#define EDJE_ENTRY_EDIT_MODE_SELECTABLE 1
396#define EDJE_ENTRY_EDIT_MODE_EDITABLE 2
397#define EDJE_ENTRY_EDIT_MODE_PASSWORD 3
398
399#define EDJE_ENTRY_SELECTION_MODE_DEFAULT 0
400#define EDJE_ENTRY_SELECTION_MODE_EXPLICIT 1
401
402#define EDJE_ENTRY_CURSOR_MODE_UNDER 0
403#define EDJE_ENTRY_CURSOR_MODE_BEFORE 1
404
405#define EDJE_ORIENTATION_AUTO 0
406#define EDJE_ORIENTATION_LTR 1
407#define EDJE_ORIENTATION_RTL 2
408
409#define EDJE_PART_PATH_SEPARATOR ':'
410#define EDJE_PART_PATH_SEPARATOR_STRING ":"
411#define EDJE_PART_PATH_SEPARATOR_INDEXL '['
412#define EDJE_PART_PATH_SEPARATOR_INDEXR ']'
413
414#define FLAG_NONE 0
415#define FLAG_X 0x01
416#define FLAG_Y 0x02
417#define FLAG_XY (FLAG_X | FLAG_Y)
418
419/*----------*/
420
421struct _Edje_File
422{
423 const char *path;
424 time_t mtime;
425
426 Edje_External_Directory *external_dir;
427 Edje_Image_Directory *image_dir;
428 Edje_Sound_Directory *sound_dir;
429 Eina_List *styles;
430 Eina_List *color_classes;
431
432 int references;
433 const char *compiler;
434 int version;
435 int minor;
436 int feature_ver;
437
438 Eina_Hash *data;
439 Eina_Hash *fonts;
440
441 Eina_Hash *collection;
442 Eina_List *collection_cache;
443
444 Edje_Patterns *collection_patterns;
445
446 Eet_File *ef;
447
448 unsigned char free_strings : 1;
449 unsigned char dangling : 1;
450 unsigned char warning : 1;
451};
452
453struct _Edje_Style
454{
455 char *name;
456 Eina_List *tags;
457 Evas_Textblock_Style *style;
458};
459
460struct _Edje_Style_Tag
461{
462 const char *key;
463 const char *value;
464 const char *font;
465 double font_size;
466 const char *text_class;
467};
468
469/*----------*/
470
471
472struct _Edje_Font_Directory_Entry
473{
474 const char *entry; /* the name of the font */
475 const char *file; /* the name of the file */
476};
477
478/*----------*/
479
480struct _Edje_External_Directory
481{
482 Edje_External_Directory_Entry *entries; /* a list of Edje_External_Directory_Entry */
483 unsigned int entries_count;
484};
485
486struct _Edje_External_Directory_Entry
487{
488 const char *entry; /* the name of the external */
489};
490
491
492/*----------*/
493
494
495
496/*----------*/
497
498struct _Edje_Image_Directory
499{
500 Edje_Image_Directory_Entry *entries; /* an array of Edje_Image_Directory_Entry */
501 unsigned int entries_count;
502
503 Edje_Image_Directory_Set *sets;
504 unsigned int sets_count; /* an array of Edje_Image_Directory_Set */
505};
506
507struct _Edje_Image_Directory_Entry
508{
509 const char *entry; /* the nominal name of the image - if any */
510 int source_type; /* alternate source mode. 0 = none */
511 int source_param; /* extra params on encoding */
512 int id; /* the id no. of the image */
513};
514
515struct _Edje_Image_Directory_Set
516{
517 char *name;
518 Eina_List *entries;
519
520 int id;
521};
522
523struct _Edje_Image_Directory_Set_Entry
524{
525 const char *name;
526 int id;
527
528 struct {
529 struct {
530 int w;
531 int h;
532 } min, max;
533 } size;
534};
535
536struct _Edje_Sound_Sample /*Sound Sample*/
537{
538 const char *name; /* the nominal name of the sound */
539 const char *snd_src; /* Sound source Wav file */
540 int compression; /* Compression - RAW, LOSSLESS COMP , LOSSY ) */
541 int mode; /* alternate source mode. 0 = none */
542 double quality;
543 int id; /* the id no. of the sound */
544};
545
546struct _Edje_Sound_Tone /*Sound Sample*/
547{
548 const char *name; /* the nominal name of the sound - if any */
549 int value; /* alternate source mode. 0 = none */
550 int id; /* the id no. of the sound */
551};
552
553struct _Edje_Sound_Directory
554{
555
556 Edje_Sound_Sample *samples; /* an array of Edje_Sound_Sample entries */
557 unsigned int samples_count;
558
559 Edje_Sound_Tone *tones; /* an array of Edje_Sound_Tone entries */
560 unsigned int tones_count;
561};
562
563/*----------*/
564
565struct _Edje_Program /* a conditional program to be run */
566{
567 int id; /* id of program */
568 const char *name; /* name of the action */
569
570 const char *signal; /* if signal emission name matches the glob here... */
571 const char *source; /* if part that emitted this (name) matches this glob */
572 const char *sample_name;
573 const char *tone_name;
574 double duration;
575 double speed;
576
577 struct {
578 const char *part;
579 const char *state; /* if state is not set, we will try with source */
580 } filter; /* the part filter.part should be in state filter.state for signal to be accepted */
581
582 struct {
583 double from;
584 double range;
585 } in;
586
587 int action; /* type - set state, stop action, set drag pos etc. */
588 const char *state; /* what state of alternates to apply, NULL = default */
589 const char *state2; /* what other state to use - for signal emit action */
590 double value; /* value of state to apply (if multiple names match) */
591 double value2; /* other value for drag actions */
592
593 struct {
594 int mode; /* how to tween - linear, sinusoidal etc. */
595 FLOAT_T time; /* time to graduate between current and new state */
596 FLOAT_T v1; /* other value for drag actions */
597 FLOAT_T v2; /* other value for drag actions */
598 } tween;
599
600 Eina_List *targets; /* list of target parts to apply the state to */
601
602 Eina_List *after; /* list of actions to run at the end of this, for looping */
603
604 struct {
605 const char *name;
606 const char *description;
607 } api;
608
609 /* used for PARAM_COPY (param names in state and state2 above!) */
610 struct {
611 int src; /* part where parameter is being retrieved */
612 int dst; /* part where parameter is being stored */
613 } param;
614};
615
616struct _Edje_Program_Target /* the target of an action */
617{
618 int id; /* just the part id no, or action id no */
619};
620
621struct _Edje_Program_After /* the action to run after another action */
622{
623 int id;
624};
625
626/*----------*/
627struct _Edje_Limit
628{
629 const char *name;
630 int value;
631};
632
633/*----------*/
634#define PART_TYPE_FIELDS(TYPE) \
635 TYPE RECTANGLE; \
636 TYPE TEXT; \
637 TYPE IMAGE; \
638 TYPE PROXY; \
639 TYPE SWALLOW; \
640 TYPE TEXTBLOCK; \
641 TYPE GROUP; \
642 TYPE BOX; \
643 TYPE TABLE; \
644 TYPE EXTERNAL;
645
646struct _Edje_Part_Collection_Directory_Entry
647{
648 const char *entry; /* the nominal name of the part collection */
649 int id; /* the id of this named part collection */
650
651 struct
652 {
653 PART_TYPE_FIELDS(int)
654 int part;
655 } count;
656
657 struct
658 {
659 PART_TYPE_FIELDS(Eina_Mempool *)
660 Eina_Mempool *part;
661 } mp;
662
663 struct
664 {
665 PART_TYPE_FIELDS(Eina_Mempool *)
666 } mp_rtl; /* For Right To Left interface */
667
668 Edje_Part_Collection *ref;
669};
670
671/*----------*/
672
673/*----------*/
674
675struct _Edje_Pack_Element
676{
677 unsigned char type; /* only GROUP supported for now */
678 Edje_Real_Part *parent; /* pointer to the table/box that hold it, set at runtime */
679 const char *name; /* if != NULL, will be set with evas_object_name_set */
680 const char *source; /* group name to use as source for this element */
681 Edje_Size min, prefer, max;
682 struct {
683 int l, r, t, b;
684 } padding;
685 Edje_Alignment align;
686 Edje_Alignment weight;
687 Edje_Aspect aspect;
688 const char *options; /* extra options for custom objects */
689 /* table specific follows */
690 int col, row;
691 unsigned short colspan, rowspan;
692};
693
694/*----------*/
695
696struct _Edje_Part_Collection
697{
698 struct { /* list of Edje_Program */
699 Edje_Program **fnmatch; /* complex match with "*?[\" */
700 unsigned int fnmatch_count;
701
702 Edje_Program **strcmp; /* No special caractere, plain strcmp does the work */
703 unsigned int strcmp_count;
704
705 Edje_Program **strncmp; /* Finish by * or ?, plain strncmp does the work */
706 unsigned int strncmp_count;
707
708 Edje_Program **strrncmp; /* Start with * or ?, reverse strncmp will do the job */
709 unsigned int strrncmp_count;
710
711 Edje_Program **nocmp; /* Empty signal/source that will never match */
712 unsigned int nocmp_count;
713 } programs;
714
715 struct { /* list of limit that need to be monitored */
716 Edje_Limit **vertical;
717 unsigned int vertical_count;
718
719 Edje_Limit **horizontal;
720 unsigned int horizontal_count;
721 } limits;
722
723 Edje_Part **parts; /* an array of Edje_Part */
724 unsigned int parts_count;
725
726 Eina_Hash *data;
727
728 int id; /* the collection id */
729
730 Eina_Hash *alias; /* aliasing part */
731 Eina_Hash *aliased; /* invert match of alias */
732
733 struct {
734 Edje_Size min, max;
735 unsigned char orientation;
736 } prop;
737
738 int references;
739
740#ifdef EDJE_PROGRAM_CACHE
741 struct {
742 Eina_Hash *no_matches;
743 Eina_Hash *matches;
744 } prog_cache;
745#endif
746
747 Embryo_Program *script; /* all the embryo script code for this group */
748 const char *part;
749
750 unsigned char script_only;
751
752 unsigned char lua_script_only;
753
754 unsigned char checked : 1;
755};
756
757struct _Edje_Part_Dragable
758{
759 int step_x; /* drag jumps n pixels (0 = no limit) */
760 int step_y; /* drag jumps n pixels (0 = no limit) */
761
762 int count_x; /* drag area divided by n (0 = no limit) */
763 int count_y; /* drag area divided by n (0 = no limit) */
764
765 int confine_id; /* dragging within this bit, -1 = no */
766
767 /* davinchi */
768 int event_id; /* If it is used as scrollbar */
769
770 signed char x; /* can u click & drag this bit in x dir */
771 signed char y; /* can u click & drag this bit in y dir */
772};
773
774struct _Edje_Part_Api
775{
776 const char *name;
777 const char *description;
778};
779
780typedef struct _Edje_Part_Description_List Edje_Part_Description_List;
781struct _Edje_Part_Description_List
782{
783 Edje_Part_Description_Common **desc;
784 Edje_Part_Description_Common **desc_rtl; /* desc for Right To Left interface */
785 unsigned int desc_count;
786};
787
788struct _Edje_Part
789{
790 const char *name; /* the name if any of the part */
791 Edje_Part_Description_Common *default_desc; /* the part descriptor for default */
792 Edje_Part_Description_Common *default_desc_rtl; /* default desc for Right To Left interface */
793
794 Edje_Part_Description_List other; /* other possible descriptors */
795
796 const char *source, *source2, *source3, *source4, *source5, *source6;
797 int id; /* its id number */
798 int clip_to_id; /* the part id to clip this one to */
799 Edje_Part_Dragable dragable;
800 Edje_Pack_Element **items; /* packed items for box and table */
801 unsigned int items_count;
802 unsigned char type; /* what type (image, rect, text) */
803 unsigned char effect; /* 0 = plain... */
804 unsigned char mouse_events; /* it will affect/respond to mouse events */
805 unsigned char repeat_events; /* it will repeat events to objects below */
806 Evas_Event_Flags ignore_flags;
807 unsigned char scale; /* should certain properties scale with edje scale factor? */
808 unsigned char precise_is_inside;
809 unsigned char use_alternate_font_metrics;
810 unsigned char pointer_mode;
811 unsigned char entry_mode;
812 unsigned char select_mode;
813 unsigned char cursor_mode;
814 unsigned char multiline;
815 Edje_Part_Api api;
816};
817
818struct _Edje_Part_Image_Id
819{
820 int id;
821 Eina_Bool set;
822};
823
824struct _Edje_Part_Description_Common
825{
826 struct {
827 double value; /* the value of the state (for ranges) */
828 const char *name; /* the named state if any */
829 } state;
830
831 Edje_Alignment align; /* 0 <-> 1.0 alignment within allocated space */
832
833 struct {
834 unsigned char w, h; /* width or height is fixed in side (cannot expand with Edje object size) */
835 } fixed;
836
837 Edje_Size min, max;
838 Edje_Position step; /* size stepping by n pixels, 0 = none */
839 Edje_Aspect_Prefer aspect;
840
841 char *color_class; /* how to modify the color */
842 Edje_Color color;
843 Edje_Color color2;
844
845 struct {
846 FLOAT_T relative_x;
847 FLOAT_T relative_y;
848 int offset_x;
849 int offset_y;
850 int id_x; /* -1 = whole part collection, or part ID */
851 int id_y; /* -1 = whole part collection, or part ID */
852 } rel1, rel2;
853
854 struct {
855 int id_persp;
856 int id_light;
857 struct {
858 int id_center;
859 FLOAT_T x, y, z;
860 } rot;
861 unsigned char backcull;
862 unsigned char on;
863 unsigned char persp_on;
864 unsigned char smooth;
865 unsigned char alpha;
866 } map;
867
868 struct {
869 int zplane;
870 int focal;
871 } persp;
872
873 unsigned char visible; /* is it shown */
874};
875
876struct _Edje_Part_Description_Spec_Fill
877{
878 FLOAT_T pos_rel_x; /* fill offset x relative to area */
879 FLOAT_T rel_x; /* relative size compared to area */
880 FLOAT_T pos_rel_y; /* fill offset y relative to area */
881 FLOAT_T rel_y; /* relative size compared to area */
882 int pos_abs_x; /* fill offset x added to fill offset */
883 int abs_x; /* size of fill added to relative fill */
884 int pos_abs_y; /* fill offset y added to fill offset */
885 int abs_y; /* size of fill added to relative fill */
886 int angle; /* angle of fill -- currently only used by grads */
887 int spread; /* spread of fill -- currently only used by grads */
888 char smooth; /* fill with smooth scaling or not */
889 unsigned char type; /* fill coordinate from container (SCALE) or from source image (TILE) */
890};
891
892struct _Edje_Part_Description_Spec_Border
893{
894 int l, r, t, b; /* border scaling on image fill */
895 unsigned char no_fill; /* do we fill the center of the image if bordered? 1 == NO!!!! */
896 unsigned char scale; /* scale image border by same as scale factor */
897 FLOAT_T scale_by; /* when border scale above is enabled, border width OUTPUT is scaled by the object or global scale factor. this value adds another multiplier that the global scale is multiplued by first. if <= 0.0 it is not used, and if 1.0 it i s "ineffective" */
898};
899
900struct _Edje_Part_Description_Spec_Image
901{
902 Edje_Part_Description_Spec_Fill fill;
903
904 Edje_Part_Image_Id **tweens; /* list of Edje_Part_Image_Id */
905 unsigned int tweens_count; /* number of tweens */
906
907 int id; /* the image id to use */
908 int scale_hint; /* evas scale hint */
909 Eina_Bool set; /* if image condition it's content */
910
911 Edje_Part_Description_Spec_Border border;
912};
913
914struct _Edje_Part_Description_Spec_Proxy
915{
916 Edje_Part_Description_Spec_Fill fill;
917
918 int id; /* the part id to use as a source for this state */
919};
920
921struct _Edje_Part_Description_Spec_Text
922{
923 Edje_String text; /* if "" or NULL, then leave text unchanged */
924 char *text_class; /* how to apply/modify the font */
925 Edje_String style; /* the text style if a textblock */
926 Edje_String font; /* if a specific font is asked for */
927 Edje_String repch; /* replacement char for password mode entry */
928
929 Edje_Alignment align; /* text alignment within bounds */
930 Edje_Color color3;
931
932 double elipsis; /* 0.0 - 1.0 defining where the elipsis align */
933 int size; /* 0 = use user set size */
934 int id_source; /* -1 if none */
935 int id_text_source; /* -1 if none */
936
937 unsigned char fit_x; /* resize font size down to fit in x dir */
938 unsigned char fit_y; /* resize font size down to fit in y dir */
939 unsigned char min_x; /* if text size should be part min size */
940 unsigned char min_y; /* if text size should be part min size */
941 unsigned char max_x; /* if text size should be part max size */
942 unsigned char max_y; /* if text size should be part max size */
943 int size_range_min;
944 int size_range_max; /* -1 means, no bound. */
945};
946
947struct _Edje_Part_Description_Spec_Box
948{
949 char *layout, *alt_layout;
950 Edje_Alignment align;
951 struct {
952 int x, y;
953 } padding;
954 struct {
955 unsigned char h, v;
956 } min;
957};
958
959struct _Edje_Part_Description_Spec_Table
960{
961 unsigned char homogeneous;
962 Edje_Alignment align;
963 struct {
964 int x, y;
965 } padding;
966 struct {
967 unsigned char h, v;
968 } min;
969};
970
971struct _Edje_Part_Description_Image
972{
973 Edje_Part_Description_Common common;
974 Edje_Part_Description_Spec_Image image;
975};
976
977struct _Edje_Part_Description_Proxy
978{
979 Edje_Part_Description_Common common;
980 Edje_Part_Description_Spec_Proxy proxy;
981};
982
983struct _Edje_Part_Description_Text
984{
985 Edje_Part_Description_Common common;
986 Edje_Part_Description_Spec_Text text;
987};
988
989struct _Edje_Part_Description_Box
990{
991 Edje_Part_Description_Common common;
992 Edje_Part_Description_Spec_Box box;
993};
994
995struct _Edje_Part_Description_Table
996{
997 Edje_Part_Description_Common common;
998 Edje_Part_Description_Spec_Table table;
999};
1000
1001struct _Edje_Part_Description_External
1002{
1003 Edje_Part_Description_Common common;
1004 Eina_List *external_params; /* parameters for external objects */
1005};
1006
1007/*----------*/
1008
1009struct _Edje_Signal_Source_Char
1010{
1011 EINA_RBTREE;
1012
1013 const char *signal;
1014 const char *source;
1015
1016 Eina_List *list;
1017};
1018
1019struct _Edje_Signals_Sources_Patterns
1020
1021{
1022 Edje_Patterns *signals_patterns;
1023 Edje_Patterns *sources_patterns;
1024
1025 Eina_Rbtree *exact_match;
1026
1027 union {
1028 struct {
1029 Edje_Program **globing;
1030 unsigned int count;
1031 } programs;
1032 struct {
1033 Eina_List *globing;
1034 } callbacks;
1035 } u;
1036};
1037
1038typedef struct _Edje_Signals_Sources_Patterns Edje_Signals_Sources_Patterns;
1039
1040struct _Edje
1041{
1042 Evas_Object_Smart_Clipped_Data base;
1043 /* This contains (or should):
1044 Evas_Object *clipper; // a big rect to clip this Edje to
1045 Evas *evas; // the Evas this Edje belongs to
1046 */
1047 const Edje_Smart_Api *api;
1048 const char *path;
1049 const char *group;
1050 const char *parent;
1051
1052 Evas_Coord x, y, w, h;
1053 Edje_Size min;
1054 double paused_at;
1055 Evas_Object *obj; /* the smart object */
1056 Edje_File *file; /* the file the data comes form */
1057 Edje_Part_Collection *collection; /* the description being used */
1058 Eina_List *actions; /* currently running actions */
1059 Eina_List *callbacks;
1060 Eina_List *pending_actions;
1061 Eina_List *color_classes;
1062 Eina_List *text_classes;
1063 /* variable pool for Edje Embryo scripts */
1064 Edje_Var_Pool *var_pool;
1065 /* for faster lookups to avoid nth list walks */
1066 Edje_Real_Part **table_parts;
1067 Edje_Program **table_programs;
1068 Edje_Real_Part *focused_part;
1069 Eina_List *subobjs;
1070 Eina_List *text_insert_filter_callbacks;
1071 void *script_only_data;
1072
1073 int table_programs_size;
1074 unsigned int table_parts_size;
1075
1076 struct {
1077 Eina_Hash *text_class;
1078 Eina_Hash *color_class;
1079 } members;
1080
1081 Edje_Perspective *persp;
1082
1083 struct {
1084 Edje_Signals_Sources_Patterns callbacks;
1085 Edje_Signals_Sources_Patterns programs;
1086 } patterns;
1087
1088 int references;
1089 int block;
1090 int load_error;
1091 int freeze;
1092 FLOAT_T scale;
1093 Eina_Bool is_rtl : 1;
1094
1095 struct {
1096 Edje_Text_Change_Cb func;
1097 void *data;
1098 } text_change;
1099
1100 struct {
1101 Edje_Message_Handler_Cb func;
1102 void *data;
1103 int num;
1104 } message;
1105 int processing_messages;
1106
1107 int state;
1108
1109 int preload_count;
1110
1111 lua_State *L;
1112 Eina_Inlist *lua_objs;
1113 int lua_ref;
1114
1115 struct {
1116 Edje_Item_Provider_Cb func;
1117 void *data;
1118 } item_provider;
1119
1120 unsigned int dirty : 1;
1121 unsigned int recalc : 1;
1122 unsigned int walking_callbacks : 1;
1123 unsigned int delete_callbacks : 1;
1124 unsigned int just_added_callbacks : 1;
1125 unsigned int have_objects : 1;
1126 unsigned int paused : 1;
1127 unsigned int no_anim : 1;
1128 unsigned int calc_only : 1;
1129 unsigned int walking_actions : 1;
1130 unsigned int block_break : 1;
1131 unsigned int delete_me : 1;
1132 unsigned int postponed : 1;
1133 unsigned int freeze_calc : 1;
1134 unsigned int has_entries : 1;
1135 unsigned int entries_inited : 1;
1136#ifdef EDJE_CALC_CACHE
1137 unsigned int text_part_change : 1;
1138 unsigned int all_part_change : 1;
1139#endif
1140 unsigned int have_mapped_part : 1;
1141};
1142
1143struct _Edje_Calc_Params
1144{
1145 int x, y, w, h; // 16
1146 Edje_Rectangle req; // 16
1147 Edje_Rectangle req_drag; // 16
1148 Edje_Color color; // 4
1149 union {
1150 struct {
1151 struct {
1152 int x, y, w, h; // 16
1153 int angle; // 4
1154 int spread; // 4
1155 } fill; // 24
1156
1157 union {
1158 struct {
1159 int l, r, t, b; // 16
1160 } image; // 16
1161 } spec; // 16
1162 } common; // 40
1163 struct {
1164 Edje_Alignment align; /* text alignment within bounds */ // 16
1165 double elipsis; // 8
1166 int size; // 4
1167 Edje_Color color2, color3; // 8
1168 } text; // 36
1169 } type; // 40
1170 struct {
1171 struct {
1172 int x, y, z;
1173 } center; // 12
1174 struct {
1175 double x, y, z;
1176 } rotation; // 24
1177 struct {
1178 int x, y, z;
1179 int r, g, b;
1180 int ar, ag, ab;
1181 } light; // 36
1182 struct {
1183 int x, y, z;
1184 int focal;
1185 } persp;
1186 } map;
1187 unsigned char persp_on : 1;
1188 unsigned char lighted : 1;
1189 unsigned char mapped : 1;
1190 unsigned char visible : 1;
1191 unsigned char smooth : 1; // 1
1192}; // 96
1193
1194struct _Edje_Real_Part_Set
1195{
1196 Edje_Image_Directory_Set_Entry *entry; // 4
1197 Edje_Image_Directory_Set *set; // 4
1198
1199 int id; // 4
1200};
1201
1202struct _Edje_Real_Part_State
1203{
1204 Edje_Part_Description_Common *description; // 4
1205 Edje_Part_Description_Common *description_rtl; // 4
1206 Edje_Real_Part *rel1_to_x; // 4
1207 Edje_Real_Part *rel1_to_y; // 4
1208 Edje_Real_Part *rel2_to_x; // 4
1209 Edje_Real_Part *rel2_to_y; // 4
1210#ifdef EDJE_CALC_CACHE
1211 int state; // 4
1212 Edje_Calc_Params p; // 96
1213#endif
1214 void *external_params; // 4
1215 Edje_Real_Part_Set *set; // 4
1216}; // 32
1217// WITH EDJE_CALC_CACHE 132
1218
1219struct _Edje_Real_Part_Drag
1220{
1221 FLOAT_T x, y; // 16
1222 Edje_Position_Scale val, size, step, page; // 64
1223 struct {
1224 unsigned int count; // 4
1225 int x, y; // 8
1226 } down;
1227 struct {
1228 int x, y; // 8
1229 } tmp;
1230 unsigned char need_reset : 1; // 4
1231 Edje_Real_Part *confine_to; // 4
1232}; // 104
1233
1234struct _Edje_Real_Part
1235{
1236 Edje *edje; // 4
1237 Edje_Part *part; // 4
1238 Evas_Object *object; // 4
1239 int x, y, w, h; // 16
1240 Edje_Rectangle req; // 16
1241
1242 Eina_List *items; // 4 //FIXME: only if table/box
1243 Edje_Part_Box_Animation *anim; // 4 //FIXME: Used only if box
1244 void *entry_data; // 4 // FIXME: move to entry section
1245
1246 Evas_Object *swallowed_object; // 4 // FIXME: move with swallow_params data
1247 struct {
1248 Edje_Size min, max; // 16
1249 Edje_Aspect aspect; // 12
1250 } swallow_params; // 28 // FIXME: only if type SWALLOW
1251
1252 Edje_Real_Part_Drag *drag; // 4
1253 Edje_Real_Part *events_to; // 4
1254
1255 struct {
1256 Edje_Real_Part *source; // 4
1257 Edje_Real_Part *text_source; // 4
1258 const char *text; // 4
1259 Edje_Position offset; // 8 text only
1260 const char *font; // 4 text only
1261 const char *style; // 4 text only
1262 int size; // 4 text only
1263 struct {
1264 double in_w, in_h; // 16 text only
1265 int in_size; // 4 text only
1266 const char *in_str; // 4 text only
1267 const char *out_str; // 4 text only
1268 int out_size; // 4 text only
1269 FLOAT_T align_x, align_y; // 16 text only
1270 double elipsis; // 8 text only
1271 int fit_x, fit_y; // 8 text only
1272 } cache; // 64
1273 } text; // 86 // FIXME make text a potiner to struct and alloc at end
1274 // if part type is TEXT move common members textblock +
1275 // text to front and have smaller struct for textblock
1276
1277 FLOAT_T description_pos; // 8
1278 Edje_Part_Description_Common *chosen_description; // 4
1279 Edje_Real_Part_State param1; // 20
1280 // WITH EDJE_CALC_CACHE: 140
1281 Edje_Real_Part_State *param2, *custom; // 8
1282 Edje_Calc_Params *current; // 4
1283
1284#ifdef EDJE_CALC_CACHE
1285 int state; // 4
1286#endif
1287
1288 Edje_Real_Part *clip_to; // 4
1289
1290 Edje_Running_Program *program; // 4
1291
1292 int clicked_button; // 4
1293
1294 unsigned char calculated; // 1
1295 unsigned char calculating; // 1
1296
1297 unsigned char still_in : 1; // 1
1298#ifdef EDJE_CALC_CACHE
1299 unsigned char invalidate : 1; // 0
1300#endif
1301}; // 264
1302// WITH EDJE_CALC_CACHE: 404
1303
1304struct _Edje_Running_Program
1305{
1306 Edje *edje;
1307 Edje_Program *program;
1308 double start_time;
1309 char delete_me : 1;
1310};
1311
1312struct _Edje_Signal_Callback
1313{
1314 const char *signal;
1315 const char *source;
1316 Edje_Signal_Cb func;
1317 void *data;
1318 unsigned char just_added : 1;
1319 unsigned char delete_me : 1;
1320 unsigned char propagate : 1;
1321};
1322
1323struct _Edje_Text_Insert_Filter_Callback
1324{
1325 const char *part;
1326 Edje_Text_Filter_Cb func;
1327 void *data;
1328};
1329
1330struct _Edje_Pending_Program
1331{
1332 Edje *edje;
1333 Edje_Program *program;
1334 Ecore_Timer *timer;
1335};
1336
1337struct _Edje_Text_Style
1338{
1339 struct {
1340 unsigned char x, y;
1341 } offset;
1342 struct {
1343 unsigned char l, r, t, b;
1344 } pad;
1345 int num;
1346 struct {
1347 unsigned char color; /* 0 = color, 1, 2 = color2, color3 */
1348 signed char x, y; /* offset */
1349 unsigned char alpha;
1350 } members[32];
1351};
1352
1353struct _Edje_Color_Class
1354{
1355 const char *name;
1356 unsigned char r, g, b, a;
1357 unsigned char r2, g2, b2, a2;
1358 unsigned char r3, g3, b3, a3;
1359};
1360
1361struct _Edje_Text_Class
1362{
1363 const char *name;
1364 const char *font;
1365 Evas_Font_Size size;
1366};
1367
1368struct _Edje_Var_Int
1369{
1370 int v;
1371};
1372
1373struct _Edje_Var_Float
1374{
1375 double v;
1376};
1377
1378struct _Edje_Var_String
1379{
1380 char *v;
1381};
1382
1383struct _Edje_Var_List
1384{
1385 Eina_List *v;
1386};
1387
1388struct _Edje_Var_Hash
1389{
1390 Eina_Hash *v;
1391};
1392
1393struct _Edje_Var_Timer
1394{
1395 Edje *edje;
1396 int id;
1397 Embryo_Function func;
1398 int val;
1399 Ecore_Timer *timer;
1400};
1401
1402struct _Edje_Var_Animator
1403{
1404 Edje *edje;
1405 int id;
1406 Embryo_Function func;
1407 int val;
1408 double start, len;
1409 char delete_me;
1410};
1411
1412struct _Edje_Var_Pool
1413{
1414 int id_count;
1415 Eina_List *timers;
1416 Eina_List *animators;
1417 int size;
1418 Edje_Var *vars;
1419 int walking_list;
1420};
1421
1422struct _Edje_Var
1423{
1424 union {
1425 Edje_Var_Int i;
1426 Edje_Var_Float f;
1427 Edje_Var_String s;
1428 Edje_Var_List l;
1429 Edje_Var_Hash h;
1430 } data;
1431 unsigned char type;
1432};
1433
1434typedef enum _Edje_Queue
1435{
1436 EDJE_QUEUE_APP,
1437 EDJE_QUEUE_SCRIPT
1438} Edje_Queue;
1439
1440typedef struct _Edje_Message_Signal Edje_Message_Signal;
1441typedef struct _Edje_Message Edje_Message;
1442
1443typedef struct _Edje_Message_Signal_Data Edje_Message_Signal_Data;
1444struct _Edje_Message_Signal_Data
1445{
1446 int ref;
1447 void *data;
1448 void (*free_func)(void *);
1449};
1450
1451struct _Edje_Message_Signal
1452{
1453 const char *sig;
1454 const char *src;
1455 Edje_Message_Signal_Data *data;
1456};
1457
1458struct _Edje_Message
1459{
1460 Edje *edje;
1461 Edje_Queue queue;
1462 Edje_Message_Type type;
1463 int id;
1464 unsigned char *msg;
1465 Eina_Bool propagated : 1;
1466};
1467
1468typedef enum _Edje_Fill
1469{
1470 EDJE_FILL_TYPE_SCALE = 0,
1471 EDJE_FILL_TYPE_TILE
1472} Edje_Fill;
1473
1474typedef enum _Edje_Match_Error
1475{
1476 EDJE_MATCH_OK,
1477 EDJE_MATCH_ALLOC_ERROR,
1478 EDJE_MATCH_SYNTAX_ERROR
1479
1480} Edje_Match_Error;
1481
1482typedef struct _Edje_States Edje_States;
1483struct _Edje_Patterns
1484{
1485 const char **patterns;
1486
1487 Edje_States *states;
1488
1489 int ref;
1490 Eina_Bool delete_me : 1;
1491
1492 size_t patterns_size;
1493 size_t max_length;
1494 size_t finals[];
1495};
1496
1497Edje_Patterns *edje_match_collection_dir_init(const Eina_List *lst);
1498Edje_Patterns *edje_match_programs_signal_init(Edje_Program * const *array,
1499 unsigned int count);
1500Edje_Patterns *edje_match_programs_source_init(Edje_Program * const *array,
1501 unsigned int count);
1502Edje_Patterns *edje_match_callback_signal_init(const Eina_List *lst);
1503Edje_Patterns *edje_match_callback_source_init(const Eina_List *lst);
1504
1505Eina_Bool edje_match_collection_dir_exec(const Edje_Patterns *ppat,
1506 const char *string);
1507Eina_Bool edje_match_programs_exec(const Edje_Patterns *ppat_signal,
1508 const Edje_Patterns *ppat_source,
1509 const char *signal,
1510 const char *source,
1511 Edje_Program **programs,
1512 Eina_Bool (*func)(Edje_Program *pr, void *data),
1513 void *data,
1514 Eina_Bool prop);
1515int edje_match_callback_exec(Edje_Patterns *ppat_signal,
1516 Edje_Patterns *ppat_source,
1517 const char *signal,
1518 const char *source,
1519 Eina_List *callbacks,
1520 Edje *ed,
1521 Eina_Bool prop);
1522
1523void edje_match_patterns_free(Edje_Patterns *ppat);
1524
1525Eina_List *edje_match_program_hash_build(Edje_Program * const * programs,
1526 unsigned int count,
1527 Eina_Rbtree **tree);
1528Eina_List *edje_match_callback_hash_build(const Eina_List *callbacks,
1529 Eina_Rbtree **tree);
1530const Eina_List *edje_match_signal_source_hash_get(const char *signal,
1531 const char *source,
1532 const Eina_Rbtree *tree);
1533void edje_match_signal_source_free(Edje_Signal_Source_Char *key, void *data);
1534
1535// FIXME remove below 2 eapi decls when edje_convert goes
1536EAPI void _edje_edd_init(void);
1537EAPI void _edje_edd_shutdown(void);
1538
1539EAPI extern Eet_Data_Descriptor *_edje_edd_edje_file;
1540EAPI extern Eet_Data_Descriptor *_edje_edd_edje_part_collection;
1541
1542extern int _edje_anim_count;
1543extern Ecore_Animator *_edje_timer;
1544extern Eina_List *_edje_animators;
1545extern Eina_List *_edje_edjes;
1546
1547extern char *_edje_fontset_append;
1548extern FLOAT_T _edje_scale;
1549extern int _edje_freeze_val;
1550extern int _edje_freeze_calc_count;
1551extern Eina_List *_edje_freeze_calc_list;
1552
1553extern Eina_Bool _edje_password_show_last;
1554extern FLOAT_T _edje_password_show_last_timeout;
1555
1556extern Eina_Mempool *_edje_real_part_mp;
1557extern Eina_Mempool *_edje_real_part_state_mp;
1558
1559extern Eina_Mempool *_emp_RECTANGLE;
1560extern Eina_Mempool *_emp_TEXT;
1561extern Eina_Mempool *_emp_IMAGE;
1562extern Eina_Mempool *_emp_PROXY;
1563extern Eina_Mempool *_emp_SWALLOW;
1564extern Eina_Mempool *_emp_TEXTBLOCK;
1565extern Eina_Mempool *_emp_GROUP;
1566extern Eina_Mempool *_emp_BOX;
1567extern Eina_Mempool *_emp_TABLE;
1568extern Eina_Mempool *_emp_EXTERNAL;
1569extern Eina_Mempool *_emp_part;
1570
1571void _edje_part_pos_set(Edje *ed, Edje_Real_Part *ep, int mode, FLOAT_T pos, FLOAT_T v1, FLOAT_T v2);
1572Edje_Part_Description_Common *_edje_part_description_find(Edje *ed,
1573 Edje_Real_Part *rp,
1574 const char *name, double val);
1575void _edje_part_description_apply(Edje *ed, Edje_Real_Part *ep, const char *d1, double v1, const char *d2, double v2);
1576void _edje_recalc(Edje *ed);
1577void _edje_recalc_do(Edje *ed);
1578void _edje_part_recalc_1(Edje *ed, Edje_Real_Part *ep);
1579int _edje_part_dragable_calc(Edje *ed, Edje_Real_Part *ep, FLOAT_T *x, FLOAT_T *y);
1580void _edje_dragable_pos_set(Edje *ed, Edje_Real_Part *ep, FLOAT_T x, FLOAT_T y);
1581
1582Eina_Bool _edje_timer_cb(void *data);
1583Eina_Bool _edje_pending_timer_cb(void *data);
1584void _edje_callbacks_add(Evas_Object *obj, Edje *ed, Edje_Real_Part *rp);
1585void _edje_callbacks_focus_add(Evas_Object *obj, Edje *ed, Edje_Real_Part *rp);
1586void _edje_callbacks_del(Evas_Object *obj, Edje *ed);
1587void _edje_callbacks_focus_del(Evas_Object *obj, Edje *ed);
1588
1589void _edje_edd_init(void);
1590void _edje_edd_shutdown(void);
1591
1592int _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *group, const char *parent, Eina_List *group_path);
1593
1594void _edje_file_add(Edje *ed);
1595void _edje_file_del(Edje *ed);
1596void _edje_file_free(Edje_File *edf);
1597void _edje_file_cache_shutdown(void);
1598void _edje_collection_free(Edje_File *edf,
1599 Edje_Part_Collection *ec,
1600 Edje_Part_Collection_Directory_Entry *ce);
1601void _edje_collection_free_part_description_clean(int type,
1602 Edje_Part_Description_Common *desc,
1603 Eina_Bool free_strings);
1604void _edje_collection_free_part_description_free(int type,
1605 Edje_Part_Description_Common *desc,
1606 Edje_Part_Collection_Directory_Entry *ce,
1607 Eina_Bool free_strings);
1608
1609void _edje_object_smart_set(Edje_Smart_Api *sc);
1610const Edje_Smart_Api * _edje_object_smart_class_get(void);
1611
1612void _edje_del(Edje *ed);
1613void _edje_ref(Edje *ed);
1614void _edje_unref(Edje *ed);
1615void _edje_clean_objects(Edje *ed);
1616void _edje_ref(Edje *ed);
1617void _edje_unref(Edje *ed);
1618
1619Eina_Bool _edje_program_run_iterate(Edje_Running_Program *runp, double tim);
1620void _edje_program_end(Edje *ed, Edje_Running_Program *runp);
1621void _edje_program_run(Edje *ed, Edje_Program *pr, Eina_Bool force, const char *ssig, const char *ssrc);
1622void _edje_programs_patterns_clean(Edje *ed);
1623void _edje_programs_patterns_init(Edje *ed);
1624void _edje_emit(Edje *ed, const char *sig, const char *src);
1625void _edje_emit_full(Edje *ed, const char *sig, const char *src, void *data, void (*free_func)(void *));
1626void _edje_emit_handle(Edje *ed, const char *sig, const char *src, Edje_Message_Signal_Data *data, Eina_Bool prop);
1627void _edje_signals_sources_patterns_clean(Edje_Signals_Sources_Patterns *ssp);
1628void _edje_callbacks_patterns_clean(Edje *ed);
1629
1630void _edje_text_init(void);
1631void _edje_text_part_on_add(Edje *ed, Edje_Real_Part *ep);
1632void _edje_text_part_on_del(Edje *ed, Edje_Part *ep);
1633void _edje_text_recalc_apply(Edje *ed,
1634 Edje_Real_Part *ep,
1635 Edje_Calc_Params *params,
1636 Edje_Part_Description_Text *chosen_desc);
1637Evas_Font_Size _edje_text_size_calc(Evas_Font_Size size, Edje_Text_Class *tc);
1638const char * _edje_text_class_font_get(Edje *ed,
1639 Edje_Part_Description_Text *chosen_desc,
1640 int *size, char **free_later);
1641
1642
1643Edje_Real_Part *_edje_real_part_get(const Edje *ed, const char *part);
1644Edje_Real_Part *_edje_real_part_recursive_get(const Edje *ed, const char *part);
1645Edje_Color_Class *_edje_color_class_find(Edje *ed, const char *color_class);
1646void _edje_color_class_member_direct_del(const char *color_class, void *lookup);
1647void _edje_color_class_member_add(Edje *ed, const char *color_class);
1648void _edje_color_class_member_del(Edje *ed, const char *color_class);
1649void _edje_color_class_on_del(Edje *ed, Edje_Part *ep);
1650void _edje_color_class_members_free(void);
1651void _edje_color_class_hash_free(void);
1652
1653Edje_Text_Class *_edje_text_class_find(Edje *ed, const char *text_class);
1654void _edje_text_class_member_add(Edje *ed, const char *text_class);
1655void _edje_text_class_member_del(Edje *ed, const char *text_class);
1656void _edje_text_class_member_direct_del(const char *text_class, void *lookup);
1657void _edje_text_class_members_free(void);
1658void _edje_text_class_hash_free(void);
1659
1660Edje *_edje_fetch(const Evas_Object *obj) EINA_PURE;
1661int _edje_freeze(Edje *ed);
1662int _edje_thaw(Edje *ed);
1663int _edje_block(Edje *ed);
1664int _edje_unblock(Edje *ed);
1665int _edje_block_break(Edje *ed);
1666void _edje_block_violate(Edje *ed);
1667void _edje_object_part_swallow_free_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
1668void _edje_object_part_swallow_changed_hints_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
1669void _edje_real_part_swallow(Edje_Real_Part *rp, Evas_Object *obj_swallow, Eina_Bool hints_update);
1670void _edje_real_part_swallow_clear(Edje_Real_Part *rp);
1671void _edje_box_init(void);
1672void _edje_box_shutdown(void);
1673Eina_Bool _edje_box_layout_find(const char *name, Evas_Object_Box_Layout *cb, void **data, void (**free_data)(void *data));
1674void _edje_box_recalc_apply(Edje *ed __UNUSED__, Edje_Real_Part *ep, Edje_Calc_Params *p3, Edje_Part_Description_Box *chosen_desc);
1675Eina_Bool _edje_box_layout_add_child(Edje_Real_Part *rp, Evas_Object *child_obj);
1676void _edje_box_layout_remove_child(Edje_Real_Part *rp, Evas_Object *child_obj);
1677Edje_Part_Box_Animation * _edje_box_layout_anim_new(Evas_Object *box);
1678void _edje_box_layout_free_data(void *data);
1679
1680Eina_Bool _edje_real_part_box_append(Edje_Real_Part *rp, Evas_Object *child_obj);
1681Eina_Bool _edje_real_part_box_prepend(Edje_Real_Part *rp, Evas_Object *child_obj);
1682Eina_Bool _edje_real_part_box_insert_before(Edje_Real_Part *rp, Evas_Object *child_obj, const Evas_Object *ref);
1683Eina_Bool _edje_real_part_box_insert_at(Edje_Real_Part *rp, Evas_Object *child_obj, unsigned int pos);
1684Evas_Object *_edje_real_part_box_remove(Edje_Real_Part *rp, Evas_Object *child_obj);
1685Evas_Object *_edje_real_part_box_remove_at(Edje_Real_Part *rp, unsigned int pos);
1686Eina_Bool _edje_real_part_box_remove_all(Edje_Real_Part *rp, Eina_Bool clear);
1687Eina_Bool _edje_real_part_table_pack(Edje_Real_Part *rp, Evas_Object *child_obj, unsigned short col, unsigned short row, unsigned short colspan, unsigned short rowspan);
1688Eina_Bool _edje_real_part_table_unpack(Edje_Real_Part *rp, Evas_Object *child_obj);
1689void _edje_real_part_table_clear(Edje_Real_Part *rp, Eina_Bool clear);
1690Evas_Object *_edje_children_get(Edje_Real_Part *rp, const char *partid);
1691
1692Eina_Bool _edje_object_part_text_raw_set(Evas_Object *obj, Edje_Real_Part *rp, const char *part, const char *text);
1693char *_edje_text_escape(const char *text);
1694char *_edje_text_unescape(const char *text);
1695
1696void _edje_embryo_script_init (Edje_Part_Collection *edc);
1697void _edje_embryo_script_shutdown (Edje_Part_Collection *edc);
1698void _edje_embryo_script_reset (Edje *ed);
1699void _edje_embryo_test_run (Edje *ed, const char *fname, const char *sig, const char *src);
1700Edje_Var *_edje_var_new (void);
1701void _edje_var_free (Edje_Var *var);
1702void _edje_var_init (Edje *ed);
1703void _edje_var_shutdown (Edje *ed);
1704int _edje_var_string_id_get (Edje *ed, const char *string);
1705int _edje_var_var_int_get (Edje *ed, Edje_Var *var);
1706void _edje_var_var_int_set (Edje *ed, Edje_Var *var, int v);
1707double _edje_var_var_float_get (Edje *ed, Edje_Var *var);
1708void _edje_var_var_float_set (Edje *ed, Edje_Var *var, double v);
1709const char *_edje_var_var_str_get (Edje *ed, Edje_Var *var);
1710void _edje_var_var_str_set (Edje *ed, Edje_Var *var, const char *str);
1711int _edje_var_int_get (Edje *ed, int id);
1712void _edje_var_int_set (Edje *ed, int id, int v);
1713double _edje_var_float_get (Edje *ed, int id);
1714void _edje_var_float_set (Edje *ed, int id, double v);
1715const char *_edje_var_str_get (Edje *ed, int id);
1716void _edje_var_str_set (Edje *ed, int id, const char *str);
1717
1718void _edje_var_list_var_append(Edje *ed, int id, Edje_Var *var);
1719void _edje_var_list_var_prepend(Edje *ed, int id, Edje_Var *var);
1720void _edje_var_list_var_append_relative(Edje *ed, int id, Edje_Var *var, Edje_Var *relative);
1721void _edje_var_list_var_prepend_relative(Edje *ed, int id, Edje_Var *var, Edje_Var *relative);
1722Edje_Var *_edje_var_list_nth(Edje *ed, int id, int n);
1723
1724int _edje_var_list_count_get(Edje *ed, int id);
1725void _edje_var_list_remove_nth(Edje *ed, int id, int n);
1726
1727int _edje_var_list_nth_int_get(Edje *ed, int id, int n);
1728void _edje_var_list_nth_int_set(Edje *ed, int id, int n, int v);
1729void _edje_var_list_int_append(Edje *ed, int id, int v);
1730void _edje_var_list_int_prepend(Edje *ed, int id, int v);
1731void _edje_var_list_int_insert(Edje *ed, int id, int n, int v);
1732
1733double _edje_var_list_nth_float_get(Edje *ed, int id, int n);
1734void _edje_var_list_nth_float_set(Edje *ed, int id, int n, double v);
1735void _edje_var_list_float_append(Edje *ed, int id, double v);
1736void _edje_var_list_float_prepend(Edje *ed, int id, double v);
1737void _edje_var_list_float_insert(Edje *ed, int id, int n, double v);
1738
1739const char *_edje_var_list_nth_str_get(Edje *ed, int id, int n);
1740void _edje_var_list_nth_str_set(Edje *ed, int id, int n, const char *v);
1741void _edje_var_list_str_append(Edje *ed, int id, const char *v);
1742void _edje_var_list_str_prepend(Edje *ed, int id, const char *v);
1743void _edje_var_list_str_insert(Edje *ed, int id, int n, const char *v);
1744
1745int _edje_var_timer_add (Edje *ed, double in, const char *fname, int val);
1746void _edje_var_timer_del (Edje *ed, int id);
1747
1748int _edje_var_anim_add (Edje *ed, double len, const char *fname, int val);
1749void _edje_var_anim_del (Edje *ed, int id);
1750
1751void _edje_message_init (void);
1752void _edje_message_shutdown (void);
1753void _edje_message_cb_set (Edje *ed, void (*func) (void *data, Evas_Object *obj, Edje_Message_Type type, int id, void *msg), void *data);
1754Edje_Message *_edje_message_new (Edje *ed, Edje_Queue queue, Edje_Message_Type type, int id);
1755void _edje_message_free (Edje_Message *em);
1756void _edje_message_propornot_send (Edje *ed, Edje_Queue queue, Edje_Message_Type type, int id, void *emsg, Eina_Bool prop);
1757void _edje_message_send (Edje *ed, Edje_Queue queue, Edje_Message_Type type, int id, void *emsg);
1758void _edje_message_parameters_push (Edje_Message *em);
1759void _edje_message_process (Edje_Message *em);
1760void _edje_message_queue_process (void);
1761void _edje_message_queue_clear (void);
1762void _edje_message_del (Edje *ed);
1763
1764void _edje_textblock_styles_add(Edje *ed);
1765void _edje_textblock_styles_del(Edje *ed);
1766void _edje_textblock_style_all_update(Edje *ed);
1767void _edje_textblock_style_parse_and_fix(Edje_File *edf);
1768void _edje_textblock_style_cleanup(Edje_File *edf);
1769Edje_File *_edje_cache_file_coll_open(const char *file, const char *coll, int *error_ret, Edje_Part_Collection **edc_ret);
1770void _edje_cache_coll_clean(Edje_File *edf);
1771void _edje_cache_coll_flush(Edje_File *edf);
1772void _edje_cache_coll_unref(Edje_File *edf, Edje_Part_Collection *edc);
1773void _edje_cache_file_unref(Edje_File *edf);
1774
1775void _edje_embryo_globals_init(Edje *ed);
1776
1777#define CHKPARAM(n) if (params[0] != (sizeof(Embryo_Cell) * (n))) return -1;
1778#define GETSTR(str, par) { \
1779 Embryo_Cell *___cptr; \
1780 int ___l; \
1781 str = NULL; \
1782 if ((___cptr = embryo_data_address_get(ep, (par)))) { \
1783 ___l = embryo_data_string_length_get(ep, ___cptr); \
1784 if (((str) = alloca(___l + 1))) \
1785 embryo_data_string_get(ep, ___cptr, (str)); } }
1786#define GETSTREVAS(str, par) { \
1787 if ((str)) { \
1788 if ((par) && (!strcmp((par), (str)))) return 0; \
1789 if ((par)) eina_stringshare_del((par)); \
1790 (par) = (char *)eina_stringshare_add((str)); } \
1791 else (par) = NULL; }
1792#define GETFLOAT(val, par) { \
1793 float *___cptr; \
1794 if ((___cptr = (float *)embryo_data_address_get(ep, (par)))) { \
1795 val = *___cptr; } }
1796
1797#define GETFLOAT_T(val, par) \
1798 { \
1799 float *___cptr; \
1800 if ((___cptr = (float *)embryo_data_address_get(ep, (par)))) \
1801 { \
1802 val = FROM_DOUBLE(*___cptr); \
1803 } \
1804 }
1805
1806#define GETINT(val, par) { \
1807 int *___cptr; \
1808 if ((___cptr = (int *)embryo_data_address_get(ep, (par)))) { \
1809 val = *___cptr; } }
1810#define SETSTR(str, par) { \
1811 Embryo_Cell *___cptr; \
1812 if ((___cptr = embryo_data_address_get(ep, (par)))) { \
1813 embryo_data_string_set(ep, str, ___cptr); } }
1814#define SETSTRALLOCATE(s) \
1815 { \
1816 if (s) { \
1817 if ((int) strlen((s)) < params[4]) { \
1818 SETSTR((s), params[3]); } \
1819 else { \
1820 char *ss; \
1821 ss = alloca(strlen((s)) + 1); \
1822 strcpy(ss, (s)); \
1823 ss[params[4] - 2] = 0; \
1824 SETSTR(ss, params[3]); } } \
1825 else \
1826 SETSTR("", params[3]); \
1827 }
1828#define SETFLOAT(val, par) { \
1829 float *___cptr; \
1830 if ((___cptr = (float *)embryo_data_address_get(ep, (par)))) { \
1831 *___cptr = (float)val; } }
1832#define SETFLOAT_T(val, par) \
1833 { \
1834 float *___cptr; \
1835 if ((___cptr = (float *)embryo_data_address_get(ep, (par)))) \
1836 { \
1837 *___cptr = (float) TO_DOUBLE(val); \
1838 } \
1839 }
1840#define SETINT(val, par) { \
1841 int *___cptr; \
1842 if ((___cptr = (int *)embryo_data_address_get(ep, (par)))) { \
1843 *___cptr = (int)val; } }
1844
1845Eina_Bool _edje_script_only(Edje *ed);
1846void _edje_script_only_init(Edje *ed);
1847void _edje_script_only_shutdown(Edje *ed);
1848void _edje_script_only_show(Edje *ed);
1849void _edje_script_only_hide(Edje *ed);
1850void _edje_script_only_move(Edje *ed);
1851void _edje_script_only_resize(Edje *ed);
1852void _edje_script_only_message(Edje *ed, Edje_Message *em);
1853
1854extern jmp_buf _edje_lua_panic_jmp;
1855#define _edje_lua_panic_here() setjmp(_edje_lua_panic_jmp)
1856
1857lua_State *_edje_lua_state_get();
1858lua_State *_edje_lua_new_thread(Edje *ed, lua_State *L);
1859void _edje_lua_free_thread(Edje *ed, lua_State *L);
1860void _edje_lua_new_reg(lua_State *L, int index, void *ptr);
1861void _edje_lua_get_reg(lua_State *L, void *ptr);
1862void _edje_lua_free_reg(lua_State *L, void *ptr);
1863void _edje_lua_script_fn_new(Edje *ed);
1864void _edje_lua_group_fn_new(Edje *ed);
1865void _edje_lua_init();
1866void _edje_lua_shutdown();
1867
1868void __edje_lua_error(const char *file, const char *fnc, int line, lua_State *L, int err_code);
1869#define _edje_lua_error(L, err_code) \
1870 __edje_lua_error(__FILE__, __FUNCTION__, __LINE__, L, err_code)
1871
1872Eina_Bool _edje_lua_script_only(Edje *ed);
1873void _edje_lua_script_only_init(Edje *ed);
1874void _edje_lua_script_only_shutdown(Edje *ed);
1875void _edje_lua_script_only_show(Edje *ed);
1876void _edje_lua_script_only_hide(Edje *ed);
1877void _edje_lua_script_only_move(Edje *ed);
1878void _edje_lua_script_only_resize(Edje *ed);
1879void _edje_lua_script_only_message(Edje *ed, Edje_Message *em);
1880
1881void _edje_entry_init(Edje *ed);
1882void _edje_entry_shutdown(Edje *ed);
1883void _edje_entry_real_part_init(Edje_Real_Part *rp);
1884void _edje_entry_real_part_shutdown(Edje_Real_Part *rp);
1885void _edje_entry_real_part_configure(Edje_Real_Part *rp);
1886const char *_edje_entry_selection_get(Edje_Real_Part *rp);
1887const char *_edje_entry_text_get(Edje_Real_Part *rp);
1888void _edje_entry_text_markup_set(Edje_Real_Part *rp, const char *text);
1889void _edje_entry_text_markup_insert(Edje_Real_Part *rp, const char *text);
1890void _edje_entry_text_markup_append(Edje_Real_Part *rp, const char *text);
1891void _edje_entry_set_cursor_start(Edje_Real_Part *rp);
1892void _edje_entry_set_cursor_end(Edje_Real_Part *rp);
1893void _edje_entry_cursor_copy(Edje_Real_Part *rp, Edje_Cursor cur, Edje_Cursor dst);
1894void _edje_entry_select_none(Edje_Real_Part *rp);
1895void _edje_entry_select_all(Edje_Real_Part *rp);
1896void _edje_entry_select_begin(Edje_Real_Part *rp);
1897void _edje_entry_select_extend(Edje_Real_Part *rp);
1898const Eina_List *_edje_entry_anchor_geometry_get(Edje_Real_Part *rp, const char *anchor);
1899const Eina_List *_edje_entry_anchors_list(Edje_Real_Part *rp);
1900Eina_Bool _edje_entry_item_geometry_get(Edje_Real_Part *rp, const char *item, Evas_Coord *cx, Evas_Coord *cy, Evas_Coord *cw, Evas_Coord *ch);
1901const Eina_List *_edje_entry_items_list(Edje_Real_Part *rp);
1902void _edje_entry_cursor_geometry_get(Edje_Real_Part *rp, Evas_Coord *cx, Evas_Coord *cy, Evas_Coord *cw, Evas_Coord *ch);
1903void _edje_entry_select_allow_set(Edje_Real_Part *rp, Eina_Bool allow);
1904Eina_Bool _edje_entry_select_allow_get(const Edje_Real_Part *rp);
1905void _edje_entry_select_abort(Edje_Real_Part *rp);
1906
1907Eina_Bool _edje_entry_cursor_next(Edje_Real_Part *rp, Edje_Cursor cur);
1908Eina_Bool _edje_entry_cursor_prev(Edje_Real_Part *rp, Edje_Cursor cur);
1909Eina_Bool _edje_entry_cursor_up(Edje_Real_Part *rp, Edje_Cursor cur);
1910Eina_Bool _edje_entry_cursor_down(Edje_Real_Part *rp, Edje_Cursor cur);
1911void _edje_entry_cursor_begin(Edje_Real_Part *rp, Edje_Cursor cur);
1912void _edje_entry_cursor_end(Edje_Real_Part *rp, Edje_Cursor cur);
1913void _edje_entry_cursor_line_begin(Edje_Real_Part *rp, Edje_Cursor cur);
1914void _edje_entry_cursor_line_end(Edje_Real_Part *rp, Edje_Cursor cur);
1915Eina_Bool _edje_entry_cursor_coord_set(Edje_Real_Part *rp, Edje_Cursor cur, int x, int y);
1916Eina_Bool _edje_entry_cursor_is_format_get(Edje_Real_Part *rp, Edje_Cursor cur);
1917Eina_Bool _edje_entry_cursor_is_visible_format_get(Edje_Real_Part *rp, Edje_Cursor cur);
1918const char *_edje_entry_cursor_content_get(Edje_Real_Part *rp, Edje_Cursor cur);
1919void _edje_entry_cursor_pos_set(Edje_Real_Part *rp, Edje_Cursor cur, int pos);
1920int _edje_entry_cursor_pos_get(Edje_Real_Part *rp, Edje_Cursor cur);
1921void _edje_entry_input_panel_layout_set(Edje_Real_Part *rp, Edje_Input_Panel_Layout layout);
1922Edje_Input_Panel_Layout _edje_entry_input_panel_layout_get(Edje_Real_Part *rp);
1923void _edje_entry_autocapital_type_set(Edje_Real_Part *rp, Edje_Text_Autocapital_Type autocapital_type);
1924Edje_Text_Autocapital_Type _edje_entry_autocapital_type_get(Edje_Real_Part *rp);
1925void _edje_entry_input_panel_enabled_set(Edje_Real_Part *rp, Eina_Bool enabled);
1926Eina_Bool _edje_entry_input_panel_enabled_get(Edje_Real_Part *rp);
1927
1928void _edje_external_init();
1929void _edje_external_shutdown();
1930Evas_Object *_edje_external_type_add(const char *type_name, Evas *evas, Evas_Object *parent, const Eina_List *params, const char *part_name);
1931void _edje_external_signal_emit(Evas_Object *obj, const char *emission, const char *source);
1932Eina_Bool _edje_external_param_set(Evas_Object *obj, Edje_Real_Part *rp, const Edje_External_Param *param) EINA_ARG_NONNULL(2);
1933Eina_Bool _edje_external_param_get(const Evas_Object *obj, Edje_Real_Part *rp, Edje_External_Param *param) EINA_ARG_NONNULL(2);
1934Evas_Object *_edje_external_content_get(const Evas_Object *obj, const char *content) EINA_ARG_NONNULL(1, 2);
1935void _edje_external_params_free(Eina_List *params, Eina_Bool free_strings);
1936void _edje_external_recalc_apply(Edje *ed, Edje_Real_Part *ep,
1937 Edje_Calc_Params *params,
1938 Edje_Part_Description_Common *chosen_desc);
1939void *_edje_external_params_parse(Evas_Object *obj, const Eina_List *params);
1940void _edje_external_parsed_params_free(Evas_Object *obj, void *params);
1941
1942Eina_Module *_edje_module_handle_load(const char *module);
1943void _edje_module_init();
1944void _edje_module_shutdown();
1945
1946static inline Eina_Bool
1947edje_program_is_strncmp(const char *str)
1948{
1949 size_t length;
1950
1951 length = strlen(str);
1952
1953 if (strpbrk(str, "*?[\\") != str + length)
1954 return EINA_FALSE;
1955 if (str[length] == '['
1956 || str[length] == '\\')
1957 return EINA_FALSE;
1958 return EINA_TRUE;
1959}
1960
1961static inline Eina_Bool
1962edje_program_is_strrncmp(const char *str)
1963{
1964 if (*str != '*' && *str != '?')
1965 return EINA_FALSE;
1966 if (strpbrk(str + 1, "*?[\\"))
1967 return EINA_FALSE;
1968 return EINA_TRUE;
1969}
1970void edje_object_propagate_callback_add(Evas_Object *obj, void (*func) (void *data, Evas_Object *o, const char *emission, const char *source), void *data);
1971
1972
1973/* used by edje_cc - private still */
1974EAPI void _edje_program_insert(Edje_Part_Collection *ed, Edje_Program *p);
1975EAPI void _edje_program_remove(Edje_Part_Collection *ed, Edje_Program *p);
1976
1977void _edje_lua2_error_full(const char *file, const char *fnc, int line, lua_State *L, int err_code);
1978#define _edje_lua2_error(L, err_code) _edje_lua2_error_full(__FILE__, __FUNCTION__, __LINE__, L, err_code)
1979void _edje_lua2_script_init(Edje *ed);
1980void _edje_lua2_script_shutdown(Edje *ed);
1981void _edje_lua2_script_load(Edje_Part_Collection *edc, void *data, int size);
1982void _edje_lua2_script_unload(Edje_Part_Collection *edc);
1983
1984void _edje_lua2_script_func_shutdown(Edje *ed);
1985void _edje_lua2_script_func_show(Edje *ed);
1986void _edje_lua2_script_func_hide(Edje *ed);
1987void _edje_lua2_script_func_move(Edje *ed);
1988void _edje_lua2_script_func_resize(Edje *ed);
1989void _edje_lua2_script_func_message(Edje *ed, Edje_Message *em);
1990void _edje_lua2_script_func_signal(Edje *ed, const char *sig, const char *src);
1991
1992const char *edje_string_get(const Edje_String *es);
1993const char *edje_string_id_get(const Edje_String *es);
1994
1995void _edje_object_orientation_inform(Evas_Object *obj);
1996
1997void _edje_lib_ref(void);
1998void _edje_lib_unref(void);
1999
2000void _edje_subobj_register(Edje *ed, Evas_Object *ob);
2001
2002void _edje_multisense_init(void);
2003void _edje_multisense_shutdown(void);
2004Eina_Bool _edje_multisense_internal_sound_sample_play(Edje *ed, const char *sample_name, const double speed);
2005Eina_Bool _edje_multisense_internal_sound_tone_play(Edje *ed, const char *tone_name, const double duration);
2006
2007void _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *state);
2008
2009#ifdef HAVE_LIBREMIX
2010#include <remix/remix.h>
2011#endif
2012#include <Eina.h>
2013
2014typedef struct _Edje_Multisense_Env Edje_Multisense_Env;
2015
2016struct _Edje_Multisense_Env
2017{
2018#ifdef HAVE_LIBREMIX
2019 RemixEnv *remixenv;
2020#endif
2021};
2022
2023typedef Eina_Bool (*MULTISENSE_FACTORY_INIT_FUNC) (Edje_Multisense_Env *);
2024#ifdef HAVE_LIBREMIX
2025typedef RemixBase* (*MULTISENSE_SOUND_PLAYER_GET_FUNC) (Edje_Multisense_Env *);
2026#endif
2027
2028#endif
diff --git a/libraries/edje/src/lib/edje_program.c b/libraries/edje/src/lib/edje_program.c
new file mode 100644
index 0000000..505b6a2
--- /dev/null
+++ b/libraries/edje/src/lib/edje_program.c
@@ -0,0 +1,2090 @@
1#include "edje_private.h"
2
3static void _edje_emit_cb(Edje *ed, const char *sig, const char *src, Edje_Message_Signal_Data *data, Eina_Bool prop);
4static void _edje_param_copy(Edje_Real_Part *src_part, const char *src_param, Edje_Real_Part *dst_part, const char *dst_param);
5static void _edje_param_set(Edje_Real_Part *part, const char *param, const char *value);
6
7int _edje_anim_count = 0;
8Ecore_Animator *_edje_timer = NULL;
9Eina_List *_edje_animators = NULL;
10
11
12/*============================================================================*
13 * API *
14 *============================================================================*/
15
16EAPI void
17edje_frametime_set(double t)
18{
19 ecore_animator_frametime_set(t);
20}
21
22EAPI double
23edje_frametime_get(void)
24{
25 return ecore_animator_frametime_get();
26}
27
28void
29edje_object_propagate_callback_add(Evas_Object *obj, void (*func) (void *data, Evas_Object *o, const char *emission, const char *source), void *data)
30{
31 Edje *ed;
32 Edje_Signal_Callback *escb;
33
34 ed = _edje_fetch(obj);
35 if (!ed) return;
36 if (ed->delete_me) return;
37 escb = calloc(1, sizeof(Edje_Signal_Callback));
38 escb->propagate = EINA_TRUE;
39 escb->signal = eina_stringshare_add("*");
40 escb->source = eina_stringshare_add("*");
41 escb->func = func;
42 escb->data = data;
43 ed->callbacks = eina_list_append(ed->callbacks, escb);
44 if (ed->walking_callbacks)
45 {
46 escb->just_added = 1;
47 ed->just_added_callbacks = 1;
48 }
49 else
50 _edje_callbacks_patterns_clean(ed);
51}
52
53EAPI void
54edje_object_signal_callback_add(Evas_Object *obj, const char *emission, const char *source, void (*func) (void *data, Evas_Object *o, const char *emission, const char *source), void *data)
55{
56 Edje *ed;
57 Edje_Signal_Callback *escb;
58
59 if ((!emission) || (!source) || (!func)) return;
60 ed = _edje_fetch(obj);
61 if (!ed) return;
62 if (ed->delete_me) return;
63 escb = calloc(1, sizeof(Edje_Signal_Callback));
64 if (emission[0])
65 escb->signal = eina_stringshare_add(emission);
66 if (source[0])
67 escb->source = eina_stringshare_add(source);
68 escb->func = func;
69 escb->data = data;
70 ed->callbacks = eina_list_append(ed->callbacks, escb);
71 if (ed->walking_callbacks)
72 {
73 escb->just_added = 1;
74 ed->just_added_callbacks = 1;
75 }
76 else
77 _edje_callbacks_patterns_clean(ed);
78}
79
80EAPI void *
81edje_object_signal_callback_del(Evas_Object *obj, const char *emission, const char *source, void (*func) (void *data, Evas_Object *o, const char *emission, const char *source))
82{
83 Edje *ed;
84 Eina_List *l;
85 Edje_Signal_Callback *escb;
86
87 if ((!emission) || (!source) || (!func)) return NULL;
88 ed = _edje_fetch(obj);
89 if (!ed) return NULL;
90 if (ed->delete_me) return NULL;
91 EINA_LIST_FOREACH(ed->callbacks, l, escb)
92 {
93 if ((escb->func == func) &&
94 ((!escb->signal && !emission[0]) ||
95 (escb->signal && !strcmp(escb->signal, emission))) &&
96 ((!escb->source && !source[0]) ||
97 (escb->source && !strcmp(escb->source, source))))
98 {
99 void *data;
100
101 data = escb->data;
102 if (ed->walking_callbacks)
103 {
104 escb->delete_me = 1;
105 ed->delete_callbacks = 1;
106 }
107 else
108 {
109 _edje_callbacks_patterns_clean(ed);
110
111 ed->callbacks = eina_list_remove_list(ed->callbacks, l);
112 if (escb->signal) eina_stringshare_del(escb->signal);
113 if (escb->source) eina_stringshare_del(escb->source);
114 free(escb);
115 }
116 return data;
117 }
118 }
119 return NULL;
120}
121
122EAPI void *
123edje_object_signal_callback_del_full(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func, void *data)
124{
125 Edje *ed;
126 Eina_List *l;
127 Edje_Signal_Callback *escb;
128
129 if ((!emission) || (!source) || (!func)) return NULL;
130 ed = _edje_fetch(obj);
131 if (!ed) return NULL;
132 if (ed->delete_me) return NULL;
133 EINA_LIST_FOREACH(ed->callbacks, l, escb)
134 {
135 if ((escb->func == func) && (escb->data == data) &&
136 ((!escb->signal && !emission[0]) ||
137 (escb->signal && !strcmp(escb->signal, emission))) &&
138 ((!escb->source && !source[0]) ||
139 (escb->source && !strcmp(escb->source, source))))
140 {
141 void *data2;
142
143 data2 = escb->data;
144 if (ed->walking_callbacks)
145 {
146 escb->delete_me = 1;
147 ed->delete_callbacks = 1;
148 }
149 else
150 {
151 _edje_callbacks_patterns_clean(ed);
152
153 ed->callbacks = eina_list_remove_list(ed->callbacks, l);
154 if (escb->signal) eina_stringshare_del(escb->signal);
155 if (escb->source) eina_stringshare_del(escb->source);
156 free(escb);
157 }
158 return data2;
159 }
160 }
161 return NULL;
162}
163
164EAPI void
165edje_object_signal_emit(Evas_Object *obj, const char *emission, const char *source)
166{
167 Edje *ed;
168
169 if ((!emission) || (!source)) return;
170 ed = _edje_fetch(obj);
171 if (!ed) return;
172 if (ed->delete_me) return;
173 _edje_emit(ed, (char *)emission, (char *)source);
174}
175
176/* FIXDOC: Verify/Expand */
177EAPI void
178edje_object_play_set(Evas_Object *obj, Eina_Bool play)
179{
180 Edje *ed;
181 double t;
182 Eina_List *l;
183 Edje_Running_Program *runp;
184 unsigned int i;
185
186 ed = _edje_fetch(obj);
187 if (!ed) return;
188 if (ed->delete_me) return;
189 if (play)
190 {
191 if (!ed->paused) return;
192 ed->paused = 0;
193 t = ecore_time_get() - ed->paused_at;
194 EINA_LIST_FOREACH(ed->actions, l, runp)
195 runp->start_time += t;
196 }
197 else
198 {
199 if (ed->paused) return;
200 ed->paused = EINA_TRUE;
201 ed->paused_at = ecore_time_get();
202 }
203
204 for (i = 0; i < ed->table_parts_size; i++)
205 {
206 Edje_Real_Part *rp;
207 rp = ed->table_parts[i];
208 if (rp->part->type == EDJE_PART_TYPE_GROUP && rp->swallowed_object)
209 edje_object_play_set(rp->swallowed_object, play);
210 }
211}
212
213EAPI Eina_Bool
214edje_object_play_get(const Evas_Object *obj)
215{
216 Edje *ed;
217
218 ed = _edje_fetch(obj);
219 if (!ed) return EINA_FALSE;
220 if (ed->delete_me) return EINA_FALSE;
221 if (ed->paused) return EINA_FALSE;
222 return EINA_TRUE;
223}
224
225/* FIXDOC: Verify/Expand */
226EAPI void
227edje_object_animation_set(Evas_Object *obj, Eina_Bool on)
228{
229 Edje *ed;
230 Eina_List *l;
231 unsigned int i;
232
233 ed = _edje_fetch(obj);
234 if (!ed) return;
235 if (ed->delete_me) return;
236 _edje_block(ed);
237 ed->no_anim = !on;
238 _edje_freeze(ed);
239 if (!on)
240 {
241 Eina_List *newl = NULL;
242 const void *data;
243
244 EINA_LIST_FOREACH(ed->actions, l, data)
245 newl = eina_list_append(newl, data);
246 while (newl)
247 {
248 Edje_Running_Program *runp;
249
250 runp = eina_list_data_get(newl);
251 newl = eina_list_remove(newl, eina_list_data_get(newl));
252 _edje_program_run_iterate(runp, runp->start_time + TO_DOUBLE(runp->program->tween.time));
253 if (_edje_block_break(ed))
254 {
255 eina_list_free(newl);
256 goto break_prog;
257 }
258 }
259 }
260 else
261 {
262 _edje_emit(ed, "load", NULL);
263 if (evas_object_visible_get(obj))
264 {
265 evas_object_hide(obj);
266 evas_object_show(obj);
267 }
268 }
269 break_prog:
270
271 for (i = 0; i < ed->table_parts_size; i++)
272 {
273 Edje_Real_Part *rp;
274 rp = ed->table_parts[i];
275 if (rp->part->type == EDJE_PART_TYPE_GROUP && rp->swallowed_object)
276 edje_object_animation_set(rp->swallowed_object, on);
277 }
278
279 _edje_thaw(ed);
280 _edje_unblock(ed);
281}
282
283
284EAPI Eina_Bool
285edje_object_animation_get(const Evas_Object *obj)
286{
287 Edje *ed;
288
289 ed = _edje_fetch(obj);
290 if (!ed) return EINA_FALSE;
291 if (ed->delete_me) return EINA_FALSE;
292 if (ed->no_anim) return EINA_FALSE;
293 return EINA_TRUE;
294}
295
296/* Private Routines */
297
298Eina_Bool
299_edje_program_run_iterate(Edje_Running_Program *runp, double tim)
300{
301 FLOAT_T t, total;
302 Eina_List *l;
303 Edje *ed;
304 Edje_Program_Target *pt;
305 Edje_Real_Part *rp;
306
307 ed = runp->edje;
308 if (ed->delete_me) return EINA_FALSE;
309 _edje_block(ed);
310 _edje_ref(ed);
311 _edje_freeze(ed);
312 t = FROM_DOUBLE(tim - runp->start_time);
313 total = runp->program->tween.time;
314 t = DIV(t, total);
315 if (t > FROM_INT(1)) t = FROM_INT(1);
316 EINA_LIST_FOREACH(runp->program->targets, l, pt)
317 {
318 if (pt->id >= 0)
319 {
320 rp = ed->table_parts[pt->id % ed->table_parts_size];
321 if (rp) _edje_part_pos_set(ed, rp,
322 runp->program->tween.mode, t,
323 runp->program->tween.v1,
324 runp->program->tween.v2);
325 }
326 }
327 if (t >= FROM_INT(1))
328 {
329 Edje_Program_After *pa;
330
331 EINA_LIST_FOREACH(runp->program->targets, l, pt)
332 {
333 if (pt->id >= 0)
334 {
335 rp = ed->table_parts[pt->id % ed->table_parts_size];
336 if (rp)
337 {
338 _edje_part_description_apply(ed, rp,
339 runp->program->state,
340 runp->program->value,
341 NULL,
342 0.0);
343 _edje_part_pos_set(ed, rp,
344 runp->program->tween.mode, ZERO,
345 runp->program->tween.v1,
346 runp->program->tween.v2);
347 rp->program = NULL;
348 }
349 }
350 }
351 _edje_recalc(ed);
352 runp->delete_me = 1;
353 if (!ed->walking_actions)
354 {
355 _edje_anim_count--;
356 ed->actions = eina_list_remove(ed->actions, runp);
357 if (!ed->actions)
358 _edje_animators = eina_list_remove(_edje_animators, ed);
359 }
360// _edje_emit(ed, "program,stop", runp->program->name);
361 if (_edje_block_break(ed))
362 {
363 if (!ed->walking_actions) free(runp);
364 goto break_prog;
365 }
366 EINA_LIST_FOREACH(runp->program->after, l, pa)
367 {
368 Edje_Program *pr;
369
370 if (pa->id >= 0)
371 {
372 pr = ed->table_programs[pa->id % ed->table_programs_size];
373 if (pr) _edje_program_run(ed, pr, 0, "", "");
374 if (_edje_block_break(ed))
375 {
376 if (!ed->walking_actions) free(runp);
377 goto break_prog;
378 }
379 }
380 }
381 _edje_thaw(ed);
382 _edje_unref(ed);
383 if (!ed->walking_actions) free(runp);
384 _edje_unblock(ed);
385 return EINA_FALSE;
386 }
387 break_prog:
388 _edje_recalc(ed);
389 _edje_thaw(ed);
390 _edje_unref(ed);
391 _edje_unblock(ed);
392 return EINA_TRUE;
393}
394
395void
396_edje_program_end(Edje *ed, Edje_Running_Program *runp)
397{
398 Eina_List *l;
399 Edje_Program_Target *pt;
400// const char *pname = NULL;
401 int free_runp = 0;
402
403 if (ed->delete_me) return;
404 _edje_ref(ed);
405 _edje_freeze(ed);
406 EINA_LIST_FOREACH(runp->program->targets, l, pt)
407 {
408 Edje_Real_Part *rp;
409
410 if (pt->id >= 0)
411 {
412 rp = ed->table_parts[pt->id % ed->table_parts_size];
413 if (rp)
414 {
415 _edje_part_description_apply(ed, rp,
416 runp->program->state,
417 runp->program->value,
418 NULL,
419 0.0);
420 _edje_part_pos_set(ed, rp,
421 runp->program->tween.mode, ZERO,
422 runp->program->tween.v1,
423 runp->program->tween.v2);
424 rp->program = NULL;
425 }
426 }
427 }
428 _edje_recalc(ed);
429 runp->delete_me = 1;
430// pname = runp->program->name;
431 if (!ed->walking_actions)
432 {
433 _edje_anim_count--;
434 ed->actions = eina_list_remove(ed->actions, runp);
435 free_runp = 1;
436 if (!ed->actions)
437 {
438 _edje_animators = eina_list_remove(_edje_animators, ed);
439 }
440 }
441// _edje_emit(ed, "program,stop", pname);
442 _edje_thaw(ed);
443 _edje_unref(ed);
444 if (free_runp) free(runp);
445}
446
447void
448_edje_program_run(Edje *ed, Edje_Program *pr, Eina_Bool force, const char *ssig, const char *ssrc)
449{
450 Eina_List *l;
451 Edje_Real_Part *rp;
452 Edje_Program_Target *pt;
453 Edje_Program *pr2;
454 Edje_Program_After *pa;
455 /* limit self-feeding loops in programs to 64 levels */
456 static int recursions = 0;
457 static int recursion_limit = 0;
458
459 if (ed->delete_me) return;
460 if ((pr->in.from > 0.0) && (pr->in.range >= 0.0) && (!force))
461 {
462 Edje_Pending_Program *pp;
463 double r = 0.0;
464
465 pp = calloc(1, sizeof(Edje_Pending_Program));
466 if (!pp) return;
467 if (pr->in.range > 0.0) r = ((double)rand() / RAND_MAX);
468 pp->timer = ecore_timer_add(pr->in.from + (pr->in.range * r),
469 _edje_pending_timer_cb, pp);
470 if (!pp->timer)
471 {
472 free(pp);
473 return;
474 }
475 pp->edje = ed;
476 pp->program = pr;
477 ed->pending_actions = eina_list_append(ed->pending_actions, pp);
478 return;
479 }
480 if ((recursions >= 64) || (recursion_limit))
481 {
482 ERR("Programs recursing up to recursion limit of %i. Disabled.",
483 64);
484 recursion_limit = 1;
485 return;
486 }
487 recursions++;
488 _edje_block(ed);
489 _edje_ref(ed);
490 _edje_freeze(ed);
491 switch (pr->action)
492 {
493 case EDJE_ACTION_TYPE_STATE_SET:
494 if ((pr->tween.time > ZERO) && (!ed->no_anim))
495 {
496 Edje_Running_Program *runp;
497
498 runp = calloc(1, sizeof(Edje_Running_Program));
499 EINA_LIST_FOREACH(pr->targets, l, pt)
500 {
501 if (pt->id >= 0)
502 {
503 rp = ed->table_parts[pt->id % ed->table_parts_size];
504 if (rp)
505 {
506 if ((rp->object) && (pr->tween.mode & EDJE_TWEEN_MODE_OPT_FROM_CURRENT))
507 {
508 Edje_Calc_Params *tmp;
509
510 tmp = calloc(1, sizeof(Edje_Calc_Params));
511 if (!tmp) goto low_mem_current;
512 _edje_part_recalc(ed, rp, FLAG_XY, tmp);
513
514 if (rp->current) free(rp->current);
515 rp->current = tmp;
516
517 rp->current->x -= ed->x;
518 rp->current->y -= ed->y;
519 rp->current->map.center.x -= ed->x;
520 rp->current->map.center.y -= ed->y;
521 rp->current->map.light.x -= ed->x;
522 rp->current->map.light.y -= ed->y;
523 rp->current->map.persp.x -= ed->x;
524 rp->current->map.persp.y -= ed->y;
525 }
526 else
527 {
528 low_mem_current:
529 if (rp->current) free(rp->current);
530 rp->current = NULL;
531 }
532
533 if (rp->program)
534 _edje_program_end(ed, rp->program);
535 _edje_part_description_apply(ed, rp,
536 rp->param1.description->state.name,
537 rp->param1.description->state.value,
538 pr->state,
539 pr->value);
540 _edje_part_pos_set(ed, rp, pr->tween.mode, ZERO,
541 pr->tween.v1,
542 pr->tween.v2);
543 rp->program = runp;
544 }
545 }
546 }
547 // _edje_emit(ed, "program,start", pr->name);
548 if (_edje_block_break(ed))
549 {
550 ed->actions = eina_list_append(ed->actions, runp);
551 goto break_prog;
552 }
553 if (!ed->actions)
554 _edje_animators = eina_list_append(_edje_animators, ed);
555 ed->actions = eina_list_append(ed->actions, runp);
556 runp->start_time = ecore_loop_time_get();
557 runp->edje = ed;
558 runp->program = pr;
559 if (!_edje_timer)
560 _edje_timer = ecore_animator_add(_edje_timer_cb, NULL);
561 _edje_anim_count++;
562 }
563 else
564 {
565 EINA_LIST_FOREACH(pr->targets, l, pt)
566 {
567 if (pt->id >= 0)
568 {
569 rp = ed->table_parts[pt->id % ed->table_parts_size];
570 if (rp)
571 {
572 if (rp->program)
573 _edje_program_end(ed, rp->program);
574 _edje_part_description_apply(ed, rp,
575 pr->state,
576 pr->value,
577 NULL,
578 0.0);
579 _edje_part_pos_set(ed, rp, pr->tween.mode, ZERO,
580 pr->tween.v1,
581 pr->tween.v2);
582 }
583 }
584 }
585 // _edje_emit(ed, "program,start", pr->name);
586 if (_edje_block_break(ed)) goto break_prog;
587 // _edje_emit(ed, "program,stop", pr->name);
588 if (_edje_block_break(ed)) goto break_prog;
589
590 EINA_LIST_FOREACH(pr->after, l, pa)
591 {
592 if (pa->id >= 0)
593 {
594 pr2 = ed->table_programs[pa->id % ed->table_programs_size];
595 if (pr2) _edje_program_run(ed, pr2, 0, "", "");
596 if (_edje_block_break(ed)) goto break_prog;
597 }
598 }
599 _edje_recalc(ed);
600 }
601 break;
602 case EDJE_ACTION_TYPE_ACTION_STOP:
603 // _edje_emit(ed, "program,start", pr->name);
604 EINA_LIST_FOREACH(pr->targets, l, pt)
605 {
606 Eina_List *ll;
607 Edje_Running_Program *runp;
608 Edje_Pending_Program *pp;
609
610 for (ll = ed->actions; ll; )
611 {
612 runp = ll->data;
613 ll = ll->next;
614 if (pt->id == runp->program->id)
615 {
616 _edje_program_end(ed, runp);
617// goto done;
618 }
619 }
620 for (ll = ed->pending_actions; ll; )
621 {
622 pp = ll->data;
623 ll = ll->next;
624 if (pt->id == pp->program->id)
625 {
626 ed->pending_actions = eina_list_remove(ed->pending_actions, pp);
627 ecore_timer_del(pp->timer);
628 free(pp);
629// goto done;
630 }
631 }
632// done:
633// continue;
634 }
635 // _edje_emit(ed, "program,stop", pr->name);
636 if (_edje_block_break(ed)) goto break_prog;
637 break;
638 case EDJE_ACTION_TYPE_SIGNAL_EMIT:
639 // _edje_emit(ed, "program,start", pr->name);
640 if (_edje_block_break(ed)) goto break_prog;
641 _edje_emit(ed, pr->state, pr->state2);
642 if (_edje_block_break(ed)) goto break_prog;
643 // _edje_emit(ed, "program,stop", pr->name);
644 if (_edje_block_break(ed)) goto break_prog;
645 break;
646 case EDJE_ACTION_TYPE_DRAG_VAL_SET:
647 // _edje_emit(ed, "program,start", pr->name);
648 if (_edje_block_break(ed)) goto break_prog;
649 EINA_LIST_FOREACH(pr->targets, l, pt)
650 {
651 if (pt->id >= 0)
652 {
653 rp = ed->table_parts[pt->id % ed->table_parts_size];
654 if ((rp) && (rp->drag) && (rp->drag->down.count == 0))
655 {
656 rp->drag->val.x = pr->value;
657 rp->drag->val.y = pr->value2;
658 if (rp->drag->val.x < 0.0) rp->drag->val.x = 0.0;
659 else if (rp->drag->val.x > 1.0) rp->drag->val.x = 1.0;
660 if (rp->drag->val.y < 0.0) rp->drag->val.y = 0.0;
661 else if (rp->drag->val.y > 1.0) rp->drag->val.y = 1.0;
662 _edje_dragable_pos_set(ed, rp, rp->drag->val.x, rp->drag->val.y);
663 _edje_emit(ed, "drag,set", rp->part->name);
664 if (_edje_block_break(ed)) goto break_prog;
665 }
666 }
667 }
668 // _edje_emit(ed, "program,stop", pr->name);
669 if (_edje_block_break(ed)) goto break_prog;
670 break;
671 case EDJE_ACTION_TYPE_DRAG_VAL_STEP:
672 // _edje_emit(ed, "program,start", pr->name);
673 if (_edje_block_break(ed)) goto break_prog;
674 EINA_LIST_FOREACH(pr->targets, l, pt)
675 {
676 if (pt->id >= 0)
677 {
678 rp = ed->table_parts[pt->id % ed->table_parts_size];
679 if ((rp) && (rp->drag) && (rp->drag->down.count == 0))
680 {
681 rp->drag->val.x += pr->value * rp->drag->step.x * rp->part->dragable.x;
682 rp->drag->val.y += pr->value2 * rp->drag->step.y * rp->part->dragable.y;
683 if (rp->drag->val.x < 0.0) rp->drag->val.x = 0.0;
684 else if (rp->drag->val.x > 1.0) rp->drag->val.x = 1.0;
685 if (rp->drag->val.y < 0.0) rp->drag->val.y = 0.0;
686 else if (rp->drag->val.y > 1.0) rp->drag->val.y = 1.0;
687 _edje_dragable_pos_set(ed, rp, rp->drag->val.x, rp->drag->val.y);
688 _edje_emit(ed, "drag,step", rp->part->name);
689 if (_edje_block_break(ed)) goto break_prog;
690 }
691 }
692 }
693 // _edje_emit(ed, "program,stop", pr->name);
694 if (_edje_block_break(ed)) goto break_prog;
695 break;
696 case EDJE_ACTION_TYPE_DRAG_VAL_PAGE:
697 // _edje_emit(ed, "program,start", pr->name);
698 if (_edje_block_break(ed)) goto break_prog;
699 EINA_LIST_FOREACH(pr->targets, l, pt)
700 {
701 if (pt->id >= 0)
702 {
703 rp = ed->table_parts[pt->id % ed->table_parts_size];
704 if ((rp) && (rp->drag) && (rp->drag->down.count == 0))
705 {
706 rp->drag->val.x += pr->value * rp->drag->page.x * rp->part->dragable.x;
707 rp->drag->val.y += pr->value2 * rp->drag->page.y * rp->part->dragable.y;
708 if (rp->drag->val.x < 0.0) rp->drag->val.x = 0.0;
709 else if (rp->drag->val.x > 1.0) rp->drag->val.x = 1.0;
710 if (rp->drag->val.y < 0.0) rp->drag->val.y = 0.0;
711 else if (rp->drag->val.y > 1.0) rp->drag->val.y = 1.0;
712 _edje_dragable_pos_set(ed, rp, rp->drag->val.x, rp->drag->val.y);
713 _edje_emit(ed, "drag,page", rp->part->name);
714 if (_edje_block_break(ed)) goto break_prog;
715 }
716 }
717 }
718 // _edje_emit(ed, "program,stop", pr->name);
719 if (_edje_block_break(ed)) goto break_prog;
720 break;
721 case EDJE_ACTION_TYPE_SCRIPT:
722 {
723 char fname[128];
724
725 // _edje_emit(ed, "program,start", pr->name);
726 if (_edje_block_break(ed)) goto break_prog;
727 snprintf(fname, sizeof(fname), "_p%i", pr->id);
728 _edje_embryo_test_run(ed, fname, ssig, ssrc);
729 // _edje_emit(ed, "program,stop", pr->name);
730 if (_edje_block_break(ed)) goto break_prog;
731 _edje_recalc_do(ed);
732 }
733 break;
734 case EDJE_ACTION_TYPE_FOCUS_SET:
735 if (!pr->targets)
736 ed->focused_part = NULL;
737 else
738 {
739 EINA_LIST_FOREACH(pr->targets, l, pt)
740 {
741 if (pt->id >= 0)
742 {
743 rp = ed->table_parts[pt->id % ed->table_parts_size];
744 if (rp)
745 {
746 if (ed->focused_part != rp)
747 {
748 if (ed->focused_part)
749 _edje_emit(ed, "focus,part,out",
750 ed->focused_part->part->name);
751 ed->focused_part = rp;
752 _edje_emit(ed, "focus,part,in",
753 ed->focused_part->part->name);
754 }
755 }
756 }
757 }
758 }
759 break;
760 case EDJE_ACTION_TYPE_FOCUS_OBJECT:
761 if (!pr->targets)
762 {
763 Evas_Object *focused;
764
765 focused = evas_focus_get(evas_object_evas_get(ed->obj));
766 if (focused)
767 {
768 unsigned int i;
769
770 /* Check if the current swallowed object is one of my child. */
771 for (i = 0; i < ed->table_parts_size; ++i)
772 {
773 rp = ed->table_parts[i];
774 if (rp && rp->swallowed_object == focused)
775 {
776 evas_object_focus_set(focused, EINA_FALSE);
777 break;
778 }
779 }
780 }
781 }
782 else
783 {
784 EINA_LIST_FOREACH(pr->targets, l, pt)
785 {
786 if (pt->id >= 0)
787 {
788 rp = ed->table_parts[pt->id % ed->table_parts_size];
789 if (rp && rp->swallowed_object)
790 evas_object_focus_set(rp->swallowed_object, EINA_TRUE);
791 }
792 }
793 }
794 break;
795 case EDJE_ACTION_TYPE_SOUND_SAMPLE:
796 if (_edje_block_break(ed))
797 goto break_prog;
798 _edje_multisense_internal_sound_sample_play(ed, pr->sample_name, pr->speed);
799 break;
800 case EDJE_ACTION_TYPE_SOUND_TONE:
801 if (_edje_block_break(ed))
802 goto break_prog;
803 _edje_multisense_internal_sound_tone_play(ed, pr->tone_name, pr->duration);
804 break;
805 case EDJE_ACTION_TYPE_PARAM_COPY:
806 {
807 Edje_Real_Part *src_part, *dst_part;
808
809 // _edje_emit(ed, "program,start", pr->name);
810 if (_edje_block_break(ed)) goto break_prog;
811
812 src_part = ed->table_parts[pr->param.src % ed->table_parts_size];
813 dst_part = ed->table_parts[pr->param.dst % ed->table_parts_size];
814 _edje_param_copy(src_part, pr->state, dst_part, pr->state2);
815
816 if (_edje_block_break(ed)) goto break_prog;
817 // _edje_emit(ed, "program,stop", pr->name);
818 if (_edje_block_break(ed)) goto break_prog;
819 }
820 break;
821 case EDJE_ACTION_TYPE_PARAM_SET:
822 {
823 Edje_Real_Part *part;
824
825 // _edje_emit(ed, "program,start", pr->name);
826 if (_edje_block_break(ed)) goto break_prog;
827
828 part = ed->table_parts[pr->param.dst % ed->table_parts_size];
829 _edje_param_set(part, pr->state, pr->state2);
830
831 if (_edje_block_break(ed)) goto break_prog;
832 // _edje_emit(ed, "program,stop", pr->name);
833 if (_edje_block_break(ed)) goto break_prog;
834 }
835 break;
836 default:
837 // _edje_emit(ed, "program,start", pr->name);
838 // _edje_emit(ed, "program,stop", pr->name);
839 break;
840 }
841 if (!((pr->action == EDJE_ACTION_TYPE_STATE_SET)
842 /* hmm this fucks somethgin up. must look into it later */
843 /* && (pr->tween.time > ZERO) && (!ed->no_anim))) */
844 ))
845 {
846 EINA_LIST_FOREACH(pr->after, l, pa)
847 {
848 if (pa->id >= 0)
849 {
850 pr2 = ed->table_programs[pa->id % ed->table_programs_size];
851 if (pr2) _edje_program_run(ed, pr2, 0, "", "");
852 if (_edje_block_break(ed)) goto break_prog;
853 }
854 }
855 }
856 break_prog:
857 _edje_thaw(ed);
858 _edje_unref(ed);
859 recursions--;
860 if (recursions == 0) recursion_limit = 0;
861 _edje_unblock(ed);
862}
863
864void
865_edje_emit(Edje *ed, const char *sig, const char *src)
866{
867 _edje_emit_full(ed, sig, src, NULL, NULL);
868}
869
870/* data should either be NULL or a malloc allocated data */
871void
872_edje_emit_full(Edje *ed, const char *sig, const char *src, void *data, void (*free_func)(void *))
873{
874 Edje_Message_Signal emsg;
875 const char *sep;
876
877 if (ed->delete_me) return;
878
879 sep = strchr(sig, EDJE_PART_PATH_SEPARATOR);
880
881 /* If we are not sending the signal to a part of the child, the
882 * signal if for ourself
883 */
884 if (sep)
885 {
886 Edje_Real_Part *rp = NULL;
887 const char *newsig;
888 Edje *ed2;
889 char *part;
890 char *idx;
891 size_t length;
892
893 /* the signal contains a colon, split the signal into "parts:signal" */
894 length = sep - sig + 1;
895 part = alloca(length);
896 memcpy(part, sig, length - 1);
897 part[length - 1] = '\0';
898
899 newsig = sep + 1;
900
901 /* lookup for alias */
902 if (ed->collection && ed->collection->alias)
903 {
904 char *alias;
905
906 alias = eina_hash_find(ed->collection->alias, part);
907 if (alias) {
908 char *aliased;
909 int alien;
910 int nslen;
911
912 alien = strlen(alias);
913 nslen = strlen(newsig);
914 length = alien + nslen + 2;
915
916 aliased = alloca(length);
917 memcpy(aliased, alias, alien);
918 aliased[alien] = EDJE_PART_PATH_SEPARATOR;
919 memcpy(aliased + alien + 1, newsig, nslen + 1);
920
921 _edje_emit(ed, aliased, src);
922 return;
923 }
924 }
925
926 /* search for the index if present and remove it from the part */
927 idx = strchr(part, EDJE_PART_PATH_SEPARATOR_INDEXL);
928 if (idx)
929 {
930 char *end;
931
932 end = strchr(idx + 1, EDJE_PART_PATH_SEPARATOR_INDEXR);
933 if (end && end != idx + 1)
934 {
935 char *tmp;
936
937 tmp = alloca(end - idx - 1);
938 memcpy(tmp, idx + 1, end - idx - 1);
939 tmp[end - idx - 1] = '\0';
940 *idx = '\0';
941 idx = tmp;
942 }
943 else
944 {
945 idx = NULL;
946 }
947 }
948
949 /* search for the right part now */
950 rp = _edje_real_part_get(ed, part);
951 if (!rp) goto end;
952
953 switch (rp->part->type)
954 {
955 case EDJE_PART_TYPE_GROUP:
956 if (!rp->swallowed_object) goto end;
957 ed2 = _edje_fetch(rp->swallowed_object);
958 if (!ed2) goto end;
959
960 _edje_emit(ed2, newsig, src);
961 break;
962
963 case EDJE_PART_TYPE_EXTERNAL:
964 if (!rp->swallowed_object) break ;
965
966 if (!idx)
967 {
968 _edje_external_signal_emit(rp->swallowed_object, newsig, src);
969 }
970 else
971 {
972 Evas_Object *child;
973
974 child = _edje_children_get(rp, idx);
975 ed2 = _edje_fetch(child);
976 if (!ed2) goto end;
977 _edje_emit(ed2, newsig, src);
978 }
979 break ;
980
981 case EDJE_PART_TYPE_BOX:
982 case EDJE_PART_TYPE_TABLE:
983 if (idx)
984 {
985 Evas_Object *child;
986
987 child = _edje_children_get(rp, idx);
988 ed2 = _edje_fetch(child);
989 if (!ed2) goto end;
990 _edje_emit(ed2, newsig, src);
991 }
992 break ;
993
994 default:
995 fprintf(stderr, "SPANK SPANK SPANK !!!\nYou should never be here !\n");
996 break;
997 }
998 }
999
1000 end:
1001 emsg.sig = sig;
1002 emsg.src = src;
1003 if (data)
1004 {
1005 emsg.data = calloc(1, sizeof(*(emsg.data)));
1006 emsg.data->ref = 1;
1007 emsg.data->data = data;
1008 emsg.data->free_func = free_func;
1009 }
1010 else
1011 {
1012 emsg.data = NULL;
1013 }
1014/* new sends code */
1015 edje_object_message_send(ed->obj, EDJE_MESSAGE_SIGNAL, 0, &emsg);
1016/* old send code - use api now
1017 _edje_message_send(ed, EDJE_QUEUE_SCRIPT, EDJE_MESSAGE_SIGNAL, 0, &emsg);
1018 EINA_LIST_FOREACH(ed->subobjs, l, obj)
1019 {
1020 Edje *ed2;
1021
1022 ed2 = _edje_fetch(obj);
1023 if (!ed2) continue;
1024 if (ed2->delete_me) continue;
1025 _edje_message_send(ed2, EDJE_QUEUE_SCRIPT, EDJE_MESSAGE_SIGNAL, 0, &emsg);
1026 }
1027 */
1028 if (emsg.data && (--(emsg.data->ref) == 0))
1029 {
1030 if (emsg.data->free_func)
1031 {
1032 emsg.data->free_func(emsg.data->data);
1033 }
1034 free(emsg.data);
1035 }
1036}
1037
1038struct _Edje_Program_Data
1039{
1040#ifdef EDJE_PROGRAM_CACHE
1041 Eina_List *matches;
1042 int matched;
1043#endif
1044 Edje *ed;
1045 const char *signal;
1046 const char *source;
1047};
1048
1049static Eina_Bool _edje_glob_callback(Edje_Program *pr, void *dt)
1050{
1051 struct _Edje_Program_Data *data = dt;
1052 Edje_Real_Part *rp = NULL;
1053 Eina_Bool exec = EINA_TRUE;
1054
1055 if (pr->filter.state)
1056 {
1057 rp = _edje_real_part_get(data->ed, pr->filter.part ? pr->filter.part : data->source);
1058 if (rp)
1059 exec = (rp->chosen_description->state.name == pr->filter.state);
1060 }
1061
1062#ifdef EDJE_PROGRAM_CACHE
1063 data->matched++;
1064#endif
1065
1066 if (exec)
1067 _edje_program_run(data->ed, pr, 0, data->signal, data->source);
1068
1069 if (_edje_block_break(data->ed))
1070 {
1071#ifdef EDJE_PROGRAM_CACHE
1072 eina_list_free(data->matches);
1073 data->matches = NULL;
1074#endif
1075 return EINA_TRUE;
1076 }
1077
1078#ifdef EDJE_PROGRAM_CACHE
1079 data->matches = eina_list_append(data->matches, pr);
1080#endif
1081
1082 return EINA_FALSE;
1083}
1084
1085
1086void
1087_edje_callbacks_patterns_clean(Edje *ed)
1088{
1089 _edje_signals_sources_patterns_clean(&ed->patterns.callbacks);
1090
1091 eina_rbtree_delete(ed->patterns.callbacks.exact_match,
1092 EINA_RBTREE_FREE_CB(edje_match_signal_source_free),
1093 NULL);
1094 ed->patterns.callbacks.exact_match = NULL;
1095
1096 ed->patterns.callbacks.u.callbacks.globing = eina_list_free(ed->patterns.callbacks.u.callbacks.globing);
1097}
1098
1099static void
1100_edje_callbacks_patterns_init(Edje *ed)
1101{
1102 Edje_Signals_Sources_Patterns *ssp = &ed->patterns.callbacks;
1103
1104 if ((ssp->signals_patterns) || (ssp->sources_patterns) ||
1105 (ssp->u.callbacks.globing) || (ssp->exact_match))
1106 return;
1107
1108 ssp->u.callbacks.globing = edje_match_callback_hash_build(ed->callbacks,
1109 &ssp->exact_match);
1110
1111 ssp->signals_patterns = edje_match_callback_signal_init(ssp->u.callbacks.globing);
1112 ssp->sources_patterns = edje_match_callback_source_init(ssp->u.callbacks.globing);
1113}
1114
1115/* FIXME: what if we delete the evas object??? */
1116void
1117_edje_emit_handle(Edje *ed, const char *sig, const char *src,
1118 Edje_Message_Signal_Data *sdata, Eina_Bool prop)
1119{
1120 if (ed->delete_me) return;
1121 if (!sig) sig = "";
1122 if (!src) src = "";
1123// printf("EDJE EMIT: (%p) signal: \"%s\" source: \"%s\"\n", ed, sig, src);
1124 _edje_block(ed);
1125 _edje_ref(ed);
1126 _edje_freeze(ed);
1127
1128 if (ed->collection && ed->L)
1129 _edje_lua2_script_func_signal(ed, sig, src);
1130
1131 if (ed->collection)
1132 {
1133#ifdef EDJE_PROGRAM_CACHE
1134 Edje_Part_Collection *ec;
1135 char *tmps;
1136 int l1, l2;
1137#endif
1138 int done;
1139
1140#ifdef EDJE_PROGRAM_CACHE
1141 ec = ed->collection;
1142 l1 = strlen(sig);
1143 l2 = strlen(src);
1144 tmps = alloca(l1 + l2 + 3); /* \0, \337, \0 */
1145 strcpy(tmps, sig);
1146 tmps[l1] = '\377';
1147 strcpy(&(tmps[l1 + 1]), src);
1148#endif
1149 done = 0;
1150
1151#ifdef EDJE_PROGRAM_CACHE
1152 {
1153 Eina_List *matches;
1154 Eina_List *l;
1155 Edje_Program *pr;
1156
1157 if (eina_hash_find(ec->prog_cache.no_matches, tmps))
1158 {
1159 done = 1;
1160 }
1161 else if ((matches = eina_hash_find(ec->prog_cache.matches, tmps)))
1162 {
1163 EINA_LIST_FOREACH(matches, l, pr)
1164 {
1165 Eina_Bool exec = EINA_TRUE;
1166
1167 if (pr->filter.state)
1168 {
1169 Edje_Real_Part *rp;
1170
1171 rp = _edje_real_part_get(ed, pr->filter.part ? pr->filter.part : src);
1172 if (rp)
1173 exec = (rp->chosen_description->state.name == pr->filter.state);
1174 }
1175
1176 if (exec)
1177 {
1178 _edje_program_run(ed, pr, 0, sig, src);
1179 if (_edje_block_break(ed))
1180 {
1181 goto break_prog;
1182 }
1183 }
1184 }
1185 done = 1;
1186 }
1187 }
1188#endif
1189 if (!done)
1190 {
1191 struct _Edje_Program_Data data;
1192
1193 data.ed = ed;
1194 data.source = src;
1195 data.signal = sig;
1196#ifdef EDJE_PROGRAM_CACHE
1197 data.matched = 0;
1198 data.matches = NULL;
1199#endif
1200 if (ed->table_programs_size > 0)
1201 {
1202 const Eina_List *match;
1203 const Eina_List *l;
1204 Edje_Program *pr;
1205
1206 if (ed->patterns.programs.u.programs.globing)
1207 if (edje_match_programs_exec(ed->patterns.programs.signals_patterns,
1208 ed->patterns.programs.sources_patterns,
1209 sig,
1210 src,
1211 ed->patterns.programs.u.programs.globing,
1212 _edje_glob_callback,
1213 &data,
1214 prop) == 0)
1215 goto break_prog;
1216
1217 match = edje_match_signal_source_hash_get(sig, src,
1218 ed->patterns.programs.exact_match);
1219 EINA_LIST_FOREACH(match, l, pr)
1220 _edje_glob_callback(pr, &data);
1221 }
1222
1223#ifdef EDJE_PROGRAM_CACHE
1224 if (tmps)
1225 {
1226 if (data.matched == 0)
1227 {
1228 if (!ec->prog_cache.no_matches)
1229 ec->prog_cache.no_matches = eina_hash_string_superfast_new(NULL);
1230 eina_hash_add(ec->prog_cache.no_matches, tmps, ed);
1231 }
1232 else
1233 {
1234 if (!ec->prog_cache.matches)
1235 ec->prog_cache.matches = eina_hash_string_superfast_new(NULL);
1236 eina_hash_add(ec->prog_cache.matches, tmps, data.matches);
1237 }
1238 }
1239#endif
1240 }
1241 _edje_emit_cb(ed, sig, src, sdata, prop);
1242 if (_edje_block_break(ed))
1243 {
1244 goto break_prog;
1245 }
1246 }
1247 break_prog:
1248 _edje_thaw(ed);
1249 _edje_unref(ed);
1250 _edje_unblock(ed);
1251}
1252
1253/* Extra data for callbacks */
1254static void *callback_extra_data = NULL;
1255
1256EAPI void *
1257edje_object_signal_callback_extra_data_get(void)
1258{
1259 return callback_extra_data;
1260}
1261
1262/* FIXME: what if we delete the evas object??? */
1263static void
1264_edje_emit_cb(Edje *ed, const char *sig, const char *src, Edje_Message_Signal_Data *data, Eina_Bool prop)
1265{
1266 Eina_List *l;
1267
1268 if (ed->delete_me) return;
1269 _edje_ref(ed);
1270 _edje_freeze(ed);
1271 _edje_block(ed);
1272
1273 if (ed->just_added_callbacks)
1274 _edje_callbacks_patterns_clean(ed);
1275
1276 ed->walking_callbacks = 1;
1277
1278 if (ed->callbacks)
1279 {
1280 Edje_Signal_Callback *escb;
1281 const Eina_List *match;
1282 const Eina_List *l2;
1283 int r = 1;
1284 callback_extra_data = (data) ? data->data : NULL;
1285
1286 _edje_callbacks_patterns_init(ed);
1287 if (ed->patterns.callbacks.u.callbacks.globing)
1288 r = edje_match_callback_exec(ed->patterns.callbacks.signals_patterns,
1289 ed->patterns.callbacks.sources_patterns,
1290 sig,
1291 src,
1292 ed->patterns.callbacks.u.callbacks.globing,
1293 ed,
1294 prop);
1295
1296 if (!r)
1297 goto break_prog;
1298
1299 match = edje_match_signal_source_hash_get(sig, src,
1300 ed->patterns.callbacks.exact_match);
1301 EINA_LIST_FOREACH(match, l2, escb)
1302 {
1303 if ((prop) && (escb->propagate)) continue;
1304 if ((!escb->just_added) && (!escb->delete_me))
1305 {
1306 escb->func(escb->data, ed->obj, sig, src);
1307 if (_edje_block_break(ed))
1308 goto break_prog;
1309 }
1310 }
1311 }
1312 break_prog:
1313
1314 ed->walking_callbacks = 0;
1315 if ((ed->delete_callbacks) || (ed->just_added_callbacks))
1316 {
1317 ed->delete_callbacks = 0;
1318 ed->just_added_callbacks = 0;
1319 l = ed->callbacks;
1320 while (l)
1321 {
1322 Edje_Signal_Callback *escb = l->data;
1323 Eina_List *next_l = l->next;
1324
1325 if (escb->just_added)
1326 escb->just_added = 0;
1327 if (escb->delete_me)
1328 {
1329 ed->callbacks = eina_list_remove_list(ed->callbacks, l);
1330 if (escb->signal) eina_stringshare_del(escb->signal);
1331 if (escb->source) eina_stringshare_del(escb->source);
1332 free(escb);
1333 }
1334 l = next_l;
1335 }
1336
1337 _edje_callbacks_patterns_clean(ed);
1338 }
1339 _edje_unblock(ed);
1340 _edje_thaw(ed);
1341 _edje_unref(ed);
1342}
1343
1344static const Edje_External_Param_Info *
1345_edje_external_param_info_get(const Evas_Object *obj, const char *name)
1346{
1347 const Edje_External_Type *type;
1348 const Edje_External_Param_Info *info;
1349
1350 type = evas_object_data_get(obj, "Edje_External_Type");
1351 if (!type) return NULL;
1352 for (info = type->parameters_info; info->name; info++)
1353 if (!strcmp(info->name, name)) return info;
1354
1355 return NULL;
1356}
1357
1358static Edje_External_Param *
1359_edje_param_external_get(Edje_Real_Part *rp, const char *name, Edje_External_Param *param)
1360{
1361 Evas_Object *swallowed_object = rp->swallowed_object;
1362 const Edje_External_Param_Info *info;
1363
1364 info = _edje_external_param_info_get(swallowed_object, name);
1365 if (!info) return NULL;
1366
1367 memset(param, 0, sizeof(*param));
1368 param->name = info->name;
1369 param->type = info->type;
1370 if (!_edje_external_param_get(NULL, rp, param)) return NULL;
1371 return param;
1372}
1373
1374/* simulate external properties for native objects */
1375static Edje_External_Param *
1376_edje_param_native_get(Edje_Real_Part *rp, const char *name, Edje_External_Param *param, void **free_ptr)
1377{
1378 *free_ptr = NULL;
1379 if ((rp->part->type == EDJE_PART_TYPE_TEXT) ||
1380 (rp->part->type == EDJE_PART_TYPE_TEXTBLOCK))
1381 {
1382 if (!strcmp(name, "text"))
1383 {
1384 param->name = name;
1385 param->type = EDJE_EXTERNAL_PARAM_TYPE_STRING;
1386
1387 _edje_recalc_do(rp->edje);
1388 if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
1389 param->s = _edje_entry_text_get(rp);
1390 else if (rp->part->type == EDJE_PART_TYPE_TEXT)
1391 param->s = rp->text.text;
1392 else
1393 param->s = evas_object_textblock_text_markup_get(rp->object);
1394 return param;
1395 }
1396 if (rp->part->type == EDJE_PART_TYPE_TEXTBLOCK)
1397 {
1398 if (!strcmp(name, "text_unescaped"))
1399 {
1400 param->name = name;
1401 param->type = EDJE_EXTERNAL_PARAM_TYPE_STRING;
1402
1403 _edje_recalc_do(rp->edje);
1404 if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
1405 {
1406 const char *tmp = _edje_entry_text_get(rp);
1407 char *unescaped = _edje_text_unescape(tmp);
1408 *free_ptr = unescaped;
1409 param->s = unescaped;
1410 }
1411 else if (rp->part->type == EDJE_PART_TYPE_TEXT)
1412 param->s = rp->text.text;
1413 else
1414 {
1415 const char *tmp;
1416 char *unescaped;
1417
1418 tmp = evas_object_textblock_text_markup_get(rp->object);
1419 unescaped = _edje_text_unescape(tmp);
1420 *free_ptr = unescaped;
1421 param->s = unescaped;
1422 }
1423
1424 return param;
1425 }
1426
1427 if ((rp->entry_data) &&
1428 (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) &&
1429 (!strcmp(name, "select_allow")))
1430 {
1431 param->name = name;
1432 param->type = EDJE_EXTERNAL_PARAM_TYPE_BOOL;
1433 param->i = _edje_entry_select_allow_get(rp);
1434 return param;
1435 }
1436 }
1437 }
1438
1439 if ((rp->drag) && (rp->drag->down.count == 0))
1440 {
1441 if (!strncmp(name, "drag_", sizeof("drag_") - 1))
1442 {
1443 const char *sub_name = name + sizeof("drag_") - 1;
1444 if (!strcmp(sub_name, "value_x"))
1445 {
1446 double d;
1447
1448 _edje_recalc_do(rp->edje);
1449 d = TO_DOUBLE(rp->drag->val.x);
1450 if (rp->part->dragable.x < 0) d = 1.0 - d;
1451 param->name = name;
1452 param->type = EDJE_EXTERNAL_PARAM_TYPE_DOUBLE;
1453 param->d = d;
1454 return param;
1455 }
1456 if (!strcmp(sub_name, "value_y"))
1457 {
1458 double d;
1459
1460 _edje_recalc_do(rp->edje);
1461 d = TO_DOUBLE(rp->drag->val.y);
1462 if (rp->part->dragable.y < 0) d = 1.0 - d;
1463 param->name = name;
1464 param->type = EDJE_EXTERNAL_PARAM_TYPE_DOUBLE;
1465 param->d = d;
1466 return param;
1467 }
1468
1469 if (!strcmp(sub_name, "size_w"))
1470 {
1471 _edje_recalc_do(rp->edje);
1472 param->name = name;
1473 param->type = EDJE_EXTERNAL_PARAM_TYPE_DOUBLE;
1474 param->d = TO_DOUBLE(rp->drag->size.x);
1475 return param;
1476 }
1477 if (!strcmp(sub_name, "size_h"))
1478 {
1479 _edje_recalc_do(rp->edje);
1480 param->name = name;
1481 param->type = EDJE_EXTERNAL_PARAM_TYPE_DOUBLE;
1482 param->d = TO_DOUBLE(rp->drag->size.y);
1483 return param;
1484 }
1485
1486 if (!strcmp(sub_name, "step_x"))
1487 {
1488 _edje_recalc_do(rp->edje);
1489 param->name = name;
1490 param->type = EDJE_EXTERNAL_PARAM_TYPE_DOUBLE;
1491 param->d = TO_DOUBLE(rp->drag->step.x);
1492 return param;
1493 }
1494 if (!strcmp(sub_name, "step_y"))
1495 {
1496 _edje_recalc_do(rp->edje);
1497 param->name = name;
1498 param->type = EDJE_EXTERNAL_PARAM_TYPE_DOUBLE;
1499 param->d = TO_DOUBLE(rp->drag->step.y);
1500 return param;
1501 }
1502
1503 if (!strcmp(sub_name, "page_x"))
1504 {
1505 _edje_recalc_do(rp->edje);
1506 param->name = name;
1507 param->type = EDJE_EXTERNAL_PARAM_TYPE_DOUBLE;
1508 param->d = TO_DOUBLE(rp->drag->page.x);
1509 return param;
1510 }
1511 if (!strcmp(sub_name, "page_y"))
1512 {
1513 _edje_recalc_do(rp->edje);
1514 param->name = name;
1515 param->type = EDJE_EXTERNAL_PARAM_TYPE_DOUBLE;
1516 param->d = TO_DOUBLE(rp->drag->page.y);
1517 return param;
1518 }
1519
1520 return NULL;
1521 }
1522 }
1523
1524 return NULL;
1525}
1526
1527static Eina_Bool
1528_edje_param_native_set(Edje_Real_Part *rp, const char *name, const Edje_External_Param *param)
1529{
1530 if ((rp->part->type == EDJE_PART_TYPE_TEXT) ||
1531 (rp->part->type == EDJE_PART_TYPE_TEXTBLOCK))
1532 {
1533 if (!strcmp(name, "text"))
1534 {
1535 if (param->type != EDJE_EXTERNAL_PARAM_TYPE_STRING)
1536 return EINA_FALSE;
1537
1538 _edje_object_part_text_raw_set
1539 (rp->edje->obj, rp, rp->part->name, param->s);
1540 return EINA_TRUE;
1541 }
1542 if (rp->part->type == EDJE_PART_TYPE_TEXTBLOCK)
1543 {
1544 if (!strcmp(name, "text_unescaped"))
1545 {
1546 if (param->type != EDJE_EXTERNAL_PARAM_TYPE_STRING)
1547 return EINA_FALSE;
1548
1549 if (rp->part->type == EDJE_PART_TYPE_TEXT)
1550 _edje_object_part_text_raw_set
1551 (rp->edje->obj, rp, rp->part->name, param->s);
1552 else
1553 {
1554 char *escaped = _edje_text_escape(param->s);
1555 _edje_object_part_text_raw_set
1556 (rp->edje->obj, rp, rp->part->name, escaped);
1557 free(escaped);
1558 }
1559
1560 return EINA_TRUE;
1561 }
1562
1563 if ((rp->entry_data) &&
1564 (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) &&
1565 (!strcmp(name, "select_allow")))
1566 {
1567 if (param->type != EDJE_EXTERNAL_PARAM_TYPE_BOOL)
1568 return EINA_FALSE;
1569 _edje_entry_select_allow_set(rp, param->i);
1570 return EINA_TRUE;
1571 }
1572 }
1573 }
1574
1575 if ((rp->drag) && (rp->drag->down.count == 0))
1576 {
1577 if (!strncmp(name, "drag_", sizeof("drag_") - 1))
1578 {
1579 const char *sub_name = name + sizeof("drag_") - 1;
1580 if (!strcmp(sub_name, "value_x"))
1581 {
1582 double d;
1583 if (param->type != EDJE_EXTERNAL_PARAM_TYPE_DOUBLE)
1584 return EINA_FALSE;
1585 d = param->d;
1586 if (rp->part->dragable.confine_id != -1)
1587 d = CLAMP(d, 0.0, 1.0);
1588 if (rp->part->dragable.x < 0) d = 1.0 - d;
1589 if (rp->drag->val.x == FROM_DOUBLE(d)) return EINA_TRUE;
1590 rp->drag->val.x = FROM_DOUBLE(d);
1591#ifdef EDJE_CALC_CACHE
1592 rp->invalidate = 1;
1593#endif
1594 _edje_dragable_pos_set
1595 (rp->edje, rp, rp->drag->val.x, rp->drag->val.y);
1596 _edje_emit(rp->edje, "drag,set", rp->part->name);
1597 return EINA_TRUE;
1598 }
1599 if (!strcmp(sub_name, "value_y"))
1600 {
1601 double d;
1602 if (param->type != EDJE_EXTERNAL_PARAM_TYPE_DOUBLE)
1603 return EINA_FALSE;
1604 d = param->d;
1605 if (rp->part->dragable.confine_id != -1)
1606 d = CLAMP(d, 0.0, 1.0);
1607 if (rp->part->dragable.y < 0) d = 1.0 - d;
1608 if (rp->drag->val.y == FROM_DOUBLE(d)) return EINA_TRUE;
1609 rp->drag->val.y = FROM_DOUBLE(d);
1610#ifdef EDJE_CALC_CACHE
1611 rp->invalidate = 1;
1612#endif
1613 _edje_dragable_pos_set
1614 (rp->edje, rp, rp->drag->val.x, rp->drag->val.y);
1615 _edje_emit(rp->edje, "drag,set", rp->part->name);
1616 return EINA_TRUE;
1617 }
1618
1619 if (!strcmp(sub_name, "size_w"))
1620 {
1621 if (param->type != EDJE_EXTERNAL_PARAM_TYPE_DOUBLE)
1622 return EINA_FALSE;
1623 rp->drag->size.x = FROM_DOUBLE(CLAMP(param->d, 0.0, 1.0));
1624 rp->edje->dirty = 1;
1625#ifdef EDJE_CALC_CACHE
1626 rp->invalidate = 1;
1627#endif
1628 _edje_recalc(rp->edje);
1629 return EINA_TRUE;
1630 }
1631 if (!strcmp(sub_name, "size_h"))
1632 {
1633 if (param->type != EDJE_EXTERNAL_PARAM_TYPE_DOUBLE)
1634 return EINA_FALSE;
1635 rp->drag->size.y = FROM_DOUBLE(CLAMP(param->d, 0.0, 1.0));
1636 rp->edje->dirty = 1;
1637#ifdef EDJE_CALC_CACHE
1638 rp->invalidate = 1;
1639#endif
1640 _edje_recalc(rp->edje);
1641 return EINA_TRUE;
1642 }
1643
1644 if (!strcmp(sub_name, "step_x"))
1645 {
1646 if (param->type != EDJE_EXTERNAL_PARAM_TYPE_DOUBLE)
1647 return EINA_FALSE;
1648 rp->drag->step.x = FROM_DOUBLE(CLAMP(param->d, 0.0, 1.0));
1649#ifdef EDJE_CALC_CACHE
1650 rp->invalidate = 1;
1651#endif
1652 return EINA_TRUE;
1653 }
1654 if (!strcmp(sub_name, "step_y"))
1655 {
1656 if (param->type != EDJE_EXTERNAL_PARAM_TYPE_DOUBLE)
1657 return EINA_FALSE;
1658 rp->drag->step.y = FROM_DOUBLE(CLAMP(param->d, 0.0, 1.0));
1659#ifdef EDJE_CALC_CACHE
1660 rp->invalidate = 1;
1661#endif
1662 return EINA_TRUE;
1663 }
1664
1665 if (!strcmp(sub_name, "page_x"))
1666 {
1667 if (param->type != EDJE_EXTERNAL_PARAM_TYPE_DOUBLE)
1668 return EINA_FALSE;
1669 rp->drag->page.x = FROM_DOUBLE(CLAMP(param->d, 0.0, 1.0));
1670#ifdef EDJE_CALC_CACHE
1671 rp->invalidate = 1;
1672#endif
1673 return EINA_TRUE;
1674 }
1675 if (!strcmp(sub_name, "page_y"))
1676 {
1677 if (param->type != EDJE_EXTERNAL_PARAM_TYPE_DOUBLE)
1678 return EINA_FALSE;
1679 rp->drag->page.y = FROM_DOUBLE(CLAMP(param->d, 0.0, 1.0));
1680#ifdef EDJE_CALC_CACHE
1681 rp->invalidate = 1;
1682#endif
1683 return EINA_TRUE;
1684 }
1685
1686 return EINA_FALSE;
1687 }
1688 }
1689
1690 return EINA_FALSE;
1691}
1692
1693static const Edje_External_Param_Info *
1694_edje_native_param_info_get(const Edje_Real_Part *rp, const char *name)
1695{
1696 if ((rp->part->type == EDJE_PART_TYPE_TEXT) ||
1697 (rp->part->type == EDJE_PART_TYPE_TEXTBLOCK))
1698 {
1699 if (!strcmp(name, "text"))
1700 {
1701 static const Edje_External_Param_Info pi =
1702 EDJE_EXTERNAL_PARAM_INFO_STRING("text");
1703 return &pi;
1704 }
1705 if (rp->part->type == EDJE_PART_TYPE_TEXTBLOCK)
1706 {
1707 if (!strcmp(name, "text_unescaped"))
1708 {
1709 static const Edje_External_Param_Info pi =
1710 EDJE_EXTERNAL_PARAM_INFO_STRING("text_unescaped");
1711 return &pi;
1712 }
1713 if (!strcmp(name, "select_allow"))
1714 {
1715 static const Edje_External_Param_Info pi =
1716 EDJE_EXTERNAL_PARAM_INFO_BOOL("text_unescaped");
1717 return &pi;
1718 }
1719 }
1720 }
1721
1722 if ((rp->drag) && (rp->drag->down.count == 0))
1723 {
1724 if (!strncmp(name, "drag_", sizeof("drag_") - 1))
1725 {
1726 name += sizeof("drag_") - 1;
1727 if (!strcmp(name, "value_x"))
1728 {
1729 static const Edje_External_Param_Info pi =
1730 EDJE_EXTERNAL_PARAM_INFO_DOUBLE("drag_value_x");
1731 return &pi;
1732 }
1733 if (!strcmp(name, "value_y"))
1734 {
1735 static const Edje_External_Param_Info pi =
1736 EDJE_EXTERNAL_PARAM_INFO_DOUBLE("drag_value_y");
1737 return &pi;
1738 }
1739 if (!strcmp(name, "size_w"))
1740 {
1741 static const Edje_External_Param_Info pi =
1742 EDJE_EXTERNAL_PARAM_INFO_DOUBLE("drag_size_w");
1743 return &pi;
1744 }
1745 if (!strcmp(name, "size_h"))
1746 {
1747 static const Edje_External_Param_Info pi =
1748 EDJE_EXTERNAL_PARAM_INFO_DOUBLE("drag_size_h");
1749 return &pi;
1750 }
1751 if (!strcmp(name, "step_x"))
1752 {
1753 static const Edje_External_Param_Info pi =
1754 EDJE_EXTERNAL_PARAM_INFO_DOUBLE("drag_step_x");
1755 return &pi;
1756 }
1757 if (!strcmp(name, "step_y"))
1758 {
1759 static const Edje_External_Param_Info pi =
1760 EDJE_EXTERNAL_PARAM_INFO_DOUBLE("drag_step_y");
1761 return &pi;
1762 }
1763 if (!strcmp(name, "page_x"))
1764 {
1765 static const Edje_External_Param_Info pi =
1766 EDJE_EXTERNAL_PARAM_INFO_DOUBLE("drag_page_x");
1767 return &pi;
1768 }
1769 if (!strcmp(name, "page_y"))
1770 {
1771 static const Edje_External_Param_Info pi =
1772 EDJE_EXTERNAL_PARAM_INFO_DOUBLE("drag_page_y");
1773 return &pi;
1774 }
1775
1776 return NULL;
1777 }
1778 }
1779
1780 return NULL;
1781}
1782
1783static Edje_External_Param *
1784_edje_param_convert(Edje_External_Param *param, const Edje_External_Param_Info *dst_info)
1785{
1786 if (param->type == dst_info->type) return param;
1787
1788 switch (dst_info->type)
1789 {
1790 case EDJE_EXTERNAL_PARAM_TYPE_BOOL:
1791 case EDJE_EXTERNAL_PARAM_TYPE_INT:
1792 {
1793 int i;
1794 switch (param->type)
1795 {
1796 case EDJE_EXTERNAL_PARAM_TYPE_DOUBLE:
1797 i = (int)param->d;
1798 break;
1799 case EDJE_EXTERNAL_PARAM_TYPE_STRING:
1800 case EDJE_EXTERNAL_PARAM_TYPE_CHOICE:
1801 i = (param->s) ? atoi(param->s) : 0;
1802 break;
1803 case EDJE_EXTERNAL_PARAM_TYPE_BOOL:
1804 case EDJE_EXTERNAL_PARAM_TYPE_INT:
1805 i = param->i;
1806 break;
1807 default:
1808 return NULL;
1809 }
1810 if (dst_info->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
1811 i = !!i;
1812 param->type = dst_info->type;
1813 param->i = i;
1814 return param;
1815 }
1816
1817 case EDJE_EXTERNAL_PARAM_TYPE_DOUBLE:
1818 {
1819 double d;
1820 switch (param->type)
1821 {
1822 case EDJE_EXTERNAL_PARAM_TYPE_INT:
1823 d = (double)param->i;
1824 break;
1825 case EDJE_EXTERNAL_PARAM_TYPE_STRING:
1826 case EDJE_EXTERNAL_PARAM_TYPE_CHOICE:
1827 d = (param->s) ? atof(param->s) : 0.0;
1828 break;
1829 case EDJE_EXTERNAL_PARAM_TYPE_BOOL:
1830 d = (double)param->i;
1831 break;
1832 default:
1833 return NULL;
1834 }
1835 param->type = dst_info->type;
1836 param->d = d;
1837 return param;
1838 }
1839
1840 case EDJE_EXTERNAL_PARAM_TYPE_STRING:
1841 {
1842 static char s[64];
1843 switch (param->type)
1844 {
1845 case EDJE_EXTERNAL_PARAM_TYPE_BOOL:
1846 case EDJE_EXTERNAL_PARAM_TYPE_INT:
1847 if (!snprintf(s, sizeof(s), "%i", param->i)) return NULL;
1848 break;
1849 case EDJE_EXTERNAL_PARAM_TYPE_DOUBLE:
1850 if (!snprintf(s, sizeof(s), "%f", param->d)) return NULL;
1851 break;
1852 case EDJE_EXTERNAL_PARAM_TYPE_CHOICE:
1853 param->type = dst_info->type;
1854 return param;
1855 default:
1856 return NULL;
1857 }
1858 param->type = dst_info->type;
1859 param->s = s;
1860 return param;
1861 }
1862
1863 case EDJE_EXTERNAL_PARAM_TYPE_CHOICE:
1864 {
1865 static char s[64];
1866 const char *val;
1867 switch (param->type)
1868 {
1869 case EDJE_EXTERNAL_PARAM_TYPE_BOOL:
1870 case EDJE_EXTERNAL_PARAM_TYPE_INT:
1871 if (!snprintf(s, sizeof(s), "%i", param->i)) return NULL;
1872 val = s;
1873 break;
1874 case EDJE_EXTERNAL_PARAM_TYPE_DOUBLE:
1875 if (!snprintf(s, sizeof(s), "%f", param->d)) return NULL;
1876 val = s;
1877 break;
1878 case EDJE_EXTERNAL_PARAM_TYPE_STRING:
1879 val = param->s;
1880 break;
1881 default:
1882 return NULL;
1883 }
1884
1885 param->type = dst_info->type;
1886 if (param->s != val) param->s = val;
1887 return param;
1888 }
1889
1890 default: return NULL;
1891 }
1892}
1893
1894static Eina_Bool
1895_edje_param_validate(const Edje_External_Param *param, const Edje_External_Param_Info *info)
1896{
1897 switch (info->type)
1898 {
1899 case EDJE_EXTERNAL_PARAM_TYPE_BOOL:
1900 return ((param->i == 0) || (param->i == 1));
1901
1902 case EDJE_EXTERNAL_PARAM_TYPE_INT:
1903 if ((info->info.i.min != EDJE_EXTERNAL_INT_UNSET) &&
1904 (info->info.i.min > param->i))
1905 return EINA_FALSE;
1906
1907 if ((info->info.i.max != EDJE_EXTERNAL_INT_UNSET) &&
1908 (info->info.i.max < param->i))
1909 return EINA_FALSE;
1910
1911 return EINA_TRUE;
1912
1913 case EDJE_EXTERNAL_PARAM_TYPE_DOUBLE:
1914 if ((info->info.d.min != EDJE_EXTERNAL_DOUBLE_UNSET) &&
1915 (info->info.d.min > param->d))
1916 return EINA_FALSE;
1917
1918 if ((info->info.d.max != EDJE_EXTERNAL_DOUBLE_UNSET) &&
1919 (info->info.d.max < param->d))
1920 return EINA_FALSE;
1921
1922 return EINA_TRUE;
1923
1924 case EDJE_EXTERNAL_PARAM_TYPE_STRING:
1925 if (!param->s) return EINA_FALSE;
1926 if (info->info.s.accept_fmt)
1927 INF("string 'accept_fmt' validation not implemented.");
1928 if (info->info.s.deny_fmt)
1929 INF("string 'deny_fmt' validation not implemented.");
1930 return EINA_TRUE;
1931
1932 case EDJE_EXTERNAL_PARAM_TYPE_CHOICE:
1933 {
1934 const char **itr = info->info.c.choices;
1935 if (!itr) return EINA_FALSE;
1936 for (; *itr; itr++)
1937 if (!strcmp(*itr, param->s))
1938 return EINA_TRUE;
1939 return EINA_FALSE;
1940 }
1941
1942 default: return EINA_FALSE;
1943 }
1944}
1945
1946static void
1947_edje_param_copy(Edje_Real_Part *src_part, const char *src_param, Edje_Real_Part *dst_part, const char *dst_param)
1948{
1949 Edje_External_Param val;
1950 const Edje_External_Param_Info *dst_info;
1951 void *free_ptr = NULL;
1952
1953 if ((!src_part) || (!src_param) || (!dst_part) || (!dst_param))
1954 return;
1955
1956 if (dst_part->part->type == EDJE_PART_TYPE_EXTERNAL)
1957 dst_info = _edje_external_param_info_get
1958 (dst_part->swallowed_object, dst_param);
1959 else
1960 dst_info = _edje_native_param_info_get(dst_part, dst_param);
1961
1962 if (!dst_info)
1963 {
1964 ERR("cannot copy, invalid destination parameter '%s' of part '%s'",
1965 dst_param, dst_part->part->name);
1966 return;
1967 }
1968
1969 if (src_part->part->type == EDJE_PART_TYPE_EXTERNAL)
1970 {
1971 if (!_edje_param_external_get
1972 (src_part, src_param, &val))
1973 {
1974 ERR("cannot get parameter '%s' of part '%s'",
1975 src_param, src_part->part->name);
1976 return;
1977 }
1978 }
1979 else
1980 {
1981 if (!_edje_param_native_get(src_part, src_param, &val, &free_ptr))
1982 {
1983 ERR("cannot get parameter '%s' of part '%s'",
1984 src_param, src_part->part->name);
1985 return;
1986 }
1987 }
1988
1989 if (!_edje_param_convert(&val, dst_info))
1990 {
1991 ERR("cannot convert parameter type %s to requested type %s",
1992 edje_external_param_type_str(val.type),
1993 edje_external_param_type_str(dst_info->type));
1994 goto end;
1995 }
1996
1997 if (!_edje_param_validate(&val, dst_info))
1998 {
1999 ERR("incorrect parameter value failed validation for type %s",
2000 edje_external_param_type_str(dst_info->type));
2001 goto end;
2002 }
2003
2004 if (dst_part->part->type == EDJE_PART_TYPE_EXTERNAL)
2005 {
2006 val.name = dst_param;
2007 if (!_edje_external_param_set(NULL, dst_part, &val))
2008 {
2009 ERR("failed to set parameter '%s' (%s) of part '%s'",
2010 dst_param, edje_external_param_type_str(dst_info->type),
2011 dst_part->part->name);
2012 goto end;
2013 }
2014 }
2015 else
2016 {
2017 if (!_edje_param_native_set(dst_part, dst_param, &val))
2018 {
2019 ERR("failed to set parameter '%s' (%s) of part '%s'",
2020 dst_param, edje_external_param_type_str(dst_info->type),
2021 dst_part->part->name);
2022 goto end;
2023 }
2024 }
2025
2026 end:
2027 free(free_ptr);
2028}
2029
2030static void
2031_edje_param_set(Edje_Real_Part *part, const char *param, const char *value)
2032{
2033 Edje_External_Param val;
2034 const Edje_External_Param_Info *info;
2035
2036 if ((!part) || (!param) || (!value))
2037 return;
2038
2039 if (part->part->type == EDJE_PART_TYPE_EXTERNAL)
2040 info = _edje_external_param_info_get(part->swallowed_object, param);
2041 else
2042 info = _edje_native_param_info_get(part, param);
2043
2044 if (!info)
2045 {
2046 ERR("cannot copy, invalid destination parameter '%s' of part '%s'",
2047 param, part->part->name);
2048 return;
2049 }
2050
2051 val.name = "(temp)";
2052 val.type = EDJE_EXTERNAL_PARAM_TYPE_STRING;
2053 val.s = value;
2054
2055 if (!_edje_param_convert(&val, info))
2056 {
2057 ERR("cannot convert parameter type STRING to requested type %s",
2058 edje_external_param_type_str(info->type));
2059 return;
2060 }
2061
2062 if (!_edje_param_validate(&val, info))
2063 {
2064 ERR("incorrect parameter value failed validation for type %s",
2065 edje_external_param_type_str(info->type));
2066 return;
2067 }
2068
2069 if (part->part->type == EDJE_PART_TYPE_EXTERNAL)
2070 {
2071 val.name = param;
2072 if (!_edje_external_param_set(NULL, part, &val))
2073 {
2074 ERR("failed to set parameter '%s' (%s) of part '%s'",
2075 param, edje_external_param_type_str(info->type),
2076 part->part->name);
2077 return;
2078 }
2079 }
2080 else
2081 {
2082 if (!_edje_param_native_set(part, param, &val))
2083 {
2084 ERR("failed to set parameter '%s' (%s) of part '%s'",
2085 param, edje_external_param_type_str(info->type),
2086 part->part->name);
2087 return;
2088 }
2089 }
2090}
diff --git a/libraries/edje/src/lib/edje_script_only.c b/libraries/edje/src/lib/edje_script_only.c
new file mode 100644
index 0000000..e7a7347
--- /dev/null
+++ b/libraries/edje/src/lib/edje_script_only.c
@@ -0,0 +1,643 @@
1#include "edje_private.h"
2
3/*
4 * ALREADY EXPORTED BY EMBRYO:
5 *
6 * enum Float_Round_Method {
7 * ROUND, FLOOR, CEIL, TOZERO
8 * };
9 * enum Float_Angle_Mode {
10 * RADIAN, DEGREES, GRADES
11 * };
12 *
13 * numargs();
14 * getarg(arg, index=0);
15 * setarg(arg, index=0, value);
16 *
17 * Float:atof(string[]);
18 * Float:fract(Float:value);
19 * round(Float:value, Float_Round_Method:method=ROUND);
20 * Float:sqrt(Float:value);
21 * Float:pow(Float:value, Float:exponent);
22 * Float:log(Float:value, Float:base=10.0);
23 * Float:sin(Float:value, Float_Angle_Mode:mode=RADIAN);
24 * Float:cos(Float:value, Float_Angle_Mode:mode=RADIAN);
25 * Float:tan(Float:value, Float_Angle_Mode:mode=RADIAN);
26 * Float:abs(Float:value);
27 * atoi(str[]);
28 * fnmatch(glob[], str[]);
29 * strcmp(str1[], str2[]);
30 * strncmp(str1[], str2[]);
31 * strcpy(dst[], src[]);
32 * strncpy(dst[], src[], n);
33 * strlen(str[]);
34 * strcat(dst[], src[]);
35 * strncat(dst[], src[], n);
36 * strprep(dst[], src[]);
37 * strnprep(dst[], src[], n);
38 * strcut(dst[], str[], n, n2);
39 * snprintf(dst[], dstn, fmt[], ...);
40 * strstr(str[], ndl[]);
41 * strchr(str[], ch[]);
42 * strrchr(str[], ch[]);
43 * rand();
44 * Float:randf();
45 * Float:seconds();
46 * date(&year, &month, &day, &yearday, &weekday, &hr, &min, &Float:sec);
47 *
48 */
49
50typedef struct _Sinfo Sinfo;
51
52struct _Sinfo
53{
54 struct
55 {
56 Embryo_Function
57 obj_init, obj_shutdown, obj_show, obj_show_immediate,
58 obj_hide, obj_hide_immediate, obj_move, obj_move_immediate,
59 obj_resize, obj_resize_immediate, obj_message;
60 } fn;
61 struct
62 {
63 Ecore_Job * show, *hide, *move, *resize;
64 } job;
65 struct
66 {
67 int id;
68 Eina_Hash *hash; // FIXME: hash -> bad. too big. one-way lookup etc.
69 } oid;
70};
71
72static void _call_fn(Edje * ed, const char *fname, Embryo_Function fn);
73
74/* frankly - these make the code shorter to type and read - just sanity for
75 * development */
76#define IFFN(func) if (si->fn.func != EMBRYO_FUNCTION_NONE)
77#define IFNO(func) if (si->fn.func == EMBRYO_FUNCTION_NONE)
78#define CLFN(func) IFFN(func) {_call_fn(ed, #func, si->fn.func);}
79#define SI Sinfo *si; si = ed->script_only_data; if (!si) return
80#define SI_RETURN(ret) Sinfo *si; si = ed->script_only_data; if (!si) return (ret)
81#define PINT(val) embryo_parameter_cell_push(ed->collection->script, (Embryo_Cell)(val))
82#define PSTR(val) embryo_parameter_string_push(ed->collection->script, val)
83#define GTFN(func) si->fn.func = embryo_program_function_find(ed->collection->script, #func)
84#define DELJ(type) if (si->job.type) ecore_job_del(si->job.type);
85#define ADDJ(type, func) si->job.type = ecore_job_add(func, ed);
86#define ZERJ(type) si->job.type = NULL;
87#define IFNJ(type) if (!si->job.type)
88#define EXPF(func) embryo_program_native_call_add(ed->collection->script, #func, _exp_##func)
89
90typedef struct _Oid Oid;
91
92struct _Oid
93{
94 Edje *ed;
95 Evas_Object *obj;
96 Evas_Coord x, y, w, h;
97 int oid;
98};
99
100/* FIXME: using eina_hash and strings is just nasty! make a custom int hash */
101static int
102_oid_alloc(Edje * ed)
103{
104 SI_RETURN(0);
105
106 si->oid.id++;
107 return si->oid.id;
108}
109
110static Oid *
111_oid_track(Edje * ed, Evas_Object * o)
112{
113 Oid *oi;
114
115 char buf[64];
116
117 SI_RETURN(NULL);
118
119 oi = calloc(1, sizeof(Oid));
120 if (!oi)
121 return NULL;
122 oi->oid = _oid_alloc(ed);
123 if (!oi->oid)
124 {
125 free(oi);
126 return NULL;
127 }
128 oi->ed = ed;
129 oi->obj = o;
130 evas_object_smart_member_add(oi->obj, oi->ed->obj);
131 evas_object_clip_set(oi->obj, oi->ed->base.clipper);
132 evas_object_geometry_get(oi->obj, &(oi->x), &(oi->y), &(oi->w), &(oi->h));
133 snprintf(buf, sizeof(buf), "%i", oi->oid);
134 if (!si->oid.hash)
135 si->oid.hash = eina_hash_string_superfast_new(NULL);
136 eina_hash_add(si->oid.hash, buf, oi);
137 return oi;
138}
139
140static Oid *
141_oid_find(Edje * ed, int oid)
142{
143 char buf[64];
144
145 SI_RETURN(NULL);
146
147 snprintf(buf, sizeof(buf), "%i", oid);
148 return eina_hash_find(si->oid.hash, buf);
149}
150
151static void
152_oid_del(Edje * ed, int oid)
153{
154 char buf[64];
155
156 SI;
157
158 snprintf(buf, sizeof(buf), "%i", oid);
159 eina_hash_del(si->oid.hash, buf, NULL);
160}
161
162static void
163_oid_free(Oid * oid)
164{
165 free(oid);
166}
167
168static Eina_Bool
169_oid_freeall_cb(const Eina_Hash *hash __UNUSED__, const void *key __UNUSED__, void *data, void *fdata __UNUSED__)
170{
171 Oid *oid = data;
172
173 evas_object_del(oid->obj);
174 free(oid);
175 return EINA_TRUE;
176}
177
178static void
179_oid_freeall(Edje * ed)
180{
181 SI;
182 if (!si->oid.hash)
183 return;
184 eina_hash_foreach(si->oid.hash, _oid_freeall_cb, ed);
185 eina_hash_free(si->oid.hash);
186 si->oid.hash = NULL;
187}
188
189static Eina_Bool
190_oid_moveall_cb(const Eina_Hash *hash __UNUSED__, const void *key __UNUSED__, void *data, void *fdata __UNUSED__)
191{
192 Oid *oid = data;
193
194 evas_object_move(oid->obj, oid->ed->x + oid->x, oid->ed->y + oid->y);
195 return EINA_TRUE;
196}
197
198static void
199_oid_moveall(Edje * ed)
200{
201 SI;
202 if (!si->oid.hash)
203 return;
204 eina_hash_foreach(si->oid.hash, _oid_moveall_cb, ed);
205}
206
207/**********/
208
209static Embryo_Cell
210_exp_e_obj_del(Embryo_Program * ep, Embryo_Cell * params)
211{
212 Edje *ed = embryo_program_data_get(ep);
213
214 Oid *oid;
215
216 SI_RETURN(-1);
217
218 CHKPARAM(1);
219 if (!(oid = _oid_find(ed, params[1])))
220 return -1;
221 evas_object_del(oid->obj);
222 _oid_del(ed, oid->oid);
223 _oid_free(oid);
224 return 0;
225}
226
227static Embryo_Cell
228_exp_e_obj_rect_add(Embryo_Program * ep, Embryo_Cell * params __UNUSED__)
229{
230 Edje *ed = embryo_program_data_get(ep);
231
232 Evas_Object *o;
233
234 Oid *oid;
235
236 SI_RETURN(-1);
237
238 o = evas_object_rectangle_add(evas_object_evas_get(ed->obj));
239 if (!o)
240 return 0;
241 oid = _oid_track(ed, o);
242 if (oid)
243 return oid->oid;
244 return 0;
245}
246
247static Embryo_Cell
248_exp_e_obj_show(Embryo_Program * ep, Embryo_Cell * params)
249{
250 Edje *ed = embryo_program_data_get(ep);
251
252 Oid *oid;
253
254 SI_RETURN(-1);
255
256 CHKPARAM(1);
257 if (!(oid = _oid_find(ed, params[1])))
258 return -1;
259 evas_object_show(oid->obj);
260 return 0;
261}
262
263static Embryo_Cell
264_exp_e_obj_hide(Embryo_Program * ep, Embryo_Cell * params)
265{
266 Edje *ed = embryo_program_data_get(ep);
267
268 Oid *oid;
269
270 SI_RETURN(-1);
271
272 CHKPARAM(1);
273 if (!(oid = _oid_find(ed, params[1])))
274 return -1;
275 evas_object_hide(oid->obj);
276 return 0;
277}
278
279static Embryo_Cell
280_exp_e_obj_move(Embryo_Program * ep, Embryo_Cell * params)
281{
282 Edje *ed = embryo_program_data_get(ep);
283
284 Oid *oid;
285
286 SI_RETURN(-1);
287
288 CHKPARAM(3);
289 if (!(oid = _oid_find(ed, params[1])))
290 return -1;
291 if ((oid->x == params[2]) && (oid->y == params[3]))
292 return -1;
293 oid->x = params[2];
294 oid->y = params[3];
295 evas_object_move(oid->obj, ed->x + oid->x, ed->y + oid->y);
296 return 0;
297}
298
299static Embryo_Cell
300_exp_e_obj_resize(Embryo_Program * ep, Embryo_Cell * params)
301{
302 Edje *ed = embryo_program_data_get(ep);
303
304 Oid *oid;
305
306 SI_RETURN(-1);
307
308 CHKPARAM(3);
309 if (!(oid = _oid_find(ed, params[1])))
310 return -1;
311 if ((oid->w == params[2]) && (oid->h == params[3]))
312 return -1;
313 oid->w = params[2];
314 oid->h = params[3];
315 evas_object_resize(oid->obj, oid->w, oid->h);
316 return 0;
317}
318
319static Embryo_Cell
320_exp_e_obj_geometry_set(Embryo_Program * ep, Embryo_Cell * params)
321{
322 Edje *ed = embryo_program_data_get(ep);
323
324 Oid *oid;
325
326 SI_RETURN(-1);
327
328 CHKPARAM(5);
329 if (!(oid = _oid_find(ed, params[1])))
330 return -1;
331 if ((oid->x == params[2]) && (oid->y == params[3]) &&
332 (oid->w == params[4]) && (oid->h == params[5]))
333 return -1;
334 oid->x = params[2];
335 oid->y = params[3];
336 oid->w = params[4];
337 oid->h = params[5];
338 evas_object_move(oid->obj, ed->x + oid->x, ed->y + oid->y);
339 evas_object_resize(oid->obj, oid->w, oid->h);
340 return 0;
341}
342
343static Embryo_Cell
344_exp_e_obj_geometry_get(Embryo_Program * ep, Embryo_Cell * params)
345{
346 Edje *ed = embryo_program_data_get(ep);
347
348 Oid *oid;
349
350 SI_RETURN(-1);
351
352 CHKPARAM(5);
353 if (!(oid = _oid_find(ed, params[1])))
354 return -1;
355 SETINT(oid->x, params[2]);
356 SETINT(oid->y, params[3]);
357 SETINT(oid->w, params[4]);
358 SETINT(oid->h, params[5]);
359 return 0;
360}
361
362static Embryo_Cell
363_exp_e_obj_color_set(Embryo_Program * ep, Embryo_Cell * params)
364{
365 Edje *ed = embryo_program_data_get(ep);
366
367 Oid *oid;
368
369 SI_RETURN(-1);
370
371 CHKPARAM(5);
372 if (!(oid = _oid_find(ed, params[1])))
373 return -1;
374 evas_object_color_set(oid->obj, params[2], params[3], params[4], params[5]);
375 return 0;
376}
377
378static Embryo_Cell
379_exp_e_obj_color_get(Embryo_Program * ep, Embryo_Cell * params)
380{
381 Edje *ed = embryo_program_data_get(ep);
382
383 Oid *oid;
384
385 int r, g, b, a;
386
387 SI_RETURN(-1);
388
389 CHKPARAM(5);
390 if (!(oid = _oid_find(ed, params[1])))
391 return -1;
392 evas_object_color_get(oid->obj, &r, &g, &b, &a);
393 SETINT(r, params[2]);
394 SETINT(g, params[3]);
395 SETINT(b, params[4]);
396 SETINT(a, params[5]);
397 return 0;
398}
399
400static Embryo_Cell
401_exp_e_signal_emit(Embryo_Program * ep, Embryo_Cell * params)
402{
403 Edje *ed = embryo_program_data_get(ep);
404
405 char *sig = NULL, *src = NULL;
406
407 SI_RETURN(-1);
408
409 CHKPARAM(2);
410 GETSTR(sig, params[1]);
411 GETSTR(src, params[2]);
412 if ((!sig) || (!src))
413 return -1;
414 _edje_emit(ed, sig, src);
415 return 0;
416}
417
418/**********/
419
420Eina_Bool
421_edje_script_only(Edje * ed)
422{
423 if ((ed->collection) && (ed->collection->script) &&
424 (ed->collection->script_only))
425 return EINA_TRUE;
426 return EINA_FALSE;
427}
428
429void
430_edje_script_only_init(Edje * ed)
431{
432 Sinfo *si;
433
434 si = calloc(1, sizeof(Sinfo));
435 if (!si)
436 return;
437 ed->script_only_data = si;
438
439 embryo_program_data_set(ed->collection->script, ed);
440
441 EXPF(e_obj_del);
442 EXPF(e_obj_rect_add);
443 EXPF(e_obj_show);
444 EXPF(e_obj_hide);
445 EXPF(e_obj_move);
446 EXPF(e_obj_resize);
447 EXPF(e_obj_geometry_set);
448 EXPF(e_obj_geometry_get);
449 EXPF(e_obj_color_set);
450 EXPF(e_obj_color_get);
451 EXPF(e_signal_emit);
452
453 embryo_program_vm_push(ed->collection->script);
454 embryo_program_max_cycle_run_set(ed->collection->script, 5000000);
455
456 GTFN(obj_init);
457 GTFN(obj_shutdown);
458 GTFN(obj_show);
459 GTFN(obj_show_immediate);
460 GTFN(obj_hide);
461 GTFN(obj_hide_immediate);
462 GTFN(obj_move);
463 GTFN(obj_move_immediate);
464 GTFN(obj_resize);
465 GTFN(obj_resize_immediate);
466 GTFN(obj_message);
467
468 CLFN(obj_init);
469 _edje_script_only_move(ed);
470}
471
472void
473_edje_script_only_shutdown(Edje * ed)
474{
475 SI;
476
477 CLFN(obj_shutdown);
478 DELJ(show);
479 DELJ(hide);
480 DELJ(move);
481 DELJ(resize);
482 _oid_freeall(ed);
483}
484
485static void
486_show_job(void *data)
487{
488 Edje *ed = data;
489
490 SI;
491
492 ZERJ(show);
493 CLFN(obj_show);
494}
495void
496_edje_script_only_show(Edje * ed)
497{
498 SI;
499
500 IFFN(obj_show)
501 {
502 IFNJ(hide)
503 {
504 DELJ(show);
505 ADDJ(show, _show_job);
506 }
507 else
508 {
509 DELJ(hide);
510 }
511 }
512 IFNO(obj_show_immediate) return;
513 CLFN(obj_show_immediate);
514}
515
516static void
517_hide_job(void *data)
518{
519 Edje *ed = data;
520
521 SI;
522
523 ZERJ(hide);
524 CLFN(obj_hide);
525}
526void
527_edje_script_only_hide(Edje * ed)
528{
529 SI;
530
531 IFFN(obj_hide)
532 {
533 IFNJ(show)
534 {
535 DELJ(hide);
536 ADDJ(hide, _hide_job);
537 }
538 else
539 {
540 DELJ(show);
541 }
542 }
543 IFNO(obj_hide_immediate) return;
544 CLFN(obj_hide_immediate);
545}
546
547static void
548_move_job(void *data)
549{
550 Edje *ed = data;
551
552 SI;
553
554 _oid_moveall(ed);
555 ZERJ(move);
556 IFNO(obj_move) return;
557 PINT(ed->x);
558 PINT(ed->y);
559 CLFN(obj_move);
560}
561void
562_edje_script_only_move(Edje * ed)
563{
564 SI;
565
566 DELJ(move);
567 ADDJ(move, _move_job);
568 IFNO(obj_move_immediate) return;
569 PINT(ed->x);
570 PINT(ed->y);
571 CLFN(obj_move_immediate);
572}
573
574static void
575_resize_job(void *data)
576{
577 Edje *ed = data;
578
579 SI;
580
581 ZERJ(resize);
582 PINT(ed->w);
583 PINT(ed->h);
584 CLFN(obj_resize);
585}
586void
587_edje_script_only_resize(Edje * ed)
588{
589 SI;
590
591 IFFN(obj_resize)
592 {
593 DELJ(resize);
594 ADDJ(resize, _resize_job);
595 }
596 PINT(ed->w);
597 PINT(ed->h);
598 CLFN(obj_resize_immediate);
599}
600
601void
602_edje_script_only_message(Edje * ed, Edje_Message * em)
603{
604 SI;
605
606 IFNO(obj_message) return;
607 _edje_message_parameters_push(em);
608 CLFN(obj_message);
609}
610
611/**************************************************/
612
613static void
614_call_fn(Edje * ed, const char *fname, Embryo_Function fn)
615{
616 int ret;
617
618 ret = embryo_program_run(ed->collection->script, fn);
619 if (ret == EMBRYO_PROGRAM_FAIL)
620 {
621 ERR("ERROR with embryo script. "
622 "OBJECT NAME: '%s', "
623 "OBJECT FILE: '%s', "
624 "ENTRY POINT: '%s', "
625 "ERROR: '%s'",
626 ed->collection->part,
627 ed->file->path,
628 fname,
629 embryo_error_string_get(embryo_program_error_get(ed->collection->script)));
630 }
631 else if (ret == EMBRYO_PROGRAM_TOOLONG)
632 {
633 ERR("ERROR with embryo script. "
634 "OBJECT NAME: '%s', "
635 "OBJECT FILE: '%s', "
636 "ENTRY POINT: '%s', "
637 "ERROR: 'Script exceeded maximum allowed cycle count of %i'",
638 ed->collection->part,
639 ed->file->path,
640 fname,
641 embryo_program_max_cycle_run_get(ed->collection->script));
642 }
643}
diff --git a/libraries/edje/src/lib/edje_smart.c b/libraries/edje/src/lib/edje_smart.c
new file mode 100644
index 0000000..59ccc46
--- /dev/null
+++ b/libraries/edje/src/lib/edje_smart.c
@@ -0,0 +1,336 @@
1#include "edje_private.h"
2
3static void _edje_smart_add(Evas_Object * obj);
4static void _edje_smart_del(Evas_Object * obj);
5static void _edje_smart_move(Evas_Object * obj, Evas_Coord x, Evas_Coord y);
6static void _edje_smart_resize(Evas_Object * obj, Evas_Coord w, Evas_Coord h);
7static void _edje_smart_show(Evas_Object * obj);
8static void _edje_smart_hide(Evas_Object * obj);
9static void _edje_smart_calculate(Evas_Object * obj);
10
11static Eina_Bool _edje_smart_file_set(Evas_Object *obj, const char *file, const char *group);
12
13static Edje_Smart_Api _edje_smart_class = EDJE_SMART_API_INIT_NAME_VERSION("edje");
14static Evas_Smart_Class _edje_smart_parent;
15static Evas_Smart *_edje_smart = NULL;
16
17Eina_List *_edje_edjes = NULL;
18
19/************************** API Routines **************************/
20
21EAPI Evas_Object *
22edje_object_add(Evas *evas)
23{
24 Evas_Object *e;
25
26 _edje_lib_ref();
27
28 if (!_edje_smart)
29 {
30 memset(&_edje_smart_parent, 0, sizeof(_edje_smart_parent));
31 _edje_object_smart_set(&_edje_smart_class);
32 _edje_smart =
33 evas_smart_class_new((Evas_Smart_Class *)&_edje_smart_class);
34 }
35
36 e = evas_object_smart_add(evas, _edje_smart);
37
38 return e;
39}
40
41void
42_edje_object_smart_set(Edje_Smart_Api *sc)
43{
44 if (!sc)
45 return;
46
47 evas_object_smart_clipped_smart_set(&sc->base);
48
49 _edje_smart_parent.add = sc->base.add; /* Save parent class */
50 sc->base.add = _edje_smart_add;
51 _edje_smart_parent.del = sc->base.del; /* Save parent class */
52 sc->base.del = _edje_smart_del;
53 /* we'll handle move thank you */
54 sc->base.move = _edje_smart_move;
55 sc->base.resize = _edje_smart_resize;
56 _edje_smart_parent.show = sc->base.show; /* Save parent class */
57 sc->base.show = _edje_smart_show;
58 _edje_smart_parent.hide = sc->base.hide; /* Save parent class */
59 sc->base.hide = _edje_smart_hide;
60 sc->base.calculate = _edje_smart_calculate;
61 //sc->base.member_add = NULL;
62 //sc->base.member_del = NULL;
63 sc->file_set = _edje_smart_file_set;
64}
65
66const Edje_Smart_Api *
67_edje_object_smart_class_get(void)
68{
69 static const Edje_Smart_Api *class = NULL;
70
71 if (class)
72 return class;
73
74 _edje_object_smart_set(&_edje_smart_class);
75 class = &_edje_smart_class;
76
77 return class;
78}
79
80/* Private Routines */
81static void
82_edje_smart_add(Evas_Object *obj)
83{
84 Edje *ed;
85 Evas *tev = evas_object_evas_get(obj);
86
87 evas_event_freeze(tev);
88 ed = evas_object_smart_data_get(obj);
89 if (!ed)
90 {
91 const Evas_Smart *smart;
92 const Evas_Smart_Class *sc;
93
94 ed = calloc(1, sizeof(Edje));
95 if (!ed) goto end_smart_add;
96
97 smart = evas_object_smart_smart_get(obj);
98 sc = evas_smart_class_get(smart);
99 ed->api = (const Edje_Smart_Api *)sc;
100
101 evas_object_smart_data_set(obj, ed);
102 }
103
104 ed->base.evas = evas_object_evas_get(obj);
105 ed->base.clipper = evas_object_rectangle_add(ed->base.evas);
106 evas_object_static_clip_set(ed->base.clipper, 1);
107 evas_object_smart_member_add(ed->base.clipper, obj);
108 evas_object_color_set(ed->base.clipper, 255, 255, 255, 255);
109 evas_object_move(ed->base.clipper, -10000, -10000);
110 evas_object_resize(ed->base.clipper, 20000, 20000);
111 evas_object_pass_events_set(ed->base.clipper, 1);
112 ed->is_rtl = EINA_FALSE;
113 ed->have_objects = 1;
114 ed->references = 1;
115
116 evas_object_geometry_get(obj, &(ed->x), &(ed->y), &(ed->w), &(ed->h));
117 ed->obj = obj;
118 _edje_edjes = eina_list_append(_edje_edjes, obj);
119 /*
120 {
121 Eina_List *l;
122 const void *data;
123
124 printf("--- EDJE DUMP [%i]\n", eina_list_count(_edje_edjes));
125 EINA_LIST_FOREACH(_edge_edges, l, data)
126 {
127 ed = _edje_fetch(data);
128 printf("EDJE: %80s | %80s\n", ed->path, ed->part);
129 }
130 printf("--- EDJE DUMP [%i]\n", eina_list_count(_edje_edjes));
131 }
132 */
133end_smart_add:
134 evas_event_thaw(tev);
135 evas_event_thaw_eval(tev);
136}
137
138static void
139_edje_smart_del(Evas_Object * obj)
140{
141 Edje *ed;
142
143 ed = evas_object_smart_data_get(obj);
144 if (!ed) return;
145 _edje_block_violate(ed);
146 ed->delete_me = 1;
147 _edje_edjes = eina_list_remove(_edje_edjes, obj);
148 evas_object_smart_data_set(obj, NULL);
149 if (_edje_script_only(ed)) _edje_script_only_shutdown(ed);
150 if (_edje_lua_script_only(ed)) _edje_lua_script_only_shutdown(ed);
151 if (ed->persp) edje_object_perspective_set(obj, NULL);
152 _edje_file_del(ed);
153 _edje_clean_objects(ed);
154 _edje_unref(ed);
155 _edje_lib_unref();
156}
157
158static void
159_edje_smart_move(Evas_Object * obj, Evas_Coord x, Evas_Coord y)
160{
161 Edje *ed;
162
163 ed = evas_object_smart_data_get(obj);
164 if (!ed) return;
165 if ((ed->x == x) && (ed->y == y)) return;
166 ed->x = x;
167 ed->y = y;
168// evas_object_move(ed->clipper, ed->x, ed->y);
169
170 if (_edje_script_only(ed))
171 {
172 _edje_script_only_move(ed);
173 return;
174 }
175 if (_edje_lua_script_only(ed))
176 {
177 _edje_lua_script_only_move(ed);
178 return;
179 }
180
181 if (ed->have_mapped_part)
182 {
183 ed->dirty = 1;
184 _edje_recalc_do(ed);
185 }
186 else
187 {
188 unsigned int i;
189
190 for (i = 0; i < ed->table_parts_size; i++)
191 {
192 Edje_Real_Part *ep;
193 Evas_Coord ox, oy;
194
195 ep = ed->table_parts[i];
196 evas_object_geometry_get(ep->object, &ox, &oy, NULL, NULL);
197 evas_object_move(ep->object, ed->x + ep->x + ep->text.offset.x, ed->y + ep->y + ep->text.offset.y);
198 if (ep->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
199 _edje_entry_real_part_configure(ep);
200 if (ep->swallowed_object)
201 {
202 evas_object_geometry_get(ep->swallowed_object, &ox, &oy, NULL, NULL);
203 evas_object_move(ep->swallowed_object, ed->x + ep->x + ep->text.offset.x, ed->y + ep->y + ep->text.offset.y);
204 }
205 }
206 }
207// _edje_emit(ed, "move", NULL);
208}
209
210static void
211_edje_limit_emit(Edje *ed, const char *limit_name, Eina_Bool over)
212{
213 char *buffer;
214 unsigned int length;
215
216 if (!limit_name) return ;
217
218 length = strlen(limit_name) + 13;
219 buffer = alloca(length);
220 snprintf(buffer, length, "limit,%s,%s", limit_name, over ? "over" : "below");
221 _edje_emit(ed, buffer, NULL);
222}
223
224static void
225_edje_limit_get(Edje *ed, Edje_Limit **limits, unsigned int length, Evas_Coord size_current, Evas_Coord size_next)
226{
227 unsigned int i;
228
229 if (size_next == size_current) return ;
230
231 for (i = 0; i < length; ++i)
232 {
233 if ((size_current <= limits[i]->value) && (limits[i]->value < size_next))
234 {
235 _edje_limit_emit(ed, limits[i]->name, EINA_TRUE);
236 }
237 else if ((size_next <= limits[i]->value) && (limits[i]->value < size_current))
238 {
239 _edje_limit_emit(ed, limits[i]->name, EINA_FALSE);
240 }
241 }
242}
243
244static void
245_edje_smart_resize(Evas_Object * obj, Evas_Coord w, Evas_Coord h)
246{
247 Edje *ed;
248
249 ed = evas_object_smart_data_get(obj);
250 if (!ed) return;
251 if ((w == ed->w) && (h == ed->h)) return;
252 if (ed->collection)
253 {
254 _edje_limit_get(ed, ed->collection->limits.horizontal, ed->collection->limits.horizontal_count, ed->w, w);
255 _edje_limit_get(ed, ed->collection->limits.vertical, ed->collection->limits.vertical_count, ed->h, h);
256 }
257 ed->w = w;
258 ed->h = h;
259#ifdef EDJE_CALC_CACHE
260 ed->all_part_change = 1;
261#endif
262 if (_edje_script_only(ed))
263 {
264 _edje_script_only_resize(ed);
265 return;
266 }
267 if (_edje_lua_script_only(ed))
268 {
269 _edje_lua_script_only_resize(ed);
270 return;
271 }
272// evas_object_resize(ed->clipper, ed->w, ed->h);
273 ed->dirty = 1;
274 _edje_recalc_do(ed);
275 _edje_emit(ed, "resize", NULL);
276}
277
278static void
279_edje_smart_show(Evas_Object * obj)
280{
281 Edje *ed;
282
283 _edje_smart_parent.show(obj);
284 ed = evas_object_smart_data_get(obj);
285 if (!ed) return;
286 if (evas_object_visible_get(obj)) return;
287 if (_edje_script_only(ed))
288 {
289 _edje_script_only_show(ed);
290 return;
291 }
292 if (_edje_lua_script_only(ed))
293 {
294 _edje_lua_script_only_show(ed);
295 return;
296 }
297 _edje_emit(ed, "show", NULL);
298}
299
300static void
301_edje_smart_hide(Evas_Object * obj)
302{
303 Edje *ed;
304
305 _edje_smart_parent.hide(obj);
306 ed = evas_object_smart_data_get(obj);
307 if (!ed) return;
308 if (!evas_object_visible_get(obj)) return;
309 if (_edje_script_only(ed))
310 {
311 _edje_script_only_hide(ed);
312 return;
313 }
314 if (_edje_lua_script_only(ed))
315 {
316 _edje_lua_script_only_hide(ed);
317 return;
318 }
319 _edje_emit(ed, "hide", NULL);
320}
321
322static void
323_edje_smart_calculate(Evas_Object *obj)
324{
325 Edje *ed;
326
327 ed = evas_object_smart_data_get(obj);
328 if (!ed) return;
329 _edje_recalc_do(ed);
330}
331
332static Eina_Bool
333_edje_smart_file_set(Evas_Object *obj, const char *file, const char *group)
334{
335 return _edje_object_file_set_internal(obj, file, group, NULL, NULL);
336}
diff --git a/libraries/edje/src/lib/edje_text.c b/libraries/edje/src/lib/edje_text.c
new file mode 100644
index 0000000..01faf99
--- /dev/null
+++ b/libraries/edje/src/lib/edje_text.c
@@ -0,0 +1,790 @@
1#include "edje_private.h"
2#define _ELLIP_STR "\xE2\x80\xA6"
3
4/* returns with and height for this part.
5 *
6 * depending on the value of the use_alternate_font_metrics flag, it will
7 * either use evas_object_geometry_get() or the _advance_get() functions.
8 *
9 * The latter is useful if you want to make sure that width and height
10 * are the same value for the same number of characters in the text.
11 * This usually only makes sense for monospaced fonts.
12 *
13 * In future changes to this file, you probably should use this wrapper
14 * function everywhere instead of calling evas_object_geometry_get()
15 * directly.
16 */
17static inline void
18part_get_geometry(Edje_Real_Part *rp, Evas_Coord *w, Evas_Coord *h)
19{
20 if (!rp->part->use_alternate_font_metrics)
21 evas_object_geometry_get(rp->object, NULL, NULL, w, h);
22 else
23 {
24 if (w) *w = evas_object_text_horiz_advance_get(rp->object);
25 if (h) *h = evas_object_text_vert_advance_get(rp->object);
26 }
27}
28
29void
30_edje_text_init(void)
31{
32}
33
34void
35_edje_text_part_on_add(Edje *ed, Edje_Real_Part *ep)
36{
37 Edje_Part *pt = ep->part;
38 Edje_Part_Description_Text *desc;
39 unsigned int i;
40
41 if (ep->part->type != EDJE_PART_TYPE_TEXT) return;
42
43 /* if text class exists for this part, add the edje to the tc member list */
44 desc = (Edje_Part_Description_Text *) pt->default_desc;
45 if ((pt->default_desc) && (desc->text.text_class))
46 _edje_text_class_member_add(ed, desc->text.text_class);
47
48 /* If any other classes exist add them */
49 for (i = 0; i < pt->other.desc_count; ++i)
50 {
51 desc = (Edje_Part_Description_Text *) pt->other.desc[i];
52 if ((desc) && (desc->text.text_class))
53 _edje_text_class_member_add(ed, desc->text.text_class);
54 }
55}
56
57void
58_edje_text_part_on_del(Edje *ed, Edje_Part *pt)
59{
60 Edje_Part_Description_Text *desc;
61 unsigned int i;
62
63 if (!pt) return;
64 if (pt->type != EDJE_PART_TYPE_TEXT
65 && pt->type != EDJE_PART_TYPE_TEXTBLOCK)
66 return ;
67
68 desc = (Edje_Part_Description_Text *) pt->default_desc;
69 if ((pt->default_desc) && (desc->text.text_class))
70 _edje_text_class_member_del(ed, desc->text.text_class);
71
72 for (i = 0; i < pt->other.desc_count; ++i)
73 {
74 desc = (Edje_Part_Description_Text *) pt->other.desc[i];
75 if (desc->text.text_class)
76 _edje_text_class_member_del(ed, desc->text.text_class);
77 }
78}
79
80static void
81_edje_text_fit_set(char *buf, const char *text, int c1, int c2)
82{
83 /* helper function called from _edje_text_fit_x().
84 * note that we can use strcpy()/strcat() safely, the buffer lengths
85 * are checked in the caller.
86 */
87
88 if (c1 >= 0)
89 {
90 strcpy(buf, _ELLIP_STR);
91
92 if (c2 >= 0)
93 {
94 strncat(buf, text + c1, c2 - c1);
95 strcat(buf, _ELLIP_STR);
96 }
97 else
98 strcat(buf, text + c1);
99 }
100 else
101 {
102 if (c2 >= 0)
103 {
104 strncpy(buf, text, c2);
105 buf[c2] = 0;
106 strcat(buf, _ELLIP_STR);
107 }
108 else
109 strcpy(buf, text);
110 }
111}
112
113static const char *
114_edje_text_fit_x(Edje *ed, Edje_Real_Part *ep,
115 Edje_Calc_Params *params,
116 const char *text, const char *font, int size,
117 Evas_Coord sw, int *free_text)
118{
119 Evas_Coord tw = 0, th = 0, p;
120 int l, r;
121 int i;
122 char *buf;
123 int uc1 = -1, uc2 = -1, c1 = -1, c2 = -1;
124 int loop = 0, extra;
125 size_t orig_len;
126 FLOAT_T sc;
127
128 sc = ed->scale;
129 if (sc == ZERO) sc = _edje_scale;
130
131 *free_text = 0;
132 if (sw <= 1) return "";
133
134 if (ep->part->scale) evas_object_scale_set(ep->object, TO_DOUBLE(sc));
135 evas_object_text_font_set(ep->object, font, size);
136 evas_object_text_text_set(ep->object, text);
137
138 part_get_geometry(ep, &tw, &th);
139 evas_object_text_style_pad_get(ep->object, &l, &r, NULL, NULL);
140
141 p = ((sw - tw) * params->type.text.elipsis);
142
143 /* chop chop */
144 if (tw > sw)
145 {
146 if (params->type.text.elipsis != 0.0)
147 /* should be the last in text! not the rightmost */
148 uc1 = evas_object_text_last_up_to_pos(ep->object,
149 -p + l, th / 2);
150 if (params->type.text.elipsis != 1.0)
151 {
152 /* should be the last in text! not the rightmost */
153 if ((-p + sw -r) < 0)
154 uc2 = evas_object_text_last_up_to_pos(ep->object, 0, th / 2);
155 else
156 uc2 = evas_object_text_last_up_to_pos(ep->object,
157 -p + sw - r, th / 2);
158 }
159 if ((uc1 < 0) && (uc2 < 0))
160 {
161 uc1 = 0;
162 uc2 = 0;
163 }
164 }
165
166 if (!(((uc1 >= 0) || (uc2 >= 0)) && (tw > sw)))
167 return text;
168
169 if ((uc1 == 0) && (uc2 == 0))
170 return text;
171
172 orig_len = strlen(text);
173
174 /* don't overflow orig_len by adding extra
175 * FIXME: we might want to set a max string length somewhere...
176 */
177 extra = 1 + 3 + 3; /* terminator, leading and trailing ellipsis */
178 orig_len = MIN(orig_len, ((size_t) 8192 - extra));
179
180 if (!(buf = malloc(orig_len + extra)))
181 return text;
182
183 /* Convert uc1, uc2 -> c1, c2 */
184 i = 0;
185 if (uc1 >= 0)
186 {
187 c1 = 0;
188 for ( ; i < uc1 ; i++)
189 {
190 c1 = evas_string_char_next_get(text, c1, NULL);
191 }
192 }
193 if (uc2 >= 0)
194 {
195 if (c1 >= 0)
196 {
197 c2 = c1;
198 }
199 else
200 {
201 c2 = 0;
202 }
203 for ( ; i < uc2 ; i++)
204 {
205 c2 = evas_string_char_next_get(text, c2, NULL);
206 }
207 }
208
209 buf[0] = '\0';
210
211 while (((c1 >= 0) || (c2 >= 0)) && (tw > sw))
212 {
213 loop++;
214 if (sw <= 0.0)
215 {
216 buf[0] = 0;
217 break;
218 }
219 if ((c1 >= 0) && (c2 >= 0))
220 {
221 if ((loop & 0x1))
222 {
223 if (c1 >= 0)
224 c1 = evas_string_char_next_get(text, c1, NULL);
225 }
226 else
227 {
228 if (c2 >= 0)
229 {
230 c2 = evas_string_char_prev_get(text, c2, NULL);
231 if (c2 < 0)
232 {
233 buf[0] = 0;
234 break;
235 }
236 }
237 }
238 }
239 else
240 {
241 if (c1 >= 0)
242 c1 = evas_string_char_next_get(text, c1, NULL);
243 else if (c2 >= 0)
244 {
245 c2 = evas_string_char_prev_get(text, c2, NULL);
246 if (c2 < 0)
247 {
248 buf[0] = 0;
249 break;
250 }
251 }
252 }
253 if ((c1 >= 0) && (c2 >= 0))
254 {
255 if (c1 >= c2)
256 {
257 buf[0] = 0;
258 break;
259 }
260 }
261 else if ((c1 > 0 && (size_t) c1 >= orig_len) || c2 == 0)
262 {
263 buf[0] = 0;
264 break;
265 }
266
267 buf[0] = 0;
268
269 _edje_text_fit_set(buf, text, c1, c2);
270
271 evas_object_text_text_set(ep->object, buf);
272 part_get_geometry(ep, &tw, &th);
273 }
274
275 *free_text = 1;
276
277 return buf;
278}
279
280static const char *
281_edje_text_font_get(const char *base, const char *new, char **free_later)
282{
283 const char *base_style, *new_style, *aux;
284 size_t font_len, style_len;
285
286 if (base && (!new))
287 return base;
288 else if (!base)
289 return new;
290
291 base_style = strstr(base, ":style=");
292 if (!base_style)
293 return new;
294
295 new_style = strstr(new, ":style=");
296 if (new_style)
297 return new;
298
299 font_len = strlen(new);
300 aux = strchr(base_style, ',');
301 style_len = (aux) ? (size_t)(aux - base_style) : strlen(base_style);
302
303 *free_later = malloc(font_len + style_len + 1);
304 memcpy(*free_later, new, font_len);
305 memcpy(*free_later + font_len, base_style, style_len);
306 (*free_later)[font_len + style_len] = '\0';
307
308 return *free_later;
309}
310
311const char *
312_edje_text_class_font_get(Edje *ed, Edje_Part_Description_Text *chosen_desc, int *size, char **free_later)
313{
314 Edje_Text_Class *tc;
315 const char *text_class_name, *font;
316
317 font = edje_string_get(&chosen_desc->text.font);
318 *size = chosen_desc->text.size;
319
320 text_class_name = chosen_desc->text.text_class;
321 if ((!text_class_name) || (!text_class_name[0]))
322 return font;
323
324 tc = _edje_text_class_find(ed, text_class_name);
325 if (!tc)
326 return font;
327
328 font = _edje_text_font_get(edje_string_get(&chosen_desc->text.font), tc->font, free_later);
329 *size = _edje_text_size_calc(*size, tc);
330
331 return font;
332}
333
334void
335_edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
336 Edje_Calc_Params *params,
337 Edje_Part_Description_Text *chosen_desc)
338{
339 const char *text = NULL;
340 const char *font;
341 char *font2 = NULL;
342 char *sfont = NULL;
343 int size;
344 Evas_Coord tw, th;
345 Evas_Coord sw, sh;
346 int inlined_font = 0, free_text = 0;
347 Eina_Bool same_text = EINA_FALSE;
348 FLOAT_T sc;
349
350 sc = ed->scale;
351 if (sc == 0.0) sc = _edje_scale;
352 text = edje_string_get(&chosen_desc->text.text);
353 font = _edje_text_class_font_get(ed, chosen_desc, &size, &sfont);
354
355 if (ep->text.text) text = ep->text.text;
356 if (ep->text.font) font = ep->text.font;
357 if (ep->text.size > 0) size = ep->text.size;
358
359 if (ep->text.text_source)
360 {
361 text = edje_string_get(&(((Edje_Part_Description_Text *)ep->text.text_source->chosen_description)->text.text));
362 if (ep->text.text_source->text.text) text = ep->text.text_source->text.text;
363 }
364 if (ep->text.source)
365 {
366 font = edje_string_get(&(((Edje_Part_Description_Text *)ep->text.source->chosen_description)->text.font));
367 size = ((Edje_Part_Description_Text *)ep->text.source->chosen_description)->text.size;
368 if (ep->text.source->text.font) font = ep->text.source->text.font;
369 if (ep->text.source->text.size > 0) size = ep->text.source->text.size;
370 }
371
372 if (!text) text = "";
373 if (!font) font = "";
374
375 /* check if the font is embedded in the .eet */
376 if (ed->file->fonts)
377 {
378 Edje_Font_Directory_Entry *fnt = eina_hash_find(ed->file->fonts, font);
379
380 if (fnt)
381 {
382 size_t len = strlen(font) + sizeof("edje/fonts/") + 1;
383 font2 = alloca(len);
384 sprintf(font2, "edje/fonts/%s", font);
385 font = font2;
386 inlined_font = 1;
387 font2 = NULL;
388 }
389 }
390
391 if ((_edje_fontset_append) && (font))
392 {
393 font2 = malloc(strlen(font) + 1 + strlen(_edje_fontset_append) + 1);
394 if (font2)
395 {
396 strcpy(font2, font);
397 strcat(font2, ",");
398 strcat(font2, _edje_fontset_append);
399 font = font2;
400 }
401 }
402 {
403 int l, r, t, b;
404
405 evas_object_text_style_pad_get(ep->object, &l, &r, &t, &b);
406 sw = params->w;
407 sh = params->h;
408 }
409
410 size = params->type.text.size;
411 if (!text) text = "";
412
413 if ((text == ep->text.cache.in_str)
414 || (text && ep->text.cache.in_str && !strcmp(ep->text.cache.in_str, text)))
415 {
416 text = ep->text.cache.in_str;
417 same_text = EINA_TRUE;
418 }
419
420 if ((ep->text.cache.in_size == size) &&
421 (ep->text.cache.in_w == sw) &&
422 (ep->text.cache.in_h == sh) &&
423 (ep->text.cache.in_str) &&
424 same_text &&
425 (ep->text.cache.align_x == params->type.text.align.x) &&
426 (ep->text.cache.align_y == params->type.text.align.y) &&
427 (ep->text.cache.elipsis == params->type.text.elipsis) &&
428 (ep->text.cache.fit_x == chosen_desc->text.fit_x) &&
429 (ep->text.cache.fit_y == chosen_desc->text.fit_y))
430 {
431 text = ep->text.cache.out_str;
432 size = ep->text.cache.out_size;
433
434 goto arrange_text;
435 }
436 if (!same_text)
437 {
438 eina_stringshare_replace(&ep->text.cache.in_str, text);
439 }
440 ep->text.cache.in_size = size;
441 if (chosen_desc->text.fit_x && (ep->text.cache.in_str && eina_stringshare_strlen(ep->text.cache.in_str) > 0))
442 {
443 if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path);
444 else evas_object_text_font_source_set(ep->object, NULL);
445
446 if (ep->part->scale) evas_object_scale_set(ep->object, TO_DOUBLE(sc));
447 evas_object_text_font_set(ep->object, font, size);
448 evas_object_text_text_set(ep->object, text);
449 part_get_geometry(ep, &tw, &th);
450 /* Find the wanted font size */
451 if ((tw != sw) && (size > 0) && (tw != 0))
452 {
453 size = (size * sw) / tw;
454
455 if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path);
456 else evas_object_text_font_source_set(ep->object, NULL);
457
458 if (ep->part->scale) evas_object_scale_set(ep->object, TO_DOUBLE(sc));
459 evas_object_text_font_set(ep->object, font, size);
460 part_get_geometry(ep, &tw, &th);
461 }
462
463 /* FIXME: This should possibly be replaced by more proper handling,
464 * but it's still way better than what was here before. */
465 if (tw > sw) size--;
466 }
467 if (chosen_desc->text.fit_y && (ep->text.cache.in_str && eina_stringshare_strlen(ep->text.cache.in_str) > 0))
468 {
469 /* if we fit in the x axis, too, size already has a somewhat
470 * meaningful value, so don't overwrite it with the starting
471 * value in that case
472 */
473 if (!chosen_desc->text.fit_x) size = sh;
474
475 if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path);
476 else evas_object_text_font_source_set(ep->object, NULL);
477
478 if (ep->part->scale) evas_object_scale_set(ep->object, TO_DOUBLE(sc));
479 evas_object_text_font_set(ep->object, font, size);
480 evas_object_text_text_set(ep->object, text);
481 part_get_geometry(ep, &tw, &th);
482
483 /* only grow the font size if we didn't already reach the max size
484 * for the x axis
485 */
486 if (!chosen_desc->text.fit_x && th < sh)
487 {
488 int dif;
489
490 dif = (th - sh) / 4;
491 if (dif < 1) dif = 1;
492 while ((th < sh) && (sw > 0))
493 {
494 size += dif;
495 if (size <= 0) break;
496 if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path);
497 else evas_object_text_font_source_set(ep->object, NULL);
498
499 if (ep->part->scale) evas_object_scale_set(ep->object, TO_DOUBLE(sc));
500 evas_object_text_font_set(ep->object, font, size);
501 part_get_geometry(ep, &tw, &th);
502 if ((size > 0) && (th == 0)) break;
503 }
504 size -= dif;
505 }
506 else if (th > sh)
507 {
508 int current;
509
510 if (ep->part->scale) evas_object_scale_set(ep->object, TO_DOUBLE(sc));
511 evas_object_text_font_set(ep->object, font, 10);
512 part_get_geometry(ep, &tw, &th);
513
514 if (th == sh)
515 current = 10;
516 else
517 {
518 int bottom, top;
519
520 if (th < sh) bottom = 10;
521 else if (th > sh) bottom = 1;
522 else bottom = 0; /* XXX shut up GCC, th == sh is handled before! */
523
524 top = size;
525 /* search one that fits (binary search) */
526 do
527 {
528 current = (top + bottom) / 2;
529
530 if (ep->part->scale) evas_object_scale_set(ep->object, TO_DOUBLE(sc));
531 evas_object_text_font_set(ep->object, font, current);
532 part_get_geometry(ep, &tw, &th);
533
534 if (th < sh) bottom = current + 1;
535 else if (th > sh) top = current - 1;
536 } while ((bottom < top) && (th != sh));
537 }
538
539 /* search the larger one that fits (linear search) */
540 do
541 {
542 current++;
543
544 if (ep->part->scale) evas_object_scale_set(ep->object, TO_DOUBLE(sc));
545 evas_object_text_font_set(ep->object, font, current);
546 part_get_geometry(ep, &tw, &th);
547 } while (th <= sh);
548 size = current - 1;
549 }
550 }
551
552 /* Make sure the size is in range */
553 if (size < 1)
554 size = 1;
555 else if ((size > chosen_desc->text.size_range_max) &&
556 (chosen_desc->text.size_range_max > 0))
557 size = chosen_desc->text.size_range_max;
558 else if (size < chosen_desc->text.size_range_min)
559 size = chosen_desc->text.size_range_min;
560
561 /* Handle ellipsis */
562 if (!chosen_desc->text.min_x)
563 {
564 if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path);
565 else evas_object_text_font_source_set(ep->object, NULL);
566
567 text = _edje_text_fit_x(ed, ep, params, text, font, size, sw, &free_text);
568 }
569
570 eina_stringshare_replace(&ep->text.cache.out_str, text);
571 ep->text.cache.in_w = sw;
572 ep->text.cache.in_h = sh;
573 ep->text.cache.out_size = size;
574 ep->text.cache.align_x = params->type.text.align.x;
575 ep->text.cache.align_y = params->type.text.align.y;
576 ep->text.cache.elipsis = params->type.text.elipsis;
577 ep->text.cache.fit_x = chosen_desc->text.fit_x;
578 ep->text.cache.fit_y = chosen_desc->text.fit_y;
579 arrange_text:
580
581 if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path);
582 else evas_object_text_font_source_set(ep->object, NULL);
583
584 if (ep->part->scale) evas_object_scale_set(ep->object, TO_DOUBLE(sc));
585 evas_object_text_font_set(ep->object, font, size);
586 evas_object_text_text_set(ep->object, text);
587 part_get_geometry(ep, &tw, &th);
588 /* Handle alignment */
589 {
590 double align_x;
591 if (params->type.text.align.x < 0.0)
592 {
593 if (evas_object_text_direction_get(ep->object) ==
594 EVAS_BIDI_DIRECTION_RTL)
595 {
596 align_x = 1.0;
597 }
598 else
599 {
600 align_x = 0.0;
601 }
602 }
603 else
604 {
605 align_x = params->type.text.align.x;
606 }
607 ep->text.offset.x = TO_INT(SCALE(align_x, (sw - tw)));
608 ep->text.offset.y = TO_INT(SCALE(params->type.text.align.y, (sh - th)));
609 }
610
611 evas_object_move(ep->object,
612 ed->x + params->x + ep->text.offset.x,
613 ed->y + params->y + ep->text.offset.y);
614
615 if (params->visible) evas_object_show(ep->object);
616 else evas_object_hide(ep->object);
617 {
618 Evas_Text_Style_Type style;
619 Edje_Text_Effect effect;
620
621 style = EVAS_TEXT_STYLE_PLAIN;
622
623 evas_object_color_set(ep->object,
624 (params->color.r * params->color.a) / 255,
625 (params->color.g * params->color.a) / 255,
626 (params->color.b * params->color.a) / 255,
627 params->color.a);
628 effect = ep->part->effect;
629 switch (effect & EDJE_TEXT_EFFECT_MASK_BASIC)
630 {
631 case EDJE_TEXT_EFFECT_NONE:
632 case EDJE_TEXT_EFFECT_PLAIN:
633 style = EVAS_TEXT_STYLE_PLAIN;
634 break;
635 case EDJE_TEXT_EFFECT_OUTLINE:
636 style = EVAS_TEXT_STYLE_OUTLINE;
637 evas_object_text_outline_color_set(ep->object,
638 (params->type.text.color2.r * params->type.text.color2.a) / 255,
639 (params->type.text.color2.g * params->type.text.color2.a) / 255,
640 (params->type.text.color2.b * params->type.text.color2.a) / 255,
641 params->type.text.color2.a);
642 break;
643 case EDJE_TEXT_EFFECT_SOFT_OUTLINE:
644 style = EVAS_TEXT_STYLE_SOFT_OUTLINE;
645 evas_object_text_outline_color_set(ep->object,
646 (params->type.text.color2.r * params->type.text.color2.a) / 255,
647 (params->type.text.color2.g * params->type.text.color2.a) / 255,
648 (params->type.text.color2.b * params->type.text.color2.a) / 255,
649 params->type.text.color2.a);
650 break;
651 case EDJE_TEXT_EFFECT_SHADOW:
652 style = EVAS_TEXT_STYLE_SHADOW;
653 evas_object_text_shadow_color_set(ep->object,
654 (params->type.text.color3.r * params->type.text.color3.a) / 255,
655 (params->type.text.color3.g * params->type.text.color3.a) / 255,
656 (params->type.text.color3.b * params->type.text.color3.a) / 255,
657 params->type.text.color3.a);
658 break;
659 case EDJE_TEXT_EFFECT_SOFT_SHADOW:
660 style = EVAS_TEXT_STYLE_SOFT_SHADOW;
661 evas_object_text_shadow_color_set(ep->object,
662 (params->type.text.color3.r * params->type.text.color3.a) / 255,
663 (params->type.text.color3.g * params->type.text.color3.a) / 255,
664 (params->type.text.color3.b * params->type.text.color3.a) / 255,
665 params->type.text.color3.a);
666 break;
667 case EDJE_TEXT_EFFECT_OUTLINE_SHADOW:
668 style = EVAS_TEXT_STYLE_OUTLINE_SHADOW;
669 evas_object_text_outline_color_set(ep->object,
670 (params->type.text.color2.r * params->type.text.color2.a) / 255,
671 (params->type.text.color2.g * params->type.text.color2.a) / 255,
672 (params->type.text.color2.b * params->type.text.color2.a) / 255,
673 params->type.text.color2.a);
674 evas_object_text_shadow_color_set(ep->object,
675 (params->type.text.color3.r * params->type.text.color3.a) / 255,
676 (params->type.text.color3.g * params->type.text.color3.a) / 255,
677 (params->type.text.color3.b * params->type.text.color3.a) / 255,
678 params->type.text.color3.a);
679 break;
680 case EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW:
681 style = EVAS_TEXT_STYLE_OUTLINE_SOFT_SHADOW;
682 evas_object_text_outline_color_set(ep->object,
683 (params->type.text.color2.r * params->type.text.color2.a) / 255,
684 (params->type.text.color2.g * params->type.text.color2.a) / 255,
685 (params->type.text.color2.b * params->type.text.color2.a) / 255,
686 params->type.text.color2.a);
687 evas_object_text_shadow_color_set(ep->object,
688 (params->type.text.color3.r * params->type.text.color3.a) / 255,
689 (params->type.text.color3.g * params->type.text.color3.a) / 255,
690 (params->type.text.color3.b * params->type.text.color3.a) / 255,
691 params->type.text.color3.a);
692 break;
693 case EDJE_TEXT_EFFECT_FAR_SHADOW:
694 style = EVAS_TEXT_STYLE_FAR_SHADOW;
695 evas_object_text_shadow_color_set(ep->object,
696 (params->type.text.color3.r * params->type.text.color3.a) / 255,
697 (params->type.text.color3.g * params->type.text.color3.a) / 255,
698 (params->type.text.color3.b * params->type.text.color3.a) / 255,
699 params->type.text.color3.a);
700 break;
701 case EDJE_TEXT_EFFECT_FAR_SOFT_SHADOW:
702 style = EVAS_TEXT_STYLE_FAR_SOFT_SHADOW;
703 evas_object_text_shadow_color_set(ep->object,
704 (params->type.text.color3.r * params->type.text.color3.a) / 255,
705 (params->type.text.color3.g * params->type.text.color3.a) / 255,
706 (params->type.text.color3.b * params->type.text.color3.a) / 255,
707 params->type.text.color3.a);
708 break;
709 case EDJE_TEXT_EFFECT_GLOW:
710 style = EVAS_TEXT_STYLE_GLOW;
711 evas_object_text_glow_color_set(ep->object,
712 (params->type.text.color2.r * params->type.text.color2.a) / 255,
713 (params->type.text.color2.g * params->type.text.color2.a) / 255,
714 (params->type.text.color2.b * params->type.text.color2.a) / 255,
715 params->type.text.color2.a);
716 evas_object_text_glow2_color_set(ep->object,
717 (params->type.text.color3.r * params->type.text.color3.a) / 255,
718 (params->type.text.color3.g * params->type.text.color3.a) / 255,
719 (params->type.text.color3.b * params->type.text.color3.a) / 255,
720 params->type.text.color3.a);
721 break;
722 default:
723 style = EVAS_TEXT_STYLE_PLAIN;
724 break;
725 }
726
727 switch (effect & EDJE_TEXT_EFFECT_MASK_SHADOW_DIRECTION)
728 {
729 case EDJE_TEXT_EFFECT_SHADOW_DIRECTION_BOTTOM_RIGHT:
730 EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET
731 (style, EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_RIGHT);
732 break;
733 case EDJE_TEXT_EFFECT_SHADOW_DIRECTION_BOTTOM:
734 EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET
735 (style, EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM);
736 break;
737 case EDJE_TEXT_EFFECT_SHADOW_DIRECTION_BOTTOM_LEFT:
738 EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET
739 (style, EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_LEFT);
740 break;
741 case EDJE_TEXT_EFFECT_SHADOW_DIRECTION_LEFT:
742 EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET
743 (style, EVAS_TEXT_STYLE_SHADOW_DIRECTION_LEFT);
744 break;
745 case EDJE_TEXT_EFFECT_SHADOW_DIRECTION_TOP_LEFT:
746 EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET
747 (style, EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_LEFT);
748 break;
749 case EDJE_TEXT_EFFECT_SHADOW_DIRECTION_TOP:
750 EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET
751 (style, EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP);
752 break;
753 case EDJE_TEXT_EFFECT_SHADOW_DIRECTION_TOP_RIGHT:
754 EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET
755 (style, EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_RIGHT);
756 break;
757 case EDJE_TEXT_EFFECT_SHADOW_DIRECTION_RIGHT:
758 EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET
759 (style, EVAS_TEXT_STYLE_SHADOW_DIRECTION_RIGHT);
760 break;
761 default:
762 break;
763 }
764 evas_object_text_style_set(ep->object, style);
765 }
766
767 if (free_text) free((char *)text);
768 if (font2) free(font2);
769 if (sfont) free(sfont);
770}
771
772Evas_Font_Size
773_edje_text_size_calc(Evas_Font_Size size, Edje_Text_Class *tc)
774{
775 int val;
776
777 if (tc->size == 0)
778 {
779 val = size;
780 }
781 else if (tc->size > 0.0)
782 {
783 val = tc->size;
784 }
785 else
786 {
787 val = (size * -tc->size) / 100;
788 }
789 return val;
790}
diff --git a/libraries/edje/src/lib/edje_textblock_styles.c b/libraries/edje/src/lib/edje_textblock_styles.c
new file mode 100644
index 0000000..13a68ad
--- /dev/null
+++ b/libraries/edje/src/lib/edje_textblock_styles.c
@@ -0,0 +1,424 @@
1#include "edje_private.h"
2
3static int
4_edje_font_is_embedded(Edje_File *edf, char *font)
5{
6 if (!eina_hash_find(edf->fonts, font)) return 0;
7 return 1;
8}
9
10static void
11_edje_format_param_parse(char *item, char **key, char **val)
12{
13 char *p, *k, *v;
14
15 p = strchr(item, '=');
16 k = malloc(p - item + 1);
17 strncpy(k, item, p - item);
18 k[p - item] = 0;
19 *key = k;
20 p++;
21 v = strdup(p);
22 *val = v;
23}
24
25static char *
26_edje_format_parse(const char **s)
27{
28 char *item, *ds;
29 const char *p, *ss;
30 const char *s1 = NULL;
31 const char *s2 = NULL;
32
33 p = *s;
34 if ((!p) || (*p == 0)) return NULL;
35 for (;;)
36 {
37 if (!s1)
38 {
39 if (*p != ' ') s1 = p;
40 if (*p == 0) break;
41 }
42 else if (!s2)
43 {
44 if ((p > *s) && (p[-1] != '\\'))
45 {
46 if (*p == ' ') s2 = p;
47 }
48 if (*p == 0) s2 = p;
49 }
50 p++;
51 if (s1 && s2)
52 {
53 item = malloc(s2 - s1 + 1);
54 if (item)
55 {
56 for (ds = item, ss = s1; ss < s2; ss++, ds++)
57 {
58 if ((*ss == '\\') && (ss < (s2 - 1))) ss++;
59 *ds = *ss;
60 }
61 *ds = 0;
62 }
63 *s = s2;
64 return item;
65 }
66 }
67 *s = p;
68 return NULL;
69}
70
71static int
72_edje_format_is_param(char *item)
73{
74 if (strchr(item, '=')) return 1;
75 return 0;
76}
77
78static char *
79_edje_format_reparse(Edje_File *edf, const char *str, Edje_Style_Tag **tag_ret)
80{
81 Eina_Strbuf *txt, *tmp = NULL;
82 char *s2, *item, *ret;
83 const char *s;
84
85 txt = eina_strbuf_new();
86 s = str;
87 while ((item = _edje_format_parse(&s)))
88 {
89 if (_edje_format_is_param(item))
90 {
91 char *key = NULL, *val = NULL;
92
93 _edje_format_param_parse(item, &key, &val);
94 if (!strcmp(key, "font_source"))
95 {
96 /* dont allow font sources */
97 }
98 else if (!strcmp(key, "text_class"))
99 {
100 if (tag_ret)
101 (*tag_ret)->text_class = eina_stringshare_add(val);
102 }
103 else if (!strcmp(key, "font_size"))
104 {
105 if (tag_ret)
106 (*tag_ret)->font_size = atof(val);
107 }
108 else if (!strcmp(key, "font")) /* Fix fonts */
109 {
110 if (tag_ret)
111 {
112 if (_edje_font_is_embedded(edf, val))
113 {
114 if (!tmp)
115 tmp = eina_strbuf_new();
116 eina_strbuf_append(tmp, "edje/fonts/");
117 eina_strbuf_append(tmp, val);
118 (*tag_ret)->font = eina_stringshare_add(eina_strbuf_string_get(tmp));
119 eina_strbuf_reset(tmp);
120 }
121 else
122 {
123 (*tag_ret)->font = eina_stringshare_add(val);
124 }
125 }
126 }
127 else /* Otherwise add to tag buffer */
128 {
129 s2 = eina_str_escape(item);
130 if (s2)
131 {
132 if (eina_strbuf_length_get(txt)) eina_strbuf_append(txt, " ");
133 eina_strbuf_append(txt, s2);
134 free(s2);
135 }
136 }
137 free(key);
138 free(val);
139 }
140 else
141 {
142 if (eina_strbuf_length_get(txt)) eina_strbuf_append(txt, " ");
143 eina_strbuf_append(txt, item);
144 }
145 free(item);
146 }
147 if (tmp)
148 eina_strbuf_free(tmp);
149 ret = eina_strbuf_string_steal(txt);
150 eina_strbuf_free(txt);
151 return ret;
152}
153
154/* Update all evas_styles which are in an edje
155 *
156 * @param ed The edje containing styles which need to be updated
157 */
158void
159_edje_textblock_style_all_update(Edje *ed)
160{
161 Eina_List *l, *ll;
162 Edje_Style *stl;
163 Eina_Strbuf *txt = NULL;
164
165 if (!ed->file) return;
166
167 EINA_LIST_FOREACH(ed->file->styles, l, stl)
168 {
169 Edje_Style_Tag *tag;
170 Edje_Text_Class *tc;
171 int found = 0;
172 char *fontset = NULL, *fontsource = NULL;
173
174 /* Make sure the style is already defined */
175 if (!stl->style) break;
176
177 /* Make sure the style contains a text_class */
178 EINA_LIST_FOREACH(stl->tags, ll, tag)
179 if (tag->text_class) found = 1;
180
181 /* No text classes , goto next style */
182 if (!found) continue;
183 found = 0;
184 if (!txt)
185 txt = eina_strbuf_new();
186
187 if (_edje_fontset_append)
188 fontset = eina_str_escape(_edje_fontset_append);
189 fontsource = eina_str_escape(ed->file->path);
190
191 /* Build the style from each tag */
192 EINA_LIST_FOREACH(stl->tags, ll, tag)
193 {
194 if (!tag->key) continue;
195
196 /* Add Tag Key */
197 eina_strbuf_append(txt, tag->key);
198 eina_strbuf_append(txt, "='");
199
200 /* Configure fonts from text class if it exists */
201 if ((tc = _edje_text_class_find(ed, tag->text_class)))
202 {
203 /* Only update if not clearing, If clear leave it at zero */
204 if (tc->font) found = 1;
205 }
206
207 /* Add and Ha`ndle tag parsed data */
208 eina_strbuf_append(txt, tag->value);
209
210 if (!strcmp(tag->key, "DEFAULT"))
211 {
212 if (fontset)
213 {
214 eina_strbuf_append(txt, " ");
215 eina_strbuf_append(txt, "font_fallbacks=");
216 eina_strbuf_append(txt, fontset);
217 }
218 eina_strbuf_append(txt, " ");
219 eina_strbuf_append(txt, "font_source=");
220 eina_strbuf_append(txt, fontsource);
221 }
222 if (tag->font_size != 0)
223 {
224 char font_size[32];
225
226 if (found)
227 snprintf(font_size, sizeof(font_size), "%f", (double) _edje_text_size_calc(tag->font_size, tc));
228 else
229 snprintf(font_size, sizeof(font_size), "%f", tag->font_size);
230
231 eina_strbuf_append(txt, " ");
232 eina_strbuf_append(txt, "font_size=");
233 eina_strbuf_append(txt, font_size);
234 }
235 /* Add font name last to save evas from multiple loads */
236 if (tag->font)
237 {
238 const char *f;
239
240 eina_strbuf_append(txt, " ");
241 eina_strbuf_append(txt, "font=");
242
243 f = (found) ? tc->font : tag->font;
244 eina_strbuf_append_escaped(txt, f);
245 }
246 found = 0;
247
248 eina_strbuf_append(txt, "'");
249 }
250 if (fontset) free(fontset);
251 if (fontsource) free(fontsource);
252
253 /* Configure the style */
254 evas_textblock_style_set(stl->style, eina_strbuf_string_get(txt));
255 eina_strbuf_reset(txt);
256 }
257 if (txt)
258 eina_strbuf_free(txt);
259}
260
261void
262_edje_textblock_styles_add(Edje *ed)
263{
264 Eina_List *l, *ll;
265 Edje_Style *stl;
266
267 if (!ed->file) return;
268
269 EINA_LIST_FOREACH(ed->file->styles, l, stl)
270 {
271 Edje_Style_Tag *tag;
272
273 /* Make sure the style contains the text_class */
274 EINA_LIST_FOREACH(stl->tags, ll, tag)
275 {
276 if (!tag->text_class) continue;
277 _edje_text_class_member_add(ed, tag->text_class);
278 }
279 }
280}
281
282void
283_edje_textblock_styles_del(Edje *ed)
284{
285 Eina_List *l, *ll;
286 Edje_Style *stl;
287
288 if (!ed->file) return;
289
290 EINA_LIST_FOREACH(ed->file->styles, l, stl)
291 {
292 Edje_Style_Tag *tag;
293
294 /* Make sure the style contains the text_class */
295 EINA_LIST_FOREACH(stl->tags, ll, tag)
296 {
297 if (!tag->text_class) continue;
298 _edje_text_class_member_del(ed, tag->text_class);
299 }
300 }
301}
302
303/* When we get to here the edje file had been read into memory
304 * the name of the style is established as well as the name and
305 * data for the tags. This function will create the Evas_Style
306 * object for each style. The style is composed of a base style
307 * followed by a list of tags.
308 */
309void
310_edje_textblock_style_parse_and_fix(Edje_File *edf)
311{
312 Eina_Strbuf *txt = NULL;
313 Eina_List *l, *ll;
314 Edje_Style *stl;
315
316 EINA_LIST_FOREACH(edf->styles, l, stl)
317 {
318 Edje_Style_Tag *tag;
319 char *fontset = NULL, *fontsource = NULL, *ts;
320
321 if (stl->style) break;
322
323 if (!txt)
324 txt = eina_strbuf_new();
325
326 stl->style = evas_textblock_style_new();
327 evas_textblock_style_set(stl->style, NULL);
328
329 if (_edje_fontset_append)
330 fontset = eina_str_escape(_edje_fontset_append);
331 fontsource = eina_str_escape(edf->path);
332
333 /* Build the style from each tag */
334 EINA_LIST_FOREACH(stl->tags, ll, tag)
335 {
336 if (!tag->key) continue;
337
338 /* Add Tag Key */
339 eina_strbuf_append(txt, tag->key);
340 eina_strbuf_append(txt, "='");
341
342 ts = _edje_format_reparse(edf, tag->value, &(tag));
343
344 /* Add and Handle tag parsed data */
345 if (ts)
346 {
347 if (eet_dictionary_string_check(eet_dictionary_get(edf->ef), tag->value) == 0)
348 eina_stringshare_del(tag->value);
349 tag->value = eina_stringshare_add(ts);
350 eina_strbuf_append(txt, tag->value);
351 free(ts);
352 }
353
354 if (!strcmp(tag->key, "DEFAULT"))
355 {
356 if (fontset)
357 {
358 eina_strbuf_append(txt, " ");
359 eina_strbuf_append(txt, "font_fallbacks=");
360 eina_strbuf_append(txt, fontset);
361 }
362 eina_strbuf_append(txt, " ");
363 eina_strbuf_append(txt, "font_source=");
364 eina_strbuf_append(txt, fontsource);
365 }
366 if (tag->font_size > 0)
367 {
368 char font_size[32];
369
370 snprintf(font_size, sizeof(font_size), "%f", tag->font_size);
371 eina_strbuf_append(txt, " ");
372 eina_strbuf_append(txt, "font_size=");
373 eina_strbuf_append(txt, font_size);
374 }
375 /* Add font name last to save evas from multiple loads */
376 if (tag->font)
377 {
378 eina_strbuf_append(txt, " ");
379 eina_strbuf_append(txt, "font=");
380 eina_strbuf_append_escaped(txt, tag->font);
381 }
382 eina_strbuf_append(txt, "'");
383 }
384 if (fontset) free(fontset);
385 if (fontsource) free(fontsource);
386
387 /* Configure the style */
388 evas_textblock_style_set(stl->style, eina_strbuf_string_get(txt));
389 eina_strbuf_reset(txt);
390 }
391 if (txt)
392 eina_strbuf_free(txt);
393}
394
395void
396_edje_textblock_style_cleanup(Edje_File *edf)
397{
398 while (edf->styles)
399 {
400 Edje_Style *stl;
401
402 stl = edf->styles->data;
403 edf->styles = eina_list_remove_list(edf->styles, edf->styles);
404 while (stl->tags)
405 {
406 Edje_Style_Tag *tag;
407
408 tag = stl->tags->data;
409 stl->tags = eina_list_remove_list(stl->tags, stl->tags);
410 if (edf->free_strings)
411 {
412 if (tag->key) eina_stringshare_del(tag->key);
413/* FIXME: Find a proper way to handle it. */
414 if (tag->value) eina_stringshare_del(tag->value);
415 if (tag->text_class) eina_stringshare_del(tag->text_class);
416 if (tag->font) eina_stringshare_del(tag->font);
417 }
418 free(tag);
419 }
420 if (edf->free_strings && stl->name) eina_stringshare_del(stl->name);
421 if (stl->style) evas_textblock_style_free(stl->style);
422 free(stl);
423 }
424}
diff --git a/libraries/edje/src/lib/edje_util.c b/libraries/edje/src/lib/edje_util.c
new file mode 100644
index 0000000..dbb37a7
--- /dev/null
+++ b/libraries/edje/src/lib/edje_util.c
@@ -0,0 +1,4317 @@
1#include "edje_private.h"
2
3typedef struct _Edje_Box_Layout Edje_Box_Layout;
4struct _Edje_Box_Layout
5{
6 EINA_RBTREE;
7 Evas_Object_Box_Layout func;
8 void *(*layout_data_get)(void *);
9 void (*layout_data_free)(void *);
10 void *data;
11 void (*free_data)(void *);
12 char name[];
13};
14
15static Eina_Hash *_edje_color_class_hash = NULL;
16static Eina_Hash *_edje_color_class_member_hash = NULL;
17
18static Eina_Hash *_edje_text_class_hash = NULL;
19static Eina_Hash *_edje_text_class_member_hash = NULL;
20
21static Eina_Rbtree *_edje_box_layout_registry = NULL;
22
23char *_edje_fontset_append = NULL;
24FLOAT_T _edje_scale = ZERO;
25Eina_Bool _edje_password_show_last = EINA_FALSE;
26FLOAT_T _edje_password_show_last_timeout = ZERO;
27int _edje_freeze_val = 0;
28int _edje_freeze_calc_count = 0;
29Eina_List *_edje_freeze_calc_list = NULL;
30
31typedef struct _Edje_List_Foreach_Data Edje_List_Foreach_Data;
32struct _Edje_List_Foreach_Data
33{
34 Eina_List *list;
35};
36
37typedef struct _Edje_List_Refcount Edje_List_Refcount;
38struct _Edje_List_Refcount
39{
40 EINA_REFCOUNT;
41
42 Eina_List *lookup;
43};
44
45static Eina_Bool _edje_color_class_list_foreach(const Eina_Hash *hash, const void *key, void *data, void *fdata);
46static Eina_Bool _edje_text_class_list_foreach(const Eina_Hash *hash, const void *key, void *data, void *fdata);
47static void _edje_object_image_preload_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
48static void _edje_object_signal_preload_cb(void *data, Evas_Object *obj, const char *emission, const char *source);
49
50Edje_Real_Part *_edje_real_part_recursive_get_helper(const Edje *ed, char **path);
51
52
53static void
54_edje_class_member_direct_del(const char *class, Edje_List_Refcount *lookup, Eina_Hash *hash)
55{
56 Eina_List *members;
57
58 members = eina_hash_find(hash, class);
59 members = eina_list_remove_list(members, lookup->lookup);
60 eina_hash_set(hash, class, members);
61 free(lookup);
62}
63
64static void
65_edje_class_member_add(Edje *ed, Eina_Hash **ehash, Eina_Hash **ghash, const char *class)
66{
67 Edje_List_Refcount *lookup;
68 Eina_List *members;
69
70 if ((!ed) || (!ehash) || (!ghash) || (!class)) return;
71
72 lookup = eina_hash_find(*ehash, class);
73 if (lookup)
74 {
75 EINA_REFCOUNT_REF(lookup);
76 return;
77 }
78
79 lookup = malloc(sizeof (Edje_List_Refcount));
80 if (!lookup) return ;
81 EINA_REFCOUNT_INIT(lookup);
82
83 /* Get members list */
84 members = eina_hash_find(*ghash, class);
85
86 /* Update the member list */
87 lookup->lookup = members = eina_list_prepend(members, ed);
88
89 /* Don't loose track of members list */
90 if (!*ehash)
91 *ehash = eina_hash_string_small_new(NULL);
92 eina_hash_add(*ehash, class, lookup);
93
94 /* Reset the member list to the right pointer */
95 if (!*ghash)
96 *ghash = eina_hash_string_superfast_new(NULL);
97 eina_hash_set(*ghash, class, members);
98}
99
100static void
101_edje_class_member_del(Eina_Hash **ehash, Eina_Hash **ghash, const char *class)
102{
103 Edje_List_Refcount *lookup;
104 Eina_List *members;
105
106 if ((!ehash) || (!ghash) || (!class)) return;
107 members = eina_hash_find(*ghash, class);
108 if (!members) return;
109
110 lookup = eina_hash_find(*ehash, class);
111 if (!lookup) return ;
112
113 EINA_REFCOUNT_UNREF(lookup)
114 {
115 members = eina_list_remove_list(members, lookup->lookup);
116 eina_hash_set(*ghash, class, members);
117
118 eina_hash_del(*ehash, class, lookup);
119 free(lookup);
120 }
121}
122
123static Eina_Bool
124member_list_free(const Eina_Hash *hash __UNUSED__, const void *key __UNUSED__, void *data, void *fdata __UNUSED__)
125{
126 eina_list_free(data);
127 return EINA_TRUE;
128}
129
130static void
131_edje_class_members_free(Eina_Hash **ghash)
132{
133 if (!ghash || !*ghash) return;
134 eina_hash_foreach(*ghash, member_list_free, NULL);
135 eina_hash_free(*ghash);
136 *ghash = NULL;
137}
138
139/************************** API Routines **************************/
140
141#define FASTFREEZE 1
142
143EAPI void
144edje_freeze(void)
145{
146#ifdef FASTFREEZE
147 _edje_freeze_val++;
148 INF("fr ++ ->%i", _edje_freeze_val);
149#else
150// FIXME: could just have a global freeze instead of per object
151// above i tried.. but this broke some things. notable e17's menus. why?
152 Eina_List *l;
153 Evas_Object *data;
154
155 EINA_LIST_FOREACH(_edje_edjes, l, data)
156 edje_object_freeze(data);
157#endif
158}
159
160#ifdef FASTFREEZE
161static void
162_edje_thaw_edje(Edje *ed)
163{
164 unsigned int i;
165
166 for (i = 0; i < ed->table_parts_size; i++)
167 {
168 Edje_Real_Part *rp;
169
170 rp = ed->table_parts[i];
171 if (rp->part->type == EDJE_PART_TYPE_GROUP && rp->swallowed_object)
172 {
173 Edje *ed2;
174
175 ed2 = _edje_fetch(rp->swallowed_object);
176 if (ed2) _edje_thaw_edje(ed2);
177 }
178 }
179 if ((ed->recalc) && (ed->freeze <= 0)) _edje_recalc_do(ed);
180}
181#endif
182
183EAPI void
184edje_thaw(void)
185{
186#ifdef FASTFREEZE
187 _edje_freeze_val--;
188 INF("fr -- ->%i", _edje_freeze_val);
189 if ((_edje_freeze_val <= 0) && (_edje_freeze_calc_count > 0))
190 {
191 Edje *ed;
192
193 _edje_freeze_calc_count = 0;
194 EINA_LIST_FREE(_edje_freeze_calc_list, ed)
195 {
196 _edje_thaw_edje(ed);
197 ed->freeze_calc = 0;
198 }
199 }
200#else
201 Evas_Object *data;
202
203// FIXME: could just have a global freeze instead of per object
204// comment as above.. why?
205 Eina_List *l;
206
207 EINA_LIST_FOREACH(_edje_edjes, l, data)
208 edje_object_thaw(data);
209#endif
210}
211
212EAPI void
213edje_fontset_append_set(const char *fonts)
214{
215 if (_edje_fontset_append)
216 free(_edje_fontset_append);
217 _edje_fontset_append = fonts ? strdup(fonts) : NULL;
218}
219
220EAPI const char *
221edje_fontset_append_get(void)
222{
223 return _edje_fontset_append;
224}
225
226EAPI void
227edje_scale_set(double scale)
228{
229 Eina_List *l;
230 Evas_Object *data;
231
232 if (_edje_scale == FROM_DOUBLE(scale)) return;
233 _edje_scale = FROM_DOUBLE(scale);
234 EINA_LIST_FOREACH(_edje_edjes, l, data)
235 edje_object_calc_force(data);
236}
237
238EAPI double
239edje_scale_get(void)
240{
241 return TO_DOUBLE(_edje_scale);
242}
243
244EAPI void
245edje_password_show_last_set(Eina_Bool password_show_last)
246{
247 if (_edje_password_show_last == password_show_last) return;
248 _edje_password_show_last = password_show_last;
249}
250
251EAPI void
252edje_password_show_last_timeout_set(double password_show_last_timeout)
253{
254 if (_edje_password_show_last_timeout == FROM_DOUBLE(password_show_last_timeout)) return;
255 _edje_password_show_last_timeout = FROM_DOUBLE(password_show_last_timeout);
256}
257
258EAPI Eina_Bool
259edje_object_scale_set(Evas_Object *obj, double scale)
260{
261 Edje *ed;
262
263 ed = _edje_fetch(obj);
264 if (!ed) return EINA_FALSE;
265 if (ed->scale == scale) return EINA_TRUE;
266 ed->scale = FROM_DOUBLE(scale);
267 edje_object_calc_force(obj);
268 return EINA_TRUE;
269}
270
271EAPI double
272edje_object_scale_get(const Evas_Object *obj)
273{
274 Edje *ed;
275
276 ed = _edje_fetch(obj);
277 if (!ed) return 0.0;
278 return TO_DOUBLE(ed->scale);
279}
280
281EAPI Eina_Bool
282edje_object_mirrored_get(const Evas_Object *obj)
283{
284 Edje *ed;
285
286 ed = _edje_fetch(obj);
287 if (!ed) return EINA_FALSE;
288
289 return ed->is_rtl;
290}
291
292void
293_edje_object_orientation_inform(Evas_Object *obj)
294{
295 if (edje_object_mirrored_get(obj))
296 edje_object_signal_emit(obj, "edje,state,rtl", "edje");
297 else
298 edje_object_signal_emit(obj, "edje,state,ltr", "edje");
299}
300
301EAPI void
302edje_object_mirrored_set(Evas_Object *obj, Eina_Bool rtl)
303{
304 Edje *ed;
305 unsigned int i;
306
307 ed = _edje_fetch(obj);
308 if (!ed) return;
309 if (ed->is_rtl == rtl) return;
310
311 ed->is_rtl = rtl;
312
313 for (i = 0 ; i < ed->table_parts_size ; i++)
314 {
315 Edje_Real_Part *ep;
316 const char *s;
317 double v;
318
319 ep = ed->table_parts[i];
320 s = ep->param1.description->state.name,
321 v = ep->param1.description->state.value;
322 _edje_part_description_apply(ed, ep, s, v , NULL, 0.0);
323 ep->chosen_description = ep->param1.description;
324 }
325 _edje_recalc_do(ed);
326
327 _edje_object_orientation_inform(obj);
328
329 return;
330}
331
332EAPI const char *
333edje_object_data_get(const Evas_Object *obj, const char *key)
334{
335 Edje *ed;
336
337 ed = _edje_fetch(obj);
338 if ((!ed) || (!key))
339 return NULL;
340 if (!ed->collection) return NULL;
341 if (!ed->collection->data) return NULL;
342 return edje_string_get(eina_hash_find(ed->collection->data, key));
343}
344
345EAPI int
346edje_object_freeze(Evas_Object *obj)
347{
348 Edje *ed;
349 unsigned int i;
350
351 ed = _edje_fetch(obj);
352 if (!ed) return 0;
353 for (i = 0; i < ed->table_parts_size; i++)
354 {
355 Edje_Real_Part *rp;
356 rp = ed->table_parts[i];
357 if (rp->part->type == EDJE_PART_TYPE_GROUP && rp->swallowed_object)
358 edje_object_freeze(rp->swallowed_object);
359 }
360 return _edje_freeze(ed);
361}
362
363EAPI int
364edje_object_thaw(Evas_Object *obj)
365{
366 Edje *ed;
367 unsigned int i;
368
369 ed = _edje_fetch(obj);
370 if (!ed) return 0;
371 for (i = 0; i < ed->table_parts_size; i++)
372 {
373 Edje_Real_Part *rp;
374
375 rp = ed->table_parts[i];
376 if (rp->part->type == EDJE_PART_TYPE_GROUP && rp->swallowed_object)
377 edje_object_thaw(rp->swallowed_object);
378 }
379 return _edje_thaw(ed);
380}
381
382EAPI Eina_Bool
383edje_color_class_set(const char *color_class, int r, int g, int b, int a, int r2, int g2, int b2, int a2, int r3, int g3, int b3, int a3)
384{
385 Eina_List *members;
386 Edje_Color_Class *cc;
387
388 if (!color_class) return EINA_FALSE;
389
390 cc = eina_hash_find(_edje_color_class_hash, color_class);
391 if (!cc)
392 {
393 cc = calloc(1, sizeof(Edje_Color_Class));
394 if (!cc) return EINA_FALSE;
395 cc->name = eina_stringshare_add(color_class);
396 if (!cc->name)
397 {
398 free(cc);
399 return EINA_FALSE;
400 }
401 if (!_edje_color_class_hash)
402 _edje_color_class_hash = eina_hash_string_superfast_new(NULL);
403 eina_hash_add(_edje_color_class_hash, color_class, cc);
404 }
405
406 if (r < 0) r = 0;
407 else if (r > 255) r = 255;
408 if (g < 0) g = 0;
409 else if (g > 255) g = 255;
410 if (b < 0) b = 0;
411 else if (b > 255) b = 255;
412 if (a < 0) a = 0;
413 else if (a > 255) a = 255;
414 if ((cc->r == r) && (cc->g == g) &&
415 (cc->b == b) && (cc->a == a) &&
416 (cc->r2 == r2) && (cc->g2 == g2) &&
417 (cc->b2 == b2) && (cc->a2 == a2) &&
418 (cc->r3 == r3) && (cc->g3 == g3) &&
419 (cc->b3 == b3) && (cc->a3 == a3))
420 return EINA_TRUE;
421 cc->r = r;
422 cc->g = g;
423 cc->b = b;
424 cc->a = a;
425 cc->r2 = r2;
426 cc->g2 = g2;
427 cc->b2 = b2;
428 cc->a2 = a2;
429 cc->r3 = r3;
430 cc->g3 = g3;
431 cc->b3 = b3;
432 cc->a3 = a3;
433
434 members = eina_hash_find(_edje_color_class_member_hash, color_class);
435 while (members)
436 {
437 Edje *ed;
438
439 ed = eina_list_data_get(members);
440 ed->dirty = 1;
441#ifdef EDJE_CALC_CACHE
442 ed->all_part_change = 1;
443#endif
444 _edje_recalc(ed);
445 _edje_emit(ed, "color_class,set", color_class);
446 members = eina_list_next(members);
447 }
448 return EINA_TRUE;
449}
450
451EAPI Eina_Bool
452edje_color_class_get(const char *color_class, int *r, int *g, int *b, int *a, int *r2, int *g2, int *b2, int *a2, int *r3, int *g3, int *b3, int *a3)
453{
454 Edje_Color_Class *cc;
455
456 if (!color_class)
457 cc = NULL;
458 else
459 cc = eina_hash_find(_edje_color_class_hash, color_class);
460
461 if (cc)
462 {
463#define X(C) if (C) *C = cc->C
464#define S(_r, _g, _b, _a) X(_r); X(_g); X(_b); X(_a)
465 S(r, g, b, a);
466 S(r2, g2, b2, a2);
467 S(r3, g3, b3, a3);
468#undef S
469#undef X
470 return EINA_TRUE;
471 }
472 else
473 {
474#define X(C) if (C) *C = 0
475#define S(_r, _g, _b, _a) X(_r); X(_g); X(_b); X(_a)
476 S(r, g, b, a);
477 S(r2, g2, b2, a2);
478 S(r3, g3, b3, a3);
479#undef S
480#undef X
481 return EINA_FALSE;
482 }
483}
484
485void
486edje_color_class_del(const char *color_class)
487{
488 Edje_Color_Class *cc;
489 Eina_List *members;
490
491 if (!color_class) return;
492
493 cc = eina_hash_find(_edje_color_class_hash, color_class);
494 if (!cc) return;
495
496 eina_hash_del(_edje_color_class_hash, color_class, cc);
497 eina_stringshare_del(cc->name);
498 free(cc);
499
500 members = eina_hash_find(_edje_color_class_member_hash, color_class);
501 while (members)
502 {
503 Edje *ed;
504
505 ed = eina_list_data_get(members);
506 ed->dirty = 1;
507#ifdef EDJE_CALC_CACHE
508 ed->all_part_change = 1;
509#endif
510 _edje_recalc(ed);
511 _edje_emit(ed, "color_class,del", color_class);
512 members = eina_list_next(members);
513 }
514}
515
516Eina_List *
517edje_color_class_list(void)
518{
519 Edje_List_Foreach_Data fdata;
520
521 if (!_edje_color_class_member_hash) return NULL;
522
523 memset(&fdata, 0, sizeof(Edje_List_Foreach_Data));
524 eina_hash_foreach(_edje_color_class_member_hash,
525 _edje_color_class_list_foreach, &fdata);
526
527 return fdata.list;
528}
529
530static Eina_Bool
531_edje_color_class_list_foreach(const Eina_Hash *hash __UNUSED__, const void *key, void *data __UNUSED__, void *fdata)
532{
533 Edje_List_Foreach_Data *fd;
534
535 fd = fdata;
536 fd->list = eina_list_append(fd->list, strdup(key));
537 return EINA_TRUE;
538}
539
540EAPI Eina_Bool
541edje_object_color_class_set(Evas_Object *obj, const char *color_class, int r, int g, int b, int a, int r2, int g2, int b2, int a2, int r3, int g3, int b3, int a3)
542{
543 Edje *ed;
544 Eina_List *l;
545 Edje_Color_Class *cc;
546 unsigned int i;
547
548 ed = _edje_fetch(obj);
549 if ((!ed) || (!color_class)) return EINA_FALSE;
550 if (r < 0) r = 0;
551 else if (r > 255) r = 255;
552 if (g < 0) g = 0;
553 else if (g > 255) g = 255;
554 if (b < 0) b = 0;
555 else if (b > 255) b = 255;
556 if (a < 0) a = 0;
557 else if (a > 255) a = 255;
558 color_class = eina_stringshare_add(color_class);
559 if (!color_class) return EINA_FALSE;
560 EINA_LIST_FOREACH(ed->color_classes, l, cc)
561 {
562 if (cc->name == color_class)
563 {
564 eina_stringshare_del(color_class);
565
566 if ((cc->r == r) && (cc->g == g) &&
567 (cc->b == b) && (cc->a == a) &&
568 (cc->r2 == r2) && (cc->g2 == g2) &&
569 (cc->b2 == b2) && (cc->a2 == a2) &&
570 (cc->r3 == r3) && (cc->g3 == g3) &&
571 (cc->b3 == b3) && (cc->a3 == a3))
572 return EINA_TRUE;
573 cc->r = r;
574 cc->g = g;
575 cc->b = b;
576 cc->a = a;
577 cc->r2 = r2;
578 cc->g2 = g2;
579 cc->b2 = b2;
580 cc->a2 = a2;
581 cc->r3 = r3;
582 cc->g3 = g3;
583 cc->b3 = b3;
584 cc->a3 = a3;
585 ed->dirty = 1;
586#ifdef EDJE_CALC_CACHE
587 ed->all_part_change = 1;
588#endif
589 _edje_recalc(ed);
590 return EINA_TRUE;
591 }
592 }
593 cc = malloc(sizeof(Edje_Color_Class));
594 if (!cc)
595 {
596 eina_stringshare_del(color_class);
597 return EINA_FALSE;
598 }
599 cc->name = color_class;
600 cc->r = r;
601 cc->g = g;
602 cc->b = b;
603 cc->a = a;
604 cc->r2 = r2;
605 cc->g2 = g2;
606 cc->b2 = b2;
607 cc->a2 = a2;
608 cc->r3 = r3;
609 cc->g3 = g3;
610 cc->b3 = b3;
611 cc->a3 = a3;
612 ed->color_classes = eina_list_append(ed->color_classes, cc);
613 ed->dirty = 1;
614#ifdef EDJE_CALC_CACHE
615 ed->all_part_change = 1;
616#endif
617
618 for (i = 0; i < ed->table_parts_size; i++)
619 {
620 Edje_Real_Part *rp;
621
622 rp = ed->table_parts[i];
623 if (rp->part->type == EDJE_PART_TYPE_GROUP && rp->swallowed_object)
624 edje_object_color_class_set(rp->swallowed_object, color_class,
625 r, g, b, a, r2, g2, b2, a2, r3, g3, b3,
626 a3);
627 }
628
629 _edje_recalc(ed);
630 _edje_emit(ed, "color_class,set", color_class);
631 return EINA_TRUE;
632}
633
634EAPI Eina_Bool
635edje_object_color_class_get(const Evas_Object *obj, const char *color_class, int *r, int *g, int *b, int *a, int *r2, int *g2, int *b2, int *a2, int *r3, int *g3, int *b3, int *a3)
636{
637 Edje *ed = _edje_fetch(obj);
638 Edje_Color_Class *cc = _edje_color_class_find(ed, color_class);
639
640 if (cc)
641 {
642#define X(C) if (C) *C = cc->C
643#define S(_r, _g, _b, _a) X(_r); X(_g); X(_b); X(_a)
644 S(r, g, b, a);
645 S(r2, g2, b2, a2);
646 S(r3, g3, b3, a3);
647#undef S
648#undef X
649 return EINA_TRUE;
650 }
651 else
652 {
653#define X(C) if (C) *C = 0
654#define S(_r, _g, _b, _a) X(_r); X(_g); X(_b); X(_a)
655 S(r, g, b, a);
656 S(r2, g2, b2, a2);
657 S(r3, g3, b3, a3);
658#undef S
659#undef X
660 return EINA_FALSE;
661 }
662}
663
664void
665edje_object_color_class_del(Evas_Object *obj, const char *color_class)
666{
667 Edje *ed;
668 Eina_List *l;
669 Edje_Color_Class *cc = NULL;
670 unsigned int i;
671
672 if (!color_class) return;
673
674 ed = _edje_fetch(obj);
675 EINA_LIST_FOREACH(ed->color_classes, l, cc)
676 {
677 if (!strcmp(cc->name, color_class))
678 {
679 ed->color_classes = eina_list_remove(ed->color_classes, cc);
680 eina_stringshare_del(cc->name);
681 free(cc);
682 break;
683 }
684 }
685
686 for (i = 0; i < ed->table_parts_size; i++)
687 {
688 Edje_Real_Part *rp;
689
690 rp = ed->table_parts[i];
691 if (rp->part->type == EDJE_PART_TYPE_GROUP && rp->swallowed_object)
692 edje_object_color_class_del(rp->swallowed_object, color_class);
693 }
694
695 ed->dirty = 1;
696#ifdef EDJE_CALC_CACHE
697 ed->all_part_change = 1;
698#endif
699 _edje_recalc(ed);
700 _edje_emit(ed, "color_class,del", color_class);
701}
702
703EAPI Eina_Bool
704edje_text_class_set(const char *text_class, const char *font, Evas_Font_Size size)
705{
706 Eina_List *members;
707 Edje_Text_Class *tc;
708
709 if (!text_class) return EINA_FALSE;
710 if (!font) font = "";
711
712 tc = eina_hash_find(_edje_text_class_hash, text_class);
713 /* Create new text class */
714 if (!tc)
715 {
716 tc = calloc(1, sizeof(Edje_Text_Class));
717 if (!tc) return EINA_FALSE;
718 tc->name = eina_stringshare_add(text_class);
719 if (!tc->name)
720 {
721 free(tc);
722 return EINA_FALSE;
723 }
724 if (!_edje_text_class_hash) _edje_text_class_hash = eina_hash_string_superfast_new(NULL);
725 eina_hash_add(_edje_text_class_hash, text_class, tc);
726
727 tc->font = eina_stringshare_add(font);
728 tc->size = size;
729 return EINA_FALSE;
730 }
731
732 /* If the class found is the same just return */
733 if ((tc->size == size) && (tc->font) && (!strcmp(tc->font, font)))
734 return EINA_TRUE;
735
736 /* Update the class found */
737 eina_stringshare_del(tc->font);
738 tc->font = eina_stringshare_add(font);
739 if (!tc->font)
740 {
741 eina_hash_del(_edje_text_class_hash, text_class, tc);
742 free(tc);
743 return EINA_FALSE;
744 }
745 tc->size = size;
746
747 /* Tell all members of the text class to recalc */
748 members = eina_hash_find(_edje_text_class_member_hash, text_class);
749 while (members)
750 {
751 Edje *ed;
752
753 ed = eina_list_data_get(members);
754 ed->dirty = 1;
755 _edje_textblock_style_all_update(ed);
756#ifdef EDJE_CALC_CACHE
757 ed->text_part_change = 1;
758#endif
759 _edje_recalc(ed);
760 members = eina_list_next(members);
761 }
762 return EINA_TRUE;
763}
764
765void
766edje_text_class_del(const char *text_class)
767{
768 Edje_Text_Class *tc;
769 Eina_List *members;
770
771 if (!text_class) return;
772
773 tc = eina_hash_find(_edje_text_class_hash, text_class);
774 if (!tc) return;
775
776 eina_hash_del(_edje_text_class_hash, text_class, tc);
777 eina_stringshare_del(tc->name);
778 eina_stringshare_del(tc->font);
779 free(tc);
780
781 members = eina_hash_find(_edje_text_class_member_hash, text_class);
782 while (members)
783 {
784 Edje *ed;
785
786 ed = eina_list_data_get(members);
787 ed->dirty = 1;
788 _edje_textblock_style_all_update(ed);
789#ifdef EDJE_CALC_CACHE
790 ed->text_part_change = 1;
791#endif
792 _edje_recalc(ed);
793 members = eina_list_next(members);
794 }
795}
796
797Eina_List *
798edje_text_class_list(void)
799{
800 Edje_List_Foreach_Data fdata;
801
802 memset(&fdata, 0, sizeof(Edje_List_Foreach_Data));
803 eina_hash_foreach(_edje_text_class_member_hash,
804 _edje_text_class_list_foreach, &fdata);
805 return fdata.list;
806}
807
808static Eina_Bool
809_edje_text_class_list_foreach(const Eina_Hash *hash __UNUSED__, const void *key, void *data __UNUSED__, void *fdata)
810{
811 Edje_List_Foreach_Data *fd;
812
813 fd = fdata;
814 fd->list = eina_list_append(fd->list, eina_stringshare_add(key));
815 return EINA_TRUE;
816}
817
818EAPI Eina_Bool
819edje_object_text_class_set(Evas_Object *obj, const char *text_class, const char *font, Evas_Font_Size size)
820{
821 Edje *ed;
822 Eina_List *l;
823 Edje_Text_Class *tc;
824 unsigned int i;
825
826 ed = _edje_fetch(obj);
827 if ((!ed) || (!text_class)) return EINA_FALSE;
828
829 /* for each text_class in the edje */
830 EINA_LIST_FOREACH(ed->text_classes, l, tc)
831 {
832 if ((tc->name) && (!strcmp(tc->name, text_class)))
833 {
834 /* Match and the same, return */
835 if ((tc->font) && (font) && (!strcmp(tc->font, font)) &&
836 (tc->size == size))
837 return EINA_TRUE;
838
839 /* No font but size is the same, return */
840 if ((!tc->font) && (!font) && (tc->size == size)) return EINA_TRUE;
841
842 /* Update new text class properties */
843 if (tc->font) eina_stringshare_del(tc->font);
844 if (font) tc->font = eina_stringshare_add(font);
845 else tc->font = NULL;
846 tc->size = size;
847
848 /* Update edje */
849 ed->dirty = 1;
850#ifdef EDJE_CALC_CACHE
851 ed->text_part_change = 1;
852#endif
853 _edje_recalc(ed);
854 return EINA_TRUE;
855 }
856 }
857
858 /* No matches, create a new text class */
859 tc = calloc(1, sizeof(Edje_Text_Class));
860 if (!tc) return EINA_FALSE;
861 tc->name = eina_stringshare_add(text_class);
862 if (!tc->name)
863 {
864 free(tc);
865 return EINA_FALSE;
866 }
867 if (font) tc->font = eina_stringshare_add(font);
868 else tc->font = NULL;
869 tc->size = size;
870
871 for (i = 0; i < ed->table_parts_size; i++)
872 {
873 Edje_Real_Part *rp;
874
875 rp = ed->table_parts[i];
876 if (rp->part->type == EDJE_PART_TYPE_GROUP && rp->swallowed_object)
877 edje_object_text_class_set(rp->swallowed_object, text_class,
878 font, size);
879 }
880
881 /* Add to edje's text class list */
882 ed->text_classes = eina_list_append(ed->text_classes, tc);
883 ed->dirty = 1;
884#ifdef EDJE_CALC_CACHE
885 ed->text_part_change = 1;
886#endif
887 _edje_textblock_style_all_update(ed);
888 _edje_recalc(ed);
889 return EINA_TRUE;
890}
891
892EAPI Eina_Bool
893edje_object_part_exists(const Evas_Object *obj, const char *part)
894{
895 Edje *ed;
896 Edje_Real_Part *rp;
897
898 ed = _edje_fetch(obj);
899 if ((!ed) || (!part)) return EINA_FALSE;
900 rp = _edje_real_part_recursive_get(ed, (char *)part);
901 if (!rp) return EINA_FALSE;
902 return EINA_TRUE;
903}
904
905EAPI const Evas_Object *
906edje_object_part_object_get(const Evas_Object *obj, const char *part)
907{
908 Edje *ed;
909 Edje_Real_Part *rp;
910
911 ed = _edje_fetch(obj);
912 if ((!ed) || (!part)) return NULL;
913
914 /* Need to recalc before providing the object. */
915 _edje_recalc_do(ed);
916
917 rp = _edje_real_part_recursive_get(ed, (char *)part);
918 if (!rp) return NULL;
919 return rp->object;
920}
921
922EAPI Eina_Bool
923edje_object_part_geometry_get(const Evas_Object *obj, const char *part, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h )
924{
925 Edje *ed;
926 Edje_Real_Part *rp;
927
928 ed = _edje_fetch(obj);
929 if ((!ed) || (!part))
930 {
931 if (x) *x = 0;
932 if (y) *y = 0;
933 if (w) *w = 0;
934 if (h) *h = 0;
935 return EINA_FALSE;
936 }
937
938 /* Need to recalc before providing the object. */
939 _edje_recalc_do(ed);
940
941 rp = _edje_real_part_recursive_get(ed, (char *)part);
942 if (!rp)
943 {
944 if (x) *x = 0;
945 if (y) *y = 0;
946 if (w) *w = 0;
947 if (h) *h = 0;
948 return EINA_FALSE;
949 }
950 if (x) *x = rp->x;
951 if (y) *y = rp->y;
952 if (w) *w = rp->w;
953 if (h) *h = rp->h;
954 return EINA_TRUE;
955}
956
957EAPI void
958edje_object_item_provider_set(Evas_Object *obj, Edje_Item_Provider_Cb func, void *data)
959{
960 Edje *ed;
961
962 ed = _edje_fetch(obj);
963 if (!ed) return;
964 ed->item_provider.func = func;
965 ed->item_provider.data = data;
966}
967
968/* FIXDOC: New Function */
969EAPI void
970edje_object_text_change_cb_set(Evas_Object *obj, Edje_Text_Change_Cb func, void *data)
971{
972 Edje *ed;
973 unsigned int i;
974
975 ed = _edje_fetch(obj);
976 if (!ed) return;
977 ed->text_change.func = func;
978 ed->text_change.data = data;
979
980 for (i = 0; i < ed->table_parts_size; i++)
981 {
982 Edje_Real_Part *rp;
983
984 rp = ed->table_parts[i];
985 if ((rp->part->type == EDJE_PART_TYPE_GROUP) && (rp->swallowed_object))
986 edje_object_text_change_cb_set(rp->swallowed_object, func, data);
987 }
988}
989
990Eina_Bool
991_edje_object_part_text_raw_set(Evas_Object *obj, Edje_Real_Part *rp, const char *part, const char *text)
992{
993 if ((!rp->text.text) && (!text))
994 return EINA_FALSE;
995 if ((rp->text.text) && (text) &&
996 (!strcmp(rp->text.text, text)))
997 return EINA_FALSE;
998 if (rp->text.text)
999 {
1000 eina_stringshare_del(rp->text.text);
1001 rp->text.text = NULL;
1002 }
1003 if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
1004 _edje_entry_text_markup_set(rp, text);
1005 else
1006 if (text) rp->text.text = eina_stringshare_add(text);
1007 rp->edje->dirty = 1;
1008#ifdef EDJE_CALC_CACHE
1009 rp->invalidate = 1;
1010#endif
1011 _edje_recalc(rp->edje);
1012 if (rp->edje->text_change.func)
1013 rp->edje->text_change.func(rp->edje->text_change.data, obj, part);
1014 return EINA_TRUE;
1015}
1016
1017Eina_Bool
1018_edje_object_part_text_raw_append(Evas_Object *obj, Edje_Real_Part *rp, const char *part, const char *text)
1019{
1020 if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
1021 _edje_entry_text_markup_append(rp, text);
1022 else if (text)
1023 {
1024 if (rp->text.text)
1025 {
1026 char *new = NULL;
1027 int len_added = strlen(text);
1028 int len_old = strlen(rp->text.text);
1029 new = malloc(len_old + len_added + 1);
1030 memcpy(new, rp->text.text, len_old);
1031 memcpy(new + len_old, text, len_added);
1032 new[len_old + len_added] = '\0';
1033 eina_stringshare_replace(&rp->text.text, new);
1034 free(new);
1035 }
1036 else
1037 {
1038 eina_stringshare_replace(&rp->text.text, text);
1039 }
1040 }
1041 rp->edje->dirty = 1;
1042#ifdef EDJE_CALC_CACHE
1043 rp->invalidate = 1;
1044#endif
1045 _edje_recalc(rp->edje);
1046 if (rp->edje->text_change.func)
1047 rp->edje->text_change.func(rp->edje->text_change.data, obj, part);
1048 return EINA_TRUE;
1049}
1050
1051EAPI Eina_Bool
1052edje_object_part_text_set(Evas_Object *obj, const char *part, const char *text)
1053{
1054 Edje *ed;
1055 Edje_Real_Part *rp;
1056
1057 ed = _edje_fetch(obj);
1058 if ((!ed) || (!part)) return EINA_FALSE;
1059 rp = _edje_real_part_recursive_get(ed, (char *)part);
1060 if (!rp) return EINA_FALSE;
1061 if ((rp->part->type != EDJE_PART_TYPE_TEXT) &&
1062 (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) return EINA_FALSE;
1063 return _edje_object_part_text_raw_set(obj, rp, part, text);
1064}
1065
1066EAPI const char *
1067edje_object_part_text_get(const Evas_Object *obj, const char *part)
1068{
1069 Edje *ed;
1070 Edje_Real_Part *rp;
1071
1072 ed = _edje_fetch(obj);
1073 if ((!ed) || (!part)) return NULL;
1074
1075 /* Need to recalc before providing the object. */
1076 _edje_recalc_do(ed);
1077
1078 rp = _edje_real_part_recursive_get(ed, (char *)part);
1079 if (!rp) return NULL;
1080 if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
1081 return _edje_entry_text_get(rp);
1082 else
1083 {
1084 if (rp->part->type == EDJE_PART_TYPE_TEXT) return rp->text.text;
1085 if (rp->part->type == EDJE_PART_TYPE_TEXTBLOCK)
1086 return evas_object_textblock_text_markup_get(rp->object);
1087 }
1088 return NULL;
1089}
1090
1091char *
1092_edje_text_escape(const char *text)
1093{
1094 Eina_Strbuf *txt;
1095 char *ret;
1096 const char *text_end;
1097 size_t text_len;
1098
1099 if (!text) return NULL;
1100
1101 txt = eina_strbuf_new();
1102 text_len = strlen(text);
1103
1104 text_end = text + text_len;
1105 while (text < text_end)
1106 {
1107 int advance;
1108 const char *escaped = evas_textblock_string_escape_get(text, &advance);
1109 if (!escaped)
1110 {
1111 eina_strbuf_append_char(txt, text[0]);
1112 advance = 1;
1113 }
1114 else
1115 eina_strbuf_append(txt, escaped);
1116
1117 text += advance;
1118 }
1119
1120 ret = eina_strbuf_string_steal(txt);
1121 eina_strbuf_free(txt);
1122 return ret;
1123}
1124
1125char *
1126_edje_text_unescape(const char *text)
1127{
1128 Eina_Strbuf *txt;
1129 char *ret;
1130 const char *text_end, *last, *escape_start;
1131 size_t text_len;
1132
1133 if (!text) return NULL;
1134
1135 txt = eina_strbuf_new();
1136 text_len = strlen(text);
1137
1138 text_end = text + text_len;
1139 last = text;
1140 escape_start = NULL;
1141 for (; text < text_end; text++)
1142 {
1143 if (*text == '&')
1144 {
1145 size_t len;
1146 const char *str;
1147
1148 if (last)
1149 {
1150 len = text - last;
1151 str = last;
1152 }
1153 else
1154 {
1155 len = text - escape_start;
1156 str = escape_start;
1157 }
1158
1159 if (len > 0)
1160 eina_strbuf_append_n(txt, str, len);
1161
1162 escape_start = text;
1163 last = NULL;
1164 }
1165 else if ((*text == ';') && (escape_start))
1166 {
1167 size_t len;
1168 const char *str = evas_textblock_escape_string_range_get(escape_start, text);
1169
1170 if (str)
1171 len = strlen(str);
1172 else
1173 {
1174 str = escape_start;
1175 len = text + 1 - escape_start;
1176 }
1177
1178 eina_strbuf_append_n(txt, str, len);
1179
1180 escape_start = NULL;
1181 last = text + 1;
1182 }
1183 }
1184
1185 if (!last && escape_start)
1186 last = escape_start;
1187
1188 if (last && (text > last))
1189 {
1190 size_t len = text - last;
1191 eina_strbuf_append_n(txt, last, len);
1192 }
1193
1194 ret = eina_strbuf_string_steal(txt);
1195 eina_strbuf_free(txt);
1196 return ret;
1197}
1198
1199EAPI Eina_Bool
1200edje_object_part_text_unescaped_set(Evas_Object *obj, const char *part, const char *text_to_escape)
1201{
1202 Edje *ed;
1203 Edje_Real_Part *rp;
1204 Eina_Bool ret = EINA_FALSE;
1205
1206 ed = _edje_fetch(obj);
1207 if ((!ed) || (!part)) return ret;
1208 rp = _edje_real_part_recursive_get(ed, part);
1209 if (!rp) return ret;
1210 if (rp->part->type == EDJE_PART_TYPE_TEXT)
1211 ret = _edje_object_part_text_raw_set(obj, rp, part, text_to_escape);
1212 else if (rp->part->type == EDJE_PART_TYPE_TEXTBLOCK)
1213 {
1214 char *text = _edje_text_escape(text_to_escape);
1215
1216 ret = _edje_object_part_text_raw_set(obj, rp, part, text);
1217 free(text);
1218 }
1219 return ret;
1220}
1221
1222EAPI char *
1223edje_object_part_text_unescaped_get(const Evas_Object *obj, const char *part)
1224{
1225 Edje *ed;
1226 Edje_Real_Part *rp;
1227
1228 ed = _edje_fetch(obj);
1229 if ((!ed) || (!part)) return NULL;
1230
1231 /* Need to recalc before providing the object. */
1232 _edje_recalc_do(ed);
1233
1234 rp = _edje_real_part_recursive_get(ed, (char *)part);
1235 if (!rp) return NULL;
1236 if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
1237 {
1238 const char *t = _edje_entry_text_get(rp);
1239 return _edje_text_unescape(t);
1240 }
1241 else
1242 {
1243 if (rp->part->type == EDJE_PART_TYPE_TEXT) return strdup(rp->text.text);
1244 if (rp->part->type == EDJE_PART_TYPE_TEXTBLOCK)
1245 {
1246 const char *t = evas_object_textblock_text_markup_get(rp->object);
1247 return _edje_text_unescape(t);
1248 }
1249 }
1250 return NULL;
1251}
1252
1253EAPI const char *
1254edje_object_part_text_selection_get(const Evas_Object *obj, const char *part)
1255{
1256 Edje *ed;
1257 Edje_Real_Part *rp;
1258
1259 ed = _edje_fetch(obj);
1260 if ((!ed) || (!part)) return NULL;
1261 rp = _edje_real_part_recursive_get(ed, (char *)part);
1262 if (!rp) return NULL;
1263 if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
1264 return _edje_entry_selection_get(rp);
1265 return NULL;
1266}
1267
1268EAPI void
1269edje_object_part_text_select_none(const Evas_Object *obj, const char *part)
1270{
1271 Edje *ed;
1272 Edje_Real_Part *rp;
1273
1274 ed = _edje_fetch(obj);
1275 if ((!ed) || (!part)) return;
1276 rp = _edje_real_part_recursive_get(ed, (char *)part);
1277 if (!rp) return;
1278 if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
1279 _edje_entry_select_none(rp);
1280}
1281
1282EAPI void
1283edje_object_part_text_select_all(const Evas_Object *obj, const char *part)
1284{
1285 Edje *ed;
1286 Edje_Real_Part *rp;
1287
1288 ed = _edje_fetch(obj);
1289 if ((!ed) || (!part)) return;
1290 rp = _edje_real_part_recursive_get(ed, (char *)part);
1291 if (!rp) return;
1292 if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
1293 _edje_entry_select_all(rp);
1294}
1295
1296EAPI void
1297edje_object_part_text_insert(Evas_Object *obj, const char *part, const char *text)
1298{
1299 Edje *ed;
1300 Edje_Real_Part *rp;
1301
1302 ed = _edje_fetch(obj);
1303 if ((!ed) || (!part)) return;
1304 rp = _edje_real_part_recursive_get(ed, (char *)part);
1305 if (!rp) return;
1306 if ((rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) return;
1307 if (rp->part->entry_mode <= EDJE_ENTRY_EDIT_MODE_NONE) return;
1308 _edje_entry_text_markup_insert(rp, text);
1309 rp->edje->dirty = 1;
1310#ifdef EDJE_CALC_CACHE
1311 rp->invalidate = 1;
1312#endif
1313 _edje_recalc(rp->edje);
1314 if (rp->edje->text_change.func)
1315 rp->edje->text_change.func(rp->edje->text_change.data, obj, part);
1316}
1317
1318EAPI void
1319edje_object_part_text_append(Evas_Object *obj, const char *part, const char *text)
1320{
1321 Edje *ed;
1322 Edje_Real_Part *rp;
1323
1324 ed = _edje_fetch(obj);
1325 if ((!ed) || (!part)) return;
1326 rp = _edje_real_part_recursive_get(ed, (char *)part);
1327 if (!rp) return;
1328 if ((rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) return;
1329 _edje_object_part_text_raw_append(obj, rp, part, text);
1330 rp->edje->dirty = 1;
1331#ifdef EDJE_CALC_CACHE
1332 rp->invalidate = 1;
1333#endif
1334 _edje_recalc(rp->edje);
1335 if (rp->edje->text_change.func)
1336 rp->edje->text_change.func(rp->edje->text_change.data, obj, part);
1337}
1338
1339EAPI const Eina_List *
1340edje_object_part_text_anchor_list_get(const Evas_Object *obj, const char *part)
1341{
1342 Edje *ed;
1343 Edje_Real_Part *rp;
1344
1345 ed = _edje_fetch(obj);
1346 if ((!ed) || (!part)) return NULL;
1347 rp = _edje_real_part_recursive_get(ed, (char *)part);
1348 if (!rp) return NULL;
1349 if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
1350 return _edje_entry_anchors_list(rp);
1351 return NULL;
1352}
1353
1354EAPI const Eina_List *
1355edje_object_part_text_anchor_geometry_get(const Evas_Object *obj, const char *part, const char *anchor)
1356{
1357 Edje *ed;
1358 Edje_Real_Part *rp;
1359
1360 ed = _edje_fetch(obj);
1361 if ((!ed) || (!part)) return NULL;
1362 rp = _edje_real_part_recursive_get(ed, (char *)part);
1363 if (!rp) return NULL;
1364 if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
1365 return _edje_entry_anchor_geometry_get(rp, anchor);
1366 return NULL;
1367}
1368
1369EAPI const Eina_List *
1370edje_object_part_text_item_list_get(const Evas_Object *obj, const char *part)
1371{
1372 Edje *ed;
1373 Edje_Real_Part *rp;
1374
1375 ed = _edje_fetch(obj);
1376 if ((!ed) || (!part)) return NULL;
1377 rp = _edje_real_part_recursive_get(ed, (char *)part);
1378 if (!rp) return NULL;
1379 if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
1380 return _edje_entry_items_list(rp);
1381 return NULL;
1382}
1383
1384EAPI Eina_Bool
1385edje_object_part_text_item_geometry_get(const Evas_Object *obj, const char *part, const char *item, Evas_Coord *cx, Evas_Coord *cy, Evas_Coord *cw, Evas_Coord *ch)
1386{
1387 Edje *ed;
1388 Edje_Real_Part *rp;
1389
1390 ed = _edje_fetch(obj);
1391 if ((!ed) || (!part)) return EINA_FALSE;
1392 rp = _edje_real_part_recursive_get(ed, (char *)part);
1393 if (!rp) return EINA_FALSE;
1394 if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
1395 return _edje_entry_item_geometry_get(rp, item, cx, cy, cw, ch);
1396 return EINA_FALSE;
1397}
1398
1399EAPI void
1400edje_object_part_text_cursor_geometry_get(const Evas_Object *obj, const char *part, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
1401{
1402 Edje *ed;
1403 Edje_Real_Part *rp;
1404
1405 ed = _edje_fetch(obj);
1406 if (x) *x = 0;
1407 if (y) *y = 0;
1408 if (w) *w = 0;
1409 if (h) *h = 0;
1410 if ((!ed) || (!part)) return;
1411 rp = _edje_real_part_recursive_get(ed, (char *)part);
1412 if (!rp) return;
1413 if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
1414 {
1415 _edje_entry_cursor_geometry_get(rp, x, y, w, h);
1416 if (x) *x -= rp->edje->x;
1417 if (y) *y -= rp->edje->y;
1418 }
1419 return;
1420}
1421
1422EAPI void
1423edje_object_part_text_select_allow_set(const Evas_Object *obj, const char *part, Eina_Bool allow)
1424{
1425 Edje *ed;
1426 Edje_Real_Part *rp;
1427
1428 ed = _edje_fetch(obj);
1429 if ((!ed) || (!part)) return;
1430 rp = _edje_real_part_recursive_get(ed, (char *)part);
1431 if (!rp) return;
1432 if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
1433 _edje_entry_select_allow_set(rp, allow);
1434}
1435
1436EAPI void
1437edje_object_part_text_select_abort(const Evas_Object *obj, const char *part)
1438{
1439 Edje *ed;
1440 Edje_Real_Part *rp;
1441
1442 ed = _edje_fetch(obj);
1443 if ((!ed) || (!part)) return;
1444 rp = _edje_real_part_recursive_get(ed, (char *)part);
1445 if (!rp) return;
1446 if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
1447 _edje_entry_select_abort(rp);
1448}
1449
1450EAPI void
1451edje_object_part_text_select_begin(const Evas_Object *obj, const char *part)
1452{
1453 Edje *ed;
1454 Edje_Real_Part *rp;
1455
1456 ed = _edje_fetch(obj);
1457 if ((!ed) || (!part)) return;
1458 rp = _edje_real_part_recursive_get(ed, (char *)part);
1459 if (!rp) return;
1460 if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
1461 _edje_entry_select_begin(rp);
1462}
1463
1464EAPI void
1465edje_object_part_text_select_extend(const Evas_Object *obj, const char *part)
1466{
1467 Edje *ed;
1468 Edje_Real_Part *rp;
1469
1470 ed = _edje_fetch(obj);
1471 if ((!ed) || (!part)) return;
1472 rp = _edje_real_part_recursive_get(ed, (char *)part);
1473 if (!rp) return;
1474 if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
1475 _edje_entry_select_extend(rp);
1476}
1477
1478EAPI Eina_Bool
1479edje_object_part_text_cursor_next(Evas_Object *obj, const char *part, Edje_Cursor cur)
1480{
1481 Edje *ed;
1482 Edje_Real_Part *rp;
1483
1484 ed = _edje_fetch(obj);
1485 if ((!ed) || (!part)) return EINA_FALSE;
1486 rp = _edje_real_part_recursive_get(ed, (char *)part);
1487 if (!rp) return EINA_FALSE;
1488 if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
1489 {
1490 return _edje_entry_cursor_next(rp, cur);
1491 }
1492 return EINA_FALSE;
1493}
1494
1495EAPI Eina_Bool
1496edje_object_part_text_cursor_prev(Evas_Object *obj, const char *part, Edje_Cursor cur)
1497{
1498 Edje *ed;
1499 Edje_Real_Part *rp;
1500
1501 ed = _edje_fetch(obj);
1502 if ((!ed) || (!part)) return EINA_FALSE;
1503 rp = _edje_real_part_recursive_get(ed, (char *)part);
1504 if (!rp) return EINA_FALSE;
1505 if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
1506 {
1507 return _edje_entry_cursor_prev(rp, cur);
1508 }
1509 return EINA_FALSE;
1510}
1511
1512EAPI Eina_Bool
1513edje_object_part_text_cursor_up(Evas_Object *obj, const char *part, Edje_Cursor cur)
1514{
1515 Edje *ed;
1516 Edje_Real_Part *rp;
1517
1518 ed = _edje_fetch(obj);
1519 if ((!ed) || (!part)) return EINA_FALSE;
1520 rp = _edje_real_part_recursive_get(ed, (char *)part);
1521 if (!rp) return EINA_FALSE;
1522 if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
1523 {
1524 return _edje_entry_cursor_up(rp, cur);
1525 }
1526 return EINA_FALSE;
1527}
1528
1529EAPI Eina_Bool
1530edje_object_part_text_cursor_down(Evas_Object *obj, const char *part, Edje_Cursor cur)
1531{
1532 Edje *ed;
1533 Edje_Real_Part *rp;
1534
1535 ed = _edje_fetch(obj);
1536 if ((!ed) || (!part)) return EINA_FALSE;
1537 rp = _edje_real_part_recursive_get(ed, (char *)part);
1538 if (!rp) return EINA_FALSE;
1539 if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
1540 {
1541 return _edje_entry_cursor_down(rp, cur);
1542 }
1543 return EINA_FALSE;
1544}
1545
1546EAPI void
1547edje_object_part_text_cursor_begin_set(Evas_Object *obj, const char *part, Edje_Cursor cur)
1548{
1549 Edje *ed;
1550 Edje_Real_Part *rp;
1551
1552 ed = _edje_fetch(obj);
1553 if ((!ed) || (!part)) return;
1554 rp = _edje_real_part_recursive_get(ed, (char *)part);
1555 if (!rp) return;
1556 if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
1557 {
1558 _edje_entry_cursor_begin(rp, cur);
1559 }
1560}
1561
1562EAPI void
1563edje_object_part_text_cursor_end_set(Evas_Object *obj, const char *part, Edje_Cursor cur)
1564{
1565 Edje *ed;
1566 Edje_Real_Part *rp;
1567
1568 ed = _edje_fetch(obj);
1569 if ((!ed) || (!part)) return;
1570 rp = _edje_real_part_recursive_get(ed, (char *)part);
1571 if (!rp) return;
1572 if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
1573 {
1574 _edje_entry_cursor_end(rp, cur);
1575 }
1576}
1577
1578EAPI void
1579edje_object_part_text_cursor_copy(Evas_Object *obj, const char *part, Edje_Cursor src, Edje_Cursor dst)
1580{
1581 Edje *ed;
1582 Edje_Real_Part *rp;
1583
1584 ed = _edje_fetch(obj);
1585 if ((!ed) || (!part)) return;
1586 rp = _edje_real_part_recursive_get(ed, (char *)part);
1587 if (!rp) return;
1588 if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
1589 {
1590 _edje_entry_cursor_copy(rp, src, dst);
1591 }
1592}
1593
1594EAPI void
1595edje_object_part_text_cursor_line_begin_set(Evas_Object *obj, const char *part, Edje_Cursor cur)
1596{
1597 Edje *ed;
1598 Edje_Real_Part *rp;
1599
1600 ed = _edje_fetch(obj);
1601 if ((!ed) || (!part)) return;
1602 rp = _edje_real_part_recursive_get(ed, (char *)part);
1603 if (!rp) return;
1604 if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
1605 {
1606 _edje_entry_cursor_line_begin(rp, cur);
1607 }
1608}
1609
1610EAPI void
1611edje_object_part_text_cursor_line_end_set(Evas_Object *obj, const char *part, Edje_Cursor cur)
1612{
1613 Edje *ed;
1614 Edje_Real_Part *rp;
1615
1616 ed = _edje_fetch(obj);
1617 if ((!ed) || (!part)) return;
1618 rp = _edje_real_part_recursive_get(ed, (char *)part);
1619 if (!rp) return;
1620 if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
1621 {
1622 _edje_entry_cursor_line_end(rp, cur);
1623 }
1624}
1625
1626EAPI Eina_Bool
1627edje_object_part_text_cursor_coord_set(Evas_Object *obj, const char *part,
1628 Edje_Cursor cur, Evas_Coord x, Evas_Coord y)
1629{
1630 Edje *ed;
1631 Edje_Real_Part *rp;
1632
1633 ed = _edje_fetch(obj);
1634 if ((!ed) || (!part)) return EINA_FALSE;
1635 rp = _edje_real_part_recursive_get(ed, (char *)part);
1636 if (!rp) return EINA_FALSE;
1637 if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
1638 {
1639 return _edje_entry_cursor_coord_set(rp, cur, x, y);
1640 }
1641 return EINA_FALSE;
1642}
1643
1644EAPI Eina_Bool
1645edje_object_part_text_cursor_is_format_get(const Evas_Object *obj, const char *part, Edje_Cursor cur)
1646{
1647 Edje *ed;
1648 Edje_Real_Part *rp;
1649
1650 ed = _edje_fetch(obj);
1651 if ((!ed) || (!part)) return EINA_FALSE;
1652 rp = _edje_real_part_recursive_get(ed, (char *)part);
1653 if (!rp) return EINA_FALSE;
1654 if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
1655 {
1656 return _edje_entry_cursor_is_format_get(rp, cur);
1657 }
1658 return EINA_FALSE;
1659}
1660
1661EAPI Eina_Bool
1662edje_object_part_text_cursor_is_visible_format_get(const Evas_Object *obj, const char *part, Edje_Cursor cur)
1663{
1664 Edje *ed;
1665 Edje_Real_Part *rp;
1666
1667 ed = _edje_fetch(obj);
1668 if ((!ed) || (!part)) return 0;
1669 rp = _edje_real_part_recursive_get(ed, (char *)part);
1670 if (!rp) return 0;
1671 if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
1672 {
1673 return _edje_entry_cursor_is_visible_format_get(rp, cur);
1674 }
1675 return 0;
1676}
1677
1678EAPI const char *
1679edje_object_part_text_cursor_content_get(const Evas_Object *obj, const char *part, Edje_Cursor cur)
1680{
1681 Edje *ed;
1682 Edje_Real_Part *rp;
1683
1684 ed = _edje_fetch(obj);
1685 if ((!ed) || (!part)) return NULL;
1686 rp = _edje_real_part_recursive_get(ed, part);
1687 if (!rp) return NULL;
1688 if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
1689 {
1690 return _edje_entry_cursor_content_get(rp, cur);
1691 }
1692 return NULL;
1693}
1694
1695EAPI void
1696edje_object_part_text_cursor_pos_set(Evas_Object *obj, const char *part, Edje_Cursor cur, int pos)
1697{
1698 Edje *ed;
1699 Edje_Real_Part *rp;
1700
1701 ed = _edje_fetch(obj);
1702 if ((!ed) || (!part)) return;
1703 rp = _edje_real_part_recursive_get(ed, part);
1704 if (!rp) return;
1705 if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
1706 {
1707 _edje_entry_cursor_pos_set(rp, cur, pos);
1708 }
1709}
1710
1711EAPI int
1712edje_object_part_text_cursor_pos_get(const Evas_Object *obj, const char *part, Edje_Cursor cur)
1713{
1714 Edje *ed;
1715 Edje_Real_Part *rp;
1716
1717 ed = _edje_fetch(obj);
1718 if ((!ed) || (!part)) return 0;
1719 rp = _edje_real_part_recursive_get(ed, part);
1720 if (!rp) return 0;
1721 if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
1722 {
1723 return _edje_entry_cursor_pos_get(rp, cur);
1724 }
1725 return 0;
1726}
1727
1728EAPI void
1729edje_object_part_text_input_panel_layout_set(const Evas_Object *obj, const char *part, Edje_Input_Panel_Layout layout)
1730{
1731 Edje *ed;
1732 Edje_Real_Part *rp;
1733
1734 ed = _edje_fetch(obj);
1735 if ((!ed) || (!part)) return;
1736 rp = _edje_real_part_recursive_get(ed, part);
1737 if (!rp) return;
1738 if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
1739 {
1740 return _edje_entry_input_panel_layout_set(rp, layout);
1741 }
1742}
1743
1744EAPI Edje_Input_Panel_Layout
1745edje_object_part_text_input_panel_layout_get(const Evas_Object *obj, const char *part)
1746{
1747 Edje *ed;
1748 Edje_Real_Part *rp;
1749
1750 ed = _edje_fetch(obj);
1751 if ((!ed) || (!part)) return EDJE_INPUT_PANEL_LAYOUT_INVALID;
1752 rp = _edje_real_part_recursive_get(ed, part);
1753 if (!rp) return EINA_FALSE;
1754 if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
1755 {
1756 return _edje_entry_input_panel_layout_get(rp);
1757 }
1758 return EDJE_INPUT_PANEL_LAYOUT_INVALID;
1759}
1760
1761EAPI void
1762edje_object_part_text_autocapital_type_set(const Evas_Object *obj, const char *part, Edje_Text_Autocapital_Type autocapital_type)
1763{
1764 Edje *ed;
1765 Edje_Real_Part *rp;
1766
1767 ed = _edje_fetch(obj);
1768 if ((!ed) || (!part)) return;
1769 rp = _edje_real_part_recursive_get(ed, (char *)part);
1770 if (!rp) return;
1771 if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
1772 {
1773 _edje_entry_autocapital_type_set(rp, autocapital_type);
1774 }
1775}
1776
1777EAPI Edje_Text_Autocapital_Type
1778edje_object_part_text_autocapital_type_get(const Evas_Object *obj, const char *part)
1779{
1780 Edje *ed;
1781 Edje_Real_Part *rp;
1782
1783 ed = _edje_fetch(obj);
1784 if ((!ed) || (!part)) return EDJE_TEXT_AUTOCAPITAL_TYPE_NONE;
1785 rp = _edje_real_part_recursive_get(ed, (char *)part);
1786 if (!rp) return EDJE_TEXT_AUTOCAPITAL_TYPE_NONE;
1787 if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
1788 {
1789 return _edje_entry_autocapital_type_get(rp);
1790 }
1791 return EDJE_TEXT_AUTOCAPITAL_TYPE_NONE;
1792}
1793
1794EAPI void
1795edje_object_part_text_input_panel_enabled_set(const Evas_Object *obj, const char *part, Eina_Bool enabled)
1796{
1797 Edje *ed;
1798 Edje_Real_Part *rp;
1799
1800 ed = _edje_fetch(obj);
1801 if ((!ed) || (!part)) return;
1802 rp = _edje_real_part_recursive_get(ed, part);
1803 if (!rp) return;
1804 if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
1805 {
1806 return _edje_entry_input_panel_enabled_set(rp, enabled);
1807 }
1808}
1809
1810EAPI Eina_Bool
1811edje_object_part_text_input_panel_enabled_get(const Evas_Object *obj, const char *part)
1812{
1813 Edje *ed;
1814 Edje_Real_Part *rp;
1815
1816 ed = _edje_fetch(obj);
1817 if ((!ed) || (!part)) return EINA_FALSE;
1818 rp = _edje_real_part_recursive_get(ed, part);
1819 if (!rp) return EINA_FALSE;
1820 if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE)
1821 {
1822 return _edje_entry_input_panel_enabled_get(rp);
1823 }
1824 return EINA_FALSE;
1825}
1826
1827EAPI void
1828edje_object_text_insert_filter_callback_add(Evas_Object *obj, const char *part, Edje_Text_Filter_Cb func, void *data)
1829{
1830 Edje *ed;
1831 Edje_Text_Insert_Filter_Callback *cb;
1832
1833 ed = _edje_fetch(obj);
1834 if ((!ed) || (!part)) return;
1835 cb = calloc(1, sizeof(Edje_Text_Insert_Filter_Callback));
1836 cb->part = eina_stringshare_add(part);
1837 cb->func = func;
1838 cb->data = (void *)data;
1839 ed->text_insert_filter_callbacks =
1840 eina_list_append(ed->text_insert_filter_callbacks, cb);
1841}
1842
1843EAPI void *
1844edje_object_text_insert_filter_callback_del(Evas_Object *obj, const char *part, Edje_Text_Filter_Cb func)
1845{
1846 Edje *ed;
1847 Edje_Text_Insert_Filter_Callback *cb;
1848 Eina_List *l;
1849
1850 ed = _edje_fetch(obj);
1851 if ((!ed) || (!part)) return NULL;
1852 EINA_LIST_FOREACH(ed->text_insert_filter_callbacks, l, cb)
1853 {
1854 if ((!strcmp(cb->part, part)) && (cb->func == func))
1855 {
1856 void *data = cb->data;
1857 ed->text_insert_filter_callbacks =
1858 eina_list_remove_list(ed->text_insert_filter_callbacks, l);
1859 eina_stringshare_del(cb->part);
1860 free(cb);
1861 return data;
1862 }
1863 }
1864 return NULL;
1865}
1866
1867EAPI void *
1868edje_object_text_insert_filter_callback_del_full(Evas_Object *obj, const char *part, Edje_Text_Filter_Cb func, void *data)
1869{
1870 Edje *ed;
1871 Edje_Text_Insert_Filter_Callback *cb;
1872 Eina_List *l;
1873
1874 ed = _edje_fetch(obj);
1875 if ((!ed) || (!part)) return NULL;
1876 EINA_LIST_FOREACH(ed->text_insert_filter_callbacks, l, cb)
1877 {
1878 if ((!strcmp(cb->part, part)) && (cb->func == func) &&
1879 (cb->data == data))
1880 {
1881 void *tmp = cb->data;
1882 ed->text_insert_filter_callbacks =
1883 eina_list_remove_list(ed->text_insert_filter_callbacks, l);
1884 eina_stringshare_del(cb->part);
1885 free(cb);
1886 return tmp;
1887 }
1888 }
1889 return NULL;
1890}
1891
1892EAPI Eina_Bool
1893edje_object_part_swallow(Evas_Object *obj, const char *part, Evas_Object *obj_swallow)
1894{
1895 Edje *ed;
1896 Edje_Real_Part *rp;
1897
1898 ed = _edje_fetch(obj);
1899 if ((!ed) || (!part)) return EINA_FALSE;
1900
1901 /* Need to recalc before providing the object. */
1902 // XXX: I guess this is not required, removing for testing purposes
1903 // XXX: uncomment if you see glitches in e17 or others.
1904 // XXX: by Gustavo, January 21th 2009.
1905 // XXX: I got a backtrace with over 30000 calls without this,
1906 // XXX: only with 32px shelves. The problem is probably somewhere else,
1907 // XXX: but until it's found, leave this here.
1908 // XXX: by Sachiel, January 21th 2009, 19:30 UTC
1909 _edje_recalc_do(ed);
1910
1911 rp = _edje_real_part_recursive_get(ed, (char *)part);
1912 if (!rp) return EINA_FALSE;
1913 if (rp->part->type != EDJE_PART_TYPE_SWALLOW)
1914 {
1915 ERR("cannot swallow part %s: not swallow type!", rp->part->name);
1916 return EINA_FALSE;
1917 }
1918 _edje_real_part_swallow(rp, obj_swallow, EINA_TRUE);
1919 return EINA_TRUE;
1920}
1921
1922static void
1923_recalc_extern_parent(Evas_Object *obj)
1924{
1925 Evas_Object *parent;
1926 Edje *ed;
1927
1928 parent = evas_object_smart_parent_get(obj);
1929 ed = _edje_fetch(parent);
1930
1931 ed->dirty = 1;
1932 _edje_recalc(ed);
1933}
1934
1935EAPI void
1936edje_extern_object_min_size_set(Evas_Object *obj, Evas_Coord minw, Evas_Coord minh)
1937{
1938 Edje_Real_Part *rp;
1939
1940 evas_object_size_hint_min_set(obj, minw, minh);
1941 rp = evas_object_data_get(obj, "\377 edje.swallowing_part");
1942 if (rp)
1943 {
1944 rp->swallow_params.min.w = minw;
1945 rp->swallow_params.min.h = minh;
1946
1947 _recalc_extern_parent(obj);
1948 }
1949}
1950
1951EAPI void
1952edje_extern_object_max_size_set(Evas_Object *obj, Evas_Coord maxw, Evas_Coord maxh)
1953{
1954 Edje_Real_Part *rp;
1955
1956 evas_object_size_hint_max_set(obj, maxw, maxh);
1957 rp = evas_object_data_get(obj, "\377 edje.swallowing_part");
1958 if (rp)
1959 {
1960 rp->swallow_params.max.w = maxw;
1961 rp->swallow_params.max.h = maxh;
1962
1963 _recalc_extern_parent(obj);
1964 }
1965}
1966
1967EAPI void
1968edje_extern_object_aspect_set(Evas_Object *obj, Edje_Aspect_Control aspect, Evas_Coord aw, Evas_Coord ah)
1969{
1970 Edje_Real_Part *rp;
1971 Evas_Aspect_Control asp;
1972
1973 asp = EVAS_ASPECT_CONTROL_NONE;
1974 switch (aspect)
1975 {
1976 case EDJE_ASPECT_CONTROL_NONE: asp = EVAS_ASPECT_CONTROL_NONE; break;
1977 case EDJE_ASPECT_CONTROL_NEITHER: asp = EVAS_ASPECT_CONTROL_NEITHER; break;
1978 case EDJE_ASPECT_CONTROL_HORIZONTAL: asp = EVAS_ASPECT_CONTROL_HORIZONTAL; break;
1979 case EDJE_ASPECT_CONTROL_VERTICAL: asp = EVAS_ASPECT_CONTROL_VERTICAL; break;
1980 case EDJE_ASPECT_CONTROL_BOTH: asp = EVAS_ASPECT_CONTROL_BOTH; break;
1981 default: break;
1982 }
1983 if (aw < 1) aw = 1;
1984 if (ah < 1) ah = 1;
1985 evas_object_size_hint_aspect_set(obj, asp, aw, ah);
1986 rp = evas_object_data_get(obj, "\377 edje.swallowing_part");
1987 if (rp)
1988 {
1989 rp->swallow_params.aspect.mode = aspect;
1990 rp->swallow_params.aspect.w = aw;
1991 rp->swallow_params.aspect.h = ah;
1992 _recalc_extern_parent(obj);
1993 }
1994}
1995
1996struct edje_box_layout_builtin {
1997 const char *name;
1998 Evas_Object_Box_Layout cb;
1999};
2000
2001static Evas_Object_Box_Layout
2002_edje_box_layout_builtin_find(const char *name)
2003{
2004 const struct edje_box_layout_builtin _edje_box_layout_builtin[] = {
2005 {"horizontal", evas_object_box_layout_horizontal},
2006 {"horizontal_flow", evas_object_box_layout_flow_horizontal},
2007 {"horizontal_homogeneous", evas_object_box_layout_homogeneous_horizontal},
2008 {"horizontal_max", evas_object_box_layout_homogeneous_max_size_horizontal},
2009 {"stack", evas_object_box_layout_stack},
2010 {"vertical", evas_object_box_layout_vertical},
2011 {"vertical_flow", evas_object_box_layout_flow_vertical},
2012 {"vertical_homogeneous", evas_object_box_layout_homogeneous_vertical},
2013 {"vertical_max", evas_object_box_layout_homogeneous_max_size_vertical},
2014 {NULL, NULL}
2015 };
2016 const struct edje_box_layout_builtin *base;
2017
2018 switch (name[0])
2019 {
2020 case 'h':
2021 base = _edje_box_layout_builtin + 0;
2022 break;
2023 case 's':
2024 base = _edje_box_layout_builtin + 4;
2025 break;
2026 case 'v':
2027 base = _edje_box_layout_builtin + 5;
2028 break;
2029 default:
2030 return NULL;
2031 }
2032
2033 for (; (base->name) && (base->name[0] == name[0]); base++)
2034 if (strcmp(base->name, name) == 0)
2035 return base->cb;
2036
2037 return NULL;
2038}
2039
2040static Eina_Rbtree_Direction
2041_edje_box_layout_external_node_cmp(const Eina_Rbtree *left, const Eina_Rbtree *right, __UNUSED__ void *data)
2042{
2043 Edje_Box_Layout *l = (Edje_Box_Layout *)left;
2044 Edje_Box_Layout *r = (Edje_Box_Layout *)right;
2045
2046 if (strcmp(l->name, r->name) < 0)
2047 return EINA_RBTREE_RIGHT;
2048 else
2049 return EINA_RBTREE_LEFT;
2050}
2051
2052static int
2053_edje_box_layout_external_find_cmp(const Eina_Rbtree *node, const void *key, __UNUSED__ int length, __UNUSED__ void *data)
2054{
2055 Edje_Box_Layout *l = (Edje_Box_Layout *)node;
2056 return strcmp(key, l->name);
2057}
2058
2059static Edje_Box_Layout *
2060_edje_box_layout_external_find(const char *name)
2061{
2062 return (Edje_Box_Layout *)eina_rbtree_inline_lookup
2063 (_edje_box_layout_registry, name, 0, _edje_box_layout_external_find_cmp,
2064 NULL);
2065}
2066
2067Eina_Bool
2068_edje_box_layout_find(const char *name, Evas_Object_Box_Layout *cb, void **data, void (**free_data)(void *data))
2069{
2070 const Edje_Box_Layout *l;
2071
2072 if (!name) return EINA_FALSE;
2073
2074 *cb = _edje_box_layout_builtin_find(name);
2075 if (*cb)
2076 {
2077 *free_data = NULL;
2078 *data = NULL;
2079 return EINA_TRUE;
2080 }
2081
2082 l = _edje_box_layout_external_find(name);
2083 if (!l) return EINA_FALSE;
2084
2085 *cb = l->func;
2086 *free_data = l->layout_data_free;
2087 if (l->layout_data_get)
2088 *data = l->layout_data_get(l->data);
2089 else
2090 *data = NULL;
2091
2092 return EINA_TRUE;
2093}
2094
2095static void
2096_edje_box_layout_external_free(Eina_Rbtree *node, __UNUSED__ void *data)
2097{
2098 Edje_Box_Layout *l = (Edje_Box_Layout *)node;
2099
2100 if (l->data && l->free_data)
2101 l->free_data(l->data);
2102 free(l);
2103}
2104
2105static Edje_Box_Layout *
2106_edje_box_layout_external_new(const char *name, Evas_Object_Box_Layout func, void *(*layout_data_get)(void *), void (*layout_data_free)(void *), void (*free_data)(void *), void *data)
2107{
2108 Edje_Box_Layout *l;
2109 size_t name_len;
2110
2111 name_len = strlen(name) + 1;
2112 l = malloc(sizeof(Edje_Box_Layout) + name_len);
2113 if (!l)
2114 {
2115 perror("malloc");
2116 return NULL;
2117 }
2118
2119 l->func = func;
2120 l->layout_data_get = layout_data_get;
2121 l->layout_data_free = layout_data_free;
2122 l->free_data = free_data;
2123 l->data = data;
2124
2125 memcpy(l->name, name, name_len);
2126
2127 return l;
2128}
2129
2130EAPI void
2131edje_box_layout_register(const char *name, Evas_Object_Box_Layout func, void *(*layout_data_get)(void *), void (*layout_data_free)(void *), void (*free_data)(void *), void *data)
2132{
2133 Edje_Box_Layout *l;
2134
2135 if (!name) return;
2136
2137 if (_edje_box_layout_builtin_find(name))
2138 {
2139 ERR("Cannot register layout '%s': would override builtin!",
2140 name);
2141
2142 if (data && free_data) free_data(data);
2143 return;
2144 }
2145
2146 l = _edje_box_layout_external_find(name);
2147 if (!l)
2148 {
2149 if (!func)
2150 {
2151 if (data && free_data) free_data(data);
2152 return;
2153 }
2154
2155 l = _edje_box_layout_external_new
2156 (name, func, layout_data_get, layout_data_free, free_data, data);
2157 if (!l)
2158 return;
2159
2160 _edje_box_layout_registry = eina_rbtree_inline_insert
2161 (_edje_box_layout_registry, (Eina_Rbtree *)l,
2162 _edje_box_layout_external_node_cmp, NULL);
2163 }
2164 else
2165 {
2166 if (func)
2167 {
2168 if (l->data && l->free_data) l->free_data(l->data);
2169
2170 l->func = func;
2171 l->layout_data_get = layout_data_get;
2172 l->layout_data_free = layout_data_free;
2173 l->free_data = free_data;
2174 l->data = data;
2175 }
2176 else
2177 {
2178 if (data && free_data) free_data(data);
2179
2180 _edje_box_layout_registry = eina_rbtree_inline_remove
2181 (_edje_box_layout_registry, (Eina_Rbtree *)l,
2182 _edje_box_layout_external_node_cmp, NULL);
2183 _edje_box_layout_external_free((Eina_Rbtree *)l, NULL);
2184 }
2185 }
2186}
2187
2188EAPI void
2189edje_object_part_unswallow(Evas_Object *obj __UNUSED__, Evas_Object *obj_swallow)
2190{
2191 Edje_Real_Part *rp;
2192
2193 if (!obj_swallow) return;
2194
2195 rp = (Edje_Real_Part *)evas_object_data_get(obj_swallow, "\377 edje.swallowing_part");
2196 if (!rp)
2197 return;
2198 if (rp->part->type != EDJE_PART_TYPE_SWALLOW)
2199 {
2200 ERR("cannot unswallow part %s: not swallow type!", rp->part->name);
2201 return;
2202 }
2203 if (rp->swallowed_object == obj_swallow)
2204 {
2205 evas_object_smart_member_del(rp->swallowed_object);
2206 evas_object_event_callback_del_full(rp->swallowed_object,
2207 EVAS_CALLBACK_FREE,
2208 _edje_object_part_swallow_free_cb,
2209 rp->edje->obj);
2210 evas_object_event_callback_del_full(rp->swallowed_object,
2211 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
2212 _edje_object_part_swallow_changed_hints_cb,
2213 rp);
2214 evas_object_clip_unset(rp->swallowed_object);
2215 evas_object_data_del(rp->swallowed_object, "\377 edje.swallowing_part");
2216
2217 if (rp->part->mouse_events)
2218 _edje_callbacks_del(rp->swallowed_object, rp->edje);
2219 _edje_callbacks_focus_del(rp->swallowed_object, rp->edje);
2220
2221 rp->swallowed_object = NULL;
2222 rp->swallow_params.min.w = 0;
2223 rp->swallow_params.min.h = 0;
2224 rp->swallow_params.max.w = 0;
2225 rp->swallow_params.max.h = 0;
2226 rp->edje->dirty = 1;
2227#ifdef EDJE_CALC_CACHE
2228 rp->invalidate = 1;
2229#endif
2230 _edje_recalc_do(rp->edje);
2231 return;
2232 }
2233}
2234
2235EAPI Evas_Object *
2236edje_object_part_swallow_get(const Evas_Object *obj, const char *part)
2237{
2238 Edje *ed;
2239 Edje_Real_Part *rp;
2240
2241 ed = _edje_fetch(obj);
2242 if ((!ed) || (!part)) return NULL;
2243
2244 /* Need to recalc before providing the object. */
2245 _edje_recalc_do(ed);
2246
2247 rp = _edje_real_part_recursive_get(ed, (char *)part);
2248 if (!rp) return NULL;
2249 return rp->swallowed_object;
2250}
2251
2252EAPI void
2253edje_object_size_min_get(const Evas_Object *obj, Evas_Coord *minw, Evas_Coord *minh)
2254{
2255 Edje *ed;
2256
2257 ed = _edje_fetch(obj);
2258 if ((!ed) || (!ed->collection))
2259 {
2260 if (minw) *minw = 0;
2261 if (minh) *minh = 0;
2262 return;
2263 }
2264 if (minw) *minw = ed->collection->prop.min.w;
2265 if (minh) *minh = ed->collection->prop.min.h;
2266}
2267
2268EAPI void
2269edje_object_size_max_get(const Evas_Object *obj, Evas_Coord *maxw, Evas_Coord *maxh)
2270{
2271 Edje *ed;
2272
2273 ed = _edje_fetch(obj);
2274 if ((!ed) || (!ed->collection))
2275 {
2276 if (maxw) *maxw = 0;
2277 if (maxh) *maxh = 0;
2278 return;
2279 }
2280
2281 /* Need to recalc before providing the object. */
2282 _edje_recalc_do(ed);
2283
2284 if (ed->collection->prop.max.w == 0)
2285 {
2286 /* XXX TODO: convert maxw to 0, fix things that break. */
2287 if (maxw) *maxw = EDJE_INF_MAX_W;
2288 }
2289 else
2290 {
2291 if (maxw) *maxw = ed->collection->prop.max.w;
2292 }
2293 if (ed->collection->prop.max.h == 0)
2294 {
2295 /* XXX TODO: convert maxh to 0, fix things that break. */
2296 if (maxh) *maxh = EDJE_INF_MAX_H;
2297 }
2298 else
2299 {
2300 if (maxh) *maxh = ed->collection->prop.max.h;
2301 }
2302}
2303
2304EAPI void
2305edje_object_calc_force(Evas_Object *obj)
2306{
2307 Edje *ed;
2308 int pf, pf2;
2309
2310 ed = _edje_fetch(obj);
2311 if (!ed) return;
2312 ed->dirty = 1;
2313#ifdef EDJE_CALC_CACHE
2314 ed->all_part_change = 1;
2315#endif
2316
2317 pf2 = _edje_freeze_val;
2318 pf = ed->freeze;
2319
2320 _edje_freeze_val = 0;
2321 ed->freeze = 0;
2322
2323 _edje_recalc_do(ed);
2324
2325 ed->freeze = pf;
2326 _edje_freeze_val = pf2;
2327}
2328
2329EAPI void
2330edje_object_size_min_calc(Evas_Object *obj, Evas_Coord *minw, Evas_Coord *minh)
2331{
2332 edje_object_size_min_restricted_calc(obj, minw, minh, 0, 0);
2333}
2334
2335EAPI Eina_Bool
2336edje_object_parts_extends_calc(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
2337{
2338 Edje *ed;
2339 Evas_Coord x1 = INT_MAX, y1 = INT_MAX;
2340 Evas_Coord x2 = 0, y2 = 0;
2341 unsigned int i;
2342
2343 ed = _edje_fetch(obj);
2344 if (!ed)
2345 {
2346 if (x) *x = 0;
2347 if (y) *y = 0;
2348 if (w) *w = 0;
2349 if (h) *h = 0;
2350 return EINA_FALSE;
2351 }
2352
2353 ed->calc_only = 1;
2354
2355 /* Need to recalc before providing the object. */
2356 ed->dirty = 1;
2357 _edje_recalc_do(ed);
2358
2359 for (i = 0; i < ed->table_parts_size; i++)
2360 {
2361 Edje_Real_Part *rp;
2362 Evas_Coord rpx1, rpy1;
2363 Evas_Coord rpx2, rpy2;
2364
2365 rp = ed->table_parts[i];
2366
2367 rpx1 = rp->x;
2368 rpy1 = rp->y;
2369 rpx2 = rpx1 + rp->w;
2370 rpy2 = rpy1 + rp->h;
2371
2372 if (x1 > rpx1) x1 = rpx1;
2373 if (y1 > rpy1) y1 = rpy1;
2374 if (x2 < rpx2) x2 = rpx2;
2375 if (y2 < rpy2) y2 = rpy2;
2376 }
2377
2378 ed->calc_only = 0;
2379
2380 if (x) *x = x1;
2381 if (y) *y = y1;
2382 if (w) *w = x2 - x1;
2383 if (h) *h = y2 - y1;
2384
2385 return EINA_TRUE;
2386}
2387
2388EAPI void
2389edje_object_size_min_restricted_calc(Evas_Object *obj, Evas_Coord *minw, Evas_Coord *minh, Evas_Coord restrictedw, Evas_Coord restrictedh)
2390{
2391 Edje *ed;
2392 Evas_Coord pw, ph;
2393 int maxw, maxh;
2394 int okw, okh;
2395 int reset_maxwh;
2396 Edje_Real_Part *pep = NULL;
2397 Eina_Bool has_non_fixed_tb = EINA_FALSE;
2398
2399 ed = _edje_fetch(obj);
2400 if ((!ed) || (!ed->collection))
2401 {
2402 if (minw) *minw = restrictedw;
2403 if (minh) *minh = restrictedh;
2404 return;
2405 }
2406 reset_maxwh = 1;
2407 ed->calc_only = 1;
2408 pw = ed->w;
2409 ph = ed->h;
2410
2411 again:
2412 ed->w = restrictedw;
2413 ed->h = restrictedh;
2414
2415 maxw = 0;
2416 maxh = 0;
2417
2418 do
2419 {
2420 unsigned int i;
2421
2422 okw = okh = 0;
2423 ed->dirty = 1;
2424#ifdef EDJE_CALC_CACHE
2425 ed->all_part_change = 1;
2426#endif
2427 _edje_recalc_do(ed);
2428 if (reset_maxwh)
2429 {
2430 maxw = 0;
2431 maxh = 0;
2432 }
2433 pep = NULL;
2434 for (i = 0; i < ed->table_parts_size; i++)
2435 {
2436 Edje_Real_Part *ep;
2437 int w, h;
2438 int didw;
2439
2440 ep = ed->table_parts[i];
2441 w = ep->w - ep->req.w;
2442 h = ep->h - ep->req.h;
2443 didw = 0;
2444 if (ep->chosen_description)
2445 {
2446 if (!ep->chosen_description->fixed.w)
2447 {
2448 if ((ep->part->type == EDJE_PART_TYPE_TEXTBLOCK))
2449 {
2450 Evas_Coord tb_mw;
2451 evas_object_textblock_size_formatted_get(ep->object,
2452 &tb_mw, NULL);
2453 tb_mw -= ep->req.w;
2454 if (tb_mw > w)
2455 {
2456 w = tb_mw;
2457 }
2458 has_non_fixed_tb = EINA_TRUE;
2459 }
2460 if (w > maxw)
2461 {
2462 maxw = w;
2463 okw = 1;
2464 pep = ep;
2465 didw = 1;
2466 }
2467 }
2468 if (!ep->chosen_description->fixed.h)
2469 {
2470 if (!((ep->part->type == EDJE_PART_TYPE_TEXTBLOCK) &&
2471 (!((Edje_Part_Description_Text *)ep->chosen_description)->text.min_x) &&
2472 (didw)))
2473 {
2474 if (h > maxh)
2475 {
2476 maxh = h;
2477 okh = 1;
2478 pep = ep;
2479 }
2480 }
2481
2482 if (ep->part->type == EDJE_PART_TYPE_TEXTBLOCK)
2483 {
2484 has_non_fixed_tb = EINA_TRUE;
2485 }
2486 }
2487 }
2488 }
2489 if (okw)
2490 {
2491 ed->w += maxw;
2492 if (ed->w < restrictedw) ed->w = restrictedw;
2493 }
2494 if (okh)
2495 {
2496 ed->h += maxh;
2497 if (ed->h < restrictedh) ed->h = restrictedh;
2498 }
2499 if ((ed->w > 4000) || (ed->h > 4000))
2500 {
2501 /* Only print it if we have a non-fixed textblock.
2502 * We should possibly avoid all of this if in this case, but in
2503 * the meanwhile, just doing this. */
2504 if (!has_non_fixed_tb)
2505 {
2506 if (pep)
2507 ERR("file %s, group %s has a non-fixed part '%s'. Adding 'fixed: 1 1;' to source EDC may help. Continuing discarding faulty part.",
2508 ed->path, ed->group, pep->part->name);
2509 else
2510 ERR("file %s, group %s overflowed 4000x4000 with minimum size of %dx%d. Continuing discarding faulty parts.",
2511 ed->path, ed->group, ed->w, ed->h);
2512 }
2513
2514 if (reset_maxwh)
2515 {
2516 reset_maxwh = 0;
2517 goto again;
2518 }
2519 }
2520 }
2521 while (okw || okh);
2522 ed->min.w = ed->w;
2523 ed->min.h = ed->h;
2524
2525 if (minw) *minw = ed->min.w;
2526 if (minh) *minh = ed->min.h;
2527
2528 ed->w = pw;
2529 ed->h = ph;
2530 ed->dirty = 1;
2531#ifdef EDJE_CALC_CACHE
2532 ed->all_part_change = 1;
2533#endif
2534 _edje_recalc(ed);
2535 ed->calc_only = 0;
2536}
2537
2538/* FIXME: Correctly return other states */
2539EAPI const char *
2540edje_object_part_state_get(const Evas_Object *obj, const char *part, double *val_ret)
2541{
2542 Edje *ed;
2543 Edje_Real_Part *rp;
2544
2545 ed = _edje_fetch(obj);
2546 if ((!ed) || (!part))
2547 {
2548 if (val_ret) *val_ret = 0;
2549 return "";
2550 }
2551
2552 /* Need to recalc before providing the object. */
2553 _edje_recalc_do(ed);
2554
2555 rp = _edje_real_part_recursive_get(ed, (char *)part);
2556 if (!rp)
2557 {
2558 if (val_ret) *val_ret = 0;
2559 INF("part not found");
2560 return "";
2561 }
2562 if (rp->chosen_description)
2563 {
2564 if (val_ret) *val_ret = rp->chosen_description->state.value;
2565 if (rp->chosen_description->state.name)
2566 return rp->chosen_description->state.name;
2567 return "default";
2568 }
2569 else
2570 {
2571 if (rp->param1.description)
2572 {
2573 if (val_ret) *val_ret = rp->param1.description->state.value;
2574 if (rp->param1.description->state.name)
2575 return rp->param1.description->state.name;
2576 return "default";
2577 }
2578 }
2579 if (val_ret) *val_ret = 0;
2580 return "";
2581}
2582
2583EAPI Edje_Drag_Dir
2584edje_object_part_drag_dir_get(const Evas_Object *obj, const char *part)
2585{
2586 Edje *ed;
2587 Edje_Real_Part *rp;
2588
2589 ed = _edje_fetch(obj);
2590 if ((!ed) || (!part)) return EDJE_DRAG_DIR_NONE;
2591
2592 /* Need to recalc before providing the object. */
2593 _edje_recalc_do(ed);
2594
2595 rp = _edje_real_part_recursive_get(ed, (char *)part);
2596 if (!rp) return EDJE_DRAG_DIR_NONE;
2597 if ((rp->part->dragable.x) && (rp->part->dragable.y)) return EDJE_DRAG_DIR_XY;
2598 else if (rp->part->dragable.x) return EDJE_DRAG_DIR_X;
2599 else if (rp->part->dragable.y) return EDJE_DRAG_DIR_Y;
2600 return EDJE_DRAG_DIR_NONE;
2601}
2602
2603EAPI Eina_Bool
2604edje_object_part_drag_value_set(Evas_Object *obj, const char *part, double dx, double dy)
2605{
2606 Edje *ed;
2607 Edje_Real_Part *rp;
2608
2609 ed = _edje_fetch(obj);
2610 if ((!ed) || (!part)) return EINA_FALSE;
2611 rp = _edje_real_part_recursive_get(ed, (char *)part);
2612 if (!rp) return EINA_FALSE;
2613 if (!rp->drag) return EINA_FALSE;
2614 if (rp->drag->down.count > 0) return EINA_FALSE;
2615 if (rp->part->dragable.confine_id != -1)
2616 {
2617 dx = CLAMP(dx, 0.0, 1.0);
2618 dy = CLAMP(dy, 0.0, 1.0);
2619 }
2620 if (rp->part->dragable.x < 0) dx = 1.0 - dx;
2621 if (rp->part->dragable.y < 0) dy = 1.0 - dy;
2622 if ((rp->drag->val.x == FROM_DOUBLE(dx)) && (rp->drag->val.y == FROM_DOUBLE(dy))) return EINA_TRUE;
2623 rp->drag->val.x = FROM_DOUBLE(dx);
2624 rp->drag->val.y = FROM_DOUBLE(dy);
2625#ifdef EDJE_CALC_CACHE
2626 rp->invalidate = 1;
2627#endif
2628 _edje_dragable_pos_set(rp->edje, rp, rp->drag->val.x, rp->drag->val.y);
2629 _edje_emit(rp->edje, "drag,set", rp->part->name);
2630 return EINA_TRUE;
2631}
2632
2633/* FIXME: Should this be x and y instead of dx/dy? */
2634EAPI Eina_Bool
2635edje_object_part_drag_value_get(const Evas_Object *obj, const char *part, double *dx, double *dy)
2636{
2637 Edje *ed;
2638 Edje_Real_Part *rp;
2639 double ddx, ddy;
2640
2641 ed = _edje_fetch(obj);
2642 if ((!ed) || (!part))
2643 {
2644 if (dx) *dx = 0;
2645 if (dy) *dy = 0;
2646 return EINA_FALSE;
2647 }
2648
2649 /* Need to recalc before providing the object. */
2650 _edje_recalc_do(ed);
2651
2652 rp = _edje_real_part_recursive_get(ed, (char *)part);
2653 if (!rp || !rp->drag)
2654 {
2655 if (dx) *dx = 0;
2656 if (dy) *dy = 0;
2657 return EINA_FALSE;
2658 }
2659 ddx = TO_DOUBLE(rp->drag->val.x);
2660 ddy = TO_DOUBLE(rp->drag->val.y);
2661 if (rp->part->dragable.x < 0) ddx = 1.0 - ddx;
2662 if (rp->part->dragable.y < 0) ddy = 1.0 - ddy;
2663 if (dx) *dx = ddx;
2664 if (dy) *dy = ddy;
2665 return EINA_TRUE;
2666}
2667
2668EAPI Eina_Bool
2669edje_object_part_drag_size_set(Evas_Object *obj, const char *part, double dw, double dh)
2670{
2671 Edje *ed;
2672 Edje_Real_Part *rp;
2673
2674 ed = _edje_fetch(obj);
2675 if ((!ed) || (!part)) return EINA_FALSE;
2676 rp = _edje_real_part_recursive_get(ed, (char *)part);
2677 if (!rp) return EINA_FALSE;
2678 if (!rp->drag) return EINA_FALSE;
2679 if (dw < 0.0) dw = 0.0;
2680 else if (dw > 1.0) dw = 1.0;
2681 if (dh < 0.0) dh = 0.0;
2682 else if (dh > 1.0) dh = 1.0;
2683 if ((rp->drag->size.x == FROM_DOUBLE(dw)) && (rp->drag->size.y == FROM_DOUBLE(dh))) return EINA_TRUE;
2684 rp->drag->size.x = FROM_DOUBLE(dw);
2685 rp->drag->size.y = FROM_DOUBLE(dh);
2686 rp->edje->dirty = 1;
2687#ifdef EDJE_CALC_CACHE
2688 rp->invalidate = 1;
2689#endif
2690 _edje_recalc(rp->edje);
2691 return EINA_TRUE;
2692}
2693
2694EAPI Eina_Bool
2695edje_object_part_drag_size_get(const Evas_Object *obj, const char *part, double *dw, double *dh)
2696{
2697 Edje *ed;
2698 Edje_Real_Part *rp;
2699
2700 ed = _edje_fetch(obj);
2701 if ((!ed) || (!part))
2702 {
2703 if (dw) *dw = 0;
2704 if (dh) *dh = 0;
2705 return EINA_FALSE;
2706 }
2707
2708 /* Need to recalc before providing the object. */
2709 _edje_recalc_do(ed);
2710
2711 rp = _edje_real_part_recursive_get(ed, (char *)part);
2712 if (!rp || !rp->drag)
2713 {
2714 if (dw) *dw = 0;
2715 if (dh) *dh = 0;
2716 return EINA_FALSE;
2717 }
2718 if (dw) *dw = TO_DOUBLE(rp->drag->size.x);
2719 if (dh) *dh = TO_DOUBLE(rp->drag->size.y);
2720 return EINA_TRUE;
2721}
2722
2723EAPI Eina_Bool
2724edje_object_part_drag_step_set(Evas_Object *obj, const char *part, double dx, double dy)
2725{
2726 Edje *ed;
2727 Edje_Real_Part *rp;
2728
2729 ed = _edje_fetch(obj);
2730 if ((!ed) || (!part)) return EINA_FALSE;
2731 rp = _edje_real_part_recursive_get(ed, (char *)part);
2732 if (!rp) return EINA_FALSE;
2733 if (!rp->drag) return EINA_FALSE;
2734 if (dx < 0.0) dx = 0.0;
2735 else if (dx > 1.0) dx = 1.0;
2736 if (dy < 0.0) dy = 0.0;
2737 else if (dy > 1.0) dy = 1.0;
2738 rp->drag->step.x = FROM_DOUBLE(dx);
2739 rp->drag->step.y = FROM_DOUBLE(dy);
2740#ifdef EDJE_CALC_CACHE
2741 rp->invalidate = 1;
2742#endif
2743 return EINA_TRUE;
2744}
2745
2746EAPI Eina_Bool
2747edje_object_part_drag_step_get(const Evas_Object *obj, const char *part, double *dx, double *dy)
2748{
2749 Edje *ed;
2750 Edje_Real_Part *rp;
2751
2752 ed = _edje_fetch(obj);
2753 if ((!ed) || (!part))
2754 {
2755 if (dx) *dx = 0;
2756 if (dy) *dy = 0;
2757 return EINA_FALSE;
2758 }
2759
2760 /* Need to recalc before providing the object. */
2761 _edje_recalc_do(ed);
2762
2763 rp = _edje_real_part_recursive_get(ed, (char *)part);
2764 if (!rp || !rp->drag)
2765 {
2766 if (dx) *dx = 0;
2767 if (dy) *dy = 0;
2768 return EINA_FALSE;
2769 }
2770 if (dx) *dx = TO_DOUBLE(rp->drag->step.x);
2771 if (dy) *dy = TO_DOUBLE(rp->drag->step.y);
2772 return EINA_TRUE;
2773}
2774
2775EAPI Eina_Bool
2776edje_object_part_drag_page_set(Evas_Object *obj, const char *part, double dx, double dy)
2777{
2778 Edje *ed;
2779 Edje_Real_Part *rp;
2780
2781 ed = _edje_fetch(obj);
2782 if ((!ed) || (!part)) return EINA_FALSE;
2783 rp = _edje_real_part_recursive_get(ed, (char *)part);
2784 if (!rp) return EINA_FALSE;
2785 if (!rp->drag) return EINA_FALSE;
2786 if (dx < 0.0) dx = 0.0;
2787 else if (dx > 1.0) dx = 1.0;
2788 if (dy < 0.0) dy = 0.0;
2789 else if (dy > 1.0) dy = 1.0;
2790 rp->drag->page.x = FROM_DOUBLE(dx);
2791 rp->drag->page.y = FROM_DOUBLE(dy);
2792#ifdef EDJE_CALC_CACHE
2793 rp->invalidate = 1;
2794#endif
2795 return EINA_TRUE;
2796}
2797
2798EAPI Eina_Bool
2799edje_object_part_drag_page_get(const Evas_Object *obj, const char *part, double *dx, double *dy)
2800{
2801 Edje *ed;
2802 Edje_Real_Part *rp;
2803
2804 ed = _edje_fetch(obj);
2805 if ((!ed) || (!part))
2806 {
2807 if (dx) *dx = 0;
2808 if (dy) *dy = 0;
2809 return EINA_FALSE;
2810 }
2811
2812 /* Need to recalc before providing the object. */
2813 _edje_recalc_do(ed);
2814
2815 rp = _edje_real_part_recursive_get(ed, (char *)part);
2816 if (!rp || !rp->drag)
2817 {
2818 if (dx) *dx = 0;
2819 if (dy) *dy = 0;
2820 return EINA_FALSE;
2821 }
2822 if (dx) *dx = TO_DOUBLE(rp->drag->page.x);
2823 if (dy) *dy = TO_DOUBLE(rp->drag->page.y);
2824 return EINA_TRUE;
2825}
2826
2827EAPI Eina_Bool
2828edje_object_part_drag_step(Evas_Object *obj, const char *part, double dx, double dy)
2829{
2830 Edje *ed;
2831 Edje_Real_Part *rp;
2832 FLOAT_T px, py;
2833
2834 ed = _edje_fetch(obj);
2835 if ((!ed) || (!part)) return EINA_FALSE;
2836 rp = _edje_real_part_recursive_get(ed, (char *)part);
2837 if (!rp) return EINA_FALSE;
2838 if (!rp->drag) return EINA_FALSE;
2839 if (rp->drag->down.count > 0) return EINA_FALSE;
2840 px = rp->drag->val.x;
2841 py = rp->drag->val.y;
2842 rp->drag->val.x = ADD(px, MUL(FROM_DOUBLE(dx),
2843 MUL(rp->drag->step.x, rp->part->dragable.x)));
2844 rp->drag->val.y = ADD(py, MUL(FROM_DOUBLE(dy),
2845 MUL(rp->drag->step.y, rp->part->dragable.y)));
2846 rp->drag->val.x = CLAMP (rp->drag->val.x, ZERO, FROM_DOUBLE(1.0));
2847 rp->drag->val.y = CLAMP (rp->drag->val.y, ZERO, FROM_DOUBLE(1.0));
2848 if ((px == rp->drag->val.x) && (py == rp->drag->val.y)) return EINA_TRUE;
2849#ifdef EDJE_CALC_CACHE
2850 rp->invalidate = 1;
2851#endif
2852 _edje_dragable_pos_set(rp->edje, rp, rp->drag->val.x, rp->drag->val.y);
2853 _edje_emit(rp->edje, "drag,step", rp->part->name);
2854 return EINA_TRUE;
2855}
2856
2857EAPI Eina_Bool
2858edje_object_part_drag_page(Evas_Object *obj, const char *part, double dx, double dy)
2859{
2860 Edje *ed;
2861 Edje_Real_Part *rp;
2862 FLOAT_T px, py;
2863
2864 ed = _edje_fetch(obj);
2865 if ((!ed) || (!part)) return EINA_FALSE;
2866 rp = _edje_real_part_recursive_get(ed, (char *)part);
2867 if (!rp) return EINA_FALSE;
2868 if (!rp->drag) return EINA_FALSE;
2869 if (rp->drag->down.count > 0) return EINA_FALSE;
2870 px = rp->drag->val.x;
2871 py = rp->drag->val.y;
2872 rp->drag->val.x = ADD(px, MUL(FROM_DOUBLE(dx), MUL(rp->drag->page.x, rp->part->dragable.x)));
2873 rp->drag->val.y = ADD(py, MUL(FROM_DOUBLE(dy), MUL(rp->drag->page.y, rp->part->dragable.y)));
2874 rp->drag->val.x = CLAMP (rp->drag->val.x, ZERO, FROM_DOUBLE(1.0));
2875 rp->drag->val.y = CLAMP (rp->drag->val.y, ZERO, FROM_DOUBLE(1.0));
2876 if ((px == rp->drag->val.x) && (py == rp->drag->val.y)) return EINA_TRUE;
2877#ifdef EDJE_CALC_CACHE
2878 rp->invalidate = 1;
2879#endif
2880 _edje_dragable_pos_set(rp->edje, rp, rp->drag->val.x, rp->drag->val.y);
2881 _edje_emit(rp->edje, "drag,page", rp->part->name);
2882 return EINA_TRUE;
2883}
2884
2885void
2886_edje_box_init(void)
2887{
2888
2889}
2890
2891void
2892_edje_box_shutdown(void)
2893{
2894 if (!_edje_box_layout_registry)
2895 return;
2896
2897 eina_rbtree_delete
2898 (_edje_box_layout_registry, _edje_box_layout_external_free, NULL);
2899 _edje_box_layout_registry = NULL;
2900}
2901
2902EAPI Eina_Bool
2903edje_object_part_box_append(Evas_Object *obj, const char *part, Evas_Object *child)
2904{
2905 Edje *ed;
2906 Edje_Real_Part *rp;
2907
2908 ed = _edje_fetch(obj);
2909 if ((!ed) || (!part) || (!child)) return EINA_FALSE;
2910
2911 rp = _edje_real_part_recursive_get(ed, part);
2912 if (!rp) return EINA_FALSE;
2913 if (rp->part->type != EDJE_PART_TYPE_BOX) return EINA_FALSE;
2914
2915 return _edje_real_part_box_append(rp, child);
2916}
2917
2918EAPI Eina_Bool
2919edje_object_part_box_prepend(Evas_Object *obj, const char *part, Evas_Object *child)
2920{
2921 Edje *ed;
2922 Edje_Real_Part *rp;
2923
2924 ed = _edje_fetch(obj);
2925 if ((!ed) || (!part)) return EINA_FALSE;
2926
2927 rp = _edje_real_part_recursive_get(ed, part);
2928 if (!rp) return EINA_FALSE;
2929 if (rp->part->type != EDJE_PART_TYPE_BOX) return EINA_FALSE;
2930
2931 return _edje_real_part_box_prepend(rp, child);
2932}
2933
2934EAPI Eina_Bool
2935edje_object_part_box_insert_before(Evas_Object *obj, const char *part, Evas_Object *child, const Evas_Object *reference)
2936{
2937 Edje *ed;
2938 Edje_Real_Part *rp;
2939
2940 ed = _edje_fetch(obj);
2941 if ((!ed) || (!part)) return EINA_FALSE;
2942
2943 rp = _edje_real_part_recursive_get(ed, part);
2944 if (!rp) return EINA_FALSE;
2945 if (rp->part->type != EDJE_PART_TYPE_BOX) return EINA_FALSE;
2946
2947 return _edje_real_part_box_insert_before(rp, child, reference);
2948}
2949
2950EAPI Eina_Bool
2951edje_object_part_box_insert_at(Evas_Object *obj, const char *part, Evas_Object *child, unsigned int pos)
2952{
2953 Edje *ed;
2954 Edje_Real_Part *rp;
2955
2956 ed = _edje_fetch(obj);
2957 if ((!ed) || (!part)) return EINA_FALSE;
2958
2959 rp = _edje_real_part_recursive_get(ed, part);
2960 if (!rp) return EINA_FALSE;
2961 if (rp->part->type != EDJE_PART_TYPE_BOX) return EINA_FALSE;
2962
2963 return _edje_real_part_box_insert_at(rp, child, pos);
2964}
2965
2966EAPI Evas_Object *
2967edje_object_part_box_remove(Evas_Object *obj, const char *part, Evas_Object *child)
2968{
2969 Edje *ed;
2970 Edje_Real_Part *rp;
2971
2972 ed = _edje_fetch(obj);
2973 if ((!ed) || (!part)) return NULL;
2974
2975 rp = _edje_real_part_recursive_get(ed, part);
2976 if (!rp) return NULL;
2977 if (rp->part->type != EDJE_PART_TYPE_BOX) return NULL;
2978
2979 return _edje_real_part_box_remove(rp, child);
2980}
2981
2982EAPI Evas_Object *
2983edje_object_part_box_remove_at(Evas_Object *obj, const char *part, unsigned int pos)
2984{
2985 Edje *ed;
2986 Edje_Real_Part *rp;
2987
2988 ed = _edje_fetch(obj);
2989 if ((!ed) || (!part)) return NULL;
2990
2991 rp = _edje_real_part_recursive_get(ed, part);
2992 if (!rp) return NULL;
2993 if (rp->part->type != EDJE_PART_TYPE_BOX) return NULL;
2994
2995 return _edje_real_part_box_remove_at(rp, pos);
2996}
2997
2998EAPI Eina_Bool
2999edje_object_part_box_remove_all(Evas_Object *obj, const char *part, Eina_Bool clear)
3000{
3001 Edje *ed;
3002 Edje_Real_Part *rp;
3003
3004 ed = _edje_fetch(obj);
3005 if ((!ed) || (!part)) return EINA_FALSE;
3006
3007 rp = _edje_real_part_recursive_get(ed, part);
3008 if (!rp) return EINA_FALSE;
3009 if (rp->part->type != EDJE_PART_TYPE_BOX) return EINA_FALSE;
3010
3011 return _edje_real_part_box_remove_all(rp, clear);
3012
3013}
3014
3015static void
3016_edje_box_child_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *child __UNUSED__, void *einfo __UNUSED__)
3017{
3018 Edje_Real_Part *rp = data;
3019
3020 rp->edje->dirty = 1;
3021#ifdef EDJE_CALC_CACHE
3022 rp->invalidate = 1;
3023#endif
3024 _edje_recalc(rp->edje);
3025}
3026
3027static void
3028_edje_box_child_add(Edje_Real_Part *rp, Evas_Object *child)
3029{
3030 evas_object_event_callback_add
3031 (child, EVAS_CALLBACK_DEL, _edje_box_child_del_cb, rp);
3032
3033 rp->edje->dirty = 1;
3034#ifdef EDJE_CALC_CACHE
3035 rp->invalidate = 1;
3036#endif
3037 _edje_recalc(rp->edje);
3038}
3039
3040static void
3041_edje_box_child_remove(Edje_Real_Part *rp, Evas_Object *child)
3042{
3043 evas_object_event_callback_del_full
3044 (child, EVAS_CALLBACK_DEL, _edje_box_child_del_cb, rp);
3045
3046 rp->edje->dirty = 1;
3047#ifdef EDJE_CALC_CACHE
3048 rp->invalidate = 1;
3049#endif
3050 _edje_recalc(rp->edje);
3051}
3052
3053Eina_Bool
3054_edje_real_part_box_append(Edje_Real_Part *rp, Evas_Object *child_obj)
3055{
3056 Evas_Object_Box_Option *opt;
3057
3058 opt = evas_object_box_append(rp->object, child_obj);
3059 if (!opt) return EINA_FALSE;
3060
3061 if (!_edje_box_layout_add_child(rp, child_obj))
3062 {
3063 evas_object_box_remove(rp->object, child_obj);
3064 return EINA_FALSE;
3065 }
3066
3067 _edje_box_child_add(rp, child_obj);
3068
3069 return EINA_TRUE;
3070}
3071
3072Eina_Bool
3073_edje_real_part_box_prepend(Edje_Real_Part *rp, Evas_Object *child_obj)
3074{
3075 Evas_Object_Box_Option *opt;
3076
3077 opt = evas_object_box_prepend(rp->object, child_obj);
3078 if (!opt) return EINA_FALSE;
3079
3080 if (!_edje_box_layout_add_child(rp, child_obj))
3081 {
3082 evas_object_box_remove(rp->object, child_obj);
3083 return EINA_FALSE;
3084 }
3085
3086 _edje_box_child_add(rp, child_obj);
3087
3088 return EINA_TRUE;
3089}
3090
3091Eina_Bool
3092_edje_real_part_box_insert_before(Edje_Real_Part *rp, Evas_Object *child_obj, const Evas_Object *ref)
3093{
3094 Evas_Object_Box_Option *opt;
3095
3096 opt = evas_object_box_insert_before(rp->object, child_obj, ref);
3097 if (!opt) return EINA_FALSE;
3098
3099 if (!_edje_box_layout_add_child(rp, child_obj))
3100 {
3101 evas_object_box_remove(rp->object, child_obj);
3102 return EINA_FALSE;
3103 }
3104
3105 _edje_box_child_add(rp, child_obj);
3106
3107 return EINA_TRUE;
3108}
3109
3110Eina_Bool
3111_edje_real_part_box_insert_at(Edje_Real_Part *rp, Evas_Object *child_obj, unsigned int pos)
3112{
3113 Evas_Object_Box_Option *opt;
3114
3115 opt = evas_object_box_insert_at(rp->object, child_obj, pos);
3116 if (!opt) return EINA_FALSE;
3117
3118 if (!_edje_box_layout_add_child(rp, child_obj))
3119 {
3120 evas_object_box_remove(rp->object, child_obj);
3121 return EINA_FALSE;
3122 }
3123
3124 _edje_box_child_add(rp, child_obj);
3125
3126 return EINA_TRUE;
3127}
3128
3129Evas_Object *
3130_edje_real_part_box_remove(Edje_Real_Part *rp, Evas_Object *child_obj)
3131{
3132 if (evas_object_data_get(child_obj, "\377 edje.box_item")) return NULL;
3133 if (!evas_object_box_remove(rp->object, child_obj)) return NULL;
3134 _edje_box_layout_remove_child(rp, child_obj);
3135 _edje_box_child_remove(rp, child_obj);
3136 return child_obj;
3137}
3138
3139Evas_Object *
3140_edje_real_part_box_remove_at(Edje_Real_Part *rp, unsigned int pos)
3141{
3142 Evas_Object_Box_Option *opt;
3143 Evas_Object_Box_Data *priv;
3144 Evas_Object *child_obj;
3145
3146 priv = evas_object_smart_data_get(rp->object);
3147 opt = eina_list_nth(priv->children, pos);
3148 if (!opt) return NULL;
3149 child_obj = opt->obj;
3150 if (evas_object_data_get(child_obj, "\377 edje.box_item")) return NULL;
3151 if (!evas_object_box_remove_at(rp->object, pos)) return NULL;
3152 _edje_box_layout_remove_child(rp, child_obj);
3153 _edje_box_child_remove(rp, child_obj);
3154 return child_obj;
3155}
3156
3157Eina_Bool
3158_edje_real_part_box_remove_all(Edje_Real_Part *rp, Eina_Bool clear)
3159{
3160 Eina_List *children;
3161 int i = 0;
3162
3163 children = evas_object_box_children_get(rp->object);
3164 while (children)
3165 {
3166 Evas_Object *child_obj = children->data;
3167 if (evas_object_data_get(child_obj, "\377 edje.box_item"))
3168 i++;
3169 else
3170 {
3171 _edje_box_layout_remove_child(rp, child_obj);
3172 _edje_box_child_remove(rp, child_obj);
3173 if (!evas_object_box_remove_at(rp->object, i))
3174 return EINA_FALSE;
3175 if (clear)
3176 evas_object_del(child_obj);
3177 }
3178 children = eina_list_remove_list(children, children);
3179 }
3180 return EINA_TRUE;
3181}
3182
3183static void
3184_edje_table_child_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *child __UNUSED__, void *einfo __UNUSED__)
3185{
3186 Edje_Real_Part *rp = data;
3187
3188 rp->edje->dirty = 1;
3189#ifdef EDJE_CALC_CACHE
3190 rp->invalidate = 1;
3191#endif
3192 _edje_recalc(rp->edje);
3193}
3194
3195static void
3196_edje_table_child_add(Edje_Real_Part *rp, Evas_Object *child)
3197{
3198 evas_object_event_callback_add
3199 (child, EVAS_CALLBACK_DEL, _edje_table_child_del_cb, rp);
3200
3201 rp->edje->dirty = 1;
3202#ifdef EDJE_CALC_CACHE
3203 rp->invalidate = 1;
3204#endif
3205 _edje_recalc(rp->edje);
3206}
3207
3208static void
3209_edje_table_child_remove(Edje_Real_Part *rp, Evas_Object *child)
3210{
3211 evas_object_event_callback_del_full
3212 (child, EVAS_CALLBACK_DEL, _edje_table_child_del_cb, rp);
3213
3214 rp->edje->dirty = 1;
3215#ifdef EDJE_CALC_CACHE
3216 rp->invalidate = 1;
3217#endif
3218 _edje_recalc(rp->edje);
3219}
3220
3221EAPI Evas_Object *
3222edje_object_part_table_child_get(Evas_Object *obj, const char *part, unsigned int col, unsigned int row)
3223{
3224 Edje *ed;
3225 Edje_Real_Part *rp;
3226
3227 ed = _edje_fetch(obj);
3228 if ((!ed) || (!part)) return NULL;
3229
3230 rp = _edje_real_part_recursive_get(ed, part);
3231 if (!rp) return NULL;
3232 if (rp->part->type != EDJE_PART_TYPE_TABLE) return NULL;
3233
3234 return evas_object_table_child_get(rp->object, col, row);
3235}
3236
3237EAPI Eina_Bool
3238edje_object_part_table_pack(Evas_Object *obj, const char *part, Evas_Object *child_obj, unsigned short col, unsigned short row, unsigned short colspan, unsigned short rowspan)
3239{
3240 Edje *ed;
3241 Edje_Real_Part *rp;
3242
3243 ed = _edje_fetch(obj);
3244 if ((!ed) || (!part)) return EINA_FALSE;
3245
3246 rp = _edje_real_part_recursive_get(ed, part);
3247 if (!rp) return EINA_FALSE;
3248 if (rp->part->type != EDJE_PART_TYPE_TABLE) return EINA_FALSE;
3249
3250 return _edje_real_part_table_pack(rp, child_obj, col, row, colspan, rowspan);
3251}
3252
3253EAPI Eina_Bool
3254edje_object_part_table_unpack(Evas_Object *obj, const char *part, Evas_Object *child_obj)
3255{
3256 Edje *ed;
3257 Edje_Real_Part *rp;
3258
3259 ed = _edje_fetch(obj);
3260 if ((!ed) || (!part)) return EINA_FALSE;
3261
3262 rp = _edje_real_part_recursive_get(ed, part);
3263 if (!rp) return EINA_FALSE;
3264 if (rp->part->type != EDJE_PART_TYPE_TABLE) return EINA_FALSE;
3265
3266 return _edje_real_part_table_unpack(rp, child_obj);
3267}
3268
3269EAPI Eina_Bool
3270edje_object_part_table_col_row_size_get(const Evas_Object *obj, const char *part, int *cols, int *rows)
3271{
3272 Edje *ed;
3273 Edje_Real_Part *rp;
3274
3275 ed = _edje_fetch(obj);
3276 if ((!ed) || (!part)) return EINA_FALSE;
3277
3278 rp = _edje_real_part_recursive_get(ed, part);
3279 if (!rp) return EINA_FALSE;
3280 if (rp->part->type != EDJE_PART_TYPE_TABLE) return EINA_FALSE;
3281
3282 evas_object_table_col_row_size_get(rp->object, cols, rows);
3283 return EINA_TRUE;
3284}
3285
3286EAPI Eina_Bool
3287edje_object_part_table_clear(Evas_Object *obj, const char *part, Eina_Bool clear)
3288{
3289 Edje *ed;
3290 Edje_Real_Part *rp;
3291
3292 ed = _edje_fetch(obj);
3293 if ((!ed) || (!part)) return EINA_FALSE;
3294
3295 rp = _edje_real_part_recursive_get(ed, part);
3296 if (!rp) return EINA_FALSE;
3297 if (rp->part->type != EDJE_PART_TYPE_TABLE) return EINA_FALSE;
3298
3299 _edje_real_part_table_clear(rp, clear);
3300 return EINA_TRUE;
3301}
3302
3303static void
3304_edje_perspective_obj_del(void *data, __UNUSED__ Evas *e, __UNUSED__ Evas_Object *obj, __UNUSED__ void *event_info)
3305{
3306 Edje_Perspective *ps = data;
3307 Evas_Object *o;
3308
3309 EINA_LIST_FREE(ps->users, o)
3310 {
3311 Edje *ed;
3312
3313 ed = evas_object_smart_data_get(o);
3314 if (!ed) continue;
3315 ed->persp = NULL;
3316 ed->dirty = 1;
3317 _edje_recalc_do(ed);
3318 }
3319 free(ps);
3320}
3321
3322EAPI Edje_Perspective *
3323edje_perspective_new(Evas *e)
3324{
3325 Edje_Perspective *ps;
3326 Evas_Coord vx, vy, vw, vh;
3327
3328 if (!e) return NULL;
3329 ps = calloc(1, sizeof(Edje_Perspective));
3330 ps->obj = evas_object_rectangle_add(e);
3331 evas_object_data_set(ps->obj, "_edje_perspective", ps);
3332 evas_object_event_callback_add(ps->obj, EVAS_CALLBACK_DEL, _edje_perspective_obj_del, ps);
3333 evas_output_viewport_get(e, &vx, &vy, &vw, &vh);
3334 ps->e = e;
3335 ps->px = vx + (vw / 2);
3336 ps->py = vy + (vh / 2);
3337 ps->z0 = 0;
3338 ps->foc = 1000;
3339 return ps;
3340}
3341
3342EAPI void
3343edje_perspective_free(Edje_Perspective *ps)
3344{
3345 if (!ps) return;
3346 evas_object_del(ps->obj);
3347}
3348
3349EAPI void
3350edje_perspective_set(Edje_Perspective *ps, Evas_Coord px, Evas_Coord py, Evas_Coord z0, Evas_Coord foc)
3351{
3352 Eina_List *l;
3353 Evas_Object *o;
3354
3355 if (!ps) return;
3356 if ((ps->px == px) && (ps->py == py) && (ps->z0 == z0) && (ps->foc == foc)) return;
3357 ps->px = px;
3358 ps->py = py;
3359 ps->z0 = z0;
3360 ps->foc = foc;
3361 EINA_LIST_FOREACH(ps->users, l, o)
3362 {
3363 Edje *ed;
3364
3365 ed = evas_object_smart_data_get(o);
3366 if (!ed) continue;
3367 if (!ed->persp)
3368 {
3369 ed->dirty = 1;
3370 _edje_recalc_do(ed);
3371 }
3372 }
3373 if (ps->global)
3374 {
3375 EINA_LIST_FOREACH(_edje_edjes, l, o)
3376 {
3377 Edje *ed;
3378
3379 ed = evas_object_smart_data_get(o);
3380 if (!ed) continue;
3381 if (!ed->persp)
3382 {
3383 ed->dirty = 1;
3384 _edje_recalc_do(ed);
3385 }
3386 }
3387 }
3388}
3389
3390EAPI void
3391edje_perspective_global_set(Edje_Perspective *ps, Eina_Bool global)
3392{
3393 Evas_Object *o;
3394 Eina_List *l;
3395
3396 if (!ps) return;
3397 if (ps->global == global) return;
3398 if (global)
3399 {
3400 o = evas_object_name_find(evas_object_evas_get(ps->obj),
3401 "_edje_perspective");
3402 if (o) evas_object_name_set(o, NULL);
3403 evas_object_name_set(ps->obj, "_edje_perspective");
3404 }
3405 else
3406 evas_object_name_set(ps->obj, NULL);
3407 ps->global = global;
3408 EINA_LIST_FOREACH(_edje_edjes, l, o)
3409 {
3410 Edje *ed;
3411
3412 ed = evas_object_smart_data_get(o);
3413 if (!ed) continue;
3414 if (!ed->persp)
3415 {
3416 ed->dirty = 1;
3417 _edje_recalc_do(ed);
3418 }
3419 }
3420}
3421
3422EAPI Eina_Bool
3423edje_perspective_global_get(const Edje_Perspective *ps)
3424{
3425 if (!ps) return EINA_FALSE;
3426 return ps->global;
3427}
3428
3429EAPI const Edje_Perspective *
3430edje_evas_global_perspective_get(const Evas *e)
3431{
3432 Evas_Object *obj;
3433
3434 if (!e) return NULL;
3435 obj = evas_object_name_find(e, "_edje_perspective");
3436 if (!obj) return NULL;
3437 return evas_object_data_get(obj, "_edje_perspective");
3438}
3439
3440EAPI void
3441edje_object_perspective_set(Evas_Object *obj, Edje_Perspective *ps)
3442{
3443 Edje *ed;
3444
3445 ed = evas_object_smart_data_get(obj);
3446 if (!ed) return;
3447 if (ed->persp == ps) return;
3448 if (ed->persp != ps)
3449 {
3450 if (ed->persp)
3451 ed->persp->users = eina_list_remove(ed->persp->users, obj);
3452 }
3453 ed->persp = ps;
3454 if (ps) ps->users = eina_list_append(ps->users, obj);
3455 ed->dirty = 1;
3456 _edje_recalc_do(ed);
3457}
3458
3459EAPI const Edje_Perspective *
3460edje_object_perspective_get(const Evas_Object *obj)
3461{
3462 Edje *ed;
3463
3464 ed = evas_object_smart_data_get(obj);
3465 if (!ed) return NULL;
3466 return ed->persp;
3467}
3468
3469#define EDJE_PRELOAD_EMISSION "preload,done"
3470#define EDJE_PRELOAD_SOURCE NULL
3471
3472EAPI Eina_Bool
3473edje_object_preload(Evas_Object *obj, Eina_Bool cancel)
3474{
3475 Edje *ed;
3476 int count;
3477 unsigned int i;
3478
3479 ed = _edje_fetch(obj);
3480 if (!ed) return EINA_FALSE;
3481
3482 _edje_recalc_do(ed);
3483
3484 for (i = 0, count = 0; i < ed->table_parts_size; i++)
3485 {
3486 Edje_Real_Part *rp;
3487 Edje_Part *ep;
3488
3489 rp = ed->table_parts[i];
3490 ep = rp->part;
3491
3492 if (ep->type == EDJE_PART_TYPE_IMAGE ||
3493 (ep->type == EDJE_PART_TYPE_GROUP && rp->swallowed_object))
3494 count++;
3495 }
3496
3497 ed->preload_count = count;
3498
3499 if (count > 0)
3500 {
3501 for (i = 0; i < ed->table_parts_size; i++)
3502 {
3503 Edje_Real_Part *rp;
3504 Edje_Part *ep;
3505
3506 rp = ed->table_parts[i];
3507 ep = rp->part;
3508
3509 if (ep->type == EDJE_PART_TYPE_IMAGE)
3510 {
3511 const char *file = NULL;
3512 const char *key = NULL;
3513
3514 evas_object_event_callback_del_full(rp->object, EVAS_CALLBACK_IMAGE_PRELOADED, _edje_object_image_preload_cb, ed);
3515
3516 evas_object_image_file_get(rp->object, &file, &key);
3517 if (!file && !key)
3518 {
3519 ed->preload_count--;
3520 }
3521 else
3522 {
3523 evas_object_event_callback_add(rp->object, EVAS_CALLBACK_IMAGE_PRELOADED, _edje_object_image_preload_cb, ed);
3524 evas_object_image_preload(rp->object, cancel);
3525 }
3526 count--;
3527 }
3528 else if (ep->type == EDJE_PART_TYPE_GROUP)
3529 {
3530 if (rp->swallowed_object) {
3531 edje_object_signal_callback_del(rp->swallowed_object, EDJE_PRELOAD_EMISSION, EDJE_PRELOAD_SOURCE, _edje_object_signal_preload_cb);
3532 edje_object_signal_callback_add(rp->swallowed_object, EDJE_PRELOAD_EMISSION, EDJE_PRELOAD_SOURCE, _edje_object_signal_preload_cb, ed);
3533 edje_object_preload(rp->swallowed_object, cancel);
3534
3535 count--;
3536 }
3537 }
3538 }
3539 }
3540 else
3541 {
3542 _edje_emit(ed, EDJE_PRELOAD_EMISSION, EDJE_PRELOAD_SOURCE);
3543 }
3544
3545 return EINA_TRUE;
3546}
3547
3548Eina_Bool
3549_edje_real_part_table_pack(Edje_Real_Part *rp, Evas_Object *child_obj, unsigned short col, unsigned short row, unsigned short colspan, unsigned short rowspan)
3550{
3551 Eina_Bool ret =
3552 evas_object_table_pack(rp->object, child_obj, col, row, colspan, rowspan);
3553
3554 _edje_table_child_add(rp, child_obj);
3555
3556 return ret;
3557}
3558
3559Eina_Bool
3560_edje_real_part_table_unpack(Edje_Real_Part *rp, Evas_Object *child_obj)
3561{
3562 Eina_Bool ret = evas_object_table_unpack(rp->object, child_obj);
3563
3564 if (ret)
3565 _edje_table_child_remove(rp, child_obj);
3566
3567 return ret;
3568}
3569
3570void
3571_edje_real_part_table_clear(Edje_Real_Part *rp, Eina_Bool clear)
3572{
3573 Eina_List *children;
3574
3575 children = evas_object_table_children_get(rp->object);
3576 while (children)
3577 {
3578 Evas_Object *child_obj = children->data;
3579
3580 _edje_table_child_remove(rp, child_obj);
3581 if (!evas_object_data_get(child_obj, "\377 edje.table_item"))
3582 {
3583 evas_object_table_unpack(rp->object, child_obj);
3584 if (clear)
3585 evas_object_del(child_obj);
3586 }
3587 children = eina_list_remove_list(children, children);
3588 }
3589}
3590
3591Edje_Real_Part *
3592_edje_real_part_recursive_get(const Edje *ed, const char *part)
3593{
3594 Edje_Real_Part *rp;
3595 char **path;
3596
3597 path = eina_str_split(part, EDJE_PART_PATH_SEPARATOR_STRING, 0);
3598 if (!path) return NULL;
3599
3600 rp = _edje_real_part_recursive_get_helper(ed, path);
3601
3602 free(*path);
3603 free(path);
3604 return rp;
3605}
3606
3607Evas_Object *
3608_edje_children_get(Edje_Real_Part *rp, const char *partid)
3609{
3610 Evas_Object *child;
3611 Eina_List *l;
3612 long int v;
3613 char *p;
3614
3615 if (!partid) return NULL;
3616
3617 switch (rp->part->type)
3618 {
3619 case EDJE_PART_TYPE_EXTERNAL:
3620 return _edje_external_content_get(rp->swallowed_object, partid);
3621 case EDJE_PART_TYPE_BOX:
3622 l = evas_object_box_children_get(rp->object);
3623 break;
3624 case EDJE_PART_TYPE_TABLE:
3625 l = evas_object_table_children_get(rp->object);
3626 break;
3627 default:
3628 return NULL;
3629 }
3630
3631 v = strtol(partid, &p, 10);
3632 if ((*p == '\0') && (v >= 0))
3633 {
3634 child = eina_list_nth(l, v);
3635 }
3636 else
3637 {
3638 Evas_Object *cur;
3639 child = NULL;
3640 EINA_LIST_FREE(l, cur)
3641 {
3642 const char *name = evas_object_name_get(cur);
3643 if ((name) && (!strcmp(name, partid)))
3644 {
3645 child = cur;
3646 break;
3647 }
3648 }
3649 }
3650 eina_list_free(l);
3651
3652 return child;
3653}
3654
3655/* rebuild alternative path */
3656char *
3657_edje_merge_path(const char *alias, char * const *path)
3658{
3659 char *tmp;
3660 unsigned int length = 1;
3661 unsigned int alias_length;
3662 unsigned int i;
3663
3664 if (!alias) return NULL;
3665
3666 alias_length = strlen(alias);
3667
3668 for (i = 0; path[i]; i++)
3669 length += strlen(path[i]) + 1;
3670
3671 tmp = malloc(sizeof (char) * (length + alias_length + 2));
3672 memcpy(tmp, alias, alias_length);
3673 tmp[alias_length] = '\0';
3674
3675 for (i = 0; path[i]; i++)
3676 {
3677 strcat(tmp, EDJE_PART_PATH_SEPARATOR_STRING);
3678 strcat(tmp, path[i]);
3679 }
3680
3681 return tmp;
3682}
3683
3684
3685Edje_Real_Part *
3686_edje_real_part_recursive_get_helper(const Edje *ed, char **path)
3687{
3688 Edje_Real_Part *rp;
3689 Evas_Object *child;
3690 char *idx = NULL;
3691
3692 if (!path[0])
3693 return NULL;
3694
3695 if (ed->collection && ed->collection->alias)
3696 {
3697 char *alias;
3698
3699 alias = _edje_merge_path(eina_hash_find(ed->collection->alias, path[0]), path + 1);
3700 if (alias) {
3701 rp = _edje_real_part_recursive_get(ed, alias);
3702 free(alias);
3703 return rp;
3704 }
3705 }
3706
3707 //printf(" lookup: %s on %s\n", path[0], ed->parent ? ed->parent : "-");
3708 idx = strchr(path[0], EDJE_PART_PATH_SEPARATOR_INDEXL);
3709 if (idx)
3710 {
3711 char *end;
3712
3713 end = strchr(idx + 1, EDJE_PART_PATH_SEPARATOR_INDEXR);
3714 if (end)
3715 {
3716 *end = '\0';
3717 *idx = '\0';
3718 idx++;
3719 }
3720 }
3721
3722 rp = _edje_real_part_get(ed, path[0]);
3723 if (!path[1] && !idx) return rp;
3724 if (!rp) return NULL;
3725
3726 switch (rp->part->type)
3727 {
3728 case EDJE_PART_TYPE_GROUP:
3729 if (!rp->swallowed_object) return NULL;
3730 ed = _edje_fetch(rp->swallowed_object);
3731 if (!ed) return NULL;
3732 path++;
3733 return _edje_real_part_recursive_get_helper(ed, path);
3734 case EDJE_PART_TYPE_BOX:
3735 case EDJE_PART_TYPE_TABLE:
3736 case EDJE_PART_TYPE_EXTERNAL:
3737 if (!idx) return rp;
3738 path++;
3739
3740 child = _edje_children_get(rp, idx);
3741
3742 ed = _edje_fetch(child);
3743
3744 if (!ed) return NULL;
3745 return _edje_real_part_recursive_get_helper(ed, path);
3746 default:
3747 return NULL;
3748 }
3749}
3750
3751/* Private Routines */
3752Edje_Real_Part *
3753_edje_real_part_get(const Edje *ed, const char *part)
3754{
3755 unsigned int i;
3756
3757 if (!part) return NULL;
3758
3759 for (i = 0; i < ed->table_parts_size; i++)
3760 {
3761 Edje_Real_Part *rp;
3762
3763 rp = ed->table_parts[i];
3764 if ((rp->part->name) && (!strcmp(rp->part->name, part))) return rp;
3765 }
3766 return NULL;
3767}
3768
3769Edje_Color_Class *
3770_edje_color_class_find(Edje *ed, const char *color_class)
3771{
3772 Eina_List *l;
3773 Edje_Color_Class *cc = NULL;
3774
3775 if ((!ed) || (!color_class)) return NULL;
3776
3777 /* first look through the object scope */
3778 EINA_LIST_FOREACH(ed->color_classes, l, cc)
3779 if ((cc->name) && (!strcmp(color_class, cc->name))) return cc;
3780
3781 /* next look through the global scope */
3782 cc = eina_hash_find(_edje_color_class_hash, color_class);
3783 if (cc) return cc;
3784
3785 /* finally, look through the file scope */
3786 EINA_LIST_FOREACH(ed->file->color_classes, l, cc)
3787 if ((cc->name) && (!strcmp(color_class, cc->name))) return cc;
3788
3789 return NULL;
3790}
3791
3792void
3793_edje_color_class_member_add(Edje *ed, const char *color_class)
3794{
3795 _edje_class_member_add(ed, &ed->members.color_class, &_edje_color_class_member_hash, color_class);
3796}
3797
3798void
3799_edje_color_class_member_direct_del(const char *color_class, void *l)
3800{
3801 _edje_class_member_direct_del(color_class, l, _edje_color_class_member_hash);
3802}
3803
3804void
3805_edje_color_class_member_del(Edje *ed, const char *color_class)
3806{
3807 if ((!ed) || (!color_class)) return;
3808
3809 _edje_class_member_del(&ed->members.color_class, &_edje_color_class_member_hash, color_class);
3810}
3811
3812void
3813_edje_color_class_members_free(void)
3814{
3815 if (!_edje_color_class_member_hash) return;
3816 eina_hash_foreach(_edje_color_class_member_hash, member_list_free, NULL);
3817 eina_hash_free(_edje_color_class_member_hash);
3818 _edje_color_class_member_hash = NULL;
3819}
3820
3821static Eina_Bool
3822color_class_hash_list_free(const Eina_Hash *hash __UNUSED__, const void *key __UNUSED__, void *data, void *fdata __UNUSED__)
3823{
3824 Edje_Color_Class *cc;
3825
3826 cc = data;
3827 if (cc->name) eina_stringshare_del(cc->name);
3828 free(cc);
3829 return EINA_TRUE;
3830}
3831
3832void
3833_edje_color_class_hash_free(void)
3834{
3835 if (!_edje_color_class_hash) return;
3836 eina_hash_foreach(_edje_color_class_hash, color_class_hash_list_free, NULL);
3837 eina_hash_free(_edje_color_class_hash);
3838 _edje_color_class_hash = NULL;
3839}
3840
3841void
3842_edje_color_class_on_del(Edje *ed, Edje_Part *ep)
3843{
3844 unsigned int i;
3845
3846 if ((ep->default_desc) && (ep->default_desc->color_class))
3847 _edje_color_class_member_del(ed, ep->default_desc->color_class);
3848
3849 for (i = 0; i < ep->other.desc_count; ++i)
3850 if (ep->other.desc[i]->color_class)
3851 _edje_color_class_member_del(ed, ep->other.desc[i]->color_class);
3852}
3853
3854Edje_Text_Class *
3855_edje_text_class_find(Edje *ed, const char *text_class)
3856{
3857 Eina_List *l;
3858 Edje_Text_Class *tc;
3859
3860 if ((!ed) || (!text_class)) return NULL;
3861 EINA_LIST_FOREACH(ed->text_classes, l, tc)
3862 if ((tc->name) && (!strcmp(text_class, tc->name))) return tc;
3863 return eina_hash_find(_edje_text_class_hash, text_class);
3864}
3865
3866void
3867_edje_text_class_member_direct_del(const char *text_class,
3868 void *l)
3869{
3870 _edje_class_member_direct_del(text_class, l, _edje_text_class_member_hash);
3871}
3872
3873void
3874_edje_text_class_member_add(Edje *ed, const char *text_class)
3875{
3876 _edje_class_member_add(ed, &ed->members.text_class, &_edje_text_class_member_hash, text_class);
3877}
3878
3879void
3880_edje_text_class_member_del(Edje *ed, const char *text_class)
3881{
3882 if ((!ed) || (!text_class)) return;
3883
3884 _edje_class_member_del(&ed->members.text_class, &_edje_text_class_member_hash, text_class);
3885}
3886
3887void
3888_edje_text_class_members_free(void)
3889{
3890 _edje_class_members_free(&_edje_text_class_member_hash);
3891}
3892
3893static Eina_Bool
3894text_class_hash_list_free(const Eina_Hash *hash __UNUSED__, const void *key __UNUSED__, void *data, void *fdata __UNUSED__)
3895{
3896 Edje_Text_Class *tc;
3897
3898 tc = data;
3899 if (tc->name) eina_stringshare_del(tc->name);
3900 if (tc->font) eina_stringshare_del(tc->font);
3901 free(tc);
3902 return EINA_TRUE;
3903}
3904
3905void
3906_edje_text_class_hash_free(void)
3907{
3908 if (!_edje_text_class_hash) return;
3909 eina_hash_foreach(_edje_text_class_hash, text_class_hash_list_free, NULL);
3910 eina_hash_free(_edje_text_class_hash);
3911 _edje_text_class_hash = NULL;
3912}
3913
3914Edje *
3915_edje_fetch(const Evas_Object *obj)
3916{
3917 Edje *ed;
3918
3919 if (!evas_object_smart_type_check(obj, "edje"))
3920 return NULL;
3921 ed = evas_object_smart_data_get(obj);
3922 if ((ed) && (ed->delete_me)) return NULL;
3923 return ed;
3924}
3925
3926int
3927_edje_freeze(Edje *ed)
3928{
3929 ed->freeze++;
3930// printf("FREEZE %i\n", ed->freeze);
3931 return ed->freeze;
3932}
3933
3934int
3935_edje_thaw(Edje *ed)
3936{
3937 ed->freeze--;
3938 if (ed->freeze < 0)
3939 {
3940// printf("-------------########### OVER THAW\n");
3941 ed->freeze = 0;
3942 }
3943 if ((ed->freeze == 0) && (ed->recalc))
3944 {
3945// printf("thaw recalc\n");
3946 _edje_recalc(ed);
3947 }
3948 return ed->freeze;
3949}
3950
3951int
3952_edje_block(Edje *ed)
3953{
3954 _edje_ref(ed);
3955 ed->block++;
3956 return ed->block;
3957}
3958
3959int
3960_edje_unblock(Edje *ed)
3961{
3962 int ret = 0;
3963
3964 if (!ed) return ret;
3965
3966 ed->block--;
3967 if (ed->block == 0) ed->block_break = 0;
3968 ret = ed->block;
3969 _edje_unref(ed);
3970 return ret;
3971}
3972
3973int
3974_edje_block_break(Edje *ed)
3975{
3976 if (ed->block_break) return 1;
3977 return 0;
3978}
3979
3980void
3981_edje_block_violate(Edje *ed)
3982{
3983 if (ed->block > 0) ed->block_break = 1;
3984}
3985
3986void
3987_edje_object_part_swallow_free_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
3988{
3989 Evas_Object *edje_obj;
3990
3991 edje_obj = data;
3992 edje_object_part_unswallow(edje_obj, obj);
3993 return;
3994}
3995
3996static void
3997_edje_real_part_swallow_hints_update(Edje_Real_Part *rp)
3998{
3999 const char *type;
4000
4001 type = evas_object_type_get(rp->swallowed_object);
4002
4003 rp->swallow_params.min.w = 0;
4004 rp->swallow_params.min.h = 0;
4005 rp->swallow_params.max.w = -1;
4006 rp->swallow_params.max.h = -1;
4007 if ((type) && (!strcmp(type, "edje")))
4008 {
4009 Evas_Coord w, h;
4010
4011 edje_object_size_min_get(rp->swallowed_object, &w, &h);
4012 rp->swallow_params.min.w = w;
4013 rp->swallow_params.min.h = h;
4014 edje_object_size_max_get(rp->swallowed_object, &w, &h);
4015 rp->swallow_params.max.w = w;
4016 rp->swallow_params.max.h = h;
4017 }
4018 else if ((type) && ((!strcmp(type, "text")) || (!strcmp(type, "polygon")) ||
4019 (!strcmp(type, "line"))))
4020 {
4021 Evas_Coord w, h;
4022
4023 evas_object_geometry_get(rp->swallowed_object, NULL, NULL, &w, &h);
4024 rp->swallow_params.min.w = w;
4025 rp->swallow_params.min.h = h;
4026 rp->swallow_params.max.w = w;
4027 rp->swallow_params.max.h = h;
4028 }
4029 {
4030 Evas_Coord w1, h1, w2, h2, aw, ah;
4031 Evas_Aspect_Control am;
4032
4033 evas_object_size_hint_min_get(rp->swallowed_object, &w1, &h1);
4034 evas_object_size_hint_max_get(rp->swallowed_object, &w2, &h2);
4035 evas_object_size_hint_aspect_get(rp->swallowed_object, &am, &aw, &ah);
4036 rp->swallow_params.min.w = w1;
4037 rp->swallow_params.min.h = h1;
4038 if (w2 > 0) rp->swallow_params.max.w = w2;
4039 if (h2 > 0) rp->swallow_params.max.h = h2;
4040 switch (am)
4041 {
4042 case EVAS_ASPECT_CONTROL_NONE:
4043 rp->swallow_params.aspect.mode = EDJE_ASPECT_CONTROL_NONE;
4044 break;
4045 case EVAS_ASPECT_CONTROL_NEITHER:
4046 rp->swallow_params.aspect.mode = EDJE_ASPECT_CONTROL_NEITHER;
4047 break;
4048 case EVAS_ASPECT_CONTROL_HORIZONTAL:
4049 rp->swallow_params.aspect.mode = EDJE_ASPECT_CONTROL_HORIZONTAL;
4050 break;
4051 case EVAS_ASPECT_CONTROL_VERTICAL:
4052 rp->swallow_params.aspect.mode = EDJE_ASPECT_CONTROL_VERTICAL;
4053 break;
4054 case EVAS_ASPECT_CONTROL_BOTH:
4055 rp->swallow_params.aspect.mode = EDJE_ASPECT_CONTROL_BOTH;
4056 break;
4057 default:
4058 break;
4059 }
4060 rp->swallow_params.aspect.w = aw;
4061 rp->swallow_params.aspect.h = ah;
4062 evas_object_data_set(rp->swallowed_object, "\377 edje.swallowing_part", rp);
4063 }
4064
4065#ifdef EDJE_CALC_CACHE
4066 rp->invalidate = 1;
4067#endif
4068}
4069
4070void
4071_edje_object_part_swallow_changed_hints_cb(void *data, __UNUSED__ Evas *e, __UNUSED__ Evas_Object *obj, __UNUSED__ void *event_info)
4072{
4073 Edje_Real_Part *rp;
4074
4075 rp = data;
4076 _edje_real_part_swallow_hints_update(rp);
4077 rp->edje->dirty = 1;
4078 _edje_recalc(rp->edje);
4079 return;
4080}
4081
4082void
4083_edje_real_part_swallow(Edje_Real_Part *rp,
4084 Evas_Object *obj_swallow,
4085 Eina_Bool hints_update)
4086{
4087 if (rp->swallowed_object)
4088 {
4089 if (rp->swallowed_object != obj_swallow)
4090 {
4091 _edje_real_part_swallow_clear(rp);
4092 rp->swallowed_object = NULL;
4093 }
4094 else
4095 {
4096 if (hints_update)
4097 _edje_real_part_swallow_hints_update(rp);
4098 rp->edje->dirty = 1;
4099 _edje_recalc(rp->edje);
4100 return;
4101 }
4102 }
4103#ifdef EDJE_CALC_CACHE
4104 rp->invalidate = 1;
4105#endif
4106 if (!obj_swallow) return;
4107 rp->swallowed_object = obj_swallow;
4108 evas_object_smart_member_add(rp->swallowed_object, rp->edje->obj);
4109 if (rp->clip_to)
4110 evas_object_clip_set(rp->swallowed_object, rp->clip_to->object);
4111 else evas_object_clip_set(rp->swallowed_object, rp->edje->base.clipper);
4112 evas_object_stack_above(rp->swallowed_object, rp->object);
4113 evas_object_event_callback_add(rp->swallowed_object,
4114 EVAS_CALLBACK_DEL,
4115 _edje_object_part_swallow_free_cb,
4116 rp->edje->obj);
4117 evas_object_event_callback_add(rp->swallowed_object,
4118 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
4119 _edje_object_part_swallow_changed_hints_cb,
4120 rp);
4121
4122 if (hints_update)
4123 _edje_real_part_swallow_hints_update(rp);
4124
4125 if (rp->part->mouse_events)
4126 {
4127 _edje_callbacks_add(obj_swallow, rp->edje, rp);
4128 if (rp->part->repeat_events)
4129 evas_object_repeat_events_set(obj_swallow, 1);
4130 if (rp->part->pointer_mode != EVAS_OBJECT_POINTER_MODE_AUTOGRAB)
4131 evas_object_pointer_mode_set(obj_swallow, rp->part->pointer_mode);
4132 evas_object_pass_events_set(obj_swallow, 0);
4133 }
4134 else
4135 evas_object_pass_events_set(obj_swallow, 1);
4136 _edje_callbacks_focus_add(rp->swallowed_object, rp->edje, rp);
4137
4138 if (rp->part->precise_is_inside)
4139 evas_object_precise_is_inside_set(obj_swallow, 1);
4140
4141 rp->edje->dirty = 1;
4142 _edje_recalc(rp->edje);
4143}
4144
4145void
4146_edje_real_part_swallow_clear(Edje_Real_Part *rp)
4147{
4148 evas_object_smart_member_del(rp->swallowed_object);
4149 evas_object_event_callback_del_full(rp->swallowed_object,
4150 EVAS_CALLBACK_FREE,
4151 _edje_object_part_swallow_free_cb,
4152 rp->edje->obj);
4153 evas_object_event_callback_del_full(rp->swallowed_object,
4154 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
4155 _edje_object_part_swallow_changed_hints_cb,
4156 rp);
4157 evas_object_clip_unset(rp->swallowed_object);
4158 evas_object_data_del(rp->swallowed_object, "\377 edje.swallowing_part");
4159 if (rp->part->mouse_events)
4160 _edje_callbacks_del(rp->swallowed_object, rp->edje);
4161 _edje_callbacks_focus_del(rp->swallowed_object, rp->edje);
4162}
4163
4164static void
4165_edje_object_preload(Edje *ed)
4166{
4167 ed->preload_count--;
4168 if (!ed->preload_count)
4169 _edje_emit(ed, EDJE_PRELOAD_EMISSION, EDJE_PRELOAD_SOURCE);
4170}
4171
4172static void
4173_edje_object_image_preload_cb(void *data, __UNUSED__ Evas *e, Evas_Object *obj, __UNUSED__ void *event_info)
4174{
4175 Edje *ed = data;
4176
4177 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_IMAGE_PRELOADED, _edje_object_image_preload_cb, ed);
4178 _edje_object_preload(ed);
4179}
4180
4181static void
4182_edje_object_signal_preload_cb(void *data, Evas_Object *obj, __UNUSED__ const char *emission, __UNUSED__ const char *source)
4183{
4184 Edje *ed = data;
4185
4186 edje_object_signal_callback_del(obj, EDJE_PRELOAD_EMISSION, EDJE_PRELOAD_SOURCE, _edje_object_signal_preload_cb);
4187 _edje_object_preload(ed);
4188}
4189
4190/**
4191 * @internal
4192 *
4193 * for edje_cc
4194 */
4195EAPI void
4196_edje_program_remove(Edje_Part_Collection *edc, Edje_Program *p)
4197{
4198 Edje_Program ***array;
4199 unsigned int *count;
4200 unsigned int i;
4201
4202 if (!p->signal && !p->source)
4203 {
4204 array = &edc->programs.nocmp;
4205 count = &edc->programs.nocmp_count;
4206 }
4207 else if (p->signal && !strpbrk(p->signal, "*?[\\")
4208 && p->source && !strpbrk(p->source, "*?[\\"))
4209 {
4210 array = &edc->programs.strcmp;
4211 count = &edc->programs.strcmp_count;
4212 }
4213 else if (p->signal && edje_program_is_strncmp(p->signal)
4214 && p->source && edje_program_is_strncmp(p->source))
4215 {
4216 array = &edc->programs.strncmp;
4217 count = &edc->programs.strncmp_count;
4218 }
4219 else if (p->signal && edje_program_is_strrncmp(p->signal)
4220 && p->source && edje_program_is_strrncmp(p->source))
4221 {
4222 array = &edc->programs.strrncmp;
4223 count = &edc->programs.strrncmp_count;
4224 }
4225 else
4226 {
4227 array = &edc->programs.fnmatch;
4228 count = &edc->programs.fnmatch_count;
4229 }
4230
4231 for (i = 0; i < *count; ++i)
4232 if ((*array)[i] == p)
4233 {
4234 memmove(*array + i, *array + i + 1, sizeof (Edje_Program *) * (*count - i -1));
4235 (*count)--;
4236 break;
4237 }
4238}
4239
4240/**
4241 * @internal
4242 *
4243 * for edje_cc
4244 */
4245EAPI void
4246_edje_program_insert(Edje_Part_Collection *edc, Edje_Program *p)
4247{
4248 Edje_Program ***array;
4249 unsigned int *count;
4250
4251 if (!p->signal && !p->source)
4252 {
4253 array = &edc->programs.nocmp;
4254 count = &edc->programs.nocmp_count;
4255 }
4256 else if (p->signal && !strpbrk(p->signal, "*?[\\")
4257 && p->source && !strpbrk(p->source, "*?[\\"))
4258 {
4259 array = &edc->programs.strcmp;
4260 count = &edc->programs.strcmp_count;
4261 }
4262 else if (p->signal && edje_program_is_strncmp(p->signal)
4263 && p->source && edje_program_is_strncmp(p->source))
4264 {
4265 array = &edc->programs.strncmp;
4266 count = &edc->programs.strncmp_count;
4267 }
4268 else if (p->signal && edje_program_is_strrncmp(p->signal)
4269 && p->source && edje_program_is_strrncmp(p->source))
4270 {
4271 array = &edc->programs.strrncmp;
4272 count = &edc->programs.strrncmp_count;
4273 }
4274 else
4275 {
4276 array = &edc->programs.fnmatch;
4277 count = &edc->programs.fnmatch_count;
4278 }
4279
4280 *array = realloc(*array, sizeof (Edje_Program *) * (*count + 1));
4281 (*array)[(*count)++] = p;
4282}
4283
4284const char *
4285edje_string_get(const Edje_String *es)
4286{
4287 /* FIXME: Handle localization here */
4288 if (!es) return NULL;
4289 return es->str;
4290}
4291
4292const char *
4293edje_string_id_get(const Edje_String *es)
4294{
4295 /* FIXME: Handle localization here */
4296 if (!es) return NULL;
4297 return es->str;
4298}
4299
4300static void
4301_cb_subobj_del(void *data, __UNUSED__ Evas *e, Evas_Object *obj, __UNUSED__ void *event_info)
4302{
4303 Edje *ed = data;
4304 ed->subobjs = eina_list_remove(ed->subobjs, obj);
4305 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_DEL,
4306 _cb_subobj_del, ed);
4307}
4308
4309void
4310_edje_subobj_register(Edje *ed, Evas_Object *ob)
4311{
4312 ed->subobjs = eina_list_append(ed->subobjs, ob);
4313 evas_object_event_callback_add(ob, EVAS_CALLBACK_DEL,
4314 _cb_subobj_del, ed);
4315}
4316
4317/* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/
diff --git a/libraries/edje/src/lib/edje_var.c b/libraries/edje/src/lib/edje_var.c
new file mode 100644
index 0000000..c6c83b1
--- /dev/null
+++ b/libraries/edje/src/lib/edje_var.c
@@ -0,0 +1,1093 @@
1#include "edje_private.h"
2
3static Eina_Bool _edje_var_timer_cb(void *data);
4static Eina_Bool _edje_var_anim_cb(void *data);
5
6static Ecore_Animator *_edje_animator = NULL;
7static Eina_List *_edje_anim_list = NULL;
8
9static Eina_Bool
10_edje_var_timer_cb(void *data)
11{
12 Edje_Var_Timer *et;
13 Edje *ed;
14 Embryo_Function fn;
15
16 et = data;
17 if (!et) return ECORE_CALLBACK_CANCEL;
18 ed = et->edje;
19// _edje_embryo_script_reset(ed);
20 embryo_program_vm_push(ed->collection->script);
21 _edje_embryo_globals_init(ed);
22 embryo_parameter_cell_push(ed->collection->script, (Embryo_Cell)et->val);
23 ed->var_pool->timers = eina_list_remove(ed->var_pool->timers, et);
24 fn = et->func;
25 free(et);
26 {
27 void *pdata;
28 int ret;
29
30 pdata = embryo_program_data_get(ed->collection->script);
31 embryo_program_data_set(ed->collection->script, ed);
32 embryo_program_max_cycle_run_set(ed->collection->script, 5000000);
33 ret = embryo_program_run(ed->collection->script, fn);
34 if (ret == EMBRYO_PROGRAM_FAIL)
35 {
36 ERR("ERROR with embryo script (timer callback). "
37 "OBJECT NAME: '%s', "
38 "OBJECT FILE: '%s', "
39 "ERROR: '%s'",
40 ed->collection->part,
41 ed->file->path,
42 embryo_error_string_get(embryo_program_error_get(ed->collection->script)));
43 }
44 else if (ret == EMBRYO_PROGRAM_TOOLONG)
45 {
46 ERR("ERROR with embryo script (timer callback). "
47 "OBJECT NAME: '%s', "
48 "OBJECT FILE: '%s', "
49 "ERROR: 'Script exceeded maximum allowed cycle count of %i'",
50 ed->collection->part,
51 ed->file->path,
52 embryo_program_max_cycle_run_get(ed->collection->script));
53 }
54 embryo_program_data_set(ed->collection->script, pdata);
55 embryo_program_vm_pop(ed->collection->script);
56 _edje_recalc(ed);
57 }
58 return ECORE_CALLBACK_CANCEL;
59}
60
61static Eina_Bool
62_edje_var_anim_cb(void *data __UNUSED__)
63{
64 Eina_List *l, *tl = NULL;
65 double t;
66 const void *tmp;
67
68 t = ecore_loop_time_get();
69 EINA_LIST_FOREACH(_edje_anim_list, l, tmp)
70 tl = eina_list_append(tl, tmp);
71 while (tl)
72 {
73 Edje *ed;
74 Eina_List *tl2;
75 Edje_Var_Animator *ea;
76
77 ed = eina_list_data_get(tl);
78 _edje_ref(ed);
79 _edje_block(ed);
80 _edje_freeze(ed);
81 tl = eina_list_remove(tl, ed);
82 if (!ed->var_pool) continue;
83 tl2 = NULL;
84 EINA_LIST_FOREACH(ed->var_pool->animators, l, tmp)
85 tl2 = eina_list_append(tl2, tmp);
86 ed->var_pool->walking_list++;
87 while (tl2)
88 {
89 ea = eina_list_data_get(tl2);
90 if ((ed->var_pool) && (!ea->delete_me))
91 {
92 if ((!ed->paused) && (!ed->delete_me))
93 {
94 Embryo_Function fn;
95 float v;
96 int ret;
97
98 v = (t - ea->start) / ea->len;
99 if (v > 1.0) v= 1.0;
100// _edje_embryo_script_reset(ed);
101 embryo_program_vm_push(ed->collection->script);
102 _edje_embryo_globals_init(ed);
103 embryo_parameter_cell_push(ed->collection->script, (Embryo_Cell)ea->val);
104 embryo_parameter_cell_push(ed->collection->script, EMBRYO_FLOAT_TO_CELL(v));
105 fn = ea->func;
106 {
107 void *pdata;
108
109 pdata = embryo_program_data_get(ed->collection->script);
110 embryo_program_data_set(ed->collection->script, ed);
111 embryo_program_max_cycle_run_set(ed->collection->script, 5000000);
112 ret = embryo_program_run(ed->collection->script, fn);
113 if (ret == EMBRYO_PROGRAM_FAIL)
114 {
115 ERR("ERROR with embryo script (anim callback). "
116 "OBJECT NAME: '%s', "
117 "OBJECT FILE: '%s', "
118 "ERROR: '%s'",
119 ed->collection->part,
120 ed->file->path,
121 embryo_error_string_get(embryo_program_error_get(ed->collection->script)));
122 }
123 else if (ret == EMBRYO_PROGRAM_TOOLONG)
124 {
125 ERR("ERROR with embryo script (anim callback). "
126 "OBJECT NAME: '%s', "
127 "OBJECT FILE: '%s', "
128 "ERROR: 'Script exceeded maximum allowed cycle count of %i'",
129 ed->collection->part,
130 ed->file->path,
131 embryo_program_max_cycle_run_get(ed->collection->script));
132 }
133 embryo_program_data_set(ed->collection->script, pdata);
134 embryo_program_vm_pop(ed->collection->script);
135 _edje_recalc(ed);
136 }
137 if (v == 1.0) ea->delete_me = 1;
138 }
139 }
140 tl2 = eina_list_remove(tl2, ea);
141 if (ed->block_break)
142 {
143 eina_list_free(tl2);
144 break;
145 }
146 }
147 ed->var_pool->walking_list--;
148 EINA_LIST_FOREACH(ed->var_pool->animators, l, ea)
149 {
150 if (ea->delete_me)
151 {
152 l = eina_list_next(l);
153 ed->var_pool->animators = eina_list_remove(ed->var_pool->animators, ea);
154 free(ea);
155 }
156 else
157 l = eina_list_next(l);
158 }
159 if (!ed->var_pool->animators)
160 _edje_anim_list = eina_list_remove(_edje_anim_list, ed);
161 _edje_unblock(ed);
162 _edje_thaw(ed);
163 _edje_unref(ed);
164 }
165 if (!_edje_anim_list)
166 {
167 if (_edje_animator)
168 {
169 ecore_animator_del(_edje_animator);
170 _edje_animator = NULL;
171 }
172 }
173 return !!_edje_animator;
174}
175
176Edje_Var *
177_edje_var_new(void)
178{
179 return calloc(1, sizeof(Edje_Var));
180}
181
182void
183_edje_var_free(Edje_Var *var)
184{
185 if (var->type == EDJE_VAR_STRING)
186 {
187 if (var->data.s.v)
188 {
189 free(var->data.s.v);
190 }
191 }
192 free(var);
193}
194
195void
196_edje_var_init(Edje *ed)
197{
198 if (!ed) return;
199 if (!ed->collection) return;
200 if (!ed->collection->script) return;
201 if (ed->var_pool) return;
202 ed->var_pool = calloc(1, sizeof(Edje_Var_Pool));
203 if (!ed->var_pool) return;
204 embryo_program_vm_push(ed->collection->script);
205 ed->var_pool->size = embryo_program_variable_count_get(ed->collection->script);
206 embryo_program_vm_pop(ed->collection->script);
207 if (ed->var_pool->size > 0)
208 ed->var_pool->vars = calloc(1, sizeof(Edje_Var) * ed->var_pool->size);
209}
210
211void
212_edje_var_shutdown(Edje *ed)
213{
214 if (!ed->var_pool) return;
215 if (ed->var_pool->vars)
216 {
217 int i;
218
219 for (i = 0; i < ed->var_pool->size; i++)
220 {
221 if (ed->var_pool->vars[i].type == EDJE_VAR_STRING)
222 {
223 if (ed->var_pool->vars[i].data.s.v)
224 {
225 free(ed->var_pool->vars[i].data.s.v);
226 ed->var_pool->vars[i].data.s.v = NULL;
227 }
228 }
229 else if (ed->var_pool->vars[i].type == EDJE_VAR_LIST)
230 {
231 while (ed->var_pool->vars[i].data.l.v)
232 {
233 _edje_var_free(eina_list_data_get(ed->var_pool->vars[i].data.l.v));
234 ed->var_pool->vars[i].data.l.v = eina_list_remove_list(ed->var_pool->vars[i].data.l.v, ed->var_pool->vars[i].data.l.v);
235 }
236 }
237 }
238 free(ed->var_pool->vars);
239 }
240 while (ed->var_pool->timers)
241 {
242 Edje_Var_Timer *et;
243
244 et = eina_list_data_get(ed->var_pool->timers);
245 ecore_timer_del(et->timer);
246 free(et);
247 ed->var_pool->timers = eina_list_remove(ed->var_pool->timers, et);
248 }
249 if (ed->var_pool->animators)
250 {
251 _edje_anim_list = eina_list_remove(_edje_anim_list, ed);
252 if (!_edje_anim_list)
253 {
254 if (_edje_animator)
255 {
256 ecore_animator_del(_edje_animator);
257 _edje_animator = NULL;
258 }
259 }
260 }
261 while (ed->var_pool->animators)
262 {
263 Edje_Var_Animator *ea;
264
265 ea = eina_list_data_get(ed->var_pool->animators);
266 free(ea);
267 ed->var_pool->animators = eina_list_remove(ed->var_pool->animators, ea);
268 }
269 free(ed->var_pool);
270 ed->var_pool = NULL;
271}
272
273int
274_edje_var_string_id_get(Edje *ed, const char *string)
275{
276 Embryo_Cell cell, *cptr;
277
278 if (!ed) return 0;
279 if (!ed->collection) return 0;
280 if (!ed->collection->script) return 0;
281 if (!string) return 0;
282 cell = embryo_program_variable_find(ed->collection->script, (char *)string);
283 if (cell == EMBRYO_CELL_NONE) return 0;
284 cptr = embryo_data_address_get(ed->collection->script, cell);
285 if (!cptr) return 0;
286 return (int)(*cptr);
287}
288
289int
290_edje_var_var_int_get(Edje *ed __UNUSED__, Edje_Var *var)
291{
292 /* auto-cast */
293 if (var->type == EDJE_VAR_STRING)
294 {
295 if (var->data.s.v)
296 {
297 double f;
298
299 f = atof(var->data.s.v);
300 free(var->data.s.v);
301 var->data.s.v = NULL;
302 var->data.i.v = (int)f;
303 }
304 var->type = EDJE_VAR_INT;
305 }
306 else if (var->type == EDJE_VAR_FLOAT)
307 {
308 var->data.i.v = (int)(var->data.f.v);
309 var->type = EDJE_VAR_INT;
310 }
311 else if (var->type == EDJE_VAR_NONE)
312 {
313 var->type = EDJE_VAR_INT;
314 }
315 else if (var->type == EDJE_VAR_LIST)
316 {
317 return 0;
318 }
319 else if (var->type == EDJE_VAR_HASH)
320 {
321 return 0;
322 }
323 return var->data.i.v;
324}
325
326void
327_edje_var_var_int_set(Edje *ed __UNUSED__, Edje_Var *var, int v)
328{
329 /* auto-cast */
330 if (var->type == EDJE_VAR_STRING)
331 {
332 if (var->data.s.v)
333 {
334 free(var->data.s.v);
335 var->data.s.v = NULL;
336 }
337 var->type = EDJE_VAR_INT;
338 }
339 else if (var->type == EDJE_VAR_FLOAT)
340 {
341 var->type = EDJE_VAR_INT;
342 }
343 else if (var->type == EDJE_VAR_NONE)
344 {
345 var->type = EDJE_VAR_INT;
346 }
347 else if (var->type == EDJE_VAR_LIST)
348 {
349 return;
350 }
351 else if (var->type == EDJE_VAR_HASH)
352 {
353 return;
354 }
355 var->data.i.v = v;
356}
357
358double
359_edje_var_var_float_get(Edje *ed __UNUSED__, Edje_Var *var)
360{
361 /* auto-cast */
362 if (var->type == EDJE_VAR_STRING)
363 {
364 if (var->data.s.v)
365 {
366 double f;
367
368 f = atof(var->data.s.v);
369 free(var->data.s.v);
370 var->data.s.v = NULL;
371 var->data.f.v = f;
372 }
373 var->type = EDJE_VAR_FLOAT;
374 }
375 else if (var->type == EDJE_VAR_INT)
376 {
377 var->data.f.v = (double)(var->data.i.v);
378 var->type = EDJE_VAR_FLOAT;
379 }
380 else if (var->type == EDJE_VAR_NONE)
381 {
382 var->type = EDJE_VAR_FLOAT;
383 }
384 else if (var->type == EDJE_VAR_LIST)
385 {
386 return 0.0;
387 }
388 else if (var->type == EDJE_VAR_HASH)
389 {
390 return 0.0;
391 }
392 return var->data.f.v;
393}
394
395void
396_edje_var_var_float_set(Edje *ed __UNUSED__, Edje_Var *var, double v)
397{
398 /* auto-cast */
399 if (var->type == EDJE_VAR_STRING)
400 {
401 if (var->data.s.v)
402 {
403 free(var->data.s.v);
404 var->data.s.v = NULL;
405 }
406 var->type = EDJE_VAR_FLOAT;
407 }
408 else if (var->type == EDJE_VAR_INT)
409 {
410 var->data.f.v = 0;
411 var->type = EDJE_VAR_FLOAT;
412 }
413 else if (var->type == EDJE_VAR_NONE)
414 {
415 var->type = EDJE_VAR_FLOAT;
416 }
417 else if (var->type == EDJE_VAR_LIST)
418 {
419 return;
420 }
421 else if (var->type == EDJE_VAR_HASH)
422 {
423 return;
424 }
425 var->data.f.v = v;
426}
427
428const char *
429_edje_var_var_str_get(Edje *ed __UNUSED__, Edje_Var *var)
430{
431 /* auto-cast */
432 if (var->type == EDJE_VAR_INT)
433 {
434 char buf[64];
435
436 snprintf(buf, sizeof(buf), "%i", var->data.i.v);
437 var->data.s.v = strdup(buf);
438 var->type = EDJE_VAR_STRING;
439 }
440 else if (var->type == EDJE_VAR_FLOAT)
441 {
442 char buf[64];
443
444 snprintf(buf, sizeof(buf), "%f", var->data.f.v);
445 var->data.s.v = strdup(buf);
446 var->type = EDJE_VAR_STRING;
447 }
448 else if (var->type == EDJE_VAR_NONE)
449 {
450 var->data.s.v = strdup("");
451 var->type = EDJE_VAR_STRING;
452 }
453 else if (var->type == EDJE_VAR_LIST)
454 {
455 return NULL;
456 }
457 else if (var->type == EDJE_VAR_HASH)
458 {
459 return NULL;
460 }
461 return var->data.s.v;
462}
463
464void
465_edje_var_var_str_set(Edje *ed __UNUSED__, Edje_Var *var, const char *str)
466{
467 /* auto-cast */
468 if (var->type == EDJE_VAR_STRING)
469 {
470 if (var->data.s.v)
471 {
472 free(var->data.s.v);
473 var->data.s.v = NULL;
474 }
475 }
476 else if (var->type == EDJE_VAR_INT)
477 {
478 var->type = EDJE_VAR_STRING;
479 }
480 else if (var->type == EDJE_VAR_FLOAT)
481 {
482 var->type = EDJE_VAR_STRING;
483 }
484 else if (var->type == EDJE_VAR_NONE)
485 {
486 var->type = EDJE_VAR_STRING;
487 }
488 else if (var->type == EDJE_VAR_LIST)
489 {
490 return;
491 }
492 else if (var->type == EDJE_VAR_HASH)
493 {
494 return;
495 }
496 var->data.s.v = strdup(str);
497}
498
499int
500_edje_var_int_get(Edje *ed, int id)
501{
502 if (!ed) return 0;
503 if (!ed->var_pool) return 0;
504 id -= EDJE_VAR_MAGIC_BASE;
505 if ((id < 0) || (id >= ed->var_pool->size)) return 0;
506 return _edje_var_var_int_get(ed, &(ed->var_pool->vars[id]));
507}
508
509void
510_edje_var_int_set(Edje *ed, int id, int v)
511{
512 if (!ed) return;
513 if (!ed->var_pool) return;
514 id -= EDJE_VAR_MAGIC_BASE;
515 if ((id < 0) || (id >= ed->var_pool->size)) return;
516 _edje_var_var_int_set(ed, &(ed->var_pool->vars[id]), v);
517}
518
519double
520_edje_var_float_get(Edje *ed, int id)
521{
522 if (!ed) return 0;
523 if (!ed->var_pool) return 0;
524 id -= EDJE_VAR_MAGIC_BASE;
525 if ((id < 0) || (id >= ed->var_pool->size)) return 0;
526 return _edje_var_var_float_get(ed, &(ed->var_pool->vars[id]));
527}
528
529void
530_edje_var_float_set(Edje *ed, int id, double v)
531{
532 if (!ed) return;
533 if (!ed->var_pool) return;
534 id -= EDJE_VAR_MAGIC_BASE;
535 if ((id < 0) || (id >= ed->var_pool->size)) return;
536 _edje_var_var_float_set(ed, &(ed->var_pool->vars[id]), v);
537}
538
539const char *
540_edje_var_str_get(Edje *ed, int id)
541{
542 if (!ed) return NULL;
543 if (!ed->var_pool) return NULL;
544 id -= EDJE_VAR_MAGIC_BASE;
545 if ((id < 0) || (id >= ed->var_pool->size)) return NULL;
546 return _edje_var_var_str_get(ed, &(ed->var_pool->vars[id]));
547}
548
549void
550_edje_var_str_set(Edje *ed, int id, const char *str)
551{
552 if (!ed) return;
553 if (!ed->var_pool) return;
554 if (!str) return;
555 id -= EDJE_VAR_MAGIC_BASE;
556 if ((id < 0) || (id >= ed->var_pool->size)) return;
557 _edje_var_var_str_set(ed, &(ed->var_pool->vars[id]), str);
558}
559
560/* list stuff */
561
562void
563_edje_var_list_var_append(Edje *ed, int id, Edje_Var *var)
564{
565 if (!ed) return;
566 if (!ed->var_pool) return;
567 id -= EDJE_VAR_MAGIC_BASE;
568 if ((id < 0) || (id >= ed->var_pool->size)) return;
569 if (ed->var_pool->vars[id].type != EDJE_VAR_LIST) return;
570 ed->var_pool->vars[id].data.l.v = eina_list_append(ed->var_pool->vars[id].data.l.v, var);
571}
572
573void
574_edje_var_list_var_prepend(Edje *ed, int id, Edje_Var *var)
575{
576 if (!ed) return;
577 if (!ed->var_pool) return;
578 id -= EDJE_VAR_MAGIC_BASE;
579 if ((id < 0) || (id >= ed->var_pool->size)) return;
580 if (ed->var_pool->vars[id].type != EDJE_VAR_LIST) return;
581 ed->var_pool->vars[id].data.l.v = eina_list_prepend(ed->var_pool->vars[id].data.l.v, var);
582}
583
584void
585_edje_var_list_var_append_relative(Edje *ed, int id, Edje_Var *var, Edje_Var *relative)
586{
587 if (!ed) return;
588 if (!ed->var_pool) return;
589 id -= EDJE_VAR_MAGIC_BASE;
590 if ((id < 0) || (id >= ed->var_pool->size)) return;
591 if (ed->var_pool->vars[id].type != EDJE_VAR_LIST) return;
592 ed->var_pool->vars[id].data.l.v = eina_list_append_relative(ed->var_pool->vars[id].data.l.v, var, relative);
593}
594
595void
596_edje_var_list_var_prepend_relative(Edje *ed, int id, Edje_Var *var, Edje_Var *relative)
597{
598 if (!ed) return;
599 if (!ed->var_pool) return;
600 id -= EDJE_VAR_MAGIC_BASE;
601 if ((id < 0) || (id >= ed->var_pool->size)) return;
602 if (ed->var_pool->vars[id].type != EDJE_VAR_LIST) return;
603 ed->var_pool->vars[id].data.l.v = eina_list_prepend_relative(ed->var_pool->vars[id].data.l.v, var, relative);
604}
605
606Edje_Var *
607_edje_var_list_nth(Edje *ed, int id, int n)
608{
609 if (!ed) return NULL;
610 if (!ed->var_pool) return NULL;
611 id -= EDJE_VAR_MAGIC_BASE;
612 if ((id < 0) || (id >= ed->var_pool->size)) return NULL;
613 if (ed->var_pool->vars[id].type != EDJE_VAR_LIST) return NULL;
614 return eina_list_nth(ed->var_pool->vars[id].data.l.v, n);
615}
616
617int
618_edje_var_list_count_get(Edje *ed, int id)
619{
620 if (!ed) return 0;
621 if (!ed->var_pool) return 0;
622 id -= EDJE_VAR_MAGIC_BASE;
623 if ((id < 0) || (id >= ed->var_pool->size)) return 0;
624 if (ed->var_pool->vars[id].type == EDJE_VAR_NONE)
625 ed->var_pool->vars[id].type = EDJE_VAR_LIST;
626 else if (ed->var_pool->vars[id].type != EDJE_VAR_LIST) return 0;
627 return eina_list_count(ed->var_pool->vars[id].data.l.v);
628}
629
630void
631_edje_var_list_remove_nth(Edje *ed, int id, int n)
632{
633 if (!ed) return;
634 if (!ed->var_pool) return;
635 id -= EDJE_VAR_MAGIC_BASE;
636 if ((id < 0) || (id >= ed->var_pool->size)) return;
637 if (ed->var_pool->vars[id].type == EDJE_VAR_NONE)
638 ed->var_pool->vars[id].type = EDJE_VAR_LIST;
639 else if (ed->var_pool->vars[id].type != EDJE_VAR_LIST) return;
640 {
641 Eina_List *nth;
642
643 nth = eina_list_nth_list(ed->var_pool->vars[id].data.l.v, n);
644 if (nth)
645 {
646 _edje_var_free(eina_list_data_get(nth));
647 ed->var_pool->vars[id].data.l.v = eina_list_remove_list(ed->var_pool->vars[id].data.l.v, nth);
648 }
649 }
650}
651
652int
653_edje_var_list_nth_int_get(Edje *ed, int id, int n)
654{
655 if (!ed) return 0;
656 if (!ed->var_pool) return 0;
657 id -= EDJE_VAR_MAGIC_BASE;
658 if ((id < 0) || (id >= ed->var_pool->size)) return 0;
659 if (ed->var_pool->vars[id].type == EDJE_VAR_NONE)
660 ed->var_pool->vars[id].type = EDJE_VAR_LIST;
661 else if (ed->var_pool->vars[id].type != EDJE_VAR_LIST) return 0;
662 {
663 Edje_Var *var;
664
665 id += EDJE_VAR_MAGIC_BASE;
666 var = _edje_var_list_nth(ed, id, n);
667 if (!var) return 0;
668 return _edje_var_var_int_get(ed, var);
669 }
670}
671
672void
673_edje_var_list_nth_int_set(Edje *ed, int id, int n, int v)
674{
675 if (!ed) return;
676 if (!ed->var_pool) return;
677 id -= EDJE_VAR_MAGIC_BASE;
678 if ((id < 0) || (id >= ed->var_pool->size)) return;
679 if (ed->var_pool->vars[id].type == EDJE_VAR_NONE)
680 ed->var_pool->vars[id].type = EDJE_VAR_LIST;
681 else if (ed->var_pool->vars[id].type != EDJE_VAR_LIST) return;
682 {
683 Edje_Var *var;
684
685 id += EDJE_VAR_MAGIC_BASE;
686 var = _edje_var_list_nth(ed, id, n);
687 if (!var) return;
688 _edje_var_var_int_set(ed, var, v);
689 }
690}
691
692void
693_edje_var_list_int_append(Edje *ed, int id, int v)
694{
695 if (!ed) return;
696 if (!ed->var_pool) return;
697 id -= EDJE_VAR_MAGIC_BASE;
698 if ((id < 0) || (id >= ed->var_pool->size)) return;
699 if (ed->var_pool->vars[id].type == EDJE_VAR_NONE)
700 ed->var_pool->vars[id].type = EDJE_VAR_LIST;
701 else if (ed->var_pool->vars[id].type != EDJE_VAR_LIST) return;
702 {
703 Edje_Var *var;
704
705 var = _edje_var_new();
706 if (!var) return;
707 id += EDJE_VAR_MAGIC_BASE;
708 _edje_var_var_int_set(ed, var, v);
709 _edje_var_list_var_append(ed, id, var);
710 }
711}
712
713void
714_edje_var_list_int_prepend(Edje *ed, int id, int v)
715{
716 if (!ed) return;
717 if (!ed->var_pool) return;
718 id -= EDJE_VAR_MAGIC_BASE;
719 if ((id < 0) || (id >= ed->var_pool->size)) return;
720 if (ed->var_pool->vars[id].type == EDJE_VAR_NONE)
721 ed->var_pool->vars[id].type = EDJE_VAR_LIST;
722 else if (ed->var_pool->vars[id].type != EDJE_VAR_LIST) return;
723 {
724 Edje_Var *var;
725
726 var = _edje_var_new();
727 if (!var) return;
728 id += EDJE_VAR_MAGIC_BASE;
729 _edje_var_var_int_set(ed, var, v);
730 _edje_var_list_var_prepend(ed, id, var);
731 }
732}
733
734void
735_edje_var_list_int_insert(Edje *ed, int id, int n, int v)
736{
737 if (!ed) return;
738 if (!ed->var_pool) return;
739 id -= EDJE_VAR_MAGIC_BASE;
740 if ((id < 0) || (id >= ed->var_pool->size)) return;
741 if (ed->var_pool->vars[id].type == EDJE_VAR_NONE)
742 ed->var_pool->vars[id].type = EDJE_VAR_LIST;
743 else if (ed->var_pool->vars[id].type != EDJE_VAR_LIST) return;
744 {
745 Edje_Var *var, *var_rel;
746
747 var = _edje_var_new();
748 if (!var) return;
749 id += EDJE_VAR_MAGIC_BASE;
750 _edje_var_var_int_set(ed, var, v);
751 var_rel = _edje_var_list_nth(ed, id, n);
752 if (!var_rel)
753 _edje_var_list_var_append(ed, id, var);
754 else
755 _edje_var_list_var_prepend_relative(ed, id, var, var_rel);
756 }
757}
758
759double
760_edje_var_list_nth_float_get(Edje *ed, int id, int n)
761{
762 if (!ed) return 0;
763 if (!ed->var_pool) return 0;
764 id -= EDJE_VAR_MAGIC_BASE;
765 if ((id < 0) || (id >= ed->var_pool->size)) return 0;
766 if (ed->var_pool->vars[id].type == EDJE_VAR_NONE)
767 ed->var_pool->vars[id].type = EDJE_VAR_LIST;
768 else if (ed->var_pool->vars[id].type != EDJE_VAR_LIST) return 0;
769 {
770 Edje_Var *var;
771
772 id += EDJE_VAR_MAGIC_BASE;
773 var = _edje_var_list_nth(ed, id, n);
774 if (!var) return 0;
775 return _edje_var_var_float_get(ed, var);
776 }
777}
778
779void
780_edje_var_list_nth_float_set(Edje *ed, int id, int n, double v)
781{
782 if (!ed) return;
783 if (!ed->var_pool) return;
784 id -= EDJE_VAR_MAGIC_BASE;
785 if ((id < 0) || (id >= ed->var_pool->size)) return;
786 if (ed->var_pool->vars[id].type == EDJE_VAR_NONE)
787 ed->var_pool->vars[id].type = EDJE_VAR_LIST;
788 else if (ed->var_pool->vars[id].type != EDJE_VAR_LIST) return;
789 {
790 Edje_Var *var;
791
792 id += EDJE_VAR_MAGIC_BASE;
793 var = _edje_var_list_nth(ed, id, n);
794 if (!var) return;
795 _edje_var_var_float_set(ed, var, v);
796 }
797}
798
799void
800_edje_var_list_float_append(Edje *ed, int id, double v)
801{
802 if (!ed) return;
803 if (!ed->var_pool) return;
804 id -= EDJE_VAR_MAGIC_BASE;
805 if ((id < 0) || (id >= ed->var_pool->size)) return;
806 if (ed->var_pool->vars[id].type == EDJE_VAR_NONE)
807 ed->var_pool->vars[id].type = EDJE_VAR_LIST;
808 else if (ed->var_pool->vars[id].type != EDJE_VAR_LIST) return;
809 {
810 Edje_Var *var;
811
812 var = _edje_var_new();
813 if (!var) return;
814 id += EDJE_VAR_MAGIC_BASE;
815 _edje_var_var_float_set(ed, var, v);
816 _edje_var_list_var_append(ed, id, var);
817 }
818}
819
820void
821_edje_var_list_float_prepend(Edje *ed, int id, double v)
822{
823 if (!ed) return;
824 if (!ed->var_pool) return;
825 id -= EDJE_VAR_MAGIC_BASE;
826 if ((id < 0) || (id >= ed->var_pool->size)) return;
827 if (ed->var_pool->vars[id].type == EDJE_VAR_NONE)
828 ed->var_pool->vars[id].type = EDJE_VAR_LIST;
829 else if (ed->var_pool->vars[id].type != EDJE_VAR_LIST) return;
830 {
831 Edje_Var *var;
832
833 var = _edje_var_new();
834 if (!var) return;
835 id += EDJE_VAR_MAGIC_BASE;
836 _edje_var_var_float_set(ed, var, v);
837 _edje_var_list_var_prepend(ed, id, var);
838 }
839}
840
841void
842_edje_var_list_float_insert(Edje *ed, int id, int n, double v)
843{
844 if (!ed) return;
845 if (!ed->var_pool) return;
846 id -= EDJE_VAR_MAGIC_BASE;
847 if ((id < 0) || (id >= ed->var_pool->size)) return;
848 if (ed->var_pool->vars[id].type == EDJE_VAR_NONE)
849 ed->var_pool->vars[id].type = EDJE_VAR_LIST;
850 else if (ed->var_pool->vars[id].type != EDJE_VAR_LIST) return;
851 {
852 Edje_Var *var, *var_rel;
853
854 var = _edje_var_new();
855 if (!var) return;
856 id += EDJE_VAR_MAGIC_BASE;
857 _edje_var_var_float_set(ed, var, v);
858 var_rel = _edje_var_list_nth(ed, id, n);
859 if (!var_rel)
860 _edje_var_list_var_append(ed, id, var);
861 else
862 _edje_var_list_var_prepend_relative(ed, id, var, var_rel);
863 }
864}
865
866const char *
867_edje_var_list_nth_str_get(Edje *ed, int id, int n)
868{
869 if (!ed) return NULL;
870 if (!ed->var_pool) return NULL;
871 id -= EDJE_VAR_MAGIC_BASE;
872 if ((id < 0) || (id >= ed->var_pool->size)) return NULL;
873 if (ed->var_pool->vars[id].type == EDJE_VAR_NONE)
874 ed->var_pool->vars[id].type = EDJE_VAR_LIST;
875 else if (ed->var_pool->vars[id].type != EDJE_VAR_LIST) return NULL;
876 {
877 Edje_Var *var;
878
879 id += EDJE_VAR_MAGIC_BASE;
880 var = _edje_var_list_nth(ed, id, n);
881 if (!var) return NULL;
882 return _edje_var_var_str_get(ed, var);
883 }
884}
885
886void
887_edje_var_list_nth_str_set(Edje *ed, int id, int n, const char *v)
888{
889 if (!ed) return;
890 if (!ed->var_pool) return;
891 id -= EDJE_VAR_MAGIC_BASE;
892 if ((id < 0) || (id >= ed->var_pool->size)) return;
893 if (ed->var_pool->vars[id].type == EDJE_VAR_NONE)
894 ed->var_pool->vars[id].type = EDJE_VAR_LIST;
895 else if (ed->var_pool->vars[id].type != EDJE_VAR_LIST) return;
896 {
897 Edje_Var *var;
898
899 id += EDJE_VAR_MAGIC_BASE;
900 var = _edje_var_list_nth(ed, id, n);
901 if (!var) return;
902 _edje_var_var_str_set(ed, var, v);
903 }
904}
905
906void
907_edje_var_list_str_append(Edje *ed, int id, const char *v)
908{
909 if (!ed) return;
910 if (!ed->var_pool) return;
911 id -= EDJE_VAR_MAGIC_BASE;
912 if ((id < 0) || (id >= ed->var_pool->size)) return;
913 if (ed->var_pool->vars[id].type == EDJE_VAR_NONE)
914 ed->var_pool->vars[id].type = EDJE_VAR_LIST;
915 else if (ed->var_pool->vars[id].type != EDJE_VAR_LIST) return;
916 {
917 Edje_Var *var;
918
919 var = _edje_var_new();
920 if (!var) return;
921 id += EDJE_VAR_MAGIC_BASE;
922 _edje_var_var_str_set(ed, var, v);
923 _edje_var_list_var_append(ed, id, var);
924 }
925}
926
927void
928_edje_var_list_str_prepend(Edje *ed, int id, const char *v)
929{
930 if (!ed) return;
931 if (!ed->var_pool) return;
932 id -= EDJE_VAR_MAGIC_BASE;
933 if ((id < 0) || (id >= ed->var_pool->size)) return;
934 if (ed->var_pool->vars[id].type == EDJE_VAR_NONE)
935 ed->var_pool->vars[id].type = EDJE_VAR_LIST;
936 else if (ed->var_pool->vars[id].type != EDJE_VAR_LIST) return;
937 {
938 Edje_Var *var;
939
940 var = _edje_var_new();
941 if (!var) return;
942 id += EDJE_VAR_MAGIC_BASE;
943 _edje_var_var_str_set(ed, var, v);
944 _edje_var_list_var_prepend(ed, id, var);
945 }
946}
947
948void
949_edje_var_list_str_insert(Edje *ed, int id, int n, const char *v)
950{
951 if (!ed) return;
952 if (!ed->var_pool) return;
953 id -= EDJE_VAR_MAGIC_BASE;
954 if ((id < 0) || (id >= ed->var_pool->size)) return;
955 if (ed->var_pool->vars[id].type == EDJE_VAR_NONE)
956 ed->var_pool->vars[id].type = EDJE_VAR_LIST;
957 else if (ed->var_pool->vars[id].type != EDJE_VAR_LIST) return;
958 {
959 Edje_Var *var, *var_rel;
960
961 var = _edje_var_new();
962 if (!var) return;
963 id += EDJE_VAR_MAGIC_BASE;
964 _edje_var_var_str_set(ed, var, v);
965 var_rel = _edje_var_list_nth(ed, id, n);
966 if (!var_rel)
967 _edje_var_list_var_append(ed, id, var);
968 else
969 _edje_var_list_var_prepend_relative(ed, id, var, var_rel);
970 }
971}
972
973int
974_edje_var_timer_add(Edje *ed, double in, const char *fname, int val)
975{
976 Edje_Var_Timer *et;
977 Embryo_Function fn;
978
979 if (!ed->var_pool) return 0;
980 fn = embryo_program_function_find(ed->collection->script, (char *)fname);
981 if (fn == EMBRYO_FUNCTION_NONE) return 0;
982 et = calloc(1, sizeof(Edje_Var_Timer));
983 if (!et) return 0;
984 et->id = ++ed->var_pool->id_count;
985 et->edje = ed;
986 et->func = fn;
987 et->val = val;
988 et->timer = ecore_timer_add(in, _edje_var_timer_cb, et);
989 if (!et->timer)
990 {
991 free(et);
992 return 0;
993 }
994 ed->var_pool->timers = eina_list_prepend(ed->var_pool->timers, et);
995 return et->id;
996}
997
998static Edje_Var_Timer *
999_edje_var_timer_find(Edje *ed, int id)
1000{
1001 Eina_List *l;
1002 Edje_Var_Timer *et;
1003
1004 if (!ed->var_pool) return NULL;
1005
1006 EINA_LIST_FOREACH(ed->var_pool->timers, l, et)
1007 if (et->id == id) return et;
1008
1009 return NULL;
1010}
1011
1012void
1013_edje_var_timer_del(Edje *ed, int id)
1014{
1015 Edje_Var_Timer *et;
1016
1017 et = _edje_var_timer_find(ed, id);
1018 if (!et) return;
1019
1020 ed->var_pool->timers = eina_list_remove(ed->var_pool->timers, et);
1021 ecore_timer_del(et->timer);
1022 free(et);
1023}
1024
1025int
1026_edje_var_anim_add(Edje *ed, double len, const char *fname, int val)
1027{
1028 Edje_Var_Animator *ea;
1029 Embryo_Function fn;
1030
1031 if (!ed->var_pool) return 0;
1032 if (len <= 0.0) return 0;
1033 fn = embryo_program_function_find(ed->collection->script, (char *)fname);
1034 if (fn == EMBRYO_FUNCTION_NONE) return 0;
1035 ea = calloc(1, sizeof(Edje_Var_Animator));
1036 if (!ea) return 0;
1037 ea->start = ecore_loop_time_get();
1038 ea->len = len;
1039 ea->id = ++ed->var_pool->id_count;
1040 ea->edje = ed;
1041 ea->func = fn;
1042 ea->val = val;
1043 if (!ed->var_pool->animators)
1044 _edje_anim_list = eina_list_append(_edje_anim_list, ed);
1045 ed->var_pool->animators = eina_list_prepend(ed->var_pool->animators, ea);
1046 if (!_edje_animator)
1047 _edje_animator = ecore_animator_add(_edje_var_anim_cb, NULL);
1048 return ea->id;
1049}
1050
1051static Edje_Var_Animator *
1052_edje_var_anim_find(Edje *ed, int id)
1053{
1054 Eina_List *l;
1055 Edje_Var_Animator *ea;
1056
1057 if (!ed->var_pool) return NULL;
1058
1059 EINA_LIST_FOREACH(ed->var_pool->animators, l, ea)
1060 if (ea->id == id) return ea;
1061
1062 return NULL;
1063}
1064
1065void
1066_edje_var_anim_del(Edje *ed, int id)
1067{
1068 Edje_Var_Animator *ea;
1069
1070 ea = _edje_var_anim_find(ed, id);
1071 if (!ea) return;
1072
1073 if (ed->var_pool->walking_list)
1074 {
1075 ea->delete_me = 1;
1076 return;
1077 }
1078
1079 ed->var_pool->animators = eina_list_remove(ed->var_pool->animators, ea);
1080 free(ea);
1081
1082 if (ed->var_pool->animators) return;
1083
1084 _edje_anim_list = eina_list_remove(_edje_anim_list, ed);
1085 if (!_edje_anim_list)
1086 {
1087 if (_edje_animator)
1088 {
1089 ecore_animator_del(_edje_animator);
1090 _edje_animator = NULL;
1091 }
1092 }
1093}