From dd7595a3475407a7fa96a97393bae8c5220e8762 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Wed, 4 Jan 2012 18:41:13 +1000 Subject: Add the base Enlightenment Foundation Libraries - eina, eet, evas, ecore, embryo, and edje. Note that embryo wont be used, but I'm not sure yet if you can build edje without it. --- libraries/edje/src/lib/Edje.h | 3926 ++++++++++++ libraries/edje/src/lib/Edje_Edit.h | 3539 +++++++++++ libraries/edje/src/lib/Makefile.am | 140 + libraries/edje/src/lib/Makefile.in | 810 +++ libraries/edje/src/lib/edje_box_layout.c | 242 + libraries/edje/src/lib/edje_cache.c | 570 ++ libraries/edje/src/lib/edje_calc.c | 2801 +++++++++ libraries/edje/src/lib/edje_callbacks.c | 546 ++ libraries/edje/src/lib/edje_container.c | 955 +++ libraries/edje/src/lib/edje_container.h | 165 + libraries/edje/src/lib/edje_convert.h | 143 + libraries/edje/src/lib/edje_data.c | 877 +++ libraries/edje/src/lib/edje_edit.c | 7829 ++++++++++++++++++++++++ libraries/edje/src/lib/edje_embryo.c | 3179 ++++++++++ libraries/edje/src/lib/edje_entry.c | 3110 ++++++++++ libraries/edje/src/lib/edje_external.c | 559 ++ libraries/edje/src/lib/edje_load.c | 1525 +++++ libraries/edje/src/lib/edje_lua.c | 5150 ++++++++++++++++ libraries/edje/src/lib/edje_lua2.c | 4129 +++++++++++++ libraries/edje/src/lib/edje_lua_script_only.c | 59 + libraries/edje/src/lib/edje_main.c | 274 + libraries/edje/src/lib/edje_match.c | 814 +++ libraries/edje/src/lib/edje_message_queue.c | 865 +++ libraries/edje/src/lib/edje_misc.c | 1 + libraries/edje/src/lib/edje_module.c | 154 + libraries/edje/src/lib/edje_multisense.c | 408 ++ libraries/edje/src/lib/edje_private.h | 2028 ++++++ libraries/edje/src/lib/edje_program.c | 2090 +++++++ libraries/edje/src/lib/edje_script_only.c | 643 ++ libraries/edje/src/lib/edje_smart.c | 336 + libraries/edje/src/lib/edje_text.c | 790 +++ libraries/edje/src/lib/edje_textblock_styles.c | 424 ++ libraries/edje/src/lib/edje_util.c | 4317 +++++++++++++ libraries/edje/src/lib/edje_var.c | 1093 ++++ 34 files changed, 54491 insertions(+) create mode 100644 libraries/edje/src/lib/Edje.h create mode 100644 libraries/edje/src/lib/Edje_Edit.h create mode 100644 libraries/edje/src/lib/Makefile.am create mode 100644 libraries/edje/src/lib/Makefile.in create mode 100644 libraries/edje/src/lib/edje_box_layout.c create mode 100644 libraries/edje/src/lib/edje_cache.c create mode 100644 libraries/edje/src/lib/edje_calc.c create mode 100644 libraries/edje/src/lib/edje_callbacks.c create mode 100644 libraries/edje/src/lib/edje_container.c create mode 100644 libraries/edje/src/lib/edje_container.h create mode 100644 libraries/edje/src/lib/edje_convert.h create mode 100644 libraries/edje/src/lib/edje_data.c create mode 100644 libraries/edje/src/lib/edje_edit.c create mode 100644 libraries/edje/src/lib/edje_embryo.c create mode 100644 libraries/edje/src/lib/edje_entry.c create mode 100644 libraries/edje/src/lib/edje_external.c create mode 100644 libraries/edje/src/lib/edje_load.c create mode 100644 libraries/edje/src/lib/edje_lua.c create mode 100644 libraries/edje/src/lib/edje_lua2.c create mode 100644 libraries/edje/src/lib/edje_lua_script_only.c create mode 100644 libraries/edje/src/lib/edje_main.c create mode 100644 libraries/edje/src/lib/edje_match.c create mode 100644 libraries/edje/src/lib/edje_message_queue.c create mode 100644 libraries/edje/src/lib/edje_misc.c create mode 100644 libraries/edje/src/lib/edje_module.c create mode 100644 libraries/edje/src/lib/edje_multisense.c create mode 100644 libraries/edje/src/lib/edje_private.h create mode 100644 libraries/edje/src/lib/edje_program.c create mode 100644 libraries/edje/src/lib/edje_script_only.c create mode 100644 libraries/edje/src/lib/edje_smart.c create mode 100644 libraries/edje/src/lib/edje_text.c create mode 100644 libraries/edje/src/lib/edje_textblock_styles.c create mode 100644 libraries/edje/src/lib/edje_util.c create mode 100644 libraries/edje/src/lib/edje_var.c (limited to 'libraries/edje/src/lib') 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 @@ +/** +@brief Edje Graphical Design Library + +These routines are used for Edje. + +@mainpage Edje Library Documentation +@version 1.1 +@date 2003-2011 + +Please see the @ref authors page for contact details. + + + + + + + +@section intro What is Edje? + +Edje is a complex graphical design & layout library. + +It doesn't pretend to do containing and regular layout like a widget +set, but it is the base for such components. Based on the requirements +of Enlightenment 0.17, Edje should serve all the purposes of creating +visual elements (borders of windows, buttons, scrollbars, etc.) and +allow the designer the ability to animate, layout and control the look +and feel of any program using Edje as its basic GUI constructor. This +library allows for multiple collections of Layouts in one file, +sharing the same image and font database and thus allowing a whole +theme to be conveniently packaged into 1 file and shipped around. + +Edje separates the layout and behavior logic. Edje files ship with an +image and font database, used by all the parts in all the collections +to source graphical data. It has a directory of logical part names +pointing to the part collection entry ID in the file (thus allowing +for multiple logical names to point to the same part collection, +allowing for the sharing of data between display elements). Each part +collection consists of a list of visual parts, as well as a list of +programs. A program is a conditionally run program that if a +particular event occurs (a button is pressed, a mouse enters or leaves +a part) will trigger an action that may affect other parts. In this +way a part collection can be "programmed" via its file as to hilight +buttons when the mouse passes over them or show hidden parts when a +button is clicked somewhere etc. The actions performed in changing +from one state to another are also allowed to transition over a period +of time, allowing animation. Programs and animations can be run in +"parallel". + +This separation and simplistic event driven style of programming can produce +almost any look and feel one could want for basic visual elements. Anything +more complex is likely the domain of an application or widget set that may +use Edje as a convenient way of being able to configure parts of the display. + +For details of Edje's history, see the \ref history section. + + +@section requirements What does Edje require? + +Edje requires fairly little on your system. to use the Edje runtime library +you need: + + - Evas (library) + - Ecore (library) + - Eet (library) + - Embryo (library) + - Eina (library) + - Lua 5.1 (library) + +Evas needs to be build with the JPEG, PNG and EET image loaders enabled at a +minimum. You will also need the buffer engine (which requires the +software_generic engine) as well. + +Ecore needs the ECORE, ECORE_EVAS and ECORE_X modules built at a minimum. +It's suggested to build all the Ecore modules. You will beed the Buffer +engine support built into Ecore_Evas for edje?_cc to function. + + +@section compiling How to compile and test Edje + +Now you need to compile and install Edje. + +@verbatim + ./configure + make + sudo make install +@endverbatim + +You now have it installed and ready to go, but you need input +data. There are lots of examples in SVN, the best one is +Enlightenment's own theme file. + +You may use different tools to edit and view the generated ".edj" +files, for instance: + + - edje_player (provided by Edje) + - editje (http://trac.enlightenment.org/e/wiki/Editje) + - edje_viewer (http://trac.enlightenment.org/e/wiki/Edje_Viewer) + + +@section details So how does this all work? + +Edje internally holds a geometry state machine and state graph of what is +visible, not, where, at what size, with what colors etc. This is described +to Edje from an Edje .edj file containing this information. These files can +be produced by using edje_cc to take a text file (a .edc file) and "compile" +an output .edj file that contains this information, images and any other +data needed. + +The application using Edje will then create an object in its Evas +canvas and set the bundle file to use, specifying the @b group name to +use. Edje will load such information and create all the required +children objects with the specified properties as defined in each @b +part of the given group. See the following annotated example: + +@code + +#include +#include +#include +#include +#include + +#define WIDTH 320 +#define HEIGHT 240 + +static Evas_Object *create_my_group(Evas *canvas, const char *text) +{ + Evas_Object *edje; + + edje = edje_object_add(canvas); + if (!edje) + { + EINA_LOG_CRIT("could not create edje object!"); + return NULL; + } + + if (!edje_object_file_set(edje, "edje_example.edj", "my_group")) + { + int err = edje_object_load_error_get(edje); + const char *errmsg = edje_load_error_str(err); + EINA_LOG_ERR("could not load 'my_group' from edje_example.edj: %s", + errmsg); + + evas_object_del(edje); + return NULL; + } + + if (text) + { + if (!edje_object_part_text_set(edje, "text", text)) + { + EINA_LOG_WARN("could not set the text. " + "Maybe part 'text' does not exist?"); + } + } + + evas_object_move(edje, 0, 0); + evas_object_resize(edje, WIDTH, HEIGHT); + evas_object_show(edje); + return edje; +} + +int main(int argc, char *argv[]) +{ + Ecore_Evas *window; + Evas *canvas; + Evas_Object *edje; + const char *text; + + eina_init(); + evas_init(); + ecore_init(); + ecore_evas_init(); + edje_init(); + + window = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL); + if (!window) + { + EINA_LOG_CRIT("could not create window."); + return -1; + } + canvas = ecore_evas_get(window); + + text = (argc > 1) ? argv[1] : NULL; + + edje = create_my_group(canvas, text); + if (!edje) + return -2; + + ecore_evas_show(window); + ecore_main_loop_begin(); + + evas_object_del(edje); + ecore_evas_free(window); + + return 0; +} +@endcode + +It requires the following source Edje file: +@code +// compile: edje_cc edje_example.edc +collections { + group { + name: "my_group"; // must be the same as in edje_example.c + + parts { + part { + name: "background"; + type: RECT; // plain boring rectangle + mouse_events: 0; // we don't need any mouse event on the background + + // just one state "default" + description { + state: "default" 0.0; // must always exist + color: 255 255 255 255; // white + + // define part coordinates: + + rel1 { // top-left point at (0, 0) [WIDTH * 0 + 0, HEIGHT * 0 + 0] + relative: 0.0 0.0; + offset: 0 0; + } + rel2 { // bottom-right point at (WIDTH * 1.0 - 1, HEIGHT * 1.0 - 1) + relative: 1.0 1.0; + offset: -1 -1; + } + } + } + + part { + name: "text"; + type: TEXT; + mouse_events: 1; // we want to change the color on mouse-over + + // 2 states, one "default" and another "over" to be used + // on mouse over effect + + description { + state: "default" 0.0; + color: 255 0 0 255; // red + + // define part coordinates: + + rel1 { // top-left at (WIDTH * 0.1 + 5, HEIGHT * 0.2 + 10) + relative: 0.1 0.2; + offset: 5 10; + } + rel2 { // bottom-right at (WIDTH * 0.9 - 6, HEIGHT * 0.8 - 11) + relative: 0.9 0.8; + offset: -6 -11; + } + + // define text specific state details + text { + font: "Sans"; // using fontconfig name! + size: 10; + text: "hello world"; + } + } + + description { + state: "over" 0.0; + inherit: "default" 0.0; // copy everything from "default" at this point + + color: 0 255 0 255; // override color, now it is green + } + } + + // do programs to change color on text mouse in/out (over) + programs { + program { + // what triggers this program: + signal: "mouse,in"; + source: "text"; + + // what this program does: + action: STATE_SET "over" 0.0; + target: "text"; + + // do the state-set in a nice interpolation animation + // using linear time in 0.1 second + transition: LINEAR 0.1; + } + + program { + // what triggers this program: + signal: "mouse,out"; + source: "text"; + + // what this program does: + action: STATE_SET "default" 0.0; + target: "text"; + + // do the state-set in a nice interpolation animation + // using linear time in 0.1 second + transition: LINEAR 0.1; + } + } + } + } +} +@endcode + + +One should save these files as edje_example.c and edje_example.edc then: +@verbatim +gcc -o edje_example edje_example.c `pkg-config --cflags --libs eina evas ecore ecore-evas edje` +edje_cc edje_example.edc + +./edje_example "some text" +@endverbatim + +Although simple, this example illustrates that animations and state +changes can be done from the Edje file itself without any requirement +in the C application. + +Before digging into changing or creating your own Edje source (edc) +files, read the @ref edcref. + + + +@section history Edje History + +It's a sequel to "Ebits" which has serviced the needs of Enlightenment +development for early version 0.17. The original design parameters under +which Ebits came about were a lot more restricted than the resulting +use of them, thus Edje was born. + +Edje is a more complex layout engine compared to Ebits. It doesn't +pretend to do containing and regular layout like a widget set. It +still inherits the more simplistic layout ideas behind Ebits, but it +now does them a lot more cleanly, allowing for easy expansion, and the +ability to cover much more ground than Ebits ever could. For the +purposes of Enlightenment 0.17, Edje was conceived to serve all the +purposes of creating visual elements (borders of windows, buttons, +scrollbars, etc.) and allow the designer the ability to animate, +layout and control the look and feel of any program using Edje as its +basic GUI constructor. + +Unlike Ebits, Edje separates the layout and behavior logic. + + + +@section Edje_Examples Examples on Edje's usage + +What follows is a list with various commented examples, covering a great +part of Edje's API: + +- @ref Example_Edje_Basics +- @ref tutorial_edje_swallow +- @ref tutorial_edje_table +- @ref tutorial_edje_box +- @ref tutorial_edje_box2 +- @ref tutorial_edje_color_class +- @ref tutorial_edje_animations +- @ref Example_Edje_Signals_Messages + + +*/ + +/** +@page authors Authors +@author Carsten Haitzler +@author Tilman Sauerbeck (tilman at code-monkey de) +@author ZigsMcKenzie +@author Cedric BAIL +@author Brian Mattern +@author Mathieu Taillefumier +@author Tristan +@author Gustavo Lima Chaves +@author Bruno Dilly +@author Fabiano Fidêncio +@author Jihoon Kim +@author Tiago Falcão +@author Davide Andreoli +@author Sebastian Dransfeld +@author Tom Hacohen +@author Aharon Hillel + +Please contact to get in +contact with the developers and maintainers. +*/ + + +/** + +@example embryo_custom_state.edc +This example show how to create a custom state from embryo. Clicking on the +3 labels will rotate the object in the given direction. + +@example embryo_pong.edc +Super-simple Pong implementation in pure embryo. + +@example embryo_run_program.edc +This example show how to run an edje program from embryo code. + +@example embryo_set_state.edc +This example show how to change the state of a part from embryo code. + +@example embryo_set_text.edc +This example show how to set the text in TEXT part from embryo code. + +@example embryo_timer.edc +This example show the usage of timers in embryo. + +@example external_elm_anchorblock.edc +This example use an elementary anchorblock and a button to animate the text. + +@example external_elm_button.edc +This example create some elementary buttons and do some actions on user click. + +@example external_elm_check.edc +This example show EXTERNAL checkbox in action. + +@example external_elm_panes.edc +This example show EXTERNAL elementary panes in action. + +@example external_emotion_elm.edc +Super-concise video player example using Edje/Emotion/Elementary. + +@example lua_script.edc +This example show the usage of lua scripting to create and animate some +objects in the canvas. + +@example toggle_using_filter.edc +This example show how to toggle the state of a part using the 'filter' +param in edje programs + +*/ + +#ifndef _EDJE_H +#define _EDJE_H + +#ifndef _MSC_VER +# include +#endif +#include +#include +#include + +#include + +#ifdef EAPI +# undef EAPI +#endif + +#ifdef _WIN32 +# ifdef EFL_EDJE_BUILD +# ifdef DLL_EXPORT +# define EAPI __declspec(dllexport) +# else +# define EAPI +# endif /* ! DLL_EXPORT */ +# else +# define EAPI __declspec(dllimport) +# endif /* ! EFL_EDJE_BUILD */ +#else +# ifdef __GNUC__ +# if __GNUC__ >= 4 +# define EAPI __attribute__ ((visibility("default"))) +# else +# define EAPI +# endif +# else +# define EAPI +# endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define EDJE_VERSION_MAJOR 1 +#define EDJE_VERSION_MINOR 0 + + typedef struct _Edje_Version + { + int major; + int minor; + int micro; + int revision; + } Edje_Version; + + EAPI extern Edje_Version *edje_version; + +/** + * @file Edje.h + * @brief Edje Graphical Design Library + * + * These routines are used for Edje. + */ + +/** + * Identifiers of Edje message types, which can be sent back and forth + * code and a given Edje object's theme file/group. + * + * @see edje_object_message_send() + * @see edje_object_message_handler_set() + */ +typedef enum _Edje_Message_Type +{ + EDJE_MESSAGE_NONE = 0, + + EDJE_MESSAGE_SIGNAL = 1, /* DONT USE THIS */ + + EDJE_MESSAGE_STRING = 2, /**< A message with a string as value. Use #Edje_Message_String structs as message body, for this type. */ + EDJE_MESSAGE_INT = 3, /**< A message with an integer number as value. Use #Edje_Message_Int structs as message body, for this type. */ + EDJE_MESSAGE_FLOAT = 4, /**< A message with a floating pointer number as value. Use #Edje_Message_Float structs as message body, for this type. */ + + 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. */ + 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. */ + 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. */ + + 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. */ + 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. */ + + 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. */ + 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. */ +} Edje_Message_Type; + +typedef enum _Edje_Aspect_Control +{ + EDJE_ASPECT_CONTROL_NONE = 0, + EDJE_ASPECT_CONTROL_NEITHER = 1, + EDJE_ASPECT_CONTROL_HORIZONTAL = 2, + EDJE_ASPECT_CONTROL_VERTICAL = 3, + EDJE_ASPECT_CONTROL_BOTH = 4 +} Edje_Aspect_Control; + +typedef enum _Edje_Object_Table_Homogeneous_Mode +{ + EDJE_OBJECT_TABLE_HOMOGENEOUS_NONE = 0, + EDJE_OBJECT_TABLE_HOMOGENEOUS_TABLE = 1, + EDJE_OBJECT_TABLE_HOMOGENEOUS_ITEM = 2 +} Edje_Object_Table_Homogeneous_Mode; + +typedef enum _Edje_Part_Type +{ + EDJE_PART_TYPE_NONE = 0, + EDJE_PART_TYPE_RECTANGLE = 1, + EDJE_PART_TYPE_TEXT = 2, + EDJE_PART_TYPE_IMAGE = 3, + EDJE_PART_TYPE_SWALLOW = 4, + EDJE_PART_TYPE_TEXTBLOCK = 5, + EDJE_PART_TYPE_GRADIENT = 6, + EDJE_PART_TYPE_GROUP = 7, + EDJE_PART_TYPE_BOX = 8, + EDJE_PART_TYPE_TABLE = 9, + EDJE_PART_TYPE_EXTERNAL = 10, + EDJE_PART_TYPE_PROXY = 11, + EDJE_PART_TYPE_LAST = 12 +} Edje_Part_Type; + +typedef enum _Edje_Text_Effect +{ +#define EDJE_TEXT_EFFECT_MASK_BASIC 0xf +#define EDJE_TEXT_EFFECT_BASIC_SET(x, s) \ + do { x = ((x) & ~EDJE_TEXT_EFFECT_MASK_BASIC) | (s); } while (0) + EDJE_TEXT_EFFECT_NONE = 0, + EDJE_TEXT_EFFECT_PLAIN = 1, + EDJE_TEXT_EFFECT_OUTLINE = 2, + EDJE_TEXT_EFFECT_SOFT_OUTLINE = 3, + EDJE_TEXT_EFFECT_SHADOW = 4, + EDJE_TEXT_EFFECT_SOFT_SHADOW = 5, + EDJE_TEXT_EFFECT_OUTLINE_SHADOW = 6, + EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW = 7, + EDJE_TEXT_EFFECT_FAR_SHADOW = 8, + EDJE_TEXT_EFFECT_FAR_SOFT_SHADOW = 9, + EDJE_TEXT_EFFECT_GLOW = 10, + + EDJE_TEXT_EFFECT_LAST = 11, + +#define EDJE_TEXT_EFFECT_MASK_SHADOW_DIRECTION (0x7 << 4) +#define EDJE_TEXT_EFFECT_SHADOW_DIRECTION_SET(x, s) \ + do { x = ((x) & ~EDJE_TEXT_EFFECT_MASK_SHADOW_DIRECTION) | (s); } while (0) + EDJE_TEXT_EFFECT_SHADOW_DIRECTION_BOTTOM_RIGHT = (0x0 << 4), + EDJE_TEXT_EFFECT_SHADOW_DIRECTION_BOTTOM = (0x1 << 4), + EDJE_TEXT_EFFECT_SHADOW_DIRECTION_BOTTOM_LEFT = (0x2 << 4), + EDJE_TEXT_EFFECT_SHADOW_DIRECTION_LEFT = (0x3 << 4), + EDJE_TEXT_EFFECT_SHADOW_DIRECTION_TOP_LEFT = (0x4 << 4), + EDJE_TEXT_EFFECT_SHADOW_DIRECTION_TOP = (0x5 << 4), + EDJE_TEXT_EFFECT_SHADOW_DIRECTION_TOP_RIGHT = (0x6 << 4), + EDJE_TEXT_EFFECT_SHADOW_DIRECTION_RIGHT = (0x7 << 4) +} Edje_Text_Effect; + +typedef enum _Edje_Action_Type +{ + EDJE_ACTION_TYPE_NONE = 0, + EDJE_ACTION_TYPE_STATE_SET = 1, + EDJE_ACTION_TYPE_ACTION_STOP = 2, + EDJE_ACTION_TYPE_SIGNAL_EMIT = 3, + EDJE_ACTION_TYPE_DRAG_VAL_SET = 4, + EDJE_ACTION_TYPE_DRAG_VAL_STEP = 5, + EDJE_ACTION_TYPE_DRAG_VAL_PAGE = 6, + EDJE_ACTION_TYPE_SCRIPT = 7, + EDJE_ACTION_TYPE_FOCUS_SET = 8, + EDJE_ACTION_TYPE_RESERVED00 = 9, + EDJE_ACTION_TYPE_FOCUS_OBJECT = 10, + EDJE_ACTION_TYPE_PARAM_COPY = 11, + EDJE_ACTION_TYPE_PARAM_SET = 12, + EDJE_ACTION_TYPE_SOUND_SAMPLE = 13, /**< @since 1.1 */ + EDJE_ACTION_TYPE_SOUND_TONE = 14, /**< @since 1.1 */ + EDJE_ACTION_TYPE_LAST = 15 +} Edje_Action_Type; + +typedef enum _Edje_Tween_Mode +{ + EDJE_TWEEN_MODE_NONE = 0, + EDJE_TWEEN_MODE_LINEAR = 1, + EDJE_TWEEN_MODE_SINUSOIDAL = 2, + EDJE_TWEEN_MODE_ACCELERATE = 3, + EDJE_TWEEN_MODE_DECELERATE = 4, + EDJE_TWEEN_MODE_ACCELERATE_FACTOR = 5, + EDJE_TWEEN_MODE_DECELERATE_FACTOR = 6, + EDJE_TWEEN_MODE_SINUSOIDAL_FACTOR = 7, + EDJE_TWEEN_MODE_DIVISOR_INTERP = 8, + EDJE_TWEEN_MODE_BOUNCE = 9, + EDJE_TWEEN_MODE_SPRING = 10, + EDJE_TWEEN_MODE_LAST = 11, + EDJE_TWEEN_MODE_MASK = 0xff, + EDJE_TWEEN_MODE_OPT_FROM_CURRENT = (1 << 31) +} Edje_Tween_Mode; + +typedef enum _Edje_Cursor +{ + EDJE_CURSOR_MAIN, + EDJE_CURSOR_SELECTION_BEGIN, + EDJE_CURSOR_SELECTION_END, + EDJE_CURSOR_PREEDIT_START, + EDJE_CURSOR_PREEDIT_END, + EDJE_CURSOR_USER, + EDJE_CURSOR_USER_EXTRA, + // more later +} Edje_Cursor; + +struct _Edje_Entry_Change_Info +{ + union { + struct { + const char *content; + size_t pos; + size_t plain_length; /* Number of cursor positions represented + in content. */ + } insert; + struct { + const char *content; + size_t start, end; + } del; + } change; + Eina_Bool insert : 1; /**< True if the "change" union's "insert" is valid */ + Eina_Bool merge : 1; /**< True if can be merged with the previous one. Used for example with insertion when something is already selected. */ +}; + +/** + * @since 1.1.0 + */ +typedef struct _Edje_Entry_Change_Info Edje_Entry_Change_Info; + +typedef struct _Edje_Message_String Edje_Message_String; +typedef struct _Edje_Message_Int Edje_Message_Int; +typedef struct _Edje_Message_Float Edje_Message_Float; +typedef struct _Edje_Message_String_Set Edje_Message_String_Set; +typedef struct _Edje_Message_Int_Set Edje_Message_Int_Set; +typedef struct _Edje_Message_Float_Set Edje_Message_Float_Set; +typedef struct _Edje_Message_String_Int Edje_Message_String_Int; +typedef struct _Edje_Message_String_Float Edje_Message_String_Float; +typedef struct _Edje_Message_String_Int_Set Edje_Message_String_Int_Set; +typedef struct _Edje_Message_String_Float_Set Edje_Message_String_Float_Set; + +struct _Edje_Message_String +{ + char *str; /**< The message's string pointer */ +}; /**< Structure passed as value on #EDJE_MESSAGE_STRING messages. The string in it is automatically freed be Edje if passed to you by Edje */ + +struct _Edje_Message_Int +{ + int val; /**< The message's value */ +}; /**< Structure passed as value on #EDJE_MESSAGE_INT messages */ + +struct _Edje_Message_Float +{ + double val; /**< The message's value */ +}; /**< Structure passed as value on #EDJE_MESSAGE_FLOAT messages */ + +struct _Edje_Message_String_Set +{ + int count; /**< The size of the message's array (may be greater than 1) */ + char *str[1]; /**< The message's @b array of string pointers */ +}; /**< 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 */ + +struct _Edje_Message_Int_Set +{ + int count; /**< The size of the message's array (may be greater than 1) */ + int val[1]; /**< The message's @b array of integers */ +}; /**< 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 */ + +struct _Edje_Message_Float_Set +{ + int count; /**< The size of the message's array (may be greater than 1) */ + double val[1]; /**< The message's @b array of floats */ +}; /**< 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 */ + +struct _Edje_Message_String_Int +{ + char *str; /**< The message's string value */ + int val; /**< The message's integer value */ +}; /**< 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 */ + +struct _Edje_Message_String_Float +{ + char *str; /**< The message's string value */ + double val; /**< The message's float value */ +}; /**< 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 */ + +struct _Edje_Message_String_Int_Set +{ + char *str; /**< The message's string value */ + int count; /**< The size of the message's array (may be greater than 1) */ + int val[1]; /**< The message's @b array of integers */ +}; /**< 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 */ + +struct _Edje_Message_String_Float_Set +{ + char *str; /**< The message's string value */ + int count; /**< The size of the message's array (may be greater than 1) */ + double val[1]; /**< The message's @b array of floats */ +}; /**< 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 */ + +typedef enum _Edje_Drag_Dir +{ + EDJE_DRAG_DIR_NONE = 0, + EDJE_DRAG_DIR_X = 1, + EDJE_DRAG_DIR_Y = 2, + EDJE_DRAG_DIR_XY = 3 +} Edje_Drag_Dir; + +typedef enum _Edje_Load_Error +{ + EDJE_LOAD_ERROR_NONE = 0, /**< No error happened, the loading was successful */ + EDJE_LOAD_ERROR_GENERIC = 1, /**< A generic error happened during the loading */ + EDJE_LOAD_ERROR_DOES_NOT_EXIST = 2, /**< The file pointed to did not exist */ + EDJE_LOAD_ERROR_PERMISSION_DENIED = 3, /**< Permission to read the given file was denied */ + EDJE_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED = 4, /**< Resource allocation failed during the loading */ + EDJE_LOAD_ERROR_CORRUPT_FILE = 5, /**< The file pointed to was corrupt */ + EDJE_LOAD_ERROR_UNKNOWN_FORMAT = 6, /**< The file pointed to had an unknown format */ + 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 */ + EDJE_LOAD_ERROR_UNKNOWN_COLLECTION = 8, /**< The group/collection set to load from was @b not found in the file */ + EDJE_LOAD_ERROR_RECURSIVE_REFERENCE = 9 /**< The group/collection set to load from had recursive references on its components */ +} Edje_Load_Error; /**< Edje file loading error codes one can get - see edje_load_error_str() too. */ + +typedef enum _Edje_Text_Filter_Type +{ + EDJE_TEXT_FILTER_TEXT = 0, + EDJE_TEXT_FILTER_FORMAT = 1, + EDJE_TEXT_FILTER_MARKUP = 2 +} Edje_Text_Filter_Type; + +typedef enum _Edje_Text_Autocapital_Type +{ + EDJE_TEXT_AUTOCAPITAL_TYPE_NONE, + EDJE_TEXT_AUTOCAPITAL_TYPE_WORD, + EDJE_TEXT_AUTOCAPITAL_TYPE_SENTENCE, + EDJE_TEXT_AUTOCAPITAL_TYPE_ALLCHARACTER +} Edje_Text_Autocapital_Type; + +/** + * The possible types the parameters of an EXTERNAL part can be. + */ +typedef enum _Edje_External_Param_Type +{ + EDJE_EXTERNAL_PARAM_TYPE_INT, /**< Parameter value is an integer. */ + EDJE_EXTERNAL_PARAM_TYPE_DOUBLE, /**< Parameter value is a double. */ + EDJE_EXTERNAL_PARAM_TYPE_STRING, /**< Paramater value is a string. */ + EDJE_EXTERNAL_PARAM_TYPE_BOOL, /**< Parameter value is boolean. */ + EDJE_EXTERNAL_PARAM_TYPE_CHOICE, /**< Parameter value is one of a set of + predefined string choices. */ + EDJE_EXTERNAL_PARAM_TYPE_MAX /**< Sentinel. Don't use. */ +} Edje_External_Param_Type; + +/** + * Flags that determine how a parameter may be accessed in different + * circumstances. + */ +typedef enum _Edje_External_Param_Flags +{ + EDJE_EXTERNAL_PARAM_FLAGS_NONE = 0, /**< Propery is incapable of operations, this is used to catch bogus flags. */ + EDJE_EXTERNAL_PARAM_FLAGS_GET = (1 << 0), /**< Property can be read/get. */ + 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. */ + EDJE_EXTERNAL_PARAM_FLAGS_STATE = (1 << 2), /**< Property can be set from state dsecription. */ + 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. */ + EDJE_EXTERNAL_PARAM_FLAGS_REGULAR = (EDJE_EXTERNAL_PARAM_FLAGS_GET | + EDJE_EXTERNAL_PARAM_FLAGS_SET | + EDJE_EXTERNAL_PARAM_FLAGS_STATE) /**< Convenience flag that sets property as GET, SET and STATE. */ +} Edje_External_Param_Flags; + +typedef enum +{ + EDJE_INPUT_PANEL_LAYOUT_NORMAL, /**< Default layout */ + EDJE_INPUT_PANEL_LAYOUT_NUMBER, /**< Number layout */ + EDJE_INPUT_PANEL_LAYOUT_EMAIL, /**< Email layout */ + EDJE_INPUT_PANEL_LAYOUT_URL, /**< URL layout */ + EDJE_INPUT_PANEL_LAYOUT_PHONENUMBER, /**< Phone Number layout */ + EDJE_INPUT_PANEL_LAYOUT_IP, /**< IP layout */ + EDJE_INPUT_PANEL_LAYOUT_MONTH, /**< Month layout */ + EDJE_INPUT_PANEL_LAYOUT_NUMBERONLY, /**< Number Only layout */ + EDJE_INPUT_PANEL_LAYOUT_INVALID +} Edje_Input_Panel_Layout; + +/** + * @brief Converts type identifier to string nicer representation. + * + * This may be used to debug or other informational purposes. + * + * @param type the identifier to convert. + * @return the string with the string representation, or @c "(unknown)". + */ +EAPI const char *edje_external_param_type_str(Edje_External_Param_Type type) EINA_PURE; + +/** + * Struct that holds parameters for parts of type EXTERNAL. + */ +struct _Edje_External_Param +{ + const char *name; /**< The name of the parameter. */ + Edje_External_Param_Type type; /**< The type of the parameter. This defines + which of the next three variables holds + the value for it. */ + // XXX these could be in a union, but eet doesn't support them (or does it?) + int i; /**< Used by both integer and boolean */ + double d; /**< Used by double */ + const char *s; /**< Used by both string and choice */ +}; +/** + * Struct that holds parameters for parts of type EXTERNAL. + */ +typedef struct _Edje_External_Param Edje_External_Param; + +/** + * Helper macro to indicate an EXTERNAL's integer parameter is undefined. + */ +#define EDJE_EXTERNAL_INT_UNSET INT_MAX +/** + * Helper macro to indicate an EXTERNAL's double parameter is undefined. + */ +#define EDJE_EXTERNAL_DOUBLE_UNSET DBL_MAX + +/** + * Struct holding information about an EXTERNAL part's parameters. + * + * When creating types to use with EXTERNAL parts, an array of this type is + * used to describe the different parameters the object uses. + * + * This struct holds the name, type and flags that define how and when the + * parameter is used, as well as information specific to each type, like the + * maximum or minimum value, that can be used by editors to restrict the + * range of values to set for each parameter. + */ +typedef struct _Edje_External_Param_Info Edje_External_Param_Info; +/** + * Struct holding information about an EXTERNAL part's parameters. + * + * When creating types to use with EXTERNAL parts, an array of this type is + * used to describe the different parameters the object uses. + * + * This struct holds the name, type and flags that define how and when the + * parameter is used, as well as information specific to each type, like the + * maximum or minimum value, that can be used by editors to restrict the + * range of values to set for each parameter. + */ +struct _Edje_External_Param_Info +{ + const char *name; /**< Name of the parameter. */ + Edje_External_Param_Type type; /**< Type of the parameter. */ + Edje_External_Param_Flags flags; /**< Flags indicating how this parameter is + used. */ + union { + struct { + int def, /**< Default value for the paramter. */ + min, /**< Minimum value it can have. */ + max, /**< Maximum value it can have. */ + step; /**< Values will be a multiple of this. */ + } i; /**< Info about integer type parametrs. Use #EDJE_EXTERNAL_INT_UNSET + on any of them to indicate they are not defined.*/ + struct { + double def, /**< Default value for the paramter. */ + min, /**< Minimum value it can have. */ + max, /**< Maximum value it can have. */ + step; /**< Values will be a multiple of this. */ + } d; /**< Info about double type parametrs. Use +#EDJE_EXTERNAL_DOUBLE_UNSET on any of them to indicate they are not defined.*/ + struct { + const char *def; /**< Default value. */ + const char *accept_fmt; /**< Not implemented. */ + const char *deny_fmt; /**< Not implemented */ + } s; /**< Info about string type parameters. NULL indicates undefined. */ + struct { + int def; /**< Default value. */ + const char *false_str; /**< String shown by editors to indicate the false state. */ + const char *true_str; /**< String shown by editors to indicate the true state. */ + } b; /**< Info about boolean type parameters.*/ + struct { + const char *def; /**< Default value. */ + const char **choices; /* Array of strings, each represents a + valid value for this parameter. The + last element of the array must be + NULL. */ + 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 */ + 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 */ + } c; /**< Info about choice type parameters. */ + } info; +}; + +#define EDJE_EXTERNAL_PARAM_INFO_INT_FULL_FLAGS(name, def, min, max, step, flags) \ + {name, EDJE_EXTERNAL_PARAM_TYPE_INT, flags, {.i = {def, min, max, step}}} +#define EDJE_EXTERNAL_PARAM_INFO_DOUBLE_FULL_FLAGS(name, def, min, max, step, flags) \ + {name, EDJE_EXTERNAL_PARAM_TYPE_DOUBLE, flags, {.d = {def, min, max, step}}} +#define EDJE_EXTERNAL_PARAM_INFO_STRING_FULL_FLAGS(name, def, accept, deny, flags) \ + {name, EDJE_EXTERNAL_PARAM_TYPE_STRING, flags, {.s = {def, accept, deny}}} +#define EDJE_EXTERNAL_PARAM_INFO_BOOL_FULL_FLAGS(name, def, false_str, true_str, flags) \ + {name, EDJE_EXTERNAL_PARAM_TYPE_BOOL, flags, {.b = {def, false_str, true_str}}} +#define EDJE_EXTERNAL_PARAM_INFO_CHOICE_FULL_FLAGS(name, def, choices, flags) \ + {name, EDJE_EXTERNAL_PARAM_TYPE_CHOICE, flags, {.c = {def, choices, NULL, NULL}}} +#define EDJE_EXTERNAL_PARAM_INFO_CHOICE_DYNAMIC_FULL_FLAGS(name, def_get, query, flags) \ + {name, EDJE_EXTERNAL_PARAM_TYPE_CHOICE, flags, {.c = {NULL, NULL, def_get, query}}} + +#define EDJE_EXTERNAL_PARAM_INFO_INT_FULL(name, def, min, max, step) \ + EDJE_EXTERNAL_PARAM_INFO_INT_FULL_FLAGS(name, def, min, max, step, EDJE_EXTERNAL_PARAM_FLAGS_REGULAR) +#define EDJE_EXTERNAL_PARAM_INFO_DOUBLE_FULL(name, def, min, max, step) \ + EDJE_EXTERNAL_PARAM_INFO_DOUBLE_FULL_FLAGS(name, def, min, max, step, EDJE_EXTERNAL_PARAM_FLAGS_REGULAR) +#define EDJE_EXTERNAL_PARAM_INFO_STRING_FULL(name, def, accept, deny) \ + EDJE_EXTERNAL_PARAM_INFO_STRING_FULL_FLAGS(name, def, accept, deny, EDJE_EXTERNAL_PARAM_FLAGS_REGULAR) +#define EDJE_EXTERNAL_PARAM_INFO_BOOL_FULL(name, def, false_str, true_str) \ + EDJE_EXTERNAL_PARAM_INFO_BOOL_FULL_FLAGS(name, def, false_str, true_str, EDJE_EXTERNAL_PARAM_FLAGS_REGULAR) +#define EDJE_EXTERNAL_PARAM_INFO_CHOICE_FULL(name, def, choices) \ + EDJE_EXTERNAL_PARAM_INFO_CHOICE_FULL_FLAGS(name, def, choices, EDJE_EXTERNAL_PARAM_FLAGS_REGULAR) +#define EDJE_EXTERNAL_PARAM_INFO_CHOICE_DYNAMIC_FULL(name, def_get, query) \ + EDJE_EXTERNAL_PARAM_INFO_CHOICE_DYNAMIC_FULL_FLAGS(name, def_get, query, EDJE_EXTERNAL_PARAM_FLAGS_REGULAR) + +#define EDJE_EXTERNAL_PARAM_INFO_INT_DEFAULT(name, def) \ + EDJE_EXTERNAL_PARAM_INFO_INT_FULL(name, def, EDJE_EXTERNAL_INT_UNSET, EDJE_EXTERNAL_INT_UNSET, EDJE_EXTERNAL_INT_UNSET) +#define EDJE_EXTERNAL_PARAM_INFO_DOUBLE_DEFAULT(name, def) \ + EDJE_EXTERNAL_PARAM_INFO_DOUBLE_FULL(name, def, EDJE_EXTERNAL_DOUBLE_UNSET, EDJE_EXTERNAL_DOUBLE_UNSET, EDJE_EXTERNAL_DOUBLE_UNSET) +#define EDJE_EXTERNAL_PARAM_INFO_STRING_DEFAULT(name, def) \ + EDJE_EXTERNAL_PARAM_INFO_STRING_FULL(name, def, NULL, NULL) +#define EDJE_EXTERNAL_PARAM_INFO_BOOL_DEFAULT(name, def) \ + EDJE_EXTERNAL_PARAM_INFO_BOOL_FULL(name, def, "false", "true") + +#define EDJE_EXTERNAL_PARAM_INFO_INT_DEFAULT_FLAGS(name, def, flags) \ + EDJE_EXTERNAL_PARAM_INFO_INT_FULL_FLAGS(name, def, EDJE_EXTERNAL_INT_UNSET, EDJE_EXTERNAL_INT_UNSET, EDJE_EXTERNAL_INT_UNSET, flags) +#define EDJE_EXTERNAL_PARAM_INFO_DOUBLE_DEFAULT_FLAGS(name, def, flags) \ + EDJE_EXTERNAL_PARAM_INFO_DOUBLE_FULL_FLAGS(name, def, EDJE_EXTERNAL_DOUBLE_UNSET, EDJE_EXTERNAL_DOUBLE_UNSET, EDJE_EXTERNAL_DOUBLE_UNSET, flags) +#define EDJE_EXTERNAL_PARAM_INFO_STRING_DEFAULT_FLAGS(name, def, flags) \ + EDJE_EXTERNAL_PARAM_INFO_STRING_FULL_FLAGS(name, def, NULL, NULL, flags) +#define EDJE_EXTERNAL_PARAM_INFO_BOOL_DEFAULT_FLAGS(name, def, flags) \ + EDJE_EXTERNAL_PARAM_INFO_BOOL_FULL_FLAGS(name, def, "false", "true", flags) + +#define EDJE_EXTERNAL_PARAM_INFO_INT(name) \ + EDJE_EXTERNAL_PARAM_INFO_INT_DEFAULT(name, 0) +#define EDJE_EXTERNAL_PARAM_INFO_DOUBLE(name) \ + EDJE_EXTERNAL_PARAM_INFO_DOUBLE_DEFAULT(name, 0.0) +#define EDJE_EXTERNAL_PARAM_INFO_STRING(name) \ + EDJE_EXTERNAL_PARAM_INFO_STRING_DEFAULT(name, NULL) +#define EDJE_EXTERNAL_PARAM_INFO_BOOL(name) \ + EDJE_EXTERNAL_PARAM_INFO_BOOL_DEFAULT(name, 0) + +#define EDJE_EXTERNAL_PARAM_INFO_INT_FLAGS(name, flags) \ + EDJE_EXTERNAL_PARAM_INFO_INT_DEFAULT_FLAGS(name, 0, flags) +#define EDJE_EXTERNAL_PARAM_INFO_DOUBLE_FLAGS(name, flags) \ + EDJE_EXTERNAL_PARAM_INFO_DOUBLE_DEFAULT_FLAGS(name, 0.0, flags) +#define EDJE_EXTERNAL_PARAM_INFO_STRING_FLAGS(name, flags) \ + EDJE_EXTERNAL_PARAM_INFO_STRING_DEFAULT_FLAGS(name, NULL, flags) +#define EDJE_EXTERNAL_PARAM_INFO_BOOL_FLAGS(name, flags) \ + EDJE_EXTERNAL_PARAM_INFO_BOOL_DEFAULT_FLAGS(name, 0, flags) + +#define EDJE_EXTERNAL_PARAM_INFO_SENTINEL {NULL, 0, 0, {.s = {NULL, NULL, NULL}}} + +/** + * @struct _Edje_External_Type + * + * @brief Information about an external type to be used. + * + * This structure provides information on how to display and modify a + * third party Evas_Object in Edje. + * + * Some function pointers are not really used by Edje, but provide + * means for Edje users to better interact with such objects. For + * instance, an editor may use label_get() and icon_get() to list all + * registered external types. + * + * @note The function pointers provided in this structure must check + * for errors and invalid or out-of-range values as for + * performance reasons Edje will not enforce hints provided as + * #Edje_External_Param_Info in the member parameters_info. + */ +struct _Edje_External_Type +{ +#define EDJE_EXTERNAL_TYPE_ABI_VERSION (3) + unsigned int abi_version; /**< always use: + * - #EDJE_EXTERNAL_TYPE_ABI_VERSION to declare. + * - edje_external_type_abi_version_get() to check. + */ + const char *module; /**< Name of the module that holds these definitions, + as used in the externals {} block of a theme + definition. */ + const char *module_name; /**< Canonical name of the module, for displaying + in edition programs, for example. */ + 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 + the object here. */ + 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. */ + 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) */ + 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 */ + 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!) */ + 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!) */ + 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() */ + void (*params_free) (void *params); /**< Free parameters parsed with params_parse() */ + + /* The following callbacks aren't used by Edje itself, but by UI design + tools instead */ + const char *(*label_get) (void *data); /**< Get a label to use to identify this EXTERNAL. (For editors) */ + const char *(*description_get) (void *data); /**< Get a user friendly description of this EXTERNAL. (For editors) */ + Evas_Object *(*icon_add) (void *data, Evas *e); /**< Get an icon to use to identify this EXTERNAL. (For editors) */ + Evas_Object *(*preview_add) (void *data, Evas *e); /**< Get a preview of the EXTERNAL object in use. (For editors) */ + 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) */ + + 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. */ + void *data; /**< Private user data that will be passed to all of the class functions. */ +}; +typedef struct _Edje_External_Type Edje_External_Type; + +/** + * Convenience struct used to mass-register types of EXTERNAL objects. + * + * Used with edje_external_type_array_register(). + */ +struct _Edje_External_Type_Info +{ + const char *name; /**< The name of the type to register. */ + const Edje_External_Type *info; /**< The type definition. */ +}; +typedef struct _Edje_External_Type_Info Edje_External_Type_Info; + +typedef 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. */ +typedef void (*Edje_Text_Change_Cb) (void *data, Evas_Object *obj, const char *part); +typedef 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. */ +typedef void (*Edje_Text_Filter_Cb) (void *data, Evas_Object *obj, const char *part, Edje_Text_Filter_Type type, char **text); +typedef Evas_Object *(*Edje_Item_Provider_Cb) (void *data, Evas_Object *obj, const char *part, const char *item); + +/** + * @brief Initialize the Edje library. + * + * @return The new init count. The initial value is zero. + * + * This function initializes the Ejde library, making the proper calls + * to internal initialization functions. It will also initialize its + * @b dependencies, making calls to @c eina_init(), @c ecore_init(), + * @c embryo_init() and @c eet_init(). So, there is no need to call + * those functions again, in your code. To shutdown Edje there is the + * function edje_shutdown(). + * + * @see edje_shutdown() + * @see eina_init() + * @see ecore_init() + * @see embryo_init() + * @see eet_init() + * + */ +EAPI int edje_init (void); + +/** + * @brief Shutdown the Edje library. + * + * @return The number of times the library has been initialised + * without being shutdown. + * + * This function shuts down the Edje library. It will also call the + * shutdown functions of its @b dependencies, which are @c + * eina_shutdown(), @c ecore_shutdown(), @c embryo_shutdown() and @c + * eet_shutdown(), so there is no need to call these functions again, + * in your code. + * + * @see edje_init() + * @see eina_shutdown() + * @see ecore_shutdown() + * @see embryo_shutdown() + * @see eet_shutdown() + * + */ +EAPI int edje_shutdown (void); + +/** + * @brief Set edje trasitions' frame time. + * + * @param t The frame time, in seconds. Default value is 1/30. + * + * This function sets the edje built-in animations' frame time (thus, + * affecting their resolution) by calling + * ecore_animator_frametime_set(). This frame time can be retrieved + * with edje_frametime_get(). + * + * @see edje_frametime_get() + * + */ +EAPI void edje_frametime_set (double t); + +/** + * @brief Get edje trasitions' frame time. + * + * @return The frame time, in seconds. + * + * This function returns the edje frame time set by + * edje_frametime_set() or the default value 1/30. + * + * @see edje_frametime_set() + * + */ +EAPI double edje_frametime_get (void); + +/** + * @brief Freeze Edje objects. + * + * This function freezes all Edje animations in the current process. + * + * @note: for freeze a specific object @see edje_object_freeze(). + * + * @see edje_thaw() + * + */ +EAPI void edje_freeze (void); + +/** + * @brief Thaw Edje objects. + * + * This function thaws all Edje animations in the current process. + * + * @note for thaw a specific object @see edje_object_thaw(). + * + * @see edje_freeze() + * + */ +EAPI void edje_thaw (void); + +/** + * @brief Set the edje append fontset. + * + * @param fonts The fontset to append. + * + * This function sets the edje append fontset. + * + */ +EAPI void edje_fontset_append_set (const char *fonts); + +/** + * @brief Get the edje append fontset. + * + * @return The edje append fontset. + * + * This function returns the edje append fontset set by + * edje_fontset_append_set() function. + * + * @see edje_fontset_append_set(). + * + */ +EAPI const char *edje_fontset_append_get (void); + +/** + * @brief Set Edje's global scaling factor. + * + * @param scale The global scaling factor (the default value is @c 1.0) + * + * Edje allows one to build scalable interfaces. Scaling factors, + * which are set to neutral (@c 1.0) values by default (no scaling, + * actual sizes), are of two types: @b global and @b individual. + * Edje's global scaling factor will affect all its objects which + * hadn't their individual scaling factors altered from the default + * value (which is zero). If they had it set differently, by + * edje_object_scale_set(), that factor will @b override the global + * one. + * + * Scaling affects the values of mininum/maximum @b part sizes, which + * are @b multiplied by it. Font sizes are scaled, too. + * + * @warning Only parts which, at EDC level, had the @c "scale" + * property set to @c 1, will be affected by this function. Check the + * complete @ref edcref "syntax reference" for EDC files. + * + * @see edje_scale_get(). + */ +EAPI void edje_scale_set (double scale); + +/** + * @brief Retrieve Edje's global scaling factor. + * + * @return The global scaling factor + * + * This function returns Edje's global scaling factor. + * + * @see edje_scale_set() for more details + * + */ +EAPI double edje_scale_get (void); + +/** + * @brief Show last character in password mode. + * + * @param password_show_last If TRUE enable last character show in password mode. + * + * This function enables last input to be visible when in password mode for few seconds + * or until the next input is entered. + * + * The time out value is obtained by edje_password_show_last_timeout_set function. + * + * @see edje_password_show_last_timeout_set(). + */ +EAPI void edje_password_show_last_set(Eina_Bool password_show_last); + +/** + * @brief Set's the timeout value in last show password mode. + * + * @param password_show_last_timeout The timeout value. + * + * This functions sets the time out value for which the last input entered in password + * mode will be visible. + * + * This value can be used only when last show mode is set in password mode. + * + * @see edje_password_show_last_set(). + * + */ +EAPI void edje_password_show_last_timeout_set(double password_show_last_timeout); + +/** + * @brief Set the scaling factor for a given Edje object. + * + * @param obj A handle to an Edje object + * @param scale The scaling factor (the default value is @c 0.0, + * meaning indivinual scaling @b not set) + * + * This function sets an @b individual scaling factor on the @a obj + * Edje object. This property (or Edje's global scaling factor, when + * applicable), will affect this object's part sizes. If @p scale is + * not zero, than the individual scaling will @b override any global + * scaling set, for the object @p obj's parts. Put it back to zero to + * get the effects of the global scaling again. + * + * @warning Only parts which, at EDC level, had the @c "scale" + * property set to @c 1, will be affected by this function. Check the + * complete @ref edcref "syntax reference" for EDC files. + * + * @see edje_object_scale_get() + * @see edje_scale_get() for more details + */ +EAPI Eina_Bool edje_object_scale_set (Evas_Object *obj, double scale); + +/** + * @brief Get a given Edje object's scaling factor. + * + * @param obj A handle to an Edje object + * + * This function returns the @c individual scaling factor set on the + * @a obj Edje object. + * + * @see edje_object_scale_set() for more details + * + */ +EAPI double edje_object_scale_get (const Evas_Object *obj); + +/** + * @brief Set the RTL orientation for this object. + * + * @param obj A handle to an Edje object. + * @rtl new value of flag EINA_TRUE/EINA_FALSE + * @since 1.1.0 + */ +EAPI void edje_object_mirrored_set (Evas_Object *obj, Eina_Bool rtl); + +/** + * @brief Get the RTL orientation for this object. + * + * You can RTL orientation explicitly with edje_object_mirrored_set. + * + * @param obj A handle to an Edje object. + * @return @c EINA_TRUE if the flag is set or @c EINA_FALSE if not. + * @since 1.1.0 + */ +EAPI Eina_Bool edje_object_mirrored_get (const Evas_Object *obj); + +/** + * Get a list of groups in an edje file + * @param file The path to the edje file + * + * @return The Eina_List of group names (char *) + * + * Note: the list must be freed using edje_file_collection_list_free() + * when you are done with it. + */ +EAPI Eina_List *edje_file_collection_list (const char *file); + +/** + * Free file collection list + * @param lst The Eina_List of groups + * + * Frees the list returned by edje_file_collection_list(). + */ +EAPI void edje_file_collection_list_free (Eina_List *lst); + +/** + * Determine whether a group matching glob exists in an edje file. + * @param file The file path + * @param glob A glob to match on + * + * @return 1 if a match is found, 0 otherwise + */ +EAPI Eina_Bool edje_file_group_exists (const char *file, const char *glob); + +/** + * Get data from the file level data block of an edje file + * @param file The path to the .edj file + * @param key The data key + * @return The string value of the data. Must be freed by the user when no + * longer needed. + * + * If an edje file is built from the following edc: + * + * data { + * item: "key1" "value1"; + * item: "key2" "value2"; + * } + * collections { ... } + * + * Then, edje_file_data_get("key1") will return "value1" + */ +EAPI char *edje_file_data_get (const char *file, const char *key); + +/** + * @brief Set the file cache size. + * + * @param count The file cache size in edje file units. Default is 16. + * + * This function sets the file cache size. Edje keeps this cache in + * order to prevent duplicates of edje file entries in memory. The + * file cache size can be retrieved with edje_file_cache_get(). + * + * @see edje_file_cache_get() + * @see edje_file_cache_flush() + * + */ +EAPI void edje_file_cache_set (int count); + +/** + * @brief Return the file cache size. + * + * @return The file cache size in edje file units. Default is 16. + * + * This function returns the file cache size set by + * edje_file_cache_set(). + * + * @see edje_file_cache_set() + * @see edje_file_cache_flush() + * + */ +EAPI int edje_file_cache_get (void); + +/** + * @brief Clean the file cache. + * + * This function cleans the file cache entries, but keeps this cache's + * size to the last value set. + * + * @see edje_file_cache_set() + * @see edje_file_cache_get() + * + */ +EAPI void edje_file_cache_flush (void); + +/** + * @brief Set the collection cache size. + * + * @param count The collection cache size, in edje object units. Default is 16. + * + * This function sets the collection cache size. Edje keeps this cache + * in order to prevent duplicates of edje {collection,group,part} + * entries in memory. The collection cache size can be retrieved with + * edje_collection_cache_get(). + * + * @see edje_collection_cache_get() + * @see edje_collection_cache_flush() + * + */ +EAPI void edje_collection_cache_set (int count); + +/** + * @brief Return the collection cache size. + * + * @return The collection cache size, in edje object units. Default is 16. + * + * This function returns the collection cache size set by + * edje_collection_cache_set(). + * + * @see edje_collection_cache_set() + * @see edje_collection_cache_flush() + * + */ +EAPI int edje_collection_cache_get (void); + +/** + * @brief Clean the collection cache. + * + * This function cleans the collection cache, but keeps this cache's + * size to the last value set. + * + * @see edje_collection_cache_set() + * @see edje_collection_cache_get() + * + */ +EAPI void edje_collection_cache_flush (void); + +/** + * @brief Set Edje color class. + * + * @param color_class + * @param r Object Red value + * @param g Object Green value + * @param b Object Blue value + * @param a Object Alpha value + * @param r2 Outline Red value + * @param g2 Outline Green value + * @param b2 Outline Blue value + * @param a2 Outline Alpha value + * @param r3 Shadow Red value + * @param g3 Shadow Green value + * @param b3 Shadow Blue value + * @param a3 Shadow Alpha value + * + * This function sets the color values for a process level color + * class. This will cause all edje parts in the current process that + * have the specified color class to have their colors multiplied by + * these values. (Object level color classes set by + * edje_object_color_class_set() will override the values set by this + * function). + * + * The first color is the object, the second is the text outline, and + * the third is the text shadow. (Note that the second two only apply + * to text parts). + * + * Setting color emits a signal "color_class,set" with source being + * the given color class in all objects. + * + * @see edje_color_class_set(). + * + * @note unlike Evas, Edje colors are @b not pre-multiplied. That is, + * half-transparent white is 255 255 255 128. + */ +EAPI 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); + +/** + * @brief Get Edje color class. + * + * @param color_class + * @param r Object Red value + * @param g Object Green value + * @param b Object Blue value + * @param a Object Alpha value + * @param r2 Outline Red value + * @param g2 Outline Green value + * @param b2 Outline Blue value + * @param a2 Outline Alpha value + * @param r3 Shadow Red value + * @param g3 Shadow Green value + * @param b3 Shadow Blue value + * @param a3 Shadow Alpha value + * + * @return EINA_TRUE if found or EINA_FALSE if not found and all + * values are zeroed. + * + * This function gets the color values for a process level color + * class. This value is the globally set and not per-object, that is, + * the value that would be used by objects if they did not override with + * edje_object_color_class_set(). + * + * The first color is the object, the second is the text outline, and + * the third is the text shadow. (Note that the second two only apply + * to text parts). + * + * @see edje_color_class_set(). + * + * @note unlike Evas, Edje colors are @b not pre-multiplied. That is, + * half-transparent white is 255 255 255 128. + */ +EAPI 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); + +/** + * @brief Delete edje color class. + * + * @param color_class + * + * This function deletes any values at the process level for the + * specified color class. + * @note Deleting the color class will revert it to the + * values defined in the theme file. + * + * Deleting the color class will emit the signal "color_class,del" + * to all the Edje objects in the running program. + */ +EAPI void edje_color_class_del (const char *color_class); + +/** + * @brief Lists color classes. + * + * @return A list of color class names (strings). These strings and + * the list must be free()'d by the caller. + * + * This function lists all color classes known about by the current + * process. + * + */ +EAPI Eina_List *edje_color_class_list (void); + +/** + * @brief Set the Edje text class. + * + * @param text_class The text class name + * @param font The font name + * @param size The font size + * + * @return @c EINA_TRUE, on success or @c EINA_FALSE, on error + * + * This function updates all Edje members at the process level which + * belong to this text class with the new font attributes. + * + * @see edje_text_class_get(). + * + */ +EAPI Eina_Bool edje_text_class_set (const char *text_class, const char *font, Evas_Font_Size size); + +/** + * @brief Delete the text class. + * + * @param text_class The text class name string + * + * This function deletes any values at the process level for the + * specified text class. + * + */ +EAPI void edje_text_class_del (const char *text_class); + +/** + * @brief List text classes. + * + * @return A list of text class names (strings). These strings are + * stringshares and the list must be free()'d by the caller. + * + * This function lists all text classes known about by the current + * process. + * + */ +EAPI Eina_List *edje_text_class_list (void); + +/** + * @brief Set the object minimum size. + * + * @param obj A valid Evas_Object handle + * @param minw The minimum width + * @param minh The minimum height + * + * This sets the minimum size restriction for the object. + */ +EAPI void edje_extern_object_min_size_set (Evas_Object *obj, Evas_Coord minw, Evas_Coord minh); + +/** + * @brief Set the object maximum size. + * + * @param obj A valid Evas_Object handle + * @param maxw The maximum width + * @param maxh The maximum height + * + * This sets the maximum size restriction for the object. + */ +EAPI void edje_extern_object_max_size_set (Evas_Object *obj, Evas_Coord maxw, Evas_Coord maxh); + +/** + * @brief Set the object aspect size. + * + * @param obj A valid Evas_Object handle + * @param aspect The aspect control axes + * @param aw The aspect radio width + * @param ah The aspect ratio height + * + * This sets the desired aspect ratio to keep an object that will be + * swallowed by Edje. The width and height define a preferred size + * ASPECT and the object may be scaled to be larger or smaller, but + * retaining the relative scale of both aspect width and height. + */ +EAPI void edje_extern_object_aspect_set (Evas_Object *obj, Edje_Aspect_Control aspect, Evas_Coord aw, Evas_Coord ah); + +/** + * @brief Registers a custom layout to be used in edje boxes. + * + * @param name The name of the layout + * @param func The function defining the layout + * @param layout_data_get This function gets the custom data pointer + * for func + * @param layout_data_free Passed to func to free its private data + * when needed + * @param free_data Frees data + * @param data Private pointer passed to layout_data_get + * + * This function registers custom layouts that can be referred from + * themes by the registered name. The Evas_Object_Box_Layout + * functions receive two pointers for internal use, one being private + * data, and the other the function to free that data when it's not + * longer needed. From Edje, this private data will be retrieved by + * calling layout_data_get, and layout_data_free will be the free + * function passed to func. layout_data_get will be called with data + * as its parameter, and this one will be freed by free_data whenever + * the layout is unregistered from Edje. + */ +EAPI 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); + +/** + * @brief Instantiate a new Edje object + * + * @param evas A valid Evas handle, the canvas to place the new object + * in + * @return A handle to the new object created or @c NULL, on errors. + * + * This function creates a new Edje smart object, returning its @c + * Evas_Object handle. An Edje object is useless without a (source) + * file set to it, so you'd most probably call edje_object_file_set() + * afterwards, like in: + * @code + * Evas_Object *edje; + * + * edje = edje_object_add(canvas); + * if (!edje) + * { + * fprintf(stderr, "could not create edje object!\n"); + * return NULL; + * } + * + * if (!edje_object_file_set(edje, "theme.edj", "group_name")) + * { + * int err = edje_object_load_error_get(edje); + * const char *errmsg = edje_load_error_str(err); + * fprintf(stderr, "could not load 'group_name' from theme.edj: %s", + * errmsg); + * + * evas_object_del(edje); + * return NULL; + * } + * + * @endcode + * + * @note before creating the first Edje object in your code, remember + * to initialize the library, with edje_init(), or unexpected behavior + * might occur. + */ +EAPI Evas_Object *edje_object_add (Evas *evas); + +/** + * @brief Retrive an EDC data field's value from a given Edje + * object's group. + * + * @param obj A handle to an Edje object + * @param key The data field's key string + * @return The data's value string. Must not be freed. + * + * This function fetches an EDC data field's value, which is declared + * on the objects building EDC file, under its group. EDC data + * blocks are most commonly used to pass arbitrary parameters from an + * application's theme to its code. + * + * They look like the following: + * + * @code + * collections { + * group { + * name: "a_group"; + * data { + * item: "key1" "value1"; + * item: "key2" "value2"; + * } + * } + * } + * @endcode + * + * EDC data fields always hold @b strings as values, hence the return + * type of this function. Check the complete @ref edcref "syntax reference" + * for EDC files. + * + * @warning Do not confuse this call with edje_file_data_get(), which + * queries for a @b global EDC data field on an EDC declaration file. + * + * @see edje_object_file_set() + */ +EAPI const char *edje_object_data_get (const Evas_Object *obj, const char *key); + +/** + * @brief Sets the @b EDJ file (and group within it) to load an Edje + * object's contents from + * + * @param obj A handle to an Edje object + * @param file The path to the EDJ file to load @p from + * @param group The name of the group, in @p file, which implements an + * Edje object + * @return @c EINA_TRUE, on success or @c EINA_FALSE, on errors (check + * edje_object_load_error_get() after this call to get errors causes) + * + * Edje expects EDJ files, which are theming objects' descriptions and + * resources packed together in an EET file, to read Edje object + * definitions from. They usually are created with the @c .edj + * extension. EDJ files, in turn, are assembled from @b textual object + * description files, where one describes Edje objects declaratively + * -- the EDC files (see @ref edcref "the syntax" for those files). + * + * Those description files were designed so that many Edje object + * definitions -- also called @b groups (or collections) -- could be + * packed together in the same EDJ file, so that a whole + * application's theme could be packed in one file only. This is the + * reason for the @p group argument. + * + * Use this function after you instantiate a new Edje object, so that + * you can "give him life", telling where to get its contents from. + * + * @see edje_object_add() + * @see edje_object_file_get() + */ +EAPI Eina_Bool edje_object_file_set (Evas_Object *obj, const char *file, const char *group); + +/** + * @brief Get the file and group name that a given Edje object is bound to + * + * @param obj A handle to an Edje object + * @param file A pointer to a variable whero to store the file's + * path + * @param group A pointer to a variable where to store the group + * name in + * + * This gets the EDJ file's path, with the respective group set for + * the given Edje object. If @a obj is either not an Edje file, or has + * not had its file/group set previously, by edje_object_file_set(), + * then both @p file and @p group will be set to @c NULL, indicating + * an error. + * + * @see edje_object_file_set() + * + * @note Use @c NULL pointers on the file/group components you're not + * interested in: they'll be ignored by the function. + */ +EAPI void edje_object_file_get (const Evas_Object *obj, const char **file, const char **group); + +/** + * @brief Gets the (last) file loading error for a given Edje object + * + * @param obj A handlet to an Edje object + * + * @return The Edje loading error, one of: + * - #EDJE_LOAD_ERROR_NONE + * - #EDJE_LOAD_ERROR_GENERIC + * - #EDJE_LOAD_ERROR_DOES_NOT_EXIST + * - #EDJE_LOAD_ERROR_PERMISSION_DENIED + * - #EDJE_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED + * - #EDJE_LOAD_ERROR_CORRUPT_FILE + * - #EDJE_LOAD_ERROR_UNKNOWN_FORMAT + * - #EDJE_LOAD_ERROR_INCOMPATIBLE_FILE + * - #EDJE_LOAD_ERROR_UNKNOWN_COLLECTION + * - #EDJE_LOAD_ERROR_RECURSIVE_REFERENCE + * + * This function is meant to be used after an Edje EDJ file + * loading, what takes place with the edje_object_file_set() + * function. If that function does not return @c EINA_TRUE, one should + * check for the reason of failure with this one. + * + * @see edje_load_error_str() + */ +EAPI Edje_Load_Error edje_object_load_error_get (const Evas_Object *obj); + +/** + * Converts the given Edje file load error code into a string + * describing it in English. + * + * @param error the error code, a value in ::Edje_Load_Error. + * @return Always returns a valid string. If the given @p error is not + * supported, "Unknown error" is returned. + * + * edje_object_file_set() is a function which sets an error value, + * afterwards, which can be fetched with + * edje_object_load_error_get(). The function in question is meant + * to be used in conjunction with the latter, for pretty-printing any + * possible error cause. + */ +EAPI const char *edje_load_error_str (Edje_Load_Error error); + +/** + * @brief Preload the images on the Edje Object in the background. + * + * @param obj A handle to an Edje object + * @param cancel @c EINA_FALSE will add it the preloading work queue, + * @c EINA_TRUE will remove it (if it was issued before). + * @return @c EINA_FASLE if obj was not a valid Edje object + * otherwise @c EINA_TRUE + * + * This function requests the preload of all data images (on the given + * object) in the background. The work is queued before being processed + * (because there might be other pending requests of this type). + * It emits a signal "preload,done" when finished. + * + * @note Use @c EINA_TRUE on scenarios where you don't need + * the image data preloaded anymore. + */ +EAPI Eina_Bool edje_object_preload (Evas_Object *obj, Eina_Bool cancel); + +/** + * @brief Add a callback for an arriving Edje signal, emitted by + * a given Ejde object. + * + * @param obj A handle to an Edje object + * @param emission The signal's "emission" string + * @param source The signal's "source" string + * @param func The callback function to be executed when the signal is + * emitted. + * @param data A pointer to data to pass in to @p func. + * + * Edje signals are one of the communication interfaces between + * @b code and a given Edje object's @b theme. With signals, one can + * communicate two string values at a time, which are: + * - "emission" value: the name of the signal, in general + * - "source" value: a name for the signal's context, in general + * + * Though there are those common uses for the two strings, one is free + * to use them however they like. + * + * This function adds a callback function to a signal emitted by @a obj, to + * be issued every time an EDC program like the following + * @code + * program { + * name: "emit_example"; + * action: SIGNAL_EMIT "a_signal" "a_source"; + * } + * @endcode + * is run, if @p emission and @p source are given those same values, + * here. + * + * Signal callback registration is powerful, in the way that @b blobs + * may be used to match multiple signals at once. All the @c + * "*?[\" set of @c fnmatch() operators can be used, both for @p + * emission and @p source. + * + * Edje has @b internal signals it will emit, automatically, on + * various actions taking place on group parts. For example, the mouse + * cursor being moved, pressed, released, etc., over a given part's + * area, all generate individual signals. + * + * By using something like + * @code + * edje_object_signal_callback_add(obj, "mouse,down,*", "button.*", + * signal_cb, NULL); + * @endcode + * being @c "button.*" the pattern for the names of parts implementing + * buttons on an interface, you'd be registering for notifications on + * events of mouse buttons being pressed down on either of those parts + * (those events all have the @c "mouse,down," common prefix on their + * names, with a suffix giving the button number). The actual emisson + * and source strings of an event will be passed in as the @a emission + * and @a source parameters of the callback function (e.g. @c + * "mouse,down,2" and @c "button.close"), for each of those events. + * + * @note See @ref edcref "the syntax" for EDC files + * @see edje_object_signal_emit() on how to emits Edje signals from + * code to a an object + * @see edje_object_signal_callback_del_full() + */ +EAPI void edje_object_signal_callback_add (Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func, void *data); + +/** + * @brief Remove a signal-triggered callback from an object. + * + * @param obj A valid Evas_Object handle. + * @param emission The emission string. + * @param source The source string. + * @param func The callback function. + * @return The data pointer + * + * This function removes a callback, previously attached to the + * emittion of a signal, from the object @a obj. The parameters @a + * emission, @a source and @a func must match exactly those passed to + * a previous call to edje_object_signal_callback_add(). The data + * pointer that was passed to this call will be returned. + * + * @see edje_object_signal_callback_add(). + * @see edje_object_signal_callback_del_full(). + * + */ +EAPI void *edje_object_signal_callback_del (Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func); + +/** + * @brief Unregister/delete a callback set for an arriving Edje + * signal, emitted by a given Ejde object. + * + * @param obj A handle to an Edje object + * @param emission The signal's "emission" string + * @param source The signal's "source" string + * @param func The callback function passed on the callback's + * registration + * @param data The pointer given to be passed as data to @p func + * @return @p data, on success or @c NULL, on errors (or if @p data + * had this value) + * + * This function removes a callback, previously attached to the + * emittion of a signal, from the object @a obj. The parameters + * @a emission, @a source, @a func and @a data must match exactly those + * passed to a previous call to edje_object_signal_callback_add(). The + * data pointer that was passed to this call will be returned. + * + * @see edje_object_signal_callback_add(). + * @see edje_object_signal_callback_del(). + * + */ +EAPI void *edje_object_signal_callback_del_full(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func, void *data); + +/** + * @brief Send/emit an Edje signal to a given Edje object + * + * @param obj A handle to an Edje object + * @param emission The signal's "emission" string + * @param source The signal's "source" string + * + * This function sends a signal to the object @a obj. An Edje program, + * at @p obj's EDC specification level, can respond to a signal by + * having declared matching @c 'signal' and @c 'source' fields on its + * block (see @ref edcref "the syntax" for EDC files). + * + * As an example, + * @code + * edje_object_signal_emit(obj, "a_signal", ""); + * @endcode + * would trigger a program which had an EDC declaration block like + * @code + * program { + * name: "a_program"; + * signal: "a_signal"; + * source: ""; + * action: ... + * } + * @endcode + * + * @see edje_object_signal_callback_add() for more on Edje signals. + */ +EAPI void edje_object_signal_emit (Evas_Object *obj, const char *emission, const char *source); + +/** + * @brief Get extra data passed to callbacks. + * + * @return the extra data for that callback. + * + * Some callbacks pass extra information. This function gives access to that + * extra information. It's somehow like event_info in smart callbacks. + * + * @see edje_object_signal_callback_add() for more on Edje signals. + * @since 1.1.0 + */ +EAPI void * edje_object_signal_callback_extra_data_get(void); + +/** + * @brief Set the Edje object to playing or paused states. + * + * @param obj A handle to an Edje object. + * @param play Object state (@c EINA_TRUE to playing, + * @c EINA_FALSE to paused). + * + * This function sets the Edje object @a obj to playing or paused + * states, depending on the parameter @a play. This has no effect if + * the object was already at that state. + * + * @see edje_object_play_get(). + * + */ +EAPI void edje_object_play_set (Evas_Object *obj, Eina_Bool play); + +/** + * @brief Get the Edje object's state. + * + * @param obj A handle to an Edje object. + * @return @c EINA_FALSE if the object is not connected, its @c delete_me flag + * is set, or it is at paused state; @c EINA_TRUE if the object is at playing + * state. + * + * This function tells if an Edje object is playing or not. This state + * is set by edje_object_play_set(). + * + * @see edje_object_play_set(). + * + */ +EAPI Eina_Bool edje_object_play_get (const Evas_Object *obj); + +/** + * @brief Set the object's animation state. + * + * @param obj A handle to an Edje object. + * @param on The animation state. @c EINA_TRUE to starts or + * @c EINA_FALSE to stops. + * + * This function starts or stops an Edje object's animation. The + * information if it's stopped can be retrieved by + * edje_object_animation_get(). + * + * @see edje_object_animation_get() + * + */ +EAPI void edje_object_animation_set (Evas_Object *obj, Eina_Bool on); + +/** + * @brief Get the Edje object's animation state. + * + * @param obj A handle to an Edje object. + * @return @c EINA_FALSE on error or if object is not animated; + * @c EINA_TRUE if animated. + * + * This function returns if the animation is stopped or not. The + * animation state is set by edje_object_animation_set(). + * + * @see edje_object_animation_set(). + * + */ +EAPI Eina_Bool edje_object_animation_get (const Evas_Object *obj); + +/** + * @brief Freezes the Edje object. + * + * @param obj A handle to an Edje object. + * @return The frozen state or 0 on Error + * + * This function puts all changes on hold. Successive freezes will + * nest, requiring an equal number of thaws. + * + * @see edje_object_thaw() + */ +EAPI int edje_object_freeze (Evas_Object *obj); + +/** + * @brief Thaws the Edje object. + * + * @param obj A handle to an Edje object. + * @return The frozen state or 0 if the object is not frozen or on error. + * + * This function thaws the given Edje object. + * + * @note: If sucessives freezes were done, an equal number of + * thaws will be required. + * + * @see edje_object_freeze() + */ +EAPI int edje_object_thaw (Evas_Object *obj); + +/** + * @brief Sets the object color class. + * + * @param obj A valid Evas_Object handle + * @param color_class + * @param r Object Red value + * @param g Object Green value + * @param b Object Blue value + * @param a Object Alpha value + * @param r2 Outline Red value + * @param g2 Outline Green value + * @param b2 Outline Blue value + * @param a2 Outline Alpha value + * @param r3 Shadow Red value + * @param g3 Shadow Green value + * @param b3 Shadow Blue value + * @param a3 Shadow Alpha value + * + * This function sets the color values for an object level color + * class. This will cause all edje parts in the specified object that + * have the specified color class to have their colors multiplied by + * these values. + * + * The first color is the object, the second is the text outline, and + * the third is the text shadow. (Note that the second two only apply + * to text parts). + * + * Setting color emits a signal "color_class,set" with source being + * the given color. + * + * @note unlike Evas, Edje colors are @b not pre-multiplied. That is, + * half-transparent white is 255 255 255 128. + */ +EAPI 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); + +/** + * @brief Gets the object color class. + * + * @param o A valid Evas_Object handle + * @param color_class + * @param r Object Red value + * @param g Object Green value + * @param b Object Blue value + * @param a Object Alpha value + * @param r2 Outline Red value + * @param g2 Outline Green value + * @param b2 Outline Blue value + * @param a2 Outline Alpha value + * @param r3 Shadow Red value + * @param g3 Shadow Green value + * @param b3 Shadow Blue value + * @param a3 Shadow Alpha value + * + * @return EINA_TRUE if found or EINA_FALSE if not found and all + * values are zeroed. + * + * This function gets the color values for an object level color + * class. If no explicit object color is set, then global values will + * be used. + * + * The first color is the object, the second is the text outline, and + * the third is the text shadow. (Note that the second two only apply + * to text parts). + * + * @note unlike Evas, Edje colors are @b not pre-multiplied. That is, + * half-transparent white is 255 255 255 128. + */ +EAPI 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); + +/** + * @brief Delete the object color class. + * + * @param obj The edje object's reference. + * @param color_class The color class to be deleted. + * + * This function deletes any values at the object level for the + * specified object and color class. + * @note Deleting the color class will revert it to the values + * defined by edje_color_class_set() or the color class + * defined in the theme file. + * + * Deleting the color class will emit the signal "color_class,del" + * for the given Edje object. + */ + EAPI void edje_object_color_class_del (Evas_Object *obj, const char *color_class); + +/** + * @brief Sets Edje text class. + * + * @param obj A valid Evas_Object handle + * @param text_class The text class name + * @param font Font name + * @param size Font Size + * + * @return @c EINA_TRUE, on success or @c EINA_FALSE, on error + * + * This function sets the text class for the Edje. + * + */ +EAPI Eina_Bool edje_object_text_class_set (Evas_Object *obj, const char *text_class, const char *font, Evas_Font_Size size); + +/** + * @brief Get the minimum size specified -- as an EDC property -- for a + * given Edje object + * + * @param obj A handle to an Edje object + * @param minw Pointer to a variable where to store the minimum width + * @param minh Pointer to a variable where to store the minimum height + * + * This function retrieves the @p obj object's minimum size values, + * as declared in its EDC group definition. Minimum size of + * groups have the following syntax + * @code + * collections { + * group { + * name: "a_group"; + * min: 100 100; + * } + * } + * @endcode + * + * where one declares a minimum size of 100 pixels both for width and + * height. Those are (hint) values which should be respected when the + * given object/group is to be controlled by a given container object + * (e.g. an Edje object being "swallowed" into a given @c SWALLOW + * typed part, as in edje_object_part_swallow()). Check the complete + * @ref edcref "syntax reference" for EDC files. + * + * @note If the @c min EDC property was not declared for @p obj, this + * call will return the value 0, for each axis. + * + * @note On failure, this function will make all non-@c NULL size + * pointers' pointed variables be set to zero. + * + * @see edje_object_size_max_get() + */ +EAPI void edje_object_size_min_get (const Evas_Object *obj, Evas_Coord *minw, Evas_Coord *minh); + +/** + * @brief Get the maximum size specified -- as an EDC property -- for a + * given Edje object + * + * @param obj A handle to an Edje object + * @param maxw Pointer to a variable where to store the maximum width + * @param maxh Pointer to a variable where to store the maximum height + * + * This function retrieves the @p obj object's maximum size values, + * as declared in its EDC group definition. Maximum size of + * groups have the following syntax + * @code + * collections { + * group { + * name: "a_group"; + * max: 100 100; + * } + * } + * @endcode + * + * where one declares a maximum size of 100 pixels both for width and + * height. Those are (hint) values which should be respected when the + * given object/group is to be controlled by a given container object + * (e.g. an Edje object being "swallowed" into a given @c SWALLOW + * typed part, as in edje_object_part_swallow()). Check the complete + * @ref edcref "syntax reference" for EDC files. + * + * @note If the @c max EDC property was not declared for @p obj, this + * call will return the maximum size a given Edje object may have, for + * each axis. + * + * @note On failure, this function will make all non-@c NULL size + * pointers' pointed variables be set to zero. + * + * @see edje_object_size_min_get() + */ +EAPI void edje_object_size_max_get (const Evas_Object *obj, Evas_Coord *maxw, Evas_Coord *maxh); + +/** + * @brief Force a Size/Geometry calculation. + * + * @param obj A valid Evas_Object handle + * + * Forces the object @p obj to recalculation layout regardless of + * freeze/thaw. + */ +EAPI void edje_object_calc_force (Evas_Object *obj); + +/** + * @brief Calculate the minimum required size for a given Edje object. + * + * @param obj A handle to an Edje object + * @param minw Pointer to a variable where to store the minimum + * required width + * @param minh Pointer to a variable where to store the minimum + * required height + * + * This call works exactly as edje_object_size_min_restricted_calc(), + * with the last two arguments set to 0. Please refer to its + * documentation, then. + */ +EAPI void edje_object_size_min_calc (Evas_Object *obj, Evas_Coord *minw, Evas_Coord *minh); + +/** + * Calculate the geometry of the region, relative to a given Edje + * object's area, occupied by all parts in the object + * + * @param obj A handle to an Edje object + * @param part The Edje part's name + * @param x A pointer to a variable where to store the parts region's + * x coordinate + * @param y A pointer to a variable where to store the parts region's + * y coordinate + * @param w A pointer to a variable where to store the parts region's + * width + * @param h A pointer to a variable where to store the parts region's + * height + * + * This function gets the geometry of the rectangle equal to the area + * required to group all parts in @p obj's group/collection. The @p x + * and @p y coordinates are relative to the top left corner of the + * whole @p obj object's area. Parts placed out of the group's + * boundaries will also be taken in account, so that @p x and @p y + * may be negative. + * + * @note Use @c NULL pointers on the geometry components you're not + * interested in: they'll be ignored by the function. + * + * @note On failure, this function will make all non-@c NULL geometry + * pointers' pointed variables be set to zero. + */ +EAPI Eina_Bool edje_object_parts_extends_calc (Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h); + +/** + * @brief Calculate the minimum required size for a given Edje object. + * + * @param obj A handle to an Edje object + * @param minw Pointer to a variable where to store the minimum + * required width + * @param minh Pointer to a variable where to store the minimum + * required height + * @param restrictedw Do not allow object's calculated (minimum) width + * to be less than this value + * @param restrictedh Do not allow object's calculated (minimum) + * height to be less than this value + * + * This call will trigger an internal recalculation of all parts of + * the @p obj object, in order to return its minimum required + * dimensions for width and height. The user might choose to @b impose + * those minimum sizes, making the resulting calculation to get to values + * equal or bigger than @p restrictedw and @p restrictedh, for width and + * height, respectively. + * + * @note At the end of this call, @p obj @b won't be automatically + * resized to new dimensions, but just return the calculated + * sizes. The caller is the one up to change its geometry or not. + * + * @warning Be advised that invisible parts in @p obj @b will be taken + * into account in this calculation. + */ +EAPI void edje_object_size_min_restricted_calc(Evas_Object *obj, Evas_Coord *minw, Evas_Coord *minh, Evas_Coord restrictedw, Evas_Coord restrictedh); + +/** + * @brief Check if an Edje part exists in a given Edje object's group + * definition.. + * + * @param obj A handle to an Edje object + * @param part The part's name to check for existence in @p obj's + * group + * @return @c EINA_TRUE, if the Edje part exists in @p obj's group or + * @c EINA_FALSE, otherwise (and on errors) + * + * This function returns if a given part exists in the Edje group + * bound to object @p obj (with edje_object_file_set()). + * + * This call is useful, for example, when one could expect or not a + * given GUI element, depending on the @b theme applied to @p obj. + */ +EAPI Eina_Bool edje_object_part_exists (const Evas_Object *obj, const char *part); + +/** + * @brief Get a handle to the Evas object implementing a given Edje + * part, in an Edje object. + * + * @param obj A handle to an Edje object + * @param part The Edje part's name + * @return A pointer to the Evas object implementing the given part, + * or @c NULL on failure (e.g. the given part doesn't exist) + * + * This function gets a pointer the Evas object corresponding to a + * given part in the @p obj object's group. + * + * You should @b never modify the state of the returned object (with + * @c evas_object_move() or @c evas_object_hide() for example), + * because it's meant to be managed be Edje, solely. You are safe to + * query information about its current state (with @c + * evas_object_visible_get() or @c evas_object_color_get() for + * example), though. + */ +EAPI const Evas_Object *edje_object_part_object_get (const Evas_Object *obj, const char *part); + +/** + * @brief Retrieve the geometry of a given Edje part, in a given Edje + * object's group definition, relative to the object's area + * + * @param obj A handle to an Edje object + * @param part The Edje part's name + * @param x A pointer to a variable where to store the part's x + * coordinate + * @param y A pointer to a variable where to store the part's y + * coordinate + * @param w A pointer to a variable where to store the part's width + * @param h A pointer to a variable where to store the part's height + * + * This function gets the geometry of an Edje part within its + * group. The @p x and @p y coordinates are relative to the top left + * corner of the whole @p obj object's area. + * + * @note Use @c NULL pointers on the geometry components you're not + * interested in: they'll be ignored by the function. + * + * @note On failure, this function will make all non-@c NULL geometry + * pointers' pointed variables be set to zero. + */ +EAPI 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); + + +/** + * @brief Set the function that provides item objects for named items in an edje entry text + * + * @param obj A valid Evas Object handle + * @param func The function to call (or NULL to disable) to get item objects + * @param data The data pointer to pass to the @p func callback + * + * Item objects may be deleted any time by Edje, and will be deleted when the + * Edje object is deleted (or file is set to a new file). + */ +EAPI void edje_object_item_provider_set (Evas_Object *obj, Edje_Item_Provider_Cb func, void *data); + + +/** + * @brief Set the object text callback. + * + * @param obj A valid Evas_Object handle + * @param func The callback function to handle the text change + * @param data The data associated to the callback function. + * + * This function sets the callback to be called when the text changes. + */ +EAPI void edje_object_text_change_cb_set (Evas_Object *obj, Edje_Text_Change_Cb func, void *data); + +/** + * @brief Sets the text for an object part + * + * @param obj A valid Evas Object handle + * @param part The part name + * @param text The text string + */ +EAPI Eina_Bool edje_object_part_text_set (Evas_Object *obj, const char *part, const char *text); + +/** + * @brief Return the text of the object part. + * + * @param obj A valid Evas_Object handle + * @param part The part name + * + * @return The text string + * + * This function returns the text associated to the object part. + * + * @see edje_object_part_text_set(). + */ +EAPI const char *edje_object_part_text_get (const Evas_Object *obj, const char *part); + +/** + * @brief Sets the raw (non escaped) text for an object part. + * + * @param obj A valid Evas Object handle + * @param part The part name + * @param text_to_escape The text string + * + * This funciton will not do escape for you if it is a TEXTBLOCK part, that is, + * if text contain tags, these tags will not be interpreted/parsed by TEXTBLOCK. + * + * @see edje_object_part_text_unescaped_get(). + */ +EAPI Eina_Bool edje_object_part_text_unescaped_set (Evas_Object *obj, const char *part, const char *text_to_escape); + +/** + * @brief Returns the text of the object part, without escaping. + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @return The @b allocated text string without escaping, or NULL on + * problems. + * + * This function is the counterpart of + * edje_object_part_text_unescaped_set(). Please notice that the + * result is newly allocated memory and should be released with free() + * when done. + * + * @see edje_object_part_text_unescaped_set(). + */ +EAPI char *edje_object_part_text_unescaped_get (const Evas_Object *obj, const char *part); + +/** + * @brief Return the selection text of the object part. + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @return The text string + * + * This function returns selection text of the object part. + * + * @see edje_object_part_text_select_all() + * @see edje_object_part_text_select_none() + */ +EAPI const char *edje_object_part_text_selection_get (const Evas_Object *obj, const char *part); + +/** + * @brief Set the selection to be none. + * + * @param obj A valid Evas_Object handle + * @param part The part name + * + * This function sets the selection text to be none. + */ +EAPI void edje_object_part_text_select_none (const Evas_Object *obj, const char *part); + +/** + * @brief Set the selection to be everything. + * + * @param obj A valid Evas_Object handle + * @param part The part name + * + * This function selects all text of the object of the part. + */ +EAPI void edje_object_part_text_select_all (const Evas_Object *obj, const char *part); + +/** + * @brief Insert text for an object part. + * + * @param obj A valid Evas Object handle + * @param part The part name + * @param text The text string + * + * This function inserts the text for an object part just before the + * cursor position. + * + */ +EAPI void edje_object_part_text_insert (Evas_Object *obj, const char *part, const char *text); + +/** + * @brief Insert text for an object part. + * + * @param obj A valid Evas Object handle + * @param part The part name + * @param text The text string + * + * This function inserts the text for an object part at the end; It does not + * move the cursor. + * + * @since 1.1 + */ +EAPI void edje_object_part_text_append(Evas_Object *obj, const char *part, const char *text); + +/** + * @brief Return a list of char anchor names. + * + * @param obj A valid Evas_Object handle + * @param part The part name + * + * @return The list of anchors (const char *), do not modify! + * + * This function returns a list of char anchor names. + * + */ +EAPI const Eina_List *edje_object_part_text_anchor_list_get (const Evas_Object *obj, const char *part); + +/** + * @brief Return a list of Evas_Textblock_Rectangle anchor rectangles. + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param anchor The anchor name + * + * @return The list of anchor rects (const Evas_Textblock_Rectangle + * *), do not modify! Geometry is relative to entry part. + * + * This function return a list of Evas_Textblock_Rectangle anchor + * rectangles. + * + */ +EAPI const Eina_List *edje_object_part_text_anchor_geometry_get (const Evas_Object *obj, const char *part, const char *anchor); + +/** + * @brief Return a list of char item names. + * + * @param obj A valid Evas_Object handle + * @param part The part name + * + * @return The list of items (const char *), do not modify! + * + * This function returns a list of char item names. + * + */ +EAPI const Eina_List *edje_object_part_text_item_list_get (const Evas_Object *obj, const char *part); + +/** + * @brief Return item geometry. + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param item The item name + * @param cx Item x return (relative to entry part) + * @param cy Item y return (relative to entry part) + * @param cw Item width return + * @param ch Item height return + * + * @return 1 if item exists, 0 if not + * + * This function return a list of Evas_Textblock_Rectangle item + * rectangles. + * + */ +EAPI 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); + +/** + * @brief Returns the cursor geometry of the part relative to the edje + * object. + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param x Cursor X position + * @param y Cursor Y position + * @param w Cursor width + * @param h Cursor height + * + */ +EAPI 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); + +/** + * @brief Enables selection if the entry is an EXPLICIT selection mode + * type. + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param allow EINA_TRUE to enable, EINA_FALSE otherwise + * + * The default is to @b not allow selection. This function only affects user + * selection, functions such as edje_object_part_text_select_all() and + * edje_object_part_text_select_none() are not affected. + */ +EAPI void edje_object_part_text_select_allow_set (const Evas_Object *obj, const char *part, Eina_Bool allow); + +/** + * @brief Aborts any selection action on a part. + * + * @param obj A valid Evas_Object handle + * @param part The part name + */ +EAPI void edje_object_part_text_select_abort (const Evas_Object *obj, const char *part); + +/** + * @brief Starts selecting at current cursor position + * + * @param obj A valid Evas_Object handle + * @param part The part name + */ +EAPI void edje_object_part_text_select_begin (const Evas_Object *obj, const char *part); + +/** + * @brief Extends the current selection to the current cursor position + * + * @param obj A valid Evas_Object handle + * @param part The part name + */ +EAPI void edje_object_part_text_select_extend (const Evas_Object *obj, const char *part); + + +/** + * @brief Advances the cursor to the next cursor position. + * @see evas_textblock_cursor_char_next + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param cur The edje cursor to advance + */ +EAPI Eina_Bool edje_object_part_text_cursor_next (Evas_Object *obj, const char *part, Edje_Cursor cur); + +/** + * @brief Moves the cursor to the previous char + * @see evas_textblock_cursor_char_prev + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param cur the edje cursor to work on + */ +EAPI Eina_Bool edje_object_part_text_cursor_prev (Evas_Object *obj, const char *part, Edje_Cursor cur); + +/** + * @brief Move the cursor to the char above the current cursor position. + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param cur the edje cursor to work on + */ +EAPI Eina_Bool edje_object_part_text_cursor_up (Evas_Object *obj, const char *part, Edje_Cursor cur); + +/** + * @brief Moves the cursor to the char below the current cursor position. + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param cur the edje cursor to work on + */ +EAPI Eina_Bool edje_object_part_text_cursor_down (Evas_Object *obj, const char *part, Edje_Cursor cur); + +/** + * @brief Moves the cursor to the beginning of the text part + * @see evas_textblock_cursor_paragraph_first + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param cur the edje cursor to work on + */ +EAPI void edje_object_part_text_cursor_begin_set (Evas_Object *obj, const char *part, Edje_Cursor cur); + +/** + * @brief Moves the cursor to the end of the text part. + * @see evas_textblock_cursor_paragraph_last + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param cur the edje cursor to work on + */ +EAPI void edje_object_part_text_cursor_end_set (Evas_Object *obj, const char *part, Edje_Cursor cur); + +/** + * @brief Copy the cursor to another cursor. + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param sry the cursor to copy from + * @param dst the cursor to copy to + */ +EAPI void edje_object_part_text_cursor_copy (Evas_Object *obj, const char *part, Edje_Cursor src, Edje_Cursor dst); + +/** + * @brief Move the cursor to the beginning of the line. + * @see evas_textblock_cursor_line_char_first + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param cur the edje cursor to work on + */ +EAPI void edje_object_part_text_cursor_line_begin_set (Evas_Object *obj, const char *part, Edje_Cursor cur); + +/** + * @brief Move the cursor to the end of the line. + * @see evas_textblock_cursor_line_char_last + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param cur the edje cursor to work on + */ +EAPI void edje_object_part_text_cursor_line_end_set (Evas_Object *obj, const char *part, Edje_Cursor cur); + +/** + * Position the given cursor to a X,Y position. + * + * This is frequently used with the user cursor. + * + * @param obj An Edje object. + * @param part The part containing the object. + * @param cur The cursor to adjust. + * @param x X Coordinate. + * @param y Y Coordinate. + * @return True on success, false on error. + */ +EAPI Eina_Bool edje_object_part_text_cursor_coord_set (Evas_Object *obj, const char *part, Edje_Cursor cur, Evas_Coord x, Evas_Coord y); + +/** + * @brief Returns whether the cursor points to a format. + * @see evas_textblock_cursor_is_format + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param cur The cursor to adjust. + * @return EINA_TRUE if it's true, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_object_part_text_cursor_is_format_get (const Evas_Object *obj, const char *part, Edje_Cursor cur); + +/** + * @brief Return true if the cursor points to a visible format + * For example \t, \n, item and etc. + * @see evas_textblock_cursor_format_is_visible_get + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param cur The cursor to adjust. + */ +EAPI Eina_Bool edje_object_part_text_cursor_is_visible_format_get(const Evas_Object *obj, const char *part, Edje_Cursor cur); + +/** + * @brief Returns the content (char) at the cursor position. + * @see evas_textblock_cursor_content_get + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param cur The cursor to use + */ +EAPI const char *edje_object_part_text_cursor_content_get (const Evas_Object *obj, const char *part, Edje_Cursor cur); + +/** + * @brief Sets the cursor position to the given value + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param cur The cursor to move + * @param pos the position of the cursor + * @since 1.1.0 + */ +EAPI void edje_object_part_text_cursor_pos_set (Evas_Object *obj, const char *part, Edje_Cursor cur, int pos); + +/** + * @brief Retrieves the current position of the cursor + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param cur The cursor to get the position + * @return The cursor position + * @since 1.1.0 + */ +EAPI int edje_object_part_text_cursor_pos_get (const Evas_Object *obj, const char *part, Edje_Cursor cur); + +/** + * @brief Set the layout of the input panel. + * + * The layout of the input panel or virtual keyboard can make it easier or + * harder to enter content. This allows you to hint what kind of input you + * are expecting to enter and thus have the input panel automatically + * come up with the right mode. + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param layout layout type + * @since 1.1 + */ +EAPI void edje_object_part_text_input_panel_layout_set (const Evas_Object *obj, const char *part, Edje_Input_Panel_Layout layout); + +/** + * @brief Get the layout of the input panel. + * + * @param obj A valid Evas_Object handle + * @param part The part name + * + * @return Layout type of the input panel + * + * @see edje_object_part_text_input_panel_layout_set + * @since 1.1 + */ +EAPI Edje_Input_Panel_Layout edje_object_part_text_input_panel_layout_get (const Evas_Object *obj, const char *part); + +/** + * @brief Set the autocapitalization type on the immodule. + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param autocapital_type The type of autocapitalization + * @since 1.1.0 + */ +EAPI void edje_object_part_text_autocapital_type_set (const Evas_Object *obj, const char *part, Edje_Text_Autocapital_Type autocapital_type); + +/** + * @brief Retrieves the autocapitalization type + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @return The autocapitalization type + * @since 1.1.0 + */ +EAPI Edje_Text_Autocapital_Type edje_object_part_text_autocapital_type_get (const Evas_Object *obj, const char *part); + +/** + * @brief Sets the attribute to show the input panel automatically. + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param enabled If true, the input panel is appeared when entry is clicked or has a focus + * @since 1.1.0 + */ +EAPI void edje_object_part_text_input_panel_enabled_set (const Evas_Object *obj, const char *part, Eina_Bool enabled); + +/** + * @brief Retrieve the attribute to show the input panel automatically. + * @see edje_object_part_text_input_panel_enabled_set + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @return EINA_TRUE if it supports or EINA_FALSE otherwise + * @since 1.1.0 + */ +EAPI Eina_Bool edje_object_part_text_input_panel_enabled_get (const Evas_Object *obj, const char *part); + +/** + * Add a filter function for newly inserted text. + * + * Whenever text is inserted (not the same as set) into the given @p part, + * the list of filter functions will be called to decide if and how the new + * text will be accepted. + * There are three types of filters, EDJE_TEXT_FILTER_TEXT, + * EDJE_TEXT_FILTER_FORMAT and EDJE_TEXT_FILTER_MARKUP. + * The text parameter in the @p func filter can be modified by the user and + * it's up to him to free the one passed if he's to change the pointer. If + * doing so, the newly set text should be malloc'ed, as once all the filters + * are called Edje will free it. + * If the text is to be rejected, freeing it and setting the pointer to NULL + * will make Edje break out of the filter cycle and reject the inserted + * text. + * + * @see edje_object_text_insert_filter_callback_del + * @see edje_object_text_insert_filter_callback_del_full + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param func The callback function that will act as filter + * @param data User provided data to pass to the filter function + */ +EAPI void edje_object_text_insert_filter_callback_add (Evas_Object *obj, const char *part, Edje_Text_Filter_Cb func, void *data); + +/** + * Delete a function from the filter list. + * + * Delete the given @p func filter from the list in @p part. Returns + * the user data pointer given when added. + * + * @see edje_object_text_insert_filter_callback_add + * @see edje_object_text_insert_filter_callback_del_full + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param func The function callback to remove + * + * @return The user data pointer if succesful, or NULL otherwise + */ +EAPI void *edje_object_text_insert_filter_callback_del (Evas_Object *obj, const char *part, Edje_Text_Filter_Cb func); + +/** + * Delete a function and matching user data from the filter list. + * + * Delete the given @p func filter and @p data user data from the list + * in @p part. + * Returns the user data pointer given when added. + * + * @see edje_object_text_insert_filter_callback_add + * @see edje_object_text_insert_filter_callback_del + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param func The function callback to remove + * @param data The data passed to the callback function + * + * @return The same data pointer if succesful, or NULL otherwise + */ +EAPI void *edje_object_text_insert_filter_callback_del_full (Evas_Object *obj, const char *part, Edje_Text_Filter_Cb func, void *data); + +/** + * @brief Swallows an object into the edje. + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param obj_swallow The object to swallow + * + * Swallows the object into the edje part so that all geometry changes + * for the part affect the swallowed object. (e.g. resize, move, show, + * raise/lower, etc.). + * + * If an object has already been swallowed into this part, then it + * will first be unswallowed before the new object is swallowed. + */ +EAPI Eina_Bool edje_object_part_swallow (Evas_Object *obj, const char *part, Evas_Object *obj_swallow); + +/** + * @brief Unswallow an object. + * + * @param obj A valid Evas_Object handle + * @param obj_swallow The swallowed object + * + * Causes the edje to regurgitate a previously swallowed object. :) + * + * @note @p obj_swallow will @b not be deleted. + */ +EAPI void edje_object_part_unswallow (Evas_Object *obj, Evas_Object *obj_swallow); + +/** + * @brief Get the object currently swallowed by a part. + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @return The swallowed object, or NULL if there is none. + */ +EAPI Evas_Object *edje_object_part_swallow_get (const Evas_Object *obj, const char *part); + +/** + * @brief Returns the state of the Edje part. + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param val_ret + * + * @return The part state:\n + * "default" for the default state\n + * "" for other states + */ +EAPI const char *edje_object_part_state_get (const Evas_Object *obj, const char *part, double *val_ret); + +/** + * @brief Determine dragable directions. + * + * @param obj A valid Evas_Object handle + * @param part The part name + * + * The dragable directions are defined in the EDC file, inside the @c dragable + * section, by the attributes @c x and @c y. See the @ref edcref for more + * information. + * + * @return #EDJE_DRAG_DIR_NONE: Not dragable\n + * #EDJE_DRAG_DIR_X: Dragable in X direction\n + * #EDJE_DRAG_DIR_Y: Dragable in Y direction\n + * #EDJE_DRAG_DIR_XY: Dragable in X & Y directions + */ +EAPI Edje_Drag_Dir edje_object_part_drag_dir_get (const Evas_Object *obj, const char *part); + +/** + * @brief Set the dragable object location. + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param dx The x value + * @param dy The y value + * + * Places the dragable object at the given location. + * + * Values for @p dx and @p dy are real numbers that range from 0 to 1, + * representing the relative position to the dragable area on that axis. + * + * This value means, for the vertical axis, that 0.0 will be at the top if the + * first parameter of @c y in the dragable part theme is 1, and at bottom if it + * is -1. + * + * For the horizontal axis, 0.0 means left if the first parameter of @c x in the + * dragable part theme is 1, and right if it is -1. + * + * @see edje_object_part_drag_value_get() + */ +EAPI Eina_Bool edje_object_part_drag_value_set (Evas_Object *obj, const char *part, double dx, double dy); + +/** + * @brief Get the dragable object location. + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param dx The X value pointer + * @param dy The Y value pointer + * + * Values for @p dx and @p dy are real numbers that range from 0 to 1, + * representing the relative position to the dragable area on that axis. + * + * @see edje_object_part_drag_value_set() + * + * Gets the drag location values. + */ +EAPI Eina_Bool edje_object_part_drag_value_get (const Evas_Object *obj, const char *part, double *dx, double *dy); + +/** + * @brief Set the dragable object size. + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param dw The drag width + * @param dh The drag height + * + * Values for @p dw and @p dh are real numbers that range from 0 to 1, + * representing the relative size of the dragable area on that axis. + * + * Sets the size of the dragable object. + * + * @see edje_object_part_drag_size_get() + */ +EAPI Eina_Bool edje_object_part_drag_size_set (Evas_Object *obj, const char *part, double dw, double dh); + +/** + * @brief Get the dragable object size. + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param dw The drag width pointer + * @param dh The drag height pointer + * + * Gets the dragable object size. + * + * @see edje_object_part_drag_size_set() + */ +EAPI Eina_Bool edje_object_part_drag_size_get (const Evas_Object *obj, const char *part, double *dw, double *dh); + +/** + * @brief Sets the drag step increment. + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param dx The x step amount + * @param dy The y step amount + * + * Sets the x,y step increments for a dragable object. + * + * Values for @p dx and @p dy are real numbers that range from 0 to 1, + * representing the relative size of the dragable area on that axis by which the + * part will be moved. + * + * @see edje_object_part_drag_step_get() + */ +EAPI Eina_Bool edje_object_part_drag_step_set (Evas_Object *obj, const char *part, double dx, double dy); + +/** + * @brief Gets the drag step increment values. + * + * @param obj A valid Evas_Object handle + * @param part The part + * @param dx The x step increment pointer + * @param dy The y step increment pointer + * + * Gets the x and y step increments for the dragable object. + * + * + * @see edje_object_part_drag_step_set() + */ +EAPI Eina_Bool edje_object_part_drag_step_get (const Evas_Object *obj, const char *part, double *dx, double *dy); + +/** + * @brief Sets the page step increments. + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param dx The x page step increment + * @param dy The y page step increment + * + * Sets the x,y page step increment values. + * + * Values for @p dx and @p dy are real numbers that range from 0 to 1, + * representing the relative size of the dragable area on that axis by which the + * part will be moved. + * + * @see edje_object_part_drag_page_get() + */ +EAPI Eina_Bool edje_object_part_drag_page_set (Evas_Object *obj, const char *part, double dx, double dy); + +/** + * @brief Gets the page step increments. + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param dx The dx page increment pointer + * @param dy The dy page increment pointer + * + * Gets the x,y page step increments for the dragable object. + * + * @see edje_object_part_drag_page_set() + */ +EAPI Eina_Bool edje_object_part_drag_page_get (const Evas_Object *obj, const char *part, double *dx, double *dy); + +/** + * @brief Steps the dragable x,y steps. + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param dx The x step + * @param dy The y step + * + * Steps x,y where the step increment is the amount set by + * edje_object_part_drag_step_set. + * + * Values for @p dx and @p dy are real numbers that range from 0 to 1. + * + * @see edje_object_part_drag_page() + */ +EAPI Eina_Bool edje_object_part_drag_step (Evas_Object *obj, const char *part, double dx, double dy); + +/** + * @brief Pages x,y steps. + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param dx The x step + * @param dy The y step + * + * Pages x,y where the increment is defined by + * edje_object_part_drag_page_set. + * + * Values for @p dx and @p dy are real numbers that range from 0 to 1. + * + * @warning Paging is bugged! + * + * @see edje_object_part_drag_step() + */ +EAPI Eina_Bool edje_object_part_drag_page (Evas_Object *obj, const char *part, double dx, double dy); + + +/** + * @brief Get the object created by this external part. + * + * Parts of type external creates the part object using information + * provided by external plugins. It's somehow like "swallow" + * (edje_object_part_swallow()), but it's all set automatically. + * + * This function returns the part created by such external plugins and + * being currently managed by this Edje. + * + * @note Almost all swallow rules apply: you should not move, resize, + * hide, show, set the color or clipper of such part. It's a bit + * more restrictive as one must @b never delete this object! + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @return The externally created object, or NULL if there is none or + * part is not an external. + */ +EAPI Evas_Object *edje_object_part_external_object_get (const Evas_Object *obj, const char *part); + +/** + * @brief Set the parameter for the external part. + * + * Parts of type external may carry extra properties that have + * meanings defined by the external plugin. For instance, it may be a + * string that defines a button label and setting this property will + * change that label on the fly. + * + * @note external parts have parameters set when they change + * states. Those parameters will never be changed by this + * function. The interpretation of how state_set parameters and + * param_set will interact is up to the external plugin. + * + * @note this function will not check if parameter value is valid + * using #Edje_External_Param_Info minimum, maximum, valid + * choices and others. However these should be checked by the + * underlying implementation provided by the external + * plugin. This is done for performance reasons. + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param param the parameter details, including its name, type and + * actual value. This pointer should be valid, and the + * parameter must exist in + * #Edje_External_Type::parameters_info, with the exact type, + * otherwise the operation will fail and @c EINA_FALSE will be + * returned. + * + * @return @c EINA_TRUE if everything went fine, @c EINA_FALSE on errors. + */ +EAPI Eina_Bool edje_object_part_external_param_set (Evas_Object *obj, const char *part, const Edje_External_Param *param); + +/** + * @brief Get the parameter for the external part. + * + * Parts of type external may carry extra properties that have + * meanings defined by the external plugin. For instance, it may be a + * string that defines a button label. This property can be modifed by + * state parameters, by explicit calls to + * edje_object_part_external_param_set() or getting the actual object + * with edje_object_part_external_object_get() and calling native + * functions. + * + * This function asks the external plugin what is the current value, + * independent on how it was set. + * + * @param obj A valid Evas_Object handle + * @param part The part name + + * @param param the parameter details. It is used as both input and + * output variable. This pointer should be valid, and the + * parameter must exist in + * #Edje_External_Type::parameters_info, with the exact type, + * otherwise the operation will fail and @c EINA_FALSE will be + * returned. + * + * @return @c EINA_TRUE if everything went fine and @p param members + * are filled with information, @c EINA_FALSE on errors and @p + * param member values are not set or valid. + */ +EAPI Eina_Bool edje_object_part_external_param_get (const Evas_Object *obj, const char *part, Edje_External_Param *param); + +/** + * @brief Get an object contained in an part of type EXTERNAL + * + * The @p content string must not be NULL. Its actual value depends on the + * code providing the EXTERNAL. + * + * @param obj The Edje object + * @param part The name of the part holding the EXTERNAL + * @param content A string identifying which content from the EXTERNAL to get + */ +EAPI Evas_Object *edje_object_part_external_content_get (const Evas_Object *obj, const char *part, const char *content); + +/** + * Facility to query the type of the given parameter of the given part. + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param param the parameter name to use. + * + * @return @c EDJE_EXTERNAL_PARAM_TYPE_MAX on errors, or another value + * from #Edje_External_Param_Type on success. + */ +EAPI Edje_External_Param_Type edje_object_part_external_param_type_get (const Evas_Object *obj, const char *part, const char *param); + + +/** + * @brief Appends an object to the box. + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param child The object to append + * + * @return @c EINA_TRUE: Successfully added.\n + * @c EINA_FALSE: An error occurred. + * + * Appends child to the box indicated by part. + * + * @see edje_object_part_box_prepend() + * @see edje_object_part_box_insert_before() + * @see edje_object_part_box_insert_at() + */ +EAPI Eina_Bool edje_object_part_box_append (Evas_Object *obj, const char *part, Evas_Object *child); + +/** + * @brief Prepends an object to the box. + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param child The object to prepend + * + * @return @c EINA_TRUE: Successfully added.\n + * @c EINA_FALSE: An error occurred. + * + * Prepends child to the box indicated by part. + * + * @see edje_object_part_box_append() + * @see edje_object_part_box_insert_before() + * @see edje_object_part_box_insert_at() + */ +EAPI Eina_Bool edje_object_part_box_prepend (Evas_Object *obj, const char *part, Evas_Object *child); + +/** + * @brief Adds an object to the box. + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param child The object to insert + * @param reference The object to be used as reference + * + * @return @c EINA_TRUE: Successfully added.\n + * @c EINA_FALSE: An error occurred. + * + * Inserts child in the box given by part, in the position marked by + * reference. + * + * @see edje_object_part_box_append() + * @see edje_object_part_box_prepend() + * @see edje_object_part_box_insert_at() + */ +EAPI Eina_Bool edje_object_part_box_insert_before (Evas_Object *obj, const char *part, Evas_Object *child, const Evas_Object *reference); + +/** + * @brief Inserts an object to the box. + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param child The object to insert + * @param pos The position where to insert child + * + * @return @c EINA_TRUE: Successfully added.\n + * @c EINA_FALSE: An error occurred. + * + * Adds child to the box indicated by part, in the position given by + * pos. + * + * @see edje_object_part_box_append() + * @see edje_object_part_box_prepend() + * @see edje_object_part_box_insert_before() + */ +EAPI Eina_Bool edje_object_part_box_insert_at (Evas_Object *obj, const char *part, Evas_Object *child, unsigned int pos); + +/** + * @brief Removes an object from the box. + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param child The object to remove + * + * @return Pointer to the object removed, or @c NULL. + * + * Removes child from the box indicated by part. + * + * @see edje_object_part_box_remove_at() + * @see edje_object_part_box_remove_all() + */ +EAPI Evas_Object *edje_object_part_box_remove (Evas_Object *obj, const char *part, Evas_Object *child); + +/** + * @brief Removes an object from the box. + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param pos The position index of the object (starts counting from 0) + * + * @return Pointer to the object removed, or @c NULL. + * + * Removes from the box indicated by part, the object in the position + * pos. + * + * @see edje_object_part_box_remove() + * @see edje_object_part_box_remove_all() + */ +EAPI Evas_Object *edje_object_part_box_remove_at (Evas_Object *obj, const char *part, unsigned int pos); + +/** + * @brief Removes all elements from the box. + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param clear Delete objects on removal + * + * @return 1: Successfully cleared.\n + * 0: An error occurred. + * + * Removes all the external objects from the box indicated by part. + * Elements created from the theme will not be removed. + * + * @see edje_object_part_box_remove() + * @see edje_object_part_box_remove_at() + */ +EAPI Eina_Bool edje_object_part_box_remove_all (Evas_Object *obj, const char *part, Eina_Bool clear); + +/** + * @brief Retrieve a child from a table + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param col The column of the child to get + * @param row The row of the child to get + * @return The child Evas_Object + */ +EAPI Evas_Object *edje_object_part_table_child_get (Evas_Object *obj, const char *part, unsigned int col, unsigned int row); + +/** + * @brief Packs an object into the table. + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param child_obj The object to pack in + * @param col The column to place it in + * @param row The row to place it in + * @param colspan Columns the child will take + * @param rowspan Rows the child will take + * + * @return @c EINA_TRUE object was added, @c EINA_FALSE on failure + * + * Packs an object into the table indicated by part. + */ +EAPI 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); + +/** + * @brief Removes an object from the table. + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param child_obj The object to pack in + * + * @return @c EINA_TRUE object removed, @c EINA_FALSE on failure + * + * Removes an object from the table indicated by part. + */ +EAPI Eina_Bool edje_object_part_table_unpack (Evas_Object *obj, const char *part, Evas_Object *child_obj); + +/** + * @brief Gets the number of columns and rows the table has. + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param cols Pointer where to store number of columns (can be NULL) + * @param rows Pointer where to store number of rows (can be NULL) + * + * @return @c EINA_TRUE get some data, @c EINA_FALSE on failure + * + * Retrieves the size of the table in number of columns and rows. + */ +EAPI Eina_Bool edje_object_part_table_col_row_size_get (const Evas_Object *obj, const char *part, int *cols, int *rows); + +/** + * @brief Removes all object from the table. + * + * @param obj A valid Evas_Object handle + * @param part The part name + * @param clear If set, will delete subobjs on remove + * + * @return @c EINA_TRUE clear the table, @c EINA_FALSE on failure + * + * Removes all object from the table indicated by part, except the + * internal ones set from the theme. + */ +EAPI Eina_Bool edje_object_part_table_clear (Evas_Object *obj, const char *part, Eina_Bool clear); + +/** + * @brief Send an (Edje) message to a given Edje object + * + * @param obj A handle to an Edje object + * @param type The type of message to send to @p obj + * @param id A identification number for the message to be sent + * @param msg The message's body, a struct depending on @p type + * + * This function sends an Edje message to @p obj and to all of its + * child objects, if it has any (swallowed objects are one kind of + * child object). @p type and @p msg @b must be matched accordingly, + * as documented in #Edje_Message_Type. + * + * The @p id argument as a form of code and theme defining a common + * interface on message communication. One should define the same IDs + * on both code and EDC declaration (see @ref edcref "the syntax" for + * EDC files), to individualize messages (binding them to a given + * context). + * + * The function to handle messages arriving @b from @b obj is set with + * edje_object_message_handler_set(). + */ +EAPI void edje_object_message_send (Evas_Object *obj, Edje_Message_Type type, int id, void *msg); + +/** + * @brief Set an Edje message handler function for a given Edje object. + * + * @param obj A handle to an Edje object + * @param func The function to handle messages @b coming from @p obj + * @param data Auxiliary data to be passed to @p func + * + * Edje messages are one of the communication interfaces between + * @b code and a given Edje object's @b theme. With messages, one can + * communicate values beyond strings (which are the subject of Edje + * signals -- see edje_object_signal_emit()), like float and integer + * numbers. Moreover, messages can be identified by integer + * numbers. See #Edje_Message_Type for the full list of message types. + * + * For scriptable programs on an Edje object's defining EDC file which + * send messages with the @c send_message() primitive, one can attach + * handler functions, to be called in the code which creates + * that object (see @ref edcref "the syntax" for EDC files). + * + * This function associates a message handler function and the + * attached data pointer to the object @p obj. + * + * @see edje_object_message_send() + */ +EAPI void edje_object_message_handler_set (Evas_Object *obj, Edje_Message_Handler_Cb func, void *data); + +/** + * @brief Process an object's message queue. + * + * @param obj A handle to an Edje object. + * + * This function goes through the object message queue processing the + * pending messages for @b this specific Edje object. Normally they'd + * be processed only at idle time. + * + */ +EAPI void edje_object_message_signal_process (Evas_Object *obj); + + +/** + * @brief Process all queued up edje messages. + * + * This function triggers the processing of messages addressed to any + * (alive) edje objects. + * + */ +EAPI void edje_message_signal_process (void); + +/** + * Register a type to be used by EXTERNAL parts. + * + * Edje supports parts of type EXTERNAL, which will call user defined functions + * to create and manipulate the object that's allocated in that part. This is + * done by expecifying in the @c source property of the part the name of the + * external to use, which must be one registered with this function. + * + * @param type_name name to register and be known by edje's "source:" + * parameter of "type: EXTERNAL" parts. + * @param type_info meta-information describing how to interact with it. + * + * @return @c EINA_TRUE on success, @c EINA_FALSE on failure (like + * type already registered). + * + * @see edje_external_type_array_register() + */ +EAPI Eina_Bool edje_external_type_register (const char *type_name, const Edje_External_Type *type_info); + +/** + * Unregister a previously registered EXTERNAL type. + * + * @param type_name name to unregister. It should have been registered with + * edje_external_type_register() before. + * + * @return @c EINA_TRUE on success, @c EINA_FALSE on failure (like + * type_name did not exist). + * + * @see edje_external_type_array_unregister() + */ +EAPI Eina_Bool edje_external_type_unregister (const char *type_name); + +/** + * Register a batch of types and their information. + * + * When several types will be registered it is recommended to use this + * function instead of several calls to edje_external_type_register(), as it + * is faster. + * + * @note The contents of the array will be referenced directly for as long as + * the type remains registered, so both the @c name and @c info in the + * @p array must be kept alive during all this period (usually, the entire + * program lifetime). The most common case would be to keep the array as a + * @c static @c const type anyway. + * + * @param array @c NULL terminated array with type name and + * information. Note that type name or information are + * referenced directly, so they must be kept alive after + * this function returns! + * + * @return @c EINA_TRUE on success, @c EINA_FALSE on failure (like + * type already registered). + * + * @see edje_external_type_register() + */ +EAPI void edje_external_type_array_register (const Edje_External_Type_Info *array); + +/** + * Unregister a batch of given external type previously registered. + * + * @param array @c NULL terminated array, should be the same as the + * one used to register with edje_external_type_array_register() + * + * @see edje_external_type_unregister() + */ +EAPI void edje_external_type_array_unregister (const Edje_External_Type_Info *array); + +/** + * Return the current ABI version for Edje_External_Type structure. + * + * Always check this number before accessing Edje_External_Type in + * your own software. If the number is not the same, your software may + * access invalid memory and crash, or just get garbage values. + * + * @warning @b NEVER, EVER define your own Edje_External_Type using the + * return of this function as it will change as Edje library + * (libedje.so) changes, but your type definition will + * not. Instead, use #EDJE_EXTERNAL_TYPE_ABI_VERSION. + * + * Summary: + * - use edje_external_type_abi_version_get() to check. + * - use #EDJE_EXTERNAL_TYPE_ABI_VERSION to define/declare. + * + * @return The external ABI version the Edje library was compiled with. That + * is, the value #EDJE_EXTERNAL_TYPE_ABI_VERSION had at that moment. + */ +EAPI unsigned int edje_external_type_abi_version_get (void) EINA_CONST; + +/** + * Returns an interator of all the registered EXTERNAL types. + * + * Each item in the iterator is an @c Eina_Hash_Tuple which has the type + * of the external in the @c key and #Edje_External_Type as @c data. + * + * @code + * const Eina_Hash_Tuple *tuple; + * Eina_Iterator *itr; + * const Eina_List *l, *modules; + * const char *s; + * + * modules = edje_available_modules_get(); + * EINA_LIST_FOREACH(modules, l, s) + * { + * if (!edje_module_load(s)) + * printf("Error loading edje module: %s\n", s); + * } + * + * itr = edje_external_iterator_get(); + * EINA_ITERATOR_FOREACH(itr, tuple) + * { + * const char *name = tuple->key; + * const Edje_External_Type *type = tuple->data; + * + * if ((!type) || + * (type->abi_version != edje_external_type_abi_version_get())) + * { + * printf("Error: invalid type %p (abi: %d, expected: %d)\n", + * type, type ? type->abi_version : 0, + * edje_external_type_abi_version_get()); + * continue; + * } + * + * printf("%s: %s (%s) label='%s' desc='%s'\n", + * name, type->module, type->module_name, + * type->label_get ? type->label_get(type->data) : "", + * type->description_get ? type->description_get(type->data) : ""); + * } + * + * @endcode + */ +EAPI Eina_Iterator *edje_external_iterator_get (void); + +/** + * Conevenience function to find a specific parameter in a list of them. + * + * @param params The list of parameters for the external + * @param key The parameter to look for + * + * @return The matching #Edje_External_Param or NULL if it's not found. + */ + EAPI Edje_External_Param *edje_external_param_find (const Eina_List *params, const char *key); +/** + * Get the value of the given parameter of integer type. + * + * Look for the @p key parameter in the @p params list and return its value in + * @p ret. If the parameter is found and is of type + * #EDJE_EXTERNAL_PARAM_TYPE_INT, its value will be stored in the int pointed + * by @p ret, returning EINA_TRUE. In any other case, the function returns + * EINA_FALSE. + * + * @param params List of parameters where to look + * @param key Name of the parameter to fetch + * @param ret Int pointer where to store the value, must not be NULL. + * + * @return EINA_TRUE if the parameter was found and is of integer type, + * EINA_FALSE otherwise. + */ + EAPI Eina_Bool edje_external_param_int_get (const Eina_List *params, const char *key, int *ret); +/** + * Get the value of the given parameter of double type. + * + * Look for the @p key parameter in the @p params list and return its value in + * @p ret. If the parameter is found and is of type + * #EDJE_EXTERNAL_PARAM_TYPE_DOUBLE, its value will be stored in the double + * pointed by @p ret, returning EINA_TRUE. In any other case, the function + * returns EINA_FALSE. + * + * @param params List of parameters where to look + * @param key Name of the parameter to fetch + * @param ret Double pointer where to store the value, must not be NULL. + * + * @return EINA_TRUE if the parameter was found and is of double type, + * EINA_FALSE otherwise. + */ + EAPI Eina_Bool edje_external_param_double_get (const Eina_List *params, const char *key, double *ret); +/** + * Get the value of the given parameter of string type. + * + * Look for the @p key parameter in the @p params list and return its value in + * @p ret. If the parameter is found and is of type + * #EDJE_EXTERNAL_PARAM_TYPE_STRING, its value will be stored in the pointer + * pointed by @p ret, returning EINA_TRUE. In any other case, the function + * returns EINA_FALSE. + * + * The string stored in @p ret must not be freed or modified. + * + * @param params List of parameters where to look + * @param key Name of the parameter to fetch + * @param ret String pointer where to store the value, must not be NULL. + * + * @return EINA_TRUE if the parameter was found and is of string type, + * EINA_FALSE otherwise. + */ + EAPI Eina_Bool edje_external_param_string_get (const Eina_List *params, const char *key, const char **ret); +/** + * Get the value of the given parameter of boolean type. + * + * Look for the @p key parameter in the @p params list and return its value in + * @p ret. If the parameter is found and is of type + * #EDJE_EXTERNAL_PARAM_TYPE_BOOL, its value will be stored in the Eina_Bool + * pointed by @p ret, returning EINA_TRUE. In any other case, the function + * returns EINA_FALSE. + * + * @param params List of parameters where to look + * @param key Name of the parameter to fetch + * @param ret Eina_Bool pointer where to store the value, must not be NULL. + * + * @return EINA_TRUE if the parameter was found and is of boolean type, + * EINA_FALSE otherwise. + */ + EAPI Eina_Bool edje_external_param_bool_get (const Eina_List *params, const char *key, Eina_Bool *ret); +/** + * Get the value of the given parameter of choice type. + * + * Look for the @p key parameter in the @p params list and return its value in + * @p ret. If the parameter is found and is of type + * #EDJE_EXTERNAL_PARAM_TYPE_CHOICE, its value will be stored in the string + * pointed by @p ret, returning EINA_TRUE. In any other case, the function + * returns EINA_FALSE. + * + * The string stored in @p ret must not be freed or modified. + * + * @param params List of parameters where to look + * @param key Name of the parameter to fetch + * @param ret String pointer where to store the value, must not be NULL. + * + * @return EINA_TRUE if the parameter was found and is of integer type, + * EINA_FALSE otherwise. + */ + EAPI Eina_Bool edje_external_param_choice_get (const Eina_List *params, const char *key, const char **ret); + +/** + * Get the array of parameters information about a type given its name. + * + * @note the type names and other strings are static, that means they are + * @b NOT translated. One must use + * Edje_External_Type::translate() to translate those. + * + * @return the NULL terminated array, or @c NULL if type is unknown or + * it does not have any parameter information. + * + * @see edje_external_type_get() + */ +EAPI const Edje_External_Param_Info *edje_external_param_info_get (const char *type_name); + +/** + * Get the #Edje_External_Type that defines an EXTERNAL type registered with + * the name @p type_name. + */ + EAPI const Edje_External_Type *edje_external_type_get (const char *type_name); + + EAPI Eina_Bool edje_module_load (const char *module); + EAPI const Eina_List *edje_available_modules_get (void); + + /* perspective info for maps inside edje objects */ + typedef struct _Edje_Perspective Edje_Perspective; + + /** + * Creates a new perspective in the given canvas. + * + * @param e The given canvas (Evas). + * @return An @ref Edje_Perspective object for this canvas, or @c NULL on errors. + * + * This function creates a perspective object that can be set on an Edje + * object, or globally to all Edje objects on this canvas. + * + * @see edje_perspective_set() + * @see edje_perspective_free() + */ + EAPI Edje_Perspective *edje_perspective_new (Evas *e); + /** + * Delete the given perspective object. + * + * @param ps A valid perspective object, or @c NULL. + * + * This function will delete the perspective object. If the perspective + * effect was being applied to any Edje object or part, this effect won't be + * applied anymore. + * + * @see edje_perspective_new() + */ + EAPI void edje_perspective_free (Edje_Perspective *ps); + /** + * Setup the transform for this perspective object. + * + * This sets the parameters of the perspective transformation. X, Y and Z + * values are used. The px and py points specify the "infinite distance" point + * in the 3D conversion (where all lines converge to like when artists draw + * 3D by hand). The @p z0 value specifis the z value at which there is a 1:1 + * mapping between spatial coorinates and screen coordinates. Any points + * on this z value will not have their X and Y values modified in the transform. + * Those further away (Z value higher) will shrink into the distance, and + * those less than this value will expand and become bigger. The @p foc value + * determines the "focal length" of the camera. This is in reality the distance + * between the camera lens plane itself (at or closer than this rendering + * results are undefined) and the "z0" z value. This allows for some "depth" + * control and @p foc must be greater than 0. + * + * @param m map to change. + * @param px The pespective distance X coordinate + * @param py The pespective distance Y coordinate + * @param z0 The "0" z plane value + * @param foc The focal distance + */ + EAPI void edje_perspective_set (Edje_Perspective *ps, Evas_Coord px, Evas_Coord py, Evas_Coord z0, Evas_Coord foc); + /** + * Make this perspective object be global for its canvas. + * + * @param ps The given perspective object + * @param global @c EINA_TRUE if the perspective should be global, @c + * EINA_FALSE otherwise. + * + * The canvas which this perspective object is being set as global is the one + * given as argument upon the object creation (the @p evas parameter on the + * function @c edje_perspective_new(evas) ). + * + * There can be only one global perspective object set per canvas, and if + * a perspective object is set to global when there was already another + * global perspective set, the old one will be set as non-global. + * + * A global perspective just affects a part if its Edje object doesn't have a + * perspective object set to it, and if the part doesn't point to another + * part to be used as perspective. + * + * @see edje_object_perspective_set() + * @see edje_perspective_global_get() + * @see edje_perspective_new() + */ + EAPI void edje_perspective_global_set (Edje_Perspective *ps, Eina_Bool global); + /** + * Get whether the given perspective object is global or not. + * + * @param ps The given perspective object. + * @return @c EINA_TRUE if this perspective object is global, @c EINA_FALSE + * otherwise. + * + * @see edje_perspective_global_set() + */ + EAPI Eina_Bool edje_perspective_global_get (const Edje_Perspective *ps); + /** + * Get the global perspective object set for this canvas. + * + * @param e The given canvas (Evas). + * @return The perspective object set as global for this canvas. Or @c NULL + * if there is no global perspective set and on errors. + * + * This function will return the perspective object that was set as global + * with edje_perspective_global_set(). + * + * @see edje_perspective_global_set() + * @see edje_perspective_global_get() + */ + EAPI const Edje_Perspective *edje_evas_global_perspective_get(const Evas *e); + /** + * Set the given perspective object on this Edje object. + * + * @param obj The Edje object on the perspective will be set. + * @param ps The perspective object that will be used. + * + * Make the given perspective object be the default perspective for this Edje + * object. + * + * There can be only one perspective object per Edje object, and if a + * previous one was set, it will be removed and the new perspective object + * will be used. + * + * An Edje perspective will only affect a part if it doesn't point to another + * part to be used as perspective. + * + * @see edje_object_perspective_new() + * @see edje_object_perspective_get() + * @see edje_perspective_set() + */ + EAPI void edje_object_perspective_set (Evas_Object *obj, Edje_Perspective *ps); + /** + * Get the current perspective used on this Edje object. + * + * @param obj the given Edje object. + * @return The perspective object being used on this Edje object. Or @c NULL + * if there was none, and on errors. + * + * @see edje_object_perspective_set() + */ + EAPI const Edje_Perspective *edje_object_perspective_get (const Evas_Object *obj); + +#ifdef __cplusplus +} +#endif + +#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 @@ +#ifndef _EDJE_EDIT_H +#define _EDJE_EDIT_H + +#ifndef EDJE_EDIT_IS_UNSTABLE_AND_I_KNOW_ABOUT_IT +#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." +#endif + +#include + +#ifdef EAPI +# undef EAPI +#endif + +#ifdef _WIN32 +# ifdef EFL_EDJE_BUILD +# ifdef DLL_EXPORT +# define EAPI __declspec(dllexport) +# else +# define EAPI +# endif /* ! DLL_EXPORT */ +# else +# define EAPI __declspec(dllimport) +# endif /* ! EFL_EDJE_BUILD */ +#else +# ifdef __GNUC__ +# if __GNUC__ >= 4 +# define EAPI __attribute__ ((visibility("default"))) +# else +# define EAPI +# endif +# else +# define EAPI +# endif +#endif + + +typedef enum _Edje_Edit_Image_Comp +{ + EDJE_EDIT_IMAGE_COMP_RAW, + EDJE_EDIT_IMAGE_COMP_USER, + EDJE_EDIT_IMAGE_COMP_COMP, + EDJE_EDIT_IMAGE_COMP_LOSSY +} Edje_Edit_Image_Comp; + +struct _Edje_Edit_Script_Error +{ + const char *program_name; /* null == group shared script */ + int line; + const char *error_str; +}; +typedef struct _Edje_Edit_Script_Error Edje_Edit_Script_Error; + +/** + * @file + * @brief Functions to deal with edje internal object. Don't use in standard + * situations. The use of any of the edje_edit_* functions can break your + * theme ability, remember that the program must be separated from the interface! + * + * This was intended ONLY for use in an actual edje editor program. Unless + * you are writing one of these, do NOT use this API here. + * + * The API can be used to query or set every part of an edje object in real time. + * You can manage every aspect of parts, part states, programs, script and whatever + * is contained in the edje file. For a reference of what all parameter means + * look at the complete @ref edcref. + * + * Don't forget to free all the strings and the lists returned by any edje_edit_*() + * functions using edje_edit_string_free() and edje_edit_string_list_free() when + * you don't need anymore. + * + * Example: print all the part in a loaded edje_object + * @code + * Eina_List *parts, *l; + * char *part; + * + * parts = edje_edit_parts_list_get(edje_object); + * EINA_LIST_FOREACH(parts, l, part) + * { + * printf("Part: %s\n", part); + * } + * edje_edit_string_list_free(parts); + * @endcode + * + * Example: Change the color of a rect inside an edje file + * @code + * Evas_Object *edje; + * + * edje = edje_edit_object_add(evas); + * edje_object_file_set(edje, "edj/file/name", "group to load"); + * edje_edit_state_color_set(edje, "MyRectName", "default", 0.00, 255, 255, 0, 255); + * edje_edit_save(edje); + * @endcode + * +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + +/******************************************************************************/ +/************************** GENERAL API ***********************************/ +/******************************************************************************/ +/** @name General API + * General functions that don't fit in other cateories. + */ //@{ + +/** Adds an editable Edje object to the canvas. + * + * An Edje_Edit object is, for the most part, a standard Edje object. Only + * difference is you can use the Edje_Edit API on them. + * + * @param e Evas canvas where to add the object. + * + * @return An Evas_Object of type Edje_Edit, or NULL if an error occurred. + */ +EAPI Evas_Object * edje_edit_object_add(Evas *e); + +/** Free a generic Eina_List of (char *) allocated by an edje_edit_*_get() function. + * + * @param lst List of strings to free. + */ +EAPI void edje_edit_string_list_free(Eina_List *lst); + +/** Free a generic string (char *) allocated by an edje_edit_*_get() function. + * + * @param str String to free. + */ +EAPI void edje_edit_string_free(const char *str); + +/** Get the name of the program that compiled the edje file. + * Can be 'edje_cc' or 'edje_edit' + * + * @param obj Object being edited. + * + * @return Compiler stored in the Edje file + */ +EAPI const char * edje_edit_compiler_get(Evas_Object *obj); + +/** Save the modified edje object back to his file. + * + * Use this function when you are done with your editing, all the change made + * to the current loaded group will be saved back to the original file. + * + * @note Source for the whole file will be auto generated and will overwrite + * any previously stored source. + * + * @param obj Object to save back to the file it was loaded from. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + * + * @todo Add a way to check what the error actually was, the way Edje Load does. + */ +EAPI Eina_Bool edje_edit_save(Evas_Object *obj); + +/** Saves every group back into the file. + * + * @param obj Object to save. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + * + * @see edje_edit_save() + */ +EAPI Eina_Bool edje_edit_save_all(Evas_Object *obj); + +/** Print on standard output many information about the internal status + * of the edje object. + * + * This is probably only useful to debug. + * + * @param obj Object being edited. + */ +EAPI void edje_edit_print_internal_status(Evas_Object *obj); + + +//@} +/******************************************************************************/ +/************************** GROUPS API ************************************/ +/******************************************************************************/ +/** @name Groups API + * Functions to deal with groups property (see @ref edcref). + */ //@{ + +/** Create a new empty group in the given edje. + * + * If a group with the same name exist none is created. + * + * @param obj Object being edited. + * @param name Name of the new group. + * + * @return EINA_TRUE if successfully added the group, EINA_FALSE if an error + * occurred or if a group with the same name exists. + */ + +/** + * @brief Add an edje (empty) group to an edje object's group set. + * + * @param obj The pointer to edje object. + * @param name The name of the group. + * + * @return 1 If it could allocate memory to the part group added + * or zero if not. + * + * This function adds, at run time, one more group, which will reside + * in memory, to the group set found in the .edj file which @a obj was + * loaded with. This group can be manipulated by other API functions, + * like @c edje_edit_part_add(), for example. If desired, the new + * group can be actually committed the respective .edj by use of @c + * edje_edit_save(). + * + */ +EAPI Eina_Bool edje_edit_group_add(Evas_Object *obj, const char *name); + +/** Delete the specified group from the given edje. + * + * You can only delete a currently unused group. + * All the parts and the programs inside the group will be deleted as well, + * but not image or font embedded in the edje. + * + * @param obj Object being edited. + * @param group_name Name of group to delete. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ + +/** + * @brief Delete the specified group from the edje file. + * + * @param obj The pointer to the edje object. + * @param group_name Group to delete. + * + * @return @c EINA_TRUE on success, @c EINA_FALSE on failure. + * + * This function deletes the given group from the file @a obj is set to. This + * operation can't be undone as all references to the group are removed from + * the file. + * This function may fail if the group to be deleted is currently in use. + * + */ +EAPI Eina_Bool edje_edit_group_del(Evas_Object *obj, const char *group_name); + +/** Check if a group with the given name exist in the edje. + * + * @param obj Object being edited. + * @param group Group name to check for. + * + * @return EINA_TRUE if group exists, EINA_FALSE if not. + */ +EAPI Eina_Bool edje_edit_group_exist(Evas_Object *obj, const char *group); + +/** Set a new name for the current open group. + * + * You can only rename a group that is currently loaded + * Note that the relative getter function don't exist as it doesn't make sense ;) + * @param obj Object being edited. + * @param new_name New name for the group. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_group_name_set(Evas_Object *obj, const char *new_name); + +/** Get the group minimum width. + * + * @param obj Object being edited. + * + * @return The minimum width set for the group. -1 if an error occurred. + */ +EAPI int edje_edit_group_min_w_get(Evas_Object *obj); + +/** Set the group minimum width. + * + * @param obj Object being edited. + * @param w New minimum width for the group. + */ +EAPI void edje_edit_group_min_w_set(Evas_Object *obj, int w); + +/** Get the group minimum height. + * + * @param obj Object being edited. + * + * @return The minimum height set for the group. -1 if an error occurred. + */ +EAPI int edje_edit_group_min_h_get(Evas_Object *obj); + +/** Set the group minimum height. + * + * @param obj Object being edited. + * @param h New minimum height for the group. + */ +EAPI void edje_edit_group_min_h_set(Evas_Object *obj, int h); + +/** Get the group maximum width. + * + * @param obj Object being edited. + * + * @return The maximum width set for the group. -1 if an error occurred. + */ +EAPI int edje_edit_group_max_w_get(Evas_Object *obj); + +/** Set the group maximum width. + * + * @param obj Object being edited. + * @param w New maximum width for the group. + */ +EAPI void edje_edit_group_max_w_set(Evas_Object *obj, int w); + +/** Get the group maximum height. + * + * @param obj Object being edited. + * + * @return The maximum height set for the group. -1 if an error occurred. + */ +EAPI int edje_edit_group_max_h_get(Evas_Object *obj); + +/** Set the group maximum height. + * + * @param obj Object being edited. + * @param h New maximum height for the group. + */ +EAPI void edje_edit_group_max_h_set(Evas_Object *obj, int h); + + +//@} +/******************************************************************************/ +/************************** DATA API **************************************/ +/******************************************************************************/ +/** @name Data API + * Functions to deal with data embedded in the edje (see @ref edcref). + */ //@{ + +/** Retrieves a list with the item names inside the data block. + * + * @param obj Object being edited. + * + * @return List of strings, each being a name entry in the global data block for the file. + */ +EAPI Eina_List * edje_edit_data_list_get(Evas_Object *obj); + +/** Create a new *global* data object in the given edje file. + * + * If another data entry with the same name exists, nothing is created and + * EINA_FALSE is returned. + * + * @param obj Object being edited. + * @param itemname Name for the new data entry. + * @param value Value for the new data entry. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_data_add(Evas_Object *obj, const char *itemname, const char *value); + +/** Delete the given data object from edje. + * + * @param obj Object being edited. + * @param itemname Data entry to remove from the global data block. + * + * @return EINA_TRUE on success, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_data_del(Evas_Object *obj, const char *itemname); + +/** Get the data associated with the given itemname. + * + * @param obj Object being edited. + * @param itemname Name of the data entry to fetch the value for. + * + * @return Value of the given entry, or NULL if not found. + */ +EAPI const char * edje_edit_data_value_get(Evas_Object *obj, const char *itemname); + +/** Set the data associated with the given itemname. + * + * @param obj Object being edited. + * @param itemname Name of data entry to change the value. + * @param value New value for the entry. + * + * @return EINA_TRUE on success, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_data_value_set(Evas_Object *obj, const char *itemname, const char *value); + +/** Change the name of the given data object. + * + * @param obj Object being edited. + * @param itemname Data entry to rename. + * @param newname New name for the data entry. + * + * @return EINA_TRUE on success, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_data_name_set(Evas_Object *obj, const char *itemname, const char *newname); + +/** Retrieves a list with the item names inside the data block at the group level. + * + * @param obj Object being edited. + * + * @return List of strings, each being a name entry in the data block for the group. + */ +EAPI Eina_List * edje_edit_group_data_list_get(Evas_Object *obj); + +/** Create a new data object in the given edje file *belonging to the current group*. + * + * If another data entry with the same name exists, + * nothing is created and EINA_FALSE is returned. + * + * @param obj Object being edited. + * @param itemname Name for the new data entry. + * @param value Value for the new data entry. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_group_data_add(Evas_Object *obj, const char *itemname, const char *value); + +/** Delete the given data object from the group. + * + * @param obj Object being edited. + * @param itemname Name of the data entry to remove. + * + * @return EINA_TRUE on success, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_group_data_del(Evas_Object *obj, const char *itemname); + +/** Get the data associated with the given itemname. + * + * @param obj Object being edited. + * @param itemname Name of the data entry. + * + * @return Value of the data entry or NULL if not found. + */ +EAPI const char * edje_edit_group_data_value_get(Evas_Object *obj, const char *itemname); + +/** Set the data associated with the given itemname. + * + * @param obj Object being edited. + * @param itemname Name of the data entry to set the value. + * @param value Value to set for the data entry. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_group_data_value_set(Evas_Object *obj, const char *itemname, const char *value); + +/** Change the name of the given data object. + * + * @param obj Object being edited. + * @param itemname Name of the data entry to rename. + * @param newname New name for the data entry. + * + * @return EINA_TRUE on success, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_group_data_name_set(Evas_Object *obj, const char *itemname, const char *newname); + + +//@} +/******************************************************************************/ +/*********************** COLOR CLASSES API ********************************/ +/******************************************************************************/ +/** @name Color Classes API + * Functions to deal with Color Classes (see @ref edcref). + */ //@{ + +/** Get the list of all the Color Classes in the given edje object. + * + * @param obj Object being edited. + * + * @return List of strings, each being one color class. + */ +EAPI Eina_List * edje_edit_color_classes_list_get(Evas_Object *obj); + +/** Create a new color class object in the given edje. + * + * If another class with the same name exists nothing is created and EINA_FALSE is returned. + * + * @param obj Object being edited. + * @param name Name for the new color class. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_color_class_add(Evas_Object *obj, const char *name); + +/** Delete the given class object from edje. + * + * @param obj Object being edited. + * @param name Color class to delete. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_color_class_del(Evas_Object *obj, const char *name); + +/** Get all the colors that compose the class. + * + * You can pass NULL to colors you are not intrested in. + * + * @param obj Object being edited. + * @param class_name Color class to fetch values. + * @param r Red component of main color. + * @param g Green component of main color. + * @param b Blue component of main color. + * @param a Alpha component of main color. + * @param r2 Red component of secondary color. + * @param g2 Green component of secondary color. + * @param b2 Blue component of secondary color. + * @param a2 Alpha component of secondary color. + * @param r3 Red component of tertiary color. + * @param g3 Green component of tertiary color. + * @param b3 Blue component of tertiary color. + * @param a3 Alpha component of tertiary color. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI 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); + +/** Set the colors for the given color class. + * + * If you set a color to -1 it will not be touched. + * + * @param obj Object being edited. + * @param class_name Color class to fetch values. + * @param r Red component of main color. + * @param g Green component of main color. + * @param b Blue component of main color. + * @param a Alpha component of main color. + * @param r2 Red component of secondary color. + * @param g2 Green component of secondary color. + * @param b2 Blue component of secondary color. + * @param a2 Alpha component of secondary color. + * @param r3 Red component of tertiary color. + * @param g3 Green component of tertiary color. + * @param b3 Blue component of tertiary color. + * @param a3 Alpha component of tertiary color. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI 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); + +/** Change the name of a color class. + * + * @param obj Object being edited. + * @param name Color class to rename. + * @param newname New name for the color class. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_color_class_name_set(Evas_Object *obj, const char *name, const char *newname); + +//@} + + +/******************************************************************************/ +/************************** TEXT STYLES *************************************/ +/******************************************************************************/ +/** @name Text styles API + * Functions to deal with text styles (see @ref edcref). + */ //@{ + +/** Get the list of all the text styles in the given edje object. + * + * @param obj Object being edited. + * + * @return List of strings, each being the name for a text style. + */ +EAPI Eina_List * edje_edit_styles_list_get(Evas_Object *obj); + +/** Create a new text style object in the given edje. + * + * If another style with the same name exists nothing is created and EINA_FALSE is returned. + * + * @param obj Object being edited. + * @param style Name for the new style. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_style_add(Evas_Object *obj, const char *style); + +/** Delete the given text style and all the child tags. + * + * @param obj Object being edited. + * @param style Style to delete. + */ +EAPI void edje_edit_style_del(Evas_Object *obj, const char *style); + +/** Get the list of all the tags name in the given text style. + * + * @param obj Object being edited. + * @param style Style to get the tags for. + * + * @return List of strings, each being one tag in the given style. + */ +EAPI Eina_List * edje_edit_style_tags_list_get(Evas_Object *obj, const char *style); + +/** Get the value of the given tag. + * + * @param obj Object being edited. + * @param style Style containing the tag being. + * @param tag Tag to get the value for. + * + * @return Value of the given tag. + */ +EAPI const char * edje_edit_style_tag_value_get(Evas_Object *obj, const char *style, const char *tag); + +/** Set the value of the given tag. + * + * @param obj Object being edited. + * @param style Style containing the tag to change. + * @param tag Name of the tag to set the value for. + * @param new_value Value for the tag. + */ +EAPI void edje_edit_style_tag_value_set(Evas_Object *obj, const char *style, const char *tag, const char *new_value); + +/** Set the name of the given tag. + * + * @param obj Object being edited. + * @param style Style containing the tag to rename. + * @param tag Tag to rename. + * @param new_name New name for the tag. + */ +EAPI void edje_edit_style_tag_name_set(Evas_Object *obj, const char *style, const char *tag, const char *new_name); + +/** Add a new tag to the given text style. + * + * If another tag with the same name exists nothing is created and EINA_FALSE is returned. + * + * @param obj Object being edited. + * @param style Style where to add the new tag. + * @param tag_name Name for the new tag. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_style_tag_add(Evas_Object *obj, const char *style, const char *tag_name); + +/** Delete the given tag. + * + * @param obj Object being edited. + * @param style Style from where to remove the tag. + * @param tag Tag to delete. + */ +EAPI void edje_edit_style_tag_del(Evas_Object *obj, const char *style, const char *tag); + + +//@} +/******************************************************************************/ +/************************ EXTERNALS API ***********************************/ +/******************************************************************************/ +/** @name Externals API + * Functions to deal with list of external modules (see @ref edcref). + */ //@{ + +/** Get the list of all the externals requested in the given edje object. + * + * @param obj Object being edited. + * + * @return List of strings, each being an entry in the block of automatically loaded external modules. + */ +EAPI Eina_List * edje_edit_externals_list_get(Evas_Object *obj); + +/** Add an external module to be requested on edje load. + * + * @param obj Object being edited. + * @param external Name of the external module to add to the list of autoload. + * + * @return EINA_TRUE on success (or it was already there), EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_external_add(Evas_Object *obj, const char *external); + +/** Delete the given external from the list. + * + * @param obj Object being edited. + * @param external Name of the external module to remove from the autoload list. + * + * @return EINA_TRUE on success, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_external_del(Evas_Object *obj, const char *external); + + +//@} +/******************************************************************************/ +/************************** PARTS API *************************************/ +/******************************************************************************/ +/** @name Parts API + * Functions to deal with part objects (see @ref edcref). + */ //@{ + +/** Get the list of all the parts in the given edje object. + * + * @param obj Object being edited. + * + * @return List of strings, each being the name for a part in the open group. + */ +EAPI Eina_List * edje_edit_parts_list_get(Evas_Object *obj); + +/** Create a new part in the given edje. + * + * If another part with the same name just exists nothing is created and EINA_FALSE is returned. + * Note that this function also create a default description for the part. + * + * @param obj Object being edited. + * @param name Name for the new part. + * @param type Type of the new part. See @ref edcref for more info on this. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_part_add(Evas_Object *obj, const char *name, Edje_Part_Type type); + +/** Create a new part of type EXTERNAL in the given edje. + * + * If another part with the same name just exists nothing is created and EINA_FALSE is returned. + * Note that this function also create a default description for the part. + * + * @param obj Object being edited. + * @param name Name for the new part. + * @param source The registered external type to use for this part. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_part_external_add(Evas_Object *obj, const char *name, const char *source); + +/** Delete the given part from the edje. + * + * All the reference to this part will be zeroed. + * + * @param obj Object being edited. + * @param part Name of part to delete. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_part_del(Evas_Object *obj, const char *part); + +/** Check if a part with the given name exist in the edje object. + * + * @param obj Object being edited. + * @param part Name of part to check for its existence. + * + * @return EINA_TRUE if the part exists, EINA_FALSE if not. + */ +EAPI Eina_Bool edje_edit_part_exist(Evas_Object *obj, const char *part); + +/** Get the name of part stacked above the one passed. + * + * @param obj Object being edited. + * @param part Name of part of which to check the one above. + * + * @return Name of the part above. NULL if an error occurred or if @p part is + * the topmost part in the group. + */ +EAPI const char * edje_edit_part_above_get(Evas_Object *obj, const char *part); + +/** Get the name of part stacked below the one passed. + * + * @param obj Object being edited. + * @param part Name of part of which to check the one below. + * + * @return Name of the part below. NULL if an error occurred or if @p part is + * the bottommost part in the group. + */ +EAPI const char * edje_edit_part_below_get(Evas_Object *obj, const char *part); + +/** Move the given part below the previous one. + * + * @param obj Object being edited. + * @param part Name of part to move one step below. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_part_restack_below(Evas_Object *obj, const char *part); + +/** Move the given part above the next one. + * + * @param obj Object being edited. + * @param part Name of part to move one step above. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_part_restack_above(Evas_Object *obj, const char *part); + +/** Set a new name for part. + * + * Note that the relative getter function don't exist as it don't make sense ;) + * + * @param obj Object being edited. + * @param part Name of part to rename. + * @param new_name New name for the given part. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_part_name_set(Evas_Object *obj, const char *part, const char *new_name); + +/** Get api's name of a part. + * + * @param obj Object being edited. + * @param part Name of the part. + * + * @return name of the api if successful, NULL otherwise. + */ +EAPI const char * edje_edit_part_api_name_get(Evas_Object *obj, const char *part); + +/** Get api's description of a part. + * + * @param obj Object being edited. + * @param part Name of the part. + * + * @return description of the api if successful, NULL otherwise. + */ +EAPI const char * edje_edit_part_api_description_get(Evas_Object *obj, const char *part); + +/** Set api's name of a part. + * + * @param obj Object being edited. + * @param part Name of the part. + * @param name New name for the api property. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_part_api_name_set(Evas_Object *obj, const char *part, const char *name); + +/** Set api's description of a part. + * + * @param obj Object being edited. + * @param part Name of part. + * @param description New description for the api property. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_part_api_description_set(Evas_Object *obj, const char *part, const char *description); + +/** Get the type of a part. + * + * @param obj Object being edited. + * @param part Name of part to get the type of. + * + * @return Type of the part. See @ref edcref for details. + */ +EAPI Edje_Part_Type edje_edit_part_type_get(Evas_Object *obj, const char *part); + +/** Get the clip_to part. + * + * @param obj Object being edited. + * @param part Name of the part whose clipper to get. + * + * @return Name of the part @p part is clipped to. NULL is returned on errors and if the part don't have a clip. + */ +EAPI const char * edje_edit_part_clip_to_get(Evas_Object *obj, const char *part); + +/** Set a part to clip part to. + * + * @param obj Object being edited. + * @param part Part to set the clipper to. + * @param clip_to Part to use as clipper, if NULL then the clipping value will be cancelled (unset clipping). + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_part_clip_to_set(Evas_Object *obj, const char *part, const char *clip_to); + +/** Get the source of part. + * + * The meaning of this parameter varies depending on the type of the part. + * For GROUP parts, it's the name of another group in the Edje file which will + * be autoloaded and swallowed on this part. + * For TEXTBLOCK parts, it's the name of a group to be used for selection + * display under the text. + * For EXTERNAL parts, it's the name of the registered external widget to load + * and swallow on this part. + * + * @param obj Object being edited. + * @param part Part to get the source from. + * + * @return Content of the source parameter or NULL if nothing set or an error occurred. + */ +EAPI const char * edje_edit_part_source_get(Evas_Object *obj, const char *part); + +/** Set the source of part. + * + * @param obj Object being edited. + * @param part Part to set the source of. + * @param source Value for the source parameter. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + * + * @see edje_edit_part_source_get() + * + * @note You can't change the source for EXTERNAL parts, it's akin to changing + * the type of the part. + * + * NOTE: This is not applied now. You must reload the edje to see the change. + */ +EAPI Eina_Bool edje_edit_part_source_set(Evas_Object *obj, const char *part, const char *source); + +/** Get the effect for a given part. + * + * Gets the effect used for parts of type TEXT. See @ref edcref for more details. + * + * @param obj Object being edited. + * @param part Part to get the effect of. + * + * @return The effect set for the part. + */ +EAPI Edje_Text_Effect edje_edit_part_effect_get(Evas_Object *obj, const char *part); + +/** Set the effect for a given part. + * + * @param obj Object being edited. + * @param part Part to set the effect to. Only makes sense on type TEXT. + * @param effect Effect to set for the part. + */ +EAPI void edje_edit_part_effect_set(Evas_Object *obj, const char *part, Edje_Text_Effect effect); + +/** Get the current selected state in part. + * + * @param obj Object being edited. + * @param part Part to get the selected state of. + * @param value Pointer to a double where the value of the state will be stored. + * + * @return The name of the currently selected state for the part. + */ +EAPI const char * edje_edit_part_selected_state_get(Evas_Object *obj, const char *part, double *value); + +/** Set the current state in part. + * + * @param obj Object being edited. + * @param part Part to set the state of. + * @param state Name of the state to set. + * @param value Value of the state. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_part_selected_state_set(Evas_Object *obj, const char *part, const char *state, double value); + +/** Get mouse_events for part. + * + * @param obj Object being edited. + * @param part Part to get if the mouse events is accepted. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_part_mouse_events_get(Evas_Object *obj, const char *part); + +/** Set mouse_events for part. + * + * @param obj Object being edited. + * @param part The part to set if the mouse events is accepted. + * @param mouse_events EINA_TRUE if part will accept mouse events, EINA_FALSE otherwise. + */ +EAPI void edje_edit_part_mouse_events_set(Evas_Object *obj, const char *part, Eina_Bool mouse_events); + +/** Get repeat_events for part. + * + * @param obj Object being edited. + * @param part Part to set if will pass all events to the other parts. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_part_repeat_events_get(Evas_Object *obj, const char *part); + +/** Set repeat_events for part. + * + * @param obj Object being edited. + * @param part Part to set if will repeat all the received mouse events to other parts. + * @param repeat_events EINA_TRUE if the events received will propagate to other parts, EINA_FALSE otherwise + */ +EAPI void edje_edit_part_repeat_events_set(Evas_Object *obj, const char *part, Eina_Bool repeat_events); + +/** Get ignore_flags for part. + * + * @param obj Object being edited. + * @param part Part to get which event_flags are being ignored. + * + * @return The Event flags set to the part. + */ +EAPI Evas_Event_Flags edje_edit_part_ignore_flags_get(Evas_Object *obj, const char *part); + +/** Set ignore_flags for part. + * + * @param obj Object being edited. + * @param part Part to set which event flags will be ignored. + * @param ignore_flags The Event flags to be ignored by the part. + */ +EAPI void edje_edit_part_ignore_flags_set(Evas_Object *obj, const char *part, Evas_Event_Flags ignore_flags); + +/** Set scale property for the part. + * + * This property tells Edje that the given part should be scaled by the + * Edje scale factor. + * + * @param obj Object being edited. + * @param part Part to set scale for. + * @param scale Scale value to set. + */ +EAPI void edje_edit_part_scale_set(Evas_Object *obj, const char *part, Eina_Bool scale); + +/** Get scale for the part. + * + * @param obj Object being edited. + * @param part Part to get the scale value of. + * + * @return Whether scale is on (EINA_TRUE) or not. + */ +EAPI Eina_Bool edje_edit_part_scale_get(Evas_Object *obj, const char *part); + +/** Get horizontal dragable state for part. + * + * @param obj Object being edited. + * @param part Part to get if can be dragged horizontally; + * + * @return 1 (or -1) if the part can be dragged horizontally, 0 otherwise. + */ +EAPI int edje_edit_part_drag_x_get(Evas_Object *obj, const char *part); + +/** Set horizontal dragable state for part. + * + * @param obj Object being edited. + * @param part Part to set if should be dragged horizontally. + * @param drag 1 (or -1) if the part should be dragged horizontally, 0 otherwise. + */ +EAPI void edje_edit_part_drag_x_set(Evas_Object *obj, const char *part, int drag); + +/** Get vertical dragable state for part. + * + * @param obj Object being edited. + * @param part Part to get if can be dragged vertically. + * + * @return 1 (or - 1) if the part can be dragged vertically, 0 otherwise. + */ +EAPI int edje_edit_part_drag_y_get(Evas_Object *obj, const char *part); + +/** Set vertical dragable state for part. + * + * @param obj Object being edited. + * @param part Part to set if should be dragged vertically. + * @param drag 1 (or -1) of the part shpuld be dragged vertically, 0 otherwise. + */ +EAPI void edje_edit_part_drag_y_set(Evas_Object *obj, const char *part, int drag); + +/** Get horizontal dragable step for part. + * + * @param obj Object being edited. + * @param part Part to get the drag horizontal step value. + * + * @return The step value. + */ +EAPI int edje_edit_part_drag_step_x_get(Evas_Object *obj, const char *part); + +/** Set horizontal dragable state for part. + * + * @param obj Object being edited. + * @param part Part to set the drag horizontal step value. + * @param step The step the will be dragged. + */ +EAPI void edje_edit_part_drag_step_x_set(Evas_Object *obj, const char *part, int step); + +/** Get vertical dragable step for part. + * + * @param obj Object being edited. + * @param part Part to get the drag vertical step value. + * + * @return The step value. + */ +EAPI int edje_edit_part_drag_step_y_get(Evas_Object *obj, const char *part); + +/** Set vertical dragable state for part. + * + * @param obj Object being edited. + * @param part Part to set the drag vertical step value. + * @param step The step the will be dragged. + */ +EAPI void edje_edit_part_drag_step_y_set(Evas_Object *obj, const char *part, int step); + +/** Get horizontal dragable count for part. + * + * @param obj Object being edited. + * @param part Part to get the drag horizontal count value. + */ +EAPI int edje_edit_part_drag_count_x_get(Evas_Object *obj, const char *part); + +/** Set horizontal dragable count for part. + * + * @param obj Object being edited. + * @param part Part to set the drag horizontal count value. + * @param count The count value. + */ +EAPI void edje_edit_part_drag_count_x_set(Evas_Object *obj, const char *part, int count); + +/** Get vertical dragable count for part. + * + * @param obj Object being edited. + * @param part Part to get the drag vertical count value. + */ +EAPI int edje_edit_part_drag_count_y_get(Evas_Object *obj, const char *part); + +/** Set vertical dragable count for part. + * + * @param obj Object being edited. + * @param part Part to set the drag vertical count value. + * @param count The count value. + */ +EAPI void edje_edit_part_drag_count_y_set(Evas_Object *obj, const char *part, int count); + +/** Get the name of the part that is used as 'confine' for the given draggies. + * + * @param obj Object being edited. + * @param part Part to get the name that is used as 'confine' for the given draggies. + * + * @return The name of the confine part or NULL (if unset). + */ +EAPI const char * edje_edit_part_drag_confine_get(Evas_Object *obj, const char *part); + +/** Set the name of the part that is used as 'confine' for the given draggies. + * + * @param obj Object being edited. + * @param part Part to set the name that is used as 'confine' for the given draggies. + * @param confine The name of the confine part or NULL to unset confine. + */ +EAPI void edje_edit_part_drag_confine_set(Evas_Object *obj, const char *part, const char *confine); + +/** Get the name of the part that is used as the receiver of the drag event. + * + * @param obj Object being edited. + * @param part Part to get the name that is used as the receiver of the drag event. + * + * @return The name of the part that will receive events, or NULL (if unset). + */ +EAPI const char * edje_edit_part_drag_event_get(Evas_Object *obj, const char *part); + +/** Set the name of the part that will receive events from the given draggies. + * + * @param obj Object being edited. + * @param part Part to set the name that will receive events from the given draggies. + * @param event The name of the part that will receive events, or NULL to unset. + */ +EAPI void edje_edit_part_drag_event_set(Evas_Object *obj, const char *part, const char *event); + + +//@} +/******************************************************************************/ +/************************** STATES API ************************************/ +/******************************************************************************/ +/** @name States API + * Functions to deal with part states (see @ref edcref). + */ //@{ + +/** Get the list of all the states in the given part. + * + * @param obj Object being edited. + * @param part Part to get the states names list. + * + * @return An Eina_List* of string (char *)containing all the states names found + * in part, including the float value (ex: "default 0.00"). + * + * Use edje_edit_string_list_free() when you don't need it anymore. + */ +EAPI Eina_List * edje_edit_part_states_list_get(Evas_Object *obj, const char *part); + +/** Set a new name for the given state in the given part. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state Name of the state to rename. + * @param value Value of the state to rename. + * @param new_name The new name for the state. + * @param new_value The new value for the state. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI 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); + +/** Create a new state to the give part. + * + * @param obj Object being edited. + * @param part Part to set the name of the new state. + * @param name Name for the new state (not including the state value). + * @param value The state value. + * + * @return EINA_TRUE if successfully, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_state_add(Evas_Object *obj, const char *part, const char *name, double value); + +/** Delete the given part state from the edje. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The current name of the state (not including the state value). + * @param value The state value. + * + * @return EINA_TRUE if successfully, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_state_del(Evas_Object *obj, const char *part, const char *state, double value); + +/** Check if a part state with the given name exist. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to check (not including the state value). + * @param value The state value. + * + * @return EINA_TRUE if the part state exist, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_state_exist(Evas_Object *obj, const char *part, const char *state, double value); + +/** Copies the state @p from into @p to. If @p to doesn't exist it will be created. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param from State to copy from (not including state value). + * @param val_from The value of the state to copy from. + * @param to State to copy into (not including state value). + * @param val_to The value of the state to copy into. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_state_copy(Evas_Object *obj, const char *part, const char *from, double val_from, const char *to, double val_to); + +/** Get the 'rel1 relative X' value of state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get 'rel1 relative X' (not including the state value). + * @param value The state value. + * + * @return The 'rel1 relative X' value of the part state. + */ +EAPI double edje_edit_state_rel1_relative_x_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Get the 'rel1 relative Y' value of state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get 'rel1 relative Y' (not including the state value). + * @param value The state value. + * + * @return The 'rel1 relative Y' value of the part state. + */ +EAPI double edje_edit_state_rel1_relative_y_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Get the 'rel2 relative X' value of state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get 'rel2 relative X' (not including the state value). + * @param value The state value. + * + * @return The 'rel2 relative X' value of the part state. + */ +EAPI double edje_edit_state_rel2_relative_x_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Get the 'rel2 relative Y' value of state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get 'rel2 relative Y' (not including the state value). + * @param value The state value. + * + * @return The 'rel2 relative Y' value of the part state. + */ +EAPI double edje_edit_state_rel2_relative_y_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Set the 'rel1 relative X' value of state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to set 'rel1 relative X' (not including the state value). + * @param value The state value. + * @param x The new 'rel1 relative X' value to set'. + */ +EAPI void edje_edit_state_rel1_relative_x_set(Evas_Object *obj, const char *part, const char *state, double value, double x); + +/** Set the 'rel1 relative Y' value of state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to set 'rel1 relative Y' (not including the state value). + * @param value The state value. + * @param y The new 'rel1 relative Y' value to set'. + */ +EAPI void edje_edit_state_rel1_relative_y_set(Evas_Object *obj, const char *part, const char *state, double value, double y); + +/** Set the 'rel2 relative X' value of state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to set 'rel2 relative X' (not including the state value). + * @param value The state value. + * @param x The new 'rel2 relative X' value to set'. + */ +EAPI void edje_edit_state_rel2_relative_x_set(Evas_Object *obj, const char *part, const char *state, double value, double x); + +/** Set the 'rel2 relative Y' value of state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to set 'rel2 relative Y' (not including the state value). + * @param value The state value. + * @param y The new 'rel2 relative Y' value to set'. + */ +EAPI void edje_edit_state_rel2_relative_y_set(Evas_Object *obj, const char *part, const char *state, double value, double y); + +/** Get the 'rel1 offset X' value of state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get 'rel1 offset X' (not including the state value). + * @param value The state value. + * + * @return The 'rel1 offset X' value of the part state. + */ +EAPI int edje_edit_state_rel1_offset_x_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Get the 'rel1 offset Y' value of state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get 'rel1 offset Y' (not including the state value). + * @param value The state value. + * + * @return The 'rel1 offset Y' value of the part state. + */ +EAPI int edje_edit_state_rel1_offset_y_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Get the 'rel2 offset X' value of state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get 'rel2 offset X' (not including the state value). + * @param value The state value. + * + * @return The 'rel2 offset X' value of the part state. + */ +EAPI int edje_edit_state_rel2_offset_x_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Get the 'rel2 offset Y' value of state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get 'rel2 offset Y' (not including the state value). + * @param value The state value. + * + * @return The 'rel2 offset Y' value of the part state. + */ +EAPI int edje_edit_state_rel2_offset_y_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Set the 'rel1 offset X' value of state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to set 'rel1 offset X' (not including the state value). + * @param value The state value. + * @param x The new 'rel1 offset X' value to set'. + */ +EAPI void edje_edit_state_rel1_offset_x_set(Evas_Object *obj, const char *part, const char *state, double value, double x); + +/** Set the 'rel1 offset Y' value of state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to set 'rel1 offset Y' (not including the state value). + * @param value The state value. + * @param y The new 'rel1 offset Y' value to set'. + */ +EAPI void edje_edit_state_rel1_offset_y_set(Evas_Object *obj, const char *part, const char *state, double value, double y); + +/** Set the 'rel2 offset X' value of state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to set 'rel2 offset X' (not including the state value). + * @param value The state value. + * @param x The new 'rel2 offset X' value to set'. + */ +EAPI void edje_edit_state_rel2_offset_x_set(Evas_Object *obj, const char *part, const char *state, double value, double x); + +/** Set the 'rel2 offset Y' value of state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to set 'rel2 offset Y' (not including the state value). + * @param value The state value. + * @param y The new 'rel2 offset Y' value to set'. + */ +EAPI void edje_edit_state_rel2_offset_y_set(Evas_Object *obj, const char *part, const char *state, double value, double y); + +/** Get the part name rel1x is relative to. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The state that contain which the part name rel1x is relative to (not including the state value). + * @param value The state value. + * + * @return The part name rel1x is relative to or NULL if the part is relative to the whole interface. + */ +EAPI const char * edje_edit_state_rel1_to_x_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Get the part name rel1y is relative to. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The state that contain which the part name rel1y is relative to (not including the state value). + * @param value The state value. + * + * @return The part name rel1y is relative to or NULL if the part is relative to the whole interface. + */ +EAPI const char * edje_edit_state_rel1_to_y_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Get the part name rel2x is relative to. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The state that contain which the part name rel2x is relative to (not including the state value). + * @param value The state value. + * + * @return The part name rel2x is relative to or NULL if the part is relative to the whole interface. + */ +EAPI const char * edje_edit_state_rel2_to_x_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Get the part name rel2y is relative to. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The state that contain which the part name rel2y is relative to (not including the state value). + * @param value The state value. + * + * @return The part name rel2y is relative to or NULL if the part is relative to the whole interface. + */ +EAPI const char * edje_edit_state_rel2_to_y_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Set the part rel1x is relative to. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to set rel1x is relative to (not including the state value). + * @param value The state value. + * @param rel_to The name of the part that is used as container/parent (NULL make the part relative to the whole interface). + * + * @return The part name rel1x is relative to or NULL if the part is relative to the whole interface. + */ +EAPI void edje_edit_state_rel1_to_x_set(Evas_Object *obj, const char *part, const char *state, double value, const char *rel_to); + +/** Set the part rel1y is relative to. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to set rel1y is relative to (not including the state value). + * @param value The state value. + * @param rel_to The name of the part that is used as container/parent (NULL make the part relative to the whole interface). + * + * @return The part name rel1y is relative to or NULL if the part is relative to the whole interface. + */ +EAPI void edje_edit_state_rel1_to_y_set(Evas_Object *obj, const char *part, const char *state, double value, const char *rel_to); + +/** Set the part rel2x is relative to. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to set rel2x is relative to (not including the state value). + * @param value The state value. + * @param rel_to The name of the part that is used as container/parent (NULL make the part relative to the whole interface). + * + * @return The part name rel2x is relative to or NULL if the part is relative to the whole interface. + */ +EAPI void edje_edit_state_rel2_to_x_set(Evas_Object *obj, const char *part, const char *state, double value, const char *rel_to); + +/** Set the part rel2y is relative to. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to set rel2y is relative to (not including the state value). + * @param value The state value. + * @param rel_to The name of the part that is used as container/parent (NULL make the part relative to the whole interface). + * + * @return The part name rel2y is relative to or NULL if the part is relative to the whole interface. + */ +EAPI void edje_edit_state_rel2_to_y_set(Evas_Object *obj, const char *part, const char *state, double value, const char *rel_to); + +/** Get the color of a part state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get color (not including the state value). + * @param value The state value. + * @param r A pointer to store the red value. + * @param g A pointer to store the green value. + * @param b A pointer to store the blue value. + * @param a A pointer to store the alpha value. + */ +EAPI 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); + +/** Get the color2 of a part state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get color (not including the state value). + * @param value The state value. + * @param r A pointer to store the red value. + * @param g A pointer to store the green value. + * @param b A pointer to store the blue value. + * @param a A pointer to store the alpha value. + */ +EAPI 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); + +/** Get the color3 of a part state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get color (not including the state value). + * @param value The state value. + * @param r A pointer to store the red value. + * @param g A pointer to store the green value. + * @param b A pointer to store the blue value. + * @param a A pointer to store the alpha value. + */ +EAPI 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); + +/** Set the color of a part state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to set color (not including the state value). + * @param value The state value. + * @param r The red value of the color. + * @param g The green value of the color. + * @param b The blue value of the color. + * @param a The alpha value of the color. + */ +EAPI 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); + +/** Set the color2 of a part state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to set color (not including the state value). + * @param value The state value. + * @param r The red value of the color. + * @param g The green value of the color. + * @param b The blue value of the color. + * @param a The alpha value of the color. + */ +EAPI 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); + +/** Set the color3 of a part state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to set color (not including the state value). + * @param value The state value. + * @param r The red value of the color. + * @param g The green value of the color. + * @param b The blue value of the color. + * @param a The alpha value of the color. + */ +EAPI 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); + +/** Get the horizontal align value of a part state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get horizontal align (not including the state value). + * @param value The state value. + * + * @return The horizontal align value for the given state + */ +EAPI double edje_edit_state_align_x_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Get the vertical align value of a part state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get horizontal align (not including the state value). + * @param value The state value. + * + * @return The vertical align value for the given state + */ +EAPI double edje_edit_state_align_y_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Set the horizontal align value of a part state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get horizontal align (not including the state value). + * @param value The state value. + * @param align The new vertical align value. + */ +EAPI void edje_edit_state_align_x_set(Evas_Object *obj, const char *part, const char *state, double value, double align); + +/** Set the vertical align value of a part state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get vertical align (not including the state value). + * @param value The state value. + * @param align The new vertical align value. + */ +EAPI void edje_edit_state_align_y_set(Evas_Object *obj, const char *part, const char *state, double value, double align); + +/** Get the minimum width value of a part state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get minimum width (not including the state value). + * @param value The state value. + * + * @return The minimum width value. + */ +EAPI int edje_edit_state_min_w_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Set the minimum width value of a part state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to set minimum width (not including the state value). + * @param value The state value. + * @param min_w Minimum width value. + */ +EAPI void edje_edit_state_min_w_set(Evas_Object *obj, const char *part, const char *state, double value, int min_w); + +/** Get the minimum height value of a part state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get minimum height (not including the state value). + * @param value The state value. + * + * @return The minimum height value. + */ +EAPI int edje_edit_state_min_h_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Set the minimum height value of a part state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to set minimum height (not including the state value). + * @param value The state value. + * @param min_h Minimum height value. + */ +EAPI void edje_edit_state_min_h_set(Evas_Object *obj, const char *part, const char *state, double value, int min_h); + +/** Get the maximum width value of a part state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get maximum width (not including the state value). + * @param value The state value. + * + * @return The maximum width value. + */ +EAPI int edje_edit_state_max_w_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Set the maximum width value of a part state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to set maximum width (not including the state value). + * @param value The state value. + * @param max_w Maximum width value. + */ +EAPI void edje_edit_state_max_w_set(Evas_Object *obj, const char *part, const char *state, double value, int max_w); + +/** Get the maximum height value of a part state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get maximum height (not including the state value). + * @param value The state value. + * + * @return The maximum height value. + */ +EAPI int edje_edit_state_max_h_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Set the maximum height value of a part state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to set maximum height (not including the state value). + * @param value The state value. + * @param max_h Maximum height value. + */ +EAPI void edje_edit_state_max_h_set(Evas_Object *obj, const char *part, const char *state, double value, int max_h); + +/** Get the minimum aspect value of a part state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get minimum aspect (not including the state value). + * @param value The state value. + * + * @return The minimum aspect + */ +EAPI double edje_edit_state_aspect_min_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Get the maximum aspect value of a part state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get maximum aspect (not including the state value). + * @param value The state value. + * + * @return The maximum aspect + */ +EAPI double edje_edit_state_aspect_max_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Set the minimum aspect value of a part state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to set minimum aspect (not including the state value). + * @param value The state value. + * @param aspect Minimum aspect value. + */ +EAPI void edje_edit_state_aspect_min_set(Evas_Object *obj, const char *part, const char *state, double value, double aspect); + +/** Set the maximum aspect value of a part state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to set maximum aspect (not including the state value). + * @param value The state value. + * @param aspect Maximum aspect value. + */ +EAPI void edje_edit_state_aspect_max_set(Evas_Object *obj, const char *part, const char *state, double value, double aspect); + +/** Get the aspect preference of a part state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get aspect preference (not including the state value). + * @param value The state value. + * + * @return The aspect preference (0 = None, 1 = Vertical, 2 = Horizontal, 3 = Both) + */ +EAPI unsigned char edje_edit_state_aspect_pref_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Set the aspect preference of a part state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to set aspect preference (not + * including the state value). + * @param value The state value. + * @param pref The aspect preference to set (0 = None, 1 = Vertical, 2 + * = Horizontal, 3 = Both) + */ +EAPI void edje_edit_state_aspect_pref_set(Evas_Object *obj, const char *part, const char *state, double value, unsigned char pref); + +/** Get the fill horizontal origin relative value of a part state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get the fill horizontal origin relative to area (not including the state value). + * @param value The state value. + * + * @return The fill horizontal origin relative to area. + */ +EAPI double edje_edit_state_fill_origin_relative_x_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Get the fill vertical origin relative value of a part state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get fill vertical origin relative to area (not including the state value). + * @param value The state value. + * + * @return The fill vertical origin relative to area. + */ +EAPI double edje_edit_state_fill_origin_relative_y_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Get the fill horizontal origin offset value of a part state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get fill horizontal origin offset relative to area (not including the state value). + * @param value The state value. + * + * @return The fill horizontal origin offset relative to area. + */ +EAPI int edje_edit_state_fill_origin_offset_x_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Get the fill vertical origin offset value of a part state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get fill vertical origin offset relative to area (not including the state value). + * @param value The state value. + * + * @return The fill vertical origin offset value. + */ +EAPI int edje_edit_state_fill_origin_offset_y_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Set the fill horizontal origin relative value of a part state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to set fill horizontal origin relative to area (not including the state value). + * @param value The state value. + * @param x The fill horizontal origin value. + */ +EAPI void edje_edit_state_fill_origin_relative_x_set(Evas_Object *obj, const char *part, const char *state, double value, double x); + +/** Set the fill horizontal origin relative value of a part state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to set fill vertical origin relative to area (not including the state value). + * @param value The state value. + * @param y The fill vertical origin value. + */ +EAPI void edje_edit_state_fill_origin_relative_y_set(Evas_Object *obj, const char *part, const char *state, double value, double y); + +/** Set the fill horizontal origin offset value of a part state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to set fill horizontal origin offset relative to area (not including the state value). + * @param value The state value. + * @param x The fill horizontal origin offset value. + */ +EAPI void edje_edit_state_fill_origin_offset_x_set(Evas_Object *obj, const char *part, const char *state, double value, double x); + +/** Set the fill vertical origin offset value of a part state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to set fill vertical origin offset relative to area (not including the state value). + * @param value The state value. + * @param y The fill vertical origin offset value. + */ +EAPI void edje_edit_state_fill_origin_offset_y_set(Evas_Object *obj, const char *part, const char *state, double value, double y); + +/** Get the fill horizontal size relative value of a part state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get fill horizontal size relative to area (not including the state value). + * @param value The state value. + * + * @return The fill horizontal size relative to area. + */ +EAPI double edje_edit_state_fill_size_relative_x_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Get the fill vertical size relative value of a part state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get fill vertical size relative to area (not including the state value). + * @param value The state value. + * + * @return The fill vertical size relative to area. + */ +EAPI double edje_edit_state_fill_size_relative_y_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Get the fill horizontal size offset value of a part state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get fill horizontal size + * offset relative to area (not including the state value). + * @param value The state value. + * + * @return The fill horizontal size offset relative to area. + */ +EAPI int edje_edit_state_fill_size_offset_x_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Get the fill vertical size offset value of a part state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get fill vertical size offset + * relative to area (not including the state value). + * @param value The state value. + * + * @return The fill vertical size offset relative to area. + */ +EAPI int edje_edit_state_fill_size_offset_y_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Set the fill horizontal size relative value of a part state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to set fill horizontal size + * relative value (not including the state value). + * @param value The state value. + * @param x The horizontal size relative value. + */ +EAPI void edje_edit_state_fill_size_relative_x_set(Evas_Object *obj, const char *part, const char *state, double value, double x); + +/** Set the fill vertical size relative value of a part state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to set fill vertical size + * relative value (not including the state value). + * @param value The state value. + * @param x The vertical size relative value. + */ +EAPI void edje_edit_state_fill_size_relative_y_set(Evas_Object *obj, const char *part, const char *state, double value, double x); + +/** Set the fill horizontal size offset value of a part state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to set fill horizontal size + * offset relative value (not including the state value). + * @param value The state value. + * @param x The horizontal size offset value. + */ +EAPI void edje_edit_state_fill_size_offset_x_set(Evas_Object *obj, const char *part, const char *state, double value, double x); + +/** Set the fill vertical size offset value of a part state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to set fill vertical size offset + * relative value (not including the state value). + * @param value The state value. + * @param y The vertical size offset value. + */ +EAPI void edje_edit_state_fill_size_offset_y_set(Evas_Object *obj, const char *part, const char *state, double value, double y); + +/** Get the visibility of a part state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get visibility (not including the state value). + * @param value The state value. + * + * @return EINA_TRUE if the state is visible, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_state_visible_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Set the visibility of a part state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to set visibility (not including the state value). + * @param value The state value. + * @param visible To set state visible (EINA_TRUE if the state is visible, EINA_FALSE otherwise) + */ +EAPI void edje_edit_state_visible_set(Evas_Object *obj, const char *part, const char *state, double value, Eina_Bool visible); + +/** Get the color class of the given part state. + * + * Remember to free the string with edje_edit_string_free() + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get color class (not including the state value). + * @param value The state value. + * + * @return The current color class. + */ +EAPI const char *edje_edit_state_color_class_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Set the color class of the given part state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to set color class (not including the state value). + * @param value The state value. + * @param color_class The color class to assign. + */ +EAPI void edje_edit_state_color_class_set(Evas_Object *obj, const char *part, const char *state, double value, const char *color_class); + +/** Get the list of parameters for an external part. + * + * DO NOT FREE THE LIST! + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get list of Edje_External_Param (not including the state value). + * @param value The state value. + * + * @return The list of Edje_External_Param. + */ +EAPI const Eina_List * edje_edit_state_external_params_list_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Get the external parameter type and value. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get external parameter (not including the state value). + * @param value The state value. + * @param param The name of the paramter to look for. + * @param type The type of the parameter will be stored here. + * @param val Pointer to value will be stored here - DO NOT FREE IT! + * + * @return EINA_TRUE if the parameter was found, EINA_FALSE otherwise. + */ +EAPI 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); + +/** Get external parameter of type INT. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get external parameter of type INT (not including the state value). + * @param value The state value. + * @param param The name of the paramter. + * @param val The value of the parameter. + * + * @return EINA_TRUE if successful. EINA_FALSE if not found or is of different type. + */ +EAPI 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); + +/** Get external parameter of type BOOL. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get external parameter of type BOOL (not including the state value). + * @param value The state value. + * @param param The name of the paramter. + * @param val The value of the parameter. + * + * @return EINA_TRUE if successful. EINA_FALSE if not found or is of different type. + */ +EAPI 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); + +/** Get external parameter of type DOUBLE. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get external parameter of type DOUBLE (not including the state value). + * @param value The state value. + * @param param The name of the paramter. + * @param val The value of the parameter. + * + * @return EINA_TRUE if successful. EINA_FALSE if not found or is of different type. + */ +EAPI 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); + +/** Get external parameter of type STRING. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get external parameter of + * type STRING (not including the state value). + * @param value The state value. + * @param param The name of the paramter. + * @param val The value of the parameter. + * + * @return EINA_TRUE if successful. EINA_FALSE if not found or is of + * different type. + */ +EAPI 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); + +/** Get external parameter of type CHOICE. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get external parameter of + * type CHOICE (not including the state value). + * @param value The state value. + * @param param The name of the paramter. + * @param val The value of the parameter. + * + * @return EINA_TRUE if successful. EINA_FALSE if not found or is of + * different type. + */ +EAPI 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); + +/** Set the external parameter type and value, adding it if it didn't + * exist before. + * + * @param obj Object being edited. + + * @param part Part that contain state. + * @param state The name of the state to get external parameter (not + * including the state value). + * @param value The state value. + * @param param The name of the paramter set. + * @param type The type of the parameter. + * + * @return EINA_TRUE if it was set, EINA_FALSE otherwise. + */ + +/** + * Arguments should have proper sized values matching their types: + * - EDJE_EXTERNAL_PARAM_TYPE_INT: int + * - EDJE_EXTERNAL_PARAM_TYPE_BOOL: int + * - EDJE_EXTERNAL_PARAM_TYPE_DOUBLE: double + * - EDJE_EXTERNAL_PARAM_TYPE_STRING: char* + * - EDJE_EXTERNAL_PARAM_TYPE_CHOICE: char* + * + * @note: The validation of the parameter will occur only if the part + * is in the same state as the one being modified. + */ +EAPI 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, ...); + +/** Set external parameter of type INT. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get external parameter of + * type INT (not including the state value). + * @param value The state value. + * @param param The name of the paramter. + * @param val Value will be stored here. + * + * @return EINA_TRUE if it was set, EINA_FALSE otherwise. + */ +EAPI 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); + +/** Set external parameter of type BOOL. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get external parameter of type BOOL (not including the state value). + * @param value The state value. + * @param param The name of the paramter. + * @param val Value will be stored here. + * + * @return EINA_TRUE if it was set, EINA_FALSE otherwise. + */ +EAPI 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); + +/** Set external parameter of type DOUBLE. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get external parameter of type DOUBLE (not including the state value). + * @param value The state value. + * @param param The name of the paramter. + * @param val Value will be stored here. + * + * @return EINA_TRUE if it was set, EINA_FALSE otherwise. + */ +EAPI 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); + +/** Set external parameter of type STRING. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get external parameter of type STRING (not including the state value). + * @param value The state value. + * @param param The name of the paramter. + * @param val Value will be stored here. + * + * @return EINA_TRUE if it was set, EINA_FALSE otherwise. + */ +EAPI 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); + +/** Set external parameter of type CHOICE. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get external parameter of type CHOICE (not including the state value). + * @param value The state value. + * @param param The name of the paramter. + * @param val Value will be stored here. + * + * @return EINA_TRUE if it was set, EINA_FALSE otherwise. + */ +EAPI 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); + + +//@} +/******************************************************************************/ +/************************** TEXT API ************************************/ +/******************************************************************************/ +/** @name Text API + * Functions to deal with text objects (see @ref edcref). + */ //@{ + +/** Get the text of a part state. + * + * Remember to free the returned string with edje_edit_string_free(). + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get text (not including the state value). + * @param value The state value. + * + * @return A newly allocated string containing the text for the given state. + */ +EAPI const char * edje_edit_state_text_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Set the text of a part state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to set text (not including the state value). + * @param value The state value. + * @param text The new text to assign. + */ +EAPI void edje_edit_state_text_set(Evas_Object *obj, const char *part, const char *state, double value,const char *text); + +/** Get font name for a given part state. + * + * @param obj Object being edited. + * @param part The name of the part to get the font of. + * @param state The state of the part to get the font of. + * @param value Value of the state. + * + * @return Font used by the part or NULL if error or nothing is set. + */ +EAPI const char * edje_edit_state_font_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Set font name for a given part state. + * + * Font name can be any alias of an internal font in the Edje file and, + * if it doesn't match any, Edje will look for a font with the given name + * in the system fonts. + * + * @param obj Object being edited. + * @param part Part to set the font of. + * @param state State in which the font is set. + * @param value Value of the state. + * @param font The font name to use. + */ +EAPI void edje_edit_state_font_set(Evas_Object *obj, const char *part, const char *state, double value, const char *font); + +/** Get the text size of a part state + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get text size (not including the state value). + * @param value The state value. + * + * @return The text size or -1 on errors. + */ +EAPI int edje_edit_state_text_size_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Set the text size of a part state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to set text size (not including the state value). + * @param value The state value. + * @param size The new font size to set (in pixel) + */ +EAPI void edje_edit_state_text_size_set(Evas_Object *obj, const char *part, const char *state, double value, int size); + +/** Get the text horizontal align of a part state. + * + * The value range is from 0.0(right) to 1.0(left) + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get the text horizontal align (not including the state value). + * @param value The state value. + * + * @return The text horizont align value + */ +EAPI double edje_edit_state_text_align_x_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Get the text vertical align of a part state. + * + * The value range is from 0.0(top) to 1.0(bottom) + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get the text vertical align (not including the state value). + * @param value The state value. + * + * @return The text horizont align value + */ +EAPI double edje_edit_state_text_align_y_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Set the text horizontal align of a part state. + * + * The value range is from 0.0(right) to 1.0(left) + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to set the text horizontal align (not including the state value). + * @param value The state value. + * @param align The new text horizontal align value + */ +EAPI void edje_edit_state_text_align_x_set(Evas_Object *obj, const char *part, const char *state, double value, double align); + +/** Set the text vertical align of a part state. + * + * The value range is from 0.0(top) to 1.0(bottom) + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to set the text vertical align (not including the state value). + * @param value The state value. + * @param align The new text vertical align value + */ +EAPI void edje_edit_state_text_align_y_set(Evas_Object *obj, const char *part, const char *state, double value, double align); + +/** Get the text elipsis of a part state. + * + * The value range is from 0.0(right) to 1.0(left) + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get the text elipses value (not including the state value). + * @param value The state value. + * + * @return The text elipsis value + */ +EAPI double edje_edit_state_text_elipsis_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Set the text vertical align of a part state. + * + * The value range is from 0.0(right) to 1.0(left) + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to set the text elipses value (not including the state value). + * @param value The state value. + * @param balance The position where to cut the string + */ +EAPI void edje_edit_state_text_elipsis_set(Evas_Object *obj, const char *part, const char *state, double value, double balance); + +/** Get if the text part fit it's container horizontally + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get the if the text part fit it's container horizontally (not including the state value). + * @param value The state value. + * + * @return EINA_TRUE If the part fit it's container horizontally, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_state_text_fit_x_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Set if the text part should fit it's container horizontally + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to set the if the text part fit it's container horizontally (not including the state value). + * @param value The state value. + * @param fit EINA_TRUE to make the text fit it's container horizontally, EINA_FALSE otherwise. + */ +EAPI void edje_edit_state_text_fit_x_set(Evas_Object *obj, const char *part, const char *state, double value, Eina_Bool fit); + +/** Get if the text part fit it's container vertically + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get the if the text part fit it's container vertically (not including the state value). + * @param value The state value. + * + * @return EINA_TRUE If the part fit it's container vertically, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_state_text_fit_y_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Set if the text part should fit it's container vertically + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to set the if the text part fit it's container vertically (not including the state value). + * @param value The state value. + * @param fit EINA_TRUE to make the text fit it's container vertically, EINA_FALSE otherwise. + */ +EAPI void edje_edit_state_text_fit_y_set(Evas_Object *obj, const char *part, const char *state, double value, Eina_Bool fit); + +/** Get the list of all the fonts in the given edje. + * + * Use edje_edit_string_list_free() when you don't need the list anymore. + * + * @param obj Object being edited. + * + * @return A list containing all the fonts names found in the edje file. + */ +EAPI Eina_List * edje_edit_fonts_list_get(Evas_Object *obj); + +/** Add a new font to the edje file. + * + * The newly created font will be available to all the groups in the edje, not only the current one. + * + * @param obj Object being edited. + * @param path The file path to load the font from. + * @param alias The alias for file, or NULL to use filename + * + * @return EINA_TRUE if font cat be loaded, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_font_add(Evas_Object *obj, const char *path, const char* alias); + +/** Delete font from the edje file. + * + * The font will be removed from all the groups in the edje, not only the current one. + * + * @param obj Object being edited. + * @param alias The font alias + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise (including the + * case when the alias is not valid). + */ +EAPI Eina_Bool edje_edit_font_del(Evas_Object *obj, const char* alias); + +/** Get font path for a given font alias. + * + * Remember to free the string with edje_edit_string_free() + * + * @param obj Object being edited. + * @param alias The font alias. + * + * @return The path of the given font alias. + */ +EAPI const char *edje_edit_font_path_get(Evas_Object *obj, const char *alias); + + +/** Get font name for a given part state. + * + * Remember to free the returned string using edje_edit_string_free(). + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get the name of the font used (not including the state value). + * @param value The state value. + * + * @return The name of the font used in the given part state. + */ +EAPI const char * edje_edit_state_font_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Set font name for a given part state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to set the name of the font that will be used (not including the state value). + * @param value The state value. + * @param font The name of the font to use in the given part state. + */ +EAPI void edje_edit_state_font_set(Evas_Object *obj, const char *part, const char *state, double value, const char *font); + + +//@} +/******************************************************************************/ +/************************** IMAGES API ************************************/ +/******************************************************************************/ +/** @name Images API + * Functions to deal with image objects (see @ref edcref). + */ //@{ + +/** Get the list of all the images in the given edje. + * Use edje_edit_string_list_free() when you don't need the list anymore. + * + * @param obj Object being edited. + * + * @return A List containing all images names found in the edje file. + */ +EAPI Eina_List * edje_edit_images_list_get(Evas_Object *obj); + +/** Add an new image to the image collection + * + * This function add the given image inside the edje. Don't add a new image part + * but only put the image inside the edje file. It actually write directly to + * the file so you don't have to save. + * After you have to create a new image_part that use this image. Note that all + * the parts in the edje share the same image collection, thus you can/must use + * the same image for different part. + * + * The format of the image files that can be loaded depend on the evas engine on your system + * + * @param obj Object being edited. + * @param path The name of the image file to include in the edje. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_image_add(Evas_Object *obj, const char *path); + +/** Delete an image from the image collection + * + * It actually write directly to the file so you don't have to save. + * + * @param obj Object being edited. + * @param name The name of the image file to include in the edje. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise (including the + * case when the name is not valid). + */ +EAPI Eina_Bool edje_edit_image_del(Evas_Object *obj, const char *name); + +/** Add an image entry to the image collection + * + * This function adds the given image entry to the edje image collection. The + * image needs to be inside the eet already, with key name "images/id". After + * you have to create a new image_part that use this image, referring to it as + * "name". Note that all the parts in the edje share the same image collection, + * thus you can/must use the same image for different part. + * + * @param obj Object being edited. + * @param name The image entry name. + * @param id The image id. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_image_data_add(Evas_Object *obj, const char *name, int id); + +/** Get normal image name for a given part state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get the name that is being used (not including the state value). + * @param value The state value. + * + * @return The name of the image used by state. + */ +EAPI const char * edje_edit_state_image_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Set normal image for a given part state. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to set the image that will be used (not including the state value). + * @param value The state value. + * @param image The name of the image (must be an image contained in the edje file). + */ +EAPI void edje_edit_state_image_set(Evas_Object *obj, const char *part, const char *state, double value, const char *image); + +/** Get image id for a given image name. + * + * @param obj Object being edited. + * @param image_name The image name. + * + * @return The id of the given image name. + */ +EAPI int edje_edit_image_id_get(Evas_Object *obj, const char *image_name); + +/** Get compression type for the given image. + * + * @param obj Object being edited. + * @param image The name of the image. + * + * @return One of Image Compression types. + * (EDJE_EDIT_IMAGE_COMP_RAW, EDJE_EDIT_IMAGE_COMP_USER, EDJE_EDIT_IMAGE_COMP_COMP, EDJE_EDIT_IMAGE_COMP_LOSSY). + */ +EAPI Edje_Edit_Image_Comp edje_edit_image_compression_type_get(Evas_Object *obj, const char *image); + +/** Get compression rate for the given image. + * + * @param obj Object being edited. + * @param image The name of the image. + * + * @return The compression rate (if the imnage is @c + * EDJE_EDIT_IMAGE_COMP_LOSSY) or < 0, on errors. + */ +EAPI int edje_edit_image_compression_rate_get(Evas_Object *obj, const char *image); + +/** Get the image border of a part state. + * + * Pass NULL to any of [r,g,b,a] to get only the others. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get the image border (not + * including the state value). + * @param value The state value. + * @param l A pointer to store the left value + * @param r A pointer to store the right value + * @param t A pointer to store the top value + * @param b A pointer to store the bottom value + */ +EAPI 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); + +/** Set the image border of a part state. + * + * Pass -1 to any of [l,r,t,b] to leave the value untouched. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to set the image border (not + * including the state value). + * @param value The state value. + * @param l Left border value (or -1). + * @param r Right border value (or -1). + * @param t Top border value (or -1). + * @param b Bottom border value (or -1). + */ +EAPI 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); + +/** Get if the image center should be draw. + * + * 1 means to draw the center, 0 to don't draw it. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get the image border fill (not including the state value). + * @param value The state value. + * + * @return 1 if the center of the bordered image is draw, 0 otherwise. + */ +EAPI unsigned char edje_edit_state_image_border_fill_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Set if the image center should be draw. + * + * 1 means to draw the center, 0 to don't draw it. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to set the image border fill (not including the state value). + * @param value The state value. + * @param fill Fill to be se. 1 if the center of the bordered image is draw, 0 otherwise. + */ +EAPI void edje_edit_state_image_border_fill_set(Evas_Object *obj, const char *part, const char *state, double value, unsigned char fill); + +/** Get the list of all the tweens images in the given part state. + * + * Use edje_edit_string_list_free() when you don't need it anymore. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to get the list of all the tweens images (not including the state value). + * @param value The state value. + * + * @return A string list containing all the image name that form a tween animation in the given part state. + */ +EAPI Eina_List * edje_edit_state_tweens_list_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Add a new tween frame to the given part state. + * + * The tween param must be the name of an existing image. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to add a new tween frame (not including the state value). + * @param value The state value. + * @param tween The name of the image to add. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_state_tween_add(Evas_Object *obj, const char *part, const char *state, double value, const char *tween); + +/** Remove the first tween with the given name. + * + * The image is not removed from the edje. + * + * @param obj Object being edited. + * @param part Part that contain state. + * @param state The name of the state to del the tween (not including the state value). + * @param value The state value. + * @param tween The name of the image to del. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_state_tween_del(Evas_Object *obj, const char *part, const char *state, double value, const char *tween); + + +//@} +/******************************************************************************/ +/************************* SPECTRUM API ***********************************/ +/******************************************************************************/ +/** @name Spectrum API + * Functions to manage spectrum (see @ref edcref). + */ //@{ + +/** Get the list of all the spectrum in the given edje object. + * + * Use edje_edit_string_list_free() when you don't need it anymore. + * + * @param obj Object being edited. + * + * @return A list containing all the spectra names. + */ +EAPI Eina_List * edje_edit_spectrum_list_get(Evas_Object *obj); + +/** Add a new spectra in the given edje object. + * + * @param obj Object being edited. + * @param name The name of the spectra to include in the edje. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_spectra_add(Evas_Object *obj, const char *name); + +/** Delete the given spectra from the edje object. + * + * @param obj Object being edited. + * @param spectra The name of the spectra to delete. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_spectra_del(Evas_Object *obj, const char *spectra); + +/** Change the name of the given spectra. + * + * @param obj Object being edited. + * @param spectra The name of the current spectra. + * @param name The new name to assign. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_spectra_name_set(Evas_Object *obj, const char *spectra, const char *name); + +/** Get the number of stops in the given spectra. + * + * @param obj Object being edited. + * @param spectra The name of the spectra. + * + * @return The number of stops (or 0 on errors). + */ +EAPI int edje_edit_spectra_stop_num_get(Evas_Object *obj, const char *spectra); + +/** Set the number of stops in the given spectra. + * + * @param obj Object being edited. + * @param spectra The name of the spectra. + * @param num The number of stops you want + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_spectra_stop_num_set(Evas_Object *obj, const char *spectra, int num); + +/** Get the colors of the given stop. + * + * @param obj Object being edited. + * @param spectra The name of the spectra. + * @param stop_number The number of the stop, + * @param r Where to store the red color value, + * @param g Where to store the green color value, + * @param b Where to store the blue color value, + * @param a Where to store the alpha color value, + * @param d Where to store the delta stop value, + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI 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); + +/** Set the colors of the given stop. + * + * @param obj Object being edited. + * @param spectra The name of the spectra. + * @param stop_number The number of the stops, + * @param r The red color value to set, + * @param g The green color value to set, + * @param b The blue color value to set, + * @param a The alpha color value to set, + * @param d The delta stop value to set, + */ +EAPI 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); + + +//@} +/******************************************************************************/ +/************************* GRADIENT API ***********************************/ +/******************************************************************************/ +/** @name Gradient API + * Functions to deal with gradient objects (see @ref edcref). + */ //@{ + +/** Get the type of gradient. + * + * Remember to free the string with edje_edit_string_free(). + * + * @param obj Object being edited. + * @param part The part that contain state. + * @param state The name of the state to get the gradient type (not including the state value). + * @param value The state value. + * + * @return The type of gradient used in state. + * (linear, linear.diag, linear.codiag, radial, rectangular, angular, sinosoidal) + */ +EAPI const char * edje_edit_state_gradient_type_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Set the type of gradient. + * + * Gradient type can be on of the following: linear, linear.diag, linear.codiag, radial, rectangular, angular, sinusoidal + * + * @param obj Object being edited. + * @param part The part that contain state. + * @param state The name of the state to set the gradient type (not including the state value). + * @param value The state value. + * @param type The type of gradient to use. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_state_gradient_type_set(Evas_Object *obj, const char *part, const char *state, double value, const char *type); + +/** Get if the current gradient use the fill properties or the gradient_rel as params. + * + * @param obj Object being edited. + * @param part The part that contain state. + * @param state The name of the state to set the gradient type (not including the state value). + * @param value The state value. + * + * @return EINA_TRUE if gradient use the fill properties, EINA_FALSE otherwise. + * */ +EAPI Eina_Bool edje_edit_state_gradient_use_fill_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Get the spectra used by part state. + * + * Remember to free the string with edje_edit_string_free(). + * + * @param obj Object being edited. + * @param part The part that contain state. + * @param state The name of the state to get the spectra name used (not including the state value). + * @param value The state value. + * + * @return The spectra name used in state. + */ +EAPI const char * edje_edit_state_gradient_spectra_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Set the spectra used by part state. + * + * @param obj Object being edited. + * @param part The part that contain state. + * @param state The name of the state to set the spectra (not including the state value). + * @param value The state value. + * @param spectra The spectra name to assign + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_state_gradient_spectra_set(Evas_Object *obj, const char *part, const char *state, double value, const char *spectra); + +/** Get the angle of the gradient. + * + * @param obj Object being edited. + * @param part The part that contain state. + * @param state The name of the state to get the angle (not including the state value). + * @param value The state value. + * + * @return The angle of the gradient. + */ +EAPI int edje_edit_state_gradient_angle_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Set the angle of the gradient. + * + * @param obj Object being edited. + * @param part The part that contain state. + * @param state The name of the state to set the angle (not including the state value). + * @param value The state value. + * @param angle The angle to set. + */ +EAPI void edje_edit_state_gradient_angle_set(Evas_Object *obj, const char *part, const char *state, double value, int angle); + +/** Get the gradient rel1 horizontal relative value + * + * @param obj Object being edited. + * @param part The part that contain state. + * @param state The name of the state to get rel1 relative x value (not including the state value). + * @param value The state value. + * + * @return The gradient rel1 horizontal relative value. + */ +EAPI double edje_edit_state_gradient_rel1_relative_x_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Get the gradient rel1 vertical relative value + * + * @param obj Object being edited. + * @param part The part that contain state. + * @param state The name of the state to get rel1 relative y value (not including the state value). + * @param value The state value. + * + * @return The gradient rel1 vertical relative value. + */ +EAPI double edje_edit_state_gradient_rel1_relative_y_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Get the gradient rel2 horizontal relative value + * + * @param obj Object being edited. + * @param part The part that contain state. + * @param state The name of the state to get rel2 relative x value (not including the state value). + * @param value The state value. + * + * @return The gradient rel2 horizontal relative value. + */ +EAPI double edje_edit_state_gradient_rel2_relative_x_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Get the gradient rel2 vertical relative value + * + * @param obj Object being edited. + * @param part The part that contain state. + * @param state The name of the state to get rel2 relative y value (not including the state value). + * @param value The state value. + * + * @return The gradient rel2 vertical relative value. + */ +EAPI double edje_edit_state_gradient_rel2_relative_y_get(Evas_Object *obj, const char *part, const char *state, double value); + + +/** Set the gradient rel1 horizontal relative value + * + * @param obj Object being edited. + * @param part The part that contain state. + * @param state The name of the state to set rel1 relative x value (not including the state value). + * @param value The state value. + * @param val The rel1 relative x to be set, + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise.. + */ +EAPI Eina_Bool edje_edit_state_gradient_rel1_relative_x_set(Evas_Object *obj, const char *part, const char *state, double value, double val); + + +/** Set the gradient rel1 vertical relative value + * + * @param obj Object being edited. + * @param part The part that contain state. + * @param state The name of the state to set rel1 relative y value (not including the state value). + * @param value The state value. + * @param val The rel1 relative y to be set, + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise.. + */ +EAPI Eina_Bool edje_edit_state_gradient_rel1_relative_y_set(Evas_Object *obj, const char *part, const char *state, double value, double val); + +/** Set the gradient rel2 horizontal relative value + * + * @param obj Object being edited. + * @param part The part that contain state. + * @param state The name of the state to set rel2 relative x value (not including the state value). + * @param value The state value. + * @param val The rel2 relative x to be set, + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise.. + */ +EAPI Eina_Bool edje_edit_state_gradient_rel2_relative_x_set(Evas_Object *obj, const char *part, const char *state, double value, double val); + +/** Set the gradient rel2 vertical relative value + * + * @param obj Object being edited. + * @param part The part that contain state. + * @param state The name of the state to set rel2 relative y value (not including the state value). + * @param value The state value. + * @param val The rel2 relative y to be set, + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise.. + */ +EAPI Eina_Bool edje_edit_state_gradient_rel2_relative_y_set(Evas_Object *obj, const char *part, const char *state, double value, double val); + +/** Get the gradient rel1 horizontal offset value + * + * @param obj Object being edited. + * @param part The part that contain state. + * @param state The name of the state to get rel1 offset x value (not including the state value). + * @param value The state value. + * + * @return The gradient rel1 horizontal offset value. + */ +EAPI int edje_edit_state_gradient_rel1_offset_x_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Get the gradient rel1 vertical offset value + * + * @param obj Object being edited. + * @param part The part that contain state. + * @param state The name of the state to get rel1 offset y value (not including the state value). + * @param value The state value. + * + * @return The gradient rel1 vertical offset value. + */ +EAPI int edje_edit_state_gradient_rel1_offset_y_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Get the gradient rel2 horizontal offset value + * + * @param obj Object being edited. + * @param part The part that contain state. + * @param state The name of the state to get rel2 offset x value (not including the state value). + * @param value The state value. + * + * @return The gradient rel2 horizontal offset value. + */ +EAPI int edje_edit_state_gradient_rel2_offset_x_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Get the gradient rel2 vertical offset value + * + * @param obj Object being edited. + * @param part The part that contain state. + * @param state The name of the state to get rel2 offset y value (not including the state value). + * @param value The state value. + * + * @return The gradient rel2 vertical offset value. + */ +EAPI int edje_edit_state_gradient_rel2_offset_y_get(Evas_Object *obj, const char *part, const char *state, double value); + +/** Set the gradient rel1 horizontal offset value + * + * @param obj Object being edited. + * @param part The part that contain state. + * @param state The name of the state to set rel1 offset x value (not including the state value). + * @param value The state value. + * @param val The rel1 offset x value. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_state_gradient_rel1_offset_x_set(Evas_Object *obj, const char *part, const char *state, double value, int val); + +/** Set the gradient rel1 vertical offset value + * + * @param obj Object being edited. + * @param part The part that contain state. + * @param state The name of the state to set rel1 offset y value (not including the state value). + * @param value The state value. + * @param val The rel1 offset y value. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_state_gradient_rel1_offset_y_set(Evas_Object *obj, const char *part, const char *state, double value, int val); + +/** Set the gradient rel2 horizontal offset value + * + * @param obj Object being edited. + * @param part The part that contain state. + * @param state The name of the state to set rel2 offset x value (not including the state value). + * @param value The state value. + * @param val The rel2 offset x value. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_state_gradient_rel2_offset_x_set(Evas_Object *obj, const char *part, const char *state, double value, int val); + +/** Set the gradient rel2 vertical offset value + * + * @param obj Object being edited. + * @param part The part that contain state. + * @param state The name of the state to set rel2 offset y value (not including the state value). + * @param value The state value. + * @param val The rel2 offset y value. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_state_gradient_rel2_offset_y_set(Evas_Object *obj, const char *part, const char *state, double value, int val); + + +//@} +/******************************************************************************/ +/************************* PROGRAMS API ***********************************/ +/******************************************************************************/ +/** @name Programs API + * Functions to deal with programs (see @ref edcref). + */ //@{ + +/** Get the list of all the programs in the given edje object. + * + * Use edje_edit_string_list_free() when you don't need it anymore. + * + * @param obj Object being edited. + * + * @return A list containing all the program names. + */ +EAPI Eina_List * edje_edit_programs_list_get(Evas_Object *obj); + +/** Add a new program to the edje file + * + * If a program with the same name just exist the function will fail. + * + * @param obj Object being edited. + * @param name The name of the new program. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_program_add(Evas_Object *obj, const char *name); + +/** Remove the given program from the edje file. + * + * @param obj Object being edited. + * @param prog The name of the program to remove. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_program_del(Evas_Object *obj, const char *prog); + +/** Check if a program with the given name exist in the edje object. + * + * @param obj Object being edited. + * @param prog The prog of the program that will be searched. + * + * @return EINA_TRUE if the program exist, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_program_exist(Evas_Object *obj, const char *prog); + +/** Run the given program. + * + * @param obj Object being edited. + * @param prog The name of the program to execute. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_program_run(Evas_Object *obj, const char *prog); + +/** Set a new name for the given program + * + * @param obj Object being edited. + * @param prog The current program name. + * @param new_name The new name to assign. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_program_name_set(Evas_Object *obj, const char *prog, const char *new_name); + +/** Get source of a given program. + * + * Remember to free the returned string using edje_edit_string_free(). + * + * @param obj Object being edited. + * @param prog The name of the program to get source. + * + * @return The source value por program. + */ +EAPI const char * edje_edit_program_source_get(Evas_Object *obj, const char *prog); + +/** Set source of the given program. + * + * @param obj Object being edited. + * @param prog The name of the program to set source. + * @param source The new source value. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_program_source_set(Evas_Object *obj, const char *prog, const char *source); + +/** Get signal of a given program. + * + * Remember to free the returned string using edje_edit_string_free(). + * + * @param obj Object being edited. + * @param prog The name of the program to get the signal. + * + * @return The signal value for program. + */ +EAPI const char * edje_edit_program_signal_get(Evas_Object *obj, const char *prog); + +/** Set signal of the given program. + * + * @param obj Object being edited. + * @param prog The name of the program to set the signal. + * @param signal The new signal value. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_program_signal_set(Evas_Object *obj, const char *prog, const char *signal); + +/** Get in.from of a given program. + * + * @param obj Object being edited. + * @param prog The name of the program to get the delay. + * + * @return The delay. + */ +EAPI double edje_edit_program_in_from_get(Evas_Object *obj, const char *prog); + +/** Set in.from of a given program. + * + * @param obj Object being edited. + * @param prog The name of the program to set the delay. + * @param seconds Number of seconds to delay the program execution + * + * */ +EAPI Eina_Bool edje_edit_program_in_from_set(Evas_Object *obj, const char *prog, double seconds); + +/** Get in.range of a given program. + * + * @param obj Object being edited. + * @param prog The name of the program to get random delay. + * + * @return The delay random. + */ +EAPI double edje_edit_program_in_range_get(Evas_Object *obj, const char *prog); + +/** Set in.range of a given program. + * + * @param obj Object being edited. + * @param prog The name of the program to set random delay. + * @param seconds Max random number of seconds to delay. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_program_in_range_set(Evas_Object *obj, const char *prog, double seconds); + +/** Get the action of a given program. + * + * @param obj Object being edited. + * @param prog The name of the program to get the action. + * + * @return The action type, or -1 on errors. + * 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 + */ +EAPI Edje_Action_Type edje_edit_program_action_get(Evas_Object *obj, const char *prog); + +/** Set the action of a given program. + * + * 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 + * + * @param obj Object being edited. + * @param prog The name of the program to set the action. + * @param action The new action type. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_program_action_set(Evas_Object *obj, const char *prog, Edje_Action_Type action); + +/** Get the list of the targets for the given program. + * + * Use edje_edit_string_list_free() when you don't need it anymore. + * + * @param obj Object being edited. + * @param prog The name of the progrem to get the list of the targets. + * + * @return A list with all the targets names, or NULL on error. + */ +EAPI Eina_List * edje_edit_program_targets_get(Evas_Object *obj, const char *prog); + +/** Add a new target program to the list of 'targets' in the given program. + * + * If program action is @c EDJE_ACTION_TYPE_ACTION_STOP, then 'target' + * must be an existing program name. If it's @c + * EDJE_ACTION_TYPE_STATE_SET, then 'target' must be an existing part + * name. + * + * @param obj Object being edited. + * @param prog The name of the program to add a new target. + * @param target The name of the new target itself. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_program_target_add(Evas_Object *obj, const char *prog, const char *target); + +/** Deletes a target from the list of 'targets' in the given program. + * + * If program action is EDJE_ACTION_TYPE_ACTION_STOP then 'target' must be an existing program name. + * If action is EDJE_ACTION_TYPE_STATE_SET then 'target' must be an existing part name. + * + * @param obj Object being edited. + * @param prog The name of the program to del a target from the list of targets. + * @param target The name of another program or another part. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_program_target_del(Evas_Object *obj, const char *prog, const char *target); + +/** Clear the 'targets' list of the given program + * + * @param obj Object being edited. + * @param prog The name of the program to cleaar the 'targets' list. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_program_targets_clear(Evas_Object *obj, const char *prog); + +/** Get the list of action that will be run after the give program + * + * Use edje_edit_string_list_free() when you don't need it anymore. + * + * @param obj Object being edited. + * @param prog The name of the program to get the list of actions + * + * @return A list with all program names. or NULL on error. + */ +EAPI Eina_List * edje_edit_program_afters_get(Evas_Object *obj, const char *prog); + +/** Add a new program name to the list of 'afters' in the given program. + * + * All the programs listed in 'afters' will be executed after program execution. + * + * @param obj Object being edited. + * @param prog The name of the program that contains the list of afters + * @param after The name of another program to add to the afters list + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_program_after_add(Evas_Object *obj, const char *prog, const char *after); + +/** Delete the given program from the list of 'afters' of the program. + * + * @param obj Object being edited. + * @param prog The name of the program from where to remove the after. + * @param after The name of the program to remove from the list of afters. + * + * @return EINA_TRUE is successful or not in the list, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_program_after_del(Evas_Object *obj, const char *prog, const char *after); + +/** Clear the 'afters' list of the given program. + * + * @param obj Object being edited. + * @param prog The name of the program to clear the 'afters' list. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_program_afters_clear(Evas_Object *obj, const char *prog); + +/** Get the state for the given program + * + * In a STATE_SET action this is the name of state to set. + * In a SIGNAL_EMIT action is the name of the signal to emit. + * + * @param obj Object being edited. + * @param prog The name of the program to get the state. + * + * @return The name of the state. + */ +EAPI const char * edje_edit_program_state_get(Evas_Object *obj, const char *prog); + +/** Get api's name of a program. + * + * @param obj Object being edited. + * @param prog Name of program. + * + * @return name of the api if successful, NULL otherwise. + */ +EAPI const char * edje_edit_program_api_name_get(Evas_Object *obj, const char *prog); + +/** Get api's description of a program. + * + * @param obj Object being edited. + * @param prog Name of program. + * + * @return description of the api if successful, NULL otherwise. + */ +EAPI const char * edje_edit_program_api_description_get(Evas_Object *obj, const char *prog); + +/** Set api's name of a program. + * + * @param obj Object being edited. + * @param prog Name of the part. + * @param name New name for the api property. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_program_api_name_set(Evas_Object *obj, const char *prog, const char *name); + +/** Set api's description of a program. + * + * @param obj Object being edited. + * @param prog Name of the program. + * @param description New description for the api property. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_program_api_description_set(Evas_Object *obj, const char *prog, const char *description); + +/** Set the state for the given program + * + * In a STATE_SET action this is the name of state to set. + * In a SIGNAL_EMIT action is the name of the signal to emit. + * + * @param obj Object being edited. + * @param prog The name of the program to set a state. + * @param state The nameo of the state to set (not including the state value) + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_program_state_set(Evas_Object *obj, const char *prog, const char *state); + +/** Get the value of state for the given program. + * + * In a STATE_SET action this is the value of state to set. + * Not used on SIGNAL_EMIT action. + * + * @param obj Object being edited. + * @param prog The name of the program to get the value of state. + * + * @return The value of state for the program. + */ +EAPI double edje_edit_program_value_get(Evas_Object *obj, const char *prog); + +/** Set the value of state for the given program. + * + * In a STATE_SET action this is the value of state to set. + * Not used on SIGNAL_EMIT action. + * + * @param obj Object being edited. + * @param prog The name of the program to set the value of state. + * @param value The vale to set. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_program_value_set(Evas_Object *obj, const char *prog, double value); + +/** Get the state2 for the given program + * + * In a STATE_SET action is not used + * In a SIGNAL_EMIT action is the source of the emitted signal. + * + * @param obj Object being edited. + * @param prog The name of the program to get the state2. + * + * @return The source to emit for the program. + */ +EAPI const char * edje_edit_program_state2_get(Evas_Object *obj, const char *prog); + +/** Set the state2 for the given program + * + * In a STATE_SET action is not used + * In a SIGNAL_EMIT action is the source of the emitted signal. + * + * @param obj Object being edited. + * @param prog The name of the program to set the state2. + * @param state2 The name of the state to set. + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_program_state2_set(Evas_Object *obj, const char *prog, const char *state2); + +/** Get the value of state2 for the given program. + * + * @param obj Object being edited. + * @param prog The name of the program to get the state2 value. + * + * @return The vale of the state2 for the program. + */ +EAPI double edje_edit_program_value2_get(Evas_Object *obj, const char *prog); + +/** Set the value2 of state for the given program. + * + * This is used in DRAG_ACTION + * + * @param obj Object being edited. + * @param prog The name of the program to set the state2 value. + * @param value The value of the state2 to set. + */ +EAPI Eina_Bool edje_edit_program_value2_set(Evas_Object *obj, const char *prog, double value); + +/** Get the type of transition to use when apply animations. + * + * 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. + * + * @param obj Object being edited. + * @param prog The name of the program to get the transition. + * + * @return The type of transition used by program. + */ +EAPI Edje_Tween_Mode edje_edit_program_transition_get(Evas_Object *obj, const char *prog); + +/** Set the type of transition to use when apply animations. + * + * 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. + * + * @param obj Object being edited. + * @param prog The name of the program to set the transition. + * @param transition The transition type to set + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_program_transition_set(Evas_Object *obj, const char *prog, Edje_Tween_Mode transition); + +/** Get the duration of the transition in seconds. + * + * @param obj Object being edited. + * @param prog The name of the program to get the transition time. + * + * @return The duration of the transition. + */ +EAPI double edje_edit_program_transition_time_get(Evas_Object *obj, const char *prog); + +/** Set the duration of the transition in seconds. + * + * @param obj Object being edited. + * @param prog The name of the program to set the transition time. + * @param seconds The duration of the transition (in seconds). + * + * @return EINA_TRUE if successful, EINA_FALSE otherwise. + */ +EAPI Eina_Bool edje_edit_program_transition_time_set(Evas_Object *obj, const char *prog, double seconds); + +EAPI const char * edje_edit_program_filter_part_get(Evas_Object *obj, const char *prog); +EAPI Eina_Bool edje_edit_program_filter_part_set(Evas_Object *obj, const char *prog, const char *filter_part); + +//@} +/******************************************************************************/ +/************************** SCRIPTS API ***********************************/ +/******************************************************************************/ +/** @name Scripts API + * Functions to deal with embryo scripts (see @ref edcref). + */ //@{ + +/** + * Get the Embryo script for the group of the given object. + * + * Get the shared script for the group under edition. Shared script means + * the script {} block for the group, not counting what's in each program. + * It returns a malloc'd duplicate of the code, so users are free to modify + * the contents directly and they should remember to free() it when done. + * NULL will be returned if there's no script or an error occurred. + * + * @param obj Object being edited. + * + * @return The shared script code for this group. + */ +EAPI char *edje_edit_script_get(Evas_Object *obj); + +/** + * Set the code for the group script. + * + * Set the Embryo source code for the shared script of the edited group. + * Note that changing the code itself will not update the running VM, you + * need to call edje_edit_script_compile for it to get updated. + * + * @param obj The object being edited + * @param code The Embryo source + */ +EAPI void edje_edit_script_set(Evas_Object *obj, const char *code); + +/** + * Get the Embryo script for the given program. + * + * Get the script code for the given program. Like the group script, this + * function returns a duplicate of the code that the user can modify at will + * and must free when done using it. + * NULL will be returned if the program doesn't exist, doesn't have any + * script or is not of type script. + * + * @param obj Object being edited + * @param prog Program name + * + * @return The program script code + */ +EAPI char *edje_edit_script_program_get(Evas_Object *obj, const char *prog); + +/** + * Set the Embryo script for the given program. + * + * Set the Embryo source code for the program @p prog. It must be an + * existing program of type EDJE_ACTION_TYPE_SCRIPT, or the function + * will fail and do nothing. + * Note that changing the code itself will not update the running VM, you + * need to call edje_edit_script_compile for it to get updated. + * + * @param obj The object being edited + * @param prog The program name. + * @param code The Embryo source + */ +EAPI void edje_edit_script_program_set(Evas_Object *obj, const char *prog, const char *code); + +/** + * Compile the Embryo script for the given object + * + * If required, this function will process all script code for the group and + * build the bytecode, updating the running Embryo VM Program if the build + * is succesful. + * + * @param obj The object being edited + * + */ +EAPI Eina_Bool edje_edit_script_compile(Evas_Object *obj); + +/** + * Get the list of errors resulting from the last script build + * + * Get the list of errors that resulted from the last attempt to rebuild + * the Embryo script for the edited group. This will be a standard Eina_List + * with Edje_Edit_Script_Error pointers as its data. + * The user should not do anything else but read the contents of this list. + * These errors can be the output of the embryo compiler, or internal errors + * generated by Edje_Edit if the preprocessing of the scripts failed. + * + * @param obj The object being edited + * + * @return A constant list of Edje_Edit_Script_Error, or NULL if there are none + */ +EAPI const Eina_List *edje_edit_script_error_list_get(Evas_Object *obj); + +//@} +/******************************************************************************/ +/************************** ERROR API ***********************************/ +/******************************************************************************/ +/** @name Error API + * to deal with error messages (see @ref edcref). + */ //@{ + +EAPI extern Eina_Error EDJE_EDIT_ERROR_GROUP_CURRENTLY_USED; +EAPI extern Eina_Error EDJE_EDIT_ERROR_GROUP_REFERENCED; +EAPI extern Eina_Error EDJE_EDIT_ERROR_GROUP_DOES_NOT_EXIST; + + +#ifdef __cplusplus +} +#endif + +#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 @@ + +MAINTAINERCLEANFILES = Makefile.in + +AM_CPPFLAGS = \ +-I. \ +-I$(top_srcdir) \ +-I$(top_srcdir)/src/bin \ +-I$(top_srcdir)/src/lib \ +-DPACKAGE_BIN_DIR=\"$(bindir)\" \ +-DPACKAGE_LIB_DIR=\"$(libdir)\" \ +-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \ +@EVIL_CFLAGS@ \ +@EDJE_CFLAGS@ \ +@ECORE_IMF_CFLAGS@ \ +@EFL_EDJE_BUILD@ \ +@REMIX_CFLAGS@ \ +@SNDFILE_CFLAGS@ + +lib_LTLIBRARIES = libedje.la + +includes_HEADERS = Edje.h Edje_Edit.h +includesdir = $(includedir)/edje-@VMAJ@ + +base_sources = \ +edje_box_layout.c \ +edje_cache.c \ +edje_calc.c \ +edje_callbacks.c \ +edje_container.c \ +edje_data.c \ +edje_edit.c \ +edje_embryo.c \ +edje_entry.c \ +edje_external.c \ +edje_load.c \ +edje_lua.c \ +edje_lua2.c \ +edje_lua_script_only.c \ +edje_main.c \ +edje_match.c \ +edje_message_queue.c \ +edje_misc.c \ +edje_module.c \ +edje_multisense.c \ +edje_program.c \ +edje_script_only.c \ +edje_smart.c \ +edje_text.c \ +edje_textblock_styles.c \ +edje_util.c \ +edje_var.c + +if EDJE_AMALGAMATION +nodist_libedje_la_SOURCES = edje_amalgamation.c + +edje_amalgamation.c: $(base_sources) Makefile + -rm -f edje_amalgamation.c + + @echo "#ifdef HAVE_CONFIG_H" >> edje_amalgamation.c + @echo "# include \"config.h\"" >> edje_amalgamation.c + @echo "#endif" >> edje_amalgamation.c + + @echo "#ifndef _WIN32" >> edje_amalgamation.c + @echo "#define _GNU_SOURCE" >> edje_amalgamation.c + @echo "#endif" >> edje_amalgamation.c + + @echo "#ifdef HAVE_ALLOCA_H" >> edje_amalgamation.c + @echo "# include " >> edje_amalgamation.c + @echo "#elif defined __GNUC__" >> edje_amalgamation.c + @echo "# define alloca __builtin_alloca" >> edje_amalgamation.c + @echo "#elif defined _AIX" >> edje_amalgamation.c + @echo "# define alloca __alloca" >> edje_amalgamation.c + @echo "#elif defined _MSC_VER" >> edje_amalgamation.c + @echo "# include " >> edje_amalgamation.c + @echo "# define alloca _alloca" >> edje_amalgamation.c + @echo "#else" >> edje_amalgamation.c + @echo "# include " >> edje_amalgamation.c + @echo "# ifdef __cplusplus" >> edje_amalgamation.c + @echo "#extern \"C\"" >> edje_amalgamation.c + @echo "# endif" >> edje_amalgamation.c + @echo "#void *alloca (size_t);" >> edje_amalgamation.c + @echo "#endif" >> edje_amalgamation.c + + @echo "#include " >> edje_amalgamation.c + @echo "#include " >> edje_amalgamation.c + @echo "#include " >> edje_amalgamation.c + @echo "#include " >> edje_amalgamation.c + @echo "#include " >> edje_amalgamation.c + @echo "#include " >> edje_amalgamation.c + @echo "#include " >> edje_amalgamation.c + + @echo "#ifndef _MSC_VER" >> edje_amalgamation.c + @echo "# include " >> edje_amalgamation.c + @echo "#endif" >> edje_amalgamation.c + + @echo "#ifdef HAVE_LOCALE_H" >> edje_amalgamation.c + @echo "# include " >> edje_amalgamation.c + @echo "#endif" >> edje_amalgamation.c + + @echo "#include " >> edje_amalgamation.c + @echo "#include " >> edje_amalgamation.c + + @echo "#ifdef HAVE_EVIL" >> edje_amalgamation.c + @echo "# include " >> edje_amalgamation.c + @echo "#endif" >> edje_amalgamation.c + + @echo "#include " >> edje_amalgamation.c + @echo "#include " >> edje_amalgamation.c + @echo "#include " >> edje_amalgamation.c + @echo "#include " >> edje_amalgamation.c + @echo "#include " >> edje_amalgamation.c + + @echo "#ifdef HAVE_ECORE_IMF" >> edje_amalgamation.c + @echo "# include " >> edje_amalgamation.c + @echo "#endif" >> edje_amalgamation.c + + @echo "#include " >> edje_amalgamation.c + + @for f in $(base_sources); do \ + if [ `echo $$f | sed -e 's/^...\(.\).*/\1/'` != '/' ]; then \ + file="$(srcdir)/$$f" ; \ + else \ + file="$$f" ; \ + fi ; \ + echo "/* file: $$file */" >> edje_amalgamation.c; \ + 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; \ + done + @echo "edje_amalgamation.c generated" + +else +libedje_la_SOURCES = $(base_sources) +endif + +libedje_la_LIBADD = @EDJE_LIBS@ @ECORE_IMF_LIBS@ @EVIL_LIBS@ @REMIX_LIBS@ @SNDFILE_LIBS@ -lm +libedje_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -version-info @version_info@ @release_info@ + +EXTRA_DIST = edje_private.h edje_container.h edje_convert.h + +clean-local: + @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 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = src/lib +DIST_COMMON = $(includes_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/ac_attribute.m4 \ + $(top_srcdir)/m4/efl_binary.m4 \ + $(top_srcdir)/m4/efl_coverage.m4 \ + $(top_srcdir)/m4/efl_doxygen.m4 \ + $(top_srcdir)/m4/efl_path_max.m4 $(top_srcdir)/m4/efl_tests.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includesdir)" +LTLIBRARIES = $(lib_LTLIBRARIES) +libedje_la_DEPENDENCIES = +am__libedje_la_SOURCES_DIST = edje_box_layout.c edje_cache.c \ + edje_calc.c edje_callbacks.c edje_container.c edje_data.c \ + edje_edit.c edje_embryo.c edje_entry.c edje_external.c \ + edje_load.c edje_lua.c edje_lua2.c edje_lua_script_only.c \ + edje_main.c edje_match.c edje_message_queue.c edje_misc.c \ + edje_module.c edje_multisense.c edje_program.c \ + edje_script_only.c edje_smart.c edje_text.c \ + edje_textblock_styles.c edje_util.c edje_var.c +am__objects_1 = edje_box_layout.lo edje_cache.lo edje_calc.lo \ + edje_callbacks.lo edje_container.lo edje_data.lo edje_edit.lo \ + edje_embryo.lo edje_entry.lo edje_external.lo edje_load.lo \ + edje_lua.lo edje_lua2.lo edje_lua_script_only.lo edje_main.lo \ + edje_match.lo edje_message_queue.lo edje_misc.lo \ + edje_module.lo edje_multisense.lo edje_program.lo \ + edje_script_only.lo edje_smart.lo edje_text.lo \ + edje_textblock_styles.lo edje_util.lo edje_var.lo +@EDJE_AMALGAMATION_FALSE@am_libedje_la_OBJECTS = $(am__objects_1) +@EDJE_AMALGAMATION_TRUE@nodist_libedje_la_OBJECTS = \ +@EDJE_AMALGAMATION_TRUE@ edje_amalgamation.lo +libedje_la_OBJECTS = $(am_libedje_la_OBJECTS) \ + $(nodist_libedje_la_OBJECTS) +AM_V_lt = $(am__v_lt_$(V)) +am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) +am__v_lt_0 = --silent +libedje_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libedje_la_LDFLAGS) $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_$(V)) +am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) +am__v_CC_0 = @echo " CC " $@; +AM_V_at = $(am__v_at_$(V)) +am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) +am__v_at_0 = @ +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_$(V)) +am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) +am__v_CCLD_0 = @echo " CCLD " $@; +AM_V_GEN = $(am__v_GEN_$(V)) +am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) +am__v_GEN_0 = @echo " GEN " $@; +SOURCES = $(libedje_la_SOURCES) $(nodist_libedje_la_SOURCES) +DIST_SOURCES = $(am__libedje_la_SOURCES_DIST) +HEADERS = $(includes_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ALLOCA = @ALLOCA@ +ALSA_CFLAGS = @ALSA_CFLAGS@ +ALSA_LIBS = @ALSA_LIBS@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CHECK_CFLAGS = @CHECK_CFLAGS@ +CHECK_LIBS = @CHECK_LIBS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +ECORE_IMF_CFLAGS = @ECORE_IMF_CFLAGS@ +ECORE_IMF_LIBS = @ECORE_IMF_LIBS@ +EDJE_CC_CFLAGS = @EDJE_CC_CFLAGS@ +EDJE_CC_LIBS = @EDJE_CC_LIBS@ +EDJE_CC_PRG = @EDJE_CC_PRG@ +EDJE_CFLAGS = @EDJE_CFLAGS@ +EDJE_DECC_CFLAGS = @EDJE_DECC_CFLAGS@ +EDJE_DECC_LIBS = @EDJE_DECC_LIBS@ +EDJE_DECC_PRG = @EDJE_DECC_PRG@ +EDJE_EXTERNAL_INSPECTOR_CFLAGS = @EDJE_EXTERNAL_INSPECTOR_CFLAGS@ +EDJE_EXTERNAL_INSPECTOR_LIBS = @EDJE_EXTERNAL_INSPECTOR_LIBS@ +EDJE_EXTERNAL_INSPECTOR_PRG = @EDJE_EXTERNAL_INSPECTOR_PRG@ +EDJE_INSPECTOR_CFLAGS = @EDJE_INSPECTOR_CFLAGS@ +EDJE_INSPECTOR_LIBS = @EDJE_INSPECTOR_LIBS@ +EDJE_INSPECTOR_PRG = @EDJE_INSPECTOR_PRG@ +EDJE_LIBS = @EDJE_LIBS@ +EDJE_PLAYER_CFLAGS = @EDJE_PLAYER_CFLAGS@ +EDJE_PLAYER_LIBS = @EDJE_PLAYER_LIBS@ +EDJE_PLAYER_PRG = @EDJE_PLAYER_PRG@ +EDJE_RECC_PRG = @EDJE_RECC_PRG@ +EFL_COVERAGE_CFLAGS = @EFL_COVERAGE_CFLAGS@ +EFL_COVERAGE_LIBS = @EFL_COVERAGE_LIBS@ +EFL_EDJE_BUILD = @EFL_EDJE_BUILD@ +EGREP = @EGREP@ +EVIL_CFLAGS = @EVIL_CFLAGS@ +EVIL_LIBS = @EVIL_LIBS@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +FLAC_CFLAGS = @FLAC_CFLAGS@ +FLAC_LIBS = @FLAC_LIBS@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +LUA_CFLAGS = @LUA_CFLAGS@ +LUA_LIBS = @LUA_LIBS@ +MAKEINFO = @MAKEINFO@ +MINIMAL_CFLAGS = @MINIMAL_CFLAGS@ +MINIMAL_LIBS = @MINIMAL_LIBS@ +MKDIR_P = @MKDIR_P@ +MODULE_ARCH = @MODULE_ARCH@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +PYTHON = @PYTHON@ +PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ +PYTHON_PLATFORM = @PYTHON_PLATFORM@ +PYTHON_PREFIX = @PYTHON_PREFIX@ +PYTHON_VERSION = @PYTHON_VERSION@ +RANLIB = @RANLIB@ +REMIX_CFLAGS = @REMIX_CFLAGS@ +REMIX_LIBS = @REMIX_LIBS@ +REMIX_PLUGIN_DIR = @REMIX_PLUGIN_DIR@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SNDFILE_CFLAGS = @SNDFILE_CFLAGS@ +SNDFILE_LIBS = @SNDFILE_LIBS@ +STRIP = @STRIP@ +VERSION = @VERSION@ +VMAJ = @VMAJ@ +VORBISENC_CFLAGS = @VORBISENC_CFLAGS@ +VORBISENC_LIBS = @VORBISENC_LIBS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +edje_cc = @edje_cc@ +efl_doxygen = @efl_doxygen@ +efl_have_doxygen = @efl_have_doxygen@ +exec_prefix = @exec_prefix@ +have_lcov = @have_lcov@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ +lt_enable_auto_import = @lt_enable_auto_import@ +lua_libs = @lua_libs@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +pkgconfig_requires_private = @pkgconfig_requires_private@ +pkgpyexecdir = @pkgpyexecdir@ +pkgpythondir = @pkgpythondir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +pyexecdir = @pyexecdir@ +pythondir = @pythondir@ +release_info = @release_info@ +requirement_edje = @requirement_edje@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +version_info = @version_info@ +vimdir = @vimdir@ +MAINTAINERCLEANFILES = Makefile.in +AM_CPPFLAGS = \ +-I. \ +-I$(top_srcdir) \ +-I$(top_srcdir)/src/bin \ +-I$(top_srcdir)/src/lib \ +-DPACKAGE_BIN_DIR=\"$(bindir)\" \ +-DPACKAGE_LIB_DIR=\"$(libdir)\" \ +-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \ +@EVIL_CFLAGS@ \ +@EDJE_CFLAGS@ \ +@ECORE_IMF_CFLAGS@ \ +@EFL_EDJE_BUILD@ \ +@REMIX_CFLAGS@ \ +@SNDFILE_CFLAGS@ + +lib_LTLIBRARIES = libedje.la +includes_HEADERS = Edje.h Edje_Edit.h +includesdir = $(includedir)/edje-@VMAJ@ +base_sources = \ +edje_box_layout.c \ +edje_cache.c \ +edje_calc.c \ +edje_callbacks.c \ +edje_container.c \ +edje_data.c \ +edje_edit.c \ +edje_embryo.c \ +edje_entry.c \ +edje_external.c \ +edje_load.c \ +edje_lua.c \ +edje_lua2.c \ +edje_lua_script_only.c \ +edje_main.c \ +edje_match.c \ +edje_message_queue.c \ +edje_misc.c \ +edje_module.c \ +edje_multisense.c \ +edje_program.c \ +edje_script_only.c \ +edje_smart.c \ +edje_text.c \ +edje_textblock_styles.c \ +edje_util.c \ +edje_var.c + +@EDJE_AMALGAMATION_TRUE@nodist_libedje_la_SOURCES = edje_amalgamation.c +@EDJE_AMALGAMATION_FALSE@libedje_la_SOURCES = $(base_sources) +libedje_la_LIBADD = @EDJE_LIBS@ @ECORE_IMF_LIBS@ @EVIL_LIBS@ @REMIX_LIBS@ @SNDFILE_LIBS@ -lm +libedje_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -version-info @version_info@ @release_info@ +EXTRA_DIST = edje_private.h edje_container.h edje_convert.h +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/lib/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu src/lib/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +install-libLTLIBRARIES: $(lib_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)" + @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ + list2=; for p in $$list; do \ + if test -f $$p; then \ + list2="$$list2 $$p"; \ + else :; fi; \ + done; \ + test -z "$$list2" || { \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ + } + +uninstall-libLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ + for p in $$list; do \ + $(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ + done + +clean-libLTLIBRARIES: + -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) + @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libedje.la: $(libedje_la_OBJECTS) $(libedje_la_DEPENDENCIES) + $(AM_V_CCLD)$(libedje_la_LINK) -rpath $(libdir) $(libedje_la_OBJECTS) $(libedje_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_amalgamation.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_box_layout.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_cache.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_calc.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_callbacks.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_container.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_data.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_edit.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_embryo.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_entry.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_external.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_load.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_lua.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_lua2.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_lua_script_only.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_main.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_match.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_message_queue.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_misc.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_module.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_multisense.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_program.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_script_only.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_smart.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_text.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_textblock_styles.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_util.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edje_var.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-includesHEADERS: $(includes_HEADERS) + @$(NORMAL_INSTALL) + test -z "$(includesdir)" || $(MKDIR_P) "$(DESTDIR)$(includesdir)" + @list='$(includes_HEADERS)'; test -n "$(includesdir)" || list=; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includesdir)'"; \ + $(INSTALL_HEADER) $$files "$(DESTDIR)$(includesdir)" || exit $$?; \ + done + +uninstall-includesHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(includes_HEADERS)'; test -n "$(includesdir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + test -n "$$files" || exit 0; \ + echo " ( cd '$(DESTDIR)$(includesdir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(includesdir)" && rm -f $$files + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) $(HEADERS) +installdirs: + for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includesdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) +clean: clean-am + +clean-am: clean-generic clean-libLTLIBRARIES clean-libtool clean-local \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: install-includesHEADERS + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: install-libLTLIBRARIES + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-includesHEADERS uninstall-libLTLIBRARIES + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libLTLIBRARIES clean-libtool clean-local ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-includesHEADERS install-info \ + install-info-am install-libLTLIBRARIES install-man install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am uninstall-includesHEADERS \ + uninstall-libLTLIBRARIES + + +@EDJE_AMALGAMATION_TRUE@edje_amalgamation.c: $(base_sources) Makefile +@EDJE_AMALGAMATION_TRUE@ -rm -f edje_amalgamation.c + +@EDJE_AMALGAMATION_TRUE@ @echo "#ifdef HAVE_CONFIG_H" >> edje_amalgamation.c +@EDJE_AMALGAMATION_TRUE@ @echo "# include \"config.h\"" >> edje_amalgamation.c +@EDJE_AMALGAMATION_TRUE@ @echo "#endif" >> edje_amalgamation.c + +@EDJE_AMALGAMATION_TRUE@ @echo "#ifndef _WIN32" >> edje_amalgamation.c +@EDJE_AMALGAMATION_TRUE@ @echo "#define _GNU_SOURCE" >> edje_amalgamation.c +@EDJE_AMALGAMATION_TRUE@ @echo "#endif" >> edje_amalgamation.c + +@EDJE_AMALGAMATION_TRUE@ @echo "#ifdef HAVE_ALLOCA_H" >> edje_amalgamation.c +@EDJE_AMALGAMATION_TRUE@ @echo "# include " >> edje_amalgamation.c +@EDJE_AMALGAMATION_TRUE@ @echo "#elif defined __GNUC__" >> edje_amalgamation.c +@EDJE_AMALGAMATION_TRUE@ @echo "# define alloca __builtin_alloca" >> edje_amalgamation.c +@EDJE_AMALGAMATION_TRUE@ @echo "#elif defined _AIX" >> edje_amalgamation.c +@EDJE_AMALGAMATION_TRUE@ @echo "# define alloca __alloca" >> edje_amalgamation.c +@EDJE_AMALGAMATION_TRUE@ @echo "#elif defined _MSC_VER" >> edje_amalgamation.c +@EDJE_AMALGAMATION_TRUE@ @echo "# include " >> edje_amalgamation.c +@EDJE_AMALGAMATION_TRUE@ @echo "# define alloca _alloca" >> edje_amalgamation.c +@EDJE_AMALGAMATION_TRUE@ @echo "#else" >> edje_amalgamation.c +@EDJE_AMALGAMATION_TRUE@ @echo "# include " >> edje_amalgamation.c +@EDJE_AMALGAMATION_TRUE@ @echo "# ifdef __cplusplus" >> edje_amalgamation.c +@EDJE_AMALGAMATION_TRUE@ @echo "#extern \"C\"" >> edje_amalgamation.c +@EDJE_AMALGAMATION_TRUE@ @echo "# endif" >> edje_amalgamation.c +@EDJE_AMALGAMATION_TRUE@ @echo "#void *alloca (size_t);" >> edje_amalgamation.c +@EDJE_AMALGAMATION_TRUE@ @echo "#endif" >> edje_amalgamation.c + +@EDJE_AMALGAMATION_TRUE@ @echo "#include " >> edje_amalgamation.c +@EDJE_AMALGAMATION_TRUE@ @echo "#include " >> edje_amalgamation.c +@EDJE_AMALGAMATION_TRUE@ @echo "#include " >> edje_amalgamation.c +@EDJE_AMALGAMATION_TRUE@ @echo "#include " >> edje_amalgamation.c +@EDJE_AMALGAMATION_TRUE@ @echo "#include " >> edje_amalgamation.c +@EDJE_AMALGAMATION_TRUE@ @echo "#include " >> edje_amalgamation.c +@EDJE_AMALGAMATION_TRUE@ @echo "#include " >> edje_amalgamation.c + +@EDJE_AMALGAMATION_TRUE@ @echo "#ifndef _MSC_VER" >> edje_amalgamation.c +@EDJE_AMALGAMATION_TRUE@ @echo "# include " >> edje_amalgamation.c +@EDJE_AMALGAMATION_TRUE@ @echo "#endif" >> edje_amalgamation.c + +@EDJE_AMALGAMATION_TRUE@ @echo "#ifdef HAVE_LOCALE_H" >> edje_amalgamation.c +@EDJE_AMALGAMATION_TRUE@ @echo "# include " >> edje_amalgamation.c +@EDJE_AMALGAMATION_TRUE@ @echo "#endif" >> edje_amalgamation.c + +@EDJE_AMALGAMATION_TRUE@ @echo "#include " >> edje_amalgamation.c +@EDJE_AMALGAMATION_TRUE@ @echo "#include " >> edje_amalgamation.c + +@EDJE_AMALGAMATION_TRUE@ @echo "#ifdef HAVE_EVIL" >> edje_amalgamation.c +@EDJE_AMALGAMATION_TRUE@ @echo "# include " >> edje_amalgamation.c +@EDJE_AMALGAMATION_TRUE@ @echo "#endif" >> edje_amalgamation.c + +@EDJE_AMALGAMATION_TRUE@ @echo "#include " >> edje_amalgamation.c +@EDJE_AMALGAMATION_TRUE@ @echo "#include " >> edje_amalgamation.c +@EDJE_AMALGAMATION_TRUE@ @echo "#include " >> edje_amalgamation.c +@EDJE_AMALGAMATION_TRUE@ @echo "#include " >> edje_amalgamation.c +@EDJE_AMALGAMATION_TRUE@ @echo "#include " >> edje_amalgamation.c + +@EDJE_AMALGAMATION_TRUE@ @echo "#ifdef HAVE_ECORE_IMF" >> edje_amalgamation.c +@EDJE_AMALGAMATION_TRUE@ @echo "# include " >> edje_amalgamation.c +@EDJE_AMALGAMATION_TRUE@ @echo "#endif" >> edje_amalgamation.c + +@EDJE_AMALGAMATION_TRUE@ @echo "#include " >> edje_amalgamation.c + +@EDJE_AMALGAMATION_TRUE@ @for f in $(base_sources); do \ +@EDJE_AMALGAMATION_TRUE@ if [ `echo $$f | sed -e 's/^...\(.\).*/\1/'` != '/' ]; then \ +@EDJE_AMALGAMATION_TRUE@ file="$(srcdir)/$$f" ; \ +@EDJE_AMALGAMATION_TRUE@ else \ +@EDJE_AMALGAMATION_TRUE@ file="$$f" ; \ +@EDJE_AMALGAMATION_TRUE@ fi ; \ +@EDJE_AMALGAMATION_TRUE@ echo "/* file: $$file */" >> edje_amalgamation.c; \ +@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; \ +@EDJE_AMALGAMATION_TRUE@ done +@EDJE_AMALGAMATION_TRUE@ @echo "edje_amalgamation.c generated" + +clean-local: + @rm -rf *.gcno edje_amalgamation.c + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.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 @@ +#include "edje_private.h" + +typedef struct _Edje_Transition_Animation_Data Edje_Transition_Animation_Data; +struct _Edje_Transition_Animation_Data +{ + Evas_Object *obj; + struct + { + Evas_Coord x, y, w, h; + } start, end; +}; + +struct _Edje_Part_Box_Animation +{ + struct + { + Evas_Object_Box_Layout layout; + void *data; + void(*free_data)(void *data); + Edje_Alignment align; + Evas_Point padding; + } start, end; + Eina_List *objs; + Eina_Bool recalculate:1; + Evas_Object *box; + double progress; + double start_progress; + int box_start_w, box_start_h; +}; + +static void +_edje_box_layout_find_all(const char *name, const char *name_alt, Evas_Object_Box_Layout *cb, void **data, void (**free_data)(void *data)) +{ + if (!_edje_box_layout_find(name, cb, data, free_data)) + { + if ((!name_alt) || + (!_edje_box_layout_find(name_alt, cb, data, free_data))) + { + ERR("box layout '%s' (fallback '%s') not available, using horizontal.", + name, name_alt); + *cb = evas_object_box_layout_horizontal; + *free_data = NULL; + *data = NULL; + } + } +} + +static void +_edje_box_layout_calculate_coords(Evas_Object *obj, Evas_Object_Box_Data *priv, Edje_Part_Box_Animation *anim) +{ + Eina_List *l; + Edje_Transition_Animation_Data *tad; + Evas_Coord x, y; + + evas_object_geometry_get(obj, &x, &y, &anim->box_start_w, &anim->box_start_h); + EINA_LIST_FOREACH(anim->objs, l, tad) + { + evas_object_geometry_get(tad->obj, &tad->start.x, &tad->start.y, + &tad->start.w, &tad->start.h); + tad->start.x = tad->start.x - x; + tad->start.y = tad->start.y - y; + } + evas_object_box_padding_set(obj, anim->end.padding.x, anim->end.padding.y); + evas_object_box_align_set(obj, TO_DOUBLE(anim->end.align.x), TO_DOUBLE(anim->end.align.y)); + anim->end.layout(obj, priv, anim->end.data); + EINA_LIST_FOREACH(anim->objs, l, tad) + { + evas_object_geometry_get(tad->obj, &tad->end.x, &tad->end.y, + &tad->end.w, &tad->end.h); + tad->end.x = tad->end.x - x; + tad->end.y = tad->end.y - y; + } +} + +static void +_edje_box_layout_exec(Evas_Object *obj, Edje_Part_Box_Animation *anim) +{ + Eina_List *l; + Edje_Transition_Animation_Data *tad; + Evas_Coord x, y, w, h; + Evas_Coord cur_x, cur_y, cur_w, cur_h; + double progress; + + evas_object_geometry_get(obj, &x, &y, &w, &h); + progress = (anim->progress - anim->start_progress) / (1 - anim->start_progress); + + EINA_LIST_FOREACH(anim->objs, l, tad) + { + cur_x = x + (tad->start.x + ((tad->end.x - tad->start.x) * progress)) * (w / (double)anim->box_start_w); + cur_y = y + (tad->start.y + ((tad->end.y - tad->start.y) * progress)) * (h / (double)anim->box_start_h); + cur_w = (w / (double)anim->box_start_w) * (tad->start.w + ((tad->end.w - tad->start.w) * progress)); + cur_h = (h / (double)anim->box_start_h) * (tad->start.h + ((tad->end.h - tad->start.h) * progress)); + evas_object_move(tad->obj, cur_x, cur_y); + evas_object_resize(tad->obj, cur_w, cur_h); + } +} + +static void +_edje_box_layout(Evas_Object *obj, Evas_Object_Box_Data *priv, void *data) +{ + Edje_Part_Box_Animation *anim = data; + if (anim->progress < 0.01) + { + if (anim->start.layout) + { + evas_object_box_padding_set(obj, anim->start.padding.x, anim->start.padding.y); + evas_object_box_align_set(obj, TO_DOUBLE(anim->start.align.x), TO_DOUBLE(anim->start.align.y)); + anim->start.layout(obj, priv, anim->start.data); + } + return; + } + + if (anim->recalculate) + { + _edje_box_layout_calculate_coords(obj, priv, anim); + anim->start_progress = anim->progress; + anim->recalculate = EINA_FALSE; + } + + if ((anim->progress > 0) && (anim->start_progress < 1)) + _edje_box_layout_exec(obj, anim); +} + +void +_edje_box_layout_free_data(void *data) +{ + Edje_Transition_Animation_Data *tad; + Edje_Part_Box_Animation *anim = data; + if (anim->start.free_data && anim->start.data) + anim->start.free_data(anim->start.data); + if (anim->end.free_data && anim->end.data) + anim->end.free_data(anim->end.data); + EINA_LIST_FREE(anim->objs, tad) + free(tad); + free(data); +} + +Edje_Part_Box_Animation * +_edje_box_layout_anim_new(Evas_Object *box) +{ + Edje_Part_Box_Animation *anim = calloc(1, sizeof(Edje_Part_Box_Animation)); + if (!anim) + return NULL; + + anim->box = box; + evas_object_box_layout_set(box, _edje_box_layout, anim, NULL); + + return anim; +} + +void +_edje_box_recalc_apply(Edje *ed __UNUSED__, Edje_Real_Part *ep, Edje_Calc_Params *p3 __UNUSED__, Edje_Part_Description_Box *chosen_desc) +{ + Evas_Object_Box_Data *priv; +#if 0 + int min_w, min_h; +#endif + if ((ep->param2) && (ep->description_pos != ZERO)) + { + Edje_Part_Description_Box *param2_desc = (Edje_Part_Description_Box *)ep->param2->description; + if (ep->anim->end.layout == NULL) + { + _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); + ep->anim->end.padding.x = param2_desc->box.padding.x; + ep->anim->end.padding.y = param2_desc->box.padding.y; + ep->anim->end.align.x = param2_desc->box.align.x; + ep->anim->end.align.y = param2_desc->box.align.y; + + priv = evas_object_smart_data_get(ep->object); + if (priv == NULL) + return; + + evas_object_box_padding_set(ep->object, ep->anim->start.padding.x, ep->anim->start.padding.y); + evas_object_box_align_set(ep->object, TO_DOUBLE(ep->anim->start.align.x), TO_DOUBLE(ep->anim->start.align.y)); + ep->anim->start.layout(ep->object, priv, ep->anim->start.data); + _edje_box_layout_calculate_coords(ep->object, priv, ep->anim); + ep->anim->start_progress = 0.0; + } + evas_object_smart_changed(ep->object); + } + else + { + ep->anim->end.layout = NULL; + } + + if (ep->description_pos < 0.01 || !ep->anim->start.layout) + { + _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); + ep->anim->start.padding.x = chosen_desc->box.padding.x; + ep->anim->start.padding.y = chosen_desc->box.padding.y; + ep->anim->start.align.x = chosen_desc->box.align.x; + ep->anim->start.align.y = chosen_desc->box.align.y; + evas_object_smart_changed(ep->object); + } + + ep->anim->progress = ep->description_pos; + + if (evas_object_smart_need_recalculate_get(ep->object)) + { + evas_object_smart_need_recalculate_set(ep->object, 0); + evas_object_smart_calculate(ep->object); + } +#if 0 /* Why the hell do we affect part size after resize ??? */ + evas_object_size_hint_min_get(ep->object, &min_w, &min_h); + if (chosen_desc->box.min.h && (p3->w < min_w)) + p3->w = min_w; + if (chosen_desc->box.min.v && (p3->h < min_h)) + p3->h = min_h; +#endif +} + +Eina_Bool +_edje_box_layout_add_child(Edje_Real_Part *rp, Evas_Object *child_obj) +{ + Edje_Transition_Animation_Data *tad; + tad = calloc(1, sizeof(Edje_Transition_Animation_Data)); + if (!tad) + return EINA_FALSE; + tad->obj = child_obj; + rp->anim->objs = eina_list_append(rp->anim->objs, tad); + rp->anim->recalculate = EINA_TRUE; + return EINA_TRUE; +} + +void +_edje_box_layout_remove_child(Edje_Real_Part *rp, Evas_Object *child_obj) +{ + Eina_List *l; + Edje_Transition_Animation_Data *tad; + + EINA_LIST_FOREACH(rp->anim->objs, l, tad) + { + if (tad->obj == child_obj) + { + free(eina_list_data_get(l)); + rp->anim->objs = eina_list_remove_list(rp->anim->objs, l); + rp->anim->recalculate = EINA_TRUE; + break; + } + } + rp->anim->recalculate = EINA_TRUE; +} 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 @@ +#include "edje_private.h" + + +/** + * @cond + */ + +static Eina_Hash *_edje_file_hash = NULL; +static int _edje_file_cache_size = 16; +static Eina_List *_edje_file_cache = NULL; + +static int _edje_collection_cache_size = 16; + +static Edje_Part_Collection * +_edje_file_coll_open(Edje_File *edf, const char *coll) +{ + Edje_Part_Collection *edc = NULL; + Edje_Part_Collection_Directory_Entry *ce; + int id = -1, size = 0; + Eina_List *l; + char buf[256]; + char *buffer; + void *data; + + ce = eina_hash_find(edf->collection, coll); + if (!ce) return NULL; + + if (ce->ref) + { + ce->ref->references++; + return ce->ref; + } + + EINA_LIST_FOREACH(edf->collection_cache, l, edc) + { + if (!strcmp(edc->part, coll)) + { + edc->references = 1; + ce->ref = edc; + + edf->collection_cache = eina_list_remove_list(edf->collection_cache, l); + return ce->ref; + } + } + + id = ce->id; + if (id < 0) return NULL; + +#define INIT_EMP(Tp, Sz, Ce) \ + buffer = alloca(strlen(ce->entry) + strlen(#Tp) + 2); \ + sprintf(buffer, "%s/%s", ce->entry, #Tp); \ + Ce->mp.Tp = eina_mempool_add("one_big", buffer, NULL, sizeof (Sz), Ce->count.Tp); \ + _emp_##Tp = Ce->mp.Tp; + +#define INIT_EMP_BOTH(Tp, Sz, Ce) \ + INIT_EMP(Tp, Sz, Ce) \ + Ce->mp_rtl.Tp = eina_mempool_add("one_big", buffer, NULL, \ + sizeof (Sz), Ce->count.Tp); + + INIT_EMP_BOTH(RECTANGLE, Edje_Part_Description_Common, ce); + INIT_EMP_BOTH(TEXT, Edje_Part_Description_Text, ce); + INIT_EMP_BOTH(IMAGE, Edje_Part_Description_Image, ce); + INIT_EMP_BOTH(PROXY, Edje_Part_Description_Proxy, ce); + INIT_EMP_BOTH(SWALLOW, Edje_Part_Description_Common, ce); + INIT_EMP_BOTH(TEXTBLOCK, Edje_Part_Description_Text, ce); + INIT_EMP_BOTH(GROUP, Edje_Part_Description_Common, ce); + INIT_EMP_BOTH(BOX, Edje_Part_Description_Box, ce); + INIT_EMP_BOTH(TABLE, Edje_Part_Description_Table, ce); + INIT_EMP_BOTH(EXTERNAL, Edje_Part_Description_External, ce); + INIT_EMP(part, Edje_Part, ce); + + snprintf(buf, sizeof(buf), "edje/collections/%i", id); + edc = eet_data_read(edf->ef, _edje_edd_edje_part_collection, buf); + if (!edc) return NULL; + + edc->references = 1; + edc->part = ce->entry; + + /* For Edje file build with Edje 1.0, people expect text.align to be 0.0 0.0 */ + if (edf->version <= 3 && edf->minor <= 1) + { + /* This will preserve previous rendering */ + unsigned int i; + + for (i = 0; i < edc->parts_count; ++i) + { + if (edc->parts[i]->type == EDJE_PART_TYPE_TEXTBLOCK) + { + Edje_Part_Description_Text *text; + unsigned int j; + + text = (Edje_Part_Description_Text*) edc->parts[i]->default_desc; + text->text.align.x = TO_DOUBLE(0.0); + text->text.align.y = TO_DOUBLE(0.0); + + for (j = 0; j < edc->parts[i]->other.desc_count; ++j) + { + text = (Edje_Part_Description_Text*) edc->parts[i]->other.desc[j]; + text->text.align.x = TO_DOUBLE(0.0); + text->text.align.y = TO_DOUBLE(0.0); + } + } + } + } + + snprintf(buf, sizeof(buf), "edje/scripts/embryo/compiled/%i", id); + data = eet_read(edf->ef, buf, &size); + + if (data) + { + edc->script = embryo_program_new(data, size); + _edje_embryo_script_init(edc); + free(data); + } + + snprintf(buf, sizeof(buf), "edje/scripts/lua/%i", id); + data = eet_read(edf->ef, buf, &size); + + if (data) + { + _edje_lua2_script_load(edc, data, size); + free(data); + } + + ce->ref = edc; + + return edc; +} + +static Edje_File * +_edje_file_open(const char *file, const char *coll, int *error_ret, Edje_Part_Collection **edc_ret) +{ + Edje_File *edf; + Edje_Part_Collection *edc; + Eet_File *ef; + struct stat st; + + if (stat(file, &st) != 0) + { + *error_ret = EDJE_LOAD_ERROR_DOES_NOT_EXIST; + return NULL; + } + + ef = eet_open(file, EET_FILE_MODE_READ); + if (!ef) + { + *error_ret = EDJE_LOAD_ERROR_UNKNOWN_FORMAT; + return NULL; + } + edf = eet_data_read(ef, _edje_edd_edje_file, "edje/file"); + if (!edf) + { + *error_ret = EDJE_LOAD_ERROR_CORRUPT_FILE; + eet_close(ef); + return NULL; + } + + edf->ef = ef; + edf->mtime = st.st_mtime; + + if (edf->version != EDJE_FILE_VERSION) + { + *error_ret = EDJE_LOAD_ERROR_INCOMPATIBLE_FILE; + _edje_file_free(edf); + return NULL; + } + if (!edf->collection) + { + *error_ret = EDJE_LOAD_ERROR_CORRUPT_FILE; + _edje_file_free(edf); + return NULL; + } + + if (edf->minor > EDJE_FILE_MINOR) + { + WRN("`%s` may use feature from a newer edje and could not show up as expected.", file); + } + + edf->path = eina_stringshare_add(file); + edf->references = 1; + + /* This should be done at edje generation time */ + _edje_textblock_style_parse_and_fix(edf); + + if (coll) + { + edc = _edje_file_coll_open(edf, coll); + if (!edc) + { + *error_ret = EDJE_LOAD_ERROR_UNKNOWN_COLLECTION; + } + if (edc_ret) *edc_ret = edc; + } + + return edf; +} + +static void +_edje_file_dangling(Edje_File *edf) +{ + if (edf->dangling) return; + edf->dangling = EINA_TRUE; + + eina_hash_del(_edje_file_hash, edf->path, edf); + if (!eina_hash_population(_edje_file_hash)) + { + eina_hash_free(_edje_file_hash); + _edje_file_hash = NULL; + } +} + +Edje_File * +_edje_cache_file_coll_open(const char *file, const char *coll, int *error_ret, Edje_Part_Collection **edc_ret) +{ + Edje_File *edf; + Eina_List *l, *hist; + Edje_Part_Collection *edc; + Edje_Part *ep; + struct stat st; + + if (stat(file, &st) != 0) + return NULL; + + if (!_edje_file_hash) + { + _edje_file_hash = eina_hash_string_small_new(NULL); + goto open_new; + } + + edf = eina_hash_find(_edje_file_hash, file); + if (edf) + { + if (edf->mtime != st.st_mtime) + { + _edje_file_dangling(edf); + goto open_new; + } + + edf->references++; + goto open; + } + + EINA_LIST_FOREACH(_edje_file_cache, l, edf) + { + if (!strcmp(edf->path, file)) + { + if (edf->mtime != st.st_mtime) + { + _edje_file_cache = eina_list_remove_list(_edje_file_cache, l); + _edje_file_free(edf); + goto open_new; + } + + edf->references = 1; + _edje_file_cache = eina_list_remove_list(_edje_file_cache, l); + eina_hash_add(_edje_file_hash, file, edf); + goto open; + } + } + +open_new: + if (!_edje_file_hash) + _edje_file_hash = eina_hash_string_small_new(NULL); + + edf = _edje_file_open(file, coll, error_ret, edc_ret); + if (!edf) + return NULL; + + eina_hash_add(_edje_file_hash, file, edf); + return edf; + +open: + if (!coll) + return edf; + + edc = _edje_file_coll_open(edf, coll); + if (!edc) + { + *error_ret = EDJE_LOAD_ERROR_UNKNOWN_COLLECTION; + } + else + { + if (!edc->checked) + { + unsigned int j; + + for (j = 0; j < edc->parts_count; ++j) + { + Edje_Part *ep2; + + ep = edc->parts[j]; + + /* Register any color classes in this parts descriptions. */ + hist = NULL; + hist = eina_list_append(hist, ep); + ep2 = ep; + while (ep2->dragable.confine_id >= 0) + { + if (ep2->dragable.confine_id >= (int) edc->parts_count) + { + ERR("confine_to above limit. invalidating it."); + ep2->dragable.confine_id = -1; + break; + } + + ep2 = edc->parts[ep2->dragable.confine_id]; + if (eina_list_data_find(hist, ep2)) + { + ERR("confine_to loops. invalidating loop."); + ep2->dragable.confine_id = -1; + break; + } + hist = eina_list_append(hist, ep2); + } + eina_list_free(hist); + hist = NULL; + hist = eina_list_append(hist, ep); + ep2 = ep; + while (ep2->dragable.event_id >= 0) + { + Edje_Part* prev; + + if (ep2->dragable.event_id >= (int) edc->parts_count) + { + ERR("event_id above limit. invalidating it."); + ep2->dragable.event_id = -1; + break; + } + prev = ep2; + + ep2 = edc->parts[ep2->dragable.event_id]; + if (!ep2->dragable.x && !ep2->dragable.y) + { + prev->dragable.event_id = -1; + break; + } + + if (eina_list_data_find(hist, ep2)) + { + ERR("events_to loops. invalidating loop."); + ep2->dragable.event_id = -1; + break; + } + hist = eina_list_append(hist, ep2); + } + eina_list_free(hist); + hist = NULL; + hist = eina_list_append(hist, ep); + ep2 = ep; + while (ep2->clip_to_id >= 0) + { + if (ep2->clip_to_id >= (int) edc->parts_count) + { + ERR("clip_to_id above limit. invalidating it."); + ep2->clip_to_id = -1; + break; + } + + ep2 = edc->parts[ep2->clip_to_id]; + if (eina_list_data_find(hist, ep2)) + { + ERR("clip_to loops. invalidating loop."); + ep2->clip_to_id = -1; + break; + } + hist = eina_list_append(hist, ep2); + } + eina_list_free(hist); + hist = NULL; + } + edc->checked = 1; + } + } + if (edc_ret) *edc_ret = edc; + + return edf; +} + +void +_edje_cache_coll_clean(Edje_File *edf) +{ + while ((edf->collection_cache) && + (eina_list_count(edf->collection_cache) > (unsigned int) _edje_collection_cache_size)) + { + Edje_Part_Collection_Directory_Entry *ce; + Edje_Part_Collection *edc; + + edc = eina_list_data_get(eina_list_last(edf->collection_cache)); + edf->collection_cache = eina_list_remove_list(edf->collection_cache, eina_list_last(edf->collection_cache)); + + ce = eina_hash_find(edf->collection, edc->part); + _edje_collection_free(edf, edc, ce); + } +} + +void +_edje_cache_coll_flush(Edje_File *edf) +{ + while (edf->collection_cache) + { + Edje_Part_Collection_Directory_Entry *ce; + Edje_Part_Collection *edc; + Eina_List *last; + + last = eina_list_last(edf->collection_cache); + edc = eina_list_data_get(last); + edf->collection_cache = eina_list_remove_list(edf->collection_cache, + last); + + ce = eina_hash_find(edf->collection, edc->part); + _edje_collection_free(edf, edc, ce); + } +} + +void +_edje_cache_coll_unref(Edje_File *edf, Edje_Part_Collection *edc) +{ + Edje_Part_Collection_Directory_Entry *ce; + + edc->references--; + if (edc->references != 0) return; + + ce = eina_hash_find(edf->collection, edc->part); + if (!ce) + { + ERR("Something is wrong with reference count of '%s'.", edc->part); + } + else if (ce->ref) + { + ce->ref = NULL; + + if (edf->dangling) + { + /* No need to keep the collection around if the file is dangling */ + _edje_collection_free(edf, edc, ce); + _edje_cache_coll_flush(edf); + } + else + { + edf->collection_cache = eina_list_prepend(edf->collection_cache, edc); + _edje_cache_coll_clean(edf); + } + } +} + +static void +_edje_cache_file_clean(void) +{ + int count; + + count = eina_list_count(_edje_file_cache); + while ((_edje_file_cache) && (count > _edje_file_cache_size)) + { + Eina_List *last; + Edje_File *edf; + + last = eina_list_last(_edje_file_cache); + edf = eina_list_data_get(last); + _edje_file_cache = eina_list_remove_list(_edje_file_cache, last); + _edje_file_free(edf); + count = eina_list_count(_edje_file_cache); + } +} + +void +_edje_cache_file_unref(Edje_File *edf) +{ + edf->references--; + if (edf->references != 0) return; + + if (edf->dangling) + { + _edje_file_free(edf); + return; + } + + eina_hash_del(_edje_file_hash, edf->path, edf); + if (!eina_hash_population(_edje_file_hash)) + { + eina_hash_free(_edje_file_hash); + _edje_file_hash = NULL; + } + _edje_file_cache = eina_list_prepend(_edje_file_cache, edf); + _edje_cache_file_clean(); +} + +void +_edje_file_cache_shutdown(void) +{ + edje_file_cache_flush(); +} + + + +/** + * @endcond + */ + +/*============================================================================* + * Global * + *============================================================================*/ + +/*============================================================================* + * API * + *============================================================================*/ + + +EAPI void +edje_file_cache_set(int count) +{ + if (count < 0) count = 0; + _edje_file_cache_size = count; + _edje_cache_file_clean(); +} + + +EAPI int +edje_file_cache_get(void) +{ + return _edje_file_cache_size; +} + + +EAPI void +edje_file_cache_flush(void) +{ + int ps; + + ps = _edje_file_cache_size; + _edje_file_cache_size = 0; + _edje_cache_file_clean(); + _edje_file_cache_size = ps; +} + + +EAPI void +edje_collection_cache_set(int count) +{ + Eina_List *l; + Edje_File *edf; + + if (count < 0) count = 0; + _edje_collection_cache_size = count; + EINA_LIST_FOREACH(_edje_file_cache, l, edf) + _edje_cache_coll_clean(edf); + /* FIXME: freach in file hash too! */ +} + + +EAPI int +edje_collection_cache_get(void) +{ + return _edje_collection_cache_size; +} + + +EAPI void +edje_collection_cache_flush(void) +{ + int ps; + Eina_List *l; + Edje_File *edf; + + ps = _edje_collection_cache_size; + _edje_collection_cache_size = 0; + EINA_LIST_FOREACH(_edje_file_cache, l, edf) + _edje_cache_coll_flush(edf); + /* FIXME: freach in file hash too! */ + _edje_collection_cache_size = ps; +} 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 @@ +#include "edje_private.h" + +static void _edje_part_make_rtl(Edje_Part_Description_Common *desc); +static Edje_Part_Description_Common *_edje_get_description_by_orientation(Edje *ed, Edje_Part_Description_Common *src, Edje_Part_Description_Common **dst, unsigned char type); + +static void _edje_part_recalc_single(Edje *ed, Edje_Real_Part *ep, + Edje_Part_Description_Common *desc, Edje_Part_Description_Common *chosen_desc, + Edje_Real_Part *center, Edje_Real_Part *light, Edje_Real_Part *persp, + Edje_Real_Part *rel1_to_x, Edje_Real_Part *rel1_to_y, + Edje_Real_Part *rel2_to_x, Edje_Real_Part *rel2_to_y, + Edje_Real_Part *confine_to, Edje_Calc_Params *params); + +void +_edje_part_pos_set(Edje *ed, Edje_Real_Part *ep, int mode, FLOAT_T pos, FLOAT_T v1, FLOAT_T v2) +{ + FLOAT_T fp_pos; + FLOAT_T npos; + + pos = CLAMP(pos, ZERO, FROM_INT(1)); + + fp_pos = pos; + + npos = ZERO; +#if 0 // old code - easy to enable for comparing float vs fixed point + /* take linear pos along timescale and use interpolation method */ + switch (mode) + { + case EDJE_TWEEN_MODE_SINUSOIDAL: + /* npos = (1.0 - cos(pos * PI)) / 2.0; */ + npos = DIV2(SUB(FROM_INT(1), + COS(MUL(fp_pos, + PI)))); + break; + case EDJE_TWEEN_MODE_ACCELERATE: + /* npos = 1.0 - sin((PI / 2.0) + (pos * PI / 2.0)); */ + npos = SUB(FROM_INT(1), + SIN(ADD(DIV2(PI), + MUL(fp_pos, + DIV2(PI))))); + break; + case EDJE_TWEEN_MODE_DECELERATE: + /* npos = sin(pos * PI / 2.0); */ + npos = SIN(MUL(fp_pos, + DIV2(PI))); + break; + case EDJE_TWEEN_MODE_LINEAR: + npos = fp_pos; + break; + default: + npos = fp_pos; + break; + } +#else + switch (mode & EDJE_TWEEN_MODE_MASK) + { + case EDJE_TWEEN_MODE_SINUSOIDAL: + npos = FROM_DOUBLE(ecore_animator_pos_map(TO_DOUBLE(pos), + ECORE_POS_MAP_SINUSOIDAL, + 0.0, 0.0)); + break; + case EDJE_TWEEN_MODE_ACCELERATE: + npos = FROM_DOUBLE(ecore_animator_pos_map(TO_DOUBLE(pos), + ECORE_POS_MAP_ACCELERATE, + 0.0, 0.0)); + break; + case EDJE_TWEEN_MODE_DECELERATE: + npos = FROM_DOUBLE(ecore_animator_pos_map(TO_DOUBLE(pos), + ECORE_POS_MAP_DECELERATE, + 0.0, 0.0)); + break; + case EDJE_TWEEN_MODE_LINEAR: + npos = fp_pos; +/* npos = FROM_DOUBLE(ecore_animator_pos_map(TO_DOUBLE(pos), + ECORE_POS_MAP_LINEAR, + 0.0, 0.0)); + */ + break; + case EDJE_TWEEN_MODE_ACCELERATE_FACTOR: + npos = FROM_DOUBLE(ecore_animator_pos_map(TO_DOUBLE(pos), + ECORE_POS_MAP_ACCELERATE_FACTOR, + TO_DOUBLE(v1), 0.0)); + break; + case EDJE_TWEEN_MODE_DECELERATE_FACTOR: + npos = FROM_DOUBLE(ecore_animator_pos_map(TO_DOUBLE(pos), + ECORE_POS_MAP_DECELERATE_FACTOR, + TO_DOUBLE(v1), 0.0)); + break; + case EDJE_TWEEN_MODE_SINUSOIDAL_FACTOR: + npos = FROM_DOUBLE(ecore_animator_pos_map(TO_DOUBLE(pos), + ECORE_POS_MAP_SINUSOIDAL_FACTOR, + TO_DOUBLE(v1), 0.0)); + break; + case EDJE_TWEEN_MODE_DIVISOR_INTERP: + npos = FROM_DOUBLE(ecore_animator_pos_map(TO_DOUBLE(pos), + ECORE_POS_MAP_DIVISOR_INTERP, + TO_DOUBLE(v1), TO_DOUBLE(v2))); + break; + case EDJE_TWEEN_MODE_BOUNCE: + npos = FROM_DOUBLE(ecore_animator_pos_map(TO_DOUBLE(pos), + ECORE_POS_MAP_BOUNCE, + TO_DOUBLE(v1), TO_DOUBLE(v2))); + break; + case EDJE_TWEEN_MODE_SPRING: + npos = FROM_DOUBLE(ecore_animator_pos_map(TO_DOUBLE(pos), + ECORE_POS_MAP_SPRING, + TO_DOUBLE(v1), TO_DOUBLE(v2))); + break; + default: + npos = fp_pos; + break; + } +#endif + if (npos == ep->description_pos) return; + + ep->description_pos = npos; + + ed->dirty = 1; +#ifdef EDJE_CALC_CACHE + ep->invalidate = 1; +#endif +} + + +/** + * Returns part description + * + * @internal + * + * Converts part description to RTL-desc. + * + * @param desc Pointer to desc buffer. + * + **/ +static void +_edje_part_make_rtl(Edje_Part_Description_Common *desc) +{ + double t; + int i; + + if(!desc) + return; + + /* This makes alignment right-oriented */ + desc->align.x = 1.0 - desc->align.x; + + /* same as above for relative components */ + t = desc->rel1.relative_x; + desc->rel1.relative_x = 1.0 - desc->rel2.relative_x; + desc->rel2.relative_x = 1.0 - t; + + /* +1 and +1 are because how edje works with right + * side borders - nothing is printed beyond that limit + * + * rel2 is now to the left of rel1, and Edje assumes + * the opposite so we switch corners on x-axis to define + * offset from right to left */ + i = desc->rel1.offset_x; + desc->rel1.offset_x = -(desc->rel2.offset_x + 1); + desc->rel2.offset_x = -(i + 1); + + i = desc->rel1.id_x; + desc->rel1.id_x = desc->rel2.id_x; + desc->rel2.id_x = i; +} + +/** + * Returns part description + * + * @internal + * + * Returns part description according to object orientation. + * When object is in RTL-orientation (RTL flag is set) + * this returns the RTL-desc of it. + * RTL-desc would be allocated if was not created by a previous call. + * The dst pointer is updated in case of an allocation. + * + * @param ed Edje object. + * @param src The Left To Right (LTR), original desc. + * @param dst Pointer to Right To Left (RTL) desc-list. + * @param type name of dec type. Example: "default". + * + * @return Edje part description. + * + **/ +static Edje_Part_Description_Common * +_edje_get_description_by_orientation(Edje *ed, Edje_Part_Description_Common *src, Edje_Part_Description_Common **dst, unsigned char type) +{ + Edje_Part_Description_Common *desc_rtl = NULL; + Edje_Part_Collection_Directory_Entry *ce; + size_t memsize = 0; + + /* RTL flag is not set, return original description */ + if(!edje_object_mirrored_get(ed->obj)) + return src; + + if(*dst) + return *dst; /* Was allocated before and we should use it */ + +#define EDIT_ALLOC_POOL_RTL(Short, Type, Name) \ + case EDJE_PART_TYPE_##Short: \ + { \ + Edje_Part_Description_##Type *Name; \ + Name = eina_mempool_malloc(ce->mp_rtl.Short, \ + sizeof (Edje_Part_Description_##Type)); \ + memset(Name, 0, sizeof(Edje_Part_Description_##Type)); \ + desc_rtl = &Name->common; \ + memsize = sizeof(Edje_Part_Description_##Type); \ + break; \ + } + + ce = eina_hash_find(ed->file->collection, ed->group); + + switch (type) + { + case EDJE_PART_TYPE_RECTANGLE: + desc_rtl = eina_mempool_malloc(ce->mp_rtl.RECTANGLE, + sizeof (Edje_Part_Description_Common)); + ce->count.RECTANGLE++; + memsize = sizeof(Edje_Part_Description_Common); + break; + case EDJE_PART_TYPE_SWALLOW: + desc_rtl = eina_mempool_malloc(ce->mp_rtl.SWALLOW, + sizeof (Edje_Part_Description_Common)); + ce->count.SWALLOW++; + memsize = sizeof(Edje_Part_Description_Common); + break; + case EDJE_PART_TYPE_GROUP: + desc_rtl = eina_mempool_malloc(ce->mp_rtl.GROUP, + sizeof (Edje_Part_Description_Common)); + ce->count.GROUP++; + memsize = sizeof(Edje_Part_Description_Common); + break; + EDIT_ALLOC_POOL_RTL(TEXT, Text, text); + EDIT_ALLOC_POOL_RTL(TEXTBLOCK, Text, text); + EDIT_ALLOC_POOL_RTL(IMAGE, Image, image); + EDIT_ALLOC_POOL_RTL(PROXY, Proxy, proxy); + EDIT_ALLOC_POOL_RTL(BOX, Box, box); + EDIT_ALLOC_POOL_RTL(TABLE, Table, table); + EDIT_ALLOC_POOL_RTL(EXTERNAL, External, external_params); + } + + if(desc_rtl) + memcpy(desc_rtl, src, memsize); + + _edje_part_make_rtl(desc_rtl); + + *dst = desc_rtl; + return desc_rtl; +} + +Edje_Part_Description_Common * +_edje_part_description_find(Edje *ed, Edje_Real_Part *rp, const char *name, + double val) +{ + Edje_Part *ep = rp->part; + Edje_Part_Description_Common *ret = NULL; + Edje_Part_Description_Common *d; + + double min_dst = 99999.0; + unsigned int i; + + /* RTL flag is set, return RTL description */ + if(edje_object_mirrored_get(ed->obj)) + if(!ep->other.desc_rtl) + ep->other.desc_rtl = (Edje_Part_Description_Common **) + calloc(ep->other.desc_count, + sizeof (Edje_Part_Description_Common *)); + + if (!strcmp(name, "default") && val == 0.0) + return _edje_get_description_by_orientation(ed, + ep->default_desc, &ep->default_desc_rtl, ep->type); + + if (!strcmp(name, "custom")) + return rp->custom ? + _edje_get_description_by_orientation(ed, rp->custom->description, + &rp->custom->description_rtl, ep->type) : NULL; + + if (!strcmp(name, "default")) + { + ret = _edje_get_description_by_orientation(ed, ep->default_desc, + &ep->default_desc_rtl, ep->type); + + min_dst = ABS(ep->default_desc->state.value - val); + } + + for (i = 0; i < ep->other.desc_count; ++i) + { + d = ep->other.desc[i]; + + if (d->state.name && (d->state.name == name || !strcmp(d->state.name, name))) + { + double dst; + + dst = ABS(d->state.value - val); + if (dst < min_dst) + { + ret = _edje_get_description_by_orientation(ed, d, + &ep->other.desc_rtl[i], ep->type); + min_dst = dst; + } + } + } + + return ret; +} + +static void +_edje_real_part_rel_to_apply(Edje *ed, Edje_Real_Part *ep, Edje_Real_Part_State *state) +{ + state->rel1_to_x = state->rel1_to_y = NULL; + state->rel2_to_x = state->rel2_to_y = NULL; + + if (state->description) + { + if (state->description->rel1.id_x >= 0) + state->rel1_to_x = ed->table_parts[state->description->rel1.id_x % ed->table_parts_size]; + if (state->description->rel1.id_y >= 0) + state->rel1_to_y = ed->table_parts[state->description->rel1.id_y % ed->table_parts_size]; + if (state->description->rel2.id_x >= 0) + state->rel2_to_x = ed->table_parts[state->description->rel2.id_x % ed->table_parts_size]; + if (state->description->rel2.id_y >= 0) + state->rel2_to_y = ed->table_parts[state->description->rel2.id_y % ed->table_parts_size]; + + if (ep->part->type == EDJE_PART_TYPE_EXTERNAL) + { + Edje_Part_Description_External *external; + + external = (Edje_Part_Description_External*) state->description; + + if (state->external_params) + _edje_external_parsed_params_free(ep->swallowed_object, state->external_params); + state->external_params = _edje_external_params_parse(ep->swallowed_object, external->external_params); + } + } +} + +void +_edje_part_description_apply(Edje *ed, Edje_Real_Part *ep, const char *d1, double v1, const char *d2, double v2) +{ + Edje_Part_Description_Common *epd1; + Edje_Part_Description_Common *epd2 = NULL; + Edje_Part_Description_Common *chosen_desc; + + Edje_Part_Description_Image *epdi; + + if (!d1) d1 = "default"; + + epd1 = _edje_part_description_find(ed, ep, d1, v1); + if (!epd1) + epd1 = ep->part->default_desc; /* never NULL */ + + if (d2) + epd2 = _edje_part_description_find(ed, ep, d2, v2); + + epdi = (Edje_Part_Description_Image*) epd2; + + /* There is an animation if both description are different or if description is an image with tweens */ + if (epd2 && (epd1 != epd2 || (ep->part->type == EDJE_PART_TYPE_IMAGE && epdi->image.tweens_count))) + { + if (!ep->param2) + { + ep->param2 = eina_mempool_malloc(_edje_real_part_state_mp, sizeof (Edje_Real_Part_State)); + memset(ep->param2, 0, sizeof (Edje_Real_Part_State)); + } + else if (ep->part->type == EDJE_PART_TYPE_EXTERNAL) + _edje_external_parsed_params_free(ep->swallowed_object, ep->param2->external_params); + ep->param2->external_params = NULL; + } + else + if (ep->param2) + { + if (ep->part->type == EDJE_PART_TYPE_EXTERNAL) + _edje_external_parsed_params_free(ep->swallowed_object, ep->param2->external_params); + if (ep->param2) + free(ep->param2->set); + eina_mempool_free(_edje_real_part_state_mp, ep->param2); + ep->param2 = NULL; + } + + chosen_desc = ep->chosen_description; + ep->param1.description = epd1; + ep->chosen_description = epd1; + + _edje_real_part_rel_to_apply(ed, ep, &ep->param1); + + if (ep->param2) + { + ep->param2->description = epd2; + + _edje_real_part_rel_to_apply(ed, ep, ep->param2); + + if (ep->description_pos != 0.0) + ep->chosen_description = epd2; + } + + if (chosen_desc != ep->chosen_description && + ep->part->type == EDJE_PART_TYPE_EXTERNAL) + _edje_external_recalc_apply(ed, ep, NULL, chosen_desc); + + ed->dirty = 1; +#ifdef EDJE_CALC_CACHE + ep->invalidate = 1; +#endif +} + +void +_edje_recalc(Edje *ed) +{ + if ((ed->freeze > 0) || (_edje_freeze_val > 0)) + { + ed->recalc = 1; + if (!ed->calc_only) + { + if (_edje_freeze_val > 0) + { + if (!ed->freeze_calc) + { + _edje_freeze_calc_count++; + _edje_freeze_calc_list = eina_list_append(_edje_freeze_calc_list, ed); + ed->freeze_calc = 1; + } + } + return; + } + } + if (ed->postponed) return; + evas_object_smart_changed(ed->obj); + ed->postponed = 1; +} + +void +_edje_recalc_do(Edje *ed) +{ + unsigned int i; + + ed->postponed = 0; + evas_object_smart_need_recalculate_set(ed->obj, 0); + if (!ed->dirty) return; + ed->have_mapped_part = 0; + ed->dirty = 0; + ed->state++; + for (i = 0; i < ed->table_parts_size; i++) + { + Edje_Real_Part *ep; + + ep = ed->table_parts[i]; + ep->calculated = FLAG_NONE; + ep->calculating = FLAG_NONE; + } + for (i = 0; i < ed->table_parts_size; i++) + { + Edje_Real_Part *ep; + + ep = ed->table_parts[i]; + if (ep->calculated != FLAG_XY) + _edje_part_recalc(ed, ep, (~ep->calculated) & FLAG_XY, NULL); + } + if (!ed->calc_only) ed->recalc = 0; +#ifdef EDJE_CALC_CACHE + ed->all_part_change = 0; + ed->text_part_change = 0; +#endif +} + +void +_edje_part_recalc_1(Edje *ed, Edje_Real_Part *ep) +{ + _edje_part_recalc(ed, ep, FLAG_XY, NULL); +} + +int +_edje_part_dragable_calc(Edje *ed __UNUSED__, Edje_Real_Part *ep, FLOAT_T *x, FLOAT_T *y) +{ + if (ep->drag) + { + if (ep->drag->confine_to) + { + FLOAT_T dx, dy, dw, dh; + int ret = 0; + + if ((ep->part->dragable.x != 0) && + (ep->part->dragable.y != 0 )) ret = 3; + else if (ep->part->dragable.x != 0) ret = 1; + else if (ep->part->dragable.y != 0) ret = 2; + + dx = FROM_INT(ep->x - ep->drag->confine_to->x); + dw = FROM_INT(ep->drag->confine_to->w - ep->w); + if (dw != ZERO) dx = DIV(dx, dw); + else dx = ZERO; + + dy = FROM_INT(ep->y - ep->drag->confine_to->y); + dh = FROM_INT(ep->drag->confine_to->h - ep->h); + if (dh != ZERO) dy = DIV(dy, dh); + else dy = ZERO; + + if (x) *x = dx; + if (y) *y = dy; + + return ret; + } + else + { + if (x) *x = ADD(FROM_INT(ep->drag->tmp.x), ep->drag->x); + if (y) *y = ADD(FROM_INT(ep->drag->tmp.y), ep->drag->y); + return 0; + } + } + if (x) *x = ZERO; + if (y) *y = ZERO; + return 0; +} + +void +_edje_dragable_pos_set(Edje *ed, Edje_Real_Part *ep, FLOAT_T x, FLOAT_T y) +{ + /* check whether this part is dragable at all */ + if (!ep->drag) return ; + + /* instead of checking for equality, we really should check that + * the difference is greater than foo, but I have no idea what + * value we would set foo to, because it would depend on the + * size of the dragable... + */ + if (ep->drag->x != x || ep->drag->tmp.x) + { + ep->drag->x = x; + ep->drag->tmp.x = 0; + ep->drag->need_reset = 0; + ed->dirty = 1; + } + + if (ep->drag->y != y || ep->drag->tmp.y) + { + ep->drag->y = y; + ep->drag->tmp.y = 0; + ep->drag->need_reset = 0; + ed->dirty = 1; + } + +#ifdef EDJE_CALC_CACHE + ep->invalidate = 1; +#endif + _edje_recalc(ed); /* won't do anything if dirty flag isn't set */ +} + +static void +_edje_part_recalc_single_rel(Edje *ed, + Edje_Real_Part *ep __UNUSED__, + Edje_Part_Description_Common *desc, + Edje_Real_Part *rel1_to_x, + Edje_Real_Part *rel1_to_y, + Edje_Real_Part *rel2_to_x, + Edje_Real_Part *rel2_to_y, + Edje_Calc_Params *params) +{ + FLOAT_T x, w; + FLOAT_T y, h; + + if (rel1_to_x) + x = ADD(FROM_INT(desc->rel1.offset_x + rel1_to_x->x), + SCALE(desc->rel1.relative_x, rel1_to_x->w)); + else + x = ADD(FROM_INT(desc->rel1.offset_x), + SCALE(desc->rel1.relative_x, ed->w)); + params->x = TO_INT(x); + + if (rel2_to_x) + w = ADD(SUB(ADD(FROM_INT(desc->rel2.offset_x + rel2_to_x->x), + SCALE(desc->rel2.relative_x, rel2_to_x->w)), + x), + FROM_INT(1)); + else + w = ADD(SUB(ADD(FROM_INT(desc->rel2.offset_x), + SCALE(desc->rel2.relative_x, ed->w)), + x), + FROM_INT(1)); + params->w = TO_INT(w); + + if (rel1_to_y) + y = ADD(FROM_INT(desc->rel1.offset_y + rel1_to_y->y), + SCALE(desc->rel1.relative_y, rel1_to_y->h)); + else + y = ADD(FROM_INT(desc->rel1.offset_y), + SCALE(desc->rel1.relative_y, ed->h)); + params->y = TO_INT(y); + + if (rel2_to_y) + h = ADD(SUB(ADD(FROM_INT(desc->rel2.offset_y + rel2_to_y->y), + SCALE(desc->rel2.relative_y, rel2_to_y->h)), + y), + FROM_INT(1)); + else + h = ADD(SUB(ADD(FROM_INT(desc->rel2.offset_y), + SCALE(desc->rel2.relative_y, ed->h)), + y), + FROM_INT(1)); + params->h = TO_INT(h); +} + +static Edje_Internal_Aspect +_edje_part_recalc_single_aspect(Edje_Real_Part *ep, + Edje_Part_Description_Common *desc, + Edje_Calc_Params *params, + int *minw, int *minh, + int *maxw, int *maxh) +{ + Edje_Internal_Aspect apref = EDJE_ASPECT_PREFER_NONE; + FLOAT_T aspect, amax, amin; + FLOAT_T new_w = ZERO, new_h = ZERO, want_x, want_y, want_w, want_h; + + if (params->h <= ZERO) aspect = FROM_INT(999999); + else aspect = DIV(FROM_INT(params->w), FROM_INT(params->h)); + amax = desc->aspect.max; + amin = desc->aspect.min; + if ((ep->swallow_params.aspect.w > 0) && + (ep->swallow_params.aspect.h > 0)) + amin = amax = + DIV(FROM_INT(ep->swallow_params.aspect.w), + FROM_INT(ep->swallow_params.aspect.h)); + want_x = FROM_INT(params->x); + want_w = new_w = FROM_INT(params->w); + + want_y = FROM_INT(params->y); + want_h = new_h = FROM_INT(params->h); + + if ((amin > ZERO) && (amax > ZERO)) + { + apref = desc->aspect.prefer; + if (ep->swallow_params.aspect.mode > EDJE_ASPECT_CONTROL_NONE) + { + switch (ep->swallow_params.aspect.mode) + { + case EDJE_ASPECT_CONTROL_NEITHER: + apref = EDJE_ASPECT_PREFER_NONE; + break; + case EDJE_ASPECT_CONTROL_HORIZONTAL: + apref = EDJE_ASPECT_PREFER_HORIZONTAL; + break; + case EDJE_ASPECT_CONTROL_VERTICAL: + apref = EDJE_ASPECT_PREFER_VERTICAL; + break; + case EDJE_ASPECT_CONTROL_BOTH: + apref = EDJE_ASPECT_PREFER_BOTH; + break; + default: + break; + } + } + switch (apref) + { + case EDJE_ASPECT_PREFER_NONE: + /* keep both dimensions in check */ + /* adjust for min aspect (width / height) */ + if ((amin > ZERO) && (aspect < amin)) + { + new_h = DIV(FROM_INT(params->w), amin); + new_w = SCALE(amin, params->h); + } + /* adjust for max aspect (width / height) */ + if ((amax > ZERO) && (aspect > amax)) + { + new_h = DIV(FROM_INT(params->w), amax); + new_w = SCALE(amax, params->h); + } + if ((amax > ZERO) && (new_w < FROM_INT(params->w))) + { + new_w = FROM_INT(params->w); + new_h = DIV(FROM_INT(params->w), amax); + } + if ((amax > ZERO) && (new_h < FROM_INT(params->h))) + { + new_w = SCALE(amax, params->h); + new_h = FROM_INT(params->h); + } + break; + /* prefer vertical size as determiner */ + case EDJE_ASPECT_PREFER_VERTICAL: + /* keep both dimensions in check */ + /* adjust for max aspect (width / height) */ + if ((amax > ZERO) && (aspect > amax)) + new_w = SCALE(amax, params->h); + /* adjust for min aspect (width / height) */ + if ((amin > ZERO) && (aspect < amin)) + new_w = SCALE(amin, params->h); + break; + /* prefer horizontal size as determiner */ + case EDJE_ASPECT_PREFER_HORIZONTAL: + /* keep both dimensions in check */ + /* adjust for max aspect (width / height) */ + if ((amax > ZERO) && (aspect > amax)) + new_h = DIV(FROM_INT(params->w), amax); + /* adjust for min aspect (width / height) */ + if ((amin > ZERO) && (aspect < amin)) + new_h = DIV(FROM_INT(params->w), amin); + break; + case EDJE_ASPECT_PREFER_BOTH: + /* keep both dimensions in check */ + /* adjust for max aspect (width / height) */ + if ((amax > ZERO) && (aspect > amax)) + { + new_w = SCALE(amax, params->h); + new_h = DIV(FROM_INT(params->w), amax); + } + /* adjust for min aspect (width / height) */ + if ((amin > ZERO) && (aspect < amin)) + { + new_w = SCALE(amin, params->h); + new_h = DIV(FROM_INT(params->w), amin); + } + break; + default: + break; + } + + if (!((amin > ZERO) && (amax > ZERO) && (apref == EDJE_ASPECT_PREFER_NONE))) + { + if ((*maxw >= 0) && (new_w > FROM_INT(*maxw))) + new_w = FROM_INT(*maxw); + if (new_w < FROM_INT(*minw)) + new_w = FROM_INT(*minw); + + if ((FROM_INT(*maxh) >= 0) && (new_h > FROM_INT(*maxh))) + new_h = FROM_INT(*maxh); + if (new_h < FROM_INT(*minh)) + new_h = FROM_INT(*minh); + } + + /* do real adjustment */ + if (apref == EDJE_ASPECT_PREFER_BOTH) + { + if (amin == ZERO) amin = amax; + if (amin != ZERO) + { + /* fix h and vary w */ + if (new_w > FROM_INT(params->w)) + { + // params->w = new_w; + // EXCEEDS BOUNDS in W + new_h = DIV(FROM_INT(params->w), amin); + new_w = FROM_INT(params->w); + if (new_h > FROM_INT(params->h)) + { + new_h = FROM_INT(params->h); + new_w = SCALE(amin, params->h); + } + } + /* fix w and vary h */ + else + { + // params->h = new_h; + // EXCEEDS BOUNDS in H + new_h = FROM_INT(params->h); + new_w = SCALE(amin, params->h); + if (new_w > FROM_INT(params->w)) + { + new_h = DIV(FROM_INT(params->w), amin); + new_w = FROM_INT(params->w); + } + } + params->w = TO_INT(new_w); + params->h = TO_INT(new_h); + } + } + } + if (apref != EDJE_ASPECT_PREFER_BOTH) + { + if ((amin > 0.0) && (amax > ZERO) && (apref == EDJE_ASPECT_PREFER_NONE)) + { + params->w = TO_INT(new_w); + params->h = TO_INT(new_h); + } + else if ((FROM_INT(params->h) - new_h) > (FROM_INT(params->w) - new_w)) + { + if (params->h < TO_INT(new_h)) + params->h = TO_INT(new_h); + else if (params->h > TO_INT(new_h)) + params->h = TO_INT(new_h); + if (apref == EDJE_ASPECT_PREFER_VERTICAL) + params->w = TO_INT(new_w); + } + else + { + if (params->w < TO_INT(new_w)) + params->w = TO_INT(new_w); + else if (params->w > TO_INT(new_w)) + params->w = TO_INT(new_w); + if (apref == EDJE_ASPECT_PREFER_HORIZONTAL) + params->h = TO_INT(new_h); + } + } + params->x = TO_INT(ADD(want_x, + MUL(SUB(want_w, FROM_INT(params->w)), + desc->align.x))); + params->y = TO_INT(ADD(want_y, + MUL(SUB(want_h, FROM_INT(params->h)), + desc->align.y))); + return apref; +} + +static void +_edje_part_recalc_single_step(Edje_Part_Description_Common *desc, + Edje_Calc_Params *params) +{ + if (desc->step.x > 0) + { + int steps; + int new_w; + + steps = params->w / desc->step.x; + new_w = desc->step.x * steps; + if (params->w > new_w) + { + params->x += TO_INT(SCALE(desc->align.x, (params->w - new_w))); + params->w = new_w; + } + } + + if (desc->step.y > 0) + { + int steps; + int new_h; + + steps = params->h / desc->step.y; + new_h = desc->step.y * steps; + if (params->h > new_h) + { + params->y += TO_INT(SCALE(desc->align.y, (params->h - new_h))); + params->h = new_h; + } + } +} + +static void +_edje_part_recalc_single_textblock(FLOAT_T sc, + Edje *ed, + Edje_Real_Part *ep, + Edje_Part_Description_Text *chosen_desc, + Edje_Calc_Params *params, + int *minw, int *minh, + int *maxw, int *maxh) +{ + if (chosen_desc) + { + Evas_Coord tw, th, ins_l, ins_r, ins_t, ins_b; + const char *text = ""; + const char *style = ""; + Edje_Style *stl = NULL; + const char *tmp; + Eina_List *l; + + if (chosen_desc->text.id_source >= 0) + { + ep->text.source = ed->table_parts[chosen_desc->text.id_source % ed->table_parts_size]; + + tmp = edje_string_get(&((Edje_Part_Description_Text *)ep->text.source->chosen_description)->text.style); + if (tmp) style = tmp; + } + else + { + ep->text.source = NULL; + + tmp = edje_string_get(&chosen_desc->text.style); + if (tmp) style = tmp; + } + + if (chosen_desc->text.id_text_source >= 0) + { + ep->text.text_source = ed->table_parts[chosen_desc->text.id_text_source % ed->table_parts_size]; + text = edje_string_get(&((Edje_Part_Description_Text*)ep->text.text_source->chosen_description)->text.text); + + if (ep->text.text_source->text.text) text = ep->text.text_source->text.text; + } + else + { + ep->text.text_source = NULL; + text = edje_string_get(&chosen_desc->text.text); + if (ep->text.text) text = ep->text.text; + } + + EINA_LIST_FOREACH(ed->file->styles, l, stl) + { + if ((stl->name) && (!strcmp(stl->name, style))) break; + stl = NULL; + } + + if (ep->part->scale) + evas_object_scale_set(ep->object, TO_DOUBLE(sc)); + + if (stl) + { + const char *ptxt; + + if (evas_object_textblock_style_get(ep->object) != stl->style) + evas_object_textblock_style_set(ep->object, stl->style); + // FIXME: need to account for editing + if (ep->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + { + // do nothing - should be done elsewhere + } + else + { + ptxt = evas_object_textblock_text_markup_get(ep->object); + if (((!ptxt) && (text)) || + ((ptxt) && (text) && (strcmp(ptxt, text))) || + ((ptxt) && (!text))) + evas_object_textblock_text_markup_set(ep->object, text); + } + if ((chosen_desc->text.min_x) || (chosen_desc->text.min_y)) + { + int mw = 0, mh = 0; + + tw = th = 0; + if (!chosen_desc->text.min_x) + { + evas_object_resize(ep->object, params->w, params->h); + evas_object_textblock_size_formatted_get(ep->object, &tw, &th); + } + else + evas_object_textblock_size_native_get(ep->object, &tw, &th); + evas_object_textblock_style_insets_get(ep->object, &ins_l, &ins_r, &ins_t, &ins_b); + mw = ins_l + tw + ins_r; + mh = ins_t + th + ins_b; + if (chosen_desc->text.min_x) + { + if (mw > *minw) *minw = mw; + } + if (chosen_desc->text.min_y) + { + if (mh > *minh) *minh = mh; + } + } + } + if ((chosen_desc->text.max_x) || (chosen_desc->text.max_y)) + { + int mw = 0, mh = 0; + + tw = th = 0; + if (!chosen_desc->text.max_x) + { + evas_object_resize(ep->object, params->w, params->h); + evas_object_textblock_size_formatted_get(ep->object, &tw, &th); + } + else + evas_object_textblock_size_native_get(ep->object, &tw, &th); + evas_object_textblock_style_insets_get(ep->object, &ins_l, &ins_r, &ins_t, &ins_b); + mw = ins_l + tw + ins_r; + mh = ins_t + th + ins_b; + if (chosen_desc->text.max_x) + { + if (mw > *maxw) *maxw = mw; + if (*maxw < *minw) *maxw = *minw; + } + if (chosen_desc->text.max_y) + { + if (mh > *maxw) *maxh = mh; + if (*maxh < *minh) *maxh = *minh; + } + } + evas_object_textblock_valign_set(ep->object, chosen_desc->text.align.y); + } +} + +static void +_edje_part_recalc_single_text(FLOAT_T sc __UNUSED__, + Edje *ed, + Edje_Real_Part *ep, + Edje_Part_Description_Text *desc, + Edje_Part_Description_Text *chosen_desc, + Edje_Calc_Params *params, + int *minw, int *minh, + int *maxw, int *maxh) +#define RECALC_SINGLE_TEXT_USING_APPLY 1 +#if RECALC_SINGLE_TEXT_USING_APPLY +/* + * XXX TODO NOTE: + * + * Original _edje_part_recalc_single_text() was not working as + * expected since it was not doing size fit, range, ellipsis and so + * on. + * + * The purpose of this function compared with + * _edje_text_recalc_apply() is to be faster, not calling Evas update + * functions. However for text this is quite difficult given that to + * fit we need to set the font, size, style, etc. If it was done + * correctly, we'd save some calls to move and some color sets, + * however those shouldn't matter much in the overall picture. + * + * I've changed this to force applying the value, it should be more + * correct and not so slow. The previous code is kept below for + * reference but should be removed before next release! + * + * -- Gustavo Barbieri at 20-Aug-2011 + */ +{ + int tw, th, mw, mh, l, r, t, b, size; + char *sfont = NULL; + + _edje_text_class_font_get(ed, desc, &size, &sfont); + free(sfont); + params->type.text.size = size; /* XXX TODO used by further calcs, go inside recalc_apply? */ + + _edje_text_recalc_apply(ed, ep, params, chosen_desc); + + evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th); + + if ((!chosen_desc) || + ((!chosen_desc->text.min_x) && (!chosen_desc->text.min_y) && + (!chosen_desc->text.max_x) && (!chosen_desc->text.max_y))) + return; + + evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th); + evas_object_text_style_pad_get(ep->object, &l, &r, &t, &b); + + mw = tw + l + r; + mh = th + t + b; + + if (chosen_desc->text.max_x) + { + if ((*maxw < 0) || (mw < *maxw)) *maxw = mw; + } + if (chosen_desc->text.max_y) + { + if ((*maxh < 0) || (mh < *maxh)) *maxh = mh; + } + if (chosen_desc->text.min_x) + { + if (mw > *minw) *minw = mw; + } + if (chosen_desc->text.min_y) + { + if (mh > *minh) *minh = mh; + } +} +#else +{ + char *sfont = NULL; + int size; + + if (chosen_desc) + { + const char *text; + const char *font; + Evas_Coord tw, th; + int inlined_font = 0; + + /* Update a object_text part */ + + if (chosen_desc->text.id_source >= 0) + ep->text.source = ed->table_parts[chosen_desc->text.id_source % ed->table_parts_size]; + else + ep->text.source = NULL; + + if (chosen_desc->text.id_text_source >= 0) + ep->text.text_source = ed->table_parts[chosen_desc->text.id_text_source % ed->table_parts_size]; + else + ep->text.text_source = NULL; + + if (ep->text.text_source) + text = edje_string_get(&(((Edje_Part_Description_Text*)ep->text.text_source->chosen_description)->text.text)); + else + text = edje_string_get(&chosen_desc->text.text); + + if (ep->text.source) + font = _edje_text_class_font_get(ed, ((Edje_Part_Description_Text*)ep->text.source->chosen_description), &size, &sfont); + else + font = _edje_text_class_font_get(ed, chosen_desc, &size, &sfont); + + if (!font) font = ""; + + if (ep->text.text_source) + { + if (ep->text.text_source->text.text) text = ep->text.text_source->text.text; + } + else + { + if (ep->text.text) text = ep->text.text; + } + + if (ep->text.source) + { + if (ep->text.source->text.font) font = ep->text.source->text.font; + if (ep->text.source->text.size > 0) size = ep->text.source->text.size; + } + else + { + if (ep->text.font) font = ep->text.font; + if (ep->text.size > 0) size = ep->text.size; + } + if (!text) text = ""; + + /* check if the font is embedded in the .eet */ + if (ed->file->fonts) + { + Edje_Font_Directory_Entry *fnt; + + fnt = eina_hash_find(ed->file->fonts, font); + + if (fnt) + { + char *font2; + + size_t len = strlen(font) + sizeof("edje/fonts/") + 1; + font2 = alloca(len); + sprintf(font2, "edje/fonts/%s", font); + font = font2; + inlined_font = 1; + } + } + if (ep->part->scale) + evas_object_scale_set(ep->object, TO_DOUBLE(sc)); + if (inlined_font) + { + evas_object_text_font_source_set(ep->object, ed->path); + } + else evas_object_text_font_source_set(ep->object, NULL); + + if ((_edje_fontset_append) && (font)) + { + char *font2; + + font2 = malloc(strlen(font) + 1 + strlen(_edje_fontset_append) + 1); + if (font2) + { + strcpy(font2, font); + strcat(font2, ","); + strcat(font2, _edje_fontset_append); + evas_object_text_font_set(ep->object, font2, size); + free(font2); + } + } + else + evas_object_text_font_set(ep->object, font, size); + if ((chosen_desc->text.min_x) || (chosen_desc->text.min_y) || + (chosen_desc->text.max_x) || (chosen_desc->text.max_y)) + { + int mw, mh; + Evas_Text_Style_Type + style = EVAS_TEXT_STYLE_PLAIN, + shadow = EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_RIGHT; + const Evas_Text_Style_Type styles[] = { + EVAS_TEXT_STYLE_PLAIN, + EVAS_TEXT_STYLE_PLAIN, + EVAS_TEXT_STYLE_OUTLINE, + EVAS_TEXT_STYLE_SOFT_OUTLINE, + EVAS_TEXT_STYLE_SHADOW, + EVAS_TEXT_STYLE_SOFT_SHADOW, + EVAS_TEXT_STYLE_OUTLINE_SHADOW, + EVAS_TEXT_STYLE_OUTLINE_SOFT_SHADOW, + EVAS_TEXT_STYLE_FAR_SHADOW, + EVAS_TEXT_STYLE_FAR_SOFT_SHADOW, + EVAS_TEXT_STYLE_GLOW + }; + const Evas_Text_Style_Type shadows[] = { + EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_RIGHT, + EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM, + EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_LEFT, + EVAS_TEXT_STYLE_SHADOW_DIRECTION_LEFT, + EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_LEFT, + EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP, + EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_RIGHT, + EVAS_TEXT_STYLE_SHADOW_DIRECTION_RIGHT + }; + + if ((ep->part->effect & EVAS_TEXT_STYLE_MASK_BASIC) + < EDJE_TEXT_EFFECT_LAST) + style = styles[ep->part->effect]; + shadow = shadows + [(ep->part->effect & EDJE_TEXT_EFFECT_MASK_SHADOW_DIRECTION) >> 4]; + EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET(style, shadow); + + evas_object_text_style_set(ep->object, style); + evas_object_text_text_set(ep->object, text); + evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th); + if (chosen_desc->text.max_x) + { + int l, r; + evas_object_text_style_pad_get(ep->object, &l, &r, NULL, NULL); + mw = tw + l + r; + if ((*maxw < 0) || (mw < *maxw)) *maxw = mw; + } + if (chosen_desc->text.max_y) + { + int t, b; + evas_object_text_style_pad_get(ep->object, NULL, NULL, &t, &b); + mh = th + t + b; + if ((*maxh < 0) || (mh < *maxh)) *maxh = mh; + } + if (chosen_desc->text.min_x) + { + int l, r; + evas_object_text_style_pad_get(ep->object, &l, &r, NULL, NULL); + mw = tw + l + r; + if (mw > *minw) *minw = mw; + } + if (chosen_desc->text.min_y) + { + int t, b; + evas_object_text_style_pad_get(ep->object, NULL, NULL, &t, &b); + mh = th + t + b; + if (mh > *minh) *minh = mh; + } + } + if (sfont) free(sfont); + } + + /* FIXME: Do we really need to call it twice if chosen_desc ? */ + sfont = NULL; + _edje_text_class_font_get(ed, desc, &size, &sfont); + free(sfont); + params->type.text.size = size; +} +#endif + +static void +_edje_part_recalc_single_min_length(FLOAT_T align, int *start, int *length, int min) +{ + if (min >= 0) + { + if (*length < min) + { + *start += TO_INT(SCALE(align, (*length - min))); + *length = min; + } + } +} + +static void +_edje_part_recalc_single_min(Edje_Part_Description_Common *desc, + Edje_Calc_Params *params, + int minw, int minh, + Edje_Internal_Aspect aspect) +{ + int tmp; + int w; + int h; + + w = params->w ? params->w : 99999; + h = params->h ? params->h : 99999; + + switch (aspect) + { + case EDJE_ASPECT_PREFER_NONE: + break; + case EDJE_ASPECT_PREFER_VERTICAL: + tmp = minh * params->w / h; + if (tmp >= minw) + { + minw = tmp; + break; + } + case EDJE_ASPECT_PREFER_HORIZONTAL: + tmp = minw * params->h / w; + if (tmp >= minh) + { + minh = tmp; + break; + } + case EDJE_ASPECT_PREFER_BOTH: + tmp = minh * params->w / h; + if (tmp >= minw) + { + minw = tmp; + break; + } + + tmp = minw * params->h / w; + if (tmp >= minh) + { + minh = tmp; + break; + } + + break; + } + + _edje_part_recalc_single_min_length(desc->align.x, ¶ms->x, ¶ms->w, minw); + _edje_part_recalc_single_min_length(desc->align.y, ¶ms->y, ¶ms->h, minh); +} + +static void +_edje_part_recalc_single_max_length(FLOAT_T align, int *start, int *length, int max) +{ + if (max >= 0) + { + if (*length > max) + { + *start += TO_INT(SCALE(align, (*length - max))); + *length = max; + } + } +} + +static void +_edje_part_recalc_single_max(Edje_Part_Description_Common *desc, + Edje_Calc_Params *params, + int maxw, int maxh, + Edje_Internal_Aspect aspect) +{ + int tmp; + int w; + int h; + + w = params->w ? params->w : 99999; + h = params->h ? params->h : 99999; + + switch (aspect) + { + case EDJE_ASPECT_PREFER_NONE: + break; + case EDJE_ASPECT_PREFER_VERTICAL: + tmp = maxh * params->w / h; + if (tmp <= maxw) + { + maxw = tmp; + break; + } + case EDJE_ASPECT_PREFER_HORIZONTAL: + tmp = maxw * params->h / w; + if (tmp <= maxh) + { + maxh = tmp; + break; + } + case EDJE_ASPECT_PREFER_BOTH: + tmp = maxh * params->w / h; + if (tmp <= maxw) + { + maxw = tmp; + break; + } + + tmp = maxw * params->h / w; + if (tmp <= maxh) + { + maxh = tmp; + break; + } + + break; + } + + _edje_part_recalc_single_max_length(desc->align.x, ¶ms->x, ¶ms->w, maxw); + _edje_part_recalc_single_max_length(desc->align.y, ¶ms->y, ¶ms->h, maxh); +} + +static void +_edje_part_recalc_single_drag(Edje_Real_Part *ep, + Edje_Real_Part *confine_to, + Edje_Calc_Params *params, + int minw, int minh, + int maxw, int maxh) +{ + /* confine */ + if (confine_to) + { + int offset; + int step; + FLOAT_T v; + + /* complex dragable params */ + v = SCALE(ep->drag->size.x, confine_to->w); + + if ((minw > 0) && (TO_INT(v) < minw)) params->w = minw; + else if ((maxw >= 0) && (TO_INT(v) > maxw)) params->w = maxw; + else params->w = TO_INT(v); + + offset = TO_INT(SCALE(ep->drag->x, (confine_to->w - params->w))) + + ep->drag->tmp.x; + if (ep->part->dragable.step_x > 0) + { + params->x = confine_to->x + + ((offset / ep->part->dragable.step_x) * ep->part->dragable.step_x); + } + else if (ep->part->dragable.count_x > 0) + { + step = (confine_to->w - params->w) / ep->part->dragable.count_x; + if (step < 1) step = 1; + params->x = confine_to->x + + ((offset / step) * step); + } + params->req_drag.x = params->x; + params->req_drag.w = params->w; + + v = SCALE(ep->drag->size.y, confine_to->h); + + if ((minh > 0) && (TO_INT(v) < minh)) params->h = minh; + else if ((maxh >= 0) && (TO_INT(v) > maxh)) params->h = maxh; + else params->h = TO_INT(v); + + offset = TO_INT(SCALE(ep->drag->y, (confine_to->h - params->h))) + + ep->drag->tmp.y; + if (ep->part->dragable.step_y > 0) + { + params->y = confine_to->y + + ((offset / ep->part->dragable.step_y) * ep->part->dragable.step_y); + } + else if (ep->part->dragable.count_y > 0) + { + step = (confine_to->h - params->h) / ep->part->dragable.count_y; + if (step < 1) step = 1; + params->y = confine_to->y + + ((offset / step) * step); + } + params->req_drag.y = params->y; + params->req_drag.h = params->h; + + /* limit to confine */ + if (params->x < confine_to->x) + { + params->x = confine_to->x; + } + if ((params->x + params->w) > (confine_to->x + confine_to->w)) + { + params->x = confine_to->x + confine_to->w - params->w; + } + if (params->y < confine_to->y) + { + params->y = confine_to->y; + } + if ((params->y + params->h) > (confine_to->y + confine_to->h)) + { + params->y = confine_to->y + confine_to->h - params->h; + } + } + else + { + /* simple dragable params */ + params->x += TO_INT(ep->drag->x) + ep->drag->tmp.x; + params->req_drag.x = params->x; + params->req_drag.w = params->w; + + params->y += TO_INT(ep->drag->y) + ep->drag->tmp.y; + params->req_drag.y = params->y; + params->req_drag.h = params->h; + } +} + +static void +_edje_part_recalc_single_fill(Edje_Real_Part *ep, + Edje_Part_Description_Spec_Fill *fill, + Edje_Calc_Params *params) +{ + int fw; + int fh; + + params->smooth = fill->smooth; + + if (fill->type == EDJE_FILL_TYPE_TILE) + evas_object_image_size_get(ep->object, &fw, NULL); + else + fw = params->w; + + params->type.common.fill.x = fill->pos_abs_x + + TO_INT(SCALE(fill->pos_rel_x, fw)); + params->type.common.fill.w = fill->abs_x + + TO_INT(SCALE(fill->rel_x, fw)); + + if (fill->type == EDJE_FILL_TYPE_TILE) + evas_object_image_size_get(ep->object, NULL, &fh); + else + fh = params->h; + + params->type.common.fill.y = fill->pos_abs_y + + TO_INT(SCALE(fill->pos_rel_y, fh)); + params->type.common.fill.h = fill->abs_y + + TO_INT(SCALE(fill->rel_y, fh)); + + params->type.common.fill.angle = fill->angle; + params->type.common.fill.spread = fill->spread; +} + +static void +_edje_part_recalc_single_min_max(FLOAT_T sc, + Edje_Real_Part *ep, + Edje_Part_Description_Common *desc, + int *minw, int *minh, + int *maxw, int *maxh) +{ + *minw = desc->min.w; + if (ep->part->scale) *minw = TO_INT(SCALE(sc, *minw)); + if (ep->swallow_params.min.w > desc->min.w) + *minw = ep->swallow_params.min.w; + + /* XXX TODO: remove need of EDJE_INF_MAX_W, see edje_util.c */ + if ((ep->swallow_params.max.w <= 0) || + (ep->swallow_params.max.w == EDJE_INF_MAX_W)) + { + *maxw = desc->max.w; + if (*maxw > 0) + { + if (ep->part->scale) *maxw = TO_INT(SCALE(sc, *maxw)); + if (*maxw < 1) *maxw = 1; + } + } + else + { + if (desc->max.w <= 0) + *maxw = ep->swallow_params.max.w; + else + { + *maxw = desc->max.w; + if (*maxw > 0) + { + if (ep->part->scale) *maxw = TO_INT(SCALE(sc, *maxw)); + if (*maxw < 1) *maxw = 1; + } + if (ep->swallow_params.max.w < *maxw) + *maxw = ep->swallow_params.max.w; + } + } + if (*maxw >= 0) + { + if (*maxw < *minw) *maxw = *minw; + } + + *minh = desc->min.h; + if (ep->part->scale) *minh = TO_INT(SCALE(sc, *minh)); + if (ep->swallow_params.min.h > desc->min.h) + *minh = ep->swallow_params.min.h; + + /* XXX TODO: remove need of EDJE_INF_MAX_H, see edje_util.c */ + if ((ep->swallow_params.max.h <= 0) || + (ep->swallow_params.max.h == EDJE_INF_MAX_H)) + { + *maxh = desc->max.h; + if (*maxh > 0) + { + if (ep->part->scale) *maxh = TO_INT(SCALE(sc, *maxh)); + if (*maxh < 1) *maxh = 1; + } + } + else + { + if (desc->max.h <= 0) + *maxh = ep->swallow_params.max.h; + else + { + *maxh = desc->max.h; + if (*maxh > 0) + { + if (ep->part->scale) *maxh = TO_INT(SCALE(sc, *maxh)); + if (*maxh < 1) *maxh = 1; + } + if (ep->swallow_params.max.h < *maxh) + *maxh = ep->swallow_params.max.h; + } + } + if (*maxh >= 0) + { + if (*maxh < *minh) *maxh = *minh; + } +} + +static void +_edje_part_recalc_single_map(Edje *ed, + Edje_Real_Part *ep __UNUSED__, + Edje_Real_Part *center, + Edje_Real_Part *light, + Edje_Real_Part *persp, + Edje_Part_Description_Common *desc, + Edje_Part_Description_Common *chosen_desc, + Edje_Calc_Params *params) +{ + params->mapped = chosen_desc->map.on; + params->lighted = params->mapped ? !!light : 0; + params->persp_on = params->mapped ? !!persp : 0; + + if (!params->mapped) return ; + + if (center) + { + params->map.center.x = ed->x + center->x + (center->w / 2); + params->map.center.y = ed->y + center->y + (center->h / 2); + } + else + { + params->map.center.x = ed->x + params->x + (params->w / 2); + params->map.center.y = ed->y + params->y + (params->h / 2); + } + params->map.center.z = 0; + + params->map.rotation.x = TO_DOUBLE(desc->map.rot.x); + params->map.rotation.y = TO_DOUBLE(desc->map.rot.y); + params->map.rotation.z = TO_DOUBLE(desc->map.rot.z); + + if (light) + { + Edje_Part_Description_Common *light_desc2; + FLOAT_T pos, pos2; + + params->map.light.x = ed->x + light->x + (light->w / 2); + params->map.light.y = ed->y + light->y + (light->h / 2); + + pos = light->description_pos; + pos2 = (pos < ZERO) ? ZERO : ((pos > FROM_INT(1)) ? FROM_INT(1) : pos); + + light_desc2 = light->param2 ? light->param2->description : NULL; + + /* take into account CURRENT state also */ + if (pos != ZERO && light_desc2) + { + params->map.light.z = light->param1.description->persp.zplane + + TO_INT(SCALE(pos, light_desc2->persp.zplane - light->param1.description->persp.zplane)); + params->map.light.r = light->param1.description->color.r + + TO_INT(SCALE(pos2, light_desc2->color.r - light->param1.description->color.r)); + params->map.light.g = light->param1.description->color.g + + TO_INT(SCALE(pos2, light_desc2->color.g - light->param1.description->color.g)); + params->map.light.b = light->param1.description->color.b + + TO_INT(SCALE(pos2, light_desc2->color.b - light->param1.description->color.b)); + params->map.light.ar = light->param1.description->color2.r + + TO_INT(SCALE(pos2, light_desc2->color2.r - light->param1.description->color2.r)); + params->map.light.ag = light->param1.description->color2.g + + TO_INT(SCALE(pos2, light_desc2->color2.g - light->param1.description->color2.g)); + params->map.light.ab = light->param1.description->color2.b + + TO_INT(SCALE(pos2, light_desc2->color2.b - light->param1.description->color2.b)); + } + else + { + params->map.light.z = light->param1.description->persp.zplane; + params->map.light.r = light->param1.description->color.r; + params->map.light.g = light->param1.description->color.g; + params->map.light.b = light->param1.description->color.b; + params->map.light.ar = light->param1.description->color2.r; + params->map.light.ag = light->param1.description->color2.g; + params->map.light.ab = light->param1.description->color2.b; + } + } + + if (persp) + { + FLOAT_T pos; + + params->map.persp.x = ed->x + persp->x + (persp->w / 2); + params->map.persp.y = ed->y + persp->y + (persp->h / 2); + + pos = persp->description_pos; + + if (pos != 0 && persp->param2) + { + params->map.persp.z = persp->param1.description->persp.zplane + + TO_INT(SCALE(pos, persp->param2->description->persp.zplane - + persp->param1.description->persp.zplane)); + params->map.persp.focal = persp->param1.description->persp.focal + + TO_INT(SCALE(pos, persp->param2->description->persp.focal - + persp->param1.description->persp.focal)); + } + else + { + params->map.persp.z = persp->param1.description->persp.zplane; + params->map.persp.focal = persp->param1.description->persp.focal; + } + } +} + +static void +_edje_part_recalc_single(Edje *ed, + Edje_Real_Part *ep, + Edje_Part_Description_Common *desc, + Edje_Part_Description_Common *chosen_desc, + Edje_Real_Part *center, + Edje_Real_Part *light, + Edje_Real_Part *persp, + Edje_Real_Part *rel1_to_x, + Edje_Real_Part *rel1_to_y, + Edje_Real_Part *rel2_to_x, + Edje_Real_Part *rel2_to_y, + Edje_Real_Part *confine_to, + Edje_Calc_Params *params) +{ + Edje_Color_Class *cc = NULL; + Edje_Internal_Aspect apref; + int minw = 0, minh = 0, maxw = 0, maxh = 0; + FLOAT_T sc; + + sc = ed->scale; + if (sc == ZERO) sc = _edje_scale; + _edje_part_recalc_single_min_max(sc, ep, desc, &minw, &minh, &maxw, &maxh); + + /* relative coords of top left & bottom right */ + _edje_part_recalc_single_rel(ed, ep, desc, rel1_to_x, rel1_to_y, rel2_to_x, rel2_to_y, params); + + /* aspect */ + apref = _edje_part_recalc_single_aspect(ep, desc, params, &minw, &minh, &maxw, &maxh); + + /* size step */ + _edje_part_recalc_single_step(desc, params); + + /* if we have text that wants to make the min size the text size... */ + if (ep->part->type == EDJE_PART_TYPE_TEXTBLOCK) + _edje_part_recalc_single_textblock(sc, ed, ep, (Edje_Part_Description_Text*) chosen_desc, params, &minw, &minh, &maxw, &maxh); + else if (ep->part->type == EDJE_PART_TYPE_TEXT) + _edje_part_recalc_single_text(sc, ed, ep, (Edje_Part_Description_Text*) desc, (Edje_Part_Description_Text*) chosen_desc, params, &minw, &minh, &maxw, &maxh); + + if ((ep->part->type == EDJE_PART_TYPE_TABLE) && + (((((Edje_Part_Description_Table *)chosen_desc)->table.min.h) || + (((Edje_Part_Description_Table *)chosen_desc)->table.min.v)))) + { + Evas_Coord lminw = 0, lminh = 0; + + evas_object_smart_need_recalculate_set(ep->object, 1); + evas_object_smart_calculate(ep->object); + evas_object_size_hint_min_get(ep->object, &lminw, &lminh); + if (((Edje_Part_Description_Table *)chosen_desc)->table.min.h) + { + if (lminw > minw) minw = lminw; + } + if (((Edje_Part_Description_Table *)chosen_desc)->table.min.v) + { + if (lminh > minh) minh = lminh; + } + } + else if ((ep->part->type == EDJE_PART_TYPE_BOX) && + ((((Edje_Part_Description_Box *)chosen_desc)->box.min.h) || + (((Edje_Part_Description_Box *)chosen_desc)->box.min.v))) + { + Evas_Coord lminw = 0, lminh = 0; + + evas_object_smart_need_recalculate_set(ep->object, 1); + evas_object_smart_calculate(ep->object); + evas_object_size_hint_min_get(ep->object, &lminw, &lminh); + if (((Edje_Part_Description_Box *)chosen_desc)->box.min.h) + { + if (lminw > minw) minw = lminw; + } + if (((Edje_Part_Description_Box *)chosen_desc)->box.min.v) + { + if (lminh > minh) minh = lminh; + } + } + + /* remember what our size is BEFORE we go limit it */ + params->req.x = params->x; + params->req.y = params->y; + params->req.w = params->w; + params->req.h = params->h; + + /* adjust for min size */ + _edje_part_recalc_single_min(desc, params, minw, minh, apref); + + /* adjust for max size */ + _edje_part_recalc_single_max(desc, params, maxw, maxh, apref); + + /* take care of dragable part */ + if (ep->drag) + _edje_part_recalc_single_drag(ep, confine_to, params, minw, minh, maxw, maxh); + + /* fill */ + if (ep->part->type == EDJE_PART_TYPE_IMAGE) + _edje_part_recalc_single_fill(ep, &((Edje_Part_Description_Image *)desc)->image.fill, params); + else if (ep->part->type == EDJE_PART_TYPE_PROXY) + _edje_part_recalc_single_fill(ep, &((Edje_Part_Description_Proxy *)desc)->proxy.fill, params); + + /* colors */ + if ((desc->color_class) && (*desc->color_class)) + cc = _edje_color_class_find(ed, desc->color_class); + + if (cc) + { + params->color.r = (((int)cc->r + 1) * desc->color.r) >> 8; + params->color.g = (((int)cc->g + 1) * desc->color.g) >> 8; + params->color.b = (((int)cc->b + 1) * desc->color.b) >> 8; + params->color.a = (((int)cc->a + 1) * desc->color.a) >> 8; + } + else + { + params->color.r = desc->color.r; + params->color.g = desc->color.g; + params->color.b = desc->color.b; + params->color.a = desc->color.a; + } + + /* visible */ + params->visible = desc->visible; + + switch (ep->part->type) + { + case EDJE_PART_TYPE_IMAGE: + { + Edje_Part_Description_Image *img_desc = (Edje_Part_Description_Image*) desc; + + /* border */ + params->type.common.spec.image.l = img_desc->image.border.l; + params->type.common.spec.image.r = img_desc->image.border.r; + + params->type.common.spec.image.t = img_desc->image.border.t; + params->type.common.spec.image.b = img_desc->image.border.b; + break; + } + case EDJE_PART_TYPE_TEXT: + case EDJE_PART_TYPE_TEXTBLOCK: + { + Edje_Part_Description_Text *text_desc = (Edje_Part_Description_Text*) desc; + + /* text.align */ + params->type.text.align.x = text_desc->text.align.x; + params->type.text.align.y = text_desc->text.align.y; + params->type.text.elipsis = text_desc->text.elipsis; + + /* text colors */ + if (cc) + { + params->type.text.color2.r = (((int)cc->r2 + 1) * text_desc->common.color2.r) >> 8; + params->type.text.color2.g = (((int)cc->g2 + 1) * text_desc->common.color2.g) >> 8; + params->type.text.color2.b = (((int)cc->b2 + 1) * text_desc->common.color2.b) >> 8; + params->type.text.color2.a = (((int)cc->a2 + 1) * text_desc->common.color2.a) >> 8; + params->type.text.color3.r = (((int)cc->r3 + 1) * text_desc->text.color3.r) >> 8; + params->type.text.color3.g = (((int)cc->g3 + 1) * text_desc->text.color3.g) >> 8; + params->type.text.color3.b = (((int)cc->b3 + 1) * text_desc->text.color3.b) >> 8; + params->type.text.color3.a = (((int)cc->a3 + 1) * text_desc->text.color3.a) >> 8; + } + else + { + params->type.text.color2.r = text_desc->common.color2.r; + params->type.text.color2.g = text_desc->common.color2.g; + params->type.text.color2.b = text_desc->common.color2.b; + params->type.text.color2.a = text_desc->common.color2.a; + params->type.text.color3.r = text_desc->text.color3.r; + params->type.text.color3.g = text_desc->text.color3.g; + params->type.text.color3.b = text_desc->text.color3.b; + params->type.text.color3.a = text_desc->text.color3.a; + } + + break; + } + case EDJE_PART_TYPE_RECTANGLE: + case EDJE_PART_TYPE_BOX: + case EDJE_PART_TYPE_TABLE: + case EDJE_PART_TYPE_SWALLOW: + case EDJE_PART_TYPE_GROUP: + case EDJE_PART_TYPE_PROXY: + break; + case EDJE_PART_TYPE_GRADIENT: + /* FIXME: THIS ONE SHOULD NEVER BE TRIGGERED. */ + break; + default: + break; + } + + _edje_part_recalc_single_map(ed, ep, center, light, persp, desc, chosen_desc, params); +} + +static void +_edje_table_recalc_apply(Edje *ed __UNUSED__, + Edje_Real_Part *ep, + Edje_Calc_Params *p3 __UNUSED__, + Edje_Part_Description_Table *chosen_desc) +{ + evas_object_table_homogeneous_set(ep->object, chosen_desc->table.homogeneous); + evas_object_table_align_set(ep->object, TO_DOUBLE(chosen_desc->table.align.x), TO_DOUBLE(chosen_desc->table.align.y)); + evas_object_table_padding_set(ep->object, chosen_desc->table.padding.x, chosen_desc->table.padding.y); + if (evas_object_smart_need_recalculate_get(ep->object)) + { + evas_object_smart_need_recalculate_set(ep->object, 0); + evas_object_smart_calculate(ep->object); + } +} + +static int +_edje_image_find(Evas_Object *obj, Edje *ed, Edje_Real_Part_Set **eps, Edje_Part_Description_Image *st, Edje_Part_Image_Id *imid) +{ + Edje_Image_Directory_Set_Entry *entry; + Edje_Image_Directory_Set *set = NULL; + Eina_List *l; + int w = 0; + int h = 0; + int id; + + if (!st && !imid) + return -1; + + if (st && !st->image.set) + return st->image.id; + + if (imid && !imid->set) + return imid->id; + + if (imid) + id = imid->id; + else + id = st->image.id; + + evas_object_geometry_get(obj, NULL, NULL, &w, &h); + + if (eps && *eps) + { + if ((*eps)->id == id) + set = (*eps)->set; + + if (set) + if ((*eps)->entry->size.min.w <= w && w <= (*eps)->entry->size.max.w) + if ((*eps)->entry->size.min.h <= h && h <= (*eps)->entry->size.max.h) + return (*eps)->entry->id; + } + + if (!set) + set = ed->file->image_dir->sets + id; + + EINA_LIST_FOREACH(set->entries, l, entry) + { + if (entry->size.min.w <= w && w <= entry->size.max.w) + if (entry->size.min.h <= h && h <= entry->size.max.h) + { + if (eps) + { + if (!*eps) + *eps = calloc(1, sizeof (Edje_Real_Part_Set)); + + if (*eps) + { + (*eps)->entry = entry; + (*eps)->set = set; + (*eps)->id = id; + } + } + return entry->id; + } + } + + return -1; +} + +static void +_edje_proxy_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3, Edje_Part_Description_Proxy *chosen_desc, FLOAT_T pos) +{ + Edje_Real_Part *pp; + int part_id = -1; + + if (pos >= 0.5) + part_id = ((Edje_Part_Description_Proxy*) ep->param2->description)->proxy.id; + else + part_id = chosen_desc->proxy.id; + + if ((p3->type.common.fill.w == 0) || (p3->type.common.fill.h == 0) || + (part_id < 0)) + { + evas_object_image_source_set(ep->object, NULL); + return; + } + pp = ed->table_parts[part_id % ed->table_parts_size]; + + switch (pp->part->type) + { + case EDJE_PART_TYPE_IMAGE: + case EDJE_PART_TYPE_TEXT: + case EDJE_PART_TYPE_TEXTBLOCK: + case EDJE_PART_TYPE_RECTANGLE: + case EDJE_PART_TYPE_BOX: + case EDJE_PART_TYPE_TABLE: + case EDJE_PART_TYPE_PROXY: + evas_object_image_source_set(ep->object, pp->object); + break; + case EDJE_PART_TYPE_GRADIENT: + /* FIXME: THIS ONE SHOULD NEVER BE TRIGGERED. */ + break; + case EDJE_PART_TYPE_GROUP: + case EDJE_PART_TYPE_SWALLOW: + case EDJE_PART_TYPE_EXTERNAL: + evas_object_image_source_set(ep->object, pp->swallowed_object); + break; + } + + evas_object_image_fill_set(ep->object, p3->type.common.fill.x, p3->type.common.fill.y, + p3->type.common.fill.w, p3->type.common.fill.h); + evas_object_image_smooth_scale_set(ep->object, p3->smooth); +} + +static void +_edje_image_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3, Edje_Part_Description_Image *chosen_desc, FLOAT_T pos) +{ + int image_id; + int image_count, image_num; + FLOAT_T sc; + + sc = ed->scale; + if (sc == 0.0) sc = _edje_scale; + evas_object_image_fill_set(ep->object, p3->type.common.fill.x, p3->type.common.fill.y, + p3->type.common.fill.w, p3->type.common.fill.h); + evas_object_image_smooth_scale_set(ep->object, p3->smooth); + if (chosen_desc->image.border.scale) + { + if (chosen_desc->image.border.scale_by > FROM_DOUBLE(0.0)) + { + FLOAT_T sc2 = MUL(sc, chosen_desc->image.border.scale_by); + evas_object_image_border_scale_set(ep->object, TO_DOUBLE(sc2)); + } + else + evas_object_image_border_scale_set(ep->object, TO_DOUBLE(sc)); + } + else + { + if (chosen_desc->image.border.scale_by > FROM_DOUBLE(0.0)) + evas_object_image_border_scale_set + (ep->object, TO_DOUBLE(chosen_desc->image.border.scale_by)); + else + evas_object_image_border_scale_set(ep->object, 1.0); + } + evas_object_image_border_set(ep->object, p3->type.common.spec.image.l, p3->type.common.spec.image.r, + p3->type.common.spec.image.t, p3->type.common.spec.image.b); + if (chosen_desc->image.border.no_fill == 0) + evas_object_image_border_center_fill_set(ep->object, EVAS_BORDER_FILL_DEFAULT); + else if (chosen_desc->image.border.no_fill == 1) + evas_object_image_border_center_fill_set(ep->object, EVAS_BORDER_FILL_NONE); + else if (chosen_desc->image.border.no_fill == 2) + evas_object_image_border_center_fill_set(ep->object, EVAS_BORDER_FILL_SOLID); + + image_id = _edje_image_find(ep->object, ed, + &ep->param1.set, + (Edje_Part_Description_Image*) ep->param1.description, + NULL); + if (image_id < 0) + { + Edje_Image_Directory_Entry *ie; + + if (!ed->file->image_dir) ie = NULL; + else ie = ed->file->image_dir->entries + (-image_id) - 1; + if ((ie) && + (ie->source_type == EDJE_IMAGE_SOURCE_TYPE_EXTERNAL) && + (ie->entry)) + { + evas_object_image_file_set(ep->object, ie->entry, NULL); + } + } + else + { + image_count = 2; + if (ep->param2) + image_count += ((Edje_Part_Description_Image*) ep->param2->description)->image.tweens_count; + image_num = TO_INT(MUL(pos, SUB(FROM_INT(image_count), + FROM_DOUBLE(0.5)))); + if (image_num > (image_count - 1)) + image_num = image_count - 1; + if (image_num == 0) + { + image_id = _edje_image_find(ep->object, ed, + &ep->param1.set, + (Edje_Part_Description_Image*) ep->param1.description, + NULL); + } + else + if (ep->param2) + { + if (image_num == (image_count - 1)) + { + image_id = _edje_image_find(ep->object, ed, + &ep->param2->set, + (Edje_Part_Description_Image*) ep->param2->description, + NULL); + } + else + { + Edje_Part_Image_Id *imid; + + imid = ((Edje_Part_Description_Image*) ep->param2->description)->image.tweens[image_num - 1]; + image_id = _edje_image_find(ep->object, ed, NULL, NULL, imid); + } + } + if (image_id < 0) + { + ERR("¨Part \"%s\" has description, " + "\"%s\" %3.3f with a missing image id!!!", + ep->part->name, + ep->param1.description->state.name, + ep->param1.description->state.value); + } + else + { + char buf[1024]; + + /* Replace snprint("edje/images/%i") == memcpy + itoa */ +#define IMAGES "edje/images/" + memcpy(buf, IMAGES, strlen(IMAGES)); + eina_convert_itoa(image_id, buf + strlen(IMAGES)); /* No need to check length as 2³² need only 10 characteres. */ + + evas_object_image_file_set(ep->object, ed->file->path, buf); + if (evas_object_image_load_error_get(ep->object) != EVAS_LOAD_ERROR_NONE) + { + ERR("Error loading image collection \"%s\" from " + "file \"%s\". Missing EET Evas loader module?", + buf, ed->file->path); + switch (evas_object_image_load_error_get(ep->object)) + { + case EVAS_LOAD_ERROR_GENERIC: + ERR("Error type: EVAS_LOAD_ERROR_GENERIC"); + break; + case EVAS_LOAD_ERROR_DOES_NOT_EXIST: + ERR("Error type: EVAS_LOAD_ERROR_DOES_NOT_EXIST"); + break; + case EVAS_LOAD_ERROR_PERMISSION_DENIED: + ERR("Error type: EVAS_LOAD_ERROR_PERMISSION_DENIED"); + break; + case EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED: + ERR("Error type: EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED"); + break; + case EVAS_LOAD_ERROR_CORRUPT_FILE: + ERR("Error type: EVAS_LOAD_ERROR_CORRUPT_FILE"); + break; + case EVAS_LOAD_ERROR_UNKNOWN_FORMAT: + ERR("Error type: EVAS_LOAD_ERROR_UNKNOWN_FORMAT"); + break; + default: + ERR("Error type: ???"); + break; + } + } + } + } +} + +static Edje_Real_Part * +_edje_real_part_state_get(Edje *ed, Edje_Real_Part *ep, int flags, int id, int *state) +{ + Edje_Real_Part *result = NULL; + + if (id >= 0 && id != ep->part->id) + { + result = ed->table_parts[id % ed->table_parts_size]; + if (result) + { + if (!result->calculated) _edje_part_recalc(ed, result, flags, NULL); +#ifdef EDJE_CALC_CACHE + if (state) *state = result->state; +#else + (void) state; +#endif + } + } + return result; +} + +void +_edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *state) +{ +#ifdef EDJE_CALC_CACHE + Eina_Bool proxy_invalidate = EINA_FALSE; + int state1 = -1; + int state2 = -1; + int statec = -1; +#else + Edje_Calc_Params lp1, lp2; +#endif + int statec1 = -1; + int statec2 = -1; + int statel1 = -1; + int statel2 = -1; + int statep1 = -1; + int statep2 = -1; + Edje_Real_Part *center[2] = { NULL, NULL }; + Edje_Real_Part *light[2] = { NULL, NULL }; + Edje_Real_Part *persp[2] = { NULL, NULL }; + Edje_Calc_Params *p1, *pf; + Edje_Part_Description_Common *chosen_desc; + Edje_Real_Part *confine_to = NULL; + FLOAT_T pos = ZERO, pos2; + Edje_Calc_Params lp3; + + /* GRADIENT ARE GONE, WE MUST IGNORE IT FROM OLD FILE. */ + if (ep->part->type == EDJE_PART_TYPE_GRADIENT) + { + ERR("GRADIENT spotted during recalc ! That should never happen ! Send your edje file to devel ml."); + return; + } + + if ((ep->calculated & FLAG_XY) == FLAG_XY && !state) + { + return; + } + if (ep->calculating & flags) + { +#if 1 + const char *axes = "NONE", *faxes = "NONE"; + + if ((ep->calculating & FLAG_X) && + (ep->calculating & FLAG_Y)) + axes = "XY"; + else if ((ep->calculating & FLAG_X)) + axes = "X"; + else if ((ep->calculating & FLAG_Y)) + axes = "Y"; + + if ((flags & FLAG_X) && + (flags & FLAG_Y)) + faxes = "XY"; + else if ((flags & FLAG_X)) + faxes = "X"; + else if ((flags & FLAG_Y)) + faxes = "Y"; + ERR("Circular dependency when calculating part \"%s\". " + "Already calculating %s [%02x] axes. " + "Need to calculate %s [%02x] axes", + ep->part->name, + axes, ep->calculating, + faxes, flags); +#endif + return; + } +#ifdef EDJE_CALC_CACHE + if (ep->state == ed->state && !state) + return ; +#endif + + if (flags & FLAG_X) + { + ep->calculating |= flags & FLAG_X; + if (ep->param1.rel1_to_x) + { + _edje_part_recalc(ed, ep->param1.rel1_to_x, FLAG_X, NULL); +#ifdef EDJE_CALC_CACHE + state1 = ep->param1.rel1_to_x->state; +#endif + } + if (ep->param1.rel2_to_x) + { + _edje_part_recalc(ed, ep->param1.rel2_to_x, FLAG_X, NULL); +#ifdef EDJE_CALC_CACHE + if (state1 < ep->param1.rel2_to_x->state) + state1 = ep->param1.rel2_to_x->state; +#endif + } + if (ep->param2) + { + if (ep->param2->rel1_to_x) + { + _edje_part_recalc(ed, ep->param2->rel1_to_x, FLAG_X, NULL); +#ifdef EDJE_CALC_CACHE + state2 = ep->param2->rel1_to_x->state; +#endif + } + if (ep->param2->rel2_to_x) + { + _edje_part_recalc(ed, ep->param2->rel2_to_x, FLAG_X, NULL); +#ifdef EDJE_CALC_CACHE + if (state2 < ep->param2->rel2_to_x->state) + state2 = ep->param2->rel2_to_x->state; +#endif + } + } + } + if (flags & FLAG_Y) + { + ep->calculating |= flags & FLAG_Y; + if (ep->param1.rel1_to_y) + { + _edje_part_recalc(ed, ep->param1.rel1_to_y, FLAG_Y, NULL); +#ifdef EDJE_CALC_CACHE + if (state1 < ep->param1.rel1_to_y->state) + state1 = ep->param1.rel1_to_y->state; +#endif + } + if (ep->param1.rel2_to_y) + { + _edje_part_recalc(ed, ep->param1.rel2_to_y, FLAG_Y, NULL); +#ifdef EDJE_CALC_CACHE + if (state1 < ep->param1.rel2_to_y->state) + state1 = ep->param1.rel2_to_y->state; +#endif + } + if (ep->param2) + { + if (ep->param2->rel1_to_y) + { + _edje_part_recalc(ed, ep->param2->rel1_to_y, FLAG_Y, NULL); +#ifdef EDJE_CALC_CACHE + if (state2 < ep->param2->rel1_to_y->state) + state2 = ep->param2->rel1_to_y->state; +#endif + } + if (ep->param2->rel2_to_y) + { + _edje_part_recalc(ed, ep->param2->rel2_to_y, FLAG_Y, NULL); +#ifdef EDJE_CALC_CACHE + if (state2 < ep->param2->rel2_to_y->state) + state2 = ep->param2->rel2_to_y->state; +#endif + } + } + } + if (ep->drag && ep->drag->confine_to) + { + confine_to = ep->drag->confine_to; + _edje_part_recalc(ed, confine_to, flags, NULL); +#ifdef EDJE_CALC_CACHE + statec = confine_to->state; +#endif + } +// if (ep->text.source) _edje_part_recalc(ed, ep->text.source, flags); +// if (ep->text.text_source) _edje_part_recalc(ed, ep->text.text_source, flags); + + /* actually calculate now */ + chosen_desc = ep->chosen_description; + if (!chosen_desc) + { + ep->calculating = FLAG_NONE; + ep->calculated |= flags; + return; + } + + if (ep->part->type == EDJE_PART_TYPE_PROXY) + { + Edje_Real_Part *pp; + int part_id = -1; + + if (pos >= 0.5) + part_id = ((Edje_Part_Description_Proxy*) ep->param2->description)->proxy.id; + else + part_id = ((Edje_Part_Description_Proxy*) chosen_desc)->proxy.id; + + pp = _edje_real_part_state_get(ed, ep, flags, part_id, NULL); + if (pp && pp->invalidate) proxy_invalidate = EINA_TRUE; + } + + /* Recalc if needed the map center && light source */ + if (ep->param1.description->map.on) + { + center[0] = _edje_real_part_state_get(ed, ep, flags, ep->param1.description->map.rot.id_center, &statec1); + light[0] = _edje_real_part_state_get(ed, ep, flags, ep->param1.description->map.id_light, &statel1); + + if (chosen_desc->map.persp_on) + { + persp[0] = _edje_real_part_state_get(ed, ep, flags, ep->param1.description->map.id_persp, &statep1); + } + } + + if (ep->param2 && ep->param2->description->map.on) + { + center[1] = _edje_real_part_state_get(ed, ep, flags, ep->param2->description->map.rot.id_center, &statec2); + light[1] = _edje_real_part_state_get(ed, ep, flags, ep->param2->description->map.id_light, &statel2); + + if (chosen_desc->map.persp_on) + { + persp[1] = _edje_real_part_state_get(ed, ep, flags, ep->param2->description->map.id_persp, &statep2); + } + } + +#ifndef EDJE_CALC_CACHE + p1 = &lp1; +#else + p1 = &ep->param1.p; +#endif + + if (ep->param1.description) + { +#ifdef EDJE_CALC_CACHE + if (ed->all_part_change || + ep->invalidate || + state1 >= ep->param1.state || + statec >= ep->param1.state || + statec1 >= ep->param1.state || + statel1 >= ep->param1.state || + statep1 >= ep->param1.state || + proxy_invalidate || + state || + ((ep->part->type == EDJE_PART_TYPE_TEXT || ep->part->type == EDJE_PART_TYPE_TEXTBLOCK) && ed->text_part_change)) +#endif + { + _edje_part_recalc_single(ed, ep, ep->param1.description, chosen_desc, center[0], light[0], persp[0], + ep->param1.rel1_to_x, ep->param1.rel1_to_y, ep->param1.rel2_to_x, ep->param1.rel2_to_y, + confine_to, + p1); + +#ifdef EDJE_CALC_CACHE + ep->param1.state = ed->state; +#endif + } + } + if (ep->param2) + { + int beginning_pos, part_type; + Edje_Calc_Params *p2, *p3; + + if (ep->current) + { + /* FIXME: except for text, we don't need in that case to recalc p1 at all*/ + memcpy(p1, ep->current, sizeof (Edje_Calc_Params)); + p1->x += ed->x; + p1->y += ed->y; + p1->map.center.x += ed->x; + p1->map.center.y += ed->y; + p1->map.light.x += ed->x; + p1->map.light.y += ed->y; + p1->map.persp.x += ed->x; + p1->map.persp.y += ed->y; + } + + p3 = &lp3; + +#ifndef EDJE_CALC_CACHE + p2 = &lp2; +#else + p2 = &ep->param2->p; + + if (ed->all_part_change || + ep->invalidate || + state2 >= ep->param2->state || + statec >= ep->param2->state || + statec2 >= ep->param2->state || + statel2 >= ep->param2->state || + statep2 >= ep->param2->state || + proxy_invalidate || + state || + ((ep->part->type == EDJE_PART_TYPE_TEXT || ep->part->type == EDJE_PART_TYPE_TEXTBLOCK) && ed->text_part_change)) +#endif + { + _edje_part_recalc_single(ed, ep, ep->param2->description, chosen_desc, center[1], light[1], persp[1], + ep->param2->rel1_to_x, ep->param2->rel1_to_y, ep->param2->rel2_to_x, ep->param2->rel2_to_y, + confine_to, + p2); +#ifdef EDJE_CALC_CACHE + ep->param2->state = ed->state; +#endif + } + + pos = ep->description_pos; + pos2 = pos; + if (pos2 < ZERO) pos2 = ZERO; + else if (pos2 > FROM_INT(1)) pos2 = FROM_INT(1); + beginning_pos = (pos < FROM_DOUBLE(0.5)); + part_type = ep->part->type; + + /* visible is special */ + if ((p1->visible) && (!p2->visible)) + p3->visible = (pos != FROM_INT(1)); + else if ((!p1->visible) && (p2->visible)) + p3->visible = (pos != ZERO); + else + p3->visible = p1->visible; + + p3->smooth = (beginning_pos) ? p1->smooth : p2->smooth; + + /* FIXME: do x and y separately base on flag */ +#define FINTP(_x1, _x2, _p) \ + (((_x1) == (_x2)) \ + ? FROM_INT((_x1)) \ + : ADD(FROM_INT(_x1), \ + SCALE((_p), (_x2) - (_x1)))) + +#define FFP(_x1, _x2, _p) \ + (((_x1) == (_x2)) \ + ? (_x1) \ + : ADD(_x1, MUL(_p, SUB(_x2, _x1)))); + +#define INTP(_x1, _x2, _p) TO_INT(FINTP(_x1, _x2, _p)) + + p3->x = INTP(p1->x, p2->x, pos); + p3->y = INTP(p1->y, p2->y, pos); + p3->w = INTP(p1->w, p2->w, pos); + p3->h = INTP(p1->h, p2->h, pos); + + p3->req.x = INTP(p1->req.x, p2->req.x, pos); + p3->req.y = INTP(p1->req.y, p2->req.y, pos); + p3->req.w = INTP(p1->req.w, p2->req.w, pos); + p3->req.h = INTP(p1->req.h, p2->req.h, pos); + + if (ep->part->dragable.x) + { + p3->req_drag.x = INTP(p1->req_drag.x, p2->req_drag.x, pos); + p3->req_drag.w = INTP(p1->req_drag.w, p2->req_drag.w, pos); + } + if (ep->part->dragable.y) + { + p3->req_drag.y = INTP(p1->req_drag.y, p2->req_drag.y, pos); + p3->req_drag.h = INTP(p1->req_drag.h, p2->req_drag.h, pos); + } + + p3->color.r = INTP(p1->color.r, p2->color.r, pos2); + p3->color.g = INTP(p1->color.g, p2->color.g, pos2); + p3->color.b = INTP(p1->color.b, p2->color.b, pos2); + p3->color.a = INTP(p1->color.a, p2->color.a, pos2); + + switch (part_type) + { + case EDJE_PART_TYPE_IMAGE: + p3->type.common.spec.image.l = INTP(p1->type.common.spec.image.l, p2->type.common.spec.image.l, pos); + p3->type.common.spec.image.r = INTP(p1->type.common.spec.image.r, p2->type.common.spec.image.r, pos); + p3->type.common.spec.image.t = INTP(p1->type.common.spec.image.t, p2->type.common.spec.image.t, pos); + p3->type.common.spec.image.b = INTP(p1->type.common.spec.image.b, p2->type.common.spec.image.b, pos); + case EDJE_PART_TYPE_PROXY: + p3->type.common.fill.x = INTP(p1->type.common.fill.x, p2->type.common.fill.x, pos); + p3->type.common.fill.y = INTP(p1->type.common.fill.y, p2->type.common.fill.y, pos); + p3->type.common.fill.w = INTP(p1->type.common.fill.w, p2->type.common.fill.w, pos); + p3->type.common.fill.h = INTP(p1->type.common.fill.h, p2->type.common.fill.h, pos); + break; + case EDJE_PART_TYPE_TEXT: + p3->type.text.size = INTP(p1->type.text.size, p2->type.text.size, pos); + case EDJE_PART_TYPE_TEXTBLOCK: + p3->type.text.color2.r = INTP(p1->type.text.color2.r, p2->type.text.color2.r, pos2); + p3->type.text.color2.g = INTP(p1->type.text.color2.g, p2->type.text.color2.g, pos2); + p3->type.text.color2.b = INTP(p1->type.text.color2.b, p2->type.text.color2.b, pos2); + p3->type.text.color2.a = INTP(p1->type.text.color2.a, p2->type.text.color2.a, pos2); + + p3->type.text.color3.r = INTP(p1->type.text.color3.r, p2->type.text.color3.r, pos2); + p3->type.text.color3.g = INTP(p1->type.text.color3.g, p2->type.text.color3.g, pos2); + p3->type.text.color3.b = INTP(p1->type.text.color3.b, p2->type.text.color3.b, pos2); + p3->type.text.color3.a = INTP(p1->type.text.color3.a, p2->type.text.color3.a, pos2); + + p3->type.text.align.x = FFP(p1->type.text.align.x, p2->type.text.align.x, pos); + p3->type.text.align.y = FFP(p1->type.text.align.y, p2->type.text.align.y, pos); + p3->type.text.elipsis = TO_DOUBLE(FINTP(p1->type.text.elipsis, p2->type.text.elipsis, pos2)); + break; + } + + p3->mapped = p1->mapped; + p3->persp_on = p3->mapped ? p1->persp_on | p2->persp_on : 0; + p3->lighted = p3->mapped ? p1->lighted | p2->lighted : 0; + if (p1->mapped) + { + p3->map.center.x = INTP(p1->map.center.x, p2->map.center.x, pos); + p3->map.center.y = INTP(p1->map.center.y, p2->map.center.y, pos); + p3->map.center.z = INTP(p1->map.center.z, p2->map.center.z, pos); + p3->map.rotation.x = FFP(p1->map.rotation.x, p2->map.rotation.x, pos); + p3->map.rotation.y = FFP(p1->map.rotation.y, p2->map.rotation.y, pos); + p3->map.rotation.z = FFP(p1->map.rotation.z, p2->map.rotation.z, pos); + +#define MIX(P1, P2, P3, pos, info) \ + P3->info = P1->info + TO_INT(SCALE(pos, P2->info - P1->info)); + + if (p1->lighted && p2->lighted) + { + MIX(p1, p2, p3, pos, map.light.x); + MIX(p1, p2, p3, pos, map.light.y); + MIX(p1, p2, p3, pos, map.light.z); + MIX(p1, p2, p3, pos, map.light.r); + MIX(p1, p2, p3, pos, map.light.g); + MIX(p1, p2, p3, pos, map.light.b); + MIX(p1, p2, p3, pos, map.light.ar); + MIX(p1, p2, p3, pos, map.light.ag); + MIX(p1, p2, p3, pos, map.light.ab); + } + else if (p1->lighted) + { + memcpy(&p3->map.light, &p1->map.light, sizeof (p1->map.light)); + } + else if (p2->lighted) + { + memcpy(&p3->map.light, &p2->map.light, sizeof (p2->map.light)); + } + + if (p1->persp_on && p2->persp_on) + { + MIX(p1, p2, p3, pos, map.persp.x); + MIX(p1, p2, p3, pos, map.persp.y); + MIX(p1, p2, p3, pos, map.persp.z); + MIX(p1, p2, p3, pos, map.persp.focal); + } + else if (p1->persp_on) + { + memcpy(&p3->map.persp, &p1->map.persp, sizeof (p1->map.light)); + } + else if (p2->persp_on) + { + memcpy(&p3->map.persp, &p2->map.persp, sizeof (p2->map.light)); + } + } + + pf = p3; + } + else + { + pf = p1; + } + + if (!pf->persp_on && chosen_desc->map.persp_on) + { + if (ed->persp) + { + pf->map.persp.x = ed->persp->px; + pf->map.persp.y = ed->persp->py; + pf->map.persp.z = ed->persp->z0; + pf->map.persp.focal = ed->persp->foc; + } + else + { + const Edje_Perspective *ps; + + // fixme: a tad inefficient as this is a has lookup + ps = edje_object_perspective_get(ed->obj); + if (!ps) + ps = edje_evas_global_perspective_get(evas_object_evas_get(ed->obj)); + if (ps) + { + pf->map.persp.x = ps->px; + pf->map.persp.y = ps->py; + pf->map.persp.z = ps->z0; + pf->map.persp.focal = ps->foc; + } + else + { + pf->map.persp.x = ed->x + (ed->w / 2); + pf->map.persp.y = ed->y + (ed->h / 2); + pf->map.persp.z = 0; + pf->map.persp.focal = 1000; + } + } + } + + if (state) + { + memcpy(state, pf, sizeof (Edje_Calc_Params)); + } + + ep->req = pf->req; + + if (ep->drag && ep->drag->need_reset) + { + FLOAT_T dx, dy; + + dx = ZERO; + dy = ZERO; + _edje_part_dragable_calc(ed, ep, &dx, &dy); + ep->drag->x = dx; + ep->drag->y = dy; + ep->drag->tmp.x = 0; + ep->drag->tmp.y = 0; + ep->drag->need_reset = 0; + } + if (!ed->calc_only) + { + Evas_Object *mo; + + /* Common move, resize and color_set for all part. */ + switch (ep->part->type) + { + case EDJE_PART_TYPE_IMAGE: + { + Edje_Part_Description_Image *img_desc = (Edje_Part_Description_Image*) chosen_desc; + + evas_object_image_scale_hint_set(ep->object, + img_desc->image.scale_hint); + } + case EDJE_PART_TYPE_PROXY: + case EDJE_PART_TYPE_RECTANGLE: + case EDJE_PART_TYPE_TEXTBLOCK: + case EDJE_PART_TYPE_BOX: + case EDJE_PART_TYPE_TABLE: + evas_object_color_set(ep->object, + (pf->color.r * pf->color.a) / 255, + (pf->color.g * pf->color.a) / 255, + (pf->color.b * pf->color.a) / 255, + pf->color.a); + if (!pf->visible) + { + evas_object_hide(ep->object); + break; + } + evas_object_show(ep->object); + /* move and resize are needed for all previous object => no break here. */ + case EDJE_PART_TYPE_SWALLOW: + case EDJE_PART_TYPE_GROUP: + case EDJE_PART_TYPE_EXTERNAL: + /* visibility and color have no meaning on SWALLOW and GROUP part. */ + evas_object_move(ep->object, ed->x + pf->x, ed->y + pf->y); + evas_object_resize(ep->object, pf->w, pf->h); + if (ep->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + _edje_entry_real_part_configure(ep); + break; + case EDJE_PART_TYPE_TEXT: + /* This is correctly handle in _edje_text_recalc_apply at the moment. */ + break; + case EDJE_PART_TYPE_GRADIENT: + /* FIXME: definitivly remove this code when we switch to new format. */ + abort(); + break; + } + + /* Some object need special recalc. */ + switch (ep->part->type) + { + case EDJE_PART_TYPE_TEXT: + _edje_text_recalc_apply(ed, ep, pf, (Edje_Part_Description_Text*) chosen_desc); + break; + case EDJE_PART_TYPE_PROXY: + _edje_proxy_recalc_apply(ed, ep, pf, (Edje_Part_Description_Proxy*) chosen_desc, pos); + break; + case EDJE_PART_TYPE_IMAGE: + _edje_image_recalc_apply(ed, ep, pf, (Edje_Part_Description_Image*) chosen_desc, pos); + break; + case EDJE_PART_TYPE_BOX: + _edje_box_recalc_apply(ed, ep, pf, (Edje_Part_Description_Box*) chosen_desc); + break; + case EDJE_PART_TYPE_TABLE: + _edje_table_recalc_apply(ed, ep, pf, (Edje_Part_Description_Table*) chosen_desc); + break; + case EDJE_PART_TYPE_EXTERNAL: + case EDJE_PART_TYPE_RECTANGLE: + case EDJE_PART_TYPE_SWALLOW: + case EDJE_PART_TYPE_GROUP: + case EDJE_PART_TYPE_TEXTBLOCK: + /* Nothing special to do for this type of object. */ + break; + case EDJE_PART_TYPE_GRADIENT: + /* FIXME: definitivly remove this code when we switch to new format. */ + abort(); + break; + } + + if (ep->swallowed_object) + { +//// the below really is wrong - swallow color shouldn't affect swallowed object +//// color - the edje color as a WHOLE should though - and that should be +//// done via the clipper anyway. this created bugs when objects had their +//// colro set and were swallowed - then had their color changed. +// evas_object_color_set(ep->swallowed_object, +// (pf->color.r * pf->color.a) / 255, +// (pf->color.g * pf->color.a) / 255, +// (pf->color.b * pf->color.a) / 255, +// pf->color.a); + if (pf->visible) + { + evas_object_move(ep->swallowed_object, ed->x + pf->x, ed->y + pf->y); + evas_object_resize(ep->swallowed_object, pf->w, pf->h); + evas_object_show(ep->swallowed_object); + } + else evas_object_hide(ep->swallowed_object); + mo = ep->swallowed_object; + } + else mo = ep->object; + if (chosen_desc->map.on) + { + Evas_Map *map; + + ed->have_mapped_part = 1; + // create map and populate with part geometry + map = evas_map_new(4); + evas_map_util_points_populate_from_object(map, ep->object); + if (ep->part->type == EDJE_PART_TYPE_IMAGE) + { + int iw = 1, ih = 1; + + evas_object_image_size_get(mo, &iw, &ih); + evas_map_point_image_uv_set(map, 0, 0.0, 0.0); + evas_map_point_image_uv_set(map, 1, iw , 0.0); + evas_map_point_image_uv_set(map, 2, iw , ih ); + evas_map_point_image_uv_set(map, 3, 0.0, ih ); + } + + evas_map_util_3d_rotate(map, + pf->map.rotation.x, pf->map.rotation.y, pf->map.rotation.z, + pf->map.center.x, pf->map.center.y, pf->map.center.z); + + // calculate light color & position etc. if there is one + if (pf->lighted) + { + evas_map_util_3d_lighting(map, + pf->map.light.x, pf->map.light.y, pf->map.light.z, + pf->map.light.r, pf->map.light.g, pf->map.light.b, + pf->map.light.ar, pf->map.light.ag, pf->map.light.ab); + } + + // calculate perspective point + if (chosen_desc->map.persp_on) + { + evas_map_util_3d_perspective(map, + pf->map.persp.x, pf->map.persp.y, pf->map.persp.z, + pf->map.persp.focal); + } + + // handle backface culling (object is facing away from view + if (chosen_desc->map.backcull) + { + if (pf->visible) + { + if (evas_map_util_clockwise_get(map)) + evas_object_show(mo); + else evas_object_hide(mo); + } + } + + // handle smooth + if (chosen_desc->map.smooth) evas_map_smooth_set(map, 1); + else evas_map_smooth_set(map, 0); + // handle alpha + if (chosen_desc->map.alpha) evas_map_alpha_set(map, 1); + else evas_map_alpha_set(map, 0); + + evas_object_map_set(mo, map); + evas_object_map_enable_set(mo, 1); + evas_map_free(map); + } + else + { + evas_object_map_enable_set(mo, 0); + evas_object_map_set(mo, NULL); + } + } + + ep->x = pf->x; + ep->y = pf->y; + ep->w = pf->w; + ep->h = pf->h; + + ep->calculated |= flags; + ep->calculating = FLAG_NONE; + +#ifdef EDJE_CALC_CACHE + if (ep->calculated == FLAG_XY) + { + ep->state = ed->state; + ep->invalidate = 0; + } +#endif + +} 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 @@ +#include "edje_private.h" + +static void +_edje_hold_signal_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info) +{ + Evas_Event_Hold *ev; + Edje *ed; + Edje_Real_Part *rp; + + ev = event_info; + ed = data; + rp = evas_object_data_get(obj, "real_part"); + if (!rp) return; + if (ev->hold) + _edje_emit(ed, "hold,on", rp->part->name); + else + _edje_emit(ed, "hold,off", rp->part->name); +} + +static void +_edje_focus_in_signal_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = data; + rp = evas_object_data_get(obj, "real_part"); + if ((!rp) || (!ed)) + return; + + _edje_emit(ed, "focus,part,in", rp->part->name); +} + +static void +_edje_focus_out_signal_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = data; + rp = evas_object_data_get(obj, "real_part"); + if ((!rp) || (!ed)) + return; + + _edje_emit(ed, "focus,part,out", rp->part->name); +} + +static void +_edje_mouse_in_signal_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info) +{ + Evas_Event_Mouse_In *ev; + Edje *ed; + Edje_Real_Part *rp; + + ev = event_info; + ed = data; + rp = evas_object_data_get(obj, "real_part"); + if ((!rp) || + ((ev->event_flags) && + (rp->part->ignore_flags & ev->event_flags))) return; + _edje_emit(ed, "mouse,in", rp->part->name); +} + +static void +_edje_mouse_out_signal_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info) +{ + Evas_Event_Mouse_Out *ev; + Edje *ed; + Edje_Real_Part *rp; + + ev = event_info; + ed = data; + rp = evas_object_data_get(obj, "real_part"); + if ((!rp) || + ((ev->event_flags) && + (rp->part->ignore_flags & ev->event_flags))) return; + _edje_emit(ed, "mouse,out", rp->part->name); +} + +static void +_edje_mouse_down_signal_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info) +{ + Evas_Event_Mouse_Down *ev; + Edje *ed; + Edje_Real_Part *rp; + char buf[256]; + int ignored; + + ev = event_info; + ed = data; + rp = evas_object_data_get(obj, "real_part"); + if (!rp) return; + + ignored = rp->part->ignore_flags & ev->event_flags; + + _edje_ref(ed); + _edje_freeze(ed); + + if ((!ev->event_flags) || (!ignored)) + { + if (ev->flags & EVAS_BUTTON_TRIPLE_CLICK) + snprintf(buf, sizeof(buf), "mouse,down,%i,triple", ev->button); + else if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK) + snprintf(buf, sizeof(buf), "mouse,down,%i,double", ev->button); + else + snprintf(buf, sizeof(buf), "mouse,down,%i", ev->button); + _edje_emit(ed, buf, rp->part->name); + } + + if (rp->events_to) + { + int x = 0, y = 0; + Edje_Real_Part *events; + + events = rp->events_to; + evas_object_geometry_get(rp->object, &x, &y, NULL, NULL); + + if ((events->part->dragable.x) || (events->part->dragable.y)) + { + if (events->part->dragable.x) + { + events->drag->down.x = ev->canvas.x; + events->drag->tmp.x = 0; + } + if (events->part->dragable.y) + { + events->drag->down.y = ev->canvas.y; + events->drag->tmp.y = 0; + } + + if (!ignored) + { + snprintf(buf, sizeof(buf), "mouse,down,%i", ev->button); + _edje_emit(ed, buf, events->part->name); + } + ed->dirty = 1; +#ifdef EDJE_CALC_CACHE + rp->invalidate = 1; +#endif + } + _edje_recalc_do(ed); + /* + _edje_thaw(ed); + _edje_unref(ed); + _edje_ref(ed); + _edje_freeze(ed); + */ + rp = events; + { + FLOAT_T dx = ZERO, dy = ZERO; + + _edje_part_dragable_calc(ed, rp, &dx, &dy); + + if ((dx != rp->drag->val.x) || (dy != rp->drag->val.y)) + { + rp->drag->val.x = dx; + rp->drag->val.y = dy; + if (!ignored) + _edje_emit(ed, "drag", rp->part->name); + ed->dirty = 1; +#ifdef EDJE_CALC_CACHE + rp->invalidate = 1; +#endif + rp->drag->need_reset = 1; + _edje_recalc_do(ed); + } + } + } + + if (rp->drag) + { + if (rp->drag->down.count == 0) + { + if (rp->part->dragable.x) + rp->drag->down.x = ev->canvas.x; + if (rp->part->dragable.y) + rp->drag->down.y = ev->canvas.y; + if (!ignored) + _edje_emit(ed, "drag,start", rp->part->name); + } + rp->drag->down.count++; + } + + if (rp->clicked_button == 0) + { + rp->clicked_button = ev->button; + if (!(ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)) + rp->still_in = 1; + } +// _edje_recalc_do(ed); + _edje_thaw(ed); + _edje_unref(ed); +} + +static void +_edje_mouse_up_signal_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info) +{ + Evas_Event_Mouse_Up *ev; + Edje *ed; + Edje_Real_Part *rp; + char buf[256]; + int ignored; + + ev = event_info; + ed = data; + rp = evas_object_data_get(obj, "real_part"); + if (!rp) return; + + ignored = rp->part->ignore_flags & ev->event_flags; + + _edje_ref(ed); + _edje_freeze(ed); + + if ((!ev->event_flags) || (!ignored)) + { + snprintf(buf, sizeof(buf), "mouse,up,%i", ev->button); + _edje_emit(ed, buf, rp->part->name); + } + + if (rp->events_to) + { + rp = rp->events_to; + if (!ignored) + { + snprintf(buf, sizeof(buf), "mouse,up,%i", ev->button); + _edje_emit(ed, buf, rp->part->name); + } + } + + if (rp->drag) + { + if (rp->drag->down.count > 0) + { + rp->drag->down.count--; + if (rp->drag->down.count == 0) + { + rp->drag->need_reset = 1; + ed->dirty = 1; +#ifdef EDJE_CALC_CACHE + rp->invalidate = 1; +#endif + if (!ignored) + _edje_emit(ed, "drag,stop", rp->part->name); + } + } + } + + if ((rp->still_in) && (rp->clicked_button == ev->button) && (!ignored)) + { + snprintf(buf, sizeof(buf), "mouse,clicked,%i", ev->button); + _edje_emit(ed, buf, rp->part->name); + } + rp->clicked_button = 0; + rp->still_in = 0; + +// _edje_recalc_do(ed); + _edje_thaw(ed); + _edje_unref(ed); +} + +static void +_edje_mouse_move_signal_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info) +{ + Evas_Event_Mouse_Move *ev; + Edje *ed; + Edje_Real_Part *rp; + int ignored; + + ev = event_info; + ed = data; + rp = evas_object_data_get(obj, "real_part"); + if (!rp) return; + if (rp->events_to) rp = rp->events_to; + + ignored = rp->part->ignore_flags & ev->event_flags; + + _edje_ref(ed); + if ((!ev->event_flags) || (!ignored)) + _edje_emit(ed, "mouse,move", rp->part->name); + + if (rp->still_in) + { + + if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) + rp->still_in = 0; + else + { + Evas_Coord x, y, w, h; + + evas_object_geometry_get(obj, &x, &y, &w, &h); + if ((ev->cur.canvas.x < x) || (ev->cur.canvas.y < y) || + (ev->cur.canvas.x >= (x + w)) || (ev->cur.canvas.y >= (y + h))) + rp->still_in = 0; + } + } + else + { + if (!(ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)) + { + Evas_Coord x, y, w, h; + + evas_object_geometry_get(obj, &x, &y, &w, &h); + if ((ev->cur.canvas.x >= x) && (ev->cur.canvas.y >= y) && + (ev->cur.canvas.x < (x + w)) && (ev->cur.canvas.y < (y + h))) + rp->still_in = 1; + } + } + _edje_freeze(ed); + if (rp->drag) + { + if (rp->drag->down.count > 0) + { + if (rp->part->dragable.x) + rp->drag->tmp.x = ev->cur.canvas.x - rp->drag->down.x; + if (rp->part->dragable.y) + rp->drag->tmp.y = ev->cur.canvas.y - rp->drag->down.y; + ed->dirty = 1; +#ifdef EDJE_CALC_CACHE + rp->invalidate = 1; +#endif + } + _edje_recalc_do(ed); + + if (rp->drag->down.count > 0) + { + FLOAT_T dx, dy; + + _edje_part_dragable_calc(ed, rp, &dx, &dy); + if ((dx != rp->drag->val.x) || (dy != rp->drag->val.y)) + { + rp->drag->val.x = dx; + rp->drag->val.y = dy; + if (!ignored) + _edje_emit(ed, "drag", rp->part->name); + ed->dirty = 1; +#ifdef EDJE_CALC_CACHE + rp->invalidate = 1; +#endif + _edje_recalc_do(ed); + } + } + } + _edje_unref(ed); + _edje_thaw(ed); +} + +static void +_edje_mouse_wheel_signal_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info) +{ + Evas_Event_Mouse_Wheel *ev; + Edje *ed; + Edje_Real_Part *rp; + char buf[256]; + + ev = event_info; + ed = data; + rp = evas_object_data_get(obj, "real_part"); + if ((!rp) || + ((ev->event_flags) && + (!(rp->part->ignore_flags & ev->event_flags)))) return; + + snprintf(buf, sizeof(buf), "mouse,wheel,%i,%i", ev->direction, (ev->z < 0) ? (-1) : (1)); + _edje_emit(ed, buf, rp->part->name); +} + +Eina_Bool +_edje_timer_cb(void *data __UNUSED__) +{ + double t; + Eina_List *l; + Eina_List *animl = NULL; + Edje *ed; + + t = ecore_loop_time_get(); + EINA_LIST_FOREACH(_edje_animators, l, ed) + { + _edje_ref(ed); + animl = eina_list_append(animl, ed); + } + while (animl) + { + Eina_List *newl = NULL; + + ed = eina_list_data_get(animl); + _edje_block(ed); + _edje_freeze(ed); + animl = eina_list_remove(animl, eina_list_data_get(animl)); + if ((!ed->paused) && (!ed->delete_me)) + { + const void *tmp; + + ed->walking_actions = 1; + EINA_LIST_FOREACH(ed->actions, l, tmp) + newl = eina_list_append(newl, tmp); + while (newl) + { + Edje_Running_Program *runp; + + runp = eina_list_data_get(newl); + newl = eina_list_remove(newl, eina_list_data_get(newl)); + if (!runp->delete_me) + _edje_program_run_iterate(runp, t); + if (_edje_block_break(ed)) + { + eina_list_free(newl); + newl = NULL; + goto break_prog; + } + } + EINA_LIST_FOREACH(ed->actions, l, tmp) + newl = eina_list_append(newl, tmp); + while (newl) + { + Edje_Running_Program *runp; + + runp = eina_list_data_get(newl); + newl = eina_list_remove(newl, eina_list_data_get(newl)); + if (runp->delete_me) + { + _edje_anim_count--; + runp->edje->actions = + eina_list_remove(runp->edje->actions, runp); + if (!runp->edje->actions) + _edje_animators = + eina_list_remove(_edje_animators, runp->edje); + free(runp); + } + } + ed->walking_actions = 0; + } + break_prog: + _edje_unblock(ed); + _edje_thaw(ed); + _edje_unref(ed); + } + if (_edje_anim_count > 0) return ECORE_CALLBACK_RENEW; + _edje_timer = NULL; + return ECORE_CALLBACK_CANCEL; +} + +Eina_Bool +_edje_pending_timer_cb(void *data) +{ + Edje_Pending_Program *pp; + + pp = data; + pp->edje->pending_actions = eina_list_remove(pp->edje->pending_actions, pp); + _edje_program_run(pp->edje, pp->program, 1, "", ""); + free(pp); + return ECORE_CALLBACK_CANCEL; +} + +void +_edje_callbacks_add(Evas_Object *obj, Edje *ed, Edje_Real_Part *rp) +{ + evas_object_event_callback_add(obj, + EVAS_CALLBACK_HOLD, + _edje_hold_signal_cb, + ed); + evas_object_event_callback_add(obj, + EVAS_CALLBACK_MOUSE_IN, + _edje_mouse_in_signal_cb, + ed); + evas_object_event_callback_add(obj, + EVAS_CALLBACK_MOUSE_OUT, + _edje_mouse_out_signal_cb, + ed); + evas_object_event_callback_add(obj, + EVAS_CALLBACK_MOUSE_DOWN, + _edje_mouse_down_signal_cb, + ed); + evas_object_event_callback_add(obj, + EVAS_CALLBACK_MOUSE_UP, + _edje_mouse_up_signal_cb, + ed); + evas_object_event_callback_add(obj, + EVAS_CALLBACK_MOUSE_MOVE, + _edje_mouse_move_signal_cb, + ed); + evas_object_event_callback_add(obj, + EVAS_CALLBACK_MOUSE_WHEEL, + _edje_mouse_wheel_signal_cb, + ed); + evas_object_data_set(obj, "real_part", rp); +} + +void +_edje_callbacks_del(Evas_Object *obj, Edje *ed) +{ + evas_object_event_callback_del_full(obj, + EVAS_CALLBACK_HOLD, + _edje_hold_signal_cb, + ed); + evas_object_event_callback_del_full(obj, + EVAS_CALLBACK_MOUSE_IN, + _edje_mouse_in_signal_cb, + ed); + evas_object_event_callback_del_full(obj, + EVAS_CALLBACK_MOUSE_OUT, + _edje_mouse_out_signal_cb, + ed); + evas_object_event_callback_del_full(obj, + EVAS_CALLBACK_MOUSE_DOWN, + _edje_mouse_down_signal_cb, + ed); + evas_object_event_callback_del_full(obj, + EVAS_CALLBACK_MOUSE_UP, + _edje_mouse_up_signal_cb, + ed); + evas_object_event_callback_del_full(obj, + EVAS_CALLBACK_MOUSE_MOVE, + _edje_mouse_move_signal_cb, + ed); + evas_object_event_callback_del_full(obj, + EVAS_CALLBACK_MOUSE_WHEEL, + _edje_mouse_wheel_signal_cb, + ed); + evas_object_data_del(obj, "real_part"); +} + +void +_edje_callbacks_focus_add(Evas_Object *obj, Edje *ed, Edje_Real_Part *rp) +{ + evas_object_event_callback_add(obj, + EVAS_CALLBACK_FOCUS_IN, + _edje_focus_in_signal_cb, + ed); + evas_object_event_callback_add(obj, + EVAS_CALLBACK_FOCUS_OUT, + _edje_focus_out_signal_cb, + ed); + evas_object_data_set(obj, "real_part", rp); +} + +void +_edje_callbacks_focus_del(Evas_Object *obj, Edje *ed) +{ + evas_object_event_callback_del_full(obj, + EVAS_CALLBACK_FOCUS_IN, + _edje_focus_in_signal_cb, + ed); + evas_object_event_callback_del_full(obj, + EVAS_CALLBACK_FOCUS_OUT, + _edje_focus_out_signal_cb, + ed); +} 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 @@ +#include "edje_private.h" +#include "edje_container.h" + +#if 0 + +static void +_edje_container_relayout(Smart_Data *sd) +{ + Eina_List *l; + Evas_Coord x, y, w, h, sw; + Edje_Item *ei; + + if (sd->freeze > 0) return; + if (!sd->need_layout) return; + + if (sd->w < sd->min_w) sw = sd->min_w; + else if (sd->w > sd->max_w) sw = sd->max_w; + else sw = sd->w; + + y = 0; + x = 0; + w = 0; + h = 0; + + EINA_LIST_FOREACH(sd->children, l, ei) + { + if (sd->homogenous) h = sd->min_row_h; + + ei->y = y; + ei->h = h; +// ei->w = w; +// ei->h = h; + } + + sd->need_layout = 0; +} + +static void +_edje_container_recalc(Smart_Data *sd) +{ + Eina_List *l; + Edje_Item *ei; + int any_max_h = 0, any_max_w = 0; + int i; + + if (sd->freeze > 0) return; + if (!sd->changed) return; + + sd->min_h = 0; + sd->max_h = -1; + sd->min_w = 0; + sd->max_w = -1; + sd->min_row_h = 0; + sd->max_row_h = -1; + sd->contents_h = 0; + sd->contents_w = 0; + + for (i = 0; i < sd->cols; i++) + { + sd->min_w += sd->colinfo[i].minw; + if (sd->colinfo[i].maxw >= 0) + { + if (sd->max_w >= 0) + sd->max_w += sd->colinfo[i].maxw; + else + sd->max_w = sd->colinfo[i].maxw; + } + else + any_max_w = 1; + } + if (any_max_w) sd->max_w = -1; + + if (sd->w < sd->min_w) + sd->contents_w = sd->min_w; + else if ((sd->max_w >= 0) && (sd->w < sd->max_w)) + sd->w = sd->max_w; + + EINA_LIST_FOREACH(sd->children, l, ei) + { + if (ei->minh > sd->min_row_h) + sd->min_row_h = ei->minh; + if (sd->max_row_h >= 0) + { + if (ei->maxh >= 0) + { + if (sd->max_row_h > ei->maxh) + sd->max_row_h = ei->maxh; + } + else + any_max_h = 1; + } + sd->min_h += ei->minh; + if (ei->maxh >= 0) + { + if (sd->max_h >= 0) + sd->max_h += ei->maxh; + else + sd->max_h = ei->maxh; + } + else + any_max_h = 1; + } + if (any_max_h) + { + sd->max_h = -1; + sd->max_row_h = -1; + } + if (sd->homogenous) + { + sd->min_h = eina_list_count(sd->children) * sd->min_row_h; + } + + sd->changed = 0; + sd->change_child = 0; + sd->change_child_list = 0; + sd->change_cols = 0; + + sd->need_layout = 1; + _edje_container_relayout(sd); +} + +static void +_edje_item_recalc(Edje_Item *ei) +{ + int i; + + if (ei->freeze > 0) return; + if (!ei->recalc) return; + if (!ei->sd) return; + + ei->minh = 0; + ei->maxh = -1; + for (i = 0; i < ((Smart_Data *)(ei->sd))->cols; i++) + { + if (ei->cells[i].minh > ei->minh) ei->minh = ei->cells[i].minh; + if (ei->cells[i].maxh >= 0) + { + if (ei->maxh >= 0) + { + if (ei->cells[i].maxh < ei->maxh) + ei->maxh = ei->cells[i].maxh; + } + else + ei->maxh = ei->cells[i].maxh; + } + if (((Smart_Data *)(ei->sd))->colinfo[i].minw < ei->cells[i].minw) + ((Smart_Data *)(ei->sd))->colinfo[i].minw = ei->cells[i].minw; + if (((Smart_Data *)(ei->sd))->colinfo[i].maxw >= 0) + { + if (ei->cells[i].maxw >= 0) + { + if (((Smart_Data *)(ei->sd))->colinfo[i].maxw > ei->cells[i].maxw) + ((Smart_Data *)(ei->sd))->colinfo[i].maxw = ei->cells[i].maxw; + } + } + else + ((Smart_Data *)(ei->sd))->colinfo[i].maxw = ei->cells[i].maxw; + } + + ei->recalc = 0; + + _edje_container_recalc(ei->sd); +} + + +/*****************************/ +/** + * @endcond + */ + +/*============================================================================* + * Global * + *============================================================================*/ + +/*============================================================================* + * API * + *============================================================================*/ + +/** + * @addtogroup Edje_container_Group Container + * + * @brief These functions provides an abstraction layer between the application + * code and the interface, while allowing extremely flexible dynamic layouts + * and animations. + * + * For more information, you can look at the @ref tutorial_list_page. + * + * @{ + */ + +/** + * @brief Create an edje item. + * + * @param cl The edje item of type Edje_Item_Class. + * @param data The edje item data. + * + * @return The new edje item created. + * + * This function creates an new edje item. The edje item data can be + * retrieved with edje_item_data_get(). + * + * @see edje_item_del() + * @see edje_item_data_set() + * @see edje_item_data_get() + * + */ + +Edje_Item * +edje_item_add(Edje_Item_Class *cl, void *data) +{ + Edje_Item *ei; + + ei = calloc(sizeof(Edje_Item), 1); + + ei->class = cl; + ei->class_data = data; + + return ei; +} + +/** + * @brief Delete an edje item. + * + * @param ei The edje item to be deleted. + * + * This function deletes the edje item from memory. + * + * @see edje_item_add() + * @see edje_item_data_set() + * @see edje_item_data_get() + * + */ + +void +edje_item_del(Edje_Item *ei) +{ + Smart_Data *sd; + + sd = ei->sd; + if (ei->object) evas_object_del(ei->object); + if (ei->overlay_object) evas_object_del(ei->overlay_object); + free(ei); + if (!sd) return; + sd->changed = 1; + sd->change_child_list = 1; + _edje_container_recalc(sd); +} + +/** + * @brief Return the smart object of the edje item. + * + * @param ei The edje item which the smart object of type Evas_Object is get + * from. + * + * This function returns the smart object in the edje item. + * + */ + +Evas_Object * +edje_item_container_get(Edje_Item *ei) +{ + if (!ei->sd) return NULL; + return ((Smart_Data *)(ei->sd))->smart_obj; +} + +/* an arbitrary data pointer to use to track other data */ +/** + * @brief Set the edje item data. + * + * @param ei The edje item of type Edje_Item_Class. + * @param data The edje item data. + * + * This function set the data of the edje item. The edje item data can be + * retrieved with edje_item_data_get(). + * + * @see edje_item_add() + * @see edje_item_del() + * @see edje_item_data_get() + * + */ + +void +edje_item_data_set(Edje_Item *ei, void *data) +{ + ei->data = data; +} + +/** + * @brief Get the data of the edje item. + * + * @param ei The edje item of type Edje_Item_Class. + * + * This function get the data of the edje item set by edje_item_data_set(). + * + * @see edje_item_data_set() + * @see edje_item_add() + * @see edje_item_del() + * + */ + +void * +edje_item_data_get(Edje_Item *ei) +{ + return ei->data; +} + +/* this object covers the entire item */ + +void +edje_item_overlay_object_set(Edje_Item *ei, Evas_Object *obj) +{ + if (ei->overlay_object) + { + /* FIXME: if it changed - remove...*/ + } + ei->overlay_object = obj; + if (ei->sd) + evas_object_smart_member_add(((Smart_Data *)(ei->sd))->smart_obj, obj); +} + + + +Evas_Object * +edje_item_overlay_object_get(Edje_Item *ei) +{ + return ei->overlay_object; +} + +/* this object goes under entire item */ +void +edje_item_object_set(Edje_Item *ei, Evas_Object *obj) +{ + if (ei->object) + { + /* FIXME: if it changed - remove...*/ + } + ei->object = obj; + if (ei->sd) + evas_object_smart_member_add(((Smart_Data *)(ei->sd))->smart_obj, obj); +} + +Evas_Object * +edje_item_object_get(Edje_Item *ei) +{ + return ei->object; +} + +/* optionally you can manage each column's object yourself OR let Edje do it */ +void +edje_item_object_column_set(Edje_Item *ei, int col, Evas_Object *obj) +{ + if (ei->cells_num <= (col + 1)) + { + /* FIXME: unsafe realloc */ + ei->cells = realloc(ei->cells, sizeof(Edje_Item_Cell) * col); + ei->cells_num = col + 1; + } + ei->cells[col].obj = obj; +} + +Evas_Object * +edje_item_object_column_get(Edje_Item *ei, int col) +{ + if (ei->cells_num <= (col + 1)) return NULL; + return ei->cells[col].obj; +} + +/* query the item for the items preferred co-ords */ +void +edje_item_geometry_get(Edje_Item *ei, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h) +{ + if (!ei->sd) + { + if (x) *x = 0; + if (y) *y = 0; + if (w) *w = 0; + if (h) *h = 0; + return; + } + if (x) *x = ((Smart_Data *)(ei->sd))->x; + if (y) *y = ((Smart_Data *)(ei->sd))->y + ei->y; + if (w) *w = ((Smart_Data *)(ei->sd))->w; + if (h) *h = ei->h; +} + +/* freeze and thaw items if u are about to do a bunch of changes */ +int +edje_item_freeze(Edje_Item *ei) +{ + ei->freeze++; + return ei->freeze; +} + +int +edje_item_thaw(Edje_Item *ei) +{ + ei->freeze--; + if (ei->freeze > 0) return ei->freeze; + if (!ei->sd) return ei->freeze; + if (ei->recalc) _edje_item_recalc(ei); + return ei->freeze; +} + +/* column info */ +void +edje_item_column_size_set(Edje_Item *ei, int col, Evas_Coord minw, Evas_Coord maxw, Evas_Coord minh, Evas_Coord maxh) +{ + if (ei->cells_num <= (col + 1)) + { + /* FIXME: unsafe realloc */ + ei->cells = realloc(ei->cells, sizeof(Edje_Item_Cell) * col); + ei->cells_num = col + 1; + } + if ((ei->cells[col].minw == minw) && + (ei->cells[col].minh == minh) && + (ei->cells[col].maxw == maxw) && + (ei->cells[col].maxh == maxh)) return; + ei->cells[col].minh = minh; + ei->cells[col].maxh = maxh; + ei->cells[col].minw = minw; + ei->cells[col].maxw = maxw; + ei->recalc = 1; + if (ei->sd) + { + ((Smart_Data *)(ei->sd))->changed = 1; + ((Smart_Data *)(ei->sd))->change_child = 1; + } + _edje_item_recalc(ei); +} + +void +edje_item_column_size_get(Edje_Item *ei, int col, Evas_Coord *minw, Evas_Coord *maxw, Evas_Coord *minh, Evas_Coord *maxh) +{ + if (ei->cells_num <= (col + 1)) + { + if (minw) *minw = 0; + if (minh) *minh = 0; + if (maxw) *maxw = -1; + if (maxh) *maxh = -1; + } + if (minw) *minw = ei->cells[col].minw; + if (minh) *minh = ei->cells[col].minh; + if (maxw) *maxw = ei->cells[col].maxw; + if (maxh) *maxh = ei->cells[col].maxh; +} + +/* selection stuff */ +void +edje_item_select(Edje_Item *ei) +{ + ei->selected = 1; + /* FIXME: trigger item to change visually */ +} + +void +edje_item_unselect(Edje_Item *ei) +{ + ei->selected = 0; + /* FIXME: trigger item to change visually */ +} + +/* focus stuff - only 1 can be focuesd */ +void +edje_item_focus(Edje_Item *ei) +{ +// ei->focused = 1; +} + +void +edje_item_unfocus(Edje_Item *ei) +{ +// ei->focused = 0; +} + +/* disable/enable stuff - stops focus and selection working on these items */ +void +edje_item_enable(Edje_Item *ei) +{ +// ei->disabled = 0; +} + +void +edje_item_disable(Edje_Item *ei) +{ +// ei->disabled = 1; +} + +/* item utils */ +int +edje_item_selected_get(Edje_Item *ei) +{ + return ei->selected; +} + +int +edje_item_focused_get(Edje_Item *ei) +{ + return ei->focused; +} + +int +edje_item_disabled_get(Edje_Item *ei) +{ + return ei->disabled; +} + +/***** container calls *****/ + +int +edje_container_freeze(Evas_Object *obj) +{ + Smart_Data *sd; + + sd = evas_object_smart_data_get(obj); + if (!sd) return 0; + sd->freeze++; + return sd->freeze; +} + +int +edje_container_thaw(Evas_Object *obj) +{ + Smart_Data *sd; + + sd = evas_object_smart_data_get(obj); + if (!sd) return 0; + sd->freeze--; + if (sd->freeze <= 0) _edje_container_recalc(sd); + return sd->freeze; +} + +void +edje_container_item_append(Evas_Object *obj, Edje_Item *ei) +{ + Smart_Data *sd; + + sd = evas_object_smart_data_get(obj); + if (!sd) return; + sd->children = eina_list_append(sd->children, ei); + sd->changed = 1; + sd->change_child_list = 1; + sd->rows = eina_list_count(sd->children); + _edje_container_recalc(sd); +} + +void +edje_container_item_prepend(Evas_Object *obj, Edje_Item *ei) +{ + Smart_Data *sd; + + sd = evas_object_smart_data_get(obj); + if (!sd) return; + sd->children = eina_list_prepend(sd->children, ei); + sd->changed = 1; + sd->change_child_list = 1; + sd->rows = eina_list_count(sd->children); + _edje_container_recalc(sd); +} + +void +edje_container_item_append_relative(Evas_Object *obj, Edje_Item *ei, Edje_Item *rel) +{ + Smart_Data *sd; + + sd = evas_object_smart_data_get(obj); + if (!sd) return; + sd->children = eina_list_append_relative(sd->children, ei, rel); + sd->changed = 1; + sd->change_child_list = 1; + sd->rows = eina_list_count(sd->children); + _edje_container_recalc(sd); +} + +void +edje_container_item_prepend_relative(Evas_Object *obj, Edje_Item *ei, Edje_Item *rel) +{ + Smart_Data *sd; + + sd = evas_object_smart_data_get(obj); + if (!sd) return; + sd->children = eina_list_prepend_relative(sd->children, ei, rel); + sd->changed = 1; + sd->change_child_list = 1; + sd->rows = eina_list_count(sd->children); + _edje_container_recalc(sd); +} + +void +edje_container_item_insert(Evas_Object *obj, Edje_Item *ei, int n) +{ + Smart_Data *sd; + void *rel; + + sd = evas_object_smart_data_get(obj); + if (!sd) return; + rel = eina_list_nth(sd->children, n); + if (!rel) + sd->children = eina_list_append(sd->children, ei); + else + sd->children = eina_list_append_relative(sd->children, ei, rel); + sd->changed = 1; + sd->change_child_list = 1; + sd->rows = eina_list_count(sd->children); + _edje_container_recalc(sd); +} + +void +edje_container_item_remove(Evas_Object *obj, Edje_Item *ei) +{ + Smart_Data *sd; + + sd = evas_object_smart_data_get(obj); + if (!sd) return; + sd->children = eina_list_remove(sd->children, ei); + sd->changed = 1; + sd->change_child_list = 1; + sd->rows = eina_list_count(sd->children); + _edje_container_recalc(sd); +} + +void +edje_container_columns_set(Evas_Object *obj, int cols) +{ + Smart_Data *sd; + + sd = evas_object_smart_data_get(obj); + if (!sd) return; + if (sd->cols == cols) return; + sd->colinfo = realloc(sd->colinfo, cols * sizeof(Smart_Data_Colinfo)); + if (cols > sd->cols) + { + int i; + + for (i = sd->cols; i < cols; i++) + { + sd->colinfo[i].minw = 0; + sd->colinfo[i].maxw = -1; + } + } + sd->cols = cols; + sd->changed = 1; + sd->change_cols = 1; + _edje_container_recalc(sd); +} + +int +edje_container_columns_get(Evas_Object *obj) +{ + Smart_Data *sd; + + sd = evas_object_smart_data_get(obj); + if (!sd) return 0; + return sd->cols; +} + +void +edje_container_min_size_get(Evas_Object *obj, Evas_Coord *minw, Evas_Coord *minh) +{ + Smart_Data *sd; + + sd = evas_object_smart_data_get(obj); + if (!sd) return; + if (sd->changed) + { + int freeze; + + freeze = sd->freeze; + sd->freeze = 0; + _edje_container_recalc(sd); + sd->freeze = freeze; + } + if (minw) *minw = sd->min_w; + if (minh) *minh = sd->min_h; +} + +void +edje_container_max_size_get(Evas_Object *obj, Evas_Coord *maxw, Evas_Coord *maxh) +{ + Smart_Data *sd; + + sd = evas_object_smart_data_get(obj); + if (!sd) return; + if (sd->changed) + { + int freeze; + + freeze = sd->freeze; + sd->freeze = 0; + _edje_container_recalc(sd); + sd->freeze = freeze; + } + if (maxw) *maxw = sd->max_w; + if (maxh) *maxh = sd->max_h; +} + +void +edje_containter_align_set(Evas_Object *obj, double halign, double valign) +{ + Smart_Data *sd; + + sd = evas_object_smart_data_get(obj); + if (!sd) return; + if ((sd->align_x == halign) && (sd->align_y == valign)) return; + sd->align_x = halign; + sd->align_y = valign; + sd->need_layout = 1; + _edje_container_relayout(sd); +} + +void +edje_container_align_get(Evas_Object *obj, double *halign, double *valign) +{ + Smart_Data *sd; + + sd = evas_object_smart_data_get(obj); + if (!sd) return; + if (halign) *halign = sd->align_x; + if (valign) *valign = sd->align_y; +} + +int +edje_container_count_get(Evas_Object *obj) +{ + Smart_Data *sd; + + sd = evas_object_smart_data_get(obj); + if (!sd) return 0; + return eina_list_count(sd->children); +} + +Edje_Item * +edje_container_item_first_get(Evas_Object *obj) +{ + Smart_Data *sd; + + sd = evas_object_smart_data_get(obj); + if (!sd) return NULL; + if (!sd->children) return NULL; + return eina_list_data_get(sd->children); +} + +Edje_Item * +edje_container_item_last_get(Evas_Object *obj) +{ + Smart_Data *sd; + + sd = evas_object_smart_data_get(obj); + if (!sd) return NULL; + if (!sd->children) return NULL; + return0 eina_list_data_get(eina_list_last(sd->children)); +} + +Edje_Item * +edje_container_item_nth_get(Evas_Object *obj, int n) +{ + Smart_Data *sd; + + sd = evas_object_smart_data_get(obj); + if (!sd) return NULL; + return eina_list_nth(sd->children, n); +} + +void +edje_container_homogenous_size_set(Evas_Object *obj, int homog) +{ + Smart_Data *sd; + + sd = evas_object_smart_data_get(obj); + if (!sd) return; + if (((homog) && (sd->homogenous)) || + ((!homog) && (!sd->homogenous))) return; + sd->homogenous = homog; + sd->changed = 1; + sd->change_child = 1; + _edje_container_recalc(sd); +} + +int +edje_container_homogenous_size_get(Evas_Object *obj) +{ + Smart_Data *sd; + + sd = evas_object_smart_data_get(obj); + if (!sd) return 0; + return sd->homogenous; +} + +void +edje_container_scroll_set(Evas_Object *obj, double pos, double shift) +{ + Smart_Data *sd; + + sd = evas_object_smart_data_get(obj); + if (!sd) return; + if ((sd->scroll_y == pos) && (sd->scroll_x == shift)) return; + sd->scroll_y = pos; + sd->scroll_x = shift; + sd->need_layout = 1; + _edje_container_relayout(sd); +} + +void +edje_container_scroll_get(Evas_Object *obj, double *pos, double *shift) +{ + Smart_Data *sd; + + sd = evas_object_smart_data_get(obj); + if (!sd) return; + if (pos) *pos = sd->scroll_y; + if (shift) *shift = sd->scroll_x; +} + +static void _smart_init(void); +static void _smart_add(Evas_Object * obj); +static void _smart_del(Evas_Object * obj); +static void _smart_move(Evas_Object * obj, Evas_Coord x, Evas_Coord y); +static void _smart_resize(Evas_Object * obj, Evas_Coord w, Evas_Coord h); +static void _smart_show(Evas_Object * obj); +static void _smart_hide(Evas_Object * obj); +static void _smart_color_set(Evas_Object * obj, int r, int g, int b, int a); +static void _smart_clip_set(Evas_Object * obj, Evas_Object * clip); +static void _smart_clip_unset(Evas_Object * obj); + +static Evas_Smart *smart = NULL; + +Evas_Object * +edje_container_object_add(Evas *evas) +{ + _smart_init(); + return evas_object_smart_add(evas, smart); +} + +/*******************************************/ +/* Internal smart object required routines */ +/*******************************************/ +static void +_smart_init(void) +{ + if (smart) return; + { + static const Evas_Smart_Class sc = + { + E_OBJ_NAME, + _smart_add, + _smart_del, + _smart_move, + _smart_resize, + _smart_show, + _smart_hide, + _smart_color_set, + _smart_clip_set, + _smart_clip_unset, + NULL, + NULL, + NULL + }; + smart = evas_smart_class_new(&sc); + } +} + +static void +_smart_add(Evas_Object *obj) +{ + Smart_Data *sd; + + sd = calloc(1, sizeof(Smart_Data)); + if (!sd) return; +// evas_object_smart_member_add(sd->obj, obj); + evas_object_smart_data_set(obj, sd); + sd->smart_obj = obj; +} + +static void +_smart_del(Evas_Object *obj) +{ + Smart_Data *sd; + + sd = evas_object_smart_data_get(obj); + if (!sd) return; + if (sd->colinfo) free(sd->colinfo); +// evas_object_del(sd->obj); + free(sd); +} + +static void +_smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y) +{ + Smart_Data *sd; + + sd = evas_object_smart_data_get(obj); + if (!sd) return; +// evas_object_move(sd->obj, x, y); +} + +static void +_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h) +{ + Smart_Data *sd; + + sd = evas_object_smart_data_get(obj); + if (!sd) return; +// evas_object_resize(sd->obj, w, h); +} + +static void +_smart_show(Evas_Object *obj) +{ + Smart_Data *sd; + + sd = evas_object_smart_data_get(obj); + if (!sd) return; +// evas_object_show(sd->obj); +} + +static void +_smart_hide(Evas_Object *obj) +{ + Smart_Data *sd; + + sd = evas_object_smart_data_get(obj); + if (!sd) return; +// evas_object_hide(sd->obj); +} + +static void +_smart_color_set(Evas_Object *obj, int r, int g, int b, int a) +{ + Smart_Data *sd; + + sd = evas_object_smart_data_get(obj); + if (!sd) return; +// evas_object_color_set(sd->obj, r, g, b, a); +} + +static void +_smart_clip_set(Evas_Object *obj, Evas_Object *clip) +{ + Smart_Data *sd; + + sd = evas_object_smart_data_get(obj); + if (!sd) return; +// evas_object_clip_set(sd->obj, clip); +} + +static void +_smart_clip_unset(Evas_Object *obj) +{ + Smart_Data *sd; + + sd = evas_object_smart_data_get(obj); + if (!sd) return; +// evas_object_clip_unset(sd->obj); +} + +#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 @@ +#include "edje_private.h" + + +#define E_SMART_OBJ_GET(smart, o, type) \ + { \ + char *_e_smart_str; \ + \ + if (!o) return; \ + smart = evas_object_smart_data_get(o); \ + if (!smart) return; \ + _e_smart_str = (char *)evas_object_type_get(o); \ + if (!_e_smart_str) return; \ + if (strcmp(_e_smart_str, type)) return; \ + } + +#define E_SMART_OBJ_GET_RETURN(smart, o, type, ret) \ + { \ + char *_e_smart_str; \ + \ + if (!o) return ret; \ + smart = evas_object_smart_data_get(o); \ + if (!smart) return ret; \ + _e_smart_str = (char *)evas_object_type_get(o); \ + if (!_e_smart_str) return ret; \ + if (strcmp(_e_smart_str, type)) return ret; \ + } + +#define E_OBJ_NAME "edje_container_object" + +typedef struct _Smart_Data Smart_Data; +typedef struct _Smart_Data_Colinfo Smart_Data_Colinfo; + +struct _Smart_Data +{ + Evas_Coord x, y, w, h; + Eina_List *children; + Evas_Object *smart_obj; + int cols, rows; + + Evas_Coord contents_w, contents_h; + Evas_Coord min_row_h, max_row_h; + Evas_Coord min_w, max_w, min_h, max_h; + + Smart_Data_Colinfo *colinfo; + + int freeze; + + double scroll_x, scroll_y; + double align_x, align_y; + + unsigned char changed : 1; + unsigned char change_child : 1; + unsigned char change_child_list : 1; + unsigned char change_cols : 1; + unsigned char change_scroll : 1; + + unsigned char need_layout : 1; + + unsigned char homogenous : 1; +}; + +struct _Smart_Data_Colinfo +{ + Evas_Coord minw, maxw; +}; + +/* All items are virtual constructs that provide Evas_Objects at some point. + * Edje may move, resize, show, hide, clip, unclip, raise, lower etc. this + * item AFTER it calls the item's add() method and before it calls the del() + * method. Edje may call add() and del() at any time as often items may not + * be visible and so may not need to exist at all - they are merely information + * used for layout, and nothing more. this helps save cpu and memory keeping + * things responsive for BIG lists of items. you create an item from an item + * class then ask that item to be appended/prepended etc. to the container. + */ +typedef struct _Edje_Item Edje_Item; +typedef struct _Edje_Item_Cell Edje_Item_Cell; +typedef struct _Edje_Item_Class Edje_Item_Class; + +struct _Edje_Item_Class +{ + Evas_Object *(*add) (Edje_Item *ei); + void (*del) (Edje_Item *ei); + void (*select) (Edje_Item *ei); + void (*deselect) (Edje_Item *ei); + void (*focus) (Edje_Item *ei); + void (*unfocus) (Edje_Item *ei); +}; + +/* private */ +struct _Edje_Item +{ + Edje_Item_Class *class; + void *class_data; + + void *sd; + + void *data; + + Evas_Object *object; + Evas_Object *overlay_object; + int freeze; + Evas_Coord y, h; + + Evas_Coord minh, maxh; + + int cells_num; + Edje_Item_Cell *cells; + + unsigned char accessible : 1; + + unsigned char recalc : 1; + unsigned char selected : 1; + unsigned char disabled : 1; + unsigned char focused : 1; +}; + +struct _Edje_Item_Cell +{ + Evas_Object *obj; + Evas_Coord x, w; + Evas_Coord minw, minh, maxw, maxh; +}; + +/* here is an item for a vertical list - with 1 or more columns. this has 3 */ +/* just rotate for a horizontal list */ + +/* + * COL 0 COL 1 COL 2 + * + * +-----------------------------+ +-------+ +----------------+ + * | pad_top | | | | | + * | pad_left OBJECT pad_right | | OBJ | | OBJECT | ROW 0 + * | pad_bottom | | | | | + * +-----------------------------+ +-------+ +----------------+ + * /\ /|\ + * space_row || +-- space_col + * \/ + * +-----------------------------+ +-------+ +----------------+ + * | | | | | | + * | | | | | | ROW 1 + * | | | | | | + * +-----------------------------+ +-------+ +----------------+ + * + * spacer object: + * 1 Edje object goes in-between each row as a spacer object (opt) + * 1 Edje object goes in-between each column as a spacer object (opt) + * + * surround object: + * 1 Edje object goes around each item - item swallowed into "item" part (opt) + * if no "item" part then just underlay it + * on select send "select" "" signal + * on unselect send "unselect" "" signal + * on focus send "focus" "" signal + * on unfocus send "unfocus" signal + * + * if any list item/cell is an Edje object emit this to them too. + * + * also call callbacks. + * if a surround object emits such a signal itself then call callbacks too + * + * only 1 or 0 items can be focused + * disabled items cannot be focused or selected/deselected + * + */ 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 @@ +#ifndef EDJE_CONVERT_H__ +# define EDJE_CONVERT_H__ + +typedef struct _Old_Edje_Image_Directory Old_Edje_Image_Directory; +typedef struct _Old_Edje_Font_Directory Old_Edje_Font_Directory; +typedef struct _Old_Edje_External_Directory Old_Edje_External_Directory; +typedef struct _Old_Edje_Part Old_Edje_Part; +typedef struct _Old_Edje_Part_Collection Old_Edje_Part_Collection; +typedef struct _Old_Edje_Part_Description Old_Edje_Part_Description; +typedef struct _Old_Edje_Part_Description_Spec_Image Old_Edje_Part_Description_Spec_Image; +typedef struct _Edje_Data Edje_Data; + +struct _Edje_Data +{ + const char *key; + char *value; +}; + +/*----------*/ + +struct _Old_Edje_Font_Directory +{ + Eina_List *entries; /* a list of Edje_Font_Directory_Entry */ +}; + +struct _Old_Edje_Image_Directory +{ + Eina_List *entries; /* a list of Edje_Image_Directory_Entry */ + Eina_List *sets; /* a list of Edje_Image_Directory_Set */ +}; + +struct _Old_Edje_External_Directory +{ + Eina_List *entries; /* a list of Edje_External_Directory_Entry */ +}; + +struct _Old_Edje_File +{ + const char *path; + time_t mtime; + + Old_Edje_External_Directory *external_dir; + Old_Edje_Font_Directory *font_dir; + Old_Edje_Image_Directory *image_dir; + Edje_Part_Collection_Directory *collection_dir; + Eina_List *data; + Eina_List *styles; + Eina_List *color_classes; + + const char *compiler; + int version; + int feature_ver; +}; + +struct _Old_Edje_Part_Collection +{ + Eina_List *programs; /* a list of Edje_Program */ + Eina_List *parts; /* a list of Edje_Part */ + Eina_List *data; + + int id; /* the collection id */ + + Eina_Hash *alias; /* aliasing part*/ + + struct { + Edje_Size min, max; + } prop; + + int references; +#ifdef EDJE_PROGRAM_CACHE + struct { + Eina_Hash *no_matches; + Eina_Hash *matches; + } prog_cache; +#endif + + Embryo_Program *script; /* all the embryo script code for this group */ + const char *part; + + unsigned char script_only; + + unsigned char lua_script_only; + + unsigned char checked : 1; +}; + +struct _Old_Edje_Part +{ + const char *name; /* the name if any of the part */ + Old_Edje_Part_Description *default_desc; /* the part descriptor for default */ + Eina_List *other_desc; /* other possible descriptors */ + const char *source, *source2, *source3, *source4, *source5, *source6; + int id; /* its id number */ + int clip_to_id; /* the part id to clip this one to */ + Edje_Part_Dragable dragable; + Eina_List *items; /* packed items for box and table */ + unsigned char type; /* what type (image, rect, text) */ + unsigned char effect; /* 0 = plain... */ + unsigned char mouse_events; /* it will affect/respond to mouse events */ + unsigned char repeat_events; /* it will repeat events to objects below */ + Evas_Event_Flags ignore_flags; + unsigned char scale; /* should certain properties scale with edje scale factor? */ + unsigned char precise_is_inside; + unsigned char use_alternate_font_metrics; + unsigned char pointer_mode; + unsigned char entry_mode; + unsigned char select_mode; + unsigned char multiline; + Edje_Part_Api api; +}; + +struct _Old_Edje_Part_Description_Spec_Image +{ + Eina_List *tween_list; /* list of Edje_Part_Image_Id */ + int id; /* the image id to use */ + int scale_hint; /* evas scale hint */ + Eina_Bool set; /* if image condition it's content */ + + Edje_Part_Description_Spec_Border border; + Edje_Part_Description_Spec_Fill fill; +}; + +struct _Old_Edje_Part_Description +{ + Edje_Part_Description_Common common; + Old_Edje_Part_Description_Spec_Image image; + Edje_Part_Description_Spec_Text text; + Edje_Part_Description_Spec_Box box; + Edje_Part_Description_Spec_Table table; + + Eina_List *external_params; /* parameters for external objects */ +}; + +Edje_File *_edje_file_convert(Eet_File *file, Old_Edje_File *oedf); +Edje_Part_Collection *_edje_collection_convert(Edje_File *file, + Old_Edje_Part_Collection *oedc); +Edje_Part_Description_Common *_edje_description_convert(int type, + Edje_Part_Collection_Directory_Entry *ce, + Old_Edje_Part_Description *oed); +const Edje_File *_edje_file_get(void); +void _edje_file_set(const Edje_File *edf); + +#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 @@ +#include "edje_private.h" + +EAPI Eet_Data_Descriptor *_edje_edd_edje_file = NULL; +EAPI Eet_Data_Descriptor *_edje_edd_edje_part_collection = NULL; + +Eet_Data_Descriptor *_edje_edd_edje_string = NULL; +Eet_Data_Descriptor *_edje_edd_edje_style = NULL; +Eet_Data_Descriptor *_edje_edd_edje_style_tag = NULL; +Eet_Data_Descriptor *_edje_edd_edje_color_class = NULL; +Eet_Data_Descriptor *_edje_edd_edje_external_directory = NULL; +Eet_Data_Descriptor *_edje_edd_edje_external_directory_entry = NULL; +Eet_Data_Descriptor *_edje_edd_edje_font_directory_entry = NULL; +Eet_Data_Descriptor *_edje_edd_edje_image_directory = NULL; +Eet_Data_Descriptor *_edje_edd_edje_image_directory_entry = NULL; +Eet_Data_Descriptor *_edje_edd_edje_image_directory_set = NULL; +Eet_Data_Descriptor *_edje_edd_edje_image_directory_set_entry = NULL; +Eet_Data_Descriptor *_edje_edd_edje_limit = NULL; +Eet_Data_Descriptor *_edje_edd_edje_limit_pointer = NULL; +Eet_Data_Descriptor *_edje_edd_edje_sound_sample = NULL; +Eet_Data_Descriptor *_edje_edd_edje_sound_tone = NULL; +Eet_Data_Descriptor *_edje_edd_edje_sound_directory = NULL; +Eet_Data_Descriptor *_edje_edd_edje_program = NULL; +Eet_Data_Descriptor *_edje_edd_edje_program_pointer = NULL; +Eet_Data_Descriptor *_edje_edd_edje_program_target = NULL; +Eet_Data_Descriptor *_edje_edd_edje_program_after = NULL; +Eet_Data_Descriptor *_edje_edd_edje_part_collection_directory_entry = NULL; +Eet_Data_Descriptor *_edje_edd_edje_pack_element = NULL; +Eet_Data_Descriptor *_edje_edd_edje_pack_element_pointer = NULL; +Eet_Data_Descriptor *_edje_edd_edje_part = NULL; +Eet_Data_Descriptor *_edje_edd_edje_part_pointer = NULL; +Eet_Data_Descriptor *_edje_edd_edje_part_description_variant = NULL; +Eet_Data_Descriptor *_edje_edd_edje_part_description_rectangle = NULL; +Eet_Data_Descriptor *_edje_edd_edje_part_description_swallow = NULL; +Eet_Data_Descriptor *_edje_edd_edje_part_description_group = NULL; +Eet_Data_Descriptor *_edje_edd_edje_part_description_image = NULL; +Eet_Data_Descriptor *_edje_edd_edje_part_description_proxy = NULL; +Eet_Data_Descriptor *_edje_edd_edje_part_description_text = NULL; +Eet_Data_Descriptor *_edje_edd_edje_part_description_textblock = NULL; +Eet_Data_Descriptor *_edje_edd_edje_part_description_box = NULL; +Eet_Data_Descriptor *_edje_edd_edje_part_description_table = NULL; +Eet_Data_Descriptor *_edje_edd_edje_part_description_external = NULL; +Eet_Data_Descriptor *_edje_edd_edje_part_description_variant_list = NULL; +Eet_Data_Descriptor *_edje_edd_edje_part_description_rectangle_pointer = NULL; +Eet_Data_Descriptor *_edje_edd_edje_part_description_swallow_pointer = NULL; +Eet_Data_Descriptor *_edje_edd_edje_part_description_group_pointer = NULL; +Eet_Data_Descriptor *_edje_edd_edje_part_description_image_pointer = NULL; +Eet_Data_Descriptor *_edje_edd_edje_part_description_proxy_pointer = NULL; +Eet_Data_Descriptor *_edje_edd_edje_part_description_text_pointer = NULL; +Eet_Data_Descriptor *_edje_edd_edje_part_description_textblock_pointer = NULL; +Eet_Data_Descriptor *_edje_edd_edje_part_description_box_pointer = NULL; +Eet_Data_Descriptor *_edje_edd_edje_part_description_table_pointer = NULL; +Eet_Data_Descriptor *_edje_edd_edje_part_description_external_pointer = NULL; +Eet_Data_Descriptor *_edje_edd_edje_part_image_id = NULL; +Eet_Data_Descriptor *_edje_edd_edje_part_image_id_pointer = NULL; +Eet_Data_Descriptor *_edje_edd_edje_external_param = NULL; + +#define EMP(Type, Minus) \ + Eina_Mempool *_emp_##Type = NULL; \ + \ + static void * \ + mem_alloc_##Minus(size_t size) \ + { \ + void *data; \ + \ + data = eina_mempool_malloc(_emp_##Type, size); \ + memset(data, 0, size); \ + return data; \ + } \ + \ + static void \ + mem_free_##Minus(void *data) \ + { \ + eina_mempool_free(_emp_##Type, data); \ + } + +EMP(RECTANGLE, rectangle); +EMP(TEXT, text); +EMP(IMAGE, image); +EMP(PROXY, proxy); +EMP(SWALLOW, swallow); +EMP(TEXTBLOCK, textblock); +EMP(GROUP, group); +EMP(BOX, box); +EMP(TABLE, table); +EMP(EXTERNAL, external); +EMP(part, part); + +#define FREED(eed) \ + if (eed) \ + { \ + eet_data_descriptor_free((eed)); \ + (eed) = NULL; \ + } + +struct { + Edje_Part_Type type; + const char *name; +} variant_convertion[] = { + { EDJE_PART_TYPE_RECTANGLE, "rectangle" }, + { EDJE_PART_TYPE_SWALLOW, "swallow" }, + { EDJE_PART_TYPE_GROUP, "group" }, + { EDJE_PART_TYPE_IMAGE, "image" }, + { EDJE_PART_TYPE_TEXT, "text" }, + { EDJE_PART_TYPE_TEXTBLOCK, "textblock" }, + { EDJE_PART_TYPE_BOX, "box" }, + { EDJE_PART_TYPE_TABLE, "table" }, + { EDJE_PART_TYPE_EXTERNAL, "external" }, + { EDJE_PART_TYPE_PROXY, "proxy" } +}; + +static const char * +_edje_description_variant_type_get(const void *data, Eina_Bool *unknow __UNUSED__) +{ + const unsigned char *type; + unsigned int i; + + type = data; + + for (i = 0; i < (sizeof (variant_convertion) / sizeof (variant_convertion[0])); ++i) + if (*type == variant_convertion[i].type) + return variant_convertion[i].name; + + return NULL; +} + +static Eina_Bool +_edje_description_variant_type_set(const char *type, void *data, Eina_Bool unknow __UNUSED__) +{ + unsigned char *dt; + unsigned int i; + + dt = data; + + for (i = 0; i < (sizeof (variant_convertion) / sizeof (variant_convertion[0])); ++i) + if (!strcmp(variant_convertion[i].name, type)) + { + *dt = variant_convertion[i].type; + return EINA_TRUE; + } + + return EINA_FALSE; +} + +static Eina_Hash * +_edje_eina_hash_add_alloc(Eina_Hash *hash, + const char *key, + void *data) +{ + if (!hash) + hash = eina_hash_string_small_new(free); + + if (!hash) + return NULL; + + eina_hash_add(hash, key, data); + return hash; +} + +// FIXME: remove EAPI when edje_convert goes +EAPI void +_edje_edd_shutdown(void) +{ + FREED(_edje_edd_edje_file); + FREED(_edje_edd_edje_string); + FREED(_edje_edd_edje_style); + FREED(_edje_edd_edje_style_tag); + FREED(_edje_edd_edje_color_class); + FREED(_edje_edd_edje_external_directory); + FREED(_edje_edd_edje_external_directory_entry); + FREED(_edje_edd_edje_font_directory_entry); + FREED(_edje_edd_edje_image_directory); + FREED(_edje_edd_edje_image_directory_entry); + FREED(_edje_edd_edje_limit); + FREED(_edje_edd_edje_limit_pointer); + FREED(_edje_edd_edje_sound_sample); + FREED(_edje_edd_edje_sound_tone); + FREED(_edje_edd_edje_sound_directory); + FREED(_edje_edd_edje_program); + FREED(_edje_edd_edje_program_pointer); + FREED(_edje_edd_edje_program_target); + FREED(_edje_edd_edje_program_after); + FREED(_edje_edd_edje_part_collection_directory_entry); + FREED(_edje_edd_edje_pack_element); + FREED(_edje_edd_edje_pack_element_pointer); + FREED(_edje_edd_edje_part_collection); + FREED(_edje_edd_edje_part); + FREED(_edje_edd_edje_part_pointer); + FREED(_edje_edd_edje_part_description_variant); + FREED(_edje_edd_edje_part_description_rectangle); + FREED(_edje_edd_edje_part_description_swallow); + FREED(_edje_edd_edje_part_description_group); + FREED(_edje_edd_edje_part_description_image); + FREED(_edje_edd_edje_part_description_proxy); + FREED(_edje_edd_edje_part_description_text); + FREED(_edje_edd_edje_part_description_textblock); + FREED(_edje_edd_edje_part_description_box); + FREED(_edje_edd_edje_part_description_table); + FREED(_edje_edd_edje_part_description_external); + FREED(_edje_edd_edje_part_description_variant_list); + FREED(_edje_edd_edje_part_description_rectangle_pointer); + FREED(_edje_edd_edje_part_description_swallow_pointer); + FREED(_edje_edd_edje_part_description_group_pointer); + FREED(_edje_edd_edje_part_description_image_pointer); + FREED(_edje_edd_edje_part_description_proxy_pointer); + FREED(_edje_edd_edje_part_description_text_pointer); + FREED(_edje_edd_edje_part_description_textblock_pointer); + FREED(_edje_edd_edje_part_description_box_pointer); + FREED(_edje_edd_edje_part_description_table_pointer); + FREED(_edje_edd_edje_part_description_external_pointer); + FREED(_edje_edd_edje_part_image_id); + FREED(_edje_edd_edje_part_image_id_pointer); + FREED(_edje_edd_edje_external_param); + FREED(_edje_edd_edje_image_directory_set); + FREED(_edje_edd_edje_image_directory_set_entry); +} + +#define EDJE_DEFINE_POINTER_TYPE(Type, Name) \ + { \ + typedef struct _Edje_##Type##_Pointer Edje_##Type##_Pointer; \ + struct _Edje_##Type##_Pointer \ + { \ + Edje_##Type *pointer; \ + }; \ + \ + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_##Type##_Pointer); \ + _edje_edd_edje_##Name##_pointer = \ + eet_data_descriptor_file_new(&eddc); \ + EET_DATA_DESCRIPTOR_ADD_SUB(_edje_edd_edje_##Name##_pointer, Edje_##Type##_Pointer, "pointer", pointer, _edje_edd_edje_##Name); \ + } + +// FIXME: remove EAPI when edje_convert goes +EAPI void +_edje_edd_init(void) +{ + Eet_Data_Descriptor_Class eddc; + + /* localisable string */ + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_String); + _edje_edd_edje_string = eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_string, Edje_String, "str", str, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_string, Edje_String, "id", id, EET_T_UINT); + + /* external directory */ + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_External_Directory_Entry); + _edje_edd_edje_external_directory_entry = + eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_external_directory_entry, Edje_External_Directory_Entry, "entry", entry, EET_T_STRING); + + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_External_Directory); + _edje_edd_edje_external_directory = + eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_edje_edd_edje_external_directory, Edje_External_Directory, "entries", entries, _edje_edd_edje_external_directory_entry); + + /* font directory */ + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Font_Directory_Entry); + _edje_edd_edje_font_directory_entry = + eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_font_directory_entry, Edje_Font_Directory_Entry, "entry", entry, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_font_directory_entry, Edje_Font_Directory_Entry, "file", file, EET_T_STRING); + + /* image directory */ + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Image_Directory_Entry); + _edje_edd_edje_image_directory_entry = + eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_image_directory_entry, Edje_Image_Directory_Entry, "entry", entry, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_image_directory_entry, Edje_Image_Directory_Entry, "source_type", source_type, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_image_directory_entry, Edje_Image_Directory_Entry, "source_param", source_param, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_image_directory_entry, Edje_Image_Directory_Entry, "id", id, EET_T_INT); + + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Image_Directory_Set_Entry); + _edje_edd_edje_image_directory_set_entry = + eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_image_directory_set_entry, Edje_Image_Directory_Set_Entry, "name", name, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_image_directory_set_entry, Edje_Image_Directory_Set_Entry, "id", id, EET_T_INT); + 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); + 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); + 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); + 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); + + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Image_Directory_Set); + _edje_edd_edje_image_directory_set = + eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_image_directory_set, Edje_Image_Directory_Set, "name", name, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_image_directory_set, Edje_Image_Directory_Set, "id", id, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_edje_image_directory_set, Edje_Image_Directory_Set, "entries", entries, _edje_edd_edje_image_directory_set_entry); + + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Image_Directory); + _edje_edd_edje_image_directory = + eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_edje_edd_edje_image_directory, Edje_Image_Directory, "entries", entries, _edje_edd_edje_image_directory_entry); + EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_edje_edd_edje_image_directory, Edje_Image_Directory, "sets", sets, _edje_edd_edje_image_directory_set); + + /* Sound */ + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Sound_Sample); + _edje_edd_edje_sound_sample = + eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_sound_sample, Edje_Sound_Sample, "name", name, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_sound_sample, Edje_Sound_Sample, "snd_src", snd_src, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_sound_sample, Edje_Sound_Sample, "compression", compression, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_sound_sample, Edje_Sound_Sample, "mode", mode, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_sound_sample, Edje_Sound_Sample, "quality", quality, EET_T_DOUBLE); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_sound_sample, Edje_Sound_Sample, "id", id, EET_T_INT); + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Sound_Tone); + _edje_edd_edje_sound_tone = + eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_sound_tone, Edje_Sound_Tone, "name", name, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_sound_tone, Edje_Sound_Tone, "value", value, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_sound_tone, Edje_Sound_Tone, "id", id, EET_T_INT); + + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Sound_Directory); + _edje_edd_edje_sound_directory = + eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_edje_edd_edje_sound_directory, Edje_Sound_Directory, "samples", samples, _edje_edd_edje_sound_sample); + EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_edje_edd_edje_sound_directory, Edje_Sound_Directory, "tones", tones, _edje_edd_edje_sound_tone); + + /* collection directory */ + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part_Collection_Directory_Entry); + _edje_edd_edje_part_collection_directory_entry = + eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "entry", entry, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "id", id, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "count.RECTANGLE", count.RECTANGLE, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "count.TEXT", count.TEXT, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "count.IMAGE", count.IMAGE, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "count.PROXY", count.PROXY, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "count.SWALLOW", count.SWALLOW, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "count.TEXTBLOCK", count.TEXTBLOCK, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "count.GROUP", count.GROUP, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "count.BOX", count.BOX, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "count.TABLE", count.TABLE, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "count.EXTERNAL", count.EXTERNAL, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "count.part", count.part, EET_T_INT); + + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Style_Tag); + _edje_edd_edje_style_tag = + eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_style_tag, Edje_Style_Tag, "key", key, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_style_tag, Edje_Style_Tag, "value", value, EET_T_STRING); + + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Style); + _edje_edd_edje_style = + eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_style, Edje_Style, "name", name, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_edje_style, Edje_Style, "tags", tags, _edje_edd_edje_style_tag); + + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Color_Class); + _edje_edd_edje_color_class = + eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_color_class, Edje_Color_Class, "name", name, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_color_class, Edje_Color_Class, "r", r, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_color_class, Edje_Color_Class, "g", g, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_color_class, Edje_Color_Class, "b", b, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_color_class, Edje_Color_Class, "a", a, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_color_class, Edje_Color_Class, "r2", r2, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_color_class, Edje_Color_Class, "g2", g2, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_color_class, Edje_Color_Class, "b2", b2, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_color_class, Edje_Color_Class, "a2", a2, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_color_class, Edje_Color_Class, "r3", r3, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_color_class, Edje_Color_Class, "g3", g3, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_color_class, Edje_Color_Class, "b3", b3, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_color_class, Edje_Color_Class, "a3", a3, EET_T_UCHAR); + + /* the main file directory */ + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_File); + eddc.func.hash_add = (void * (*)(void *, const char *, void *)) _edje_eina_hash_add_alloc; + _edje_edd_edje_file = eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_file, Edje_File, "compiler", compiler, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_file, Edje_File, "version", version, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_file, Edje_File, "minor", minor, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_file, Edje_File, "feature_ver", feature_ver, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_SUB(_edje_edd_edje_file, Edje_File, "external_dir", external_dir, _edje_edd_edje_external_directory); + EET_DATA_DESCRIPTOR_ADD_SUB(_edje_edd_edje_file, Edje_File, "image_dir", image_dir, _edje_edd_edje_image_directory); + EET_DATA_DESCRIPTOR_ADD_SUB(_edje_edd_edje_file, Edje_File, "sound_dir", sound_dir, _edje_edd_edje_sound_directory); + EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_edje_file, Edje_File, "styles", styles, _edje_edd_edje_style); + EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_edje_file, Edje_File, "color_classes", color_classes, _edje_edd_edje_color_class); + EET_DATA_DESCRIPTOR_ADD_HASH(_edje_edd_edje_file, Edje_File, "data", data, _edje_edd_edje_string); + EET_DATA_DESCRIPTOR_ADD_HASH(_edje_edd_edje_file, Edje_File, "fonts", fonts, _edje_edd_edje_font_directory_entry); + EET_DATA_DESCRIPTOR_ADD_HASH(_edje_edd_edje_file, Edje_File, "collection", collection, _edje_edd_edje_part_collection_directory_entry); + + /* parts & limit & programs - loaded induvidually */ + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Limit); + _edje_edd_edje_limit = eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_limit, Edje_Limit, "name", name, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_limit, Edje_Limit, "value", value, EET_T_INT); + + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Program_Target); + _edje_edd_edje_program_target = + eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program_target, Edje_Program_Target, "id", id, EET_T_INT); + + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Program_After); + _edje_edd_edje_program_after = + eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program_after, + Edje_Program_After, "id", id, EET_T_INT); + + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Program); + _edje_edd_edje_program = + eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "id", id, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "name", name, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "signal", signal, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "source", source, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "filter_part", filter.part, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "filter_state", filter.state, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "in.from", in.from, EET_T_DOUBLE); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "in.range", in.range, EET_T_DOUBLE); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "action", action, EET_T_INT); + + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "sample_name", sample_name, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "tone_name", tone_name, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program ,"duration", duration, EET_T_DOUBLE); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program ,"speed", speed, EET_T_DOUBLE); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "state", state, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "state2", state2, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "value", value, EET_T_DOUBLE); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "value2", value2, EET_T_DOUBLE); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "tween.mode", tween.mode, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "tween.time", tween.time, EDJE_T_FLOAT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "v1", tween.v1, EDJE_T_FLOAT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "v2", tween.v2, EDJE_T_FLOAT); + EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_edje_program, Edje_Program, "targets", targets, _edje_edd_edje_program_target); + EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_edje_program, Edje_Program, "after", after, _edje_edd_edje_program_after); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "api.name", api.name, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "api.description", api.description, EET_T_STRING); + + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "param.src", param.src, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_program, Edje_Program, "param.dst", param.dst, EET_T_INT); + + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part_Image_Id); + _edje_edd_edje_part_image_id = + eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_image_id, Edje_Part_Image_Id, "id", id, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_image_id, Edje_Part_Image_Id, "set", set, EET_T_UCHAR); + + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_External_Param); + _edje_edd_edje_external_param = + eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_external_param, Edje_External_Param, "name", name, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_external_param, Edje_External_Param, "type", type, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_external_param, Edje_External_Param, "i", i, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_external_param, Edje_External_Param, "d", d, EET_T_DOUBLE); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_external_param, Edje_External_Param, "s", s, EET_T_STRING); + +#define EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON(Edd, Type) \ + { \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "state.name", state.name, EET_T_STRING); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "state.value", state.value, EET_T_DOUBLE); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "visible", visible, EET_T_CHAR); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "align.x", align.x, EDJE_T_FLOAT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "align.y", align.y, EDJE_T_FLOAT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "fixed.w", fixed.w, EET_T_UCHAR); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "fixed.h", fixed.h, EET_T_UCHAR); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "min.w", min.w, EET_T_INT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "min.h", min.h, EET_T_INT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "max.w", max.w, EET_T_INT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "max.h", max.h, EET_T_INT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "step.x", step.x, EET_T_INT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "step.y", step.y, EET_T_INT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "aspect.min", aspect.min, EDJE_T_FLOAT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "aspect.max", aspect.max, EDJE_T_FLOAT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "aspect.prefer", aspect.prefer, EET_T_CHAR); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "rel1.relative_x", rel1.relative_x, EDJE_T_FLOAT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "rel1.relative_y", rel1.relative_y, EDJE_T_FLOAT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "rel1.offset_x", rel1.offset_x, EET_T_INT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "rel1.offset_y", rel1.offset_y, EET_T_INT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "rel1.id_x", rel1.id_x, EET_T_INT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "rel1.id_y", rel1.id_y, EET_T_INT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "rel2.relative_x", rel2.relative_x, EDJE_T_FLOAT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "rel2.relative_y", rel2.relative_y, EDJE_T_FLOAT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "rel2.offset_x", rel2.offset_x, EET_T_INT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "rel2.offset_y", rel2.offset_y, EET_T_INT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "rel2.id_x", rel2.id_x, EET_T_INT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "rel2.id_y", rel2.id_y, EET_T_INT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "color_class", color_class, EET_T_STRING); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "color.r", color.r, EET_T_UCHAR); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "color.g", color.g, EET_T_UCHAR); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "color.b", color.b, EET_T_UCHAR); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "color.a", color.a, EET_T_UCHAR); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "color2.r", color2.r, EET_T_UCHAR); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "color2.g", color2.g, EET_T_UCHAR); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "color2.b", color2.b, EET_T_UCHAR); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "color2.a", color2.a, EET_T_UCHAR); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.id_persp", map.id_persp, EET_T_INT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.id_light", map.id_light, EET_T_INT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.rot.id_center", map.rot.id_center, EET_T_INT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.rot.x", map.rot.x, EDJE_T_FLOAT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.rot.y", map.rot.y, EDJE_T_FLOAT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.rot.z", map.rot.z, EDJE_T_FLOAT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.on", map.on, EET_T_UCHAR); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.smooth", map.smooth, EET_T_UCHAR); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.alpha", map.alpha, EET_T_UCHAR); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.persp_on", map.persp_on, EET_T_UCHAR); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.backcull", map.backcull, EET_T_UCHAR); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "persp.zplane", persp.zplane, EET_T_INT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "persp.focal", persp.focal, EET_T_INT); \ + } + +#define EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON_SUB(Edd, Type, Dec) \ + { \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "state.name", Dec.state.name, EET_T_STRING); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "state.value", Dec.state.value, EET_T_DOUBLE); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "visible", Dec.visible, EET_T_CHAR); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "align.x", Dec.align.x, EDJE_T_FLOAT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "align.y", Dec.align.y, EDJE_T_FLOAT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "fixed.w", Dec.fixed.w, EET_T_UCHAR); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "fixed.h", Dec.fixed.h, EET_T_UCHAR); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "min.w", Dec.min.w, EET_T_INT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "min.h", Dec.min.h, EET_T_INT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "max.w", Dec.max.w, EET_T_INT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "max.h", Dec.max.h, EET_T_INT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "step.x", Dec.step.x, EET_T_INT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "step.y", Dec.step.y, EET_T_INT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "aspect.min", Dec.aspect.min, EDJE_T_FLOAT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "aspect.max", Dec.aspect.max, EDJE_T_FLOAT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "aspect.prefer", Dec.aspect.prefer, EET_T_CHAR); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "rel1.relative_x", Dec.rel1.relative_x, EDJE_T_FLOAT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "rel1.relative_y", Dec.rel1.relative_y, EDJE_T_FLOAT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "rel1.offset_x", Dec.rel1.offset_x, EET_T_INT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "rel1.offset_y", Dec.rel1.offset_y, EET_T_INT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "rel1.id_x", Dec.rel1.id_x, EET_T_INT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "rel1.id_y", Dec.rel1.id_y, EET_T_INT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "rel2.relative_x", Dec.rel2.relative_x, EDJE_T_FLOAT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "rel2.relative_y", Dec.rel2.relative_y, EDJE_T_FLOAT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "rel2.offset_x", Dec.rel2.offset_x, EET_T_INT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "rel2.offset_y", Dec.rel2.offset_y, EET_T_INT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "rel2.id_x", Dec.rel2.id_x, EET_T_INT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "rel2.id_y", Dec.rel2.id_y, EET_T_INT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "color_class", Dec.color_class, EET_T_STRING); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "color.r", Dec.color.r, EET_T_UCHAR); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "color.g", Dec.color.g, EET_T_UCHAR); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "color.b", Dec.color.b, EET_T_UCHAR); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "color.a", Dec.color.a, EET_T_UCHAR); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "color2.r", Dec.color2.r, EET_T_UCHAR); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "color2.g", Dec.color2.g, EET_T_UCHAR); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "color2.b", Dec.color2.b, EET_T_UCHAR); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "color2.a", Dec.color2.a, EET_T_UCHAR); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.id_persp", Dec.map.id_persp, EET_T_INT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.id_light", Dec.map.id_light, EET_T_INT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.rot.id_center", Dec.map.rot.id_center, EET_T_INT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.rot.x", Dec.map.rot.x, EDJE_T_FLOAT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.rot.y", Dec.map.rot.y, EDJE_T_FLOAT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.rot.z", Dec.map.rot.z, EDJE_T_FLOAT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.on", Dec.map.on, EET_T_UCHAR); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.smooth", Dec.map.smooth, EET_T_UCHAR); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.alpha", Dec.map.alpha, EET_T_UCHAR); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.persp_on", Dec.map.persp_on, EET_T_UCHAR); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.backcull", Dec.map.backcull, EET_T_UCHAR); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "persp.zplane", Dec.persp.zplane, EET_T_INT); \ + EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "persp.focal", Dec.persp.focal, EET_T_INT); \ + } + + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part_Description_Common); + eddc.func.mem_free = mem_free_rectangle; + eddc.func.mem_alloc = mem_alloc_rectangle; + _edje_edd_edje_part_description_rectangle = + eet_data_descriptor_file_new(&eddc); + EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON(_edje_edd_edje_part_description_rectangle, Edje_Part_Description_Common); + + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part_Description_Common); + eddc.func.mem_free = mem_free_swallow; + eddc.func.mem_alloc = mem_alloc_swallow; + _edje_edd_edje_part_description_swallow = + eet_data_descriptor_file_new(&eddc); + EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON(_edje_edd_edje_part_description_swallow, Edje_Part_Description_Common); + + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part_Description_Common); + eddc.func.mem_free = mem_free_group; + eddc.func.mem_alloc = mem_alloc_group; + _edje_edd_edje_part_description_group = + eet_data_descriptor_file_new(&eddc); + EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON(_edje_edd_edje_part_description_group, Edje_Part_Description_Common); + + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part_Description_Image); + eddc.func.mem_free = mem_free_image; + eddc.func.mem_alloc = mem_alloc_image; + _edje_edd_edje_part_description_image = + eet_data_descriptor_file_new(&eddc); + EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON_SUB(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, common); + + EDJE_DEFINE_POINTER_TYPE(Part_Image_Id, part_image_id); + 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); + + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, "image.id", image.id, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, "image.set", image.set, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, "image.border.l", image.border.l, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, "image.border.r", image.border.r, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, "image.border.t", image.border.t, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, "image.border.b", image.border.b, EET_T_INT); + 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); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, "image.border.scale", image.border.scale, EET_T_UCHAR); + 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); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, "image.fill.smooth", image.fill.smooth, EET_T_CHAR); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, "image.fill.angle", image.fill.angle, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, "image.fill.spread", image.fill.spread, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, Edje_Part_Description_Image, "image.fill.type", image.fill.type, EET_T_CHAR); + + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part_Description_Proxy); + eddc.func.mem_free = mem_free_proxy; + eddc.func.mem_alloc = mem_alloc_proxy; + _edje_edd_edje_part_description_proxy = + eet_data_descriptor_file_new(&eddc); + EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON_SUB(_edje_edd_edje_part_description_proxy, Edje_Part_Description_Proxy, common); + + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_proxy, Edje_Part_Description_Proxy, "proxy.id", proxy.id, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_proxy, Edje_Part_Description_Proxy, "proxy.fill.smooth", proxy.fill.smooth, EET_T_CHAR); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_proxy, Edje_Part_Description_Proxy, "proxy.fill.angle", proxy.fill.angle, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_proxy, Edje_Part_Description_Proxy, "proxy.fill.spread", proxy.fill.spread, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_proxy, Edje_Part_Description_Proxy, "proxy.fill.type", proxy.fill.type, EET_T_CHAR); + + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part_Description_Text); + eddc.func.mem_free = mem_free_text; + eddc.func.mem_alloc = mem_alloc_text; + _edje_edd_edje_part_description_text = + eet_data_descriptor_file_new(&eddc); + EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON_SUB(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, common); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.color3.r", text.color3.r, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.color3.g", text.color3.g, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.color3.b", text.color3.b, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.color3.a", text.color3.a, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.text", text.text, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.text_class", text.text_class, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.style", text.style, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.font", text.font, EET_T_STRING); + 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); + 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); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.repch", text.repch, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.size", text.size, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.fit_x", text.fit_x, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.fit_y", text.fit_y, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.min_x", text.min_x, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.min_y", text.min_y, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.max_x", text.max_x, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.max_y", text.max_y, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.align.x", text.align.x, EDJE_T_FLOAT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.align.y", text.align.y, EDJE_T_FLOAT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.id_source", text.id_source, EET_T_INT); + 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); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, Edje_Part_Description_Text, "text.elipsis", text.elipsis, EET_T_DOUBLE); + + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part_Description_Text); + eddc.func.mem_free = mem_free_textblock; + eddc.func.mem_alloc = mem_alloc_textblock; + _edje_edd_edje_part_description_textblock = + eet_data_descriptor_file_new(&eddc); + EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON_SUB(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, common); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.color3.r", text.color3.r, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.color3.g", text.color3.g, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.color3.b", text.color3.b, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.color3.a", text.color3.a, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.text", text.text, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.text_class", text.text_class, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.style", text.style, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.font", text.font, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.repch", text.repch, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.size", text.size, EET_T_INT); + 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); + 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); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.fit_x", text.fit_x, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.fit_y", text.fit_y, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.min_x", text.min_x, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.min_y", text.min_y, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.max_x", text.max_x, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.max_y", text.max_y, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.align.x", text.align.x, EDJE_T_FLOAT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.align.y", text.align.y, EDJE_T_FLOAT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.id_source", text.id_source, EET_T_INT); + 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); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_textblock, Edje_Part_Description_Text, "text.elipsis", text.elipsis, EET_T_DOUBLE); + + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part_Description_Box); + eddc.func.mem_free = mem_free_box; + eddc.func.mem_alloc = mem_alloc_box; + _edje_edd_edje_part_description_box = + eet_data_descriptor_file_new(&eddc); + EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON_SUB(_edje_edd_edje_part_description_box, Edje_Part_Description_Box, common); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_box, Edje_Part_Description_Box, "box.layout", box.layout, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_box, Edje_Part_Description_Box, "box.alt_layout", box.alt_layout, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_box, Edje_Part_Description_Box, "box.align.x", box.align.x, EDJE_T_FLOAT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_box, Edje_Part_Description_Box, "box.align.y", box.align.y, EDJE_T_FLOAT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_box, Edje_Part_Description_Box, "box.padding.x", box.padding.x, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_box, Edje_Part_Description_Box, "box.padding.y", box.padding.y, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_box, Edje_Part_Description_Box, "box.min.h", box.min.h, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_box, Edje_Part_Description_Box, "box.min.v", box.min.v, EET_T_UCHAR); + + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part_Description_Table); + eddc.func.mem_free = mem_free_table; + eddc.func.mem_alloc = mem_alloc_table; + _edje_edd_edje_part_description_table = + eet_data_descriptor_file_new(&eddc); + EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON_SUB(_edje_edd_edje_part_description_table, Edje_Part_Description_Table, common); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_table, Edje_Part_Description_Table, "table.homogeneous", table.homogeneous, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_table, Edje_Part_Description_Table, "table.align.x", table.align.x, EDJE_T_FLOAT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_table, Edje_Part_Description_Table, "table.align.y", table.align.y, EDJE_T_FLOAT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_table, Edje_Part_Description_Table, "table.padding.x", table.padding.x, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_table, Edje_Part_Description_Table, "table.padding.y", table.padding.y, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_table, Edje_Part_Description_Table, "table.min.h", table.min.h, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_table, Edje_Part_Description_Table, "table.min.v", table.min.v, EET_T_UCHAR); + + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part_Description_External); + eddc.func.mem_free = mem_free_external; + eddc.func.mem_alloc = mem_alloc_external; + _edje_edd_edje_part_description_external = + eet_data_descriptor_file_new(&eddc); + EDJE_DATA_DESCRIPTOR_DESCRIPTION_COMMON_SUB(_edje_edd_edje_part_description_external, Edje_Part_Description_External, common); + EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_edje_part_description_external, Edje_Part_Description_External, "external_params", external_params, _edje_edd_edje_external_param); + + EDJE_DEFINE_POINTER_TYPE(Part_Description_Common, part_description_rectangle); + EDJE_DEFINE_POINTER_TYPE(Part_Description_Common, part_description_swallow); + EDJE_DEFINE_POINTER_TYPE(Part_Description_Common, part_description_group); + EDJE_DEFINE_POINTER_TYPE(Part_Description_Image, part_description_image); + EDJE_DEFINE_POINTER_TYPE(Part_Description_Proxy, part_description_proxy); + EDJE_DEFINE_POINTER_TYPE(Part_Description_Text, part_description_text); + EDJE_DEFINE_POINTER_TYPE(Part_Description_Text, part_description_textblock); + EDJE_DEFINE_POINTER_TYPE(Part_Description_Box, part_description_box); + EDJE_DEFINE_POINTER_TYPE(Part_Description_Table, part_description_table); + EDJE_DEFINE_POINTER_TYPE(Part_Description_External, part_description_external); + + eddc.version = EET_DATA_DESCRIPTOR_CLASS_VERSION; + eddc.func.type_get = _edje_description_variant_type_get; + eddc.func.type_set = _edje_description_variant_type_set; + _edje_edd_edje_part_description_variant = eet_data_descriptor_file_new(&eddc); + + EET_DATA_DESCRIPTOR_ADD_MAPPING(_edje_edd_edje_part_description_variant, "rectangle", _edje_edd_edje_part_description_rectangle); + EET_DATA_DESCRIPTOR_ADD_MAPPING(_edje_edd_edje_part_description_variant, "swallow", _edje_edd_edje_part_description_swallow); + EET_DATA_DESCRIPTOR_ADD_MAPPING(_edje_edd_edje_part_description_variant, "group", _edje_edd_edje_part_description_group); + EET_DATA_DESCRIPTOR_ADD_MAPPING(_edje_edd_edje_part_description_variant, "image", _edje_edd_edje_part_description_image); + EET_DATA_DESCRIPTOR_ADD_MAPPING(_edje_edd_edje_part_description_variant, "proxy", _edje_edd_edje_part_description_proxy); + EET_DATA_DESCRIPTOR_ADD_MAPPING(_edje_edd_edje_part_description_variant, "text", _edje_edd_edje_part_description_text); + EET_DATA_DESCRIPTOR_ADD_MAPPING(_edje_edd_edje_part_description_variant, "textblock", _edje_edd_edje_part_description_textblock); + EET_DATA_DESCRIPTOR_ADD_MAPPING(_edje_edd_edje_part_description_variant, "box", _edje_edd_edje_part_description_box); + EET_DATA_DESCRIPTOR_ADD_MAPPING(_edje_edd_edje_part_description_variant, "table", _edje_edd_edje_part_description_table); + EET_DATA_DESCRIPTOR_ADD_MAPPING(_edje_edd_edje_part_description_variant, "external", _edje_edd_edje_part_description_external); + +#define EDJE_ADD_ARRAY_MAPPING(Variant, Type, Minus) \ + { \ + Edje_Part_Description_List tmp; \ + \ + eet_data_descriptor_element_add(Variant, Type, \ + EET_T_UNKNOW, EET_G_VAR_ARRAY, \ + 0, (char*)(&tmp.desc_count) - (char*)(&tmp), \ + NULL, \ + _edje_edd_edje_part_description_##Minus##_pointer); \ + } + + _edje_edd_edje_part_description_variant_list = eet_data_descriptor_file_new(&eddc); + + EDJE_ADD_ARRAY_MAPPING(_edje_edd_edje_part_description_variant_list, "rectangle", rectangle); + EDJE_ADD_ARRAY_MAPPING(_edje_edd_edje_part_description_variant_list, "swallow", swallow); + EDJE_ADD_ARRAY_MAPPING(_edje_edd_edje_part_description_variant_list, "group", group); + EDJE_ADD_ARRAY_MAPPING(_edje_edd_edje_part_description_variant_list, "image", image); + EDJE_ADD_ARRAY_MAPPING(_edje_edd_edje_part_description_variant_list, "proxy", proxy); + EDJE_ADD_ARRAY_MAPPING(_edje_edd_edje_part_description_variant_list, "text", text); + EDJE_ADD_ARRAY_MAPPING(_edje_edd_edje_part_description_variant_list, "textblock", textblock); + EDJE_ADD_ARRAY_MAPPING(_edje_edd_edje_part_description_variant_list, "box", box); + EDJE_ADD_ARRAY_MAPPING(_edje_edd_edje_part_description_variant_list, "table", table); + EDJE_ADD_ARRAY_MAPPING(_edje_edd_edje_part_description_variant_list, "external", external); + + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Pack_Element); + _edje_edd_edje_pack_element = + eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "type", type, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "name", name, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "source", source, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "min.w", min.w, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "min.h", min.h, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "prefer.w", prefer.w, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "prefer.h", prefer.h, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "max.w", max.w, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "max.h", max.h, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "padding.l", padding.l, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "padding.r", padding.r, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "padding.t", padding.t, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "padding.b", padding.b, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "align.x", align.x, EDJE_T_FLOAT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "align.y", align.y, EDJE_T_FLOAT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "weight.x", weight.x, EDJE_T_FLOAT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "weight.y", weight.y, EDJE_T_FLOAT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "aspect.w", aspect.w, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "aspect.h", aspect.h, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "aspect.mode", aspect.mode, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "options", options, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "col", col, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "row", row, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "colspan", colspan, EET_T_USHORT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "rowspan", rowspan, EET_T_USHORT); + + EDJE_DEFINE_POINTER_TYPE(Pack_Element, pack_element); + + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part); + eddc.func.mem_free = mem_free_part; + eddc.func.mem_alloc = mem_alloc_part; + _edje_edd_edje_part = + eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "name", name, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_VARIANT(_edje_edd_edje_part, Edje_Part, "default_desc", default_desc, type, _edje_edd_edje_part_description_variant); + EET_DATA_DESCRIPTOR_ADD_VARIANT(_edje_edd_edje_part, Edje_Part, "other", other, type, _edje_edd_edje_part_description_variant_list); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "source", source, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "source2", source2, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "source3", source3, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "source4", source4, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "source5", source5, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "source6", source6, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "id", id, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "clip_to_id", clip_to_id, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "dragable.x", dragable.x, EET_T_CHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "dragable.step_x", dragable.step_x, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "dragable.count_x", dragable.count_x, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "dragable.y", dragable.y, EET_T_CHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "dragable.step_y", dragable.step_y, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "dragable.count_y", dragable.count_y, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "dragable.counfine_id", dragable.confine_id, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "dragable.events_id", dragable.event_id, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_edje_edd_edje_part, Edje_Part, "items", items, _edje_edd_edje_pack_element_pointer); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "type", type, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "effect", effect, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "mouse_events", mouse_events, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "repeat_events", repeat_events, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "ignore_flags", ignore_flags, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "scale", scale, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "precise_is_inside", precise_is_inside, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "use_alternate_font_metrics", use_alternate_font_metrics, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "pointer_mode", pointer_mode, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "entry_mode", entry_mode, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "select_mode", select_mode, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "cursor_mode", cursor_mode, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "multiline", multiline, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "api.name", api.name, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "api.description", api.description, EET_T_STRING); + + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part_Collection); + _edje_edd_edje_part_collection = + eet_data_descriptor_file_new(&eddc); + + EDJE_DEFINE_POINTER_TYPE(Program, program); + EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_edje_edd_edje_part_collection, Edje_Part_Collection, "programs.fnmatch", programs.fnmatch, _edje_edd_edje_program_pointer); + EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_edje_edd_edje_part_collection, Edje_Part_Collection, "programs.strcmp", programs.strcmp, _edje_edd_edje_program_pointer); + EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_edje_edd_edje_part_collection, Edje_Part_Collection, "programs.strncmp", programs.strncmp, _edje_edd_edje_program_pointer); + EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_edje_edd_edje_part_collection, Edje_Part_Collection, "programs.strrncmp", programs.strrncmp, _edje_edd_edje_program_pointer); + EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_edje_edd_edje_part_collection, Edje_Part_Collection, "programs.nocmp", programs.nocmp, _edje_edd_edje_program_pointer); + + EDJE_DEFINE_POINTER_TYPE(Part, part); + EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_edje_edd_edje_part_collection, Edje_Part_Collection, "parts", parts, _edje_edd_edje_part_pointer); + + EDJE_DEFINE_POINTER_TYPE(Limit, limit); + EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_edje_edd_edje_part_collection, Edje_Part_Collection, "limits.vertical", limits.vertical, _edje_edd_edje_limit_pointer); + EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_edje_edd_edje_part_collection, Edje_Part_Collection, "limits.horizontal", limits.horizontal, _edje_edd_edje_limit_pointer); + + EET_DATA_DESCRIPTOR_ADD_HASH(_edje_edd_edje_part_collection, Edje_Part_Collection, "data", data, _edje_edd_edje_string); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "id", id, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_HASH_STRING(_edje_edd_edje_part_collection, Edje_Part_Collection, "alias", alias); + EET_DATA_DESCRIPTOR_ADD_HASH_STRING(_edje_edd_edje_part_collection, Edje_Part_Collection, "aliased", aliased); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "prop.min.w", prop.min.w, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "prop.min.h", prop.min.h, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "prop.max.w", prop.max.w, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "prop.max.h", prop.max.h, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "part", part, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "script_only", script_only, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "lua_script_only", lua_script_only, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "prop.orientation", prop.orientation, EET_T_INT); +} 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 @@ +/* + * TODO + * ----------------------------------------------------------------- + * Add LUA Support :) + * Remove images/fonts + * Clean the saving routines + * + */ + +#include "edje_private.h" + +#define EDJE_EDIT_IS_UNSTABLE_AND_I_KNOW_ABOUT_IT +#include "Edje_Edit.h" + +static const char EDJE_EDIT_ERROR_GROUP_CURRENTLY_USED_STR[] = "Current group cannot be deleted"; +static const char EDJE_EDIT_ERROR_GROUP_REFERENCED_STR[] = "Group still in use"; +static const char EDJE_EDIT_ERROR_GROUP_DOES_NOT_EXIST_STR[] = "Group does not exist"; + +EAPI Eina_Error EDJE_EDIT_ERROR_GROUP_CURRENTLY_USED = 0 ; +EAPI Eina_Error EDJE_EDIT_ERROR_GROUP_REFERENCED = 0; +EAPI Eina_Error EDJE_EDIT_ERROR_GROUP_DOES_NOT_EXIST = 0; + +/* Get ed(Edje*) from obj(Evas_Object*) */ +#define GET_ED_OR_RETURN(RET) \ + Edje *ed; \ + Edje_Edit *eed; \ + if (!evas_object_smart_type_check_ptr(obj, _edje_edit_type)) \ + return RET; \ + eed = evas_object_smart_data_get(obj); \ + if (!eed) return RET; \ + ed = (Edje *)eed; + +/* Get rp(Edje_Real_Part*) from obj(Evas_Object*) and part(char*) */ +#define GET_RP_OR_RETURN(RET) \ + Edje *ed; \ + Edje_Edit *eed; \ + Edje_Real_Part *rp; \ + if (!evas_object_smart_type_check_ptr(obj, _edje_edit_type)) \ + return RET; \ + eed = evas_object_smart_data_get(obj); \ + if (!eed) return RET; \ + ed = (Edje *)eed; \ + rp = _edje_real_part_get(ed, part); \ + if (!rp) return RET; + +/* Get pd(Edje_Part_Description*) from obj(Evas_Object*), part(char*) and state (char*) */ +#define GET_PD_OR_RETURN(RET) \ + Edje *ed; \ + Edje_Edit *eed; \ + Edje_Real_Part *rp; \ + Edje_Part_Description_Common *pd; \ + if (!evas_object_smart_type_check_ptr(obj, _edje_edit_type)) \ + return RET; \ + eed = evas_object_smart_data_get(obj); \ + if (!eed) return RET; \ + ed = (Edje *)eed; \ + rp = _edje_real_part_get(ed, part); \ + if (!rp) return RET; \ + pd = _edje_part_description_find_byname(eed, part, state, value); \ + if (!pd) return RET; + +/* Get epr(Edje_Program*) from obj(Evas_Object*) and prog(char*)*/ +#define GET_EPR_OR_RETURN(RET) \ + Edje_Program *epr; \ + if (!evas_object_smart_type_check_ptr(obj, _edje_edit_type)) \ + return RET; \ + epr = _edje_program_get_byname(obj, prog); \ + if (!epr) return RET; + +static void * +_alloc(size_t size) +{ + void *mem; + + mem = calloc(1, size); + if (mem) return mem; + ERR("Edje_Edit: Error. memory allocation of %i bytes failed. %s", + (int)size, strerror(errno)); + return NULL; +} + +/*************/ +/* INTERNALS */ +/*************/ + +/* Edje_Edit smart! Overloads the edje one adding some more control stuff */ +static const char _edje_edit_type[] = "edje_edit"; + +typedef struct _Edje_Edit Edje_Edit; +struct _Edje_Edit +{ + Edje base; + + void *bytecode; + int bytecode_size; + + char *embryo_source; + char *embryo_processed; + Eina_Hash *program_scripts; + + Eina_List *errors; + + Eina_Bool bytecode_dirty:1; + Eina_Bool embryo_source_dirty:1; + Eina_Bool all_dirty:1; + Eina_Bool script_need_recompile:1; +}; + +typedef struct _Program_Script Program_Script; +struct _Program_Script +{ + int id; + char *code; + char *processed; + Eina_Bool dirty:1; + Eina_Bool delete_me:1; +}; + +static void _edje_edit_smart_add(Evas_Object *obj); +static void _edje_edit_smart_del(Evas_Object *obj); + +static Eina_Bool _edje_edit_smart_file_set(Evas_Object *obj, const char *file, const char *group); +static Eina_Bool _edje_edit_edje_file_save(Eet_File *eetf, Edje_File *ef); + +EVAS_SMART_SUBCLASS_NEW(_edje_edit_type, _edje_edit, Edje_Smart_Api, + Edje_Smart_Api, _edje_object_smart_class_get, NULL) + +static void +_edje_edit_smart_set_user(Edje_Smart_Api *sc) +{ + sc->base.add = _edje_edit_smart_add; + sc->base.del = _edje_edit_smart_del; + sc->file_set = _edje_edit_smart_file_set; +} + +static void +_edje_edit_smart_add(Evas_Object *obj) +{ + Edje_Edit *eed; + + eed = evas_object_smart_data_get(obj); + if (!eed) + { + const Evas_Smart *smart; + const Evas_Smart_Class *sc; + + eed = calloc(1, sizeof(Edje_Edit)); + if (!eed) return; + + smart = evas_object_smart_smart_get(obj); + sc = evas_smart_class_get(smart); + eed->base.api = (const Edje_Smart_Api *)sc; + + evas_object_smart_data_set(obj, eed); + } + + _edje_edit_parent_sc->base.add(obj); +} + +static void +_edje_edit_data_clean(Edje_Edit *eed) +{ + Edje_Edit_Script_Error *se; + + free(eed->bytecode); + free(eed->embryo_source); + free(eed->embryo_processed); + + if (eed->program_scripts) + eina_hash_free(eed->program_scripts); + + EINA_LIST_FREE(eed->errors, se) + { + eina_stringshare_del(se->program_name); + eina_stringshare_del(se->error_str); + free(se); + } + + eed->bytecode = NULL; + eed->embryo_source = NULL; + eed->embryo_processed = NULL; + eed->program_scripts = NULL; + eed->bytecode_size = 0; + eed->bytecode_dirty = EINA_FALSE; + eed->embryo_source_dirty = EINA_FALSE; + eed->all_dirty = EINA_FALSE; + eed->script_need_recompile = EINA_FALSE; +} + +static void +_edje_edit_smart_del(Evas_Object *obj) +{ + Edje_Edit *eed; + + eed = evas_object_smart_data_get(obj); + + _edje_edit_data_clean(eed); + + _edje_edit_parent_sc->base.del(obj); +} + +static void +_edje_edit_program_script_free(Program_Script *ps) +{ + free(ps->code); + free(ps->processed); + free(ps); +} + +static Eina_Bool +_edje_edit_smart_file_set(Evas_Object *obj, const char *file, const char *group) +{ + Edje_Edit *eed; + Eet_File *ef; + char **keys, buf[64]; + int count, i; + int len = strlen("edje/scripts/embryo/source/"); + + eed = evas_object_smart_data_get(obj); + + _edje_edit_data_clean(eed); + + /* TODO and maybes: + * * The whole point of this thing is keep track of stuff such as + * strings to free and who knows what, so we need to take care + * of those if the file/group changes. + * * Maybe have the possibility to open just files, not always with + * a group given. + * * A way to skip the cache? Could help avoid some issues when editing + * a group being used by the application in some other way, or multiple + * opens of the same file. + * * Here we probably want to allow opening groups with broken references + * (GROUP parts or BOX/TABLE items pointing to non-existent/renamed + * groups). + */ + if (!_edje_edit_parent_sc->file_set(obj, file, group)) + return EINA_FALSE; + + eed->program_scripts = eina_hash_int32_new((Eina_Free_Cb)_edje_edit_program_script_free); + + ef = eet_open(file, EET_FILE_MODE_READ); + + snprintf(buf, sizeof(buf), "edje/scripts/embryo/source/%i", + eed->base.collection->id); + eed->embryo_source = eet_read(ef, buf, &count); + + snprintf(buf, sizeof(buf), "edje/scripts/embryo/source/%i/*", + eed->base.collection->id); + keys = eet_list(ef, buf, &count); + for (i = 0; i < count; i++) + { + Program_Script *ps; + int size; + + ps = calloc(1, sizeof(Program_Script)); + + sscanf(keys[i] + len, "%*i/%i", &ps->id); + ps->code = eet_read(ef, keys[i], &size); + eina_hash_add(eed->program_scripts, &ps->id, ps); + } + if (keys) free(keys); + return EINA_TRUE; +} + +static void +_edje_edit_error_register(void) +{ + EDJE_EDIT_ERROR_GROUP_DOES_NOT_EXIST = + eina_error_msg_static_register(EDJE_EDIT_ERROR_GROUP_DOES_NOT_EXIST_STR); + EDJE_EDIT_ERROR_GROUP_CURRENTLY_USED = + eina_error_msg_static_register(EDJE_EDIT_ERROR_GROUP_CURRENTLY_USED_STR); + EDJE_EDIT_ERROR_GROUP_REFERENCED = + eina_error_msg_static_register(EDJE_EDIT_ERROR_GROUP_REFERENCED_STR); +} + +EAPI Evas_Object * +edje_edit_object_add(Evas *e) +{ + eina_error_set(0); + + if (!EDJE_EDIT_ERROR_GROUP_DOES_NOT_EXIST) + _edje_edit_error_register(); + + return evas_object_smart_add(e, _edje_edit_smart_class_new()); +} +/* End of Edje_Edit smart stuff */ + +static Edje_Part_Description_Common * +_edje_part_description_find_byname(Edje_Edit *eed, const char *part, const char *state, double value) +{ + Edje_Real_Part *rp; + Edje_Part_Description_Common *pd; + + if (!eed || !part || !state) return NULL; + + rp = _edje_real_part_get((Edje *)eed, part); + if (!rp) return NULL; + + pd = _edje_part_description_find((Edje *)eed, rp, state, value); + + return pd; +} + +static int +_edje_image_id_find(Edje_Edit *eed, const char *image_name) +{ + unsigned int i; + + if (!eed->base.file) return -1; + if (!eed->base.file->image_dir) return -1; + + //printf("SEARCH IMAGE %s\n", image_name); + + for (i = 0; i < eed->base.file->image_dir->entries_count; ++i) + if (eed->base.file->image_dir->entries[i].entry + && !strcmp(image_name, eed->base.file->image_dir->entries[i].entry)) + return i; + + return -1; +} + +static const char * +_edje_image_name_find(Edje_Edit *eed, int image_id) +{ + if (!eed->base.file) return NULL; + if (!eed->base.file->image_dir) return NULL; + + /* Special case for external image */ + if (image_id < 0) image_id = -image_id - 1; + + //printf("SEARCH IMAGE ID %d\n", image_id); + if ((unsigned int) image_id >= eed->base.file->image_dir->entries_count) + return NULL; + return eed->base.file->image_dir->entries[image_id].entry; +} + +static void +_edje_real_part_free(Edje_Real_Part *rp) +{ + if (!rp) return; + + if (rp->object) + { + _edje_callbacks_del(rp->object, rp->edje); + evas_object_del(rp->object); + } + + if (rp->swallowed_object) + { + evas_object_smart_member_del(rp->swallowed_object); + evas_object_event_callback_del(rp->swallowed_object, + EVAS_CALLBACK_FREE, + _edje_object_part_swallow_free_cb); + evas_object_clip_unset(rp->swallowed_object); + evas_object_data_del(rp->swallowed_object, "\377 edje.swallowing_part"); + if (rp->part->mouse_events) + _edje_callbacks_del(rp->swallowed_object, rp->edje); + + if (rp->part->type == EDJE_PART_TYPE_GROUP || + rp->part->type == EDJE_PART_TYPE_EXTERNAL) + evas_object_del(rp->swallowed_object); + + rp->swallowed_object = NULL; + } + + if (rp->text.text) eina_stringshare_del(rp->text.text); + if (rp->text.font) eina_stringshare_del(rp->text.font); + if (rp->text.cache.in_str) eina_stringshare_del(rp->text.cache.in_str); + if (rp->text.cache.out_str) eina_stringshare_del(rp->text.cache.out_str); + + if (rp->custom) + { + _edje_collection_free_part_description_clean(rp->part->type, rp->custom->description, 0); + if (rp->custom) free(rp->custom->set); + eina_mempool_free(_edje_real_part_state_mp, rp->custom); + rp->custom = NULL; + } + + free(rp->drag); + + if (rp->param2) free(rp->param2->set); + eina_mempool_free(_edje_real_part_state_mp, rp->param2); + + _edje_unref(rp->edje); + eina_mempool_free(_edje_real_part_mp, rp); +} + +static Eina_Bool +_edje_import_font_file(Edje *ed, const char *path, const char *entry) +{ + void *fdata = NULL; + long fsize = 0; + + /* Read font data from file */ + { + FILE *f = fopen(path, "rb"); + if (!f) + { + ERR("Unable to open font file \"%s\"", path); + return EINA_FALSE; + } + + fseek(f, 0, SEEK_END); + fsize = ftell(f); + rewind(f); + fdata = malloc(fsize); + if (!fdata) + { + ERR("Unable to alloc font file \"%s\"", path); + fclose(f); + return EINA_FALSE; + } + if (fread(fdata, fsize, 1, f) != 1) + { + free(fdata); + fclose(f); + ERR("Unable to read all of font file \"%s\"", path); + return EINA_FALSE; + } + fclose(f); + } + + /* Write font to edje file */ + { + /* open the eet file */ + Eet_File *eetf = eet_open(ed->path, EET_FILE_MODE_READ_WRITE); + if (!eetf) + { + ERR("Unable to open \"%s\" for writing output", ed->path); + free(fdata); + return EINA_FALSE; + } + + if (eet_write(eetf, entry, fdata, fsize, 1) <= 0) + { + ERR("Unable to write font part \"%s\" as \"%s\" part entry", + path, entry); + eet_close(eetf); + free(fdata); + return EINA_FALSE; + } + + free(fdata); + + /* write the edje_file */ + if (!_edje_edit_edje_file_save(eetf, ed->file)) + { + eet_delete(eetf, entry); + eet_close(eetf); + return EINA_FALSE; + } + + eet_close(eetf); + } + + return EINA_TRUE; +} + + +static Eina_Bool +_edje_import_image_file(Edje *ed, const char *path, int id) +{ + char entry[PATH_MAX]; + Evas_Object *im; + Eet_File *eetf; + void *im_data; + int im_w, im_h; + int im_alpha; + int bytes; + + /* Try to load the file */ + im = evas_object_image_add(ed->base.evas); + if (!im) return EINA_FALSE; + + evas_object_image_file_set(im, path, NULL); + if (evas_object_image_load_error_get(im) != EVAS_LOAD_ERROR_NONE) + { + ERR("Edje_Edit: unable to load image \"%s\"." + "Missing PNG or JPEG loader modules for Evas or " + "file does not exist, or is not readable.", path); + evas_object_del(im); + im = NULL; + return EINA_FALSE; + } + + /* Write the loaded image to the edje file */ + + evas_object_image_size_get(im, &im_w, &im_h); + im_alpha = evas_object_image_alpha_get(im); + im_data = evas_object_image_data_get(im, 0); + if ((!im_data) || !(im_w > 0) || !(im_h > 0)) + { + evas_object_del(im); + return EINA_FALSE; + } + + /* open the eet file */ + eetf = eet_open(ed->path, EET_FILE_MODE_READ_WRITE); + if (!eetf) + { + ERR("Unable to open \"%s\" for writing output", ed->path); + evas_object_del(im); + return EINA_FALSE; + } + + snprintf(entry, sizeof(entry), "edje/images/%i", id); + + /* write the image data */ + bytes = eet_data_image_write(eetf, entry, + im_data, im_w, im_h, + im_alpha, + 0, 100, 1); + if (bytes <= 0) + { + ERR("Unable to write image part \"%s\" part entry to %s", + entry, ed->path); + eet_close(eetf); + evas_object_del(im); + return EINA_FALSE; + } + + evas_object_del(im); + + /* write the edje_file */ + if (!_edje_edit_edje_file_save(eetf, ed->file)) + { + eet_delete(eetf, entry); + eet_close(eetf); + return EINA_FALSE; + } + + eet_close(eetf); + return EINA_TRUE; +} + +static int +_edje_part_id_find(Edje *ed, const char *part) +{ + unsigned int id; + + for (id = 0; id < ed->table_parts_size; id++) + { + Edje_Real_Part *rp = ed->table_parts[id]; + + if (!strcmp(rp->part->name, part)) + return id; + } + return -1; +} + +static void +_edje_part_description_id_set(int type, Edje_Part_Description_Common *c, int old_id, int new_id) +{ + if (c->rel1.id_x == old_id) c->rel1.id_x = new_id; + if (c->rel1.id_y == old_id) c->rel1.id_y = new_id; + if (c->rel2.id_x == old_id) c->rel2.id_x = new_id; + if (c->rel2.id_y == old_id) c->rel2.id_y = new_id; + + if (type == EDJE_PART_TYPE_TEXT + || type == EDJE_PART_TYPE_TEXTBLOCK) + { + Edje_Part_Description_Text *t; + + t = (Edje_Part_Description_Text *) c; + + if (t->text.id_source == old_id) t->text.id_source = new_id; + if (t->text.id_text_source == old_id) t->text.id_text_source = new_id; + } +} + +static void +_edje_part_program_id_set(Edje_Program *epr, int old_id, int new_id) +{ + Edje_Program_Target *pt; + Eina_List *ll, *l_next; + + if (epr->action != EDJE_ACTION_TYPE_STATE_SET) + return; + + EINA_LIST_FOREACH_SAFE(epr->targets, ll, l_next, pt) + { + if (pt->id == old_id) + { + if (new_id == -1) + epr->targets = eina_list_remove_list(epr->targets, ll); + else + pt->id = new_id; + } + } +} + +static void +_edje_part_id_set(Edje *ed, Edje_Real_Part *rp, int new_id) +{ + /* This function change the id of a given real_part. + * All the depedency will be updated too. + * Also the table_parts is updated, and the current *rp in the table + * is lost. + * If new Id = -1 then all the depencies will be deleted + */ + Edje_Part *part; + unsigned int j; + int old_id; + + part = rp->part; + + if (!part) return; + //printf("CHANGE ID OF PART %s TO %d\n", part->name, new_id); + + if (!ed || new_id < -1) return; + + if (part->id == new_id) return; + + old_id = part->id; + part->id = new_id; + + /* Fix all the dependecies in all parts... */ + for (j = 0; j < ed->collection->parts_count; ++j) + { + Edje_Part *p; + unsigned int k; + + p = ed->collection->parts[j]; + + //printf(" search id: %d in %s\n", old_id, p->name); + if (p->clip_to_id == old_id) p->clip_to_id = new_id; + if (p->dragable.confine_id == old_id) p->dragable.confine_id = new_id; + + /* ...in default description */ + _edje_part_description_id_set(p->type, p->default_desc, old_id, new_id); + + /* ...and in all other descriptions */ + for (k = 0; k < p->other.desc_count; ++k) + _edje_part_description_id_set(p->type, p->other.desc[k], old_id, new_id); + } + + /*...and also in programs targets */ +#define EDJE_EDIT_PROGRAM_ID_SET(Array, Ed, It, Old, New) \ + for (It = 0; It < Ed->collection->programs.Array##_count; ++It) \ + _edje_part_program_id_set(Ed->collection->programs.Array[It], Old, New); + + EDJE_EDIT_PROGRAM_ID_SET(fnmatch, ed, j, old_id, new_id); + EDJE_EDIT_PROGRAM_ID_SET(strcmp, ed, j, old_id, new_id); + EDJE_EDIT_PROGRAM_ID_SET(strncmp, ed, j, old_id, new_id); + EDJE_EDIT_PROGRAM_ID_SET(strrncmp, ed, j, old_id, new_id); + EDJE_EDIT_PROGRAM_ID_SET(nocmp, ed, j, old_id, new_id); + + /* Adjust table_parts */ + if (new_id >= 0) + ed->table_parts[new_id] = rp; +} + +static void +_edje_part_description_id_switch(int type, Edje_Part_Description_Common *c, int id1, int id2) +{ + if (c->rel1.id_x == id1) c->rel1.id_x = id2; + else if (c->rel1.id_x == id2) c->rel1.id_x = id1; + if (c->rel1.id_y == id1) c->rel1.id_y = id2; + else if (c->rel1.id_y == id2) c->rel1.id_y = id1; + if (c->rel2.id_x == id1) c->rel2.id_x = id2; + else if (c->rel2.id_x == id2) c->rel2.id_x = id1; + if (c->rel2.id_y == id1) c->rel2.id_y = id2; + else if (c->rel2.id_y == id2) c->rel2.id_y = id1; + + if (type == EDJE_PART_TYPE_TEXT + || type == EDJE_PART_TYPE_TEXTBLOCK) + { + Edje_Part_Description_Text *t; + + t = (Edje_Part_Description_Text *) c; + + if (t->text.id_source == id1) t->text.id_source = id2; + else if (t->text.id_source == id2) t->text.id_source = id1; + if (t->text.id_text_source == id1) t->text.id_text_source = id2; + else if (t->text.id_text_source == id2) t->text.id_text_source = id2; + } +} + +static void +_edje_part_program_id_switch(Edje_Program *epr, int id1, int id2) +{ + Edje_Program_Target *pt; + Eina_List *ll; + + if (epr->action != EDJE_ACTION_TYPE_STATE_SET) + return; + + EINA_LIST_FOREACH(epr->targets, ll, pt) + { + if (pt->id == id1) pt->id = id2; + else if (pt->id == id2) pt->id = id1; + } +} + +static void +_edje_parts_id_switch(Edje *ed, Edje_Real_Part *rp1, Edje_Real_Part *rp2) +{ + /* This function switch the id of two parts. + * All the depedency will be updated too. + * Also the table_parts is updated, + * The parts list isn't touched + */ + int id1; + int id2; + unsigned int i; + + //printf("SWITCH ID OF PART %d AND %d\n", rp1->part->id, rp2->part->id); + + if (!ed || !rp1 || !rp2) return; + if (rp1 == rp2) return; + + id1 = rp1->part->id; + id2 = rp2->part->id; + + /* Switch ids */ + rp1->part->id = id2; + rp2->part->id = id1; + + /* adjust table_parts */ + ed->table_parts[id1] = rp2; + ed->table_parts[id2] = rp1; + + // Fix all the dependecies in all parts... + for (i = 0; i < ed->collection->parts_count; ++i) + { + unsigned int j; + Edje_Part *p; + + p = ed->collection->parts[i]; + + //printf(" search id: %d in %s\n", old_id, p->name); + if (p->clip_to_id == id1) p->clip_to_id = id2; + else if (p->clip_to_id == id2) p->clip_to_id = id1; + if (p->dragable.confine_id == id1) p->dragable.confine_id = id2; + else if (p->dragable.confine_id == id2) p->dragable.confine_id = id1; + + // ...in default description + _edje_part_description_id_switch(p->type, p->default_desc, id1, id2); + + // ...and in all other descriptions + for (j = 0; j < p->other.desc_count; ++j) + _edje_part_description_id_switch(p->type, p->other.desc[j], id1, id2); + } + + //...and also in programs targets +#define EDJE_EDIT_PROGRAM_SWITCH(Array, Ed, It, Id1, Id2) \ + for (It = 0; It < Ed->collection->programs.Array##_count; ++It) \ + _edje_part_program_id_switch(Ed->collection->programs.Array[i], Id1, Id2); + + EDJE_EDIT_PROGRAM_SWITCH(fnmatch, ed, i, id1, id2); + EDJE_EDIT_PROGRAM_SWITCH(strcmp, ed, i, id1, id2); + EDJE_EDIT_PROGRAM_SWITCH(strncmp, ed, i, id1, id2); + EDJE_EDIT_PROGRAM_SWITCH(strrncmp, ed, i, id1, id2); + EDJE_EDIT_PROGRAM_SWITCH(nocmp, ed, i, id1, id2); + //TODO Real part dependencies are ok? +} + +static void +_edje_fix_parts_id(Edje *ed) +{ + /* We use this to clear the id hole leaved when a part is removed. + * After the execution of this function all parts will have a right + * (uniqe & ordered) id. The table_parts is also updated. + */ + unsigned int i; + int correct_id; + unsigned int count; + + //printf("FIXING PARTS ID \n"); + + //TODO order the list first to be more robust + + /* Give a correct id to all the parts */ + correct_id = 0; + for (i = 0; i < ed->collection->parts_count; ++i) + { + Edje_Part *p; + + p = ed->collection->parts[i]; + + //printf(" [%d]Checking part: %s id: %d\n", correct_id, p->name, p->id); + if (p->id != correct_id) + if (ed->table_parts[p->id]) + _edje_part_id_set(ed, ed->table_parts[p->id], correct_id); + + correct_id++; + } + + /* If we have removed some parts realloc table_parts */ + count = ed->collection->parts_count; + if (count != ed->table_parts_size) + { + ed->table_parts = realloc(ed->table_parts, sizeof(Edje_Real_Part *) * count); + ed->table_parts_size = count; + } + + //printf("\n"); +} + +static void +_edje_if_string_free(Edje *ed, const char *str) +{ + Eet_Dictionary *dict; + + if (!ed || !str) return; + + dict = eet_dictionary_get(ed->file->ef); + if (eet_dictionary_string_check(dict, str)) return; + eina_stringshare_del(str); + str = NULL; +} + +static Edje_Style * +_edje_edit_style_get(Edje *ed, const char *name) +{ + Eina_List *l; + Edje_Style *s; + + if (!ed || !ed->file || !ed->file->styles || !name) + return NULL; + + EINA_LIST_FOREACH(ed->file->styles, l, s) + if (s->name && !strcmp(s->name, name)) + return s; + + return NULL; +} + +static Edje_Style_Tag * +_edje_edit_style_tag_get(Edje *ed, const char *style, const char *name) +{ + Eina_List *l; + Edje_Style *s; + Edje_Style_Tag *t; + + if (!ed || !ed->file || !ed->file->styles || !name) + return NULL; + + s = _edje_edit_style_get(ed, style); + + EINA_LIST_FOREACH(s->tags, l, t) + if (t->key && !strcmp(t->key, name)) + return t; + + return NULL; +} + +static Edje_External_Directory_Entry * +_edje_edit_external_get(Edje *ed, const char *name) +{ + unsigned int i; + + if (!ed || !ed->file || !ed->file->external_dir || !name) + return NULL; + + for (i = 0; i < ed->file->external_dir->entries_count; ++i) + if (ed->file->external_dir->entries[i].entry + && !strcmp(ed->file->external_dir->entries[i].entry, name)) + return ed->file->external_dir->entries + i; + + return NULL; +} + +static void +_edje_edit_group_references_update(Evas_Object *obj, const char *old_group_name, const char *new_group_name) +{ + Eina_Iterator *i; + Eina_List *pll, *pl; +// Edje_Part_Collection *pc; + Edje_Part_Collection_Directory_Entry *pce; + char *part_name; + const char *source, *old; + Edje_Part_Type type; + Evas_Object *part_obj; + + GET_ED_OR_RETURN(); + +// pc = ed->collection; + + part_obj = edje_edit_object_add(ed->base.evas); + + old = eina_stringshare_add(old_group_name); + + i = eina_hash_iterator_data_new(ed->file->collection); + + EINA_ITERATOR_FOREACH(i, pce) + { + edje_object_file_set(part_obj, ed->file->path, pce->entry); + + pl = edje_edit_parts_list_get(part_obj); + + EINA_LIST_FOREACH(pl, pll, part_name) + { + source = edje_edit_part_source_get(part_obj, part_name); + type = edje_edit_part_type_get(part_obj, part_name); + + if (type == EDJE_PART_TYPE_GROUP && source == old) + edje_edit_part_source_set(part_obj, part_name, new_group_name); + + if (source) + eina_stringshare_del(source); + } + } + + eina_iterator_free(i); + + eina_stringshare_del(old); + + evas_object_del(part_obj); +} + +static void +_edje_edit_flag_script_dirty(Edje_Edit *eed, Eina_Bool all) +{ + eed->script_need_recompile = EINA_TRUE; + if (all) + eed->all_dirty = EINA_TRUE; +} + +/*****************/ +/* GENERAL API */ +/*****************/ + +EAPI void +edje_edit_string_list_free(Eina_List *lst) +{ + eina_error_set(0); + //printf("FREE LIST: \n"); + while (lst) + { + if (eina_list_data_get(lst)) eina_stringshare_del(eina_list_data_get(lst)); + //printf("FREE: %s\n", eina_list_data_get(lst)); + lst = eina_list_remove(lst, eina_list_data_get(lst)); + } +} + +EAPI void +edje_edit_string_free(const char *str) +{ + eina_error_set(0); + + if (str) eina_stringshare_del(str); +} + +EAPI const char* +edje_edit_compiler_get(Evas_Object *obj) +{ + eina_error_set(0); + + GET_ED_OR_RETURN(0); + return eina_stringshare_add(ed->file->compiler); +} + +/****************/ +/* GROUPS API */ +/****************/ + +EAPI Eina_Bool +edje_edit_group_add(Evas_Object *obj, const char *name) +{ + Edje_Part_Collection_Directory_Entry *de; + Edje_Part_Collection_Directory_Entry *d; + Edje_Part_Collection *pc; + int id; + int search; + //Code *cd; + + eina_error_set(0); + + GET_ED_OR_RETURN(EINA_FALSE); + + //printf("ADD GROUP: %s \n", name); + + /* check if a group with the same name already exists */ + if (eina_hash_find(ed->file->collection, name)) + return EINA_FALSE; + + /* Create structs */ + de = _alloc(sizeof(Edje_Part_Collection_Directory_Entry)); + if (!de) return EINA_FALSE; + + pc = _alloc(sizeof(Edje_Part_Collection)); + if (!pc) + { + free(de); + return EINA_FALSE; + } + + /* Search first free id */ + id = -1; + search = 0; + while (id == -1) + { + Eina_Iterator *i; + Eina_Bool found = 0; + + i = eina_hash_iterator_data_new(ed->file->collection); + + EINA_ITERATOR_FOREACH(i, d) + { + // printf("search if %d is free [id %d]\n", search, d->id); + if (search == d->id) + { + found = 1; + break; + } + } + + eina_iterator_free(i); + + if (!found) id = search; + else search++; + } + + /* Init Edje_Part_Collection_Directory_Entry */ + //printf(" new id: %d\n", id); + de->id = id; + de->entry = eina_stringshare_add(name); + eina_hash_direct_add(ed->file->collection, de->entry, de); + + /* Init Edje_Part_Collection */ + pc->id = id; + pc->references = 0; + memset(&pc->programs, 0, sizeof (pc->programs)); + pc->parts = NULL; + pc->data = NULL; + pc->script = NULL; + pc->part = eina_stringshare_add(name); + + //cd = _alloc(sizeof(Code)); + //codes = eina_list_append(codes, cd); +#define EDIT_EMN(Tp, Sz, Ce) \ + Ce->mp.Tp = eina_mempool_add("chained_mempool", #Tp, NULL, sizeof (Sz), 10); + + EDIT_EMN(RECTANGLE, Edje_Part_Description_Common, de); + EDIT_EMN(TEXT, Edje_Part_Description_Text, de); + EDIT_EMN(IMAGE, Edje_Part_Description_Image, de); + EDIT_EMN(SWALLOW, Edje_Part_Description_Common, de); + EDIT_EMN(TEXTBLOCK, Edje_Part_Description_Text, de); + EDIT_EMN(GROUP, Edje_Part_Description_Common, de); + EDIT_EMN(BOX, Edje_Part_Description_Box, de); + EDIT_EMN(TABLE, Edje_Part_Description_Table, de); + EDIT_EMN(EXTERNAL, Edje_Part_Description_External, de); + EDIT_EMN(part, Edje_Part, de); + + ed->file->collection_cache = eina_list_prepend(ed->file->collection_cache, pc); + _edje_cache_coll_clean(ed->file); + + return EINA_TRUE; +} + +EAPI Eina_Bool +edje_edit_group_del(Evas_Object *obj, const char *group_name) +{ + Edje_Part_Collection_Directory_Entry *e; + Edje_Part_Collection *die = NULL; + Edje_Part_Collection *g; + Eina_List *l; + Eet_File *eetf; + char buf[64], **keys; + int count; + + eina_error_set(0); + + GET_ED_OR_RETURN(EINA_FALSE); + + /* if (eina_hash_find(ed->file->collection_hash, group_name)) */ + /* return EINA_FALSE; */ + + if (strcmp(ed->group, group_name) == 0) + { + eina_error_set(EDJE_EDIT_ERROR_GROUP_CURRENTLY_USED); + return EINA_FALSE; + } + + e = eina_hash_find(ed->file->collection, group_name); + if (!e) + { + eina_error_set(EDJE_EDIT_ERROR_GROUP_DOES_NOT_EXIST); + return EINA_FALSE; + } + + if (e->id == ed->collection->id) + { + eina_error_set(EDJE_EDIT_ERROR_GROUP_CURRENTLY_USED); + return EINA_FALSE; + } + + if (e->ref) + { + eina_error_set(EDJE_EDIT_ERROR_GROUP_REFERENCED); + return EINA_FALSE; + } + + _edje_edit_group_references_update(obj, group_name, NULL); + + EINA_LIST_FOREACH(ed->file->collection_cache, l, g) + if (g->id == e->id) + { + ed->file->collection_cache = + eina_list_remove_list(ed->file->collection_cache, l); + die = g; + break; + } + + /* Remove collection/id from eet file */ + eetf = eet_open(ed->file->path, EET_FILE_MODE_READ_WRITE); + if (!eetf) + { + ERR("Edje_Edit: Error. unable to open \"%s\" " + "for writing output", ed->file->path); + return EINA_FALSE; + } + snprintf(buf, sizeof(buf), "edje/collections/%d", e->id); + eet_delete(eetf, buf); + snprintf(buf, sizeof(buf), "edje/scripts/embryo/compiled/%d", e->id); + eet_delete(eetf, buf); + snprintf(buf, sizeof(buf), "edje/scripts/embryo/source/%d", e->id); + eet_delete(eetf, buf); + snprintf(buf, sizeof(buf), "edje/scripts/embryo/source/%d/*", e->id); + keys = eet_list(eetf, buf, &count); + if (keys) + { + do + { + count--; + eet_delete(eetf, keys[count]); + } + while(count); + free(keys); + } + eet_close(eetf); + + /* Free Group */ + if (die) _edje_collection_free(ed->file, die, e); + eina_hash_del(ed->file->collection, group_name, e); + + /* we need to save everything to make sure the file won't have broken + * references the next time is loaded */ + edje_edit_save_all(obj); + + return EINA_TRUE; +} + +EAPI Eina_Bool +edje_edit_group_exist(Evas_Object *obj, const char *group) +{ + eina_error_set(0); + + GET_ED_OR_RETURN(EINA_FALSE); + + if (eina_hash_find(ed->file->collection, group)) + return EINA_TRUE; + return EINA_FALSE; +} + +EAPI Eina_Bool +edje_edit_group_name_set(Evas_Object *obj, const char *new_name) +{ + Edje_Part_Collection_Directory_Entry *pce; + Edje_Part_Collection *pc; + + eina_error_set(0); + + GET_ED_OR_RETURN(EINA_FALSE); + + if (!new_name) return EINA_FALSE; + + pc = ed->collection; + + if (!strcmp(pc->part, new_name)) return EINA_TRUE; + + if (edje_edit_group_exist(obj, new_name)) return EINA_FALSE; + + _edje_edit_group_references_update(obj, pc->part, new_name); + + //printf("Set name of current group: %s [id: %d][new name: %s]\n", + // pc->part, pc->id, new_name); + + //if (pc->part && ed->file->free_strings) eina_stringshare_del(pc->part); TODO FIXME + pce = eina_hash_find(ed->file->collection, pc->part); + + eina_hash_move(ed->file->collection, pce->entry, new_name); + + pce->entry = eina_stringshare_add(new_name); + pc->part = pce->entry; + eina_stringshare_replace(&ed->group, new_name); + + return EINA_TRUE; +} + +#define FUNC_GROUP_ACCESSOR(Class, Value) \ + EAPI int \ + edje_edit_group_##Class##_##Value##_get(Evas_Object *obj) \ + { \ + eina_error_set(0); \ + GET_ED_OR_RETURN(-1); \ + if (!ed->collection) return -1; \ + return ed->collection->prop.Class.Value; \ + } \ + EAPI void \ + edje_edit_group_##Class##_##Value##_set(Evas_Object *obj, int v) \ + { \ + eina_error_set(0); \ + GET_ED_OR_RETURN(); \ + ed->collection->prop.Class.Value = v; \ + } + +FUNC_GROUP_ACCESSOR(min, w); +FUNC_GROUP_ACCESSOR(min, h); +FUNC_GROUP_ACCESSOR(max, w); +FUNC_GROUP_ACCESSOR(max, h); + +/***************/ +/* DATA API */ +/***************/ + +EAPI Eina_List * +edje_edit_group_data_list_get(Evas_Object * obj) +{ + Eina_Iterator *it; + Eina_List *datas = NULL; + const char *key; + + eina_error_set(0); + + GET_ED_OR_RETURN(NULL); + + if (!ed->file || !ed->collection || !ed->collection->data) + return NULL; + + it = eina_hash_iterator_key_new(ed->collection->data); + if (!it) return NULL; + + EINA_ITERATOR_FOREACH(it, key) + datas = eina_list_append(datas, eina_stringshare_add(key)); + + eina_iterator_free(it); + + return datas; +} + +EAPI Eina_List * +edje_edit_data_list_get(Evas_Object * obj) +{ + Eina_Iterator *i; + Eina_List *datas = NULL; + const char *key; + + eina_error_set(0); + + GET_ED_OR_RETURN(NULL); + + if (!ed->file || !ed->file->data) + return NULL; + + i = eina_hash_iterator_key_new(ed->file->data); + + EINA_ITERATOR_FOREACH(i, key) + datas = eina_list_append(datas, eina_stringshare_add(key)); + + eina_iterator_free(i); + + return datas; +} + +EAPI Eina_Bool +edje_edit_group_data_add(Evas_Object *obj, const char *key, const char *value) +{ + Edje_String *es; + + eina_error_set(0); + + GET_ED_OR_RETURN(EINA_FALSE); + + if (!key || !ed->file || !ed->collection) + return EINA_FALSE; + + if (!ed->collection->data) + ed->collection->data = eina_hash_string_small_new(NULL); + + if (eina_hash_find(ed->collection->data, key)) + return EINA_FALSE; + + es = calloc(1, sizeof(Edje_String)); + if (!es) + return EINA_FALSE; + es->str = eina_stringshare_add(value); + + if (!eina_hash_add(ed->collection->data, key, es)) + { + eina_stringshare_del(es->str); + free(es); + return EINA_FALSE; + } + return EINA_TRUE; +} + +EAPI Eina_Bool +edje_edit_data_add(Evas_Object *obj, const char *itemname, const char *value) +{ + Edje_String *es; + + eina_error_set(0); + + GET_ED_OR_RETURN(EINA_FALSE); + + if (!itemname || !ed->file) + return EINA_FALSE; + + if (eina_hash_find(ed->file->data, itemname)) + return EINA_FALSE; + + es = calloc(1, sizeof(Edje_String)); + if (!es) + return EINA_FALSE; + es->str = eina_stringshare_add(value); + + if (!eina_hash_add(ed->file->data, itemname, es)) + { + eina_stringshare_del(es->str); + free(es); + return EINA_FALSE; + } + return EINA_TRUE; +} + +EAPI Eina_Bool +edje_edit_group_data_del(Evas_Object *obj, const char *key) +{ + Edje_String *value; + + eina_error_set(0); + + GET_ED_OR_RETURN(EINA_FALSE); + + if (!key || !ed->file || !ed->collection) + return EINA_FALSE; + + value = eina_hash_find(ed->collection->data, key); + if (!value) return EINA_FALSE; + + eina_hash_del(ed->collection->data, key, value); + _edje_if_string_free(ed, value->str); + free(value); + + return EINA_TRUE; +} + +EAPI Eina_Bool +edje_edit_data_del(Evas_Object *obj, const char *itemname) +{ + Edje_String *value; + + eina_error_set(0); + + GET_ED_OR_RETURN(EINA_FALSE); + + if (!itemname || !ed->file || !ed->file->data) + return 0; + + value = eina_hash_find(ed->file->data, itemname); + if (!value) + return EINA_FALSE; + + eina_hash_del(ed->file->data, itemname, value); + _edje_if_string_free(ed, value->str); + free(value); + + return EINA_TRUE; +} + +EAPI const char * +edje_edit_group_data_value_get(Evas_Object * obj, const char *key) +{ + Edje_String *value; + + eina_error_set(0); + + GET_ED_OR_RETURN(NULL); + + if (!key || !ed->file || !ed->collection) + return NULL; + + value = eina_hash_find(ed->collection->data, key); + if (!value) + return NULL; + + return eina_stringshare_add(edje_string_get(value)); +} + +EAPI const char * +edje_edit_data_value_get(Evas_Object * obj, const char *itemname) +{ + Edje_String *value; + + eina_error_set(0); + + GET_ED_OR_RETURN(NULL); + + if (!itemname || !ed->file || !ed->file->data) + return NULL; + + value = eina_hash_find(ed->file->data, itemname); + if (!value) + return NULL; + + return eina_stringshare_add(edje_string_get(value)); +} + +EAPI Eina_Bool +edje_edit_group_data_value_set(Evas_Object *obj, const char *key, const char *value) +{ + Edje_String *es; + + eina_error_set(0); + + GET_ED_OR_RETURN(EINA_FALSE); + + if (!key || !value || !ed->file || !ed->collection) + return EINA_FALSE; + + es = eina_hash_find(ed->collection->data, key); + if (es) + { + _edje_if_string_free(ed, es->str); + es->str = eina_stringshare_add(value); + es->id = 0; + return EINA_TRUE; + } + + return EINA_FALSE; +} + +EAPI Eina_Bool +edje_edit_data_value_set(Evas_Object *obj, const char *itemname, const char *value) +{ + Edje_String *es; + + eina_error_set(0); + + GET_ED_OR_RETURN(EINA_FALSE); + + if (!itemname || !value || !ed->file || !ed->file->data) + return EINA_FALSE; + + es = eina_hash_find(ed->file->data, itemname); + if (es) + { + _edje_if_string_free(ed, es->str); + es->str = eina_stringshare_add(value); + es->id = 0; + return EINA_TRUE; + } + return EINA_FALSE; +} + +EAPI Eina_Bool +edje_edit_group_data_name_set(Evas_Object *obj, const char *key, const char *new_key) +{ + + eina_error_set(0); + + GET_ED_OR_RETURN(EINA_FALSE); + + if (!key || !new_key || !ed->file || !ed->collection) { + return EINA_FALSE; + } + + return eina_hash_move(ed->collection->data, key, new_key); +} + +EAPI Eina_Bool +edje_edit_data_name_set(Evas_Object *obj, const char *itemname, const char *newname) +{ + + eina_error_set(0); + + GET_ED_OR_RETURN(EINA_FALSE); + + if (!itemname || !newname || !ed->file || !ed->file->data) + return EINA_FALSE; + + return eina_hash_move(ed->file->data, itemname, newname); +} + +/***********************/ +/* COLOR CLASSES API */ +/***********************/ + +EAPI Eina_List * +edje_edit_color_classes_list_get(Evas_Object * obj) +{ + Eina_List *classes = NULL; + Eina_List *l; + Edje_Color_Class *cc; + + eina_error_set(0); + + GET_ED_OR_RETURN(NULL); + + if (!ed->file || !ed->file->color_classes) + return NULL; + //printf("GET CLASSES LIST %d %d\n", eina_list_count(ed->color_classes), eina_list_count(ed->file->color_classes)); + EINA_LIST_FOREACH(ed->file->color_classes, l, cc) + classes = eina_list_append(classes, eina_stringshare_add(cc->name)); + + return classes; +} + +EAPI 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) +{ + Eina_List *l; + Edje_Color_Class *cc; + + eina_error_set(0); + + GET_ED_OR_RETURN(EINA_FALSE); + + if (!ed->file || !ed->file->color_classes) + return EINA_FALSE; + + EINA_LIST_FOREACH(ed->file->color_classes, l, cc) + if (!strcmp(cc->name, class_name)) + { + if (r) *r = cc->r; + if (g) *g = cc->g; + if (b) *b = cc->b; + if (a) *a = cc->a; + + if (r2) *r2 = cc->r2; + if (g2) *g2 = cc->g2; + if (b2) *b2 = cc->b2; + if (a2) *a2 = cc->a2; + + if (r3) *r3 = cc->r3; + if (g3) *g3 = cc->g3; + if (b3) *b3 = cc->b3; + if (a3) *a3 = cc->a3; + + return EINA_TRUE; + } + return EINA_FALSE; +} + +EAPI 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) +{ + Eina_List *l; + Edje_Color_Class *cc; + + eina_error_set(0); + + GET_ED_OR_RETURN(EINA_FALSE); + + if (!ed->file || !ed->file->color_classes) + return EINA_FALSE; + + EINA_LIST_FOREACH(ed->file->color_classes, l, cc) + if (!strcmp(cc->name, class_name)) + { + if (r > -1) cc->r = r; + if (g > -1) cc->g = g; + if (b > -1) cc->b = b; + if (a > -1) cc->a = a; + + if (r2 > -1) cc->r2 = r2; + if (g2 > -1) cc->g2 = g2; + if (b2 > -1) cc->b2 = b2; + if (a2 > -1) cc->a2 = a2; + + if (r3 > -1) cc->r3 = r3; + if (g3 > -1) cc->g3 = g3; + if (b3 > -1) cc->b3 = b3; + if (a3 > -1) cc->a3 = a3; + + return EINA_TRUE; + } + return EINA_FALSE; +} + +EAPI Eina_Bool +edje_edit_color_class_add(Evas_Object *obj, const char *name) +{ + Eina_List *l; + Edje_Color_Class *c; + Edje_Color_Class *cc; + + eina_error_set(0); + + GET_ED_OR_RETURN(EINA_FALSE); + + if (!name || !ed->file) + return EINA_FALSE; + + EINA_LIST_FOREACH(ed->file->color_classes, l, cc) + if (strcmp(cc->name, name) == 0) + return EINA_FALSE; + + c = _alloc(sizeof(Edje_Color_Class)); + if (!c) return EINA_FALSE; + + c->name = (char*)eina_stringshare_add(name); + c->r = c->g = c->b = c->a = 255; + c->r2 = c->g2 = c->b2 = c->a2 = 255; + c->r3 = c->g3 = c->b3 = c->a3 = 255; + + ed->file->color_classes = eina_list_append(ed->file->color_classes, c); + + return EINA_TRUE; +} + +EAPI Eina_Bool +edje_edit_color_class_del(Evas_Object *obj, const char *name) +{ + Eina_List *l; + Edje_Color_Class *cc; + + eina_error_set(0); + + GET_ED_OR_RETURN(EINA_FALSE); + + if (!name || !ed->file || !ed->file->color_classes) + return EINA_FALSE; + + EINA_LIST_FOREACH(ed->file->color_classes, l, cc) + if (strcmp(cc->name, name) == 0) + { + _edje_if_string_free(ed, cc->name); + ed->file->color_classes = eina_list_remove(ed->file->color_classes, cc); + free(cc); + return EINA_TRUE; + } + return EINA_FALSE; +} + +EAPI Eina_Bool +edje_edit_color_class_name_set(Evas_Object *obj, const char *name, const char *newname) +{ + Eina_List *l; + Edje_Color_Class *cc; + + eina_error_set(0); + + GET_ED_OR_RETURN(EINA_FALSE); + + if (!ed->file || !ed->file->color_classes) + return EINA_FALSE; + + EINA_LIST_FOREACH(ed->file->color_classes, l, cc) + if (!strcmp(cc->name, name)) + { + _edje_if_string_free(ed, cc->name); + cc->name = (char*)eina_stringshare_add(newname); + return EINA_TRUE; + } + + return EINA_FALSE; +} + + + +/*********************/ +/* TEXT STYLES API */ +/*********************/ + +EAPI Eina_List * +edje_edit_styles_list_get(Evas_Object * obj) +{ + Eina_List *styles = NULL; + Eina_List *l; + Edje_Style *s; + + eina_error_set(0); + + GET_ED_OR_RETURN(NULL); + + if (!ed->file || !ed->file->styles) + return NULL; + //printf("GET STYLES LIST %d\n", eina_list_count(ed->file->styles)); + EINA_LIST_FOREACH(ed->file->styles, l, s) + styles = eina_list_append(styles, eina_stringshare_add(s->name)); + + return styles; +} + +EAPI Eina_Bool +edje_edit_style_add(Evas_Object * obj, const char* style) +{ + Edje_Style *s; + + eina_error_set(0); + + GET_ED_OR_RETURN(EINA_FALSE); + //printf("ADD STYLE '%s'\n", style); + + s = _edje_edit_style_get(ed, style); + if (s) return EINA_FALSE; + + s = _alloc(sizeof(Edje_Style)); + if (!s) return EINA_FALSE; + s->name = (char*)eina_stringshare_add(style); + s->tags = NULL; + s->style = NULL; + + ed->file->styles = eina_list_append(ed->file->styles, s); + return EINA_TRUE; +} + +EAPI void +edje_edit_style_del(Evas_Object * obj, const char* style) +{ + Edje_Style *s; + + eina_error_set(0); + + GET_ED_OR_RETURN(); + //printf("DEL STYLE '%s'\n", style); + + s = _edje_edit_style_get(ed, style); + if (!s) return; + + ed->file->styles = eina_list_remove(ed->file->styles, s); + + _edje_if_string_free(ed, s->name); + //~ //s->style HOWTO FREE ??? + while (s->tags) + { + Edje_Style_Tag *t; + + t = s->tags->data; + + s->tags = eina_list_remove(s->tags, t); + _edje_if_string_free(ed, t->key); + _edje_if_string_free(ed, t->value); + _edje_if_string_free(ed, t->font); + _edje_if_string_free(ed, t->text_class); + free(t); + t = NULL; + } + free(s); + s = NULL; + s = NULL; +} + + +EAPI Eina_List * +edje_edit_style_tags_list_get(Evas_Object * obj, const char* style) +{ + Eina_List *tags = NULL; + Eina_List *l; + Edje_Style *s; + Edje_Style_Tag *t; + + eina_error_set(0); + + GET_ED_OR_RETURN(NULL); + if (!ed->file || !ed->file->styles || !style) + return NULL; + + s = _edje_edit_style_get(ed, style); + + //printf("GET STYLE TAG LIST %d\n", eina_list_count(s->tags)); + EINA_LIST_FOREACH(s->tags, l, t) + tags = eina_list_append(tags, eina_stringshare_add(t->key)); + + return tags; +} + +EAPI void +edje_edit_style_tag_name_set(Evas_Object * obj, const char* style, const char* tag, const char*new_name) +{ + Edje_Style_Tag *t; + + eina_error_set(0); + + GET_ED_OR_RETURN(); + //printf("SET TAG NAME for '%s' FOR STYLE '%s'\n", tag, style); + + if (!ed->file || !ed->file->styles || !style || !tag) + return; + + t = _edje_edit_style_tag_get(ed, style, tag); + if (!t) return; + _edje_if_string_free(ed, t->key); + t->key = eina_stringshare_add(new_name); +} + +EAPI const char* +edje_edit_style_tag_value_get(Evas_Object * obj, const char* style, const char* tag) +{ + Edje_Style_Tag *t; + + eina_error_set(0); + + GET_ED_OR_RETURN(NULL); + //printf("GET TAG '%s' FOR STYLE '%s'\n", tag, style); + + if (!ed->file || !ed->file->styles || !style || !tag) + return NULL; + + t = _edje_edit_style_tag_get(ed, style, tag); + if (t && t->value) + return eina_stringshare_add(t->value); + + return NULL; +} + +EAPI void +edje_edit_style_tag_value_set(Evas_Object * obj, const char* style, const char* tag, const char*new_value) +{ + Edje_Style_Tag *t; + + eina_error_set(0); + + GET_ED_OR_RETURN(); + //printf("SET TAG VALUE for '%s' FOR STYLE '%s'\n", tag, style); + + if (!ed->file || !ed->file->styles || !style || !tag) + return; + + t = _edje_edit_style_tag_get(ed, style, tag); + if (!t) return; + _edje_if_string_free(ed, t->value); + t->value = eina_stringshare_add(new_value); +} + +EAPI Eina_Bool +edje_edit_style_tag_add(Evas_Object * obj, const char* style, const char* tag_name) +{ + Edje_Style *s; + Edje_Style_Tag *t; + + eina_error_set(0); + + GET_ED_OR_RETURN(EINA_FALSE); + //printf("ADD TAG '%s' IN STYLE '%s'\n", tag_name, style); + + t = _edje_edit_style_tag_get(ed, style, tag_name); + if (t) return EINA_FALSE; + s = _edje_edit_style_get(ed, style); + if (!s) return EINA_FALSE; + + t = _alloc(sizeof(Edje_Style_Tag)); + if (!t) return EINA_FALSE; + t->key = eina_stringshare_add(tag_name); + t->value = NULL; + t->font = NULL; + t->text_class = NULL; + + s->tags = eina_list_append(s->tags, t); + return EINA_TRUE; +} + +EAPI void +edje_edit_style_tag_del(Evas_Object * obj, const char* style, const char* tag) +{ + Edje_Style *s; + Edje_Style_Tag *t; + + eina_error_set(0); + + GET_ED_OR_RETURN(); + //printf("DEL TAG '%s' IN STYLE '%s'\n", tag, style); + + s = _edje_edit_style_get(ed, style); + t = _edje_edit_style_tag_get(ed, style, tag); + + s->tags = eina_list_remove(s->tags, t); + _edje_if_string_free(ed, t->key); + _edje_if_string_free(ed, t->value); + _edje_if_string_free(ed, t->font); + _edje_if_string_free(ed, t->text_class); + free(t); + t = NULL; +} + +/*******************/ +/* EXTERNALS API */ +/*******************/ + +EAPI Eina_List * +edje_edit_externals_list_get(Evas_Object *obj) +{ + Eina_List *externals = NULL; + unsigned int i; + + eina_error_set(0); + + GET_ED_OR_RETURN(NULL); + + if (!ed->file || !ed->file->external_dir) + return NULL; + //printf("GET STYLES LIST %d\n", eina_list_count(ed->file->styles)); + for (i = 0; i < ed->file->external_dir->entries_count; ++i) + externals = eina_list_append(externals, + eina_stringshare_add(ed->file->external_dir->entries[i].entry)); + + return externals; +} + +EAPI Eina_Bool +edje_edit_external_add(Evas_Object *obj, const char *external) +{ + Edje_External_Directory_Entry *e; + unsigned int freeid; + unsigned int i; + + eina_error_set(0); + + GET_ED_OR_RETURN(EINA_FALSE); + + e = _edje_edit_external_get(ed, external); + if (e) return EINA_FALSE; + + if (!ed->file->external_dir) + ed->file->external_dir = _alloc(sizeof(Edje_External_Directory)); + + for (i = 0; i < ed->file->external_dir->entries_count; ++i) + if (!ed->file->external_dir->entries[i].entry) + break ; + + if (i == ed->file->external_dir->entries_count) + { + Edje_External_Directory_Entry *tmp; + unsigned int max; + + max = ed->file->external_dir->entries_count + 1; + tmp = realloc(ed->file->external_dir->entries, + sizeof (Edje_External_Directory_Entry) * max); + + if (!tmp) return EINA_FALSE; + + ed->file->external_dir->entries = tmp; + freeid = ed->file->external_dir->entries_count; + ed->file->external_dir->entries_count = max; + } + else + freeid = i; + + ed->file->external_dir->entries[freeid].entry = (char*)eina_stringshare_add(external); + + return EINA_TRUE; +} + +EAPI Eina_Bool +edje_edit_external_del(Evas_Object *obj, const char *external) +{ + Edje_External_Directory_Entry *e; + + eina_error_set(0); + + GET_ED_OR_RETURN(EINA_FALSE); + + e = _edje_edit_external_get(ed, external); + if (!e) return EINA_FALSE; + + _edje_if_string_free(ed, e->entry); + e->entry = NULL; + + return EINA_TRUE; +} + +/***************/ +/* PARTS API */ +/***************/ + +EAPI Eina_List * +edje_edit_parts_list_get(Evas_Object *obj) +{ + Eina_List *parts = NULL; + unsigned int i; + + eina_error_set(0); + + GET_ED_OR_RETURN(NULL); + + //printf("EE: Found %d parts\n", ed->table_parts_size); + + parts = NULL; + for (i = 0; i < ed->table_parts_size; i++) + { + Edje_Real_Part *rp; + + rp = ed->table_parts[i]; + parts = eina_list_append(parts, eina_stringshare_add(rp->part->name)); + } + + return parts; +} + +EAPI Eina_Bool +edje_edit_part_name_set(Evas_Object *obj, const char* part, const char* new_name) +{ + eina_error_set(0); + + GET_RP_OR_RETURN(EINA_FALSE); + + if (!new_name) return EINA_FALSE; + if (!strcmp(part, new_name)) return EINA_TRUE; + if (_edje_real_part_get(ed, new_name)) return EINA_FALSE; + + //printf("Set name of part: %s [new name: %s]\n", part, new_name); + + _edje_if_string_free(ed, rp->part->name); + rp->part->name = (char *)eina_stringshare_add(new_name); + + _edje_edit_flag_script_dirty(eed, EINA_TRUE); + + return EINA_TRUE; +} + +#define FUNC_PART_API_STRING(Value) \ + EAPI const char * \ + edje_edit_part_api_##Value##_get(Evas_Object *obj, const char *part) \ + { \ + eina_error_set(0); \ + GET_RP_OR_RETURN(NULL); \ + return eina_stringshare_add(rp->part->api.Value); \ + } \ + EAPI Eina_Bool \ + edje_edit_part_api_##Value##_set(Evas_Object *obj, const char *part, const char *s) \ + { \ + eina_error_set(0); \ + GET_RP_OR_RETURN(EINA_FALSE); \ + _edje_if_string_free(ed, rp->part->api.Value); \ + rp->part->api.Value = eina_stringshare_add(s); \ + return EINA_TRUE; \ + } + +FUNC_PART_API_STRING(name); +FUNC_PART_API_STRING(description); + +static Eina_Bool +_edje_edit_real_part_add(Evas_Object *obj, const char *name, Edje_Part_Type type, const char *source) +{ + Edje_Part_Collection_Directory_Entry *ce; + Edje_Part_Collection *pc; + Edje_Part **tmp; + Edje_Part *ep; + Edje_Real_Part *rp; + int id; + + GET_ED_OR_RETURN(EINA_FALSE); + + //printf("ADD PART: %s [type: %d]\n", name, type); + + /* Check if part already exists */ + if (_edje_real_part_get(ed, name)) + return EINA_FALSE; + + ce = eina_hash_find(ed->file->collection, ed->group); + + /* Alloc Edje_Part or return */ + ep = eina_mempool_malloc(ce->mp.part, sizeof(Edje_Part)); + if (!ep) return EINA_FALSE; + memset(ep, 0, sizeof(Edje_Part)); + + /* Alloc Edje_Real_Part or return */ + rp = eina_mempool_malloc(_edje_real_part_mp, sizeof(Edje_Real_Part)); + if (!rp) + { + eina_mempool_free(ce->mp.part, ep); + return EINA_FALSE; + } + memset(rp, 0, sizeof(Edje_Real_Part)); + + /* Init Edje_Part */ + pc = ed->collection; + + tmp = realloc(pc->parts, (pc->parts_count + 1) * sizeof (Edje_Part *)); + if (!tmp) + { + eina_mempool_free(ce->mp.part, ep); + eina_mempool_free(_edje_real_part_mp, rp); + return EINA_FALSE; + } + + id = pc->parts_count++; + + pc->parts = tmp; + pc->parts[id] = ep; + + ep->id = id; + ep->type = type; + ep->name = eina_stringshare_add(name); + ep->mouse_events = 1; + ep->repeat_events = 0; + ep->ignore_flags = EVAS_EVENT_FLAG_NONE; + ep->pointer_mode = EVAS_OBJECT_POINTER_MODE_AUTOGRAB; + ep->precise_is_inside = 0; + ep->use_alternate_font_metrics = 0; + ep->clip_to_id = -1; + ep->dragable.confine_id = -1; + ep->dragable.event_id = -1; + if (source) + ep->source = eina_stringshare_add(source); + + ep->default_desc = NULL; + ep->other.desc = NULL; + ep->other.desc_count = 0; + + /* Init Edje_Real_Part */ + rp->edje = ed; + _edje_ref(rp->edje); + rp->part = ep; + + if (ep->type == EDJE_PART_TYPE_RECTANGLE) + rp->object = evas_object_rectangle_add(ed->base.evas); + else if (ep->type == EDJE_PART_TYPE_IMAGE || ep->type == EDJE_PART_TYPE_PROXY) + rp->object = evas_object_image_add(ed->base.evas); + else if (ep->type == EDJE_PART_TYPE_TEXT) + { + _edje_text_part_on_add(ed, rp); + rp->object = evas_object_text_add(ed->base.evas); + evas_object_text_font_source_set(rp->object, ed->path); + } + else if (ep->type == EDJE_PART_TYPE_SWALLOW || + ep->type == EDJE_PART_TYPE_GROUP || + ep->type == EDJE_PART_TYPE_EXTERNAL) + { + rp->object = evas_object_rectangle_add(ed->base.evas); + evas_object_color_set(rp->object, 0, 0, 0, 0); + evas_object_pass_events_set(rp->object, 1); + evas_object_pointer_mode_set(rp->object, EVAS_OBJECT_POINTER_MODE_NOGRAB); + } + else if (ep->type == EDJE_PART_TYPE_TEXTBLOCK) + rp->object = evas_object_textblock_add(ed->base.evas); + else + ERR("wrong part type %i!", ep->type); + if (rp->object) + { + evas_object_show(rp->object); + evas_object_smart_member_add(rp->object, ed->obj); + evas_object_layer_set(rp->object, evas_object_layer_get(ed->obj)); + if (ep->type != EDJE_PART_TYPE_SWALLOW && ep->type != EDJE_PART_TYPE_GROUP) + { + if (ep->mouse_events) + { + _edje_callbacks_add(rp->object, ed, rp); + if (ep->repeat_events) + evas_object_repeat_events_set(rp->object, 1); + + if (ep->pointer_mode != EVAS_OBJECT_POINTER_MODE_AUTOGRAB) + evas_object_pointer_mode_set(rp->object, ep->pointer_mode); + } + else + { + evas_object_pass_events_set(rp->object, 1); + evas_object_pointer_mode_set(rp->object, + EVAS_OBJECT_POINTER_MODE_NOGRAB); + } + if (ep->precise_is_inside) + evas_object_precise_is_inside_set(rp->object, 1); + } + if (ep->type == EDJE_PART_TYPE_EXTERNAL) + { + Evas_Object *child; + child = _edje_external_type_add(source, evas_object_evas_get(ed->obj), ed->obj, NULL, name); + if (child) + _edje_real_part_swallow(rp, child, EINA_TRUE); + } + evas_object_clip_set(rp->object, ed->base.clipper); + evas_object_show(ed->base.clipper); + } + + /* Update table_parts */ + ed->table_parts_size++; + ed->table_parts = realloc(ed->table_parts, + sizeof(Edje_Real_Part *) * ed->table_parts_size); + + ed->table_parts[ep->id % ed->table_parts_size] = rp; + + /* Create default description */ + if (!edje_edit_state_add(obj, name, "default", 0.0)) + { + _edje_if_string_free(ed, ep->name); + if (source) + _edje_if_string_free(ed, ep->source); + eina_mempool_free(ce->mp.part, ep); + eina_mempool_free(_edje_real_part_mp, rp); + return EINA_FALSE; + } + edje_edit_part_selected_state_set(obj, name, "default", 0.0); + + ce->count.part++; + + return EINA_TRUE; +} + +EAPI Eina_Bool +edje_edit_part_add(Evas_Object *obj, const char *name, Edje_Part_Type type) +{ + eina_error_set(0); + + if (type == EDJE_PART_TYPE_EXTERNAL) + return EINA_FALSE; + return _edje_edit_real_part_add(obj, name, type, NULL); +} + +EAPI Eina_Bool +edje_edit_part_external_add(Evas_Object *obj, const char *name, const char *source) +{ + eina_error_set(0); + + if (!source) + return EINA_FALSE; + return _edje_edit_real_part_add(obj, name, EDJE_PART_TYPE_EXTERNAL, source); +} + +EAPI Eina_Bool +edje_edit_part_del(Evas_Object *obj, const char* part) +{ + Edje_Part_Collection_Directory_Entry *ce; + Edje_Part_Collection *pc; + Edje_Part *ep; + unsigned int k; + unsigned int id; + unsigned int i; + + eina_error_set(0); + + GET_RP_OR_RETURN(EINA_FALSE); + + //printf("REMOVE PART: %s\n", part); + + ep = rp->part; + id = ep->id; + + /* Unlik Edje_Real_Parts that link to the removed one */ + for (i = 0; i < ed->table_parts_size; i++) + { + Edje_Real_Part *real; + + if (i == id) continue; //don't check the deleted id + real = ed->table_parts[i]; + + if (real->text.source == rp) real->text.source = NULL; + if (real->text.text_source == rp) real->text.text_source = NULL; + + if (real->param1.rel1_to_x == rp) real->param1.rel1_to_x = NULL; + if (real->param1.rel1_to_y == rp) real->param1.rel1_to_y = NULL; + if (real->param1.rel2_to_x == rp) real->param1.rel2_to_x = NULL; + if (real->param1.rel2_to_y == rp) real->param1.rel2_to_y = NULL; + + if (real->param2) + { + if (real->param2->rel1_to_x == rp) real->param2->rel1_to_x = NULL; + if (real->param2->rel1_to_y == rp) real->param2->rel1_to_y = NULL; + if (real->param2->rel2_to_x == rp) real->param2->rel2_to_x = NULL; + if (real->param2->rel2_to_y == rp) real->param2->rel2_to_y = NULL; + } + + if (real->custom) + { + if (real->custom->rel1_to_x == rp) real->custom->rel1_to_x = NULL; + if (real->custom->rel1_to_y == rp) real->custom->rel1_to_y = NULL; + if (real->custom->rel2_to_x == rp) real->custom->rel2_to_x = NULL; + if (real->custom->rel2_to_y == rp) real->custom->rel2_to_y = NULL; + } + + if (real->clip_to == rp) + { + evas_object_clip_set(real->object, ed->base.clipper); + real->clip_to = NULL; + } + if (real->drag && real->drag->confine_to == rp) + real->drag->confine_to = NULL; + } + + /* Unlink all the parts and descriptions that refer to id */ + _edje_part_id_set(ed, rp, -1); + + /* Remove part from parts list */ + pc = ed->collection; + pc->parts_count--; + if (id < pc->parts_count) /* Forward parts */ + { + int mcount = (pc->parts_count - id) * sizeof(Edje_Part *); + memmove(&pc->parts[id], &pc->parts[id+1], mcount); + } + pc->parts[pc->parts_count] = NULL; + _edje_fix_parts_id(ed); + + /* Free Edje_Part and all descriptions */ + ce = eina_hash_find(ed->file->collection, ed->group); + + _edje_if_string_free(ed, ep->name); + if (ep->default_desc) + { + _edje_collection_free_part_description_free(ep->type, ep->default_desc, ce, 0); + ep->default_desc = NULL; + } + + for (k = 0; k < ep->other.desc_count; ++k) + _edje_collection_free_part_description_free(ep->type, ep->other.desc[k], ce, 0); + + free(ep->other.desc); + eina_mempool_free(ce->mp.part, ep); + + /* Free Edje_Real_Part */ + _edje_real_part_free(rp); + + /* if all parts are gone, hide the clipper */ + if (ed->table_parts_size == 0) + evas_object_hide(ed->base.clipper); + + edje_object_calc_force(obj); + + ce->count.part--; + + _edje_edit_flag_script_dirty(eed, EINA_TRUE); + + return EINA_TRUE; +} + +EAPI Eina_Bool +edje_edit_part_exist(Evas_Object *obj, const char *part) +{ + eina_error_set(0); + + GET_RP_OR_RETURN(EINA_FALSE); + return EINA_TRUE; +} + +EAPI const char* +edje_edit_part_below_get(Evas_Object *obj, const char* part) +{ + Edje_Real_Part *prev; + + eina_error_set(0); + + GET_RP_OR_RETURN(0); + + if (rp->part->id < 1) return NULL; + + prev = ed->table_parts[(rp->part->id - 1) % ed->table_parts_size]; + + return eina_stringshare_add(prev->part->name); +} + +EAPI const char* +edje_edit_part_above_get(Evas_Object *obj, const char* part) +{ + Edje_Real_Part *next; + + eina_error_set(0); + + GET_RP_OR_RETURN(0); + + if ((unsigned int) rp->part->id >= ed->table_parts_size - 1) return 0; + + next = ed->table_parts[(rp->part->id + 1) % ed->table_parts_size]; + + return eina_stringshare_add(next->part->name); +} + +EAPI Eina_Bool +edje_edit_part_restack_below(Evas_Object *obj, const char* part) +{ + Edje_Part_Collection *group; + Edje_Real_Part *prev; + Edje_Part *swap; + + eina_error_set(0); + + GET_RP_OR_RETURN(EINA_FALSE); + + //printf("RESTACK PART: %s BELOW\n", part); + + if (rp->part->id < 1) return EINA_FALSE; + group = ed->collection; + + /* update parts list */ + prev = ed->table_parts[(rp->part->id - 1) % ed->table_parts_size]; + + swap = group->parts[rp->part->id]; + group->parts[rp->part->id] = group->parts[prev->part->id]; + group->parts[prev->part->id] = swap; + + _edje_parts_id_switch(ed, rp, prev); + + evas_object_stack_below(rp->object, prev->object); + if (rp->swallowed_object) + evas_object_stack_above(rp->swallowed_object, rp->object); + + _edje_edit_flag_script_dirty(eed, EINA_TRUE); + + return EINA_TRUE; +} + +EAPI Eina_Bool +edje_edit_part_restack_above(Evas_Object *obj, const char* part) +{ + Edje_Part_Collection *group; + Edje_Real_Part *next; + Edje_Part *swap; + + eina_error_set(0); + + GET_RP_OR_RETURN(EINA_FALSE); + + //printf("RESTACK PART: %s ABOVE\n", part); + + if ((unsigned int) rp->part->id >= ed->table_parts_size - 1) return EINA_FALSE; + + group = ed->collection; + + /* update parts list */ + next = ed->table_parts[(rp->part->id + 1) % ed->table_parts_size]; + + swap = group->parts[rp->part->id]; + group->parts[rp->part->id] = group->parts[next->part->id]; + group->parts[next->part->id] = swap; + + /* update ids */ + _edje_parts_id_switch(ed, rp, next); + + evas_object_stack_above(rp->object, next->object); + if (rp->swallowed_object) + evas_object_stack_above(rp->swallowed_object, rp->object); + + _edje_edit_flag_script_dirty(eed, EINA_TRUE); + + return EINA_TRUE; +} + +EAPI Edje_Part_Type +edje_edit_part_type_get(Evas_Object *obj, const char *part) +{ + + eina_error_set(0); + + GET_RP_OR_RETURN(0); + + return rp->part->type; +} + +EAPI const char * +edje_edit_part_selected_state_get(Evas_Object *obj, const char *part, double *value) +{ + eina_error_set(0); + + GET_RP_OR_RETURN(NULL); + + if (!rp->chosen_description) + { + if (value) *value = 0.0; // FIXME: Make sure edje_edit supports correctly the default having any value + return eina_stringshare_add("default"); + } + + if (value) *value = rp->chosen_description->state.value; + return eina_stringshare_add(rp->chosen_description->state.name); +} + +EAPI Eina_Bool +edje_edit_part_selected_state_set(Evas_Object *obj, const char *part, const char *state, double value) +{ + Edje_Part_Description_Common *pd; + + eina_error_set(0); + + GET_RP_OR_RETURN(EINA_FALSE); + + pd = _edje_part_description_find_byname(eed, part, state, value); + if (!pd) return EINA_FALSE; + + //printf("EDJE: Set state: %s %f\n", pd->state.name, pd->state.value); + _edje_part_description_apply(ed, rp, pd->state.name, pd->state.value, NULL, 0.0); + + edje_object_calc_force(obj); + return EINA_TRUE; +} + +EAPI const char * +edje_edit_part_clip_to_get(Evas_Object *obj, const char *part) +{ + Edje_Real_Part *clip = NULL; + + eina_error_set(0); + + GET_RP_OR_RETURN(NULL); + + //printf("Get clip_to for part: %s [to_id: %d]\n", part, rp->part->clip_to_id); + if (rp->part->clip_to_id < 0) return NULL; + + clip = ed->table_parts[rp->part->clip_to_id % ed->table_parts_size]; + if (!clip || !clip->part || !clip->part->name) return NULL; + + return eina_stringshare_add(clip->part->name); +} + +EAPI Eina_Bool +edje_edit_part_clip_to_set(Evas_Object *obj, const char *part, const char *clip_to) +{ + Edje_Real_Part *clip; + Evas_Object *o, *oo; + + eina_error_set(0); + + GET_RP_OR_RETURN(EINA_FALSE); + + /* unset clipping */ + if (!clip_to) + { + //printf("UnSet clip_to for part: %s\n", part); + + if (rp->clip_to && rp->clip_to->object) + { + evas_object_pointer_mode_set(rp->clip_to->object, + EVAS_OBJECT_POINTER_MODE_AUTOGRAB); + evas_object_clip_unset(rp->object); + } + + evas_object_clip_set(rp->object, ed->base.clipper); + if (rp->swallowed_object) + evas_object_clip_set(rp->swallowed_object, ed->base.clipper); + + rp->part->clip_to_id = -1; + rp->clip_to = NULL; + + edje_object_calc_force(obj); + + return EINA_TRUE; + } + + /* set clipping */ + //printf("Set clip_to for part: %s [to: %s]\n", part, clip_to); + clip = _edje_real_part_get(ed, clip_to); + if (!clip || !clip->part) return EINA_FALSE; + o = clip->object; + while ((oo = evas_object_clip_get(o))) + { + if (o == rp->object) + return EINA_FALSE; + o = oo; + } + + rp->part->clip_to_id = clip->part->id; + rp->clip_to = clip; + + evas_object_pass_events_set(rp->clip_to->object, 1); + evas_object_pointer_mode_set(rp->clip_to->object, EVAS_OBJECT_POINTER_MODE_NOGRAB); + evas_object_clip_set(rp->object, rp->clip_to->object); + if (rp->swallowed_object) + evas_object_clip_set(rp->swallowed_object, rp->clip_to->object); + + edje_object_calc_force(obj); + + return EINA_TRUE; +} + +EAPI Eina_Bool +edje_edit_part_mouse_events_get(Evas_Object *obj, const char *part) +{ + eina_error_set(0); + + GET_RP_OR_RETURN(EINA_FALSE); + //printf("Get mouse_events for part: %s [%d]\n", part, rp->part->mouse_events); + return rp->part->mouse_events; +} + +EAPI void +edje_edit_part_mouse_events_set(Evas_Object *obj, const char *part, Eina_Bool mouse_events) +{ + eina_error_set(0); + + GET_RP_OR_RETURN(); + + if (!rp->object) return; + + //printf("Set mouse_events for part: %s [%d]\n", part, mouse_events); + + rp->part->mouse_events = mouse_events ? 1 : 0; + + if (mouse_events) + { + evas_object_pass_events_set(rp->object, 0); + _edje_callbacks_add(rp->object, ed, rp); + } + else + { + evas_object_pass_events_set(rp->object, 1); + _edje_callbacks_del(rp->object, ed); + } +} + +EAPI Eina_Bool +edje_edit_part_repeat_events_get(Evas_Object *obj, const char *part) +{ + eina_error_set(0); + + GET_RP_OR_RETURN(EINA_FALSE); + + //printf("Get repeat_events for part: %s [%d]\n", part, rp->part->repeat_events); + return rp->part->repeat_events; +} + +EAPI void +edje_edit_part_repeat_events_set(Evas_Object *obj, const char *part, Eina_Bool repeat_events) +{ + eina_error_set(0); + + GET_RP_OR_RETURN(); + + if (!rp->object) return; + + //printf("Set repeat_events for part: %s [%d]\n", part, repeat_events); + + rp->part->repeat_events = repeat_events ? 1 : 0; + + if (repeat_events) + evas_object_repeat_events_set(rp->object, 1); + else + evas_object_repeat_events_set(rp->object, 0); +} + +EAPI Evas_Event_Flags +edje_edit_part_ignore_flags_get(Evas_Object *obj, const char *part) +{ + eina_error_set(0); + + GET_RP_OR_RETURN(0); + + return rp->part->ignore_flags; +} + +EAPI void +edje_edit_part_ignore_flags_set(Evas_Object *obj, const char *part, Evas_Event_Flags ignore_flags) +{ + eina_error_set(0); + + GET_RP_OR_RETURN(); + + if (!rp->object) return; + //printf("Set ignore_flags for part: %s [%#x]\n", part, ignore_flags); + + rp->part->ignore_flags = ignore_flags; +} + +EAPI void +edje_edit_part_scale_set(Evas_Object *obj, const char *part, Eina_Bool scale) +{ + eina_error_set(0); + + GET_RP_OR_RETURN(); + + rp->part->scale = scale; + edje_object_calc_force(obj); +} + +EAPI Eina_Bool +edje_edit_part_scale_get(Evas_Object *obj, const char *part) +{ + eina_error_set(0); + + GET_RP_OR_RETURN(EINA_FALSE); + + return rp->part->scale; +} + +EAPI const char * +edje_edit_part_source_get(Evas_Object *obj, const char *part) +{ + //Edje_Real_Part *clip = NULL; + eina_error_set(0); + + GET_RP_OR_RETURN(NULL); + + //printf("Get source for part: %s\n", part); + if (!rp->part->source) return NULL; + + return eina_stringshare_add(rp->part->source); +} + +EAPI Eina_Bool +edje_edit_part_source_set(Evas_Object *obj, const char *part, const char *source) +{ + eina_error_set(0); + + GET_RP_OR_RETURN(EINA_FALSE); + + Evas_Object *child_obj; + //printf("Set source for part: %s [source: %s]\n", part, source); + + if (rp->part->type == EDJE_PART_TYPE_EXTERNAL) + return EINA_FALSE; + + _edje_if_string_free(ed, rp->part->source); + + if (rp->swallowed_object) + { + _edje_real_part_swallow_clear(rp); + evas_object_del(rp->swallowed_object); + rp->swallowed_object = NULL; + } + if (source) + { + rp->part->source = eina_stringshare_add(source); + child_obj = edje_object_add(ed->base.evas); + edje_object_file_set(child_obj, ed->file->path, source); + _edje_real_part_swallow(rp, child_obj, EINA_TRUE); + } + else + rp->part->source = NULL; + return EINA_TRUE; +} + +EAPI int +edje_edit_part_drag_x_get(Evas_Object *obj, const char *part) +{ + eina_error_set(0); + + GET_RP_OR_RETURN(0); + //printf("Get dragX for part: %s\n", part); + return rp->part->dragable.x; +} + +EAPI void +edje_edit_part_drag_x_set(Evas_Object *obj, const char *part, int drag) +{ + eina_error_set(0); + + GET_RP_OR_RETURN(); + //printf("Set dragX for part: %s\n", part); + rp->part->dragable.x = drag; + + if (!drag && !rp->part->dragable.y) + { + free(rp->drag); + rp->drag = NULL; + return ; + } + + if (rp->drag) return; + + rp->drag = _alloc(sizeof (Edje_Real_Part_Drag)); + if (!rp->drag) return; + + rp->drag->step.x = rp->part->dragable.step_x; + rp->drag->step.y = rp->part->dragable.step_y; +} + +EAPI int +edje_edit_part_drag_y_get(Evas_Object *obj, const char *part) +{ + eina_error_set(0); + + GET_RP_OR_RETURN(0); + //printf("Get dragY for part: %s\n", part); + return rp->part->dragable.y; +} + +EAPI void +edje_edit_part_drag_y_set(Evas_Object *obj, const char *part, int drag) +{ + eina_error_set(0); + + GET_RP_OR_RETURN(); + //printf("Set dragY for part: %s\n", part); + rp->part->dragable.y = drag; + + if (!drag && !rp->part->dragable.x) + { + free(rp->drag); + rp->drag = NULL; + return ; + } + + if (rp->drag) return; + + rp->drag = _alloc(sizeof (Edje_Real_Part_Drag)); + if (!rp->drag) return; + + rp->drag->step.x = rp->part->dragable.step_x; + rp->drag->step.y = rp->part->dragable.step_y; +} + +#define FUNC_PART_DRAG_INT(Class, Value) \ + EAPI int \ + edje_edit_part_drag_##Class##_##Value##_get(Evas_Object *obj, const char *part) \ + { \ + eina_error_set(0); \ + GET_RP_OR_RETURN(0); \ + return rp->part->dragable.Class##_##Value; \ + } \ + EAPI void \ + edje_edit_part_drag_##Class##_##Value##_set(Evas_Object *obj, const char *part, int v) \ + { \ + eina_error_set(0); \ + GET_RP_OR_RETURN(); \ + rp->part->dragable.Class##_##Value = v; \ + } + +FUNC_PART_DRAG_INT(step, x); +FUNC_PART_DRAG_INT(step, y); +FUNC_PART_DRAG_INT(count, x); +FUNC_PART_DRAG_INT(count, y); + +#define FUNC_PART_DRAG_ID(Id) \ + EAPI const char* \ + edje_edit_part_drag_##Id##_get(Evas_Object *obj, const char *part) \ + { \ + Edje_Real_Part *p; \ + \ + eina_error_set(0); \ + \ + GET_RP_OR_RETURN(NULL); \ + \ + if (rp->part->dragable.Id##_id < 0) \ + return NULL; \ + \ + p = ed->table_parts[rp->part->dragable.Id##_id]; \ + return eina_stringshare_add(p->part->name); \ + } \ + EAPI void \ + edje_edit_part_drag_##Id##_set(Evas_Object *obj, const char *part, const char *e) \ + { \ + Edje_Real_Part *e_part; \ + \ + eina_error_set(0); \ + \ + GET_RP_OR_RETURN(); \ + if (!e) \ + { \ + rp->part->dragable.Id##_id = -1; \ + return ; \ + } \ + \ + e_part = _edje_real_part_get(ed, e); \ + rp->part->dragable.Id##_id = e_part->part->id; \ + } + +FUNC_PART_DRAG_ID(confine); +FUNC_PART_DRAG_ID(event); + +/*********************/ +/* PART STATES API */ +/*********************/ +EAPI Eina_List * +edje_edit_part_states_list_get(Evas_Object *obj, const char *part) +{ + char state_name[PATH_MAX]; + Eina_List *states = NULL; + unsigned int i; + + eina_error_set(0); + + GET_RP_OR_RETURN(NULL); + + //Is there a better place to put this? maybe edje_edit_init() ? +#ifdef HAVE_LOCALE_H + setlocale(LC_NUMERIC, "C"); +#endif + + states = NULL; + + //append default state + snprintf(state_name, PATH_MAX, + "%s %.2f", + rp->part->default_desc->state.name, + rp->part->default_desc->state.value); + states = eina_list_append(states, eina_stringshare_add(state_name)); + //printf("NEW STATE def: %s\n", state->state.name); + + //append other states + for (i = 0; i < rp->part->other.desc_count; ++i) + { + snprintf(state_name, sizeof(state_name), + "%s %.2f", + rp->part->other.desc[i]->state.name, + rp->part->other.desc[i]->state.value); + states = eina_list_append(states, eina_stringshare_add(state_name)); + //printf("NEW STATE: %s\n", state_name); + } + return states; +} + +EAPI 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) +{ + int part_id; + int i; + + eina_error_set(0); + + GET_PD_OR_RETURN(EINA_FALSE); + //printf("Set name of state: %s in part: %s [new name: %s]\n", + // part, state, new_name); + + if (!new_name) return EINA_FALSE; + + /* update programs */ + /* update the 'state' field in all programs. update only if program has + a single target */ + part_id = _edje_part_id_find(ed, part); + for (i = 0; i < ed->table_programs_size; i++) + { + Edje_Program *epr = ed->table_programs[i]; + + if (eina_list_count(epr->targets) == 1) + { + Edje_Program_Target *t = eina_list_data_get(epr->targets); + + if (t->id == part_id && + !strcmp(epr->state, pd->state.name) && + pd->state.value == epr->value) + { + _edje_if_string_free(ed, epr->state); + epr->state = eina_stringshare_add(new_name); + epr->value = value; + } + } + } + + /* set name */ + _edje_if_string_free(ed, pd->state.name); + pd->state.name = (char *)eina_stringshare_add(new_name); + /* set value */ + pd->state.value = new_value; + + return EINA_TRUE; +} + +EAPI Eina_Bool +edje_edit_state_del(Evas_Object *obj, const char *part, const char *state, double value) +{ + Edje_Part_Collection_Directory_Entry *ce; + Edje_Part_Description_Common *pd; + unsigned int i; + + eina_error_set(0); + + GET_RP_OR_RETURN(EINA_FALSE); + + if (!edje_edit_state_exist(obj, part, state, value)) + return EINA_FALSE; + + pd = _edje_part_description_find_byname(eed, part, state, value); + if (!pd) return EINA_FALSE; + + /* Don't allow to delete default state, for now at least; */ + if (pd == rp->part->default_desc) + return EINA_FALSE; + + /* And if we are deleting the current state, go back to default first */ + if (pd == rp->chosen_description) + _edje_part_description_apply(ed, rp, "default", 0.0, NULL, 0.0); + + ce = eina_hash_find(ed->file->collection, ed->group); + + for (i = 0; i < rp->part->other.desc_count; ++i) + if (pd == rp->part->other.desc[i]) + { + memmove(rp->part->other.desc + i, + rp->part->other.desc + i + 1, + sizeof (Edje_Part_Description_Common*) * (rp->part->other.desc_count - i - 1)); + rp->part->other.desc_count--; + break; + } + + _edje_collection_free_part_description_free(rp->part->type, pd, ce, 0); + return EINA_TRUE; +} + +static Edje_Part_Description_Common * +_edje_edit_state_alloc(int type, Edje *ed) +{ + Edje_Part_Collection_Directory_Entry *ce; + Edje_Part_Description_Common *pd = NULL; + + ce = eina_hash_find(ed->file->collection, ed->group); + + switch (type) + { + case EDJE_PART_TYPE_RECTANGLE: + pd = eina_mempool_malloc(ce->mp.RECTANGLE, sizeof (Edje_Part_Description_Common)); + ce->count.RECTANGLE++; + break; + case EDJE_PART_TYPE_SWALLOW: + pd = eina_mempool_malloc(ce->mp.SWALLOW, sizeof (Edje_Part_Description_Common)); + ce->count.SWALLOW++; + break; + case EDJE_PART_TYPE_GROUP: + pd = eina_mempool_malloc(ce->mp.GROUP, sizeof (Edje_Part_Description_Common)); + ce->count.GROUP++; + break; + +#define EDIT_ALLOC_POOL(Short, Type, Name) \ + case EDJE_PART_TYPE_##Short: \ + { \ + Edje_Part_Description_##Type *Name; \ + \ + Name = eina_mempool_malloc(ce->mp.Short, \ + sizeof (Edje_Part_Description_##Type)); \ + memset(Name, 0, sizeof(Edje_Part_Description_##Type)); \ + pd = &Name->common; \ + ce->count.Short++; \ + break; \ + } + + EDIT_ALLOC_POOL(IMAGE, Image, image); + EDIT_ALLOC_POOL(TEXT, Text, text); + EDIT_ALLOC_POOL(TEXTBLOCK, Text, text); + EDIT_ALLOC_POOL(BOX, Box, box); + EDIT_ALLOC_POOL(TABLE, Table, table); + EDIT_ALLOC_POOL(EXTERNAL, External, external_params); + } + + return pd; +} + +EAPI Eina_Bool +edje_edit_state_add(Evas_Object *obj, const char *part, const char *name, double value) +{ + Edje_Part_Description_Common *pd; + + GET_RP_OR_RETURN(EINA_FALSE); + + if (edje_edit_state_exist(obj, part, name, value)) + return EINA_FALSE; + + //printf("ADD STATE: %s TO PART: %s\n", name , part); + pd = _edje_edit_state_alloc(rp->part->type, ed); + if (!pd) return EINA_FALSE; + + if (!rp->part->default_desc) + { + rp->part->default_desc = pd; + } + else + { + Edje_Part_Description_Common **tmp; + + tmp = realloc(rp->part->other.desc, + sizeof (Edje_Part_Description_Common *) * (rp->part->other.desc_count + 1)); + if (!tmp) + { + free(pd); + return EINA_FALSE; + } + rp->part->other.desc = tmp; + rp->part->other.desc[rp->part->other.desc_count++] = pd; + } + + memset(pd, 0, sizeof (*pd)); + + pd->state.name = eina_stringshare_add(name); + pd->state.value = value; + pd->visible = 1; + pd->align.x = 0.5; + pd->align.y = 0.5; + pd->min.w = 0; + pd->min.h = 0; + pd->fixed.w = 0; + pd->fixed.h = 0; + pd->max.w = -1; + pd->max.h = -1; + pd->rel1.relative_x = 0.0; + pd->rel1.relative_y = 0.0; + pd->rel1.offset_x = 0; + pd->rel1.offset_y = 0; + pd->rel1.id_x = -1; + pd->rel1.id_y = -1; + pd->rel2.relative_x = 1.0; + pd->rel2.relative_y = 1.0; + pd->rel2.offset_x = -1; + pd->rel2.offset_y = -1; + pd->rel2.id_x = -1; + pd->rel2.id_y = -1; + pd->color_class = NULL; + pd->color.r = 255; + pd->color.g = 255; + pd->color.b = 255; + pd->color.a = 255; + pd->color2.r = 0; + pd->color2.g = 0; + pd->color2.b = 0; + pd->color2.a = 255; + pd->map.id_persp = -1; + pd->map.id_light = -1; + pd->map.rot.id_center = -1; + pd->map.rot.x = FROM_DOUBLE(0.0); + pd->map.rot.y = FROM_DOUBLE(0.0); + pd->map.rot.z = FROM_DOUBLE(0.0); + pd->map.on = 0; + pd->map.smooth = 1; + pd->map.alpha = 1; + pd->map.backcull = 0; + pd->map.persp_on = 0; + pd->persp.zplane = 0; + pd->persp.focal = 1000; + + if (rp->part->type == EDJE_PART_TYPE_TEXT + || rp->part->type == EDJE_PART_TYPE_TEXTBLOCK) + { + Edje_Part_Description_Text *text; + + text = (Edje_Part_Description_Text*) pd; + + memset(&text->text, 0, sizeof (text->text)); + + text->text.color3.r = 0; + text->text.color3.g = 0; + text->text.color3.b = 0; + text->text.color3.a = 128; + text->text.align.x = 0.5; + text->text.align.y = 0.5; + text->text.id_source = -1; + text->text.id_text_source = -1; + } + else if (rp->part->type == EDJE_PART_TYPE_IMAGE) + { + Edje_Part_Description_Image *img; + + img = (Edje_Part_Description_Image*) pd; + + memset(&img->image, 0, sizeof (img->image)); + + img->image.id = -1; + img->image.fill.smooth = 1; + img->image.fill.pos_rel_x = 0.0; + img->image.fill.pos_abs_x = 0; + img->image.fill.rel_x = 1.0; + img->image.fill.abs_x = 0; + img->image.fill.pos_rel_y = 0.0; + img->image.fill.pos_abs_y = 0; + img->image.fill.rel_y = 1.0; + img->image.fill.abs_y = 0; + img->image.fill.angle = 0; + img->image.fill.spread = 0; + img->image.fill.type = EDJE_FILL_TYPE_SCALE; + } + else if (rp->part->type == EDJE_PART_TYPE_PROXY) + { + Edje_Part_Description_Proxy *pro; + + pro = (Edje_Part_Description_Proxy*) pd; + + memset(&pro->proxy, 0, sizeof (pro->proxy)); + + pro->proxy.id = -1; + pro->proxy.fill.smooth = 1; + pro->proxy.fill.pos_rel_x = 0.0; + pro->proxy.fill.pos_abs_x = 0; + pro->proxy.fill.rel_x = 1.0; + pro->proxy.fill.abs_x = 0; + pro->proxy.fill.pos_rel_y = 0.0; + pro->proxy.fill.pos_abs_y = 0; + pro->proxy.fill.rel_y = 1.0; + pro->proxy.fill.abs_y = 0; + pro->proxy.fill.angle = 0; + pro->proxy.fill.spread = 0; + pro->proxy.fill.type = EDJE_FILL_TYPE_SCALE; + } + else if (rp->part->type == EDJE_PART_TYPE_EXTERNAL) + { + Edje_Part_Description_External *external; + Edje_External_Param_Info *pi; + + external = (Edje_Part_Description_External*) pd; + + external->external_params = NULL; + + if (rp->part->source) + { + pi = (Edje_External_Param_Info *)edje_external_param_info_get(rp->part->source); + while (pi && pi->name) + { + Edje_External_Param *p; + p = _alloc(sizeof(Edje_External_Param)); + /* error checking.. meh */ + p->name = eina_stringshare_add(pi->name); + p->type = pi->type; + switch(p->type) + { + case EDJE_EXTERNAL_PARAM_TYPE_INT: + case EDJE_EXTERNAL_PARAM_TYPE_BOOL: + if (pi->info.i.def != EDJE_EXTERNAL_INT_UNSET) + p->i = pi->info.i.def; + break; + case EDJE_EXTERNAL_PARAM_TYPE_DOUBLE: + if (pi->info.d.def != EDJE_EXTERNAL_DOUBLE_UNSET) + p->d = pi->info.d.def; + break; + case EDJE_EXTERNAL_PARAM_TYPE_CHOICE: + if (pi->info.c.def) + p->s = eina_stringshare_add(pi->info.c.def); + break; + case EDJE_EXTERNAL_PARAM_TYPE_STRING: + if (pi->info.s.def) + p->s = eina_stringshare_add(pi->info.s.def); + break; + default: + ERR("unknown external parameter type '%d'", p->type); + } + external->external_params = eina_list_append(external->external_params, p); + pi++; + } + if (external->external_params) + rp->param1.external_params = _edje_external_params_parse(rp->swallowed_object, external->external_params); + } + } + else if (rp->part->type == EDJE_PART_TYPE_BOX) + { + Edje_Part_Description_Box *box; + + box = (Edje_Part_Description_Box*) pd; + memset(&box->box, 0, sizeof (box->box)); + } + else if (rp->part->type == EDJE_PART_TYPE_TABLE) + { + Edje_Part_Description_Table *table; + + table = (Edje_Part_Description_Table*) pd; + memset(&table->table, 0, sizeof (table->table)); + } + + return EINA_TRUE; +} + +EAPI Eina_Bool +edje_edit_state_exist(Evas_Object *obj, const char *part, const char *state, double value) +{ + eina_error_set(0); + + GET_PD_OR_RETURN(EINA_FALSE); + return EINA_TRUE; +} + +EAPI Eina_Bool +edje_edit_state_copy(Evas_Object *obj, const char *part, const char *from, double val_from, const char *to, double val_to) +{ + Edje_Part_Description_Common *pdfrom, *pdto; + Edje_External_Param *p; + + eina_error_set(0); + + GET_RP_OR_RETURN(EINA_FALSE); + + pdfrom = _edje_part_description_find_byname(eed, part, from, val_from); + if (!pdfrom) + return EINA_FALSE; + + pdto = _edje_part_description_find_byname(eed, part, to, val_to); + if (!pdto) + { + Edje_Part_Description_Common **tmp; + + pdto = _edje_edit_state_alloc(rp->part->type, ed); + if (!pdto) return EINA_FALSE; + /* No need to check for default desc, at this point it must exist */ + + tmp = realloc(rp->part->other.desc, + sizeof (Edje_Part_Description_Common *) * (rp->part->other.desc_count + 1)); + if (!tmp) + { + free(pdto); + return EINA_FALSE; + } + rp->part->other.desc = tmp; + rp->part->other.desc[rp->part->other.desc_count++] = pdto; + } + +#define PD_STRING_COPY(To, From, _x) \ + _edje_if_string_free(ed, To->_x); \ + To->_x = (char *)eina_stringshare_add(From->_x); + + /* Copy all value */ + *pdto = *pdfrom; + /* Keeping the pdto state name and value */ + pdto->state.name = eina_stringshare_add(to); + pdto->state.value = val_to; + /* Update pointer. */ + PD_STRING_COPY(pdto, pdfrom, color_class); + + switch (rp->part->type) + { + case EDJE_PART_TYPE_PROXY: + { + Edje_Part_Description_Proxy *pro_to = (Edje_Part_Description_Proxy*) pdto; + Edje_Part_Description_Proxy *pro_from = (Edje_Part_Description_Proxy*) pdfrom; + + pro_to->proxy = pro_from->proxy; + + break; + } + case EDJE_PART_TYPE_IMAGE: + { + Edje_Part_Description_Image *img_to = (Edje_Part_Description_Image*) pdto; + Edje_Part_Description_Image *img_from = (Edje_Part_Description_Image*) pdfrom; + unsigned int i; + + img_to->image = img_from->image; + + /* Update pointers. */ + for (i = 0; i < img_to->image.tweens_count; ++i) + free(img_to->image.tweens[i]); + if (img_to->image.tweens_count > 0) + free(img_to->image.tweens); + + img_to->image.tweens_count = img_from->image.tweens_count; + img_to->image.tweens = calloc(img_to->image.tweens_count, + sizeof (Edje_Part_Image_Id*)); + if (!img_to->image.tweens) + break; + + for (i = 0; i < img_to->image.tweens_count; ++i) + { + Edje_Part_Image_Id *new_i; + new_i = _alloc(sizeof(Edje_Part_Image_Id)); + if (!new_i) continue ; + + *new_i = *img_from->image.tweens[i]; + + img_to->image.tweens[i] = new_i; + } + break; + } + case EDJE_PART_TYPE_TEXT: + case EDJE_PART_TYPE_TEXTBLOCK: + { + Edje_Part_Description_Text *text_to = (Edje_Part_Description_Text*) pdto; + Edje_Part_Description_Text *text_from = (Edje_Part_Description_Text*) pdfrom; + + text_to->text = text_from->text; + + /* Update pointers. */ + PD_STRING_COPY(text_to, text_from, text.text.str); + PD_STRING_COPY(text_to, text_from, text.text_class); + PD_STRING_COPY(text_to, text_from, text.style.str); + PD_STRING_COPY(text_to, text_from, text.font.str); + PD_STRING_COPY(text_to, text_from, text.repch.str); + break; + } + case EDJE_PART_TYPE_BOX: + { + Edje_Part_Description_Box *box_to = (Edje_Part_Description_Box*) pdto; + Edje_Part_Description_Box *box_from = (Edje_Part_Description_Box*) pdfrom; + + box_to->box = box_from->box; + + PD_STRING_COPY(box_to, box_from, box.layout); + PD_STRING_COPY(box_to, box_from, box.alt_layout); + break; + } + case EDJE_PART_TYPE_TABLE: + { + Edje_Part_Description_Table *table_to = (Edje_Part_Description_Table*) pdto; + Edje_Part_Description_Table *table_from = (Edje_Part_Description_Table*) pdfrom; + + table_to->table = table_from->table; + break; + } + case EDJE_PART_TYPE_EXTERNAL: + { + Edje_Part_Description_External *ext_to = (Edje_Part_Description_External*) pdto; + Edje_Part_Description_External *ext_from = (Edje_Part_Description_External*) pdfrom; + Eina_List *l; + + /* XXX: optimize this, most likely we don't need to remove and add */ + EINA_LIST_FREE(ext_to->external_params, p) + { + _edje_if_string_free(ed, p->name); + if (p->s) + _edje_if_string_free(ed, p->s); + free(p); + } + EINA_LIST_FOREACH(ext_from->external_params, l, p) + { + Edje_External_Param *new_p; + new_p = _alloc(sizeof(Edje_External_Param)); + new_p->name = eina_stringshare_add(p->name); + new_p->type = p->type; + switch (p->type) + { + case EDJE_EXTERNAL_PARAM_TYPE_INT: + new_p->i = p->i; + break; + case EDJE_EXTERNAL_PARAM_TYPE_DOUBLE: + new_p->d = p->d; + break; + case EDJE_EXTERNAL_PARAM_TYPE_CHOICE: + case EDJE_EXTERNAL_PARAM_TYPE_STRING: + new_p->s = eina_stringshare_add(p->s); + break; + default: + break; + } + ext_to->external_params = eina_list_append(ext_to->external_params, new_p); + } + break; + } + } + +#undef PD_STRING_COPY + + return EINA_TRUE; +} + +#define FUNC_STATE_RELATIVE_DOUBLE(Sub, Value) \ + EAPI double \ + edje_edit_state_##Sub##_relative_##Value##_get(Evas_Object *obj, const char *part, const char *state, double value) \ + { \ + eina_error_set(0); \ + GET_PD_OR_RETURN(0); \ + return TO_DOUBLE(pd->Sub.relative_##Value); \ + } \ + EAPI void \ + edje_edit_state_##Sub##_relative_##Value##_set(Evas_Object *obj, const char *part, const char *state, double value, double v) \ + { \ + eina_error_set(0); \ + GET_PD_OR_RETURN(); \ + pd->Sub.relative_##Value = FROM_DOUBLE(v); \ + edje_object_calc_force(obj); \ + } + +FUNC_STATE_RELATIVE_DOUBLE(rel1, x); +FUNC_STATE_RELATIVE_DOUBLE(rel1, y); +FUNC_STATE_RELATIVE_DOUBLE(rel2, x); +FUNC_STATE_RELATIVE_DOUBLE(rel2, y); + +#define FUNC_STATE_OFFSET_INT(Sub, Value) \ + EAPI int \ + edje_edit_state_##Sub##_offset_##Value##_get(Evas_Object *obj, const char *part, const char *state, double value) \ + { \ + eina_error_set(0); \ + GET_PD_OR_RETURN(0); \ + return pd->Sub.offset_##Value; \ + } \ + EAPI void \ + edje_edit_state_##Sub##_offset_##Value##_set(Evas_Object *obj, const char *part, const char *state, double value, double v) \ + { \ + eina_error_set(0); \ + GET_PD_OR_RETURN(); \ + pd->Sub.offset_##Value = TO_INT(FROM_DOUBLE(v)); \ + edje_object_calc_force(obj); \ + } + +FUNC_STATE_OFFSET_INT(rel1, x); +FUNC_STATE_OFFSET_INT(rel1, y); +FUNC_STATE_OFFSET_INT(rel2, x); +FUNC_STATE_OFFSET_INT(rel2, y); + +#define FUNC_STATE_REL(Sub, Value) \ + EAPI const char * \ + edje_edit_state_##Sub##_to_##Value##_get(Evas_Object *obj, const char *part, const char *state, double value) \ + { \ + Edje_Real_Part *rel; \ + \ + eina_error_set(0); \ + \ + GET_PD_OR_RETURN(NULL); \ + \ + if (pd->Sub.id_##Value == -1) return NULL; \ + \ + rel = ed->table_parts[pd->Sub.id_##Value % ed->table_parts_size]; \ + \ + if (rel->part->name) return eina_stringshare_add(rel->part->name); \ + return NULL; \ + } \ + EAPI void \ + edje_edit_state_##Sub##_to_##Value##_set(Evas_Object *obj, const char *part, const char *state, double value, const char *to) \ + { \ + Edje_Real_Part *relp; \ + \ + eina_error_set(0); \ + \ + GET_PD_OR_RETURN(); \ + \ + if (to) \ + { \ + relp = _edje_real_part_get(ed, to); \ + if (!relp) return; \ + pd->Sub.id_##Value = relp->part->id; \ + } \ + else \ + pd->Sub.id_##Value = -1; \ + \ + } +//note after this call edje_edit_part_selected_state_set() to update !! need to fix this +//_edje_part_description_apply(ed, rp, pd->state.name, pd->state.value, "state", 0.1); //Why segfault?? +// edje_object_calc_force(obj);//don't work for redraw + +FUNC_STATE_REL(rel1, x); +FUNC_STATE_REL(rel1, y); +FUNC_STATE_REL(rel2, x); +FUNC_STATE_REL(rel2, y); + +//colors +#define FUNC_COLOR(Code) \ + EAPI void \ + edje_edit_state_##Code##_get(Evas_Object *obj, const char *part, const char *state, double value, int *r, int *g, int *b, int *a) \ + { \ + eina_error_set(0); \ + GET_PD_OR_RETURN(); \ + \ + if (r) *r = pd->Code.r; \ + if (g) *g = pd->Code.g; \ + if (b) *b = pd->Code.b; \ + if (a) *a = pd->Code.a; \ + } \ + EAPI void \ + edje_edit_state_##Code##_set(Evas_Object *obj, const char *part, const char *state, double value, int r, int g, int b, int a) \ + { \ + eina_error_set(0); \ + GET_PD_OR_RETURN(); \ + \ + if (r > -1 && r < 256) pd->Code.r = r; \ + if (g > -1 && g < 256) pd->Code.g = g; \ + if (b > -1 && b < 256) pd->Code.b = b; \ + if (a > -1 && a < 256) pd->Code.a = a; \ + \ + edje_object_calc_force(obj); \ + } + +FUNC_COLOR(color); +FUNC_COLOR(color2); + +EAPI 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) +{ + Edje_Part_Description_Text *txt; + + eina_error_set(0); + + GET_PD_OR_RETURN(); + + if ((rp->part->type != EDJE_PART_TYPE_TEXT) && + (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) + { + if (r) *r = 0; + if (g) *g = 0; + if (b) *b = 0; + if (a) *a = 0; + return; + } + + txt = (Edje_Part_Description_Text*) pd; + + if (r) *r = txt->text.color3.r; + if (g) *g = txt->text.color3.g; + if (b) *b = txt->text.color3.b; + if (a) *a = txt->text.color3.a; +} + +EAPI 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) +{ + Edje_Part_Description_Text *txt; + + eina_error_set(0); + + GET_PD_OR_RETURN(); + + if ((rp->part->type != EDJE_PART_TYPE_TEXT) && + (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) + return; + + txt = (Edje_Part_Description_Text*) pd; + + if (r > -1 && r < 256) txt->text.color3.r = r; + if (g > -1 && g < 256) txt->text.color3.g = g; + if (b > -1 && b < 256) txt->text.color3.b = b; + if (a > -1 && a < 256) txt->text.color3.a = a; + + edje_object_calc_force(obj); +} + +#define FUNC_STATE_DOUBLE(Class, Value) \ + EAPI double \ + edje_edit_state_##Class##_##Value##_get(Evas_Object *obj, const char *part, const char *state, double value) \ + { \ + eina_error_set(0); \ + GET_PD_OR_RETURN(0); \ + return TO_DOUBLE(pd->Class.Value); \ + } \ + EAPI void \ + edje_edit_state_##Class##_##Value##_set(Evas_Object *obj, const char *part, const char *state, double value, double v) \ + { \ + eina_error_set(0); \ + GET_PD_OR_RETURN(); \ + pd->Class.Value = FROM_DOUBLE(v); \ + edje_object_calc_force(obj); \ + } + +#define FUNC_STATE_INT(Class, Value) \ + EAPI int \ + edje_edit_state_##Class##_##Value##_get(Evas_Object *obj, const char *part, const char *state, double value) \ + { \ + eina_error_set(0); \ + GET_PD_OR_RETURN(0); \ + return pd->Class.Value; \ + } \ + EAPI void \ + edje_edit_state_##Class##_##Value##_set(Evas_Object *obj, const char *part, const char *state, double value, int v) \ + { \ + eina_error_set(0); \ + GET_PD_OR_RETURN(); \ + pd->Class.Value = v; \ + edje_object_calc_force(obj); \ + } + +FUNC_STATE_DOUBLE(align, x); +FUNC_STATE_DOUBLE(align, y); +FUNC_STATE_INT(min, w); +FUNC_STATE_INT(min, h); +FUNC_STATE_INT(max, w); +FUNC_STATE_INT(max, h); +FUNC_STATE_DOUBLE(aspect, min); +FUNC_STATE_DOUBLE(aspect, max); + +#define FUNC_STATE_DOUBLE_FILL(Class, Type, Value) \ + EAPI double \ + edje_edit_state_fill_##Type##_relative_##Value##_get(Evas_Object *obj, const char *part, const char *state, double value) \ + { \ + eina_error_set(0); \ + \ + GET_PD_OR_RETURN(0); \ + \ + switch (rp->part->type) \ + { \ + case EDJE_PART_TYPE_IMAGE: \ + { \ + Edje_Part_Description_Image *img; \ + \ + img = (Edje_Part_Description_Image*) pd; \ + \ + return TO_DOUBLE(img->image.fill.Class##rel_##Value); \ + } \ + case EDJE_PART_TYPE_PROXY: \ + { \ + Edje_Part_Description_Proxy *pro; \ + \ + pro = (Edje_Part_Description_Proxy*) pd; \ + \ + return TO_DOUBLE(pro->proxy.fill.Class##rel_##Value); \ + } \ + } \ + \ + return 0; \ + } \ + EAPI void \ + edje_edit_state_fill_##Type##_relative_##Value##_set(Evas_Object *obj, const char *part, const char *state, double value, double v) \ + { \ + eina_error_set(0); \ + \ + GET_PD_OR_RETURN(); \ + \ + switch (rp->part->type) \ + { \ + case EDJE_PART_TYPE_IMAGE: \ + { \ + Edje_Part_Description_Image *img; \ + \ + img = (Edje_Part_Description_Image*) pd; \ + \ + img->image.fill.Class##rel_##Value = FROM_DOUBLE(v); \ + \ + break; \ + } \ + case EDJE_PART_TYPE_PROXY: \ + { \ + Edje_Part_Description_Proxy *pro; \ + \ + pro = (Edje_Part_Description_Proxy*) pd; \ + \ + pro->proxy.fill.Class##rel_##Value = FROM_DOUBLE(v); \ + \ + break; \ + } \ + default: \ + return; \ + } \ + \ + edje_object_calc_force(obj); \ + } + +#define FUNC_STATE_INT_FILL(Class, Type, Value) \ + EAPI int \ + edje_edit_state_fill_##Type##_offset_##Value##_get(Evas_Object *obj, const char *part, const char *state, double value) \ + { \ + eina_error_set(0); \ + \ + GET_PD_OR_RETURN(0); \ + \ + switch (rp->part->type) \ + { \ + case EDJE_PART_TYPE_IMAGE: \ + { \ + Edje_Part_Description_Image *img; \ + \ + img = (Edje_Part_Description_Image*) pd; \ + \ + return img->image.fill.Class##abs_##Value; \ + } \ + case EDJE_PART_TYPE_PROXY: \ + { \ + Edje_Part_Description_Proxy *pro; \ + \ + pro = (Edje_Part_Description_Proxy*) pd; \ + \ + return pro->proxy.fill.Class##abs_##Value; \ + } \ + } \ + return 0; \ + } \ + EAPI void \ + edje_edit_state_fill_##Type##_offset_##Value##_set(Evas_Object *obj, const char *part, const char *state, double value, double v) \ + { \ + eina_error_set(0); \ + \ + GET_PD_OR_RETURN(); \ + \ + switch (rp->part->type) \ + { \ + case EDJE_PART_TYPE_IMAGE: \ + { \ + Edje_Part_Description_Image *img; \ + \ + img = (Edje_Part_Description_Image*) pd; \ + \ + img->image.fill.Class##abs_##Value = FROM_DOUBLE(v); \ + return; \ + } \ + case EDJE_PART_TYPE_PROXY: \ + { \ + Edje_Part_Description_Proxy *pro; \ + \ + pro = (Edje_Part_Description_Proxy*) pd; \ + \ + pro->proxy.fill.Class##abs_##Value = FROM_DOUBLE(v); \ + return; \ + } \ + default: \ + return; \ + } \ + \ + edje_object_calc_force(obj); \ + } + +FUNC_STATE_DOUBLE_FILL(pos_, origin, x); +FUNC_STATE_DOUBLE_FILL(pos_, origin, y); +FUNC_STATE_INT_FILL(pos_, origin, x); +FUNC_STATE_INT_FILL(pos_, origin, y); + +FUNC_STATE_DOUBLE_FILL(, size, x); +FUNC_STATE_DOUBLE_FILL(, size, y); +FUNC_STATE_INT_FILL(, size, x); +FUNC_STATE_INT_FILL(, size, y); + +EAPI Eina_Bool +edje_edit_state_visible_get(Evas_Object *obj, const char *part, const char *state, double value) +{ + eina_error_set(0); + + GET_PD_OR_RETURN(EINA_FALSE); + + //printf("Get state visible flag of part: %s state: %s\n", part, state); + return pd->visible; +} + +EAPI void +edje_edit_state_visible_set(Evas_Object *obj, const char *part, const char *state, double value, Eina_Bool visible) +{ + eina_error_set(0); + + GET_PD_OR_RETURN(); + //printf("Set state visible flag of part: %s state: %s to: %d\n", part, state, visible); + if (visible) pd->visible = 1; + else pd->visible = 0; + edje_object_calc_force(obj); +} + +EAPI unsigned char +edje_edit_state_aspect_pref_get(Evas_Object *obj, const char *part, const char *state, double value) +{ + eina_error_set(0); + + GET_PD_OR_RETURN(0); + + //printf("GET ASPECT_PREF of state '%s' [%d]\n", state, pd->aspect.prefer); + return pd->aspect.prefer; +} + +EAPI void +edje_edit_state_aspect_pref_set(Evas_Object *obj, const char *part, const char *state, double value, unsigned char pref) +{ + eina_error_set(0); + + GET_PD_OR_RETURN(); + + //printf("SET ASPECT_PREF of state '%s' [to: %d]\n", state, pref); + pd->aspect.prefer = pref; +} + +EAPI const char* +edje_edit_state_color_class_get(Evas_Object *obj, const char *part, const char *state, double value) +{ + eina_error_set(0); + + GET_PD_OR_RETURN(NULL); + //printf("Get ColorClass of part: %s state: %s\n", part, state); + return eina_stringshare_add(pd->color_class); +} + +EAPI void +edje_edit_state_color_class_set(Evas_Object *obj, const char *part, const char *state, double value, const char *color_class) +{ + eina_error_set(0); + + GET_PD_OR_RETURN(); + //printf("Set ColorClass of part: %s state: %s [to: %s]\n", part, state, color_class); + _edje_if_string_free(ed, pd->color_class); + pd->color_class = (char*)eina_stringshare_add(color_class); +} + +EAPI const Eina_List * +edje_edit_state_external_params_list_get(Evas_Object *obj, const char *part, const char *state, double value) +{ + Edje_Part_Description_External *external; + + eina_error_set(0); + + GET_PD_OR_RETURN(NULL); + + if (rp->part->type != EDJE_PART_TYPE_EXTERNAL) + return NULL; + + external = (Edje_Part_Description_External *) pd; + + return external->external_params; +} + +EAPI 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) +{ + Edje_Part_Description_External *external; + Edje_External_Param *p; + Eina_List *l; + + eina_error_set(0); + + GET_PD_OR_RETURN(EINA_FALSE); + + if (rp->part->type != EDJE_PART_TYPE_EXTERNAL) + return EINA_FALSE; + + external = (Edje_Part_Description_External *) pd; + + EINA_LIST_FOREACH(external->external_params, l, p) + if (!strcmp(p->name, param)) + { + if (type) *type = p->type; + if (val) + switch (p->type) + { + case EDJE_EXTERNAL_PARAM_TYPE_INT: + case EDJE_EXTERNAL_PARAM_TYPE_BOOL: + *val = &p->i; + break; + case EDJE_EXTERNAL_PARAM_TYPE_DOUBLE: + *val = &p->d; + break; + case EDJE_EXTERNAL_PARAM_TYPE_CHOICE: + case EDJE_EXTERNAL_PARAM_TYPE_STRING: + *val = (void *)p->s; + break; + default: + ERR("unknown external parameter type '%d'", p->type); + } + return EINA_TRUE; + } + + return EINA_FALSE; +} + +EAPI 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) +{ + Edje_Part_Description_External *external; + Edje_External_Param *p; + Eina_List *l; + + eina_error_set(0); + + GET_PD_OR_RETURN(EINA_FALSE); + + if (rp->part->type != EDJE_PART_TYPE_EXTERNAL) + { + if (val) *val = 0; + return EINA_FALSE; + } + + external = (Edje_Part_Description_External *) pd; + + EINA_LIST_FOREACH(external->external_params, l, p) + if (!strcmp(p->name, param)) + { + if (p->type != EDJE_EXTERNAL_PARAM_TYPE_INT) + return EINA_FALSE; + if (val) + *val = p->i; + return EINA_TRUE; + } + + return EINA_FALSE; +} + +EAPI 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) +{ + Edje_Part_Description_External *external; + Edje_External_Param *p; + Eina_List *l; + + eina_error_set(0); + + GET_PD_OR_RETURN(EINA_FALSE); + + if (rp->part->type != EDJE_PART_TYPE_EXTERNAL) + { + if (val) *val = 0; + return EINA_FALSE; + } + + external = (Edje_Part_Description_External *) pd; + + EINA_LIST_FOREACH(external->external_params, l, p) + if (!strcmp(p->name, param)) + { + if (p->type != EDJE_EXTERNAL_PARAM_TYPE_BOOL) + return EINA_FALSE; + if (val) + *val = p->i; + return EINA_TRUE; + } + + return EINA_FALSE; +} + +EAPI 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) +{ + Edje_Part_Description_External *external; + Edje_External_Param *p; + Eina_List *l; + + eina_error_set(0); + + GET_PD_OR_RETURN(EINA_FALSE); + + if (rp->part->type != EDJE_PART_TYPE_EXTERNAL) + { + if (val) *val = 0; + return EINA_FALSE; + } + + external = (Edje_Part_Description_External *) pd; + + EINA_LIST_FOREACH(external->external_params, l, p) + if (!strcmp(p->name, param)) + { + if (p->type != EDJE_EXTERNAL_PARAM_TYPE_DOUBLE) + return EINA_FALSE; + if (val) + *val = p->d; + return EINA_TRUE; + } + + return EINA_FALSE; +} + +EAPI 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) +{ + Edje_Part_Description_External *external; + Edje_External_Param *p; + Eina_List *l; + + eina_error_set(0); + + GET_PD_OR_RETURN(EINA_FALSE); + + if (rp->part->type != EDJE_PART_TYPE_EXTERNAL) + { + if (val) *val = NULL; + return EINA_FALSE; + } + + external = (Edje_Part_Description_External *) pd; + + EINA_LIST_FOREACH(external->external_params, l, p) + if (!strcmp(p->name, param)) + { + if (p->type != EDJE_EXTERNAL_PARAM_TYPE_STRING) + return EINA_FALSE; + if (val) + *val = p->s; + return EINA_TRUE; + } + + return EINA_FALSE; +} + +EAPI 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) +{ + Edje_Part_Description_External *external; + Edje_External_Param *p; + Eina_List *l; + + eina_error_set(0); + + GET_PD_OR_RETURN(EINA_FALSE); + + if (rp->part->type != EDJE_PART_TYPE_EXTERNAL) + { + if (val) *val = NULL; + return EINA_FALSE; + } + + external = (Edje_Part_Description_External *) pd; + + EINA_LIST_FOREACH(external->external_params, l, p) + if (!strcmp(p->name, param)) + { + if (p->type != EDJE_EXTERNAL_PARAM_TYPE_CHOICE) + return EINA_FALSE; + if (val) + *val = p->s; + return EINA_TRUE; + } + + return EINA_FALSE; +} + +EAPI 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, ...) +{ + va_list ap; + Eina_List *l; + Edje_Part_Description_External *external; + Edje_External_Param *p = NULL, old_p = { 0, 0, 0, 0, 0 }; + int found = 0; + + eina_error_set(0); + + GET_PD_OR_RETURN(EINA_FALSE); + + if (rp->part->type != EDJE_PART_TYPE_EXTERNAL) + return EINA_FALSE; + + external = (Edje_Part_Description_External *) pd; + + va_start(ap, type); + + EINA_LIST_FOREACH(external->external_params, l, p) + if (!strcmp(p->name, param)) + { + found = 1; + old_p = *p; + break; + } + + if (!found) + { + p = _alloc(sizeof(Edje_External_Param)); + if (!p) + { + va_end(ap); + return EINA_FALSE; + } + p->name = eina_stringshare_add(param); + } + + p->type = type; + p->i = 0; + p->d = 0; + _edje_if_string_free(ed, p->s); + p->s = NULL; + + switch (type) + { + case EDJE_EXTERNAL_PARAM_TYPE_INT: + case EDJE_EXTERNAL_PARAM_TYPE_BOOL: + p->i = (int)va_arg(ap, int); + break; + case EDJE_EXTERNAL_PARAM_TYPE_DOUBLE: + p->d = (double)va_arg(ap, double); + break; + case EDJE_EXTERNAL_PARAM_TYPE_CHOICE: + case EDJE_EXTERNAL_PARAM_TYPE_STRING: + p->s = eina_stringshare_add((const char *)va_arg(ap, char *)); + break; + default: + ERR("unknown external parameter type '%d'", type); + va_end(ap); + if (!found) free(p); + else *p = old_p; + return EINA_FALSE; + } + + va_end(ap); + + //FIXME: + //For now, we're just setting the value if the state is the selected state. + //This is a conceptual error and is incoherent with the rest of the API! + { + const char *sname; + double svalue; + sname = edje_edit_part_selected_state_get(obj, part, &svalue); + if (!strcmp(state, sname) && svalue == value) + if (!edje_object_part_external_param_set(obj, part, p)) + if ((type == EDJE_EXTERNAL_PARAM_TYPE_CHOICE) || + (type == EDJE_EXTERNAL_PARAM_TYPE_STRING)) + { + _edje_if_string_free(ed, p->s); + if (!found) free(p); + else *p = old_p; + eina_stringshare_del(sname); + return EINA_FALSE; + } + eina_stringshare_del(sname); + } + + if (!found) + external->external_params = eina_list_append(external->external_params, p); + + _edje_external_parsed_params_free(rp->swallowed_object, + rp->param1.external_params); + rp->param1.external_params = \ + _edje_external_params_parse(rp->swallowed_object, + external->external_params); + + + return EINA_TRUE; +} + +EAPI 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) +{ + eina_error_set(0); + return edje_edit_state_external_param_set(obj, part, state, value, param, EDJE_EXTERNAL_PARAM_TYPE_INT, val); +} + +EAPI 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) +{ + eina_error_set(0); + return edje_edit_state_external_param_set(obj, part, state, value, param, EDJE_EXTERNAL_PARAM_TYPE_BOOL, (int)val); +} + +EAPI 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) +{ + eina_error_set(0); + return edje_edit_state_external_param_set(obj, part, state, value, param, EDJE_EXTERNAL_PARAM_TYPE_DOUBLE, val); +} + +EAPI 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) +{ + eina_error_set(0); + return edje_edit_state_external_param_set(obj, part, state, value, param, EDJE_EXTERNAL_PARAM_TYPE_STRING, val); +} + +EAPI 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) +{ + eina_error_set(0); + return edje_edit_state_external_param_set(obj, part, state, value, param, EDJE_EXTERNAL_PARAM_TYPE_CHOICE, val); +} + +/**************/ +/* TEXT API */ +/**************/ + +EAPI const char * +edje_edit_state_text_get(Evas_Object *obj, const char *part, const char *state, double value) +{ + Edje_Part_Description_Text *txt; + + eina_error_set(0); + + GET_PD_OR_RETURN(NULL); + + if ((rp->part->type != EDJE_PART_TYPE_TEXT) && + (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) + return NULL; + + txt = (Edje_Part_Description_Text *) pd; + //printf("GET TEXT of state: %s\n", state); + + return eina_stringshare_add(edje_string_get(&txt->text.text)); +} + +EAPI void +edje_edit_state_text_set(Evas_Object *obj, const char *part, const char *state, double value, const char *text) +{ + Edje_Part_Description_Text *txt; + + eina_error_set(0); + + GET_PD_OR_RETURN(); + + //printf("SET TEXT of state: %s\n", state); + + if (!text) return; + + if ((rp->part->type != EDJE_PART_TYPE_TEXT) && + (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) + return; + + txt = (Edje_Part_Description_Text *) pd; + + _edje_if_string_free(ed, txt->text.text.str); + txt->text.text.str = (char *)eina_stringshare_add(text); + txt->text.text.id = 0; + + edje_object_calc_force(obj); +} + +EAPI int +edje_edit_state_text_size_get(Evas_Object *obj, const char *part, const char *state, double value) +{ + Edje_Part_Description_Text *txt; + + eina_error_set(0); + + GET_PD_OR_RETURN(-1); + + if ((rp->part->type != EDJE_PART_TYPE_TEXT) && + (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) + return -1; + + txt = (Edje_Part_Description_Text *) pd; + //printf("GET TEXT_SIZE of state: %s [%d]\n", state, pd->text.size); + return txt->text.size; +} + +EAPI void +edje_edit_state_text_size_set(Evas_Object *obj, const char *part, const char *state, double value, int size) +{ + Edje_Part_Description_Text *txt; + + eina_error_set(0); + + GET_PD_OR_RETURN(); + + //printf("SET TEXT_SIZE of state: %s [%d]\n", state, size); + + if (size < 0) return; + + if ((rp->part->type != EDJE_PART_TYPE_TEXT) && + (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) + return; + + txt = (Edje_Part_Description_Text *) pd; + + txt->text.size = size; + + edje_object_calc_force(obj); +} + +#define FUNC_TEXT_DOUBLE(Name, Value) \ + EAPI double \ + edje_edit_state_text_##Name##_get(Evas_Object *obj, const char *part, const char *state, double value) \ + { \ + Edje_Part_Description_Text *txt; \ + \ + eina_error_set(0); \ + \ + GET_PD_OR_RETURN(0); \ + \ + if ((rp->part->type != EDJE_PART_TYPE_TEXT) && \ + (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) \ + return 0; \ + \ + txt = (Edje_Part_Description_Text *) pd; \ + return TO_DOUBLE(txt->text.Value); \ + } \ + EAPI void \ + edje_edit_state_text_##Name##_set(Evas_Object *obj, const char *part, const char *state, double value, double v) \ + { \ + Edje_Part_Description_Text *txt; \ + \ + eina_error_set(0); \ + \ + GET_PD_OR_RETURN(); \ + \ + if ((rp->part->type != EDJE_PART_TYPE_TEXT) && \ + (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) \ + return; \ + \ + txt = (Edje_Part_Description_Text *) pd; \ + txt->text.Value = FROM_DOUBLE(v); \ + edje_object_calc_force(obj); \ + } \ + +FUNC_TEXT_DOUBLE(align_x, align.x); +FUNC_TEXT_DOUBLE(align_y, align.y); +FUNC_TEXT_DOUBLE(elipsis, elipsis); + +#define FUNC_TEXT_BOOL_FIT(Value) \ + EAPI Eina_Bool \ + edje_edit_state_text_fit_##Value##_get(Evas_Object *obj, const char *part, const char *state, double value) \ + { \ + Edje_Part_Description_Text *txt; \ + \ + eina_error_set(0); \ + \ + GET_PD_OR_RETURN(EINA_FALSE); \ + \ + if ((rp->part->type != EDJE_PART_TYPE_TEXT) && \ + (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) \ + return EINA_FALSE; \ + \ + txt = (Edje_Part_Description_Text *) pd; \ + return txt->text.fit_##Value; \ + } \ + EAPI void \ + edje_edit_state_text_fit_##Value##_set(Evas_Object *obj, const char *part, const char *state, double value, Eina_Bool fit) \ + { \ + Edje_Part_Description_Text *txt; \ + \ + GET_PD_OR_RETURN(); \ + \ + if ((rp->part->type != EDJE_PART_TYPE_TEXT) && \ + (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) \ + return; \ + \ + txt = (Edje_Part_Description_Text *) pd; \ + txt->text.fit_##Value = fit ? 1 : 0; \ + edje_object_calc_force(obj); \ + } + +FUNC_TEXT_BOOL_FIT(x); +FUNC_TEXT_BOOL_FIT(y); + +EAPI Eina_List * +edje_edit_fonts_list_get(Evas_Object *obj) +{ + Eina_Iterator *it; + Eina_List *fonts = NULL; + Edje_Font_Directory_Entry *f; + + eina_error_set(0); + + GET_ED_OR_RETURN(NULL); + + if (!ed->file || !ed->file->fonts) return NULL; + + it = eina_hash_iterator_data_new(ed->file->fonts); + if (!it) return NULL; + + EINA_ITERATOR_FOREACH(it, f) + fonts = eina_list_append(fonts, eina_stringshare_add(f->entry)); + + eina_iterator_free(it); + + return fonts; +} + +EAPI Eina_Bool +edje_edit_font_add(Evas_Object *obj, const char* path, const char* alias) +{ + char entry[PATH_MAX]; + char *new_path; + struct stat st; + Edje_Font_Directory_Entry *fnt; + + eina_error_set(0); + + GET_ED_OR_RETURN(EINA_FALSE); + + INF("ADD FONT: %s", path); + + if (!path) return EINA_FALSE; + if (stat(path, &st) || !S_ISREG(st.st_mode)) return EINA_FALSE; + if (!ed->file) return EINA_FALSE; + if (!ed->path) return EINA_FALSE; + + /* Alias */ + if (alias) + { + if ((new_path = strrchr(path, '/'))) new_path ++; + else new_path = (char *)path; + } + else + { + if ((alias = strrchr(path, '/'))) alias ++; + else alias = (char *)path; + new_path = (char *)alias; + } + snprintf(entry, sizeof(entry), "edje/fonts/%s", alias); + + /* Initializing a new font hash, if no exist */ + if (!ed->file->fonts) + { + ed->file->fonts = eina_hash_string_small_new(NULL); + if (!ed->file->fonts) return EINA_FALSE; + } + + /* Check if exists */ + fnt = eina_hash_find(ed->file->fonts, alias); + if (fnt) + return EINA_FALSE; + + /* Create Edje_Font_Directory_Entry */ + fnt = _alloc(sizeof(Edje_Font_Directory_Entry)); + if (!fnt) + { + ERR("Unable to alloc font entry part \"%s\"", alias); + return EINA_FALSE; + } + fnt->file = eina_stringshare_add(new_path); + fnt->entry = eina_stringshare_add(alias); + + eina_hash_direct_add(ed->file->fonts, fnt->entry, fnt); + + /* Import font */ + if (!_edje_import_font_file(ed, path, entry)) + { + eina_hash_del(ed->file->fonts, fnt->entry, fnt); + eina_stringshare_del(fnt->file); + eina_stringshare_del(fnt->entry); + return EINA_FALSE; + } + + return EINA_TRUE; +} + +EAPI Eina_Bool +edje_edit_font_del(Evas_Object *obj, const char* alias) +{ + Edje_Font_Directory_Entry *fnt; + + eina_error_set(0); + + GET_ED_OR_RETURN(EINA_FALSE); + + INF("DEL FONT: %s", alias); + + if (!alias) return EINA_FALSE; + if (!ed->file) return EINA_FALSE; + if (!ed->path) return EINA_FALSE; + + fnt = eina_hash_find(ed->file->fonts, alias); + if (!fnt) + { + WRN("Unable to find font entry part \"%s\"", alias); + return EINA_FALSE; + } + + /* Erase font to edje file */ + { + char entry[PATH_MAX]; + Eet_File *eetf; + + /* open the eet file */ + eetf = eet_open(ed->path, EET_FILE_MODE_READ_WRITE); + if (!eetf) + { + ERR("Unable to open \"%s\" for writing output", ed->path); + return EINA_FALSE; + } + + snprintf(entry, sizeof(entry), "edje/fonts/%s", alias); + + if (eet_delete(eetf, entry) <= 0) + { + ERR("Unable to delete \"%s\" font entry", entry); + eet_close(eetf); + return EINA_FALSE; + } + + /* write the edje_file */ + if (!_edje_edit_edje_file_save(eetf, ed->file)) + { + eet_close(eetf); + return EINA_FALSE; + } + eet_close(eetf); + } + + eina_hash_del(ed->file->fonts, alias, fnt); + + return EINA_TRUE; +} + +EAPI const char * +edje_edit_font_path_get(Evas_Object *obj, const char *alias) +{ + Eina_Iterator *it; + Edje_Font_Directory_Entry *f; + const char *str = NULL; + + eina_error_set(0); + + if (!alias) return NULL; + GET_ED_OR_RETURN(NULL); + + if (!ed->file || !ed->file->fonts) return NULL; + + it = eina_hash_iterator_data_new(ed->file->fonts); + if (!it) return NULL; + + EINA_ITERATOR_FOREACH(it, f) + if (!strcmp(f->entry, alias)) + { + str = f->file; + break; + } + + eina_iterator_free(it); + return eina_stringshare_add(str); +} + +EAPI const char * +edje_edit_state_font_get(Evas_Object *obj, const char *part, const char *state, double value) +{ + Edje_Part_Description_Text *txt; + + eina_error_set(0); + + GET_PD_OR_RETURN(NULL); + + if ((rp->part->type != EDJE_PART_TYPE_TEXT) && + (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) + return NULL; + + txt = (Edje_Part_Description_Text*) pd; + + return eina_stringshare_add(edje_string_get(&txt->text.font)); +} + +EAPI void +edje_edit_state_font_set(Evas_Object *obj, const char *part, const char *state, double value, const char *font) +{ + Edje_Part_Description_Text *txt; + + eina_error_set(0); + + GET_PD_OR_RETURN(); + + if ((rp->part->type != EDJE_PART_TYPE_TEXT) && + (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) + return; + + txt = (Edje_Part_Description_Text*) pd; + + _edje_if_string_free(ed, txt->text.font.str); + txt->text.font.str = (char *)eina_stringshare_add(font); + txt->text.font.id = 0; + + edje_object_calc_force(obj); +} + +EAPI Edje_Text_Effect +edje_edit_part_effect_get(Evas_Object *obj, const char *part) +{ + eina_error_set(0); + + GET_RP_OR_RETURN(0); + + //printf("GET EFFECT of part: %s\n", part); + return rp->part->effect; +} + +EAPI void +edje_edit_part_effect_set(Evas_Object *obj, const char *part, Edje_Text_Effect effect) +{ + eina_error_set(0); + + GET_RP_OR_RETURN(); + + //printf("SET EFFECT of part: %s [%d]\n", part, effect); + rp->part->effect = effect; + + edje_object_calc_force(obj); +} + +/****************/ +/* IMAGES API */ +/****************/ + +EAPI Eina_List * +edje_edit_images_list_get(Evas_Object *obj) +{ + Eina_List *images = NULL; + unsigned int i; + + eina_error_set(0); + + GET_ED_OR_RETURN(NULL); + + if (!ed->file) return NULL; + if (!ed->file->image_dir) return NULL; + + //printf("GET IMAGES LIST for %s\n", ed->file->path); + for (i = 0; i < ed->file->image_dir->entries_count; ++i) + images = eina_list_append(images, + eina_stringshare_add(ed->file->image_dir->entries[i].entry)); + + return images; +} + +EAPI Eina_Bool +edje_edit_image_add(Evas_Object *obj, const char* path) +{ + Edje_Image_Directory_Entry *de; + unsigned int i; + int free_id = -1; + char *name; + + eina_error_set(0); + + GET_ED_OR_RETURN(EINA_FALSE); + + if (!path) return EINA_FALSE; + if (!ed->file) return EINA_FALSE; + if (!ed->path) return EINA_FALSE; + + /* Create Image_Directory if not exist */ + if (!ed->file->image_dir) + { + ed->file->image_dir = _alloc(sizeof(Edje_Image_Directory)); + if (!ed->file->image_dir) return EINA_FALSE; + } + + /* Image name */ + if ((name = strrchr(path, '/'))) name++; + else name = (char *)path; + + /* Loop trough image directory to find if image exist */ + for (i = 0; i < ed->file->image_dir->entries_count; ++i) + { + de = ed->file->image_dir->entries + i; + + if (!de->entry) + free_id = i; + else if (!strcmp(name, de->entry)) + return EINA_FALSE; + } + + if (free_id == -1) + { + Edje_Image_Directory_Entry *tmp; + unsigned int count; + + count = ed->file->image_dir->entries_count + 1; + + tmp = realloc(ed->file->image_dir->entries, + sizeof (Edje_Image_Directory_Entry) * count); + if (!tmp) return EINA_FALSE; + + ed->file->image_dir->entries = tmp; + free_id = ed->file->image_dir->entries_count; + ed->file->image_dir->entries_count = count; + } + + /* Set Image Entry */ + de = ed->file->image_dir->entries + free_id; + de->entry = eina_stringshare_add(name); + de->id = free_id; + de->source_type = 1; + de->source_param = 1; + + /* Import image */ + if (!_edje_import_image_file(ed, path, free_id)) + { + eina_stringshare_del(de->entry); + de->entry = NULL; + return EINA_FALSE; + } + + return EINA_TRUE; +} + +EAPI Eina_Bool +edje_edit_image_del(Evas_Object *obj, const char* name) +{ + Edje_Image_Directory_Entry *de; + unsigned int i; + + eina_error_set(0); + + GET_ED_OR_RETURN(EINA_FALSE); + + if (!name) return EINA_FALSE; + if (!ed->file) return EINA_FALSE; + if (!ed->path) return EINA_FALSE; + + /* Create Image_Directory if not exist */ + if (!ed->file->image_dir) + goto invalid_image; + + return EINA_TRUE; + + for (i = 0; i < ed->file->image_dir->entries_count; ++i) + { + de = ed->file->image_dir->entries + i; + + if (de->entry + && !strcmp(name, de->entry)) + break; + } + + if (i == ed->file->image_dir->entries_count) + goto invalid_image; + + { + char entry[PATH_MAX]; + Eet_File *eetf; + + /* open the eet file */ + eetf = eet_open(ed->path, EET_FILE_MODE_READ_WRITE); + if (!eetf) + { + ERR("Unable to open \"%s\" for writing output", ed->path); + return EINA_FALSE; + } + + snprintf(entry, sizeof(entry), "edje/images/%i", de->id); + + if (eet_delete(eetf, entry) <= 0) + { + ERR("Unable to delete \"%s\" font entry", entry); + eet_close(eetf); + return EINA_FALSE; + } + + /* write the edje_file */ + if (!_edje_edit_edje_file_save(eetf, ed->file)) + { + eet_close(eetf); + return EINA_FALSE; + } + + eet_close(eetf); + } + + _edje_if_string_free(ed, de->entry); + de->entry = NULL; + + _edje_edit_flag_script_dirty(eed, EINA_TRUE); + + return EINA_TRUE; + +invalid_image: + WRN("Unable to find image entry part \"%s\"", name); + return EINA_FALSE; +} + +EAPI Eina_Bool +edje_edit_image_data_add(Evas_Object *obj, const char *name, int id) +{ + Edje_Image_Directory_Entry *de; + + eina_error_set(0); + + GET_ED_OR_RETURN(EINA_FALSE); + + if (!name) return EINA_FALSE; + if (!ed->file) return EINA_FALSE; + if (!ed->path) return EINA_FALSE; + + /* Create Image_Directory if not exist */ + if (!ed->file->image_dir) + { + ed->file->image_dir = _alloc(sizeof(Edje_Image_Directory)); + if (!ed->file->image_dir) return EINA_FALSE; + } + + /* Loop trough image directory to find if image exist */ + if (id < 0) id = - id - 1; + if ((unsigned int) id >= ed->file->image_dir->entries_count) return EINA_FALSE; + + de = ed->file->image_dir->entries + id; + eina_stringshare_replace(&de->entry, name); + de->source_type = 1; + de->source_param = 1; + + return EINA_TRUE; +} + +EAPI int +edje_edit_image_id_get(Evas_Object *obj, const char *image_name) +{ + eina_error_set(0); + + GET_ED_OR_RETURN(-1); + + return _edje_image_id_find(eed, image_name); +} + +EAPI Edje_Edit_Image_Comp +edje_edit_image_compression_type_get(Evas_Object *obj, const char *image) +{ + Edje_Image_Directory_Entry *de = NULL; + unsigned int i; + + eina_error_set(0); + + GET_ED_OR_RETURN(-1); + + if (!ed->file) return -1; + if (!ed->file->image_dir) return -1; + + for (i = 0; i < ed->file->image_dir->entries_count; ++i) + { + de = ed->file->image_dir->entries + i; + + if (de->entry + && !strcmp(image, de->entry)) + break; + } + + if (i == ed->file->image_dir->entries_count) return -1; + + switch(de->source_type) + { + case EDJE_IMAGE_SOURCE_TYPE_INLINE_PERFECT: + if (de->source_param == 0) // RAW + return EDJE_EDIT_IMAGE_COMP_RAW; + else // COMP + return EDJE_EDIT_IMAGE_COMP_COMP; + break; + case EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY: // LOSSY + return EDJE_EDIT_IMAGE_COMP_LOSSY; + break; + case EDJE_IMAGE_SOURCE_TYPE_EXTERNAL: // USER + return EDJE_EDIT_IMAGE_COMP_USER; + break; + } + + return -1; +} + +EAPI int +edje_edit_image_compression_rate_get(Evas_Object *obj, const char *image) +{ + Edje_Image_Directory_Entry *de; + unsigned int i; + + eina_error_set(0); + + GET_ED_OR_RETURN(-1); + + // Gets the Image Entry + for (i = 0; i < ed->file->image_dir->entries_count; ++i) + { + de = ed->file->image_dir->entries + i; + if (de->entry + && !strcmp(de->entry, image)) + break; + } + + if (i == ed->file->image_dir->entries_count) return -1; + if (de->source_type != EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY) return -2; + + return de->source_param; +} + +EAPI const char * +edje_edit_state_image_get(Evas_Object *obj, const char *part, const char *state, double value) +{ + Edje_Part_Description_Image *img; + const char *image; + + eina_error_set(0); + + GET_PD_OR_RETURN(NULL); + + if (rp->part->type != EDJE_PART_TYPE_IMAGE) + return NULL; + + img = (Edje_Part_Description_Image *) pd; + + image = _edje_image_name_find(eed, img->image.id); + if (!image) return NULL; + + //printf("GET IMAGE for %s [%s]\n", state, image); + return eina_stringshare_add(image); +} + +EAPI void +edje_edit_state_image_set(Evas_Object *obj, const char *part, const char *state, double value, const char *image) +{ + Edje_Part_Description_Image *img; + int id; + + eina_error_set(0); + + GET_PD_OR_RETURN(); + + if (!image) return; + + if (rp->part->type != EDJE_PART_TYPE_IMAGE) + return; + + id = _edje_image_id_find(eed, image); + //printf("SET IMAGE for %s [%s]\n", state, image); + + img = (Edje_Part_Description_Image *) pd; + + if (id > -1) img->image.id = id; + + edje_object_calc_force(obj); +} + +EAPI Eina_List * +edje_edit_state_tweens_list_get(Evas_Object *obj, const char *part, const char *state, double value) +{ + Edje_Part_Description_Image *img; + Eina_List *tweens = NULL; + const char *name; + unsigned int i; + + eina_error_set(0); + + GET_PD_OR_RETURN(NULL); + + if (rp->part->type != EDJE_PART_TYPE_IMAGE) + return NULL; + + img = (Edje_Part_Description_Image *) pd; + + for (i = 0; i < img->image.tweens_count; ++i) + { + name = _edje_image_name_find(eed, img->image.tweens[i]->id); + //printf(" t: %s\n", name); + tweens = eina_list_append(tweens, eina_stringshare_add(name)); + } + + return tweens; +} + +EAPI Eina_Bool +edje_edit_state_tween_add(Evas_Object *obj, const char *part, const char *state, double value, const char *tween) +{ + Edje_Part_Description_Image *img; + Edje_Part_Image_Id **tmp; + Edje_Part_Image_Id *i; + int id; + + eina_error_set(0); + + GET_PD_OR_RETURN(EINA_FALSE); + + if (rp->part->type != EDJE_PART_TYPE_IMAGE) + return EINA_FALSE; + + id = _edje_image_id_find(eed, tween); + if (id < EINA_FALSE) return 0; + + /* alloc Edje_Part_Image_Id */ + i = _alloc(sizeof(Edje_Part_Image_Id)); + if (!i) return EINA_FALSE; + i->id = id; + + img = (Edje_Part_Description_Image *) pd; + + /* add to tween list */ + tmp = realloc(img->image.tweens, + sizeof (Edje_Part_Image_Id*) * img->image.tweens_count); + if (!tmp) + { + free(i); + return EINA_FALSE; + } + + tmp[img->image.tweens_count++] = i; + img->image.tweens = tmp; + + return EINA_TRUE; +} + +EAPI Eina_Bool +edje_edit_state_tween_del(Evas_Object *obj, const char *part, const char *state, double value, const char *tween) +{ + Edje_Part_Description_Image *img; + unsigned int i; + int search; + + eina_error_set(0); + + GET_PD_OR_RETURN(EINA_FALSE); + + if (rp->part->type != EDJE_PART_TYPE_IMAGE) + return EINA_FALSE; + + img = (Edje_Part_Description_Image *) pd; + + if (!img->image.tweens_count) return EINA_FALSE; + + search = _edje_image_id_find(eed, tween); + if (search < 0) return EINA_FALSE; + + for (i = 0; i < img->image.tweens_count; ++i) + { + if (img->image.tweens[i]->id == search) + { + img->image.tweens_count--; + free(img->image.tweens[i]); + memmove(img->image.tweens + i, + img->image.tweens + i + 1, + sizeof (Edje_Part_Description_Image*) * (img->image.tweens_count - i)); + return EINA_TRUE; + } + } + return EINA_FALSE; +} + +EAPI 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) +{ + Edje_Part_Description_Image *img; + + eina_error_set(0); + + GET_PD_OR_RETURN(); + + if (rp->part->type != EDJE_PART_TYPE_IMAGE) + { + if (l) *l = 0; + if (r) *r = 0; + if (t) *t = 0; + if (b) *b = 0; + return; + } + + img = (Edje_Part_Description_Image *) pd; + + //printf("GET IMAGE_BORDER of state '%s'\n", state); + + if (l) *l = img->image.border.l; + if (r) *r = img->image.border.r; + if (t) *t = img->image.border.t; + if (b) *b = img->image.border.b; +} + +EAPI 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) +{ + Edje_Part_Description_Image *img; + + eina_error_set(0); + + GET_PD_OR_RETURN(); + + if (rp->part->type != EDJE_PART_TYPE_IMAGE) + return; + + img = (Edje_Part_Description_Image *) pd; + + //printf("SET IMAGE_BORDER of state '%s'\n", state); + + if (l > -1) img->image.border.l = l; + if (r > -1) img->image.border.r = r; + if (t > -1) img->image.border.t = t; + if (b > -1) img->image.border.b = b; + + edje_object_calc_force(obj); +} + +EAPI unsigned char +edje_edit_state_image_border_fill_get(Evas_Object *obj, const char *part, const char *state, double value) +{ + Edje_Part_Description_Image *img; + + eina_error_set(0); + + GET_PD_OR_RETURN(0); + + if (rp->part->type != EDJE_PART_TYPE_IMAGE) + return 0; + + img = (Edje_Part_Description_Image *) pd; + + if (img->image.border.no_fill == 0) return 1; + else if (img->image.border.no_fill == 1) return 0; + else if (img->image.border.no_fill == 2) return 2; + return 0; +} + +EAPI void +edje_edit_state_image_border_fill_set(Evas_Object *obj, const char *part, const char *state, double value, unsigned char fill) +{ + Edje_Part_Description_Image *img; + + eina_error_set(0); + + GET_PD_OR_RETURN(); + + if (rp->part->type != EDJE_PART_TYPE_IMAGE) + return; + + img = (Edje_Part_Description_Image *) pd; + + if (fill == 0) img->image.border.no_fill = 1; + else if (fill == 1) img->image.border.no_fill = 0; + else if (fill == 2) img->image.border.no_fill = 2; + + edje_object_calc_force(obj); +} + +/******************/ +/* PROGRAMS API */ +/******************/ +static int +_edje_program_id_find(Edje_Edit *eed, const char *program) +{ + Edje_Program *epr; + int i; + + for (i = 0; i < eed->base.table_programs_size; i++) + { + epr = eed->base.table_programs[i]; + if (epr->name && !strcmp(epr->name, program)) + return epr->id; + } + return -1; +} + +static Edje_Program * +_edje_program_get_byname(Evas_Object *obj, const char *prog_name) +{ + Edje_Program *epr; + int i; + + GET_ED_OR_RETURN(NULL); + + if (!prog_name) return NULL; + + for (i = 0; i < ed->table_programs_size; i++) + { + epr = ed->table_programs[i]; + if ((epr->name) && (strcmp(epr->name, prog_name) == 0)) + return epr; + } + return NULL; +} + +EAPI Eina_List * +edje_edit_programs_list_get(Evas_Object *obj) +{ + Eina_List *progs = NULL; + int i; + + eina_error_set(0); + + GET_ED_OR_RETURN(NULL); + + //printf("EE: Found %d programs\n", ed->table_programs_size); + + for (i = 0; i < ed->table_programs_size; i++) + { + Edje_Program *epr; + + epr = ed->table_programs[i]; + /* XXX: bad, we miss programs this way, but since you can't access + * them in any way without a name, better ignore them. */ + if (!epr->name) continue; + progs = eina_list_append(progs, eina_stringshare_add(epr->name)); + } + + return progs; +} + +EAPI Eina_Bool +edje_edit_program_add(Evas_Object *obj, const char *name) +{ + Edje_Program *epr; + Edje_Part_Collection *pc; + + eina_error_set(0); + + GET_ED_OR_RETURN(EINA_FALSE); + + //printf("ADD PROGRAM [new name: %s]\n", name); + + //Check if program already exists + if (_edje_program_get_byname(obj, name)) + return EINA_FALSE; + + //Alloc Edje_Program or return + epr = _alloc(sizeof(Edje_Program)); + if (!epr) return EINA_FALSE; + + //Add program to group + pc = ed->collection; + + /* By default, source and signal are empty, so they fill in nocmp category */ + ed->collection->programs.nocmp = realloc(ed->collection->programs.nocmp, + sizeof (Edje_Program*) * (ed->collection->programs.nocmp_count + 1)); + ed->collection->programs.nocmp[ed->collection->programs.nocmp_count++] = epr; + + //Init Edje_Program + epr->id = ed->table_programs_size; + epr->name = eina_stringshare_add(name); + epr->signal = NULL; + epr->source = NULL; + epr->filter.part = NULL; + epr->filter.state = NULL; + epr->in.from = 0.0; + epr->in.range = 0.0; + epr->action = 0; + epr->state = NULL; + epr->value = 0.0; + epr->state2 = NULL; + epr->value2 = 0.0; + epr->tween.mode = 1; + epr->tween.time = ZERO; + epr->targets = NULL; + epr->after = NULL; + + + //Update table_programs + ed->table_programs_size++; + ed->table_programs = realloc(ed->table_programs, + sizeof(Edje_Program *) * ed->table_programs_size); + ed->table_programs[epr->id % ed->table_programs_size] = epr; + + //Update patterns + _edje_programs_patterns_clean(ed); + _edje_programs_patterns_init(ed); + + return EINA_TRUE; +} + +EAPI Eina_Bool +edje_edit_program_del(Evas_Object *obj, const char *prog) +{ + Eina_List *l, *l_next; + Edje_Program_Target *prt; + Edje_Program_After *pa; + Edje_Part_Collection *pc; + Edje_Program *p; + Program_Script *ps, *old_ps; + int id, i; + int old_id = -1; + + eina_error_set(0); + + GET_ED_OR_RETURN(EINA_FALSE); + GET_EPR_OR_RETURN(EINA_FALSE); + + pc = ed->collection; + + //Remove program from programs list + id = epr->id; + _edje_program_remove(ed->collection, epr); + + /* fix table program */ + if (epr->id != ed->table_programs_size - 1) + { + /* If the removed program is not the last in the list/table, + * put the last one in its place and update references to it later */ + ed->table_programs[epr->id] = ed->table_programs[ed->table_programs_size - 1]; + old_id = ed->table_programs_size - 1; + ed->table_programs[epr->id]->id = epr->id; + } + + ps = eina_hash_find(eed->program_scripts, &id); + old_ps = eina_hash_find(eed->program_scripts, &old_id); + if (old_ps) + { + if (!ps) + { + ps = _alloc(sizeof(Program_Script)); + ps->id = id; + eina_hash_add(eed->program_scripts, &id, ps); + } + else + { + free(ps->code); + free(ps->processed); + ps->processed = NULL; + ps->delete_me = EINA_FALSE; + } + ps->code = old_ps->code; + old_ps->code = NULL; + free(old_ps->processed); + old_ps->processed = NULL; + ps->dirty = EINA_TRUE; + old_ps->dirty = EINA_FALSE; + old_ps->delete_me = EINA_TRUE; + } + else if (ps) + { + ps->dirty = EINA_FALSE; + ps->delete_me = EINA_TRUE; + } + + //Free Edje_Program + _edje_if_string_free(ed, epr->name); + _edje_if_string_free(ed, epr->signal); + _edje_if_string_free(ed, epr->source); + _edje_if_string_free(ed, epr->filter.part); + _edje_if_string_free(ed, epr->filter.state); + _edje_if_string_free(ed, epr->state); + _edje_if_string_free(ed, epr->state2); + + EINA_LIST_FREE(epr->targets, prt) + free(prt); + EINA_LIST_FREE(epr->after, pa) + free(pa); + free(epr); + + ed->table_programs_size--; + ed->table_programs = realloc(ed->table_programs, + sizeof(Edje_Program *) * ed->table_programs_size); + + //We also update all other programs that point to old_id and id + for (i = 0; i < ed->table_programs_size; i++) + { + p = ed->table_programs[i]; + + /* check in afters */ + EINA_LIST_FOREACH_SAFE(p->after, l, l_next, pa) + { + if (pa->id == old_id) + pa->id = id; + else if (pa->id == id) + { + p->after = eina_list_remove_list(p->after, l); + free(pa); + } + } + /* check in targets */ + if (p->action == EDJE_ACTION_TYPE_ACTION_STOP) + { + Edje_Program_Target *pt; + + EINA_LIST_FOREACH_SAFE(p->targets, l, l_next, pt) + { + if (pt->id == old_id) + pt->id = id; + else if (pt->id == id) + { + p->targets = eina_list_remove_list(p->targets, l); + free(pt); + } + } + } + } + + _edje_edit_flag_script_dirty(eed, EINA_TRUE); + + return EINA_TRUE; +} + +EAPI Eina_Bool +edje_edit_program_exist(Evas_Object *obj, const char *prog) +{ + eina_error_set(0); + + GET_EPR_OR_RETURN(EINA_FALSE); + + return EINA_TRUE; +} + +EAPI Eina_Bool +edje_edit_program_run(Evas_Object *obj, const char *prog) +{ + eina_error_set(0); + + GET_ED_OR_RETURN(EINA_FALSE); + GET_EPR_OR_RETURN(EINA_FALSE); + + _edje_program_run(ed, epr, 0, "", ""); + return EINA_TRUE; +} + +EAPI Eina_Bool +edje_edit_program_name_set(Evas_Object *obj, const char *prog, const char* new_name) +{ + eina_error_set(0); + + GET_ED_OR_RETURN(EINA_FALSE); + GET_EPR_OR_RETURN(EINA_FALSE); + + if (!new_name) return EINA_FALSE; + + if (_edje_program_get_byname(obj, new_name)) return EINA_FALSE; + + //printf("SET NAME for program: %s [new name: %s]\n", prog, new_name); + + _edje_if_string_free(ed, epr->name); + epr->name = eina_stringshare_add(new_name); + + _edje_edit_flag_script_dirty(eed, EINA_TRUE); + + return EINA_TRUE; +} + +EAPI const char * +edje_edit_program_source_get(Evas_Object *obj, const char *prog) +{ + eina_error_set(0); + + GET_EPR_OR_RETURN(NULL); + + if (!epr->source) return NULL; + //printf("GET SOURCE for program: %s [%s]\n", prog, epr->source); + return eina_stringshare_add(epr->source); +} + +EAPI Eina_Bool +edje_edit_program_source_set(Evas_Object *obj, const char *prog, const char *source) +{ + eina_error_set(0); + + GET_ED_OR_RETURN(EINA_FALSE); + GET_EPR_OR_RETURN(EINA_FALSE); + + if (!source) return EINA_FALSE; + + /* Remove from program array */ + _edje_program_remove(ed->collection, epr); + _edje_if_string_free(ed, epr->source); + + /* Insert it back */ + epr->source = eina_stringshare_add(source); + _edje_program_insert(ed->collection, epr); + + //Update patterns + _edje_programs_patterns_clean(ed); + _edje_programs_patterns_init(ed); + + return EINA_TRUE; +} + +EAPI const char * +edje_edit_program_filter_part_get(Evas_Object *obj, const char *prog) +{ + eina_error_set(0); + + GET_EPR_OR_RETURN(NULL); + + if (!epr->filter.part) return NULL; + return eina_stringshare_add(epr->filter.part); +} + +EAPI Eina_Bool +edje_edit_program_filter_part_set(Evas_Object *obj, const char *prog, const char *filter_part) +{ + eina_error_set(0); + + GET_ED_OR_RETURN(EINA_FALSE); + GET_EPR_OR_RETURN(EINA_FALSE); + + if (!filter_part) return EINA_FALSE; + + _edje_if_string_free(ed, epr->filter.part); + epr->filter.part = eina_stringshare_add(filter_part); + + return EINA_TRUE; +} + +EAPI const char * +edje_edit_program_filter_state_get(Evas_Object *obj, const char *prog) +{ + eina_error_set(0); + + GET_EPR_OR_RETURN(NULL); + + if (!epr->filter.state) return NULL; + return eina_stringshare_add(epr->filter.state); +} + +EAPI Eina_Bool +edje_edit_program_filter_state_set(Evas_Object *obj, const char *prog, const char *filter_state) +{ + eina_error_set(0); + + GET_ED_OR_RETURN(EINA_FALSE); + GET_EPR_OR_RETURN(EINA_FALSE); + + if (!filter_state) return EINA_FALSE; + + _edje_if_string_free(ed, epr->filter.state); + epr->filter.state = eina_stringshare_add(filter_state); + + return EINA_TRUE; +} + +EAPI const char * +edje_edit_program_signal_get(Evas_Object *obj, const char *prog) +{ + eina_error_set(0); + + GET_EPR_OR_RETURN(NULL); + + if (!epr->signal) return NULL; + //printf("GET SIGNAL for program: %s [%s]\n", prog, epr->signal); + return eina_stringshare_add(epr->signal); +} + +EAPI Eina_Bool +edje_edit_program_signal_set(Evas_Object *obj, const char *prog, const char *sig) +{ + eina_error_set(0); + + GET_ED_OR_RETURN(EINA_FALSE); + GET_EPR_OR_RETURN(EINA_FALSE); + + if (!sig) return EINA_FALSE; + + /* Remove from program array */ + _edje_program_remove(ed->collection, epr); + _edje_if_string_free(ed, epr->signal); + + /* Insert it back */ + epr->signal = eina_stringshare_add(sig); + _edje_program_insert(ed->collection, epr); + + //Update patterns + _edje_programs_patterns_clean(ed); + _edje_programs_patterns_init(ed); + + return EINA_TRUE; +} + +EAPI const char * +edje_edit_program_state_get(Evas_Object *obj, const char *prog) +{ + eina_error_set(0); + + GET_EPR_OR_RETURN(NULL); + + if (!epr->state) return NULL; + //printf("GET STATE for program: %s [%s %.2f]\n", prog, epr->state, epr->value); + return eina_stringshare_add(epr->state); +} + +EAPI Eina_Bool +edje_edit_program_state_set(Evas_Object *obj, const char *prog, const char *state) +{ + eina_error_set(0); + + GET_ED_OR_RETURN(EINA_FALSE); + GET_EPR_OR_RETURN(EINA_FALSE); + + //printf("SET STATE for program: %s\n", prog); + + _edje_if_string_free(ed, epr->state); + epr->state = eina_stringshare_add(state); + + return EINA_TRUE; +} + +EAPI const char * +edje_edit_program_state2_get(Evas_Object *obj, const char *prog) +{ + eina_error_set(0); + + GET_EPR_OR_RETURN(NULL); + + if (!epr->state2) return NULL; + //printf("GET STATE2 for program: %s [%s %.2f]\n", prog, epr->state2, epr->value2); + return eina_stringshare_add(epr->state2); +} + +EAPI Eina_Bool +edje_edit_program_state2_set(Evas_Object *obj, const char *prog, const char *state2) +{ + eina_error_set(0); + + GET_ED_OR_RETURN(EINA_FALSE); + GET_EPR_OR_RETURN(EINA_FALSE); + + //printf("SET STATE2 for program: %s\n", prog); + + _edje_if_string_free(ed, epr->state2); + epr->state2 = eina_stringshare_add(state2); + + return EINA_TRUE; +} + +EAPI double +edje_edit_program_value_get(Evas_Object *obj, const char *prog) +{ + eina_error_set(0); + + GET_EPR_OR_RETURN(-1); + + //printf("GET VALUE for program: %s [%s %.2f]\n", prog, epr->state, epr->value); + return epr->value; +} + +EAPI Eina_Bool +edje_edit_program_value_set(Evas_Object *obj, const char *prog, double value) +{ + eina_error_set(0); + + GET_EPR_OR_RETURN(EINA_FALSE); + + //printf("SET VALUE for program: %s [%.2f]\n", prog, value); + epr->value = value; + return EINA_TRUE; +} + +EAPI double +edje_edit_program_value2_get(Evas_Object *obj, const char *prog) +{ + eina_error_set(0); + + GET_EPR_OR_RETURN(-1); + + //printf("GET VALUE2 for program: %s [%s %.2f]\n", prog, epr->state2, epr->value2); + return epr->value2; +} + +EAPI Eina_Bool +edje_edit_program_value2_set(Evas_Object *obj, const char *prog, double value) +{ + eina_error_set(0); + + GET_EPR_OR_RETURN(EINA_FALSE); + + //printf("SET VALUE for program: %s [%.2f]\n", prog, value); + epr->value2 = value; + return EINA_TRUE; +} + +EAPI double +edje_edit_program_in_from_get(Evas_Object *obj, const char *prog) +{ + eina_error_set(0); + + GET_EPR_OR_RETURN(0); + + //printf("GET IN.FROM for program: %s [%f]\n", prog, epr->in.from); + return epr->in.from; +} + +EAPI Eina_Bool +edje_edit_program_in_from_set(Evas_Object *obj, const char *prog, double seconds) +{ + eina_error_set(0); + + GET_EPR_OR_RETURN(EINA_FALSE); + + //printf("SET IN.FROM for program: %s [%f]\n", prog, epr->in.from); + epr->in.from = seconds; + return EINA_TRUE; +} + +EAPI double +edje_edit_program_in_range_get(Evas_Object *obj, const char *prog) +{ + eina_error_set(0); + + GET_EPR_OR_RETURN(0); + + //printf("GET IN.RANGE for program: %s [%f]\n", prog, epr->in.range); + return epr->in.range; +} + +EAPI Eina_Bool +edje_edit_program_in_range_set(Evas_Object *obj, const char *prog, double seconds) +{ + eina_error_set(0); + + GET_EPR_OR_RETURN(EINA_FALSE); + + //printf("SET IN.RANGE for program: %s [%f]\n", prog, epr->in.range); + epr->in.range = seconds; + return EINA_TRUE; +} + +EAPI Edje_Tween_Mode +edje_edit_program_transition_get(Evas_Object *obj, const char *prog) +{ + eina_error_set(0); + + GET_EPR_OR_RETURN(-1); + + //printf("GET TRANSITION for program: %s [%d]\n", prog, epr->tween.mode); + return epr->tween.mode; +} + +EAPI Eina_Bool +edje_edit_program_transition_set(Evas_Object *obj, const char *prog, Edje_Tween_Mode transition) +{ + eina_error_set(0); + + GET_EPR_OR_RETURN(EINA_FALSE); + + //printf("GET TRANSITION for program: %s [%d]\n", prog, epr->tween.mode); + epr->tween.mode = transition; + return EINA_TRUE; +} + +EAPI double +edje_edit_program_transition_time_get(Evas_Object *obj, const char *prog) +{ + eina_error_set(0); + + GET_EPR_OR_RETURN(-1); + + //printf("GET TRANSITION_TIME for program: %s [%.4f]\n", prog, epr->tween.time); + return TO_DOUBLE(epr->tween.time); +} + +EAPI Eina_Bool +edje_edit_program_transition_time_set(Evas_Object *obj, const char *prog, double seconds) +{ + eina_error_set(0); + + GET_EPR_OR_RETURN(EINA_FALSE); + + //printf("GET TRANSITION_TIME for program: %s [%.4f]\n", prog, epr->tween.time); + epr->tween.time = FROM_DOUBLE(seconds); + return EINA_TRUE; +} + +EAPI Edje_Action_Type +edje_edit_program_action_get(Evas_Object *obj, const char *prog) +{ + eina_error_set(0); + + GET_EPR_OR_RETURN(-1); + + //printf("GET ACTION for program: %s [%d]\n", prog, epr->action); + return epr->action; +} + +EAPI Eina_Bool +edje_edit_program_action_set(Evas_Object *obj, const char *prog, Edje_Action_Type action) +{ + Program_Script *ps; + + eina_error_set(0); + + GET_ED_OR_RETURN(EINA_FALSE); + GET_EPR_OR_RETURN(EINA_FALSE); + + //printf("SET ACTION for program: %s [%d]\n", prog, action); + if (action >= EDJE_ACTION_TYPE_LAST) return EINA_FALSE; + + if ((Edje_Action_Type)epr->action == action) + return EINA_TRUE; + + if (action == EDJE_ACTION_TYPE_SCRIPT) + { + ps = eina_hash_find(eed->program_scripts, &epr->id); + if (!ps) + { + ps = _alloc(sizeof(Program_Script)); + if (!ps) + return EINA_FALSE; + } + ps->id = epr->id; + ps->code = strdup(""); + ps->dirty = EINA_TRUE; + ps->delete_me = EINA_FALSE; + eina_hash_set(eed->program_scripts, &ps->id, ps); + _edje_edit_flag_script_dirty(eed, EINA_FALSE); + } + if (epr->action == EDJE_ACTION_TYPE_SCRIPT) + { + ps = eina_hash_find(eed->program_scripts, &epr->id); + if (ps) + { + free(ps->code); + free(ps->processed); + ps->code = ps->processed = NULL; + ps->dirty = EINA_FALSE; + ps->delete_me = EINA_TRUE; + _edje_edit_flag_script_dirty(eed, EINA_FALSE); + } + } + + epr->action = action; + return EINA_TRUE; +} + +EAPI Eina_List * +edje_edit_program_targets_get(Evas_Object *obj, const char *prog) +{ + Eina_List *l, *targets = NULL; + Edje_Program_Target *t; + + eina_error_set(0); + + GET_ED_OR_RETURN(NULL); + GET_EPR_OR_RETURN(NULL); + + //printf("GET TARGETS for program: %s [count: %d]\n", prog, eina_list_count(epr->targets)); + EINA_LIST_FOREACH(epr->targets, l, t) + { + if (epr->action == EDJE_ACTION_TYPE_STATE_SET) + { + /* the target is a part */ + Edje_Real_Part *p = NULL; + + p = ed->table_parts[t->id % ed->table_parts_size]; + if (p && p->part && p->part->name) + targets = eina_list_append(targets, + eina_stringshare_add(p->part->name)); + } + else if (epr->action == EDJE_ACTION_TYPE_ACTION_STOP) + { + /* the target is a program */ + Edje_Program *p; + + p = ed->table_programs[t->id % ed->table_programs_size]; + if (p && p->name) + targets = eina_list_append(targets, + eina_stringshare_add(p->name)); + } + } + return targets; +} + +EAPI Eina_Bool +edje_edit_program_targets_clear(Evas_Object *obj, const char *prog) +{ + eina_error_set(0); + + GET_EPR_OR_RETURN(EINA_FALSE); + + while (epr->targets) + { + Edje_Program_Target *prt; + + prt = eina_list_data_get(epr->targets); + epr->targets = eina_list_remove_list(epr->targets, epr->targets); + free(prt); + } + + return EINA_TRUE; +} + +EAPI Eina_Bool +edje_edit_program_target_add(Evas_Object *obj, const char *prog, const char *target) +{ + int id; + Edje_Program_Target *t; + + eina_error_set(0); + + GET_ED_OR_RETURN(EINA_FALSE); + GET_EPR_OR_RETURN(EINA_FALSE); + + if (epr->action == EDJE_ACTION_TYPE_STATE_SET) + { + /* the target is a part */ + Edje_Real_Part *rp; + + rp = _edje_real_part_get(ed, target); + if (!rp) return EINA_FALSE; + id = rp->part->id; + } + else if (epr->action == EDJE_ACTION_TYPE_ACTION_STOP) + { + /* the target is a program */ + Edje_Program *tar; + + tar = _edje_program_get_byname(obj, target); + if (!tar) return EINA_FALSE; + id = tar->id; + } + else + return EINA_FALSE; + + t = _alloc(sizeof(Edje_Program_Target)); + if (!t) return EINA_FALSE; + + t->id = id; + epr->targets = eina_list_append(epr->targets, t); + + return EINA_TRUE; +} + +EAPI Eina_Bool +edje_edit_program_target_del(Evas_Object *obj, const char *prog, const char *target) +{ + int id; + Eina_List *l; + Edje_Program_Target *t; + + eina_error_set(0); + + GET_ED_OR_RETURN(EINA_FALSE); + GET_EPR_OR_RETURN(EINA_FALSE); + + if (epr->action == EDJE_ACTION_TYPE_STATE_SET) + { + /* the target is a part */ + Edje_Real_Part *rp; + + rp = _edje_real_part_get(ed, target); + if (!rp) return EINA_FALSE; + id = rp->part->id; + } + else if (epr->action == EDJE_ACTION_TYPE_ACTION_STOP) + { + /* the target is a program */ + Edje_Program *tar; + + tar = _edje_program_get_byname(obj, target); + if (!tar) return EINA_FALSE; + id = tar->id; + } + else + return EINA_FALSE; + + EINA_LIST_FOREACH(epr->targets, l, t) + if (t->id == id) + break; + epr->targets = eina_list_remove_list(epr->targets, l); + free(t); + + return EINA_TRUE; +} + +EAPI Eina_List * +edje_edit_program_afters_get(Evas_Object *obj, const char *prog) +{ + Eina_List *l, *afters = NULL; + Edje_Program_After *a; + + eina_error_set(0); + + GET_ED_OR_RETURN(NULL); + GET_EPR_OR_RETURN(NULL); + + // printf("GET AFTERS for program: %s [count: %d]\n", prog, eina_list_count(epr->after)); + EINA_LIST_FOREACH(epr->after, l, a) + { + Edje_Program *p = NULL; + + p = ed->table_programs[a->id % ed->table_programs_size]; + if (p && p->name) + { + //printf(" a: %d name: %s\n", a->id, p->name); + afters = eina_list_append(afters, eina_stringshare_add(p->name)); + } + } + return afters; +} + +EAPI Eina_Bool +edje_edit_program_afters_clear(Evas_Object *obj, const char *prog) +{ + eina_error_set(0); + + GET_EPR_OR_RETURN(EINA_FALSE); + + while (epr->after) + { + Edje_Program_After *pa; + + pa = eina_list_data_get(epr->after); + epr->after = eina_list_remove_list(epr->after, epr->after); + free(pa); + } + + return EINA_TRUE; +} + +EAPI Eina_Bool +edje_edit_program_after_add(Evas_Object *obj, const char *prog, const char *after) +{ + Edje_Program *af; + Edje_Program_After *a; + + eina_error_set(0); + + GET_EPR_OR_RETURN(EINA_FALSE); + + af = _edje_program_get_byname(obj, after); + if (!af) return EINA_FALSE; + + a = _alloc(sizeof(Edje_Program_After)); + if (!a) return EINA_FALSE; + + a->id = af->id; + + epr->after = eina_list_append(epr->after, a); + + return EINA_TRUE; +} + +EAPI Eina_Bool +edje_edit_program_after_del(Evas_Object *obj, const char *prog, const char *after) +{ + Edje_Program *af; + Edje_Program_After *a; + Eina_List *l; + + eina_error_set(0); + + GET_EPR_OR_RETURN(EINA_FALSE); + + af = _edje_program_get_byname(obj, after); + if (!af) return EINA_FALSE; + + EINA_LIST_FOREACH(epr->after, l, a) + if (a->id == af->id) + { + epr->after = eina_list_remove_list(epr->after, l); + break; + } + + return EINA_TRUE; +} + +EAPI const char * +edje_edit_program_api_name_get(Evas_Object *obj, const char *prog) +{ + eina_error_set(0); + + GET_EPR_OR_RETURN(NULL); + + return eina_stringshare_add(epr->api.name); +} + +EAPI const char * +edje_edit_program_api_description_get(Evas_Object *obj, const char *prog) +{ + eina_error_set(0); + + GET_EPR_OR_RETURN(NULL); + + return eina_stringshare_add(epr->api.description); +} + +EAPI Eina_Bool +edje_edit_program_api_name_set(Evas_Object *obj, const char *prog, const char* name) +{ + eina_error_set(0); + + GET_ED_OR_RETURN(EINA_FALSE); + GET_EPR_OR_RETURN(EINA_FALSE); + + _edje_if_string_free(ed, epr->api.name); + epr->api.name = eina_stringshare_add(name); + + return EINA_TRUE; +} + +EAPI Eina_Bool +edje_edit_program_api_description_set(Evas_Object *obj, const char *prog, const char *description) +{ + eina_error_set(0); + + GET_ED_OR_RETURN(EINA_FALSE); + GET_EPR_OR_RETURN(EINA_FALSE); + + _edje_if_string_free(ed, epr->api.description); + epr->api.description = eina_stringshare_add(description); + + return EINA_TRUE; +} + +/*************************/ +/* EMBRYO SCRIPTS API */ +/*************************/ +EAPI char * +edje_edit_script_get(Evas_Object *obj) +{ + eina_error_set(0); + + GET_ED_OR_RETURN(NULL); + + if (!ed->collection) return NULL; + if (!eed->embryo_source) return NULL; + + return strdup(eed->embryo_source); +} + +EAPI void +edje_edit_script_set(Evas_Object *obj, const char *code) +{ + eina_error_set(0); + + GET_ED_OR_RETURN(); + + free(eed->embryo_source); + free(eed->embryo_processed); + + if (code) + eed->embryo_source = strdup(code); + else + eed->embryo_source = NULL; + eed->embryo_processed = NULL; + + eed->embryo_source_dirty = EINA_TRUE; + + _edje_edit_flag_script_dirty(eed, EINA_FALSE); +} + +EAPI char * +edje_edit_script_program_get(Evas_Object *obj, const char *prog) +{ + Program_Script *ps; + + eina_error_set(0); + + GET_ED_OR_RETURN(NULL); + GET_EPR_OR_RETURN(NULL); + + if (epr->action != EDJE_ACTION_TYPE_SCRIPT) + return NULL; + + ps = eina_hash_find(eed->program_scripts, prog); + if (!ps) /* mmm? it should be there, even if empty */ + return NULL; + + return ps->code ? strdup(ps->code) : NULL; +} + +EAPI void +edje_edit_script_program_set(Evas_Object *obj, const char *prog, const char *code) +{ + Program_Script *ps; + + eina_error_set(0); + + GET_ED_OR_RETURN(); + GET_EPR_OR_RETURN(); + + if (epr->action != EDJE_ACTION_TYPE_SCRIPT) + return; + + ps = eina_hash_find(eed->program_scripts, prog); + if (!ps) /* ???? how so? */ + return; + + free(ps->code); + free(ps->processed); + + if (code) + ps->code = strdup(code); + else + ps->code = NULL; + ps->processed = NULL; + ps->dirty = EINA_TRUE; + + _edje_edit_flag_script_dirty(eed, EINA_FALSE); +} + +static int +__part_replace(Edje_Edit *eed, char *pcode, char *name) +{ + int id; + + id = _edje_part_id_find((Edje *)eed, name); + if (id < 0) + return 0; + return eina_convert_itoa(id, pcode); +} + +static int +__program_replace(Edje_Edit *eed, char *pcode, char *name) +{ + int id; + + id = _edje_program_id_find(eed, name); + if (id < 0) + return 0; + return eina_convert_itoa(id, pcode); +} + +static int +__group_replace(Edje_Edit *eed __UNUSED__, char *pcode, char *name) +{ + strcpy(pcode, name); + return strlen(name) + 1; +} + +static int +__image_replace(Edje_Edit *eed, char *pcode, char *name) +{ + int id; + + id = _edje_image_id_find(eed, name); + if (id < 0) + return 0; + return eina_convert_itoa(id, pcode); +} + +static char * +_edje_edit_script_process(Edje_Edit *eed, const char *progname, char *code) +{ + char *pcode, *psrc, *pdst; + int codesize, pcodesize; + int quoted = 0, escaped = 0; + int line = 1; + Eina_Bool success = EINA_TRUE; + + codesize = strlen(code); + pcode = malloc(codesize + 1); + if (!pcode) + return NULL; + + pcodesize = 0; + psrc = code; + pdst = pcode; + while (*psrc) + { + if (!quoted) + { + char *ptr = NULL; + const char *what = NULL; + int (*func)(Edje_Edit *, char *, char *); + + if (*psrc == 'P') + { + if (!strncmp(psrc, "PART:\"", 6)) + { + psrc += 6; + ptr = psrc; + func = __part_replace; + what = "part"; + } + else if (!strncmp(psrc, "PROGRAM:\"", 9)) + { + psrc += 9; + ptr = psrc; + func = __program_replace; + what = "program"; + } + } + else if (*psrc == 'G') + { + if (!strncmp(psrc, "GROUP:\"", 7)) + { + psrc += 7; + ptr = psrc; + func = __group_replace; + what = "group"; + } + } + else if (*psrc == 'I') + { + if (!strncmp(psrc, "IMAGE:\"", 7)) + { + psrc += 7; + ptr = psrc; + func = __image_replace; + what = "image"; + } + } + else if (*psrc == '#') + { + while (*psrc) + if (*psrc == '\n') + break; + line++; + continue; + } + else if (*psrc == '\"') + quoted = 1; + else if (*psrc == '\n') + line++; + + if (ptr) + { + int i = 0, inesc = 0; + char *name; + while (*psrc) + { + if (!inesc) + { + if (*psrc == '\\') + inesc = 1; + else if (*psrc == '\"') + { + /* string concatenation as in "foo""bar" */ + if (*(psrc + 1) != '\"') + { + psrc++; + break; + } + else + psrc++; + } + } + else + inesc = 0; + psrc++; + } + name = alloca(psrc - ptr); + inesc = 0; + while (*ptr) + { + if (!inesc) + { + if (*ptr == '\\') + inesc = 1; + else if (*ptr == '\"') + { + if (*(ptr + 1) == '\"') + ptr++; + else + { + name[i] = 0; + break; + } + } + else + { + name[i] = *ptr; + name[i + 1] = 0; + i++; + } + } + else + inesc = 0; + ptr++; + } + i = func(eed, pdst, name); + if (!i) + { + Edje_Edit_Script_Error *se; + se = malloc(sizeof(Edje_Edit_Script_Error)); + se->program_name = progname ? + eina_stringshare_add(progname) : NULL; + se->line = line; + se->error_str = eina_stringshare_printf( + "Referenced %s '%s' could not be found in object.", + what, name); + eed->errors = eina_list_append(eed->errors, se); + success = EINA_FALSE; + } + else + { + pcodesize += i; + pdst += i; + } + /* replaced reference for the right value, now go + * to the next iteration */ + continue; + } + } + else + { + if (!escaped) + { + if (*psrc == '\"') + quoted = 0; + else if (*psrc == '\\') + escaped = 1; + } + else if (escaped) + escaped = 0; + } + *pdst = *psrc; + pdst++; + psrc++; + pcodesize++; + } + + if (!success) + { + free(pcode); + return NULL; + } + + if (pcodesize < codesize) + pcode = realloc(pcode, pcodesize + 1); + pcode[pcodesize] = 0; + + return pcode; +} + +static Eina_Bool +_edje_edit_embryo_rebuild(Edje_Edit *eed) +{ + FILE *f; + int fd, size, ret; + const char *tmp_dir; + char tmp_in[PATH_MAX]; + char tmp_out[PATH_MAX]; + char buf[4096]; + Eina_Iterator *it; + Program_Script *ps; + Edje_Part_Collection *edc; + Eina_Bool success = EINA_TRUE; /* we are optimists! */ + Edje_Edit_Script_Error *se; + + EINA_LIST_FREE(eed->errors, se) + { + eina_stringshare_del(se->program_name); + eina_stringshare_del(se->error_str); + free(se); + } + +#ifdef HAVE_EVIL + tmp_dir = evil_tmpdir_get(); +#else + tmp_dir = "/tmp"; +#endif + + snprintf(tmp_in, sizeof(tmp_in), "%s/edje_edit.sma-tmp-XXXXXX", tmp_dir); + snprintf(tmp_out, sizeof(tmp_out), "%s/edje_edit.amx-tmp-XXXXXX", tmp_dir); + + fd = mkstemp(tmp_in); + if (fd < 0) + return EINA_FALSE; /* FIXME: report something */ + + f = fdopen(fd, "w"); + if (!f) + { + close(fd); + unlink(tmp_in); + return EINA_FALSE; + } + + fprintf(f, "#include \n"); + if (eed->embryo_source) + { + if (eed->all_dirty) + { + free(eed->embryo_processed); + eed->embryo_processed = NULL; + } + if (!eed->embryo_processed) + eed->embryo_processed = _edje_edit_script_process(eed, NULL, + eed->embryo_source); + if (!eed->embryo_processed) + { + /* oops.. an error finding references parts or something. + * we could flag it and do some lighter processing of the + * rest of the scripts, in order to find all the errors of + * this kind and report them at once, but knowing already + * that the script will not compile we can avoid some work + */ + success = EINA_FALSE; + } + else + fprintf(f, "%s", eed->embryo_processed); + } + + it = eina_hash_iterator_data_new(eed->program_scripts); + EINA_ITERATOR_FOREACH(it, ps) + { + Edje_Program *epr; + + if (ps->delete_me) + continue; + if (eed->all_dirty) + { + free(ps->processed); + ps->processed = NULL; + } + epr = eed->base.table_programs[ps->id]; + if (!ps->processed) + ps->processed = _edje_edit_script_process(eed, epr->name, ps->code); + if (!ps->processed) + { + /* oops.. an error finding references parts or something. + * we could flag it and do some lighter processing of the + * rest of the scripts, in order to find all the errors of + * this kind and report them at once, but knowing already + * that the script will not compile we can avoid some work + */ + success = EINA_FALSE; + continue; + } + fprintf(f, "public _p%i(sig[], src[]) {\n", ps->id); + fprintf(f, "%s", ps->processed); + fprintf(f, "}\n"); + } + eina_iterator_free(it); + + fclose(f); + + if (!success) + goto almost_out; + + fd = mkstemp(tmp_out); + if (fd < 0) + { + success = EINA_FALSE; + goto almost_out; + } + + snprintf(buf, sizeof(buf), "embryo_cc -i %s/include -o %s %s", + PACKAGE_DATA_DIR, tmp_out, tmp_in); + ret = system(buf); + + if ((ret < 0) || (ret > 1)) + { + success = EINA_FALSE; + close(fd); + goto the_doorway; + } + + f = fdopen(fd, "rb"); + if (!f) + { + success = EINA_FALSE; + close(fd); + goto the_doorway; + } + + fseek(f, 0, SEEK_END); + size = ftell(f); + rewind(f); + + free(eed->bytecode); + if (size > 0) + { + eed->bytecode = malloc(size); + if (!eed->bytecode) + { + success = EINA_FALSE; + goto the_way_out; + } + if (fread(eed->bytecode, size, 1, f) != 1) + { + success = EINA_FALSE; + goto the_way_out; + } + } + else + eed->bytecode = NULL; /* correctness mostly, I don't see why we + would get a 0 sized program */ + + eed->bytecode_size = size; + eed->bytecode_dirty = EINA_TRUE; + eed->script_need_recompile = EINA_FALSE; + eed->all_dirty = EINA_FALSE; + + edc = eed->base.collection; + embryo_program_free(edc->script); + edc->script = embryo_program_new(eed->bytecode, eed->bytecode_size); + _edje_embryo_script_init(edc); + _edje_var_init((Edje *)eed); + +the_way_out: + fclose(f); +the_doorway: + unlink(tmp_out); +almost_out: + unlink(tmp_in); + + return success; +} + +EAPI Eina_Bool +edje_edit_script_compile(Evas_Object *obj) +{ + GET_ED_OR_RETURN(EINA_FALSE); + + if (!eed->script_need_recompile) + return EINA_TRUE; + + return _edje_edit_embryo_rebuild(eed); +} + +EAPI const Eina_List * +edje_edit_script_error_list_get(Evas_Object *obj) +{ + GET_ED_OR_RETURN(NULL); + return eed->errors; +} + +/***************************/ +/* EDC SOURCE GENERATION */ +/***************************/ +#define I0 "" +#define I1 " " +#define I2 " " +#define I3 " " +#define I4 " " +#define I5 " " +#define I6 " " +#define I7 " " + +#define BUF_APPEND(STR) \ + ret &= eina_strbuf_append(buf, STR) + +#define BUF_APPENDF(FMT, ...) \ + ret &= eina_strbuf_append_printf(buf, FMT, ##__VA_ARGS__) + +static const char *types[] = {"NONE", "RECT", "TEXT", "IMAGE", "SWALLOW", "TEXTBLOCK", "GRADIENT", "GROUP", "BOX", "TABLE", "EXTERNAL"}; +static const char *effects[] = {"NONE", "PLAIN", "OUTLINE", "SOFT_OUTLINE", "SHADOW", "SOFT_SHADOW", "OUTLINE_SHADOW", "OUTLINE_SOFT_SHADOW ", "FAR_SHADOW ", "FAR_SOFT_SHADOW", "GLOW"}; +static const char *prefers[] = {"NONE", "VERTICAL", "HORIZONTAL", "BOTH"}; + + static Eina_Bool +_edje_generate_source_of_colorclass(Edje * ed, const char *name, Eina_Strbuf *buf) +{ + Eina_List *l; + Edje_Color_Class *cc; + Eina_Bool ret = EINA_TRUE; + + EINA_LIST_FOREACH(ed->file->color_classes, l, cc) + if (!strcmp(cc->name, name)) + { + BUF_APPENDF(I1 "color_class { name: \"%s\";\n", cc->name); + BUF_APPENDF(I2 "color: %d %d %d %d;\n", cc->r, cc->g, cc->b, cc->a); + BUF_APPENDF(I2 "color2: %d %d %d %d;\n", cc->r2, cc->g2, cc->b2, cc->a2); + BUF_APPENDF(I2 "color3: %d %d %d %d;\n", cc->r3, cc->g3, cc->b3, cc->a3); + BUF_APPEND(I1 "}\n"); + } + return ret; +} + + static Eina_Bool +_edje_generate_source_of_style(Edje * ed, const char *name, Eina_Strbuf *buf) +{ + Eina_List *l, *ll; + Edje_Style *s; + Edje_Style_Tag *t; + Eina_Bool ret = EINA_TRUE; + + EINA_LIST_FOREACH(ed->file->styles, l, s) + if (!strcmp(s->name, name)) + { + t = s->tags ? s->tags->data : NULL; + BUF_APPENDF(I1 "style { name:\"%s\";\n", s->name); + if (t && t->value) + BUF_APPENDF(I2 "base: \"%s\";\n", t->value); + + EINA_LIST_FOREACH(s->tags, ll, t) + if (ll->prev && t && t->value) + BUF_APPENDF(I2 "tag: \"%s\" \"%s\";\n", t->key, + t->value); + BUF_APPEND(I1 "}\n"); + return ret; + } + return EINA_FALSE; +} + +static Eina_Bool +_edje_generate_source_of_program(Evas_Object *obj, const char *program, Eina_Strbuf *buf) +{ + Eina_List *l, *ll; + const char *s, *s2; + double db, db2; + char *data; + Eina_Bool ret = EINA_TRUE; + const char *api_name, *api_description; + Edje_Program *epr; + + GET_ED_OR_RETURN(EINA_FALSE); + + epr = _edje_program_get_byname(obj, program); + + BUF_APPENDF(I3"program { name: \"%s\";\n", program); + + /* Signal */ + if ((s = edje_edit_program_signal_get(obj, program))) + { + BUF_APPENDF(I4"signal: \"%s\";\n", s); + edje_edit_string_free(s); + } + + /* Source */ + if ((s = edje_edit_program_source_get(obj, program))) + { + BUF_APPENDF(I4"source: \"%s\";\n", s); + edje_edit_string_free(s); + } + + /* Action */ + switch (edje_edit_program_action_get(obj, program)) + { + case EDJE_ACTION_TYPE_ACTION_STOP: + BUF_APPEND(I4"action: ACTION_STOP;\n"); + break; + case EDJE_ACTION_TYPE_STATE_SET: + if ((s = edje_edit_program_state_get(obj, program))) + { + BUF_APPENDF(I4"action: STATE_SET \"%s\" %.2f;\n", s, + edje_edit_program_value_get(obj, program)); + edje_edit_string_free(s); + } + break; + case EDJE_ACTION_TYPE_SIGNAL_EMIT: + s = edje_edit_program_state_get(obj, program); + s2 = edje_edit_program_state2_get(obj, program); + if (s && s2) + { + BUF_APPENDF(I4"action: SIGNAL_EMIT \"%s\" \"%s\";\n", s, s2); + edje_edit_string_free(s); + edje_edit_string_free(s2); + } + break; + case EDJE_ACTION_TYPE_SCRIPT: + { + Program_Script *ps; + + ps = eina_hash_find(eed->program_scripts, &epr->id); + if (ps && !ps->delete_me) + { + BUF_APPEND(I4"script {\n"); + BUF_APPEND(ps->code); + BUF_APPEND(I4"}\n"); + } + } + break; + //TODO Support Drag + //~ case EDJE_ACTION_TYPE_DRAG_VAL_SET: + //~ eina_strbuf_append(buf, I4"action: DRAG_VAL_SET TODO;\n"); + //~ break; + //~ case EDJE_ACTION_TYPE_DRAG_VAL_STEP: + //~ eina_strbuf_append(buf, I4"action: DRAG_VAL_STEP TODO;\n"); + //~ break; + //~ case EDJE_ACTION_TYPE_DRAG_VAL_PAGE: + //~ eina_strbuf_append(buf, I4"action: DRAG_VAL_PAGE TODO;\n"); + //~ break; + default: + break; + } + + /* Transition */ + db = edje_edit_program_transition_time_get(obj, program); + switch (edje_edit_program_transition_get(obj, program)) + { + case EDJE_TWEEN_MODE_LINEAR: + if (db) + BUF_APPENDF(I4"transition: LINEAR %.5f;\n", db); + break; + case EDJE_TWEEN_MODE_ACCELERATE: + BUF_APPENDF(I4"transition: ACCELERATE %.5f;\n", db); + break; + case EDJE_TWEEN_MODE_DECELERATE: + BUF_APPENDF(I4"transition: DECELERATE %.5f;\n", db); + break; + case EDJE_TWEEN_MODE_SINUSOIDAL: + BUF_APPENDF(I4"transition: SINUSOIDAL %.5f;\n", db); + break; + default: + break; + } + + /* In */ + db = edje_edit_program_in_from_get(obj, program); + db2 = edje_edit_program_in_range_get(obj, program); + if (db || db2) + BUF_APPENDF(I4"in: %.5f %.5f;\n", db, db2); + + /* Targets */ + if ((ll = edje_edit_program_targets_get(obj, program))) + { + EINA_LIST_FOREACH(ll, l, data) + BUF_APPENDF(I4"target: \"%s\";\n", data); + edje_edit_string_list_free(ll); + } + + /* Afters */ + if ((ll = edje_edit_program_afters_get(obj, program))) + { + EINA_LIST_FOREACH(ll, l, data) + BUF_APPENDF(I4"after: \"%s\";\n", data); + edje_edit_string_list_free(ll); + } + + // TODO Support script {} + /* api */ + api_name = edje_edit_program_api_name_get(obj, program); + api_description = edje_edit_program_api_description_get(obj, program); + + if (api_name || api_description) + { + if (api_name && api_description) + { + BUF_APPENDF(I4"api: \"%s\" \"%s\";\n", api_name, api_description); + edje_edit_string_free(api_name); + edje_edit_string_free(api_description); + } + else + if (api_name) + { + BUF_APPENDF(I4"api: \"%s\" \"\";\n", api_name); + edje_edit_string_free(api_name); + } + else + { + BUF_APPENDF(I4"api: \"\" \"%s\";\n", api_description); + edje_edit_string_free(api_description); + } + } + + BUF_APPEND(I3 "}\n"); + return ret; +} + +static Eina_Bool +_edje_generate_source_of_state(Evas_Object *obj, const char *part, const char *state, double value, Eina_Strbuf *buf) +{ + Eina_List *l, *ll; + Eina_Bool ret = EINA_TRUE; + + GET_PD_OR_RETURN(EINA_FALSE); + + BUF_APPENDF(I4"description { state: \"%s\" %g;\n", pd->state.name, pd->state.value); + //TODO Support inherit + + if (!pd->visible) + BUF_APPEND(I5"visible: 0;\n"); + + if (pd->align.x != 0.5 || pd->align.y != 0.5) + BUF_APPENDF(I5"align: %g %g;\n", TO_DOUBLE(pd->align.x), TO_DOUBLE(pd->align.y)); + + //TODO Support fixed + + if (pd->min.w || pd->min.h) + BUF_APPENDF(I5"min: %d %d;\n", pd->min.w, pd->min.h); + if (pd->max.w != -1 || pd->max.h != -1) + BUF_APPENDF(I5"max: %d %d;\n", pd->max.w, pd->max.h); + + //TODO Support step + + if (pd->aspect.min || pd->aspect.max) + BUF_APPENDF(I5"aspect: %g %g;\n", TO_DOUBLE(pd->aspect.min), TO_DOUBLE(pd->aspect.max)); + if (pd->aspect.prefer) + BUF_APPENDF(I5"aspect_preference: %s;\n", prefers[pd->aspect.prefer]); + + if (pd->color_class) + BUF_APPENDF(I5"color_class: \"%s\";\n", pd->color_class); + + if (pd->color.r != 255 || pd->color.g != 255 || + pd->color.b != 255 || pd->color.a != 255) + BUF_APPENDF(I5"color: %d %d %d %d;\n", + pd->color.r, pd->color.g, pd->color.b, pd->color.a); + if (pd->color2.r != 0 || pd->color2.g != 0 || + pd->color2.b != 0 || pd->color2.a != 255) + BUF_APPENDF(I5"color2: %d %d %d %d;\n", + pd->color2.r, pd->color2.g, pd->color2.b, pd->color2.a); + + if (rp->part->type == EDJE_PART_TYPE_TEXT + || rp->part->type == EDJE_PART_TYPE_TEXTBLOCK) + { + Edje_Part_Description_Text *txt; + + txt = (Edje_Part_Description_Text *) pd; + + if (txt->text.color3.r != 0 || txt->text.color3.g != 0 || + txt->text.color3.b != 0 || txt->text.color3.a != 128) + BUF_APPENDF(I5"color3: %d %d %d %d;\n", + txt->text.color3.r, txt->text.color3.g, txt->text.color3.b, txt->text.color3.a); + } + + //Rel1 + if (pd->rel1.relative_x || pd->rel1.relative_y || pd->rel1.offset_x || + pd->rel1.offset_y || pd->rel1.id_x != -1 || pd->rel1.id_y != -1) + { + BUF_APPEND(I5"rel1 {\n"); + if (pd->rel1.relative_x || pd->rel1.relative_y) + BUF_APPENDF(I6"relative: %g %g;\n", TO_DOUBLE(pd->rel1.relative_x), TO_DOUBLE(pd->rel1.relative_y)); + if (pd->rel1.offset_x || pd->rel1.offset_y) + BUF_APPENDF(I6"offset: %d %d;\n", pd->rel1.offset_x, pd->rel1.offset_y); + if (pd->rel1.id_x != -1 && pd->rel1.id_x == pd->rel1.id_y) + BUF_APPENDF(I6"to: \"%s\";\n", ed->table_parts[pd->rel1.id_x]->part->name); + else + { + if (pd->rel1.id_x != -1) + BUF_APPENDF(I6"to_x: \"%s\";\n", ed->table_parts[pd->rel1.id_x]->part->name); + if (pd->rel1.id_y != -1) + BUF_APPENDF(I6"to_y: \"%s\";\n", ed->table_parts[pd->rel1.id_y]->part->name); + } + BUF_APPEND(I5"}\n");//rel1 + } + + //Rel2 + if (pd->rel2.relative_x != 1.0 || pd->rel2.relative_y != 1.0 || + pd->rel2.offset_x != -1 || pd->rel2.offset_y != -1 || + pd->rel2.id_x != -1 || pd->rel2.id_y != -1) + { + BUF_APPEND(I5"rel2 {\n"); + if (TO_DOUBLE(pd->rel2.relative_x) != 1.0 || TO_DOUBLE(pd->rel2.relative_y) != 1.0) + BUF_APPENDF(I6"relative: %g %g;\n", TO_DOUBLE(pd->rel2.relative_x), TO_DOUBLE(pd->rel2.relative_y)); + if (pd->rel2.offset_x != -1 || pd->rel2.offset_y != -1) + BUF_APPENDF(I6"offset: %d %d;\n", pd->rel2.offset_x, pd->rel2.offset_y); + if (pd->rel2.id_x != -1 && pd->rel2.id_x == pd->rel2.id_y) + BUF_APPENDF(I6"to: \"%s\";\n", ed->table_parts[pd->rel2.id_x]->part->name); + else + { + if (pd->rel2.id_x != -1) + BUF_APPENDF(I6"to_x: \"%s\";\n", ed->table_parts[pd->rel2.id_x]->part->name); + if (pd->rel2.id_y != -1) + BUF_APPENDF(I6"to_y: \"%s\";\n", ed->table_parts[pd->rel2.id_y]->part->name); + } + BUF_APPEND(I5"}\n");//rel2 + } + + //Image + if (rp->part->type == EDJE_PART_TYPE_IMAGE) + { + char *data; + const char *image_name; + + Edje_Part_Description_Image *img; + + img = (Edje_Part_Description_Image *) pd; + + BUF_APPEND(I5"image {\n"); + + image_name = _edje_image_name_find(eed, img->image.id); + if (image_name) + BUF_APPENDF(I6"normal: \"%s\";\n", image_name); + + ll = edje_edit_state_tweens_list_get(obj, part, state, value); + EINA_LIST_FOREACH(ll, l, data) + BUF_APPENDF(I6"tween: \"%s\";\n", data); + edje_edit_string_list_free(ll); + + if (img->image.border.l || img->image.border.r || img->image.border.t || img->image.border.b) + 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); + if (img->image.border.no_fill == 1) + BUF_APPEND(I6"middle: NONE;\n"); + else if (img->image.border.no_fill == 0) + BUF_APPEND(I6"middle: DEFAULT;\n"); + else if (img->image.border.no_fill == 2) + BUF_APPEND(I6"middle: SOLID;\n"); + + BUF_APPEND(I5"}\n");//image + + //Fill + + BUF_APPEND(I5"fill {\n"); + if (!img->image.fill.smooth) + BUF_APPEND(I6"smooth: 0;\n"); + //TODO Support spread + + if (img->image.fill.pos_rel_x || img->image.fill.pos_rel_y || + img->image.fill.pos_abs_x || img->image.fill.pos_abs_y) + { + BUF_APPEND(I6"origin {\n"); + if (img->image.fill.pos_rel_x || img->image.fill.pos_rel_y) + BUF_APPENDF(I7"relative: %g %g;\n", TO_DOUBLE(img->image.fill.pos_rel_x), TO_DOUBLE(img->image.fill.pos_rel_y)); + if (img->image.fill.pos_abs_x || img->image.fill.pos_abs_y) + BUF_APPENDF(I7"offset: %d %d;\n", img->image.fill.pos_abs_x, img->image.fill.pos_abs_y); + BUF_APPEND(I6"}\n"); + } + + if (TO_DOUBLE(img->image.fill.rel_x) != 1.0 || TO_DOUBLE(img->image.fill.rel_y) != 1.0 || + img->image.fill.abs_x || img->image.fill.abs_y) + { + BUF_APPEND(I6"size {\n"); + if (img->image.fill.rel_x != 1.0 || img->image.fill.rel_y != 1.0) + BUF_APPENDF(I7"relative: %g %g;\n", TO_DOUBLE(img->image.fill.rel_x), TO_DOUBLE(img->image.fill.rel_y)); + if (img->image.fill.abs_x || img->image.fill.abs_y) + BUF_APPENDF(I7"offset: %d %d;\n", img->image.fill.abs_x, img->image.fill.abs_y); + BUF_APPEND(I6"}\n"); + } + + BUF_APPEND(I5"}\n"); + } + + if (rp->part->type == EDJE_PART_TYPE_PROXY) + { + Edje_Part_Description_Proxy *pro; + + pro = (Edje_Part_Description_Proxy *) pd; + + //Fill + + BUF_APPEND(I5"fill {\n"); + if (!pro->proxy.fill.smooth) + BUF_APPEND(I6"smooth: 0;\n"); + //TODO Support spread + //TODO Support source + + if (pro->proxy.fill.pos_rel_x || pro->proxy.fill.pos_rel_y || + pro->proxy.fill.pos_abs_x || pro->proxy.fill.pos_abs_y) + { + BUF_APPEND(I6"origin {\n"); + if (pro->proxy.fill.pos_rel_x || pro->proxy.fill.pos_rel_y) + BUF_APPENDF(I7"relative: %g %g;\n", TO_DOUBLE(pro->proxy.fill.pos_rel_x), TO_DOUBLE(pro->proxy.fill.pos_rel_y)); + if (pro->proxy.fill.pos_abs_x || pro->proxy.fill.pos_abs_y) + BUF_APPENDF(I7"offset: %d %d;\n", pro->proxy.fill.pos_abs_x, pro->proxy.fill.pos_abs_y); + BUF_APPEND(I6"}\n"); + } + + if (TO_DOUBLE(pro->proxy.fill.rel_x) != 1.0 || TO_DOUBLE(pro->proxy.fill.rel_y) != 1.0 || + pro->proxy.fill.abs_x || pro->proxy.fill.abs_y) + { + BUF_APPEND(I6"size {\n"); + if (pro->proxy.fill.rel_x != 1.0 || pro->proxy.fill.rel_y != 1.0) + BUF_APPENDF(I7"relative: %g %g;\n", TO_DOUBLE(pro->proxy.fill.rel_x), TO_DOUBLE(pro->proxy.fill.rel_y)); + if (pro->proxy.fill.abs_x || pro->proxy.fill.abs_y) + BUF_APPENDF(I7"offset: %d %d;\n", pro->proxy.fill.abs_x, pro->proxy.fill.abs_y); + BUF_APPEND(I6"}\n"); + } + + BUF_APPEND(I5"}\n"); + } + + //Text + if (rp->part->type == EDJE_PART_TYPE_TEXT) + { + Edje_Part_Description_Text *txt; + + txt = (Edje_Part_Description_Text *) pd; + + BUF_APPEND(I5"text {\n"); + if (edje_string_get(&txt->text.text)) + { + if (txt->text.text.id) + BUF_APPENDF(I6"text: _(\"%s\");\n", edje_string_id_get(&txt->text.text)); + else + BUF_APPENDF(I6"text: \"%s\";\n", edje_string_get(&txt->text.text)); + } + if (edje_string_get(&txt->text.font)) + { + if (txt->text.font.id) + BUF_APPENDF(I6"font: _(\"%s\");\n", edje_string_id_get(&txt->text.font)); + else + BUF_APPENDF(I6"font: \"%s\";\n", edje_string_get(&txt->text.font)); + } + if (txt->text.size) + BUF_APPENDF(I6"size: %d;\n", txt->text.size); + if (txt->text.text_class) + BUF_APPENDF(I6"text_class: \"%s\";\n", txt->text.text_class); + if (txt->text.fit_x || txt->text.fit_y) + BUF_APPENDF(I6"fit: %d %d;\n", txt->text.fit_x, txt->text.fit_y); + //TODO Support min & max + if (TO_DOUBLE(txt->text.align.x) != 0.5 || TO_DOUBLE(txt->text.align.y) != 0.5) + BUF_APPENDF(I6"align: %g %g;\n", TO_DOUBLE(txt->text.align.x), TO_DOUBLE(txt->text.align.y)); + //TODO Support source + //TODO Support text_source + if (txt->text.elipsis) + BUF_APPENDF(I6"elipsis: %g;\n", txt->text.elipsis); + BUF_APPEND(I5"}\n"); + } + + //External + if (rp->part->type == EDJE_PART_TYPE_EXTERNAL) + { + if ((ll = (Eina_List *)edje_edit_state_external_params_list_get(obj, part, state, value))) + { + Edje_External_Param *p; + + BUF_APPEND(I5"params {\n"); + EINA_LIST_FOREACH(ll, l, p) + { + switch (p->type) + { + case EDJE_EXTERNAL_PARAM_TYPE_INT: + BUF_APPENDF(I6"int: \"%s\" \"%d\";\n", p->name, p->i); + break; + case EDJE_EXTERNAL_PARAM_TYPE_DOUBLE: + BUF_APPENDF(I6"double: \"%s\" \"%g\";\n", p->name, p->d); + break; + case EDJE_EXTERNAL_PARAM_TYPE_STRING: + if (p->s) + BUF_APPENDF(I6"string: \"%s\" \"%s\";\n", p->name, + p->s); + break; + case EDJE_EXTERNAL_PARAM_TYPE_BOOL: + BUF_APPENDF(I6"bool: \"%s\" \"%d\";\n", p->name, p->i); + break; + case EDJE_EXTERNAL_PARAM_TYPE_CHOICE: + if (p->s) + BUF_APPENDF(I6"choice: \"%s\" \"%s\";\n", p->name, + p->s); + break; + default: + break; + } + } + BUF_APPEND(I5"}\n"); + } + } + + BUF_APPEND(I4"}\n");//description + return ret; +} + +static Eina_Bool +_edje_generate_source_of_part(Evas_Object *obj, Edje_Part *ep, Eina_Strbuf *buf) +{ + const char *part = ep->name; + const char *str; + Eina_List *l, *ll; + char *data; + Eina_Bool ret = EINA_TRUE; + const char *api_name, *api_description; + + BUF_APPENDF(I3"part { name: \"%s\";\n", part); + BUF_APPENDF(I4"type: %s;\n", types[edje_edit_part_type_get(obj, part)]); + if (!edje_edit_part_mouse_events_get(obj, part)) + BUF_APPEND(I4"mouse_events: 0;\n"); + if (edje_edit_part_repeat_events_get(obj, part)) + BUF_APPEND(I4"repeat_events: 1;\n"); + if (edje_edit_part_scale_get(obj, part)) + BUF_APPEND(I4"scale: 1;\n"); + //TODO Support ignore_flags + //TODO Support pointer_mode + //TODO Support precise_is_inside + //TODO Support use_alternate_font_metrics + if ((str = edje_edit_part_clip_to_get(obj, part))) + { + BUF_APPENDF(I4"clip_to: \"%s\";\n", str); + edje_edit_string_free(str); + } + if ((str = edje_edit_part_source_get(obj, part))) + { + BUF_APPENDF(I4"source: \"%s\";\n", str); + edje_edit_string_free(str); + } + if (edje_edit_part_effect_get(obj, part)) + BUF_APPENDF(I4"effect: %s;\n", + effects[edje_edit_part_effect_get(obj, part)]); + + //Dragable + if (edje_edit_part_drag_x_get(obj, part) || + edje_edit_part_drag_y_get(obj, part)) + { + BUF_APPEND(I4"dragable {\n"); + BUF_APPENDF(I5"x: %d %d %d;\n", + edje_edit_part_drag_x_get(obj, part), + edje_edit_part_drag_step_x_get(obj, part), + edje_edit_part_drag_count_x_get(obj, part)); + BUF_APPENDF(I5"y: %d %d %d;\n", + edje_edit_part_drag_y_get(obj, part), + edje_edit_part_drag_step_y_get(obj, part), + edje_edit_part_drag_count_y_get(obj, part)); + if ((str = edje_edit_part_drag_confine_get(obj, part))) + { + BUF_APPENDF(I5"confine: \"%s\";\n", str); + edje_edit_string_free(str); + } + if ((str = edje_edit_part_drag_event_get(obj, part))) + { + BUF_APPENDF(I5"events: \"%s\";\n", str); + edje_edit_string_free(str); + } + BUF_APPEND(I4"}\n"); + } + + //Descriptions + ll = edje_edit_part_states_list_get(obj, part); + EINA_LIST_FOREACH(ll, l, data) + { + char state[512], *delim; + double value; + 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 */ + delim = strchr(state, ' '); + *delim = '\0'; + delim++; + value = strtod(delim, NULL); + ret &= _edje_generate_source_of_state(obj, part, state, value, buf); + } + edje_edit_string_list_free(ll); + + api_name = edje_edit_part_api_name_get(obj, part); + api_description = edje_edit_part_api_description_get(obj, part); + + if (api_name || api_description) + { + if (api_name && api_description) + { + BUF_APPENDF(I4"api: \"%s\" \"%s\";\n", api_name, api_description); + edje_edit_string_free(api_name); + edje_edit_string_free(api_description); + } + else + if (api_name) + { + BUF_APPENDF(I4"api: \"%s\" \"\";\n", api_name); + edje_edit_string_free(api_name); + } + else + { + BUF_APPENDF(I4"api: \"\" \"%s\";\n", api_description); + edje_edit_string_free(api_description); + } + } + + BUF_APPEND(I3"}\n");//part + return ret; +} + +static Eina_Bool +_edje_generate_source_of_group(Edje *ed, Edje_Part_Collection_Directory_Entry *pce, Eina_Strbuf *buf) +{ + Edje_Edit *eed; + Eet_File *ef; + Evas_Object *obj; + Eina_List *l, *ll; + unsigned int i; + int w, h; + char *data; + const char *group = pce->entry; + Edje_Part_Collection *pc; + Eina_Bool ret = EINA_TRUE; + + obj = edje_edit_object_add(ed->base.evas); + if (!edje_object_file_set(obj, ed->file->path, group)) return EINA_FALSE; + + ef = eet_open(ed->file->path, EET_FILE_MODE_READ); + if (!ef) + { + evas_object_del(obj); + return EINA_FALSE; + } + + eed = evas_object_smart_data_get(obj); + pc = eed->base.collection; + + BUF_APPENDF(I1"group { name: \"%s\";\n", group); + //TODO Support alias: + w = edje_edit_group_min_w_get(obj); + h = edje_edit_group_min_h_get(obj); + if ((w > 0) || (h > 0)) + BUF_APPENDF(I2"min: %d %d;\n", w, h); + w = edje_edit_group_max_w_get(obj); + h = edje_edit_group_max_h_get(obj); + if ((w > 0) || (h > 0)) + BUF_APPENDF(I2"max: %d %d;\n", w, h); + + /* Data */ + if (pc->data) + { + Eina_Iterator *it; + Eina_Hash_Tuple *tuple; + BUF_APPEND(I2"data {\n"); + + it = eina_hash_iterator_tuple_new(pc->data); + + if (!it) + { + ERR("Generating EDC for Group[%s] data.", group); + return EINA_FALSE; + } + + EINA_ITERATOR_FOREACH(it, tuple) + BUF_APPENDF(I3"item: \"%s\" \"%s\";\n", (char *)tuple->key, + edje_string_get(tuple->data)); + + eina_iterator_free(it); + BUF_APPEND(I2"}\n"); + } + + if (eed->embryo_source) + { + BUF_APPEND(I2"script {\n"); + BUF_APPEND(eed->embryo_source); + BUF_APPEND(I2"}\n"); + } + + /* Parts */ + BUF_APPEND(I2"parts {\n"); + for (i = 0; i < pc->parts_count; i++) + { + Edje_Part *ep; + ep = pc->parts[i]; + ret &= _edje_generate_source_of_part(obj, ep, buf); + } + BUF_APPEND(I2"}\n");//parts + + if (!ret) + { + ERR("Generating EDC for Group[%s] Parts.", group); + return EINA_FALSE; + } + + /* Programs */ + if ((ll = edje_edit_programs_list_get(obj))) + { + BUF_APPEND(I2 "programs {\n"); + EINA_LIST_FOREACH(ll, l, data) + ret &= _edje_generate_source_of_program(obj, data, buf); + BUF_APPEND(I2 "}\n"); + edje_edit_string_list_free(ll); + } + BUF_APPEND(I1"}\n");//group + + if (!ret) + { + ERR("Generating EDC for Group[%s] Programs.", group); + evas_object_del(obj); + return EINA_FALSE; + } + + eet_close(ef); + evas_object_del(obj); + return ret; +} + +static Eina_Strbuf* +_edje_generate_source(Evas_Object *obj) +{ + Eina_Strbuf *buf; + + Eina_List *l, *ll; + Edje_Font_Directory_Entry *fnt; + + char *entry; + Eina_Bool ret = EINA_TRUE; + + GET_ED_OR_RETURN(NULL); + + /* Open a str buffer */ + + buf = eina_strbuf_new(); + if (!buf) return NULL; + + /* Write edc into file */ + //TODO Probably we need to save the file before generation + + /* Images */ + if ((ll = edje_edit_images_list_get(obj))) + { + BUF_APPEND(I0"images {\n"); + + EINA_LIST_FOREACH(ll, l, entry) + { + int comp = edje_edit_image_compression_type_get(obj, entry); + if (comp < 0) continue; + + BUF_APPENDF(I1"image: \"%s\" ", entry); + + if (comp == EDJE_EDIT_IMAGE_COMP_LOSSY) + BUF_APPENDF("LOSSY %d;\n", + edje_edit_image_compression_rate_get(obj, entry)); + else if (comp == EDJE_EDIT_IMAGE_COMP_RAW) + BUF_APPEND("RAW;\n"); + else if (comp == EDJE_EDIT_IMAGE_COMP_USER) + BUF_APPEND("USER;\n"); + else + BUF_APPEND("COMP;\n"); + } + BUF_APPEND(I0"}\n\n"); + edje_edit_string_list_free(ll); + + if (!ret) + { + ERR("Generating EDC for Images"); + eina_strbuf_free(buf); + return NULL; + } + } + + /* Fonts */ + if (ed->file->fonts) + { + Eina_Iterator *it; + + it = eina_hash_iterator_data_new(ed->file->fonts); + if (it) + { + BUF_APPEND(I0"fonts {\n"); + + EINA_ITERATOR_FOREACH(it, fnt) + BUF_APPENDF(I1"font: \"%s\" \"%s\";\n", fnt->file, + fnt->entry); + + BUF_APPEND(I0"}\n\n"); + eina_iterator_free(it); + + if (!ret) + { + ERR("Generating EDC for Fonts"); + eina_strbuf_free(buf); + return NULL; + } + } + } + + /* Data */ + if ((ll = edje_edit_data_list_get(obj))) + { + BUF_APPEND(I0 "data {\n"); + + EINA_LIST_FOREACH(ll, l, entry) + BUF_APPENDF(I1 "item: \"%s\" \"%s\";\n", entry, + edje_edit_data_value_get(obj, entry)); + + BUF_APPEND(I0 "}\n\n"); + edje_edit_string_list_free(ll); + + if (!ret) + { + ERR("Generating EDC for Data"); + eina_strbuf_free(buf); + return NULL; + } + } + + /* Color Classes */ + if ((ll = edje_edit_color_classes_list_get(obj))) + { + BUF_APPEND(I0 "color_classes {\n"); + + EINA_LIST_FOREACH(ll, l, entry) + _edje_generate_source_of_colorclass(ed, entry, buf); + + BUF_APPEND(I0 "}\n\n"); + edje_edit_string_list_free(ll); + + if (!ret) + { + ERR("Generating EDC for Color Classes"); + eina_strbuf_free(buf); + return NULL; + } + } + + /* Styles */ + if ((ll = edje_edit_styles_list_get(obj))) + { + BUF_APPEND(I0 "styles {\n"); + EINA_LIST_FOREACH(ll, l, entry) + _edje_generate_source_of_style(ed, entry, buf); + BUF_APPEND(I0 "}\n\n"); + edje_edit_string_list_free(ll); + + if (!ret) + { + ERR("Generating EDC for Styles"); + eina_strbuf_free(buf); + return NULL; + } + } + + /* Externals */ + if ((ll = edje_edit_externals_list_get(obj))) + { + BUF_APPEND(I0 "externals {\n"); + EINA_LIST_FOREACH(ll, l, entry) + BUF_APPENDF(I1 "external: \"%s\";\n", entry); + + BUF_APPEND(I0 "}\n\n"); + edje_edit_string_list_free(ll); + + if (!ret) + { + ERR("Generating EDC for Externals"); + eina_strbuf_free(buf); + return NULL; + } + } + + /* Collections */ + if (ed->file->collection) + { + Eina_Iterator *it; + Edje_Part_Collection_Directory_Entry *pce; + BUF_APPEND("collections {\n"); + + it = eina_hash_iterator_data_new(ed->file->collection); + + if (!it) + { + ERR("Generating EDC for Collections"); + eina_strbuf_free(buf); + return NULL; + } + + EINA_ITERATOR_FOREACH(it, pce) + { + ret &= _edje_generate_source_of_group(ed, pce, buf); + } + + eina_iterator_free(it); + BUF_APPEND("}\n\n"); + } + + return buf; +} + + + +/*********************/ +/* SAVING ROUTINES */ +/*********************/ +//////////////////////////////////////// +typedef struct _SrcFile SrcFile; +typedef struct _SrcFile_List SrcFile_List; + +struct _SrcFile +{ + char *name; + const char *file; +}; + +struct _SrcFile_List +{ + Eina_List *list; +}; + +static Eet_Data_Descriptor *_srcfile_edd = NULL; +static Eet_Data_Descriptor *_srcfile_list_edd = NULL; + +static void +source_edd(void) +{ + Eet_Data_Descriptor_Class eddc; + + if (_srcfile_edd) return; + + eet_eina_stream_data_descriptor_class_set(&eddc, sizeof (eddc), "srcfile", sizeof(SrcFile)); + _srcfile_edd = eet_data_descriptor_stream_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_BASIC(_srcfile_edd, SrcFile, "name", name, EET_T_INLINED_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_srcfile_edd, SrcFile, "file", file, EET_T_INLINED_STRING); + + eet_eina_stream_data_descriptor_class_set(&eddc, sizeof (eddc), "srcfile_list", sizeof(SrcFile_List)); + _srcfile_list_edd = eet_data_descriptor_stream_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_LIST(_srcfile_list_edd, SrcFile_List, "list", list, _srcfile_edd); +} +///////////////////////////////////////// + +static Eina_Bool +_edje_edit_edje_file_save(Eet_File *eetf, Edje_File *ef) +{ + /* Write Edje_File structure */ + INF("** Writing Edje_File* ed->file"); + if (eet_data_write(eetf, _edje_edd_edje_file, "edje/file", ef, 1) <= 0) + { + ERR("Error. unable to write \"edje_file\" entry to \"%s\"", ef->path); + return EINA_FALSE; + } + return EINA_TRUE; +} + +static Eina_Bool +_edje_edit_collection_save(Eet_File *eetf, Edje_Part_Collection *epc) +{ + char buf[256]; + + snprintf(buf, sizeof(buf), "edje/collections/%i", epc->id); + + if (eet_data_write(eetf, _edje_edd_edje_part_collection, buf, epc, 1) > 0) + return EINA_TRUE; + + ERR("Error. unable to write \"%s\" part entry", buf); + return EINA_FALSE; +} + +static Eina_Bool +_edje_edit_source_save(Eet_File *eetf, Evas_Object *obj) +{ + SrcFile *sf; + SrcFile_List *sfl; + Eina_Strbuf *source_file; + Eina_Bool ret = EINA_TRUE; + + source_file = _edje_generate_source(obj); + if (!source_file) + { + ERR("Can't create edc source"); + return EINA_FALSE; + } + + //open the temp file and put the contents in SrcFile + sf = _alloc(sizeof(SrcFile)); + if (!sf) + { + ERR("Unable to create source file struct"); + ret = EINA_FALSE; + goto save_free_source; + } + sf->name = strdup("generated_source.edc"); + if (!sf->name) + { + ERR("Unable to alloc filename"); + ret = EINA_FALSE; + goto save_free_sf; + } + + sf->file = eina_strbuf_string_get(source_file); + + //create the needed list of source files (only one) + sfl = _alloc(sizeof(SrcFile_List)); + if (!sfl) + { + ERR("Unable to create file list"); + ret = EINA_FALSE; + goto save_free_filename; + } + sfl->list = NULL; + sfl->list = eina_list_append(sfl->list, sf); + if (!sfl->list) + { + ERR("Error. unable to append file in list"); + ret = EINA_FALSE; + goto save_free_sfl; + } + + // write the sources list to the eet file + source_edd(); + if (eet_data_write(eetf, _srcfile_list_edd, "edje_sources", sfl, 1) <= 0) + { + ERR("Unable to write edc source"); + ret = EINA_FALSE; + } + + /* Clear stuff */ + eina_list_free(sfl->list); +save_free_sfl: + free(sfl); +save_free_filename: + free(sf->name); +save_free_sf: + free(sf); +save_free_source: + eina_strbuf_free(source_file); + return ret; +} + +Eina_Bool +_edje_edit_internal_save(Evas_Object *obj, int current_only) +{ + Edje_File *ef; + Eet_File *eetf; + + GET_ED_OR_RETURN(EINA_FALSE); + + ef = ed->file; + if (!ef) return EINA_FALSE; + + INF("*********** Saving file ******************"); + INF("** path: %s", ef->path); + + /* Open the eet file */ + eetf = eet_open(ef->path, EET_FILE_MODE_READ_WRITE); + if (!eetf) + { + ERR("Error. unable to open \"%s\" for writing output", + ef->path); + return EINA_FALSE; + } + + /* Set compiler name */ + if (strcmp(ef->compiler, "edje_edit")) + { + _edje_if_string_free(ed, ef->compiler); + ef->compiler = (char *)eina_stringshare_add("edje_edit"); + } + + if (!_edje_edit_edje_file_save(eetf, ef)) + { + eet_close(eetf); + return EINA_FALSE; + } + + if (current_only) + { + if (ed->collection) + { + INF("** Writing Edje_Part_Collection* ed->collection " + "[id: %d]", ed->collection->id); + if (!_edje_edit_collection_save(eetf, ed->collection)) + { + eet_close(eetf); + return EINA_FALSE; + } + } + } + else + { + Eina_List *l; + Edje_Part_Collection *edc; + Edje_Part_Collection_Directory_Entry *ce; + Eina_Iterator *it; + + INF("** Writing all collections"); + + it = eina_hash_iterator_data_new(ef->collection); + while (eina_iterator_next(it, (void **)&ce)) + { + if (ce->ref) + { + INF("** Writing hash Edje_Part_Collection* ed->collection " + "[id: %d]", ce->id); + if(!_edje_edit_collection_save(eetf, ce->ref)) + { + eet_close(eetf); + return EINA_FALSE; + } + } + } + eina_iterator_free(it); + + EINA_LIST_FOREACH(ef->collection_cache, l, edc) + { + INF("** Writing cache Edje_Part_Collection* ed->collection " + "[id: %d]", edc->id); + if(!_edje_edit_collection_save(eetf, edc)) + { + eet_close(eetf); + return EINA_FALSE; + } + } + } + + if (eed->bytecode_dirty || eed->script_need_recompile) + { + char buf[64]; + Eina_Iterator *it; + Program_Script *ps; + Eina_List *deathnote = NULL; + + if (eed->bytecode_dirty) + { + snprintf(buf, sizeof(buf), "edje/scripts/embryo/compiled/%i", + ed->collection->id); + eet_write(eetf, buf, eed->bytecode, eed->bytecode_size, 1); + free(eed->bytecode); + eed->bytecode = NULL; + eed->bytecode_size = 0; + eed->bytecode_dirty = EINA_FALSE; + } + + if (eed->embryo_source_dirty) + { + snprintf(buf, sizeof(buf), "edje/scripts/embryo/source/%i", + ed->collection->id); + eet_write(eetf, buf, eed->embryo_source, + strlen(eed->embryo_source) +1, 1); + eed->embryo_source_dirty = EINA_FALSE; + } + + it = eina_hash_iterator_data_new(eed->program_scripts); + EINA_ITERATOR_FOREACH(it, ps) + { + if (ps->dirty) + { + snprintf(buf, sizeof(buf), "edje/scripts/embryo/source/%i/%i", + ed->collection->id, ps->id); + eet_write(eetf, buf, ps->code, strlen(ps->code) + 1, 1); + ps->dirty = EINA_FALSE; + } + else if (ps->delete_me) + { + snprintf(buf, sizeof(buf), "edje/scripts/embryo/source/%i/%i", + ed->collection->id, ps->id); + eet_delete(eetf, buf); + deathnote = eina_list_append(deathnote, ps); + } + } + eina_iterator_free(it); + + EINA_LIST_FREE(deathnote, ps) + eina_hash_del(eed->program_scripts, &ps->id, ps); + } + + if (!_edje_edit_source_save(eetf, obj)) + { + eet_close(eetf); + return EINA_FALSE; + } + + eet_close(eetf); + + /* Update mtime */ + { + struct stat st; + if (stat(ed->path, &st) != 0) + return EINA_FALSE; + ef->mtime = st.st_mtime; + } + + INF("*********** Saving DONE ******************"); + return EINA_TRUE; +} + +EAPI Eina_Bool +edje_edit_save(Evas_Object *obj) +{ + eina_error_set(0); + + return _edje_edit_internal_save(obj, 1); +} + +EAPI Eina_Bool +edje_edit_save_all(Evas_Object *obj) +{ + eina_error_set(0); + + return _edje_edit_internal_save(obj, 0); +} + +EAPI void +edje_edit_print_internal_status(Evas_Object *obj) +{ +/* + Edje_Program *epr; + unsigned int i; + int j; +*/ + eina_error_set(0); + + GET_ED_OR_RETURN(); + + _edje_generate_source(obj); +/* + INF("****** CHECKIN' INTERNAL STRUCTS STATUS *********"); + + INF("path: '%s', group: '%s', parent: '%s'", + ed->path, ed->group, ed->parent); + + INF("Parts [table:%d list:%d]", ed->table_parts_size, + ed->collection->parts_count); + for (i = 0; i < ed->collection->parts_count; ++i) + { + Edje_Real_Part *rp; + Edje_Part *p; + + p = ed->collection->parts[i]; + + rp = ed->table_parts[p->id % ed->table_parts_size]; + printf("part[%d]: '%s' ", p->id, p->name); + if (p == rp->part) + printf("OK!\n"); + else + printf("WRONG (table[%d]->name = '%s')\n", p->id, rp->part->name); + } + + INF("Programs [table:%d list:%d,%d,%d,%d,%d]", ed->table_programs_size, + ed->collection->programs.fnmatch_count, + ed->collection->programs.strcmp_count, + ed->collection->programs.strncmp_count, + ed->collection->programs.strrncmp_count, + ed->collection->programs.nocmp_count); + for(j = 0; j < ed->table_programs_size; ++j) + { + epr = ed->table_programs[i % ed->table_programs_size]; + printf("program[%d]: '%s'\n", epr->id, epr->name); + } + + INF("****************** END ************************"); + */ +} 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 @@ +#include "edje_private.h" + +/* + * ALREADY EXPORTED BY EMBRYO: + * + * enum Float_Round_Method { + * ROUND, FLOOR, CEIL, TOZERO + * }; + * enum Float_Angle_Mode { + * RADIAN, DEGREES, GRADES + * }; + * + * numargs(); + * getarg(arg, index=0); + * setarg(arg, index=0, value); + * + * Float:atof(string[]); + * Float:fract(Float:value); + * round(Float:value, Float_Round_Method:method=ROUND); + * Float:sqrt(Float:value); + * Float:pow(Float:value, Float:exponent); + * Float:log(Float:value, Float:base=10.0); + * Float:sin(Float:value, Float_Angle_Mode:mode=RADIAN); + * Float:cos(Float:value, Float_Angle_Mode:mode=RADIAN); + * Float:tan(Float:value, Float_Angle_Mode:mode=RADIAN); + * Float:abs(Float:value); + * atoi(str[]); + * fnmatch(glob[], str[]); + * strcmp(str1[], str2[]); + * strncmp(str1[], str2[]); + * strcpy(dst[], src[]); + * strncpy(dst[], src[], n); + * strlen(str[]); + * strcat(dst[], src[]); + * strncat(dst[], src[], n); + * strprep(dst[], src[]); + * strnprep(dst[], src[], n); + * strcut(dst[], str[], n, n2); + * snprintf(dst[], dstn, fmt[], ...); + * strstr(str[], ndl[]); + * strchr(str[], ch[]); + * strrchr(str[], ch[]); + * rand(); + * Float:randf(); + * Float:seconds(); + * date(&year, &month, &day, &yearday, &weekday, &hr, &min, &Float:sec); + * + */ + +/* EDJE... + * + * implemented so far as examples: + * + * enum Msg_Type { + * MSG_NONE, MSG_STRING, MSG_INT, MSG_FLOAT, MSG_STRING_SET, MSG_INT_SET, + * MSG_FLOAT_SET, MSG_STRING_INT, MSG_INT_FLOAT, MSG_STRING_INT_SET, + * MSG_INT_FLOAT_SET + * }; + * + * get_int(id) + * set_int(id, v) + * Float:get_float (id) + * set_float(id, Float:v) + * get_strlen(id) + * get_str(id, dst[], maxlen) + * set_str(id, str[]) + * timer(Float:in, fname[], val) + * cancel_timer(id) + * anim(Float:len, fname[], val) + * cancel_anim(id) + * emit(sig[], src[]) + * set_state(part_id, state[], Float:state_val) + * get_state(part_id, dst[], maxlen, &Float:val) + * set_tween_state(part_id, Float:tween, state1[], Float:state1_val, state2[], Float:state2_val) + * play_sample(sample_name, speed) + * play_tone(tone_name, duration) + * run_program(program_id) + * Direction:get_drag_dir(part_id) + * get_drag(part_id, &Float:dx, &Float:&dy) + * set_drag(part_id, Float:dx, Float:dy) + * get_drag_size(part_id, &Float:dx, &Float:&dy) + * set_drag_size(part_id, Float:dx, Float:dy) + * set_text(part_id, str[]) + * get_text(part_id, dst[], maxlen) + * get_min_size(w, h) + * get_max_size(w, h) + * set_color_class(class[], r, g, b, a) + * get_color_class(class[], &r, &g, &b, &a) + * set_text_class(class[], font[], Float:size) + * get_text_class(class[], font[], &Float:size) + * get_drag_step(part_id, &Float:dx, &Float:&dy) + * set_drag_step(part_id, Float:dx, Float:dy) + * get_drag_page(part_id, &Float:dx, &Float:&dy) + * set_drag_page(part_id, Float:dx, Float:dy) + * get_geometry(part_id, &Float:x, &Float:y, &Float:w, &Float:h) + * get_mouse(&x, &y) + * stop_program(program_id) + * stop_programs_on(part_id) + * set_min_size(w, h) + * set_max_size(w, h) + * send_message(Msg_Type:type, id, ...) + * + * count(id) + * remove(id, n) + * + * append_int(id, v) + * prepend_int(id, v) + * insert_int(id, n, v) + * replace_int(id, n, v) + * fetch_int(id, n) + * + * append_str(id, str[]) + * prepend_str(id, str[]) + * insert_str(id, n, str[]) + * replace_str(id, n, str[]) + * fetch_str(id, n, dst[], maxlen) + * + * append_float(id, Float:v) + * prepend_float(id, Float:v) + * insert_float(id, n, Float:v) + * replace_float(id, n, Float:v) + * Float:fetch_float(id, n) + * + * custom_state(part_id, state[], Float:state_val = 0.0) + * set_state_val(part_id, State_Param:param, ...) + * get_state_val(part_id, State_Param:param, ...) + * + * Supported parameters: + * align[Float:x, Float:y] + * min[w, h] + * max[w, h] + * step[x,y] + * aspect[Float:min, Float:max] + * color[r,g,b,a] + * color2[r,g,b,a] + * color3[r,g,b,a] + * aspect_preference + * rel1[relx,rely] + * rel1[part_id,part_id] + * rel1[offx,offy] + * rel2[relx,relyr] + * rel2[part_id,part_id] + * rel2[offx,offy] + * image[image_id] <- all images have an Id not name in the edje + * border[l,r,t,b] + * fill[smooth] + * fill[pos_relx,pos_rely,pos_offx,pos_offy] + * fill[sz_relx,sz_rely,sz_offx,sz_offy] + * color_class + * text[text] + * text[text_class] + * text[font] + * text[size] + * text[style] + * text[fit_x,fit_y] + * text[min_x,min_y] + * text[align_x,align_y] + * visible[on] + * map_on[on] + * map_persp[part_id] + * map_light[part_id] + * map_rot_center[part_id] + * map_rot_x[deg] + * map_rot_y[deg] + * map_rot_z[deg] + * map_back_cull[on] + * map_persp_on[on] + * persp_zplane[z] + * persp_focal[z] + * + * ** part_id and program_id need to be able to be "found" from strings + * + * get_drag_count(part_id, &Float:dx, &Float:&dy) + * set_drag_count(part_id, Float:dx, Float:dy) + * set_drag_confine(part_id, confine_part_id) + * get_size(&w, &h); + * resize_request(w, h) + * get_mouse_buttons() + * //set_type(part_id, Type:type) + * //set_effect(part_id, Effect:fx) + * set_mouse_events(part_id, ev) + * get_mouse_events(part_id) + * set_repeat_events(part_id, rep) + * get_repeat_events(part_id) + * set_clip(part_id, clip_part_id) + * get_clip(part_id) + * + * part_swallow(part_id, group_name) + * + * external_param_get_int(id, param_name[]) + * external_param_set_int(id, param_name[], value) + * Float:external_param_get_float(id, param_name[]) + * external_param_set_float(id, param_name[], Float:value) + * external_param_get_strlen(id, param_name[]) + * external_param_get_str(id, param_name[], value[], value_maxlen) + * external_param_set_str(id, param_name[], value[]) + * external_param_get_choice_len(id, param_name[]) + * external_param_get_choice(id, param_name[], value[], value_maxlen) + * external_param_set_choice(id, param_name[], value[]) + * external_param_get_bool(id, param_name[]) + * external_param_set_bool(id, param_name[], value) + * + * ADD/DEL CUSTOM OBJECTS UNDER SOLE EMBRYO SCRIPT CONTROL + * + */ + +/* get_int(id) */ +static Embryo_Cell +_edje_embryo_fn_get_int(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + + CHKPARAM(1); + ed = embryo_program_data_get(ep); + return (Embryo_Cell)_edje_var_int_get(ed, (int)params[1]); +} + +/* set_int(id, v) */ +static Embryo_Cell +_edje_embryo_fn_set_int(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + + CHKPARAM(2); + ed = embryo_program_data_get(ep); + _edje_var_int_set(ed, (int)params[1], (int)params[2]); + return 0; +} + +/* get_float(id) */ +static Embryo_Cell +_edje_embryo_fn_get_float(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + float v; + + CHKPARAM(1); + ed = embryo_program_data_get(ep); + v = (float)_edje_var_float_get(ed, params[1]); + return EMBRYO_FLOAT_TO_CELL(v); +} + +/* set_float(id, v) */ +static Embryo_Cell +_edje_embryo_fn_set_float(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + float v; + + CHKPARAM(2); + ed = embryo_program_data_get(ep); + v = EMBRYO_CELL_TO_FLOAT(params[2]); + _edje_var_float_set(ed, (int)params[1], (double)v); + return 0; +} + +/* get_str(id, dst[], maxlen) */ +static Embryo_Cell +_edje_embryo_fn_get_str(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + char *s; + + CHKPARAM(3); + if (params[3] < 1) return 0; + ed = embryo_program_data_get(ep); + s = (char *)_edje_var_str_get(ed, (int)params[1]); + if (s) + { + if ((int) strlen(s) < params[3]) + { + SETSTR(s, params[2]); + } + else + { + char *ss; + + ss = alloca(strlen(s) + 1); + strcpy(ss, s); + ss[params[3] - 1] = 0; + SETSTR(ss, params[2]); + } + } + else + { + SETSTR("", params[2]); + } + return 0; +} + +/* get_strlen(id) */ +static Embryo_Cell +_edje_embryo_fn_get_strlen(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + char *s; + + CHKPARAM(1); + ed = embryo_program_data_get(ep); + s = (char *)_edje_var_str_get(ed, (int)params[1]); + if (s) + { + return strlen(s); + } + return 0; +} + +/* set_str(id, str[]) */ +static Embryo_Cell +_edje_embryo_fn_set_str(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + char *s; + + CHKPARAM(2); + ed = embryo_program_data_get(ep); + GETSTR(s, params[2]); + if (s) + { + _edje_var_str_set(ed, (int)params[1], s); + } + return 0; +} + +/* count(id) */ +static Embryo_Cell +_edje_embryo_fn_count(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed = embryo_program_data_get(ep); + + CHKPARAM(1); + + return (Embryo_Cell)_edje_var_list_count_get(ed, (int) params[1]); +} + +/* remove(id, n) */ +static Embryo_Cell +_edje_embryo_fn_remove(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed = embryo_program_data_get(ep); + + CHKPARAM(2); + + _edje_var_list_remove_nth(ed, (int) params[1], (int) params[2]); + + return 0; +} + +/* append_int(id, var) */ +static Embryo_Cell +_edje_embryo_fn_append_int(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed = embryo_program_data_get(ep); + + CHKPARAM(2); + + _edje_var_list_int_append(ed, (int) params[1], (int) params[2]); + + return 0; +} + +/* prepend_int(id, var) */ +static Embryo_Cell +_edje_embryo_fn_prepend_int(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed = embryo_program_data_get(ep); + + CHKPARAM(2); + + _edje_var_list_int_prepend(ed, (int) params[1], (int) params[2]); + + return 0; +} + +/* insert_int(id, pos, var) */ +static Embryo_Cell +_edje_embryo_fn_insert_int(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed = embryo_program_data_get(ep); + + CHKPARAM(3); + + _edje_var_list_int_insert(ed, (int) params[1], (int) params[2], + (int) params[3]); + + return 0; +} + +/* replace_int(id, pos, var) */ +static Embryo_Cell +_edje_embryo_fn_replace_int(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed = embryo_program_data_get(ep); + + CHKPARAM(3); + + _edje_var_list_nth_int_set(ed, (int) params[1], (int) params[2], + (int) params[3]); + + return 0; +} + +/* fetch_int(id, pos) */ +static Embryo_Cell +_edje_embryo_fn_fetch_int(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed = embryo_program_data_get(ep); + + CHKPARAM(2); + + return _edje_var_list_nth_int_get(ed, (int) params[1], + (int) params[2]); +} + +/* append_str(id, str[]) */ +static Embryo_Cell +_edje_embryo_fn_append_str(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed = embryo_program_data_get(ep); + char *s; + + CHKPARAM(2); + + GETSTR(s, params[2]); + if (s) + _edje_var_list_str_append(ed, (int) params[1], s); + + return 0; +} + +/* prepend_str(id, str[]) */ +static Embryo_Cell +_edje_embryo_fn_prepend_str(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed = embryo_program_data_get(ep); + char *s; + + CHKPARAM(2); + + GETSTR(s, params[2]); + if (s) + _edje_var_list_str_prepend(ed, (int) params[1], s); + + return 0; +} + +/* insert_str(id, pos, str[]) */ +static Embryo_Cell +_edje_embryo_fn_insert_str(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed = embryo_program_data_get(ep); + char *s; + + CHKPARAM(3); + + GETSTR(s, params[3]); + if (s) + _edje_var_list_str_insert(ed, (int) params[1], (int) params[2], s); + + return 0; +} + +/* replace_str(id, pos, str[]) */ +static Embryo_Cell +_edje_embryo_fn_replace_str(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed = embryo_program_data_get(ep); + char *s; + + CHKPARAM(3); + + GETSTR(s, params[3]); + if (s) + _edje_var_list_nth_str_set(ed, (int) params[1], (int) params[2], s); + + return 0; +} + + +/* fetch_str(id, pos, dst[], maxlen) */ +static Embryo_Cell +_edje_embryo_fn_fetch_str(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed = embryo_program_data_get(ep); + char *s; + + CHKPARAM(4); + + s = (char *) _edje_var_list_nth_str_get(ed, (int) params[1], + (int) params[2]); + if (s) + { + if ((int) strlen(s) < params[4]) + { + SETSTR(s, params[3]); + } + else + { + char *ss; + + ss = alloca(strlen(s) + 1); + strcpy(ss, s); + ss[params[4] - 1] = 0; + SETSTR(ss, params[3]); + } + } + else + { + SETSTR("", params[3]); + } + + return 0; +} + +/* append_float(id, Float:f) */ +static Embryo_Cell +_edje_embryo_fn_append_float(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed = embryo_program_data_get(ep); + float f; + + CHKPARAM(2); + + f = EMBRYO_CELL_TO_FLOAT(params[2]); + _edje_var_list_float_append(ed, (int) params[1], f); + + return 0; +} + +/* prepend_float(id, Float:f) */ +static Embryo_Cell +_edje_embryo_fn_prepend_float(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed = embryo_program_data_get(ep); + float f; + + CHKPARAM(2); + + f = EMBRYO_CELL_TO_FLOAT(params[2]); + _edje_var_list_float_prepend(ed, (int) params[1], f); + + return 0; +} + +/* insert_float(id, pos, Float:f) */ +static Embryo_Cell +_edje_embryo_fn_insert_float(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed = embryo_program_data_get(ep); + float f; + + CHKPARAM(3); + + f = EMBRYO_CELL_TO_FLOAT(params[3]); + _edje_var_list_float_insert(ed, (int) params[1], (int) params[2], f); + + return 0; +} + +/* replace_float(id, pos, Float:f) */ +static Embryo_Cell +_edje_embryo_fn_replace_float(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed = embryo_program_data_get(ep); + + CHKPARAM(3); + + _edje_var_list_nth_float_set(ed, (int) params[1], (int) params[2], + EMBRYO_CELL_TO_FLOAT(params[3])); + + return 0; +} + +/* Float:fetch_float(id, pos) */ +static Embryo_Cell +_edje_embryo_fn_fetch_float(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed = embryo_program_data_get(ep); + float f; + + CHKPARAM(2); + + f = _edje_var_list_nth_float_get(ed, (int) params[1], (int) params[2]); + + return EMBRYO_FLOAT_TO_CELL(f); +} + +/* timer(Float:in, fname[], val) */ +static Embryo_Cell +_edje_embryo_fn_timer(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + char *fname = NULL; + float f; + double in; + int val; + + CHKPARAM(3); + ed = embryo_program_data_get(ep); + GETSTR(fname, params[2]); + if ((!fname)) return 0; + f = EMBRYO_CELL_TO_FLOAT(params[1]); + in = (double)f; + val = params[3]; + return _edje_var_timer_add(ed, in, fname, val); +} + +/* cancel_timer(id) */ +static Embryo_Cell +_edje_embryo_fn_cancel_timer(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + int id; + + CHKPARAM(1); + ed = embryo_program_data_get(ep); + id = params[1]; + if (id <= 0) return 0; + _edje_var_timer_del(ed, id); + return 0; +} + +/* anim(Float:len, fname[], val) */ +static Embryo_Cell +_edje_embryo_fn_anim(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + char *fname = NULL; + float f; + double len; + int val; + + CHKPARAM(3); + ed = embryo_program_data_get(ep); + GETSTR(fname, params[2]); + if ((!fname)) return 0; + f = EMBRYO_CELL_TO_FLOAT(params[1]); + len = (double)f; + val = params[3]; + return _edje_var_anim_add(ed, len, fname, val); +} + +/* cancel_anim(id) */ +static Embryo_Cell +_edje_embryo_fn_cancel_anim(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + int id; + + CHKPARAM(1); + ed = embryo_program_data_get(ep); + id = params[1]; + if (id <= 0) return 0; + _edje_var_anim_del(ed, id); + return 0; +} + +/* set_min_size(Float:w, Float:h) */ +static Embryo_Cell +_edje_embryo_fn_set_min_size(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + float f = 0.0; + double w = 0.0, h = 0.0; + + CHKPARAM(2); + ed = embryo_program_data_get(ep); + f = EMBRYO_CELL_TO_FLOAT(params[1]); + w = (double)f; + f = EMBRYO_CELL_TO_FLOAT(params[2]); + h = (double)f; + + if (w < 0.0) w = 0.0; + if (h < 0.0) h = 0.0; + ed->collection->prop.min.w = w; + ed->collection->prop.min.h = h; + ed->dirty = 1; +#ifdef EDJE_CALC_CACHE + ed->all_part_change = 1; +#endif + _edje_recalc(ed); + return 0; +} + +/* set_max_size(Float:w, Float:h) */ +static Embryo_Cell +_edje_embryo_fn_set_max_size(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + float f = 0.0; + double w = 0.0, h = 0.0; + + CHKPARAM(2); + ed = embryo_program_data_get(ep); + f = EMBRYO_CELL_TO_FLOAT(params[1]); + w = (double)f; + f = EMBRYO_CELL_TO_FLOAT(params[2]); + h = (double)f; + + if (w < 0.0) w = 0.0; + if (h < 0.0) h = 0.0; + ed->collection->prop.max.w = w; + ed->collection->prop.max.h = h; + ed->dirty = 1; +#ifdef EDJE_CALC_CACHE + ed->all_part_change = 1; +#endif + _edje_recalc(ed); + + return 0; +} + +/* stop_program(program_id) */ +static Embryo_Cell +_edje_embryo_fn_stop_program(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + int program_id = 0; + Edje_Running_Program *runp; + Eina_List *l; + + CHKPARAM(1); + ed = embryo_program_data_get(ep); + program_id = params[1]; + if (program_id < 0) return 0; + + ed->walking_actions = 1; + + EINA_LIST_FOREACH(ed->actions, l, runp) + if (program_id == runp->program->id) + _edje_program_end(ed, runp); + + ed->walking_actions = 0; + + return 0; +} + +/* stop_programs_on(part_id) */ +static Embryo_Cell +_edje_embryo_fn_stop_programs_on(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + + int part_id = 0; + Edje_Real_Part *rp; + + CHKPARAM(1); + ed = embryo_program_data_get(ep); + part_id = params[1]; + if (part_id < 0) return 0; + rp = ed->table_parts[part_id % ed->table_parts_size]; + if (rp) + { + /* there is only ever 1 program acting on a part at any time */ + if (rp->program) _edje_program_end(ed, rp->program); + } + return 0; +} + +/* get_mouse(&x, &y) */ +static Embryo_Cell +_edje_embryo_fn_get_mouse(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + Evas_Coord x = 0, y = 0; + + CHKPARAM(2); + ed = embryo_program_data_get(ep); + evas_pointer_canvas_xy_get(ed->base.evas, &x, &y); + x -= ed->x; + y -= ed->y; + SETINT((int)x, params[1]); + SETINT((int)y, params[2]); + return 0; +} + +/* get_mouse_buttons() */ +static Embryo_Cell +_edje_embryo_fn_get_mouse_buttons(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + + CHKPARAM(0); + ed = embryo_program_data_get(ep); + return evas_pointer_button_down_mask_get(ed->base.evas); +} + +/* emit(sig[], src[]) */ +static Embryo_Cell +_edje_embryo_fn_emit(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + char *sig = NULL, *src = NULL; + + CHKPARAM(2); + ed = embryo_program_data_get(ep); + GETSTR(sig, params[1]); + GETSTR(src, params[2]); + if ((!sig) || (!src)) return 0; + _edje_emit(ed, sig, src); + return 0; +} + +/* get_part_id(part[]) */ +static Embryo_Cell +_edje_embryo_fn_get_part_id(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + Edje_Part_Collection *col; + Edje_Part **part; + char *p; + unsigned int i; + + CHKPARAM(1); + ed = embryo_program_data_get(ep); + GETSTR(p, params[1]); + if (!p) return -1; + col = ed->collection; + if (!col) return -1; + part = col->parts; + for (i = 0; i < col->parts_count; i++, part++) + { + if (!(*part)->name) continue; + if (!strcmp((*part)->name, p)) return (*part)->id; + } + return -1; +} + +static Embryo_Cell +_edje_embryo_fn_play_sample(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + char *sample_name = NULL; + float speed = 1.0; + + CHKPARAM(1); + ed = embryo_program_data_get(ep); + GETSTR(sample_name, params[1]); + if ((!sample_name)) return 0; + speed = EMBRYO_CELL_TO_FLOAT(params[2]); + _edje_multisense_internal_sound_sample_play(ed, sample_name, (double)speed); + return 0; +} + +static Embryo_Cell +_edje_embryo_fn_play_tone(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + char *tone_name = NULL; + float duration = 0.1; + + CHKPARAM(2); + ed = embryo_program_data_get(ep); + GETSTR(tone_name, params[1]); + if ((!tone_name)) return 0; + duration = EMBRYO_CELL_TO_FLOAT(params[2]); + _edje_multisense_internal_sound_tone_play(ed, tone_name, (double) duration); + return 0; +} + +/* set_state(part_id, state[], Float:state_val) */ +static Embryo_Cell +_edje_embryo_fn_set_state(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + char *state = NULL; + int part_id = 0; + float f = 0.0; + double value = 0.0; + Edje_Real_Part *rp; + + CHKPARAM(3); + ed = embryo_program_data_get(ep); + GETSTR(state, params[2]); + if ((!state)) return 0; + part_id = params[1]; + if (part_id < 0) return 0; + f = EMBRYO_CELL_TO_FLOAT(params[3]); + value = (double)f; + rp = ed->table_parts[part_id % ed->table_parts_size]; + if (rp) + { + if (rp->program) _edje_program_end(ed, rp->program); + _edje_part_description_apply(ed, rp, state, value, NULL, 0.0); + _edje_part_pos_set(ed, rp, EDJE_TWEEN_MODE_LINEAR, ZERO, ZERO, ZERO); + _edje_recalc(ed); + } + return 0; +} + +/* get_state(part_id, dst[], maxlen, &Float:val) */ +static Embryo_Cell +_edje_embryo_fn_get_state(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + int part_id = 0; + Edje_Real_Part *rp; + const char *s; + + CHKPARAM(4); + ed = embryo_program_data_get(ep); + part_id = params[1]; + if (part_id < 0) return 0; + rp = ed->table_parts[part_id % ed->table_parts_size]; + if (rp->chosen_description) + { + SETFLOAT(rp->chosen_description->state.value, params[4]); + s = rp->chosen_description->state.name; + if (s) + { + if ((int) strlen(s) < params[3]) + { + SETSTR(s, params[2]); + } + else + { + char *ss; + + ss = alloca(strlen(s) + 1); + strcpy(ss, s); + ss[params[3] - 1] = 0; + SETSTR(ss, params[2]); + } + } + else + { + SETSTR("", params[2]); + } + } + else + { + SETFLOAT(0.0, params[4]); + SETSTR("", params[2]); + } + return 0; +} + +/* set_tween_state(part_id, Float:tween, state1[], Float:state1_val, state2[], Float:state2_val) */ +static Embryo_Cell +_edje_embryo_fn_set_tween_state(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + char *state1 = NULL, *state2 = NULL; + int part_id = 0; + float f = 0.0; + double tween = 0.0, value1 = 0.0, value2 = 0.0; + Edje_Real_Part *rp; + + CHKPARAM(6); + ed = embryo_program_data_get(ep); + GETSTR(state1, params[3]); + GETSTR(state2, params[5]); + if ((!state1) || (!state2)) return 0; + part_id = params[1]; + if (part_id < 0) return 0; + f = EMBRYO_CELL_TO_FLOAT(params[2]); + tween = (double)f; + f = EMBRYO_CELL_TO_FLOAT(params[4]); + value1 = (double)f; + f = EMBRYO_CELL_TO_FLOAT(params[6]); + value2 = (double)f; + rp = ed->table_parts[part_id % ed->table_parts_size]; + if (rp) + { + if (rp->program) _edje_program_end(ed, rp->program); + _edje_part_description_apply(ed, rp, state1, value1, state2, value2); + _edje_part_pos_set(ed, rp, EDJE_TWEEN_MODE_LINEAR, FROM_DOUBLE(tween), ZERO, ZERO); + _edje_recalc(ed); + } + return 0; +} + +/* run_program(program_id) */ +static Embryo_Cell +_edje_embryo_fn_run_program(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + int program_id = 0; + Edje_Program *pr; + + CHKPARAM(1); + ed = embryo_program_data_get(ep); + program_id = params[1]; + if (program_id < 0) return 0; + pr = ed->table_programs[program_id % ed->table_programs_size]; + if (pr) + { + _edje_program_run(ed, pr, 0, "", ""); + } + return 0; +} + +/* get_drag_dir(part_id) */ +static Embryo_Cell +_edje_embryo_fn_get_drag_dir(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + int part_id = 0; + Edje_Real_Part *rp; + + CHKPARAM(1); + ed = embryo_program_data_get(ep); + part_id = params[1]; + if (part_id < 0) return 0; + rp = ed->table_parts[part_id % ed->table_parts_size]; + return edje_object_part_drag_dir_get(ed->obj, rp->part->name); +} + +/* get_drag(part_id, &Float:dx, &Float:dy) */ +static Embryo_Cell +_edje_embryo_fn_get_drag(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + int part_id = 0; + Edje_Real_Part *rp; + double dx = 0.0, dy = 0.0; + + CHKPARAM(3); + ed = embryo_program_data_get(ep); + part_id = params[1]; + if (part_id < 0) return 0; + rp = ed->table_parts[part_id % ed->table_parts_size]; + edje_object_part_drag_value_get(ed->obj, rp->part->name, &dx, &dy); + SETFLOAT(dx, params[2]); + SETFLOAT(dy, params[3]); + + return 0; +} + +/* set_drag(part_id, Float:dx, Float:dy) */ +static Embryo_Cell +_edje_embryo_fn_set_drag(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + int part_id = 0; + Edje_Real_Part *rp; + + CHKPARAM(3); + ed = embryo_program_data_get(ep); + part_id = params[1]; + if (part_id < 0) return 0; + rp = ed->table_parts[part_id % ed->table_parts_size]; + edje_object_part_drag_value_set(ed->obj, rp->part->name, + (double)EMBRYO_CELL_TO_FLOAT(params[2]), + (double)EMBRYO_CELL_TO_FLOAT(params[3])); + return(0); +} + +/* get_drag_size(part_id, &Float:dx, &Float:dy) */ +static Embryo_Cell +_edje_embryo_fn_get_drag_size(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + int part_id = 0; + Edje_Real_Part *rp; + double dx = 0.0, dy = 0.0; + + CHKPARAM(3); + ed = embryo_program_data_get(ep); + part_id = params[1]; + if (part_id < 0) return 0; + rp = ed->table_parts[part_id % ed->table_parts_size]; + edje_object_part_drag_size_get(ed->obj, rp->part->name, &dx, &dy); + SETFLOAT(dx, params[2]); + SETFLOAT(dy, params[3]); + + return 0; +} + +/* set_drag_size(part_id, Float:dx, Float:dy) */ +static Embryo_Cell +_edje_embryo_fn_set_drag_size(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + int part_id = 0; + Edje_Real_Part *rp; + + CHKPARAM(3); + ed = embryo_program_data_get(ep); + part_id = params[1]; + if (part_id < 0) return 0; + rp = ed->table_parts[part_id % ed->table_parts_size]; + edje_object_part_drag_size_set(ed->obj, rp->part->name, + (double)EMBRYO_CELL_TO_FLOAT(params[2]), + (double)EMBRYO_CELL_TO_FLOAT(params[3])); + return(0); +} + +/* set_text(part_id, str[]) */ +static Embryo_Cell +_edje_embryo_fn_set_text(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + int part_id = 0; + Edje_Real_Part *rp; + char *s; + + CHKPARAM(2); + ed = embryo_program_data_get(ep); + part_id = params[1]; + if (part_id < 0) return 0; + rp = ed->table_parts[part_id % ed->table_parts_size]; + GETSTR(s, params[2]); + if (s){ + edje_object_part_text_set(ed->obj, rp->part->name, s); + } + return(0); +} + +/* get_text(part_id, dst[], maxlen) */ +static Embryo_Cell +_edje_embryo_fn_get_text(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + int part_id = 0; + Edje_Real_Part *rp; + char *s; + + CHKPARAM(3); + ed = embryo_program_data_get(ep); + part_id = params[1]; + if (part_id < 0) return 0; + rp = ed->table_parts[part_id % ed->table_parts_size]; + s = (char *)edje_object_part_text_get(ed->obj, rp->part->name); + if (s) + { + if ((int) strlen(s) < params[3]) + { + SETSTR(s, params[2]); + } + else + { + char *ss; + + ss = alloca(strlen(s) + 1); + strcpy(ss, s); + ss[params[3] - 1] = 0; + SETSTR(ss, params[2]); + } + } + else + { + SETSTR("", params[2]); + } + return 0; +} + +/* get_min_size(&w, &h) */ +static Embryo_Cell +_edje_embryo_fn_get_min_size(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + Evas_Coord w = 0, h = 0; + + CHKPARAM(2); + ed = embryo_program_data_get(ep); + edje_object_size_min_get(ed->obj, &w, &h); + SETINT(w, params[1]); + SETINT(h, params[2]); + return 0; +} + +/* get_max_size(&w, &h) */ +static Embryo_Cell +_edje_embryo_fn_get_max_size(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + Evas_Coord w = 0, h = 0; + + CHKPARAM(2); + ed = embryo_program_data_get(ep); + edje_object_size_max_get(ed->obj, &w, &h); + SETINT(w, params[1]); + SETINT(h, params[2]); + return 0; + +} + +/* get_color_class(class[], &r, &g, &b, &a) */ +static Embryo_Cell +_edje_embryo_fn_get_color_class(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + Edje_Color_Class *c_class; + char *class; + + CHKPARAM(5); + ed = embryo_program_data_get(ep); + GETSTR(class, params[1]); + if (!class) return 0; + c_class = _edje_color_class_find(ed, class); + if (!c_class) return 0; + SETINT(c_class->r, params[2]); + SETINT(c_class->g, params[3]); + SETINT(c_class->b, params[4]); + SETINT(c_class->a, params[5]); + return 0; +} + +/* set_color_class(class[], r, g, b, a) */ +static Embryo_Cell +_edje_embryo_fn_set_color_class(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + char *class; + + CHKPARAM(5); + ed = embryo_program_data_get(ep); + GETSTR(class, params[1]); + if (!class) return 0; + edje_object_color_class_set(ed->obj, class, params[2], params[3], params[4], params[5], + params[2], params[3], params[4], params[5], + params[2], params[3], params[4], params[5]); + return 0; +} + +/* set_text_class(class[], font[], Float:size) */ +static Embryo_Cell +_edje_embryo_fn_set_text_class(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + char *class, *font; + Evas_Font_Size fsize; + + CHKPARAM(3); + ed = embryo_program_data_get(ep); + GETSTR(class, params[1]); + GETSTR(font, params[2]); + if( !class || !font ) return 0; + fsize = (Evas_Font_Size) EMBRYO_CELL_TO_FLOAT(params[3]); + edje_object_text_class_set(ed->obj, class, font, fsize); + return 0; +} + +/* get_text_class(class[], font[], &Float:size) */ +static Embryo_Cell +_edje_embryo_fn_get_text_class(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + char *class; + Edje_Text_Class *t_class; + + CHKPARAM(3); + ed = embryo_program_data_get(ep); + GETSTR(class, params[1]); + if (!class) return 0; + t_class = _edje_text_class_find(ed, class); + if (!t_class) return 0; + SETSTR((char *)t_class->font, params[2]); + SETFLOAT(t_class->size, params[3]); + return 0; +} + +/* get_drag_step(part_id, &Float:dx, &Float:&dy) */ +static Embryo_Cell +_edje_embryo_fn_get_drag_step(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + int part_id = 0; + Edje_Real_Part *rp; + double dx = 0.0, dy = 0.0; + + CHKPARAM(3); + ed = embryo_program_data_get(ep); + part_id = params[1]; + if (part_id < 0) return 0; + rp = ed->table_parts[part_id % ed->table_parts_size]; + edje_object_part_drag_step_get(ed->obj, rp->part->name, &dx, &dy); + SETFLOAT(dx, params[2]); + SETFLOAT(dy, params[3]); + + return 0; +} + +/* set_drag_step(part_id, Float:dx, Float:dy) */ +static Embryo_Cell +_edje_embryo_fn_set_drag_step(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + int part_id = 0; + Edje_Real_Part *rp; + + CHKPARAM(3); + ed = embryo_program_data_get(ep); + part_id = params[1]; + if (part_id < 0) return 0; + rp = ed->table_parts[part_id % ed->table_parts_size]; + edje_object_part_drag_step_set(ed->obj, rp->part->name, + (double)EMBRYO_CELL_TO_FLOAT(params[2]), + (double)EMBRYO_CELL_TO_FLOAT(params[3])); + return(0); +} + +/* get_drag_page(part_id, &Float:dx, &Float:&dy) */ +static Embryo_Cell +_edje_embryo_fn_get_drag_page(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + int part_id = 0; + Edje_Real_Part *rp; + double dx = 0.0, dy = 0.0; + + CHKPARAM(3); + ed = embryo_program_data_get(ep); + part_id = params[1]; + if (part_id < 0) return 0; + rp = ed->table_parts[part_id % ed->table_parts_size]; + edje_object_part_drag_page_get(ed->obj, rp->part->name, &dx, &dy); + SETFLOAT(dx, params[2]); + SETFLOAT(dy, params[3]); + + return 0; +} + +/* get_geometry(pard_id, &x, &y, &w, &h) */ +static Embryo_Cell +_edje_embryo_fn_get_geometry(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + int part_id = 0; + Edje_Real_Part *rp; + Evas_Coord x = 0.0, y = 0.0, w = 0.0, h = 0.0; + + CHKPARAM(5); + ed = embryo_program_data_get(ep); + part_id = params[1]; + if (part_id < 0) return 0; + rp = ed->table_parts[part_id % ed->table_parts_size]; + edje_object_part_geometry_get(ed->obj, rp->part->name, &x, &y, &w, &h); + SETINT(x, params[2]); + SETINT(y, params[3]); + SETINT(w, params[4]); + SETINT(h, params[5]); + + return 0; +} + +/* set_drag_page(part_id, Float:dx, Float:dy) */ +static Embryo_Cell +_edje_embryo_fn_set_drag_page(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + int part_id = 0; + Edje_Real_Part *rp; + + CHKPARAM(3); + ed = embryo_program_data_get(ep); + part_id = params[1]; + if (part_id < 0) return 0; + rp = ed->table_parts[part_id % ed->table_parts_size]; + edje_object_part_drag_page_set(ed->obj, rp->part->name, + (double)EMBRYO_CELL_TO_FLOAT(params[2]), + (double)EMBRYO_CELL_TO_FLOAT(params[3])); + return(0); +} + +/* send_message(Msg_Type:type, id,...); */ +static Embryo_Cell +_edje_embryo_fn_send_message(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + Edje_Message_Type type; + int id, i, n; + Embryo_Cell *ptr; + + if (params[0] < (int) (sizeof(Embryo_Cell) * (2))) return 0; + ed = embryo_program_data_get(ep); + type = params[1]; + id = params[2]; + switch (type) + { + case EDJE_MESSAGE_NONE: + _edje_message_send(ed, EDJE_QUEUE_APP, type, id, NULL); + break; + case EDJE_MESSAGE_SIGNAL: + break; + case EDJE_MESSAGE_STRING: + { + Embryo_Cell *cptr; + + cptr = embryo_data_address_get(ep, params[3]); + if (cptr) + { + Edje_Message_String *emsg; + int l; + char *s; + + l = embryo_data_string_length_get(ep, cptr); + s = alloca(l + 1); + s[0] = 0; + embryo_data_string_get(ep, cptr, s); + emsg = alloca(sizeof(Edje_Message_String)); + emsg->str = s; + _edje_message_send(ed, EDJE_QUEUE_APP, type, id, emsg); + } + } + break; + case EDJE_MESSAGE_INT: + { + Edje_Message_Int *emsg; + + emsg = alloca(sizeof(Edje_Message_Int)); + ptr = embryo_data_address_get(ep, params[3]); + if (ptr) emsg->val = (int)*ptr; + else emsg->val = 0; + _edje_message_send(ed, EDJE_QUEUE_APP, type, id, emsg); + } + break; + case EDJE_MESSAGE_FLOAT: + { + Edje_Message_Float *emsg; + float f; + + emsg = alloca(sizeof(Edje_Message_Float)); + ptr = embryo_data_address_get(ep, params[3]); + if (ptr) + { + f = EMBRYO_CELL_TO_FLOAT(*ptr); + emsg->val = (double)f; + } + else + emsg->val = 0.0; + _edje_message_send(ed, EDJE_QUEUE_APP, type, id, emsg); + } + break; + case EDJE_MESSAGE_STRING_SET: + { + Edje_Message_String_Set *emsg; + + n = (params[0] / sizeof(Embryo_Cell)) + 1; + emsg = alloca(sizeof(Edje_Message_String_Set) + ((n - 3 - 1) * sizeof(char *))); + emsg->count = n - 3; + for (i = 3; i < n; i++) + { + Embryo_Cell *cptr; + + cptr = embryo_data_address_get(ep, params[i]); + if (cptr) + { + int l; + char *s; + + l = embryo_data_string_length_get(ep, cptr); + s = alloca(l + 1); + s[0] = 0; + embryo_data_string_get(ep, cptr, s); + emsg->str[i - 3] = s; + } + } + _edje_message_send(ed, EDJE_QUEUE_APP, type, id, emsg); + } + break; + case EDJE_MESSAGE_INT_SET: + { + Edje_Message_Int_Set *emsg; + + n = (params[0] / sizeof(Embryo_Cell)) + 1; + emsg = alloca(sizeof(Edje_Message_Int_Set) + ((n - 3 - 1) * sizeof(int))); + emsg->count = n - 3; + for (i = 3; i < n; i++) + { + ptr = embryo_data_address_get(ep, params[i]); + if (ptr) emsg->val[i - 3] = (int)*ptr; + else emsg->val[i - 3] = 0; + } + _edje_message_send(ed, EDJE_QUEUE_APP, type, id, emsg); + } + break; + case EDJE_MESSAGE_FLOAT_SET: + { + Edje_Message_Float_Set *emsg; + + n = (params[0] / sizeof(Embryo_Cell)) + 1; + emsg = alloca(sizeof(Edje_Message_Float_Set) + ((n - 3 - 1) * sizeof(double))); + emsg->count = n - 3; + for (i = 3; i < n; i++) + { + float f; + + ptr = embryo_data_address_get(ep, params[i]); + if (ptr) + { + f = EMBRYO_CELL_TO_FLOAT(*ptr); + emsg->val[i - 3] = (double)f; + } + else + emsg->val[i - 3] = 0.0; + } + _edje_message_send(ed, EDJE_QUEUE_APP, type, id, emsg); + } + break; + case EDJE_MESSAGE_STRING_INT: + { + Edje_Message_String_Int *emsg; + Embryo_Cell *cptr; + + cptr = embryo_data_address_get(ep, params[3]); + if (cptr) + { + int l; + char *s; + + l = embryo_data_string_length_get(ep, cptr); + s = alloca(l + 1); + s[0] = 0; + embryo_data_string_get(ep, cptr, s); + emsg = alloca(sizeof(Edje_Message_String_Int)); + emsg->str = s; + ptr = embryo_data_address_get(ep, params[4]); + if (ptr) emsg->val = (int)*ptr; + else emsg->val = 0; + _edje_message_send(ed, EDJE_QUEUE_APP, type, id, emsg); + } + } + break; + case EDJE_MESSAGE_STRING_FLOAT: + { + Edje_Message_String_Float *emsg; + Embryo_Cell *cptr; + + cptr = embryo_data_address_get(ep, params[3]); + if (cptr) + { + int l; + char *s; + float f; + + l = embryo_data_string_length_get(ep, cptr); + s = alloca(l + 1); + s[0] = 0; + embryo_data_string_get(ep, cptr, s); + emsg = alloca(sizeof(Edje_Message_String_Float)); + emsg->str = s; + ptr = embryo_data_address_get(ep, params[4]); + if (ptr) + { + f = EMBRYO_CELL_TO_FLOAT(*ptr); + emsg->val = (double)f; + } + else + emsg->val = 0.0; + _edje_message_send(ed, EDJE_QUEUE_APP, type, id, emsg); + } + } + break; + case EDJE_MESSAGE_STRING_INT_SET: + { + Edje_Message_String_Int_Set *emsg; + Embryo_Cell *cptr; + + cptr = embryo_data_address_get(ep, params[3]); + if (cptr) + { + int l; + char *s; + + l = embryo_data_string_length_get(ep, cptr); + s = alloca(l + 1); + s[0] = 0; + embryo_data_string_get(ep, cptr, s); + n = (params[0] / sizeof(Embryo_Cell)) + 1; + emsg = alloca(sizeof(Edje_Message_String_Int_Set) + ((n - 4 - 1) * sizeof(int))); + emsg->str = s; + emsg->count = n - 4; + for (i = 4; i < n; i++) + { + ptr = embryo_data_address_get(ep, params[i]); + if (ptr) emsg->val[i - 4] = (int)*ptr; + else emsg->val[i - 4] = 0; + } + _edje_message_send(ed, EDJE_QUEUE_APP, type, id, emsg); + } + } + break; + case EDJE_MESSAGE_STRING_FLOAT_SET: + { + Edje_Message_String_Float_Set *emsg; + Embryo_Cell *cptr; + + cptr = embryo_data_address_get(ep, params[3]); + if (cptr) + { + int l; + char *s; + + l = embryo_data_string_length_get(ep, cptr); + s = alloca(l + 1); + s[0] = 0; + embryo_data_string_get(ep, cptr, s); + n = (params[0] / sizeof(Embryo_Cell)) + 1; + emsg = alloca(sizeof(Edje_Message_String_Float_Set) + ((n - 4 - 1) * sizeof(double))); + emsg->str = s; + emsg->count = n - 4; + for (i = 4; i < n; i++) + { + float f; + + ptr = embryo_data_address_get(ep, params[i]); + if (ptr) + { + f = EMBRYO_CELL_TO_FLOAT(*ptr); + emsg->val[i - 4] = (double)f; + } + else + emsg->val[i - 4] = 0.0; + } + _edje_message_send(ed, EDJE_QUEUE_APP, type, id, emsg); + } + } + break; + default: + break; + } + return(0); +} + +/* custom_state(part_id, state[], Float:state_val = 0.0) */ +static Embryo_Cell +_edje_embryo_fn_custom_state(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed = embryo_program_data_get(ep); + Edje_Real_Part *rp; + Edje_Part_Description_Common *parent, *d = NULL; + char *name; + float val; + + CHKPARAM(3); + + if (params[1] < 0) + return 0; + + if (!(rp = ed->table_parts[params[1] % ed->table_parts_size])) + return 0; + + /* check whether this part already has a "custom" state */ + if (rp->custom) + return 0; + + GETSTR(name, params[2]); + if (!name) + return 0; + + val = EMBRYO_CELL_TO_FLOAT(params[3]); + + if (!(parent = _edje_part_description_find(ed, rp, name, val))) + return 0; + + /* now create the custom state */ + switch (rp->part->type) + { +#define ALLOC_DESC(Short, Type, To) \ + case EDJE_PART_TYPE_##Short: To = calloc(1, sizeof (Edje_Part_Description_##Type)); break; + +#define ALLOC_COPY_DESC(Short, Type, To, Spec) \ + case EDJE_PART_TYPE_##Short: \ + { \ + Edje_Part_Description_##Type *tmp; \ + Edje_Part_Description_##Type *new; \ + \ + tmp = (Edje_Part_Description_##Type *) parent; \ + \ + new = calloc(1, sizeof (Edje_Part_Description_##Type)); \ + new->Spec = tmp->Spec; \ + d = &new->common; \ + break; \ + } + + ALLOC_DESC(RECTANGLE, Common, d); + ALLOC_DESC(SWALLOW, Common, d); + ALLOC_DESC(GROUP, Common, d); + + ALLOC_COPY_DESC(IMAGE, Image, d, image); + ALLOC_COPY_DESC(TEXT, Text, d, text); + ALLOC_COPY_DESC(TEXTBLOCK, Text, d, text); + ALLOC_COPY_DESC(BOX, Box, d, box); + ALLOC_COPY_DESC(TABLE, Table, d, table); + ALLOC_COPY_DESC(EXTERNAL, External, d, external_params); + } + + if (!d) return 0; + + rp->custom = eina_mempool_malloc(_edje_real_part_state_mp, sizeof (Edje_Real_Part_State)); + if (!rp->custom) + { + free(d); + return 0; + } + + memset(rp->custom, 0, sizeof (Edje_Real_Part_State)); + + *d = *parent; + + d->state.name = (char *)eina_stringshare_add("custom"); + d->state.value = 0.0; + + /* make sure all the allocated memory is getting copied, + * not just referenced + */ + if (rp->part->type == EDJE_PART_TYPE_IMAGE) + { + Edje_Part_Description_Image *img_desc; + Edje_Part_Description_Image *parent_img_desc; + + img_desc = (Edje_Part_Description_Image*) d; + parent_img_desc = (Edje_Part_Description_Image*) parent; + + img_desc->image.tweens_count = parent_img_desc->image.tweens_count; + img_desc->image.tweens = calloc(img_desc->image.tweens_count, + sizeof(Edje_Part_Image_Id*)); + if (img_desc->image.tweens) + { + unsigned int i; + + for (i = 0; i < parent_img_desc->image.tweens_count; ++i) + { + Edje_Part_Image_Id *iid_new; + + iid_new = calloc(1, sizeof(Edje_Part_Image_Id)); + if (!iid_new) continue; + + *iid_new = *parent_img_desc->image.tweens[i]; + + img_desc->image.tweens[i] = iid_new; + } + } + } + +#define DUP(x) x ? (char *)eina_stringshare_add(x) : NULL + d->color_class = DUP(d->color_class); + + if (rp->part->type == EDJE_PART_TYPE_TEXT + || rp->part->type == EDJE_PART_TYPE_TEXTBLOCK) + { + Edje_Part_Description_Text *text_desc; + + text_desc = (Edje_Part_Description_Text*) d; + + text_desc->text.text_class = DUP(text_desc->text.text_class); + text_desc->text.text.str = DUP(edje_string_get(&text_desc->text.text)); + text_desc->text.text.id = 0; + text_desc->text.font.str = DUP(edje_string_get(&text_desc->text.font)); + text_desc->text.font.id = 0; + text_desc->text.style.str = DUP(edje_string_get(&text_desc->text.style)); + text_desc->text.style.id = 0; + } +#undef DUP + + rp->custom->description = d; + + return 0; +} + +/* set_state_val(part_id, State_Param:p, ...) */ +static Embryo_Cell +_edje_embryo_fn_set_state_val(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed = embryo_program_data_get(ep); + Edje_Real_Part *rp; + char *s; + + /* we need at least 3 arguments */ + if (params[0] < (int) (sizeof(Embryo_Cell) * 3)) + return 0; + + if (params[1] < 0) + return 0; + + if (!(rp = ed->table_parts[params[1] % ed->table_parts_size])) + return 0; + + /* check whether this part has a "custom" state */ + if (!rp->custom) + return 0; + + switch (params[2]) + { + case EDJE_STATE_PARAM_ALIGNMENT: + CHKPARAM(4); + + GETFLOAT_T(rp->custom->description->align.x, params[3]); + GETFLOAT_T(rp->custom->description->align.y, params[4]); + + break; + case EDJE_STATE_PARAM_MIN: + CHKPARAM(4); + + GETINT(rp->custom->description->min.w, params[3]); + GETINT(rp->custom->description->min.h, params[4]); + + break; + case EDJE_STATE_PARAM_MAX: + CHKPARAM(4); + + GETINT(rp->custom->description->max.w, params[3]); + GETINT(rp->custom->description->max.h, params[4]); + + break; + case EDJE_STATE_PARAM_STEP: + CHKPARAM(4); + + GETINT(rp->custom->description->step.x, params[3]); + GETINT(rp->custom->description->step.y, params[4]); + + break; + case EDJE_STATE_PARAM_ASPECT: + CHKPARAM(4); + + GETFLOAT_T(rp->custom->description->aspect.min, params[3]); + GETFLOAT_T(rp->custom->description->aspect.max, params[4]); + + break; + case EDJE_STATE_PARAM_ASPECT_PREF: + CHKPARAM(3); + + GETINT(rp->custom->description->aspect.prefer, params[3]); + + break; + case EDJE_STATE_PARAM_COLOR: + CHKPARAM(6); + + GETINT(rp->custom->description->color.r, params[3]); + GETINT(rp->custom->description->color.g, params[4]); + GETINT(rp->custom->description->color.b, params[5]); + GETINT(rp->custom->description->color.a, params[6]); + + break; + case EDJE_STATE_PARAM_COLOR2: + CHKPARAM(6); + + GETINT(rp->custom->description->color2.r, params[3]); + GETINT(rp->custom->description->color2.g, params[4]); + GETINT(rp->custom->description->color2.b, params[5]); + GETINT(rp->custom->description->color2.a, params[6]); + + break; + case EDJE_STATE_PARAM_COLOR3: + { + Edje_Part_Description_Text *text; + + if ( (rp->part->type != EDJE_PART_TYPE_TEXT) && + (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) + return 0; + + CHKPARAM(6); + + text = (Edje_Part_Description_Text*) rp->custom->description; + + GETINT(text->text.color3.r, params[3]); + GETINT(text->text.color3.g, params[4]); + GETINT(text->text.color3.b, params[5]); + GETINT(text->text.color3.a, params[6]); + break; + } + case EDJE_STATE_PARAM_COLOR_CLASS: + CHKPARAM(3); + + GETSTR(s, params[3]); + GETSTREVAS(s, rp->custom->description->color_class); + + break; + case EDJE_STATE_PARAM_REL1: + CHKPARAM(4); + + GETFLOAT_T(rp->custom->description->rel1.relative_x, params[3]); + GETFLOAT_T(rp->custom->description->rel1.relative_y, params[4]); + + break; + case EDJE_STATE_PARAM_REL1_TO: + CHKPARAM(4); + + GETINT(rp->custom->description->rel1.id_x, params[3]); + GETINT(rp->custom->description->rel1.id_y, params[4]); + + if (rp->param1.description->rel1.id_x >= 0) + rp->param1.rel1_to_x = ed->table_parts[rp->param1.description->rel1.id_x % ed->table_parts_size]; + if (rp->param1.description->rel1.id_y >= 0) + rp->param1.rel1_to_y = ed->table_parts[rp->param1.description->rel1.id_y % ed->table_parts_size]; + + break; + case EDJE_STATE_PARAM_REL1_OFFSET: + CHKPARAM(4); + + GETINT(rp->custom->description->rel1.offset_x, params[3]); + GETINT(rp->custom->description->rel1.offset_y, params[4]); + + break; + case EDJE_STATE_PARAM_REL2: + CHKPARAM(4); + + GETFLOAT_T(rp->custom->description->rel2.relative_x, params[3]); + GETFLOAT_T(rp->custom->description->rel2.relative_y, params[4]); + + break; + case EDJE_STATE_PARAM_REL2_TO: + CHKPARAM(4); + + GETINT(rp->custom->description->rel2.id_x, params[3]); + GETINT(rp->custom->description->rel2.id_y, params[4]); + + if (rp->param1.description->rel2.id_x >= 0) + rp->param1.rel2_to_x = ed->table_parts[rp->param1.description->rel2.id_x % ed->table_parts_size]; + if (rp->param1.description->rel2.id_y >= 0) + rp->param1.rel2_to_y = ed->table_parts[rp->param1.description->rel2.id_y % ed->table_parts_size]; + + break; + case EDJE_STATE_PARAM_REL2_OFFSET: + CHKPARAM(4); + + GETINT(rp->custom->description->rel2.offset_x, params[3]); + GETINT(rp->custom->description->rel2.offset_y, params[4]); + + break; + case EDJE_STATE_PARAM_IMAGE: + { + Edje_Part_Description_Image *img; + + if ( (rp->part->type != EDJE_PART_TYPE_IMAGE) ) return 0; + CHKPARAM(3); + + img = (Edje_Part_Description_Image*) rp->custom->description; + GETINT(img->image.id, params[3]); + + break; + } + case EDJE_STATE_PARAM_BORDER: + { + Edje_Part_Description_Image *img; + + if ( (rp->part->type != EDJE_PART_TYPE_IMAGE) ) return 0; + CHKPARAM(6); + + img = (Edje_Part_Description_Image*) rp->custom->description; + + GETINT(img->image.border.l, params[3]); + GETINT(img->image.border.r, params[4]); + GETINT(img->image.border.t, params[5]); + GETINT(img->image.border.b, params[6]); + + break; + } + case EDJE_STATE_PARAM_FILL_SMOOTH: + { + Edje_Part_Description_Image *img; + + if ( (rp->part->type != EDJE_PART_TYPE_IMAGE) ) return 0; + CHKPARAM(3); + + img = (Edje_Part_Description_Image*) rp->custom->description; + + GETINT(img->image.fill.smooth, params[3]); + + break; + } + case EDJE_STATE_PARAM_FILL_POS: + { + Edje_Part_Description_Image *img; + + if ( (rp->part->type != EDJE_PART_TYPE_IMAGE) ) return 0; + CHKPARAM(6); + + img = (Edje_Part_Description_Image*) rp->custom->description; + + GETFLOAT_T(img->image.fill.pos_rel_x, params[3]); + GETFLOAT_T(img->image.fill.pos_rel_y, params[4]); + GETINT(img->image.fill.pos_abs_x, params[5]); + GETINT(img->image.fill.pos_abs_y, params[6]); + + break; + } + case EDJE_STATE_PARAM_FILL_SIZE: + { + Edje_Part_Description_Image *img; + + if ( (rp->part->type != EDJE_PART_TYPE_IMAGE) ) return 0; + CHKPARAM(6); + + img = (Edje_Part_Description_Image*) rp->custom->description; + + GETFLOAT_T(img->image.fill.rel_x, params[3]); + GETFLOAT_T(img->image.fill.rel_y, params[4]); + GETINT(img->image.fill.abs_x, params[5]); + GETINT(img->image.fill.abs_y, params[6]); + + break; + } + case EDJE_STATE_PARAM_TEXT: + { + Edje_Part_Description_Text *text; + + if ( (rp->part->type != EDJE_PART_TYPE_TEXT) && + (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) + return 0; + CHKPARAM(3); + + GETSTR(s, params[3]); + + text = (Edje_Part_Description_Text*) rp->custom->description; + GETSTREVAS(s, text->text.text.str); + + break; + } + case EDJE_STATE_PARAM_TEXT_CLASS: + { + Edje_Part_Description_Text *text; + + if ( (rp->part->type != EDJE_PART_TYPE_TEXT) && + (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) + return 0; + CHKPARAM(3); + + GETSTR(s, params[3]); + + text = (Edje_Part_Description_Text*) rp->custom->description; + GETSTREVAS(s, text->text.text_class); + + break; + } + case EDJE_STATE_PARAM_TEXT_FONT: + { + Edje_Part_Description_Text *text; + + if ((rp->part->type != EDJE_PART_TYPE_TEXT)) return 0; + CHKPARAM(3); + + GETSTR(s, params[3]); + + text = (Edje_Part_Description_Text*) rp->custom->description; + GETSTREVAS(s, text->text.font.str); + + break; + } + case EDJE_STATE_PARAM_TEXT_STYLE: + { + Edje_Part_Description_Text *text; + + if ((rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) return 0; + CHKPARAM(3); + + GETSTR(s, params[3]); + + text = (Edje_Part_Description_Text*) rp->custom->description; + GETSTREVAS(s, text->text.style.str); + + break; + } + case EDJE_STATE_PARAM_TEXT_SIZE: + { + Edje_Part_Description_Text *text; + + if ((rp->part->type != EDJE_PART_TYPE_TEXT)) return 0; + CHKPARAM(3); + + text = (Edje_Part_Description_Text*) rp->custom->description; + GETINT(text->text.size, params[3]); + + break; + } + case EDJE_STATE_PARAM_TEXT_FIT: + { + Edje_Part_Description_Text *text; + + if ((rp->part->type != EDJE_PART_TYPE_TEXT)) return 0; + CHKPARAM(4); + + text = (Edje_Part_Description_Text*) rp->custom->description; + + GETINT(text->text.fit_x, params[3]); + GETINT(text->text.fit_y, params[4]); + + break; + } + case EDJE_STATE_PARAM_TEXT_MIN: + { + Edje_Part_Description_Text *text; + + if ( (rp->part->type != EDJE_PART_TYPE_TEXT) && + (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) + return 0; + CHKPARAM(4); + + text = (Edje_Part_Description_Text*) rp->custom->description; + + GETINT(text->text.min_x, params[3]); + GETINT(text->text.min_y, params[4]); + + break; + } + case EDJE_STATE_PARAM_TEXT_MAX: + { + Edje_Part_Description_Text *text; + + if ( (rp->part->type != EDJE_PART_TYPE_TEXT) && + (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) + return 0; + CHKPARAM(4); + + text = (Edje_Part_Description_Text*) rp->custom->description; + + GETINT(text->text.max_x, params[3]); + GETINT(text->text.max_y, params[4]); + + break; + } + case EDJE_STATE_PARAM_TEXT_ALIGN: + { + Edje_Part_Description_Text *text; + + if ((rp->part->type != EDJE_PART_TYPE_TEXT)) return 0; + CHKPARAM(4); + + text = (Edje_Part_Description_Text*) rp->custom->description; + + GETFLOAT_T(text->text.align.x, params[3]); + GETFLOAT_T(text->text.align.y, params[4]); + + break; + } + case EDJE_STATE_PARAM_VISIBLE: + CHKPARAM(3); + + GETINT(rp->custom->description->visible, params[3]); + + break; + case EDJE_STATE_PARAM_MAP_OM: + CHKPARAM(3); + + GETINT(rp->custom->description->map.on, params[3]); + + break; + case EDJE_STATE_PARAM_MAP_PERSP: + CHKPARAM(3); + + GETINT(rp->custom->description->map.id_persp, params[3]); + + break; + case EDJE_STATE_PARAM_MAP_LIGNT: + CHKPARAM(3); + + GETINT(rp->custom->description->map.id_light, params[3]); + + break; + case EDJE_STATE_PARAM_MAP_ROT_CENTER: + CHKPARAM(3); + + GETINT(rp->custom->description->map.rot.id_center, params[3]); + + break; + case EDJE_STATE_PARAM_MAP_ROT_X: + CHKPARAM(3); + + GETFLOAT_T(rp->custom->description->map.rot.x, params[3]); + + break; + case EDJE_STATE_PARAM_MAP_ROT_Y: + CHKPARAM(3); + + GETFLOAT_T(rp->custom->description->map.rot.y, params[3]); + + break; + case EDJE_STATE_PARAM_MAP_ROT_Z: + CHKPARAM(3); + + GETFLOAT_T(rp->custom->description->map.rot.z, params[3]); + + break; + case EDJE_STATE_PARAM_MAP_BACK_CULL: + CHKPARAM(3); + + GETINT(rp->custom->description->map.backcull, params[3]); + + break; + case EDJE_STATE_PARAM_MAP_PERSP_ON: + CHKPARAM(3); + + GETINT(rp->custom->description->map.persp_on, params[3]); + + break; + case EDJE_STATE_PARAM_PERSP_ZPLANE: + CHKPARAM(3); + + GETINT(rp->custom->description->persp.zplane, params[3]); + + break; + case EDJE_STATE_PARAM_PERSP_FOCAL: + CHKPARAM(3); + + GETINT(rp->custom->description->persp.focal, params[3]); + + break; + default: + break; + } + +#ifdef EDJE_CALC_CACHE + rp->invalidate = 1; +#endif + ed->dirty=1; + return 0; +} + +/* get_state_val(part_id, State_Param:p, ...) */ +static Embryo_Cell +_edje_embryo_fn_get_state_val(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed = embryo_program_data_get(ep); + Edje_Real_Part *rp; + char *s; + + /* we need at least 3 arguments */ + if (params[0] < (int) (sizeof(Embryo_Cell) * 3)) + return 0; + + if (params[1] < 0) + return 0; + + if (!(rp = ed->table_parts[params[1] % ed->table_parts_size])) + return 0; + + /* check whether this part has a "custom" state */ + if (!rp->custom) + return 0; + + switch (params[2]) + { + case EDJE_STATE_PARAM_ALIGNMENT: + CHKPARAM(4); + + SETFLOAT_T(rp->custom->description->align.x, params[3]); + SETFLOAT_T(rp->custom->description->align.y, params[4]); + + break; + case EDJE_STATE_PARAM_MIN: + CHKPARAM(4); + + SETINT(rp->custom->description->min.w, params[3]); + SETINT(rp->custom->description->min.h, params[4]); + + break; + case EDJE_STATE_PARAM_MAX: + CHKPARAM(4); + + SETINT(rp->custom->description->max.w, params[3]); + SETINT(rp->custom->description->max.h, params[4]); + + break; + case EDJE_STATE_PARAM_STEP: + CHKPARAM(4); + + SETINT(rp->custom->description->step.x, params[3]); + SETINT(rp->custom->description->step.y, params[4]); + + break; + case EDJE_STATE_PARAM_ASPECT: + CHKPARAM(4); + + SETFLOAT_T(rp->custom->description->aspect.min, params[3]); + SETFLOAT_T(rp->custom->description->aspect.max, params[4]); + + break; + case EDJE_STATE_PARAM_ASPECT_PREF: + CHKPARAM(3); + + SETINT(rp->custom->description->aspect.prefer, params[3]); + + break; + case EDJE_STATE_PARAM_COLOR: + CHKPARAM(6); + + SETINT(rp->custom->description->color.r, params[3]); + SETINT(rp->custom->description->color.g, params[4]); + SETINT(rp->custom->description->color.b, params[5]); + SETINT(rp->custom->description->color.a, params[6]); + + break; + case EDJE_STATE_PARAM_COLOR2: + CHKPARAM(6); + + SETINT(rp->custom->description->color2.r, params[3]); + SETINT(rp->custom->description->color2.g, params[4]); + SETINT(rp->custom->description->color2.b, params[5]); + SETINT(rp->custom->description->color2.a, params[6]); + + break; + case EDJE_STATE_PARAM_COLOR3: + { + Edje_Part_Description_Text *text; + + if (rp->part->type == EDJE_PART_TYPE_TEXT + || rp->part->type == EDJE_PART_TYPE_TEXTBLOCK) + return 0; + + CHKPARAM(6); + + text = (Edje_Part_Description_Text*) rp->custom->description; + + SETINT(text->text.color3.r, params[3]); + SETINT(text->text.color3.g, params[4]); + SETINT(text->text.color3.b, params[5]); + SETINT(text->text.color3.a, params[6]); + + break; + } + case EDJE_STATE_PARAM_COLOR_CLASS: + CHKPARAM(4); + + s = rp->custom->description->color_class; + SETSTRALLOCATE(s); + + break; + case EDJE_STATE_PARAM_REL1: + CHKPARAM(4); + + SETFLOAT_T(rp->custom->description->rel1.relative_x, params[3]); + SETFLOAT_T(rp->custom->description->rel1.relative_y, params[4]); + + break; + case EDJE_STATE_PARAM_REL1_TO: + CHKPARAM(4); + + SETINT(rp->custom->description->rel1.id_x, params[3]); + SETINT(rp->custom->description->rel1.id_y, params[4]); + + break; + case EDJE_STATE_PARAM_REL1_OFFSET: + CHKPARAM(4); + + SETINT(rp->custom->description->rel1.offset_x, params[3]); + SETINT(rp->custom->description->rel1.offset_y, params[4]); + + break; + case EDJE_STATE_PARAM_REL2: + CHKPARAM(4); + + SETFLOAT_T(rp->custom->description->rel2.relative_x, params[3]); + SETFLOAT_T(rp->custom->description->rel2.relative_y, params[4]); + + break; + case EDJE_STATE_PARAM_REL2_TO: + CHKPARAM(4); + + SETINT(rp->custom->description->rel2.id_x, params[3]); + SETINT(rp->custom->description->rel2.id_y, params[4]); + + break; + case EDJE_STATE_PARAM_REL2_OFFSET: + CHKPARAM(4); + + SETINT(rp->custom->description->rel2.offset_x, params[3]); + SETINT(rp->custom->description->rel2.offset_y, params[4]); + + break; + case EDJE_STATE_PARAM_IMAGE: + { + Edje_Part_Description_Image *img; + + if ( (rp->part->type != EDJE_PART_TYPE_IMAGE) ) return 0; + CHKPARAM(3); + + img = (Edje_Part_Description_Image*) rp->custom->description; + + SETINT(img->image.id, params[3]); + + break; + } + case EDJE_STATE_PARAM_BORDER: + { + Edje_Part_Description_Image *img; + + if ( (rp->part->type != EDJE_PART_TYPE_IMAGE) ) return 0; + CHKPARAM(6); + + img = (Edje_Part_Description_Image*) rp->custom->description; + + SETINT(img->image.border.l, params[3]); + SETINT(img->image.border.r, params[4]); + SETINT(img->image.border.t, params[5]); + SETINT(img->image.border.b, params[6]); + + break; + } + case EDJE_STATE_PARAM_FILL_SMOOTH: + { + Edje_Part_Description_Image *img; + + if ( (rp->part->type != EDJE_PART_TYPE_IMAGE) ) return 0; + CHKPARAM(3); + + img = (Edje_Part_Description_Image*) rp->custom->description; + + SETINT(img->image.fill.smooth, params[3]); + + break; + } + case EDJE_STATE_PARAM_FILL_POS: + { + Edje_Part_Description_Image *img; + + if ( (rp->part->type != EDJE_PART_TYPE_IMAGE) ) return 0; + CHKPARAM(6); + + img = (Edje_Part_Description_Image*) rp->custom->description; + + SETFLOAT_T(img->image.fill.pos_rel_x, params[3]); + SETFLOAT_T(img->image.fill.pos_rel_y, params[4]); + SETINT(img->image.fill.pos_abs_x, params[5]); + SETINT(img->image.fill.pos_abs_y, params[6]); + + break; + } + case EDJE_STATE_PARAM_FILL_SIZE: + { + Edje_Part_Description_Image *img; + + if ( (rp->part->type != EDJE_PART_TYPE_IMAGE) ) return 0; + CHKPARAM(6); + + img = (Edje_Part_Description_Image*) rp->custom->description; + + SETFLOAT_T(img->image.fill.rel_x, params[3]); + SETFLOAT_T(img->image.fill.rel_y, params[4]); + SETINT(img->image.fill.abs_x, params[5]); + SETINT(img->image.fill.abs_y, params[6]); + + break; + } + case EDJE_STATE_PARAM_TEXT: + { + Edje_Part_Description_Text *text; + + if (rp->part->type == EDJE_PART_TYPE_TEXT + || rp->part->type == EDJE_PART_TYPE_TEXTBLOCK) + return 0; + + CHKPARAM(4); + + text = (Edje_Part_Description_Text*) rp->custom->description; + + s = (char *)text->text.text.str; + SETSTRALLOCATE(s); + + break; + } + case EDJE_STATE_PARAM_TEXT_CLASS: + { + Edje_Part_Description_Text *text; + + if ( (rp->part->type != EDJE_PART_TYPE_TEXT) && + (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) + return 0; + + CHKPARAM(4); + + text = (Edje_Part_Description_Text*) rp->custom->description; + + s = text->text.text_class; + SETSTRALLOCATE(s); + + break; + } + case EDJE_STATE_PARAM_TEXT_FONT: + { + Edje_Part_Description_Text *text; + + if ((rp->part->type != EDJE_PART_TYPE_TEXT)) return 0; + + CHKPARAM(4); + + text = (Edje_Part_Description_Text*) rp->custom->description; + + s = (char *)text->text.font.str; + SETSTRALLOCATE(s); + + break; + } + case EDJE_STATE_PARAM_TEXT_STYLE: + { + Edje_Part_Description_Text *text; + + if ((rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) return 0; + + CHKPARAM(4); + + text = (Edje_Part_Description_Text*) rp->custom->description; + + s = (char *)text->text.style.str; + SETSTRALLOCATE(s); + + break; + } + case EDJE_STATE_PARAM_TEXT_SIZE: + { + Edje_Part_Description_Text *text; + + if ((rp->part->type != EDJE_PART_TYPE_TEXT)) return 0; + + CHKPARAM(3); + + text = (Edje_Part_Description_Text*) rp->custom->description; + + SETINT(text->text.size, params[3]); + + break; + } + case EDJE_STATE_PARAM_TEXT_FIT: + { + Edje_Part_Description_Text *text; + + if ((rp->part->type != EDJE_PART_TYPE_TEXT)) return 0; + CHKPARAM(4); + + text = (Edje_Part_Description_Text*) rp->custom->description; + + SETINT(text->text.fit_x, params[3]); + SETINT(text->text.fit_y, params[4]); + + break; + } + case EDJE_STATE_PARAM_TEXT_MIN: + { + Edje_Part_Description_Text *text; + + if ( (rp->part->type != EDJE_PART_TYPE_TEXT) && + (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) + return 0; + + CHKPARAM(4); + + text = (Edje_Part_Description_Text*) rp->custom->description; + + SETINT(text->text.min_x, params[3]); + SETINT(text->text.min_y, params[4]); + + break; + } + case EDJE_STATE_PARAM_TEXT_MAX: + { + Edje_Part_Description_Text *text; + + if ( (rp->part->type != EDJE_PART_TYPE_TEXT) && + (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) + return 0; + + CHKPARAM(4); + + text = (Edje_Part_Description_Text*) rp->custom->description; + + SETINT(text->text.max_x, params[3]); + SETINT(text->text.max_y, params[4]); + + break; + } + case EDJE_STATE_PARAM_TEXT_ALIGN: + { + Edje_Part_Description_Text *text; + + if ((rp->part->type != EDJE_PART_TYPE_TEXT)) return 0; + + CHKPARAM(4); + + text = (Edje_Part_Description_Text*) rp->custom->description; + + SETFLOAT_T(text->text.align.x, params[3]); + SETFLOAT_T(text->text.align.y, params[4]); + + break; + } + case EDJE_STATE_PARAM_VISIBLE: + CHKPARAM(3); + + SETINT(rp->custom->description->visible, params[3]); + + break; + default: + break; + } + + return 0; +} + +/* part_swallow(part_id, group_name) */ +static Embryo_Cell +_edje_embryo_fn_part_swallow(Embryo_Program *ep, Embryo_Cell *params) +{ + int part_id = 0; + char* group_name = 0; + Edje *ed; + Edje_Real_Part *rp; + Evas_Object *new_obj; + + CHKPARAM(2); + + part_id = params[1]; + if (part_id < 0) return 0; + + GETSTR(group_name, params[2]); + if (!group_name) return 0; + + ed = embryo_program_data_get(ep); + + rp = ed->table_parts[part_id % ed->table_parts_size]; + if (!rp) return 0; + + new_obj = edje_object_add(ed->base.evas); + if (!new_obj) return 0; + + if (!edje_object_file_set(new_obj, ed->file->path, group_name)) + { + evas_object_del(new_obj); + return 0; + } + edje_object_part_swallow(ed->obj, rp->part->name, new_obj); + _edje_subobj_register(ed, new_obj); + + return 0; +} + +/* external_param_get_int(id, param_name[]) */ +static Embryo_Cell +_edje_embryo_fn_external_param_get_int(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + int part_id; + Edje_Real_Part *rp; + Edje_External_Param eep; + char *param_name; + + CHKPARAM(2); + ed = embryo_program_data_get(ep); + + part_id = params[1]; + if (part_id < 0) return 0; + rp = ed->table_parts[part_id % ed->table_parts_size]; + + GETSTR(param_name, params[2]); + if (!param_name) return 0; + eep.name = param_name; + eep.type = EDJE_EXTERNAL_PARAM_TYPE_INT; + eep.i = 0; + _edje_external_param_get(NULL, rp, &eep); + return eep.i; +} + +/* external_param_set_int(id, param_name[], val) */ +static Embryo_Cell +_edje_embryo_fn_external_param_set_int(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + int part_id; + Edje_Real_Part *rp; + Edje_External_Param eep; + char *param_name; + + CHKPARAM(3); + ed = embryo_program_data_get(ep); + + part_id = params[1]; + if (part_id < 0) return 0; + rp = ed->table_parts[part_id % ed->table_parts_size]; + + GETSTR(param_name, params[2]); + if (!param_name) return 0; + eep.name = param_name; + eep.type = EDJE_EXTERNAL_PARAM_TYPE_INT; + eep.i = params[3]; + return _edje_external_param_set(NULL, rp, &eep); +} + +/* Float:external_param_get_float(id, param_name[]) */ +static Embryo_Cell +_edje_embryo_fn_external_param_get_float(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + int part_id; + Edje_Real_Part *rp; + Edje_External_Param eep; + char *param_name; + float v; + + CHKPARAM(2); + ed = embryo_program_data_get(ep); + + part_id = params[1]; + if (part_id < 0) return 0; + rp = ed->table_parts[part_id % ed->table_parts_size]; + + GETSTR(param_name, params[2]); + if (!param_name) return 0; + eep.name = param_name; + eep.type = EDJE_EXTERNAL_PARAM_TYPE_DOUBLE; + eep.d = 0.0; + _edje_external_param_get(NULL, rp, &eep); + v = eep.d; + return EMBRYO_FLOAT_TO_CELL(v); +} + +/* external_param_set_float(id, param_name[], Float:val) */ +static Embryo_Cell +_edje_embryo_fn_external_param_set_float(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + int part_id; + Edje_Real_Part *rp; + Edje_External_Param eep; + char *param_name; + + CHKPARAM(3); + ed = embryo_program_data_get(ep); + + part_id = params[1]; + if (part_id < 0) return 0; + rp = ed->table_parts[part_id % ed->table_parts_size]; + + GETSTR(param_name, params[2]); + if (!param_name) return 0; + eep.name = param_name; + eep.type = EDJE_EXTERNAL_PARAM_TYPE_DOUBLE; + eep.d = EMBRYO_CELL_TO_FLOAT(params[3]); + return _edje_external_param_set(NULL, rp, &eep); +} + +/* external_param_get_strlen(id, param_name[]) */ +static Embryo_Cell +_edje_embryo_fn_external_param_get_strlen(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + int part_id; + Edje_Real_Part *rp; + Edje_External_Param eep; + char *param_name; + + CHKPARAM(2); + ed = embryo_program_data_get(ep); + + part_id = params[1]; + if (part_id < 0) return 0; + rp = ed->table_parts[part_id % ed->table_parts_size]; + + GETSTR(param_name, params[2]); + if (!param_name) return 0; + eep.name = param_name; + eep.type = EDJE_EXTERNAL_PARAM_TYPE_STRING; + eep.s = NULL; + _edje_external_param_get(NULL, rp, &eep); + if (!eep.s) return 0; + return strlen(eep.s); +} + +/* external_param_get_str(id, param_name[], val[], val_maxlen) */ +static Embryo_Cell +_edje_embryo_fn_external_param_get_str(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + int part_id; + Edje_Real_Part *rp; + Edje_External_Param eep; + char *param_name; + size_t src_len, dst_len; + + CHKPARAM(4); + dst_len = params[4]; + if (dst_len < 1) goto error; + + ed = embryo_program_data_get(ep); + + part_id = params[1]; + if (part_id < 0) goto error; + rp = ed->table_parts[part_id % ed->table_parts_size]; + + GETSTR(param_name, params[2]); + if (!param_name) return 0; + eep.name = param_name; + eep.type = EDJE_EXTERNAL_PARAM_TYPE_STRING; + eep.s = NULL; + _edje_external_param_get(NULL, rp, &eep); + if (!eep.s) goto error; + src_len = strlen(eep.s); + if (src_len < dst_len) + { + SETSTR(eep.s, params[3]); + } + else + { + char *tmp = alloca(dst_len); + memcpy(tmp, eep.s, dst_len - 1); + tmp[dst_len] = '\0'; + SETSTR(tmp, params[3]); + } + return 1; + + error: + SETSTR("", params[3]); + return 0; +} + +/* external_param_set_str(id, param_name[], val[]) */ +static Embryo_Cell +_edje_embryo_fn_external_param_set_str(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + int part_id; + Edje_Real_Part *rp; + Edje_External_Param eep; + char *param_name, *val; + + CHKPARAM(3); + ed = embryo_program_data_get(ep); + + part_id = params[1]; + if (part_id < 0) return 0; + rp = ed->table_parts[part_id % ed->table_parts_size]; + + GETSTR(param_name, params[2]); + if (!param_name) return 0; + eep.name = param_name; + eep.type = EDJE_EXTERNAL_PARAM_TYPE_STRING; + GETSTR(val, params[3]); + if (!val) return 0; + eep.s = val; + return _edje_external_param_set(NULL, rp, &eep); +} + +/* external_param_get_choice_len(id, param_name[]) */ +static Embryo_Cell +_edje_embryo_fn_external_param_get_choice_len(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + int part_id; + Edje_Real_Part *rp; + Edje_External_Param eep; + char *param_name; + + CHKPARAM(2); + ed = embryo_program_data_get(ep); + + part_id = params[1]; + if (part_id < 0) return 0; + rp = ed->table_parts[part_id % ed->table_parts_size]; + + GETSTR(param_name, params[2]); + if (!param_name) return 0; + eep.name = param_name; + eep.type = EDJE_EXTERNAL_PARAM_TYPE_CHOICE; + eep.s = NULL; + _edje_external_param_get(NULL, rp, &eep); + if (!eep.s) return 0; + return strlen(eep.s); +} + +/* external_param_get_choice(id, param_name[], val[], val_maxlen) */ +static Embryo_Cell +_edje_embryo_fn_external_param_get_choice(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + int part_id; + Edje_Real_Part *rp; + Edje_External_Param eep; + char *param_name; + size_t src_len, dst_len; + + CHKPARAM(4); + dst_len = params[4]; + if (dst_len < 1) goto error; + + ed = embryo_program_data_get(ep); + + part_id = params[1]; + if (part_id < 0) goto error; + rp = ed->table_parts[part_id % ed->table_parts_size]; + + GETSTR(param_name, params[2]); + if (!param_name) return 0; + eep.name = param_name; + eep.type = EDJE_EXTERNAL_PARAM_TYPE_CHOICE; + eep.s = NULL; + _edje_external_param_get(NULL, rp, &eep); + if (!eep.s) goto error; + src_len = strlen(eep.s); + if (src_len < dst_len) + { + SETSTR(eep.s, params[3]); + } + else + { + char *tmp = alloca(dst_len); + memcpy(tmp, eep.s, dst_len - 1); + tmp[dst_len] = '\0'; + SETSTR(tmp, params[3]); + } + return 1; + + error: + SETSTR("", params[3]); + return 0; +} + +/* external_param_set_choice(id, param_name[], val[]) */ +static Embryo_Cell +_edje_embryo_fn_external_param_set_choice(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + int part_id; + Edje_Real_Part *rp; + Edje_External_Param eep; + char *param_name, *val; + + CHKPARAM(3); + ed = embryo_program_data_get(ep); + + part_id = params[1]; + if (part_id < 0) return 0; + rp = ed->table_parts[part_id % ed->table_parts_size]; + + GETSTR(param_name, params[2]); + if (!param_name) return 0; + eep.name = param_name; + eep.type = EDJE_EXTERNAL_PARAM_TYPE_CHOICE; + GETSTR(val, params[3]); + if (!val) return 0; + eep.s = val; + return _edje_external_param_set(NULL, rp, &eep); +} + +/* external_param_get_bool(id, param_name[]) */ +static Embryo_Cell +_edje_embryo_fn_external_param_get_bool(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + int part_id; + Edje_Real_Part *rp; + Edje_External_Param eep; + char *param_name; + + CHKPARAM(2); + ed = embryo_program_data_get(ep); + + part_id = params[1]; + if (part_id < 0) return 0; + rp = ed->table_parts[part_id % ed->table_parts_size]; + + GETSTR(param_name, params[2]); + if (!param_name) return 0; + eep.name = param_name; + eep.type = EDJE_EXTERNAL_PARAM_TYPE_BOOL; + eep.i = 0; + _edje_external_param_get(NULL, rp, &eep); + return eep.i; +} + +/* external_param_set_bool(id, param_name[], val) */ +static Embryo_Cell +_edje_embryo_fn_external_param_set_bool(Embryo_Program *ep, Embryo_Cell *params) +{ + Edje *ed; + int part_id; + Edje_Real_Part *rp; + Edje_External_Param eep; + char *param_name; + + CHKPARAM(3); + ed = embryo_program_data_get(ep); + + part_id = params[1]; + if (part_id < 0) return 0; + rp = ed->table_parts[part_id % ed->table_parts_size]; + + GETSTR(param_name, params[2]); + if (!param_name) return 0; + eep.name = param_name; + eep.type = EDJE_EXTERNAL_PARAM_TYPE_BOOL; + eep.i = params[3]; + return _edje_external_param_set(NULL, rp, &eep); +} + +void +_edje_embryo_script_init(Edje_Part_Collection *edc) +{ + Embryo_Program *ep; + + if (!edc) return; + if (!edc->script) return; + + ep = edc->script; + /* first advertise all the edje "script" calls */ + embryo_program_native_call_add(ep, "get_int", _edje_embryo_fn_get_int); + embryo_program_native_call_add(ep, "set_int", _edje_embryo_fn_set_int); + embryo_program_native_call_add(ep, "get_float", _edje_embryo_fn_get_float); + embryo_program_native_call_add(ep, "set_float", _edje_embryo_fn_set_float); + embryo_program_native_call_add(ep, "get_str", _edje_embryo_fn_get_str); + embryo_program_native_call_add(ep, "get_strlen", _edje_embryo_fn_get_strlen); + embryo_program_native_call_add(ep, "set_str", _edje_embryo_fn_set_str); + embryo_program_native_call_add(ep, "count", _edje_embryo_fn_count); + embryo_program_native_call_add(ep, "remove", _edje_embryo_fn_remove); + embryo_program_native_call_add(ep, "append_int", _edje_embryo_fn_append_int); + embryo_program_native_call_add(ep, "prepend_int", _edje_embryo_fn_prepend_int); + embryo_program_native_call_add(ep, "insert_int", _edje_embryo_fn_insert_int); + embryo_program_native_call_add(ep, "replace_int", _edje_embryo_fn_replace_int); + embryo_program_native_call_add(ep, "fetch_int", _edje_embryo_fn_fetch_int); + embryo_program_native_call_add(ep, "append_str", _edje_embryo_fn_append_str); + embryo_program_native_call_add(ep, "prepend_str", _edje_embryo_fn_prepend_str); + embryo_program_native_call_add(ep, "insert_str", _edje_embryo_fn_insert_str); + embryo_program_native_call_add(ep, "replace_str", _edje_embryo_fn_replace_str); + embryo_program_native_call_add(ep, "fetch_str", _edje_embryo_fn_fetch_str); + embryo_program_native_call_add(ep, "append_float", _edje_embryo_fn_append_float); + embryo_program_native_call_add(ep, "prepend_float", _edje_embryo_fn_prepend_float); + embryo_program_native_call_add(ep, "insert_float", _edje_embryo_fn_insert_float); + embryo_program_native_call_add(ep, "replace_float", _edje_embryo_fn_replace_float); + embryo_program_native_call_add(ep, "fetch_float", _edje_embryo_fn_fetch_float); + + embryo_program_native_call_add(ep, "timer", _edje_embryo_fn_timer); + embryo_program_native_call_add(ep, "cancel_timer", _edje_embryo_fn_cancel_timer); + + embryo_program_native_call_add(ep, "anim", _edje_embryo_fn_anim); + embryo_program_native_call_add(ep, "cancel_anim", _edje_embryo_fn_cancel_anim); + + embryo_program_native_call_add(ep, "emit", _edje_embryo_fn_emit); + embryo_program_native_call_add(ep, "get_part_id", _edje_embryo_fn_get_part_id); + embryo_program_native_call_add(ep, "set_state", _edje_embryo_fn_set_state); + embryo_program_native_call_add(ep, "get_state", _edje_embryo_fn_get_state); + embryo_program_native_call_add(ep, "set_tween_state", _edje_embryo_fn_set_tween_state); + embryo_program_native_call_add(ep, "run_program", _edje_embryo_fn_run_program); + embryo_program_native_call_add(ep, "get_drag_dir", _edje_embryo_fn_get_drag_dir); + embryo_program_native_call_add(ep, "get_drag", _edje_embryo_fn_get_drag); + embryo_program_native_call_add(ep, "set_drag", _edje_embryo_fn_set_drag); + embryo_program_native_call_add(ep, "get_drag_size", _edje_embryo_fn_get_drag_size); + embryo_program_native_call_add(ep, "set_drag_size", _edje_embryo_fn_set_drag_size); + embryo_program_native_call_add(ep, "set_text", _edje_embryo_fn_set_text); + embryo_program_native_call_add(ep, "get_text", _edje_embryo_fn_get_text); + embryo_program_native_call_add(ep, "get_min_size", _edje_embryo_fn_get_min_size); + embryo_program_native_call_add(ep, "get_max_size", _edje_embryo_fn_get_max_size); + embryo_program_native_call_add(ep, "get_color_class", _edje_embryo_fn_get_color_class); + embryo_program_native_call_add(ep, "set_color_class", _edje_embryo_fn_set_color_class); + embryo_program_native_call_add(ep, "set_text_class", _edje_embryo_fn_set_text_class); + embryo_program_native_call_add(ep, "get_text_class", _edje_embryo_fn_get_text_class); + embryo_program_native_call_add(ep, "get_drag_step", _edje_embryo_fn_get_drag_step); + embryo_program_native_call_add(ep, "set_drag_step", _edje_embryo_fn_set_drag_step); + embryo_program_native_call_add(ep, "get_drag_page", _edje_embryo_fn_get_drag_page); + embryo_program_native_call_add(ep, "set_drag_page", _edje_embryo_fn_set_drag_page); + embryo_program_native_call_add(ep, "get_mouse", _edje_embryo_fn_get_mouse); + embryo_program_native_call_add(ep, "get_mouse_buttons", _edje_embryo_fn_get_mouse_buttons); + embryo_program_native_call_add(ep, "stop_program", _edje_embryo_fn_stop_program); + embryo_program_native_call_add(ep, "stop_programs_on", _edje_embryo_fn_stop_programs_on); + embryo_program_native_call_add(ep, "set_min_size", _edje_embryo_fn_set_min_size); + embryo_program_native_call_add(ep, "set_max_size", _edje_embryo_fn_set_max_size); + embryo_program_native_call_add(ep, "play_sample", _edje_embryo_fn_play_sample); + embryo_program_native_call_add(ep, "play_tone", _edje_embryo_fn_play_tone); + embryo_program_native_call_add(ep, "send_message", _edje_embryo_fn_send_message); + embryo_program_native_call_add(ep, "get_geometry", _edje_embryo_fn_get_geometry); + embryo_program_native_call_add(ep, "custom_state", _edje_embryo_fn_custom_state); + embryo_program_native_call_add(ep, "set_state_val", _edje_embryo_fn_set_state_val); + embryo_program_native_call_add(ep, "get_state_val", _edje_embryo_fn_get_state_val); + + embryo_program_native_call_add(ep, "part_swallow", _edje_embryo_fn_part_swallow); + + embryo_program_native_call_add(ep, "external_param_get_int", _edje_embryo_fn_external_param_get_int); + embryo_program_native_call_add(ep, "external_param_set_int", _edje_embryo_fn_external_param_set_int); + embryo_program_native_call_add(ep, "external_param_get_float", _edje_embryo_fn_external_param_get_float); + embryo_program_native_call_add(ep, "external_param_set_float", _edje_embryo_fn_external_param_set_float); + embryo_program_native_call_add(ep, "external_param_get_strlen", _edje_embryo_fn_external_param_get_strlen); + embryo_program_native_call_add(ep, "external_param_get_str", _edje_embryo_fn_external_param_get_str); + embryo_program_native_call_add(ep, "external_param_set_str", _edje_embryo_fn_external_param_set_str); + embryo_program_native_call_add(ep, "external_param_get_choice_len", _edje_embryo_fn_external_param_get_choice_len); + embryo_program_native_call_add(ep, "external_param_get_choice", _edje_embryo_fn_external_param_get_choice); + embryo_program_native_call_add(ep, "external_param_set_choice", _edje_embryo_fn_external_param_set_choice); + embryo_program_native_call_add(ep, "external_param_get_bool", _edje_embryo_fn_external_param_get_bool); + embryo_program_native_call_add(ep, "external_param_set_bool", _edje_embryo_fn_external_param_set_bool); +} + +void +_edje_embryo_script_shutdown(Edje_Part_Collection *edc) +{ + if (!edc) return; + if (!edc->script) return; + if (embryo_program_recursion_get(edc->script) > 0) return; + embryo_program_free(edc->script); + edc->script = NULL; +} + +void +_edje_embryo_script_reset(Edje *ed) +{ + if (!ed) return; + if (!ed->collection) return; + if (!ed->collection->script) return; + if (embryo_program_recursion_get(ed->collection->script) > 0) return; + embryo_program_vm_reset(ed->collection->script); + _edje_embryo_globals_init(ed); +} + +/* this may change in future - thus "test_run" is its name */ +void +_edje_embryo_test_run(Edje *ed, const char *fname, const char *sig, const char *src) +{ + Embryo_Function fn; + + if (!ed) return; + if (!ed->collection) return; + if (!ed->collection->script) return; + embryo_program_vm_push(ed->collection->script); + _edje_embryo_globals_init(ed); + + // _edje_embryo_script_reset(ed); + fn = embryo_program_function_find(ed->collection->script, (char *)fname); + if (fn != EMBRYO_FUNCTION_NONE) + { + void *pdata; + int ret; + + embryo_parameter_string_push(ed->collection->script, (char *)sig); + embryo_parameter_string_push(ed->collection->script, (char *)src); + pdata = embryo_program_data_get(ed->collection->script); + embryo_program_data_set(ed->collection->script, ed); + /* 5 million instructions is an arbitrary number. on my p4-2.6 here */ + /* IF embryo is ONLY running embryo stuff and NO native calls thats */ + /* about 0.016 seconds, and longer on slower cpu's. if a simple */ + /* embryo script snippet hasn't managed to do its work in 5 MILLION */ + /* embryo virtual machine instructions - something is wrong, or */ + /* embryo is simply being mis-used. Embryo is meant to be minimal */ + /* logic enhancment - not entire applications. this cycle count */ + /* does NOT include time spent in native function calls, that the */ + /* script may call to do the REAL work, so in terms of time this */ + /* will likely end up being much longer than 0.016 seconds - more */ + /* like 0.03 - 0.05 seconds or even more */ + embryo_program_max_cycle_run_set(ed->collection->script, 5000000); + ret = embryo_program_run(ed->collection->script, fn); + if (ret == EMBRYO_PROGRAM_FAIL) + { + ERR("ERROR with embryo script. " + "OBJECT NAME: '%s', " + "OBJECT FILE: '%s', " + "ENTRY POINT: '%s', " + "SIGNAL: '%s', " + "SOURCE: '%s', " + "ERROR: '%s'", + ed->collection->part, + ed->file->path, + fname, + sig, src, + embryo_error_string_get(embryo_program_error_get(ed->collection->script))); + } + else if (ret == EMBRYO_PROGRAM_TOOLONG) + { + ERR("ERROR with embryo script. " + "OBJECT NAME: '%s', " + "OBJECT FILE: '%s', " + "ENTRY POINT: '%s', " + "SIGNAL: '%s', " + "SOURCE: '%s', " + "ERROR: 'Script exceeded maximum allowed cycle count of %i'", + ed->collection->part, + ed->file->path, + fname, + sig, src, + embryo_program_max_cycle_run_get(ed->collection->script)); + } + embryo_program_data_set(ed->collection->script, pdata); + } + embryo_program_vm_pop(ed->collection->script); +} + +void +_edje_embryo_globals_init(Edje *ed) +{ + int n, i; + Embryo_Program *ep; + + ep = ed->collection->script; + n = embryo_program_variable_count_get(ep); + for (i = 0; i < n; i++) + { + Embryo_Cell cell, *cptr; + + cell = embryo_program_variable_get(ep, i); + if (cell != EMBRYO_CELL_NONE) + { + cptr = embryo_data_address_get(ep, cell); + if (cptr) *cptr = EDJE_VAR_MAGIC_BASE + i; + } + } +} 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 @@ +#include "edje_private.h" + +#ifdef HAVE_ECORE_IMF +static Eina_Bool _edje_entry_imf_retrieve_surrounding_cb(void *data, Ecore_IMF_Context *ctx, char **text, int *cursor_pos); +static Eina_Bool _edje_entry_imf_event_commit_cb(void *data, int type, void *event); +static Eina_Bool _edje_entry_imf_event_preedit_changed_cb(void *data, int type, void *event); +static Eina_Bool _edje_entry_imf_event_delete_surrounding_cb(void *data, int type, void *event); +#endif + +typedef struct _Entry Entry; +typedef struct _Sel Sel; +typedef struct _Anchor Anchor; + +static void _edje_entry_imf_cursor_info_set(Entry *en); +static void _edje_entry_imf_context_reset(Entry *en); + +struct _Entry +{ + Edje_Real_Part *rp; + Evas_Object *cursor_bg; + Evas_Object *cursor_fg; + Evas_Textblock_Cursor *cursor; + Evas_Textblock_Cursor *sel_start, *sel_end; + Evas_Textblock_Cursor *cursor_user, *cursor_user_extra; + Evas_Textblock_Cursor *preedit_start, *preedit_end; + Ecore_Timer *pw_timer; + Eina_List *sel; + Eina_List *anchors; + Eina_List *anchorlist; + Eina_List *itemlist; + char *selection; + Eina_Bool selecting : 1; + Eina_Bool have_selection : 1; + Eina_Bool select_allow : 1; + Eina_Bool select_mod_start : 1; + Eina_Bool select_mod_end : 1; + Eina_Bool had_sel : 1; + +#ifdef HAVE_ECORE_IMF + Eina_Bool have_preedit : 1; + Ecore_IMF_Context *imf_context; + + Ecore_Event_Handler *imf_ee_handler_commit; + Ecore_Event_Handler *imf_ee_handler_delete; + Ecore_Event_Handler *imf_ee_handler_changed; +#endif +}; + +struct _Sel +{ + Evas_Textblock_Rectangle rect; + Evas_Object *obj_fg, *obj_bg, *obj, *sobj; +}; + +struct _Anchor +{ + Entry *en; + char *name; + Evas_Textblock_Cursor *start, *end; + Eina_List *sel; + Eina_Bool item : 1; +}; + +#ifdef HAVE_ECORE_IMF +static void +_preedit_clear(Entry *en) +{ + if (en->preedit_start) + { + evas_textblock_cursor_free(en->preedit_start); + en->preedit_start = NULL; + } + + if (en->preedit_end) + { + evas_textblock_cursor_free(en->preedit_end); + en->preedit_end = NULL; + } + + en->have_preedit = EINA_FALSE; +} + +static void +_preedit_del(Entry *en) +{ + if (!en || !en->have_preedit) return; + if (!en->preedit_start || !en->preedit_end) return; + if (!evas_textblock_cursor_compare(en->preedit_start, en->preedit_end)) return; + + /* delete the preedit characters */ + evas_textblock_cursor_range_delete(en->preedit_start, en->preedit_end); +} + +static void +_edje_entry_focus_in_cb(void *data, Evas_Object *o __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__) +{ + Edje_Real_Part *rp; + Entry *en; + + rp = data; + if (!rp || !rp->entry_data || !rp->edje || !rp->edje->obj) return; + + en = rp->entry_data; + if (!en || !en->imf_context) return; + + if (evas_object_focus_get(rp->edje->obj)) + { + ecore_imf_context_reset(en->imf_context); + ecore_imf_context_focus_in(en->imf_context); + _edje_entry_imf_cursor_info_set(en); + } +} + +static void +_edje_entry_focus_out_cb(void *data, Evas_Object *o __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__) +{ + Edje_Real_Part *rp; + Entry *en; + + rp = data; + if (!rp || !rp->entry_data) return; + + en = rp->entry_data; + if (!en || !en->imf_context) return; + + ecore_imf_context_reset(en->imf_context); + _edje_entry_imf_cursor_info_set(en); + ecore_imf_context_focus_out(en->imf_context); +} +#endif + +static void +_edje_focus_in_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +{ + Edje *ed = data; +#ifdef HAVE_ECORE_IMF + Edje_Real_Part *rp; + Entry *en; +#endif + + _edje_emit(ed, "focus,in", ""); +#ifdef HAVE_ECORE_IMF + rp = ed->focused_part; + if (!rp) return; + + en = rp->entry_data; + if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) || + (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_EDITABLE)) + return; + + if (!en->imf_context) return; + + ecore_imf_context_reset(en->imf_context); + ecore_imf_context_focus_in(en->imf_context); + _edje_entry_imf_cursor_info_set(en); +#endif +} + +static void +_edje_focus_out_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +{ + Edje *ed = data; +#ifdef HAVE_ECORE_IMF + Edje_Real_Part *rp = ed->focused_part; + Entry *en; +#endif + + _edje_emit(ed, "focus,out", ""); + +#ifdef HAVE_ECORE_IMF + if (!rp) return; + en = rp->entry_data; + if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) || + (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_EDITABLE)) + return; + + if (!en->imf_context) return; + + ecore_imf_context_reset(en->imf_context); + _edje_entry_imf_cursor_info_set(en); + ecore_imf_context_focus_out(en->imf_context); +#endif +} + +static void +_text_filter_text_prepend(Entry *en, Evas_Textblock_Cursor *c, const char *text) +{ + char *text2; + Edje_Text_Insert_Filter_Callback *cb; + Eina_List *l; + + text2 = strdup(text); + EINA_LIST_FOREACH(en->rp->edje->text_insert_filter_callbacks, l, cb) + { + if (!strcmp(cb->part, en->rp->part->name)) + { + cb->func(cb->data, en->rp->edje->obj, cb->part, EDJE_TEXT_FILTER_TEXT, &text2); + if (!text2) break; + } + } + if (text2) + { + evas_textblock_cursor_text_prepend(c, text2); + free(text2); + } +} + +static void +_text_filter_format_prepend(Entry *en, Evas_Textblock_Cursor *c, const char *text) +{ + char *text2; + Edje_Text_Insert_Filter_Callback *cb; + Eina_List *l; + + text2 = strdup(text); + EINA_LIST_FOREACH(en->rp->edje->text_insert_filter_callbacks, l, cb) + { + if (!strcmp(cb->part, en->rp->part->name)) + { + cb->func(cb->data, en->rp->edje->obj, cb->part, EDJE_TEXT_FILTER_FORMAT, &text2); + if (!text2) break; + } + } + if (text2) + { + evas_textblock_cursor_format_prepend(c, text2); + free(text2); + } +} + +static void +_text_filter_markup_prepend(Entry *en, Evas_Textblock_Cursor *c, const char *text) +{ + char *text2; + Edje_Text_Insert_Filter_Callback *cb; + Eina_List *l; + + text2 = strdup(text); + EINA_LIST_FOREACH(en->rp->edje->text_insert_filter_callbacks, l, cb) + { + if (!strcmp(cb->part, en->rp->part->name)) + { + cb->func(cb->data, en->rp->edje->obj, cb->part, EDJE_TEXT_FILTER_MARKUP, &text2); + if (!text2) break; + } + } + if (text2) + { + evas_object_textblock_text_markup_prepend(c, text2); + free(text2); + } +} + +static void +_curs_update_from_curs(Evas_Textblock_Cursor *c, Evas_Object *o __UNUSED__, Entry *en, Evas_Coord *cx, Evas_Coord *cy) +{ + Evas_Coord cw, ch; + Evas_Textblock_Cursor_Type cur_type; + if (c != en->cursor) return; + switch (en->rp->part->cursor_mode) + { + case EDJE_ENTRY_CURSOR_MODE_BEFORE: + cur_type = EVAS_TEXTBLOCK_CURSOR_BEFORE; + break; + case EDJE_ENTRY_CURSOR_MODE_UNDER: + /* no break for a resaon */ + default: + cur_type = EVAS_TEXTBLOCK_CURSOR_UNDER; + } + evas_textblock_cursor_geometry_get(c, cx, cy, &cw, &ch, NULL, cur_type); + *cx += (cw / 2); + *cy += (ch / 2); +} + +static void +_curs_back(Evas_Textblock_Cursor *c, Evas_Object *o __UNUSED__, + Entry *en __UNUSED__) +{ + evas_textblock_cursor_char_prev(c); +} + +static void +_curs_next(Evas_Textblock_Cursor *c, Evas_Object *o __UNUSED__, + Entry *en __UNUSED__) +{ + evas_textblock_cursor_char_next(c); +} + +static int +_curs_line_last_get(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o, Entry *en __UNUSED__) +{ + Evas_Textblock_Cursor *cc; + int ln; + + cc = evas_object_textblock_cursor_new(o); + evas_textblock_cursor_paragraph_last(cc); + ln = evas_textblock_cursor_line_geometry_get(cc, NULL, NULL, NULL, NULL); + evas_textblock_cursor_free(cc); + return ln; +} + +static void +_curs_lin_start(Evas_Textblock_Cursor *c, Evas_Object *o __UNUSED__, + Entry *en __UNUSED__) +{ + evas_textblock_cursor_line_char_first(c); +} + +static void +_curs_lin_end(Evas_Textblock_Cursor *c, Evas_Object *o __UNUSED__, + Entry *en __UNUSED__) +{ + evas_textblock_cursor_line_char_last(c); +} + +static void +_curs_start(Evas_Textblock_Cursor *c, Evas_Object *o __UNUSED__, + Entry *en __UNUSED__) +{ + evas_textblock_cursor_paragraph_first(c); +} + +static void +_curs_end(Evas_Textblock_Cursor *c, Evas_Object *o __UNUSED__, Entry *en __UNUSED__) +{ + evas_textblock_cursor_paragraph_last(c); +} + +static void +_curs_jump_line(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en, int ln) +{ + Evas_Coord cx, cy; + Evas_Coord lx, ly, lw, lh; + int last = _curs_line_last_get(c, o, en); + + if (ln < 0) ln = 0; + else + { + if (ln > last) ln = last; + } + + _curs_update_from_curs(c, o, en, &cx, &cy); + + if (!evas_object_textblock_line_number_geometry_get(o, ln, &lx, &ly, &lw, &lh)) + return; + if (evas_textblock_cursor_char_coord_set(c, cx, ly + (lh / 2))) + return; + evas_textblock_cursor_line_set(c, ln); + if (cx < (lx + (lw / 2))) + { + if (ln == last) _curs_end(c, o, en); + _curs_lin_start(c, o, en); + } + else + { + if (ln == last) + _curs_end(c, o, en); + else + _curs_lin_end(c, o, en); + } +} + +static void +_curs_jump_line_by(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en, int by) +{ + int ln; + + ln = evas_textblock_cursor_line_geometry_get(c, NULL, NULL, NULL, NULL) + by; + _curs_jump_line(c, o, en, ln); +} + +static void +_curs_up(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en) +{ + _curs_jump_line_by(c, o, en, -1); +} + +static void +_curs_down(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en) +{ + _curs_jump_line_by(c, o, en, 1); +} + +static void +_sel_start(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en) +{ + if (en->sel_start) return; + en->sel_start = evas_object_textblock_cursor_new(o); + evas_textblock_cursor_copy(c, en->sel_start); + en->sel_end = evas_object_textblock_cursor_new(o); + evas_textblock_cursor_copy(c, en->sel_end); + + en->have_selection = EINA_FALSE; + if (en->selection) + { + free(en->selection); + en->selection = NULL; + } +} + +static void +_sel_enable(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o __UNUSED__, Entry *en) +{ + if (en->have_selection) return; + en->have_selection = EINA_TRUE; + if (en->selection) + { + free(en->selection); + en->selection = NULL; + } + _edje_emit(en->rp->edje, "selection,start", en->rp->part->name); +} + +static void +_sel_extend(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en) +{ + if (!en->sel_end) return; + _sel_enable(c, o, en); + if (!evas_textblock_cursor_compare(c, en->sel_end)) return; + evas_textblock_cursor_copy(c, en->sel_end); + if (en->selection) + { + free(en->selection); + en->selection = NULL; + } + _edje_emit(en->rp->edje, "selection,changed", en->rp->part->name); + _edje_entry_imf_context_reset(en); +} + +static void +_sel_preextend(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en) +{ + if (!en->sel_end) return; + _sel_enable(c, o, en); + if (!evas_textblock_cursor_compare(c, en->sel_start)) return; + evas_textblock_cursor_copy(c, en->sel_start); + if (en->selection) + { + free(en->selection); + en->selection = NULL; + } + _edje_emit(en->rp->edje, "selection,changed", en->rp->part->name); + _edje_entry_imf_context_reset(en); +} + +static void +_sel_clear(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o __UNUSED__, Entry *en) +{ + en->had_sel = EINA_FALSE; + if (en->sel_start) + { + evas_textblock_cursor_free(en->sel_start); + evas_textblock_cursor_free(en->sel_end); + en->sel_start = NULL; + en->sel_end = NULL; + } + if (en->selection) + { + free(en->selection); + en->selection = NULL; + } + while (en->sel) + { + Sel *sel; + + sel = en->sel->data; + if (sel->obj_bg) evas_object_del(sel->obj_bg); + if (sel->obj_fg) evas_object_del(sel->obj_fg); + free(sel); + en->sel = eina_list_remove_list(en->sel, en->sel); + } + if (en->have_selection) + { + en->have_selection = EINA_FALSE; + _edje_emit(en->rp->edje, "selection,cleared", en->rp->part->name); + } +} + +static void +_sel_update(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o, Entry *en) +{ + Eina_List *range = NULL, *l; + Sel *sel; + Evas_Coord x, y, w, h; + Evas_Object *smart, *clip; + + smart = evas_object_smart_parent_get(o); + clip = evas_object_clip_get(o); + if (en->sel_start) + range = evas_textblock_cursor_range_geometry_get(en->sel_start, en->sel_end); + else + return; + if (eina_list_count(range) != eina_list_count(en->sel)) + { + while (en->sel) + { + sel = en->sel->data; + if (sel->obj_bg) evas_object_del(sel->obj_bg); + if (sel->obj_fg) evas_object_del(sel->obj_fg); + free(sel); + en->sel = eina_list_remove_list(en->sel, en->sel); + } + if (en->have_selection) + { + for (l = range; l; l = eina_list_next(l)) + { + Evas_Object *ob; + + sel = calloc(1, sizeof(Sel)); + en->sel = eina_list_append(en->sel, sel); + ob = edje_object_add(en->rp->edje->base.evas); + edje_object_file_set(ob, en->rp->edje->path, en->rp->part->source); + evas_object_smart_member_add(ob, smart); + evas_object_stack_below(ob, o); + evas_object_clip_set(ob, clip); + evas_object_pass_events_set(ob, EINA_TRUE); + evas_object_show(ob); + sel->obj_bg = ob; + _edje_subobj_register(en->rp->edje, sel->obj_bg); + + ob = edje_object_add(en->rp->edje->base.evas); + edje_object_file_set(ob, en->rp->edje->path, en->rp->part->source2); + evas_object_smart_member_add(ob, smart); + evas_object_stack_above(ob, o); + evas_object_clip_set(ob, clip); + evas_object_pass_events_set(ob, EINA_TRUE); + evas_object_show(ob); + sel->obj_fg = ob; + _edje_subobj_register(en->rp->edje, sel->obj_fg); + } + } + } + x = y = w = h = -1; + evas_object_geometry_get(o, &x, &y, &w, &h); + if (en->have_selection) + { + EINA_LIST_FOREACH(en->sel, l, sel) + { + Evas_Textblock_Rectangle *r; + + r = range->data; + if (sel->obj_bg) + { + evas_object_move(sel->obj_bg, x + r->x, y + r->y); + evas_object_resize(sel->obj_bg, r->w, r->h); + } + if (sel->obj_fg) + { + evas_object_move(sel->obj_fg, x + r->x, y + r->y); + evas_object_resize(sel->obj_fg, r->w, r->h); + } + *(&(sel->rect)) = *r; + range = eina_list_remove_list(range, range); + free(r); + } + } + else + { + while (range) + { + free(range->data); + range = eina_list_remove_list(range, range); + } + } +} + +static void +_edje_anchor_mouse_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) +{ + Anchor *an = data; + Evas_Event_Mouse_Down *ev = event_info; + Edje_Real_Part *rp = an->en->rp; + char *buf, *n; + size_t len; + int ignored; + Entry *en; + + en = rp->entry_data; + if ((rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT) && + (en->select_allow)) + return; + ignored = rp->part->ignore_flags & ev->event_flags; + if ((!ev->event_flags) || (!ignored)) + { + n = an->name; + if (!n) n = ""; + len = 200 + strlen(n); + buf = alloca(len); + if (ev->flags & EVAS_BUTTON_TRIPLE_CLICK) + snprintf(buf, len, "anchor,mouse,down,%i,%s,triple", ev->button, n); + else if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK) + snprintf(buf, len, "anchor,mouse,down,%i,%s,double", ev->button, n); + else + snprintf(buf, len, "anchor,mouse,down,%i,%s", ev->button, n); + _edje_emit(rp->edje, buf, rp->part->name); + } +} + +static void +_edje_anchor_mouse_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) +{ + Anchor *an = data; + Evas_Event_Mouse_Up *ev = event_info; + Edje_Real_Part *rp = an->en->rp; + char *buf, *n; + size_t len; + int ignored; + Entry *en; + + en = rp->entry_data; + ignored = rp->part->ignore_flags & ev->event_flags; + if ((rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT) && + (en->select_allow)) + return; + n = an->name; + if (!n) n = ""; + len = 200 + strlen(n); + buf = alloca(len); + if ((!ev->event_flags) || (!ignored)) + { + snprintf(buf, len, "anchor,mouse,up,%i,%s", ev->button, n); + _edje_emit(rp->edje, buf, rp->part->name); + } + if ((rp->still_in) && (rp->clicked_button == ev->button) && (!ignored)) + { + snprintf(buf, len, "anchor,mouse,clicked,%i,%s", ev->button, n); + _edje_emit(rp->edje, buf, rp->part->name); + } +} + +static void +_edje_anchor_mouse_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) +{ + Anchor *an = data; + Evas_Event_Mouse_Move *ev = event_info; + Edje_Real_Part *rp = an->en->rp; + char *buf, *n; + size_t len; + int ignored; + Entry *en; + + en = rp->entry_data; + if ((rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT) && + (en->select_allow)) + return; + ignored = rp->part->ignore_flags & ev->event_flags; + if ((!ev->event_flags) || (!ignored)) + { + n = an->name; + if (!n) n = ""; + len = 200 + strlen(n); + buf = alloca(len); + snprintf(buf, len, "anchor,mouse,move,%s", n); + _edje_emit(rp->edje, buf, rp->part->name); + } +} + +static void +_edje_anchor_mouse_in_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) +{ + Anchor *an = data; + Evas_Event_Mouse_In *ev = event_info; + Edje_Real_Part *rp = an->en->rp; + char *buf, *n; + size_t len; + int ignored; + + ignored = rp->part->ignore_flags & ev->event_flags; + if ((!ev->event_flags) || (!ignored)) + { + n = an->name; + if (!n) n = ""; + len = 200 + strlen(n); + buf = alloca(len); + snprintf(buf, len, "anchor,mouse,in,%s", n); + _edje_emit(rp->edje, buf, rp->part->name); + } +} + +static void +_edje_anchor_mouse_out_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) +{ + Anchor *an = data; + Evas_Event_Mouse_Out *ev = event_info; + Edje_Real_Part *rp = an->en->rp; + char *buf, *n; + size_t len; + int ignored; + + ignored = rp->part->ignore_flags & ev->event_flags; + if ((!ev->event_flags) || (!ignored)) + { + n = an->name; + if (!n) n = ""; + len = 200 + strlen(n); + buf = alloca(len); + snprintf(buf, len, "anchor,mouse,out,%s", n); + _edje_emit(rp->edje, buf, rp->part->name); + } +} + +static void +_anchors_update(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o, Entry *en) +{ + Eina_List *l, *ll, *range = NULL; + Evas_Coord x, y, w, h; + Evas_Object *smart, *clip; + Sel *sel; + Anchor *an; + + smart = evas_object_smart_parent_get(o); + clip = evas_object_clip_get(o); + x = y = w = h = -1; + evas_object_geometry_get(o, &x, &y, &w, &h); + EINA_LIST_FOREACH(en->anchors, l, an) + { + // for item anchors + if (an->item) + { + Evas_Object *ob; + + if (!an->sel) + { + while (an->sel) + { + sel = an->sel->data; + if (sel->obj_bg) evas_object_del(sel->obj_bg); + if (sel->obj_fg) evas_object_del(sel->obj_fg); + if (sel->obj) evas_object_del(sel->obj); + free(sel); + an->sel = eina_list_remove_list(an->sel, an->sel); + } + + sel = calloc(1, sizeof(Sel)); + an->sel = eina_list_append(an->sel, sel); + + if (en->rp->edje->item_provider.func) + { + ob = en->rp->edje->item_provider.func + (en->rp->edje->item_provider.data, smart, + en->rp->part->name, an->name); + evas_object_smart_member_add(ob, smart); + evas_object_stack_above(ob, o); + evas_object_clip_set(ob, clip); + evas_object_pass_events_set(ob, EINA_TRUE); + evas_object_show(ob); + sel->obj = ob; + } + } + } + // for link anchors + else + { + range = + evas_textblock_cursor_range_geometry_get(an->start, an->end); + if (eina_list_count(range) != eina_list_count(an->sel)) + { + while (an->sel) + { + sel = an->sel->data; + if (sel->obj_bg) evas_object_del(sel->obj_bg); + if (sel->obj_fg) evas_object_del(sel->obj_fg); + if (sel->obj) evas_object_del(sel->obj); + free(sel); + an->sel = eina_list_remove_list(an->sel, an->sel); + } + for (ll = range; ll; ll = eina_list_next(ll)) + { + Evas_Object *ob; + + sel = calloc(1, sizeof(Sel)); + an->sel = eina_list_append(an->sel, sel); + ob = edje_object_add(en->rp->edje->base.evas); + edje_object_file_set(ob, en->rp->edje->path, en->rp->part->source5); + evas_object_smart_member_add(ob, smart); + evas_object_stack_below(ob, o); + evas_object_clip_set(ob, clip); + evas_object_pass_events_set(ob, EINA_TRUE); + evas_object_show(ob); + sel->obj_bg = ob; + _edje_subobj_register(en->rp->edje, sel->obj_bg); + + ob = edje_object_add(en->rp->edje->base.evas); + edje_object_file_set(ob, en->rp->edje->path, en->rp->part->source6); + evas_object_smart_member_add(ob, smart); + evas_object_stack_above(ob, o); + evas_object_clip_set(ob, clip); + evas_object_pass_events_set(ob, EINA_TRUE); + evas_object_show(ob); + sel->obj_fg = ob; + _edje_subobj_register(en->rp->edje, sel->obj_fg); + + ob = evas_object_rectangle_add(en->rp->edje->base.evas); + evas_object_color_set(ob, 0, 0, 0, 0); + evas_object_smart_member_add(ob, smart); + evas_object_stack_above(ob, o); + evas_object_clip_set(ob, clip); + evas_object_repeat_events_set(ob, EINA_TRUE); + evas_object_event_callback_add(ob, EVAS_CALLBACK_MOUSE_DOWN, _edje_anchor_mouse_down_cb, an); + evas_object_event_callback_add(ob, EVAS_CALLBACK_MOUSE_UP, _edje_anchor_mouse_up_cb, an); + evas_object_event_callback_add(ob, EVAS_CALLBACK_MOUSE_MOVE, _edje_anchor_mouse_move_cb, an); + evas_object_event_callback_add(ob, EVAS_CALLBACK_MOUSE_IN, _edje_anchor_mouse_in_cb, an); + evas_object_event_callback_add(ob, EVAS_CALLBACK_MOUSE_OUT, _edje_anchor_mouse_out_cb, an); + evas_object_show(ob); + sel->obj = ob; + } + } + } + EINA_LIST_FOREACH(an->sel, ll, sel) + { + if (an->item) + { + Evas_Coord cx, cy, cw, ch; + + if (!evas_textblock_cursor_format_item_geometry_get + (an->start, &cx, &cy, &cw, &ch)) + continue; + evas_object_move(sel->obj, x + cx, y + cy); + evas_object_resize(sel->obj, cw, ch); + } + else + { + Evas_Textblock_Rectangle *r; + + r = range->data; + *(&(sel->rect)) = *r; + if (sel->obj_bg) + { + evas_object_move(sel->obj_bg, x + r->x, y + r->y); + evas_object_resize(sel->obj_bg, r->w, r->h); + } + if (sel->obj_fg) + { + evas_object_move(sel->obj_fg, x + r->x, y + r->y); + evas_object_resize(sel->obj_fg, r->w, r->h); + } + if (sel->obj) + { + evas_object_move(sel->obj, x + r->x, y + r->y); + evas_object_resize(sel->obj, r->w, r->h); + } + range = eina_list_remove_list(range, range); + free(r); + } + } + } +} + +static void +_anchors_clear(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o __UNUSED__, Entry *en) +{ + while (en->anchorlist) + { + free(en->anchorlist->data); + en->anchorlist = eina_list_remove_list(en->anchorlist, en->anchorlist); + } + while (en->itemlist) + { + free(en->itemlist->data); + en->itemlist = eina_list_remove_list(en->itemlist, en->itemlist); + } + while (en->anchors) + { + Anchor *an = en->anchors->data; + + evas_textblock_cursor_free(an->start); + evas_textblock_cursor_free(an->end); + while (an->sel) + { + Sel *sel = an->sel->data; + if (sel->obj_bg) evas_object_del(sel->obj_bg); + if (sel->obj_fg) evas_object_del(sel->obj_fg); + if (sel->obj) evas_object_del(sel->obj); + free(sel); + an->sel = eina_list_remove_list(an->sel, an->sel); + } + free(an->name); + free(an); + en->anchors = eina_list_remove_list(en->anchors, en->anchors); + } +} + +static void +_anchors_get(Evas_Textblock_Cursor *c, Evas_Object *o, Entry *en) +{ + const Eina_List *anchors_a, *anchors_item; + Anchor *an = NULL; + _anchors_clear(c, o, en); + + anchors_a = evas_textblock_node_format_list_get(o, "a"); + anchors_item = evas_textblock_node_format_list_get(o, "item"); + + if (anchors_a) + { + const Evas_Object_Textblock_Node_Format *node; + const Eina_List *itr; + EINA_LIST_FOREACH(anchors_a, itr, node) + { + const char *s = evas_textblock_node_format_text_get(node); + char *p; + an = calloc(1, sizeof(Anchor)); + if (!an) + break; + + an->en = en; + p = strstr(s, "href="); + if (p) + { + an->name = strdup(p + 5); + } + en->anchors = eina_list_append(en->anchors, an); + an->start = evas_object_textblock_cursor_new(o); + an->end = evas_object_textblock_cursor_new(o); + evas_textblock_cursor_at_format_set(an->start, node); + evas_textblock_cursor_copy(an->start, an->end); + + /* Close the anchor, if the anchor was without text, + * free it as well */ + node = evas_textblock_node_format_next_get(node); + for (; node; node = evas_textblock_node_format_next_get(node)) + { + s = evas_textblock_node_format_text_get(node); + if ((!strcmp(s, "- a")) || (!strcmp(s, "-a"))) + break; + } + + if (node) + { + evas_textblock_cursor_at_format_set(an->end, node); + } + else if (!evas_textblock_cursor_compare(an->start, an->end)) + { + if (an->name) free(an->name); + evas_textblock_cursor_free(an->start); + evas_textblock_cursor_free(an->end); + en->anchors = eina_list_remove(en->anchors, an); + free(an); + } + an = NULL; + } + } + + if (anchors_item) + { + const Evas_Object_Textblock_Node_Format *node; + const Eina_List *itr; + EINA_LIST_FOREACH(anchors_item, itr, node) + { + const char *s = evas_textblock_node_format_text_get(node); + char *p; + an = calloc(1, sizeof(Anchor)); + if (!an) + break; + + an->en = en; + an->item = 1; + p = strstr(s, "href="); + if (p) + { + an->name = strdup(p + 5); + } + en->anchors = eina_list_append(en->anchors, an); + an->start = evas_object_textblock_cursor_new(o); + an->end = evas_object_textblock_cursor_new(o); + evas_textblock_cursor_at_format_set(an->start, node); + evas_textblock_cursor_copy(an->start, an->end); + /* Although needed in textblock, don't bother with finding the end + * here cause it doesn't really matter. */ + } + } +} + +static void +_free_entry_change_info(void *_info) +{ + Edje_Entry_Change_Info *info = (Edje_Entry_Change_Info *) _info; + if (info->insert) + { + eina_stringshare_del(info->change.insert.content); + } + else + { + eina_stringshare_del(info->change.del.content); + } + free(info); +} + +static void +_range_del_emit(Edje *ed, Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o __UNUSED__, Entry *en) +{ + size_t start, end; + char *tmp; + Edje_Entry_Change_Info *info = calloc(1, sizeof(*info)); + info->insert = EINA_FALSE; + start = evas_textblock_cursor_pos_get(en->sel_start); + end = evas_textblock_cursor_pos_get(en->sel_end); + info->change.del.start = start; + info->change.del.end = end; + + tmp = evas_textblock_cursor_range_text_get(en->sel_start, en->sel_end, EVAS_TEXTBLOCK_TEXT_MARKUP); + info->change.del.content = eina_stringshare_add(tmp); + if (tmp) free(tmp); + evas_textblock_cursor_range_delete(en->sel_start, en->sel_end); + _edje_emit(ed, "entry,changed", en->rp->part->name); + _edje_emit_full(ed, "entry,changed,user", en->rp->part->name, info, + _free_entry_change_info); +} + +static void +_range_del(Evas_Textblock_Cursor *c __UNUSED__, Evas_Object *o __UNUSED__, Entry *en) +{ + evas_textblock_cursor_range_delete(en->sel_start, en->sel_end); +} + +static void +_delete_emit(Edje *ed, Evas_Textblock_Cursor *c, Entry *en, size_t pos, + Eina_Bool backspace) +{ + if (!evas_textblock_cursor_char_next(c)) + { + return; + } + evas_textblock_cursor_char_prev(c); + + Edje_Entry_Change_Info *info = calloc(1, sizeof(*info)); + char *tmp = evas_textblock_cursor_content_get(c); + + info->insert = EINA_FALSE; + if (backspace) + { + info->change.del.start = pos - 1; + info->change.del.end = pos; + } + else + { + info->change.del.start = pos + 1; + info->change.del.end = pos; + } + + info->change.del.content = eina_stringshare_add(tmp); + if (tmp) free(tmp); + + evas_textblock_cursor_char_delete(c); + _edje_emit(ed, "entry,changed", en->rp->part->name); + _edje_emit_full(ed, "entry,changed,user", en->rp->part->name, + info, _free_entry_change_info); +} + +static void +_edje_entry_hide_visible_password(Edje_Real_Part *rp) +{ + const Evas_Object_Textblock_Node_Format *node; + node = evas_textblock_node_format_first_get(rp->object); + for (; node; node = evas_textblock_node_format_next_get(node)) + { + const char *text = evas_textblock_node_format_text_get(node); + if (text) + { + if (!strcmp(text, "+ password=off")) + { + evas_textblock_node_format_remove_pair(rp->object, + (Evas_Object_Textblock_Node_Format *) node); + break; + } + } + } + _edje_entry_real_part_configure(rp); + _edje_emit(rp->edje, "entry,changed", rp->part->name); +} + +static Eina_Bool +_password_timer_cb(void *data) +{ + Entry *en = (Entry *)data; + _edje_entry_hide_visible_password(en->rp); + en->pw_timer = NULL; + return ECORE_CALLBACK_CANCEL; +} + +static void +_edje_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) +{ + Edje *ed = data; + Evas_Event_Key_Down *ev = event_info; + Edje_Real_Part *rp = ed->focused_part; + Entry *en; + Eina_Bool control, alt, shift; + Eina_Bool multiline; + Eina_Bool cursor_changed; + int old_cur_pos; + if (!rp) return; + en = rp->entry_data; + if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) || + (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_EDITABLE)) + return; + if (!ev->key) return; + +#ifdef HAVE_ECORE_IMF + if (en->imf_context) + { + Ecore_IMF_Event_Key_Down ecore_ev; + ecore_imf_evas_event_key_down_wrap(ev, &ecore_ev); + if (ecore_imf_context_filter_event(en->imf_context, + ECORE_IMF_EVENT_KEY_DOWN, + (Ecore_IMF_Event *)&ecore_ev)) + return; + } +#endif + + old_cur_pos = evas_textblock_cursor_pos_get(en->cursor); + + control = evas_key_modifier_is_set(ev->modifiers, "Control"); + alt = evas_key_modifier_is_set(ev->modifiers, "Alt"); + shift = evas_key_modifier_is_set(ev->modifiers, "Shift"); + multiline = rp->part->multiline; + cursor_changed = EINA_FALSE; + if (!strcmp(ev->key, "Escape")) + { + // dead keys here. Escape for now (should emit these) + _edje_emit(ed, "entry,key,escape", rp->part->name); + ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; + } + else if (!strcmp(ev->key, "Up") || !strcmp(ev->key, "KP_Up")) + { + if (multiline) + { + if (en->select_allow) + { + if (shift) _sel_start(en->cursor, rp->object, en); + else _sel_clear(en->cursor, rp->object, en); + } + _curs_up(en->cursor, rp->object, en); + if (en->select_allow) + { + if (shift) _sel_extend(en->cursor, rp->object, en); + } + ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; + } + _sel_clear(en->cursor, rp->object, en); + _edje_emit(ed, "entry,key,up", rp->part->name); + } + else if (!strcmp(ev->key, "Down") || !strcmp(ev->key, "KP_Down")) + { + if (multiline) + { + if (en->select_allow) + { + if (shift) _sel_start(en->cursor, rp->object, en); + else _sel_clear(en->cursor, rp->object, en); + } + _curs_down(en->cursor, rp->object, en); + if (en->select_allow) + { + if (shift) _sel_extend(en->cursor, rp->object, en); + } + ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; + } + _sel_clear(en->cursor, rp->object, en); + _edje_emit(ed, "entry,key,down", rp->part->name); + } + else if (!strcmp(ev->key, "Left") || !strcmp(ev->key, "KP_Left")) + { + if (en->select_allow) + { + if (shift) _sel_start(en->cursor, rp->object, en); + else _sel_clear(en->cursor, rp->object, en); + } + _curs_back(en->cursor, rp->object, en); + if (en->select_allow) + { + if (shift) _sel_extend(en->cursor, rp->object, en); + } + _sel_clear(en->cursor, rp->object, en); + _edje_emit(ed, "entry,key,left", rp->part->name); + ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; + } + else if (!strcmp(ev->key, "Right") || !strcmp(ev->key, "KP_Right")) + { + if (en->select_allow) + { + if (shift) _sel_start(en->cursor, rp->object, en); + else _sel_clear(en->cursor, rp->object, en); + } + _curs_next(en->cursor, rp->object, en); + if (en->select_allow) + { + if (shift) _sel_extend(en->cursor, rp->object, en); + } + _sel_clear(en->cursor, rp->object, en); + _edje_emit(ed, "entry,key,right", rp->part->name); + ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; + } + else if (!strcmp(ev->key, "BackSpace")) + { + if (control) + { + // del to start of previous word + } + else if ((alt) && (shift)) + { + // undo last action + } + else + { + if (en->have_selection) + { + _range_del_emit(ed, en->cursor, rp->object, en); + } + else + { + if (evas_textblock_cursor_char_prev(en->cursor)) + { + _delete_emit(ed, en->cursor, en, old_cur_pos, EINA_TRUE); + } + } + } + _sel_clear(en->cursor, rp->object, en); + _anchors_get(en->cursor, rp->object, en); + _edje_emit(ed, "entry,key,backspace", rp->part->name); + ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; + } + else if (!strcmp(ev->key, "Delete") || !strcmp(ev->key, "KP_Delete")) + { + if (control) + { + // del to end of next word + } + else if (shift) + { + // cut + } + else + { + if (en->have_selection) + { + _range_del_emit(ed, en->cursor, rp->object, en); + } + else + { + _delete_emit(ed, en->cursor, en, old_cur_pos, EINA_FALSE); + } + } + _sel_clear(en->cursor, rp->object, en); + _anchors_get(en->cursor, rp->object, en); + _edje_emit(ed, "entry,key,delete", rp->part->name); + ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; + } + else if (!strcmp(ev->key, "Home") || !strcmp(ev->key, "KP_Home")) + { + if (en->select_allow) + { + if (shift) _sel_start(en->cursor, rp->object, en); + else _sel_clear(en->cursor, rp->object, en); + } + if ((control) && (multiline)) + _curs_start(en->cursor, rp->object, en); + else + _curs_lin_start(en->cursor, rp->object, en); + if (en->select_allow) + { + if (shift) _sel_extend(en->cursor, rp->object, en); + } + _edje_emit(ed, "entry,key,home", rp->part->name); + ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; + } + else if (!strcmp(ev->key, "End") || !strcmp(ev->key, "KP_End")) + { + if (en->select_allow) + { + if (shift) _sel_start(en->cursor, rp->object, en); + else _sel_clear(en->cursor, rp->object, en); + } + if ((control) && (multiline)) + _curs_end(en->cursor, rp->object, en); + else + _curs_lin_end(en->cursor, rp->object, en); + if (en->select_allow) + { + if (shift) _sel_extend(en->cursor, rp->object, en); + } + _edje_emit(ed, "entry,key,end", rp->part->name); + ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; + } + else if (!strcmp(ev->key, "Shift_L") || !strcmp(ev->key, "Shift_R")) + { + return; + } + else if ((control) && (!strcmp(ev->key, "v"))) + { + _edje_emit(ed, "entry,paste,request", rp->part->name); + _edje_emit(ed, "entry,paste,request,3", rp->part->name); + ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; + } + else if ((control) && (!strcmp(ev->key, "a"))) + { + _edje_emit(ed, "entry,selection,all,request", rp->part->name); + ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; + } + else if ((control) && (!strcmp(ev->key, "A"))) + { + _edje_emit(ed, "entry,selection,none,request", rp->part->name); + ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; + } + else if ((control) && ((!strcmp(ev->key, "c") || (!strcmp(ev->key, "Insert"))))) + { + // FIXME: copy - save selection + _edje_emit(ed, "entry,copy,notify", rp->part->name); + ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; + } + else if ((control) && ((!strcmp(ev->key, "x") || (!strcmp(ev->key, "m"))))) + { + // FIXME: cut - save selection, delete seletion + _edje_emit(ed, "entry,cut,notify", rp->part->name); + ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; + } + else if ((control) && (!strcmp(ev->key, "z"))) + { + if (shift) + { + // redo + _edje_emit(ed, "entry,redo,request", rp->part->name); + } + else + { + // undo + _edje_emit(ed, "entry,undo,request", rp->part->name); + } + ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; + } + else if ((control) && (!strcmp(ev->key, "y"))) + { + // redo + _edje_emit(ed, "entry,redo,request", rp->part->name); + ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; + } + else if ((control) && (!strcmp(ev->key, "w"))) + { + _sel_clear(en->cursor, rp->object, en); + // select current word + ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; + } + else if (!strcmp(ev->key, "Tab")) + { + if (multiline) + { + if (shift) + { + // remove a tab + } + else + { + Edje_Entry_Change_Info *info = calloc(1, sizeof(*info)); + info->insert = EINA_TRUE; + info->change.insert.plain_length = 1; + + if (en->have_selection) + { + _range_del_emit(ed, en->cursor, rp->object, en); + info->merge = EINA_TRUE; + } + _sel_clear(en->cursor, rp->object, en); + info->change.insert.pos = + evas_textblock_cursor_pos_get(en->cursor); + info->change.insert.content = eina_stringshare_add("<\t>"); + //yy +// evas_textblock_cursor_format_prepend(en->cursor, "\t"); + _text_filter_format_prepend(en, en->cursor, "\t"); + _anchors_get(en->cursor, rp->object, en); + _edje_emit(ed, "entry,changed", rp->part->name); + _edje_emit_full(ed, "entry,changed,user", rp->part->name, + info, _free_entry_change_info); + } + ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; + } + _edje_emit(ed, "entry,key,tab", rp->part->name); + } + else if ((!strcmp(ev->key, "ISO_Left_Tab")) && (multiline)) + { + // remove a tab + ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; + } + else if (!strcmp(ev->key, "Prior") || !strcmp(ev->key, "KP_Prior")) + { + if (en->select_allow) + { + if (shift) _sel_start(en->cursor, rp->object, en); + else _sel_clear(en->cursor, rp->object, en); + } + _curs_jump_line_by(en->cursor, rp->object, en, -10); + if (en->select_allow) + { + if (shift) _sel_extend(en->cursor, rp->object, en); + } + _sel_clear(en->cursor, rp->object, en); + _edje_emit(ed, "entry,key,pgup", rp->part->name); + ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; + } + else if (!strcmp(ev->key, "Next") || !strcmp(ev->key, "KP_Next")) + { + if (en->select_allow) + { + if (shift) _sel_start(en->cursor, rp->object, en); + else _sel_clear(en->cursor, rp->object, en); + } + _curs_jump_line_by(en->cursor, rp->object, en, 10); + if (en->select_allow) + { + if (shift) _sel_extend(en->cursor, rp->object, en); + } + _sel_clear(en->cursor, rp->object, en); + _edje_emit(ed, "entry,key,pgdn", rp->part->name); + ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; + } + else if ((!strcmp(ev->key, "Return")) || (!strcmp(ev->key, "KP_Enter"))) + { + if (multiline) + { + Edje_Entry_Change_Info *info = calloc(1, sizeof(*info)); + info->insert = EINA_TRUE; + info->change.insert.plain_length = 1; + if (en->have_selection) + { + _range_del_emit(ed, en->cursor, rp->object, en); + info->merge = EINA_TRUE; + } + _sel_clear(en->cursor, rp->object, en); + + info->change.insert.pos = + evas_textblock_cursor_pos_get(en->cursor); + if (shift) + { + //yy +// evas_textblock_cursor_format_prepend(en->cursor, "\n"); + _text_filter_format_prepend(en, en->cursor, "\n"); + info->change.insert.content = eina_stringshare_add("<\n>"); + } + else + { + //yy +// evas_textblock_cursor_format_prepend(en->cursor, "ps"); + _text_filter_format_prepend(en, en->cursor, "ps"); + info->change.insert.content = eina_stringshare_add(""); + } + _anchors_get(en->cursor, rp->object, en); + _edje_emit(ed, "entry,changed", rp->part->name); + _edje_emit_full(ed, "entry,changed,user", rp->part->name, + info, _free_entry_change_info); + _edje_emit(ed, "cursor,changed", rp->part->name); + cursor_changed = EINA_TRUE; + ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; + } + _edje_emit(ed, "entry,key,enter", rp->part->name); + } + else + { + if (ev->string) + { + Edje_Entry_Change_Info *info = calloc(1, sizeof(*info)); + info->insert = EINA_TRUE; + info->change.insert.plain_length = 1; + info->change.insert.content = eina_stringshare_add(ev->string); + + if (en->have_selection) + { + _range_del_emit(ed, en->cursor, rp->object, en); + info->merge = EINA_TRUE; + } + _sel_clear(en->cursor, rp->object, en); + + info->change.insert.pos = + evas_textblock_cursor_pos_get(en->cursor); + // if PASSWORD_SHOW_LAST mode, appending text with password=off tag + if ((rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD) && + _edje_password_show_last) + { + _edje_entry_hide_visible_password(en->rp); + _text_filter_format_prepend(en, en->cursor, "+ password=off"); + _text_filter_text_prepend(en, en->cursor, ev->string); + _text_filter_format_prepend(en, en->cursor, "- password"); + if (en->pw_timer) + { + ecore_timer_del(en->pw_timer); + en->pw_timer = NULL; + } + en->pw_timer = ecore_timer_add(_edje_password_show_last_timeout, + _password_timer_cb, en); + } + else + _text_filter_text_prepend(en, en->cursor, ev->string); + _anchors_get(en->cursor, rp->object, en); + _edje_emit(ed, "entry,changed", rp->part->name); + _edje_emit_full(ed, "entry,changed,user", rp->part->name, + info, _free_entry_change_info); + _edje_emit(ed, "cursor,changed", rp->part->name); + cursor_changed = EINA_TRUE; + ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; + } + } + if (!cursor_changed && (old_cur_pos != evas_textblock_cursor_pos_get(en->cursor))) + _edje_emit(ed, "cursor,changed", rp->part->name); + + _edje_entry_imf_context_reset(en); + _edje_entry_imf_cursor_info_set(en); + _edje_entry_real_part_configure(rp); +} + +static void +_edje_key_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) +{ + Edje *ed = data; + Edje_Real_Part *rp = ed->focused_part; + Entry *en; + + if (!rp) return; + en = rp->entry_data; + if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) || + (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_EDITABLE)) + return; + +#ifdef HAVE_ECORE_IMF + if (en->imf_context) + { + Evas_Event_Key_Up *ev = event_info; + Ecore_IMF_Event_Key_Up ecore_ev; + + ecore_imf_evas_event_key_up_wrap(ev, &ecore_ev); + if (ecore_imf_context_filter_event(en->imf_context, + ECORE_IMF_EVENT_KEY_UP, + (Ecore_IMF_Event *)&ecore_ev)) + return; + } +#else + (void) event_info; +#endif +} + +static void +_edje_part_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +{ + Edje_Real_Part *rp = data; + Entry *en; + if (!rp) return; + en = rp->entry_data; + if (!en) return; + _edje_entry_imf_cursor_info_set(en); +} + +static void +_edje_part_mouse_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) +{ + Evas_Coord cx, cy; + Edje_Real_Part *rp = data; + Evas_Event_Mouse_Down *ev = event_info; + Entry *en; + Evas_Coord x, y, w, h; + // Eina_Bool multiline; + Evas_Textblock_Cursor *tc; + Eina_Bool dosel = EINA_FALSE; + if (!rp) return; + if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return; + en = rp->entry_data; + if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) || + (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE)) + return; + if ((ev->button != 1) && (ev->button != 2)) return; + +#ifdef HAVE_ECORE_IMF + if (en->imf_context) + { + Ecore_IMF_Event_Mouse_Down ecore_ev; + ecore_imf_evas_event_mouse_down_wrap(ev, &ecore_ev); + if (ecore_imf_context_filter_event(en->imf_context, + ECORE_IMF_EVENT_MOUSE_DOWN, + (Ecore_IMF_Event *)&ecore_ev)) + return; + } +#endif + + en->select_mod_start = EINA_FALSE; + en->select_mod_end = EINA_FALSE; + if (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_DEFAULT) + dosel = EINA_TRUE; + else if (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT) + { + if (en->select_allow) dosel = EINA_TRUE; + } + if (ev->button == 2) dosel = EINA_FALSE; + if (dosel) + { + // double click -> select word + // triple click -> select line + } + tc = evas_object_textblock_cursor_new(rp->object); + evas_textblock_cursor_copy(en->cursor, tc); + // multiline = rp->part->multiline; + evas_object_geometry_get(rp->object, &x, &y, &w, &h); + cx = ev->canvas.x - x; + cy = ev->canvas.y - y; + if (!evas_textblock_cursor_char_coord_set(en->cursor, cx, cy)) + { + Evas_Coord lx, ly, lw, lh; + int line; + + line = evas_textblock_cursor_line_coord_set(en->cursor, cy); + if (line == -1) + { + if (rp->part->multiline) + _curs_end(en->cursor, rp->object, en); + else + { + evas_textblock_cursor_paragraph_first(en->cursor); + evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh); + if (!evas_textblock_cursor_char_coord_set(en->cursor, cx, ly + (lh / 2))) + _curs_end(en->cursor, rp->object, en); + } + } + else + { + int lnum; + + lnum = evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh); + if (lnum < 0) + { + _curs_lin_start(en->cursor, rp->object, en); + } + else + { + if (cx <= lx) + _curs_lin_start(en->cursor, rp->object, en); + else + _curs_lin_end(en->cursor, rp->object, en); + } + } + } + if (dosel) + { + if ((en->have_selection) && + (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT)) + { + Eina_List *first, *last; + FLOAT_T sc; + + first = en->sel; + last = eina_list_last(en->sel); + if (first && last) + { + Evas_Textblock_Rectangle *r1, *r2; + Evas_Coord d, d1, d2; + + r1 = first->data; + r2 = last->data; + d = r1->x - cx; + d1 = d * d; + d = (r1->y + (r1->h / 2)) - cy; + d1 += d * d; + d = r2->x + r2->w - 1 - cx; + d2 = d * d; + d = (r2->y + (r2->h / 2)) - cy; + d2 += d * d; + sc = rp->edje->scale; + if (sc == ZERO) sc = _edje_scale; + d = (Evas_Coord)MUL(FROM_INT(20), sc); // FIXME: maxing number! + d = d * d; + if (d1 < d2) + { + if (d1 <= d) + { + en->select_mod_start = EINA_TRUE; + en->selecting = EINA_TRUE; + } + } + else + { + if (d2 <= d) + { + en->select_mod_end = EINA_TRUE; + en->selecting = EINA_TRUE; + } + } + } + } + else + { + en->selecting = EINA_TRUE; + _sel_clear(en->cursor, rp->object, en); + if (en->select_allow) + { + _sel_start(en->cursor, rp->object, en); + } + } + } + if (evas_textblock_cursor_compare(tc, en->cursor)) + _edje_emit(rp->edje, "cursor,changed", rp->part->name); + evas_textblock_cursor_free(tc); + + _edje_entry_imf_context_reset(en); + _edje_entry_imf_cursor_info_set(en); + + _edje_entry_real_part_configure(rp); + if (ev->button == 2) + { + _edje_emit(rp->edje, "entry,paste,request", rp->part->name); + _edje_emit(rp->edje, "entry,paste,request,1", rp->part->name); + } +} + +static void +_edje_part_mouse_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) +{ + Evas_Coord cx, cy; + Edje_Real_Part *rp = data; + Evas_Event_Mouse_Up *ev = event_info; + Entry *en; + Evas_Coord x, y, w, h; + Evas_Textblock_Cursor *tc; + if (ev->button != 1) return; + if (!rp) return; + if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return; + en = rp->entry_data; + if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) || + (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE)) + return; + +#ifdef HAVE_ECORE_IMF + if (en->imf_context) + { + Ecore_IMF_Event_Mouse_Up ecore_ev; + ecore_imf_evas_event_mouse_up_wrap(ev, &ecore_ev); + if (ecore_imf_context_filter_event(en->imf_context, + ECORE_IMF_EVENT_MOUSE_UP, + (Ecore_IMF_Event *)&ecore_ev)) + return; + } +#endif + + tc = evas_object_textblock_cursor_new(rp->object); + evas_textblock_cursor_copy(en->cursor, tc); + evas_object_geometry_get(rp->object, &x, &y, &w, &h); + cx = ev->canvas.x - x; + cy = ev->canvas.y - y; + if (!evas_textblock_cursor_char_coord_set(en->cursor, cx, cy)) + { + Evas_Coord lx, ly, lw, lh; + int line; + + line = evas_textblock_cursor_line_coord_set(en->cursor, cy); + if (line == -1) + { + if (rp->part->multiline) + _curs_end(en->cursor, rp->object, en); + else + { + evas_textblock_cursor_paragraph_first(en->cursor); + evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh); + if (!evas_textblock_cursor_char_coord_set(en->cursor, cx, ly + (lh / 2))) + _curs_end(en->cursor, rp->object, en); + } + } + else + { + int lnum; + + lnum = evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh); + if (lnum < 0) + { + _curs_lin_start(en->cursor, rp->object, en); + } + else + { + if (cx <= lx) + _curs_lin_start(en->cursor, rp->object, en); + else + _curs_lin_end(en->cursor, rp->object, en); + } + } + } + if (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT) + { + if (en->select_allow) + { + if (en->had_sel) + { + if (en->select_mod_end) + _sel_extend(en->cursor, rp->object, en); + else if (en->select_mod_start) + _sel_preextend(en->cursor, rp->object, en); + } + else + _sel_extend(en->cursor, rp->object, en); + //evas_textblock_cursor_copy(en->cursor, en->sel_end); + } + } + else + evas_textblock_cursor_copy(en->cursor, en->sel_end); + if (en->selecting) + { + if (en->have_selection) + en->had_sel = EINA_TRUE; + en->selecting = EINA_FALSE; + } + if (evas_textblock_cursor_compare(tc, en->cursor)) + _edje_emit(rp->edje, "cursor,changed", rp->part->name); + evas_textblock_cursor_free(tc); + + _edje_entry_imf_context_reset(en); + _edje_entry_imf_cursor_info_set(en); + _edje_entry_real_part_configure(rp); +} + +static void +_edje_part_mouse_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) +{ + Evas_Coord cx, cy; + Edje_Real_Part *rp = data; + Evas_Event_Mouse_Move *ev = event_info; + Entry *en; + Evas_Coord x, y, w, h; + Evas_Textblock_Cursor *tc; + if (!rp) return; + en = rp->entry_data; + if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) || + (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE)) + return; + +#ifdef HAVE_ECORE_IMF + if (en->imf_context) + { + Ecore_IMF_Event_Mouse_Move ecore_ev; + ecore_imf_evas_event_mouse_move_wrap(ev, &ecore_ev); + if (ecore_imf_context_filter_event(en->imf_context, + ECORE_IMF_EVENT_MOUSE_MOVE, + (Ecore_IMF_Event *)&ecore_ev)) + return; + } +#endif + + if (en->selecting) + { + tc = evas_object_textblock_cursor_new(rp->object); + evas_textblock_cursor_copy(en->cursor, tc); + evas_object_geometry_get(rp->object, &x, &y, &w, &h); + cx = ev->cur.canvas.x - x; + cy = ev->cur.canvas.y - y; + if (!evas_textblock_cursor_char_coord_set(en->cursor, cx, cy)) + { + Evas_Coord lx, ly, lw, lh; + + if (evas_textblock_cursor_line_coord_set(en->cursor, cy) < 0) + { + if (rp->part->multiline) + _curs_end(en->cursor, rp->object, en); + else + { + evas_textblock_cursor_paragraph_first(en->cursor); + evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh); + if (!evas_textblock_cursor_char_coord_set(en->cursor, cx, ly + (lh / 2))) + _curs_end(en->cursor, rp->object, en); + } + } + else + { + evas_textblock_cursor_line_geometry_get(en->cursor, &lx, &ly, &lw, &lh); + if (cx <= lx) + _curs_lin_start(en->cursor, rp->object, en); + else + _curs_lin_end(en->cursor, rp->object, en); + } + } + if (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_EXPLICIT) + { + if (en->select_allow) + { + if (en->had_sel) + { + if (en->select_mod_end) + _sel_extend(en->cursor, rp->object, en); + else if (en->select_mod_start) + _sel_preextend(en->cursor, rp->object, en); + } + else + _sel_extend(en->cursor, rp->object, en); + } + } + else + { + _sel_extend(en->cursor, rp->object, en); + } + if (en->select_allow) + { + if (evas_textblock_cursor_compare(en->sel_start, en->sel_end) != 0) + _sel_enable(en->cursor, rp->object, en); + if (en->have_selection) + _sel_update(en->cursor, rp->object, en); + } + if (evas_textblock_cursor_compare(tc, en->cursor)) + _edje_emit(rp->edje, "cursor,changed", rp->part->name); + evas_textblock_cursor_free(tc); + + _edje_entry_imf_context_reset(en); + _edje_entry_imf_cursor_info_set(en); + + _edje_entry_real_part_configure(rp); + } +} + +static void +_evas_focus_in_cb(void *data, Evas *e, __UNUSED__ void *event_info) +{ + Edje *ed = (Edje *)data; + + if (evas_focus_get(e) == ed->obj) + { + _edje_focus_in_cb(data, NULL, NULL, NULL); + } +} + +static void +_evas_focus_out_cb(void *data, Evas *e, __UNUSED__ void *event_info) +{ + Edje *ed = (Edje *)data; + + if (evas_focus_get(e) == ed->obj) + { + _edje_focus_out_cb(data, NULL, NULL, NULL); + } +} + +/***************************************************************/ +void +_edje_entry_init(Edje *ed) +{ + if (!ed->has_entries) + return; + if (ed->entries_inited) + return; + ed->entries_inited = EINA_TRUE; + + evas_object_event_callback_add(ed->obj, EVAS_CALLBACK_FOCUS_IN, _edje_focus_in_cb, ed); + evas_object_event_callback_add(ed->obj, EVAS_CALLBACK_FOCUS_OUT, _edje_focus_out_cb, ed); + evas_object_event_callback_add(ed->obj, EVAS_CALLBACK_KEY_DOWN, _edje_key_down_cb, ed); + evas_object_event_callback_add(ed->obj, EVAS_CALLBACK_KEY_UP, _edje_key_up_cb, ed); + evas_event_callback_add(ed->base.evas, EVAS_CALLBACK_CANVAS_FOCUS_IN, _evas_focus_in_cb, ed); + evas_event_callback_add(ed->base.evas, EVAS_CALLBACK_CANVAS_FOCUS_OUT, _evas_focus_out_cb, ed); +} + +void +_edje_entry_shutdown(Edje *ed) +{ + if (!ed->has_entries) + return; + if (!ed->entries_inited) + return; + ed->entries_inited = EINA_FALSE; + + evas_object_event_callback_del(ed->obj, EVAS_CALLBACK_FOCUS_IN, _edje_focus_in_cb); + evas_object_event_callback_del(ed->obj, EVAS_CALLBACK_FOCUS_OUT, _edje_focus_out_cb); + evas_object_event_callback_del(ed->obj, EVAS_CALLBACK_KEY_DOWN, _edje_key_down_cb); + evas_object_event_callback_del(ed->obj, EVAS_CALLBACK_KEY_UP, _edje_key_up_cb); + if (evas_event_callback_del_full(ed->base.evas, EVAS_CALLBACK_CANVAS_FOCUS_IN, _evas_focus_in_cb, ed) != ed) + ERR("could not unregister EVAS_CALLBACK_FOCUS_IN"); + if (evas_event_callback_del_full(ed->base.evas, EVAS_CALLBACK_CANVAS_FOCUS_OUT, _evas_focus_out_cb, ed) != ed) + ERR("could not unregister EVAS_CALLBACK_FOCUS_OUT"); +} + +void +_edje_entry_real_part_init(Edje_Real_Part *rp) +{ + Entry *en; +#ifdef HAVE_ECORE_IMF + const char *ctx_id; + const Ecore_IMF_Context_Info *ctx_info; +#endif + + en = calloc(1, sizeof(Entry)); + if (!en) return; + rp->entry_data = en; + en->rp = rp; + + evas_object_event_callback_add(rp->object, EVAS_CALLBACK_MOVE, _edje_part_move_cb, rp); + + evas_object_event_callback_add(rp->object, EVAS_CALLBACK_MOUSE_DOWN, _edje_part_mouse_down_cb, rp); + evas_object_event_callback_add(rp->object, EVAS_CALLBACK_MOUSE_UP, _edje_part_mouse_up_cb, rp); + evas_object_event_callback_add(rp->object, EVAS_CALLBACK_MOUSE_MOVE, _edje_part_mouse_move_cb, rp); + + if (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_DEFAULT) + en->select_allow = EINA_TRUE; + + if (rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD) + { + Edje_Part_Description_Text *txt; + + txt = (Edje_Part_Description_Text *)rp->chosen_description; + + en->select_allow = EINA_FALSE; + if (txt && edje_string_get(&txt->text.repch)) + evas_object_textblock_replace_char_set(rp->object, edje_string_get(&txt->text.repch)); + else + evas_object_textblock_replace_char_set(rp->object, "*"); + } + + en->cursor_bg = edje_object_add(rp->edje->base.evas); + edje_object_file_set(en->cursor_bg, rp->edje->path, rp->part->source3); + evas_object_smart_member_add(en->cursor_bg, rp->edje->obj); + evas_object_stack_below(en->cursor_bg, rp->object); + evas_object_clip_set(en->cursor_bg, evas_object_clip_get(rp->object)); + evas_object_pass_events_set(en->cursor_bg, EINA_TRUE); + _edje_subobj_register(en->rp->edje, en->cursor_bg); + + en->cursor_fg = edje_object_add(rp->edje->base.evas); + edje_object_file_set(en->cursor_fg, rp->edje->path, rp->part->source4); + evas_object_smart_member_add(en->cursor_fg, rp->edje->obj); + evas_object_stack_above(en->cursor_fg, rp->object); + evas_object_clip_set(en->cursor_fg, evas_object_clip_get(rp->object)); + evas_object_pass_events_set(en->cursor_fg, EINA_TRUE); + _edje_subobj_register(en->rp->edje, en->cursor_fg); + + if (rp->part->entry_mode >= EDJE_ENTRY_EDIT_MODE_EDITABLE) + { + evas_object_show(en->cursor_bg); + evas_object_show(en->cursor_fg); +#ifdef HAVE_ECORE_IMF + ecore_imf_init(); + + edje_object_signal_callback_add(rp->edje->obj, "focus,part,in", rp->part->name, _edje_entry_focus_in_cb, rp); + edje_object_signal_callback_add(rp->edje->obj, "focus,part,out", rp->part->name, _edje_entry_focus_out_cb, rp); + + ctx_id = ecore_imf_context_default_id_get(); + if (ctx_id) + { + ctx_info = ecore_imf_context_info_by_id_get(ctx_id); + if (!ctx_info->canvas_type || + strcmp(ctx_info->canvas_type, "evas") == 0) + { + en->imf_context = ecore_imf_context_add(ctx_id); + } + else + { + ctx_id = ecore_imf_context_default_id_by_canvas_type_get("evas"); + if (ctx_id) + { + en->imf_context = ecore_imf_context_add(ctx_id); + } + } + } + else + en->imf_context = NULL; + + if (!en->imf_context) goto done; + + ecore_imf_context_client_window_set + (en->imf_context, + (void *)ecore_evas_window_get + (ecore_evas_ecore_evas_get(rp->edje->base.evas))); + ecore_imf_context_client_canvas_set(en->imf_context, rp->edje->base.evas); + + ecore_imf_context_retrieve_surrounding_callback_set(en->imf_context, + _edje_entry_imf_retrieve_surrounding_cb, rp->edje); + en->imf_ee_handler_commit = ecore_event_handler_add(ECORE_IMF_EVENT_COMMIT, _edje_entry_imf_event_commit_cb, rp->edje); + en->imf_ee_handler_delete = ecore_event_handler_add(ECORE_IMF_EVENT_DELETE_SURROUNDING, _edje_entry_imf_event_delete_surrounding_cb, rp->edje); + en->imf_ee_handler_changed = ecore_event_handler_add(ECORE_IMF_EVENT_PREEDIT_CHANGED, _edje_entry_imf_event_preedit_changed_cb, rp->edje); + ecore_imf_context_input_mode_set(en->imf_context, + rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD ? + ECORE_IMF_INPUT_MODE_INVISIBLE : ECORE_IMF_INPUT_MODE_FULL); +#endif + } +#ifdef HAVE_ECORE_IMF +done: +#endif + en->cursor = (Evas_Textblock_Cursor *)evas_object_textblock_cursor_get(rp->object); +} + +void +_edje_entry_real_part_shutdown(Edje_Real_Part *rp) +{ + Entry *en = rp->entry_data; + if (!en) return; + rp->entry_data = NULL; + _sel_clear(en->cursor, rp->object, en); + _anchors_clear(en->cursor, rp->object, en); +#ifdef HAVE_ECORE_IMF + _preedit_clear(en); +#endif + evas_object_del(en->cursor_bg); + evas_object_del(en->cursor_fg); + + if (en->pw_timer) + { + ecore_timer_del(en->pw_timer); + en->pw_timer = NULL; + } + +#ifdef HAVE_ECORE_IMF + if (rp->part->entry_mode >= EDJE_ENTRY_EDIT_MODE_EDITABLE) + { + if (en->imf_context) + { + if (en->imf_ee_handler_commit) + { + ecore_event_handler_del(en->imf_ee_handler_commit); + en->imf_ee_handler_commit = NULL; + } + + if (en->imf_ee_handler_delete) + { + ecore_event_handler_del(en->imf_ee_handler_delete); + en->imf_ee_handler_delete = NULL; + } + + if (en->imf_ee_handler_changed) + { + ecore_event_handler_del(en->imf_ee_handler_changed); + en->imf_ee_handler_changed = NULL; + } + + ecore_imf_context_del(en->imf_context); + en->imf_context = NULL; + } + + edje_object_signal_callback_del(rp->edje->obj, "focus,part,in", rp->part->name, _edje_entry_focus_in_cb); + edje_object_signal_callback_del(rp->edje->obj, "focus,part,out", rp->part->name, _edje_entry_focus_out_cb); + ecore_imf_shutdown(); + } +#endif + + free(en); +} + +void +_edje_entry_real_part_configure(Edje_Real_Part *rp) +{ + Evas_Coord x, y, w, h, xx, yy, ww, hh; + Entry *en = rp->entry_data; + Evas_Textblock_Cursor_Type cur_type; + if (!en) return; + switch (rp->part->cursor_mode) + { + case EDJE_ENTRY_CURSOR_MODE_BEFORE: + cur_type = EVAS_TEXTBLOCK_CURSOR_BEFORE; + break; + case EDJE_ENTRY_CURSOR_MODE_UNDER: + /* no break for a resaon */ + default: + cur_type = EVAS_TEXTBLOCK_CURSOR_UNDER; + } + + _sel_update(en->cursor, rp->object, en); + _anchors_update(en->cursor, rp->object, en); + x = y = w = h = -1; + xx = yy = ww = hh = -1; + evas_object_geometry_get(rp->object, &x, &y, &w, &h); + evas_textblock_cursor_geometry_get(en->cursor, &xx, &yy, &ww, &hh, NULL, cur_type); + if (ww < 1) ww = 1; + if (hh < 1) hh = 1; + if (en->cursor_bg) + { + evas_object_move(en->cursor_bg, x + xx, y + yy); + evas_object_resize(en->cursor_bg, ww, hh); + } + if (en->cursor_fg) + { + evas_object_move(en->cursor_fg, x + xx, y + yy); + evas_object_resize(en->cursor_fg, ww, hh); + } +} + +const char * +_edje_entry_selection_get(Edje_Real_Part *rp) +{ + Entry *en = rp->entry_data; + if (!en) return NULL; + // get selection - convert to markup + if ((!en->selection) && (en->have_selection)) + en->selection = evas_textblock_cursor_range_text_get + (en->sel_start, en->sel_end, EVAS_TEXTBLOCK_TEXT_MARKUP); + return en->selection; +} + +const char * +_edje_entry_text_get(Edje_Real_Part *rp) +{ + Entry *en = rp->entry_data; + if (!en) return NULL; + // get text - convert to markup + return evas_object_textblock_text_markup_get(rp->object); +} + +void +_edje_entry_text_markup_set(Edje_Real_Part *rp, const char *text) +{ + Entry *en = rp->entry_data; + if (!en) return; + + // set text as markup + _sel_clear(en->cursor, rp->object, en); + evas_object_textblock_text_markup_set(rp->object, text); + _edje_entry_set_cursor_start(rp); + + _anchors_get(en->cursor, rp->object, en); + _edje_emit(rp->edje, "entry,changed", rp->part->name); + _edje_entry_imf_cursor_info_set(en); +#if 0 + /* Don't emit cursor changed cause it didn't. It's just init to 0. */ + _edje_emit(rp->edje, "cursor,changed", rp->part->name); +#endif +} + +void +_edje_entry_text_markup_append(Edje_Real_Part *rp, const char *text) +{ + Entry *en = rp->entry_data; + Evas_Textblock_Cursor *end_cur; + if (!en) return; + end_cur = evas_object_textblock_cursor_new(rp->object); + evas_textblock_cursor_paragraph_last(end_cur); + + _text_filter_markup_prepend(en, end_cur, text); + evas_textblock_cursor_free(end_cur); + + /* We are updating according to the real cursor on purpose */ + _anchors_get(en->cursor, rp->object, en); + _edje_emit(rp->edje, "entry,changed", rp->part->name); + + _edje_entry_real_part_configure(rp); +} + +void +_edje_entry_text_markup_insert(Edje_Real_Part *rp, const char *text) +{ + Entry *en = rp->entry_data; + if (!en) return; + // prepend markup @ cursor pos + if (en->have_selection) + _range_del(en->cursor, rp->object, en); + _sel_clear(en->cursor, rp->object, en); + //xx +// evas_object_textblock_text_markup_prepend(en->cursor, text); + _text_filter_markup_prepend(en, en->cursor, text); + _anchors_get(en->cursor, rp->object, en); + _edje_emit(rp->edje, "entry,changed", rp->part->name); + _edje_emit(rp->edje, "cursor,changed", rp->part->name); + + _edje_entry_imf_context_reset(en); + _edje_entry_imf_cursor_info_set(en); + + _edje_entry_real_part_configure(rp); +} + +void +_edje_entry_set_cursor_start(Edje_Real_Part *rp) +{ + Entry *en = rp->entry_data; + if (!en) return; + _curs_start(en->cursor, rp->object, en); + + _edje_entry_imf_cursor_info_set(en); +} + +void +_edje_entry_set_cursor_end(Edje_Real_Part *rp) +{ + Entry *en = rp->entry_data; + if (!en) return; + _curs_end(en->cursor, rp->object, en); + + _edje_entry_imf_cursor_info_set(en); +} + +void +_edje_entry_select_none(Edje_Real_Part *rp) +{ + Entry *en = rp->entry_data; + if (!en) return; + _sel_clear(en->cursor, rp->object, en); +} + +void +_edje_entry_select_all(Edje_Real_Part *rp) +{ + Entry *en = rp->entry_data; + if (!en) return; + _sel_clear(en->cursor, rp->object, en); + _curs_start(en->cursor, rp->object, en); + _sel_enable(en->cursor, rp->object, en); + _sel_start(en->cursor, rp->object, en); + _curs_end(en->cursor, rp->object, en); + _sel_extend(en->cursor, rp->object, en); + + _edje_entry_imf_context_reset(en); + _edje_entry_imf_cursor_info_set(en); + _edje_entry_real_part_configure(rp); +} + +void +_edje_entry_select_begin(Edje_Real_Part *rp) +{ + Entry *en = rp->entry_data; + if (!en) return; + _sel_clear(en->cursor, rp->object, en); + _sel_enable(en->cursor, rp->object, en); + _sel_start(en->cursor, rp->object, en); + _sel_extend(en->cursor, rp->object, en); + + _edje_entry_imf_context_reset(en); + _edje_entry_imf_cursor_info_set(en); + + _edje_entry_real_part_configure(rp); +} + +void +_edje_entry_select_extend(Edje_Real_Part *rp) +{ + Entry *en = rp->entry_data; + if (!en) return; + _sel_extend(en->cursor, rp->object, en); + + _edje_entry_imf_context_reset(en); + _edje_entry_imf_cursor_info_set(en); + + _edje_entry_real_part_configure(rp); +} + +const Eina_List * +_edje_entry_anchor_geometry_get(Edje_Real_Part *rp, const char *anchor) +{ + Entry *en = rp->entry_data; + Eina_List *l; + Anchor *an; + + if (!en) return NULL; + EINA_LIST_FOREACH(en->anchors, l, an) + { + if (an->item) continue; + if (!strcmp(anchor, an->name)) + return an->sel; + } + return NULL; +} + +const Eina_List * +_edje_entry_anchors_list(Edje_Real_Part *rp) +{ + Entry *en = rp->entry_data; + Eina_List *l, *anchors = NULL; + Anchor *an; + + if (!en) return NULL; + if (!en->anchorlist) + { + EINA_LIST_FOREACH(en->anchors, l, an) + { + const char *n = an->name; + if (an->item) continue; + if (!n) n = ""; + anchors = eina_list_append(anchors, strdup(n)); + } + en->anchorlist = anchors; + } + return en->anchorlist; +} + +Eina_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) +{ + Entry *en = rp->entry_data; + Eina_List *l; + Anchor *an; + + if (!en) return EINA_FALSE; + EINA_LIST_FOREACH(en->anchors, l, an) + { + if (an->item) continue; + if (!strcmp(item, an->name)) + { + evas_textblock_cursor_format_item_geometry_get(an->start, cx, cy, cw, ch); + return EINA_TRUE; + } + } + return EINA_FALSE; +} + +const Eina_List * +_edje_entry_items_list(Edje_Real_Part *rp) +{ + Entry *en = rp->entry_data; + Eina_List *l, *items = NULL; + Anchor *an; + + if (!en) return NULL; + if (!en->itemlist) + { + EINA_LIST_FOREACH(en->anchors, l, an) + { + const char *n = an->name; + if (an->item) continue; + if (!n) n = ""; + items = eina_list_append(items, strdup(n)); + } + en->itemlist = items; + } + return en->itemlist; +} + +void +_edje_entry_cursor_geometry_get(Edje_Real_Part *rp, Evas_Coord *cx, Evas_Coord *cy, Evas_Coord *cw, Evas_Coord *ch) +{ + Evas_Coord x, y, w, h, xx, yy, ww, hh; + Entry *en = rp->entry_data; + Evas_Textblock_Cursor_Type cur_type; + if (!en) return; + switch (rp->part->cursor_mode) + { + case EDJE_ENTRY_CURSOR_MODE_BEFORE: + cur_type = EVAS_TEXTBLOCK_CURSOR_BEFORE; + break; + case EDJE_ENTRY_CURSOR_MODE_UNDER: + /* no break for a resaon */ + default: + cur_type = EVAS_TEXTBLOCK_CURSOR_UNDER; + } + + x = y = w = h = -1; + xx = yy = ww = hh = -1; + evas_object_geometry_get(rp->object, &x, &y, &w, &h); + evas_textblock_cursor_geometry_get(en->cursor, &xx, &yy, &ww, &hh, NULL, cur_type); + if (ww < 1) ww = 1; + if (rp->part->cursor_mode == EDJE_ENTRY_CURSOR_MODE_BEFORE) + edje_object_size_min_restricted_calc(en->cursor_fg, &ww, NULL, ww, 0); + if (hh < 1) hh = 1; + if (cx) *cx = x + xx; + if (cy) *cy = y + yy; + if (cw) *cw = ww; + if (ch) *ch = hh; +} + +void +_edje_entry_select_allow_set(Edje_Real_Part *rp, Eina_Bool allow) +{ + Entry *en = rp->entry_data; + if (rp->part->select_mode == EDJE_ENTRY_SELECTION_MODE_DEFAULT) + return; + en->select_allow = allow; +} + +Eina_Bool +_edje_entry_select_allow_get(const Edje_Real_Part *rp) +{ + const Entry *en = rp->entry_data; + return en->select_allow; +} + +void +_edje_entry_select_abort(Edje_Real_Part *rp) +{ + Entry *en = rp->entry_data; + if (en->selecting) + { + en->selecting = EINA_FALSE; + + _edje_entry_imf_context_reset(en); + _edje_entry_imf_cursor_info_set(en); + _edje_entry_real_part_configure(rp); + } +} + +void +_edje_entry_autocapital_type_set(Edje_Real_Part *rp, Edje_Text_Autocapital_Type autocapital_type) +{ + Entry *en = rp->entry_data; + if (!en) return; + + if (rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD) + autocapital_type = EDJE_TEXT_AUTOCAPITAL_TYPE_NONE; + +#ifdef HAVE_ECORE_IMF + if (en->imf_context) + ecore_imf_context_autocapital_type_set(en->imf_context, autocapital_type); +#endif +} + +Edje_Text_Autocapital_Type +_edje_entry_autocapital_type_get(Edje_Real_Part *rp) +{ + Entry *en = rp->entry_data; + if (!en) return EDJE_TEXT_AUTOCAPITAL_TYPE_NONE; + +#ifdef HAVE_ECORE_IMF + if (en->imf_context) + return ecore_imf_context_autocapital_type_get(en->imf_context); +#endif + + return EDJE_TEXT_AUTOCAPITAL_TYPE_NONE; +} + +void +_edje_entry_input_panel_enabled_set(Edje_Real_Part *rp, Eina_Bool enabled) +{ + Entry *en = rp->entry_data; + + if (!en) return; +#ifdef HAVE_ECORE_IMF + if (en->imf_context) + ecore_imf_context_input_panel_enabled_set(en->imf_context, enabled); +#else + (void) enabled; +#endif +} + +Eina_Bool +_edje_entry_input_panel_enabled_get(Edje_Real_Part *rp) +{ + Entry *en = rp->entry_data; + if (!en) return EINA_FALSE; +#ifdef HAVE_ECORE_IMF + if (en->imf_context) + return ecore_imf_context_input_panel_enabled_get(en->imf_context); +#endif + + return EINA_FALSE; +} + +static Evas_Textblock_Cursor * +_cursor_get(Edje_Real_Part *rp, Edje_Cursor cur) +{ + Entry *en = rp->entry_data; + if (!en) return NULL; + + switch (cur) + { + case EDJE_CURSOR_MAIN: + return en->cursor; + case EDJE_CURSOR_SELECTION_BEGIN: + return en->sel_start; + case EDJE_CURSOR_SELECTION_END: + return en->sel_end; + case EDJE_CURSOR_PREEDIT_START: + if (!en->preedit_start) + en->preedit_start = evas_object_textblock_cursor_new(rp->object); + return en->preedit_start; + case EDJE_CURSOR_PREEDIT_END: + if (!en->preedit_end) + en->preedit_end = evas_object_textblock_cursor_new(rp->object); + return en->preedit_end; + case EDJE_CURSOR_USER: + if (!en->cursor_user) + en->cursor_user = evas_object_textblock_cursor_new(rp->object); + return en->cursor_user; + case EDJE_CURSOR_USER_EXTRA: + if (!en->cursor_user_extra) + en->cursor_user_extra = evas_object_textblock_cursor_new(rp->object); + return en->cursor_user_extra; + default: + break; + } + return NULL; +} + +Eina_Bool +_edje_entry_cursor_next(Edje_Real_Part *rp, Edje_Cursor cur) +{ + Entry *en = rp->entry_data; + Evas_Textblock_Cursor *c = _cursor_get(rp, cur); + if (!c) return EINA_FALSE; + if (!evas_textblock_cursor_char_next(c)) + { + return EINA_FALSE; + } + _sel_update(c, rp->object, rp->entry_data); + + _edje_entry_imf_context_reset(en); + _edje_entry_imf_cursor_info_set(en); + + _edje_emit(rp->edje, "cursor,changed", rp->part->name); + _edje_entry_real_part_configure(rp); + return EINA_TRUE; +} + +Eina_Bool +_edje_entry_cursor_prev(Edje_Real_Part *rp, Edje_Cursor cur) +{ + Entry *en = rp->entry_data; + Evas_Textblock_Cursor *c = _cursor_get(rp, cur); + if (!c) return EINA_FALSE; + if (!evas_textblock_cursor_char_prev(c)) + { + if (evas_textblock_cursor_paragraph_prev(c)) goto ok; + else return EINA_FALSE; + } +ok: + _sel_update(c, rp->object, rp->entry_data); + + _edje_entry_imf_context_reset(en); + _edje_entry_imf_cursor_info_set(en); + + _edje_emit(rp->edje, "cursor,changed", rp->part->name); + _edje_entry_real_part_configure(rp); + return EINA_TRUE; +} + +Eina_Bool +_edje_entry_cursor_up(Edje_Real_Part *rp, Edje_Cursor cur) +{ + Entry *en = rp->entry_data; + Evas_Textblock_Cursor *c = _cursor_get(rp, cur); + Evas_Coord lx, ly, lw, lh, cx, cy, cw, ch; + int ln; + if (!c) return EINA_FALSE; + ln = evas_textblock_cursor_line_geometry_get(c, NULL, NULL, NULL, NULL); + ln--; + if (ln < 0) return EINA_FALSE; + if (!evas_object_textblock_line_number_geometry_get(rp->object, ln, + &lx, &ly, &lw, &lh)) + return EINA_FALSE; + evas_textblock_cursor_char_geometry_get(c, &cx, &cy, &cw, &ch); + if (!evas_textblock_cursor_char_coord_set(c, cx, ly + (lh / 2))) + { + if (cx < (lx + (lw / 2))) + evas_textblock_cursor_line_char_last(c); + else + evas_textblock_cursor_line_char_last(c); + } + _sel_update(c, rp->object, rp->entry_data); + + _edje_entry_imf_context_reset(en); + _edje_entry_imf_cursor_info_set(en); + + _edje_emit(rp->edje, "cursor,changed", rp->part->name); + _edje_entry_real_part_configure(rp); + return EINA_TRUE; +} + +Eina_Bool +_edje_entry_cursor_down(Edje_Real_Part *rp, Edje_Cursor cur) +{ + Entry *en = rp->entry_data; + Evas_Textblock_Cursor *c = _cursor_get(rp, cur); + Evas_Coord lx, ly, lw, lh, cx, cy, cw, ch; + int ln; + if (!c) return EINA_FALSE; + ln = evas_textblock_cursor_line_geometry_get(c, NULL, NULL, NULL, NULL); + ln++; + if (!evas_object_textblock_line_number_geometry_get(rp->object, ln, + &lx, &ly, &lw, &lh)) + return EINA_FALSE; + evas_textblock_cursor_char_geometry_get(c, &cx, &cy, &cw, &ch); + if (!evas_textblock_cursor_char_coord_set(c, cx, ly + (lh / 2))) + { + if (cx < (lx + (lw / 2))) + evas_textblock_cursor_line_char_last(c); + else + evas_textblock_cursor_line_char_last(c); + } + _sel_update(c, rp->object, rp->entry_data); + + _edje_entry_imf_context_reset(en); + _edje_entry_imf_cursor_info_set(en); + _edje_emit(rp->edje, "cursor,changed", rp->part->name); + _edje_entry_real_part_configure(rp); + return EINA_TRUE; +} + +void +_edje_entry_cursor_begin(Edje_Real_Part *rp, Edje_Cursor cur) +{ + Entry *en = rp->entry_data; + Evas_Textblock_Cursor *c = _cursor_get(rp, cur); + if (!c) return; + evas_textblock_cursor_paragraph_first(c); + _sel_update(c, rp->object, rp->entry_data); + + _edje_entry_imf_context_reset(en); + _edje_entry_imf_cursor_info_set(en); + _edje_emit(rp->edje, "cursor,changed", rp->part->name); + _edje_entry_real_part_configure(rp); +} + +void +_edje_entry_cursor_end(Edje_Real_Part *rp, Edje_Cursor cur) +{ + Entry *en = rp->entry_data; + Evas_Textblock_Cursor *c = _cursor_get(rp, cur); + if (!c) return; + _curs_end(c, rp->object, rp->entry_data); + _sel_update(c, rp->object, rp->entry_data); + + _edje_entry_imf_context_reset(en); + _edje_entry_imf_cursor_info_set(en); + + _edje_emit(rp->edje, "cursor,changed", rp->part->name); + _edje_entry_real_part_configure(rp); +} + +void +_edje_entry_cursor_copy(Edje_Real_Part *rp, Edje_Cursor cur, Edje_Cursor dst) +{ + Entry *en = rp->entry_data; + Evas_Textblock_Cursor *c; + Evas_Textblock_Cursor *d; + + c = _cursor_get(rp, cur); + if (!c) return; + d = _cursor_get(rp, dst); + if (!d) return; + evas_textblock_cursor_copy(c, d); + _sel_update(c, rp->object, rp->entry_data); + + _edje_entry_imf_context_reset(en); + _edje_entry_imf_cursor_info_set(en); + _edje_emit(rp->edje, "cursor,changed", rp->part->name); + _edje_entry_real_part_configure(rp); +} + +void +_edje_entry_cursor_line_begin(Edje_Real_Part *rp, Edje_Cursor cur) +{ + Entry *en = rp->entry_data; + Evas_Textblock_Cursor *c = _cursor_get(rp, cur); + if (!c) return; + evas_textblock_cursor_line_char_first(c); + _sel_update(c, rp->object, rp->entry_data); + + _edje_entry_imf_context_reset(en); + _edje_entry_imf_cursor_info_set(en); + + _edje_emit(rp->edje, "cursor,changed", rp->part->name); + _edje_entry_real_part_configure(rp); +} + +void +_edje_entry_cursor_line_end(Edje_Real_Part *rp, Edje_Cursor cur) +{ + Entry *en = rp->entry_data; + Evas_Textblock_Cursor *c = _cursor_get(rp, cur); + if (!c) return; + evas_textblock_cursor_line_char_last(c); + _sel_update(c, rp->object, rp->entry_data); + + _edje_entry_imf_context_reset(en); + _edje_entry_imf_cursor_info_set(en); + _edje_emit(rp->edje, "cursor,changed", rp->part->name); + _edje_entry_real_part_configure(rp); +} + +Eina_Bool +_edje_entry_cursor_coord_set(Edje_Real_Part *rp, Edje_Cursor cur, + Evas_Coord x, Evas_Coord y) +{ + Evas_Textblock_Cursor *c = _cursor_get(rp, cur); + if (!c) return EINA_FALSE; + return evas_textblock_cursor_char_coord_set(c, x, y); +} + +Eina_Bool +_edje_entry_cursor_is_format_get(Edje_Real_Part *rp, Edje_Cursor cur) +{ + Evas_Textblock_Cursor *c = _cursor_get(rp, cur); + if (!c) return EINA_FALSE; + if (evas_textblock_cursor_is_format(c)) return EINA_TRUE; + return EINA_FALSE; +} + +Eina_Bool +_edje_entry_cursor_is_visible_format_get(Edje_Real_Part *rp, Edje_Cursor cur) +{ + Evas_Textblock_Cursor *c = _cursor_get(rp, cur); + if (!c) return EINA_FALSE; + return evas_textblock_cursor_format_is_visible_get(c); +} + +const char * +_edje_entry_cursor_content_get(Edje_Real_Part *rp, Edje_Cursor cur) +{ + static char *s = NULL; + Evas_Textblock_Cursor *c = _cursor_get(rp, cur); + + if (!c) return NULL; + if (s) + { + free(s); + s = NULL; + } + + s = evas_textblock_cursor_content_get(c); + return s; +} + +void +_edje_entry_cursor_pos_set(Edje_Real_Part *rp, Edje_Cursor cur, int pos) +{ + Entry *en = rp->entry_data; + Evas_Textblock_Cursor *c = _cursor_get(rp, cur); + if (!c) return; + /* Abort if cursor position didn't really change */ + if (evas_textblock_cursor_pos_get(c) == pos) + return; + + evas_textblock_cursor_pos_set(c, pos); + _sel_update(c, rp->object, rp->entry_data); + + _edje_entry_imf_context_reset(en); + _edje_entry_imf_cursor_info_set(en); + _edje_emit(rp->edje, "cursor,changed", rp->part->name); + _edje_entry_real_part_configure(rp); +} + +int +_edje_entry_cursor_pos_get(Edje_Real_Part *rp, Edje_Cursor cur) +{ + Evas_Textblock_Cursor *c = _cursor_get(rp, cur); + if (!c) return 0; + return evas_textblock_cursor_pos_get(c); +} + +void +_edje_entry_input_panel_layout_set(Edje_Real_Part *rp, Edje_Input_Panel_Layout layout) +{ + Entry *en = rp->entry_data; + if (!en) return; +#ifdef HAVE_ECORE_IMF + if (en->imf_context) + ecore_imf_context_input_panel_layout_set(en->imf_context, layout); +#else + (void) layout; +#endif +} + +Edje_Input_Panel_Layout +_edje_entry_input_panel_layout_get(Edje_Real_Part *rp) +{ + Entry *en = rp->entry_data; + if (!en) return EDJE_INPUT_PANEL_LAYOUT_INVALID; +#ifdef HAVE_ECORE_IMF + if (en->imf_context) + return ecore_imf_context_input_panel_layout_get(en->imf_context); +#endif + + return EDJE_INPUT_PANEL_LAYOUT_INVALID; +} + +static void +_edje_entry_imf_context_reset(Entry *en) +{ +#ifdef HAVE_ECORE_IMF + if (en->imf_context) + ecore_imf_context_reset(en->imf_context); +#else + (void) en; +#endif +} + +static void +_edje_entry_imf_cursor_info_set(Entry *en) +{ +#ifdef HAVE_ECORE_IMF + Evas_Coord cx, cy, cw, ch; + if (!en || !en->rp || !en->imf_context) return; + + _edje_entry_cursor_geometry_get(en->rp, &cx, &cy, &cw, &ch); + + ecore_imf_context_cursor_position_set(en->imf_context, + evas_textblock_cursor_pos_get(en->cursor)); + ecore_imf_context_cursor_location_set(en->imf_context, cx, cy, cw, ch); +#else + (void) en; +#endif +} + +#ifdef HAVE_ECORE_IMF +static Eina_Bool +_edje_entry_imf_retrieve_surrounding_cb(void *data, Ecore_IMF_Context *ctx __UNUSED__, char **text, int *cursor_pos) +{ + Edje *ed = data; + Edje_Real_Part *rp = ed->focused_part; + Entry *en; + const char *str; + + if (!rp) return EINA_FALSE; + en = rp->entry_data; + if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) || + (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE)) + return EINA_FALSE; + + if (text) + { + str = _edje_entry_text_get(rp); + *text = str ? strdup(str) : strdup(""); + } + + if (cursor_pos) + *cursor_pos = evas_textblock_cursor_pos_get(en->cursor); + + return EINA_TRUE; +} + +static Eina_Bool +_edje_entry_imf_event_commit_cb(void *data, int type __UNUSED__, void *event) +{ + Edje *ed = data; + Edje_Real_Part *rp = ed->focused_part; + Entry *en; + Ecore_IMF_Event_Commit *ev = event; + Evas_Textblock_Cursor *tc; + Eina_Bool cursor_move = EINA_FALSE; + + if ((!rp) || (!ev) || (!ev->str)) return ECORE_CALLBACK_PASS_ON; + + en = rp->entry_data; + if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) || + (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE)) + return ECORE_CALLBACK_PASS_ON; + + if (!en->imf_context) return ECORE_CALLBACK_PASS_ON; + if (en->imf_context != ev->ctx) return ECORE_CALLBACK_PASS_ON; + + if (en->have_selection) + { + if (strcmp(ev->str, "")) + { + /* delete selected characters */ + _range_del(en->cursor, rp->object, en); + _sel_clear(en->cursor, rp->object, en); + } + } + + tc = evas_object_textblock_cursor_new(rp->object); + + /* calculate the cursor position to insert commit string */ + if (en->preedit_start) + evas_textblock_cursor_copy(en->preedit_start, tc); + else + evas_textblock_cursor_copy(en->cursor, tc); + +#ifdef HAVE_ECORE_IMF + /* delete preedit characters */ + _preedit_del(en); + _preedit_clear(en); +#endif + + if (evas_textblock_cursor_compare(en->cursor, tc)) + cursor_move = EINA_TRUE; + if ((rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD) && + _edje_password_show_last) + _edje_entry_hide_visible_password(en->rp); + if ((rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD) && + _edje_password_show_last && (!en->preedit_start)) + { + _text_filter_format_prepend(en, tc, "+ password=off"); + _text_filter_markup_prepend(en, tc, ev->str); + _text_filter_format_prepend(en, tc, "- password"); + if (en->pw_timer) + { + ecore_timer_del(en->pw_timer); + en->pw_timer = NULL; + } + en->pw_timer = ecore_timer_add(_edje_password_show_last_timeout, + _password_timer_cb, en); + } + else + _text_filter_text_prepend(en, tc, ev->str); + + if (!cursor_move) + { + /* move cursor to the end of commit string */ + evas_textblock_cursor_copy(tc, en->cursor); + } + + evas_textblock_cursor_free(tc); + + _edje_entry_imf_cursor_info_set(en); + _anchors_get(en->cursor, rp->object, en); + _edje_emit(rp->edje, "entry,changed", rp->part->name); + _edje_emit(ed, "entry,changed,user", rp->part->name); + _edje_emit(ed, "cursor,changed", rp->part->name); + + return ECORE_CALLBACK_DONE; +} + +static Eina_Bool +_edje_entry_imf_event_preedit_changed_cb(void *data, int type __UNUSED__, void *event) +{ + Edje *ed = data; + Edje_Real_Part *rp = ed->focused_part; + Entry *en; + Ecore_IMF_Event_Preedit_Changed *ev = event; + int cursor_pos; + int preedit_start_pos, preedit_end_pos; + char *preedit_string; + int i; + Eina_Bool preedit_end_state = EINA_FALSE; + + if ((!rp) || (!ev)) return ECORE_CALLBACK_PASS_ON; + + en = rp->entry_data; + if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) || + (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE)) + return ECORE_CALLBACK_PASS_ON; + + if (!en->imf_context) return ECORE_CALLBACK_PASS_ON; + + if (en->imf_context != ev->ctx) return ECORE_CALLBACK_PASS_ON; + + ecore_imf_context_preedit_string_get(en->imf_context, &preedit_string, &cursor_pos); + if (!preedit_string) return ECORE_CALLBACK_PASS_ON; + + if (!strcmp(preedit_string, "")) + preedit_end_state = EINA_TRUE; + + if (en->have_selection && !preedit_end_state) + { + /* delete selected characters */ + _range_del(en->cursor, rp->object, en); + _sel_clear(en->cursor, rp->object, en); + } + + /* delete preedit characters */ + _preedit_del(en); + + preedit_start_pos = evas_textblock_cursor_pos_get(en->cursor); + + /* insert preedit character(s) */ + if ((rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD) && + _edje_password_show_last) + { + _text_filter_format_prepend(en, en->cursor, "+ password=off"); + _text_filter_markup_prepend(en, en->cursor, preedit_string); + _text_filter_format_prepend(en, en->cursor, "- password"); + if (en->pw_timer) + { + ecore_timer_del(en->pw_timer); + en->pw_timer = NULL; + } + en->pw_timer = ecore_timer_add(_edje_password_show_last_timeout, + _password_timer_cb, en); + } + else + { + _text_filter_markup_prepend(en, en->cursor, preedit_string); + } + + if (!preedit_end_state) + { + /* set preedit start cursor */ + if (!en->preedit_start) + en->preedit_start = evas_object_textblock_cursor_new(rp->object); + evas_textblock_cursor_copy(en->cursor, en->preedit_start); + + /* set preedit end cursor */ + if (!en->preedit_end) + en->preedit_end = evas_object_textblock_cursor_new(rp->object); + evas_textblock_cursor_copy(en->cursor, en->preedit_end); + + preedit_end_pos = evas_textblock_cursor_pos_get(en->cursor); + + for (i = 0; i < (preedit_end_pos - preedit_start_pos); i++) + { + evas_textblock_cursor_char_prev(en->preedit_start); + } + + en->have_preedit = EINA_TRUE; + + /* set cursor position */ + evas_textblock_cursor_pos_set(en->cursor, preedit_start_pos + cursor_pos); + } + + _edje_entry_imf_cursor_info_set(en); + _anchors_get(en->cursor, rp->object, en); + _edje_emit(rp->edje, "preedit,changed", rp->part->name); + _edje_emit(ed, "cursor,changed", rp->part->name); + + free(preedit_string); + + return ECORE_CALLBACK_DONE; +} + +static Eina_Bool +_edje_entry_imf_event_delete_surrounding_cb(void *data, int type __UNUSED__, void *event) +{ + Edje *ed = data; + Edje_Real_Part *rp = ed->focused_part; + Entry *en; + Ecore_IMF_Event_Delete_Surrounding *ev = event; + Evas_Textblock_Cursor *del_start, *del_end; + int cursor_pos; + + if ((!rp) || (!ev)) return ECORE_CALLBACK_PASS_ON; + en = rp->entry_data; + if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) || + (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE)) + return ECORE_CALLBACK_PASS_ON; + + if (!en->imf_context) return ECORE_CALLBACK_PASS_ON; + if (en->imf_context != ev->ctx) return ECORE_CALLBACK_PASS_ON; + + cursor_pos = evas_textblock_cursor_pos_get(en->cursor); + + del_start = evas_object_textblock_cursor_new(en->rp->object); + evas_textblock_cursor_pos_set(del_start, cursor_pos + ev->offset); + + del_end = evas_object_textblock_cursor_new(en->rp->object); + evas_textblock_cursor_pos_set(del_end, cursor_pos + ev->offset + ev->n_chars); + + evas_textblock_cursor_range_delete(del_start, del_end); + + evas_textblock_cursor_free(del_start); + evas_textblock_cursor_free(del_end); + + return ECORE_CALLBACK_DONE; +} +#endif + +/* 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 @@ +#include "edje_private.h" + +static Eina_Hash *type_registry = NULL; +static int init_count = 0; + +EAPI const char * +edje_external_param_type_str(Edje_External_Param_Type type) +{ + switch (type) + { + case EDJE_EXTERNAL_PARAM_TYPE_INT: + return "INT"; + case EDJE_EXTERNAL_PARAM_TYPE_DOUBLE: + return "DOUBLE"; + case EDJE_EXTERNAL_PARAM_TYPE_STRING: + return "STRING"; + case EDJE_EXTERNAL_PARAM_TYPE_BOOL: + return "BOOL"; + case EDJE_EXTERNAL_PARAM_TYPE_CHOICE: + return "CHOICE"; + default: + return "(unknown)"; + } +} + +EAPI Evas_Object * +edje_object_part_external_object_get(const Evas_Object *obj, const char *part) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return NULL; + + /* Need to recalc before providing the object. */ + _edje_recalc_do(ed); + + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp) + { + ERR("no part '%s'", part); + return NULL; + } + if (rp->part->type != EDJE_PART_TYPE_EXTERNAL) + { + ERR("cannot get external object of a part '%s' that is not EXTERNAL", + rp->part->name); + return NULL; + } + return rp->swallowed_object; +} + +EAPI Eina_Bool +edje_object_part_external_param_set(Evas_Object *obj, const char *part, const Edje_External_Param *param) +{ + Edje *ed; + Edje_Real_Part *rp; + + if ((!param) || (!param->name)) return EINA_FALSE; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return EINA_FALSE; + + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp) + { + ERR("no part '%s'", part); + return EINA_FALSE; + } + + return _edje_external_param_set(obj, rp, param); +} + +EAPI Eina_Bool +edje_object_part_external_param_get(const Evas_Object *obj, const char *part, Edje_External_Param *param) +{ + Edje *ed; + Edje_Real_Part *rp; + + if ((!param) || (!param->name)) return EINA_FALSE; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return EINA_FALSE; + + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp) + { + ERR("no part '%s'", part); + return EINA_FALSE; + } + + return _edje_external_param_get(obj, rp, param); +} + + + +EAPI Evas_Object * +edje_object_part_external_content_get(const Evas_Object *obj, const char *part, const char *content) +{ + Edje *ed; + Edje_Real_Part *rp; + + if (!content) return EINA_FALSE; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return EINA_FALSE; + + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp) + { + ERR("no part '%s'", part); + return EINA_FALSE; + } + + return _edje_external_content_get(rp->swallowed_object, content); +} + +EAPI Edje_External_Param_Type +edje_object_part_external_param_type_get(const Evas_Object *obj, const char *part, const char *param) +{ + Edje *ed; + Edje_Real_Part *rp; + Edje_External_Type *type; + Edje_External_Param_Info *info; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return EDJE_EXTERNAL_PARAM_TYPE_MAX; + + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp) + { + ERR("no part '%s'", part); + return EDJE_EXTERNAL_PARAM_TYPE_MAX; + } + type = evas_object_data_get(rp->swallowed_object, "Edje_External_Type"); + if (!type) + { + ERR("no external type for object %p", obj); + return EDJE_EXTERNAL_PARAM_TYPE_MAX; + } + if (!type->parameters_info) + { + ERR("no parameters information for external type '%s'", + type->module_name); + return EDJE_EXTERNAL_PARAM_TYPE_MAX; + } + for (info = type->parameters_info; info->name; info++) + if (strcmp(info->name, param) == 0) + return info->type; + + ERR("no parameter '%s' external type '%s'", param, type->module_name); + return EDJE_EXTERNAL_PARAM_TYPE_MAX; +} + + +EAPI Eina_Bool +edje_external_type_register(const char *type_name, const Edje_External_Type *type_info) +{ + if (!type_name) + return EINA_FALSE; + if (!type_info) + return EINA_FALSE; + + if (type_info->abi_version != EDJE_EXTERNAL_TYPE_ABI_VERSION) + { + ERR("external type '%s' (%p) has incorrect abi version. " + "got %#x where %#x was expected.", + type_name, type_info, + type_info->abi_version, EDJE_EXTERNAL_TYPE_ABI_VERSION); + return EINA_FALSE; + } + + if (eina_hash_find(type_registry, type_name)) + { + ERR("External type '%s' already registered", type_name); + return EINA_FALSE; + } + return eina_hash_add(type_registry, type_name, type_info); +} + +EAPI Eina_Bool +edje_external_type_unregister(const char *type_name) +{ + if (!type_name) + return EINA_FALSE; + return eina_hash_del_by_key(type_registry, type_name); +} + +EAPI void +edje_external_type_array_register(const Edje_External_Type_Info *array) +{ + const Edje_External_Type_Info *itr; + + if (!array) + return; + + for (itr = array; itr->name; itr++) + { + if (itr->info->abi_version != EDJE_EXTERNAL_TYPE_ABI_VERSION) + { + ERR("external type '%s' (%p) has incorrect abi " + "version. got %#x where %#x was expected.", + itr->name, itr->info, + itr->info->abi_version, EDJE_EXTERNAL_TYPE_ABI_VERSION); + continue; + } + + eina_hash_direct_add(type_registry, itr->name, itr->info); + } +} + +EAPI void +edje_external_type_array_unregister(const Edje_External_Type_Info *array) +{ + const Edje_External_Type_Info *itr; + + if (!array) + return; + + for (itr = array; itr->name; itr++) + eina_hash_del(type_registry, itr->name, itr->info); +} + +EAPI unsigned int +edje_external_type_abi_version_get(void) +{ + return EDJE_EXTERNAL_TYPE_ABI_VERSION; +} + +EAPI Eina_Iterator * +edje_external_iterator_get(void) +{ + return eina_hash_iterator_tuple_new(type_registry); +} + +EAPI Edje_External_Param * +edje_external_param_find(const Eina_List *params, const char *key) +{ + const Eina_List *l; + Edje_External_Param *param; + + EINA_LIST_FOREACH(params, l, param) + if (!strcmp(param->name, key)) return param; + + return NULL; +} + +EAPI Eina_Bool +edje_external_param_int_get(const Eina_List *params, const char *key, int *ret) +{ + Edje_External_Param *param; + + if (!params) return EINA_FALSE; + param = edje_external_param_find(params, key); + + if (param && param->type == EDJE_EXTERNAL_PARAM_TYPE_INT && ret) + { + *ret = param->i; + return EINA_TRUE; + } + + return EINA_FALSE; +} + +EAPI Eina_Bool +edje_external_param_double_get(const Eina_List *params, const char *key, double *ret) +{ + Edje_External_Param *param; + + if (!params) return EINA_FALSE; + param = edje_external_param_find(params, key); + + if (param && param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE && ret) + { + *ret = param->d; + return EINA_TRUE; + } + + return EINA_FALSE; +} + +EAPI Eina_Bool +edje_external_param_string_get(const Eina_List *params, const char *key, const char **ret) +{ + Edje_External_Param *param; + + if (!params) return EINA_FALSE; + param = edje_external_param_find(params, key); + + if (param && param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING && ret) + { + *ret = param->s; + return EINA_TRUE; + } + + return EINA_FALSE; +} + +EAPI Eina_Bool +edje_external_param_bool_get(const Eina_List *params, const char *key, Eina_Bool *ret) +{ + Edje_External_Param *param; + + if (!params) return EINA_FALSE; + param = edje_external_param_find(params, key); + + if (param && param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL && ret) + { + *ret = param->i; + return EINA_TRUE; + } + + return EINA_FALSE; +} + +EAPI Eina_Bool +edje_external_param_choice_get(const Eina_List *params, const char *key, const char **ret) +{ + Edje_External_Param *param; + + if (!params) return EINA_FALSE; + param = edje_external_param_find(params, key); + + if (param && param->type == EDJE_EXTERNAL_PARAM_TYPE_CHOICE && ret) + { + *ret = param->s; + return EINA_TRUE; + } + + return EINA_FALSE; +} + +EAPI const Edje_External_Param_Info * +edje_external_param_info_get(const char *type_name) +{ + Edje_External_Type *type; + + type = eina_hash_find(type_registry, type_name); + if (!type) + return NULL; + return type->parameters_info; +} + +EAPI const Edje_External_Type * +edje_external_type_get(const char *type_name) +{ + return eina_hash_find(type_registry, type_name); +} + +void +_edje_external_init() +{ + if (!type_registry) + type_registry = eina_hash_string_superfast_new(NULL); + + init_count++; +} + +void +_edje_external_shutdown() +{ + if (--init_count == 0) + { + eina_hash_free(type_registry); + type_registry = NULL; + } +} + +Evas_Object * +_edje_external_type_add(const char *type_name, Evas *evas, Evas_Object *parent, const Eina_List *params, const char *part_name) +{ + Edje_External_Type *type; + Evas_Object *obj; + + type = eina_hash_find(type_registry, type_name); + if (!type) + { + ERR("external type '%s' not registered", type_name); + return NULL; + } + + obj = type->add(type->data, evas, parent, params, part_name); + if (!obj) + { + ERR("External type '%s' returned NULL from constructor", type_name); + return NULL; + } + + evas_object_data_set(obj, "Edje_External_Type", type); + + return obj; +} + +void +_edje_external_signal_emit(Evas_Object *obj, const char *emission, const char *source) +{ + Edje_External_Type *type; + + type = evas_object_data_get(obj, "Edje_External_Type"); + if (!type) + { + ERR("External type data not found."); + return; + } + + type->signal_emit(type->data, obj, emission, source); +} + +Eina_Bool +_edje_external_param_set(Evas_Object *obj, Edje_Real_Part *rp, const Edje_External_Param *param) +{ + Evas_Object *swallowed_object = rp->swallowed_object; + Edje_External_Type *type = evas_object_data_get(swallowed_object, "Edje_External_Type"); + if (!type) + { + if ((rp->part->type == EDJE_PART_TYPE_TEXT) || + (rp->part->type == EDJE_PART_TYPE_TEXTBLOCK)) + { + if ((param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING) && + (!strcmp (param->name, "text")) && (obj)) + { + return edje_object_part_text_set(obj, rp->part->name, param->s); + } + } + + ERR("no external type for object %p", swallowed_object); + return EINA_FALSE; + } + if (!type->param_set) + { + ERR("external type '%s' from module '%s' does not provide param_set()", + type->module_name, type->module); + return EINA_FALSE; + } + return type->param_set(type->data, swallowed_object, param); +} + +Eina_Bool +_edje_external_param_get(const Evas_Object *obj, Edje_Real_Part *rp, Edje_External_Param *param) +{ + Evas_Object *swallowed_object = rp->swallowed_object; + Edje_External_Type *type = evas_object_data_get(swallowed_object, "Edje_External_Type"); + if (!type) + { + if ((rp->part->type == EDJE_PART_TYPE_TEXT) || + (rp->part->type == EDJE_PART_TYPE_TEXTBLOCK)) + { + const char *text; + param->type = EDJE_EXTERNAL_PARAM_TYPE_STRING; + param->name = "text"; + text = edje_object_part_text_get(obj, rp->part->name); + param->s = text; + return EINA_TRUE; + } + + ERR("no external type for object %p", swallowed_object); + return EINA_FALSE; + } + if (!type->param_get) + { + ERR("external type '%s' from module '%s' does not provide param_get()", + type->module_name, type->module); + return EINA_FALSE; + } + return type->param_get(type->data, swallowed_object, param); +} + +Evas_Object* +_edje_external_content_get(const Evas_Object *obj, const char *content) +{ + Edje_External_Type *type = evas_object_data_get(obj, "Edje_External_Type"); + if (!type) + { + ERR("no external type for object %p", obj); + return EINA_FALSE; + } + if (!type->content_get) + { + ERR("external type '%s' from module '%s' does not provide content_get()", + type->module_name, type->module); + return EINA_FALSE; + } + return type->content_get(type->data, obj, content); +} + +void +_edje_external_params_free(Eina_List *external_params, Eina_Bool free_strings) +{ + Edje_External_Param *param; + + EINA_LIST_FREE(external_params, param) + { + if (free_strings) + { + if (param->name) eina_stringshare_del(param->name); + if (param->s) eina_stringshare_del(param->s); + } + free(param); + } +} + +void +_edje_external_recalc_apply(Edje *ed __UNUSED__, Edje_Real_Part *ep, + Edje_Calc_Params *params __UNUSED__, + Edje_Part_Description_Common *chosen_desc __UNUSED__) +{ + Edje_External_Type *type; + Edje_Part_Description_External *ext; + void *params1, *params2 = NULL; + + if (!ep->swallowed_object) return; + type = evas_object_data_get(ep->swallowed_object, "Edje_External_Type"); + + if ((!type) || (!type->state_set)) return; + + ext = (Edje_Part_Description_External*) ep->param1.description; + + params1 = ep->param1.external_params ? + ep->param1.external_params : ext->external_params; + + if (ep->param2 && ep->param2->description) + { + ext = (Edje_Part_Description_External*) ep->param2->description; + + params2 = ep->param2->external_params ? + ep->param2->external_params : ext->external_params; + } + + type->state_set(type->data, ep->swallowed_object, + params1, params2, ep->description_pos); +} + +void * +_edje_external_params_parse(Evas_Object *obj, const Eina_List *params) +{ + Edje_External_Type *type; + + type = evas_object_data_get(obj, "Edje_External_Type"); + if (!type) return NULL; + + if (!type->params_parse) return NULL; + + return type->params_parse(type->data, obj, params); +} + +void +_edje_external_parsed_params_free(Evas_Object *obj, void *params) +{ + Edje_External_Type *type; + + if (!params) return; + + type = evas_object_data_get(obj, "Edje_External_Type"); + if (!type) return; + + if (!type->params_free) return; + + type->params_free(params); +} 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 @@ +#include "edje_private.h" + +#ifdef EDJE_PROGRAM_CACHE +static Eina_Bool _edje_collection_free_prog_cache_matches_free_cb(const Eina_Hash *hash, const void *key, void *data, void *fdata); +#endif +static void _edje_object_pack_item_hints_set(Evas_Object *obj, Edje_Pack_Element *it); +static void _cb_signal_repeat(void *data, Evas_Object *obj, const char *signal, const char *source); + +static Eina_List *_edje_swallows_collect(Edje *ed); + +/************************** API Routines **************************/ + +EAPI Eina_Bool +edje_object_file_set(Evas_Object *obj, const char *file, const char *group) +{ + Eina_Bool ret; + Edje *ed; + + ed = _edje_fetch(obj); + if (!ed) + return EINA_FALSE; + ret = ed->api->file_set(obj, file, group); + _edje_object_orientation_inform(obj); + return ret; +} + +EAPI void +edje_object_file_get(const Evas_Object *obj, const char **file, const char **group) +{ + Edje *ed; + + ed = _edje_fetch(obj); + if (!ed) + { + if (file) *file = NULL; + if (group) *group = NULL; + return; + } + if (file) *file = ed->path; + if (group) *group = ed->group; +} + +EAPI Edje_Load_Error +edje_object_load_error_get(const Evas_Object *obj) +{ + Edje *ed; + + ed = _edje_fetch(obj); + if (!ed) return EDJE_LOAD_ERROR_NONE; + return ed->load_error; +} + +EAPI const char * +edje_load_error_str(Edje_Load_Error error) +{ + switch (error) + { + case EDJE_LOAD_ERROR_NONE: + return "No Error"; + case EDJE_LOAD_ERROR_GENERIC: + return "Generic Error"; + case EDJE_LOAD_ERROR_DOES_NOT_EXIST: + return "File Does Not Exist"; + case EDJE_LOAD_ERROR_PERMISSION_DENIED: + return "Permission Denied"; + case EDJE_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED: + return "Resource Allocation Failed"; + case EDJE_LOAD_ERROR_CORRUPT_FILE: + return "Corrupt File"; + case EDJE_LOAD_ERROR_UNKNOWN_FORMAT: + return "Unknown Format"; + case EDJE_LOAD_ERROR_INCOMPATIBLE_FILE: + return "Incompatible File"; + case EDJE_LOAD_ERROR_UNKNOWN_COLLECTION: + return "Unknown Collection"; + case EDJE_LOAD_ERROR_RECURSIVE_REFERENCE: + return "Recursive Reference"; + default: + return "Unknown Error"; + } +} + + +EAPI Eina_List * +edje_file_collection_list(const char *file) +{ + Eina_List *lst = NULL; + Edje_File *edf; + int error_ret = 0; + + if ((!file) || (!*file)) return NULL; + edf = _edje_cache_file_coll_open(file, NULL, &error_ret, NULL); + if (edf) + { + Eina_Iterator *i; + const char *key; + + i = eina_hash_iterator_key_new(edf->collection); + + EINA_ITERATOR_FOREACH(i, key) + lst = eina_list_append(lst, eina_stringshare_add(key)); + + eina_iterator_free(i); + + _edje_cache_file_unref(edf); + } + return lst; +} + +EAPI void +edje_file_collection_list_free(Eina_List *lst) +{ + while (lst) + { + if (eina_list_data_get(lst)) eina_stringshare_del(eina_list_data_get(lst)); + lst = eina_list_remove(lst, eina_list_data_get(lst)); + } +} + +EAPI Eina_Bool +edje_file_group_exists(const char *file, const char *glob) +{ + Edje_File *edf; + int error_ret = 0; + Eina_Bool succeed = EINA_FALSE; + Eina_Bool is_glob = EINA_FALSE; + const char *p; + + if ((!file) || (!*file)) + return EINA_FALSE; + + edf = _edje_cache_file_coll_open(file, NULL, &error_ret, NULL); + if (!edf) + return EINA_FALSE; + + for (p = glob; *p; p++) + { + if ((*p == '*') || (*p == '?') || (*p == '[')) + { + is_glob = EINA_TRUE; + break; + } + } + + if (is_glob) + { + if (!edf->collection_patterns) + { + Edje_Part_Collection_Directory_Entry *ce; + Eina_Iterator *i; + Eina_List *l = NULL; + + i = eina_hash_iterator_data_new(edf->collection); + + EINA_ITERATOR_FOREACH(i, ce) + l = eina_list_append(l, ce); + + eina_iterator_free(i); + + edf->collection_patterns = edje_match_collection_dir_init(l); + eina_list_free(l); + } + + succeed = edje_match_collection_dir_exec(edf->collection_patterns, glob); + if (edf->collection_patterns) + { + edje_match_patterns_free(edf->collection_patterns); + edf->collection_patterns = NULL; + } + } + else + { + if (eina_hash_find(edf->collection, glob)) succeed = EINA_TRUE; + } + _edje_cache_file_unref(edf); + + INF("edje_file_group_exists: '%s', '%s': %i\n", file, glob, succeed); + + return succeed; +} + + +EAPI char * +edje_file_data_get(const char *file, const char *key) +{ + Edje_File *edf; + char *str = NULL; + int error_ret = 0; + + if (key) + { + edf = _edje_cache_file_coll_open(file, NULL, &error_ret, NULL); + if (edf) + { + str = (char*) edje_string_get(eina_hash_find(edf->data, key)); + + if (str) str = strdup(str); + + _edje_cache_file_unref(edf); + } + } + return str; +} + +void +_edje_programs_patterns_clean(Edje *ed) +{ + _edje_signals_sources_patterns_clean(&ed->patterns.programs); + + eina_rbtree_delete(ed->patterns.programs.exact_match, + EINA_RBTREE_FREE_CB(edje_match_signal_source_free), + NULL); + ed->patterns.programs.exact_match = NULL; + + free(ed->patterns.programs.u.programs.globing); + ed->patterns.programs.u.programs.globing = NULL; +} + +void +_edje_programs_patterns_init(Edje *ed) +{ + Edje_Signals_Sources_Patterns *ssp = &ed->patterns.programs; + Edje_Program **all; + unsigned int i, j; + + if (ssp->signals_patterns) + return; + + edje_match_program_hash_build(ed->collection->programs.strcmp, + ed->collection->programs.strcmp_count, + &ssp->exact_match); + + j = ed->collection->programs.strncmp_count + + ed->collection->programs.strrncmp_count + + ed->collection->programs.fnmatch_count + + ed->collection->programs.nocmp_count; + if (j == 0) return ; + + all = malloc(sizeof (Edje_Program *) * j); + if (!all) return ; + j = 0; + + /* FIXME: Build specialized data type for each case */ +#define EDJE_LOAD_PROGRAMS_ADD(Array, Ed, It, Git, All) \ + for (It = 0; It < Ed->collection->programs.Array##_count; ++It, ++Git) \ + All[Git] = Ed->collection->programs.Array[It]; + + EDJE_LOAD_PROGRAMS_ADD(fnmatch, ed, i, j, all); + EDJE_LOAD_PROGRAMS_ADD(strncmp, ed, i, j, all); + EDJE_LOAD_PROGRAMS_ADD(strrncmp, ed, i, j, all); + /* FIXME: Do a special pass for that one */ + EDJE_LOAD_PROGRAMS_ADD(nocmp, ed, i, j, all); + + ssp->u.programs.globing = all; + ssp->u.programs.count = j; + ssp->signals_patterns = edje_match_programs_signal_init(all, j); + ssp->sources_patterns = edje_match_programs_source_init(all, j); +} + +int +_edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *group, const char *parent, Eina_List *group_path) +{ + Edje *ed; + Evas *tev; + Eina_List *old_swallows; + unsigned int n; + Eina_List *parts = NULL; + int group_path_started = 0; + + ed = _edje_fetch(obj); + if (!ed) return 0; + if (!file) file = ""; + if (!group) group = ""; + if (((ed->path) && (!strcmp(file, ed->path))) && + (ed->group) && (!strcmp(group, ed->group))) + return 1; + + tev = evas_object_evas_get(obj); + evas_event_freeze(tev); + old_swallows = _edje_swallows_collect(ed); + + if (_edje_script_only(ed)) _edje_script_only_shutdown(ed); + if (_edje_lua_script_only(ed)) _edje_lua_script_only_shutdown(ed); + _edje_file_del(ed); + + eina_stringshare_replace(&ed->path, file); + eina_stringshare_replace(&ed->group, group); + + ed->parent = eina_stringshare_add(parent); + + ed->load_error = EDJE_LOAD_ERROR_NONE; + _edje_file_add(ed); + + if (ed->file && ed->file->external_dir) + { + unsigned int i; + + for (i = 0; i < ed->file->external_dir->entries_count; ++i) + edje_module_load(ed->file->external_dir->entries[i].entry); + } + + _edje_textblock_styles_add(ed); + _edje_textblock_style_all_update(ed); + + ed->has_entries = EINA_FALSE; + + if (ed->collection) + { + if (ed->collection->prop.orientation != EDJE_ORIENTATION_AUTO) + ed->is_rtl = (ed->collection->prop.orientation == + EDJE_ORIENTATION_RTL); + + if (ed->collection->script_only) + { + ed->load_error = EDJE_LOAD_ERROR_NONE; + _edje_script_only_init(ed); + } + else if (ed->collection->lua_script_only) + { + ed->load_error = EDJE_LOAD_ERROR_NONE; + _edje_lua_script_only_init(ed); + } + else + { + unsigned int i; + int errors = 0; + + /* colorclass stuff */ + for (i = 0; i < ed->collection->parts_count; ++i) + { + Edje_Part *ep; + unsigned int k; + + ep = ed->collection->parts[i]; + + if (errors) + break; + /* Register any color classes in this parts descriptions. */ + if ((ep->default_desc) && (ep->default_desc->color_class)) + _edje_color_class_member_add(ed, ep->default_desc->color_class); + + for (k = 0; k < ep->other.desc_count; k++) + { + Edje_Part_Description_Common *desc; + + desc = ep->other.desc[k]; + + if (desc->color_class) + _edje_color_class_member_add(ed, desc->color_class); + } + } + /* build real parts */ + for (n = 0; n < ed->collection->parts_count; n++) + { + Edje_Part *ep; + Edje_Real_Part *rp; + + ep = ed->collection->parts[n]; + rp = eina_mempool_malloc(_edje_real_part_mp, sizeof(Edje_Real_Part)); + if (!rp) + { + ed->load_error = EDJE_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED; + evas_event_thaw(tev); + evas_event_thaw_eval(tev); + return 0; + } + + memset(rp, 0, sizeof (Edje_Real_Part)); + + if ((ep->dragable.x != 0) || (ep->dragable.y != 0)) + { + rp->drag = calloc(1, sizeof (Edje_Real_Part_Drag)); + if (!rp->drag) + { + ed->load_error = EDJE_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED; + free(rp); + evas_event_thaw(tev); + evas_event_thaw_eval(tev); + return 0; + } + + rp->drag->step.x = FROM_INT(ep->dragable.step_x); + rp->drag->step.y = FROM_INT(ep->dragable.step_y); + } + + rp->edje = ed; + _edje_ref(rp->edje); + rp->part = ep; + parts = eina_list_append(parts, rp); + rp->param1.description = + _edje_part_description_find(ed, rp, "default", 0.0); + rp->chosen_description = rp->param1.description; + if (!rp->param1.description) + ERR("no default part description!"); + + switch (ep->type) + { + case EDJE_PART_TYPE_RECTANGLE: + rp->object = evas_object_rectangle_add(ed->base.evas); + break; + case EDJE_PART_TYPE_PROXY: + case EDJE_PART_TYPE_IMAGE: + rp->object = evas_object_image_add(ed->base.evas); + break; + case EDJE_PART_TYPE_TEXT: + _edje_text_part_on_add(ed, rp); + rp->object = evas_object_text_add(ed->base.evas); + evas_object_text_font_source_set(rp->object, ed->path); + break; + case EDJE_PART_TYPE_SWALLOW: + case EDJE_PART_TYPE_GROUP: + case EDJE_PART_TYPE_EXTERNAL: + rp->object = evas_object_rectangle_add(ed->base.evas); + evas_object_color_set(rp->object, 0, 0, 0, 0); + evas_object_pass_events_set(rp->object, 1); + evas_object_pointer_mode_set(rp->object, EVAS_OBJECT_POINTER_MODE_NOGRAB); + _edje_callbacks_focus_add(rp->object, ed, rp); + break; + case EDJE_PART_TYPE_TEXTBLOCK: + rp->object = evas_object_textblock_add(ed->base.evas); + break; + case EDJE_PART_TYPE_BOX: + rp->object = evas_object_box_add(ed->base.evas); + rp->anim = _edje_box_layout_anim_new(rp->object); + break; + case EDJE_PART_TYPE_TABLE: + rp->object = evas_object_table_add(ed->base.evas); + break; + case EDJE_PART_TYPE_GRADIENT: + ERR("SPANK ! SPANK ! SPANK ! YOU ARE USING GRADIENT IN PART %s FROM GROUP %s INSIDE FILE %s !! THEY ARE NOW REMOVED !", + ep->name, group, file); + default: + ERR("wrong part type %i!", ep->type); + break; + } + + if (rp->object) + { + evas_object_smart_member_add(rp->object, ed->obj); +// evas_object_layer_set(rp->object, evas_object_layer_get(ed->obj)); + if (ep->type != EDJE_PART_TYPE_SWALLOW && ep->type != EDJE_PART_TYPE_GROUP && ep->type != EDJE_PART_TYPE_EXTERNAL) + { + if (ep->mouse_events) + { + _edje_callbacks_add(rp->object, ed, rp); + if (ep->repeat_events) + evas_object_repeat_events_set(rp->object, 1); + + if (ep->pointer_mode != EVAS_OBJECT_POINTER_MODE_AUTOGRAB) + evas_object_pointer_mode_set(rp->object, ep->pointer_mode); + } + else + { + evas_object_pass_events_set(rp->object, 1); + evas_object_pointer_mode_set(rp->object, EVAS_OBJECT_POINTER_MODE_NOGRAB); + } + if (ep->precise_is_inside) + evas_object_precise_is_inside_set(rp->object, 1); + } + if (rp->part->clip_to_id < 0) + evas_object_clip_set(rp->object, ed->base.clipper); + } + } + if (n > 0) + { + Edje_Real_Part *rp; + Eina_List *l; + + ed->table_parts = malloc(sizeof(Edje_Real_Part *) * n); + ed->table_parts_size = n; + /* FIXME: check malloc return */ + n = 0; + EINA_LIST_FOREACH(parts, l, rp) + { + ed->table_parts[n] = rp; + n++; + } + eina_list_free(parts); + for (i = 0; i < ed->table_parts_size; i++) + { + rp = ed->table_parts[i]; + if (rp->param1.description) /* FIXME: prevent rel to gone radient part to go wrong. You may + be able to remove this when all theme are correctly rewritten. */ + { + if (rp->param1.description->rel1.id_x >= 0) + rp->param1.rel1_to_x = ed->table_parts[rp->param1.description->rel1.id_x % ed->table_parts_size]; + if (rp->param1.description->rel1.id_y >= 0) + rp->param1.rel1_to_y = ed->table_parts[rp->param1.description->rel1.id_y % ed->table_parts_size]; + if (rp->param1.description->rel2.id_x >= 0) + rp->param1.rel2_to_x = ed->table_parts[rp->param1.description->rel2.id_x % ed->table_parts_size]; + if (rp->param1.description->rel2.id_y >= 0) + rp->param1.rel2_to_y = ed->table_parts[rp->param1.description->rel2.id_y % ed->table_parts_size]; + } + if (rp->part->clip_to_id >= 0) + { + rp->clip_to = ed->table_parts[rp->part->clip_to_id % ed->table_parts_size]; + if (rp->clip_to) + { + evas_object_pass_events_set(rp->clip_to->object, 1); + evas_object_pointer_mode_set(rp->clip_to->object, EVAS_OBJECT_POINTER_MODE_NOGRAB); + evas_object_clip_set(rp->object, rp->clip_to->object); + } + } + if (rp->drag) + { + if (rp->part->dragable.confine_id >= 0) + rp->drag->confine_to = ed->table_parts[rp->part->dragable.confine_id % ed->table_parts_size]; + } + + /* replay events for dragable */ + if (rp->part->dragable.event_id >= 0) + { + rp->events_to = + ed->table_parts[rp->part->dragable.event_id % ed->table_parts_size]; + /* events_to may be used only with dragable */ + if (!rp->events_to->part->dragable.x && + !rp->events_to->part->dragable.y) + rp->events_to = NULL; + } + + rp->swallow_params.min.w = 0; + rp->swallow_params.min.w = 0; + rp->swallow_params.max.w = -1; + rp->swallow_params.max.h = -1; + + if (rp->part->type == EDJE_PART_TYPE_TEXT + || rp->part->type == EDJE_PART_TYPE_TEXTBLOCK) + { + Edje_Part_Description_Text *text; + + text = (Edje_Part_Description_Text *) rp->param1.description; + + if (ed->file->feature_ver < 1) + { + text->text.id_source = -1; + text->text.id_text_source = -1; + } + + if (text->text.id_source >= 0) + rp->text.source = ed->table_parts[text->text.id_source % ed->table_parts_size]; + if (text->text.id_text_source >= 0) + rp->text.text_source = ed->table_parts[text->text.id_text_source % ed->table_parts_size]; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + { + _edje_entry_real_part_init(rp); + if (!ed->has_entries) + ed->has_entries = EINA_TRUE; + } + } + } + } + + _edje_programs_patterns_init(ed); + + n = ed->collection->programs.fnmatch_count + + ed->collection->programs.strcmp_count + + ed->collection->programs.strncmp_count + + ed->collection->programs.strrncmp_count + + ed->collection->programs.nocmp_count; + if (n > 0) + { + Edje_Program *pr; + + ed->table_programs = malloc(sizeof(Edje_Program *) * n); + if (ed->table_programs) + { + ed->table_programs_size = n; + +#define EDJE_LOAD_BUILD_TABLE(Array, Ed, It, Tmp) \ + for (It = 0; It < Ed->collection->programs.Array##_count; ++It) \ + { \ + Tmp = Ed->collection->programs.Array[It]; \ + Ed->table_programs[Tmp->id] = Tmp; \ + } + + EDJE_LOAD_BUILD_TABLE(fnmatch, ed, i, pr); + EDJE_LOAD_BUILD_TABLE(strcmp, ed, i, pr); + EDJE_LOAD_BUILD_TABLE(strncmp, ed, i, pr); + EDJE_LOAD_BUILD_TABLE(strrncmp, ed, i, pr); + EDJE_LOAD_BUILD_TABLE(nocmp, ed, i, pr); + } + } + _edje_ref(ed); + _edje_block(ed); + _edje_freeze(ed); +// if (ed->collection->script) _edje_embryo_script_init(ed); + _edje_var_init(ed); + for (i = 0; i < ed->table_parts_size; i++) + { + Edje_Real_Part *rp; + + rp = ed->table_parts[i]; + evas_object_show(rp->object); + if (_edje_block_break(ed)) break; + if (rp->drag) + { + if (rp->part->dragable.x < 0) rp->drag->val.x = FROM_DOUBLE(1.0); + if (rp->part->dragable.y < 0) rp->drag->val.x = FROM_DOUBLE(1.0); + _edje_dragable_pos_set(ed, rp, rp->drag->val.x, rp->drag->val.y); + } + } + ed->dirty = 1; +#ifdef EDJE_CALC_CACHE + ed->all_part_change = 1; +#endif + if ((evas_object_clipees_get(ed->base.clipper)) && + (evas_object_visible_get(obj))) + evas_object_show(ed->base.clipper); + + /* instantiate 'internal swallows' */ + for (i = 0; i < ed->table_parts_size; i++) + { + Edje_Real_Part *rp; + /* XXX: curr_item and pack_it don't require to be NULL since + * XXX: they are just used when source != NULL and type == BOX, + * XXX: and they're always set in this case, but GCC fails to + * XXX: notice that, so let's shut it up + */ + Edje_Pack_Element **curr_item = NULL; + unsigned int item_count = 0; + Edje_Pack_Element *pack_it = NULL; + const char *source = NULL; + + rp = ed->table_parts[i]; + + switch (rp->part->type) + { + case EDJE_PART_TYPE_GROUP: + source = rp->part->source; + break; + case EDJE_PART_TYPE_BOX: + case EDJE_PART_TYPE_TABLE: + if (rp->part->items) + { + curr_item = rp->part->items; + item_count = rp->part->items_count; + if (item_count > 0) + { + pack_it = *curr_item; + source = pack_it->source; + item_count--; + curr_item++; + } + } + break; + case EDJE_PART_TYPE_EXTERNAL: + { + Edje_Part_Description_External *external; + Evas_Object *child_obj; + + external = (Edje_Part_Description_External *) rp->part->default_desc; + child_obj = _edje_external_type_add(rp->part->source, + evas_object_evas_get(ed->obj), ed->obj, + external->external_params, rp->part->name); + if (child_obj) + { + _edje_real_part_swallow(rp, child_obj, EINA_TRUE); + rp->param1.external_params = _edje_external_params_parse(child_obj, + external->external_params); + _edje_external_recalc_apply(ed, rp, NULL, rp->chosen_description); + } + } + continue; + default: + continue; + } + + while (source) + { + Eina_List *l; + Evas_Object *child_obj; + const char *group_path_entry = eina_stringshare_add(source); + const char *data; + + if (!group_path) + { + group_path = eina_list_append(NULL, eina_stringshare_add(group)); + group_path_started = 1; + } + /* make sure that this group isn't already in the tree of parents */ + EINA_LIST_FOREACH(group_path, l, data) + { + if (data == group_path_entry) + { + _edje_thaw(ed); + _edje_unblock(ed); + _edje_unref(ed); + _edje_file_del(ed); + eina_stringshare_del(group_path_entry); + if (group_path_started) + { + eina_stringshare_del(eina_list_data_get(group_path)); + eina_list_free(group_path); + } + ed->load_error = EDJE_LOAD_ERROR_RECURSIVE_REFERENCE; + evas_event_thaw(tev); + evas_event_thaw_eval(tev); + return 0; + } + } + + child_obj = edje_object_add(ed->base.evas); + group_path = eina_list_append(group_path, group_path_entry); + if (rp->part->type == EDJE_PART_TYPE_GROUP) + { + _edje_real_part_swallow(rp, child_obj, EINA_FALSE); + } + + if (!_edje_object_file_set_internal(child_obj, file, source, rp->part->name, group_path)) + { + _edje_thaw(ed); + _edje_unblock(ed); + _edje_unref(ed); + _edje_file_del(ed); + + if (group_path_started) + { + while (group_path) + { + eina_stringshare_del(eina_list_data_get(group_path)); + group_path = eina_list_remove_list(group_path, group_path); + } + } + ed->load_error = edje_object_load_error_get(child_obj); + evas_object_del(child_obj); + evas_event_thaw(tev); + evas_event_thaw_eval(tev); + return 0; + } + + group_path = eina_list_remove(group_path, group_path_entry); + eina_stringshare_del(group_path_entry); + + edje_object_propagate_callback_add(child_obj, + _cb_signal_repeat, + obj); + if (rp->part->type == EDJE_PART_TYPE_GROUP) + { + _edje_real_part_swallow(rp, child_obj, EINA_TRUE); + _edje_subobj_register(ed, child_obj); + source = NULL; + } + else + { + pack_it->parent = rp; + + _edje_object_pack_item_hints_set(child_obj, pack_it); + if (pack_it->name) + evas_object_name_set(child_obj, pack_it->name); + + if (rp->part->type == EDJE_PART_TYPE_BOX) + { + _edje_real_part_box_append(rp, child_obj); + evas_object_data_set(child_obj, "\377 edje.box_item", pack_it); + } + else if (rp->part->type == EDJE_PART_TYPE_TABLE) + { + _edje_real_part_table_pack(rp, child_obj, pack_it->col, pack_it->row, pack_it->colspan, pack_it->rowspan); + evas_object_data_set(child_obj, "\377 edje.table_item", pack_it); + } + _edje_subobj_register(ed, child_obj); + evas_object_show(child_obj); + rp->items = eina_list_append(rp->items, child_obj); + + if (item_count > 0) + { + pack_it = *curr_item; + source = pack_it->source; + curr_item++; + item_count--; + } + else + { + source = NULL; + curr_item = NULL; + pack_it = NULL; + } + } + } + } + + if (group_path_started) + { + const char *str; + + EINA_LIST_FREE(group_path, str) + eina_stringshare_del(str); + } + + /* reswallow any swallows that existed before setting the file */ + if (old_swallows) + { + while (old_swallows) + { + const char *name; + Evas_Object *swallow; + + name = eina_list_data_get(old_swallows); + old_swallows = eina_list_remove_list(old_swallows, old_swallows); + + swallow = eina_list_data_get(old_swallows); + old_swallows = eina_list_remove_list(old_swallows, old_swallows); + + edje_object_part_swallow(obj, name, swallow); + eina_stringshare_del(name); + } + } + + _edje_recalc(ed); + _edje_thaw(ed); + _edje_unblock(ed); + _edje_unref(ed); + ed->load_error = EDJE_LOAD_ERROR_NONE; + _edje_emit(ed, "load", NULL); + /* instantiate 'internal swallows' */ + for (i = 0; i < ed->table_parts_size; i++) + { + Edje_Real_Part *rp; + + rp = ed->table_parts[i]; + if ((rp->part->type == EDJE_PART_TYPE_TEXTBLOCK) && + (rp->part->default_desc)) + { + Edje_Part_Description_Text *text; + Edje_Style *stl = NULL; + const char *style; + + text = (Edje_Part_Description_Text *) rp->part->default_desc; + style = edje_string_get(&text->text.style); + if (style) + { + Eina_List *l; + + EINA_LIST_FOREACH(ed->file->styles, l, stl) + { + if ((stl->name) && (!strcmp(stl->name, style))) break; + stl = NULL; + } + } + if (stl) + { + if (evas_object_textblock_style_get(rp->object) != stl->style) + evas_object_textblock_style_set(rp->object, stl->style); + } + } + } + } + _edje_entry_init(ed); + evas_event_thaw(tev); + evas_event_thaw_eval(tev); + return 1; + } + else + { + evas_event_thaw(tev); + evas_event_thaw_eval(tev); + return 0; + } + ed->load_error = EDJE_LOAD_ERROR_NONE; + _edje_entry_init(ed); + evas_event_thaw(tev); + evas_event_thaw_eval(tev); + return 1; +} + +void +_edje_file_add(Edje *ed) +{ + if (!_edje_edd_edje_file) return; + ed->file = _edje_cache_file_coll_open(ed->path, ed->group, + &(ed->load_error), + &(ed->collection)); + + if (!ed->collection) + { + if (ed->file) + { + _edje_cache_file_unref(ed->file); + ed->file = NULL; + } + } +} + +static Eina_List * +_edje_swallows_collect(Edje *ed) +{ + Eina_List *swallows = NULL; + unsigned int i; + + if (!ed->file || !ed->table_parts) return NULL; + for (i = 0; i < ed->table_parts_size; i++) + { + Edje_Real_Part *rp; + + rp = ed->table_parts[i]; + if (rp->part->type != EDJE_PART_TYPE_SWALLOW || !rp->swallowed_object) continue; + swallows = eina_list_append(swallows, eina_stringshare_add(rp->part->name)); + swallows = eina_list_append(swallows, rp->swallowed_object); + } + return swallows; +} + +void +_edje_file_del(Edje *ed) +{ + Evas *tev = evas_object_evas_get(ed->obj); + + evas_event_freeze(tev); + if (ed->freeze_calc) + { + _edje_freeze_calc_list = eina_list_remove(_edje_freeze_calc_list, ed); + ed->freeze_calc = 0; + _edje_freeze_calc_count--; + } + _edje_entry_shutdown(ed); + _edje_message_del(ed); + _edje_block_violate(ed); + _edje_var_shutdown(ed); + _edje_programs_patterns_clean(ed); +// if (ed->collection) +// { +// if (ed->collection->script) _edje_embryo_script_shutdown(ed); +// } + + if (!((ed->file) && (ed->collection))) + { + evas_event_thaw(tev); + evas_event_thaw_eval(tev); + return; + } + if (ed->table_parts) + { + unsigned int i; + for (i = 0; i < ed->table_parts_size; i++) + { + Edje_Real_Part *rp; + + rp = ed->table_parts[i]; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + _edje_entry_real_part_shutdown(rp); + if (rp->object) + { + _edje_callbacks_del(rp->object, ed); + _edje_callbacks_focus_del(rp->object, ed); + evas_object_del(rp->object); + } + if (rp->swallowed_object) + { + _edje_real_part_swallow_clear(rp); + /* Objects swallowed by the app do not get deleted, + but those internally swallowed (GROUP type) do. */ + switch (rp->part->type) + { + case EDJE_PART_TYPE_EXTERNAL: + _edje_external_parsed_params_free(rp->swallowed_object, rp->param1.external_params); + if (rp->param2) + _edje_external_parsed_params_free(rp->swallowed_object, rp->param2->external_params); + case EDJE_PART_TYPE_GROUP: + evas_object_del(rp->swallowed_object); + default: + break; + } + rp->swallowed_object = NULL; + } + if (rp->items) + { + /* evas_box/table handles deletion of objects */ + rp->items = eina_list_free(rp->items); + } + if (rp->anim) + { + _edje_box_layout_free_data(rp->anim); + rp->anim = NULL; + } + if (rp->text.text) eina_stringshare_del(rp->text.text); + if (rp->text.font) eina_stringshare_del(rp->text.font); + if (rp->text.cache.in_str) eina_stringshare_del(rp->text.cache.in_str); + if (rp->text.cache.out_str) eina_stringshare_del(rp->text.cache.out_str); + + if (rp->custom) + { + // xxx: lua2 + _edje_collection_free_part_description_clean(rp->part->type, + rp->custom->description, + ed->file->free_strings); + free(rp->custom->description); + rp->custom->description = NULL; + } + + /* Cleanup optional part. */ + free(rp->drag); + free(rp->param1.set); + + if (rp->param2) + free(rp->param2->set); + eina_mempool_free(_edje_real_part_state_mp, rp->param2); + + if (rp->custom) + free(rp->custom->set); + eina_mempool_free(_edje_real_part_state_mp, rp->custom); + + _edje_unref(rp->edje); + eina_mempool_free(_edje_real_part_mp, rp); + } + } + if ((ed->file) && (ed->collection)) + { + Edje_Part *ep; + unsigned int i; + + _edje_textblock_styles_del(ed); + for (i = 0; i < ed->collection->parts_count; ++i) + { + ep = ed->collection->parts[i]; + + _edje_text_part_on_del(ed, ep); + _edje_color_class_on_del(ed, ep); + } + + _edje_cache_coll_unref(ed->file, ed->collection); + ed->collection = NULL; + } + if (ed->file) + { + _edje_cache_file_unref(ed->file); + ed->file = NULL; + } + if (ed->actions) + { + Edje_Running_Program *runp; + + EINA_LIST_FREE(ed->actions, runp) + { + _edje_anim_count--; + free(runp); + } + } + _edje_animators = eina_list_remove(_edje_animators, ed); + if (ed->pending_actions) + { + Edje_Pending_Program *pp; + + EINA_LIST_FREE(ed->pending_actions, pp) + { + ecore_timer_del(pp->timer); + free(pp); + } + } + if (ed->L) _edje_lua2_script_shutdown(ed); + while (ed->subobjs) evas_object_del(ed->subobjs->data); + if (ed->table_parts) free(ed->table_parts); + ed->table_parts = NULL; + ed->table_parts_size = 0; + if (ed->table_programs) free(ed->table_programs); + ed->table_programs = NULL; + ed->table_programs_size = 0; + ed->focused_part = NULL; + evas_event_thaw(tev); + evas_event_thaw_eval(tev); +} + +void +_edje_file_free(Edje_File *edf) +{ + Edje_Color_Class *ecc; + +#define HASH_FREE(Hash) \ + if (Hash) eina_hash_free(Hash); \ + Hash = NULL; + + /* Clean cache before cleaning memory pool */ + if (edf->collection_cache) _edje_cache_coll_flush(edf); + + HASH_FREE(edf->fonts); + HASH_FREE(edf->collection); + HASH_FREE(edf->data); + + if (edf->image_dir) + { + unsigned int i; + + if (edf->free_strings) + { + for (i = 0; i < edf->image_dir->entries_count; ++i) + eina_stringshare_del(edf->image_dir->entries[i].entry); + } + + /* Sets have been added after edje received eet dictionnary support */ + for (i = 0; i < edf->image_dir->sets_count; ++i) + { + Edje_Image_Directory_Set_Entry *se; + + EINA_LIST_FREE(edf->image_dir->sets[i].entries, se) + free(se); + + } + + free(edf->image_dir->entries); + free(edf->image_dir->sets); + free(edf->image_dir); + } + if (edf->sound_dir) + { + unsigned int i; + + if (edf->free_strings) + { + for (i = 0; i < edf->sound_dir->samples_count; ++i) + { + eina_stringshare_del(edf->sound_dir->samples[i].name); + eina_stringshare_del(edf->sound_dir->samples[i].snd_src); + } + + for (i = 0; i < edf->sound_dir->tones_count; ++i) + eina_stringshare_del(edf->sound_dir->tones[i].name); + } + free(edf->sound_dir->samples); + free(edf->sound_dir->tones); + free(edf->sound_dir); + } + + if (edf->external_dir) + { + if (edf->external_dir->entries) free(edf->external_dir->entries); + free(edf->external_dir); + } + + EINA_LIST_FREE(edf->color_classes, ecc) + { + if (edf->free_strings && ecc->name) eina_stringshare_del(ecc->name); + free(ecc); + } + + if (edf->collection_patterns) edje_match_patterns_free(edf->collection_patterns); + if (edf->path) eina_stringshare_del(edf->path); + if (edf->free_strings && edf->compiler) eina_stringshare_del(edf->compiler); + _edje_textblock_style_cleanup(edf); + if (edf->ef) eet_close(edf->ef); + free(edf); +} + +static void +_edje_program_free(Edje_Program *pr, Eina_Bool free_strings) +{ + Edje_Program_Target *prt; + Edje_Program_After *pa; + + if (free_strings) + { + if (pr->name) eina_stringshare_del(pr->name); + if (pr->signal) eina_stringshare_del(pr->signal); + if (pr->source) eina_stringshare_del(pr->source); + if (pr->filter.part) eina_stringshare_del(pr->filter.part); + if (pr->filter.state) eina_stringshare_del(pr->filter.state); + if (pr->state) eina_stringshare_del(pr->state); + if (pr->state2) eina_stringshare_del(pr->state2); + if (pr->sample_name) eina_stringshare_del(pr->sample_name); + if (pr->tone_name) eina_stringshare_del(pr->tone_name); + } + EINA_LIST_FREE(pr->targets, prt) + free(prt); + EINA_LIST_FREE(pr->after, pa) + free(pa); + free(pr); +} + +void +_edje_collection_free(Edje_File *edf, Edje_Part_Collection *ec, Edje_Part_Collection_Directory_Entry *ce) +{ + unsigned int i; + + _edje_embryo_script_shutdown(ec); + +#define EDJE_LOAD_PROGRAM_FREE(Array, Ec, It, FreeStrings) \ + for (It = 0; It < Ec->programs.Array##_count; ++It) \ + _edje_program_free(Ec->programs.Array[It], FreeStrings); \ + free(Ec->programs.Array); + + EDJE_LOAD_PROGRAM_FREE(fnmatch, ec, i, edf->free_strings); + EDJE_LOAD_PROGRAM_FREE(strcmp, ec, i, edf->free_strings); + EDJE_LOAD_PROGRAM_FREE(strncmp, ec, i, edf->free_strings); + EDJE_LOAD_PROGRAM_FREE(strrncmp, ec, i, edf->free_strings); + EDJE_LOAD_PROGRAM_FREE(nocmp, ec, i, edf->free_strings); + + for (i = 0; i < ec->parts_count; ++i) + { + Edje_Part *ep; + unsigned int j; + + ep = ec->parts[i]; + + if (edf->free_strings && ep->name) eina_stringshare_del(ep->name); + if (ep->default_desc) + { + _edje_collection_free_part_description_clean(ep->type, ep->default_desc, edf->free_strings); + ep->default_desc = NULL; + } + for (j = 0; j < ep->other.desc_count; ++j) + _edje_collection_free_part_description_clean(ep->type, ep->other.desc[j], edf->free_strings); + + free(ep->other.desc); + /* Alloc for RTL objects in edje_calc.c:_edje_part_description_find() */ + if(ep->other.desc_rtl) + free(ep->other.desc_rtl); + + free(ep->items); +// technically need this - but we ASSUME we use "one_big" so everything gets +// freed in one go lower down when we del the mempool... but what if pool goes +// "over"? + eina_mempool_free(ce->mp.part, ep); + } + free(ec->parts); + ec->parts = NULL; + + if (ec->data) + { + Eina_Iterator *it; + Edje_String *es; + + it = eina_hash_iterator_data_new(ec->data); + EINA_ITERATOR_FOREACH(it, es) + free(es); + eina_iterator_free(it); + + eina_hash_free(ec->data); + } +#ifdef EDJE_PROGRAM_CACHE + if (ec->prog_cache.no_matches) eina_hash_free(ec->prog_cache.no_matches); + if (ec->prog_cache.matches) + { + eina_hash_foreach(ec->prog_cache.matches, + _edje_collection_free_prog_cache_matches_free_cb, + NULL); + eina_hash_free(ec->prog_cache.matches); + } +#endif + if (ec->script) embryo_program_free(ec->script); + _edje_lua2_script_unload(ec); + + /* Destroy all part and description. */ + eina_mempool_del(ce->mp.RECTANGLE); + eina_mempool_del(ce->mp.TEXT); + eina_mempool_del(ce->mp.IMAGE); + eina_mempool_del(ce->mp.PROXY); + eina_mempool_del(ce->mp.SWALLOW); + eina_mempool_del(ce->mp.TEXTBLOCK); + eina_mempool_del(ce->mp.GROUP); + eina_mempool_del(ce->mp.BOX); + eina_mempool_del(ce->mp.TABLE); + eina_mempool_del(ce->mp.EXTERNAL); + eina_mempool_del(ce->mp.part); + memset(&ce->mp, 0, sizeof (ce->mp)); + + eina_mempool_del(ce->mp_rtl.RECTANGLE); + eina_mempool_del(ce->mp_rtl.TEXT); + eina_mempool_del(ce->mp_rtl.IMAGE); + eina_mempool_del(ce->mp_rtl.PROXY); + eina_mempool_del(ce->mp_rtl.SWALLOW); + eina_mempool_del(ce->mp_rtl.TEXTBLOCK); + eina_mempool_del(ce->mp_rtl.GROUP); + eina_mempool_del(ce->mp_rtl.BOX); + eina_mempool_del(ce->mp_rtl.TABLE); + eina_mempool_del(ce->mp_rtl.EXTERNAL); + memset(&ce->mp_rtl, 0, sizeof (ce->mp_rtl)); + free(ec); + ce->ref = NULL; +} + +void +_edje_collection_free_part_description_clean(int type, Edje_Part_Description_Common *desc, Eina_Bool free_strings) +{ + if (free_strings && desc->color_class) eina_stringshare_del(desc->color_class); + + switch (type) + { + case EDJE_PART_TYPE_IMAGE: + { + Edje_Part_Description_Image *img; + unsigned int i; + + img = (Edje_Part_Description_Image *) desc; + + for (i = 0; i < img->image.tweens_count; ++i) + free(img->image.tweens[i]); + free(img->image.tweens); + break; + } + case EDJE_PART_TYPE_EXTERNAL: + { + Edje_Part_Description_External *external; + + external = (Edje_Part_Description_External *) desc; + + if (external->external_params) + _edje_external_params_free(external->external_params, free_strings); + break; + } + case EDJE_PART_TYPE_TEXT: + case EDJE_PART_TYPE_TEXTBLOCK: + if (free_strings) + { + Edje_Part_Description_Text *text; + + text = (Edje_Part_Description_Text *) desc; + + if (text->text.text.str) eina_stringshare_del(text->text.text.str); + if (text->text.text_class) eina_stringshare_del(text->text.text_class); + if (text->text.style.str) eina_stringshare_del(text->text.style.str); + if (text->text.font.str) eina_stringshare_del(text->text.font.str); + } + break; + } +} + +void +_edje_collection_free_part_description_free(int type, + Edje_Part_Description_Common *desc, + Edje_Part_Collection_Directory_Entry *ce, + Eina_Bool free_strings) +{ +#define FREE_POOL(Type, Ce, Desc) \ + case EDJE_PART_TYPE_##Type: eina_mempool_free(Ce->mp.Type, Desc); \ + ce->count.Type--; \ + break; + + _edje_collection_free_part_description_clean(type, desc, free_strings); + + switch (type) + { + FREE_POOL(RECTANGLE, ce, desc); + FREE_POOL(TEXT, ce, desc); + FREE_POOL(IMAGE, ce, desc); + FREE_POOL(PROXY, ce, desc); + FREE_POOL(SWALLOW, ce, desc); + FREE_POOL(TEXTBLOCK, ce, desc); + FREE_POOL(GROUP, ce, desc); + FREE_POOL(BOX, ce, desc); + FREE_POOL(TABLE, ce, desc); + FREE_POOL(EXTERNAL, ce, desc); + } +} + +#ifdef EDJE_PROGRAM_CACHE +static Eina_Bool +_edje_collection_free_prog_cache_matches_free_cb(const Eina_Hash *hash, const void *key, void *data, void *fdata) +{ + eina_list_free((Eina_List *)data); + return EINA_TRUE; + key = NULL; + hash = NULL; + fdata = NULL; +} +#endif + +static void +_edje_object_pack_item_hints_set(Evas_Object *obj, Edje_Pack_Element *it) +{ + Evas_Coord w = 0, h = 0, minw, minh; + + minw = it->min.w; + minh = it->min.h; + + if ((minw <= 0) && (minh <= 0)) + { + edje_object_size_min_get(obj, &w, &h); + if ((w <= 0) && (h <= 0)) + edje_object_size_min_calc(obj, &w, &h); + } + else + { + w = minw; + h = minh; + } + if (((minw <= 0) && (minh <= 0)) && ((w > 0) || (h > 0))) + evas_object_size_hint_min_set(obj, w, h); + else + evas_object_size_hint_min_set(obj, minw, minh); + + evas_object_size_hint_request_set(obj, it->prefer.w, it->prefer.h); + evas_object_size_hint_max_set(obj, it->max.w, it->max.h); + evas_object_size_hint_padding_set(obj, it->padding.l, it->padding.r, it->padding.t, it->padding.b); + evas_object_size_hint_align_set(obj, it->align.x, it->align.y); + evas_object_size_hint_weight_set(obj, it->weight.x, it->weight.y); + evas_object_size_hint_aspect_set(obj, it->aspect.mode, it->aspect.w, it->aspect.h); + + evas_object_resize(obj, w, h); +} + +static const char * +_edje_find_alias(Eina_Hash *aliased, char *src, int *length) +{ + const char *alias; + char *search; + + *length = strlen(src); + if (*length == 0) return NULL; + + alias = eina_hash_find(aliased, src); + if (alias) return alias; + + search = strrchr(src, EDJE_PART_PATH_SEPARATOR); + if (search == NULL) return NULL; + + *search = '\0'; + alias = _edje_find_alias(aliased, src, length); + *search = EDJE_PART_PATH_SEPARATOR; + + return alias; +} + +static void +_cb_signal_repeat(void *data, Evas_Object *obj, const char *sig, const char *source) +{ + Edje_Pack_Element *pack_it; + Evas_Object *parent; + Edje *ed; + Edje *ed_parent; + char new_src[4096]; /* XXX is this max reasonable? */ + size_t length_parent = 0; + size_t length_index = 0; + size_t length_source; + int i = 0; + const char *alias = NULL; + Edje_Message_Signal emsg; + + parent = data; + ed = _edje_fetch(obj); + if (!ed) return; + + pack_it = evas_object_data_get(obj, "\377 edje.box_item"); + if (!pack_it) pack_it = evas_object_data_get(obj, "\377 edje.table_item"); + if (pack_it) + { + if (!pack_it->name) + { + Eina_List *child = NULL; + Evas_Object *o; + + if (pack_it->parent->part->type == EDJE_PART_TYPE_BOX) + { + child = evas_object_box_children_get(pack_it->parent->object); + } + else if (pack_it->parent->part->type == EDJE_PART_TYPE_TABLE) + { + child = evas_object_table_children_get(pack_it->parent->object); + } + + EINA_LIST_FREE(child, o) + { + if (o == obj) break; + i++; + } + + eina_list_free(child); + + length_index = 12; + } + else + { + length_index = strlen(pack_it->name) + 2; + } + } + + /* Replace snprint("%s%c%s") == memcpy + *new_src + memcat */ + if (ed->parent) + length_parent = strlen(ed->parent); + length_source = strlen(source); + if (length_source + length_parent + 2 + length_index > sizeof(new_src)) + return; + + if (ed->parent) + memcpy(new_src, ed->parent, length_parent); + if (ed->parent && length_index) + { + new_src[length_parent++] = EDJE_PART_PATH_SEPARATOR_INDEXL; + if (length_index == 12) + length_parent += eina_convert_itoa(i, new_src + length_parent); + else + { + memcpy(new_src + length_parent, pack_it->name, length_index); + length_parent += length_index - 2; + } + new_src[length_parent++] = EDJE_PART_PATH_SEPARATOR_INDEXR; + } + + new_src[length_parent] = EDJE_PART_PATH_SEPARATOR; + memcpy(new_src + length_parent + 1, source, length_source + 1); + + /* Handle alias renaming */ + ed_parent = _edje_fetch(parent); + if (ed_parent && ed_parent->collection && ed_parent->collection->aliased) + { + int length; + + alias = _edje_find_alias(ed_parent->collection->aliased, new_src, &length); + + if (alias) + { + int origin; + + /* Add back the end of the source */ + origin = strlen(new_src); + length ++; /* Remove the trailing ':' from the count */ + if (origin > length) + { + char *tmp; + size_t alias_length; + + alias_length = strlen(alias); + tmp = alloca(alias_length + origin - length + 2); + memcpy(tmp, alias, alias_length); + tmp[alias_length] = EDJE_PART_PATH_SEPARATOR; + memcpy(tmp + alias_length + 1, new_src + length, origin - length + 1); + + alias = tmp; + } + } + } + + emsg.sig = sig; + emsg.src = alias ? alias : new_src; + emsg.data = NULL; + _edje_message_send(ed_parent, EDJE_QUEUE_SCRIPT, + EDJE_MESSAGE_SIGNAL, 0, &emsg); +} 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 @@ +#include "edje_private.h" + +#if 0 +///////////////////////////////////////////////////////////////////////////// +// the below is deprecated and here for reference only until removed. look +// at edje_lua2.c for the active workign code +///////////////////////////////////////////////////////////////////////////// + +#include +#include + +#define EDJE_LUA_GET 1 +#define EDJE_LUA_SET 2 +#define EDJE_LUA_FN 3 + +typedef struct _Edje_Lua_Alloc Edje_Lua_Alloc; + +typedef struct _Edje_Lua_Ref Edje_Lua_Ref; + +typedef struct _Edje_Lua_Reg Edje_Lua_Reg; + +typedef struct _Edje_Lua_Timer Edje_Lua_Timer; + +typedef struct _Edje_Lua_Animator Edje_Lua_Animator; + +typedef struct _Edje_Lua_Poller Edje_Lua_Poller; + +typedef struct _Edje_Lua_Transform Edje_Lua_Transform; + +typedef struct _Edje_Lua_Transition Edje_Lua_Transition; + +typedef struct _Edje_Lua_Evas_Object Edje_Lua_Evas_Object; + +typedef struct _Edje_Lua_Edje_Part_Object Edje_Lua_Edje_Part_Object; + +typedef struct _Edje_Lua_Edje_Part_Description Edje_Lua_Edje_Part_Description; + +struct _Edje_Lua_Alloc +{ + size_t max, cur; /* maximal and current memory used by Lua */ +}; + +struct _Edje_Lua_Ref +{ + int id; + lua_State *L; +}; + +struct _Edje_Lua_Reg +{ + const luaL_Reg *mt, *get, *set, *fn; +}; + +struct _Edje_Lua_Timer +{ + lua_State *L; + Ecore_Timer *et; + Edje_Lua_Ref *cb; +}; + +struct _Edje_Lua_Animator +{ + lua_State *L; + Ecore_Animator *ea; + Edje_Lua_Ref *cb; +}; + +struct _Edje_Lua_Poller +{ + lua_State *L; + Ecore_Poller *ep; + Edje_Lua_Ref *cb; +}; + +struct _Edje_Lua_Transform +{ + lua_State *L; + Evas_Transform et; +}; + +struct _Edje_Lua_Transition +{ + lua_State *L; + Ecore_Timer *et; + Edje_Lua_Ref *trans; + Edje_Lua_Ref *cb; + Edje_Lua_Ref *ref; + double dur; +}; + +struct _Edje_Lua_Evas_Object +{ + lua_State *L; + Edje *ed; + Evas_Object *eo; + Eina_Bool mouse_events; + Eina_List *cb; +}; + +struct _Edje_Lua_Edje_Part_Object +{ + lua_State *L; + Edje *ed; + Evas_Object *eo; + Edje_Real_Part *rp; + const char *key; +}; + +struct _Edje_Lua_Edje_Part_Description +{ + lua_State *L; + Edje *ed; + Evas_Object *eo; + Edje_Real_Part *rp; + Edje_Part_Description *pd; +}; + +jmp_buf _edje_lua_panic_jmp; + +static int +_edje_lua_custom_panic(__UNUSED__ lua_State *L) +{ + CRITICAL("PANIC"); + longjmp(_edje_lua_panic_jmp, 1); + return 1; /* longjmp() never returns, but this keep gcc happy */ +} + +void +__edje_lua_error(const char *file, const char *fnc, int line, lua_State *L, int err_code) +{ + char *err_type; + + switch (err_code) + { + case LUA_ERRRUN: + err_type = "runtime"; + break; + case LUA_ERRSYNTAX: + err_type = "syntax"; + break; + case LUA_ERRMEM: + err_type = "memory allocation"; + break; + case LUA_ERRERR: + err_type = "error handler"; + break; + default: + err_type = "unknown"; + break; + } + eina_log_print + (_edje_default_log_dom, EINA_LOG_LEVEL_ERR, file, fnc, line, + "Lua %s error: %s", err_type, lua_tostring(L, -1)); + // don't exit. this is BAD. lua script bugs will cause thngs like e to + // exit mysteriously ending your x session. bad! + // exit(-1); +} + +lua_State * +_edje_lua_new_thread(Edje *ed, lua_State *L) +{ +#if 1 // newlua + lua_newtable(L); + ed->lua_ref = luaL_ref(L, LUA_REGISTRYINDEX); + /* inherit new environment from global environment */ + lua_createtable(L, 1, 0); + lua_pushvalue(L, LUA_GLOBALSINDEX); + lua_setfield(L, -2, "__index"); + lua_setmetatable(L, -2); + lua_setfenv(L, -2); + return L; +#else + /* create new thread */ + lua_State *thread = lua_newthread(L); + //printf ("new thread %d->%d\n", L, thread); + /* create new environment for new thread */ + lua_newtable(L); + /* inherit new environment from global environment */ + lua_createtable(L, 1, 0); + lua_pushvalue(L, LUA_GLOBALSINDEX); + lua_setfield(L, -2, "__index"); + lua_setmetatable(L, -2); + lua_setfenv(L, -2); + return thread; +#endif +} + +void +_edje_lua_free_thread(Edje *ed, lua_State *L) +{ +#if 1 // newlua + luaL_unref(L, LUA_REGISTRYINDEX, ed->lua_ref); + lua_gc(L, LUA_GCCOLLECT, 0); +#else + lua_pushthread(L); + lua_getfenv(L, -1); + lua_pushnil(L); + while (lua_next(L, -2)) + { + // key at -2, value at -1 + lua_pop(L, 1); + lua_pushvalue(L, -1); + lua_pushnil(L); + lua_rawset(L, -4); + } + lua_settop(L, 0); + lua_gc(L, LUA_GCCOLLECT, 0); +#endif +} + +/* + * only for debug, returns number of objects in registry + */ +static int +_edje_lua_reg_count (lua_State *L) +{ + int count = 0; + lua_pushvalue(L, LUA_REGISTRYINDEX); + lua_pushnil(L); + while (lua_next(L, -2)) + { + // key at -2, value at -1 + lua_pop(L, 1); + count++; + } + lua_pop(L, 1); + return count; +} + +static Edje_Lua_Ref * +_edje_lua_new_ref(lua_State *L, int index) +{ + lua_pushvalue(L, index); + Edje_Lua_Ref *ref = malloc(sizeof(Edje_Lua_Ref)); + ref->id = luaL_ref(L, LUA_REGISTRYINDEX); + ref->L = L; + return ref; +} + +static void +_edje_lua_get_ref(lua_State *L, Edje_Lua_Ref *ref) +{ + lua_rawgeti(L, LUA_REGISTRYINDEX, ref->id); +} + +static void +_edje_lua_free_ref(lua_State *L, Edje_Lua_Ref *ref) +{ + //printf ("_edje_lua_free_ref %d %d %d\n", L, lua_objlen(L, LUA_REGISTRYINDEX), _edje_lua_reg_count(L)); + luaL_unref(L, LUA_REGISTRYINDEX, ref->id); + free(ref); + lua_gc(L, LUA_GCCOLLECT, 0); +} + +void +_edje_lua_new_reg(lua_State *L, int index, void *ptr) +{ + //printf ("_edje_lua_new_reg %d %d %d\n", L, ptr, _edje_lua_reg_count(L)); + lua_pushvalue(L, index); + lua_pushlightuserdata(L, ptr); + lua_insert(L, -2); + lua_rawset(L, LUA_REGISTRYINDEX); /* freed in _edje_lua_free_reg */ +} + +void +_edje_lua_get_reg(lua_State *L, void *ptr) +{ + //printf ("_edje_lua_get_reg %d %d\n", L, ptr); + lua_pushlightuserdata(L, ptr); + lua_rawget(L, LUA_REGISTRYINDEX); +} + +void +_edje_lua_free_reg(lua_State *L, void *ptr) +{ + //printf ("_edje_lua_free_reg %d %d %d\n", L, ptr, _edje_lua_reg_count(L)); + lua_pushlightuserdata(L, ptr); + lua_pushnil(L); + lua_rawset(L, LUA_REGISTRYINDEX); /* created in _edje_lua_new_reg */ + lua_gc(L, LUA_GCCOLLECT, 0); +} + +static void +_edje_lua_rawsetfield(lua_State *L, int index, const char *key) +{ + lua_pushstring(L, key); + lua_insert(L, -2); + if (index < 0) + lua_rawset(L, index - 1); + else + lua_rawset(L, index); +} + +static void +_edje_lua_rawgetfield(lua_State *L, int index, const char *key) +{ + lua_pushstring(L, key); + if (index < 0) + lua_rawget(L, index - 1); + else + lua_rawget(L, index); +} + +static void +_edje_lua_new_const(lua_State *L, const char *id, int val) +{ + lua_pushnumber(L, val); + lua_setglobal(L, id); +} + +static void +_edje_lua_new_metatable(lua_State *L, const Edje_Lua_Reg ** class) +{ + lua_newtable(L); + lua_pushlightuserdata(L, class); + lua_pushvalue(L, -2); + lua_rawset(L, LUA_REGISTRYINDEX); /* freed in _edje_lua_free_metatable */ + lua_pushvalue(L, -1); + lua_pushlightuserdata(L, class); + lua_rawset(L, LUA_REGISTRYINDEX); /* freed in _edje_lua_free_metatable */ +} + +static void +_edje_lua_get_metatable(lua_State *L, const Edje_Lua_Reg ** class) +{ + lua_pushlightuserdata(L, class); + lua_rawget(L, LUA_REGISTRYINDEX); +} + +static void +_edje_lua_free_metatable(lua_State *L, const Edje_Lua_Reg ** class) +{ + lua_pushlightuserdata(L, class); + lua_rawget(L, LUA_REGISTRYINDEX); + lua_pushnil(L); + lua_rawset(L, LUA_REGISTRYINDEX); /* created in _edje_lua_new_metatable */ + lua_pushlightuserdata(L, class); + lua_pushnil(L); + lua_rawset(L, LUA_REGISTRYINDEX); /* created in _edje_lua_new_metatable */ + lua_gc(L, LUA_GCCOLLECT, 0); +} + +static void * +_edje_lua_checkudata(lua_State *L, int pos, const Edje_Lua_Reg * module) +{ + luaL_checktype(L, pos, LUA_TUSERDATA); + lua_getmetatable(L, pos); + lua_rawget(L, LUA_REGISTRYINDEX); + Edje_Lua_Reg **class = lua_touserdata(L, -1); + lua_pop(L, 1); // class + int flag = 0; + int ptr = 0; + while (class[ptr] && !flag) + if (class[ptr++] == module) + flag = 1; + if (!flag) + { + lua_pushstring(L, "class type mismatch"); + lua_error(L); + } + return lua_touserdata(L, pos); +} + +static void +_edje_lua_new_class(lua_State *L, const Edje_Lua_Reg ** class) +{ + int n = 0; + _edje_lua_new_metatable(L, class); + while (class && (class[n] != NULL)) + { + luaL_register(L, NULL, class[n]->mt); + lua_pushstring(L, "hands off, it's none of your business!"); + _edje_lua_rawsetfield(L, -2, "__metatable"); + + if (n == 0) + { + lua_newtable(L); + luaL_register(L, NULL, class[n]->set); + lua_rawseti (L, -2, EDJE_LUA_SET); + + lua_newtable(L); + luaL_register(L, NULL, class[n]->get); + lua_rawseti (L, -2, EDJE_LUA_GET); + + lua_newtable(L); + luaL_register(L, NULL, class[n]->fn); + lua_rawseti (L, -2, EDJE_LUA_FN); + } + else + { + lua_rawgeti(L, -1, EDJE_LUA_SET); + luaL_register(L, NULL, class[n]->set); + lua_pop(L, 1); + + lua_rawgeti(L, -1, EDJE_LUA_GET); + luaL_register(L, NULL, class[n]->get); + lua_pop(L, 1); + + lua_rawgeti(L, -1, EDJE_LUA_FN); + luaL_register(L, NULL, class[n]->fn); + lua_pop(L, 1); + } + n += 1; + } +} + +static void +_edje_lua_set_class(lua_State *L, int index, const Edje_Lua_Reg ** class) +{ + lua_newtable(L); + if (index < 0) + lua_setfenv(L, index - 1); + else + lua_setfenv(L, index); + + _edje_lua_get_metatable(L, class); + if (index < 0) + lua_setmetatable(L, index - 1); + else + lua_setmetatable(L, index); +} + +static int +_edje_lua_look_fn(lua_State *L) +{ + lua_rawgeti(L, -1, EDJE_LUA_FN); + lua_pushvalue(L, 2); // key + lua_rawget(L, -2); // .fn[key] + if (lua_iscfunction(L, -1)) + return 1; + else + { + lua_pop(L, 2); // .fn[key], .fn + return 0; + } +} + +static int +_edje_lua_look_get(lua_State *L) +{ + lua_rawgeti(L, -1, EDJE_LUA_GET); + lua_pushvalue(L, 2); // key + lua_rawget(L, -2); // .get[key] + if (lua_iscfunction(L, -1)) + { + int err_code; + + lua_pushvalue(L, 1); + + if ((err_code = lua_pcall(L, 1, 1, 0))) + _edje_lua_error(L, err_code); + return 1; + } + else + { + lua_pop(L, 2); // .get[key], .get + return 0; + } +} + +static int +_edje_lua_look_set(lua_State *L) +{ + lua_rawgeti(L, -1, EDJE_LUA_SET); + lua_pushvalue(L, 2); // key + lua_rawget(L, -2); // .set[key] + if (lua_iscfunction(L, -1)) + { + int err_code; + + lua_pushvalue(L, 1); // obj + lua_pushvalue(L, 3); // value + + if ((err_code = lua_pcall(L, 2, 0, 0))) // .set[key](obj,key,value) + _edje_lua_error(L, err_code); + return 1; + } + else + { + lua_pop(L, 2); // .set[key], .set + return 0; + } +} + +/* + * Lua Class bindings + */ + +const luaL_Reg lNil[] = { + {NULL, NULL} // sentinel +}; + +const luaL_Reg lClass_mt[]; + +const luaL_Reg lClass_fn[]; + +const Edje_Lua_Reg mClass = { + lClass_mt, + lNil, + lNil, + lClass_fn +}; + +static int +_edje_lua_class_mt_index(lua_State *L) +{ + _edje_lua_checkudata(L, 1, &mClass); + lua_getmetatable(L, 1); + if (!_edje_lua_look_fn(L)) // look in lClass_fn + if (!_edje_lua_look_get(L)) // look in lClass_get + { // look in obj ref hash + lua_getfenv(L, 1); + lua_pushvalue(L, 2); // key + lua_rawget(L, -2); + } + return 1; +} + +static int +_edje_lua_class_mt_newindex(lua_State *L) +{ + _edje_lua_checkudata(L, 1, &mClass); + lua_getmetatable(L, 1); + if (!_edje_lua_look_set(L)) // look in lClass_set + { // look in obj ref hash + lua_getfenv(L, 1); + lua_pushvalue(L, 2); + lua_pushvalue(L, 3); + lua_rawset(L, -3); + } + return 0; +} + +static int +_edje_lua_class_mt_gc(lua_State *L) +{ + _edje_lua_checkudata(L, 1, &mClass); + //printf("_edje_lua_class_mt_gc\n"); + /* FIXME has to be commented to not raise an error, solve differently + lua_getfield(L, 1, "del"); + if (!lua_isnil(L, -1)) + { + lua_pushvalue(L, 1); + int err_code; + + if (err_code = lua_pcall(L, 1, 0, 0)) + _edje_lua_error(L, err_code); + } + lua_pop(L, 1); + */ + return 0; +} + +static int +_edje_lua_class_fn_set(lua_State *L) +{ + _edje_lua_checkudata(L, 1, &mClass); + /* + * for k,v in pairs(table) do + * obj[k] = v + * end + */ + lua_pushnil(L); + while (lua_next(L, 2)) + { + // key at -2, value at -1 + lua_pushvalue(L, -2); + lua_insert(L, -2); + lua_settable(L, 1); + } + return 0; +} + +static int +_edje_lua_class_fn_get(lua_State *L) +{ + _edje_lua_checkudata(L, 1, &mClass); + /* + * res = {} + * mtG = getmetatable(obj)['.get'] + * for k,v in pairs(mtG) do + * res[k] = obj[k] + * end + */ + lua_newtable(L); // res + lua_getmetatable(L, 1); // mt + lua_getfield(L, -1, ".get"); + lua_remove(L, -2); // mt + + lua_pushnil(L); + while (lua_next(L, -2)) + { + // key at -2, value at -1 + lua_pop(L, 1); // value = cfunction + lua_pushvalue(L, -1); // key + lua_pushvalue(L, -1); // key + lua_gettable(L, 1); // obj[key] + lua_settable(L, 2); // res[key] + } + lua_pop(L, 1); // .get + return 1; +} + +static int +_edje_lua_class_itr_call(lua_State *L, int id) +{ + int err_code; + + _edje_lua_checkudata(L, 1, &mClass); + lua_getmetatable(L, 1); // mt + lua_rawgeti(L, -1, id); + lua_remove(L, -2); // mt + lua_getglobal(L, "pairs"); + lua_insert(L, -2); + + if ((err_code = lua_pcall(L, 1, 3, 0))) + _edje_lua_error(L, err_code); + return 3; +} + +static int +_edje_lua_class_fn_gpairs(lua_State *L) +{ + _edje_lua_checkudata(L, 1, &mClass); + return _edje_lua_class_itr_call(L, EDJE_LUA_GET); +} + +static int +_edje_lua_class_fn_spairs(lua_State *L) +{ + _edje_lua_checkudata(L, 1, &mClass); + return _edje_lua_class_itr_call(L, EDJE_LUA_SET); +} + +static int +_edje_lua_class_fn_fpairs(lua_State *L) +{ + _edje_lua_checkudata(L, 1, &mClass); + return _edje_lua_class_itr_call(L, EDJE_LUA_FN); +} + +static int +_edje_lua_class_fn_pairs(lua_State *L) +{ + int err_code; + + _edje_lua_checkudata(L, 1, &mClass); + lua_getfenv(L, 1); + lua_getglobal(L, "pairs"); + lua_insert(L, -2); + + if ((err_code = lua_pcall(L, 1, 3, 0))) + _edje_lua_error(L, err_code); + return 3; +} + +static int +_edje_lua_class_fn_ipairs(lua_State *L) +{ + int err_code; + + _edje_lua_checkudata(L, 1, &mClass); + lua_getfenv(L, 1); + lua_getglobal(L, "ipairs"); + lua_insert(L, -2); + + if ((err_code = lua_pcall(L, 1, 3, 0))) + _edje_lua_error(L, err_code); + return 3; +} + +const luaL_Reg lClass_mt[] = { + {"__index", _edje_lua_class_mt_index}, + {"__newindex", _edje_lua_class_mt_newindex}, + {"__gc", _edje_lua_class_mt_gc}, + {NULL, NULL} // sentinel +}; + +const luaL_Reg lClass_fn[] = { + {"get", _edje_lua_class_fn_get}, + {"set", _edje_lua_class_fn_set}, + {"gpairs", _edje_lua_class_fn_gpairs}, + {"spairs", _edje_lua_class_fn_spairs}, + {"fpairs", _edje_lua_class_fn_fpairs}, + {"pairs", _edje_lua_class_fn_pairs}, + {"ipairs", _edje_lua_class_fn_ipairs}, + {NULL, NULL} // sentinel +}; + + +const luaL_Reg lTimer_get[]; + +const luaL_Reg lTimer_set[]; + +const luaL_Reg lTimer_fn[]; + +const Edje_Lua_Reg mTimer = { + lNil, + lTimer_get, + lTimer_set, + lTimer_fn +}; + +const Edje_Lua_Reg *cTimer[] = { + &mClass, + &mTimer, + NULL // sentinel +}; + +static Eina_Bool +_edje_lua_timer_cb(void *data) +{ + Edje_Lua_Timer *obj = data; + lua_State *L = obj->L; + int err_code; + Eina_Bool res; + + _edje_lua_get_ref(L, obj->cb); // callback function + _edje_lua_get_reg(L, obj); + + if ((err_code = lua_pcall(L, 1, 1, 0))) + { + _edje_lua_error(L, err_code); + return ECORE_CALLBACK_CANCEL; + } + + res = luaL_optint(L, -1, ECORE_CALLBACK_CANCEL); + lua_pop(L, 1); // -- res + +/* + if (_edje_lua_panic_here()) + printf("blahc\n"); + else + lua_pop(L, 1); // -- res + */ + if (res == ECORE_CALLBACK_CANCEL) + { + // delete object + _edje_lua_get_reg(L, obj); + lua_pushvalue(L, -1); + lua_pushstring(L, "del"); + lua_gettable(L, -2); + lua_insert(L, -2); + if ((err_code = lua_pcall(L, 1, 0, 0))) + _edje_lua_error(L, err_code); + } + return res; +} + +static int +_edje_lua_timer_get_pending(lua_State *L) +{ + Edje_Lua_Timer *obj = _edje_lua_checkudata(L, 1, &mTimer); + if (obj->et) + lua_pushnumber(L, ecore_timer_pending_get(obj->et)); + else + lua_pushnil(L); + return 1; +} + +static int +_edje_lua_timer_get_precision(lua_State *L) +{ + Edje_Lua_Timer *obj = _edje_lua_checkudata(L, 1, &mTimer); + + if (obj->et) + lua_pushnumber(L, ecore_timer_precision_get()); + else + lua_pushnil(L); + + return 1; +} + +static int +_edje_lua_timer_get_interval(lua_State *L) +{ + Edje_Lua_Timer *obj = _edje_lua_checkudata(L, 1, &mTimer); + + if (obj->et) + lua_pushnumber(L, ecore_timer_interval_get(obj->et)); + else + lua_pushnil(L); + + return 1; +} + +const luaL_Reg lTimer_get[] = { + {"pending", _edje_lua_timer_get_pending}, + {"precision", _edje_lua_timer_get_precision}, + {"interval", _edje_lua_timer_get_interval}, + {NULL, NULL} // sentinel +}; + +static int +_edje_lua_timer_set_interval(lua_State *L) +{ + Edje_Lua_Timer *obj = _edje_lua_checkudata(L, 1, &mTimer); + if (obj->et) + ecore_timer_interval_set(obj->et, luaL_checknumber(L, 2)); + return 0; +} + +const luaL_Reg lTimer_set[] = { + {"interval", _edje_lua_timer_set_interval}, + {NULL, NULL} // sentinel +}; + +static int +_edje_lua_timer_fn_del(lua_State *L) +{ + Edje_Lua_Timer *obj = _edje_lua_checkudata(L, 1, &mTimer); + if (obj->et) + { + ecore_timer_del(obj->et); + obj->et = NULL; + } + if (obj->cb) + { + _edje_lua_free_ref(L, obj->cb); // created in _edje_lua_group_fn_timer + obj->cb = NULL; + } + _edje_lua_free_reg(L, obj); // created in _edje_lua_group_fn_timer + return 0; +} + +static int +_edje_lua_timer_fn_freeze(lua_State *L) +{ + Edje_Lua_Timer *obj = _edje_lua_checkudata(L, 1, &mTimer); + if (obj->et) + ecore_timer_freeze(obj->et); + return 0; +} + +static int +_edje_lua_timer_fn_thaw(lua_State *L) +{ + Edje_Lua_Timer *obj = _edje_lua_checkudata(L, 1, &mTimer); + if (obj->et) + ecore_timer_thaw(obj->et); + return 0; +} + +static int +_edje_lua_timer_fn_delay(lua_State *L) +{ + Edje_Lua_Timer *obj = _edje_lua_checkudata(L, 1, &mTimer); + if (obj->et) + ecore_timer_delay(obj->et, luaL_checknumber(L, 2)); + return 0; +} + +const luaL_Reg lTimer_fn[] = { + {"del", _edje_lua_timer_fn_del}, + {"freeze", _edje_lua_timer_fn_freeze}, + {"thaw", _edje_lua_timer_fn_thaw}, + {"delay", _edje_lua_timer_fn_delay}, + {NULL, NULL} // sentinel +}; + +const luaL_Reg lAnimator_get[]; + +const luaL_Reg lAnimator_fn[]; + +const Edje_Lua_Reg mAnimator = { + lNil, + lAnimator_get, + lNil, + lAnimator_fn +}; + +const Edje_Lua_Reg *cAnimator[] = { + &mClass, + &mAnimator, + NULL // sentinel +}; + +static Eina_Bool +_edje_lua_animator_cb(void *data) +{ + Eina_Bool res; + int err; + Edje_Lua_Animator *obj = data; + lua_State *L = obj->L; + + _edje_lua_get_ref(L, obj->cb); + _edje_lua_get_reg(L, obj); + + if ((err = lua_pcall(L, 1, 1, 0))) + { + _edje_lua_error(L, err); + return ECORE_CALLBACK_CANCEL; + } + + res = luaL_checkint(L, -1); + lua_pop(L, 1); // Pop res off the stack + if (res == ECORE_CALLBACK_CANCEL) + { + /* delete animator */ + _edje_lua_get_reg(L, obj); + lua_pushvalue(L, -1); + lua_pushstring(L, "del"); + lua_gettable(L, -2); + lua_insert(L, -2); + if ((err = lua_pcall(L, 1, 0, 0))) + _edje_lua_error(L, err); + } + + return res; +} + +static int +_edje_lua_animator_get_frametime(lua_State *L) +{ + Edje_Lua_Animator *obj = _edje_lua_checkudata(L, 1, &mAnimator); + + if (obj->ea) + lua_pushnumber(L, ecore_animator_frametime_get()); + else + lua_pushnil(L); + + return 1; +} + +const luaL_Reg lAnimator_get[] = { + {"frametime", _edje_lua_animator_get_frametime}, + {NULL, NULL} +}; + +static int +_edje_lua_animator_fn_del(lua_State *L) +{ + Edje_Lua_Animator *obj = _edje_lua_checkudata(L, 1, &mAnimator); + if (obj->ea) + { + ecore_animator_del(obj->ea); + obj->ea = NULL; + } + if (obj->cb) + { + _edje_lua_free_ref(L, obj->cb); // created in _edje_lua_group_fn_animator + obj->cb = NULL; + } + _edje_lua_free_reg(L, obj); // created in _edje_lua_group_fn_animator + return 0; +} + +const luaL_Reg lAnimator_fn[] = { + {"del", _edje_lua_animator_fn_del}, + {NULL, NULL} // sentinel +}; + +const luaL_Reg lPoller_get[]; + +const luaL_Reg lPoller_fn[]; + +const Edje_Lua_Reg mPoller = { + lNil, + lPoller_get, + lNil, + lPoller_fn +}; + +const Edje_Lua_Reg *cPoller[] = { + &mClass, + &mPoller, + NULL // sentinel +}; + +static Eina_Bool +_edje_lua_poller_cb(void *data) +{ + Eina_Bool res; + int err; + Edje_Lua_Poller *obj = data; + lua_State *L = obj->L; + + _edje_lua_get_ref(L, obj->cb); + _edje_lua_get_reg(L, obj); + + if ((err = lua_pcall(L, 1, 1, 0))) + { + _edje_lua_error(L, err); + return ECORE_CALLBACK_CANCEL; + } + + res = luaL_checkint(L, -1); + lua_pop(L, 1); // Pop res off the stack + if (res == ECORE_CALLBACK_CANCEL) + { + /* delete poller */ + _edje_lua_get_reg(L, obj); + lua_pushvalue(L, -1); + lua_pushstring(L, "del"); + lua_gettable(L, -2); + lua_insert(L, -2); + if ((err = lua_pcall(L, 1, 0, 0))) + _edje_lua_error(L, err); + } + + return res; +} + +static int +_edje_lua_poller_get_interval(lua_State *L) +{ + Edje_Lua_Poller *obj = _edje_lua_checkudata(L, 1, &mPoller); + + if (obj->ep) + lua_pushnumber(L, ecore_poller_poll_interval_get(ECORE_POLLER_CORE)); + else + lua_pushnil(L); + + return 1; +} + +const luaL_Reg lPoller_get[] = { + {"interval", _edje_lua_poller_get_interval}, + {NULL, NULL} +}; + +static int +_edje_lua_poller_fn_del(lua_State *L) +{ + Edje_Lua_Poller *obj = _edje_lua_checkudata(L, 1, &mPoller); + if (obj->ep) + { + ecore_poller_del(obj->ep); + obj->ep = NULL; + } + + if (obj->cb) + { + _edje_lua_free_ref(L, obj->cb); // created in _edje_lua_group_fn_poller + obj->cb = NULL; + } + _edje_lua_free_reg(L, obj); // created in _edje_lua_group_fn_poller + + return 0; +} + +const luaL_Reg lPoller_fn[] = { + {"del", _edje_lua_poller_fn_del}, + {NULL, NULL} +}; + +/* + * Lua Edje Transform bindings + */ + +const luaL_Reg lTransform_get[]; + +const luaL_Reg lTransform_set[]; + +const luaL_Reg lTransform_fn[]; + +const Edje_Lua_Reg mTransform = { + lNil, + lTransform_get, + lTransform_set, + lTransform_fn +}; + +const Edje_Lua_Reg *cTransform[] = { + &mClass, + &mTransform, + NULL // sentinel +}; + +static int +_edje_lua_transform_get_matrix(lua_State *L) +{ + Edje_Lua_Transform *obj = _edje_lua_checkudata(L, 1, &mTransform); + lua_createtable(L, 3, 0); + lua_createtable(L, 3, 0); + lua_pushnumber(L, obj->et.mxx); lua_rawseti(L, -2, 1); + lua_pushnumber(L, obj->et.mxy); lua_rawseti(L, -2, 2); + lua_pushnumber(L, obj->et.mxz); lua_rawseti(L, -2, 3); + lua_rawseti(L, -2, 1); + lua_createtable(L, 3, 0); + lua_pushnumber(L, obj->et.myx); lua_rawseti(L, -2, 1); + lua_pushnumber(L, obj->et.myy); lua_rawseti(L, -2, 2); + lua_pushnumber(L, obj->et.myz); lua_rawseti(L, -2, 3); + lua_rawseti(L, -2, 2); + lua_createtable(L, 3, 0); + lua_pushnumber(L, obj->et.mzx); lua_rawseti(L, -2, 1); + lua_pushnumber(L, obj->et.mzy); lua_rawseti(L, -2, 2); + lua_pushnumber(L, obj->et.mzz); lua_rawseti(L, -2, 3); + lua_rawseti(L, -2, 3); + return 1; +} + +const luaL_Reg lTransform_get[] = { + {"matrix", _edje_lua_transform_get_matrix}, + {NULL, NULL} // sentinel +}; + +static int +_edje_lua_transform_set_matrix(lua_State *L) +{ + Edje_Lua_Transform *obj = _edje_lua_checkudata(L, 1, &mTransform); + luaL_checktype(L, 2, LUA_TTABLE); + lua_rawgeti(L, 2, 1); + luaL_checktype(L, -1, LUA_TTABLE); + lua_rawgeti(L, -1, 1); obj->et.mxx = luaL_checknumber(L, -1); lua_pop(L, 1); + lua_rawgeti(L, -1, 2); obj->et.mxy = luaL_checknumber(L, -1); lua_pop(L, 1); + lua_rawgeti(L, -1, 3); obj->et.mxz = luaL_checknumber(L, -1); lua_pop(L, 1); + lua_pop(L, 1); + lua_rawgeti(L, 2, 2); + luaL_checktype(L, -1, LUA_TTABLE); + lua_rawgeti(L, -1, 1); obj->et.myx = luaL_checknumber(L, -1); lua_pop(L, 1); + lua_rawgeti(L, -1, 2); obj->et.myy = luaL_checknumber(L, -1); lua_pop(L, 1); + lua_rawgeti(L, -1, 3); obj->et.myz = luaL_checknumber(L, -1); lua_pop(L, 1); + lua_pop(L, 1); + lua_rawgeti(L, 2, 3); + luaL_checktype(L, -1, LUA_TTABLE); + lua_rawgeti(L, -1, 1); obj->et.mzx = luaL_checknumber(L, -1); lua_pop(L, 1); + lua_rawgeti(L, -1, 2); obj->et.mzy = luaL_checknumber(L, -1); lua_pop(L, 1); + lua_rawgeti(L, -1, 3); obj->et.mzz = luaL_checknumber(L, -1); lua_pop(L, 1); + lua_pop(L, 1); + return 0; +} + +const luaL_Reg lTransform_set[] = { + {"matrix", _edje_lua_transform_set_matrix}, + {NULL, NULL} // sentinel +}; + +static int +_edje_lua_transform_fn_identity(lua_State *L) +{ + Edje_Lua_Transform *obj = _edje_lua_checkudata(L, 1, &mTransform); + evas_transform_identity_set(&(obj->et)); + return 0; +} + +static int +_edje_lua_transform_fn_rotate(lua_State *L) +{ + Edje_Lua_Transform *obj = _edje_lua_checkudata(L, 1, &mTransform); + evas_transform_rotate(luaL_checknumber(L, 2), &(obj->et)); + return 0; +} + +static int +_edje_lua_transform_fn_translate(lua_State *L) +{ + Edje_Lua_Transform *obj = _edje_lua_checkudata(L, 1, &mTransform); + evas_transform_translate(luaL_checknumber(L, 2), luaL_checknumber(L, 3), &(obj->et)); + return 0; +} + +static int +_edje_lua_transform_fn_scale(lua_State *L) +{ + Edje_Lua_Transform *obj = _edje_lua_checkudata(L, 1, &mTransform); + evas_transform_scale(luaL_checknumber(L, 2), luaL_checknumber(L, 3), &(obj->et)); + return 0; +} + +static int +_edje_lua_transform_fn_shear(lua_State *L) +{ + Edje_Lua_Transform *obj = _edje_lua_checkudata(L, 1, &mTransform); + evas_transform_shear(luaL_checknumber(L, 2), luaL_checknumber(L, 3), &(obj->et)); + return 0; +} + +static int +_edje_lua_transform_fn_compose(lua_State *L) +{ + Edje_Lua_Transform *obj = _edje_lua_checkudata(L, 1, &mTransform); + Edje_Lua_Transform *tar = _edje_lua_checkudata(L, 2, &mTransform); + evas_transform_compose(&(tar->et), &(obj->et)); + return 0; +} + +const luaL_Reg lTransform_fn[] = { + {"identity", _edje_lua_transform_fn_identity}, + {"rotate", _edje_lua_transform_fn_rotate}, + {"translate", _edje_lua_transform_fn_translate}, + {"scale", _edje_lua_transform_fn_scale}, + {"shear", _edje_lua_transform_fn_shear}, + {"compose", _edje_lua_transform_fn_compose}, + {NULL, NULL} // sentinel +}; + +/* + * Lua Edje Transition bindings + */ + +const luaL_Reg lTransition_get[]; + +const luaL_Reg lTransition_set[]; + +const luaL_Reg lTransition_fn[]; + +const Edje_Lua_Reg mTransition = { + lNil, + lTransition_get, + lTransition_set, + lTransition_fn +}; + +const Edje_Lua_Reg *cTransition[] = { + &mClass, + &mTransition, + NULL // sentinel +}; + +const luaL_Reg lTransition_get[] = { + {NULL, NULL} // sentinel +}; + +const luaL_Reg lTransition_set[] = { + {NULL, NULL} // sentinel +}; + +const luaL_Reg lTransition_fn[] = { + {NULL, NULL} // sentinel +}; + +const luaL_Reg lObject_get[]; + +const luaL_Reg lObject_set[]; + +const luaL_Reg lObject_fn[]; + +const Edje_Lua_Reg mObject = { + lNil, + lObject_get, + lObject_set, + lObject_fn +}; + +static void +_edje_lua_object_del_cb(void *data, __UNUSED__ Evas * e, Evas_Object * obj, __UNUSED__ void *event_info) +{ + //printf("_edje_lua_object_delete_cb\n"); + lua_State *L = data; + _edje_lua_get_reg(L, obj); + Edje_Lua_Evas_Object *udata = _edje_lua_checkudata(L, -1, &mObject); + lua_pop(L, 1); + _edje_lua_free_reg(L, udata); // created in EDJE_LUA_SCRIPT_FN_ADD + _edje_lua_free_reg(L, obj); // created in EDJE_LUA_SCRIPT_FN_ADD + + Edje_Lua_Ref *ref; + EINA_LIST_FREE(udata->cb, ref) + _edje_lua_free_ref(L, ref); +} + +static int +_edje_lua_object_fn_del(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + + if (obj->eo) + { + evas_object_del(obj->eo); + obj->eo = NULL; + obj->ed = NULL; + } + return 0; +} + +static int +_edje_lua_object_fn_show(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + evas_object_show(obj->eo); + return 0; +} + +static int +_edje_lua_object_fn_hide(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + evas_object_hide(obj->eo); + return 0; +} + +static int +_edje_lua_object_fn_move(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + //printf ("%i %i %i %i\n", obj->ed->x, obj->ed->y, luaL_checkint (L, 2), luaL_checkint (L, 3)); + evas_object_move(obj->eo, + obj->ed->x + luaL_checkint(L, 2), + obj->ed->y + luaL_checkint(L, 3)); + return 0; +} + +static int +_edje_lua_object_fn_resize(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + evas_object_resize(obj->eo, luaL_checkint(L, 2), luaL_checkint(L, 3)); + return 0; +} + +static int +_edje_lua_object_fn_raise(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + evas_object_raise(obj->eo); + return 0; +} + +static int +_edje_lua_object_fn_lower(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + evas_object_lower(obj->eo); + return 0; +} + +static int +_edje_lua_object_fn_stack_above(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + Edje_Lua_Evas_Object *tar = _edje_lua_checkudata(L, 2, &mObject); + evas_object_stack_above(obj->eo, tar->eo); + return 0; +} + +static int +_edje_lua_object_fn_stack_below(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + Edje_Lua_Evas_Object *tar = _edje_lua_checkudata(L, 2, &mObject); + evas_object_stack_below(obj->eo, tar->eo); + return 0; +} + +static int +_edje_lua_object_fn_clip_unset(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + evas_object_clip_unset(obj->eo); + return 0; +} + +const luaL_Reg lObject_fn[] = { + {"del", _edje_lua_object_fn_del}, + {"show", _edje_lua_object_fn_show}, + {"hide", _edje_lua_object_fn_hide}, + {"move", _edje_lua_object_fn_move}, + {"resize", _edje_lua_object_fn_resize}, + {"raise", _edje_lua_object_fn_raise}, + {"lower", _edje_lua_object_fn_lower}, + {"stack_above", _edje_lua_object_fn_stack_above}, + {"stack_below", _edje_lua_object_fn_stack_below}, + {"clip_unset", _edje_lua_object_fn_clip_unset}, + {NULL, NULL} // sentinel +}; + +static int +_edje_lua_object_get_name(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + lua_pushstring(L, evas_object_name_get(obj->eo)); + return 1; +} + +static int +_edje_lua_object_get_geometry(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + int x, y, w, h; + evas_object_geometry_get(obj->eo, &x, &y, &w, &h); + lua_createtable(L, 4, 0); + lua_pushnumber(L, x); + lua_rawseti(L, -2, 1); + lua_pushnumber(L, y); + lua_rawseti(L, -2, 2); + lua_pushnumber(L, w); + lua_rawseti(L, -2, 3); + lua_pushnumber(L, h); + lua_rawseti(L, -2, 4); + return 1; +} + +static int +_edje_lua_object_get_type(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + lua_pushstring(L, evas_object_type_get(obj->eo)); + return 1; +} + +static int +_edje_lua_object_get_layer(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + lua_pushnumber(L, evas_object_layer_get(obj->eo)); + return 1; +} + +static int +_edje_lua_object_get_above(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + Evas_Object *above = evas_object_above_get(obj->eo); + _edje_lua_get_reg(L, above); + // TODO create object if it does not already exist? + return 1; +} + +static int +_edje_lua_object_get_below(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + Evas_Object *below = evas_object_below_get(obj->eo); + _edje_lua_get_reg(L, below); + // TODO create object if it does not already exist? + return 1; +} + +static int +_edje_lua_object_get_size_hint_min(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + int w, h; + evas_object_size_hint_min_get(obj->eo, &w, &h); + lua_createtable(L, 2, 0); + lua_pushnumber(L, w); + lua_rawseti(L, -2, 1); + lua_pushnumber(L, h); + lua_rawseti(L, -2, 2); + return 1; +} + +static int +_edje_lua_object_get_size_hint_max(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + int w, h; + evas_object_size_hint_max_get(obj->eo, &w, &h); + lua_createtable(L, 2, 0); + lua_pushnumber(L, w); + lua_rawseti(L, -2, 1); + lua_pushnumber(L, h); + lua_rawseti(L, -2, 2); + return 1; +} + +static int +_edje_lua_object_get_size_hint_request(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + int w, h; + evas_object_size_hint_request_get(obj->eo, &w, &h); + lua_createtable(L, 2, 0); + lua_pushnumber(L, w); + lua_rawseti(L, -2, 1); + lua_pushnumber(L, h); + lua_rawseti(L, -2, 2); + return 1; +} + +static int +_edje_lua_object_get_size_hint_aspect(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + Evas_Aspect_Control a; + int w, h; + evas_object_size_hint_aspect_get(obj->eo, &a, &w, &h); + lua_createtable(L, 3, 0); + lua_pushnumber(L, a); + lua_rawseti(L, -2, 1); + lua_pushnumber(L, w); + lua_rawseti(L, -2, 2); + lua_pushnumber(L, h); + lua_rawseti(L, -2, 3); + return 1; +} + +static int +_edje_lua_object_get_size_hint_align(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + double w, h; + evas_object_size_hint_align_get(obj->eo, &w, &h); + lua_createtable(L, 2, 0); + lua_pushnumber(L, w); + lua_rawseti(L, -2, 1); + lua_pushnumber(L, h); + lua_rawseti(L, -2, 2); + return 1; +} + +static int +_edje_lua_object_get_size_hint_weight(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + double w, h; + evas_object_size_hint_weight_get(obj->eo, &w, &h); + lua_createtable(L, 2, 0); + lua_pushnumber(L, w); + lua_rawseti(L, -2, 1); + lua_pushnumber(L, h); + lua_rawseti(L, -2, 2); + return 1; +} + +static int +_edje_lua_object_get_size_hint_padding(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + int l, r, t, b; + evas_object_size_hint_padding_get(obj->eo, &l, &r, &t, &b); + lua_createtable(L, 4, 0); + lua_pushnumber(L, l); + lua_rawseti(L, -2, 1); + lua_pushnumber(L, r); + lua_rawseti(L, -2, 2); + lua_pushnumber(L, t); + lua_rawseti(L, -2, 3); + lua_pushnumber(L, b); + lua_rawseti(L, -2, 4); + return 1; +} + +static int +_edje_lua_object_get_visible(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + lua_pushboolean(L, evas_object_visible_get(obj->eo)); + return 1; +} + +static int +_edje_lua_object_get_render_op(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + lua_pushnumber(L, evas_object_render_op_get(obj->eo)); + return 1; +} + +static int +_edje_lua_object_get_anti_alias(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + lua_pushboolean(L, evas_object_anti_alias_get(obj->eo)); + return 1; +} + +static int +_edje_lua_object_get_scale(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + lua_pushnumber(L, evas_object_scale_get(obj->eo)); + return 1; +} + +static int +_edje_lua_object_get_color(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + int r, g, b, a; + evas_object_color_get(obj->eo, &r, &g, &b, &a); + lua_createtable(L, 4, 0); + lua_pushnumber(L, r); + lua_rawseti(L, -2, 1); + lua_pushnumber(L, g); + lua_rawseti(L, -2, 2); + lua_pushnumber(L, b); + lua_rawseti(L, -2, 3); + lua_pushnumber(L, a); + lua_rawseti(L, -2, 4); + return 1; +} + +static int +_edje_lua_object_get_color_interpolation(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + lua_pushnumber(L, evas_object_color_interpolation_get(obj->eo)); + return 1; +} + +static int +_edje_lua_object_get_clip(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + Evas_Object *clip = evas_object_clip_get(obj->eo); + _edje_lua_get_reg(L, clip); + // TODO create object if it does not already exist? + return 1; +} + +static int +_edje_lua_object_get_clipees(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + Eina_List *clipees = (Eina_List *) evas_object_clipees_get(obj->eo); + Eina_List *l; + Evas_Object *clip; + int i = 1; + lua_createtable(L, eina_list_count(clipees), 0); + EINA_LIST_FOREACH(clipees, l, clip) + { + _edje_lua_get_reg(L, clip); + // TODO create object if it does not already exist? + lua_rawseti(L, -2, i++); + } + return 1; +} + +static int +_edje_lua_object_get_evas(lua_State *L) +{ + //Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + lua_pushnil(L); + // FIXME implement Evas class in the first place? + return 1; +} + +static int +_edje_lua_object_get_pass_events(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + lua_pushboolean(L, evas_object_pass_events_get(obj->eo)); + return 1; +} + +static int +_edje_lua_object_get_repeat_events(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + lua_pushboolean(L, evas_object_repeat_events_get(obj->eo)); + return 1; +} + +static int +_edje_lua_object_get_propagate_events(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + lua_pushboolean(L, evas_object_propagate_events_get(obj->eo)); + return 1; +} + +static int +_edje_lua_object_get_focus(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + lua_pushboolean(L, evas_object_focus_get(obj->eo)); + return 1; +} + +static int +_edje_lua_object_get_pointer_mode(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + lua_pushnumber(L, evas_object_pointer_mode_get(obj->eo)); + return 1; +} + +static int +_edje_lua_object_get_precise_is_inside(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + lua_pushboolean(L, evas_object_precise_is_inside_get(obj->eo)); + return 1; +} + +static int +_edje_lua_object_get_mouse_events(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + lua_pushboolean(L, obj->mouse_events); + return 1; +} + +const luaL_Reg lObject_get[] = { + {"name", _edje_lua_object_get_name}, + {"geometry", _edje_lua_object_get_geometry}, + {"type", _edje_lua_object_get_type}, + {"layer", _edje_lua_object_get_layer}, + {"above", _edje_lua_object_get_above}, + {"below", _edje_lua_object_get_below}, + {"size_hint_min", _edje_lua_object_get_size_hint_min}, + {"size_hint_max", _edje_lua_object_get_size_hint_max}, + {"size_hint_request", _edje_lua_object_get_size_hint_request}, + {"size_hint_aspect", _edje_lua_object_get_size_hint_aspect}, + {"size_hint_align", _edje_lua_object_get_size_hint_align}, + {"size_hint_weight", _edje_lua_object_get_size_hint_weight}, + {"size_hint_padding", _edje_lua_object_get_size_hint_padding}, + {"visible", _edje_lua_object_get_visible}, + {"render_op", _edje_lua_object_get_render_op}, + {"anti_alias", _edje_lua_object_get_anti_alias}, + {"scale", _edje_lua_object_get_scale}, + {"color", _edje_lua_object_get_color}, + {"color_interpolation", _edje_lua_object_get_color_interpolation}, + {"clip", _edje_lua_object_get_clip}, + {"clipees", _edje_lua_object_get_clipees}, + {"evas", _edje_lua_object_get_evas}, + {"pass_events", _edje_lua_object_get_pass_events}, + {"repeat_events", _edje_lua_object_get_repeat_events}, + {"propagate_events", _edje_lua_object_get_propagate_events}, + {"focus", _edje_lua_object_get_focus}, + {"pointer_mode", _edje_lua_object_get_pointer_mode}, + {"precise_is_inside", _edje_lua_object_get_precise_is_inside}, + {"mouse_events", _edje_lua_object_get_mouse_events}, + {NULL, NULL} // sentinel +}; + +static int +_edje_lua_object_set_name(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + evas_object_name_set(obj->eo, luaL_checkstring(L, 2)); + return 0; +} + +static int +_edje_lua_object_set_layer(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + evas_object_layer_set(obj->eo, luaL_checkint(L, 2)); + return 0; +} + +static int +_edje_lua_object_set_size_hint_min(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + luaL_checktype(L, 2, LUA_TTABLE); + lua_rawgeti(L, 2, 1); + lua_rawgeti(L, 2, 2); + evas_object_size_hint_min_set(obj->eo, + luaL_checkint(L, -2), + luaL_checkint(L, -1)); + return 0; +} + +static int +_edje_lua_object_set_size_hint_max(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + luaL_checktype(L, 2, LUA_TTABLE); + lua_rawgeti(L, 2, 1); + lua_rawgeti(L, 2, 2); + evas_object_size_hint_max_set(obj->eo, + luaL_checkint(L, -2), + luaL_checkint(L, -1)); + return 0; +} + +static int +_edje_lua_object_set_size_hint_request(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + luaL_checktype(L, 2, LUA_TTABLE); + lua_rawgeti(L, 2, 1); + lua_rawgeti(L, 2, 2); + evas_object_size_hint_request_set(obj->eo, + luaL_checkint(L, -2), + luaL_checkint(L, -1)); + return 0; +} + +static int +_edje_lua_object_set_size_hint_aspect(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + luaL_checktype(L, 2, LUA_TTABLE); + lua_rawgeti(L, 2, 1); + lua_rawgeti(L, 2, 2); + lua_rawgeti(L, 2, 3); + evas_object_size_hint_aspect_set(obj->eo, + luaL_checkint(L, -3), + luaL_checkint(L, -2), + luaL_checkint(L, -1)); + return 0; +} + +static int +_edje_lua_object_set_size_hint_align(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + luaL_checktype(L, 2, LUA_TTABLE); + lua_rawgeti(L, 2, 1); + lua_rawgeti(L, 2, 2); + evas_object_size_hint_align_set(obj->eo, + luaL_checknumber(L, -2), + luaL_checknumber(L, -1)); + return 0; +} + +static int +_edje_lua_object_set_size_hint_weight(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + luaL_checktype(L, 2, LUA_TTABLE); + lua_rawgeti(L, 2, 1); + lua_rawgeti(L, 2, 2); + evas_object_size_hint_weight_set(obj->eo, + luaL_checknumber(L, -2), + luaL_checknumber(L, -1)); + return 0; +} + +static int +_edje_lua_object_set_size_hint_padding(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + luaL_checktype(L, 2, LUA_TTABLE); + lua_rawgeti(L, 2, 1); + lua_rawgeti(L, 2, 2); + lua_rawgeti(L, 2, 3); + lua_rawgeti(L, 2, 4); + evas_object_size_hint_padding_set(obj->eo, + luaL_checknumber(L, -4), + luaL_checknumber(L, -3), + luaL_checknumber(L, -2), + luaL_checknumber(L, -1)); + return 0; +} + +static int +_edje_lua_object_set_render_op(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + evas_object_render_op_set(obj->eo, luaL_checkint(L, 2)); + return 0; +} + +static int +_edje_lua_object_set_anti_alias(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + evas_object_anti_alias_set(obj->eo, lua_toboolean(L, 2)); + return 0; +} + +static int +_edje_lua_object_set_scale(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + evas_object_scale_set(obj->eo, luaL_checknumber(L, 2)); + return 0; +} + +static int +_edje_lua_object_set_color(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + luaL_checktype(L, 2, LUA_TTABLE); + lua_rawgeti(L, 2, 1); + lua_rawgeti(L, 2, 2); + lua_rawgeti(L, 2, 3); + lua_rawgeti(L, 2, 4); + evas_object_color_set(obj->eo, + luaL_checkint(L, -4), + luaL_checkint(L, -3), + luaL_checkint(L, -2), + luaL_checkint(L, -1)); + return 0; +} + +static int +_edje_lua_object_set_color_interpolation(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + evas_object_color_interpolation_set(obj->eo, luaL_checkint(L, 2)); + return 0; +} + +static int +_edje_lua_object_set_clip(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + Edje_Lua_Evas_Object *clip = _edje_lua_checkudata(L, 2, &mObject); + evas_object_clip_set(obj->eo, clip->eo); + return 0; +} + +static int +_edje_lua_object_set_pass_events(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + evas_object_pass_events_set(obj->eo, lua_toboolean(L, 2)); + return 0; +} + +static int +_edje_lua_object_set_repeat_events(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + evas_object_repeat_events_set(obj->eo, lua_toboolean(L, 2)); + return 0; +} + +static int +_edje_lua_object_set_propagate_events(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + evas_object_propagate_events_set(obj->eo, lua_toboolean(L, 2)); + return 0; +} + +static int +_edje_lua_object_set_focus(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + evas_object_focus_set(obj->eo, lua_toboolean(L, 2)); + return 0; +} + +static int +_edje_lua_object_set_pointer_mode(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + evas_object_pointer_mode_set(obj->eo, luaL_checkint(L, 2)); + return 0; +} + +static int +_edje_lua_object_set_precise_is_inside(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + evas_object_precise_is_inside_set(obj->eo, lua_toboolean(L, 2)); + return 0; +} + +#define OBJECT_CB_MACRO(KEY) \ + lua_State *L = data; \ + _edje_lua_get_reg(L, obj); \ + lua_getfield(L, -1, KEY); \ + if (lua_type(L, -1) != LUA_TFUNCTION) \ + { \ + lua_pop(L, 2); \ + return; \ + } \ + lua_insert(L, -2); + +static void +_edje_lua_object_cb_mouse_in(void *data, __UNUSED__ Evas * e, Evas_Object * obj, + void *event_info) +{ + OBJECT_CB_MACRO("mouse_in"); + Evas_Event_Mouse_In * ev = event_info; + int err_code; + + lua_pushnumber(L, ev->output.x); + lua_pushnumber(L, ev->output.y); + lua_pushnumber(L, ev->canvas.x); + lua_pushnumber(L, ev->canvas.y); + + if ((err_code = lua_pcall(L, 5, 0, 0))) + _edje_lua_error(L, err_code); +} + +static void +_edje_lua_object_cb_mouse_out(void *data, __UNUSED__ Evas * e, Evas_Object * obj, + void *event_info) +{ + OBJECT_CB_MACRO("mouse_out"); + Evas_Event_Mouse_In * ev = event_info; + int err_code; + + lua_pushnumber(L, ev->output.x); + lua_pushnumber(L, ev->output.y); + lua_pushnumber(L, ev->canvas.x); + lua_pushnumber(L, ev->canvas.y); + + if ((err_code = lua_pcall(L, 5, 0, 0))) + _edje_lua_error(L, err_code); +} + +static void +_edje_lua_object_cb_mouse_down(void *data, __UNUSED__ Evas * e, Evas_Object * obj, + void *event_info) +{ + OBJECT_CB_MACRO("mouse_down"); + Evas_Event_Mouse_Down * ev = event_info; + int err_code; + + lua_pushnumber(L, ev->button); + lua_pushnumber(L, ev->output.x); + lua_pushnumber(L, ev->output.y); + lua_pushnumber(L, ev->canvas.x); + lua_pushnumber(L, ev->canvas.y); + + if ((err_code = lua_pcall(L, 6, 0, 0))) + _edje_lua_error(L, err_code); +} + +static void +_edje_lua_object_cb_mouse_up(void *data, __UNUSED__ Evas * e, Evas_Object * obj, + void *event_info) +{ + OBJECT_CB_MACRO("mouse_up"); + Evas_Event_Mouse_Up * ev = event_info; + int err_code; + + lua_pushnumber(L, ev->button); + lua_pushnumber(L, ev->output.x); + lua_pushnumber(L, ev->output.y); + lua_pushnumber(L, ev->canvas.x); + lua_pushnumber(L, ev->canvas.y); + + if ((err_code = lua_pcall(L, 6, 0, 0))) + _edje_lua_error(L, err_code); +} + +static void +_edje_lua_object_cb_mouse_move(void *data, __UNUSED__ Evas * e, Evas_Object * obj, + void *event_info) +{ + OBJECT_CB_MACRO("mouse_move"); + Evas_Event_Mouse_Move * ev = event_info; + int err_code; + + lua_pushnumber(L, ev->buttons); + lua_pushnumber(L, ev->cur.output.x); + lua_pushnumber(L, ev->cur.output.y); + lua_pushnumber(L, ev->cur.canvas.x); + lua_pushnumber(L, ev->cur.canvas.y); + + if ((err_code = lua_pcall(L, 6, 0, 0))) + _edje_lua_error(L, err_code); +} + +static void +_edje_lua_object_cb_mouse_wheel(void *data, __UNUSED__ Evas * e, Evas_Object * obj, + void *event_info) +{ + OBJECT_CB_MACRO("mouse_wheel"); + Evas_Event_Mouse_Wheel * ev = event_info; + int err_code; + + lua_pushnumber(L, ev->z); + lua_pushnumber(L, ev->output.x); + lua_pushnumber(L, ev->output.y); + lua_pushnumber(L, ev->canvas.x); + lua_pushnumber(L, ev->canvas.y); + + if ((err_code = lua_pcall(L, 6, 0, 0))) + _edje_lua_error(L, err_code); +} + +static int +_edje_lua_object_set_mouse_events(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + obj->mouse_events = lua_toboolean(L, 2); + if (obj->mouse_events) + { + // add all mouse events + evas_object_event_callback_add(obj->eo, EVAS_CALLBACK_MOUSE_IN, _edje_lua_object_cb_mouse_in, L); + evas_object_event_callback_add(obj->eo, EVAS_CALLBACK_MOUSE_OUT, _edje_lua_object_cb_mouse_out, L); + evas_object_event_callback_add(obj->eo, EVAS_CALLBACK_MOUSE_DOWN, _edje_lua_object_cb_mouse_down, L); + evas_object_event_callback_add(obj->eo, EVAS_CALLBACK_MOUSE_UP, _edje_lua_object_cb_mouse_up, L); + evas_object_event_callback_add(obj->eo, EVAS_CALLBACK_MOUSE_MOVE, _edje_lua_object_cb_mouse_move, L); + evas_object_event_callback_add(obj->eo, EVAS_CALLBACK_MOUSE_WHEEL, _edje_lua_object_cb_mouse_wheel, L); + } + else + { + // delete all mouse events + evas_object_event_callback_del(obj->eo, EVAS_CALLBACK_MOUSE_IN, _edje_lua_object_cb_mouse_in); + evas_object_event_callback_del(obj->eo, EVAS_CALLBACK_MOUSE_OUT, _edje_lua_object_cb_mouse_out); + evas_object_event_callback_del(obj->eo, EVAS_CALLBACK_MOUSE_DOWN, _edje_lua_object_cb_mouse_down); + evas_object_event_callback_del(obj->eo, EVAS_CALLBACK_MOUSE_UP, _edje_lua_object_cb_mouse_up); + evas_object_event_callback_del(obj->eo, EVAS_CALLBACK_MOUSE_MOVE, _edje_lua_object_cb_mouse_move); + evas_object_event_callback_del(obj->eo, EVAS_CALLBACK_MOUSE_WHEEL, _edje_lua_object_cb_mouse_wheel); + } + return 0; +} + +const luaL_Reg lObject_set[] = { + {"name", _edje_lua_object_set_name}, + {"layer", _edje_lua_object_set_layer}, + {"size_hint_min", _edje_lua_object_set_size_hint_min}, + {"size_hint_max", _edje_lua_object_set_size_hint_max}, + {"size_hint_request", _edje_lua_object_set_size_hint_request}, + {"size_hint_aspect", _edje_lua_object_set_size_hint_aspect}, + {"size_hint_align", _edje_lua_object_set_size_hint_align}, + {"size_hint_weight", _edje_lua_object_set_size_hint_weight}, + {"size_hint_padding", _edje_lua_object_set_size_hint_padding}, + {"render_op", _edje_lua_object_set_render_op}, + {"anti_alias", _edje_lua_object_set_anti_alias}, + {"scale", _edje_lua_object_set_scale}, + {"color", _edje_lua_object_set_color}, + {"color_interpolation", _edje_lua_object_set_color_interpolation}, + {"clip", _edje_lua_object_set_clip}, + {"pass_events", _edje_lua_object_set_pass_events}, + {"repeat_events", _edje_lua_object_set_repeat_events}, + {"propagate_events", _edje_lua_object_set_propagate_events}, + {"focus", _edje_lua_object_set_focus}, + {"pointer_mode", _edje_lua_object_get_pointer_mode}, + {"precise_is_inside", _edje_lua_object_get_precise_is_inside}, + {"mouse_events", _edje_lua_object_set_mouse_events}, + {NULL, NULL} // sentinel +}; + +const Edje_Lua_Reg *cRectangle[] = { + &mClass, + &mObject, + NULL // sentinel +}; + +const luaL_Reg lImage_get[]; + +const luaL_Reg lImage_set[]; + +const Edje_Lua_Reg mImage = { + lNil, + lImage_get, + lImage_set, + lNil +}; + +const Edje_Lua_Reg *cImage[] = { + &mClass, + &mObject, + &mImage, + NULL // sentinel +}; + +static int +_edje_lua_image_get_size(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mImage); + int w, h; + evas_object_image_size_get(obj->eo, &w, &h); + lua_createtable(L, 2, 0); + lua_pushnumber(L, w); + lua_rawseti(L, -2, 1); + lua_pushnumber(L, h); + lua_rawseti(L, -2, 2); + return 1; +}; + +const luaL_Reg lImage_get[] = { + {"size", _edje_lua_image_get_size}, + {NULL, NULL} // sentinel +}; + +static int +_edje_lua_image_set_file(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mImage); + int id = edje_edit_image_id_get(obj->ed->obj, luaL_checkstring(L, 2)); + char buf[256]; + sprintf(buf, "edje/images/%i", id); + evas_object_image_file_set(obj->eo, obj->ed->path, buf); + return 0; +} + +static int +_edje_lua_image_set_fill(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mImage); + luaL_checktype(L, 2, LUA_TTABLE); + lua_rawgeti(L, 2, 1); + lua_rawgeti(L, 2, 2); + lua_rawgeti(L, 2, 3); + lua_rawgeti(L, 2, 4); + evas_object_image_fill_set(obj->eo, + luaL_checkint(L, -4), + luaL_checkint(L, -3), + luaL_checkint(L, -2), luaL_checkint(L, -1)); + return 0; +} + +static int +_edje_lua_image_set_fill_transform(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mImage); + Edje_Lua_Transform *tar = _edje_lua_checkudata(L, 2, &mTransform); + evas_object_image_fill_transform_set(obj->eo, &(tar->et)); + return 0; +} + +static int +_edje_lua_image_set_alpha(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mObject); + evas_object_image_alpha_set(obj->eo, lua_toboolean(L, 2)); + return 0; +} + +const luaL_Reg lImage_set[] = { + {"file", _edje_lua_image_set_file}, + {"fill", _edje_lua_image_set_fill}, + {"fill_transform", _edje_lua_image_set_fill_transform}, + {"alpha", _edje_lua_image_set_alpha}, + {NULL, NULL} // sentinel +}; + +const luaL_Reg lLine_get[]; +const luaL_Reg lLine_set[]; + +const Edje_Lua_Reg mLine = { + lNil, + lLine_get, + lLine_set, + lNil +}; + +const Edje_Lua_Reg *cLine[] = { + &mClass, + &mObject, + &mLine, + NULL // sentinel +}; + +static int +_edje_lua_line_get_xy(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mLine); + int x1, y1, x2, y2; + evas_object_line_xy_get(obj->eo, &x1, &y1, &x2, &y2); + lua_createtable(L, 4, 0); + lua_pushnumber(L, x1); lua_rawseti(L, -2, 1); + lua_pushnumber(L, y1); lua_rawseti(L, -2, 2); + lua_pushnumber(L, x2); lua_rawseti(L, -2, 3); + lua_pushnumber(L, y2); lua_rawseti(L, -2, 4); + return 1; +} + +const luaL_Reg lLine_get[] = { + {"xy", _edje_lua_line_get_xy}, + {NULL, NULL} // sentinel +}; + +static int +_edje_lua_line_set_xy(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mLine); + luaL_checktype(L, 2, LUA_TTABLE); + lua_rawgeti(L, 2, 1); + lua_rawgeti(L, 2, 2); + lua_rawgeti(L, 2, 3); + lua_rawgeti(L, 2, 4); + evas_object_line_xy_set(obj->eo, + luaL_checkint(L, -4), + luaL_checkint(L, -3), + luaL_checkint(L, -2), + luaL_checkint(L, -1)); + return 0; +} + +const luaL_Reg lLine_set[] = { + {"xy", _edje_lua_line_set_xy}, + {NULL, NULL} // sentinel +}; + +const luaL_Reg lPolygon_fn[]; + +const Edje_Lua_Reg mPolygon = { + lNil, + lNil, + lNil, + lPolygon_fn +}; + +const Edje_Lua_Reg *cPolygon[] = { + &mClass, + &mObject, + &mPolygon, + NULL // sentinel +}; + +static int +_edje_lua_polygon_fn_point_add(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mPolygon); + evas_object_polygon_point_add(obj->eo, + luaL_checknumber(L, 2), + luaL_checknumber(L, 3)); + return 0; +} + +static int +_edje_lua_polygon_fn_points_clear(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mPolygon); + evas_object_polygon_points_clear(obj->eo); + return 0; +} + +const luaL_Reg lPolygon_fn[] = { + {"point_add", _edje_lua_polygon_fn_point_add}, + {"points_clear", _edje_lua_polygon_fn_points_clear}, + {NULL, NULL} // sentinel +}; + +const luaL_Reg lTable_get[]; + +const luaL_Reg lTable_set[]; + +const luaL_Reg lTable_fn[]; + +const Edje_Lua_Reg mTable = { + lNil, + lTable_get, + lTable_set, + lTable_fn +}; + +const Edje_Lua_Reg *cTable[] = { + &mClass, + &mObject, + &mTable, + NULL // sentinel +}; + +static int +_edje_lua_table_get_homogeneous(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mTable); + lua_pushnumber(L, evas_object_table_homogeneous_get(obj->eo)); + return 1; +} + +static int +_edje_lua_table_get_padding(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mTable); + int x, y; + evas_object_table_padding_get(obj->eo, &x, &y); + lua_createtable(L, 2, 0); + lua_pushnumber(L, x); + lua_rawseti(L, -2, 1); + lua_pushnumber(L, y); + lua_rawseti(L, -2, 2); + return 1; +} + +static int +_edje_lua_table_get_align(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mTable); + double x, y; + evas_object_table_align_get(obj->eo, &x, &y); + lua_createtable(L, 2, 0); + lua_pushnumber(L, x); + lua_rawseti(L, -2, 1); + lua_pushnumber(L, y); + lua_rawseti(L, -2, 2); + return 1; +} + +static int +_edje_lua_table_get_col_row_size(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mTable); + int x, y; + evas_object_table_col_row_size_get(obj->eo, &x, &y); + lua_createtable(L, 2, 0); + lua_pushnumber(L, x); + lua_rawseti(L, -2, 1); + lua_pushnumber(L, y); + lua_rawseti(L, -2, 2); + return 1; +} + +static int +_edje_lua_table_get_children(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mTable); + Eina_List *children = (Eina_List *) evas_object_table_children_get(obj->eo); + Eina_List *l; + Evas_Object *child; + int i = 1; + lua_createtable(L, eina_list_count(children), 0); + EINA_LIST_FOREACH(children, l, child) + { + _edje_lua_get_reg(L, child); + // TODO create object if it does not already exist? + lua_rawseti(L, -2, i++); + } + return 1; +} + +const luaL_Reg lTable_get[] = { + {"homogeneous", _edje_lua_table_get_homogeneous}, + {"padding", _edje_lua_table_get_padding}, + {"align", _edje_lua_table_get_align}, + {"col_row_size", _edje_lua_table_get_col_row_size}, + {"children", _edje_lua_table_get_children}, + {NULL, NULL} // sentinel +}; + +static int +_edje_lua_table_set_homogeneous(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mTable); + evas_object_table_homogeneous_set(obj->eo, + luaL_checkint(L, 2)); + return 0; +} + +static int +_edje_lua_table_set_padding(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mTable); + luaL_checktype(L, 2, LUA_TTABLE); + lua_rawgeti(L, 2, 1); + lua_rawgeti(L, 2, 2); + evas_object_table_padding_set(obj->eo, + luaL_checkint(L, -2), + luaL_checkint(L, -1)); + return 0; +} + +static int +_edje_lua_table_set_align(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mTable); + luaL_checktype(L, 2, LUA_TTABLE); + lua_rawgeti(L, 2, 1); + lua_rawgeti(L, 2, 2); + evas_object_table_align_set(obj->eo, + luaL_checknumber(L, -2), + luaL_checknumber(L, -1)); + return 0; +} + +const luaL_Reg lTable_set[] = { + {"homogeneous", _edje_lua_table_set_homogeneous}, + {"padding", _edje_lua_table_set_padding}, + {"align", _edje_lua_table_set_align}, + {NULL, NULL} // sentinel +}; + +static int +_edje_lua_table_fn_pack(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mTable); + Edje_Lua_Evas_Object *tar = _edje_lua_checkudata(L, 2, &mObject); + lua_pushboolean(L, + evas_object_table_pack(obj->eo, tar->eo, + luaL_checkint(L, 3), + luaL_checkint(L, 4), + luaL_checkint(L, 5), + luaL_checkint(L, 6))); + return 1; +} + +static int +_edje_lua_table_fn_unpack(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mTable); + Edje_Lua_Evas_Object *tar = _edje_lua_checkudata(L, 2, &mObject); + lua_pushboolean(L, + evas_object_table_unpack(obj->eo, tar->eo)); + return 1; +} + +static int +_edje_lua_table_fn_clear(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mTable); + evas_object_table_clear(obj->eo, lua_toboolean(L, 2)); + return 0; +} + +const luaL_Reg lTable_fn[] = { + {"pack", _edje_lua_table_fn_pack}, + {"unpack", _edje_lua_table_fn_unpack}, + {"clear", _edje_lua_table_fn_clear}, + {NULL, NULL} // sentinel +}; + +const luaL_Reg lDescription_get[]; + +const luaL_Reg lDescription_set[]; + +const Edje_Lua_Reg mDescription = { + lNil, + lDescription_get, + lDescription_set, + lNil +}; + +const Edje_Lua_Reg *cDescription[] = { + &mClass, + &mObject, + &mDescription, + NULL // sentinel +}; + +static int +_edje_lua_description_get_alignment(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if (!obj->rp->custom) return 0; + lua_createtable(L, 2, 0); + lua_pushnumber(L, TO_DOUBLE(obj->rp->custom->description->align.x)); + lua_rawseti(L, -2, 1); + lua_pushnumber(L, TO_DOUBLE(obj->rp->custom->description->align.y)); + lua_rawseti(L, -2, 1); + return 1; +} + +static int +_edje_lua_description_get_min(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if (!obj->rp->custom) return 0; + lua_createtable(L, 2, 0); + lua_pushnumber(L, obj->rp->custom->description->min.w); + lua_rawseti(L, -2, 1); + lua_pushnumber(L, obj->rp->custom->description->min.h); + lua_rawseti(L, -2, 1); + return 1; +} + +static int +_edje_lua_description_get_max(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if (!obj->rp->custom) return 0; + lua_createtable(L, 2, 0); + lua_pushnumber(L, obj->rp->custom->description->max.w); + lua_rawseti(L, -2, 1); + lua_pushnumber(L, obj->rp->custom->description->max.h); + lua_rawseti(L, -2, 1); + return 1; +} + +static int +_edje_lua_description_get_step(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if (!obj->rp->custom) return 0; + lua_createtable(L, 2, 0); + lua_pushnumber(L, obj->rp->custom->description->step.x); + lua_rawseti(L, -2, 1); + lua_pushnumber(L, obj->rp->custom->description->step.y); + lua_rawseti(L, -2, 1); + return 1; +} + +static int +_edje_lua_description_get_aspect(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if (!obj->rp->custom) return 0; + lua_createtable(L, 2, 0); + lua_pushnumber(L, TO_DOUBLE(obj->rp->custom->description->aspect.min)); + lua_rawseti(L, -2, 1); + lua_pushnumber(L, TO_DOUBLE(obj->rp->custom->description->aspect.max)); + lua_rawseti(L, -2, 1); + return 1; +} + +static int +_edje_lua_description_get_aspect_pref(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if (!obj->rp->custom) return 0; + lua_pushnumber(L, obj->rp->custom->description->aspect.prefer); + return 1; +} + +static int +_edje_lua_description_get_color(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + /* check whether this part has a "custom" state */ + if (!obj->rp->custom) return 0; + lua_createtable(L, 4, 0); + lua_pushnumber(L, obj->rp->custom->description->color.r); + lua_rawseti(L, -2, 1); + lua_pushnumber(L, obj->rp->custom->description->color.g); + lua_rawseti(L, -2, 2); + lua_pushnumber(L, obj->rp->custom->description->color.b); + lua_rawseti(L, -2, 3); + lua_pushnumber(L, obj->rp->custom->description->color.a); + lua_rawseti(L, -2, 4); + return 1; +} + +static int +_edje_lua_description_get_color2(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if (!obj->rp->custom) return 0; + lua_createtable(L, 4, 0); + lua_pushnumber(L, obj->rp->custom->description->color2.r); + lua_rawseti(L, -2, 1); + lua_pushnumber(L, obj->rp->custom->description->color2.g); + lua_rawseti(L, -2, 2); + lua_pushnumber(L, obj->rp->custom->description->color2.b); + lua_rawseti(L, -2, 3); + lua_pushnumber(L, obj->rp->custom->description->color2.a); + lua_rawseti(L, -2, 4); + return 1; +} + +static int +_edje_lua_description_get_color3(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if (!obj->rp->custom) return 0; + lua_createtable(L, 4, 0); + lua_pushnumber(L, obj->rp->custom->description->color3.r); + lua_rawseti(L, -2, 1); + lua_pushnumber(L, obj->rp->custom->description->color3.g); + lua_rawseti(L, -2, 2); + lua_pushnumber(L, obj->rp->custom->description->color3.b); + lua_rawseti(L, -2, 3); + lua_pushnumber(L, obj->rp->custom->description->color3.a); + lua_rawseti(L, -2, 4); + return 1; +} + +static int +_edje_lua_description_get_color_class(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if (!obj->rp->custom) return 0; + lua_pushstring(L, obj->rp->custom->description->color_class); + return 1; +} + +static int +_edje_lua_description_get_rel1(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if (!obj->rp->custom) return 0; + lua_createtable(L, 2, 0); + lua_pushnumber(L, TO_DOUBLE(obj->rp->custom->description->rel1.relative_x)); + lua_rawseti(L, -2, 1); + lua_pushnumber(L, TO_DOUBLE(obj->rp->custom->description->rel1.relative_y)); + lua_rawseti(L, -2, 2); + return 1; +} + +static int +_edje_lua_description_get_rel1_to(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if (!obj->rp->custom) return 0; + lua_createtable(L, 2, 0); + lua_pushnumber(L, obj->rp->custom->description->rel1.id_x); + lua_rawseti(L, -2, 1); + lua_pushnumber(L, obj->rp->custom->description->rel1.id_y); + lua_rawseti(L, -2, 2); + return 1; +} + +static int +_edje_lua_description_get_rel1_offset(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if (!obj->rp->custom) return 0; + lua_createtable(L, 2, 0); + lua_pushnumber(L, obj->rp->custom->description->rel1.offset_x); + lua_rawseti(L, -2, 1); + lua_pushnumber(L, obj->rp->custom->description->rel1.offset_y); + lua_rawseti(L, -2, 2); + return 1; +} + +static int +_edje_lua_description_get_rel2(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if (!obj->rp->custom) return 0; + lua_createtable(L, 2, 0); + lua_pushnumber(L, TO_DOUBLE(obj->rp->custom->description->rel2.relative_x)); + lua_rawseti(L, -2, 1); + lua_pushnumber(L, TO_DOUBLE(obj->rp->custom->description->rel2.relative_y)); + lua_rawseti(L, -2, 2); + return 1; +} + +static int +_edje_lua_description_get_rel2_to(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if (!obj->rp->custom) return 0; + lua_createtable(L, 2, 0); + lua_pushnumber(L, obj->rp->custom->description->rel2.id_x); + lua_rawseti(L, -2, 1); + lua_pushnumber(L, obj->rp->custom->description->rel2.id_y); + lua_rawseti(L, -2, 2); + return 1; +} + +static int +_edje_lua_description_get_rel2_offset(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if (!obj->rp->custom) return 0; + lua_createtable(L, 2, 0); + lua_pushnumber(L, obj->rp->custom->description->rel2.offset_x); + lua_rawseti(L, -2, 1); + lua_pushnumber(L, obj->rp->custom->description->rel2.offset_y); + lua_rawseti(L, -2, 2); + return 1; +} + +static int +_edje_lua_description_get_image(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if (!obj->rp->custom) return 0; + if ((obj->rp->part->type != EDJE_PART_TYPE_IMAGE)) + return 0; + // TODO + return 0; +} + +static int +_edje_lua_description_get_border(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if ((obj->rp->part->type != EDJE_PART_TYPE_IMAGE)) + return 0; + if (!obj->rp->custom) return 0; + lua_createtable(L, 4, 0); + lua_pushnumber(L, obj->rp->custom->description->border.l); + lua_rawseti(L, -2, 1); + lua_pushnumber(L, obj->rp->custom->description->border.r); + lua_rawseti(L, -2, 2); + lua_pushnumber(L, obj->rp->custom->description->border.t); + lua_rawseti(L, -2, 3); + lua_pushnumber(L, obj->rp->custom->description->border.b); + lua_rawseti(L, -2, 4); + return 1; +} + +static int +_edje_lua_description_get_fill_smooth(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if ((obj->rp->part->type != EDJE_PART_TYPE_IMAGE)) + return 0; + if (!obj->rp->custom) return 0; + lua_pushboolean(L, obj->rp->custom->description->fill.smooth); + return 1; +} + +static int +_edje_lua_description_get_fill_pos(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if ((obj->rp->part->type != EDJE_PART_TYPE_IMAGE)) + return 0; + if (!obj->rp->custom) return 0; + lua_createtable(L, 4, 0); + lua_pushnumber(L, TO_DOUBLE(obj->rp->custom->description->fill.pos_rel_x)); + lua_rawseti(L, -2, 1); + lua_pushnumber(L, TO_DOUBLE(obj->rp->custom->description->fill.pos_rel_y)); + lua_rawseti(L, -2, 2); + lua_pushnumber(L, obj->rp->custom->description->fill.pos_abs_x); + lua_rawseti(L, -2, 3); + lua_pushnumber(L, obj->rp->custom->description->fill.pos_abs_y); + lua_rawseti(L, -2, 4); + return 1; +} + +static int +_edje_lua_description_get_fill_size(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if ((obj->rp->part->type != EDJE_PART_TYPE_IMAGE)) + return 0; + if (!obj->rp->custom) return 0; + lua_createtable(L, 4, 0); + lua_pushnumber(L, TO_DOUBLE(obj->rp->custom->description->fill.rel_x)); + lua_rawseti(L, -2, 1); + lua_pushnumber(L, TO_DOUBLE(obj->rp->custom->description->fill.rel_y)); + lua_rawseti(L, -2, 2); + lua_pushnumber(L, obj->rp->custom->description->fill.abs_x); + lua_rawseti(L, -2, 3); + lua_pushnumber(L, obj->rp->custom->description->fill.abs_y); + lua_rawseti(L, -2, 4); + return 1; +} + +static int +_edje_lua_description_get_text(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if ((obj->rp->part->type != EDJE_PART_TYPE_TEXT) + && (obj->rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) + return 0; + if (!obj->rp->custom) return 0; + lua_pushstring(L, obj->rp->custom->description->text.text); + return 1; +} + +static int +_edje_lua_description_get_text_class(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if ((obj->rp->part->type != EDJE_PART_TYPE_TEXT) + && (obj->rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) + return 0; + if (!obj->rp->custom) return 0; + lua_pushstring(L, obj->rp->custom->description->text.text_class); + return 1; +} + +static int +_edje_lua_description_get_text_font(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if ((obj->rp->part->type != EDJE_PART_TYPE_TEXT)) + return 0; + if (!obj->rp->custom) return 0; + lua_pushstring(L, obj->rp->custom->description->text.text_class); + return 1; +} + +static int +_edje_lua_description_get_text_style(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if ((obj->rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) + return 0; + if (!obj->rp->custom) return 0; + lua_pushstring(L, obj->rp->custom->description->text.style); + return 1; +} + +static int +_edje_lua_description_get_text_size(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if ((obj->rp->part->type != EDJE_PART_TYPE_TEXT)) + return 0; + if (!obj->rp->custom) return 0; + lua_pushnumber(L, obj->rp->custom->description->text.size); + return 1; +} + +static int +_edje_lua_description_get_text_fit(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if ((obj->rp->part->type != EDJE_PART_TYPE_TEXT)) + return 0; + if (!obj->rp->custom) return 0; + lua_createtable(L, 2, 0); + lua_pushboolean(L, obj->rp->custom->description->text.fit_x); + lua_rawseti(L, -2, 1); + lua_pushboolean(L, obj->rp->custom->description->text.fit_y); + lua_rawseti(L, -2, 2); + return 1; +} + +static int +_edje_lua_description_get_text_min(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if ((obj->rp->part->type != EDJE_PART_TYPE_TEXT) + && (obj->rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) + return 0; + if (!obj->rp->custom) return 0; + lua_createtable(L, 2, 0); + lua_pushnumber(L, obj->rp->custom->description->text.min_x); + lua_rawseti(L, -2, 1); + lua_pushnumber(L, obj->rp->custom->description->text.min_y); + lua_rawseti(L, -2, 2); + return 1; +} + +static int +_edje_lua_description_get_text_max(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if ((obj->rp->part->type != EDJE_PART_TYPE_TEXT) + && (obj->rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) + return 0; + if (!obj->rp->custom) return 0; + lua_createtable(L, 2, 0); + lua_pushnumber(L, obj->rp->custom->description->text.max_x); + lua_rawseti(L, -2, 1); + lua_pushnumber(L, obj->rp->custom->description->text.max_y); + lua_rawseti(L, -2, 2); + return 1; +} + +static int +_edje_lua_description_get_text_align(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if ((obj->rp->part->type != EDJE_PART_TYPE_TEXT)) + return 0; + if (!obj->rp->custom) return 0; + lua_createtable(L, 2, 0); + lua_pushnumber(L, TO_DOUBLE(obj->rp->custom->description->text.align.x)); + lua_rawseti(L, -2, 1); + lua_pushnumber(L, TO_DOUBLE(obj->rp->custom->description->text.align.y)); + lua_rawseti(L, -2, 2); + return 1; +} + +static int +_edje_lua_description_get_visible(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if (!obj->rp->custom) return 0; + lua_pushboolean(L, obj->rp->custom->description->visible); + return 1; +} + +const luaL_Reg lDescription_get[] = { + {"alignment", _edje_lua_description_get_alignment}, + {"min", _edje_lua_description_get_min}, + {"max", _edje_lua_description_get_max}, + {"step", _edje_lua_description_get_step}, + {"aspect", _edje_lua_description_get_aspect}, + {"aspect_pref", _edje_lua_description_get_aspect_pref}, + {"color", _edje_lua_description_get_color}, + {"color2", _edje_lua_description_get_color2}, + {"color3", _edje_lua_description_get_color3}, + {"color_class", _edje_lua_description_get_color_class}, + {"rel1", _edje_lua_description_get_rel1}, + {"rel1_to", _edje_lua_description_get_rel1_to}, + {"rel1_offset", _edje_lua_description_get_rel1_offset}, + {"rel2", _edje_lua_description_get_rel2}, + {"rel2_to", _edje_lua_description_get_rel2_to}, + {"rel2_offset", _edje_lua_description_get_rel2_offset}, + {"image", _edje_lua_description_get_image}, + {"border", _edje_lua_description_get_border}, + {"fill_smooth", _edje_lua_description_get_fill_smooth}, + {"fill_pos", _edje_lua_description_get_fill_pos}, + {"fill_size", _edje_lua_description_get_fill_size}, + {"text", _edje_lua_description_get_text}, + {"text_class", _edje_lua_description_get_text_class}, + {"text_font", _edje_lua_description_get_text_font}, + {"text_style", _edje_lua_description_get_text_style}, + {"text_size", _edje_lua_description_get_text_size}, + {"text_fit", _edje_lua_description_get_text_fit}, + {"text_min", _edje_lua_description_get_text_min}, + {"text_max", _edje_lua_description_get_text_max}, + {"text_align", _edje_lua_description_get_text_align}, + {"visible", _edje_lua_description_get_visible}, + {NULL, NULL} // sentinel +}; + +static int +_edje_lua_description_set_alignment(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if (!obj->rp->custom) return 0; + luaL_checktype(L, 2, LUA_TTABLE); + lua_rawgeti(L, 2, 1); + lua_rawgeti(L, 2, 2); + obj->rp->custom->description->align.x = FROM_DOUBLE(luaL_checknumber(L, -2)); + obj->rp->custom->description->align.y = FROM_DOUBLE(luaL_checknumber(L, -1)); + return 0; +} + +static int +_edje_lua_description_set_min(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if (!obj->rp->custom) return 0; + lua_rawgeti(L, 2, 1); + lua_rawgeti(L, 2, 2); + obj->rp->custom->description->min.w = luaL_checkint(L, -2); + obj->rp->custom->description->min.h = luaL_checkint(L, -1); + return 0; +} + +static int +_edje_lua_description_set_max(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if (!obj->rp->custom) return 0; + lua_rawgeti(L, 2, 1); + lua_rawgeti(L, 2, 2); + obj->rp->custom->description->max.w = luaL_checkint(L, -2); + obj->rp->custom->description->max.h = luaL_checkint(L, -1); + return 0; +} + +static int +_edje_lua_description_set_step(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if (!obj->rp->custom) return 0; + lua_rawgeti(L, 2, 1); + lua_rawgeti(L, 2, 2); + obj->rp->custom->description->step.x = luaL_checkint(L, -2); + obj->rp->custom->description->step.y = luaL_checkint(L, -1); + return 0; +} + +static int +_edje_lua_description_set_aspect(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if (!obj->rp->custom) return 0; + lua_rawgeti(L, 2, 1); + lua_rawgeti(L, 2, 2); + obj->rp->custom->description->aspect.min = FROM_DOUBLE(luaL_checknumber(L, -2)); + obj->rp->custom->description->aspect.max = FROM_DOUBLE(luaL_checknumber(L, -1)); + return 0; + +} + +static int +_edje_lua_description_set_aspect_pref(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if (!obj->rp->custom) return 0; + obj->rp->custom->description->aspect.prefer = luaL_checknumber(L, 2); + return 0; + +} + +static int +_edje_lua_description_set_color(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if (!obj->rp->custom) return 0; + luaL_checktype(L, 2, LUA_TTABLE); + lua_rawgeti(L, 2, 1); + lua_rawgeti(L, 2, 2); + lua_rawgeti(L, 2, 3); + lua_rawgeti(L, 2, 4); + obj->rp->custom->description->color.r = luaL_checkint(L, -4); + obj->rp->custom->description->color.g = luaL_checkint(L, -3); + obj->rp->custom->description->color.b = luaL_checkint(L, -2); + obj->rp->custom->description->color.a = luaL_checkint(L, -1); + return 0; +} + +static int +_edje_lua_description_set_color2(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if (!obj->rp->custom) return 0; + luaL_checktype(L, 2, LUA_TTABLE); + lua_rawgeti(L, 2, 1); + lua_rawgeti(L, 2, 2); + lua_rawgeti(L, 2, 3); + lua_rawgeti(L, 2, 4); + obj->rp->custom->description->color2.r = luaL_checkint(L, -4); + obj->rp->custom->description->color2.g = luaL_checkint(L, -3); + obj->rp->custom->description->color2.b = luaL_checkint(L, -2); + obj->rp->custom->description->color2.a = luaL_checkint(L, -1); + return 0; +} + +static int +_edje_lua_description_set_color3(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if (!obj->rp->custom) return 0; + luaL_checktype(L, 2, LUA_TTABLE); + lua_rawgeti(L, 2, 1); + lua_rawgeti(L, 2, 2); + lua_rawgeti(L, 2, 3); + lua_rawgeti(L, 2, 4); + obj->rp->custom->description->color3.r = luaL_checkint(L, -4); + obj->rp->custom->description->color3.g = luaL_checkint(L, -3); + obj->rp->custom->description->color3.b = luaL_checkint(L, -2); + obj->rp->custom->description->color3.a = luaL_checkint(L, -1); + return 0; +} + +static int +_edje_lua_description_set_color_class(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if (!obj->rp->custom) return 0; + obj->rp->custom->description->color_class = (char *)luaL_checkstring(L, 2); + return 0; +} + +static int +_edje_lua_description_set_rel1(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if (!obj->rp->custom) return 0; + luaL_checktype(L, 2, LUA_TTABLE); + lua_rawgeti(L, 2, 1); + lua_rawgeti(L, 2, 2); + obj->rp->custom->description->rel1.relative_x = FROM_DOUBLE(luaL_checknumber(L, -2)); + obj->rp->custom->description->rel1.relative_y = FROM_DOUBLE(luaL_checknumber(L, -1)); + return 0; +} + +static int +_edje_lua_description_set_rel1_to(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if (!obj->rp->custom) return 0; + luaL_checktype(L, 2, LUA_TTABLE); + lua_rawgeti(L, 2, 1); + lua_rawgeti(L, 2, 2); + obj->rp->custom->description->rel1.id_x = luaL_checknumber(L, -2); + obj->rp->custom->description->rel1.id_y = luaL_checknumber(L, -1); + if (obj->rp->param1.description->rel1.id_x >= 0) + obj->rp->param1.rel1_to_x = obj->ed->table_parts[obj->rp->param1.description->rel1.id_x % obj->ed->table_parts_size]; + if (obj->rp->param1.description->rel1.id_y >= 0) + obj->rp->param1.rel1_to_y = obj->ed->table_parts[obj->rp->param1.description->rel1.id_y % obj->ed->table_parts_size]; + return 0; +} + +static int +_edje_lua_description_set_rel1_offset(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if (!obj->rp->custom) return 0; + luaL_checktype(L, 2, LUA_TTABLE); + lua_rawgeti(L, 2, 1); + lua_rawgeti(L, 2, 2); + obj->rp->custom->description->rel1.offset_x = luaL_checkint(L, -2); + obj->rp->custom->description->rel1.offset_y = luaL_checkint(L, -1); + return 0; +} + +static int +_edje_lua_description_set_rel2(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if (!obj->rp->custom) return 0; + luaL_checktype(L, 2, LUA_TTABLE); + lua_rawgeti(L, 2, 1); + lua_rawgeti(L, 2, 2); + obj->rp->custom->description->rel2.relative_x = FROM_DOUBLE(luaL_checknumber(L, -2)); + obj->rp->custom->description->rel2.relative_y = FROM_DOUBLE(luaL_checknumber(L, -1)); + return 0; +} + +static int +_edje_lua_description_set_rel2_to(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if (!obj->rp->custom) return 0; + luaL_checktype(L, 2, LUA_TTABLE); + lua_rawgeti(L, 2, 1); + lua_rawgeti(L, 2, 2); + obj->rp->custom->description->rel2.id_x = luaL_checknumber(L, -2); + obj->rp->custom->description->rel2.id_y = luaL_checknumber(L, -1); + if (obj->rp->param1.description->rel2.id_x >= 0) + obj->rp->param1.rel2_to_x = obj->ed->table_parts[obj->rp->param1.description->rel2.id_x % obj->ed->table_parts_size]; + if (obj->rp->param1.description->rel2.id_y >= 0) + obj->rp->param1.rel2_to_y = obj->ed->table_parts[obj->rp->param1.description->rel2.id_y % obj->ed->table_parts_size]; + return 0; +} + +static int +_edje_lua_description_set_rel2_offset(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if (!obj->rp->custom) return 0; + luaL_checktype(L, 2, LUA_TTABLE); + lua_rawgeti(L, 2, 1); + lua_rawgeti(L, 2, 2); + obj->rp->custom->description->rel2.offset_x = luaL_checkint(L, -2); + obj->rp->custom->description->rel2.offset_y = luaL_checkint(L, -1); + return 0; +} + +static int +_edje_lua_description_set_image(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if (!obj->rp->custom) return 0; + if ((obj->rp->part->type != EDJE_PART_TYPE_IMAGE)) + return 0; + obj->rp->custom->description->image.id = + edje_edit_image_id_get(obj->ed->obj, (char *)luaL_checkstring(L, 2)); + return 0; +} + +static int +_edje_lua_description_set_border(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if ((obj->rp->part->type != EDJE_PART_TYPE_IMAGE)) + return 0; + if (!obj->rp->custom) return 0; + luaL_checktype(L, 2, LUA_TTABLE); + lua_rawgeti(L, 2, 1); + lua_rawgeti(L, 2, 2); + lua_rawgeti(L, 2, 3); + lua_rawgeti(L, 2, 4); + obj->rp->custom->description->border.l = luaL_checkint(L, -2); + obj->rp->custom->description->border.r = luaL_checkint(L, -1); + obj->rp->custom->description->border.t = luaL_checkint(L, -2); + obj->rp->custom->description->border.b = luaL_checkint(L, -1); + return 0; +} + +static int +_edje_lua_description_set_fill_smooth(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if ((obj->rp->part->type != EDJE_PART_TYPE_IMAGE)) + return 0; + if (!obj->rp->custom) return 0; + obj->rp->custom->description->fill.smooth = lua_toboolean(L, 2); + return 0; +} + +static int +_edje_lua_description_set_fill_pos(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if ((obj->rp->part->type != EDJE_PART_TYPE_IMAGE)) + return 0; + if (!obj->rp->custom) return 0; + luaL_checktype(L, 2, LUA_TTABLE); + lua_rawgeti(L, 2, 1); + lua_rawgeti(L, 2, 2); + lua_rawgeti(L, 2, 3); + lua_rawgeti(L, 2, 4); + obj->rp->custom->description->fill.pos_rel_x = luaL_checkint(L, -2); + obj->rp->custom->description->fill.pos_rel_y = luaL_checkint(L, -1); + obj->rp->custom->description->fill.pos_abs_x = luaL_checkint(L, -2); + obj->rp->custom->description->fill.pos_abs_y = luaL_checkint(L, -1); + return 0; +} + +static int +_edje_lua_description_set_fill_size(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if ((obj->rp->part->type != EDJE_PART_TYPE_IMAGE)) + return 0; + if (!obj->rp->custom) return 0; + luaL_checktype(L, 2, LUA_TTABLE); + lua_rawgeti(L, 2, 1); + lua_rawgeti(L, 2, 2); + lua_rawgeti(L, 2, 3); + lua_rawgeti(L, 2, 4); + obj->rp->custom->description->fill.rel_x = luaL_checkint(L, -2); + obj->rp->custom->description->fill.rel_y = luaL_checkint(L, -1); + obj->rp->custom->description->fill.abs_x = luaL_checkint(L, -2); + obj->rp->custom->description->fill.abs_y = luaL_checkint(L, -1); + return 0; +} + +static int +_edje_lua_description_set_text(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if ((obj->rp->part->type != EDJE_PART_TYPE_TEXT) + && (obj->rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) + return 0; + if (!obj->rp->custom) return 0; + obj->rp->custom->description->text.text = (char *)luaL_checkstring(L, 2); + return 0; +} + +static int +_edje_lua_description_set_text_class(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if ((obj->rp->part->type != EDJE_PART_TYPE_TEXT) + && (obj->rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) + return 0; + if (!obj->rp->custom) return 0; + obj->rp->custom->description->text.text_class = + (char *)luaL_checkstring(L, 2); + return 0; +} + +static int +_edje_lua_description_set_text_font(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if ((obj->rp->part->type != EDJE_PART_TYPE_TEXT)) + return 0; + if (!obj->rp->custom) return 0; + obj->rp->custom->description->text.font = (char *)luaL_checkstring(L, 2); + return 0; +} + +static int +_edje_lua_description_set_text_style(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if ((obj->rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) + return 0; + if (!obj->rp->custom) return 0; + obj->rp->custom->description->text.style = (char *)luaL_checkstring(L, 2); + return 0; +} + +static int +_edje_lua_description_set_text_size(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if ((obj->rp->part->type != EDJE_PART_TYPE_TEXT)) + return 0; + if (!obj->rp->custom) return 0; + obj->rp->custom->description->text.size = luaL_checkint(L, 2); + return 0; +} + +static int +_edje_lua_description_set_text_fit(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if (!obj->rp->custom) return 0; + luaL_checktype(L, 2, LUA_TTABLE); + lua_rawgeti(L, 2, 1); + lua_rawgeti(L, 2, 2); + obj->rp->custom->description->text.fit_x = lua_toboolean(L, -2); + obj->rp->custom->description->text.fit_y = lua_toboolean(L, -1); + return 0; +} + +static int +_edje_lua_description_set_text_min(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if ((obj->rp->part->type != EDJE_PART_TYPE_TEXT) + && (obj->rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) + return 0; + if (!obj->rp->custom) return 0; + luaL_checktype(L, 2, LUA_TTABLE); + lua_rawgeti(L, 2, 1); + lua_rawgeti(L, 2, 2); + obj->rp->custom->description->text.min_x = luaL_checkint(L, -2); + obj->rp->custom->description->text.min_y = luaL_checkint(L, -1); + return 0; +} + +static int +_edje_lua_description_set_text_max(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if ((obj->rp->part->type != EDJE_PART_TYPE_TEXT) + && (obj->rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) + return 0; + if (!obj->rp->custom) return 0; + luaL_checktype(L, 2, LUA_TTABLE); + lua_rawgeti(L, 2, 1); + lua_rawgeti(L, 2, 2); + obj->rp->custom->description->text.max_x = luaL_checkint(L, -2); + obj->rp->custom->description->text.max_y = luaL_checkint(L, -1); + return 0; +} + +static int +_edje_lua_description_set_text_align(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if ((obj->rp->part->type != EDJE_PART_TYPE_TEXT)) + return 0; + if (!obj->rp->custom) return 0; + luaL_checktype(L, 2, LUA_TTABLE); + lua_rawgeti(L, 2, 1); + lua_rawgeti(L, 2, 2); + obj->rp->custom->description->text.align.x = FROM_DOUBLE(luaL_checknumber(L, -2)); + obj->rp->custom->description->text.align.y = FROM_DOUBLE(luaL_checknumber(L, -1)); + return 0; +} + +static int +_edje_lua_description_set_visible(lua_State *L) +{ + Edje_Lua_Edje_Part_Description *obj = + _edje_lua_checkudata(L, 1, &mDescription); + if (!obj->rp->custom) return 0; + obj->rp->custom->description->visible = lua_toboolean(L, 2); + return 0; +} + +const luaL_Reg lDescription_set[] = { + {"alignment", _edje_lua_description_set_alignment}, + {"min", _edje_lua_description_set_min}, + {"max", _edje_lua_description_set_max}, + {"step", _edje_lua_description_set_step}, + {"aspect", _edje_lua_description_set_aspect}, + {"aspect_pref", _edje_lua_description_set_aspect_pref}, + {"color", _edje_lua_description_set_color}, + {"color2", _edje_lua_description_set_color2}, + {"color3", _edje_lua_description_set_color3}, + {"color_class", _edje_lua_description_set_color_class}, + {"rel1", _edje_lua_description_set_rel1}, + {"rel1_to", _edje_lua_description_set_rel1_to}, + {"rel1_offset", _edje_lua_description_set_rel1_offset}, + {"rel2", _edje_lua_description_set_rel2}, + {"rel2_to", _edje_lua_description_set_rel2_to}, + {"rel2_offset", _edje_lua_description_set_rel2_offset}, + {"image", _edje_lua_description_set_image}, + {"border", _edje_lua_description_set_border}, + {"fill_smooth", _edje_lua_description_set_fill_smooth}, + {"fill_pos", _edje_lua_description_set_fill_pos}, + {"fill_size", _edje_lua_description_set_fill_size}, + {"text", _edje_lua_description_set_text}, + {"text_class", _edje_lua_description_set_text_class}, + {"text_font", _edje_lua_description_set_text_font}, + {"text_style", _edje_lua_description_set_text_style}, + {"text_size", _edje_lua_description_set_text_size}, + {"text_fit", _edje_lua_description_set_text_fit}, + {"text_min", _edje_lua_description_set_text_min}, + {"text_max", _edje_lua_description_set_text_max}, + {"text_align", _edje_lua_description_set_text_align}, + {"visible", _edje_lua_description_set_visible}, + {NULL, NULL} // sentinel +}; + +const luaL_Reg lPart_get[]; + +const luaL_Reg lPart_set[]; + +const luaL_Reg lPart_fn[]; + +const Edje_Lua_Reg mPart = { + lNil, + lPart_get, + lPart_set, + lPart_fn +}; + +static void +_edje_lua_edje_part_del_cb(void *data, __UNUSED__ Evas * e, Evas_Object * obj, + __UNUSED__ void *event_info) +{ + //printf("_edje_lua_object_delete_cb\n"); + lua_State *L = data; + _edje_lua_get_reg(L, obj); + Edje_Lua_Edje_Part_Object *udata = _edje_lua_checkudata(L, -1, &mPart); + lua_pop(L, 1); + _edje_lua_free_reg(L, udata); // created in _edje_lua_group_mt_index + _edje_lua_free_reg(L, obj); // created in _edje_lua_group_mt_index +} + +const Edje_Lua_Reg *cPart[] = { + &mClass, + &mObject, + &mPart, + NULL // sentinel +}; + +static int +_edje_lua_part_get_swallow(lua_State *L) +{ + Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart); + Evas_Object *swa = edje_object_part_swallow_get(obj->ed->obj, obj->key); + _edje_lua_get_reg(L, swa); + // TODO create object if it does not already exist? + return 1; +} + +static int +_edje_lua_part_get_type(lua_State *L) +{ + Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart); + lua_pushnumber(L, edje_edit_part_type_get(obj->ed->obj, obj->key)); + return 1; +} + +static int +_edje_lua_part_get_effect(lua_State *L) +{ + Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart); + lua_pushnumber(L, edje_edit_part_effect_get(obj->ed->obj, obj->key)); + return 1; +} + +static int +_edje_lua_part_get_mouse_events(lua_State *L) +{ + Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart); + lua_pushboolean(L, edje_edit_part_mouse_events_get(obj->ed->obj, obj->key)); + return 1; +} + +static int +_edje_lua_part_get_repeat_events(lua_State *L) +{ + Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart); + lua_pushboolean(L, edje_edit_part_repeat_events_get(obj->ed->obj, obj->key)); + return 1; +} + +static int +_edje_lua_part_get_states_list(lua_State *L) +{ + Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart); + Eina_List *slist = edje_edit_part_states_list_get(obj->ed->obj, obj->key); + Eina_List *ilist; + lua_newtable(L); + int i = 1; + for (ilist = slist; ilist; ilist = eina_list_next(ilist)) + { + lua_pushstring(L, eina_list_data_get(ilist)); + lua_rawseti(L, -2, i++); + } + edje_edit_string_list_free(slist); + return 1; +}; + +static int +_edje_lua_part_get_state(lua_State *L) +{ + Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart); + const char *state; + double val; + state = edje_object_part_state_get(obj->ed->obj, obj->key, &val); + lua_createtable(L, 2, 0); + lua_pushstring(L, state); + lua_rawseti(L, -2, 1); + lua_pushnumber(L, val); + lua_rawseti(L, -2, 2); + return 1; +}; + +static int +_edje_lua_part_get_text(lua_State *L) +{ + Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart); + lua_pushstring(L, edje_object_part_text_get(obj->ed->obj, obj->key)); + return 1; +}; + +static int +_edje_lua_part_get_text_selection(lua_State *L) +{ + Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart); + lua_pushstring(L, + edje_object_part_text_selection_get(obj->ed->obj, obj->key)); + return 1; +}; + +static int +_edje_lua_part_get_drag_dir(lua_State *L) +{ + Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart); + lua_pushnumber(L, edje_object_part_drag_dir_get(obj->ed->obj, obj->key)); + return 1; +} + +static int +_edje_lua_part_get_drag_value(lua_State *L) +{ + Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart); + double dx, dy; + edje_object_part_drag_value_get(obj->ed->obj, obj->key, &dx, &dy); + lua_createtable(L, 2, 0); + lua_pushnumber(L, dx); + lua_rawseti(L, -2, 1); + lua_pushnumber(L, dy); + lua_rawseti(L, -2, 2); + return 1; +} + +static int +_edje_lua_part_get_drag_size(lua_State *L) +{ + Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart); + double dx, dy; + edje_object_part_drag_size_get(obj->ed->obj, obj->key, &dx, &dy); + lua_createtable(L, 2, 0); + lua_pushnumber(L, dx); + lua_rawseti(L, -2, 1); + lua_pushnumber(L, dy); + lua_rawseti(L, -2, 2); + return 1; +} + +static int +_edje_lua_part_get_drag_step(lua_State *L) +{ + Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart); + double dx, dy; + edje_object_part_drag_step_get(obj->ed->obj, obj->key, &dx, &dy); + lua_createtable(L, 2, 0); + lua_pushnumber(L, dx); + lua_rawseti(L, -2, 1); + lua_pushnumber(L, dy); + lua_rawseti(L, -2, 2); + return 1; +} + +static int +_edje_lua_part_get_drag_page(lua_State *L) +{ + Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart); + double dx, dy; + edje_object_part_drag_page_get(obj->ed->obj, obj->key, &dx, &dy); + lua_createtable(L, 2, 0); + lua_pushnumber(L, dx); + lua_rawseti(L, -2, 1); + lua_pushnumber(L, dy); + lua_rawseti(L, -2, 2); + return 1; +} + +static int +_edje_lua_part_get_text_cursor_geometry(lua_State *L) +{ + Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart); + Evas_Coord x, y, w, h; + edje_object_part_text_cursor_geometry_get(obj->ed->obj, obj->key, + &x, &y, &w, &h); + lua_createtable(L, 4, 0); + lua_pushnumber(L, x); + lua_rawseti(L, -2, 1); + lua_pushnumber(L, y); + lua_rawseti(L, -2, 2); + lua_pushnumber(L, w); + lua_rawseti(L, -2, 3); + lua_pushnumber(L, h); + lua_rawseti(L, -2, 4); + return 1; +} + +static int +_edje_lua_part_get_geometry(lua_State *L) +{ + Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart); + Evas_Coord x, y, w, h; + edje_object_part_geometry_get(obj->ed->obj, obj->key, &x, &y, &w, &h); + lua_createtable(L, 4, 0); + lua_pushnumber(L, x); + lua_rawseti(L, -2, 1); + lua_pushnumber(L, y); + lua_rawseti(L, -2, 2); + lua_pushnumber(L, w); + lua_rawseti(L, -2, 3); + lua_pushnumber(L, h); + lua_rawseti(L, -2, 4); + return 1; +} + +static int +_edje_lua_part_get_table_col_row_size(lua_State *L) +{ + Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart); + int cols, rows; + edje_object_part_table_col_row_size_get(obj->ed->obj, obj->key, &cols, &rows); + lua_createtable(L, 2, 0); + lua_pushnumber(L, cols); lua_rawseti(L, -2, 1); + lua_pushnumber(L, rows); lua_rawseti(L, -2, 2); + return 1; +} + +static int _edje_lua_part_fn_custom_state(lua_State *L); + +const luaL_Reg lPart_get[] = { + {"custom_state", _edje_lua_part_fn_custom_state}, + {"Swallow", _edje_lua_part_get_swallow}, //TODO it the capital S correct? + + {"drag_dir", _edje_lua_part_get_drag_dir}, + {"drag_value", _edje_lua_part_get_drag_value}, + {"drag_size", _edje_lua_part_get_drag_size}, + {"drag_step", _edje_lua_part_get_drag_step}, + {"drag_page", _edje_lua_part_get_drag_page}, + + {"type", _edje_lua_part_get_type}, + {"effect", _edje_lua_part_get_effect}, + {"mouse_events", _edje_lua_part_get_mouse_events}, + {"repeat_events", _edje_lua_part_get_repeat_events}, + {"states_list", _edje_lua_part_get_states_list}, + {"state", _edje_lua_part_get_state}, + + {"text", _edje_lua_part_get_text}, + {"text_selection", _edje_lua_part_get_text_selection}, + {"text_cursor_geometry", _edje_lua_part_get_text_cursor_geometry}, + + {"geometry", _edje_lua_part_get_geometry}, + {"part_col_row_size", _edje_lua_part_get_table_col_row_size}, + {NULL, NULL} // sentinel +}; + +static int +_edje_lua_part_set_effect(lua_State *L) +{ + Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart); + edje_edit_part_effect_set(obj->ed->obj, obj->key, luaL_checkint(L, 2)); + return 0; +} + +static int +_edje_lua_part_set_mouse_events(lua_State *L) +{ + Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart); + edje_edit_part_mouse_events_set(obj->ed->obj, obj->key, lua_toboolean(L, 2)); + return 0; +} + +static int +_edje_lua_part_set_repeat_events(lua_State *L) +{ + Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart); + edje_edit_part_repeat_events_set(obj->ed->obj, obj->key, + lua_toboolean(L, 2)); + return 0; +} + +static int +_edje_lua_part_set_state(lua_State *L) +{ + Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart); + luaL_checktype(L, 2, LUA_TTABLE); + lua_rawgeti(L, 2, 1); + lua_rawgeti(L, 2, 2); + _edje_part_description_apply(obj->ed, obj->rp, + luaL_checkstring(L, -2), luaL_checknumber(L, -1), + NULL, 0.0); + _edje_part_pos_set(obj->ed, obj->rp, EDJE_TWEEN_MODE_LINEAR, ZERO, ZERO, ZERO); + _edje_recalc(obj->ed); + return 0; +} + +static int +_edje_lua_part_set_tween_state(lua_State *L) +{ + Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart); + luaL_checktype(L, 2, LUA_TTABLE); + lua_rawgeti(L, 2, 1); + lua_rawgeti(L, 2, 2); + lua_rawgeti(L, 2, 3); + lua_rawgeti(L, 2, 4); + lua_rawgeti(L, 2, 5); + _edje_part_description_apply(obj->ed, obj->rp, + luaL_checkstring(L, -4), luaL_checknumber(L, -3), + luaL_checkstring(L, -2), luaL_checknumber(L, -1)); + _edje_part_pos_set(obj->ed, obj->rp, EDJE_TWEEN_MODE_LINEAR, + FROM_DOUBLE(luaL_checknumber(L, -5)), ZERO, ZERO); + _edje_recalc(obj->ed); + return 0; +} + +static int +_edje_lua_part_set_text(lua_State *L) +{ + Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart); + edje_object_part_text_set(obj->ed->obj, obj->key, luaL_checkstring(L, 2)); + return 0; +} + +static int +_edje_lua_part_set_drag_value(lua_State *L) +{ + Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart); + lua_rawgeti(L, 2, 1); + lua_rawgeti(L, 2, 2); + edje_object_part_drag_value_set(obj->ed->obj, obj->key, + luaL_checknumber(L, -2), + luaL_checknumber(L, -1)); + return 0; +} + +static int +_edje_lua_part_set_drag_size(lua_State *L) +{ + Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart); + lua_rawgeti(L, 2, 1); + lua_rawgeti(L, 2, 2); + edje_object_part_drag_size_set(obj->ed->obj, obj->key, + luaL_checknumber(L, -2), + luaL_checknumber(L, -1)); + return 0; +} + +static int +_edje_lua_part_set_drag_step(lua_State *L) +{ + Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart); + lua_rawgeti(L, 2, 1); + lua_rawgeti(L, 2, 2); + edje_object_part_drag_step_set(obj->ed->obj, obj->key, + luaL_checknumber(L, -2), + luaL_checknumber(L, -1)); + return 0; +} + +static int +_edje_lua_part_set_drag_page(lua_State *L) +{ + Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart); + lua_rawgeti(L, 2, 1); + lua_rawgeti(L, 2, 2); + edje_object_part_drag_page_set(obj->ed->obj, obj->key, + luaL_checknumber(L, -2), + luaL_checknumber(L, -1)); + return 0; +} + +const luaL_Reg lPart_set[] = { + {"drag_value", _edje_lua_part_set_drag_value}, + {"drag_size", _edje_lua_part_set_drag_size}, + {"drag_step", _edje_lua_part_set_drag_step}, + {"drag_page", _edje_lua_part_set_drag_page}, + + {"effect", _edje_lua_part_set_effect}, + {"mouse_events", _edje_lua_part_set_mouse_events}, + {"repeat_events", _edje_lua_part_set_repeat_events}, + {"state", _edje_lua_part_set_state}, + {"tween_state", _edje_lua_part_set_tween_state}, + {"text", _edje_lua_part_set_text}, + {NULL, NULL} // sentinel +}; + +static int +_edje_lua_part_fn_swallow(lua_State *L) +{ + Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart); + Edje_Lua_Evas_Object *swa = _edje_lua_checkudata(L, 2, &mObject); + edje_object_part_swallow(obj->ed->obj, obj->key, swa->eo); + return 0; +} + +static int +_edje_lua_part_fn_unswallow(lua_State *L) +{ + Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart); + edje_object_part_unswallow(obj->ed->obj, obj->eo); + return 0; +} + +static int +_edje_lua_part_fn_text_select_none(lua_State *L) +{ + Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart); + edje_object_part_text_select_none(obj->ed->obj, obj->key); + return 0; +} + +static int +_edje_lua_part_fn_text_select_all(lua_State *L) +{ + Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart); + edje_object_part_text_select_all(obj->ed->obj, obj->key); + return 0; +} + +static int +_edje_lua_part_fn_text_insert(lua_State *L) +{ + Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart); + edje_object_part_text_insert(obj->ed->obj, obj->key, luaL_checkstring(L, 2)); + return 0; +} + +static int +_edje_lua_part_fn_custom_state(lua_State *L) +{ + char *name; + float val; + Edje_Part_Description *parent; + Edje_Part_Image_Id *iid; + Eina_List *l; + Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart); + /* check whether this part already has a "custom" state */ + if (obj->rp->custom) + { + _edje_lua_get_reg(L, obj->rp->custom->description); + return 1; + } + + name = (char *)luaL_checkstring(L, 2); // state name + val = luaL_checknumber(L, 3); // state val + if (!(parent = _edje_part_description_find(obj->ed, obj->rp, name, val))) + { + lua_pushnil(L); + return 1; + } + /* now create the custom state */ + Edje_Lua_Edje_Part_Description *tar = + lua_newuserdata(L, sizeof(Edje_Lua_Edje_Part_Description)); + tar->rp = obj->rp; + _edje_lua_set_class(L, -1, cDescription); + _edje_lua_new_reg(L, -1, tar); // freed in edje_load.c::_edje_file_del + if (!(tar->pd = calloc(1, sizeof(Edje_Part_Description)))) + { + lua_pushnil(L); + return 1; + } + + obj->rp->custom = eina_mempool_malloc(_edje_real_part_state_mp, sizeof (Edje_Real_Part_State)); + if (!obj->rp->custom) + { + free(tar->pd); + tar->pd = NULL; + lua_pushnil(L); + return 1; + } + + *(tar->pd) = *parent; + tar->pd->state.name = (char *)eina_stringshare_add("custom"); + tar->pd->state.value = 0.0; + /* + * make sure all the allocated memory is getting copied, + * not just referenced + */ + tar->pd->image.tween_list = NULL; + EINA_LIST_FOREACH(parent->image.tween_list, l, iid) + { + Edje_Part_Image_Id *iid_new; + iid_new = calloc(1, sizeof(Edje_Part_Image_Id)); + iid_new->id = iid->id; + + tar->pd->image.tween_list = + eina_list_append(tar->pd->image.tween_list, iid_new); + } +#define DUP(x) x ? (char *)eina_stringshare_add(x) : NULL + tar->pd->color_class = DUP(tar->pd->color_class); + tar->pd->text.text = DUP(tar->pd->text.text); + tar->pd->text.text_class = DUP(tar->pd->text.text_class); + tar->pd->text.font = DUP(tar->pd->text.font); + tar->pd->text.style = DUP(tar->pd->text.style); +#undef DUP + obj->rp->custom->description = tar->pd; + _edje_lua_new_reg(L, -1, obj->rp->custom->description); // freed in edje_load.c::_edje_file_del + return 1; +} + +static int +_edje_lua_part_fn_table_pack(lua_State *L) +{ + Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart); + Edje_Lua_Evas_Object *tar = _edje_lua_checkudata(L, 2, &mObject); + lua_pushboolean(L, + edje_object_part_table_pack(obj->ed->obj, obj->key, tar->eo, + luaL_checkint(L, 3), + luaL_checkint(L, 4), + luaL_checkint(L, 5), + luaL_checkint(L, 6))); + return 1; +} + +static int +_edje_lua_part_fn_table_unpack(lua_State *L) +{ + Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart); + Edje_Lua_Evas_Object *tar = _edje_lua_checkudata(L, 2, &mObject); + lua_pushboolean(L, + edje_object_part_table_unpack(obj->ed->obj, obj->key, tar->eo)); + return 1; +} + +static int +_edje_lua_part_fn_table_clear(lua_State *L) +{ + Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart); + lua_pushboolean(L, + edje_object_part_table_clear(obj->ed->obj, obj->key, lua_toboolean(L, 2))); + return 1; +} + +static int +_edje_lua_part_fn_box_append(lua_State *L) +{ + Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart); + Edje_Lua_Evas_Object *tar = _edje_lua_checkudata(L, 2, &mObject); + lua_pushboolean(L, + edje_object_part_box_append(obj->ed->obj, obj->key, tar->eo)); + return 1; +} + +static int +_edje_lua_part_fn_box_prepend(lua_State *L) +{ + Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart); + Edje_Lua_Evas_Object *tar = _edje_lua_checkudata(L, 2, &mObject); + lua_pushboolean(L, + edje_object_part_box_prepend(obj->ed->obj, obj->key, tar->eo)); + return 1; +} + +static int +_edje_lua_part_fn_box_insert_before(lua_State *L) +{ + Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart); + Edje_Lua_Evas_Object *tar = _edje_lua_checkudata(L, 2, &mObject); + Edje_Lua_Evas_Object *ref = _edje_lua_checkudata(L, 3, &mObject); + lua_pushboolean(L, + edje_object_part_box_insert_before(obj->ed->obj, obj->key, tar->eo, ref->eo)); + return 1; +} + +static int +_edje_lua_part_fn_box_insert_at(lua_State *L) +{ + Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart); + Edje_Lua_Evas_Object *tar = _edje_lua_checkudata(L, 2, &mObject); + lua_pushboolean(L, + edje_object_part_box_insert_at(obj->ed->obj, obj->key, tar->eo, luaL_checkint(L, 3))); + return 1; +} + +static int +_edje_lua_part_fn_box_remove(lua_State *L) +{ + Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart); + Edje_Lua_Evas_Object *tar = _edje_lua_checkudata(L, 2, &mObject); + edje_object_part_box_remove(obj->ed->obj, obj->key, tar->eo); + lua_pushvalue(L, 2); + return 1; +} + +static int +_edje_lua_part_fn_box_remove_at(lua_State *L) +{ + Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart); + _edje_lua_get_reg(L, edje_object_part_box_remove_at(obj->ed->obj, obj->key, luaL_checkint(L, 2))); + return 1; +} + +static int +_edje_lua_part_fn_box_remove_all(lua_State *L) +{ + Edje_Lua_Edje_Part_Object *obj = _edje_lua_checkudata(L, 1, &mPart); + lua_pushboolean(L, + edje_object_part_box_remove_all(obj->ed->obj, obj->key, lua_toboolean(L, 2))); + return 1; +} + +const luaL_Reg lPart_fn[] = { + {"swallow", _edje_lua_part_fn_swallow}, + {"unswallow", _edje_lua_part_fn_unswallow}, + + {"custom_state", _edje_lua_part_fn_custom_state}, + + {"text_select_none", _edje_lua_part_fn_text_select_none}, + {"text_select_all", _edje_lua_part_fn_text_select_all}, + {"text_insert", _edje_lua_part_fn_text_insert}, + + {"table_pack", _edje_lua_part_fn_table_pack}, + {"table_unpack", _edje_lua_part_fn_table_unpack}, + {"table_clear", _edje_lua_part_fn_table_clear}, + + {"box_append", _edje_lua_part_fn_box_append}, + {"box_prepend", _edje_lua_part_fn_box_prepend}, + {"box_insert_before", _edje_lua_part_fn_box_insert_before}, + {"box_insert_at", _edje_lua_part_fn_box_insert_at}, + {"box_remove", _edje_lua_part_fn_box_remove}, + {"box_remove_at", _edje_lua_part_fn_box_remove_at}, + {"box_remove_all", _edje_lua_part_fn_box_remove_all}, + {NULL, NULL} // sentinel +}; + +const luaL_Reg lGroup_mt[]; + +const luaL_Reg lGroup_get[]; + +const luaL_Reg lGroup_set[]; + +const luaL_Reg lGroup_fn[]; + +const Edje_Lua_Reg mGroup = { + lGroup_mt, + lGroup_get, + lGroup_set, + lGroup_fn +}; + +const Edje_Lua_Reg *cGroup[] = { + &mClass, + &mObject, + &mGroup, + NULL // sentinel +}; + +static int +_edje_lua_group_mt_index(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup); + lua_getmetatable(L, 1); + if (!_edje_lua_look_fn(L)) + { + // look in lGroup_fn + if (!_edje_lua_look_get(L)) + { + // look in lGroup_get + const char *key = luaL_checkstring(L, 2); + Edje *ed = _edje_fetch(obj->eo); + Edje_Real_Part *rp = _edje_real_part_recursive_get(ed, key); + if (rp) + { + // check if lua userdata exists + Evas_Object *part = (Evas_Object *) edje_object_part_object_get(obj->eo, key); + _edje_lua_get_reg(L, part); + if (lua_isnil(L, -1)) + { + // create it + lua_pop(L, 1); + Edje_Lua_Edje_Part_Object *tar = + lua_newuserdata(L, sizeof(Edje_Lua_Edje_Part_Object)); + tar->eo = part; + tar->ed = ed; + tar->key = key; + tar->L = L; + tar->rp = rp; + _edje_lua_set_class(L, -1, cPart); + _edje_lua_new_reg(L, -1, tar); // freed in _edje_lua_edje_part_del_cb + _edje_lua_new_reg(L, -1, part); // freed in _edje_lua_edje_part_del_cb + evas_object_event_callback_add(tar->eo, + EVAS_CALLBACK_DEL, + _edje_lua_edje_part_del_cb, + L); + } + } + else + { + // look in obj environment table + lua_getfenv(L, 1); + lua_pushvalue(L, 2); // key + lua_rawget(L, -2); + } + } + } + return 1; +} + +const luaL_Reg lGroup_mt[] = { + {"__index", _edje_lua_group_mt_index}, + {NULL, NULL} // sentinel +}; + +static int +_edje_lua_group_get_group(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup); + const char *file, *group; + edje_object_file_get(obj->eo, &file, &group); + lua_pushstring(L, group); + return 1; +} + +static int +_edje_lua_group_get_mouse(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup); + int x, y; + evas_pointer_canvas_xy_get(evas_object_evas_get(obj->eo), &x, &y); + x -= obj->ed->x; + y -= obj->ed->y; + lua_createtable(L, 2, 0); + lua_pushnumber(L, x); + lua_rawseti(L, -2, 1); + lua_pushnumber(L, y); + lua_rawseti(L, -2, 2); + return 1; +} + +static int +_edje_lua_group_get_mouse_buttons(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup); + lua_pushnumber(L, evas_pointer_button_down_mask_get(obj->ed->evas)); + return 1; +} + +static int +_edje_lua_group_get_size_min(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup); + int w, h; + edje_object_size_min_get(obj->eo, &w, &h); + lua_createtable(L, 2, 0); + lua_pushnumber(L, w); + lua_rawseti(L, -2, 1); + lua_pushnumber(L, h); + lua_rawseti(L, -2, 2); + return 1; +} + +static int +_edje_lua_group_get_size_max(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup); + int w, h; + edje_object_size_max_get(obj->eo, &w, &h); + lua_createtable(L, 2, 0); + lua_pushnumber(L, w); + lua_rawseti(L, -2, 1); + lua_pushnumber(L, h); + lua_rawseti(L, -2, 2); + return 1; +} + +static int +_edje_lua_group_get_scale(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup); + lua_pushnumber(L, edje_object_scale_get(obj->eo)); + return 1; +} + +static int +_edje_lua_group_get_load_error(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup); + lua_pushnumber(L, edje_object_load_error_get(obj->eo)); + return 1; +} + +static int +_edje_lua_group_get_load_error_str(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup); + lua_pushstring(L, edje_load_error_str(edje_object_load_error_get(obj->eo))); + return 1; +} + +static int +_edje_lua_group_get_play(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup); + lua_pushboolean(L, edje_object_play_get(obj->eo)); + return 1; +} + +static int +_edje_lua_group_get_animation(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup); + lua_pushboolean(L, edje_object_animation_get(obj->eo)); + return 1; +} + +static int +_edje_lua_group_get_frametime(lua_State *L) +{ + lua_pushnumber(L, edje_frametime_get()); + return 1; +} + +const luaL_Reg lGroup_get[] = { + {"group", _edje_lua_group_get_group}, + {"mouse", _edje_lua_group_get_mouse}, + {"mouse_buttons", _edje_lua_group_get_mouse_buttons}, + {"size_min", _edje_lua_group_get_size_min}, + {"size_max", _edje_lua_group_get_size_max}, + {"scale", _edje_lua_group_get_scale}, + {"load_error", _edje_lua_group_get_load_error}, + {"load_error_str", _edje_lua_group_get_load_error_str}, + {"play", _edje_lua_group_get_play}, + {"animation", _edje_lua_group_get_animation}, + {"frametime", _edje_lua_group_get_frametime}, + {NULL, NULL} // sentinel +}; + +static int +_edje_lua_group_set_group(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup); + edje_object_file_set(obj->eo, obj->ed->file->path, luaL_checkstring(L, 2)); + return 0; +} + +static int +_edje_lua_group_set_size_min(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup); + + luaL_checktype(L, 2, LUA_TTABLE); + lua_rawgeti(L, 2, 1); + lua_rawgeti(L, 2, 2); + obj->ed->collection->prop.min.w = luaL_checkint(L, -2); + obj->ed->collection->prop.min.h = luaL_checkint(L, -1); + obj->ed->dirty = 1; + _edje_recalc(obj->ed); + return 0; +} + +static int +_edje_lua_group_set_size_max(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup); + luaL_checktype(L, 2, LUA_TTABLE); + lua_rawgeti(L, 2, 1); + lua_rawgeti(L, 2, 2); + obj->ed->collection->prop.max.w = luaL_checkint(L, -2); + obj->ed->collection->prop.max.h = luaL_checkint(L, -1); + obj->ed->dirty = 1; + _edje_recalc(obj->ed); + return 0; +} + +static int +_edje_lua_group_set_scale(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup); + edje_object_scale_set(obj->eo, luaL_checknumber(L, 2)); + return 0; +} + +static int +_edje_lua_group_set_play(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup); + edje_object_play_set(obj->eo, lua_toboolean(L, 2)); + return 0; +} + +static int +_edje_lua_group_set_animation(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup); + edje_object_animation_set(obj->eo, lua_toboolean(L, 2)); + return 0; +} + +static void +_edje_lua_group_text_change_cb(void* data, Evas_Object *obj, const char* part) +{ + Edje_Lua_Ref *ref = data; + lua_State *L = ref->L; + int err_code; + + _edje_lua_get_ref(L, ref); + _edje_lua_get_reg(L, obj); + lua_pushstring(L, part); + + if ((err_code = lua_pcall(L, 2, 0, 0))) + _edje_lua_error(L, err_code); +} + +static int +_edje_lua_group_set_text_change_cb(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup); + edje_object_text_change_cb_set(obj->eo, _edje_lua_group_text_change_cb, _edje_lua_new_ref(L, 2)); + return 0; +} + +static int +_edje_lua_group_set_frametime(lua_State *L) +{ + edje_frametime_set(luaL_checknumber(L, 2)); + return 0; +} +const luaL_Reg lGroup_set[] = { + {"group", _edje_lua_group_set_group}, + {"size_min", _edje_lua_group_set_size_min}, + {"size_max", _edje_lua_group_set_size_max}, + {"scale", _edje_lua_group_set_scale}, + {"play", _edje_lua_group_set_play}, + {"animation", _edje_lua_group_set_animation}, + {"text_change_cb", _edje_lua_group_set_text_change_cb}, + {"frametime", _edje_lua_group_set_frametime}, + {NULL, NULL} // sentinel +}; + +static int +_edje_lua_group_fn_timer(lua_State *L) +{ + Edje_Lua_Timer *tar = lua_newuserdata(L, sizeof(Edje_Lua_Timer)); + + _edje_lua_set_class(L, -1, cTimer); + /* ^^^^^^^^^^^^^^^^(L, index, class) + lua_newtable(L); + if (index < 0) + lua_setfenv(L, index - 1); + else + lua_setfenv(L, index); + + _edje_lua_get_metatable(L, class); + if (index < 0) + lua_setmetatable(L, index - 1); + else + lua_setmetatable(L, index); + */ + + tar->et = ecore_timer_add(luaL_checknumber(L, 2), _edje_lua_timer_cb, tar); + tar->L = L; + + _edje_lua_new_reg(L, -1, tar); // freed in _edje_lua_timer_cb/del + /* ^^^^^^^^^^^^^^(L, index, ptr) + lua_pushvalue(L, index); + lua_pushlightuserdata(L, ptr); + lua_insert(L, -2); + lua_rawset(L, LUA_REGISTRYINDEX); // freed in _edje_lua_free_reg + */ + + tar->cb = _edje_lua_new_ref(L, 3); // freed in _edje_lua_timer_cb/del + /* ^^^^^^^^^^^^^^^^^^^^^^^^(L, index) + lua_pushvalue(L, index); + Edje_Lua_Ref *ref = malloc(sizeof(Edje_Lua_Ref)); + ref->id = luaL_ref(L, LUA_REGISTRYINDEX); + ref->L = L; + return ref; + */ + return 1; +} + +static int +_edje_lua_group_fn_animator(lua_State *L) +{ + Edje_Lua_Animator *tar = lua_newuserdata(L, sizeof(Edje_Lua_Animator)); + _edje_lua_set_class(L, -1, cAnimator); + tar->ea = ecore_animator_add(_edje_lua_animator_cb, tar); + tar->L = L; + _edje_lua_new_reg(L, -1, tar); // freed in _edje_lua_animator_cb/del + tar->cb = _edje_lua_new_ref(L, 2); // freed in _edje_lua_animator_cb/del + return 1; +} + +static int +_edje_lua_group_fn_poller(lua_State *L) +{ + int interval; + Edje_Lua_Poller *tar; + tar = lua_newuserdata(L, sizeof(Edje_Lua_Poller)); + _edje_lua_set_class(L, -1, cPoller); + + interval = luaL_checknumber(L, 2); + if ((interval <= 0) || ((interval & 1) != 0)) + { + return 0; + } + + // Only 1 type of poller currently implemented in ecore + tar->ep = ecore_poller_add(ECORE_POLLER_CORE, interval, + _edje_lua_poller_cb, tar); + tar->L = L; + _edje_lua_new_reg(L, -1, tar); // freed in _edje_lua_poller_cb/del + tar->cb = _edje_lua_new_ref(L, 3); // freed in _edje_lua_poller_cb/del + + return 1; +} + +static int +_edje_lua_group_fn_transform(lua_State *L) +{ + Edje_Lua_Transform *tar = lua_newuserdata(L, sizeof(Edje_Lua_Transform)); + evas_transform_identity_set (&(tar->et)); + _edje_lua_set_class(L, -1, cTransform); + tar->L = L; + return 1; +} + +static int +_edje_lua_group_fn_signal_emit(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup); + edje_object_signal_emit(obj->eo, + luaL_checkstring(L, 2), luaL_checkstring(L, 3)); + return 0; +} + +static Edje_Program * +_edje_lua_program_get_byname(Evas_Object * obj, const char *prog_name) +{ + Edje_Program *epr; + int i; + Edje *ed; + ed = _edje_fetch(obj); + if (!ed) + return NULL; + if (!prog_name) + return NULL; + for (i = 0; i < ed->table_programs_size; i++) + { + epr = ed->table_programs[i]; + if ((epr->name) && (strcmp(epr->name, prog_name) == 0)) + return epr; + } + return NULL; +} + +static int +_edje_lua_group_fn_program_run(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup); + Edje_Program *pr = + _edje_lua_program_get_byname(obj->eo, luaL_checkstring(L, 2)); + if (pr) + _edje_program_run(obj->ed, pr, 0, "", ""); + return 0; +} + +static int +_edje_lua_group_fn_program_stop(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup); + Edje_Program *pr = + _edje_lua_program_get_byname(obj->eo, luaL_checkstring(L, 2)); + int program_id = pr->id; + Edje_Running_Program *runp; + Eina_List *l; + obj->ed->walking_actions = 1; + EINA_LIST_FOREACH(obj->ed->actions, l, runp) + if (program_id == runp->program->id) + _edje_program_end(obj->ed, runp); + obj->ed->walking_actions = 0; + return 0; +} + +static int +_edje_lua_group_fn_message_send(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup); + int type = luaL_checkint(L, 2); + void *msg = NULL; + int i; + int size; + switch (type) + { + case EDJE_MESSAGE_NONE: + break; + case EDJE_MESSAGE_SIGNAL: + break; + case EDJE_MESSAGE_STRING: + { + Edje_Message_String *msg_string = + malloc(sizeof(Edje_Message_String)); + msg_string->str = (char *)luaL_checkstring(L, 4); + msg = msg_string; + } + break; + case EDJE_MESSAGE_INT: + { + Edje_Message_Int *msg_int = malloc(sizeof(Edje_Message_Int)); + + msg_int->val = luaL_checkint(L, 4); + msg = msg_int; + } + break; + case EDJE_MESSAGE_FLOAT: + { + Edje_Message_Float *msg_float = malloc(sizeof(Edje_Message_Float)); + + msg_float->val = luaL_checknumber(L, 4); + msg = msg_float; + } + break; + case EDJE_MESSAGE_STRING_SET: + { + if (lua_type(L, 4) != LUA_TTABLE) + break; + size = lua_objlen(L, 4); + Edje_Message_String_Set *msg_string_set = + malloc(sizeof(Edje_Message_String_Set) + + (size - 1) * sizeof(char *)); + msg_string_set->count = size; + for (i = 0; i < size; i++) + { + lua_rawgeti(L, 4, i + 1); + msg_string_set->str[i] = (char *)luaL_checkstring(L, -1); + lua_pop(L, 1); + } + msg = msg_string_set; + } + break; + case EDJE_MESSAGE_INT_SET: + { + if (lua_type(L, 4) != LUA_TTABLE) + break; + size = lua_objlen(L, 4); + Edje_Message_Int_Set *msg_int_set = + malloc(sizeof(Edje_Message_Int_Set) + (size - 1) * sizeof(int)); + msg_int_set->count = size; + for (i = 0; i < size; i++) + { + lua_rawgeti(L, 4, i + 1); + msg_int_set->val[i] = luaL_checkint(L, -1); + lua_pop(L, 1); + } + msg = msg_int_set; + } + break; + case EDJE_MESSAGE_FLOAT_SET: + { + if (lua_type(L, 4) != LUA_TTABLE) + break; + size = lua_objlen(L, 4); + Edje_Message_Float_Set *msg_float_set = + malloc(sizeof(Edje_Message_Float_Set) + + (size - 1) * sizeof(double)); + msg_float_set->count = size; + for (i = 0; i < size; i++) + { + lua_rawgeti(L, 4, i + 1); + msg_float_set->val[i] = luaL_checknumber(L, -1); + lua_pop(L, 1); + } + msg = msg_float_set; + } + break; + case EDJE_MESSAGE_STRING_INT: + { + Edje_Message_String_Int *msg_string_int = + malloc(sizeof(Edje_Message_String_Int)); + msg_string_int->str = (char *)luaL_checkstring(L, 4); + msg_string_int->val = luaL_checkint(L, 5); + msg = msg_string_int; + } + break; + case EDJE_MESSAGE_STRING_FLOAT: + { + Edje_Message_String_Float *msg_string_float = + malloc(sizeof(Edje_Message_String_Float)); + msg_string_float->str = (char *)luaL_checkstring(L, 4); + msg_string_float->val = luaL_checknumber(L, 5); + msg = msg_string_float; + } + break; + case EDJE_MESSAGE_STRING_INT_SET: + { + if (lua_type(L, 5) != LUA_TTABLE) + break; + size = lua_objlen(L, 5); + Edje_Message_String_Int_Set *msg_string_int_set = + malloc(sizeof(Edje_Message_String_Int_Set) + + (size - 1) * sizeof(int)); + msg_string_int_set->str = (char *)luaL_checkstring(L, 4); + msg_string_int_set->count = size; + for (i = 0; i < size; i++) + { + lua_rawgeti(L, 5, i + 1); + msg_string_int_set->val[i] = luaL_checkint(L, -1); + lua_pop(L, 1); + } + msg = msg_string_int_set; + } + break; + case EDJE_MESSAGE_STRING_FLOAT_SET: + { + if (lua_type(L, 5) != LUA_TTABLE) + break; + size = lua_objlen(L, 5); + Edje_Message_String_Float_Set *msg_string_float_set = + malloc(sizeof(Edje_Message_String_Float_Set) + + (size - 1) * sizeof(double)); + msg_string_float_set->str = (char *)luaL_checkstring(L, 4); + msg_string_float_set->count = size; + for (i = 0; i < size; i++) + { + lua_rawgeti(L, 5, i + 1); + msg_string_float_set->val[i] = luaL_checknumber(L, -1); + lua_pop(L, 1); + } + msg = msg_string_float_set; + } + break; + default: + break; + } + + if (msg) + { + edje_object_message_send(obj->eo, type, luaL_checkint(L, 3), msg); + free(msg); + } + + return 0; +} + +static void +_edje_lua_group_signal_callback(void *data, Evas_Object * edj, + const char *signal, const char *source) +{ + Edje_Lua_Ref *cb = data; + lua_State *L = cb->L; + _edje_lua_get_ref(L, cb); // signal callback function + if (lua_isfunction(L, -1)) + { + int err_code; + + _edje_lua_get_reg(L, edj); + lua_pushstring(L, signal); // signal + lua_pushstring(L, source); // source + + if ((err_code = lua_pcall(L, 3, 0, 0))) + _edje_lua_error(L, err_code); + } +} + +static int +_edje_lua_group_fn_signal_callback_add(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup); + if (lua_type(L, 4) == LUA_TFUNCTION) + { + Edje_Lua_Ref *ref = _edje_lua_new_ref(L, 4); + obj->cb = eina_list_append(obj->cb, ref); + edje_object_signal_callback_add(obj->eo, + luaL_checkstring(L, 2), + luaL_checkstring(L, 3), + _edje_lua_group_signal_callback, + ref); // freed in _edje_lua_group_fn_signal_callback_del + } + return 0; +} + +static int +_edje_lua_group_fn_signal_callback_del(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup); + Edje_Lua_Ref *ref = edje_object_signal_callback_del(obj->eo, + luaL_checkstring(L, 2), + luaL_checkstring(L, 3), + _edje_lua_group_signal_callback); + obj->cb = eina_list_remove(obj->cb, ref); + _edje_lua_free_ref(L, ref); // created in _edje_lua_group_fn_signal_callback_add + return 0; +} + +static int +_edje_lua_group_fn_freeze(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup); + edje_object_freeze(obj->eo); + return 0; +} + +static int +_edje_lua_group_fn_thaw(lua_State *L) +{ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata(L, 1, &mGroup); + edje_object_thaw(obj->eo); + return 0; +} + +const luaL_Reg lGroup_fn[] = { + {"timer", _edje_lua_group_fn_timer}, + {"animator", _edje_lua_group_fn_animator}, + {"poller", _edje_lua_group_fn_poller}, + {"transform", _edje_lua_group_fn_transform}, + {"signal_emit", _edje_lua_group_fn_signal_emit}, + {"message_send", _edje_lua_group_fn_message_send}, + {"program_run", _edje_lua_group_fn_program_run}, + {"program_stop", _edje_lua_group_fn_program_stop}, + {"signal_callback_add", _edje_lua_group_fn_signal_callback_add}, + {"signal_callback_del", _edje_lua_group_fn_signal_callback_del}, + {"freeze", _edje_lua_group_fn_freeze}, + {"thaw", _edje_lua_group_fn_thaw}, + {NULL, NULL} // sentinel +}; + +/* + * Lua bindings + */ + +const luaL_Reg lScript_get[]; + +const luaL_Reg lScript_set[]; + +const luaL_Reg lScript_fn[]; + +const Edje_Lua_Reg mScript = { + lNil, + lScript_get, + lScript_set, + lScript_fn +}; + +const Edje_Lua_Reg *cScript[] = { + &mClass, + &mObject, + &mGroup, + &mScript, + NULL // sentinel +}; + +/* + * macro for adding an evas_object in the lua_script_only object + */ +#define _EDJE_LUA_SCRIPT_FN_ADD(DEF, CLASS, FUNC) \ + static int \ + DEF (lua_State *L) \ + { \ + int set = lua_gettop (L) == 2; \ + Edje_Lua_Evas_Object *obj = _edje_lua_checkudata (L, 1, &mScript); \ + Edje_Lua_Evas_Object *tar = lua_newuserdata (L, sizeof (Edje_Lua_Evas_Object)); \ + _edje_lua_set_class (L, -1, CLASS); \ + tar->eo = FUNC (obj->ed->evas); \ + tar->ed = obj->ed; \ + tar->L = L; \ + tar->cb = NULL; \ + evas_object_move (tar->eo, obj->ed->x, obj->ed->y); \ + _edje_lua_new_reg (L, -1, tar); /* freed in _edje_lua_object_del_cb */ \ + _edje_lua_new_reg (L, -1, tar->eo); /* freed in _edje_lua_object_del_cb */ \ + evas_object_smart_member_add (tar->eo, obj->eo); \ + evas_object_clip_set (tar->eo, obj->ed->clipper); \ + evas_object_event_callback_add (tar->eo, EVAS_CALLBACK_DEL, _edje_lua_object_del_cb, L); \ + if (set) \ + { \ + int err_code; \ + lua_getfield (L, -1, "set"); \ + lua_pushvalue (L, -2); \ + lua_pushvalue (L, 2); \ + if ((err_code = lua_pcall (L, 2, 0, 0))) \ + _edje_lua_error (L, err_code); \ + } \ + return 1; \ + } + +_EDJE_LUA_SCRIPT_FN_ADD(_edje_lua_script_fn_rectangle, + cRectangle, + evas_object_rectangle_add) +_EDJE_LUA_SCRIPT_FN_ADD(_edje_lua_script_fn_image, + cImage, + evas_object_image_add) +_EDJE_LUA_SCRIPT_FN_ADD(_edje_lua_script_fn_table, + cTable, + evas_object_table_add) +_EDJE_LUA_SCRIPT_FN_ADD(_edje_lua_script_fn_line, + cLine, + evas_object_line_add) +_EDJE_LUA_SCRIPT_FN_ADD(_edje_lua_script_fn_polygon, + cPolygon, + evas_object_polygon_add) +_EDJE_LUA_SCRIPT_FN_ADD(_edje_lua_script_fn_group, cGroup, edje_object_add) + +const luaL_Reg lScript_fn[] = { + {"rectangle", _edje_lua_script_fn_rectangle}, + {"image", _edje_lua_script_fn_image}, + {"table", _edje_lua_script_fn_table}, + {"line", _edje_lua_script_fn_line}, + {"polygon", _edje_lua_script_fn_polygon}, + {"group", _edje_lua_script_fn_group}, + {NULL, NULL} // sentinel +}; + +const luaL_Reg lScript_get[] = { + {NULL, NULL} // sentinel +}; + +const luaL_Reg lScript_set[] = { + {NULL, NULL} // sentinel +}; + +/* + * creates and exports a lua_script_only object + */ +void +_edje_lua_script_fn_new(Edje * ed) +{ + lua_State *L = ed->L; + Edje_Lua_Evas_Object *tar = lua_newuserdata(L, sizeof(Edje_Lua_Evas_Object)); + _edje_lua_set_class(L, -1, cScript); + tar->eo = ed->obj; + tar->ed = ed; + tar->L = L; + tar->cb = NULL; + _edje_lua_new_reg(L, -1, tar); // freed in _edje_lua_object_del_cb + _edje_lua_new_reg(L, -1, ed); // freed in edje_load.c::_edje_file_del + _edje_lua_new_reg(L, -1, ed->obj); // freed in _edje_lua_object_del_cb + evas_object_event_callback_add(tar->eo, EVAS_CALLBACK_DEL, + _edje_lua_object_del_cb, L); +} + +/* + * creates and exports an Edje group with associated Lua scripts in the parts and programs sections + */ +void +_edje_lua_group_fn_new(Edje * ed) +{ + lua_State *L = ed->L; + Edje_Lua_Evas_Object *tar = lua_newuserdata(L, sizeof(Edje_Lua_Evas_Object)); + _edje_lua_set_class(L, -1, cGroup); + tar->eo = ed->obj; + tar->ed = ed; + tar->L = L; + tar->cb = NULL; + _edje_lua_new_reg(L, -1, tar); // freed in _edje_lua_object_del_cb + _edje_lua_new_reg(L, -1, ed); // freed in edje_load.c::_edje_file_del + _edje_lua_new_reg(L, -1, ed->obj); // freed in _edje_lua_object_del_cb + evas_object_event_callback_add(tar->eo, EVAS_CALLBACK_DEL, + _edje_lua_object_del_cb, L); +} + +/* + * this function loads all the Lua bindings into the global Lua state + */ +static void +_edje_lua_open(lua_State *L) +{ + /* + * export classes + */ + _edje_lua_new_class(L, cTimer); + _edje_lua_new_class(L, cAnimator); + _edje_lua_new_class(L, cPoller); + _edje_lua_new_class(L, cTransform); + _edje_lua_new_class(L, cRectangle); + _edje_lua_new_class(L, cImage); + _edje_lua_new_class(L, cTable); + _edje_lua_new_class(L, cLine); + _edje_lua_new_class(L, cPolygon); + _edje_lua_new_class(L, cGroup); + _edje_lua_new_class(L, cDescription); + _edje_lua_new_class(L, cPart); + _edje_lua_new_class(L, cScript); + + /* + * export constants + */ + _edje_lua_new_const(L, "MESSAGE_NONE", EDJE_MESSAGE_NONE); + _edje_lua_new_const(L, "MESSAGE_SIGNAL", EDJE_MESSAGE_SIGNAL); + _edje_lua_new_const(L, "MESSAGE_STRING", EDJE_MESSAGE_STRING); + _edje_lua_new_const(L, "MESSAGE_INT", EDJE_MESSAGE_INT); + _edje_lua_new_const(L, "MESSAGE_FLOAT", EDJE_MESSAGE_FLOAT); + _edje_lua_new_const(L, "MESSAGE_STRING_SET", EDJE_MESSAGE_STRING_SET); + _edje_lua_new_const(L, "MESSAGE_INT_SET", EDJE_MESSAGE_INT_SET); + _edje_lua_new_const(L, "MESSAGE_FLOAT_SET", EDJE_MESSAGE_FLOAT_SET); + _edje_lua_new_const(L, "MESSAGE_STRING_INT", EDJE_MESSAGE_STRING_INT); + _edje_lua_new_const(L, "MESSAGE_STRING_FLOAT", EDJE_MESSAGE_STRING_FLOAT); + _edje_lua_new_const(L, "MESSAGE_STRING_INT_SET", EDJE_MESSAGE_STRING_INT_SET); + _edje_lua_new_const(L, "MESSAGE_STRING_FLOAT_SET", EDJE_MESSAGE_STRING_FLOAT_SET); + + _edje_lua_new_const(L, "PART_TYPE_NONE", EDJE_PART_TYPE_NONE); + _edje_lua_new_const(L, "PART_TYPE_RECTANGLE", EDJE_PART_TYPE_RECTANGLE); + _edje_lua_new_const(L, "PART_TYPE_TEXT", EDJE_PART_TYPE_TEXT); + _edje_lua_new_const(L, "PART_TYPE_IMAGE", EDJE_PART_TYPE_IMAGE); + _edje_lua_new_const(L, "PART_TYPE_SWALLOW", EDJE_PART_TYPE_SWALLOW); + _edje_lua_new_const(L, "PART_TYPE_TEXTBLOCK", EDJE_PART_TYPE_TEXTBLOCK); + _edje_lua_new_const(L, "PART_TYPE_GRADIENT", EDJE_PART_TYPE_GRADIENT); + _edje_lua_new_const(L, "PART_TYPE_GROUP", EDJE_PART_TYPE_GROUP); + _edje_lua_new_const(L, "PART_TYPE_BOX", EDJE_PART_TYPE_BOX); + + _edje_lua_new_const(L, "TEXT_EFFECT_NONE", EDJE_TEXT_EFFECT_NONE); + _edje_lua_new_const(L, "TEXT_EFFECT_PLAIN", EDJE_TEXT_EFFECT_PLAIN); + _edje_lua_new_const(L, "TEXT_EFFECT_OUTLINE", EDJE_TEXT_EFFECT_OUTLINE); + _edje_lua_new_const(L, "TEXT_EFFECT_OTLINE", EDJE_TEXT_EFFECT_SOFT_OUTLINE); + _edje_lua_new_const(L, "TEXT_EFFECT_SHADOW", EDJE_TEXT_EFFECT_SHADOW); + _edje_lua_new_const(L, "TEXT_EFFECT_SOFT_SHADOW", EDJE_TEXT_EFFECT_SOFT_SHADOW); + _edje_lua_new_const(L, "TEXT_EFFECT_OUTLINE_SHADOW", EDJE_TEXT_EFFECT_OUTLINE_SHADOW); + _edje_lua_new_const(L, "TEXT_EFFECT_OUTLINE_SOFT_SHADOW", EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW); + _edje_lua_new_const(L, "TEXT_EFFECT_FAR_SHADOW", EDJE_TEXT_EFFECT_FAR_SHADOW); + _edje_lua_new_const(L, "TEXT_EFFECT_FAR_SOFT_SHADOW", EDJE_TEXT_EFFECT_FAR_SOFT_SHADOW); + _edje_lua_new_const(L, "TEXT_EFFECT_GLOW", EDJE_TEXT_EFFECT_GLOW); + + _edje_lua_new_const(L, "RENDER_BLEND", EVAS_RENDER_BLEND); + _edje_lua_new_const(L, "RENDER_BLEND_REL", EVAS_RENDER_BLEND_REL); + _edje_lua_new_const(L, "RENDER_COPY", EVAS_RENDER_COPY); + _edje_lua_new_const(L, "RENDER_COPY_REL", EVAS_RENDER_COPY_REL); + _edje_lua_new_const(L, "RENDER_ADD", EVAS_RENDER_ADD); + _edje_lua_new_const(L, "RENDER_ADD_REL", EVAS_RENDER_ADD_REL); + _edje_lua_new_const(L, "RENDER_SUB", EVAS_RENDER_SUB); + _edje_lua_new_const(L, "RENDER_SUB_REL", EVAS_RENDER_SUB_REL); + _edje_lua_new_const(L, "RENDER_TINT", EVAS_RENDER_TINT); + _edje_lua_new_const(L, "RENDER_TINT_REL", EVAS_RENDER_TINT_REL); + _edje_lua_new_const(L, "RENDER_MASK", EVAS_RENDER_MASK); + _edje_lua_new_const(L, "RENDER_MUL", EVAS_RENDER_MUL); + + _edje_lua_new_const(L, "BORDER_FILL_NONE", EVAS_BORDER_FILL_NONE); + _edje_lua_new_const(L, "BORDER_FILL_DEFAULT", EVAS_BORDER_FILL_DEFAULT); + _edje_lua_new_const(L, "BORDER_FILL_SOLID", EVAS_BORDER_FILL_SOLID); + + _edje_lua_new_const(L, "POINTER_MODE_AUTOGRAB", EVAS_OBJECT_POINTER_MODE_AUTOGRAB); + _edje_lua_new_const(L, "POINTER_MODE_NOGRAB", EVAS_OBJECT_POINTER_MODE_NOGRAB); + + _edje_lua_new_const(L, "ASPECT_CONTROL_NEITHER", EVAS_ASPECT_CONTROL_NEITHER); + _edje_lua_new_const(L, "ASPECT_CONTROL_HORIZONTAL", EVAS_ASPECT_CONTROL_HORIZONTAL); + _edje_lua_new_const(L, "ASPECT_CONTROL_VERTICAL", EVAS_ASPECT_CONTROL_VERTICAL); + _edje_lua_new_const(L, "ASPECT_CONTROL_BOTH", EVAS_ASPECT_CONTROL_BOTH); + + _edje_lua_new_const(L, "CALLBACK_RENEW", ECORE_CALLBACK_RENEW); + _edje_lua_new_const(L, "CALLBACK_CANCEL", ECORE_CALLBACK_CANCEL); +} + +/* + * main Lua state + * created by edje_init () + * closed by edje_shutdown () + * any other private Lua state inherits from this global state + */ +static lua_State *Ledje = NULL; + +lua_State * +_edje_lua_state_get () +{ + return Ledje; +} + +/* + * custom memory allocation function + * raises an error, if memory usage is above the given maximum + */ +static void * +_edje_lua_alloc(void *ud, void *ptr, size_t osize, size_t nsize) +{ + Edje_Lua_Alloc *ela = ud; + void *ptr2; + + ela->cur += nsize - osize; + if (ela->cur > ela->max) + { + ERR("Edje Lua memory limit of %zu bytes reached (%zu allocated)", + ela->max, ela->cur); + return NULL; + } + if (nsize == 0) + { + free(ptr); /* ANSI requires that free(NULL) has no effect */ + return NULL; + } + + /* ANSI requires that realloc(NULL, size) == malloc(size) */ + ptr2 = realloc(ptr, nsize); + if (ptr2) return ptr2; + ERR("Edje Lua cannot re-allocate %zu bytes", nsize); + return ptr2; +} + +void +_edje_lua_init() +{ + if (Ledje != NULL) return; + /* + * create main Lua state with the custom memory allocation function + */ + static Edje_Lua_Alloc ela = { 1e7, 0 }; // TODO make the memory limit configurable? + Ledje = lua_newstate(_edje_lua_alloc, &ela); + if (!Ledje) + { + ERR("Lua error: Lua state could not be initialized"); + exit(-1); + } + + lua_atpanic(Ledje, _edje_lua_custom_panic); + + /* + * configure Lua garbage collector + * TODO optimize garbage collector for typical edje use or make it configurable + */ + lua_gc(Ledje, LUA_GCSETPAUSE, 200); + lua_gc(Ledje, LUA_GCSETSTEPMUL, 200); + + /* + * sandbox Lua + * no access to io, os and package routines + * no loading and execution of files + * no loading and execution of strings + * no access to the OS environment + */ + luaopen_base(Ledje); + luaopen_table(Ledje); + luaopen_string(Ledje); + luaopen_math(Ledje); + luaopen_os(Ledje); + + /* + * FIXME + * this is just for debug purposes + * remove it in the final version + */ + lua_pushnil(Ledje); + lua_setglobal(Ledje, "load"); + lua_pushnil(Ledje); + lua_setglobal(Ledje, "loadfile"); + lua_pushnil(Ledje); + lua_setglobal(Ledje, "loadstring"); + lua_pushnil(Ledje); + lua_setglobal(Ledje, "dofile"); + lua_pushnil(Ledje); + lua_setglobal(Ledje, "dostring"); + + lua_getglobal(Ledje, "os"); + lua_pushnil(Ledje); + lua_setfield(Ledje, -2, "exit"); + lua_pushnil(Ledje); + lua_setfield(Ledje, -2, "setlocale"); + lua_pushnil(Ledje); + lua_setfield(Ledje, -2, "getenv"); + lua_pushnil(Ledje); + lua_setfield(Ledje, -2, "remove"); + lua_pushnil(Ledje); + lua_setfield(Ledje, -2, "tmpname"); + lua_pushnil(Ledje); + lua_setfield(Ledje, -2, "rename"); + lua_pushnil(Ledje); + lua_setfield(Ledje, -2, "execute"); + lua_pushnil(Ledje); + + /* + * we need a weak value registry + * so that deleted and unused objects can be garbage collected + */ + lua_createtable(Ledje, 1, 0); + //lua_pushstring(Ledje, "v"); + lua_pushstring(Ledje, ""); + lua_setfield(Ledje, -2, "__mode"); + lua_setmetatable(Ledje, LUA_REGISTRYINDEX); + + /* + * load Lua Evas/Edje bindings + */ + _edje_lua_open(Ledje); +} + +void +_edje_lua_shutdown() +{ + if (Ledje == NULL) return; + lua_close(Ledje); + Ledje = NULL; +} + +#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 @@ +// FIXME: Some error checking would be nice. + + +#include "edje_private.h" +#include + +#define RASTER_FORGOT_WHY "this is here." + +#ifdef _WIN32 +# define FMT_SIZE_T "%Iu" +#else +# define FMT_SIZE_T "%zu" +#endif + +//--------------------------------------------------------------------------// +#define MAX_LUA_MEM (4 * (1024 * 1024)) +#define ELO "|-ELO" + +#define LC(...) EINA_LOG_DOM_CRIT(_log_domain, __VA_ARGS__) +#define LE(...) EINA_LOG_DOM_ERR(_log_domain, __VA_ARGS__) +#define LW(...) EINA_LOG_DOM_WARN(_log_domain, __VA_ARGS__) +#define LI(...) EINA_LOG_DOM_INFO(_log_domain, __VA_ARGS__) +#define LD(...) EINA_LOG_DOM_DBG(_log_domain, __VA_ARGS__) + +/** +@page luaref Edje Lua scripting + +@section intro Introduction + +Lua is intended for script-only objects at this point (with embryo left +for augmenting standard programs). Since script-only objects effectively +define objects entirely via Lua script (resize handling, event handling +etc. etc.) this places many more demands on them, and thus a more powerful +language is in order. Lua is that language. + +To get you started, here's an example that uses most of this lua API: +@ref lua_script.edc + +Most of these lua functions are wrappers around various evas, ecore, and edje C +functions. Refer to their documentation for more in depth details and up to +date documentation. A lot of this documentation is simple copied from the C +functions it wraps. + +@section args Lua function argument and return syntax + +Some of the lua functions can accept a table as well as separate arguments. +Some of them return tables. + +@section classes Lua classes + +*/ + +/* +Lua functions stack usage. + +In the definition of the lua functions provided, always mention the stack usage, +using the same notation that is used in the Lua 5.1 Reference Manual. +http://www.lua.org/manual/5.1/manual.html#3.7 describes that notation. + +On the other hand, lua discards excess stack entries when control passes back to +it, but it's good to maintain proper discipline. + +Should do the same for the support functions. These ARE more important to check. +*/ + +//--------------------------------------------------------------------------// +typedef struct _Edje_Lua_Alloc Edje_Lua_Alloc; +typedef struct _Edje_Lua_Obj Edje_Lua_Obj; +typedef struct _Edje_Lua_Animator Edje_Lua_Animator; +typedef struct _Edje_Lua_Timer Edje_Lua_Timer; +typedef struct _Edje_Lua_Transition Edje_Lua_Transition; +typedef struct _Edje_Lua_Evas_Object Edje_Lua_Evas_Object; +typedef struct _Edje_Lua_Map Edje_Lua_Map; + +struct _Edje_Lua_Alloc +{ + size_t max, cur; +}; + +struct _Edje_Lua_Obj +{ + EINA_INLIST; + + Edje *ed; + void (*free_func) (void *obj); + const char *meta; +}; + +struct _Edje_Lua_Animator +{ + Edje_Lua_Obj obj; + Ecore_Animator *animator; + int fn_ref; +}; + +struct _Edje_Lua_Timer +{ + Edje_Lua_Obj obj; + Ecore_Timer *timer; + int fn_ref; +}; + +struct _Edje_Lua_Transition +{ + Edje_Lua_Obj obj; + Ecore_Animator *animator; + double transition, start; + int fn_ref; +}; + +struct _Edje_Lua_Evas_Object +{ + Edje_Lua_Obj obj; + Evas_Object *evas_obj; + int x, y; +}; + +struct _Edje_Lua_Map +{ + Edje_Lua_Obj obj; + Evas_Map *map; +}; + + +static void _elua_add_functions(lua_State *L, const char *api, const luaL_Reg *funcs, const char *meta, const char *parent, const char *base); +static Eina_Bool _elua_isa(Edje_Lua_Obj *obj, const char *type); + +//--------------------------------------------------------------------------// +#ifndef RASTER_FORGOT_WHY +static lua_State *lstate = NULL; +#endif +static const char *_elua_key = "key"; +static const char *_elua_objs = "objs"; +/* This is not needed, pcalls don't longjmp(), that's why they are protected. +static jmp_buf panic_jmp; +*/ +static int panics = 0; +static int _log_domain = -1; +static int _log_count = 0; + +// FIXME: methods lua script can provide that edje will call (not done yet): +// // scale set +// // key down +// // key up +// // get dragable pos +// // set dragable pos +// // set drag size, step, page +// // get drag size, step, page +// // dragable step +// // dragable page +// // get part text +// // set part text +// // get swallow part +// // set swallow part +// // unswallow part +// // textclass change +// // colorclass change +// // min size get <- ?? maybe set fn +// // max size get <- ?? maybe set fn +// // min size caclc (min/max restriction) +// // preload +// // preload cancel +// // play set +// // animation set +// // parts extends calc +// // part object get +// // part geometry get +// +// // LATER: all the entry calls +// // LATER: box and table calls +// // LATER: perspective stuff change +// + +// Grumble, pre-declare these. +static const char *_elua_edje_meta = "edje_meta"; +static const char *_elua_evas_meta = "evas_meta"; +static const char *_elua_evas_edje_meta = "evas_edje_meta"; +static const char *_elua_evas_image_meta = "evas_image_meta"; +static const char *_elua_evas_line_meta = "evas_line_meta"; +static const char *_elua_evas_map_meta = "evas_map_meta"; +static const char *_elua_evas_polygon_meta = "evas_polygon_meta"; +static const char *_elua_evas_text_meta = "evas_text_meta"; +static const char *_elua_ecore_animator_meta = "ecore_animator_meta"; +static const char *_elua_ecore_timer_meta = "ecore_timer_meta"; + +static int _elua_obj_gc(lua_State *L); + +static const struct luaL_reg _elua_edje_gc_funcs [] = +{ + {"__gc", _elua_obj_gc}, // garbage collector func for edje objects + + {NULL, NULL} // end +}; + +static const luaL_Reg _elua_libs[] = +{ + {"", luaopen_base}, +// {LUA_LOADLIBNAME, luaopen_package}, // disable this lib - don't want + {LUA_TABLIBNAME, luaopen_table}, +// {LUA_IOLIBNAME, luaopen_io}, // disable this lib - don't want +// {LUA_OSLIBNAME, luaopen_os}, // FIXME: audit os lib - maybe not provide or only provide specific calls + {LUA_STRLIBNAME, luaopen_string}, + {LUA_MATHLIBNAME, luaopen_math}, +// {LUA_DBLIBNAME, luaopen_debug}, // disable this lib - don't want + + {NULL, NULL} // end +}; + +//--------------------------------------------------------------------------// +static void * +_elua_alloc(void *ud, void *ptr, size_t osize, size_t nsize) +{ + Edje_Lua_Alloc *ela = ud; + void *ptr2; + + ela->cur += nsize - osize; + if (ela->cur > ela->max) + { + ERR("Lua memory limit of " FMT_SIZE_T " bytes reached (" FMT_SIZE_T " allocated)", + ela->max, ela->cur); + return NULL; + } + if (nsize == 0) + { + free(ptr); + return NULL; + } + + ptr2 = realloc(ptr, nsize); + if (ptr2) return ptr2; + ERR("Lua cannot re-allocate " FMT_SIZE_T " bytes", nsize); + return ptr2; +} + +static int +_elua_custom_panic(lua_State *L) // Stack usage [-0, +0, m] +{ + // If we somehow manage to have multiple panics, it's likely due to being out + // of memory in the following lua_tostring() call. + panics++; + if (panics) + { + EINA_LOG_DOM_CRIT(_edje_default_log_dom, "Lua PANICS!!!!!"); + } + else + { + EINA_LOG_DOM_CRIT(_edje_default_log_dom, + "Lua PANIC!!!!!: %s", lua_tostring(L, -1)); // Stack usage [-0, +0, m] + } + // The docs say that this will cause an exit(EXIT_FAILURE) if we return, + // and that we we should long jump some where to avoid that. This is only + // called for things not called from a protected environment. We always + // use pcalls though, except for the library load calls. If we can't load + // the standard libraries, then perhaps a crash is the right thing. + return 0; +} + +// Really only used to manage the pointer to our edje. +static void +_elua_table_ptr_set(lua_State *L, const void *key, const void *val) // Stack usage [-2, +2, e] +{ + lua_pushlightuserdata(L, (void *)key); // Stack usage [-0, +1, -] + lua_pushlightuserdata(L, (void *)val); // Stack usage [-0, +1, -] + lua_settable(L, LUA_REGISTRYINDEX); // Stack usage [-2, +0, e] +} + +static const void * +_elua_table_ptr_get(lua_State *L, const void *key) // Stack usage [-2, +2, e] +{ + const void *ptr; + lua_pushlightuserdata(L, (void *)key); // Stack usage [-0, +1, -] + lua_gettable(L, LUA_REGISTRYINDEX); // Stack usage [-1, +1, e] + ptr = lua_topointer(L, -1); // Stack usage [-0, +0, -] + lua_pop(L, 1); // Stack usage [-n, +0, -] + return ptr; +} + +/* XXX: not used +static void +_elua_table_ptr_del(lua_State *L, const void *key) // Stack usage [-2, +2, e] +{ + lua_pushlightuserdata(L, (void *)key); // Stack usage [-0, +1, -] + lua_pushnil(L); // Stack usage [-0, +1, -] + lua_settable(L, LUA_REGISTRYINDEX); // Stack usage [-2, +0, e] +} +*/ + +/* + * Cori: Assumes object to be saved on top of stack + */ +static void +_elua_ref_set(lua_State *L, void *key) // Stack usage [-4, +4, m] +{ + lua_pushlightuserdata(L, &_elua_objs); // Stack usage [-0, +1, -] + lua_rawget(L, LUA_REGISTRYINDEX); // Stack usage [-1, +1, -] + lua_pushlightuserdata(L, key); // Stack usage [-0, +1, -] + lua_pushvalue(L,-3); // Stack usage [-0, +1, -] + lua_rawset(L, -3); // Stack usage [-2, +0, m] + lua_pop(L, 1); // Stack usage [-n, +0, -] +} + +/* + * Cori: Get an object from the object table + */ +static void * +_elua_ref_get(lua_State *L, void *key) // Stack usage [-3, +4, -] +{ + lua_pushlightuserdata(L, &_elua_objs); // Stack usage [-0, +1, -] + lua_rawget(L, LUA_REGISTRYINDEX); // Stack usage [-1, +1, -] + lua_pushlightuserdata(L, key); // Stack usage [-0, +1, -] + lua_rawget(L, -2); // Stack usage [-1, +1, -] + lua_remove(L, -2); // Stack usage [-1, +0, -] + return lua_touserdata(L, -2); // Stack usage [-0, +0, -] +} + +static Edje_Lua_Obj * +_elua_obj_new(lua_State *L, Edje *ed, int size, const char *metatable) // Stack usage [-5, +6, m] +{ + Edje_Lua_Obj *obj; + + obj = (Edje_Lua_Obj *)lua_newuserdata(L, size); // Stack usage [-0, +1, m] + memset(obj, 0, size); + ed->lua_objs = eina_inlist_append(ed->lua_objs, EINA_INLIST_GET(obj)); + + luaL_getmetatable(L, metatable); // Stack usage [-0, +1, -] + lua_setmetatable(L, -2); // Stack usage [-1, +0, -] + obj->ed = ed; + obj->meta = metatable; + + _elua_ref_set(L, obj); // Stack usage [-4, +4, m] + return obj; +} + +static void +_elua_obj_free(lua_State *L __UNUSED__, Edje_Lua_Obj *obj) +{ + if (!obj->free_func) return; + obj->free_func(obj); + obj->ed->lua_objs = eina_inlist_remove(obj->ed->lua_objs, EINA_INLIST_GET(obj)); + obj->free_func = NULL; + obj->ed = NULL; +} + +static int +_elua_obj_gc(lua_State *L) // Stack usage [-0, +0, -] +{ + Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -] + if (!obj) return 0; + _elua_obj_free(L, obj); + return 0; +} + +static int +_elua_obj_del(lua_State *L) // Stack usage [-0, +0, -] +{ + return _elua_obj_gc(L); // Stack usage [-0, +0, -] +} + +static void +_elua_gc(lua_State *L) // Stack usage [-0, +0, e] +{ + lua_gc(L, LUA_GCCOLLECT, 0); // Stack usage [-0, +0, e] +} + +// These are what the various symbols are for each type - +// int % +// num # +// str $ +// bool ! +// FIXME: Still to do, if we ever use them - +// func & +// userdata + +// lightuserdata * +// table @ +// thread ^ +// nil ~ + +static char * +_elua_push_name(lua_State *L, char *q, int index) // Stack usage [-0, +1, e or m] +{ + char *p = q; + char temp = '\0'; + + // A simplistic scan through an identifier, it's wrong, but it's quick, + // and we don't mind that it's wrong, coz this is only internal. + while (isalnum((int)*q)) + q++; + temp = *q; + *q = '\0'; + if (index > 0) + lua_getfield(L, index, p); // Stack usage [-0, +1, e] + else + lua_pushstring(L, p); // Stack usage [-0, +1, m] + *q = temp; + + return q; +} + +static int +_elua_scan_params(lua_State *L, int i, char *params, ...) // Stack usage - + // if i is a table + // [-n, +n, e] + // else + // [-0, +0, -] +{ + va_list vl; + char *f = strdup(params); + char *p = f; + int n = 0, j = i, count = 0; + Eina_Bool table = EINA_FALSE; + + if (!f) return -1; + va_start(vl, params); + + if (lua_istable(L, i)) // Stack usage [-0, +0, -] + { + j = -1; + table = EINA_TRUE; + } + + while (*p) + { + char *q; + Eina_Bool get = EINA_TRUE; + + while (isspace((int)*p)) + p++; + q = p + 1; + switch (*p) + { + case '%': + { + if (table) + { + q = _elua_push_name(L, q, i); // Stack usage [-0, +1, e] + } + if (lua_isnumber(L, j)) // Stack usage [-0, +0, -] + { + int *v = va_arg(vl, int *); + *v = lua_tointeger(L, j); // Stack usage [-0, +0, -] + n++; + } + break; + } + case '#': + { + if (table) + { + q = _elua_push_name(L, q, i); // Stack usage [-0, +1, e] + } + if (lua_isnumber(L, j)) // Stack usage [-0, +0, -] + { + double *v = va_arg(vl, double *); + *v = lua_tonumber(L, j); // Stack usage [-0, +0, -] + n++; + } + break; + } + case '$': + { + if (table) + { + q = _elua_push_name(L, q, i); // Stack usage [-0, +1, e] + } + if (lua_isstring(L, j)) // Stack usage [-0, +0, -] + { + char **v = va_arg(vl, char **); + size_t len; + char *temp = (char *) lua_tolstring(L, j, &len); // Stack usage [-0, +0, m] + + len++; // Cater for the null at the end. + *v = malloc(len); + if (*v) + { + memcpy(*v, temp, len); + n++; + } + } + break; + } + case '!': + { + if (table) + { + q = _elua_push_name(L, q, i); // Stack usage [-0, +1, e] + } + if (lua_isboolean(L, j)) // Stack usage [-0, +0, -] + { + int *v = va_arg(vl, int *); + *v = lua_toboolean(L, j); // Stack usage [-0, +0, -] + n++; + } + break; + } + default: + { + get = EINA_FALSE; + break; + } + } + + if (get) + { + if (table) + { + // If this is a table, then we pushed a value on the stack, pop it off. + lua_pop(L, 1); // Stack usage [-n, +0, -] + } + else + j++; + count++; + } + p = q; + } + + free(f); + va_end(vl); + if (count > n) + n = 0; + else if (table) + n = 1; + return n; +} + +static int +_elua_ret(lua_State *L, char *params, ...) // Stack usage [-(2*n), +(2*n+1), em] +{ + va_list vl; + char *f = strdup(params); + char *p = f; + int n = 0; + + if (!f) return -1; + + lua_newtable(L); // Stack usage [-0, +1, m] + va_start(vl, params); + + while (*p) + { + char *q; + Eina_Bool set = EINA_TRUE; + + while (isspace((int)*p)) + p++; + q = p + 1; + switch (*p) + { + case '%': + { + q = _elua_push_name(L, q, -1); // Stack usage [-0, +1, m] + lua_pushinteger(L, va_arg(vl, int)); // Stack usage [-0, +1, -] + break; + } + case '#': + { + q = _elua_push_name(L, q, -1); // Stack usage [-0, +1, m] + lua_pushnumber(L, va_arg(vl, double)); // Stack usage [-0, +1, -] + break; + } + case '$': + { + q = _elua_push_name(L, q, -1); // Stack usage [-0, +1, m] + lua_pushstring(L, va_arg(vl, char *)); // Stack usage [-0, +1, m] + break; + } + case '!': + { + q = _elua_push_name(L, q, -1); // Stack usage [-0, +1, m] + lua_pushboolean(L, va_arg(vl, int)); // Stack usage [-0, +1, -] + break; + } + default: + { + set = EINA_FALSE; + break; + } + } + + if (set) + { + lua_settable(L, -3); // Stack usage [-2, +0, e] + n++; + } + p = q; + } + + free(f); + va_end(vl); + return n; +} + +static void +_elua_color_fix(int *r, int *g, int *b, int *a) +{ + if (*r > *a) *r = *a; + if (*g > *a) *g = *a; + if (*b > *a) *b = *a; +} + +//--------------------------------------------------------------------------// + +/** +@page luaref +@subsection edje Edje class. + +The lua edje class includes functions for dealing with the lua script only group +as an edje object, basic functions, and functions to create other objects. + +In the following, "edje" is the actual global table used to access these edje functions. +*/ + +static int _elua_echo(lua_State *L); + +static int _elua_date(lua_State *L); +static int _elua_looptime(lua_State *L); +static int _elua_seconds(lua_State *L); + +static int _elua_objgeom(lua_State *L); +static int _elua_objpos(lua_State *L); +static int _elua_objsize(lua_State *L); + +static int _elua_emit(lua_State *L); +static int _elua_messagesend(lua_State *L); + +static int _elua_animator(lua_State *L); +static int _elua_timer(lua_State *L); +static int _elua_transition(lua_State *L); + +static int _elua_color_class(lua_State *L); +static int _elua_text_class(lua_State *L); + +static int _elua_edje(lua_State *L); +static int _elua_image(lua_State *L); +static int _elua_line(lua_State *L); +static int _elua_map(lua_State *L); +static int _elua_polygon(lua_State *L); +static int _elua_rect(lua_State *L); +static int _elua_text(lua_State *L); +//static int _elua_textblock(lua_State *L); /* XXX: disabled until there are enough textblock functions implemented to make it actually useful + +static const char *_elua_edje_api = "edje"; +static const struct luaL_reg _elua_edje_funcs [] = +{ + // add an echo too to make it more shelly + {"echo", _elua_echo}, // test func - echo (i know we have print. test) + // FIXME: add logging functions here, probably to it's own domain, or even a script defined domain. + + // system information (time, date blah blah) + {"date", _elua_date}, // get date in a table + {"looptime", _elua_looptime}, // get loop time + {"seconds", _elua_seconds}, // get seconds + + // query edje - size, pos + {"geom", _elua_objgeom}, // get while edje object geometry in canvas + {"pos", _elua_objpos}, // get while edje object pos in canvas + {"size", _elua_objsize}, // get while edje object pos in canvas + + // talk to application/caller + {"emit", _elua_emit}, // emit signal + src + {"messagesend", _elua_messagesend}, // send a structured message + + // time based "callback" systems + {"animator", _elua_animator}, // add animator + {"timer", _elua_timer}, // add timer + {"transition", _elua_transition}, // add transition + // FIXME: need poller + + // set and query color / text class + {"color_class", _elua_color_class}, + {"text_class", _elua_text_class}, + + // create new objects + {"edje", _elua_edje}, + {"image", _elua_image}, // defaults to a filled image. + {"line", _elua_line}, + {"map", _elua_map}, + {"polygon", _elua_polygon}, + {"rect", _elua_rect}, + {"text", _elua_text}, +// {"textblock", _elua_textblock}, /* XXX: disabled until there are enough textblock functions implemented to make it actually useful + + // FIXME: add the new sound stuff. + + {NULL, NULL} // end +}; + +/** +@page luaref +@subsubsection edje_echo edje:echo(text) + +Make lua a bit shelly. Prints a string to the console + +@param text The string to print. +*/ +static int +_elua_echo(lua_State *L) // Stack usage [-0, +0, v] +{ + const char *string = luaL_checkstring(L, 1); // Stack usage [-0, +0, v] + LD("%s\n", string); + return 0; +} + +//------------- +/** +@page luaref +@subsubsection edje_date edje:date() + +Retrieves the current time and date. + +Wraps gettimeofday(), as passed through localtime(). + +@return A table with these fields: + - integer year: Year. + - integer month: Month of the year. + - integer day: Day of the month. + - integer yearday: Day of the year. + - integer weekday: Day of the week. + - integer hour: Hour of the day (24 hour format). + - integer min: Minute of the hour. + - number sec: Seconds as a number. + +*/ +static int +_elua_date(lua_State *L) // Stack usage [-16, +17, em] +{ + static time_t last_tzset = 0; + struct timeval timev; + struct tm *tm; + time_t tt; + + gettimeofday(&timev, NULL); + tt = (time_t)(timev.tv_sec); + if ((tt > (last_tzset + 1)) || (tt < (last_tzset - 1))) + { + last_tzset = tt; + tzset(); + } + tm = localtime(&tt); + if (tm) + { // Stack usage [-16, +17, em] + _elua_ret(L, "%year %month %day %yearday %weekday %hour %min #sec", + (int)(tm->tm_year + 1900), + (int)(tm->tm_mon + 1), + (int)(tm->tm_mday), + (int)(tm->tm_yday), + (int)((tm->tm_wday + 6) % 7), + (int)(tm->tm_hour), + (int)(tm->tm_min), + (double)((double)tm->tm_sec + (((double)timev.tv_usec) / 1000000)) + ); + + + } + return 1; +} + +/** +@page luaref +@subsubsection edje_looptime edje:looptime() + +Retrieves the time at which the last loop stopped waiting for timeouts or events. + +This gets the time that the main loop ceased waiting for timouts and/or events +to come in or for signals or any other interrupt source. This should be +considered a reference point for all time based activity that should calculate +its timepoint from the return of edje:looptime(). Use this UNLESS you absolutely +must get the current actual timepoint - then use edje:seconds(). Note that this +time is meant to be used as relative to other times obtained on this run. + +Wraps ecore_loop_time_get(). + +@returns A number of seconds. +*/ +static int +_elua_looptime(lua_State *L) // Stack usage [-0, +1, -] +{ + double t = ecore_loop_time_get(); + lua_pushnumber(L, t); // Stack usage [-0, +1, -] + return 1; +} + +/** +@page luaref +@subsubsection edje_seconds edje:seconds() + +Retrieves the current system time as a floating point value in seconds. + +This uses a monotonic clock and thus never goes back in time while machine is +live (even if user changes time or timezone changes, however it may be reset +whenever the machine is restarted). + +Wraps ecore_time_get(). + +@returns A number of seconds. +*/ +static int +_elua_seconds(lua_State *L) // Stack usage [-0, +1, -] +{ + double t = ecore_time_get(); + lua_pushnumber(L, t); // Stack usage [-0, +1, -] + return 1; +} + +//------------- +/** +@page luaref +@subsubsection edje_geom edje:geom() + +Retrieves the position and size of the edje object that this lua group is in. + +@returns A table with these fields: + - integer x: The edjes X position. + - integer y: The edjes Y position. + - integer w: The edjes width. + - integer h: The edjes height. +*/ +static int +_elua_objgeom(lua_State *L) // Stack usage [-10, +11, em] +{ + Edje *ed = (Edje *)_elua_table_ptr_get(L, _elua_key); // Stack usage [-2, +2, e] + _elua_ret(L, "%x %y %w %h", ed->x, ed->y, ed->w, ed->h); // Stack usage [-8, +9, em] + return 1; +} + +/** +@page luaref +@subsubsection edje_pos edje:pos() + + +Retrieves the position of the edje object that this lua group is in. + +@returns A table with these fields: + - integer x: The edjes X position. + - integer y: The edjes Y position. +*/ +static int +_elua_objpos(lua_State *L) // Stack usage [-6, +7, em] +{ + Edje *ed = (Edje *)_elua_table_ptr_get(L, _elua_key); // Stack usage [-2, +2, e] + _elua_ret(L, "%x %y", ed->x, ed->y); // Stack usage [-4, +5, em] + return 1; +} + +/** +@page luaref +@subsubsection edje_size edje:size() + + +Retrieves the size of the edje object that this lua group is in. + +@returns A table with these fields: + - integer w: The edjes width. + - integer h: The edjes height. +*/ +static int +_elua_objsize(lua_State *L) // Stack usage [-6, +7, em] +{ + Edje *ed = (Edje *)_elua_table_ptr_get(L, _elua_key); // Stack usage [-2, +2, e] + _elua_ret(L, "%w %h", ed->w, ed->h); // Stack usage [-4, +5, em] + return 1; +} + +//------------- +/** +@page luaref +@subsubsection edje_emit edje:emit(signal, source) + +Emit a signal. + +Wraps edje_object_signal_emit(). + +@param signal The signal string to send. +@param source The source string of the signal. + +NOTE: The source string will have a name and a colon prepended to in when it is +delivered to things that are not this edje, like C and other edje groups. +If this edje is a top level edje, then it will be the name of the group (I think). +If this edje is swallowed into some other part, then it will be the name of the +part: + + group_name:source + +FIXME: I actually have no idea what happens if it's swallowed into another lua +edje group. +*/ +static int +_elua_emit(lua_State *L) // Stack usage [-2, +2, ev] +{ + Edje *ed = (Edje *)_elua_table_ptr_get(L, _elua_key); // Stack usage [-2, +2, e] + const char *sig = luaL_checkstring(L, 1); // Stack usage [-0, +0, v] + const char *src = luaL_checkstring(L, 2); // Stack usage [-0, +0, v] + if ((!sig) || (!src)) return 0; + _edje_emit(ed, sig, src); + return 0; +} + +/** +@page luaref +@subsubsection edje_message_send edje:messagesend(id, type, ...) + +Send a message to this edje, and all it's child objects. + +Wraps edje_object_message_send(). + +@param id An identification integer for the message. +@param type The type of message to send. +@param ... Zero or more things to send as part of the message, depending on the type. + +The type can be one of: + - none: No msg. + - sig: The msg is two strings (signal, source), sent as a signal. + - str: The msg is a C string. + - int: The message is a C integer. + - float: The message is a C float. + - strset: The message is an array of C strings. + - intset: The message is an array of C integers. + - floatset: The message is an array of C floats. + - strint: The message is a C stnring and a C integer. + - strfloat: The message is a C string and a C float. + - strintset: The message is a C string and an array of C integers. + - strfloatset: The message is a G string and an array of C floats. + +For the array types, the lua caller passes a table. +*/ +static int +_elua_messagesend(lua_State *L) // Stack usage [-2, +2, ev] plus [-2, +2] for every element if it's an array message. +{ + Edje *ed = (Edje *)_elua_table_ptr_get(L, _elua_key); // Stack usage [-2, +2, e] + int id = luaL_checkinteger(L, 1); // Stack usage [-0, +0, v] + const char *type = luaL_checkstring(L, 2); // Stack usage [-0, +0, v] + if (!type) return 0; + if (!strcmp(type, "none")) + { + _edje_message_send(ed, EDJE_QUEUE_APP, EDJE_MESSAGE_NONE, id, NULL); + } + else if (!strcmp(type, "sig")) + { + const char *sig = luaL_checkstring(L, 3); // Stack usage [-0, +0, v] + const char *src = luaL_checkstring(L, 4); // Stack usage [-0, +0, v] + _edje_emit(ed, sig, src); + } + else if (!strcmp(type, "str")) + { + Edje_Message_String *emsg; + const char *str = luaL_checkstring(L, 3); // Stack usage [-0, +0, v] + emsg = alloca(sizeof(Edje_Message_String)); + emsg->str = (char *)str; + _edje_message_send(ed, EDJE_QUEUE_APP, EDJE_MESSAGE_STRING, id, emsg); + } + else if (!strcmp(type, "int")) + { + Edje_Message_Int *emsg; + int val = luaL_checkinteger(L, 3); // Stack usage [-0, +0, v] + emsg = alloca(sizeof(Edje_Message_Int)); + emsg->val = val; + _edje_message_send(ed, EDJE_QUEUE_APP, EDJE_MESSAGE_INT, id, emsg); + } + else if (!strcmp(type, "float")) + { + Edje_Message_Float *emsg; + float val = luaL_checknumber(L, 3); // Stack usage [-0, +0, v] + emsg = alloca(sizeof(Edje_Message_Float)); + emsg->val = val; + _edje_message_send(ed, EDJE_QUEUE_APP, EDJE_MESSAGE_FLOAT, id, emsg); + } + else if (!strcmp(type, "strset")) + { + Edje_Message_String_Set *emsg; + int i, n; + const char *str; + luaL_checktype(L, 3, LUA_TTABLE); // Stack usage [-0, +0, v] + n = lua_objlen(L, 3); // Stack usage [-0, +0, -] + emsg = alloca(sizeof(Edje_Message_String_Set) + ((n - 1) * sizeof(char *))); + emsg->count = n; + for (i = 1; i <= n; i ++) + { + lua_pushinteger(L, i); // Stack usage [-0, +1, -] + lua_gettable(L, 3); // Stack usage [-1, +1, e] + str = lua_tostring(L, -1); // Stack usage [-0, +0, m] + lua_pop(L, 1); // Stack usage [-n, +0, -] + emsg->str[i - 1] = (char *)str; + } + _edje_message_send(ed, EDJE_QUEUE_APP, EDJE_MESSAGE_STRING_SET, id, emsg); + } + else if (!strcmp(type, "intset")) + { + Edje_Message_Int_Set *emsg; + int i, n; + luaL_checktype(L, 3, LUA_TTABLE); // Stack usage [-0, +0, v] + n = lua_objlen(L, 3); // Stack usage [-0, +0, -] + emsg = alloca(sizeof(Edje_Message_Int_Set) + ((n - 1) * sizeof(int))); + emsg->count = n; + for (i = 1; i <= n; i ++) + { + lua_pushinteger(L, i); // Stack usage [-0, +1, -] + lua_gettable(L, 3); // Stack usage [-1, +1, e] + emsg->val[i - 1] = lua_tointeger(L, -1); // Stack usage [-0, +0, -] + lua_pop(L, 1); // Stack usage [-n, +0, -] + } + _edje_message_send(ed, EDJE_QUEUE_APP, EDJE_MESSAGE_INT_SET, id, emsg); + } + else if (!strcmp(type, "floatset")) + { + Edje_Message_Float_Set *emsg; + int i, n; + luaL_checktype(L, 3, LUA_TTABLE); // Stack usage [-0, +0, v] + n = lua_objlen(L, 3); // Stack usage [-0, +0, -] + emsg = alloca(sizeof(Edje_Message_Float_Set) + ((n - 1) * sizeof(double))); + emsg->count = n; + for (i = 1; i <= n; i ++) + { + lua_pushinteger(L, i); // Stack usage [-0, +1, -] + lua_gettable(L, 3); // Stack usage [-1, +1, e] + emsg->val[i - 1] = lua_tonumber(L, -1); // Stack usage [-0, +0, -] + lua_pop(L, 1); // Stack usage [-n, +0, -] + } + _edje_message_send(ed, EDJE_QUEUE_APP, EDJE_MESSAGE_FLOAT_SET, id, emsg); + } + else if (!strcmp(type, "strint")) + { + Edje_Message_String_Int *emsg; + const char *str = luaL_checkstring(L, 3); // Stack usage [-0, +0, v] + emsg = alloca(sizeof(Edje_Message_String_Int)); + emsg->str = (char *)str; + emsg->val = luaL_checkinteger(L, 4); // Stack usage [-0, +0, v] + _edje_message_send(ed, EDJE_QUEUE_APP, EDJE_MESSAGE_STRING_INT, id, emsg); + } + else if (!strcmp(type, "strfloat")) + { + Edje_Message_String_Float *emsg; + const char *str = luaL_checkstring(L, 3); // Stack usage [-0, +0, v] + emsg = alloca(sizeof(Edje_Message_String_Float)); + emsg->str = (char *)str; + emsg->val = luaL_checknumber(L, 4); // Stack usage [-0, +0, v] + _edje_message_send(ed, EDJE_QUEUE_APP, EDJE_MESSAGE_STRING_FLOAT, id, emsg); + } + else if (!strcmp(type, "strintset")) + { + Edje_Message_String_Int_Set *emsg; + int i, n; + const char *str = luaL_checkstring(L, 3); // Stack usage [-0, +0, v] + if (!str) return 0; + luaL_checktype(L, 4, LUA_TTABLE); // Stack usage [-0, +0, v] + n = lua_objlen(L, 4); // Stack usage [-0, +0, -] + emsg = alloca(sizeof(Edje_Message_String_Int_Set) + ((n - 1) * sizeof(int))); + emsg->str = (char *)str; + emsg->count = n; + for (i = 1; i <= n; i ++) + { + lua_pushinteger(L, i); // Stack usage [-0, +1, -] + lua_gettable(L, 4); // Stack usage [-1, +1, e] + emsg->val[i - 1] = lua_tointeger(L, -1); // Stack usage [-0, +0, -] + lua_pop(L, 1); // Stack usage [-n, +0, -] + } + _edje_message_send(ed, EDJE_QUEUE_APP, EDJE_MESSAGE_STRING_INT_SET, id, emsg); + } + else if (!strcmp(type, "strfloatset")) + { + Edje_Message_String_Float_Set *emsg; + int i, n; + const char *str = luaL_checkstring(L, 3); // Stack usage [-0, +0, v] + if (!str) return 0; + luaL_checktype(L, 4, LUA_TTABLE); // Stack usage [-0, +0, v] + n = lua_objlen(L, 4); + emsg = alloca(sizeof(Edje_Message_String_Float_Set) + ((n - 1) * sizeof(double))); + emsg->str = (char *)str; + emsg->count = n; + for (i = 1; i <= n; i ++) + { + lua_pushinteger(L, i); // Stack usage [-0, +1, -] + lua_gettable(L, 4); // Stack usage [-1, +1, e] + emsg->val[i - 1] = lua_tonumber(L, -1); // Stack usage [-0, +0, -] + lua_pop(L, 1); // Stack usage [-n, +0, -] + } + _edje_message_send(ed, EDJE_QUEUE_APP, EDJE_MESSAGE_STRING_FLOAT_SET, id, emsg); + } + return 0; +} + +//------------- +static Eina_Bool +_elua_animator_cb(void *data) // Stack usage [-2, +2, em] +{ + Edje_Lua_Animator *ela = data; + lua_State *L; + int ret = 0, err = 0; + + if (!ela->obj.ed) return 0; + L = ela->obj.ed->L; + if (!L) return 0; + /* This is not needed, pcalls don't longjmp(), that's why they are protected. + if (setjmp(panic_jmp) == 1) + { + LE("Animator callback panic"); + _edje_lua2_error(L, err); // Stack usage [-0, +0, m] + _elua_obj_free(L, (Edje_Lua_Obj *)ela); + _elua_gc(L); // Stack usage [-0, +0, e] + return 0; + } + */ + lua_rawgeti(L, LUA_REGISTRYINDEX, ela->fn_ref); // Stack usage [-0, +1, -] + if ((err = lua_pcall(L, 0, 1, 0))) // Stack usage [-1, +1, -] + { + _edje_lua2_error(L, err); // Stack usage [-0, +0, m] + _elua_obj_free(L, (Edje_Lua_Obj *)ela); + _elua_gc(L); // Stack usage [-0, +0, e] + return 0; + } + ret = lua_toboolean(L, -1); // Stack usage [-0, +0, -] + lua_pop(L, 1); // Stack usage [-n, +0, -] + if (ret == 0) _elua_obj_free(L, (Edje_Lua_Obj *)ela); + _elua_gc(L); // Stack usage [-0, +0, e] + return ret; +} + +static void +_elua_animator_free(void *obj) // Stack usage [-0, +0, -] +{ + Edje_Lua_Animator *ela = obj; + lua_State *L; + if (!ela->obj.ed) return; + L = ela->obj.ed->L; + luaL_unref(L, LUA_REGISTRYINDEX, ela->fn_ref); // Stack usage [-0, +0, -] + ela->fn_ref = 0; + ecore_animator_del(ela->animator); + ela->animator = NULL; +} + +/** +@page luaref +@subsubsection edje_animator edje:animator(func) + +This function adds an animator and returns its handle on success and NULL on +failure. The function func will be called every frame tick. Note that setting +the frame tick is not available as a lua function, so has to be done from C. +The default tick is 1/30 second. + +When the animator func is called, it must return a value of either true or false. +If it returns true it will be called again at the next tick, or if it returns +false it will be deleted automatically making any references/handles for it +invalid. + +Wraps ecore_animator_add(). + +@param func The function to call when the animator triggers. + +@returns A userdata that is an ecore animator. +*/ +static int +_elua_animator(lua_State *L) // Stack usage [-8, +9, emv] +{ + Edje *ed = (Edje *)_elua_table_ptr_get(L, _elua_key); // Stack usage [-2, +2, e] + Edje_Lua_Animator *ela; + + luaL_checkany(L, 1); // Stack usage [-0, +0, v] + + // FIXME: Allow lua to set a data to be sent back with the callback. + ela = (Edje_Lua_Animator *)_elua_obj_new(L, ed, sizeof(Edje_Lua_Animator), _elua_ecore_animator_meta); + // Stack usage [-5, +6, m] + ela->obj.free_func = _elua_animator_free; + ela->animator = ecore_animator_add(_elua_animator_cb, ela); + lua_pushvalue(L, 1); // Stack usage [-0, +1, -] + ela->fn_ref = luaL_ref(L, LUA_REGISTRYINDEX); // Stack usage [-1, +0, m] + _elua_gc(L); // Stack usage [-0, +0, e] + return 1; +} + +static Eina_Bool +_elua_timer_cb(void *data) // Stack usage [-2, +2, em] +{ + Edje_Lua_Timer *elt = data; + lua_State *L; + int ret = 0, err = 0; + + if (!elt->obj.ed) return 0; + L = elt->obj.ed->L; + if (!L) return 0; + /* This is not needed, pcalls don't longjmp(), that's why they are protected. + if (setjmp(panic_jmp) == 1) + { + LE("Timer callback panic"); + _edje_lua2_error(L, err); // Stack usage [-0, +0, m] + _elua_obj_free(L, (Edje_Lua_Obj *)elt); + _elua_gc(L); // Stack usage [-0, +0, e] + return 0; + } + */ + lua_rawgeti(L, LUA_REGISTRYINDEX, elt->fn_ref); // Stack usage [-0, +1, -] + if ((err = lua_pcall(L, 0, 1, 0))) // Stack usage [-1, +1, -] + { + _edje_lua2_error(L, err); + _elua_obj_free(L, (Edje_Lua_Obj *)elt); // Stack usage [-0, +0, m] + _elua_gc(L); // Stack usage [-0, +0, e] + return 0; + } + ret = lua_toboolean(L, -1); // Stack usage [-0, +0, -] + lua_pop(L, 1); // Stack usage [-n, +0, -] + if (ret == 0) _elua_obj_free(L, (Edje_Lua_Obj *)elt); + _elua_gc(L); // Stack usage [-0, +0, e] + return ret; +} + +static void +_elua_timer_free(void *obj) // Stack usage [-0, +0, -] +{ + Edje_Lua_Timer *elt = obj; + lua_State *L; + if (!elt->obj.ed) return; + L = elt->obj.ed->L; + luaL_unref(L, LUA_REGISTRYINDEX, elt->fn_ref); // Stack usage [-0, +0, -] + elt->fn_ref = 0; + ecore_timer_del(elt->timer); + elt->timer = NULL; +} + +/** +@page luaref +@subsubsection edje_timer edje:timer(tick, func) + +This function adds a timer and returns its handle on success and NULL on failure. +The function func will be called every tick seconds. + +When the timer func is called, it must return a value of either true or false. +If it returns true, it will be called again at the next tick, or if it returns +false it will be deleted automatically making any references/handles for it +invalid. + +Wraps ecore_timer_add(). + +@param tick How often, in seconds, to call the function. +@param func The function to call when the timer triggers. + +@returns A userdata that is an ecore timer. +*/ +static int +_elua_timer(lua_State *L) // Stack usage [-8, +9, emv] +{ + Edje *ed = (Edje *)_elua_table_ptr_get(L, _elua_key); // Stack usage [-2, +2, e] + Edje_Lua_Timer *elt; + double val; + + val = luaL_checknumber(L, 1); // Stack usage [-0, +0, v] + luaL_checkany(L, 2); // Stack usage [-0, +0, v] + + elt = (Edje_Lua_Timer *)_elua_obj_new(L, ed, sizeof(Edje_Lua_Timer), _elua_ecore_timer_meta); + // Stack usage [-5, +6, m] + elt->obj.free_func = _elua_timer_free; + elt->timer = ecore_timer_add(val, _elua_timer_cb, elt); + lua_pushvalue(L, 2); // Stack usage [-0, +1, -] + elt->fn_ref = luaL_ref(L, LUA_REGISTRYINDEX); // Stack usage [-1, +0, m] + _elua_gc(L); // Stack usage [-0, +0, e] + return 1; +} + +static Eina_Bool +_elua_transition_cb(void *data) // Stack usage [-3, +3, em] +{ + Edje_Lua_Transition *elt = data; + lua_State *L; + int ret = 0, err = 0; + double t; + + if (!elt->obj.ed) return 0; + L = elt->obj.ed->L; + if (!L) return 0; + t = (ecore_loop_time_get() - elt->start) / elt->transition; + if (t > 1.0) t = 1.0; + /* This is not needed, pcalls don't longjmp(), that's why they are protected. + if (setjmp(panic_jmp) == 1) + { + LE("Transition callback panic"); + _edje_lua2_error(L, err); // Stack usage [-0, +0, m] + _elua_obj_free(L, (Edje_Lua_Obj *)elt); + _elua_gc(L); // Stack usage [-0, +0, e] + return 0; + } + */ + lua_rawgeti(L, LUA_REGISTRYINDEX, elt->fn_ref); // Stack usage [-0, +1, -] + lua_pushnumber(L, t); // Stack usage [-0, +1, -] + if ((err = lua_pcall(L, 1, 1, 0))) // Stack usage [-2, +1, -] + { + _edje_lua2_error(L, err); + _elua_obj_free(L, (Edje_Lua_Obj *)elt); // Stack usage [-0, +0, m] + _elua_gc(L); // Stack usage [-0, +0, e] + return 0; + } + ret = lua_toboolean(L, -1); // Stack usage [-0, +0, -] + lua_pop(L, 1); // Stack usage [-n, +0, -] + if (t >= 1.0) ret = 0; + if (ret == 0) _elua_obj_free(L, (Edje_Lua_Obj *)elt); + _elua_gc(L); // Stack usage [-0, +0, e] + return ret; +} + +static void +_elua_transition_free(void *obj) // Stack usage [-0, +0, -] +{ + Edje_Lua_Transition *elt = obj; + lua_State *L; + if (!elt->obj.ed) return; + L = elt->obj.ed->L; + luaL_unref(L, LUA_REGISTRYINDEX, elt->fn_ref); // Stack usage [-0, +0, -] + elt->fn_ref = 0; + ecore_animator_del(elt->animator); + elt->animator = NULL; +} + +/** +@page luaref +@subsubsection edje_transition edje:transition(div, func) + +Just like edje:animator(), except that the callback function gets called with an +argument. The argument is the amount of time since the transition was created, +divided by the div parameter. + +@param div A number to divide the time since creation by. +@param func The function to call when the transition triggers. + +@returns A userdata that is a transition (ecore animator, plus other info). +*/ +static int +_elua_transition(lua_State *L) // Stack usage [-8, +9, emv] +{ + Edje *ed = (Edje *)_elua_table_ptr_get(L, _elua_key); // Stack usage [-2, +2, e] + Edje_Lua_Transition *elt; + double val; + + val = luaL_checknumber(L, 1); // Stack usage [-0, +0, v] + luaL_checkany(L, 2); // Stack usage [-0, +0, v] + + elt = (Edje_Lua_Transition *)_elua_obj_new(L, ed, sizeof(Edje_Lua_Transition), _elua_ecore_animator_meta); + // Stack usage [-5, +6, m] + elt->obj.free_func = _elua_transition_free; + elt->animator = ecore_animator_add(_elua_transition_cb, elt); + if (val < 0.0000001) val = 0.0000001; + elt->transition = val; + elt->start = ecore_loop_time_get(); + lua_pushvalue(L, 2); // Stack usage [-0, +1, -] + elt->fn_ref = luaL_ref(L, LUA_REGISTRYINDEX); // Stack usage [-1, +0, m] + _elua_gc(L); // Stack usage [-0, +0, e] + return 1; +} + +//------------- +/** +@page luaref +@subsubsection edje_colour_class edje:color_class(class, r, g, b, a) + +Gets, (and optionally sets) the colours for a color class. + +Wraps edje_object_color_class_set(). + +@param class A color class name. +@param r The new red value. +@param g The new green value. +@param b The new blue value. +@param a The new alpha value. + +Note that the r, g, b, and a arguments are optional, without them this function +just queries the current values. The r, g, b, and a arguments can be separate +values, or named fields in a table. + +@return A table with these fields: + - integer r: The red value. + - integer g: The green value. + - integer b: The blue value. + - integer a: The alpha value. + +@since 1.1.0 +*/ +static int +_elua_color_class(lua_State *L) // Stack usage [-(10|14), +(11|15), ?] +{ + Edje *ed = (Edje *)_elua_table_ptr_get(L, _elua_key); // Stack usage [-2, +2, e] + Edje_Color_Class *c_class; + const char *class = luaL_checkstring(L, 1); // Stack usage [-0, +0, v] + int r, g, b, a; + + if (!class) return 0; + + if (_elua_scan_params(L, 2, "%r %g %b %a", &r, &g, &b, &a) > 0) + { // Stack usage [-0, +0, m] unless it's in a table [-4, +4, e] + _elua_color_fix(&r, &g, &b, &a); + // This is the way that embryo does it - + //edje_object_color_class_set(ed->obj, class, r, g, b, a, r, g, b, a, r, g, b, a); + // But that deals with object scope, which is currently useless in lua, + // since we have no objects that can use color_class yet. + // So we do it at global scope instead. + // LATER - Should do both? + edje_color_class_set(class, r, g, b, a, r, g, b, a, r, g, b, a); + } + + c_class = _edje_color_class_find(ed, class); + if (!c_class) return 0; + + _elua_ret(L, "%r %g %b %a", c_class->r, c_class->g, c_class->b, c_class->a); + // Stack usage [-8, +9, em] + return 1; +} + +/** +@page luaref +@subsubsection edje_text_class edje:text_class(class, font, size) + +Gets, (and optionally sets) the details for a text class. + +Wraps edje_object_text_class_set(). + +@param class A text class name. +@param font The new font name. +@param size The new font size. + +Note that the font and size arguments are optional, without them this function +just queries the current values. The font and size arguments can be separate +values, or named fields in a table. The font name can refer to a font in the +edje file, or an external font. + +@return A table with these fields: + - string font: The font name. + - integer size: The font size. + +@since 1.1.0 +*/ +static int +_elua_text_class(lua_State *L) // Stack usage [-(6|8), +(7|9), emv] +{ + Edje *ed = (Edje *)_elua_table_ptr_get(L, _elua_key); // Stack usage [-2, +2, e] + Edje_Text_Class *t_class; + const char *class = luaL_checkstring(L, 1); // Stack usage [-0, +0, v] + char *font = NULL; + Evas_Font_Size size = 0; + + if (!class) return 0; + + // Just like color_class above, this does things differently from embryo, + // for the same reason. + if (_elua_scan_params(L, 2, "$font %size", &font, &size) > 0) + // Stack usage [-0, +0, m] unless it's in a table [-2, +2, e] + edje_text_class_set(class, font, size); + + t_class = _edje_text_class_find(ed, class); + if (!t_class) return 0; + + _elua_ret(L, "$font %size", t_class->font, t_class->size); + // Stack usage [-4, +5, em] + return 1; +} + +//------------- +static void +_elua_evas_obj_free(void *obj) +{ + Edje_Lua_Evas_Object *elo = obj; + + if (!elo->obj.ed) return; + evas_object_del(elo->evas_obj); + elo->evas_obj = NULL; +} + +// Stack usage [-7, +8, em] +#define _ELUA_PLANT_EVAS_OBJECT(type, meta, free) \ + Edje *ed = (Edje *)_elua_table_ptr_get(L, _elua_key); \ + type *elo; \ + elo = (type *)_elua_obj_new(L, ed, sizeof(type), meta); \ + elo->obj.free_func = free; +// Stack usage [-2, +2, e] +// Stack usage [-5, +6, m] + +static void +_elua_polish_evas_object(Edje *ed, Edje_Lua_Evas_Object *elo) +{ + evas_object_smart_member_add(elo->evas_obj, ed->obj); + evas_object_clip_set(elo->evas_obj, ed->base.clipper); + evas_object_move(elo->evas_obj, ed->x, ed->y); + evas_object_resize(elo->evas_obj, 0, 0); + evas_object_data_set(elo->evas_obj, ELO, elo); +} + +/** +@page luaref +@subsubsection edje_edje edje:edje() + +Create an edje object, and add it to the edje. + +Wraps edje_object_add(). + +@returns A userdata that is an edje object. + +@since 1.1.0 +*/ +static int +_elua_edje(lua_State *L) // Stack usage [-7, +8, em] +{ + _ELUA_PLANT_EVAS_OBJECT(Edje_Lua_Evas_Object, _elua_evas_edje_meta, _elua_evas_obj_free) + // Stack usage [-7, +8, em] + elo->evas_obj = edje_object_add(evas_object_evas_get(ed->obj)); + _edje_subobj_register(ed, elo->evas_obj); + _elua_polish_evas_object(ed, elo); + return 1; +} + +/** +@page luaref +@subsubsection edje_image edje:image() + +Create an evas image, and add it to the edje. + +Wraps evas_object_image_add(). + +@returns A userdata that is an evas image. + +@since 1.1.0 +*/ +static int +_elua_image(lua_State *L) // Stack usage [-7, +8, em] +{ + _ELUA_PLANT_EVAS_OBJECT(Edje_Lua_Evas_Object, _elua_evas_image_meta, _elua_evas_obj_free) + // Stack usage [-7, +8, em] + elo->evas_obj = evas_object_image_filled_add(evas_object_evas_get(ed->obj)); + _elua_polish_evas_object(ed, elo); + return 1; +} + +/** +@page luaref +@subsubsection edje_line edje:line() + +Create an evas line, and add it to the edje. + +Wraps evas_object_line_add(). + +@returns A userdata that is an evas line. + +@since 1.1.0 +*/ +static int +_elua_line(lua_State *L) // Stack usage [-7, +8, em] +{ + _ELUA_PLANT_EVAS_OBJECT(Edje_Lua_Evas_Object, _elua_evas_line_meta, _elua_evas_obj_free) + // Stack usage [-7, +8, em] + elo->evas_obj = evas_object_line_add(evas_object_evas_get(ed->obj)); + _elua_polish_evas_object(ed, elo); + return 1; +} + +static void +_elua_map_free(void *obj) +{ + Edje_Lua_Map *elm = obj; + if (!elm->obj.ed) return; + evas_map_free(elm->map); + elm->map = NULL; +} + +/** +@page luaref +@subsubsection edje_map edje:map() + +Create an evas map. + +Wraps evas_map_new(). + +@returns A userdata that is an evas map. + +@since 1.1.0 +*/ +static int +_elua_map(lua_State *L) // Stack usage [-7, +8, emv] +{ + _ELUA_PLANT_EVAS_OBJECT(Edje_Lua_Map, _elua_evas_map_meta, _elua_map_free) + // Stack usage [-7, +8, em] + elo->map = evas_map_new(luaL_checkinteger(L, 1)); // Stack usage [-0, +0, v] + return 1; +} + +/** +@page luaref +@subsubsection edje_polygon edje:polygon() + +Create an evas polygon, and add it to the edje. + +Wraps evas_object_polygon_add(). + +@returns A userdata that is an evas polygon. + +@since 1.1.0 +*/ +static int +_elua_polygon(lua_State *L) // Stack usage [-7, +8, em] +{ + _ELUA_PLANT_EVAS_OBJECT(Edje_Lua_Evas_Object, _elua_evas_polygon_meta, _elua_evas_obj_free) + // Stack usage [-7, +8, em] + elo->evas_obj = evas_object_polygon_add(evas_object_evas_get(ed->obj)); + _elua_polish_evas_object(ed, elo); + return 1; +} + +/** +@page luaref +@subsubsection edje_rect edje:rect() + +Create an evas rectangle, and add it to the edje. + +Wraps evas_object_rectangle_add(). + +@returns A userdata that is an evas rectangle. +*/ +static int +_elua_rect(lua_State *L) // Stack usage [-7, +8, em] +{ + _ELUA_PLANT_EVAS_OBJECT(Edje_Lua_Evas_Object, _elua_evas_meta, _elua_evas_obj_free) + // Stack usage [-7, +8, em] + elo->evas_obj = evas_object_rectangle_add(evas_object_evas_get(ed->obj)); + _elua_polish_evas_object(ed, elo); + return 1; +} + +/** +@page luaref +@subsubsection edje_text edje:text() + +Create an evas text object, and add it to the edje. + +Wraps evas_object_text_add(). + +@returns A userdata that is an evas text object. + +@since 1.1.0 +*/ +static int +_elua_text(lua_State *L) // Stack usage [-7, +8, em] +{ + _ELUA_PLANT_EVAS_OBJECT(Edje_Lua_Evas_Object, _elua_evas_text_meta, _elua_evas_obj_free) + // Stack usage [-7, +8, em] + elo->evas_obj = evas_object_text_add(evas_object_evas_get(ed->obj)); + _elua_polish_evas_object(ed, elo); + return 1; +} + +/* XXX: disabled until there are enough textblock functions implemented to make it actually useful +_elua_textblock(lua_State *L) // Stack usage [-7, +8, em] +{ + _ELUA_PLANT_EVAS_OBJECT(Edje_Lua_Evas_Object, _elua_evas_textblock_meta, _elua_evas_obj_free) + // Stack usage [-7, +8, em] + elo->evas_obj = evas_object_textblock_add(evas_object_evas_get(ed->obj)); + _elua_polish_evas_object(ed, elo); + return 1; +} +*/ + +//------------- +//------------- + +/** +@page luaref +@subsection evas Evas class. + +The lua evas class includes functions for dealing with evas objects. The evas +objects must have been previously created by lua using one of the lua ezas +object creation functions from the lua edje class. + +In the following, "evas_object" is a place holder for any lua variable that +holds a reference to an evas object. +*/ + +static int _elua_obj_del(lua_State *L); + +static int _elua_hide(lua_State *L); +static int _elua_show(lua_State *L); +static int _elua_visible(lua_State *L); + +static int _elua_above(lua_State *L); +static int _elua_below(lua_State *L); +static int _elua_bottom(lua_State *L); +static int _elua_lower(lua_State *L); +static int _elua_raise(lua_State *L); +static int _elua_top(lua_State *L); + +static int _elua_geom(lua_State *L); +static int _elua_move(lua_State *L); +static int _elua_pos(lua_State *L); +static int _elua_resize(lua_State *L); +static int _elua_size(lua_State *L); + +static int _elua_clip(lua_State *L); +static int _elua_clipees(lua_State *L); +static int _elua_unclip(lua_State *L); + +static int _elua_type(lua_State *L); + +static int _elua_pass(lua_State *L); +static int _elua_precise(lua_State *L); +static int _elua_repeat(lua_State *L); + +static int _elua_color(lua_State *L); + +static int _elua_obj_map(lua_State *L); +static int _elua_obj_map_enable(lua_State *L); +static int _elua_obj_map_source(lua_State *L); + +static const char *_elua_evas_api = "evas"; +static const struct luaL_reg _elua_evas_funcs [] = +{ + {"del", _elua_obj_del}, // generic del any object created for edje (evas objects, timers, animators, transitions... everything) + + {"hide", _elua_hide}, // hide, return current visibility + {"show", _elua_show}, // show, return current visibility + {"visible", _elua_visible}, // get object visibility + + {"above", _elua_above}, // get object above or stack obj above given obj + {"below", _elua_below}, // get object below or stack obj below given obj + {"bottom", _elua_bottom}, // get bottom + {"lower", _elua_lower}, // lower to bottom + {"raise", _elua_raise}, // raise to top + {"top", _elua_top}, // get top + + {"geom", _elua_geom}, // move and resize and return current geometry + {"move", _elua_move}, // move, return current position + {"pos", _elua_pos}, // move, return current position + {"resize", _elua_resize}, // resize, return current size + {"size", _elua_size}, // resize, return current size + + {"clip", _elua_clip}, // set clip obj, return clip object + {"clipees", _elua_clipees}, // get clip children + {"unclip", _elua_unclip}, // clear clip obj + + {"type", _elua_type}, // get object type + + {"pass", _elua_pass}, // set pass events, get pass events + {"precise", _elua_precise}, // set precise inside flag, get precise + {"repeat", _elua_repeat}, // set repeat events, get repeat events + + {"color", _elua_color}, // set color, return color +// {"color_class", _elua_object_color_class}, // get or set object color class + + // FIXME: set callbacks (mouse down, up, blah blah blah) + // + // FIXME: set scale (explicit value) + // FIXME: need to set auto-scale (same as scale: 1) + + // FIXME: later - set render op, anti-alias, pointer mode (autograb, nograb) + + // map api here + {"map", _elua_obj_map}, + {"map_enable", _elua_obj_map_enable}, + {"map_source", _elua_obj_map_source}, + + {NULL, NULL} // end +}; + +//------------- +/** +@page luaref +@subsubsection evas_hide evas_object:hide() + +Hides the object. + +Wraps evas_object_hide(). + +@returns A boolean representing the current visibility. +*/ +static int +_elua_hide(lua_State *L) // Stack usage [-0, +1, -] +{ + Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -] + Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj; + if (!_elua_isa(obj, _elua_evas_meta)) return 0; + evas_object_hide(elo->evas_obj); + lua_pushboolean(L, evas_object_visible_get(elo->evas_obj)); // Stack usage [-0, +1, -] + return 1; +} + +/** +@page luaref +@subsubsection evas_show evas_object:show() + +Shows the object. + +Wraps evas_object_show(). + +@returns A boolean representing the current visibility. +*/ +static int +_elua_show(lua_State *L) // Stack usage [-0, +1, -] +{ + Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -] + Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj; + if (!_elua_isa(obj, _elua_evas_meta)) return 0; + evas_object_show(elo->evas_obj); + lua_pushboolean(L, evas_object_visible_get(elo->evas_obj)); // Stack usage [-0, +1, -] + return 1; +} + +/** +@page luaref +@subsubsection evas_visible evas_object:visible(visibility) + +Gets (and optionally sets) this objects visibility. + +Wraps evas_object_hide() or evas_object_show(). + +@param visibility The new visibility you want to change it to. + +Note that the argument is optional, without it this function just queries the +current value. + +@returns A boolean representing the current visibility. +*/ +static int +_elua_visible(lua_State *L) // Stack usage [-0, +1, -] +{ + Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -] + Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj; + int n; + if (!_elua_isa(obj, _elua_evas_meta)) return 0; + n = lua_gettop(L); // Stack usage [-0, +0, -] + if (n == 2) + { + if (lua_isboolean(L, 2)) // Stack usage [-0, +0, -] + { + if (lua_toboolean(L, 2)) evas_object_show(elo->evas_obj); + // Stack usage [-0, +0, -] + else evas_object_hide(elo->evas_obj); + } + } + lua_pushboolean(L, evas_object_visible_get(elo->evas_obj)); // Stack usage [-0, +1, -] + return 1; +} + +//------------- +/** +@page luaref +@subsubsection evas_above evas_object:above() + +Figure out what, if anything, is above us. + +Wraps evas_object_above_get(). + +Note that it may not return any value. + +@returns A reference to the object above this one. +*/ +static int +_elua_above(lua_State *L) // Stack usage [-3, +4, -] +{ + Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -] + Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj; + Edje_Lua_Evas_Object *elo2; + Evas_Object *o; + if (!_elua_isa(obj, _elua_evas_meta)) return 0; + if (!(o = evas_object_above_get(elo->evas_obj))) return 0; + if (!(elo2 = evas_object_data_get(o, ELO))) return 0; + _elua_ref_get(L, elo2); // Stack usage [-3, +4, -] + return 1; +} + +/** +@page luaref +@subsubsection evas_below evas_object:below() + +Figure out what, if anything, is below us. + +Wraps evas_object_below_get(). + +Note that it may not return any value. + +@returns A reference to the object below this one. +*/ +static int +_elua_below(lua_State *L) // Stack usage [-3, +4, -] +{ + Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -] + Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj; + Edje_Lua_Evas_Object *elo2; + Evas_Object *o; + if (!_elua_isa(obj, _elua_evas_meta)) return 0; + if (!(o = evas_object_below_get(elo->evas_obj))) return 0; + if (!(elo2 = evas_object_data_get(o, ELO))) return 0; + _elua_ref_get(L, elo2); // Stack usage [-3, +4, -] + return 1; +} + +/** +@page luaref +@subsubsection evas_bottom evas_object:bottom() + +Figure out what, if anything, is waaaay below us. + +Note that it may not return any value. + +@returns A reference to the object at the bottom. +*/ +static int +_elua_bottom(lua_State *L) // Stack usage [-(0|3), +(0|4), -] +{ + Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -] + Edje_Lua_Evas_Object *elo2; + Evas_Object *o; + Eina_List *list, *l; + if (!_elua_isa(obj, _elua_evas_meta)) return 0; + if (!(list = (Eina_List *)evas_object_smart_members_get(obj->ed->obj))) return 0; + for (l = list; l; l = l->next) + { + o = l->data; + if ((elo2 = evas_object_data_get(o, ELO))) + { + _elua_ref_get(L, elo2); // Stack usage [-3, +4, -] + return 1; + } + } + return 0; +} + +/** +@page luaref +@subsubsection evas_lower evas_object:lower() + +Lower this object to the bottom. + +Wraps evas_object_lower(). +*/ +static int +_elua_lower(lua_State *L) // Stack usage [-0, +0, -] +{ + Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -] + Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj; + if (!_elua_isa(obj, _elua_evas_meta)) return 0; + evas_object_lower(elo->evas_obj); + return 0; +} + +/** +@page luaref +@subsubsection evas_raise evas_object:raise() + +Raise this object to the top. + +Wraps evas_object_raise(). +*/ +static int +_elua_raise(lua_State *L) // Stack usage [-0, +0, -] +{ + Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -] + Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj; + if (!_elua_isa(obj, _elua_evas_meta)) return 0; + evas_object_raise(elo->evas_obj); + return 0; +} + +/** +@page luaref +@subsubsection evas_top evas_object:top() + +Figure out what, if anything, is waaaay above us. + +Note that it may not return any value. + +@returns A reference to the object at the top. +*/ +static int +_elua_top(lua_State *L) // Stack usage [-(0|3), +(0|4), -] +{ + Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-(0, +0, -] + Edje_Lua_Evas_Object *elo2; + Evas_Object *o; + Eina_List *list, *l; + if (!_elua_isa(obj, _elua_evas_meta)) return 0; + if (!(list = (Eina_List *)evas_object_smart_members_get(obj->ed->obj))) return 0; + if (!list) return 0; + for (l = eina_list_last(list); l; l = l->prev) + { + o = l->data; + if ((elo2 = evas_object_data_get(o, ELO))) + { + _elua_ref_get(L, elo2); // Stack usage [-3, +4, -] + return 1; + } + } + return 0; +} + +//------------- +/** +@page luaref +@subsubsection evas_geom evas_object:geom(x, y, w, h) + +Gets (and optionally sets) this objects geometry. + +Wraps evas_object_move() and evas_object_resize. + +@param x The new X coordinate. +@param y The new Y coordinate. +@param w The new width. +@param h The new height. + +Note that the arguments are optional, without them this function just queries +the current values. The arguments can be separate values, or named fields in a +table. + +@return A table with these fields: + - integer x: X coordinate. + - integer x: Y coordinate. + - integer w: Width. + - integer w: Height. +*/ +static int +_elua_geom(lua_State *L) // Stack usage [-(8|12), +(9|13), em] +{ + Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -] + Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj; + Evas_Coord ox, oy, ow, oh; + int x, y, w, h; + + if (!_elua_isa(obj, _elua_evas_meta)) return 0; + evas_object_geometry_get(elo->evas_obj, &ox, &oy, &ow, &oh); + if (_elua_scan_params(L, 2, "%x %y %w %h", &x, &y, &w, &h) > 0) + { // Stack usage [-0, +0, m] unless it's in a table [-4, +4, e] + if ((x != (ox - obj->ed->x)) || (y != (oy - obj->ed->y))) + { + evas_object_move(elo->evas_obj, + obj->ed->x + x, + obj->ed->y + y); + } + if ((w != ow) || (h != oh)) + { + evas_object_resize(elo->evas_obj, w, h); + } + evas_object_geometry_get(elo->evas_obj, &ox, &oy, &ow, &oh); + elo->x = ox - obj->ed->x; + elo->y = oy - obj->ed->y; + } + _elua_ret(L, "%x %y %w %h", elo->x, elo->y, ow, oh); + // Stack usage [-8, +9, em] + return 1; +} + +/** +@page luaref +@subsubsection evas_move evas_object:move(x, y) + +Gets (and optionally sets) this objects position. + +Wraps evas_object_move(). + +@param x The new X coordinate. +@param y The new Y coordinate. + +Note that the arguments are optional, without them this function just queries +the current values. The arguments can be separate values, or named fields in a +table. + +@return A table with these fields: + - integer x: X coordinate. + - integer x: Y coordinate. +*/ +static int +_elua_move(lua_State *L) // Stack usage [-(4|6), +(5|7), em] +{ + Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -] + Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj; + Evas_Coord ox, oy; + int x, y; + + if (!_elua_isa(obj, _elua_evas_meta)) return 0; + evas_object_geometry_get(elo->evas_obj, &ox, &oy, NULL, NULL); + if (_elua_scan_params(L, 2, "%x %y", &x, &y) > 0) + { // Stack usage [-0, +0, m] unless it's in a table [-2, +2, e] + if ((x != (ox - obj->ed->x)) || (y != (oy - obj->ed->y))) + { + evas_object_move(elo->evas_obj, + obj->ed->x + x, + obj->ed->y + y); + evas_object_geometry_get(elo->evas_obj, &ox, &oy, NULL, NULL); + } + elo->x = ox - obj->ed->x; + elo->y = oy - obj->ed->y; + } + _elua_ret(L, "%x %y", elo->x, elo->y); + // Stack usage [-4, +5, em] + return 1; +} + +/** +@page luaref +@subsubsection evas_pos evas_object:pos(x, y) + +An alias for evas_object:move(). +*/ +static int +_elua_pos(lua_State *L) // Stack usage [-(4|6), +(5|7), em] +{ + return _elua_move(L); +} + +/** +@page luaref +@subsubsection evas_resize evas_object:resize(w, h) + +Gets (and optionally sets) this objects size. + +Wraps evas_object_resize(). + +@param w The new width. +@param h The new height. + +Note that the arguments are optional, without them this function just queries +the current values. The arguments can be separate values, or named fields in a +table. + +@return A table with these fields: + - integer w: Width. + - integer w: Height. +*/ +static int +_elua_resize(lua_State *L) // Stack usage [-(4|6), +(5|7), em] +{ + Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -] + Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj; + Evas_Coord ow, oh; + int w, h; + + if (!_elua_isa(obj, _elua_evas_meta)) return 0; + evas_object_geometry_get(elo->evas_obj, NULL, NULL, &ow, &oh); + if (_elua_scan_params(L, 2, "%w %h", &w, &h) > 0) + { // Stack usage [-0, +0, m] unless it's in a table [-2, +2, e] + if ((w != ow) || (h != oh)) + { + evas_object_resize(elo->evas_obj, w, h); + evas_object_geometry_get(elo->evas_obj, NULL, NULL, &ow, &oh); + } + } + _elua_ret(L, "%w %h", ow, oh); + // Stack usage [-4, +5, em] + return 1; +} + +/** +@page luaref +@subsubsection evas_size evas_object:size() + +An alias for evas_object:resize(). +*/ +static int +_elua_size(lua_State *L) // Stack usage [-(4|6), +(5|7), em] +{ + return _elua_resize(L); +} + +//------------- +/** +@page luaref +@subsubsection evas_clip evas_object:clip(evas_object2) + +Get (and optionally set) the object that clips this object. + +Note that the argument is optional, without it this function just queries the +current value. + +Wraps evas_object_clip_set(). + +@param evas_object2 A reference to the object to clip this object with. + +@returns A reference to the object clipping this object, if any. +*/ +static int +_elua_clip(lua_State *L) // Stack usage [-3, +4, -] +{ + Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -] + Edje_Lua_Evas_Object *elo2, *elo = (Edje_Lua_Evas_Object *)obj; + Evas_Object *o; + int n; + if (!_elua_isa(obj, _elua_evas_meta)) return 0; + n = lua_gettop(L); // Stack usage [-0, +0, -] + if (n == 2) + { + Edje_Lua_Obj *obj2 = (Edje_Lua_Obj *)lua_touserdata(L, 2); // Stack usage [-0, +0, -] + elo2 = (Edje_Lua_Evas_Object *)obj2; + if (!_elua_isa(obj2, _elua_evas_meta)) return 0; + evas_object_clip_set(elo->evas_obj, elo2->evas_obj); + } + o = evas_object_clip_get(elo->evas_obj); + if (!o) return 0; + if (!(elo2 = evas_object_data_get(o, ELO))) return 0; + _elua_ref_get(L, elo2); // Stack usage [-3, +4, -] + return 1; +} + +/** +@page luaref +@subsubsection evas_clipees evas_object:clipees() + +Gets the list of objects this objects clips. + +Wraps evas_object_clipees_get(). + +@return A table, that holds all the objects this clips, if any, + otherwise an empty table. +*/ +static int +_elua_clipees(lua_State *L) // Stack usage [-0, +1, me] plus [-5, +5] for each clipee. +{ + Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -] + Edje_Lua_Evas_Object *elo2, *elo = (Edje_Lua_Evas_Object *)obj; + Eina_List *list, *l; + Evas_Object *o; + int n = 0; + if (!_elua_isa(obj, _elua_evas_meta)) return 0; + list = (Eina_List *)evas_object_clipees_get(elo->evas_obj); + lua_newtable(L); // Stack usage [-0, +1, m] + EINA_LIST_FOREACH(list, l, o) + { + if (!(elo2 = evas_object_data_get(o, ELO))) continue; + lua_pushinteger(L, n + 1); // Stack usage [-0, +1, -] + _elua_ref_get(L, elo2); // Stack usage [-3, +4, -] + lua_settable(L, -3); // Stack usage [-2, +0, e] + n++; + } + return 1; +} + +/** +@page luaref +@subsubsection evas_unclip evas_object:unclip() + +Remove any clipping on this object. + +Wraps evas_object_clip_unset(). +*/ +static int +_elua_unclip(lua_State *L) // Stack usage [-0, +0, -] +{ + Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -] + Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj; + if (!_elua_isa(obj, _elua_evas_meta)) return 0; + evas_object_clip_unset(elo->evas_obj); + return 0; +} + +//------------- +/** +@page luaref +@subsubsection evas_type evas_object:type() + +Get the type of this object. See the documentation of the evas_object_type_get() +C function for details. + +Wraps evas_object_type_get(). + +@return A string with this objects type in it. +*/ +static int +_elua_type(lua_State *L) // Stack usage [-0, +1, m] +{ + Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -] + Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj; + const char *t; + if (!_elua_isa(obj, _elua_evas_meta)) return 0; + t = evas_object_type_get(elo->evas_obj); + if (!t) return 0; + lua_pushstring(L, t); // Stack usage [-0, +1, m] + return 1; +} + +//------------- +/** +@page luaref +@subsubsection evas_pass evas_object:pass(pass) + +Get (and optionally set) whether this object ignores events, passing them to the +next object underneath it. + +Wraps evas_object_pass_events_set(). + +@param pass A boolean saying if this object passes events. + +Note that the argument is optional, without it this function just queries the +current value. + +@return A boolean saying if this object passes events. +*/ +static int +_elua_pass(lua_State *L) // Stack usage [-0, +1, -] +{ + Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -] + Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj; + int n; + if (!_elua_isa(obj, _elua_evas_meta)) return 0; + n = lua_gettop(L); // Stack usage [-0, +0, -] + if (n == 2) + { + if (lua_isboolean(L, 2)) // Stack usage [-0, +0, -] + { + evas_object_pass_events_set(elo->evas_obj, lua_toboolean(L, 2)); + // Stack usage [-0, +0, -] + } + } + lua_pushboolean(L, evas_object_pass_events_get(elo->evas_obj)); + // Stack usage [-0, +1, -] + return 1; +} + +/** +@page luaref +@subsubsection evas_precise evas_object:precise(precise) + +Get (and optionally set) whether to use precise (usually expensive) point +collision detection for this object. + +Wraps evas_object_precise_is_inside_set(). + +@param precise A boolean saying if this object is precisely detected. + +Note that the argument is optional, without it this function just queries the +current value. + +@return A boolean saying if this object is precisely detected. +*/ +static int +_elua_precise(lua_State *L) // Stack usage [-0, +1, -] +{ + Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -] + Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj; + int n; + if (!_elua_isa(obj, _elua_evas_meta)) return 0; + n = lua_gettop(L); // Stack usage [-0, +0, -] + if (n == 2) + { + if (lua_isboolean(L, 2)) // Stack usage [-0, +0, -] + { + evas_object_precise_is_inside_set(elo->evas_obj, lua_toboolean(L, 2)); + // Stack usage [-0, +0, -] + } + } + lua_pushboolean(L, evas_object_precise_is_inside_get(elo->evas_obj)); + // Stack usage [-0, +1, -] + return 1; +} + +/** +@page luaref +@subsubsection evas_repeat evas_object:repeat(repeat) + +Get (and optionally set) whether this object repeats events. + +Wraps evas_object_repeat_events_set(). + +@param repeat A boolean saying if this object repeats events to lower objects. + +Note that the argument is optional, without it this function just queries the +current value. + +@return A boolean saying if this object repeats events. +*/ +static int +_elua_repeat(lua_State *L) // Stack usage [-0, +1, -] +{ + Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -] + Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj; + int n; + if (!_elua_isa(obj, _elua_evas_meta)) return 0; + n = lua_gettop(L); // Stack usage [-0, +0, -] + if (n == 2) + { + if (lua_isboolean(L, 2)) // Stack usage [-0, +0, -] + { + evas_object_repeat_events_set(elo->evas_obj, lua_toboolean(L, 2)); + // Stack usage [-0, +0, -] + } + } + lua_pushboolean(L, evas_object_repeat_events_get(elo->evas_obj)); + // Stack usage [-0, +1, -] + return 1; +} + +//------------- +/** +@page luaref +@subsubsection evas_colour evas_object:color(r, g, b, a) + +Gets (and optionally sets) this objects colour. + +Wraps evas_object_color_set(). + +@param r The new red value. +@param g The new green value. +@param b The new blue value. +@param a The new alpha value. + +Note that the arguments are optional, without them this function just queries +the current values. The arguments can be separate values, or named fields in a +table. + +@return A table with these fields: + - integer r: The red value. + - integer g: The green value. + - integer b: The blue value. + - integer a: The alpha value. +*/ +static int +_elua_color(lua_State *L) // Stack usage [-(8|12), +(9|13), em] +{ + Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -] + Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj; + int r, g, b, a; + + if (!_elua_isa(obj, _elua_evas_meta)) return 0; + if (_elua_scan_params(L, 2, "%r %g %b %a", &r, &g, &b, &a) > 0) + { // Stack usage [-0, +0, m] unless it's in a table [-4, +4, e] + _elua_color_fix(&r, &g, &b, &a); + evas_object_color_set(elo->evas_obj, r, g, b, a); + } + evas_object_color_get(elo->evas_obj, &r, &g, &b, &a); + _elua_ret(L, "%r %g %b %a", r, g, b, a); + // Stack usage [-8, +9, em] + return 1; +} + +//------------- +/** +@page luaref +@subsubsection evas_map evas_object:map(map) + +Attach a map to this object. + +Wraps evas_object_map_set(). + +@param map The map to attach. + +@since 1.1.0 +*/ +static int +_elua_obj_map(lua_State *L) // Stack usage [-0, +0, -] +{ + Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -] + Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj; + Edje_Lua_Obj *obj2 = (Edje_Lua_Obj *)lua_touserdata(L, 2); // Stack usage [-0, +0, -] + Edje_Lua_Map *elm = (Edje_Lua_Map *)obj2; + if (!_elua_isa(obj, _elua_evas_meta)) return 0; + if (!_elua_isa(obj2, _elua_evas_map_meta)) return 0; + + evas_object_map_set(elo->evas_obj, elm->map); + + return 0; +} + +/** +@page luaref +@subsubsection evas_map_enable evas_object:map_enable(enable) + +Enable or disable the map attached to this object. + +Wraps evas_object_map_enable_set(). + +@param enable A booleon that controls if the attached map is enabled or not. + +@return A boolean reflecting the map enabled status of this object. + +@since 1.1.0 +*/ +static int +_elua_obj_map_enable(lua_State *L) // Stack usage [-0, +1, -] +{ + Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -] + Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj; + int n; + if (!_elua_isa(obj, _elua_evas_meta)) return 0; + + n = lua_gettop(L); // Stack usage [-0, +0, -] + if (n == 2) + { + evas_object_map_enable_set(elo->evas_obj, lua_toboolean(L, 2)); + // Stack usage [-0, +0, -] + } + lua_pushboolean(L, evas_object_map_enable_get(elo->evas_obj)); + // Stack usage [-0, +1, -] + return 1; +} + +/** +@page luaref +@subsubsection evas_map_source evas_object:map_source(object) + +Sets the object as the map source for this object. + +Wraps evas_object_map_source_set(). + +@param object The map source object. + +@return A userdata reference to the current map source object. + +@since 1.1.0 +*/ +static int +_elua_obj_map_source(lua_State *L) // Stack usage [-3, +4, -] +{ + Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -] + Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj; + Evas_Object *o; + Edje_Lua_Evas_Object *elo2; + int n; + + if (!_elua_isa(obj, _elua_evas_meta)) return 0; + + n = lua_gettop(L); // Stack usage [-0, +0, -] + if (n == 2) + { + Edje_Lua_Obj *obj2 = (Edje_Lua_Obj *)lua_touserdata(L, 2); // Stack usage [-0, +0, -] + const Edje_Lua_Evas_Object *source = (Edje_Lua_Evas_Object *)obj2; + + if (!_elua_isa(obj2, _elua_evas_meta)) return 0; + evas_object_map_source_set(elo->evas_obj, source->evas_obj); + } + + if (!(o = evas_object_map_source_get(elo->evas_obj))) return 0; + if (!(elo2 = evas_object_data_get(o, ELO))) return 0; + _elua_ref_get(L, elo2); // Stack usage [-3, +4, -] + + return 1; +} + +//------------- +//------------- +/** +@page luaref +@subsection ecore_animator Ecore animator class. + +The lua ecore animator class includes functions for dealing with ecore animator objects. +The ecore animator objects must have been previously created by lua using the lua +edje object creation function edje:animator() or edje:transition(). + +In the following, "animator_object" is a place holder for any lua variable that +holds a reference to an ecore animator object. +*/ +static const char *_elua_ecore_animator_api = "ecore_animator"; +static const struct luaL_reg _elua_ecore_animator_funcs [] = +{ + {NULL, NULL} // end +}; + +//------------- +//------------- +/** +@page luaref +@subsection ecore_timer Ecore timer class. + +The lua ecore timer class includes functions for dealing with ecore timer objects. +The ecore timer objects must have been previously created by lua using the lua +edje object creation function edje:timer(). + +In the following, "timer_object" is a place holder for any lua variable that +holds a reference to an ecore timer object. +*/ + +static const char *_elua_ecore_timer_api = "ecore_timer"; +static const struct luaL_reg _elua_ecore_timer_funcs [] = +{ + {NULL, NULL} // end +}; + +//------------- +//------------- +/** +@page luaref +@subsection evas_edje Evas edje class. + +The lua evas edje class includes functions for dealing with evas edje objects. +The evas edje objects must have been previously created by lua using the lua +edje object creation function edje:edje(). + +In the following, "edje_object" is a place holder for any lua variable that +holds a reference to an evas edje object. NOT the edje class specified earlier +though. + +@since 1.1.0 +*/ + +static int _elua_edje_file(lua_State *L); + +static const char *_elua_evas_edje_api = "evas_edje"; +static const char *_elua_evas_edje_parent = "evas_edje_parent"; +static const struct luaL_reg _elua_evas_edje_funcs [] = +{ + {"file", _elua_edje_file}, // get or set edje file and group + + {NULL, NULL} // end +}; + +/** +@page luaref +@subsubsection edje_file edje_object:file(file, group) + +Load an edje group into this edje object. + +Wraps edje_object_file_set(). + +@param file An edje file name (ignored, sandboxed to the file this lua script is in). +@param group The group within the edje file to be loaded. + +Note that the arguments are optional, without them this function just queries +the current values. The arguments can be separate values, or named fields in a +table. The file argument is optional, and ignored anyway. + +@return A table with these fields: + - string file: The name of the edje file this edje's group is loaded from. + - string group: The name of the group this edje is loaded from. + +@since 1.1.0 +*/ +static int +_elua_edje_file(lua_State *L) // Stack usage [-(4|6), +(5|7), em] +{ + Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -] + Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj; + const char *file = NULL, *group = NULL; + int n = lua_gettop(L); // Stack usage [-0, +0, -] + + if (!_elua_isa(obj, _elua_evas_edje_meta)) return 0; + + n = _elua_scan_params(L, 2, "$file $group", &file, &group); + // Stack usage [-0, +0, m] unless it's in a table [-2, +2, e] + if (0 >= n) + { + file = (char *) obj->ed->file->path; + group = (char *) lua_tostring(L, 2); // Stack usage [-0, +0, m] + n = 2; + } + + if (1 < n) + { + // Sandbox lua - Only allow access to groups within the same file. + // By the simple expedient of completely ignoring what file was requested. + file = (char *) obj->ed->file->path; + if (!edje_object_file_set(elo->evas_obj, file, group)) + { + Edje_Load_Error err = edje_object_load_error_get(elo->evas_obj); + + switch (err) + { + 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; + case EDJE_LOAD_ERROR_GENERIC : LE("Edje file loading errer %s %s - generic error.\n", obj->ed->file->path, group); break; + 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; + 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; + case EDJE_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED : LE("Edje file loading errer %s %s - resource allocation failed.\n", obj->ed->file->path, group); break; + case EDJE_LOAD_ERROR_CORRUPT_FILE : LE("Edje file loading errer %s %s - corrupt file.\n", obj->ed->file->path, group); break; + case EDJE_LOAD_ERROR_UNKNOWN_FORMAT : LE("Edje file loading errer %s %s - unknown file format.\n", obj->ed->file->path, group); break; + case EDJE_LOAD_ERROR_INCOMPATIBLE_FILE : LE("Edje file loading errer %s %s - incompatible file.\n", obj->ed->file->path, group); break; + case EDJE_LOAD_ERROR_UNKNOWN_COLLECTION : LE("Edje file loading errer %s %s - unknown group.\n", obj->ed->file->path, group); break; + case EDJE_LOAD_ERROR_RECURSIVE_REFERENCE : LE("Edje file loading errer %s %s - recursive reference in group.\n", obj->ed->file->path, group); break; + } + } + } + edje_object_file_get(elo->evas_obj, &file, &group); + _elua_ret(L, "$file $group", file, group); + // Stack usage [-4, +5, em] + return 1; +} + +//------------- +//------------- +/** +@page luaref +@subsection evas_image Evas image class. + +The lua evas image class includes functions for dealing with evas image objects. +The evas image objects must have been previously created by lua using the lua +image object creation function edje:image(). + +In the following, "image_object" is a place holder for any lua variable that +holds a reference to an evas image object. + +@since 1.1.0 +*/ + +static int _elua_image_fill(lua_State *L); +static int _elua_image_filled(lua_State *L); +static int _elua_image_image(lua_State *L); + +static const char *_elua_evas_image_api = "evas_image"; +static const char *_elua_evas_image_parent = "evas_image_parent"; +static const struct luaL_reg _elua_evas_image_funcs [] = +{ + {"fill", _elua_image_fill}, // get or set the fill parameters + {"filled", _elua_image_filled}, // get or set the filled state (overrides fill()) + {"image", _elua_image_image}, // get or set image + + {NULL, NULL} // end +}; + +/** +@page luaref +@subsubsection image_fill image_object:fill(x, y, w, h) + +Gets (and optionally sets) how to fill this image's drawing rectangle given the +(real) image bound to it. + +Wraps evas_object_image_fill_set(). + +@param x The x coordinate (from the top left corner of the bound image) to start drawing from. +@param y The y coordinate (from the top left corner of the bound image) to start drawing from. +@param w The width the bound image will be displayed at. +@param h The height the bound image will be displayed at. + +Note that the arguments are optional, without them this function just queries +the current values. The arguments can be separate values, or named fields in a +table. + +@return A table with these fields: + - integer x: The x coordinate (from the top left corner of the bound image) to start drawing from. + - integer y: The y coordinate (from the top left corner of the bound image) to start drawing from. + - integer w: The width the bound image will be displayed at. + - integer h: The height the bound image will be displayed at. + +@since 1.1.0 +*/ +static int +_elua_image_fill(lua_State *L) // Stack usage [-(8|12), +(9|13), em] +{ + Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -] + Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj; + Evas_Coord x, y, w, h; + + if (!_elua_isa(obj, _elua_evas_image_meta)) return 0; + + if (_elua_scan_params(L, 2, "%x %y %w %h", &x, &y, &w, &h) > 0) + { // Stack usage [-0, +0, m] unless it's in a table [-4, +4, e] + evas_object_image_fill_set(elo->evas_obj, x, y, w, h); + } + evas_object_image_fill_get(elo->evas_obj, &x, &y, &w, &h); + _elua_ret(L, "%x %y %w %h", x, y, w, h); + // Stack usage [-8, +9, em] + return 1; +} + +/** +@page luaref +@subsubsection image_filled image_object:filled(filled) + +Get (and optionally set) whether this image fills the object. + +Wraps evas_object_image_filled_set(). + +@param filled A boolean saying if this image fills the object. + +Note that the argument is optional, without it this function just queries the +current value. + +@return A boolean saying if this image fills the object. + +@since 1.1.0 +*/ +static int +_elua_image_filled(lua_State *L) // Stack usage [-0, +0, -] +{ + Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -] + Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj; + int n; + + if (!_elua_isa(obj, _elua_evas_image_meta)) return 0; + + n = lua_gettop(L); // Stack usage [-0, +0, -] + if (n == 2) + { + evas_object_image_filled_set(elo->evas_obj, lua_toboolean(L, 2)); + // Stack usage [-0, +0, -] + } + lua_pushboolean(L, evas_object_image_filled_get(elo->evas_obj)); + // Stack usage [-0, +0, -] + return 1; +} + +/** +@page luaref +@subsubsection image_image image_object:image(file, key) + +Load an image into this edje object. + +Wraps evas_object_image_file_set(). + +@param file An edje file name (ignored, sandboxed to the file this lua script is in). +@param group The name of an image. + +Note that the arguments are optional, without them this function just queries +the current values. The arguments can be separate values, or named fields in a +table. The file argument is optional, and ignored anyway. + +@return A table with these fields: + - string file: The name of the edje file the image is loaded from. + - string key: The name of the image within the edje file. + +@since 1.1.0 +*/ +static int +_elua_image_image(lua_State *L) // Stack usage [-(4|6), +(5|7), em] +{ + Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -] + Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj; + const char *file = NULL, *key = NULL; + int n, id = -1; + + if (!_elua_isa(obj, _elua_evas_image_meta)) return 0; + + n = _elua_scan_params(L, 2, "$file $key", &file, &key); + // Stack usage [-0, +0, m] unless it's in a table [-2, +2, e] + if (0 >= n) + { + file = (char *) obj->ed->file->path; + key = (char *) lua_tostring(L, 2); // Stack usage [-0, +0, m] + n = 2; + } + + if (1 < n) + { + if (obj->ed->file->image_dir) + { + Edje_Image_Directory_Entry *de; + unsigned int i; + char *name; + + /* Image name */ + if ((name = strrchr(key, '/'))) name++; + else name = (char *)key; + + /* Loop through image directory to find if image exists */ + for (i = 0; i < obj->ed->file->image_dir->entries_count; ++i) + { + de = obj->ed->file->image_dir->entries + i; + + if (de->entry) + { + if (strcmp(name, de->entry) == 0) + { + char buf[32]; + + id = i; + // This is copied from _edje_image_recalc_apply()), dunno if it provides any benefit over sprintf(). + /* Replace snprint("edje/images/%i") == memcpy + itoa */ +#define IMAGES "edje/images/" + memcpy(buf, IMAGES, strlen(IMAGES)); + eina_convert_itoa(id, buf + strlen(IMAGES)); /* No need to check length as 2³² need only 10 characters. */ + evas_object_image_file_set(elo->evas_obj, obj->ed->file->path, buf); + break; + } + } + } + } + + /* 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. + if (-1 == id) + { + LI("Image %s not found in our edje file, trying external image file %s.\n", key, file); + evas_object_image_file_set(elo->evas_obj, file, key); + } + */ + } + evas_object_image_file_get(elo->evas_obj, &file, &key); + _elua_ret(L, "$file $key", file, key); + // Stack usage [-4, +5, em] + return 1; +} + +//------------- +//------------- +/** +@page luaref +@subsection evas_line Evas line class. + +The lua evas line class includes functions for dealing with evas line objects. +The evas line objects must have been previously created by lua using the lua +line object creation function edje:line(). + +In the following, "line_object" is a place holder for any lua variable that +holds a reference to an evas line object. + +@since 1.1.0 +*/ + +static int _elua_line_xy(lua_State *L); + +static const char *_elua_evas_line_api = "evas_line"; +static const char *_elua_evas_line_parent = "evas_line_parent"; +static const struct luaL_reg _elua_evas_line_funcs [] = +{ + {"xy", _elua_line_xy}, // get or set line coords + + {NULL, NULL} // end +}; + +/** +@page luaref +@subsubsection line_xy line_object:xy(x1, y1, x2, y2) + +Sets the end points of this line. + +Wraps evas_object_line_xy_set(). + +@param x1 The X coordinate of the first line end. +@param y1 The Y coordinate of the first line end. +@param x2 The X coordinate of the other line end. +@param y2 The Y coordinate of the other line end. + +Note that the arguments are optional, without them this function just queries +the current values. The arguments can be separate values, or named fields in a +table. + +@return A table with these fields: + - integer x1: The X coordinate of the first line end. + - integer y1: The Y coordinate of the first line end. + - integer x2: The X coordinate of the other line end. + - integer y2: The Y coordinate of the other line end. + +@since 1.1.0 +*/ +static int _elua_line_xy(lua_State *L) // Stack usage [-(8|12), +(9|13), em] +{ + Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -] + Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj; + Evas_Coord x1, y1, x2, y2; + + if (!_elua_isa(obj, _elua_evas_line_meta)) return 0; + + if (_elua_scan_params(L, 2, "%x1 %y1 %x2 %y2", &x1, &y1, &x2, &y2) > 0) + { // Stack usage [-0, +0, m] unless it's in a table [-4, +4, e] + evas_object_line_xy_set(elo->evas_obj, x1, y1, x2, y2); + } + evas_object_line_xy_get(elo->evas_obj, &x1, &y1, &x2, &y2); + _elua_ret(L, "%x1 %y1 %x2 %y2", x1, y1, x2, y2); + // Stack usage [-8, +9, em] + return 1; +} + +//------------- +//------------- +/** +@page luaref +@subsection evas_object_map Evas map class. + +The lua evas map class includes functions for dealing with evas map objects. +The evas map objects must have been previously created by lua using the lua +map object creation function edje:map(). + +In the following, "map_object" is a place holder for any lua variable that +holds a reference to an evas map object. + +@since 1.1.0 +*/ + +static int _elua_map_alpha(lua_State *L); +static int _elua_map_clockwise(lua_State *L); +static int _elua_map_colour(lua_State *L); +static int _elua_map_coord(lua_State *L); +static int _elua_map_lighting(lua_State *L); +static int _elua_map_perspective(lua_State *L); +static int _elua_map_populate(lua_State *L); +static int _elua_map_rotate(lua_State *L); +static int _elua_map_rotate3d(lua_State *L); +static int _elua_map_smooth(lua_State *L); +static int _elua_map_uv(lua_State *L); +static int _elua_map_zoom(lua_State *L); + +static const char *_elua_evas_map_api = "ewas_map"; +static const struct luaL_reg _elua_evas_map_funcs [] = +{ + {"alpha", _elua_map_alpha}, +// {"dup", _elua_map_dup}, // not sure of proper api for this. + {"clockwise", _elua_map_clockwise}, + {"color", _elua_map_colour}, + {"coord", _elua_map_coord}, + {"lighting", _elua_map_lighting}, + {"perspective", _elua_map_perspective}, + {"populate", _elua_map_populate}, + {"rotate", _elua_map_rotate}, + {"rotate3d", _elua_map_rotate3d}, +// {"size", _elua_map_size}, // not sure of proper API for this + {"smooth", _elua_map_smooth}, + {"uv", _elua_map_uv}, + {"zoom", _elua_map_zoom}, + + {NULL, NULL} // end +}; + +/** +@page luaref +@subsubsection map_alpha map_object:alpha() + + +@since 1.1.0 +*/ +static int +_elua_map_alpha(lua_State *L) // Stack usage [-0, +1, -] +{ + Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -] + Edje_Lua_Map *elm = (Edje_Lua_Map *)obj; + int n; + + if (!_elua_isa(obj, _elua_evas_map_meta)) return 0; + + n = lua_gettop(L); // Stack usage [-0, +0, -] + if (n == 2) + { + evas_map_alpha_set(elm->map, lua_toboolean(L, 2)); + // Stack usage [-0, +0, -] + } + lua_pushboolean(L, evas_map_alpha_get(elm->map)); // Stack usage [-0, +1, -] + return 1; +} + +/** +@page luaref +@subsubsection map_clockwise map_object:clockwise() + + +@since 1.1.0 +*/ +static int +_elua_map_clockwise(lua_State *L) // Stack usage [-0, +1, -] +{ + Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -] + Edje_Lua_Map *elm = (Edje_Lua_Map *)obj; + + if (!_elua_isa(obj, _elua_evas_map_meta)) return 0; + + lua_pushboolean(L, evas_map_util_clockwise_get(elm->map)); // Stack usage [-0, +1, -] + return 1; +} + +/** +@page luaref +@subsubsection map_colour map_object:colour() + + +@since 1.1.0 +*/ +static int +_elua_map_colour(lua_State *L) // Stack usage [-(8|12), +(9|13), em] +{ + Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -] + Edje_Lua_Map *elm = (Edje_Lua_Map *)obj; + int r, g, b, a; + int n; + + if (!_elua_isa(obj, _elua_evas_map_meta)) return 0; + n = lua_gettop(L); // Stack usage [-0, +0, -] + + switch (n) + { + case 5 : + { + if (_elua_scan_params(L, 2, "%r %g %b %a", &r, &g, &b, &a) > 0) + { // Stack usage [-0, +0, m] unless it's in a table [-4, +4, e] + evas_map_util_points_color_set(elm->map, r, g, b, a); + } + break; + } + + case 1 : + case 6 : + { + if (_elua_scan_params(L, 3, "%r %g %b %a", &r, &g, &b, &a) > 0) + { // Stack usage [-0, +0, m] unless it's in a table [-4, +4, e] + evas_map_point_color_set(elm->map, lua_tointeger(L, 2), r, g, b, a); + // Stack usage [-0, +0, -] + } + evas_map_point_color_get(elm->map, lua_tointeger(L, 2), &r, &g, &b, &a); + // Stack usage [-0, +0, -] + _elua_ret(L, "%r %g %b %a", r, g, b, a); + // Stack usage [-8, +9, em] + return 1; + } + } + + return 0; +} + +/** +@page luaref +@subsubsection map_coord map_object:coord() + + +@since 1.1.0 +*/ +static int +_elua_map_coord(lua_State *L) // Stack usage [-(6|9), +(7|10), em] +{ + Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -] + Edje_Lua_Map *elm = (Edje_Lua_Map *)obj; + Evas_Coord x, y, z; + int n; + + if (!_elua_isa(obj, _elua_evas_map_meta)) return 0; + n = lua_gettop(L); // Stack usage [-0, +0, -] + if (2 > n) return 0; + + if (_elua_scan_params(L, 2, "%x %y %z", &x, &y, &z) > 0) + { // Stack usage [-0, +0, m] unless it's in a table [-3, +3, e] + evas_map_point_coord_set(elm->map, lua_tointeger(L, 2), x, y, z); + // Stack usage [-0, +0, -] + } + evas_map_point_coord_get(elm->map, lua_tointeger(L, 2), &x, &y, &z); + // Stack usage [-0, +0, -] + _elua_ret(L, "%x %y %z", x, y, z); + // Stack usage [-6, +7, em] + return 1; +} + +/** +@page luaref +@subsubsection map_lighting map_object:lighting() + + +@since 1.1.0 +*/ +static int +_elua_map_lighting(lua_State *L) // Stack usage [-(0|9), +(0|9), e] +{ + Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -] + Edje_Lua_Map *elm = (Edje_Lua_Map *)obj; + Evas_Coord x, y, z; + int r, g, b, r1, g1, b1; + int n; + + if (!_elua_isa(obj, _elua_evas_map_meta)) return 0; + + if ((n = _elua_scan_params(L, 2, "%x %y %z", &x, &y, &z)) > 0) + // Stack usage [-0, +0, m] unless it's in a table [-3, +3, e] + if (n += _elua_scan_params(L, 2 + n, "%r %g %b", &r, &g, &b) > 0) + // Stack usage [-0, +0, m] unless it's in a table [-3, +3, e] + if (_elua_scan_params(L, 2 + n, "%r %g %b", &r1, &g1, &b1) > 0) + { // Stack usage [-0, +0, m] unless it's in a table [-3, +3, e] + evas_map_util_3d_lighting(elm->map, x, y, z, r, g, b, r1, g1, b1); + } + return 0; +} + +/** +@page luaref +@subsubsection map_perspective map_object:perspective() + + +@since 1.1.0 +*/ +static int +_elua_map_perspective(lua_State *L) // Stack usage [-(0|4), +(0|4), e] +{ + Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -] + Edje_Lua_Map *elm = (Edje_Lua_Map *)obj; + Evas_Coord x, y, z, f; + + if (!_elua_isa(obj, _elua_evas_map_meta)) return 0; + + if (_elua_scan_params(L, 2, "%x %y %z %f", &x, &y, &z, &f) > 0) + { // Stack usage [-0, +0, m] unless it's in a table [-4, +4, e] + evas_map_util_3d_perspective(elm->map, x, y, z, f); + } + return 0; +} + +/** +@page luaref +@subsubsection map_populate map_object:populate() + + +@since 1.1.0 +*/ +static int +_elua_map_populate(lua_State *L) // Stack usage [-(0|4), +(0|4), e] +{ + Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -] + Edje_Lua_Map *elm = (Edje_Lua_Map *)obj; + int n; + + if (!_elua_isa(obj, _elua_evas_map_meta)) return 0; + n = lua_gettop(L); // Stack usage [-0, +0, -] + + switch (n) + { + case 2 : + { + Edje_Lua_Obj *obj2 = (Edje_Lua_Obj *)lua_touserdata(L, 2); // Stack usage [-0, +0, -] + const Edje_Lua_Evas_Object *source = (Edje_Lua_Evas_Object *)obj2; + + if (!_elua_isa(obj2, _elua_evas_meta)) return 0; + evas_map_util_points_populate_from_object(elm->map, source->evas_obj); + break; + } + + case 3 : + { + Edje_Lua_Obj *obj2 = (Edje_Lua_Obj *)lua_touserdata(L, 2); // Stack usage [-0, +0, -] + const Edje_Lua_Evas_Object *source = (Edje_Lua_Evas_Object *)obj2; + Evas_Coord z = lua_tointeger(L, 3); + + if (!_elua_isa(obj2, _elua_evas_meta)) return 0; + evas_map_util_points_populate_from_object_full(elm->map, source->evas_obj, z); + break; + } + + case 6 : + { + Evas_Coord x, y, w, h; + + if ((n = _elua_scan_params(L, 2, "%x %y %w %h", &x, &y, &w, &h)) > 0) + { // Stack usage [-0, +0, m] unless it's in a table [-4, +4, e] + evas_map_util_points_populate_from_geometry(elm->map, x, y, w, h, lua_tointeger(L, 2 + n)); + } + break; + } + } + return 0; +} + +/** +@page luaref +@subsubsection map_rotate map_object:rotate() + + +@since 1.1.0 +*/ +static int +_elua_map_rotate(lua_State *L) // Stack usage [-(0|2), +(0|2), e] +{ + Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -] + Edje_Lua_Map *elm = (Edje_Lua_Map *)obj; + double degrees; + Evas_Coord x, y; + int n; + + if (!_elua_isa(obj, _elua_evas_map_meta)) return 0; + n = lua_gettop(L); // Stack usage [-0, +0, -] + if (4 != n) return 0; + + degrees = lua_tonumber(L, 2); + if (_elua_scan_params(L, 3, "%x %y", &x, &y) > 0) + { // Stack usage [-0, +0, m] unless it's in a table [-2, +2, e] + evas_map_util_rotate(elm->map, degrees, x, y); + } + return 0; +} + +/** +@page luaref +@subsubsection map_rotate3d map_object:rotate3d() + + +@since 1.1.0 +*/ +static int +_elua_map_rotate3d(lua_State *L) // Stack usage [-(0|6), +(0|6), e] +{ + Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -] + Edje_Lua_Map *elm = (Edje_Lua_Map *)obj; + double zx, zy, zz; + Evas_Coord x, y, z; + int n; + + if (!_elua_isa(obj, _elua_evas_map_meta)) return 0; + + if ((n = _elua_scan_params(L, 2, "#x #y #z", &zx, &zy, &zz)) > 0) + // Stack usage [-0, +0, m] unless it's in a table [-3, +3, e] + if (_elua_scan_params(L, 2 + n, "%x %y %z", &x, &y, &z) > 0) + { // Stack usage [-0, +0, m] unless it's in a table [-3, +3, e] + evas_map_util_3d_rotate(elm->map, zx, zy, zz, x, y, z); + } + return 0; +} + +/** +@page luaref +@subsubsection map_smooth map_object:smooth() + + +@since 1.1.0 +*/ +static int +_elua_map_smooth(lua_State *L) // Stack usage [-0, +1, -] +{ + Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -] + Edje_Lua_Map *elm = (Edje_Lua_Map *)obj; + int n; + + if (!_elua_isa(obj, _elua_evas_map_meta)) return 0; + + n = lua_gettop(L); // Stack usage [-0, +0, -] + if (n == 2) + { + evas_map_smooth_set(elm->map, lua_toboolean(L, 2)); + // Stack usage [-0, +0, -] + } + lua_pushboolean(L, evas_map_smooth_get(elm->map)); // Stack usage [-0, +1, -] + return 1; +} + +/** +@page luaref +@subsubsection map_uv map_object:uv() + + +@since 1.1.0 +*/ +static int +_elua_map_uv(lua_State *L) // Stack usage [-(4|6), +(5|7), em] +{ + Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -] + Edje_Lua_Map *elm = (Edje_Lua_Map *)obj; + double u, v; + int n; + + if (!_elua_isa(obj, _elua_evas_map_meta)) return 0; + n = lua_gettop(L); // Stack usage [-0, +0, -] + if (2 > n) return 0; + + if (_elua_scan_params(L, 3, "#u #v", &u, &v) > 0) + { // Stack usage [-0, +0, m] unless it's in a table [-2, +2, e] + evas_map_point_image_uv_set(elm->map, lua_tonumber(L, 2), u, v); + // Stack usage [-0, +0, -] + } + evas_map_point_image_uv_get(elm->map, lua_tonumber(L, 2), &u, &v); + // Stack usage [-0, +0, -] + _elua_ret(L, "#u #v", u, v); + // Stack usage [-4, +5, em] + return 1; +} + +/** +@page luaref +@subsubsection map_zoom map_object:zoom() + + +@since 1.1.0 +*/ +static int +_elua_map_zoom(lua_State *L) // Stack usage [-(0|4), +(0|4), e] +{ + Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -] + Edje_Lua_Map *elm = (Edje_Lua_Map *)obj; + double zx, zy; + Evas_Coord x, y; + int n; + + if (!_elua_isa(obj, _elua_evas_map_meta)) return 0; + + if ((n = _elua_scan_params(L, 2, "#x #y", &zx, &zy)) > 0) + // Stack usage [-0, +0, m] unless it's in a table [-2, +2, e] + if (_elua_scan_params(L, 2 + n, "%x %y", &x, &y) > 0) + { // Stack usage [-0, +0, m] unless it's in a table [-2, +2, e] + evas_map_util_zoom(elm->map, zx, zy, x, y); + } + return 0; +} + +//------------- +//------------- +/** +@page luaref +@subsection evas_polygon Evas polygon class. + +The lua evas polygon class includes functions for dealing with evas polygon objects. +The evas polygon objects must have been previously created by lua using the lua +polygon object creation function edje:polygon(). + +In the following, "polygon_object" is a place holder for any lua variable that +holds a reference to an evas polygon object. + +@since 1.1.0 +*/ + +static int _elua_polygon_clear(lua_State *L); +static int _elua_polygon_point(lua_State *L); + +static const char *_elua_evas_polygon_api = "evas_polygon"; +static const char *_elua_evas_polygon_parent = "evas_polygon_parent"; +static const struct luaL_reg _elua_evas_polygon_funcs [] = +{ + {"clear", _elua_polygon_clear}, // clear all polygon points + {"point", _elua_polygon_point}, // add a polygon point + + {NULL, NULL} // end +}; + +/** +@page luaref +@subsubsection polygon_clear polygon_object:clear() + +Clears all points from the polygon. + +Wraps evas_object_polygon_points_clear(), + +@since 1.1.0 +*/ +static int +_elua_polygon_clear(lua_State *L) // Stack usage [-0, +0, -] +{ + Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -] + Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj; + + if (!_elua_isa(obj, _elua_evas_polygon_meta)) return 0; + evas_object_polygon_points_clear(elo->evas_obj); + return 0; +} + +/** +@page luaref +@subsubsection polygon_point polygon_object:point(x, y) + +Adds a point to this polygon. + +Wraps evas_object_polygon_point_add(). + +@param x The X coordinate of the point. +@param y The Y coordinate of the point. + +@since 1.1.0 +*/ +static int +_elua_polygon_point(lua_State *L) // Stack usage [-(0|2), +(0|2), e] +{ + Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -] + Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj; + Evas_Coord x, y; + + if (!_elua_isa(obj, _elua_evas_polygon_meta)) return 0; + + if (_elua_scan_params(L, 2, "%x %y", &x, &y) > 0) + { // Stack usage [-0, +0, m] unless it's in a table [-2, +2, e] + evas_object_polygon_point_add(elo->evas_obj, x, y); + } + + return 0; +} + +//------------- +//------------- +/** +@page luaref +@subsection evas_text Evas text class. + +The lua evas text class includes functions for dealing with evas text objects. +The evas text objects must have been previously created by lua using the lua +text object creation function edje:text(). + +In the following, "text_object" is a place holder for any lua variable that +holds a reference to an evas text object. + +@since 1.1.0 +*/ + +static int _elua_text_font(lua_State *L); +static int _elua_text_text(lua_State *L); + +static const char *_elua_evas_text_api = "evas_text"; +static const char *_elua_evas_text_parent = "evas_text_parent"; +static const struct luaL_reg _elua_evas_text_funcs [] = +{ + {"font", _elua_text_font}, // get or set text font + {"text", _elua_text_text}, // get or set text +// {"text_class", _elua_object_text_class}, // get or set object text class + + {NULL, NULL} // end +}; + +/** +@page luaref +@subsubsection text_font text_object:font(font, size) + +Gets, (and optionally sets) the font for this text object. + +Wraps evas_object_text_font_set(). + +@param font The new font name. +@param size The new font size. + +Note that the font and size arguments are optional, without them this function +just queries the current values. The font and size arguments can be separate +values, or named fields in a table. The font name can refer to a font in the +edje file, or an external font. + +@return A table with these fields: + - string font: The font name. + - integer size: The font size. + +@since 1.1.0 +*/ +static int +_elua_text_font(lua_State *L) // Stack usage [-(4|6), +(5|7), em] +{ + Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -] + Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj; + char *font, *font2 = NULL; + Evas_Font_Size size; + int inlined_font = 0; + + if (!_elua_isa(obj, _elua_evas_text_meta)) return 0; + + if (_elua_scan_params(L, 2, "$font %size", &font, &size) > 0) + { // Stack usage [-0, +0, m] unless it's in a table [-2, +2, e] + /* Check if the font is embedded in the .edj + * This is a simple check. + * There is a much more complicated version in edje_text.c _edje_text_recalc_apply(). + * If we need to get more complicated, we can do that later, + * and maybe refactor things. + */ + if (obj->ed->file->fonts) + { + Edje_Font_Directory_Entry *fnt = eina_hash_find(obj->ed->file->fonts, font); + + if (fnt) + { + size_t len = strlen(font) + sizeof("edje/fonts/") + 1; + font2 = alloca(len); + sprintf(font2, "edje/fonts/%s", font); + font = font2; + inlined_font = 1; + font2 = NULL; + } + } + + if (inlined_font) evas_object_text_font_source_set(elo->evas_obj, obj->ed->path); + else evas_object_text_font_source_set(elo->evas_obj, NULL); + + evas_object_text_font_set(elo->evas_obj, font, size); + } + + // When one external API says it's gotta be const, and another one says not, then one of them's gotta be cast. :-P + evas_object_text_font_get(elo->evas_obj, (const char **) &font, &size); + _elua_ret(L, "$font %size", font, size); + // Stack usage [-4, +5, em] + return 1; +} + +/** +@page luaref +@subsubsection text_text text_object:text(text) + +Get (and optionally set) the actual tetx for this text object. + +Wraps evas_object_text_text_set(). + +@param text The text to set for this text object. + +Note that the argument is optional, without it this function just queries the +current value. + +@return A string of the text on this text object. + +@since 1.1.0 +*/ +static int +_elua_text_text(lua_State *L) // Stack usage [-0, +1, m] +{ + Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1); // Stack usage [-0, +0, -] + Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj; + int n; + + if (!_elua_isa(obj, _elua_evas_text_meta)) return 0; + n = lua_gettop(L); // Stack usage [-0, +0, -] + if (n == 2) + { + if (lua_isstring(L, 2)) + { + const char *str; + + if ((str = lua_tostring(L, 2))) // Extra parenthesis, coz Mikes compiler has a lisp. + // Stack usage [-0, +0, m] + evas_object_text_text_set(elo->evas_obj, str); + } + } + lua_pushstring(L, evas_object_text_text_get(elo->evas_obj)); // Stack usage [-0, +1, m] + return 1; +} + + +//--------------------------------------------------------------------------// +// Brain dead inheritance thingy, built for speed. Kinda. Part 1. +static void +_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] +{ + luaL_register(L, api, funcs); // Stack usage [-0, +1, m] + luaL_newmetatable(L, meta); // Stack usage [-0, +1, m] + luaL_register(L, 0, _elua_edje_gc_funcs); // Stack usage [-1, +1, m] + lua_pushliteral(L, "__index"); // Stack usage [-0, +1, m] + lua_pushvalue(L, -3); // Stack usage [-0, +1, -] + lua_rawset(L, -3); // Stack usage [-2, +0, m] + + if (base && parent) + { + // Inherit from base + lua_getglobal(L, base); // Stack usage [-0, +1, e] + luaL_newmetatable(L, parent); // Stack usage [-0, +1, m] + lua_pushliteral(L, "__index"); // Stack usage [-0, +1, m] + lua_pushvalue(L, -3); // Stack usage [-0, +1, -] + lua_rawset(L, -3); // Stack usage [-2, +0, m] + lua_getglobal(L, api); // Stack usage [-0, +1, e] + luaL_getmetatable(L, parent); // Stack usage [-0, +1, -] + lua_setmetatable(L, -2); // Stack usage [-1, +0, -] + } +} + +// Brain dead inheritance thingy, built for speed. Kinda. Part 2. +static Eina_Bool +_elua_isa(Edje_Lua_Obj *obj, const char *type) +{ + Eina_Bool isa = EINA_FALSE; + + if (!obj) return isa; + if (obj->meta == type) + isa = EINA_TRUE; + if (_elua_evas_meta == type) + { + if (obj->meta == _elua_evas_image_meta) + isa = EINA_TRUE; + else if (obj->meta == _elua_evas_text_meta) + isa = EINA_TRUE; + else if (obj->meta == _elua_evas_edje_meta) + isa = EINA_TRUE; + else if (obj->meta == _elua_evas_line_meta) + isa = EINA_TRUE; + else if (obj->meta == _elua_evas_polygon_meta) + isa = EINA_TRUE; + } + return isa; +} + +#ifndef RASTER_FORGOT_WHY +static void +_elua_init(void) // Stack usage [-16, +20, em] +{ + static Edje_Lua_Alloc ela = { MAX_LUA_MEM, 0 }; + const luaL_Reg *l; + lua_State *L; + + if (lstate) return; + + lstate = L = lua_newstate(_elua_alloc, &ela); // Stack usage [-0, +0, -] + lua_atpanic(L, _elua_custom_panic); // Stack usage [-0, +0, -] + +// FIXME: figure out optimal gc settings later +// lua_gc(L, LUA_GCSETPAUSE, 200); // Stack usage [-0, +0, e] +// lua_gc(L, LUA_GCSETSTEPMUL, 200); // Stack usage [-0, +0, e] + + for (l = _elua_libs; l->func; l++) // Currently * 4 + { + lua_pushcfunction(L, l->func); // Stack usage [-0, +1, m] + lua_pushstring(L, l->name); // Stack usage [-0, +1, m] + lua_call(L, 1, 0); // Stack usage [-2, +0, e] + } + + luaL_register(L, _elua_edje_api, _elua_edje_funcs); // Stack usage [-0, +1, m] + luaL_newmetatable(L, _elua_edje_meta); // Stack usage [-0, +1, m] + luaL_register(L, 0, _elua_edje_gc_funcs); // Stack usage [-1, +1, m] + + _elua_add_functions(L, _elua_evas_api, _elua_evas_funcs, _elua_evas_meta, NULL, NULL); // Stack usage [-3, +5, m] + + // weak table for our objects + lua_pushlightuserdata(L, &_elua_objs); // Stack usage [-0, +1, -] + lua_newtable(L); // Stack usage [-0, +1, m] + lua_pushstring(L, "__mode"); // Stack usage [-0, +1, m] + lua_pushstring(L, "v"); // Stack usage [-0, +1, m] + lua_rawset(L, -3); // Stack usage [-2, +0, m] + lua_rawset(L, LUA_REGISTRYINDEX); // Stack usage [-2, +0, m] +} +#endif + +void +_edje_lua2_script_init(Edje *ed) // Stack usage [-63, +99, em] +{ + static Edje_Lua_Alloc ela = { MAX_LUA_MEM, 0 }; + const luaL_Reg *l; + char buf[256]; + void *data; + int size; + lua_State *L; + + if (ed->L) return; + if (0 > _log_domain) + _log_domain = eina_log_domain_register("lua", NULL); + if (0 <= _log_domain) + { + _log_count++; + eina_log_domain_level_set("lua", EINA_LOG_LEVEL_WARN); + } + +#ifndef RASTER_FORGOT_WHY + _elua_init(); // This is actually truly pointless, even if raster remembers. +#endif + L = ed->L = lua_newstate(_elua_alloc, &ela); // Stack usage [-0, +0, -] + lua_atpanic(L, _elua_custom_panic); // Stack usage [-0, +0, -] + +// FIXME: figure out optimal gc settings later +// lua_gc(L, LUA_GCSETPAUSE, 200); // Stack usage [-0, +0, e] +// lua_gc(L, LUA_GCSETSTEPMUL, 200); // Stack usage [-0, +0, e] + + for (l = _elua_libs; l->func; l++) // Currently * 4 + { + lua_pushcfunction(L, l->func); // Stack usage [-0, +1, m] + lua_pushstring(L, l->name); // Stack usage [-0, +1, m] + lua_call(L, 1, 0); // Stack usage [-2, +0, m] + } + + luaL_register(L, _elua_edje_api, _elua_edje_funcs); // Stack usage [-0, +1, m] + luaL_newmetatable(L, _elua_edje_meta); // Stack usage [-0, +1, m] + luaL_register(L, 0, _elua_edje_gc_funcs); // Stack usage [-1, +1, m] + + lua_pop(L, 2); // Stack usage [-n, +0, -] + + _elua_add_functions(L, _elua_evas_api, _elua_evas_funcs, _elua_evas_meta, NULL, NULL); + // Stack usage [-3, +5, m] + _elua_add_functions(L, _elua_ecore_timer_api, _elua_ecore_timer_funcs, _elua_ecore_timer_meta, NULL, NULL); + // Stack usage [-3, +5, m] + _elua_add_functions(L, _elua_ecore_animator_api, _elua_ecore_animator_funcs, _elua_ecore_animator_meta, NULL, NULL); + // Stack usage [-6, +11, m] + _elua_add_functions(L, _elua_evas_edje_api, _elua_evas_edje_funcs, _elua_evas_edje_meta, _elua_evas_edje_parent, _elua_evas_api); + // Stack usage [-6, +11, em] + _elua_add_functions(L, _elua_evas_image_api, _elua_evas_image_funcs, _elua_evas_image_meta, _elua_evas_image_parent, _elua_evas_api); + // Stack usage [-6, +11, em] + _elua_add_functions(L, _elua_evas_line_api, _elua_evas_line_funcs, _elua_evas_line_meta, _elua_evas_line_parent, _elua_evas_api); + // Stack usage [-6, +11, em] + _elua_add_functions(L, _elua_evas_map_api, _elua_evas_map_funcs, _elua_evas_map_meta, NULL, NULL); + // Stack usage [-3, +5, m] + _elua_add_functions(L, _elua_evas_polygon_api, _elua_evas_polygon_funcs, _elua_evas_polygon_meta, _elua_evas_polygon_parent, _elua_evas_api); + // Stack usage [-6, +11, em] + _elua_add_functions(L, _elua_evas_text_api, _elua_evas_text_funcs, _elua_evas_text_meta, _elua_evas_text_parent, _elua_evas_api); + // Stack usage [-6, +11, em] + + // weak table for our objects + lua_pushlightuserdata(L, &_elua_objs); // Stack usage [-0, +1, -] + lua_newtable(L); // Stack usage [-0, +1, m] + lua_pushstring(L, "__mode"); // Stack usage [-0, +1, m] + lua_pushstring(L, "v"); // Stack usage [-0, +1, m] + lua_rawset(L, -3); // Stack usage [-2, +0, m] + lua_rawset(L, LUA_REGISTRYINDEX); // Stack usage [-2, +0, m] + + _elua_table_ptr_set(L, _elua_key, ed); // Stack usage [-2, +2, e] + + snprintf(buf, sizeof(buf), "edje/scripts/lua/%i", ed->collection->id); + data = eet_read(ed->file->ef, buf, &size); + + if (data) + { + int err; + + err = luaL_loadbuffer(L, data, size, "edje_lua_script"); // Stack usage [-0, +1, m] + if (err) + { + if (err == LUA_ERRSYNTAX) + ERR("Lua load syntax error: %s", + lua_tostring(L, -1)); // Stack usage [-0, +0, m] + else if (err == LUA_ERRMEM) + ERR("Lua load memory allocation error: %s", + lua_tostring(L, -1)); // Stack usage [-0, +0, m] + } + free(data); + /* This is not needed, pcalls don't longjmp(), that's why they are protected. + if (setjmp(panic_jmp) == 1) + { + ERR("Lua script init panic"); + return; + } + */ + if ((err = lua_pcall(L, 0, 0, 0))) // Stack usage [-1, +0, -] + _edje_lua2_error(L, err); // Stack usage [-0, +0, m] + } +} + +void +_edje_lua2_script_shutdown(Edje *ed) +{ + if (!ed->L) return; + lua_close(ed->L); // Stack usage irrelevant, as it's all gone now. + ed->L = NULL; + while (ed->lua_objs) + { + Edje_Lua_Obj *obj = (Edje_Lua_Obj *)ed->lua_objs; + if (obj->free_func) + { + ERR("uncollected Lua object %p", obj); + ed->lua_objs = eina_inlist_remove(ed->lua_objs, ed->lua_objs); + } + else + { + ERR("dangling Lua object %p", obj); + ed->lua_objs = eina_inlist_remove(ed->lua_objs, ed->lua_objs); + } + } + + if (0 <= _log_domain) + { + _log_count--; + if (0 >= _log_count) + { + eina_log_domain_unregister(_log_domain); + _log_domain = -1; + } + } +} + +void +_edje_lua2_script_load(Edje_Part_Collection *edc __UNUSED__, void *data __UNUSED__, int size __UNUSED__) // Stack usage [-16, +20, em] +{ +#ifndef RASTER_FORGOT_WHY + _elua_init(); // Stack usage [-16, +20, em] +#endif +} + +void +_edje_lua2_script_unload(Edje_Part_Collection *edc __UNUSED__) // Stack usage [-0, +0, e] +{ +#ifndef RASTER_FORGOT_WHY + lua_State *L; + + if (!lstate) return; + L = lstate; + lua_gc(L, LUA_GCCOLLECT, 0); // Stack usage [-0, +0, e] +#endif +} + +void +_edje_lua2_error_full(const char *file, const char *fnc, int line, + lua_State *L, int err_code) // Stack usage [-0, +0, m] +{ + const char *err_type; + + switch (err_code) + { + case LUA_ERRRUN: + err_type = "runtime"; + break; + case LUA_ERRSYNTAX: + err_type = "syntax"; + break; + case LUA_ERRMEM: + err_type = "memory allocation"; + break; + case LUA_ERRERR: + err_type = "error handler"; + break; + default: + err_type = "unknown"; + break; + } + eina_log_print + (_edje_default_log_dom, EINA_LOG_LEVEL_ERR, file, fnc, line, + "Lua %s error: %s", err_type, lua_tostring(L, -1)); // Stack usage [-0, +0, m] +} + +/** +@page luaref +@section callbacks Lua callbacks + +These are lua functions that are called by the lua edje system when certain +events occur. If the functions don't exist in the lua group, they don't get +called. + + */ + +/** +@page luaref +@subsection edje_shutdown Edje shutdown() callback. + +If a function called "shutdown" exists in a lua edje group, then it is called when +that edje gets deleted. +*/ +void +_edje_lua2_script_func_shutdown(Edje *ed) // Stack usage [-1, +1, em] +{ + int err; + + lua_getglobal(ed->L, "shutdown"); // Stack usage [-0, +1, e] + if (!lua_isnil(ed->L, -1)) // Stack usage [-0, +0, -] + { + if ((err = lua_pcall(ed->L, 0, 0, 0))) // Stack usage [-1, +0, -] + _edje_lua2_error(ed->L, err); // Stack usage [-0, +0, m] + } + else + lua_pop(ed->L, 1); // Stack usage [-n, +0, -] + _edje_lua2_script_shutdown(ed); +} + +/** +@page luaref +@subsection edje_show Edje show() callback. + +If a function called "show" exists in a lua edje group, then it is called when +that edje gets shown. +*/ +void +_edje_lua2_script_func_show(Edje *ed) // Stack usage [-1, +1, e] +{ + int err; + + lua_getglobal(ed->L, "show"); + if (!lua_isnil(ed->L, -1)) + { + if ((err = lua_pcall(ed->L, 0, 0, 0))) + _edje_lua2_error(ed->L, err); + } + else + lua_pop(ed->L, 1); +} + +/** +@page luaref +@subsection edje_hide Edje hide() callback. + +If a function called "hide" exists in a lua edje group, then it is called when +that edje gets hidden. +*/ +void +_edje_lua2_script_func_hide(Edje *ed) // Stack usage [-1, +1, e] +{ + int err; + + lua_getglobal(ed->L, "hide"); + if (!lua_isnil(ed->L, -1)) + { + if ((err = lua_pcall(ed->L, 0, 0, 0))) + _edje_lua2_error(ed->L, err); + } + else + lua_pop(ed->L, 1); +} + +/** +@page luaref +@subsection edje_move Edje move(x, y) callback. + +If a function called "move" exists in a lua edje group, then it is called when +that edje gets moved, with the new position passed to it. +*/ +void +_edje_lua2_script_func_move(Edje *ed) // Stack usage [-3, +3, e] or [-1, +1, e] if no matching function. +{ + int err; + + // FIXME: move all objects created by script + lua_getglobal(ed->L, "move"); // Stack usage [-0, +1, e] + if (!lua_isnil(ed->L, -1)) // Stack usage [-0, +0, -] + { + lua_pushinteger(ed->L, ed->x); // Stack usage [-0, +1, -] + lua_pushinteger(ed->L, ed->y); // Stack usage [-0, +1, -] + if ((err = lua_pcall(ed->L, 2, 0, 0))) // Stack usage [-3, +0, -] + _edje_lua2_error(ed->L, err); + } + else + lua_pop(ed->L, 1); // Stack usage [-n, +0, -] +} + +/** +@page luaref +@subsection edje_resize Edje resize(w, h) callback. + +If a function called "resize" exists in a lua edje group, then it is called when +that edje gets resized, with the new size passed to it. +*/ +void +_edje_lua2_script_func_resize(Edje *ed) // Stack usage [-3, +3, e] or [-1, +1, e] if no matching function. +{ + int err; + + lua_getglobal(ed->L, "resize"); + if (!lua_isnil(ed->L, -1)) + { + lua_pushinteger(ed->L, ed->w); + lua_pushinteger(ed->L, ed->h); + if ((err = lua_pcall(ed->L, 2, 0, 0))) + _edje_lua2_error(ed->L, err); + } + else + lua_pop(ed->L, 1); +} + +/** +@page luaref +@subsection edje_message Edje message(id, type, ...) callback. + +If a function called "message" exists in a lua edje group, then it is called when +that edje gets gets a message sent to it, with the message details passed to it. +See edje:messagesend() for details of what each type means. The arrays are +passed as a table. +*/ +void +_edje_lua2_script_func_message(Edje *ed, Edje_Message *em) // Stack usage [-?, +?, em] It's complicated, but it's even at least. +{ + int err, n, c, i; + + lua_getglobal(ed->L, "message"); // Stack usage [-0, +1, e] + if (!lua_isnil(ed->L, -1)) // Stack usage [-0, +0, -] + { + n = 2; + lua_pushinteger(ed->L, em->id); // Stack usage [-0, +1, -] + switch (em->type) + { + case EDJE_MESSAGE_NONE: + lua_pushstring(ed->L, "none"); // Stack usage [-0, +1, m] + break; + case EDJE_MESSAGE_SIGNAL: + break; + case EDJE_MESSAGE_STRING: + lua_pushstring(ed->L, "str"); // Stack usage [-0, +1, m] + lua_pushstring(ed->L, ((Edje_Message_String *)em->msg)->str); + // Stack usage [-0, +1, m] + n += 1; + break; + case EDJE_MESSAGE_INT: + lua_pushstring(ed->L, "int"); // Stack usage [-0, +1, m] + lua_pushinteger(ed->L, ((Edje_Message_Int *)em->msg)->val); + // Stack usage [-0, +1, -] + n += 1; + break; + case EDJE_MESSAGE_FLOAT: + lua_pushstring(ed->L, "float"); // Stack usage [-0, +1, m] + lua_pushnumber(ed->L, ((Edje_Message_Float *)em->msg)->val); + // Stack usage [-0, +1, -] + n += 1; + break; + case EDJE_MESSAGE_STRING_SET: + lua_pushstring(ed->L, "strset"); // Stack usage [-0, +1, m] + c = ((Edje_Message_String_Set *)em->msg)->count; + lua_createtable(ed->L, c, 0); // Stack usage [-0, +1, m] + for (i = 0; i < c; i++) + { + lua_pushstring(ed->L, ((Edje_Message_String_Set *)em->msg)->str[i]); + // Stack usage [-0, +1, m] + // It's OK to bypass the metatable in these cases, + // we create the table, and know there is no metatable. B-) + lua_rawseti(ed->L, -2, i + 1); // Stack usage [-1, +0, m] + } + n += 1; + break; + case EDJE_MESSAGE_INT_SET: + lua_pushstring(ed->L, "intset"); // Stack usage [-0, +1, m] + c = ((Edje_Message_Int_Set *)em->msg)->count; + lua_createtable(ed->L, c, 0); // Stack usage [-0, +1, m] + for (i = 0; i < c; i++) + { + lua_pushinteger(ed->L, ((Edje_Message_Int_Set *)em->msg)->val[i]); + // Stack usage [-0, +1, -] + lua_rawseti(ed->L, -2, i + 1); // Stack usage [-1, +0, m] + } + n += 1; + break; + case EDJE_MESSAGE_FLOAT_SET: + lua_pushstring(ed->L, "floatset"); // Stack usage [-0, +1, m] + c = ((Edje_Message_Float_Set *)em->msg)->count; + lua_createtable(ed->L, c, 0); // Stack usage [-0, +1, m] + for (i = 0; i < c; i++) + { + lua_pushnumber(ed->L, ((Edje_Message_Float_Set *)em->msg)->val[i]); + // Stack usage [-0, +1, -] + lua_rawseti(ed->L, -2, i + 1); // Stack usage [-1, +0, m] + } + n += 1; + break; + case EDJE_MESSAGE_STRING_INT: + lua_pushstring(ed->L, "strint"); // Stack usage [-0, +1, m] + lua_pushstring(ed->L, ((Edje_Message_String_Int *)em->msg)->str); + // Stack usage [-0, +1, m] + lua_pushinteger(ed->L, ((Edje_Message_String_Int *)em->msg)->val); + // Stack usage [-0, +1, -] + n += 2; + break; + case EDJE_MESSAGE_STRING_FLOAT: + lua_pushstring(ed->L, "strfloat"); // Stack usage [-0, +1, m] + lua_pushstring(ed->L, ((Edje_Message_String_Float *)em->msg)->str); + // Stack usage [-0, +1, m] + lua_pushnumber(ed->L, ((Edje_Message_String_Float *)em->msg)->val); + // Stack usage [-0, +1, -] + n += 2; + break; + case EDJE_MESSAGE_STRING_INT_SET: + lua_pushstring(ed->L, "strintset"); // Stack usage [-0, +1, m] + lua_pushstring(ed->L, ((Edje_Message_String_Int_Set *)em->msg)->str); + // Stack usage [-0, +1, m] + c = ((Edje_Message_String_Int_Set *)em->msg)->count; + lua_createtable(ed->L, c, 0); // Stack usage [-0, +1, m] + for (i = 0; i < c; i++) + { + lua_pushinteger(ed->L, ((Edje_Message_String_Int_Set *)em->msg)->val[i]); + // Stack usage [-0, +1, -] + lua_rawseti(ed->L, -2, i + 1); // Stack usage [-1, +0, m] + } + n += 2; + break; + case EDJE_MESSAGE_STRING_FLOAT_SET: + lua_pushstring(ed->L, "strfloatset"); // Stack usage [-0, +1, m] + lua_pushstring(ed->L, ((Edje_Message_String_Float_Set *)em->msg)->str); + // Stack usage [-0, +1, m] + c = ((Edje_Message_String_Float_Set *)em->msg)->count; + lua_createtable(ed->L, c, 0); // Stack usage [-0, +1, m] + for (i = 0; i < c; i++) + { + lua_pushnumber(ed->L, ((Edje_Message_String_Float_Set *)em->msg)->val[i]); + // Stack usage [-0, +1, -] + lua_rawseti(ed->L, -2, i + 1); // Stack usage [-1, +0, m] + } + n += 2; + break; + default: + break; + } + if ((err = lua_pcall(ed->L, n, 0, 0))) // Stack usage [-n+1, +0, -] + _edje_lua2_error(ed->L, err); + } + else + lua_pop(ed->L, 1); // Stack usage [-n, +0, -] +} + +/** +@page luaref +@subsection edje_signal Edje signal(signal, source) callback. + +If a function called "signal" exists in a lua edje group, then it is called when +ever a signal arrives, with the signal details passed to it. + +*/ +void +_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. +{ + int err; + + lua_getglobal(ed->L, "signal"); + if (!lua_isnil(ed->L, -1)) + { + lua_pushstring(ed->L, sig); + lua_pushstring(ed->L, src); + if ((err = lua_pcall(ed->L, 2, 0, 0))) + _edje_lua2_error(ed->L, err); + } + else + lua_pop(ed->L, 1); +} 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 @@ +#include "edje_private.h" + +Eina_Bool +_edje_lua_script_only(Edje *ed) +{ + if ((ed->collection) && (ed->collection->lua_script_only)) + return EINA_TRUE; + return EINA_FALSE; +} + +void +_edje_lua_script_only_init(Edje *ed) +{ + if (ed->collection) + _edje_lua2_script_init(ed); +} + +void +_edje_lua_script_only_shutdown(Edje *ed) +{ + if (ed->collection && ed->L) + _edje_lua2_script_func_shutdown(ed); +} + +void +_edje_lua_script_only_show(Edje * ed) +{ + if (ed->collection && ed->L) + _edje_lua2_script_func_show(ed); +} + +void +_edje_lua_script_only_hide(Edje * ed) +{ + if (ed->collection && ed->L) + _edje_lua2_script_func_hide(ed); +} + +void +_edje_lua_script_only_move(Edje * ed) +{ + if (ed->collection && ed->L) + _edje_lua2_script_func_move(ed); +} + +void +_edje_lua_script_only_resize(Edje * ed) +{ + if (ed->collection && ed->L) + _edje_lua2_script_func_resize(ed); +} + +void +_edje_lua_script_only_message(Edje * ed, Edje_Message * em) +{ + if (ed->collection && ed->L) + _edje_lua2_script_func_message(ed, em); +} + 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 @@ +#include "edje_private.h" + +static Edje_Version _version = { VMAJ, VMIN, VMIC, VREV }; +EAPI Edje_Version *edje_version = &_version; + +static int _edje_init_count = 0; +int _edje_default_log_dom = -1; +Eina_Mempool *_edje_real_part_mp = NULL; +Eina_Mempool *_edje_real_part_state_mp = NULL; + +/*============================================================================* + * API * + *============================================================================*/ + + +EAPI int +edje_init(void) +{ + if (++_edje_init_count != 1) + return _edje_init_count; + + srand(time(NULL)); + + if (!eina_init()) + { + fprintf(stderr, "Edje: Eina init failed"); + return --_edje_init_count; + } + + _edje_default_log_dom = eina_log_domain_register + ("edje", EDJE_DEFAULT_LOG_COLOR); + if (_edje_default_log_dom < 0) + { + EINA_LOG_ERR("Edje Can not create a general log domain."); + goto shutdown_eina; + } + + if (!ecore_init()) + { + ERR("Ecore init failed"); + goto unregister_log_domain; + } + + if (!embryo_init()) + { + ERR("Embryo init failed"); + goto shutdown_ecore; + } + + if (!eet_init()) + { + ERR("Eet init failed"); + goto shutdown_embryo; + } + + _edje_scale = FROM_DOUBLE(1.0); + + _edje_edd_init(); + _edje_text_init(); + _edje_box_init(); + _edje_external_init(); + _edje_module_init(); + _edje_message_init(); + _edje_multisense_init(); + + _edje_real_part_mp = eina_mempool_add("chained_mempool", + "Edje_Real_Part", NULL, + sizeof (Edje_Real_Part), 128); + if (!_edje_real_part_mp) + { + ERR("Mempool for Edje_Real_Part cannot be allocated."); + goto shutdown_eet; + } + + _edje_real_part_state_mp = eina_mempool_add("chained_mempool", + "Edje_Real_Part_State", NULL, + sizeof (Edje_Real_Part_State), 256); + if (!_edje_real_part_state_mp) + { + ERR("Mempool for Edje_Real_Part_State cannot be allocated."); + goto shutdown_eet; + } + + return _edje_init_count; + + shutdown_eet: + eina_mempool_del(_edje_real_part_state_mp); + eina_mempool_del(_edje_real_part_mp); + _edje_real_part_state_mp = NULL; + _edje_real_part_mp = NULL; + _edje_message_shutdown(); + _edje_module_shutdown(); + _edje_external_shutdown(); + _edje_box_shutdown(); + _edje_text_class_members_free(); + _edje_text_class_hash_free(); + _edje_edd_shutdown(); + eet_shutdown(); + shutdown_embryo: + embryo_shutdown(); + shutdown_ecore: + ecore_shutdown(); + unregister_log_domain: + eina_log_domain_unregister(_edje_default_log_dom); + _edje_default_log_dom = -1; + shutdown_eina: + eina_shutdown(); + return --_edje_init_count; +} + +static int _edje_users = 0; + +static void +_edje_shutdown_core(void) +{ + if (_edje_users > 0) return; + + _edje_file_cache_shutdown(); + _edje_color_class_members_free(); + _edje_color_class_hash_free(); + + eina_mempool_del(_edje_real_part_state_mp); + eina_mempool_del(_edje_real_part_mp); + _edje_real_part_state_mp = NULL; + _edje_real_part_mp = NULL; + + _edje_multisense_shutdown(); + _edje_message_shutdown(); + _edje_module_shutdown(); + _edje_external_shutdown(); + _edje_box_shutdown(); + _edje_text_class_members_free(); + _edje_text_class_hash_free(); + _edje_edd_shutdown(); + + eet_shutdown(); + embryo_shutdown(); + ecore_shutdown(); + eina_log_domain_unregister(_edje_default_log_dom); + _edje_default_log_dom = -1; + eina_shutdown(); +} + +void +_edje_lib_ref(void) +{ + _edje_users++; +} + +void +_edje_lib_unref(void) +{ + _edje_users--; + if (_edje_users != 0) return; + if (_edje_init_count == 0) _edje_shutdown_core(); +} + +EAPI int +edje_shutdown(void) +{ + if (--_edje_init_count != 0) + return _edje_init_count; + + if (_edje_timer) + ecore_animator_del(_edje_timer); + _edje_timer = NULL; + + _edje_shutdown_core(); + + return _edje_init_count; +} + +/* Private Routines */ +static Eina_Bool +_class_member_free(const Eina_Hash *hash __UNUSED__, + const void *key, + void *data, + void *fdata) +{ + void (*_edje_class_member_direct_del)(const char *class, void *l) = fdata; + + _edje_class_member_direct_del(key, data); + return EINA_TRUE; +} + +void +_edje_del(Edje *ed) +{ + Edje_Running_Program *runp; + Edje_Pending_Program *pp; + Edje_Signal_Callback *escb; + Edje_Color_Class *cc; + Edje_Text_Class *tc; + Edje_Text_Insert_Filter_Callback *cb; + + if (ed->processing_messages) + { + ed->delete_me = 1; + return; + } + _edje_message_del(ed); + _edje_callbacks_patterns_clean(ed); + _edje_file_del(ed); + if (ed->path) eina_stringshare_del(ed->path); + if (ed->group) eina_stringshare_del(ed->group); + if (ed->parent) eina_stringshare_del(ed->parent); + ed->path = NULL; + ed->group = NULL; + if ((ed->actions) || (ed->pending_actions)) + { + _edje_animators = eina_list_remove(_edje_animators, ed); + } + EINA_LIST_FREE(ed->actions, runp) + free(runp); + EINA_LIST_FREE(ed->pending_actions, pp) + free(pp); + EINA_LIST_FREE(ed->callbacks, escb) + { + if (escb->signal) eina_stringshare_del(escb->signal); + if (escb->source) eina_stringshare_del(escb->source); + free(escb); + } + EINA_LIST_FREE(ed->color_classes, cc) + { + if (cc->name) eina_stringshare_del(cc->name); + free(cc); + } + EINA_LIST_FREE(ed->text_classes, tc) + { + if (tc->name) eina_stringshare_del(tc->name); + if (tc->font) eina_stringshare_del(tc->font); + free(tc); + } + EINA_LIST_FREE(ed->text_insert_filter_callbacks, cb) + { + eina_stringshare_del(cb->part); + free(cb); + } + + if (ed->members.text_class) + { + eina_hash_foreach(ed->members.text_class, _class_member_free, _edje_text_class_member_direct_del); + eina_hash_free(ed->members.text_class); + } + if (ed->members.color_class) + { + eina_hash_foreach(ed->members.color_class, _class_member_free, _edje_color_class_member_direct_del); + eina_hash_free(ed->members.color_class); + } + free(ed); +} + +void +_edje_clean_objects(Edje *ed) +{ + evas_object_del(ed->base.clipper); + ed->base.evas = NULL; + ed->obj = NULL; + ed->base.clipper = NULL; +} + +void +_edje_ref(Edje *ed) +{ + if (ed->references <= 0) return; + ed->references++; +} + +void +_edje_unref(Edje *ed) +{ + ed->references--; + if (ed->references == 0) _edje_del(ed); +} 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 @@ +#include "edje_private.h" + +/* States manipulations. */ + +typedef struct _Edje_State Edje_State; +struct _Edje_State +{ + size_t idx; + size_t pos; +}; + +struct _Edje_States +{ + size_t size; + Edje_State *states; + Eina_Bool *has; +}; + +static void +_edje_match_states_free(Edje_States *states, + size_t states_size) +{ + (void) states_size; + free(states); +} + +#define ALIGN(Size) \ + { \ + Size--; \ + Size |= sizeof (void*) - 1; \ + Size++; \ + }; + +static int +_edje_match_states_alloc(Edje_Patterns *ppat, int n) +{ + Edje_States *l; + + const size_t patterns_size = ppat->patterns_size; + const size_t patterns_max_length = ppat->max_length; + + const size_t array_len = (patterns_max_length + 1) * patterns_size; + + size_t states_size; + size_t has_size; + size_t states_has_size; + size_t struct_size; + + unsigned char *states; + unsigned char *has; + + int i; + + states_size = sizeof (*l->states) * array_len; + ALIGN(states_size); + + has_size = sizeof (*l->has) * array_len; + ALIGN(has_size); + + states_has_size = states_size + has_size; + + struct_size = sizeof (*l); + ALIGN(struct_size); + struct_size += states_has_size; + + l = malloc(n * struct_size); + if (!l) return 0; + + ppat->states = l; + ppat->states->size = 0; + + states = (unsigned char *) (l + n); + has = states + states_size; + + for (i = 0; i < n; ++i) + { + l[i].states = (Edje_State *) states; + l[i].has = (Eina_Bool *) has; + l[i].size = 0; + + memset(l[i].has, 0, has_size); + + states += states_has_size; + has += states_has_size; + } + + return 1; +} + +static void +_edje_match_states_insert(Edje_States *list, + size_t patterns_max_length, + size_t idx, + size_t pos) +{ + size_t i; + + i = (idx * (patterns_max_length + 1)) + pos; + + if (i < list->size) + { + if (list->has[i]) return; + } + list->has[i] = 1; + + i = list->size; + list->states[i].idx = idx; + list->states[i].pos = pos; + list->has[i] = 0; + list->size++; +} + +static void +_edje_match_states_clear(Edje_States *list, + __UNUSED__ size_t patterns_size, + __UNUSED__ size_t patterns_max_length) +{ + list->size = 0; +} + +/* Token manipulation. */ + +enum status +{ + patterns_not_found = 0, + patterns_found = 1, + patterns_syntax_error = 2 +}; + +static size_t +_edje_match_patterns_exec_class_token(enum status *status, + const char *cl_tok, + char c) +{ + if (! *cl_tok) + { + *status = patterns_syntax_error; + return 0; + } + else if (cl_tok[1] == '-' && cl_tok[2] != ']') + { + if (*cl_tok <= c && c <= cl_tok[2]) + *status = patterns_found; + return 3; + } + else + { + if (c == *cl_tok) + *status = patterns_found; + return 1; + } +} + +static Edje_Match_Error +_edje_match_patterns_exec_class_complement(const char *cl_tok, size_t *ret) +{ + switch (*cl_tok) + { + case 0: + return EDJE_MATCH_SYNTAX_ERROR; + + case '!': + *ret = 1; + return EDJE_MATCH_OK; + + default: + *ret = 0; + return EDJE_MATCH_OK; + } +} + +static Edje_Match_Error +_edje_match_patterns_exec_class(const char *cl, + char c, + size_t *ret) +{ + enum status status = patterns_not_found; + int pos = 1; + size_t neg; + + if (_edje_match_patterns_exec_class_complement(cl + 1, &neg) != EDJE_MATCH_OK) + return EDJE_MATCH_SYNTAX_ERROR; + + pos += neg; + + do + { + pos += _edje_match_patterns_exec_class_token(&status, cl + pos, c); + } + while (cl[pos] && cl[pos] != ']'); + + if (status == patterns_syntax_error || ! cl[pos]) + return EDJE_MATCH_SYNTAX_ERROR; + + if (status == patterns_found) + *ret = neg ? 0 : pos + 1; + else + *ret = neg ? pos + 1 : 0; + + return EDJE_MATCH_OK; +} + +static Edje_Match_Error +_edje_match_patterns_exec_token(const char *tok, + char c, + size_t *ret) +{ + switch (*tok) + { + case '\\': + if (tok[1]) + { + *ret = tok[1] == c ? 2 : 0; + return EDJE_MATCH_OK; + } + return EDJE_MATCH_SYNTAX_ERROR; + + case '?': + *ret = 1; + return EDJE_MATCH_OK; + + case '[': + return _edje_match_patterns_exec_class(tok, c, ret); + + default: + *ret = *tok == c ? 1 : 0; + return EDJE_MATCH_OK; + } +} + +static void +_edje_match_patterns_exec_init_states(Edje_States *states, + size_t patterns_size, + size_t patterns_max_length) +{ + size_t i; + + states->size = patterns_size; + + for (i = 0; i < patterns_size; ++i) + { + states->states[i].idx = i; + states->states[i].pos = 0; + states->has[i * (patterns_max_length + 1)] = 1; + } +} + +/* Exported function. */ + +#define EDJE_MATCH_INIT_LIST(Func, Type, Source, Show) \ + Edje_Patterns* \ + Func(const Eina_List *lst) \ + { \ + Edje_Patterns *r; \ + size_t i; \ + \ + if (!lst || eina_list_count(lst) <= 0) \ + return NULL; \ + \ + r = malloc(sizeof (Edje_Patterns) + \ + eina_list_count(lst) \ + * sizeof(*r->finals) \ + * sizeof(*r->patterns)); \ + if (!r) return NULL; \ + \ + r->ref = 1; \ + r->delete_me = 0; \ + r->patterns_size = eina_list_count(lst); \ + r->max_length = 0; \ + r->patterns = (const char **) r->finals + r->patterns_size + 1; \ + \ + for (i = 0; lst; ++i) \ + { \ + const char *str; \ + Type *data; \ + size_t j; \ + int special = 0; \ + \ + data = eina_list_data_get(lst); \ + if (!data) \ + { \ + free(r); \ + return NULL; \ + } \ + \ + str = data->Source; \ + if (!str) str = ""; \ + r->patterns[i] = str; \ + \ + if (Show) \ + INF("%lu [%s]", (unsigned long)i, str); \ + \ + r->finals[i] = 0; \ + for (j = 0; str[j]; ++j) \ + if (str[j] != '*') \ + { \ + r->finals[i] = j + 1; \ + special++; \ + } \ + j += special ? special + 1 : 0; \ + \ + if (j > r->max_length) \ + r->max_length = j; \ + \ + lst = eina_list_next(lst); \ + } \ + \ + if (!_edje_match_states_alloc(r, 2)) \ + { \ + free(r); \ + return NULL; \ + } \ + \ + return r; \ + } + +#define EDJE_MATCH_INIT_ARRAY(Func, Type, Source, Show) \ + Edje_Patterns* \ + Func(Type * const *lst, unsigned int count) \ + { \ + Edje_Patterns *r; \ + size_t i; \ + \ + if (!lst || count == 0) \ + return NULL; \ + \ + r = malloc(sizeof (Edje_Patterns) + \ + count \ + * sizeof(*r->finals) \ + * sizeof(*r->patterns)); \ + if (!r) return NULL; \ + \ + r->ref = 1; \ + r->delete_me = 0; \ + r->patterns_size = count; \ + r->max_length = 0; \ + r->patterns = (const char **) r->finals + r->patterns_size + 1; \ + \ + for (i = 0; i < count; ++i) \ + { \ + const char *str; \ + size_t j; \ + int special = 0; \ + \ + if (!lst[i]) \ + { \ + free(r); \ + return NULL; \ + } \ + \ + str = lst[i]->Source; \ + if (!str) str = ""; \ + r->patterns[i] = str; \ + \ + if (Show) \ + INF("%lu [%s]", (unsigned long)i, str); \ + \ + r->finals[i] = 0; \ + for (j = 0; str[j]; ++j) \ + if (str[j] != '*') \ + { \ + r->finals[i] = j + 1; \ + special++; \ + } \ + j += special ? special + 1 : 0; \ + \ + if (j > r->max_length) \ + r->max_length = j; \ + } \ + \ + if (!_edje_match_states_alloc(r, 2)) \ + { \ + free(r); \ + return NULL; \ + } \ + \ + return r; \ + } + +EDJE_MATCH_INIT_LIST(edje_match_collection_dir_init, + Edje_Part_Collection_Directory_Entry, + entry, 0); +EDJE_MATCH_INIT_ARRAY(edje_match_programs_signal_init, + Edje_Program, + signal, 0); +EDJE_MATCH_INIT_ARRAY(edje_match_programs_source_init, + Edje_Program, + source, 0); +EDJE_MATCH_INIT_LIST(edje_match_callback_signal_init, + Edje_Signal_Callback, + signal, 0); +EDJE_MATCH_INIT_LIST(edje_match_callback_source_init, + Edje_Signal_Callback, + source, 0); + +static Eina_Bool +_edje_match_collection_dir_exec_finals(const size_t *finals, + const Edje_States *states) +{ + size_t i; + + for (i = 0; i < states->size; ++i) + { + if (states->states[i].pos >= finals[states->states[i].idx]) + return EINA_TRUE; + } + return EINA_FALSE; +} + +static Eina_Bool +edje_match_programs_exec_check_finals(const size_t *signal_finals, + const size_t *source_finals, + const Edje_States *signal_states, + const Edje_States *source_states, + Edje_Program **programs, + Eina_Bool (*func)(Edje_Program *pr, void *data), + void *data, + Eina_Bool prop __UNUSED__) +{ + size_t i; + size_t j; + + /* when not enought memory, they could be NULL */ + if (!signal_finals || !source_finals) return EINA_TRUE; + + for (i = 0; i < signal_states->size; ++i) + { + if (signal_states->states[i].pos >= signal_finals[signal_states->states[i].idx]) + { + for (j = 0; j < source_states->size; ++j) + { + if (signal_states->states[i].idx == source_states->states[j].idx + && source_states->states[j].pos >= source_finals[source_states->states[j].idx]) + { + Edje_Program *pr; + + pr = programs[signal_states->states[i].idx]; + if (pr) + { + if (func(pr, data)) + return EINA_FALSE; + } + } + } + } + } + + return EINA_TRUE; +} + +static int +edje_match_callback_exec_check_finals(const Edje_Patterns *singal_ppat, + const Edje_Patterns *source_ppat, + const size_t *signal_finals, + const size_t *source_finals, + const Edje_States *signal_states, + const Edje_States *source_states, + const char *sig, + const char *source, + Eina_List *callbacks, + Edje *ed, + Eina_Bool prop + ) +{ + size_t i; + size_t j; + int r = 1; + + for (i = 0; i < signal_states->size; ++i) + { + if (signal_states->states[i].pos >= signal_finals[signal_states->states[i].idx]) + { + for (j = 0; j < source_states->size; ++j) + { + if (signal_states->states[i].idx == source_states->states[j].idx + && source_states->states[j].pos >= source_finals[source_states->states[j].idx]) + { + Edje_Signal_Callback *escb; + + escb = eina_list_nth(callbacks, signal_states->states[i].idx); + if (escb) + { + if ((prop) && (escb->propagate)) continue; + if ((!escb->just_added) + && (!escb->delete_me)) + { + escb->func(escb->data, ed->obj, sig, source); + r = 2; + } + if (_edje_block_break(ed)) + return 0; + if ((singal_ppat->delete_me) || (source_ppat->delete_me)) + return 0; + } + } + } + } + } + + return r; +} + + +static Edje_States* +_edje_match_fn(const Edje_Patterns *ppat, + const char *string, + Edje_States *states) +{ + Edje_States *new_states = states + 1; + const char *c; + + for (c = string; *c && states->size; ++c) + { + size_t i; + + _edje_match_states_clear(new_states, ppat->patterns_size, ppat->max_length); + + for (i = 0; i < states->size; ++i) + { + const size_t idx = states->states[i].idx; + const size_t pos = states->states[i].pos; + + if (!ppat->patterns[idx][pos]) + continue; + else if (ppat->patterns[idx][pos] == '*') + { + _edje_match_states_insert(states, ppat->max_length, idx, pos + 1); + _edje_match_states_insert(new_states, ppat->max_length, idx, pos); + } + else + { + size_t m; + + if (_edje_match_patterns_exec_token(ppat->patterns[idx] + pos, + *c, + &m) != EDJE_MATCH_OK) + return NULL; + + if (m) + _edje_match_states_insert(new_states, ppat->max_length, idx, pos + m); + } + } + { + Edje_States *tmp = states; + + states = new_states; + new_states = tmp; + } + } + + return states; +} + +Eina_Bool +edje_match_collection_dir_exec(const Edje_Patterns *ppat, + const char *string) +{ + Edje_States *result; + Eina_Bool r = EINA_FALSE; + + /* under high memory presure, it could be NULL */ + if (!ppat) return EINA_FALSE; + + _edje_match_patterns_exec_init_states(ppat->states, ppat->patterns_size, ppat->max_length); + + result = _edje_match_fn(ppat, string, ppat->states); + + if (result) + r = _edje_match_collection_dir_exec_finals(ppat->finals, result); + + return r; +} + +Eina_Bool +edje_match_programs_exec(const Edje_Patterns *ppat_signal, + const Edje_Patterns *ppat_source, + const char *sig, + const char *source, + Edje_Program **programs, + Eina_Bool (*func)(Edje_Program *pr, void *data), + void *data, + Eina_Bool prop) +{ + Edje_States *signal_result; + Edje_States *source_result; + Eina_Bool r = EINA_FALSE; + + /* under high memory presure, they could be NULL */ + if (!ppat_source || !ppat_signal) return EINA_FALSE; + + _edje_match_patterns_exec_init_states(ppat_signal->states, + ppat_signal->patterns_size, + ppat_signal->max_length); + _edje_match_patterns_exec_init_states(ppat_source->states, + ppat_source->patterns_size, + ppat_source->max_length); + + signal_result = _edje_match_fn(ppat_signal, sig, ppat_signal->states); + source_result = _edje_match_fn(ppat_source, source, ppat_source->states); + + if (signal_result && source_result) + r = edje_match_programs_exec_check_finals(ppat_signal->finals, + ppat_source->finals, + signal_result, + source_result, + programs, + func, + data, + prop); + return r; +} + +int +edje_match_callback_exec(Edje_Patterns *ppat_signal, + Edje_Patterns *ppat_source, + const char *sig, + const char *source, + Eina_List *callbacks, + Edje *ed, + Eina_Bool prop + ) +{ + Edje_States *signal_result; + Edje_States *source_result; + int r = 0; + + /* under high memory presure, they could be NULL */ + if (!ppat_source || !ppat_signal) return 0; + + ppat_signal->ref++; + ppat_source->ref++; + _edje_match_patterns_exec_init_states(ppat_signal->states, + ppat_signal->patterns_size, + ppat_signal->max_length); + _edje_match_patterns_exec_init_states(ppat_source->states, + ppat_source->patterns_size, + ppat_source->max_length); + + signal_result = _edje_match_fn(ppat_signal, sig, ppat_signal->states); + source_result = _edje_match_fn(ppat_source, source, ppat_source->states); + + if (signal_result && source_result) + r = edje_match_callback_exec_check_finals(ppat_signal, + ppat_source, + ppat_signal->finals, + ppat_source->finals, + signal_result, + source_result, + sig, + source, + callbacks, + ed, + prop); + ppat_signal->ref--; + ppat_source->ref--; + if (ppat_signal->ref <= 0) edje_match_patterns_free(ppat_signal); + if (ppat_source->ref <= 0) edje_match_patterns_free(ppat_source); + return r; +} + +void +edje_match_patterns_free(Edje_Patterns *ppat) +{ + if (!ppat) return ; + + ppat->delete_me = 1; + ppat->ref--; + if (ppat->ref > 0) return; + _edje_match_states_free(ppat->states, 2); + free(ppat); +} + +void +_edje_signals_sources_patterns_clean(Edje_Signals_Sources_Patterns *ssp) +{ + if (!ssp->signals_patterns) + return; + + edje_match_patterns_free(ssp->signals_patterns); + edje_match_patterns_free(ssp->sources_patterns); + ssp->signals_patterns = NULL; + ssp->sources_patterns = NULL; +} + +static Eina_Rbtree_Direction +_edje_signal_source_node_cmp(const Edje_Signal_Source_Char *n1, + const Edje_Signal_Source_Char *n2, + __UNUSED__ void *data) +{ + int cmp; + + cmp = strcmp(n1->signal, n2->signal); + if (cmp) return cmp < 0 ? EINA_RBTREE_LEFT : EINA_RBTREE_RIGHT; + + return strcmp(n1->source, n2->source) < 0 ? EINA_RBTREE_LEFT : EINA_RBTREE_RIGHT; +} + +static int +_edje_signal_source_key_cmp(const Edje_Signal_Source_Char *node, + const char *sig, + __UNUSED__ int length, + const char *source) +{ + int cmp; + + cmp = strcmp(node->signal, sig); + if (cmp) return cmp; + + return strcmp(node->source, source); +} + + +Eina_List * +edje_match_program_hash_build(Edje_Program * const *programs, + unsigned int count, + Eina_Rbtree **tree) +{ + Eina_List *result = NULL; + Eina_Rbtree *new = NULL; + unsigned int i; + + for (i = 0; i < count; ++i) + { + if (programs[i]->signal && !strpbrk(programs[i]->signal, "*?[\\") + && programs[i]->source && !strpbrk(programs[i]->source, "*?[\\")) + { + Edje_Signal_Source_Char *item; + + item = (Edje_Signal_Source_Char*) eina_rbtree_inline_lookup(new, programs[i]->signal, 0, + EINA_RBTREE_CMP_KEY_CB(_edje_signal_source_key_cmp), programs[i]->source); + if (!item) + { + item = malloc(sizeof (Edje_Signal_Source_Char)); + if (!item) continue; + + item->signal = programs[i]->signal; + item->source = programs[i]->source; + item->list = NULL; + + new = eina_rbtree_inline_insert(new, EINA_RBTREE_GET(item), + EINA_RBTREE_CMP_NODE_CB(_edje_signal_source_node_cmp), NULL); + } + + item->list = eina_list_prepend(item->list, programs[i]); + } + else + result = eina_list_prepend(result, programs[i]); + } + + *tree = new; + return result; +} + +Eina_List * +edje_match_callback_hash_build(const Eina_List *callbacks, + Eina_Rbtree **tree) +{ + Eina_List *result = NULL; + Eina_Rbtree *new = NULL; + Edje_Signal_Callback *callback; + const Eina_List *l; + + EINA_LIST_FOREACH(callbacks, l, callback) + { + if (callback->signal && !strpbrk(callback->signal, "*?[\\") + && callback->source && !strpbrk(callback->source, "*?[\\")) + { + Edje_Signal_Source_Char *item; + + item = (Edje_Signal_Source_Char*) eina_rbtree_inline_lookup(new, callback->signal, 0, + EINA_RBTREE_CMP_KEY_CB(_edje_signal_source_key_cmp), callback->source); + if (!item) + { + item = malloc(sizeof (Edje_Signal_Source_Char)); + if (!item) continue; + + item->signal = callback->signal; + item->source = callback->source; + item->list = NULL; + + new = eina_rbtree_inline_insert(new, EINA_RBTREE_GET(item), + EINA_RBTREE_CMP_NODE_CB(_edje_signal_source_node_cmp), NULL); + } + + item->list = eina_list_prepend(item->list, callback); + } + else + result = eina_list_prepend(result, callback); + } + + *tree = new; + return result; +} + +const Eina_List * +edje_match_signal_source_hash_get(const char *sig, + const char *source, + const Eina_Rbtree *tree) +{ + Edje_Signal_Source_Char *lookup; + + lookup = (Edje_Signal_Source_Char*) eina_rbtree_inline_lookup(tree, sig, 0, + EINA_RBTREE_CMP_KEY_CB(_edje_signal_source_key_cmp), source); + + if (lookup) return lookup->list; + return NULL; +} + +void +edje_match_signal_source_free(Edje_Signal_Source_Char *key, __UNUSED__ void *data) +{ + eina_list_free(key->list); + free(key); +} 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 @@ +#include "edje_private.h" + +static void _edje_object_message_popornot_send(Evas_Object *obj, Edje_Message_Type type, int id, void *msg, Eina_Bool prop); + +static int _injob = 0; +static Ecore_Job *_job = NULL; +static Ecore_Timer *_job_loss_timer = NULL; + +static Eina_List *msgq = NULL; +static Eina_List *tmp_msgq = NULL; +static int tmp_msgq_processing = 0; +static int tmp_msgq_restart = 0; + +/*============================================================================* + * API * + *============================================================================*/ + +static void +_edje_object_message_popornot_send(Evas_Object *obj, Edje_Message_Type type, int id, void *msg, Eina_Bool prop) +{ + Edje *ed; + Eina_List *l; + Evas_Object *o; + + ed = _edje_fetch(obj); + if (!ed) return; + _edje_message_propornot_send(ed, EDJE_QUEUE_SCRIPT, type, id, msg, prop); + EINA_LIST_FOREACH(ed->subobjs, l, o) + { + _edje_object_message_popornot_send(o, type, id, msg, EINA_TRUE); + } +} + +EAPI void +edje_object_message_send(Evas_Object *obj, Edje_Message_Type type, int id, void *msg) +{ + _edje_object_message_popornot_send(obj, type, id, msg, EINA_FALSE); +} + + +EAPI void +edje_object_message_handler_set(Evas_Object *obj, Edje_Message_Handler_Cb func, void *data) +{ + Edje *ed; + + ed = _edje_fetch(obj); + if (!ed) return; + _edje_message_cb_set(ed, func, data); +} + + +EAPI void +edje_object_message_signal_process(Evas_Object *obj) +{ + Eina_List *l, *ln, *tmpq = NULL; + Edje *ed; + Edje_Message *em; + int gotos = 0; + + ed = _edje_fetch(obj); + if (!ed) return; + + for (l = msgq; l; ) + { + ln = l->next; + em = l->data; + if (em->edje == ed) + { + tmpq = eina_list_append(tmpq, em); + msgq = eina_list_remove_list(msgq, l); + } + l = ln; + } + /* a temporary message queue */ + if (tmp_msgq) + { + while (tmpq) + { + tmp_msgq = eina_list_append(tmp_msgq, tmpq->data); + tmpq = eina_list_remove_list(tmpq, tmpq); + } + } + else + { + tmp_msgq = tmpq; + tmpq = NULL; + } + + tmp_msgq_processing++; +again: + EINA_LIST_FOREACH_SAFE(tmp_msgq, l, ln, em) + { + if (em->edje != ed) continue; + tmp_msgq = eina_list_remove_list(tmp_msgq, l); + if (!ed->delete_me) + { + ed->processing_messages++; + _edje_message_process(em); + _edje_message_free(em); + ed->processing_messages--; + } + else + _edje_message_free(em); + if (ed->processing_messages == 0) + { + if (ed->delete_me) _edje_del(ed); + } + // if some child callback in _edje_message_process called + // edje_object_message_signal_process() or + // edje_message_signal_process() then those will mark the restart + // flag when they finish - it mabsicammyt means tmp_msgq and + // any item in it has potentially become invalid - so that means l + // and ln could be rogue pointers, so start again from the beginning + // and skip anything that is not this object and process only what is. + // to avoid self-feeding loops allow a max of 1024 loops. + if (tmp_msgq_restart) + { + tmp_msgq_restart = 0; + gotos++; + if (gotos < 1024) goto again; + else + { + WRN("Edje is in a self-feeding message loop (> 1024 gotos needed in a row)"); + goto end; + } + } + } +end: + tmp_msgq_processing--; + if (tmp_msgq_processing == 0) + tmp_msgq_restart = 0; + else + tmp_msgq_restart = 1; +} + + +EAPI void +edje_message_signal_process(void) +{ + _edje_message_queue_process(); +} + + +static Eina_Bool +_edje_dummy_timer(void *data __UNUSED__) +{ + return ECORE_CALLBACK_CANCEL; +} + +static void +_edje_job(void *data __UNUSED__) +{ + if (_job_loss_timer) + { + ecore_timer_del(_job_loss_timer); + _job_loss_timer = NULL; + } + _job = NULL; + _injob++; + _edje_message_queue_process(); + _injob--; +} + +static Eina_Bool +_edje_job_loss_timer(void *data __UNUSED__) +{ + _job_loss_timer = NULL; + if (!_job) + { + _job = ecore_job_add(_edje_job, NULL); + } + return ECORE_CALLBACK_CANCEL; +} + +void +_edje_message_init(void) +{ +} + +void +_edje_message_shutdown(void) +{ + _edje_message_queue_clear(); + if (_job_loss_timer) + { + ecore_timer_del(_job_loss_timer); + _job_loss_timer = NULL; + } + if (_job) + { + ecore_job_del(_job); + _job = NULL; + } +} + +void +_edje_message_cb_set(Edje *ed, void (*func) (void *data, Evas_Object *obj, Edje_Message_Type type, int id, void *msg), void *data) +{ + Eina_List *l; + Evas_Object *o; + + ed->message.func = func; + ed->message.data = data; + EINA_LIST_FOREACH(ed->subobjs, l, o) + { + Edje *edj2 = _edje_fetch(o); + if (!edj2) continue; + _edje_message_cb_set(edj2, func, data); + } +} + +Edje_Message * +_edje_message_new(Edje *ed, Edje_Queue queue, Edje_Message_Type type, int id) +{ + Edje_Message *em; + + em = calloc(1, sizeof(Edje_Message)); + if (!em) return NULL; + em->edje = ed; + em->queue = queue; + em->type = type; + em->id = id; + em->edje->message.num++; + return em; +} + +void +_edje_message_free(Edje_Message *em) +{ + if (em->msg) + { + int i; + + switch (em->type) + { + case EDJE_MESSAGE_STRING: + { + Edje_Message_String *emsg; + + emsg = (Edje_Message_String *)em->msg; + free(emsg->str); + free(emsg); + } + break; + case EDJE_MESSAGE_INT: + { + Edje_Message_Int *emsg; + + emsg = (Edje_Message_Int *)em->msg; + free(emsg); + } + break; + case EDJE_MESSAGE_FLOAT: + { + Edje_Message_Float *emsg; + + emsg = (Edje_Message_Float *)em->msg; + free(emsg); + } + break; + case EDJE_MESSAGE_INT_SET: + { + Edje_Message_Int_Set *emsg; + + emsg = (Edje_Message_Int_Set *)em->msg; + free(emsg); + } + break; + case EDJE_MESSAGE_FLOAT_SET: + { + Edje_Message_Float_Set *emsg; + + emsg = (Edje_Message_Float_Set *)em->msg; + free(emsg); + } + break; + case EDJE_MESSAGE_STRING_FLOAT: + { + Edje_Message_String_Float *emsg; + + emsg = (Edje_Message_String_Float *)em->msg; + free(emsg->str); + free(emsg); + } + break; + case EDJE_MESSAGE_STRING_INT: + { + Edje_Message_String_Int *emsg; + + emsg = (Edje_Message_String_Int *)em->msg; + free(emsg->str); + free(emsg); + } + break; + case EDJE_MESSAGE_STRING_FLOAT_SET: + { + Edje_Message_String_Float_Set *emsg; + + emsg = (Edje_Message_String_Float_Set *)em->msg; + free(emsg->str); + free(emsg); + } + break; + case EDJE_MESSAGE_STRING_INT_SET: + { + Edje_Message_String_Int_Set *emsg; + + emsg = (Edje_Message_String_Int_Set *)em->msg; + free(emsg->str); + free(emsg); + } + break; + case EDJE_MESSAGE_SIGNAL: + { + Edje_Message_Signal *emsg; + + emsg = (Edje_Message_Signal *)em->msg; + if (emsg->sig) eina_stringshare_del(emsg->sig); + if (emsg->src) eina_stringshare_del(emsg->src); + if (emsg->data && (--(emsg->data->ref) == 0)) + { + if (emsg->data->free_func) + { + emsg->data->free_func(emsg->data->data); + } + free(emsg->data); + } + free(emsg); + } + break; + case EDJE_MESSAGE_STRING_SET: + { + Edje_Message_String_Set *emsg; + + emsg = (Edje_Message_String_Set *)em->msg; + for (i = 0; i < emsg->count; i++) + free(emsg->str[i]); + free(emsg); + } + break; + case EDJE_MESSAGE_NONE: + default: + break; + } + } + free(em); +} + +void +_edje_message_propornot_send(Edje *ed, Edje_Queue queue, Edje_Message_Type type, int id, void *emsg, Eina_Bool prop) +{ + /* FIXME: check all malloc & strdup fails and gracefully unroll and exit */ + Edje_Message *em; + int i; + unsigned char *msg = NULL; + + em = _edje_message_new(ed, queue, type, id); + if (!em) return; + em->propagated = prop; + if (_job) + { + ecore_job_del(_job); + _job = NULL; + } + if (_injob > 0) + { + if (_job_loss_timer) ecore_timer_del(_job_loss_timer); + _job_loss_timer = ecore_timer_add(0.001, _edje_job_loss_timer, NULL); + } + else + { + if (!_job) + { + _job = ecore_job_add(_edje_job, NULL); + } + if (_job_loss_timer) + { + ecore_timer_del(_job_loss_timer); + _job_loss_timer = NULL; + } + } + switch (em->type) + { + case EDJE_MESSAGE_NONE: + break; + case EDJE_MESSAGE_SIGNAL: + { + Edje_Message_Signal *emsg2, *emsg3; + + emsg2 = (Edje_Message_Signal *)emsg; + emsg3 = calloc(1, sizeof(Edje_Message_Signal)); + if (emsg2->sig) emsg3->sig = eina_stringshare_add(emsg2->sig); + if (emsg2->src) emsg3->src = eina_stringshare_add(emsg2->src); + if (emsg2->data) + { + emsg3->data = emsg2->data; + emsg3->data->ref++; + } + msg = (unsigned char *)emsg3; + } + break; + case EDJE_MESSAGE_STRING: + { + Edje_Message_String *emsg2, *emsg3; + + emsg2 = (Edje_Message_String *)emsg; + + emsg3 = malloc(sizeof(Edje_Message_String)); + emsg3->str = strdup(emsg2->str); + msg = (unsigned char *)emsg3; + } + break; + case EDJE_MESSAGE_INT: + { + Edje_Message_Int *emsg2, *emsg3; + + emsg2 = (Edje_Message_Int *)emsg; + emsg3 = malloc(sizeof(Edje_Message_Int)); + emsg3->val = emsg2->val; + msg = (unsigned char *)emsg3; + } + break; + case EDJE_MESSAGE_FLOAT: + { + Edje_Message_Float *emsg2, *emsg3; + + emsg2 = (Edje_Message_Float *)emsg; + emsg3 = malloc(sizeof(Edje_Message_Float)); + emsg3->val = emsg2->val; + msg = (unsigned char *)emsg3; + } + break; + case EDJE_MESSAGE_STRING_SET: + { + Edje_Message_String_Set *emsg2, *emsg3; + + emsg2 = (Edje_Message_String_Set *)emsg; + emsg3 = malloc(sizeof(Edje_Message_String_Set) + ((emsg2->count - 1) * sizeof(char *))); + emsg3->count = emsg2->count; + for (i = 0; i < emsg3->count; i++) + emsg3->str[i] = strdup(emsg2->str[i]); + msg = (unsigned char *)emsg3; + } + break; + case EDJE_MESSAGE_INT_SET: + { + Edje_Message_Int_Set *emsg2, *emsg3; + + emsg2 = (Edje_Message_Int_Set *)emsg; + emsg3 = malloc(sizeof(Edje_Message_Int_Set) + ((emsg2->count - 1) * sizeof(int))); + emsg3->count = emsg2->count; + for (i = 0; i < emsg3->count; i++) + emsg3->val[i] = emsg2->val[i]; + msg = (unsigned char *)emsg3; + } + break; + case EDJE_MESSAGE_FLOAT_SET: + { + Edje_Message_Float_Set *emsg2, *emsg3; + + emsg2 = (Edje_Message_Float_Set *)emsg; + emsg3 = malloc(sizeof(Edje_Message_Float_Set) + ((emsg2->count - 1) * sizeof(double))); + emsg3->count = emsg2->count; + for (i = 0; i < emsg3->count; i++) + emsg3->val[i] = emsg2->val[i]; + msg = (unsigned char *)emsg3; + } + break; + case EDJE_MESSAGE_STRING_INT: + { + Edje_Message_String_Int *emsg2, *emsg3; + + emsg2 = (Edje_Message_String_Int *)emsg; + emsg3 = malloc(sizeof(Edje_Message_String_Int)); + emsg3->str = strdup(emsg2->str); + emsg3->val = emsg2->val; + msg = (unsigned char *)emsg3; + } + break; + case EDJE_MESSAGE_STRING_FLOAT: + { + Edje_Message_String_Float *emsg2, *emsg3; + + emsg2 = (Edje_Message_String_Float *)emsg; + emsg3 = malloc(sizeof(Edje_Message_String_Float)); + emsg3->str = strdup(emsg2->str); + emsg3->val = emsg2->val; + msg = (unsigned char *)emsg3; + } + break; + case EDJE_MESSAGE_STRING_INT_SET: + { + Edje_Message_String_Int_Set *emsg2, *emsg3; + + emsg2 = (Edje_Message_String_Int_Set *)emsg; + emsg3 = malloc(sizeof(Edje_Message_String_Int_Set) + ((emsg2->count - 1) * sizeof(int))); + emsg3->str = strdup(emsg2->str); + emsg3->count = emsg2->count; + for (i = 0; i < emsg3->count; i++) + emsg3->val[i] = emsg2->val[i]; + msg = (unsigned char *)emsg3; + } + break; + case EDJE_MESSAGE_STRING_FLOAT_SET: + { + Edje_Message_String_Float_Set *emsg2, *emsg3; + + emsg2 = (Edje_Message_String_Float_Set *)emsg; + emsg3 = malloc(sizeof(Edje_Message_String_Float_Set) + ((emsg2->count - 1) * sizeof(double))); + emsg3->str = strdup(emsg2->str); + emsg3->count = emsg2->count; + for (i = 0; i < emsg3->count; i++) + emsg3->val[i] = emsg2->val[i]; + msg = (unsigned char *)emsg3; + } + break; + default: + break; + } + + em->msg = msg; + msgq = eina_list_append(msgq, em); +} + +void +_edje_message_send(Edje *ed, Edje_Queue queue, Edje_Message_Type type, int id, void *emsg) +{ + _edje_message_propornot_send(ed, queue, type, id, emsg, EINA_FALSE); +} + +void +_edje_message_parameters_push(Edje_Message *em) +{ + int i; + + /* these params ALWAYS go on */ + /* first param is the message type - always */ + embryo_parameter_cell_push(em->edje->collection->script, + (Embryo_Cell)em->type); + /* 2nd param is the integer of the event id - always there */ + embryo_parameter_cell_push(em->edje->collection->script, + (Embryo_Cell)em->id); + /* the rest is varags of whatever is in the msg */ + switch (em->type) + { + case EDJE_MESSAGE_NONE: + break; + case EDJE_MESSAGE_STRING: + embryo_parameter_string_push(em->edje->collection->script, + ((Edje_Message_String *)em->msg)->str); + break; + case EDJE_MESSAGE_INT: + { + Embryo_Cell v; + + v = (Embryo_Cell)((Edje_Message_Int *)em->msg)->val; + embryo_parameter_cell_array_push(em->edje->collection->script, &v, 1); + } + break; + case EDJE_MESSAGE_FLOAT: + { + Embryo_Cell v; + float fv; + + fv = ((Edje_Message_Float *)em->msg)->val; + v = EMBRYO_FLOAT_TO_CELL(fv); + embryo_parameter_cell_array_push(em->edje->collection->script, &v, 1); + } + break; + case EDJE_MESSAGE_STRING_SET: + for (i = 0; i < ((Edje_Message_String_Set *)em->msg)->count; i++) + embryo_parameter_string_push(em->edje->collection->script, + ((Edje_Message_String_Set *)em->msg)->str[i]); + break; + case EDJE_MESSAGE_INT_SET: + for (i = 0; i < ((Edje_Message_Int_Set *)em->msg)->count; i++) + { + Embryo_Cell v; + + v = (Embryo_Cell)((Edje_Message_Int_Set *)em->msg)->val[i]; + embryo_parameter_cell_array_push(em->edje->collection->script, &v, 1); + } + break; + case EDJE_MESSAGE_FLOAT_SET: + for (i = 0; i < ((Edje_Message_Float_Set *)em->msg)->count; i++) + { + Embryo_Cell v; + float fv; + + fv = ((Edje_Message_Float_Set *)em->msg)->val[i]; + v = EMBRYO_FLOAT_TO_CELL(fv); + embryo_parameter_cell_array_push(em->edje->collection->script, &v, 1); + } + break; + case EDJE_MESSAGE_STRING_INT: + embryo_parameter_string_push(em->edje->collection->script, + ((Edje_Message_String_Int *)em->msg)->str); + { + Embryo_Cell v; + + v = (Embryo_Cell)((Edje_Message_String_Int *)em->msg)->val; + embryo_parameter_cell_array_push(em->edje->collection->script, &v, 1); + } + break; + case EDJE_MESSAGE_STRING_FLOAT: + embryo_parameter_string_push(em->edje->collection->script, + ((Edje_Message_String_Float *)em->msg)->str); + { + Embryo_Cell v; + float fv; + + fv = ((Edje_Message_String_Float *)em->msg)->val; + v = EMBRYO_FLOAT_TO_CELL(fv); + embryo_parameter_cell_array_push(em->edje->collection->script, &v, 1); + } + break; + case EDJE_MESSAGE_STRING_INT_SET: + embryo_parameter_string_push(em->edje->collection->script, + ((Edje_Message_String_Int_Set *)em->msg)->str); + for (i = 0; i < ((Edje_Message_String_Int_Set *)em->msg)->count; i++) + { + Embryo_Cell v; + + v = (Embryo_Cell)((Edje_Message_String_Int_Set *)em->msg)->val[i]; + embryo_parameter_cell_array_push(em->edje->collection->script, &v, 1); + } + break; + case EDJE_MESSAGE_STRING_FLOAT_SET: + embryo_parameter_string_push(em->edje->collection->script, + ((Edje_Message_String_Float_Set *)em->msg)->str); + for (i = 0; i < ((Edje_Message_String_Float_Set *)em->msg)->count; i++) + { + Embryo_Cell v; + float fv; + + fv = ((Edje_Message_String_Float_Set *)em->msg)->val[i]; + v = EMBRYO_FLOAT_TO_CELL(fv); + embryo_parameter_cell_array_push(em->edje->collection->script, &v, 1); + } + break; + default: + break; + } +} + +void +_edje_message_process(Edje_Message *em) +{ + Embryo_Function fn; + void *pdata; + int ret; + + /* signals are only handled one way */ + if (em->type == EDJE_MESSAGE_SIGNAL) + { + _edje_emit_handle(em->edje, + ((Edje_Message_Signal *)em->msg)->sig, + ((Edje_Message_Signal *)em->msg)->src, + ((Edje_Message_Signal *)em->msg)->data, + em->propagated); + return; + } + /* if this has been queued up for the app then just call the callback */ + if (em->queue == EDJE_QUEUE_APP) + { + if (em->edje->message.func) + em->edje->message.func(em->edje->message.data, em->edje->obj, + em->type, em->id, em->msg); + return; + } + /* now this message is destined for the script message handler fn */ + if (!(em->edje->collection)) return; + if ((em->edje->collection->script) && _edje_script_only (em->edje)) + { + _edje_script_only_message(em->edje, em); + return; + } + if (em->edje->L) + { + _edje_lua_script_only_message(em->edje, em); + return; + } + fn = embryo_program_function_find(em->edje->collection->script, "message"); + if (fn == EMBRYO_FUNCTION_NONE) return; + /* reset the engine */ + _edje_embryo_script_reset(em->edje); + + _edje_message_parameters_push(em); + + embryo_program_vm_push(em->edje->collection->script); + _edje_embryo_globals_init(em->edje); + pdata = embryo_program_data_get(em->edje->collection->script); + embryo_program_data_set(em->edje->collection->script, em->edje); + embryo_program_max_cycle_run_set(em->edje->collection->script, 5000000); + ret = embryo_program_run(em->edje->collection->script, fn); + if (ret == EMBRYO_PROGRAM_FAIL) + { + ERR("ERROR with embryo script. " + "OBJECT NAME: '%s', " + "OBJECT FILE: '%s', " + "ENTRY POINT: '%s', " + "ERROR: '%s'", + em->edje->collection->part, + em->edje->file->path, + "message", + embryo_error_string_get(embryo_program_error_get(em->edje->collection->script))); + } + else if (ret == EMBRYO_PROGRAM_TOOLONG) + { + ERR("ERROR with embryo script. " + "OBJECT NAME: '%s', " + "OBJECT FILE: '%s', " + "ENTRY POINT: '%s', " + "ERROR: 'Script exceeded maximum allowed cycle count of %i'", + em->edje->collection->part, + em->edje->file->path, + "message", + embryo_program_max_cycle_run_get(em->edje->collection->script)); + } + + embryo_program_data_set(em->edje->collection->script, pdata); + embryo_program_vm_pop(em->edje->collection->script); +} + +void +_edje_message_queue_process(void) +{ + int i; + + if (!msgq) return; + + /* allow the message queue to feed itself up to 8 times before forcing */ + /* us to go back to normal processing and let a 0 timeout deal with it */ + for (i = 0; (i < 8) && (msgq); i++) + { + /* a temporary message queue */ + if (tmp_msgq) + { + while (msgq) + { + tmp_msgq = eina_list_append(tmp_msgq, msgq->data); + msgq = eina_list_remove_list(msgq, msgq); + } + } + else + { + tmp_msgq = msgq; + msgq = NULL; + } + + tmp_msgq_processing++; + while (tmp_msgq) + { + Edje_Message *em; + Edje *ed; + + em = tmp_msgq->data; + ed = em->edje; + tmp_msgq = eina_list_remove_list(tmp_msgq, tmp_msgq); + em->edje->message.num--; + if (!ed->delete_me) + { + ed->processing_messages++; + _edje_message_process(em); + _edje_message_free(em); + ed->processing_messages--; + } + else + _edje_message_free(em); + if (ed->processing_messages == 0) + { + if (ed->delete_me) _edje_del(ed); + } + } + tmp_msgq_processing--; + if (tmp_msgq_processing == 0) + tmp_msgq_restart = 0; + else + tmp_msgq_restart = 1; + } + + /* if the message queue filled again set a timer to expire in 0.0 sec */ + /* to get the idle enterer to be run again */ + if (msgq) + { + static int self_feed_debug = -1; + + if (self_feed_debug == -1) + { + const char *s = getenv("EDJE_SELF_FEED_DEBUG"); + if (s) self_feed_debug = atoi(s); + else self_feed_debug = 0; + } + if (self_feed_debug) + { + WRN("Edje is in a self-feeding message loop (> 8 loops needed)"); + } + ecore_timer_add(0.0, _edje_dummy_timer, NULL); + } +} + +void +_edje_message_queue_clear(void) +{ + while (msgq) + { + Edje_Message *em; + + em = msgq->data; + msgq = eina_list_remove_list(msgq, msgq); + em->edje->message.num--; + _edje_message_free(em); + } + while (tmp_msgq) + { + Edje_Message *em; + + em = tmp_msgq->data; + tmp_msgq = eina_list_remove_list(tmp_msgq, tmp_msgq); + em->edje->message.num--; + _edje_message_free(em); + } +} + +void +_edje_message_del(Edje *ed) +{ + Eina_List *l; + + if (ed->message.num <= 0) return; + /* delete any messages on the main queue for this edje object */ + for (l = msgq; l; ) + { + Edje_Message *em; + Eina_List *lp; + + em = eina_list_data_get(l); + lp = l; + l = eina_list_next(l); + if (em->edje == ed) + { + msgq = eina_list_remove_list(msgq, lp); + em->edje->message.num--; + _edje_message_free(em); + } + if (ed->message.num <= 0) return; + } + /* delete any on the processing queue */ + for (l = tmp_msgq; l; ) + { + Edje_Message *em; + Eina_List *lp; + + em = eina_list_data_get(l); + lp = l; + l = eina_list_next(l); + if (em->edje == ed) + { + tmp_msgq = eina_list_remove_list(tmp_msgq, lp); + em->edje->message.num--; + _edje_message_free(em); + } + if (ed->message.num <= 0) return; + } +} 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 @@ +#include "edje_private.h" + +Eina_Hash *_registered_modules = NULL; +Eina_List *_modules_paths = NULL; + +Eina_List *_modules_found = NULL; + +#if defined(__CEGCC__) || defined(__MINGW32CE__) +# define EDJE_MODULE_NAME "edje_%s.dll" +# define EDJE_EXTRA_MODULE_NAME 1 +#elif _WIN32 +# define EDJE_MODULE_NAME "module.dll" +#else +# define EDJE_MODULE_NAME "module.so" +#endif + +EAPI Eina_Bool +edje_module_load(const char *module) +{ + if (_edje_module_handle_load(module)) return EINA_TRUE; + return EINA_FALSE; +} + +Eina_Module * +_edje_module_handle_load(const char *module) +{ + const char *path; + Eina_List *l; + Eina_Module *em = NULL; + + EINA_SAFETY_ON_NULL_RETURN_VAL(module, NULL); + + em = (Eina_Module *)eina_hash_find(_registered_modules, module); + if (em) return em; + + EINA_LIST_FOREACH(_modules_paths, l, path) + { + char tmp[PATH_MAX]; + + snprintf(tmp, sizeof (tmp), "%s/%s/%s/" EDJE_MODULE_NAME, path, module, MODULE_ARCH +#ifdef EDJE_EXTRA_MODULE_NAME + , module +#endif + ); + em = eina_module_new(tmp); + if (!em) continue; + + if (!eina_module_load(em)) + { + eina_module_free(em); + continue; + } + if (eina_hash_add(_registered_modules, module, em)) + return em; + } + + return NULL; +} + +void +_edje_module_init(void) +{ + char *paths[4] = { NULL, NULL, NULL, NULL }; + unsigned int i; + unsigned int j; + + _registered_modules = eina_hash_string_small_new(EINA_FREE_CB(eina_module_free)); + + /* 1. ~/.edje/modules/ */ + paths[0] = eina_module_environment_path_get("HOME", "/.edje/modules"); + /* 2. $(EDJE_MODULE_DIR)/edje/modules/ */ + paths[1] = eina_module_environment_path_get("EDJE_MODULES_DIR", "/edje/modules"); + /* 3. libedje.so/../edje/modules/ */ + paths[2] = eina_module_symbol_path_get(_edje_module_init, "/edje/modules"); + /* 4. PREFIX/edje/modules/ */ +#ifndef _MSC_VER + paths[3] = strdup(PACKAGE_LIB_DIR "/edje/modules"); +#endif + + for (j = 0; j < ((sizeof (paths) / sizeof (char*)) - 1); ++j) + for (i = j + 1; i < sizeof (paths) / sizeof (char*); ++i) + if (paths[i] && paths[j] && !strcmp(paths[i], paths[j])) + { + free(paths[i]); + paths[i] = NULL; + } + + for (i = 0; i < sizeof (paths) / sizeof (char*); ++i) + if (paths[i]) + _modules_paths = eina_list_append(_modules_paths, paths[i]); +} + +void +_edje_module_shutdown(void) +{ + char *path; + + if (_registered_modules) + { + eina_hash_free(_registered_modules); + _registered_modules = NULL; + } + + EINA_LIST_FREE(_modules_paths, path) + free(path); + + EINA_LIST_FREE(_modules_found, path) + eina_stringshare_del(path); +} + +EAPI const Eina_List * +edje_available_modules_get(void) +{ + Eina_File_Direct_Info *info; + Eina_Iterator *it; + Eina_List *l; + const char *path; + Eina_List *result = NULL; + + /* FIXME: Stat each possible dir and check if they did change, before starting a huge round of readdir/stat */ + if (_modules_found) + { + EINA_LIST_FREE(_modules_found, path) + eina_stringshare_del(path); + } + + EINA_LIST_FOREACH(_modules_paths, l, path) + { + it = eina_file_direct_ls(path); + + if (it) + { + EINA_ITERATOR_FOREACH(it, info) + { + char tmp[PATH_MAX]; + + snprintf(tmp, sizeof (tmp), "%s/%s/" EDJE_MODULE_NAME, info->path, MODULE_ARCH +#ifdef EDJE_EXTRA_MODULE_NAME + , ecore_file_file_get(info->path) +#endif + ); + + if (ecore_file_exists(tmp)) + result = eina_list_append(result, eina_stringshare_add(ecore_file_file_get(info->path))); + } + + eina_iterator_free(it); + } + } + + _modules_found = result; + + return result; +} 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 @@ +#include "config.h" +#include +#include +#include +#include +#include "edje_private.h" + +typedef struct _Multisense_Data +{ + Edje_Multisense_Env *msenv; +#ifdef HAVE_LIBREMIX + RemixDeck *deck; + RemixTrack *track; + RemixLayer *snd_layer, *player_layer; + RemixBase *player; + RemixBase *player_snd; + int remaining; + int offset; + Eina_List *snd_src_list; + + MULTISENSE_SOUND_PLAYER_GET_FUNC multisense_sound_player_get; +#endif +}Multisense_Data; + +#define BUF_LEN 64 +#define SND_PROCESS_LENGTH 2048 + +#ifdef HAVE_LIBREMIX +static Ecore_Thread *player_thread = NULL; +static int command_pipe[2]; +static Eina_Bool pipe_initialized = EINA_FALSE; +#endif + +typedef enum _Edje_Sound_Action_Type +{ + EDJE_PLAY_SAMPLE = 0, + EDJE_PLAY_TONE, + /* + EDJE_PLAY_PATTERN, + EDJE_PLAY_INSTRUMENT, + EDJE_PLAY_SONG, + */ + EDJE_SOUND_LAST +} Edje_Sound_Action_Type; + +typedef struct _Edje_Sample_Action Edje_Sample_Action; +typedef struct _Edje_Tone_Action Edje_Tone_Action; +typedef struct _Edje_Multisense_Sound_Action Edje_Multisense_Sound_Action; + +struct _Edje_Sample_Action +{ + char sample_name[BUF_LEN]; + double speed; +}; + +struct _Edje_Tone_Action +{ + char tone_name[BUF_LEN]; + double duration; +}; + +struct _Edje_Multisense_Sound_Action +{ + Edje *ed; + Edje_Sound_Action_Type action; + union { + Edje_Sample_Action sample; + Edje_Tone_Action tone; + } type; +}; + +#ifdef HAVE_LIBREMIX +static Multisense_Data * +init_multisense_environment(void) +{ + Multisense_Data *msdata; + char ms_factory[BUF_LEN]; + char *ms_factory_env; + Eina_Module *m = NULL; + MULTISENSE_FACTORY_INIT_FUNC multisense_factory_init; + + msdata = calloc(1, sizeof(Multisense_Data)); + if (!msdata) goto err; + + msdata->msenv = calloc(1, sizeof(Edje_Multisense_Env)); + if (!msdata->msenv) goto err; + + ms_factory_env = getenv("MULTISENSE_FACTORY"); + if (ms_factory_env) + strncpy(ms_factory, ms_factory_env, BUF_LEN); + else + strcpy(ms_factory, "multisense_factory"); + + m = _edje_module_handle_load(ms_factory); + if (!m) goto err; + + msdata->msenv->remixenv = remix_init(); + + multisense_factory_init = + eina_module_symbol_get(m, "multisense_factory_init"); + if (multisense_factory_init) multisense_factory_init(msdata->msenv); + + msdata->multisense_sound_player_get = + eina_module_symbol_get(m, "multisense_sound_player_get"); + if (!msdata->multisense_sound_player_get) goto err; + + msdata->deck = remix_deck_new(msdata->msenv->remixenv); + msdata->track = remix_track_new(msdata->msenv->remixenv, msdata->deck); + msdata->snd_layer = remix_layer_new_ontop(msdata->msenv->remixenv, + msdata->track, + REMIX_TIME_SAMPLES); + msdata->player_layer = remix_layer_new_ontop(msdata->msenv->remixenv, + msdata->track, + REMIX_TIME_SAMPLES); + msdata->player = msdata->multisense_sound_player_get(msdata->msenv); + if (!msdata->player) goto err; + msdata->player_snd = remix_sound_new(msdata->msenv->remixenv, + msdata->player, msdata->player_layer, + REMIX_SAMPLES(0), + REMIX_SAMPLES(REMIX_COUNT_INFINITE)); + return msdata; + +err: + if (msdata) + { + if (msdata->deck) remix_destroy(msdata->msenv->remixenv, msdata->deck); + if (msdata->msenv->remixenv) remix_purge(msdata->msenv->remixenv); + if (msdata->msenv) free(msdata->msenv); + free(msdata); + } + return NULL; +} +#endif + +#ifdef HAVE_LIBREMIX +static RemixBase * +eet_sound_reader_get(Edje_Multisense_Env *msenv, const char *path, const char *sound_id, const double speed) +{ + RemixPlugin *sf_plugin = NULL; + RemixBase * eet_snd_reader = NULL; + int sf_path_key = 0; + int sf_sound_id_key = 0; + int sf_speed_key = 0; + CDSet *sf_parms = NULL; + RemixEnv *env = msenv->remixenv; + + if (sf_plugin == NULL) + { + sf_plugin = remix_find_plugin(env, "eet_sndfile_reader"); + if (sf_plugin == NULL) + { + ERR ("Multisense EET Sound reader plugin NULL\n"); + return NULL; + } + + sf_path_key = remix_get_init_parameter_key(env, sf_plugin, "path"); + sf_sound_id_key = remix_get_init_parameter_key(env, sf_plugin, "sound_id"); + sf_speed_key = remix_get_init_parameter_key(env, sf_plugin, "speed"); + } + sf_parms = cd_set_replace(env, sf_parms, sf_path_key, CD_STRING(path)); + sf_parms = cd_set_replace(env, sf_parms, sf_sound_id_key, CD_STRING(sound_id)); + sf_parms = cd_set_replace(env, sf_parms, sf_speed_key, CD_DOUBLE(speed)); + eet_snd_reader = remix_new(env, sf_plugin, sf_parms); + + return eet_snd_reader; +} + + +static RemixBase * +edje_remix_sample_create(Multisense_Data *msdata, Edje*ed, Edje_Sample_Action *action) +{ + RemixBase *remix_snd = NULL; + Edje_Sound_Sample *sample; + int i; + char snd_id_str[16]; + + if ((!ed) || (!ed->file) || (!ed->file->sound_dir)) + return NULL; + + for (i = 0; i < (int)ed->file->sound_dir->samples_count; i++) + { + sample = &ed->file->sound_dir->samples[i]; + if (!strcmp(sample->name, action->sample_name)) + { + snprintf(snd_id_str, sizeof(snd_id_str), "edje/sounds/%i", sample->id); + remix_snd = eet_sound_reader_get(msdata->msenv, ed->file->path, + snd_id_str, action->speed); + break; + } + } + return remix_snd; +} + +static RemixBase * +edje_remix_tone_create(Multisense_Data *msdata, Edje*ed, Edje_Tone_Action *action) +{ + Edje_Sound_Tone *tone; + RemixSquareTone *square = NULL; + unsigned int i; + + if ((!ed) || (!ed->file) || (!ed->file->sound_dir)) + return NULL; + + for (i = 0; i < ed->file->sound_dir->tones_count; i++) + { + tone = &ed->file->sound_dir->tones[i]; + if (!strcmp(tone->name, action->tone_name)) + { + square = remix_squaretone_new (msdata->msenv->remixenv, tone->value); + break; + } + } + return square; +} + +static void +sound_command_handler(Multisense_Data *msdata) +{ + RemixCount length; + Edje_Multisense_Sound_Action command; + RemixBase *base = NULL; + RemixBase *sound; + + if (read(command_pipe[0], &command, sizeof(command)) <= 0) return; + switch (command.action) + { + case EDJE_PLAY_SAMPLE: + base = edje_remix_sample_create(msdata, command.ed, + &command.type.sample); + length = remix_length(msdata->msenv->remixenv, base); + break; + case EDJE_PLAY_TONE: + base = edje_remix_tone_create(msdata, command.ed, &command.type.tone); + length = (command.type.tone.duration * + remix_get_samplerate(msdata->msenv->remixenv)); + break; + default: + ERR("Invalid Sound Play Command\n"); + break; + } + if (base) + { + sound = remix_sound_new(msdata->msenv->remixenv, base, msdata->snd_layer, + REMIX_SAMPLES(msdata->offset), + REMIX_SAMPLES(length)); + if (msdata->remaining < length) msdata->remaining = length; + msdata->snd_src_list = eina_list_append(msdata->snd_src_list, sound); + msdata->snd_src_list = eina_list_append(msdata->snd_src_list, base); + } +} +#endif + +#ifdef HAVE_LIBREMIX +// msdata outside of thread due to thread issues in dlsym etc. +static Multisense_Data *msdata = NULL; + +static void +_msdata_free(void) +{ + // cleanup msdata outside of thread due to thread issues in dlsym etc. + if (!msdata) return; + //cleanup Remix stuffs + remix_destroy(msdata->msenv->remixenv, msdata->player); + remix_destroy(msdata->msenv->remixenv, msdata->deck); + remix_purge(msdata->msenv->remixenv); + + free(msdata->msenv); + free(msdata); + msdata = NULL; +} + +static void +_player_job(void *data __UNUSED__, Ecore_Thread *th) +{ + fd_set wait_fds; + RemixBase *sound; + RemixCount process_len; +// disable and move outside of thread due to dlsym etc. thread issues +// Multisense_Data * msdata = init_multisense_environment(); + + if (!msdata) return; + + fcntl(command_pipe[0], F_SETFL, O_NONBLOCK); + FD_ZERO(&wait_fds); + FD_SET(command_pipe[0], &wait_fds); + + while (!ecore_thread_check(th)) + { + if (!msdata->remaining) + { + //Cleanup already played sound sources + EINA_LIST_FREE(msdata->snd_src_list, sound) + { + remix_destroy(msdata->msenv->remixenv, sound); + } + //wait for new sound + select(command_pipe[0] + 1, &wait_fds, NULL, NULL, 0); + } + //read sound command , if any + sound_command_handler(msdata); + process_len = MIN(msdata->remaining, SND_PROCESS_LENGTH); + remix_process(msdata->msenv->remixenv, msdata->deck, process_len, + RemixNone, RemixNone); + msdata->offset += process_len; + msdata->remaining -= process_len; + } + + //Cleanup last played sound sources + EINA_LIST_FREE(msdata->snd_src_list, sound) + { + remix_destroy(msdata->msenv->remixenv, sound); + } + + close(command_pipe[0]); + close(command_pipe[1]); +} +#endif + +#ifdef HAVE_LIBREMIX +static void +_player_cancel(void *data __UNUSED__, Ecore_Thread *th __UNUSED__) +{ + // cleanup msdata outside of thread due to thread issues in dlsym etc. + _msdata_free(); + player_thread = NULL; +} +#endif + +#ifdef HAVE_LIBREMIX +static void +_player_end(void *data __UNUSED__, Ecore_Thread *th __UNUSED__) +{ + // cleanup msdata outside of thread due to thread issues in dlsym etc. + _msdata_free(); + player_thread = NULL; +} +#endif + +Eina_Bool +_edje_multisense_internal_sound_sample_play(Edje *ed, const char *sample_name, const double speed) +{ + ssize_t size = 0; +#ifdef ENABLE_MULTISENSE + Edje_Multisense_Sound_Action command; + + if ((!pipe_initialized) && (!player_thread)) return EINA_FALSE; + + command.action = EDJE_PLAY_SAMPLE; + command.ed = ed; + strncpy(command.type.sample.sample_name, sample_name, BUF_LEN); + command.type.sample.speed = speed; + size = write(command_pipe[1], &command, sizeof(command)); +#else + ed = NULL; // warning shh + if (speed > 0) sample_name = NULL; // warning shh +#endif + return (size == sizeof(Edje_Multisense_Sound_Action)); +} + +Eina_Bool +_edje_multisense_internal_sound_tone_play(Edje *ed, const char *tone_name, const double duration) +{ + ssize_t size = 0; +#ifdef ENABLE_MULTISENSE + Edje_Multisense_Sound_Action command; + + if ((!pipe_initialized) && (!player_thread)) return EINA_FALSE; + command.action = EDJE_PLAY_TONE; + command.ed = ed; + strncpy(command.type.tone.tone_name, tone_name, BUF_LEN); + command.type.tone.duration = duration; + size = write(command_pipe[1], &command, sizeof(command)); +#else + ed = NULL; // warning shh + if (duration > 0) tone_name = NULL; // warning shh +#endif + return (size == sizeof(Edje_Multisense_Sound_Action)); + +} + +/* Initialize the modules in main thread. to avoid dlopen issue in the Threads */ +void +_edje_multisense_init(void) +{ +#ifdef ENABLE_MULTISENSE + if (!pipe_initialized && (pipe(command_pipe) != -1)) + pipe_initialized = EINA_TRUE; + + // init msdata outside of thread due to thread issues in dlsym etc. + if (!msdata) msdata = init_multisense_environment(); + + if (!player_thread) + player_thread = ecore_thread_run(_player_job, _player_end, _player_cancel, NULL); +#endif +} + +void +_edje_multisense_shutdown(void) +{ +#ifdef ENABLE_MULTISENSE + if (pipe_initialized) + { + close(command_pipe[1]); + close(command_pipe[0]); + } + if (player_thread) ecore_thread_cancel(player_thread); +#endif +} 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 @@ +#ifndef _EDJE_PRIVATE_H +#define _EDJE_PRIVATE_H + +#ifdef HAVE_CONFIG_H +# include +#endif + +#ifndef _WIN32 +# define _GNU_SOURCE +#endif + +#ifdef HAVE_ALLOCA_H +# include +#elif defined __GNUC__ +# define alloca __builtin_alloca +#elif defined _AIX +# define alloca __alloca +#elif defined _MSC_VER +# include +# define alloca _alloca +#else +# include +void *alloca (size_t); +#endif + +#include +#include +#include +#include +#include +#include + +#ifndef _MSC_VER +# include +# include +#endif + +#include +#include +#include +#include + +#ifdef HAVE_LOCALE_H +# include +#endif + +#ifdef HAVE_EVIL +# include +#endif + +#include +#include +#include +#include +#include +#include +#ifdef HAVE_ECORE_IMF +# include +# include +#endif +#include + +#include "Edje.h" + +EAPI extern int _edje_default_log_dom ; + +#ifdef EDJE_DEFAULT_LOG_COLOR +# undef EDJE_DEFAULT_LOG_COLOR +#endif +#define EDJE_DEFAULT_LOG_COLOR EINA_COLOR_CYAN +#ifdef ERR +# undef ERR +#endif +#define ERR(...) EINA_LOG_DOM_ERR(_edje_default_log_dom, __VA_ARGS__) +#ifdef INF +# undef INF +#endif +#define INF(...) EINA_LOG_DOM_INFO(_edje_default_log_dom, __VA_ARGS__) +#ifdef WRN +# undef WRN +#endif +#define WRN(...) EINA_LOG_DOM_WARN(_edje_default_log_dom, __VA_ARGS__) +#ifdef CRIT +# undef CRIT +#endif +#define CRIT(...) EINA_LOG_DOM_CRIT(_edje_default_log_dom, __VA_ARGS__) +#ifdef __GNUC__ +# if __GNUC__ >= 4 +// BROKEN in gcc 4 on amd64 +//# pragma GCC visibility push(hidden) +# endif +#endif + +#ifndef ABS +#define ABS(x) ((x) < 0 ? -(x) : (x)) +#endif + +#ifndef CLAMP +#define CLAMP(x, min, max) (((x) > (max)) ? (max) : (((x) < (min)) ? (min) : (x))) +#endif + +#ifndef MIN +#define MIN(a, b) (((a) < (b)) ? (a) : (b)) +#endif + + +#ifdef BUILD_EDJE_FP + +#define FLOAT_T Eina_F32p32 +#define EDJE_T_FLOAT EET_T_F32P32 +#define MUL(a, b) eina_f32p32_mul(a, b) +#define SCALE(a, b) eina_f32p32_scale(a, b) +#define DIV(a, b) eina_f32p32_div(a, b) +#define DIV2(a) ((a) >> 1) +#define ADD(a, b) eina_f32p32_add(a, b) +#define SUB(a, b) eina_f32p32_sub(a, b) +#define SQRT(a) eina_f32p32_sqrt(a) +#define TO_DOUBLE(a) eina_f32p32_double_to(a) +#define FROM_DOUBLE(a) eina_f32p32_double_from(a) +#define FROM_INT(a) eina_f32p32_int_from(a) +#define TO_INT(a) eina_f32p32_int_to(a) +#define ZERO 0 +#define COS(a) eina_f32p32_cos(a) +#define SIN(a) eina_f32p32_sin(a) +#define PI EINA_F32P32_PI + +#else + +#define FLOAT_T double +#define EDJE_T_FLOAT EET_T_DOUBLE +#define MUL(a, b) ((a) * (b)) +#define SCALE(a, b) ((a) * (double)(b)) +#define DIV(a, b) ((a) / (b)) +#define DIV2(a) ((a) / 2.0) +#define ADD(a, b) ((a) + (b)) +#define SUB(a, b) ((a) - (b)) +#define SQRT(a) sqrt(a) +#define TO_DOUBLE(a) (double)(a) +#define FROM_DOUBLE(a) (a) +#define FROM_INT(a) (double)(a) +#define TO_INT(a) (int)(a) +#define ZERO 0.0 +#define COS(a) cos(a) +#define SIN(a) sin(a) +#define PI 3.14159265358979323846 + +#endif + +/* Inheritable Edje Smart API. For now private so only Edje Edit makes + * use of this, but who knows what will be possible in the future */ +#define EDJE_SMART_API_VERSION 1 + +typedef struct _Edje_Smart_Api Edje_Smart_Api; + +struct _Edje_Smart_Api +{ + Evas_Smart_Class base; + int version; + Eina_Bool (*file_set)(Evas_Object *obj, const char *file, const char *group); +}; + +/* Basic macro to init the Edje Smart API */ +#define EDJE_SMART_API_INIT(smart_class_init) {smart_class_init, EDJE_SMART_API_VERSION, NULL} + +#define EDJE_SMART_API_INIT_NULL EDJE_SMART_API_INIT(EVAS_SMART_CLASS_INIT_NULL) +#define EDJE_SMART_API_INIT_VERSION EDJE_SMART_API_INIT(EVAS_SMART_CLASS_INIT_VERSION) +#define EDJE_SMART_API_INIT_NAME_VERSION(name) EDJE_SMART_API_INIT(EVAS_SMART_CLASS_INIT_NAME_VERSION(name)) + +/* increment this when the EET data descriptors have changed and old + * EETs cannot be loaded/used correctly anymore. + */ +#define EDJE_FILE_VERSION 3 +/* increment this when you add new feature to edje file format without + * breaking backward compatibility. + */ +#define EDJE_FILE_MINOR 2 + +/* FIXME: + * + * More example Edje files + * + * ? programs can do multiple actions from one signal + * ? add containering (hbox, vbox, table, wrapping multi-line hbox & vbox) + * ? text entry widget (single line only) + * + * ? recursions, unsafe callbacks outside Edje etc. with freeze, ref/unref and block/unblock and break_programs needs to be redesigned & fixed + * ? all unsafe calls that may result in callbacks must be marked and dealt with + */ + +typedef enum +{ + EDJE_ASPECT_PREFER_NONE, + EDJE_ASPECT_PREFER_VERTICAL, + EDJE_ASPECT_PREFER_HORIZONTAL, + EDJE_ASPECT_PREFER_BOTH +} Edje_Internal_Aspect; + +struct _Edje_Perspective +{ + Evas_Object *obj; + Evas *e; + Evas_Coord px, py, z0, foc; + Eina_List *users; + Eina_Bool global : 1; +}; + +struct _Edje_Position_Scale +{ + FLOAT_T x, y; +}; + +struct _Edje_Position +{ + int x, y; +}; + +struct _Edje_Size +{ + int w, h; +}; + +struct _Edje_Rectangle +{ + int x, y, w, h; +}; + +struct _Edje_Color +{ + unsigned char r, g, b, a; +}; + +struct _Edje_Aspect_Prefer +{ + FLOAT_T min, max; + Edje_Internal_Aspect prefer; +}; + +struct _Edje_Aspect +{ + int w, h; + Edje_Aspect_Control mode; +}; + +struct _Edje_String +{ + const char *str; + unsigned int id; +}; + +typedef struct _Edje_Position_Scale Edje_Alignment; +typedef struct _Edje_Position_Scale Edje_Position_Scale; +typedef struct _Edje_Position Edje_Position; +typedef struct _Edje_Size Edje_Size; +typedef struct _Edje_Rectangle Edje_Rectangle; +typedef struct _Edje_Color Edje_Color; +typedef struct _Edje_Aspect_Prefer Edje_Aspect_Prefer; +typedef struct _Edje_Aspect Edje_Aspect; +typedef struct _Edje_String Edje_String; + +typedef struct _Edje_File Edje_File; +typedef struct _Edje_Style Edje_Style; +typedef struct _Edje_Style_Tag Edje_Style_Tag; +typedef struct _Edje_External_Directory Edje_External_Directory; +typedef struct _Edje_External_Directory_Entry Edje_External_Directory_Entry; +typedef struct _Edje_Font_Directory_Entry Edje_Font_Directory_Entry; +typedef struct _Edje_Image_Directory Edje_Image_Directory; +typedef struct _Edje_Image_Directory_Entry Edje_Image_Directory_Entry; +typedef struct _Edje_Image_Directory_Set Edje_Image_Directory_Set; +typedef struct _Edje_Image_Directory_Set_Entry Edje_Image_Directory_Set_Entry; +typedef struct _Edje_Limit Edje_Limit; +typedef struct _Edje_Sound_Sample Edje_Sound_Sample; +typedef struct _Edje_Sound_Tone Edje_Sound_Tone; +typedef struct _Edje_Sound_Directory Edje_Sound_Directory; +typedef struct _Edje_Program Edje_Program; +typedef struct _Edje_Program_Target Edje_Program_Target; +typedef struct _Edje_Program_After Edje_Program_After; +typedef struct _Edje_Part_Collection_Directory_Entry Edje_Part_Collection_Directory_Entry; +typedef struct _Edje_Pack_Element Edje_Pack_Element; +typedef struct _Edje_Part_Collection Edje_Part_Collection; +typedef struct _Edje_Part Edje_Part; +typedef struct _Edje_Part_Api Edje_Part_Api; +typedef struct _Edje_Part_Dragable Edje_Part_Dragable; +typedef struct _Edje_Part_Image_Id Edje_Part_Image_Id; +typedef struct _Edje_Part_Description_Image Edje_Part_Description_Image; +typedef struct _Edje_Part_Description_Proxy Edje_Part_Description_Proxy; +typedef struct _Edje_Part_Description_Text Edje_Part_Description_Text; +typedef struct _Edje_Part_Description_Box Edje_Part_Description_Box; +typedef struct _Edje_Part_Description_Table Edje_Part_Description_Table; +typedef struct _Edje_Part_Description_External Edje_Part_Description_External; +typedef struct _Edje_Part_Description_Common Edje_Part_Description_Common; +typedef struct _Edje_Part_Description_Spec_Fill Edje_Part_Description_Spec_Fill; +typedef struct _Edje_Part_Description_Spec_Border Edje_Part_Description_Spec_Border; +typedef struct _Edje_Part_Description_Spec_Image Edje_Part_Description_Spec_Image; +typedef struct _Edje_Part_Description_Spec_Proxy Edje_Part_Description_Spec_Proxy; +typedef struct _Edje_Part_Description_Spec_Text Edje_Part_Description_Spec_Text; +typedef struct _Edje_Part_Description_Spec_Box Edje_Part_Description_Spec_Box; +typedef struct _Edje_Part_Description_Spec_Table Edje_Part_Description_Spec_Table; +typedef struct _Edje_Patterns Edje_Patterns; +typedef struct _Edje_Part_Box_Animation Edje_Part_Box_Animation; + +typedef struct _Edje Edje; +typedef struct _Edje_Real_Part_State Edje_Real_Part_State; +typedef struct _Edje_Real_Part_Drag Edje_Real_Part_Drag; +typedef struct _Edje_Real_Part_Set Edje_Real_Part_Set; +typedef struct _Edje_Real_Part Edje_Real_Part; +typedef struct _Edje_Running_Program Edje_Running_Program; +typedef struct _Edje_Signal_Callback Edje_Signal_Callback; +typedef struct _Edje_Calc_Params Edje_Calc_Params; +typedef struct _Edje_Pending_Program Edje_Pending_Program; +typedef struct _Edje_Text_Style Edje_Text_Style; +typedef struct _Edje_Color_Class Edje_Color_Class; +typedef struct _Edje_Text_Class Edje_Text_Class; +typedef struct _Edje_Var Edje_Var; +typedef struct _Edje_Var_Int Edje_Var_Int; +typedef struct _Edje_Var_Float Edje_Var_Float; +typedef struct _Edje_Var_String Edje_Var_String; +typedef struct _Edje_Var_List Edje_Var_List; +typedef struct _Edje_Var_Hash Edje_Var_Hash; +typedef struct _Edje_Var_Animator Edje_Var_Animator; +typedef struct _Edje_Var_Timer Edje_Var_Timer; +typedef struct _Edje_Var_Pool Edje_Var_Pool; +typedef struct _Edje_Signal_Source_Char Edje_Signal_Source_Char; +typedef struct _Edje_Text_Insert_Filter_Callback Edje_Text_Insert_Filter_Callback; + +#define EDJE_INF_MAX_W 100000 +#define EDJE_INF_MAX_H 100000 + +#define EDJE_IMAGE_SOURCE_TYPE_NONE 0 +#define EDJE_IMAGE_SOURCE_TYPE_INLINE_PERFECT 1 +#define EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY 2 +#define EDJE_IMAGE_SOURCE_TYPE_EXTERNAL 3 +#define EDJE_IMAGE_SOURCE_TYPE_LAST 4 + +#define EDJE_SOUND_SOURCE_TYPE_NONE 0 +#define EDJE_SOUND_SOURCE_TYPE_INLINE_RAW 1 +#define EDJE_SOUND_SOURCE_TYPE_INLINE_COMP 2 +#define EDJE_SOUND_SOURCE_TYPE_INLINE_LOSSY 3 +#define EDJE_SOUND_SOURCE_TYPE_INLINE_AS_IS 4 + +#define EDJE_VAR_NONE 0 +#define EDJE_VAR_INT 1 +#define EDJE_VAR_FLOAT 2 +#define EDJE_VAR_STRING 3 +#define EDJE_VAR_LIST 4 +#define EDJE_VAR_HASH 5 + +#define EDJE_VAR_MAGIC_BASE 0x12fe84ba + +#define EDJE_STATE_PARAM_NONE 0 +#define EDJE_STATE_PARAM_ALIGNMENT 1 +#define EDJE_STATE_PARAM_MIN 2 +#define EDJE_STATE_PARAM_MAX 3 +#define EDJE_STATE_PARAM_STEP 4 +#define EDJE_STATE_PARAM_ASPECT 5 +#define EDJE_STATE_PARAM_ASPECT_PREF 6 +#define EDJE_STATE_PARAM_COLOR 7 +#define EDJE_STATE_PARAM_COLOR2 8 +#define EDJE_STATE_PARAM_COLOR3 9 +#define EDJE_STATE_PARAM_COLOR_CLASS 10 +#define EDJE_STATE_PARAM_REL1 11 +#define EDJE_STATE_PARAM_REL1_TO 12 +#define EDJE_STATE_PARAM_REL1_OFFSET 13 +#define EDJE_STATE_PARAM_REL2 14 +#define EDJE_STATE_PARAM_REL2_TO 15 +#define EDJE_STATE_PARAM_REL2_OFFSET 16 +#define EDJE_STATE_PARAM_IMAGE 17 +#define EDJE_STATE_PARAM_BORDER 18 +#define EDJE_STATE_PARAM_FILL_SMOOTH 19 +#define EDJE_STATE_PARAM_FILL_POS 20 +#define EDJE_STATE_PARAM_FILL_SIZE 21 +#define EDJE_STATE_PARAM_TEXT 22 +#define EDJE_STATE_PARAM_TEXT_CLASS 23 +#define EDJE_STATE_PARAM_TEXT_FONT 24 +#define EDJE_STATE_PARAM_TEXT_STYLE 25 +#define EDJE_STATE_PARAM_TEXT_SIZE 26 +#define EDJE_STATE_PARAM_TEXT_FIT 27 +#define EDJE_STATE_PARAM_TEXT_MIN 28 +#define EDJE_STATE_PARAM_TEXT_MAX 29 +#define EDJE_STATE_PARAM_TEXT_ALIGN 30 +#define EDJE_STATE_PARAM_VISIBLE 31 +#define EDJE_STATE_PARAM_MAP_OM 32 +#define EDJE_STATE_PARAM_MAP_PERSP 33 +#define EDJE_STATE_PARAM_MAP_LIGNT 34 +#define EDJE_STATE_PARAM_MAP_ROT_CENTER 35 +#define EDJE_STATE_PARAM_MAP_ROT_X 36 +#define EDJE_STATE_PARAM_MAP_ROT_Y 37 +#define EDJE_STATE_PARAM_MAP_ROT_Z 38 +#define EDJE_STATE_PARAM_MAP_BACK_CULL 39 +#define EDJE_STATE_PARAM_MAP_PERSP_ON 40 +#define EDJE_STATE_PARAM_PERSP_ZPLANE 41 +#define EDJE_STATE_PARAM_PERSP_FOCAL 42 +#define EDJE_STATE_PARAM_LAST 43 + +#define EDJE_ENTRY_EDIT_MODE_NONE 0 +#define EDJE_ENTRY_EDIT_MODE_SELECTABLE 1 +#define EDJE_ENTRY_EDIT_MODE_EDITABLE 2 +#define EDJE_ENTRY_EDIT_MODE_PASSWORD 3 + +#define EDJE_ENTRY_SELECTION_MODE_DEFAULT 0 +#define EDJE_ENTRY_SELECTION_MODE_EXPLICIT 1 + +#define EDJE_ENTRY_CURSOR_MODE_UNDER 0 +#define EDJE_ENTRY_CURSOR_MODE_BEFORE 1 + +#define EDJE_ORIENTATION_AUTO 0 +#define EDJE_ORIENTATION_LTR 1 +#define EDJE_ORIENTATION_RTL 2 + +#define EDJE_PART_PATH_SEPARATOR ':' +#define EDJE_PART_PATH_SEPARATOR_STRING ":" +#define EDJE_PART_PATH_SEPARATOR_INDEXL '[' +#define EDJE_PART_PATH_SEPARATOR_INDEXR ']' + +#define FLAG_NONE 0 +#define FLAG_X 0x01 +#define FLAG_Y 0x02 +#define FLAG_XY (FLAG_X | FLAG_Y) + +/*----------*/ + +struct _Edje_File +{ + const char *path; + time_t mtime; + + Edje_External_Directory *external_dir; + Edje_Image_Directory *image_dir; + Edje_Sound_Directory *sound_dir; + Eina_List *styles; + Eina_List *color_classes; + + int references; + const char *compiler; + int version; + int minor; + int feature_ver; + + Eina_Hash *data; + Eina_Hash *fonts; + + Eina_Hash *collection; + Eina_List *collection_cache; + + Edje_Patterns *collection_patterns; + + Eet_File *ef; + + unsigned char free_strings : 1; + unsigned char dangling : 1; + unsigned char warning : 1; +}; + +struct _Edje_Style +{ + char *name; + Eina_List *tags; + Evas_Textblock_Style *style; +}; + +struct _Edje_Style_Tag +{ + const char *key; + const char *value; + const char *font; + double font_size; + const char *text_class; +}; + +/*----------*/ + + +struct _Edje_Font_Directory_Entry +{ + const char *entry; /* the name of the font */ + const char *file; /* the name of the file */ +}; + +/*----------*/ + +struct _Edje_External_Directory +{ + Edje_External_Directory_Entry *entries; /* a list of Edje_External_Directory_Entry */ + unsigned int entries_count; +}; + +struct _Edje_External_Directory_Entry +{ + const char *entry; /* the name of the external */ +}; + + +/*----------*/ + + + +/*----------*/ + +struct _Edje_Image_Directory +{ + Edje_Image_Directory_Entry *entries; /* an array of Edje_Image_Directory_Entry */ + unsigned int entries_count; + + Edje_Image_Directory_Set *sets; + unsigned int sets_count; /* an array of Edje_Image_Directory_Set */ +}; + +struct _Edje_Image_Directory_Entry +{ + const char *entry; /* the nominal name of the image - if any */ + int source_type; /* alternate source mode. 0 = none */ + int source_param; /* extra params on encoding */ + int id; /* the id no. of the image */ +}; + +struct _Edje_Image_Directory_Set +{ + char *name; + Eina_List *entries; + + int id; +}; + +struct _Edje_Image_Directory_Set_Entry +{ + const char *name; + int id; + + struct { + struct { + int w; + int h; + } min, max; + } size; +}; + +struct _Edje_Sound_Sample /*Sound Sample*/ +{ + const char *name; /* the nominal name of the sound */ + const char *snd_src; /* Sound source Wav file */ + int compression; /* Compression - RAW, LOSSLESS COMP , LOSSY ) */ + int mode; /* alternate source mode. 0 = none */ + double quality; + int id; /* the id no. of the sound */ +}; + +struct _Edje_Sound_Tone /*Sound Sample*/ +{ + const char *name; /* the nominal name of the sound - if any */ + int value; /* alternate source mode. 0 = none */ + int id; /* the id no. of the sound */ +}; + +struct _Edje_Sound_Directory +{ + + Edje_Sound_Sample *samples; /* an array of Edje_Sound_Sample entries */ + unsigned int samples_count; + + Edje_Sound_Tone *tones; /* an array of Edje_Sound_Tone entries */ + unsigned int tones_count; +}; + +/*----------*/ + +struct _Edje_Program /* a conditional program to be run */ +{ + int id; /* id of program */ + const char *name; /* name of the action */ + + const char *signal; /* if signal emission name matches the glob here... */ + const char *source; /* if part that emitted this (name) matches this glob */ + const char *sample_name; + const char *tone_name; + double duration; + double speed; + + struct { + const char *part; + const char *state; /* if state is not set, we will try with source */ + } filter; /* the part filter.part should be in state filter.state for signal to be accepted */ + + struct { + double from; + double range; + } in; + + int action; /* type - set state, stop action, set drag pos etc. */ + const char *state; /* what state of alternates to apply, NULL = default */ + const char *state2; /* what other state to use - for signal emit action */ + double value; /* value of state to apply (if multiple names match) */ + double value2; /* other value for drag actions */ + + struct { + int mode; /* how to tween - linear, sinusoidal etc. */ + FLOAT_T time; /* time to graduate between current and new state */ + FLOAT_T v1; /* other value for drag actions */ + FLOAT_T v2; /* other value for drag actions */ + } tween; + + Eina_List *targets; /* list of target parts to apply the state to */ + + Eina_List *after; /* list of actions to run at the end of this, for looping */ + + struct { + const char *name; + const char *description; + } api; + + /* used for PARAM_COPY (param names in state and state2 above!) */ + struct { + int src; /* part where parameter is being retrieved */ + int dst; /* part where parameter is being stored */ + } param; +}; + +struct _Edje_Program_Target /* the target of an action */ +{ + int id; /* just the part id no, or action id no */ +}; + +struct _Edje_Program_After /* the action to run after another action */ +{ + int id; +}; + +/*----------*/ +struct _Edje_Limit +{ + const char *name; + int value; +}; + +/*----------*/ +#define PART_TYPE_FIELDS(TYPE) \ + TYPE RECTANGLE; \ + TYPE TEXT; \ + TYPE IMAGE; \ + TYPE PROXY; \ + TYPE SWALLOW; \ + TYPE TEXTBLOCK; \ + TYPE GROUP; \ + TYPE BOX; \ + TYPE TABLE; \ + TYPE EXTERNAL; + +struct _Edje_Part_Collection_Directory_Entry +{ + const char *entry; /* the nominal name of the part collection */ + int id; /* the id of this named part collection */ + + struct + { + PART_TYPE_FIELDS(int) + int part; + } count; + + struct + { + PART_TYPE_FIELDS(Eina_Mempool *) + Eina_Mempool *part; + } mp; + + struct + { + PART_TYPE_FIELDS(Eina_Mempool *) + } mp_rtl; /* For Right To Left interface */ + + Edje_Part_Collection *ref; +}; + +/*----------*/ + +/*----------*/ + +struct _Edje_Pack_Element +{ + unsigned char type; /* only GROUP supported for now */ + Edje_Real_Part *parent; /* pointer to the table/box that hold it, set at runtime */ + const char *name; /* if != NULL, will be set with evas_object_name_set */ + const char *source; /* group name to use as source for this element */ + Edje_Size min, prefer, max; + struct { + int l, r, t, b; + } padding; + Edje_Alignment align; + Edje_Alignment weight; + Edje_Aspect aspect; + const char *options; /* extra options for custom objects */ + /* table specific follows */ + int col, row; + unsigned short colspan, rowspan; +}; + +/*----------*/ + +struct _Edje_Part_Collection +{ + struct { /* list of Edje_Program */ + Edje_Program **fnmatch; /* complex match with "*?[\" */ + unsigned int fnmatch_count; + + Edje_Program **strcmp; /* No special caractere, plain strcmp does the work */ + unsigned int strcmp_count; + + Edje_Program **strncmp; /* Finish by * or ?, plain strncmp does the work */ + unsigned int strncmp_count; + + Edje_Program **strrncmp; /* Start with * or ?, reverse strncmp will do the job */ + unsigned int strrncmp_count; + + Edje_Program **nocmp; /* Empty signal/source that will never match */ + unsigned int nocmp_count; + } programs; + + struct { /* list of limit that need to be monitored */ + Edje_Limit **vertical; + unsigned int vertical_count; + + Edje_Limit **horizontal; + unsigned int horizontal_count; + } limits; + + Edje_Part **parts; /* an array of Edje_Part */ + unsigned int parts_count; + + Eina_Hash *data; + + int id; /* the collection id */ + + Eina_Hash *alias; /* aliasing part */ + Eina_Hash *aliased; /* invert match of alias */ + + struct { + Edje_Size min, max; + unsigned char orientation; + } prop; + + int references; + +#ifdef EDJE_PROGRAM_CACHE + struct { + Eina_Hash *no_matches; + Eina_Hash *matches; + } prog_cache; +#endif + + Embryo_Program *script; /* all the embryo script code for this group */ + const char *part; + + unsigned char script_only; + + unsigned char lua_script_only; + + unsigned char checked : 1; +}; + +struct _Edje_Part_Dragable +{ + int step_x; /* drag jumps n pixels (0 = no limit) */ + int step_y; /* drag jumps n pixels (0 = no limit) */ + + int count_x; /* drag area divided by n (0 = no limit) */ + int count_y; /* drag area divided by n (0 = no limit) */ + + int confine_id; /* dragging within this bit, -1 = no */ + + /* davinchi */ + int event_id; /* If it is used as scrollbar */ + + signed char x; /* can u click & drag this bit in x dir */ + signed char y; /* can u click & drag this bit in y dir */ +}; + +struct _Edje_Part_Api +{ + const char *name; + const char *description; +}; + +typedef struct _Edje_Part_Description_List Edje_Part_Description_List; +struct _Edje_Part_Description_List +{ + Edje_Part_Description_Common **desc; + Edje_Part_Description_Common **desc_rtl; /* desc for Right To Left interface */ + unsigned int desc_count; +}; + +struct _Edje_Part +{ + const char *name; /* the name if any of the part */ + Edje_Part_Description_Common *default_desc; /* the part descriptor for default */ + Edje_Part_Description_Common *default_desc_rtl; /* default desc for Right To Left interface */ + + Edje_Part_Description_List other; /* other possible descriptors */ + + const char *source, *source2, *source3, *source4, *source5, *source6; + int id; /* its id number */ + int clip_to_id; /* the part id to clip this one to */ + Edje_Part_Dragable dragable; + Edje_Pack_Element **items; /* packed items for box and table */ + unsigned int items_count; + unsigned char type; /* what type (image, rect, text) */ + unsigned char effect; /* 0 = plain... */ + unsigned char mouse_events; /* it will affect/respond to mouse events */ + unsigned char repeat_events; /* it will repeat events to objects below */ + Evas_Event_Flags ignore_flags; + unsigned char scale; /* should certain properties scale with edje scale factor? */ + unsigned char precise_is_inside; + unsigned char use_alternate_font_metrics; + unsigned char pointer_mode; + unsigned char entry_mode; + unsigned char select_mode; + unsigned char cursor_mode; + unsigned char multiline; + Edje_Part_Api api; +}; + +struct _Edje_Part_Image_Id +{ + int id; + Eina_Bool set; +}; + +struct _Edje_Part_Description_Common +{ + struct { + double value; /* the value of the state (for ranges) */ + const char *name; /* the named state if any */ + } state; + + Edje_Alignment align; /* 0 <-> 1.0 alignment within allocated space */ + + struct { + unsigned char w, h; /* width or height is fixed in side (cannot expand with Edje object size) */ + } fixed; + + Edje_Size min, max; + Edje_Position step; /* size stepping by n pixels, 0 = none */ + Edje_Aspect_Prefer aspect; + + char *color_class; /* how to modify the color */ + Edje_Color color; + Edje_Color color2; + + struct { + FLOAT_T relative_x; + FLOAT_T relative_y; + int offset_x; + int offset_y; + int id_x; /* -1 = whole part collection, or part ID */ + int id_y; /* -1 = whole part collection, or part ID */ + } rel1, rel2; + + struct { + int id_persp; + int id_light; + struct { + int id_center; + FLOAT_T x, y, z; + } rot; + unsigned char backcull; + unsigned char on; + unsigned char persp_on; + unsigned char smooth; + unsigned char alpha; + } map; + + struct { + int zplane; + int focal; + } persp; + + unsigned char visible; /* is it shown */ +}; + +struct _Edje_Part_Description_Spec_Fill +{ + FLOAT_T pos_rel_x; /* fill offset x relative to area */ + FLOAT_T rel_x; /* relative size compared to area */ + FLOAT_T pos_rel_y; /* fill offset y relative to area */ + FLOAT_T rel_y; /* relative size compared to area */ + int pos_abs_x; /* fill offset x added to fill offset */ + int abs_x; /* size of fill added to relative fill */ + int pos_abs_y; /* fill offset y added to fill offset */ + int abs_y; /* size of fill added to relative fill */ + int angle; /* angle of fill -- currently only used by grads */ + int spread; /* spread of fill -- currently only used by grads */ + char smooth; /* fill with smooth scaling or not */ + unsigned char type; /* fill coordinate from container (SCALE) or from source image (TILE) */ +}; + +struct _Edje_Part_Description_Spec_Border +{ + int l, r, t, b; /* border scaling on image fill */ + unsigned char no_fill; /* do we fill the center of the image if bordered? 1 == NO!!!! */ + unsigned char scale; /* scale image border by same as scale factor */ + 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" */ +}; + +struct _Edje_Part_Description_Spec_Image +{ + Edje_Part_Description_Spec_Fill fill; + + Edje_Part_Image_Id **tweens; /* list of Edje_Part_Image_Id */ + unsigned int tweens_count; /* number of tweens */ + + int id; /* the image id to use */ + int scale_hint; /* evas scale hint */ + Eina_Bool set; /* if image condition it's content */ + + Edje_Part_Description_Spec_Border border; +}; + +struct _Edje_Part_Description_Spec_Proxy +{ + Edje_Part_Description_Spec_Fill fill; + + int id; /* the part id to use as a source for this state */ +}; + +struct _Edje_Part_Description_Spec_Text +{ + Edje_String text; /* if "" or NULL, then leave text unchanged */ + char *text_class; /* how to apply/modify the font */ + Edje_String style; /* the text style if a textblock */ + Edje_String font; /* if a specific font is asked for */ + Edje_String repch; /* replacement char for password mode entry */ + + Edje_Alignment align; /* text alignment within bounds */ + Edje_Color color3; + + double elipsis; /* 0.0 - 1.0 defining where the elipsis align */ + int size; /* 0 = use user set size */ + int id_source; /* -1 if none */ + int id_text_source; /* -1 if none */ + + unsigned char fit_x; /* resize font size down to fit in x dir */ + unsigned char fit_y; /* resize font size down to fit in y dir */ + unsigned char min_x; /* if text size should be part min size */ + unsigned char min_y; /* if text size should be part min size */ + unsigned char max_x; /* if text size should be part max size */ + unsigned char max_y; /* if text size should be part max size */ + int size_range_min; + int size_range_max; /* -1 means, no bound. */ +}; + +struct _Edje_Part_Description_Spec_Box +{ + char *layout, *alt_layout; + Edje_Alignment align; + struct { + int x, y; + } padding; + struct { + unsigned char h, v; + } min; +}; + +struct _Edje_Part_Description_Spec_Table +{ + unsigned char homogeneous; + Edje_Alignment align; + struct { + int x, y; + } padding; + struct { + unsigned char h, v; + } min; +}; + +struct _Edje_Part_Description_Image +{ + Edje_Part_Description_Common common; + Edje_Part_Description_Spec_Image image; +}; + +struct _Edje_Part_Description_Proxy +{ + Edje_Part_Description_Common common; + Edje_Part_Description_Spec_Proxy proxy; +}; + +struct _Edje_Part_Description_Text +{ + Edje_Part_Description_Common common; + Edje_Part_Description_Spec_Text text; +}; + +struct _Edje_Part_Description_Box +{ + Edje_Part_Description_Common common; + Edje_Part_Description_Spec_Box box; +}; + +struct _Edje_Part_Description_Table +{ + Edje_Part_Description_Common common; + Edje_Part_Description_Spec_Table table; +}; + +struct _Edje_Part_Description_External +{ + Edje_Part_Description_Common common; + Eina_List *external_params; /* parameters for external objects */ +}; + +/*----------*/ + +struct _Edje_Signal_Source_Char +{ + EINA_RBTREE; + + const char *signal; + const char *source; + + Eina_List *list; +}; + +struct _Edje_Signals_Sources_Patterns + +{ + Edje_Patterns *signals_patterns; + Edje_Patterns *sources_patterns; + + Eina_Rbtree *exact_match; + + union { + struct { + Edje_Program **globing; + unsigned int count; + } programs; + struct { + Eina_List *globing; + } callbacks; + } u; +}; + +typedef struct _Edje_Signals_Sources_Patterns Edje_Signals_Sources_Patterns; + +struct _Edje +{ + Evas_Object_Smart_Clipped_Data base; + /* This contains (or should): + Evas_Object *clipper; // a big rect to clip this Edje to + Evas *evas; // the Evas this Edje belongs to + */ + const Edje_Smart_Api *api; + const char *path; + const char *group; + const char *parent; + + Evas_Coord x, y, w, h; + Edje_Size min; + double paused_at; + Evas_Object *obj; /* the smart object */ + Edje_File *file; /* the file the data comes form */ + Edje_Part_Collection *collection; /* the description being used */ + Eina_List *actions; /* currently running actions */ + Eina_List *callbacks; + Eina_List *pending_actions; + Eina_List *color_classes; + Eina_List *text_classes; + /* variable pool for Edje Embryo scripts */ + Edje_Var_Pool *var_pool; + /* for faster lookups to avoid nth list walks */ + Edje_Real_Part **table_parts; + Edje_Program **table_programs; + Edje_Real_Part *focused_part; + Eina_List *subobjs; + Eina_List *text_insert_filter_callbacks; + void *script_only_data; + + int table_programs_size; + unsigned int table_parts_size; + + struct { + Eina_Hash *text_class; + Eina_Hash *color_class; + } members; + + Edje_Perspective *persp; + + struct { + Edje_Signals_Sources_Patterns callbacks; + Edje_Signals_Sources_Patterns programs; + } patterns; + + int references; + int block; + int load_error; + int freeze; + FLOAT_T scale; + Eina_Bool is_rtl : 1; + + struct { + Edje_Text_Change_Cb func; + void *data; + } text_change; + + struct { + Edje_Message_Handler_Cb func; + void *data; + int num; + } message; + int processing_messages; + + int state; + + int preload_count; + + lua_State *L; + Eina_Inlist *lua_objs; + int lua_ref; + + struct { + Edje_Item_Provider_Cb func; + void *data; + } item_provider; + + unsigned int dirty : 1; + unsigned int recalc : 1; + unsigned int walking_callbacks : 1; + unsigned int delete_callbacks : 1; + unsigned int just_added_callbacks : 1; + unsigned int have_objects : 1; + unsigned int paused : 1; + unsigned int no_anim : 1; + unsigned int calc_only : 1; + unsigned int walking_actions : 1; + unsigned int block_break : 1; + unsigned int delete_me : 1; + unsigned int postponed : 1; + unsigned int freeze_calc : 1; + unsigned int has_entries : 1; + unsigned int entries_inited : 1; +#ifdef EDJE_CALC_CACHE + unsigned int text_part_change : 1; + unsigned int all_part_change : 1; +#endif + unsigned int have_mapped_part : 1; +}; + +struct _Edje_Calc_Params +{ + int x, y, w, h; // 16 + Edje_Rectangle req; // 16 + Edje_Rectangle req_drag; // 16 + Edje_Color color; // 4 + union { + struct { + struct { + int x, y, w, h; // 16 + int angle; // 4 + int spread; // 4 + } fill; // 24 + + union { + struct { + int l, r, t, b; // 16 + } image; // 16 + } spec; // 16 + } common; // 40 + struct { + Edje_Alignment align; /* text alignment within bounds */ // 16 + double elipsis; // 8 + int size; // 4 + Edje_Color color2, color3; // 8 + } text; // 36 + } type; // 40 + struct { + struct { + int x, y, z; + } center; // 12 + struct { + double x, y, z; + } rotation; // 24 + struct { + int x, y, z; + int r, g, b; + int ar, ag, ab; + } light; // 36 + struct { + int x, y, z; + int focal; + } persp; + } map; + unsigned char persp_on : 1; + unsigned char lighted : 1; + unsigned char mapped : 1; + unsigned char visible : 1; + unsigned char smooth : 1; // 1 +}; // 96 + +struct _Edje_Real_Part_Set +{ + Edje_Image_Directory_Set_Entry *entry; // 4 + Edje_Image_Directory_Set *set; // 4 + + int id; // 4 +}; + +struct _Edje_Real_Part_State +{ + Edje_Part_Description_Common *description; // 4 + Edje_Part_Description_Common *description_rtl; // 4 + Edje_Real_Part *rel1_to_x; // 4 + Edje_Real_Part *rel1_to_y; // 4 + Edje_Real_Part *rel2_to_x; // 4 + Edje_Real_Part *rel2_to_y; // 4 +#ifdef EDJE_CALC_CACHE + int state; // 4 + Edje_Calc_Params p; // 96 +#endif + void *external_params; // 4 + Edje_Real_Part_Set *set; // 4 +}; // 32 +// WITH EDJE_CALC_CACHE 132 + +struct _Edje_Real_Part_Drag +{ + FLOAT_T x, y; // 16 + Edje_Position_Scale val, size, step, page; // 64 + struct { + unsigned int count; // 4 + int x, y; // 8 + } down; + struct { + int x, y; // 8 + } tmp; + unsigned char need_reset : 1; // 4 + Edje_Real_Part *confine_to; // 4 +}; // 104 + +struct _Edje_Real_Part +{ + Edje *edje; // 4 + Edje_Part *part; // 4 + Evas_Object *object; // 4 + int x, y, w, h; // 16 + Edje_Rectangle req; // 16 + + Eina_List *items; // 4 //FIXME: only if table/box + Edje_Part_Box_Animation *anim; // 4 //FIXME: Used only if box + void *entry_data; // 4 // FIXME: move to entry section + + Evas_Object *swallowed_object; // 4 // FIXME: move with swallow_params data + struct { + Edje_Size min, max; // 16 + Edje_Aspect aspect; // 12 + } swallow_params; // 28 // FIXME: only if type SWALLOW + + Edje_Real_Part_Drag *drag; // 4 + Edje_Real_Part *events_to; // 4 + + struct { + Edje_Real_Part *source; // 4 + Edje_Real_Part *text_source; // 4 + const char *text; // 4 + Edje_Position offset; // 8 text only + const char *font; // 4 text only + const char *style; // 4 text only + int size; // 4 text only + struct { + double in_w, in_h; // 16 text only + int in_size; // 4 text only + const char *in_str; // 4 text only + const char *out_str; // 4 text only + int out_size; // 4 text only + FLOAT_T align_x, align_y; // 16 text only + double elipsis; // 8 text only + int fit_x, fit_y; // 8 text only + } cache; // 64 + } text; // 86 // FIXME make text a potiner to struct and alloc at end + // if part type is TEXT move common members textblock + + // text to front and have smaller struct for textblock + + FLOAT_T description_pos; // 8 + Edje_Part_Description_Common *chosen_description; // 4 + Edje_Real_Part_State param1; // 20 + // WITH EDJE_CALC_CACHE: 140 + Edje_Real_Part_State *param2, *custom; // 8 + Edje_Calc_Params *current; // 4 + +#ifdef EDJE_CALC_CACHE + int state; // 4 +#endif + + Edje_Real_Part *clip_to; // 4 + + Edje_Running_Program *program; // 4 + + int clicked_button; // 4 + + unsigned char calculated; // 1 + unsigned char calculating; // 1 + + unsigned char still_in : 1; // 1 +#ifdef EDJE_CALC_CACHE + unsigned char invalidate : 1; // 0 +#endif +}; // 264 +// WITH EDJE_CALC_CACHE: 404 + +struct _Edje_Running_Program +{ + Edje *edje; + Edje_Program *program; + double start_time; + char delete_me : 1; +}; + +struct _Edje_Signal_Callback +{ + const char *signal; + const char *source; + Edje_Signal_Cb func; + void *data; + unsigned char just_added : 1; + unsigned char delete_me : 1; + unsigned char propagate : 1; +}; + +struct _Edje_Text_Insert_Filter_Callback +{ + const char *part; + Edje_Text_Filter_Cb func; + void *data; +}; + +struct _Edje_Pending_Program +{ + Edje *edje; + Edje_Program *program; + Ecore_Timer *timer; +}; + +struct _Edje_Text_Style +{ + struct { + unsigned char x, y; + } offset; + struct { + unsigned char l, r, t, b; + } pad; + int num; + struct { + unsigned char color; /* 0 = color, 1, 2 = color2, color3 */ + signed char x, y; /* offset */ + unsigned char alpha; + } members[32]; +}; + +struct _Edje_Color_Class +{ + const char *name; + unsigned char r, g, b, a; + unsigned char r2, g2, b2, a2; + unsigned char r3, g3, b3, a3; +}; + +struct _Edje_Text_Class +{ + const char *name; + const char *font; + Evas_Font_Size size; +}; + +struct _Edje_Var_Int +{ + int v; +}; + +struct _Edje_Var_Float +{ + double v; +}; + +struct _Edje_Var_String +{ + char *v; +}; + +struct _Edje_Var_List +{ + Eina_List *v; +}; + +struct _Edje_Var_Hash +{ + Eina_Hash *v; +}; + +struct _Edje_Var_Timer +{ + Edje *edje; + int id; + Embryo_Function func; + int val; + Ecore_Timer *timer; +}; + +struct _Edje_Var_Animator +{ + Edje *edje; + int id; + Embryo_Function func; + int val; + double start, len; + char delete_me; +}; + +struct _Edje_Var_Pool +{ + int id_count; + Eina_List *timers; + Eina_List *animators; + int size; + Edje_Var *vars; + int walking_list; +}; + +struct _Edje_Var +{ + union { + Edje_Var_Int i; + Edje_Var_Float f; + Edje_Var_String s; + Edje_Var_List l; + Edje_Var_Hash h; + } data; + unsigned char type; +}; + +typedef enum _Edje_Queue +{ + EDJE_QUEUE_APP, + EDJE_QUEUE_SCRIPT +} Edje_Queue; + +typedef struct _Edje_Message_Signal Edje_Message_Signal; +typedef struct _Edje_Message Edje_Message; + +typedef struct _Edje_Message_Signal_Data Edje_Message_Signal_Data; +struct _Edje_Message_Signal_Data +{ + int ref; + void *data; + void (*free_func)(void *); +}; + +struct _Edje_Message_Signal +{ + const char *sig; + const char *src; + Edje_Message_Signal_Data *data; +}; + +struct _Edje_Message +{ + Edje *edje; + Edje_Queue queue; + Edje_Message_Type type; + int id; + unsigned char *msg; + Eina_Bool propagated : 1; +}; + +typedef enum _Edje_Fill +{ + EDJE_FILL_TYPE_SCALE = 0, + EDJE_FILL_TYPE_TILE +} Edje_Fill; + +typedef enum _Edje_Match_Error +{ + EDJE_MATCH_OK, + EDJE_MATCH_ALLOC_ERROR, + EDJE_MATCH_SYNTAX_ERROR + +} Edje_Match_Error; + +typedef struct _Edje_States Edje_States; +struct _Edje_Patterns +{ + const char **patterns; + + Edje_States *states; + + int ref; + Eina_Bool delete_me : 1; + + size_t patterns_size; + size_t max_length; + size_t finals[]; +}; + +Edje_Patterns *edje_match_collection_dir_init(const Eina_List *lst); +Edje_Patterns *edje_match_programs_signal_init(Edje_Program * const *array, + unsigned int count); +Edje_Patterns *edje_match_programs_source_init(Edje_Program * const *array, + unsigned int count); +Edje_Patterns *edje_match_callback_signal_init(const Eina_List *lst); +Edje_Patterns *edje_match_callback_source_init(const Eina_List *lst); + +Eina_Bool edje_match_collection_dir_exec(const Edje_Patterns *ppat, + const char *string); +Eina_Bool edje_match_programs_exec(const Edje_Patterns *ppat_signal, + const Edje_Patterns *ppat_source, + const char *signal, + const char *source, + Edje_Program **programs, + Eina_Bool (*func)(Edje_Program *pr, void *data), + void *data, + Eina_Bool prop); +int edje_match_callback_exec(Edje_Patterns *ppat_signal, + Edje_Patterns *ppat_source, + const char *signal, + const char *source, + Eina_List *callbacks, + Edje *ed, + Eina_Bool prop); + +void edje_match_patterns_free(Edje_Patterns *ppat); + +Eina_List *edje_match_program_hash_build(Edje_Program * const * programs, + unsigned int count, + Eina_Rbtree **tree); +Eina_List *edje_match_callback_hash_build(const Eina_List *callbacks, + Eina_Rbtree **tree); +const Eina_List *edje_match_signal_source_hash_get(const char *signal, + const char *source, + const Eina_Rbtree *tree); +void edje_match_signal_source_free(Edje_Signal_Source_Char *key, void *data); + +// FIXME remove below 2 eapi decls when edje_convert goes +EAPI void _edje_edd_init(void); +EAPI void _edje_edd_shutdown(void); + +EAPI extern Eet_Data_Descriptor *_edje_edd_edje_file; +EAPI extern Eet_Data_Descriptor *_edje_edd_edje_part_collection; + +extern int _edje_anim_count; +extern Ecore_Animator *_edje_timer; +extern Eina_List *_edje_animators; +extern Eina_List *_edje_edjes; + +extern char *_edje_fontset_append; +extern FLOAT_T _edje_scale; +extern int _edje_freeze_val; +extern int _edje_freeze_calc_count; +extern Eina_List *_edje_freeze_calc_list; + +extern Eina_Bool _edje_password_show_last; +extern FLOAT_T _edje_password_show_last_timeout; + +extern Eina_Mempool *_edje_real_part_mp; +extern Eina_Mempool *_edje_real_part_state_mp; + +extern Eina_Mempool *_emp_RECTANGLE; +extern Eina_Mempool *_emp_TEXT; +extern Eina_Mempool *_emp_IMAGE; +extern Eina_Mempool *_emp_PROXY; +extern Eina_Mempool *_emp_SWALLOW; +extern Eina_Mempool *_emp_TEXTBLOCK; +extern Eina_Mempool *_emp_GROUP; +extern Eina_Mempool *_emp_BOX; +extern Eina_Mempool *_emp_TABLE; +extern Eina_Mempool *_emp_EXTERNAL; +extern Eina_Mempool *_emp_part; + +void _edje_part_pos_set(Edje *ed, Edje_Real_Part *ep, int mode, FLOAT_T pos, FLOAT_T v1, FLOAT_T v2); +Edje_Part_Description_Common *_edje_part_description_find(Edje *ed, + Edje_Real_Part *rp, + const char *name, double val); +void _edje_part_description_apply(Edje *ed, Edje_Real_Part *ep, const char *d1, double v1, const char *d2, double v2); +void _edje_recalc(Edje *ed); +void _edje_recalc_do(Edje *ed); +void _edje_part_recalc_1(Edje *ed, Edje_Real_Part *ep); +int _edje_part_dragable_calc(Edje *ed, Edje_Real_Part *ep, FLOAT_T *x, FLOAT_T *y); +void _edje_dragable_pos_set(Edje *ed, Edje_Real_Part *ep, FLOAT_T x, FLOAT_T y); + +Eina_Bool _edje_timer_cb(void *data); +Eina_Bool _edje_pending_timer_cb(void *data); +void _edje_callbacks_add(Evas_Object *obj, Edje *ed, Edje_Real_Part *rp); +void _edje_callbacks_focus_add(Evas_Object *obj, Edje *ed, Edje_Real_Part *rp); +void _edje_callbacks_del(Evas_Object *obj, Edje *ed); +void _edje_callbacks_focus_del(Evas_Object *obj, Edje *ed); + +void _edje_edd_init(void); +void _edje_edd_shutdown(void); + +int _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *group, const char *parent, Eina_List *group_path); + +void _edje_file_add(Edje *ed); +void _edje_file_del(Edje *ed); +void _edje_file_free(Edje_File *edf); +void _edje_file_cache_shutdown(void); +void _edje_collection_free(Edje_File *edf, + Edje_Part_Collection *ec, + Edje_Part_Collection_Directory_Entry *ce); +void _edje_collection_free_part_description_clean(int type, + Edje_Part_Description_Common *desc, + Eina_Bool free_strings); +void _edje_collection_free_part_description_free(int type, + Edje_Part_Description_Common *desc, + Edje_Part_Collection_Directory_Entry *ce, + Eina_Bool free_strings); + +void _edje_object_smart_set(Edje_Smart_Api *sc); +const Edje_Smart_Api * _edje_object_smart_class_get(void); + +void _edje_del(Edje *ed); +void _edje_ref(Edje *ed); +void _edje_unref(Edje *ed); +void _edje_clean_objects(Edje *ed); +void _edje_ref(Edje *ed); +void _edje_unref(Edje *ed); + +Eina_Bool _edje_program_run_iterate(Edje_Running_Program *runp, double tim); +void _edje_program_end(Edje *ed, Edje_Running_Program *runp); +void _edje_program_run(Edje *ed, Edje_Program *pr, Eina_Bool force, const char *ssig, const char *ssrc); +void _edje_programs_patterns_clean(Edje *ed); +void _edje_programs_patterns_init(Edje *ed); +void _edje_emit(Edje *ed, const char *sig, const char *src); +void _edje_emit_full(Edje *ed, const char *sig, const char *src, void *data, void (*free_func)(void *)); +void _edje_emit_handle(Edje *ed, const char *sig, const char *src, Edje_Message_Signal_Data *data, Eina_Bool prop); +void _edje_signals_sources_patterns_clean(Edje_Signals_Sources_Patterns *ssp); +void _edje_callbacks_patterns_clean(Edje *ed); + +void _edje_text_init(void); +void _edje_text_part_on_add(Edje *ed, Edje_Real_Part *ep); +void _edje_text_part_on_del(Edje *ed, Edje_Part *ep); +void _edje_text_recalc_apply(Edje *ed, + Edje_Real_Part *ep, + Edje_Calc_Params *params, + Edje_Part_Description_Text *chosen_desc); +Evas_Font_Size _edje_text_size_calc(Evas_Font_Size size, Edje_Text_Class *tc); +const char * _edje_text_class_font_get(Edje *ed, + Edje_Part_Description_Text *chosen_desc, + int *size, char **free_later); + + +Edje_Real_Part *_edje_real_part_get(const Edje *ed, const char *part); +Edje_Real_Part *_edje_real_part_recursive_get(const Edje *ed, const char *part); +Edje_Color_Class *_edje_color_class_find(Edje *ed, const char *color_class); +void _edje_color_class_member_direct_del(const char *color_class, void *lookup); +void _edje_color_class_member_add(Edje *ed, const char *color_class); +void _edje_color_class_member_del(Edje *ed, const char *color_class); +void _edje_color_class_on_del(Edje *ed, Edje_Part *ep); +void _edje_color_class_members_free(void); +void _edje_color_class_hash_free(void); + +Edje_Text_Class *_edje_text_class_find(Edje *ed, const char *text_class); +void _edje_text_class_member_add(Edje *ed, const char *text_class); +void _edje_text_class_member_del(Edje *ed, const char *text_class); +void _edje_text_class_member_direct_del(const char *text_class, void *lookup); +void _edje_text_class_members_free(void); +void _edje_text_class_hash_free(void); + +Edje *_edje_fetch(const Evas_Object *obj) EINA_PURE; +int _edje_freeze(Edje *ed); +int _edje_thaw(Edje *ed); +int _edje_block(Edje *ed); +int _edje_unblock(Edje *ed); +int _edje_block_break(Edje *ed); +void _edje_block_violate(Edje *ed); +void _edje_object_part_swallow_free_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); +void _edje_object_part_swallow_changed_hints_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); +void _edje_real_part_swallow(Edje_Real_Part *rp, Evas_Object *obj_swallow, Eina_Bool hints_update); +void _edje_real_part_swallow_clear(Edje_Real_Part *rp); +void _edje_box_init(void); +void _edje_box_shutdown(void); +Eina_Bool _edje_box_layout_find(const char *name, Evas_Object_Box_Layout *cb, void **data, void (**free_data)(void *data)); +void _edje_box_recalc_apply(Edje *ed __UNUSED__, Edje_Real_Part *ep, Edje_Calc_Params *p3, Edje_Part_Description_Box *chosen_desc); +Eina_Bool _edje_box_layout_add_child(Edje_Real_Part *rp, Evas_Object *child_obj); +void _edje_box_layout_remove_child(Edje_Real_Part *rp, Evas_Object *child_obj); +Edje_Part_Box_Animation * _edje_box_layout_anim_new(Evas_Object *box); +void _edje_box_layout_free_data(void *data); + +Eina_Bool _edje_real_part_box_append(Edje_Real_Part *rp, Evas_Object *child_obj); +Eina_Bool _edje_real_part_box_prepend(Edje_Real_Part *rp, Evas_Object *child_obj); +Eina_Bool _edje_real_part_box_insert_before(Edje_Real_Part *rp, Evas_Object *child_obj, const Evas_Object *ref); +Eina_Bool _edje_real_part_box_insert_at(Edje_Real_Part *rp, Evas_Object *child_obj, unsigned int pos); +Evas_Object *_edje_real_part_box_remove(Edje_Real_Part *rp, Evas_Object *child_obj); +Evas_Object *_edje_real_part_box_remove_at(Edje_Real_Part *rp, unsigned int pos); +Eina_Bool _edje_real_part_box_remove_all(Edje_Real_Part *rp, Eina_Bool clear); +Eina_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); +Eina_Bool _edje_real_part_table_unpack(Edje_Real_Part *rp, Evas_Object *child_obj); +void _edje_real_part_table_clear(Edje_Real_Part *rp, Eina_Bool clear); +Evas_Object *_edje_children_get(Edje_Real_Part *rp, const char *partid); + +Eina_Bool _edje_object_part_text_raw_set(Evas_Object *obj, Edje_Real_Part *rp, const char *part, const char *text); +char *_edje_text_escape(const char *text); +char *_edje_text_unescape(const char *text); + +void _edje_embryo_script_init (Edje_Part_Collection *edc); +void _edje_embryo_script_shutdown (Edje_Part_Collection *edc); +void _edje_embryo_script_reset (Edje *ed); +void _edje_embryo_test_run (Edje *ed, const char *fname, const char *sig, const char *src); +Edje_Var *_edje_var_new (void); +void _edje_var_free (Edje_Var *var); +void _edje_var_init (Edje *ed); +void _edje_var_shutdown (Edje *ed); +int _edje_var_string_id_get (Edje *ed, const char *string); +int _edje_var_var_int_get (Edje *ed, Edje_Var *var); +void _edje_var_var_int_set (Edje *ed, Edje_Var *var, int v); +double _edje_var_var_float_get (Edje *ed, Edje_Var *var); +void _edje_var_var_float_set (Edje *ed, Edje_Var *var, double v); +const char *_edje_var_var_str_get (Edje *ed, Edje_Var *var); +void _edje_var_var_str_set (Edje *ed, Edje_Var *var, const char *str); +int _edje_var_int_get (Edje *ed, int id); +void _edje_var_int_set (Edje *ed, int id, int v); +double _edje_var_float_get (Edje *ed, int id); +void _edje_var_float_set (Edje *ed, int id, double v); +const char *_edje_var_str_get (Edje *ed, int id); +void _edje_var_str_set (Edje *ed, int id, const char *str); + +void _edje_var_list_var_append(Edje *ed, int id, Edje_Var *var); +void _edje_var_list_var_prepend(Edje *ed, int id, Edje_Var *var); +void _edje_var_list_var_append_relative(Edje *ed, int id, Edje_Var *var, Edje_Var *relative); +void _edje_var_list_var_prepend_relative(Edje *ed, int id, Edje_Var *var, Edje_Var *relative); +Edje_Var *_edje_var_list_nth(Edje *ed, int id, int n); + +int _edje_var_list_count_get(Edje *ed, int id); +void _edje_var_list_remove_nth(Edje *ed, int id, int n); + +int _edje_var_list_nth_int_get(Edje *ed, int id, int n); +void _edje_var_list_nth_int_set(Edje *ed, int id, int n, int v); +void _edje_var_list_int_append(Edje *ed, int id, int v); +void _edje_var_list_int_prepend(Edje *ed, int id, int v); +void _edje_var_list_int_insert(Edje *ed, int id, int n, int v); + +double _edje_var_list_nth_float_get(Edje *ed, int id, int n); +void _edje_var_list_nth_float_set(Edje *ed, int id, int n, double v); +void _edje_var_list_float_append(Edje *ed, int id, double v); +void _edje_var_list_float_prepend(Edje *ed, int id, double v); +void _edje_var_list_float_insert(Edje *ed, int id, int n, double v); + +const char *_edje_var_list_nth_str_get(Edje *ed, int id, int n); +void _edje_var_list_nth_str_set(Edje *ed, int id, int n, const char *v); +void _edje_var_list_str_append(Edje *ed, int id, const char *v); +void _edje_var_list_str_prepend(Edje *ed, int id, const char *v); +void _edje_var_list_str_insert(Edje *ed, int id, int n, const char *v); + +int _edje_var_timer_add (Edje *ed, double in, const char *fname, int val); +void _edje_var_timer_del (Edje *ed, int id); + +int _edje_var_anim_add (Edje *ed, double len, const char *fname, int val); +void _edje_var_anim_del (Edje *ed, int id); + +void _edje_message_init (void); +void _edje_message_shutdown (void); +void _edje_message_cb_set (Edje *ed, void (*func) (void *data, Evas_Object *obj, Edje_Message_Type type, int id, void *msg), void *data); +Edje_Message *_edje_message_new (Edje *ed, Edje_Queue queue, Edje_Message_Type type, int id); +void _edje_message_free (Edje_Message *em); +void _edje_message_propornot_send (Edje *ed, Edje_Queue queue, Edje_Message_Type type, int id, void *emsg, Eina_Bool prop); +void _edje_message_send (Edje *ed, Edje_Queue queue, Edje_Message_Type type, int id, void *emsg); +void _edje_message_parameters_push (Edje_Message *em); +void _edje_message_process (Edje_Message *em); +void _edje_message_queue_process (void); +void _edje_message_queue_clear (void); +void _edje_message_del (Edje *ed); + +void _edje_textblock_styles_add(Edje *ed); +void _edje_textblock_styles_del(Edje *ed); +void _edje_textblock_style_all_update(Edje *ed); +void _edje_textblock_style_parse_and_fix(Edje_File *edf); +void _edje_textblock_style_cleanup(Edje_File *edf); +Edje_File *_edje_cache_file_coll_open(const char *file, const char *coll, int *error_ret, Edje_Part_Collection **edc_ret); +void _edje_cache_coll_clean(Edje_File *edf); +void _edje_cache_coll_flush(Edje_File *edf); +void _edje_cache_coll_unref(Edje_File *edf, Edje_Part_Collection *edc); +void _edje_cache_file_unref(Edje_File *edf); + +void _edje_embryo_globals_init(Edje *ed); + +#define CHKPARAM(n) if (params[0] != (sizeof(Embryo_Cell) * (n))) return -1; +#define GETSTR(str, par) { \ + Embryo_Cell *___cptr; \ + int ___l; \ + str = NULL; \ + if ((___cptr = embryo_data_address_get(ep, (par)))) { \ + ___l = embryo_data_string_length_get(ep, ___cptr); \ + if (((str) = alloca(___l + 1))) \ + embryo_data_string_get(ep, ___cptr, (str)); } } +#define GETSTREVAS(str, par) { \ + if ((str)) { \ + if ((par) && (!strcmp((par), (str)))) return 0; \ + if ((par)) eina_stringshare_del((par)); \ + (par) = (char *)eina_stringshare_add((str)); } \ + else (par) = NULL; } +#define GETFLOAT(val, par) { \ + float *___cptr; \ + if ((___cptr = (float *)embryo_data_address_get(ep, (par)))) { \ + val = *___cptr; } } + +#define GETFLOAT_T(val, par) \ + { \ + float *___cptr; \ + if ((___cptr = (float *)embryo_data_address_get(ep, (par)))) \ + { \ + val = FROM_DOUBLE(*___cptr); \ + } \ + } + +#define GETINT(val, par) { \ + int *___cptr; \ + if ((___cptr = (int *)embryo_data_address_get(ep, (par)))) { \ + val = *___cptr; } } +#define SETSTR(str, par) { \ + Embryo_Cell *___cptr; \ + if ((___cptr = embryo_data_address_get(ep, (par)))) { \ + embryo_data_string_set(ep, str, ___cptr); } } +#define SETSTRALLOCATE(s) \ + { \ + if (s) { \ + if ((int) strlen((s)) < params[4]) { \ + SETSTR((s), params[3]); } \ + else { \ + char *ss; \ + ss = alloca(strlen((s)) + 1); \ + strcpy(ss, (s)); \ + ss[params[4] - 2] = 0; \ + SETSTR(ss, params[3]); } } \ + else \ + SETSTR("", params[3]); \ + } +#define SETFLOAT(val, par) { \ + float *___cptr; \ + if ((___cptr = (float *)embryo_data_address_get(ep, (par)))) { \ + *___cptr = (float)val; } } +#define SETFLOAT_T(val, par) \ + { \ + float *___cptr; \ + if ((___cptr = (float *)embryo_data_address_get(ep, (par)))) \ + { \ + *___cptr = (float) TO_DOUBLE(val); \ + } \ + } +#define SETINT(val, par) { \ + int *___cptr; \ + if ((___cptr = (int *)embryo_data_address_get(ep, (par)))) { \ + *___cptr = (int)val; } } + +Eina_Bool _edje_script_only(Edje *ed); +void _edje_script_only_init(Edje *ed); +void _edje_script_only_shutdown(Edje *ed); +void _edje_script_only_show(Edje *ed); +void _edje_script_only_hide(Edje *ed); +void _edje_script_only_move(Edje *ed); +void _edje_script_only_resize(Edje *ed); +void _edje_script_only_message(Edje *ed, Edje_Message *em); + +extern jmp_buf _edje_lua_panic_jmp; +#define _edje_lua_panic_here() setjmp(_edje_lua_panic_jmp) + +lua_State *_edje_lua_state_get(); +lua_State *_edje_lua_new_thread(Edje *ed, lua_State *L); +void _edje_lua_free_thread(Edje *ed, lua_State *L); +void _edje_lua_new_reg(lua_State *L, int index, void *ptr); +void _edje_lua_get_reg(lua_State *L, void *ptr); +void _edje_lua_free_reg(lua_State *L, void *ptr); +void _edje_lua_script_fn_new(Edje *ed); +void _edje_lua_group_fn_new(Edje *ed); +void _edje_lua_init(); +void _edje_lua_shutdown(); + +void __edje_lua_error(const char *file, const char *fnc, int line, lua_State *L, int err_code); +#define _edje_lua_error(L, err_code) \ + __edje_lua_error(__FILE__, __FUNCTION__, __LINE__, L, err_code) + +Eina_Bool _edje_lua_script_only(Edje *ed); +void _edje_lua_script_only_init(Edje *ed); +void _edje_lua_script_only_shutdown(Edje *ed); +void _edje_lua_script_only_show(Edje *ed); +void _edje_lua_script_only_hide(Edje *ed); +void _edje_lua_script_only_move(Edje *ed); +void _edje_lua_script_only_resize(Edje *ed); +void _edje_lua_script_only_message(Edje *ed, Edje_Message *em); + +void _edje_entry_init(Edje *ed); +void _edje_entry_shutdown(Edje *ed); +void _edje_entry_real_part_init(Edje_Real_Part *rp); +void _edje_entry_real_part_shutdown(Edje_Real_Part *rp); +void _edje_entry_real_part_configure(Edje_Real_Part *rp); +const char *_edje_entry_selection_get(Edje_Real_Part *rp); +const char *_edje_entry_text_get(Edje_Real_Part *rp); +void _edje_entry_text_markup_set(Edje_Real_Part *rp, const char *text); +void _edje_entry_text_markup_insert(Edje_Real_Part *rp, const char *text); +void _edje_entry_text_markup_append(Edje_Real_Part *rp, const char *text); +void _edje_entry_set_cursor_start(Edje_Real_Part *rp); +void _edje_entry_set_cursor_end(Edje_Real_Part *rp); +void _edje_entry_cursor_copy(Edje_Real_Part *rp, Edje_Cursor cur, Edje_Cursor dst); +void _edje_entry_select_none(Edje_Real_Part *rp); +void _edje_entry_select_all(Edje_Real_Part *rp); +void _edje_entry_select_begin(Edje_Real_Part *rp); +void _edje_entry_select_extend(Edje_Real_Part *rp); +const Eina_List *_edje_entry_anchor_geometry_get(Edje_Real_Part *rp, const char *anchor); +const Eina_List *_edje_entry_anchors_list(Edje_Real_Part *rp); +Eina_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); +const Eina_List *_edje_entry_items_list(Edje_Real_Part *rp); +void _edje_entry_cursor_geometry_get(Edje_Real_Part *rp, Evas_Coord *cx, Evas_Coord *cy, Evas_Coord *cw, Evas_Coord *ch); +void _edje_entry_select_allow_set(Edje_Real_Part *rp, Eina_Bool allow); +Eina_Bool _edje_entry_select_allow_get(const Edje_Real_Part *rp); +void _edje_entry_select_abort(Edje_Real_Part *rp); + +Eina_Bool _edje_entry_cursor_next(Edje_Real_Part *rp, Edje_Cursor cur); +Eina_Bool _edje_entry_cursor_prev(Edje_Real_Part *rp, Edje_Cursor cur); +Eina_Bool _edje_entry_cursor_up(Edje_Real_Part *rp, Edje_Cursor cur); +Eina_Bool _edje_entry_cursor_down(Edje_Real_Part *rp, Edje_Cursor cur); +void _edje_entry_cursor_begin(Edje_Real_Part *rp, Edje_Cursor cur); +void _edje_entry_cursor_end(Edje_Real_Part *rp, Edje_Cursor cur); +void _edje_entry_cursor_line_begin(Edje_Real_Part *rp, Edje_Cursor cur); +void _edje_entry_cursor_line_end(Edje_Real_Part *rp, Edje_Cursor cur); +Eina_Bool _edje_entry_cursor_coord_set(Edje_Real_Part *rp, Edje_Cursor cur, int x, int y); +Eina_Bool _edje_entry_cursor_is_format_get(Edje_Real_Part *rp, Edje_Cursor cur); +Eina_Bool _edje_entry_cursor_is_visible_format_get(Edje_Real_Part *rp, Edje_Cursor cur); +const char *_edje_entry_cursor_content_get(Edje_Real_Part *rp, Edje_Cursor cur); +void _edje_entry_cursor_pos_set(Edje_Real_Part *rp, Edje_Cursor cur, int pos); +int _edje_entry_cursor_pos_get(Edje_Real_Part *rp, Edje_Cursor cur); +void _edje_entry_input_panel_layout_set(Edje_Real_Part *rp, Edje_Input_Panel_Layout layout); +Edje_Input_Panel_Layout _edje_entry_input_panel_layout_get(Edje_Real_Part *rp); +void _edje_entry_autocapital_type_set(Edje_Real_Part *rp, Edje_Text_Autocapital_Type autocapital_type); +Edje_Text_Autocapital_Type _edje_entry_autocapital_type_get(Edje_Real_Part *rp); +void _edje_entry_input_panel_enabled_set(Edje_Real_Part *rp, Eina_Bool enabled); +Eina_Bool _edje_entry_input_panel_enabled_get(Edje_Real_Part *rp); + +void _edje_external_init(); +void _edje_external_shutdown(); +Evas_Object *_edje_external_type_add(const char *type_name, Evas *evas, Evas_Object *parent, const Eina_List *params, const char *part_name); +void _edje_external_signal_emit(Evas_Object *obj, const char *emission, const char *source); +Eina_Bool _edje_external_param_set(Evas_Object *obj, Edje_Real_Part *rp, const Edje_External_Param *param) EINA_ARG_NONNULL(2); +Eina_Bool _edje_external_param_get(const Evas_Object *obj, Edje_Real_Part *rp, Edje_External_Param *param) EINA_ARG_NONNULL(2); +Evas_Object *_edje_external_content_get(const Evas_Object *obj, const char *content) EINA_ARG_NONNULL(1, 2); +void _edje_external_params_free(Eina_List *params, Eina_Bool free_strings); +void _edje_external_recalc_apply(Edje *ed, Edje_Real_Part *ep, + Edje_Calc_Params *params, + Edje_Part_Description_Common *chosen_desc); +void *_edje_external_params_parse(Evas_Object *obj, const Eina_List *params); +void _edje_external_parsed_params_free(Evas_Object *obj, void *params); + +Eina_Module *_edje_module_handle_load(const char *module); +void _edje_module_init(); +void _edje_module_shutdown(); + +static inline Eina_Bool +edje_program_is_strncmp(const char *str) +{ + size_t length; + + length = strlen(str); + + if (strpbrk(str, "*?[\\") != str + length) + return EINA_FALSE; + if (str[length] == '[' + || str[length] == '\\') + return EINA_FALSE; + return EINA_TRUE; +} + +static inline Eina_Bool +edje_program_is_strrncmp(const char *str) +{ + if (*str != '*' && *str != '?') + return EINA_FALSE; + if (strpbrk(str + 1, "*?[\\")) + return EINA_FALSE; + return EINA_TRUE; +} +void edje_object_propagate_callback_add(Evas_Object *obj, void (*func) (void *data, Evas_Object *o, const char *emission, const char *source), void *data); + + +/* used by edje_cc - private still */ +EAPI void _edje_program_insert(Edje_Part_Collection *ed, Edje_Program *p); +EAPI void _edje_program_remove(Edje_Part_Collection *ed, Edje_Program *p); + +void _edje_lua2_error_full(const char *file, const char *fnc, int line, lua_State *L, int err_code); +#define _edje_lua2_error(L, err_code) _edje_lua2_error_full(__FILE__, __FUNCTION__, __LINE__, L, err_code) +void _edje_lua2_script_init(Edje *ed); +void _edje_lua2_script_shutdown(Edje *ed); +void _edje_lua2_script_load(Edje_Part_Collection *edc, void *data, int size); +void _edje_lua2_script_unload(Edje_Part_Collection *edc); + +void _edje_lua2_script_func_shutdown(Edje *ed); +void _edje_lua2_script_func_show(Edje *ed); +void _edje_lua2_script_func_hide(Edje *ed); +void _edje_lua2_script_func_move(Edje *ed); +void _edje_lua2_script_func_resize(Edje *ed); +void _edje_lua2_script_func_message(Edje *ed, Edje_Message *em); +void _edje_lua2_script_func_signal(Edje *ed, const char *sig, const char *src); + +const char *edje_string_get(const Edje_String *es); +const char *edje_string_id_get(const Edje_String *es); + +void _edje_object_orientation_inform(Evas_Object *obj); + +void _edje_lib_ref(void); +void _edje_lib_unref(void); + +void _edje_subobj_register(Edje *ed, Evas_Object *ob); + +void _edje_multisense_init(void); +void _edje_multisense_shutdown(void); +Eina_Bool _edje_multisense_internal_sound_sample_play(Edje *ed, const char *sample_name, const double speed); +Eina_Bool _edje_multisense_internal_sound_tone_play(Edje *ed, const char *tone_name, const double duration); + +void _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *state); + +#ifdef HAVE_LIBREMIX +#include +#endif +#include + +typedef struct _Edje_Multisense_Env Edje_Multisense_Env; + +struct _Edje_Multisense_Env +{ +#ifdef HAVE_LIBREMIX + RemixEnv *remixenv; +#endif +}; + +typedef Eina_Bool (*MULTISENSE_FACTORY_INIT_FUNC) (Edje_Multisense_Env *); +#ifdef HAVE_LIBREMIX +typedef RemixBase* (*MULTISENSE_SOUND_PLAYER_GET_FUNC) (Edje_Multisense_Env *); +#endif + +#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 @@ +#include "edje_private.h" + +static void _edje_emit_cb(Edje *ed, const char *sig, const char *src, Edje_Message_Signal_Data *data, Eina_Bool prop); +static void _edje_param_copy(Edje_Real_Part *src_part, const char *src_param, Edje_Real_Part *dst_part, const char *dst_param); +static void _edje_param_set(Edje_Real_Part *part, const char *param, const char *value); + +int _edje_anim_count = 0; +Ecore_Animator *_edje_timer = NULL; +Eina_List *_edje_animators = NULL; + + +/*============================================================================* + * API * + *============================================================================*/ + +EAPI void +edje_frametime_set(double t) +{ + ecore_animator_frametime_set(t); +} + +EAPI double +edje_frametime_get(void) +{ + return ecore_animator_frametime_get(); +} + +void +edje_object_propagate_callback_add(Evas_Object *obj, void (*func) (void *data, Evas_Object *o, const char *emission, const char *source), void *data) +{ + Edje *ed; + Edje_Signal_Callback *escb; + + ed = _edje_fetch(obj); + if (!ed) return; + if (ed->delete_me) return; + escb = calloc(1, sizeof(Edje_Signal_Callback)); + escb->propagate = EINA_TRUE; + escb->signal = eina_stringshare_add("*"); + escb->source = eina_stringshare_add("*"); + escb->func = func; + escb->data = data; + ed->callbacks = eina_list_append(ed->callbacks, escb); + if (ed->walking_callbacks) + { + escb->just_added = 1; + ed->just_added_callbacks = 1; + } + else + _edje_callbacks_patterns_clean(ed); +} + +EAPI void +edje_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) +{ + Edje *ed; + Edje_Signal_Callback *escb; + + if ((!emission) || (!source) || (!func)) return; + ed = _edje_fetch(obj); + if (!ed) return; + if (ed->delete_me) return; + escb = calloc(1, sizeof(Edje_Signal_Callback)); + if (emission[0]) + escb->signal = eina_stringshare_add(emission); + if (source[0]) + escb->source = eina_stringshare_add(source); + escb->func = func; + escb->data = data; + ed->callbacks = eina_list_append(ed->callbacks, escb); + if (ed->walking_callbacks) + { + escb->just_added = 1; + ed->just_added_callbacks = 1; + } + else + _edje_callbacks_patterns_clean(ed); +} + +EAPI void * +edje_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)) +{ + Edje *ed; + Eina_List *l; + Edje_Signal_Callback *escb; + + if ((!emission) || (!source) || (!func)) return NULL; + ed = _edje_fetch(obj); + if (!ed) return NULL; + if (ed->delete_me) return NULL; + EINA_LIST_FOREACH(ed->callbacks, l, escb) + { + if ((escb->func == func) && + ((!escb->signal && !emission[0]) || + (escb->signal && !strcmp(escb->signal, emission))) && + ((!escb->source && !source[0]) || + (escb->source && !strcmp(escb->source, source)))) + { + void *data; + + data = escb->data; + if (ed->walking_callbacks) + { + escb->delete_me = 1; + ed->delete_callbacks = 1; + } + else + { + _edje_callbacks_patterns_clean(ed); + + ed->callbacks = eina_list_remove_list(ed->callbacks, l); + if (escb->signal) eina_stringshare_del(escb->signal); + if (escb->source) eina_stringshare_del(escb->source); + free(escb); + } + return data; + } + } + return NULL; +} + +EAPI void * +edje_object_signal_callback_del_full(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func, void *data) +{ + Edje *ed; + Eina_List *l; + Edje_Signal_Callback *escb; + + if ((!emission) || (!source) || (!func)) return NULL; + ed = _edje_fetch(obj); + if (!ed) return NULL; + if (ed->delete_me) return NULL; + EINA_LIST_FOREACH(ed->callbacks, l, escb) + { + if ((escb->func == func) && (escb->data == data) && + ((!escb->signal && !emission[0]) || + (escb->signal && !strcmp(escb->signal, emission))) && + ((!escb->source && !source[0]) || + (escb->source && !strcmp(escb->source, source)))) + { + void *data2; + + data2 = escb->data; + if (ed->walking_callbacks) + { + escb->delete_me = 1; + ed->delete_callbacks = 1; + } + else + { + _edje_callbacks_patterns_clean(ed); + + ed->callbacks = eina_list_remove_list(ed->callbacks, l); + if (escb->signal) eina_stringshare_del(escb->signal); + if (escb->source) eina_stringshare_del(escb->source); + free(escb); + } + return data2; + } + } + return NULL; +} + +EAPI void +edje_object_signal_emit(Evas_Object *obj, const char *emission, const char *source) +{ + Edje *ed; + + if ((!emission) || (!source)) return; + ed = _edje_fetch(obj); + if (!ed) return; + if (ed->delete_me) return; + _edje_emit(ed, (char *)emission, (char *)source); +} + +/* FIXDOC: Verify/Expand */ +EAPI void +edje_object_play_set(Evas_Object *obj, Eina_Bool play) +{ + Edje *ed; + double t; + Eina_List *l; + Edje_Running_Program *runp; + unsigned int i; + + ed = _edje_fetch(obj); + if (!ed) return; + if (ed->delete_me) return; + if (play) + { + if (!ed->paused) return; + ed->paused = 0; + t = ecore_time_get() - ed->paused_at; + EINA_LIST_FOREACH(ed->actions, l, runp) + runp->start_time += t; + } + else + { + if (ed->paused) return; + ed->paused = EINA_TRUE; + ed->paused_at = ecore_time_get(); + } + + for (i = 0; i < ed->table_parts_size; i++) + { + Edje_Real_Part *rp; + rp = ed->table_parts[i]; + if (rp->part->type == EDJE_PART_TYPE_GROUP && rp->swallowed_object) + edje_object_play_set(rp->swallowed_object, play); + } +} + +EAPI Eina_Bool +edje_object_play_get(const Evas_Object *obj) +{ + Edje *ed; + + ed = _edje_fetch(obj); + if (!ed) return EINA_FALSE; + if (ed->delete_me) return EINA_FALSE; + if (ed->paused) return EINA_FALSE; + return EINA_TRUE; +} + +/* FIXDOC: Verify/Expand */ +EAPI void +edje_object_animation_set(Evas_Object *obj, Eina_Bool on) +{ + Edje *ed; + Eina_List *l; + unsigned int i; + + ed = _edje_fetch(obj); + if (!ed) return; + if (ed->delete_me) return; + _edje_block(ed); + ed->no_anim = !on; + _edje_freeze(ed); + if (!on) + { + Eina_List *newl = NULL; + const void *data; + + EINA_LIST_FOREACH(ed->actions, l, data) + newl = eina_list_append(newl, data); + while (newl) + { + Edje_Running_Program *runp; + + runp = eina_list_data_get(newl); + newl = eina_list_remove(newl, eina_list_data_get(newl)); + _edje_program_run_iterate(runp, runp->start_time + TO_DOUBLE(runp->program->tween.time)); + if (_edje_block_break(ed)) + { + eina_list_free(newl); + goto break_prog; + } + } + } + else + { + _edje_emit(ed, "load", NULL); + if (evas_object_visible_get(obj)) + { + evas_object_hide(obj); + evas_object_show(obj); + } + } + break_prog: + + for (i = 0; i < ed->table_parts_size; i++) + { + Edje_Real_Part *rp; + rp = ed->table_parts[i]; + if (rp->part->type == EDJE_PART_TYPE_GROUP && rp->swallowed_object) + edje_object_animation_set(rp->swallowed_object, on); + } + + _edje_thaw(ed); + _edje_unblock(ed); +} + + +EAPI Eina_Bool +edje_object_animation_get(const Evas_Object *obj) +{ + Edje *ed; + + ed = _edje_fetch(obj); + if (!ed) return EINA_FALSE; + if (ed->delete_me) return EINA_FALSE; + if (ed->no_anim) return EINA_FALSE; + return EINA_TRUE; +} + +/* Private Routines */ + +Eina_Bool +_edje_program_run_iterate(Edje_Running_Program *runp, double tim) +{ + FLOAT_T t, total; + Eina_List *l; + Edje *ed; + Edje_Program_Target *pt; + Edje_Real_Part *rp; + + ed = runp->edje; + if (ed->delete_me) return EINA_FALSE; + _edje_block(ed); + _edje_ref(ed); + _edje_freeze(ed); + t = FROM_DOUBLE(tim - runp->start_time); + total = runp->program->tween.time; + t = DIV(t, total); + if (t > FROM_INT(1)) t = FROM_INT(1); + EINA_LIST_FOREACH(runp->program->targets, l, pt) + { + if (pt->id >= 0) + { + rp = ed->table_parts[pt->id % ed->table_parts_size]; + if (rp) _edje_part_pos_set(ed, rp, + runp->program->tween.mode, t, + runp->program->tween.v1, + runp->program->tween.v2); + } + } + if (t >= FROM_INT(1)) + { + Edje_Program_After *pa; + + EINA_LIST_FOREACH(runp->program->targets, l, pt) + { + if (pt->id >= 0) + { + rp = ed->table_parts[pt->id % ed->table_parts_size]; + if (rp) + { + _edje_part_description_apply(ed, rp, + runp->program->state, + runp->program->value, + NULL, + 0.0); + _edje_part_pos_set(ed, rp, + runp->program->tween.mode, ZERO, + runp->program->tween.v1, + runp->program->tween.v2); + rp->program = NULL; + } + } + } + _edje_recalc(ed); + runp->delete_me = 1; + if (!ed->walking_actions) + { + _edje_anim_count--; + ed->actions = eina_list_remove(ed->actions, runp); + if (!ed->actions) + _edje_animators = eina_list_remove(_edje_animators, ed); + } +// _edje_emit(ed, "program,stop", runp->program->name); + if (_edje_block_break(ed)) + { + if (!ed->walking_actions) free(runp); + goto break_prog; + } + EINA_LIST_FOREACH(runp->program->after, l, pa) + { + Edje_Program *pr; + + if (pa->id >= 0) + { + pr = ed->table_programs[pa->id % ed->table_programs_size]; + if (pr) _edje_program_run(ed, pr, 0, "", ""); + if (_edje_block_break(ed)) + { + if (!ed->walking_actions) free(runp); + goto break_prog; + } + } + } + _edje_thaw(ed); + _edje_unref(ed); + if (!ed->walking_actions) free(runp); + _edje_unblock(ed); + return EINA_FALSE; + } + break_prog: + _edje_recalc(ed); + _edje_thaw(ed); + _edje_unref(ed); + _edje_unblock(ed); + return EINA_TRUE; +} + +void +_edje_program_end(Edje *ed, Edje_Running_Program *runp) +{ + Eina_List *l; + Edje_Program_Target *pt; +// const char *pname = NULL; + int free_runp = 0; + + if (ed->delete_me) return; + _edje_ref(ed); + _edje_freeze(ed); + EINA_LIST_FOREACH(runp->program->targets, l, pt) + { + Edje_Real_Part *rp; + + if (pt->id >= 0) + { + rp = ed->table_parts[pt->id % ed->table_parts_size]; + if (rp) + { + _edje_part_description_apply(ed, rp, + runp->program->state, + runp->program->value, + NULL, + 0.0); + _edje_part_pos_set(ed, rp, + runp->program->tween.mode, ZERO, + runp->program->tween.v1, + runp->program->tween.v2); + rp->program = NULL; + } + } + } + _edje_recalc(ed); + runp->delete_me = 1; +// pname = runp->program->name; + if (!ed->walking_actions) + { + _edje_anim_count--; + ed->actions = eina_list_remove(ed->actions, runp); + free_runp = 1; + if (!ed->actions) + { + _edje_animators = eina_list_remove(_edje_animators, ed); + } + } +// _edje_emit(ed, "program,stop", pname); + _edje_thaw(ed); + _edje_unref(ed); + if (free_runp) free(runp); +} + +void +_edje_program_run(Edje *ed, Edje_Program *pr, Eina_Bool force, const char *ssig, const char *ssrc) +{ + Eina_List *l; + Edje_Real_Part *rp; + Edje_Program_Target *pt; + Edje_Program *pr2; + Edje_Program_After *pa; + /* limit self-feeding loops in programs to 64 levels */ + static int recursions = 0; + static int recursion_limit = 0; + + if (ed->delete_me) return; + if ((pr->in.from > 0.0) && (pr->in.range >= 0.0) && (!force)) + { + Edje_Pending_Program *pp; + double r = 0.0; + + pp = calloc(1, sizeof(Edje_Pending_Program)); + if (!pp) return; + if (pr->in.range > 0.0) r = ((double)rand() / RAND_MAX); + pp->timer = ecore_timer_add(pr->in.from + (pr->in.range * r), + _edje_pending_timer_cb, pp); + if (!pp->timer) + { + free(pp); + return; + } + pp->edje = ed; + pp->program = pr; + ed->pending_actions = eina_list_append(ed->pending_actions, pp); + return; + } + if ((recursions >= 64) || (recursion_limit)) + { + ERR("Programs recursing up to recursion limit of %i. Disabled.", + 64); + recursion_limit = 1; + return; + } + recursions++; + _edje_block(ed); + _edje_ref(ed); + _edje_freeze(ed); + switch (pr->action) + { + case EDJE_ACTION_TYPE_STATE_SET: + if ((pr->tween.time > ZERO) && (!ed->no_anim)) + { + Edje_Running_Program *runp; + + runp = calloc(1, sizeof(Edje_Running_Program)); + EINA_LIST_FOREACH(pr->targets, l, pt) + { + if (pt->id >= 0) + { + rp = ed->table_parts[pt->id % ed->table_parts_size]; + if (rp) + { + if ((rp->object) && (pr->tween.mode & EDJE_TWEEN_MODE_OPT_FROM_CURRENT)) + { + Edje_Calc_Params *tmp; + + tmp = calloc(1, sizeof(Edje_Calc_Params)); + if (!tmp) goto low_mem_current; + _edje_part_recalc(ed, rp, FLAG_XY, tmp); + + if (rp->current) free(rp->current); + rp->current = tmp; + + rp->current->x -= ed->x; + rp->current->y -= ed->y; + rp->current->map.center.x -= ed->x; + rp->current->map.center.y -= ed->y; + rp->current->map.light.x -= ed->x; + rp->current->map.light.y -= ed->y; + rp->current->map.persp.x -= ed->x; + rp->current->map.persp.y -= ed->y; + } + else + { + low_mem_current: + if (rp->current) free(rp->current); + rp->current = NULL; + } + + if (rp->program) + _edje_program_end(ed, rp->program); + _edje_part_description_apply(ed, rp, + rp->param1.description->state.name, + rp->param1.description->state.value, + pr->state, + pr->value); + _edje_part_pos_set(ed, rp, pr->tween.mode, ZERO, + pr->tween.v1, + pr->tween.v2); + rp->program = runp; + } + } + } + // _edje_emit(ed, "program,start", pr->name); + if (_edje_block_break(ed)) + { + ed->actions = eina_list_append(ed->actions, runp); + goto break_prog; + } + if (!ed->actions) + _edje_animators = eina_list_append(_edje_animators, ed); + ed->actions = eina_list_append(ed->actions, runp); + runp->start_time = ecore_loop_time_get(); + runp->edje = ed; + runp->program = pr; + if (!_edje_timer) + _edje_timer = ecore_animator_add(_edje_timer_cb, NULL); + _edje_anim_count++; + } + else + { + EINA_LIST_FOREACH(pr->targets, l, pt) + { + if (pt->id >= 0) + { + rp = ed->table_parts[pt->id % ed->table_parts_size]; + if (rp) + { + if (rp->program) + _edje_program_end(ed, rp->program); + _edje_part_description_apply(ed, rp, + pr->state, + pr->value, + NULL, + 0.0); + _edje_part_pos_set(ed, rp, pr->tween.mode, ZERO, + pr->tween.v1, + pr->tween.v2); + } + } + } + // _edje_emit(ed, "program,start", pr->name); + if (_edje_block_break(ed)) goto break_prog; + // _edje_emit(ed, "program,stop", pr->name); + if (_edje_block_break(ed)) goto break_prog; + + EINA_LIST_FOREACH(pr->after, l, pa) + { + if (pa->id >= 0) + { + pr2 = ed->table_programs[pa->id % ed->table_programs_size]; + if (pr2) _edje_program_run(ed, pr2, 0, "", ""); + if (_edje_block_break(ed)) goto break_prog; + } + } + _edje_recalc(ed); + } + break; + case EDJE_ACTION_TYPE_ACTION_STOP: + // _edje_emit(ed, "program,start", pr->name); + EINA_LIST_FOREACH(pr->targets, l, pt) + { + Eina_List *ll; + Edje_Running_Program *runp; + Edje_Pending_Program *pp; + + for (ll = ed->actions; ll; ) + { + runp = ll->data; + ll = ll->next; + if (pt->id == runp->program->id) + { + _edje_program_end(ed, runp); +// goto done; + } + } + for (ll = ed->pending_actions; ll; ) + { + pp = ll->data; + ll = ll->next; + if (pt->id == pp->program->id) + { + ed->pending_actions = eina_list_remove(ed->pending_actions, pp); + ecore_timer_del(pp->timer); + free(pp); +// goto done; + } + } +// done: +// continue; + } + // _edje_emit(ed, "program,stop", pr->name); + if (_edje_block_break(ed)) goto break_prog; + break; + case EDJE_ACTION_TYPE_SIGNAL_EMIT: + // _edje_emit(ed, "program,start", pr->name); + if (_edje_block_break(ed)) goto break_prog; + _edje_emit(ed, pr->state, pr->state2); + if (_edje_block_break(ed)) goto break_prog; + // _edje_emit(ed, "program,stop", pr->name); + if (_edje_block_break(ed)) goto break_prog; + break; + case EDJE_ACTION_TYPE_DRAG_VAL_SET: + // _edje_emit(ed, "program,start", pr->name); + if (_edje_block_break(ed)) goto break_prog; + EINA_LIST_FOREACH(pr->targets, l, pt) + { + if (pt->id >= 0) + { + rp = ed->table_parts[pt->id % ed->table_parts_size]; + if ((rp) && (rp->drag) && (rp->drag->down.count == 0)) + { + rp->drag->val.x = pr->value; + rp->drag->val.y = pr->value2; + if (rp->drag->val.x < 0.0) rp->drag->val.x = 0.0; + else if (rp->drag->val.x > 1.0) rp->drag->val.x = 1.0; + if (rp->drag->val.y < 0.0) rp->drag->val.y = 0.0; + else if (rp->drag->val.y > 1.0) rp->drag->val.y = 1.0; + _edje_dragable_pos_set(ed, rp, rp->drag->val.x, rp->drag->val.y); + _edje_emit(ed, "drag,set", rp->part->name); + if (_edje_block_break(ed)) goto break_prog; + } + } + } + // _edje_emit(ed, "program,stop", pr->name); + if (_edje_block_break(ed)) goto break_prog; + break; + case EDJE_ACTION_TYPE_DRAG_VAL_STEP: + // _edje_emit(ed, "program,start", pr->name); + if (_edje_block_break(ed)) goto break_prog; + EINA_LIST_FOREACH(pr->targets, l, pt) + { + if (pt->id >= 0) + { + rp = ed->table_parts[pt->id % ed->table_parts_size]; + if ((rp) && (rp->drag) && (rp->drag->down.count == 0)) + { + rp->drag->val.x += pr->value * rp->drag->step.x * rp->part->dragable.x; + rp->drag->val.y += pr->value2 * rp->drag->step.y * rp->part->dragable.y; + if (rp->drag->val.x < 0.0) rp->drag->val.x = 0.0; + else if (rp->drag->val.x > 1.0) rp->drag->val.x = 1.0; + if (rp->drag->val.y < 0.0) rp->drag->val.y = 0.0; + else if (rp->drag->val.y > 1.0) rp->drag->val.y = 1.0; + _edje_dragable_pos_set(ed, rp, rp->drag->val.x, rp->drag->val.y); + _edje_emit(ed, "drag,step", rp->part->name); + if (_edje_block_break(ed)) goto break_prog; + } + } + } + // _edje_emit(ed, "program,stop", pr->name); + if (_edje_block_break(ed)) goto break_prog; + break; + case EDJE_ACTION_TYPE_DRAG_VAL_PAGE: + // _edje_emit(ed, "program,start", pr->name); + if (_edje_block_break(ed)) goto break_prog; + EINA_LIST_FOREACH(pr->targets, l, pt) + { + if (pt->id >= 0) + { + rp = ed->table_parts[pt->id % ed->table_parts_size]; + if ((rp) && (rp->drag) && (rp->drag->down.count == 0)) + { + rp->drag->val.x += pr->value * rp->drag->page.x * rp->part->dragable.x; + rp->drag->val.y += pr->value2 * rp->drag->page.y * rp->part->dragable.y; + if (rp->drag->val.x < 0.0) rp->drag->val.x = 0.0; + else if (rp->drag->val.x > 1.0) rp->drag->val.x = 1.0; + if (rp->drag->val.y < 0.0) rp->drag->val.y = 0.0; + else if (rp->drag->val.y > 1.0) rp->drag->val.y = 1.0; + _edje_dragable_pos_set(ed, rp, rp->drag->val.x, rp->drag->val.y); + _edje_emit(ed, "drag,page", rp->part->name); + if (_edje_block_break(ed)) goto break_prog; + } + } + } + // _edje_emit(ed, "program,stop", pr->name); + if (_edje_block_break(ed)) goto break_prog; + break; + case EDJE_ACTION_TYPE_SCRIPT: + { + char fname[128]; + + // _edje_emit(ed, "program,start", pr->name); + if (_edje_block_break(ed)) goto break_prog; + snprintf(fname, sizeof(fname), "_p%i", pr->id); + _edje_embryo_test_run(ed, fname, ssig, ssrc); + // _edje_emit(ed, "program,stop", pr->name); + if (_edje_block_break(ed)) goto break_prog; + _edje_recalc_do(ed); + } + break; + case EDJE_ACTION_TYPE_FOCUS_SET: + if (!pr->targets) + ed->focused_part = NULL; + else + { + EINA_LIST_FOREACH(pr->targets, l, pt) + { + if (pt->id >= 0) + { + rp = ed->table_parts[pt->id % ed->table_parts_size]; + if (rp) + { + if (ed->focused_part != rp) + { + if (ed->focused_part) + _edje_emit(ed, "focus,part,out", + ed->focused_part->part->name); + ed->focused_part = rp; + _edje_emit(ed, "focus,part,in", + ed->focused_part->part->name); + } + } + } + } + } + break; + case EDJE_ACTION_TYPE_FOCUS_OBJECT: + if (!pr->targets) + { + Evas_Object *focused; + + focused = evas_focus_get(evas_object_evas_get(ed->obj)); + if (focused) + { + unsigned int i; + + /* Check if the current swallowed object is one of my child. */ + for (i = 0; i < ed->table_parts_size; ++i) + { + rp = ed->table_parts[i]; + if (rp && rp->swallowed_object == focused) + { + evas_object_focus_set(focused, EINA_FALSE); + break; + } + } + } + } + else + { + EINA_LIST_FOREACH(pr->targets, l, pt) + { + if (pt->id >= 0) + { + rp = ed->table_parts[pt->id % ed->table_parts_size]; + if (rp && rp->swallowed_object) + evas_object_focus_set(rp->swallowed_object, EINA_TRUE); + } + } + } + break; + case EDJE_ACTION_TYPE_SOUND_SAMPLE: + if (_edje_block_break(ed)) + goto break_prog; + _edje_multisense_internal_sound_sample_play(ed, pr->sample_name, pr->speed); + break; + case EDJE_ACTION_TYPE_SOUND_TONE: + if (_edje_block_break(ed)) + goto break_prog; + _edje_multisense_internal_sound_tone_play(ed, pr->tone_name, pr->duration); + break; + case EDJE_ACTION_TYPE_PARAM_COPY: + { + Edje_Real_Part *src_part, *dst_part; + + // _edje_emit(ed, "program,start", pr->name); + if (_edje_block_break(ed)) goto break_prog; + + src_part = ed->table_parts[pr->param.src % ed->table_parts_size]; + dst_part = ed->table_parts[pr->param.dst % ed->table_parts_size]; + _edje_param_copy(src_part, pr->state, dst_part, pr->state2); + + if (_edje_block_break(ed)) goto break_prog; + // _edje_emit(ed, "program,stop", pr->name); + if (_edje_block_break(ed)) goto break_prog; + } + break; + case EDJE_ACTION_TYPE_PARAM_SET: + { + Edje_Real_Part *part; + + // _edje_emit(ed, "program,start", pr->name); + if (_edje_block_break(ed)) goto break_prog; + + part = ed->table_parts[pr->param.dst % ed->table_parts_size]; + _edje_param_set(part, pr->state, pr->state2); + + if (_edje_block_break(ed)) goto break_prog; + // _edje_emit(ed, "program,stop", pr->name); + if (_edje_block_break(ed)) goto break_prog; + } + break; + default: + // _edje_emit(ed, "program,start", pr->name); + // _edje_emit(ed, "program,stop", pr->name); + break; + } + if (!((pr->action == EDJE_ACTION_TYPE_STATE_SET) + /* hmm this fucks somethgin up. must look into it later */ + /* && (pr->tween.time > ZERO) && (!ed->no_anim))) */ + )) + { + EINA_LIST_FOREACH(pr->after, l, pa) + { + if (pa->id >= 0) + { + pr2 = ed->table_programs[pa->id % ed->table_programs_size]; + if (pr2) _edje_program_run(ed, pr2, 0, "", ""); + if (_edje_block_break(ed)) goto break_prog; + } + } + } + break_prog: + _edje_thaw(ed); + _edje_unref(ed); + recursions--; + if (recursions == 0) recursion_limit = 0; + _edje_unblock(ed); +} + +void +_edje_emit(Edje *ed, const char *sig, const char *src) +{ + _edje_emit_full(ed, sig, src, NULL, NULL); +} + +/* data should either be NULL or a malloc allocated data */ +void +_edje_emit_full(Edje *ed, const char *sig, const char *src, void *data, void (*free_func)(void *)) +{ + Edje_Message_Signal emsg; + const char *sep; + + if (ed->delete_me) return; + + sep = strchr(sig, EDJE_PART_PATH_SEPARATOR); + + /* If we are not sending the signal to a part of the child, the + * signal if for ourself + */ + if (sep) + { + Edje_Real_Part *rp = NULL; + const char *newsig; + Edje *ed2; + char *part; + char *idx; + size_t length; + + /* the signal contains a colon, split the signal into "parts:signal" */ + length = sep - sig + 1; + part = alloca(length); + memcpy(part, sig, length - 1); + part[length - 1] = '\0'; + + newsig = sep + 1; + + /* lookup for alias */ + if (ed->collection && ed->collection->alias) + { + char *alias; + + alias = eina_hash_find(ed->collection->alias, part); + if (alias) { + char *aliased; + int alien; + int nslen; + + alien = strlen(alias); + nslen = strlen(newsig); + length = alien + nslen + 2; + + aliased = alloca(length); + memcpy(aliased, alias, alien); + aliased[alien] = EDJE_PART_PATH_SEPARATOR; + memcpy(aliased + alien + 1, newsig, nslen + 1); + + _edje_emit(ed, aliased, src); + return; + } + } + + /* search for the index if present and remove it from the part */ + idx = strchr(part, EDJE_PART_PATH_SEPARATOR_INDEXL); + if (idx) + { + char *end; + + end = strchr(idx + 1, EDJE_PART_PATH_SEPARATOR_INDEXR); + if (end && end != idx + 1) + { + char *tmp; + + tmp = alloca(end - idx - 1); + memcpy(tmp, idx + 1, end - idx - 1); + tmp[end - idx - 1] = '\0'; + *idx = '\0'; + idx = tmp; + } + else + { + idx = NULL; + } + } + + /* search for the right part now */ + rp = _edje_real_part_get(ed, part); + if (!rp) goto end; + + switch (rp->part->type) + { + case EDJE_PART_TYPE_GROUP: + if (!rp->swallowed_object) goto end; + ed2 = _edje_fetch(rp->swallowed_object); + if (!ed2) goto end; + + _edje_emit(ed2, newsig, src); + break; + + case EDJE_PART_TYPE_EXTERNAL: + if (!rp->swallowed_object) break ; + + if (!idx) + { + _edje_external_signal_emit(rp->swallowed_object, newsig, src); + } + else + { + Evas_Object *child; + + child = _edje_children_get(rp, idx); + ed2 = _edje_fetch(child); + if (!ed2) goto end; + _edje_emit(ed2, newsig, src); + } + break ; + + case EDJE_PART_TYPE_BOX: + case EDJE_PART_TYPE_TABLE: + if (idx) + { + Evas_Object *child; + + child = _edje_children_get(rp, idx); + ed2 = _edje_fetch(child); + if (!ed2) goto end; + _edje_emit(ed2, newsig, src); + } + break ; + + default: + fprintf(stderr, "SPANK SPANK SPANK !!!\nYou should never be here !\n"); + break; + } + } + + end: + emsg.sig = sig; + emsg.src = src; + if (data) + { + emsg.data = calloc(1, sizeof(*(emsg.data))); + emsg.data->ref = 1; + emsg.data->data = data; + emsg.data->free_func = free_func; + } + else + { + emsg.data = NULL; + } +/* new sends code */ + edje_object_message_send(ed->obj, EDJE_MESSAGE_SIGNAL, 0, &emsg); +/* old send code - use api now + _edje_message_send(ed, EDJE_QUEUE_SCRIPT, EDJE_MESSAGE_SIGNAL, 0, &emsg); + EINA_LIST_FOREACH(ed->subobjs, l, obj) + { + Edje *ed2; + + ed2 = _edje_fetch(obj); + if (!ed2) continue; + if (ed2->delete_me) continue; + _edje_message_send(ed2, EDJE_QUEUE_SCRIPT, EDJE_MESSAGE_SIGNAL, 0, &emsg); + } + */ + if (emsg.data && (--(emsg.data->ref) == 0)) + { + if (emsg.data->free_func) + { + emsg.data->free_func(emsg.data->data); + } + free(emsg.data); + } +} + +struct _Edje_Program_Data +{ +#ifdef EDJE_PROGRAM_CACHE + Eina_List *matches; + int matched; +#endif + Edje *ed; + const char *signal; + const char *source; +}; + +static Eina_Bool _edje_glob_callback(Edje_Program *pr, void *dt) +{ + struct _Edje_Program_Data *data = dt; + Edje_Real_Part *rp = NULL; + Eina_Bool exec = EINA_TRUE; + + if (pr->filter.state) + { + rp = _edje_real_part_get(data->ed, pr->filter.part ? pr->filter.part : data->source); + if (rp) + exec = (rp->chosen_description->state.name == pr->filter.state); + } + +#ifdef EDJE_PROGRAM_CACHE + data->matched++; +#endif + + if (exec) + _edje_program_run(data->ed, pr, 0, data->signal, data->source); + + if (_edje_block_break(data->ed)) + { +#ifdef EDJE_PROGRAM_CACHE + eina_list_free(data->matches); + data->matches = NULL; +#endif + return EINA_TRUE; + } + +#ifdef EDJE_PROGRAM_CACHE + data->matches = eina_list_append(data->matches, pr); +#endif + + return EINA_FALSE; +} + + +void +_edje_callbacks_patterns_clean(Edje *ed) +{ + _edje_signals_sources_patterns_clean(&ed->patterns.callbacks); + + eina_rbtree_delete(ed->patterns.callbacks.exact_match, + EINA_RBTREE_FREE_CB(edje_match_signal_source_free), + NULL); + ed->patterns.callbacks.exact_match = NULL; + + ed->patterns.callbacks.u.callbacks.globing = eina_list_free(ed->patterns.callbacks.u.callbacks.globing); +} + +static void +_edje_callbacks_patterns_init(Edje *ed) +{ + Edje_Signals_Sources_Patterns *ssp = &ed->patterns.callbacks; + + if ((ssp->signals_patterns) || (ssp->sources_patterns) || + (ssp->u.callbacks.globing) || (ssp->exact_match)) + return; + + ssp->u.callbacks.globing = edje_match_callback_hash_build(ed->callbacks, + &ssp->exact_match); + + ssp->signals_patterns = edje_match_callback_signal_init(ssp->u.callbacks.globing); + ssp->sources_patterns = edje_match_callback_source_init(ssp->u.callbacks.globing); +} + +/* FIXME: what if we delete the evas object??? */ +void +_edje_emit_handle(Edje *ed, const char *sig, const char *src, + Edje_Message_Signal_Data *sdata, Eina_Bool prop) +{ + if (ed->delete_me) return; + if (!sig) sig = ""; + if (!src) src = ""; +// printf("EDJE EMIT: (%p) signal: \"%s\" source: \"%s\"\n", ed, sig, src); + _edje_block(ed); + _edje_ref(ed); + _edje_freeze(ed); + + if (ed->collection && ed->L) + _edje_lua2_script_func_signal(ed, sig, src); + + if (ed->collection) + { +#ifdef EDJE_PROGRAM_CACHE + Edje_Part_Collection *ec; + char *tmps; + int l1, l2; +#endif + int done; + +#ifdef EDJE_PROGRAM_CACHE + ec = ed->collection; + l1 = strlen(sig); + l2 = strlen(src); + tmps = alloca(l1 + l2 + 3); /* \0, \337, \0 */ + strcpy(tmps, sig); + tmps[l1] = '\377'; + strcpy(&(tmps[l1 + 1]), src); +#endif + done = 0; + +#ifdef EDJE_PROGRAM_CACHE + { + Eina_List *matches; + Eina_List *l; + Edje_Program *pr; + + if (eina_hash_find(ec->prog_cache.no_matches, tmps)) + { + done = 1; + } + else if ((matches = eina_hash_find(ec->prog_cache.matches, tmps))) + { + EINA_LIST_FOREACH(matches, l, pr) + { + Eina_Bool exec = EINA_TRUE; + + if (pr->filter.state) + { + Edje_Real_Part *rp; + + rp = _edje_real_part_get(ed, pr->filter.part ? pr->filter.part : src); + if (rp) + exec = (rp->chosen_description->state.name == pr->filter.state); + } + + if (exec) + { + _edje_program_run(ed, pr, 0, sig, src); + if (_edje_block_break(ed)) + { + goto break_prog; + } + } + } + done = 1; + } + } +#endif + if (!done) + { + struct _Edje_Program_Data data; + + data.ed = ed; + data.source = src; + data.signal = sig; +#ifdef EDJE_PROGRAM_CACHE + data.matched = 0; + data.matches = NULL; +#endif + if (ed->table_programs_size > 0) + { + const Eina_List *match; + const Eina_List *l; + Edje_Program *pr; + + if (ed->patterns.programs.u.programs.globing) + if (edje_match_programs_exec(ed->patterns.programs.signals_patterns, + ed->patterns.programs.sources_patterns, + sig, + src, + ed->patterns.programs.u.programs.globing, + _edje_glob_callback, + &data, + prop) == 0) + goto break_prog; + + match = edje_match_signal_source_hash_get(sig, src, + ed->patterns.programs.exact_match); + EINA_LIST_FOREACH(match, l, pr) + _edje_glob_callback(pr, &data); + } + +#ifdef EDJE_PROGRAM_CACHE + if (tmps) + { + if (data.matched == 0) + { + if (!ec->prog_cache.no_matches) + ec->prog_cache.no_matches = eina_hash_string_superfast_new(NULL); + eina_hash_add(ec->prog_cache.no_matches, tmps, ed); + } + else + { + if (!ec->prog_cache.matches) + ec->prog_cache.matches = eina_hash_string_superfast_new(NULL); + eina_hash_add(ec->prog_cache.matches, tmps, data.matches); + } + } +#endif + } + _edje_emit_cb(ed, sig, src, sdata, prop); + if (_edje_block_break(ed)) + { + goto break_prog; + } + } + break_prog: + _edje_thaw(ed); + _edje_unref(ed); + _edje_unblock(ed); +} + +/* Extra data for callbacks */ +static void *callback_extra_data = NULL; + +EAPI void * +edje_object_signal_callback_extra_data_get(void) +{ + return callback_extra_data; +} + +/* FIXME: what if we delete the evas object??? */ +static void +_edje_emit_cb(Edje *ed, const char *sig, const char *src, Edje_Message_Signal_Data *data, Eina_Bool prop) +{ + Eina_List *l; + + if (ed->delete_me) return; + _edje_ref(ed); + _edje_freeze(ed); + _edje_block(ed); + + if (ed->just_added_callbacks) + _edje_callbacks_patterns_clean(ed); + + ed->walking_callbacks = 1; + + if (ed->callbacks) + { + Edje_Signal_Callback *escb; + const Eina_List *match; + const Eina_List *l2; + int r = 1; + callback_extra_data = (data) ? data->data : NULL; + + _edje_callbacks_patterns_init(ed); + if (ed->patterns.callbacks.u.callbacks.globing) + r = edje_match_callback_exec(ed->patterns.callbacks.signals_patterns, + ed->patterns.callbacks.sources_patterns, + sig, + src, + ed->patterns.callbacks.u.callbacks.globing, + ed, + prop); + + if (!r) + goto break_prog; + + match = edje_match_signal_source_hash_get(sig, src, + ed->patterns.callbacks.exact_match); + EINA_LIST_FOREACH(match, l2, escb) + { + if ((prop) && (escb->propagate)) continue; + if ((!escb->just_added) && (!escb->delete_me)) + { + escb->func(escb->data, ed->obj, sig, src); + if (_edje_block_break(ed)) + goto break_prog; + } + } + } + break_prog: + + ed->walking_callbacks = 0; + if ((ed->delete_callbacks) || (ed->just_added_callbacks)) + { + ed->delete_callbacks = 0; + ed->just_added_callbacks = 0; + l = ed->callbacks; + while (l) + { + Edje_Signal_Callback *escb = l->data; + Eina_List *next_l = l->next; + + if (escb->just_added) + escb->just_added = 0; + if (escb->delete_me) + { + ed->callbacks = eina_list_remove_list(ed->callbacks, l); + if (escb->signal) eina_stringshare_del(escb->signal); + if (escb->source) eina_stringshare_del(escb->source); + free(escb); + } + l = next_l; + } + + _edje_callbacks_patterns_clean(ed); + } + _edje_unblock(ed); + _edje_thaw(ed); + _edje_unref(ed); +} + +static const Edje_External_Param_Info * +_edje_external_param_info_get(const Evas_Object *obj, const char *name) +{ + const Edje_External_Type *type; + const Edje_External_Param_Info *info; + + type = evas_object_data_get(obj, "Edje_External_Type"); + if (!type) return NULL; + for (info = type->parameters_info; info->name; info++) + if (!strcmp(info->name, name)) return info; + + return NULL; +} + +static Edje_External_Param * +_edje_param_external_get(Edje_Real_Part *rp, const char *name, Edje_External_Param *param) +{ + Evas_Object *swallowed_object = rp->swallowed_object; + const Edje_External_Param_Info *info; + + info = _edje_external_param_info_get(swallowed_object, name); + if (!info) return NULL; + + memset(param, 0, sizeof(*param)); + param->name = info->name; + param->type = info->type; + if (!_edje_external_param_get(NULL, rp, param)) return NULL; + return param; +} + +/* simulate external properties for native objects */ +static Edje_External_Param * +_edje_param_native_get(Edje_Real_Part *rp, const char *name, Edje_External_Param *param, void **free_ptr) +{ + *free_ptr = NULL; + if ((rp->part->type == EDJE_PART_TYPE_TEXT) || + (rp->part->type == EDJE_PART_TYPE_TEXTBLOCK)) + { + if (!strcmp(name, "text")) + { + param->name = name; + param->type = EDJE_EXTERNAL_PARAM_TYPE_STRING; + + _edje_recalc_do(rp->edje); + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + param->s = _edje_entry_text_get(rp); + else if (rp->part->type == EDJE_PART_TYPE_TEXT) + param->s = rp->text.text; + else + param->s = evas_object_textblock_text_markup_get(rp->object); + return param; + } + if (rp->part->type == EDJE_PART_TYPE_TEXTBLOCK) + { + if (!strcmp(name, "text_unescaped")) + { + param->name = name; + param->type = EDJE_EXTERNAL_PARAM_TYPE_STRING; + + _edje_recalc_do(rp->edje); + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + { + const char *tmp = _edje_entry_text_get(rp); + char *unescaped = _edje_text_unescape(tmp); + *free_ptr = unescaped; + param->s = unescaped; + } + else if (rp->part->type == EDJE_PART_TYPE_TEXT) + param->s = rp->text.text; + else + { + const char *tmp; + char *unescaped; + + tmp = evas_object_textblock_text_markup_get(rp->object); + unescaped = _edje_text_unescape(tmp); + *free_ptr = unescaped; + param->s = unescaped; + } + + return param; + } + + if ((rp->entry_data) && + (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) && + (!strcmp(name, "select_allow"))) + { + param->name = name; + param->type = EDJE_EXTERNAL_PARAM_TYPE_BOOL; + param->i = _edje_entry_select_allow_get(rp); + return param; + } + } + } + + if ((rp->drag) && (rp->drag->down.count == 0)) + { + if (!strncmp(name, "drag_", sizeof("drag_") - 1)) + { + const char *sub_name = name + sizeof("drag_") - 1; + if (!strcmp(sub_name, "value_x")) + { + double d; + + _edje_recalc_do(rp->edje); + d = TO_DOUBLE(rp->drag->val.x); + if (rp->part->dragable.x < 0) d = 1.0 - d; + param->name = name; + param->type = EDJE_EXTERNAL_PARAM_TYPE_DOUBLE; + param->d = d; + return param; + } + if (!strcmp(sub_name, "value_y")) + { + double d; + + _edje_recalc_do(rp->edje); + d = TO_DOUBLE(rp->drag->val.y); + if (rp->part->dragable.y < 0) d = 1.0 - d; + param->name = name; + param->type = EDJE_EXTERNAL_PARAM_TYPE_DOUBLE; + param->d = d; + return param; + } + + if (!strcmp(sub_name, "size_w")) + { + _edje_recalc_do(rp->edje); + param->name = name; + param->type = EDJE_EXTERNAL_PARAM_TYPE_DOUBLE; + param->d = TO_DOUBLE(rp->drag->size.x); + return param; + } + if (!strcmp(sub_name, "size_h")) + { + _edje_recalc_do(rp->edje); + param->name = name; + param->type = EDJE_EXTERNAL_PARAM_TYPE_DOUBLE; + param->d = TO_DOUBLE(rp->drag->size.y); + return param; + } + + if (!strcmp(sub_name, "step_x")) + { + _edje_recalc_do(rp->edje); + param->name = name; + param->type = EDJE_EXTERNAL_PARAM_TYPE_DOUBLE; + param->d = TO_DOUBLE(rp->drag->step.x); + return param; + } + if (!strcmp(sub_name, "step_y")) + { + _edje_recalc_do(rp->edje); + param->name = name; + param->type = EDJE_EXTERNAL_PARAM_TYPE_DOUBLE; + param->d = TO_DOUBLE(rp->drag->step.y); + return param; + } + + if (!strcmp(sub_name, "page_x")) + { + _edje_recalc_do(rp->edje); + param->name = name; + param->type = EDJE_EXTERNAL_PARAM_TYPE_DOUBLE; + param->d = TO_DOUBLE(rp->drag->page.x); + return param; + } + if (!strcmp(sub_name, "page_y")) + { + _edje_recalc_do(rp->edje); + param->name = name; + param->type = EDJE_EXTERNAL_PARAM_TYPE_DOUBLE; + param->d = TO_DOUBLE(rp->drag->page.y); + return param; + } + + return NULL; + } + } + + return NULL; +} + +static Eina_Bool +_edje_param_native_set(Edje_Real_Part *rp, const char *name, const Edje_External_Param *param) +{ + if ((rp->part->type == EDJE_PART_TYPE_TEXT) || + (rp->part->type == EDJE_PART_TYPE_TEXTBLOCK)) + { + if (!strcmp(name, "text")) + { + if (param->type != EDJE_EXTERNAL_PARAM_TYPE_STRING) + return EINA_FALSE; + + _edje_object_part_text_raw_set + (rp->edje->obj, rp, rp->part->name, param->s); + return EINA_TRUE; + } + if (rp->part->type == EDJE_PART_TYPE_TEXTBLOCK) + { + if (!strcmp(name, "text_unescaped")) + { + if (param->type != EDJE_EXTERNAL_PARAM_TYPE_STRING) + return EINA_FALSE; + + if (rp->part->type == EDJE_PART_TYPE_TEXT) + _edje_object_part_text_raw_set + (rp->edje->obj, rp, rp->part->name, param->s); + else + { + char *escaped = _edje_text_escape(param->s); + _edje_object_part_text_raw_set + (rp->edje->obj, rp, rp->part->name, escaped); + free(escaped); + } + + return EINA_TRUE; + } + + if ((rp->entry_data) && + (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) && + (!strcmp(name, "select_allow"))) + { + if (param->type != EDJE_EXTERNAL_PARAM_TYPE_BOOL) + return EINA_FALSE; + _edje_entry_select_allow_set(rp, param->i); + return EINA_TRUE; + } + } + } + + if ((rp->drag) && (rp->drag->down.count == 0)) + { + if (!strncmp(name, "drag_", sizeof("drag_") - 1)) + { + const char *sub_name = name + sizeof("drag_") - 1; + if (!strcmp(sub_name, "value_x")) + { + double d; + if (param->type != EDJE_EXTERNAL_PARAM_TYPE_DOUBLE) + return EINA_FALSE; + d = param->d; + if (rp->part->dragable.confine_id != -1) + d = CLAMP(d, 0.0, 1.0); + if (rp->part->dragable.x < 0) d = 1.0 - d; + if (rp->drag->val.x == FROM_DOUBLE(d)) return EINA_TRUE; + rp->drag->val.x = FROM_DOUBLE(d); +#ifdef EDJE_CALC_CACHE + rp->invalidate = 1; +#endif + _edje_dragable_pos_set + (rp->edje, rp, rp->drag->val.x, rp->drag->val.y); + _edje_emit(rp->edje, "drag,set", rp->part->name); + return EINA_TRUE; + } + if (!strcmp(sub_name, "value_y")) + { + double d; + if (param->type != EDJE_EXTERNAL_PARAM_TYPE_DOUBLE) + return EINA_FALSE; + d = param->d; + if (rp->part->dragable.confine_id != -1) + d = CLAMP(d, 0.0, 1.0); + if (rp->part->dragable.y < 0) d = 1.0 - d; + if (rp->drag->val.y == FROM_DOUBLE(d)) return EINA_TRUE; + rp->drag->val.y = FROM_DOUBLE(d); +#ifdef EDJE_CALC_CACHE + rp->invalidate = 1; +#endif + _edje_dragable_pos_set + (rp->edje, rp, rp->drag->val.x, rp->drag->val.y); + _edje_emit(rp->edje, "drag,set", rp->part->name); + return EINA_TRUE; + } + + if (!strcmp(sub_name, "size_w")) + { + if (param->type != EDJE_EXTERNAL_PARAM_TYPE_DOUBLE) + return EINA_FALSE; + rp->drag->size.x = FROM_DOUBLE(CLAMP(param->d, 0.0, 1.0)); + rp->edje->dirty = 1; +#ifdef EDJE_CALC_CACHE + rp->invalidate = 1; +#endif + _edje_recalc(rp->edje); + return EINA_TRUE; + } + if (!strcmp(sub_name, "size_h")) + { + if (param->type != EDJE_EXTERNAL_PARAM_TYPE_DOUBLE) + return EINA_FALSE; + rp->drag->size.y = FROM_DOUBLE(CLAMP(param->d, 0.0, 1.0)); + rp->edje->dirty = 1; +#ifdef EDJE_CALC_CACHE + rp->invalidate = 1; +#endif + _edje_recalc(rp->edje); + return EINA_TRUE; + } + + if (!strcmp(sub_name, "step_x")) + { + if (param->type != EDJE_EXTERNAL_PARAM_TYPE_DOUBLE) + return EINA_FALSE; + rp->drag->step.x = FROM_DOUBLE(CLAMP(param->d, 0.0, 1.0)); +#ifdef EDJE_CALC_CACHE + rp->invalidate = 1; +#endif + return EINA_TRUE; + } + if (!strcmp(sub_name, "step_y")) + { + if (param->type != EDJE_EXTERNAL_PARAM_TYPE_DOUBLE) + return EINA_FALSE; + rp->drag->step.y = FROM_DOUBLE(CLAMP(param->d, 0.0, 1.0)); +#ifdef EDJE_CALC_CACHE + rp->invalidate = 1; +#endif + return EINA_TRUE; + } + + if (!strcmp(sub_name, "page_x")) + { + if (param->type != EDJE_EXTERNAL_PARAM_TYPE_DOUBLE) + return EINA_FALSE; + rp->drag->page.x = FROM_DOUBLE(CLAMP(param->d, 0.0, 1.0)); +#ifdef EDJE_CALC_CACHE + rp->invalidate = 1; +#endif + return EINA_TRUE; + } + if (!strcmp(sub_name, "page_y")) + { + if (param->type != EDJE_EXTERNAL_PARAM_TYPE_DOUBLE) + return EINA_FALSE; + rp->drag->page.y = FROM_DOUBLE(CLAMP(param->d, 0.0, 1.0)); +#ifdef EDJE_CALC_CACHE + rp->invalidate = 1; +#endif + return EINA_TRUE; + } + + return EINA_FALSE; + } + } + + return EINA_FALSE; +} + +static const Edje_External_Param_Info * +_edje_native_param_info_get(const Edje_Real_Part *rp, const char *name) +{ + if ((rp->part->type == EDJE_PART_TYPE_TEXT) || + (rp->part->type == EDJE_PART_TYPE_TEXTBLOCK)) + { + if (!strcmp(name, "text")) + { + static const Edje_External_Param_Info pi = + EDJE_EXTERNAL_PARAM_INFO_STRING("text"); + return π + } + if (rp->part->type == EDJE_PART_TYPE_TEXTBLOCK) + { + if (!strcmp(name, "text_unescaped")) + { + static const Edje_External_Param_Info pi = + EDJE_EXTERNAL_PARAM_INFO_STRING("text_unescaped"); + return π + } + if (!strcmp(name, "select_allow")) + { + static const Edje_External_Param_Info pi = + EDJE_EXTERNAL_PARAM_INFO_BOOL("text_unescaped"); + return π + } + } + } + + if ((rp->drag) && (rp->drag->down.count == 0)) + { + if (!strncmp(name, "drag_", sizeof("drag_") - 1)) + { + name += sizeof("drag_") - 1; + if (!strcmp(name, "value_x")) + { + static const Edje_External_Param_Info pi = + EDJE_EXTERNAL_PARAM_INFO_DOUBLE("drag_value_x"); + return π + } + if (!strcmp(name, "value_y")) + { + static const Edje_External_Param_Info pi = + EDJE_EXTERNAL_PARAM_INFO_DOUBLE("drag_value_y"); + return π + } + if (!strcmp(name, "size_w")) + { + static const Edje_External_Param_Info pi = + EDJE_EXTERNAL_PARAM_INFO_DOUBLE("drag_size_w"); + return π + } + if (!strcmp(name, "size_h")) + { + static const Edje_External_Param_Info pi = + EDJE_EXTERNAL_PARAM_INFO_DOUBLE("drag_size_h"); + return π + } + if (!strcmp(name, "step_x")) + { + static const Edje_External_Param_Info pi = + EDJE_EXTERNAL_PARAM_INFO_DOUBLE("drag_step_x"); + return π + } + if (!strcmp(name, "step_y")) + { + static const Edje_External_Param_Info pi = + EDJE_EXTERNAL_PARAM_INFO_DOUBLE("drag_step_y"); + return π + } + if (!strcmp(name, "page_x")) + { + static const Edje_External_Param_Info pi = + EDJE_EXTERNAL_PARAM_INFO_DOUBLE("drag_page_x"); + return π + } + if (!strcmp(name, "page_y")) + { + static const Edje_External_Param_Info pi = + EDJE_EXTERNAL_PARAM_INFO_DOUBLE("drag_page_y"); + return π + } + + return NULL; + } + } + + return NULL; +} + +static Edje_External_Param * +_edje_param_convert(Edje_External_Param *param, const Edje_External_Param_Info *dst_info) +{ + if (param->type == dst_info->type) return param; + + switch (dst_info->type) + { + case EDJE_EXTERNAL_PARAM_TYPE_BOOL: + case EDJE_EXTERNAL_PARAM_TYPE_INT: + { + int i; + switch (param->type) + { + case EDJE_EXTERNAL_PARAM_TYPE_DOUBLE: + i = (int)param->d; + break; + case EDJE_EXTERNAL_PARAM_TYPE_STRING: + case EDJE_EXTERNAL_PARAM_TYPE_CHOICE: + i = (param->s) ? atoi(param->s) : 0; + break; + case EDJE_EXTERNAL_PARAM_TYPE_BOOL: + case EDJE_EXTERNAL_PARAM_TYPE_INT: + i = param->i; + break; + default: + return NULL; + } + if (dst_info->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL) + i = !!i; + param->type = dst_info->type; + param->i = i; + return param; + } + + case EDJE_EXTERNAL_PARAM_TYPE_DOUBLE: + { + double d; + switch (param->type) + { + case EDJE_EXTERNAL_PARAM_TYPE_INT: + d = (double)param->i; + break; + case EDJE_EXTERNAL_PARAM_TYPE_STRING: + case EDJE_EXTERNAL_PARAM_TYPE_CHOICE: + d = (param->s) ? atof(param->s) : 0.0; + break; + case EDJE_EXTERNAL_PARAM_TYPE_BOOL: + d = (double)param->i; + break; + default: + return NULL; + } + param->type = dst_info->type; + param->d = d; + return param; + } + + case EDJE_EXTERNAL_PARAM_TYPE_STRING: + { + static char s[64]; + switch (param->type) + { + case EDJE_EXTERNAL_PARAM_TYPE_BOOL: + case EDJE_EXTERNAL_PARAM_TYPE_INT: + if (!snprintf(s, sizeof(s), "%i", param->i)) return NULL; + break; + case EDJE_EXTERNAL_PARAM_TYPE_DOUBLE: + if (!snprintf(s, sizeof(s), "%f", param->d)) return NULL; + break; + case EDJE_EXTERNAL_PARAM_TYPE_CHOICE: + param->type = dst_info->type; + return param; + default: + return NULL; + } + param->type = dst_info->type; + param->s = s; + return param; + } + + case EDJE_EXTERNAL_PARAM_TYPE_CHOICE: + { + static char s[64]; + const char *val; + switch (param->type) + { + case EDJE_EXTERNAL_PARAM_TYPE_BOOL: + case EDJE_EXTERNAL_PARAM_TYPE_INT: + if (!snprintf(s, sizeof(s), "%i", param->i)) return NULL; + val = s; + break; + case EDJE_EXTERNAL_PARAM_TYPE_DOUBLE: + if (!snprintf(s, sizeof(s), "%f", param->d)) return NULL; + val = s; + break; + case EDJE_EXTERNAL_PARAM_TYPE_STRING: + val = param->s; + break; + default: + return NULL; + } + + param->type = dst_info->type; + if (param->s != val) param->s = val; + return param; + } + + default: return NULL; + } +} + +static Eina_Bool +_edje_param_validate(const Edje_External_Param *param, const Edje_External_Param_Info *info) +{ + switch (info->type) + { + case EDJE_EXTERNAL_PARAM_TYPE_BOOL: + return ((param->i == 0) || (param->i == 1)); + + case EDJE_EXTERNAL_PARAM_TYPE_INT: + if ((info->info.i.min != EDJE_EXTERNAL_INT_UNSET) && + (info->info.i.min > param->i)) + return EINA_FALSE; + + if ((info->info.i.max != EDJE_EXTERNAL_INT_UNSET) && + (info->info.i.max < param->i)) + return EINA_FALSE; + + return EINA_TRUE; + + case EDJE_EXTERNAL_PARAM_TYPE_DOUBLE: + if ((info->info.d.min != EDJE_EXTERNAL_DOUBLE_UNSET) && + (info->info.d.min > param->d)) + return EINA_FALSE; + + if ((info->info.d.max != EDJE_EXTERNAL_DOUBLE_UNSET) && + (info->info.d.max < param->d)) + return EINA_FALSE; + + return EINA_TRUE; + + case EDJE_EXTERNAL_PARAM_TYPE_STRING: + if (!param->s) return EINA_FALSE; + if (info->info.s.accept_fmt) + INF("string 'accept_fmt' validation not implemented."); + if (info->info.s.deny_fmt) + INF("string 'deny_fmt' validation not implemented."); + return EINA_TRUE; + + case EDJE_EXTERNAL_PARAM_TYPE_CHOICE: + { + const char **itr = info->info.c.choices; + if (!itr) return EINA_FALSE; + for (; *itr; itr++) + if (!strcmp(*itr, param->s)) + return EINA_TRUE; + return EINA_FALSE; + } + + default: return EINA_FALSE; + } +} + +static void +_edje_param_copy(Edje_Real_Part *src_part, const char *src_param, Edje_Real_Part *dst_part, const char *dst_param) +{ + Edje_External_Param val; + const Edje_External_Param_Info *dst_info; + void *free_ptr = NULL; + + if ((!src_part) || (!src_param) || (!dst_part) || (!dst_param)) + return; + + if (dst_part->part->type == EDJE_PART_TYPE_EXTERNAL) + dst_info = _edje_external_param_info_get + (dst_part->swallowed_object, dst_param); + else + dst_info = _edje_native_param_info_get(dst_part, dst_param); + + if (!dst_info) + { + ERR("cannot copy, invalid destination parameter '%s' of part '%s'", + dst_param, dst_part->part->name); + return; + } + + if (src_part->part->type == EDJE_PART_TYPE_EXTERNAL) + { + if (!_edje_param_external_get + (src_part, src_param, &val)) + { + ERR("cannot get parameter '%s' of part '%s'", + src_param, src_part->part->name); + return; + } + } + else + { + if (!_edje_param_native_get(src_part, src_param, &val, &free_ptr)) + { + ERR("cannot get parameter '%s' of part '%s'", + src_param, src_part->part->name); + return; + } + } + + if (!_edje_param_convert(&val, dst_info)) + { + ERR("cannot convert parameter type %s to requested type %s", + edje_external_param_type_str(val.type), + edje_external_param_type_str(dst_info->type)); + goto end; + } + + if (!_edje_param_validate(&val, dst_info)) + { + ERR("incorrect parameter value failed validation for type %s", + edje_external_param_type_str(dst_info->type)); + goto end; + } + + if (dst_part->part->type == EDJE_PART_TYPE_EXTERNAL) + { + val.name = dst_param; + if (!_edje_external_param_set(NULL, dst_part, &val)) + { + ERR("failed to set parameter '%s' (%s) of part '%s'", + dst_param, edje_external_param_type_str(dst_info->type), + dst_part->part->name); + goto end; + } + } + else + { + if (!_edje_param_native_set(dst_part, dst_param, &val)) + { + ERR("failed to set parameter '%s' (%s) of part '%s'", + dst_param, edje_external_param_type_str(dst_info->type), + dst_part->part->name); + goto end; + } + } + + end: + free(free_ptr); +} + +static void +_edje_param_set(Edje_Real_Part *part, const char *param, const char *value) +{ + Edje_External_Param val; + const Edje_External_Param_Info *info; + + if ((!part) || (!param) || (!value)) + return; + + if (part->part->type == EDJE_PART_TYPE_EXTERNAL) + info = _edje_external_param_info_get(part->swallowed_object, param); + else + info = _edje_native_param_info_get(part, param); + + if (!info) + { + ERR("cannot copy, invalid destination parameter '%s' of part '%s'", + param, part->part->name); + return; + } + + val.name = "(temp)"; + val.type = EDJE_EXTERNAL_PARAM_TYPE_STRING; + val.s = value; + + if (!_edje_param_convert(&val, info)) + { + ERR("cannot convert parameter type STRING to requested type %s", + edje_external_param_type_str(info->type)); + return; + } + + if (!_edje_param_validate(&val, info)) + { + ERR("incorrect parameter value failed validation for type %s", + edje_external_param_type_str(info->type)); + return; + } + + if (part->part->type == EDJE_PART_TYPE_EXTERNAL) + { + val.name = param; + if (!_edje_external_param_set(NULL, part, &val)) + { + ERR("failed to set parameter '%s' (%s) of part '%s'", + param, edje_external_param_type_str(info->type), + part->part->name); + return; + } + } + else + { + if (!_edje_param_native_set(part, param, &val)) + { + ERR("failed to set parameter '%s' (%s) of part '%s'", + param, edje_external_param_type_str(info->type), + part->part->name); + return; + } + } +} 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 @@ +#include "edje_private.h" + +/* + * ALREADY EXPORTED BY EMBRYO: + * + * enum Float_Round_Method { + * ROUND, FLOOR, CEIL, TOZERO + * }; + * enum Float_Angle_Mode { + * RADIAN, DEGREES, GRADES + * }; + * + * numargs(); + * getarg(arg, index=0); + * setarg(arg, index=0, value); + * + * Float:atof(string[]); + * Float:fract(Float:value); + * round(Float:value, Float_Round_Method:method=ROUND); + * Float:sqrt(Float:value); + * Float:pow(Float:value, Float:exponent); + * Float:log(Float:value, Float:base=10.0); + * Float:sin(Float:value, Float_Angle_Mode:mode=RADIAN); + * Float:cos(Float:value, Float_Angle_Mode:mode=RADIAN); + * Float:tan(Float:value, Float_Angle_Mode:mode=RADIAN); + * Float:abs(Float:value); + * atoi(str[]); + * fnmatch(glob[], str[]); + * strcmp(str1[], str2[]); + * strncmp(str1[], str2[]); + * strcpy(dst[], src[]); + * strncpy(dst[], src[], n); + * strlen(str[]); + * strcat(dst[], src[]); + * strncat(dst[], src[], n); + * strprep(dst[], src[]); + * strnprep(dst[], src[], n); + * strcut(dst[], str[], n, n2); + * snprintf(dst[], dstn, fmt[], ...); + * strstr(str[], ndl[]); + * strchr(str[], ch[]); + * strrchr(str[], ch[]); + * rand(); + * Float:randf(); + * Float:seconds(); + * date(&year, &month, &day, &yearday, &weekday, &hr, &min, &Float:sec); + * + */ + +typedef struct _Sinfo Sinfo; + +struct _Sinfo +{ + struct + { + Embryo_Function + obj_init, obj_shutdown, obj_show, obj_show_immediate, + obj_hide, obj_hide_immediate, obj_move, obj_move_immediate, + obj_resize, obj_resize_immediate, obj_message; + } fn; + struct + { + Ecore_Job * show, *hide, *move, *resize; + } job; + struct + { + int id; + Eina_Hash *hash; // FIXME: hash -> bad. too big. one-way lookup etc. + } oid; +}; + +static void _call_fn(Edje * ed, const char *fname, Embryo_Function fn); + +/* frankly - these make the code shorter to type and read - just sanity for + * development */ +#define IFFN(func) if (si->fn.func != EMBRYO_FUNCTION_NONE) +#define IFNO(func) if (si->fn.func == EMBRYO_FUNCTION_NONE) +#define CLFN(func) IFFN(func) {_call_fn(ed, #func, si->fn.func);} +#define SI Sinfo *si; si = ed->script_only_data; if (!si) return +#define SI_RETURN(ret) Sinfo *si; si = ed->script_only_data; if (!si) return (ret) +#define PINT(val) embryo_parameter_cell_push(ed->collection->script, (Embryo_Cell)(val)) +#define PSTR(val) embryo_parameter_string_push(ed->collection->script, val) +#define GTFN(func) si->fn.func = embryo_program_function_find(ed->collection->script, #func) +#define DELJ(type) if (si->job.type) ecore_job_del(si->job.type); +#define ADDJ(type, func) si->job.type = ecore_job_add(func, ed); +#define ZERJ(type) si->job.type = NULL; +#define IFNJ(type) if (!si->job.type) +#define EXPF(func) embryo_program_native_call_add(ed->collection->script, #func, _exp_##func) + +typedef struct _Oid Oid; + +struct _Oid +{ + Edje *ed; + Evas_Object *obj; + Evas_Coord x, y, w, h; + int oid; +}; + +/* FIXME: using eina_hash and strings is just nasty! make a custom int hash */ +static int +_oid_alloc(Edje * ed) +{ + SI_RETURN(0); + + si->oid.id++; + return si->oid.id; +} + +static Oid * +_oid_track(Edje * ed, Evas_Object * o) +{ + Oid *oi; + + char buf[64]; + + SI_RETURN(NULL); + + oi = calloc(1, sizeof(Oid)); + if (!oi) + return NULL; + oi->oid = _oid_alloc(ed); + if (!oi->oid) + { + free(oi); + return NULL; + } + oi->ed = ed; + oi->obj = o; + evas_object_smart_member_add(oi->obj, oi->ed->obj); + evas_object_clip_set(oi->obj, oi->ed->base.clipper); + evas_object_geometry_get(oi->obj, &(oi->x), &(oi->y), &(oi->w), &(oi->h)); + snprintf(buf, sizeof(buf), "%i", oi->oid); + if (!si->oid.hash) + si->oid.hash = eina_hash_string_superfast_new(NULL); + eina_hash_add(si->oid.hash, buf, oi); + return oi; +} + +static Oid * +_oid_find(Edje * ed, int oid) +{ + char buf[64]; + + SI_RETURN(NULL); + + snprintf(buf, sizeof(buf), "%i", oid); + return eina_hash_find(si->oid.hash, buf); +} + +static void +_oid_del(Edje * ed, int oid) +{ + char buf[64]; + + SI; + + snprintf(buf, sizeof(buf), "%i", oid); + eina_hash_del(si->oid.hash, buf, NULL); +} + +static void +_oid_free(Oid * oid) +{ + free(oid); +} + +static Eina_Bool +_oid_freeall_cb(const Eina_Hash *hash __UNUSED__, const void *key __UNUSED__, void *data, void *fdata __UNUSED__) +{ + Oid *oid = data; + + evas_object_del(oid->obj); + free(oid); + return EINA_TRUE; +} + +static void +_oid_freeall(Edje * ed) +{ + SI; + if (!si->oid.hash) + return; + eina_hash_foreach(si->oid.hash, _oid_freeall_cb, ed); + eina_hash_free(si->oid.hash); + si->oid.hash = NULL; +} + +static Eina_Bool +_oid_moveall_cb(const Eina_Hash *hash __UNUSED__, const void *key __UNUSED__, void *data, void *fdata __UNUSED__) +{ + Oid *oid = data; + + evas_object_move(oid->obj, oid->ed->x + oid->x, oid->ed->y + oid->y); + return EINA_TRUE; +} + +static void +_oid_moveall(Edje * ed) +{ + SI; + if (!si->oid.hash) + return; + eina_hash_foreach(si->oid.hash, _oid_moveall_cb, ed); +} + +/**********/ + +static Embryo_Cell +_exp_e_obj_del(Embryo_Program * ep, Embryo_Cell * params) +{ + Edje *ed = embryo_program_data_get(ep); + + Oid *oid; + + SI_RETURN(-1); + + CHKPARAM(1); + if (!(oid = _oid_find(ed, params[1]))) + return -1; + evas_object_del(oid->obj); + _oid_del(ed, oid->oid); + _oid_free(oid); + return 0; +} + +static Embryo_Cell +_exp_e_obj_rect_add(Embryo_Program * ep, Embryo_Cell * params __UNUSED__) +{ + Edje *ed = embryo_program_data_get(ep); + + Evas_Object *o; + + Oid *oid; + + SI_RETURN(-1); + + o = evas_object_rectangle_add(evas_object_evas_get(ed->obj)); + if (!o) + return 0; + oid = _oid_track(ed, o); + if (oid) + return oid->oid; + return 0; +} + +static Embryo_Cell +_exp_e_obj_show(Embryo_Program * ep, Embryo_Cell * params) +{ + Edje *ed = embryo_program_data_get(ep); + + Oid *oid; + + SI_RETURN(-1); + + CHKPARAM(1); + if (!(oid = _oid_find(ed, params[1]))) + return -1; + evas_object_show(oid->obj); + return 0; +} + +static Embryo_Cell +_exp_e_obj_hide(Embryo_Program * ep, Embryo_Cell * params) +{ + Edje *ed = embryo_program_data_get(ep); + + Oid *oid; + + SI_RETURN(-1); + + CHKPARAM(1); + if (!(oid = _oid_find(ed, params[1]))) + return -1; + evas_object_hide(oid->obj); + return 0; +} + +static Embryo_Cell +_exp_e_obj_move(Embryo_Program * ep, Embryo_Cell * params) +{ + Edje *ed = embryo_program_data_get(ep); + + Oid *oid; + + SI_RETURN(-1); + + CHKPARAM(3); + if (!(oid = _oid_find(ed, params[1]))) + return -1; + if ((oid->x == params[2]) && (oid->y == params[3])) + return -1; + oid->x = params[2]; + oid->y = params[3]; + evas_object_move(oid->obj, ed->x + oid->x, ed->y + oid->y); + return 0; +} + +static Embryo_Cell +_exp_e_obj_resize(Embryo_Program * ep, Embryo_Cell * params) +{ + Edje *ed = embryo_program_data_get(ep); + + Oid *oid; + + SI_RETURN(-1); + + CHKPARAM(3); + if (!(oid = _oid_find(ed, params[1]))) + return -1; + if ((oid->w == params[2]) && (oid->h == params[3])) + return -1; + oid->w = params[2]; + oid->h = params[3]; + evas_object_resize(oid->obj, oid->w, oid->h); + return 0; +} + +static Embryo_Cell +_exp_e_obj_geometry_set(Embryo_Program * ep, Embryo_Cell * params) +{ + Edje *ed = embryo_program_data_get(ep); + + Oid *oid; + + SI_RETURN(-1); + + CHKPARAM(5); + if (!(oid = _oid_find(ed, params[1]))) + return -1; + if ((oid->x == params[2]) && (oid->y == params[3]) && + (oid->w == params[4]) && (oid->h == params[5])) + return -1; + oid->x = params[2]; + oid->y = params[3]; + oid->w = params[4]; + oid->h = params[5]; + evas_object_move(oid->obj, ed->x + oid->x, ed->y + oid->y); + evas_object_resize(oid->obj, oid->w, oid->h); + return 0; +} + +static Embryo_Cell +_exp_e_obj_geometry_get(Embryo_Program * ep, Embryo_Cell * params) +{ + Edje *ed = embryo_program_data_get(ep); + + Oid *oid; + + SI_RETURN(-1); + + CHKPARAM(5); + if (!(oid = _oid_find(ed, params[1]))) + return -1; + SETINT(oid->x, params[2]); + SETINT(oid->y, params[3]); + SETINT(oid->w, params[4]); + SETINT(oid->h, params[5]); + return 0; +} + +static Embryo_Cell +_exp_e_obj_color_set(Embryo_Program * ep, Embryo_Cell * params) +{ + Edje *ed = embryo_program_data_get(ep); + + Oid *oid; + + SI_RETURN(-1); + + CHKPARAM(5); + if (!(oid = _oid_find(ed, params[1]))) + return -1; + evas_object_color_set(oid->obj, params[2], params[3], params[4], params[5]); + return 0; +} + +static Embryo_Cell +_exp_e_obj_color_get(Embryo_Program * ep, Embryo_Cell * params) +{ + Edje *ed = embryo_program_data_get(ep); + + Oid *oid; + + int r, g, b, a; + + SI_RETURN(-1); + + CHKPARAM(5); + if (!(oid = _oid_find(ed, params[1]))) + return -1; + evas_object_color_get(oid->obj, &r, &g, &b, &a); + SETINT(r, params[2]); + SETINT(g, params[3]); + SETINT(b, params[4]); + SETINT(a, params[5]); + return 0; +} + +static Embryo_Cell +_exp_e_signal_emit(Embryo_Program * ep, Embryo_Cell * params) +{ + Edje *ed = embryo_program_data_get(ep); + + char *sig = NULL, *src = NULL; + + SI_RETURN(-1); + + CHKPARAM(2); + GETSTR(sig, params[1]); + GETSTR(src, params[2]); + if ((!sig) || (!src)) + return -1; + _edje_emit(ed, sig, src); + return 0; +} + +/**********/ + +Eina_Bool +_edje_script_only(Edje * ed) +{ + if ((ed->collection) && (ed->collection->script) && + (ed->collection->script_only)) + return EINA_TRUE; + return EINA_FALSE; +} + +void +_edje_script_only_init(Edje * ed) +{ + Sinfo *si; + + si = calloc(1, sizeof(Sinfo)); + if (!si) + return; + ed->script_only_data = si; + + embryo_program_data_set(ed->collection->script, ed); + + EXPF(e_obj_del); + EXPF(e_obj_rect_add); + EXPF(e_obj_show); + EXPF(e_obj_hide); + EXPF(e_obj_move); + EXPF(e_obj_resize); + EXPF(e_obj_geometry_set); + EXPF(e_obj_geometry_get); + EXPF(e_obj_color_set); + EXPF(e_obj_color_get); + EXPF(e_signal_emit); + + embryo_program_vm_push(ed->collection->script); + embryo_program_max_cycle_run_set(ed->collection->script, 5000000); + + GTFN(obj_init); + GTFN(obj_shutdown); + GTFN(obj_show); + GTFN(obj_show_immediate); + GTFN(obj_hide); + GTFN(obj_hide_immediate); + GTFN(obj_move); + GTFN(obj_move_immediate); + GTFN(obj_resize); + GTFN(obj_resize_immediate); + GTFN(obj_message); + + CLFN(obj_init); + _edje_script_only_move(ed); +} + +void +_edje_script_only_shutdown(Edje * ed) +{ + SI; + + CLFN(obj_shutdown); + DELJ(show); + DELJ(hide); + DELJ(move); + DELJ(resize); + _oid_freeall(ed); +} + +static void +_show_job(void *data) +{ + Edje *ed = data; + + SI; + + ZERJ(show); + CLFN(obj_show); +} +void +_edje_script_only_show(Edje * ed) +{ + SI; + + IFFN(obj_show) + { + IFNJ(hide) + { + DELJ(show); + ADDJ(show, _show_job); + } + else + { + DELJ(hide); + } + } + IFNO(obj_show_immediate) return; + CLFN(obj_show_immediate); +} + +static void +_hide_job(void *data) +{ + Edje *ed = data; + + SI; + + ZERJ(hide); + CLFN(obj_hide); +} +void +_edje_script_only_hide(Edje * ed) +{ + SI; + + IFFN(obj_hide) + { + IFNJ(show) + { + DELJ(hide); + ADDJ(hide, _hide_job); + } + else + { + DELJ(show); + } + } + IFNO(obj_hide_immediate) return; + CLFN(obj_hide_immediate); +} + +static void +_move_job(void *data) +{ + Edje *ed = data; + + SI; + + _oid_moveall(ed); + ZERJ(move); + IFNO(obj_move) return; + PINT(ed->x); + PINT(ed->y); + CLFN(obj_move); +} +void +_edje_script_only_move(Edje * ed) +{ + SI; + + DELJ(move); + ADDJ(move, _move_job); + IFNO(obj_move_immediate) return; + PINT(ed->x); + PINT(ed->y); + CLFN(obj_move_immediate); +} + +static void +_resize_job(void *data) +{ + Edje *ed = data; + + SI; + + ZERJ(resize); + PINT(ed->w); + PINT(ed->h); + CLFN(obj_resize); +} +void +_edje_script_only_resize(Edje * ed) +{ + SI; + + IFFN(obj_resize) + { + DELJ(resize); + ADDJ(resize, _resize_job); + } + PINT(ed->w); + PINT(ed->h); + CLFN(obj_resize_immediate); +} + +void +_edje_script_only_message(Edje * ed, Edje_Message * em) +{ + SI; + + IFNO(obj_message) return; + _edje_message_parameters_push(em); + CLFN(obj_message); +} + +/**************************************************/ + +static void +_call_fn(Edje * ed, const char *fname, Embryo_Function fn) +{ + int ret; + + ret = embryo_program_run(ed->collection->script, fn); + if (ret == EMBRYO_PROGRAM_FAIL) + { + ERR("ERROR with embryo script. " + "OBJECT NAME: '%s', " + "OBJECT FILE: '%s', " + "ENTRY POINT: '%s', " + "ERROR: '%s'", + ed->collection->part, + ed->file->path, + fname, + embryo_error_string_get(embryo_program_error_get(ed->collection->script))); + } + else if (ret == EMBRYO_PROGRAM_TOOLONG) + { + ERR("ERROR with embryo script. " + "OBJECT NAME: '%s', " + "OBJECT FILE: '%s', " + "ENTRY POINT: '%s', " + "ERROR: 'Script exceeded maximum allowed cycle count of %i'", + ed->collection->part, + ed->file->path, + fname, + embryo_program_max_cycle_run_get(ed->collection->script)); + } +} 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 @@ +#include "edje_private.h" + +static void _edje_smart_add(Evas_Object * obj); +static void _edje_smart_del(Evas_Object * obj); +static void _edje_smart_move(Evas_Object * obj, Evas_Coord x, Evas_Coord y); +static void _edje_smart_resize(Evas_Object * obj, Evas_Coord w, Evas_Coord h); +static void _edje_smart_show(Evas_Object * obj); +static void _edje_smart_hide(Evas_Object * obj); +static void _edje_smart_calculate(Evas_Object * obj); + +static Eina_Bool _edje_smart_file_set(Evas_Object *obj, const char *file, const char *group); + +static Edje_Smart_Api _edje_smart_class = EDJE_SMART_API_INIT_NAME_VERSION("edje"); +static Evas_Smart_Class _edje_smart_parent; +static Evas_Smart *_edje_smart = NULL; + +Eina_List *_edje_edjes = NULL; + +/************************** API Routines **************************/ + +EAPI Evas_Object * +edje_object_add(Evas *evas) +{ + Evas_Object *e; + + _edje_lib_ref(); + + if (!_edje_smart) + { + memset(&_edje_smart_parent, 0, sizeof(_edje_smart_parent)); + _edje_object_smart_set(&_edje_smart_class); + _edje_smart = + evas_smart_class_new((Evas_Smart_Class *)&_edje_smart_class); + } + + e = evas_object_smart_add(evas, _edje_smart); + + return e; +} + +void +_edje_object_smart_set(Edje_Smart_Api *sc) +{ + if (!sc) + return; + + evas_object_smart_clipped_smart_set(&sc->base); + + _edje_smart_parent.add = sc->base.add; /* Save parent class */ + sc->base.add = _edje_smart_add; + _edje_smart_parent.del = sc->base.del; /* Save parent class */ + sc->base.del = _edje_smart_del; + /* we'll handle move thank you */ + sc->base.move = _edje_smart_move; + sc->base.resize = _edje_smart_resize; + _edje_smart_parent.show = sc->base.show; /* Save parent class */ + sc->base.show = _edje_smart_show; + _edje_smart_parent.hide = sc->base.hide; /* Save parent class */ + sc->base.hide = _edje_smart_hide; + sc->base.calculate = _edje_smart_calculate; + //sc->base.member_add = NULL; + //sc->base.member_del = NULL; + sc->file_set = _edje_smart_file_set; +} + +const Edje_Smart_Api * +_edje_object_smart_class_get(void) +{ + static const Edje_Smart_Api *class = NULL; + + if (class) + return class; + + _edje_object_smart_set(&_edje_smart_class); + class = &_edje_smart_class; + + return class; +} + +/* Private Routines */ +static void +_edje_smart_add(Evas_Object *obj) +{ + Edje *ed; + Evas *tev = evas_object_evas_get(obj); + + evas_event_freeze(tev); + ed = evas_object_smart_data_get(obj); + if (!ed) + { + const Evas_Smart *smart; + const Evas_Smart_Class *sc; + + ed = calloc(1, sizeof(Edje)); + if (!ed) goto end_smart_add; + + smart = evas_object_smart_smart_get(obj); + sc = evas_smart_class_get(smart); + ed->api = (const Edje_Smart_Api *)sc; + + evas_object_smart_data_set(obj, ed); + } + + ed->base.evas = evas_object_evas_get(obj); + ed->base.clipper = evas_object_rectangle_add(ed->base.evas); + evas_object_static_clip_set(ed->base.clipper, 1); + evas_object_smart_member_add(ed->base.clipper, obj); + evas_object_color_set(ed->base.clipper, 255, 255, 255, 255); + evas_object_move(ed->base.clipper, -10000, -10000); + evas_object_resize(ed->base.clipper, 20000, 20000); + evas_object_pass_events_set(ed->base.clipper, 1); + ed->is_rtl = EINA_FALSE; + ed->have_objects = 1; + ed->references = 1; + + evas_object_geometry_get(obj, &(ed->x), &(ed->y), &(ed->w), &(ed->h)); + ed->obj = obj; + _edje_edjes = eina_list_append(_edje_edjes, obj); + /* + { + Eina_List *l; + const void *data; + + printf("--- EDJE DUMP [%i]\n", eina_list_count(_edje_edjes)); + EINA_LIST_FOREACH(_edge_edges, l, data) + { + ed = _edje_fetch(data); + printf("EDJE: %80s | %80s\n", ed->path, ed->part); + } + printf("--- EDJE DUMP [%i]\n", eina_list_count(_edje_edjes)); + } + */ +end_smart_add: + evas_event_thaw(tev); + evas_event_thaw_eval(tev); +} + +static void +_edje_smart_del(Evas_Object * obj) +{ + Edje *ed; + + ed = evas_object_smart_data_get(obj); + if (!ed) return; + _edje_block_violate(ed); + ed->delete_me = 1; + _edje_edjes = eina_list_remove(_edje_edjes, obj); + evas_object_smart_data_set(obj, NULL); + if (_edje_script_only(ed)) _edje_script_only_shutdown(ed); + if (_edje_lua_script_only(ed)) _edje_lua_script_only_shutdown(ed); + if (ed->persp) edje_object_perspective_set(obj, NULL); + _edje_file_del(ed); + _edje_clean_objects(ed); + _edje_unref(ed); + _edje_lib_unref(); +} + +static void +_edje_smart_move(Evas_Object * obj, Evas_Coord x, Evas_Coord y) +{ + Edje *ed; + + ed = evas_object_smart_data_get(obj); + if (!ed) return; + if ((ed->x == x) && (ed->y == y)) return; + ed->x = x; + ed->y = y; +// evas_object_move(ed->clipper, ed->x, ed->y); + + if (_edje_script_only(ed)) + { + _edje_script_only_move(ed); + return; + } + if (_edje_lua_script_only(ed)) + { + _edje_lua_script_only_move(ed); + return; + } + + if (ed->have_mapped_part) + { + ed->dirty = 1; + _edje_recalc_do(ed); + } + else + { + unsigned int i; + + for (i = 0; i < ed->table_parts_size; i++) + { + Edje_Real_Part *ep; + Evas_Coord ox, oy; + + ep = ed->table_parts[i]; + evas_object_geometry_get(ep->object, &ox, &oy, NULL, NULL); + evas_object_move(ep->object, ed->x + ep->x + ep->text.offset.x, ed->y + ep->y + ep->text.offset.y); + if (ep->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + _edje_entry_real_part_configure(ep); + if (ep->swallowed_object) + { + evas_object_geometry_get(ep->swallowed_object, &ox, &oy, NULL, NULL); + evas_object_move(ep->swallowed_object, ed->x + ep->x + ep->text.offset.x, ed->y + ep->y + ep->text.offset.y); + } + } + } +// _edje_emit(ed, "move", NULL); +} + +static void +_edje_limit_emit(Edje *ed, const char *limit_name, Eina_Bool over) +{ + char *buffer; + unsigned int length; + + if (!limit_name) return ; + + length = strlen(limit_name) + 13; + buffer = alloca(length); + snprintf(buffer, length, "limit,%s,%s", limit_name, over ? "over" : "below"); + _edje_emit(ed, buffer, NULL); +} + +static void +_edje_limit_get(Edje *ed, Edje_Limit **limits, unsigned int length, Evas_Coord size_current, Evas_Coord size_next) +{ + unsigned int i; + + if (size_next == size_current) return ; + + for (i = 0; i < length; ++i) + { + if ((size_current <= limits[i]->value) && (limits[i]->value < size_next)) + { + _edje_limit_emit(ed, limits[i]->name, EINA_TRUE); + } + else if ((size_next <= limits[i]->value) && (limits[i]->value < size_current)) + { + _edje_limit_emit(ed, limits[i]->name, EINA_FALSE); + } + } +} + +static void +_edje_smart_resize(Evas_Object * obj, Evas_Coord w, Evas_Coord h) +{ + Edje *ed; + + ed = evas_object_smart_data_get(obj); + if (!ed) return; + if ((w == ed->w) && (h == ed->h)) return; + if (ed->collection) + { + _edje_limit_get(ed, ed->collection->limits.horizontal, ed->collection->limits.horizontal_count, ed->w, w); + _edje_limit_get(ed, ed->collection->limits.vertical, ed->collection->limits.vertical_count, ed->h, h); + } + ed->w = w; + ed->h = h; +#ifdef EDJE_CALC_CACHE + ed->all_part_change = 1; +#endif + if (_edje_script_only(ed)) + { + _edje_script_only_resize(ed); + return; + } + if (_edje_lua_script_only(ed)) + { + _edje_lua_script_only_resize(ed); + return; + } +// evas_object_resize(ed->clipper, ed->w, ed->h); + ed->dirty = 1; + _edje_recalc_do(ed); + _edje_emit(ed, "resize", NULL); +} + +static void +_edje_smart_show(Evas_Object * obj) +{ + Edje *ed; + + _edje_smart_parent.show(obj); + ed = evas_object_smart_data_get(obj); + if (!ed) return; + if (evas_object_visible_get(obj)) return; + if (_edje_script_only(ed)) + { + _edje_script_only_show(ed); + return; + } + if (_edje_lua_script_only(ed)) + { + _edje_lua_script_only_show(ed); + return; + } + _edje_emit(ed, "show", NULL); +} + +static void +_edje_smart_hide(Evas_Object * obj) +{ + Edje *ed; + + _edje_smart_parent.hide(obj); + ed = evas_object_smart_data_get(obj); + if (!ed) return; + if (!evas_object_visible_get(obj)) return; + if (_edje_script_only(ed)) + { + _edje_script_only_hide(ed); + return; + } + if (_edje_lua_script_only(ed)) + { + _edje_lua_script_only_hide(ed); + return; + } + _edje_emit(ed, "hide", NULL); +} + +static void +_edje_smart_calculate(Evas_Object *obj) +{ + Edje *ed; + + ed = evas_object_smart_data_get(obj); + if (!ed) return; + _edje_recalc_do(ed); +} + +static Eina_Bool +_edje_smart_file_set(Evas_Object *obj, const char *file, const char *group) +{ + return _edje_object_file_set_internal(obj, file, group, NULL, NULL); +} 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 @@ +#include "edje_private.h" +#define _ELLIP_STR "\xE2\x80\xA6" + +/* returns with and height for this part. + * + * depending on the value of the use_alternate_font_metrics flag, it will + * either use evas_object_geometry_get() or the _advance_get() functions. + * + * The latter is useful if you want to make sure that width and height + * are the same value for the same number of characters in the text. + * This usually only makes sense for monospaced fonts. + * + * In future changes to this file, you probably should use this wrapper + * function everywhere instead of calling evas_object_geometry_get() + * directly. + */ +static inline void +part_get_geometry(Edje_Real_Part *rp, Evas_Coord *w, Evas_Coord *h) +{ + if (!rp->part->use_alternate_font_metrics) + evas_object_geometry_get(rp->object, NULL, NULL, w, h); + else + { + if (w) *w = evas_object_text_horiz_advance_get(rp->object); + if (h) *h = evas_object_text_vert_advance_get(rp->object); + } +} + +void +_edje_text_init(void) +{ +} + +void +_edje_text_part_on_add(Edje *ed, Edje_Real_Part *ep) +{ + Edje_Part *pt = ep->part; + Edje_Part_Description_Text *desc; + unsigned int i; + + if (ep->part->type != EDJE_PART_TYPE_TEXT) return; + + /* if text class exists for this part, add the edje to the tc member list */ + desc = (Edje_Part_Description_Text *) pt->default_desc; + if ((pt->default_desc) && (desc->text.text_class)) + _edje_text_class_member_add(ed, desc->text.text_class); + + /* If any other classes exist add them */ + for (i = 0; i < pt->other.desc_count; ++i) + { + desc = (Edje_Part_Description_Text *) pt->other.desc[i]; + if ((desc) && (desc->text.text_class)) + _edje_text_class_member_add(ed, desc->text.text_class); + } +} + +void +_edje_text_part_on_del(Edje *ed, Edje_Part *pt) +{ + Edje_Part_Description_Text *desc; + unsigned int i; + + if (!pt) return; + if (pt->type != EDJE_PART_TYPE_TEXT + && pt->type != EDJE_PART_TYPE_TEXTBLOCK) + return ; + + desc = (Edje_Part_Description_Text *) pt->default_desc; + if ((pt->default_desc) && (desc->text.text_class)) + _edje_text_class_member_del(ed, desc->text.text_class); + + for (i = 0; i < pt->other.desc_count; ++i) + { + desc = (Edje_Part_Description_Text *) pt->other.desc[i]; + if (desc->text.text_class) + _edje_text_class_member_del(ed, desc->text.text_class); + } +} + +static void +_edje_text_fit_set(char *buf, const char *text, int c1, int c2) +{ + /* helper function called from _edje_text_fit_x(). + * note that we can use strcpy()/strcat() safely, the buffer lengths + * are checked in the caller. + */ + + if (c1 >= 0) + { + strcpy(buf, _ELLIP_STR); + + if (c2 >= 0) + { + strncat(buf, text + c1, c2 - c1); + strcat(buf, _ELLIP_STR); + } + else + strcat(buf, text + c1); + } + else + { + if (c2 >= 0) + { + strncpy(buf, text, c2); + buf[c2] = 0; + strcat(buf, _ELLIP_STR); + } + else + strcpy(buf, text); + } +} + +static const char * +_edje_text_fit_x(Edje *ed, Edje_Real_Part *ep, + Edje_Calc_Params *params, + const char *text, const char *font, int size, + Evas_Coord sw, int *free_text) +{ + Evas_Coord tw = 0, th = 0, p; + int l, r; + int i; + char *buf; + int uc1 = -1, uc2 = -1, c1 = -1, c2 = -1; + int loop = 0, extra; + size_t orig_len; + FLOAT_T sc; + + sc = ed->scale; + if (sc == ZERO) sc = _edje_scale; + + *free_text = 0; + if (sw <= 1) return ""; + + if (ep->part->scale) evas_object_scale_set(ep->object, TO_DOUBLE(sc)); + evas_object_text_font_set(ep->object, font, size); + evas_object_text_text_set(ep->object, text); + + part_get_geometry(ep, &tw, &th); + evas_object_text_style_pad_get(ep->object, &l, &r, NULL, NULL); + + p = ((sw - tw) * params->type.text.elipsis); + + /* chop chop */ + if (tw > sw) + { + if (params->type.text.elipsis != 0.0) + /* should be the last in text! not the rightmost */ + uc1 = evas_object_text_last_up_to_pos(ep->object, + -p + l, th / 2); + if (params->type.text.elipsis != 1.0) + { + /* should be the last in text! not the rightmost */ + if ((-p + sw -r) < 0) + uc2 = evas_object_text_last_up_to_pos(ep->object, 0, th / 2); + else + uc2 = evas_object_text_last_up_to_pos(ep->object, + -p + sw - r, th / 2); + } + if ((uc1 < 0) && (uc2 < 0)) + { + uc1 = 0; + uc2 = 0; + } + } + + if (!(((uc1 >= 0) || (uc2 >= 0)) && (tw > sw))) + return text; + + if ((uc1 == 0) && (uc2 == 0)) + return text; + + orig_len = strlen(text); + + /* don't overflow orig_len by adding extra + * FIXME: we might want to set a max string length somewhere... + */ + extra = 1 + 3 + 3; /* terminator, leading and trailing ellipsis */ + orig_len = MIN(orig_len, ((size_t) 8192 - extra)); + + if (!(buf = malloc(orig_len + extra))) + return text; + + /* Convert uc1, uc2 -> c1, c2 */ + i = 0; + if (uc1 >= 0) + { + c1 = 0; + for ( ; i < uc1 ; i++) + { + c1 = evas_string_char_next_get(text, c1, NULL); + } + } + if (uc2 >= 0) + { + if (c1 >= 0) + { + c2 = c1; + } + else + { + c2 = 0; + } + for ( ; i < uc2 ; i++) + { + c2 = evas_string_char_next_get(text, c2, NULL); + } + } + + buf[0] = '\0'; + + while (((c1 >= 0) || (c2 >= 0)) && (tw > sw)) + { + loop++; + if (sw <= 0.0) + { + buf[0] = 0; + break; + } + if ((c1 >= 0) && (c2 >= 0)) + { + if ((loop & 0x1)) + { + if (c1 >= 0) + c1 = evas_string_char_next_get(text, c1, NULL); + } + else + { + if (c2 >= 0) + { + c2 = evas_string_char_prev_get(text, c2, NULL); + if (c2 < 0) + { + buf[0] = 0; + break; + } + } + } + } + else + { + if (c1 >= 0) + c1 = evas_string_char_next_get(text, c1, NULL); + else if (c2 >= 0) + { + c2 = evas_string_char_prev_get(text, c2, NULL); + if (c2 < 0) + { + buf[0] = 0; + break; + } + } + } + if ((c1 >= 0) && (c2 >= 0)) + { + if (c1 >= c2) + { + buf[0] = 0; + break; + } + } + else if ((c1 > 0 && (size_t) c1 >= orig_len) || c2 == 0) + { + buf[0] = 0; + break; + } + + buf[0] = 0; + + _edje_text_fit_set(buf, text, c1, c2); + + evas_object_text_text_set(ep->object, buf); + part_get_geometry(ep, &tw, &th); + } + + *free_text = 1; + + return buf; +} + +static const char * +_edje_text_font_get(const char *base, const char *new, char **free_later) +{ + const char *base_style, *new_style, *aux; + size_t font_len, style_len; + + if (base && (!new)) + return base; + else if (!base) + return new; + + base_style = strstr(base, ":style="); + if (!base_style) + return new; + + new_style = strstr(new, ":style="); + if (new_style) + return new; + + font_len = strlen(new); + aux = strchr(base_style, ','); + style_len = (aux) ? (size_t)(aux - base_style) : strlen(base_style); + + *free_later = malloc(font_len + style_len + 1); + memcpy(*free_later, new, font_len); + memcpy(*free_later + font_len, base_style, style_len); + (*free_later)[font_len + style_len] = '\0'; + + return *free_later; +} + +const char * +_edje_text_class_font_get(Edje *ed, Edje_Part_Description_Text *chosen_desc, int *size, char **free_later) +{ + Edje_Text_Class *tc; + const char *text_class_name, *font; + + font = edje_string_get(&chosen_desc->text.font); + *size = chosen_desc->text.size; + + text_class_name = chosen_desc->text.text_class; + if ((!text_class_name) || (!text_class_name[0])) + return font; + + tc = _edje_text_class_find(ed, text_class_name); + if (!tc) + return font; + + font = _edje_text_font_get(edje_string_get(&chosen_desc->text.font), tc->font, free_later); + *size = _edje_text_size_calc(*size, tc); + + return font; +} + +void +_edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep, + Edje_Calc_Params *params, + Edje_Part_Description_Text *chosen_desc) +{ + const char *text = NULL; + const char *font; + char *font2 = NULL; + char *sfont = NULL; + int size; + Evas_Coord tw, th; + Evas_Coord sw, sh; + int inlined_font = 0, free_text = 0; + Eina_Bool same_text = EINA_FALSE; + FLOAT_T sc; + + sc = ed->scale; + if (sc == 0.0) sc = _edje_scale; + text = edje_string_get(&chosen_desc->text.text); + font = _edje_text_class_font_get(ed, chosen_desc, &size, &sfont); + + if (ep->text.text) text = ep->text.text; + if (ep->text.font) font = ep->text.font; + if (ep->text.size > 0) size = ep->text.size; + + if (ep->text.text_source) + { + text = edje_string_get(&(((Edje_Part_Description_Text *)ep->text.text_source->chosen_description)->text.text)); + if (ep->text.text_source->text.text) text = ep->text.text_source->text.text; + } + if (ep->text.source) + { + font = edje_string_get(&(((Edje_Part_Description_Text *)ep->text.source->chosen_description)->text.font)); + size = ((Edje_Part_Description_Text *)ep->text.source->chosen_description)->text.size; + if (ep->text.source->text.font) font = ep->text.source->text.font; + if (ep->text.source->text.size > 0) size = ep->text.source->text.size; + } + + if (!text) text = ""; + if (!font) font = ""; + + /* check if the font is embedded in the .eet */ + if (ed->file->fonts) + { + Edje_Font_Directory_Entry *fnt = eina_hash_find(ed->file->fonts, font); + + if (fnt) + { + size_t len = strlen(font) + sizeof("edje/fonts/") + 1; + font2 = alloca(len); + sprintf(font2, "edje/fonts/%s", font); + font = font2; + inlined_font = 1; + font2 = NULL; + } + } + + if ((_edje_fontset_append) && (font)) + { + font2 = malloc(strlen(font) + 1 + strlen(_edje_fontset_append) + 1); + if (font2) + { + strcpy(font2, font); + strcat(font2, ","); + strcat(font2, _edje_fontset_append); + font = font2; + } + } + { + int l, r, t, b; + + evas_object_text_style_pad_get(ep->object, &l, &r, &t, &b); + sw = params->w; + sh = params->h; + } + + size = params->type.text.size; + if (!text) text = ""; + + if ((text == ep->text.cache.in_str) + || (text && ep->text.cache.in_str && !strcmp(ep->text.cache.in_str, text))) + { + text = ep->text.cache.in_str; + same_text = EINA_TRUE; + } + + if ((ep->text.cache.in_size == size) && + (ep->text.cache.in_w == sw) && + (ep->text.cache.in_h == sh) && + (ep->text.cache.in_str) && + same_text && + (ep->text.cache.align_x == params->type.text.align.x) && + (ep->text.cache.align_y == params->type.text.align.y) && + (ep->text.cache.elipsis == params->type.text.elipsis) && + (ep->text.cache.fit_x == chosen_desc->text.fit_x) && + (ep->text.cache.fit_y == chosen_desc->text.fit_y)) + { + text = ep->text.cache.out_str; + size = ep->text.cache.out_size; + + goto arrange_text; + } + if (!same_text) + { + eina_stringshare_replace(&ep->text.cache.in_str, text); + } + ep->text.cache.in_size = size; + if (chosen_desc->text.fit_x && (ep->text.cache.in_str && eina_stringshare_strlen(ep->text.cache.in_str) > 0)) + { + if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path); + else evas_object_text_font_source_set(ep->object, NULL); + + if (ep->part->scale) evas_object_scale_set(ep->object, TO_DOUBLE(sc)); + evas_object_text_font_set(ep->object, font, size); + evas_object_text_text_set(ep->object, text); + part_get_geometry(ep, &tw, &th); + /* Find the wanted font size */ + if ((tw != sw) && (size > 0) && (tw != 0)) + { + size = (size * sw) / tw; + + if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path); + else evas_object_text_font_source_set(ep->object, NULL); + + if (ep->part->scale) evas_object_scale_set(ep->object, TO_DOUBLE(sc)); + evas_object_text_font_set(ep->object, font, size); + part_get_geometry(ep, &tw, &th); + } + + /* FIXME: This should possibly be replaced by more proper handling, + * but it's still way better than what was here before. */ + if (tw > sw) size--; + } + if (chosen_desc->text.fit_y && (ep->text.cache.in_str && eina_stringshare_strlen(ep->text.cache.in_str) > 0)) + { + /* if we fit in the x axis, too, size already has a somewhat + * meaningful value, so don't overwrite it with the starting + * value in that case + */ + if (!chosen_desc->text.fit_x) size = sh; + + if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path); + else evas_object_text_font_source_set(ep->object, NULL); + + if (ep->part->scale) evas_object_scale_set(ep->object, TO_DOUBLE(sc)); + evas_object_text_font_set(ep->object, font, size); + evas_object_text_text_set(ep->object, text); + part_get_geometry(ep, &tw, &th); + + /* only grow the font size if we didn't already reach the max size + * for the x axis + */ + if (!chosen_desc->text.fit_x && th < sh) + { + int dif; + + dif = (th - sh) / 4; + if (dif < 1) dif = 1; + while ((th < sh) && (sw > 0)) + { + size += dif; + if (size <= 0) break; + if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path); + else evas_object_text_font_source_set(ep->object, NULL); + + if (ep->part->scale) evas_object_scale_set(ep->object, TO_DOUBLE(sc)); + evas_object_text_font_set(ep->object, font, size); + part_get_geometry(ep, &tw, &th); + if ((size > 0) && (th == 0)) break; + } + size -= dif; + } + else if (th > sh) + { + int current; + + if (ep->part->scale) evas_object_scale_set(ep->object, TO_DOUBLE(sc)); + evas_object_text_font_set(ep->object, font, 10); + part_get_geometry(ep, &tw, &th); + + if (th == sh) + current = 10; + else + { + int bottom, top; + + if (th < sh) bottom = 10; + else if (th > sh) bottom = 1; + else bottom = 0; /* XXX shut up GCC, th == sh is handled before! */ + + top = size; + /* search one that fits (binary search) */ + do + { + current = (top + bottom) / 2; + + if (ep->part->scale) evas_object_scale_set(ep->object, TO_DOUBLE(sc)); + evas_object_text_font_set(ep->object, font, current); + part_get_geometry(ep, &tw, &th); + + if (th < sh) bottom = current + 1; + else if (th > sh) top = current - 1; + } while ((bottom < top) && (th != sh)); + } + + /* search the larger one that fits (linear search) */ + do + { + current++; + + if (ep->part->scale) evas_object_scale_set(ep->object, TO_DOUBLE(sc)); + evas_object_text_font_set(ep->object, font, current); + part_get_geometry(ep, &tw, &th); + } while (th <= sh); + size = current - 1; + } + } + + /* Make sure the size is in range */ + if (size < 1) + size = 1; + else if ((size > chosen_desc->text.size_range_max) && + (chosen_desc->text.size_range_max > 0)) + size = chosen_desc->text.size_range_max; + else if (size < chosen_desc->text.size_range_min) + size = chosen_desc->text.size_range_min; + + /* Handle ellipsis */ + if (!chosen_desc->text.min_x) + { + if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path); + else evas_object_text_font_source_set(ep->object, NULL); + + text = _edje_text_fit_x(ed, ep, params, text, font, size, sw, &free_text); + } + + eina_stringshare_replace(&ep->text.cache.out_str, text); + ep->text.cache.in_w = sw; + ep->text.cache.in_h = sh; + ep->text.cache.out_size = size; + ep->text.cache.align_x = params->type.text.align.x; + ep->text.cache.align_y = params->type.text.align.y; + ep->text.cache.elipsis = params->type.text.elipsis; + ep->text.cache.fit_x = chosen_desc->text.fit_x; + ep->text.cache.fit_y = chosen_desc->text.fit_y; + arrange_text: + + if (inlined_font) evas_object_text_font_source_set(ep->object, ed->path); + else evas_object_text_font_source_set(ep->object, NULL); + + if (ep->part->scale) evas_object_scale_set(ep->object, TO_DOUBLE(sc)); + evas_object_text_font_set(ep->object, font, size); + evas_object_text_text_set(ep->object, text); + part_get_geometry(ep, &tw, &th); + /* Handle alignment */ + { + double align_x; + if (params->type.text.align.x < 0.0) + { + if (evas_object_text_direction_get(ep->object) == + EVAS_BIDI_DIRECTION_RTL) + { + align_x = 1.0; + } + else + { + align_x = 0.0; + } + } + else + { + align_x = params->type.text.align.x; + } + ep->text.offset.x = TO_INT(SCALE(align_x, (sw - tw))); + ep->text.offset.y = TO_INT(SCALE(params->type.text.align.y, (sh - th))); + } + + evas_object_move(ep->object, + ed->x + params->x + ep->text.offset.x, + ed->y + params->y + ep->text.offset.y); + + if (params->visible) evas_object_show(ep->object); + else evas_object_hide(ep->object); + { + Evas_Text_Style_Type style; + Edje_Text_Effect effect; + + style = EVAS_TEXT_STYLE_PLAIN; + + evas_object_color_set(ep->object, + (params->color.r * params->color.a) / 255, + (params->color.g * params->color.a) / 255, + (params->color.b * params->color.a) / 255, + params->color.a); + effect = ep->part->effect; + switch (effect & EDJE_TEXT_EFFECT_MASK_BASIC) + { + case EDJE_TEXT_EFFECT_NONE: + case EDJE_TEXT_EFFECT_PLAIN: + style = EVAS_TEXT_STYLE_PLAIN; + break; + case EDJE_TEXT_EFFECT_OUTLINE: + style = EVAS_TEXT_STYLE_OUTLINE; + evas_object_text_outline_color_set(ep->object, + (params->type.text.color2.r * params->type.text.color2.a) / 255, + (params->type.text.color2.g * params->type.text.color2.a) / 255, + (params->type.text.color2.b * params->type.text.color2.a) / 255, + params->type.text.color2.a); + break; + case EDJE_TEXT_EFFECT_SOFT_OUTLINE: + style = EVAS_TEXT_STYLE_SOFT_OUTLINE; + evas_object_text_outline_color_set(ep->object, + (params->type.text.color2.r * params->type.text.color2.a) / 255, + (params->type.text.color2.g * params->type.text.color2.a) / 255, + (params->type.text.color2.b * params->type.text.color2.a) / 255, + params->type.text.color2.a); + break; + case EDJE_TEXT_EFFECT_SHADOW: + style = EVAS_TEXT_STYLE_SHADOW; + evas_object_text_shadow_color_set(ep->object, + (params->type.text.color3.r * params->type.text.color3.a) / 255, + (params->type.text.color3.g * params->type.text.color3.a) / 255, + (params->type.text.color3.b * params->type.text.color3.a) / 255, + params->type.text.color3.a); + break; + case EDJE_TEXT_EFFECT_SOFT_SHADOW: + style = EVAS_TEXT_STYLE_SOFT_SHADOW; + evas_object_text_shadow_color_set(ep->object, + (params->type.text.color3.r * params->type.text.color3.a) / 255, + (params->type.text.color3.g * params->type.text.color3.a) / 255, + (params->type.text.color3.b * params->type.text.color3.a) / 255, + params->type.text.color3.a); + break; + case EDJE_TEXT_EFFECT_OUTLINE_SHADOW: + style = EVAS_TEXT_STYLE_OUTLINE_SHADOW; + evas_object_text_outline_color_set(ep->object, + (params->type.text.color2.r * params->type.text.color2.a) / 255, + (params->type.text.color2.g * params->type.text.color2.a) / 255, + (params->type.text.color2.b * params->type.text.color2.a) / 255, + params->type.text.color2.a); + evas_object_text_shadow_color_set(ep->object, + (params->type.text.color3.r * params->type.text.color3.a) / 255, + (params->type.text.color3.g * params->type.text.color3.a) / 255, + (params->type.text.color3.b * params->type.text.color3.a) / 255, + params->type.text.color3.a); + break; + case EDJE_TEXT_EFFECT_OUTLINE_SOFT_SHADOW: + style = EVAS_TEXT_STYLE_OUTLINE_SOFT_SHADOW; + evas_object_text_outline_color_set(ep->object, + (params->type.text.color2.r * params->type.text.color2.a) / 255, + (params->type.text.color2.g * params->type.text.color2.a) / 255, + (params->type.text.color2.b * params->type.text.color2.a) / 255, + params->type.text.color2.a); + evas_object_text_shadow_color_set(ep->object, + (params->type.text.color3.r * params->type.text.color3.a) / 255, + (params->type.text.color3.g * params->type.text.color3.a) / 255, + (params->type.text.color3.b * params->type.text.color3.a) / 255, + params->type.text.color3.a); + break; + case EDJE_TEXT_EFFECT_FAR_SHADOW: + style = EVAS_TEXT_STYLE_FAR_SHADOW; + evas_object_text_shadow_color_set(ep->object, + (params->type.text.color3.r * params->type.text.color3.a) / 255, + (params->type.text.color3.g * params->type.text.color3.a) / 255, + (params->type.text.color3.b * params->type.text.color3.a) / 255, + params->type.text.color3.a); + break; + case EDJE_TEXT_EFFECT_FAR_SOFT_SHADOW: + style = EVAS_TEXT_STYLE_FAR_SOFT_SHADOW; + evas_object_text_shadow_color_set(ep->object, + (params->type.text.color3.r * params->type.text.color3.a) / 255, + (params->type.text.color3.g * params->type.text.color3.a) / 255, + (params->type.text.color3.b * params->type.text.color3.a) / 255, + params->type.text.color3.a); + break; + case EDJE_TEXT_EFFECT_GLOW: + style = EVAS_TEXT_STYLE_GLOW; + evas_object_text_glow_color_set(ep->object, + (params->type.text.color2.r * params->type.text.color2.a) / 255, + (params->type.text.color2.g * params->type.text.color2.a) / 255, + (params->type.text.color2.b * params->type.text.color2.a) / 255, + params->type.text.color2.a); + evas_object_text_glow2_color_set(ep->object, + (params->type.text.color3.r * params->type.text.color3.a) / 255, + (params->type.text.color3.g * params->type.text.color3.a) / 255, + (params->type.text.color3.b * params->type.text.color3.a) / 255, + params->type.text.color3.a); + break; + default: + style = EVAS_TEXT_STYLE_PLAIN; + break; + } + + switch (effect & EDJE_TEXT_EFFECT_MASK_SHADOW_DIRECTION) + { + case EDJE_TEXT_EFFECT_SHADOW_DIRECTION_BOTTOM_RIGHT: + EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET + (style, EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_RIGHT); + break; + case EDJE_TEXT_EFFECT_SHADOW_DIRECTION_BOTTOM: + EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET + (style, EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM); + break; + case EDJE_TEXT_EFFECT_SHADOW_DIRECTION_BOTTOM_LEFT: + EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET + (style, EVAS_TEXT_STYLE_SHADOW_DIRECTION_BOTTOM_LEFT); + break; + case EDJE_TEXT_EFFECT_SHADOW_DIRECTION_LEFT: + EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET + (style, EVAS_TEXT_STYLE_SHADOW_DIRECTION_LEFT); + break; + case EDJE_TEXT_EFFECT_SHADOW_DIRECTION_TOP_LEFT: + EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET + (style, EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_LEFT); + break; + case EDJE_TEXT_EFFECT_SHADOW_DIRECTION_TOP: + EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET + (style, EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP); + break; + case EDJE_TEXT_EFFECT_SHADOW_DIRECTION_TOP_RIGHT: + EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET + (style, EVAS_TEXT_STYLE_SHADOW_DIRECTION_TOP_RIGHT); + break; + case EDJE_TEXT_EFFECT_SHADOW_DIRECTION_RIGHT: + EVAS_TEXT_STYLE_SHADOW_DIRECTION_SET + (style, EVAS_TEXT_STYLE_SHADOW_DIRECTION_RIGHT); + break; + default: + break; + } + evas_object_text_style_set(ep->object, style); + } + + if (free_text) free((char *)text); + if (font2) free(font2); + if (sfont) free(sfont); +} + +Evas_Font_Size +_edje_text_size_calc(Evas_Font_Size size, Edje_Text_Class *tc) +{ + int val; + + if (tc->size == 0) + { + val = size; + } + else if (tc->size > 0.0) + { + val = tc->size; + } + else + { + val = (size * -tc->size) / 100; + } + return val; +} 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 @@ +#include "edje_private.h" + +static int +_edje_font_is_embedded(Edje_File *edf, char *font) +{ + if (!eina_hash_find(edf->fonts, font)) return 0; + return 1; +} + +static void +_edje_format_param_parse(char *item, char **key, char **val) +{ + char *p, *k, *v; + + p = strchr(item, '='); + k = malloc(p - item + 1); + strncpy(k, item, p - item); + k[p - item] = 0; + *key = k; + p++; + v = strdup(p); + *val = v; +} + +static char * +_edje_format_parse(const char **s) +{ + char *item, *ds; + const char *p, *ss; + const char *s1 = NULL; + const char *s2 = NULL; + + p = *s; + if ((!p) || (*p == 0)) return NULL; + for (;;) + { + if (!s1) + { + if (*p != ' ') s1 = p; + if (*p == 0) break; + } + else if (!s2) + { + if ((p > *s) && (p[-1] != '\\')) + { + if (*p == ' ') s2 = p; + } + if (*p == 0) s2 = p; + } + p++; + if (s1 && s2) + { + item = malloc(s2 - s1 + 1); + if (item) + { + for (ds = item, ss = s1; ss < s2; ss++, ds++) + { + if ((*ss == '\\') && (ss < (s2 - 1))) ss++; + *ds = *ss; + } + *ds = 0; + } + *s = s2; + return item; + } + } + *s = p; + return NULL; +} + +static int +_edje_format_is_param(char *item) +{ + if (strchr(item, '=')) return 1; + return 0; +} + +static char * +_edje_format_reparse(Edje_File *edf, const char *str, Edje_Style_Tag **tag_ret) +{ + Eina_Strbuf *txt, *tmp = NULL; + char *s2, *item, *ret; + const char *s; + + txt = eina_strbuf_new(); + s = str; + while ((item = _edje_format_parse(&s))) + { + if (_edje_format_is_param(item)) + { + char *key = NULL, *val = NULL; + + _edje_format_param_parse(item, &key, &val); + if (!strcmp(key, "font_source")) + { + /* dont allow font sources */ + } + else if (!strcmp(key, "text_class")) + { + if (tag_ret) + (*tag_ret)->text_class = eina_stringshare_add(val); + } + else if (!strcmp(key, "font_size")) + { + if (tag_ret) + (*tag_ret)->font_size = atof(val); + } + else if (!strcmp(key, "font")) /* Fix fonts */ + { + if (tag_ret) + { + if (_edje_font_is_embedded(edf, val)) + { + if (!tmp) + tmp = eina_strbuf_new(); + eina_strbuf_append(tmp, "edje/fonts/"); + eina_strbuf_append(tmp, val); + (*tag_ret)->font = eina_stringshare_add(eina_strbuf_string_get(tmp)); + eina_strbuf_reset(tmp); + } + else + { + (*tag_ret)->font = eina_stringshare_add(val); + } + } + } + else /* Otherwise add to tag buffer */ + { + s2 = eina_str_escape(item); + if (s2) + { + if (eina_strbuf_length_get(txt)) eina_strbuf_append(txt, " "); + eina_strbuf_append(txt, s2); + free(s2); + } + } + free(key); + free(val); + } + else + { + if (eina_strbuf_length_get(txt)) eina_strbuf_append(txt, " "); + eina_strbuf_append(txt, item); + } + free(item); + } + if (tmp) + eina_strbuf_free(tmp); + ret = eina_strbuf_string_steal(txt); + eina_strbuf_free(txt); + return ret; +} + +/* Update all evas_styles which are in an edje + * + * @param ed The edje containing styles which need to be updated + */ +void +_edje_textblock_style_all_update(Edje *ed) +{ + Eina_List *l, *ll; + Edje_Style *stl; + Eina_Strbuf *txt = NULL; + + if (!ed->file) return; + + EINA_LIST_FOREACH(ed->file->styles, l, stl) + { + Edje_Style_Tag *tag; + Edje_Text_Class *tc; + int found = 0; + char *fontset = NULL, *fontsource = NULL; + + /* Make sure the style is already defined */ + if (!stl->style) break; + + /* Make sure the style contains a text_class */ + EINA_LIST_FOREACH(stl->tags, ll, tag) + if (tag->text_class) found = 1; + + /* No text classes , goto next style */ + if (!found) continue; + found = 0; + if (!txt) + txt = eina_strbuf_new(); + + if (_edje_fontset_append) + fontset = eina_str_escape(_edje_fontset_append); + fontsource = eina_str_escape(ed->file->path); + + /* Build the style from each tag */ + EINA_LIST_FOREACH(stl->tags, ll, tag) + { + if (!tag->key) continue; + + /* Add Tag Key */ + eina_strbuf_append(txt, tag->key); + eina_strbuf_append(txt, "='"); + + /* Configure fonts from text class if it exists */ + if ((tc = _edje_text_class_find(ed, tag->text_class))) + { + /* Only update if not clearing, If clear leave it at zero */ + if (tc->font) found = 1; + } + + /* Add and Ha`ndle tag parsed data */ + eina_strbuf_append(txt, tag->value); + + if (!strcmp(tag->key, "DEFAULT")) + { + if (fontset) + { + eina_strbuf_append(txt, " "); + eina_strbuf_append(txt, "font_fallbacks="); + eina_strbuf_append(txt, fontset); + } + eina_strbuf_append(txt, " "); + eina_strbuf_append(txt, "font_source="); + eina_strbuf_append(txt, fontsource); + } + if (tag->font_size != 0) + { + char font_size[32]; + + if (found) + snprintf(font_size, sizeof(font_size), "%f", (double) _edje_text_size_calc(tag->font_size, tc)); + else + snprintf(font_size, sizeof(font_size), "%f", tag->font_size); + + eina_strbuf_append(txt, " "); + eina_strbuf_append(txt, "font_size="); + eina_strbuf_append(txt, font_size); + } + /* Add font name last to save evas from multiple loads */ + if (tag->font) + { + const char *f; + + eina_strbuf_append(txt, " "); + eina_strbuf_append(txt, "font="); + + f = (found) ? tc->font : tag->font; + eina_strbuf_append_escaped(txt, f); + } + found = 0; + + eina_strbuf_append(txt, "'"); + } + if (fontset) free(fontset); + if (fontsource) free(fontsource); + + /* Configure the style */ + evas_textblock_style_set(stl->style, eina_strbuf_string_get(txt)); + eina_strbuf_reset(txt); + } + if (txt) + eina_strbuf_free(txt); +} + +void +_edje_textblock_styles_add(Edje *ed) +{ + Eina_List *l, *ll; + Edje_Style *stl; + + if (!ed->file) return; + + EINA_LIST_FOREACH(ed->file->styles, l, stl) + { + Edje_Style_Tag *tag; + + /* Make sure the style contains the text_class */ + EINA_LIST_FOREACH(stl->tags, ll, tag) + { + if (!tag->text_class) continue; + _edje_text_class_member_add(ed, tag->text_class); + } + } +} + +void +_edje_textblock_styles_del(Edje *ed) +{ + Eina_List *l, *ll; + Edje_Style *stl; + + if (!ed->file) return; + + EINA_LIST_FOREACH(ed->file->styles, l, stl) + { + Edje_Style_Tag *tag; + + /* Make sure the style contains the text_class */ + EINA_LIST_FOREACH(stl->tags, ll, tag) + { + if (!tag->text_class) continue; + _edje_text_class_member_del(ed, tag->text_class); + } + } +} + +/* When we get to here the edje file had been read into memory + * the name of the style is established as well as the name and + * data for the tags. This function will create the Evas_Style + * object for each style. The style is composed of a base style + * followed by a list of tags. + */ +void +_edje_textblock_style_parse_and_fix(Edje_File *edf) +{ + Eina_Strbuf *txt = NULL; + Eina_List *l, *ll; + Edje_Style *stl; + + EINA_LIST_FOREACH(edf->styles, l, stl) + { + Edje_Style_Tag *tag; + char *fontset = NULL, *fontsource = NULL, *ts; + + if (stl->style) break; + + if (!txt) + txt = eina_strbuf_new(); + + stl->style = evas_textblock_style_new(); + evas_textblock_style_set(stl->style, NULL); + + if (_edje_fontset_append) + fontset = eina_str_escape(_edje_fontset_append); + fontsource = eina_str_escape(edf->path); + + /* Build the style from each tag */ + EINA_LIST_FOREACH(stl->tags, ll, tag) + { + if (!tag->key) continue; + + /* Add Tag Key */ + eina_strbuf_append(txt, tag->key); + eina_strbuf_append(txt, "='"); + + ts = _edje_format_reparse(edf, tag->value, &(tag)); + + /* Add and Handle tag parsed data */ + if (ts) + { + if (eet_dictionary_string_check(eet_dictionary_get(edf->ef), tag->value) == 0) + eina_stringshare_del(tag->value); + tag->value = eina_stringshare_add(ts); + eina_strbuf_append(txt, tag->value); + free(ts); + } + + if (!strcmp(tag->key, "DEFAULT")) + { + if (fontset) + { + eina_strbuf_append(txt, " "); + eina_strbuf_append(txt, "font_fallbacks="); + eina_strbuf_append(txt, fontset); + } + eina_strbuf_append(txt, " "); + eina_strbuf_append(txt, "font_source="); + eina_strbuf_append(txt, fontsource); + } + if (tag->font_size > 0) + { + char font_size[32]; + + snprintf(font_size, sizeof(font_size), "%f", tag->font_size); + eina_strbuf_append(txt, " "); + eina_strbuf_append(txt, "font_size="); + eina_strbuf_append(txt, font_size); + } + /* Add font name last to save evas from multiple loads */ + if (tag->font) + { + eina_strbuf_append(txt, " "); + eina_strbuf_append(txt, "font="); + eina_strbuf_append_escaped(txt, tag->font); + } + eina_strbuf_append(txt, "'"); + } + if (fontset) free(fontset); + if (fontsource) free(fontsource); + + /* Configure the style */ + evas_textblock_style_set(stl->style, eina_strbuf_string_get(txt)); + eina_strbuf_reset(txt); + } + if (txt) + eina_strbuf_free(txt); +} + +void +_edje_textblock_style_cleanup(Edje_File *edf) +{ + while (edf->styles) + { + Edje_Style *stl; + + stl = edf->styles->data; + edf->styles = eina_list_remove_list(edf->styles, edf->styles); + while (stl->tags) + { + Edje_Style_Tag *tag; + + tag = stl->tags->data; + stl->tags = eina_list_remove_list(stl->tags, stl->tags); + if (edf->free_strings) + { + if (tag->key) eina_stringshare_del(tag->key); +/* FIXME: Find a proper way to handle it. */ + if (tag->value) eina_stringshare_del(tag->value); + if (tag->text_class) eina_stringshare_del(tag->text_class); + if (tag->font) eina_stringshare_del(tag->font); + } + free(tag); + } + if (edf->free_strings && stl->name) eina_stringshare_del(stl->name); + if (stl->style) evas_textblock_style_free(stl->style); + free(stl); + } +} 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 @@ +#include "edje_private.h" + +typedef struct _Edje_Box_Layout Edje_Box_Layout; +struct _Edje_Box_Layout +{ + EINA_RBTREE; + Evas_Object_Box_Layout func; + void *(*layout_data_get)(void *); + void (*layout_data_free)(void *); + void *data; + void (*free_data)(void *); + char name[]; +}; + +static Eina_Hash *_edje_color_class_hash = NULL; +static Eina_Hash *_edje_color_class_member_hash = NULL; + +static Eina_Hash *_edje_text_class_hash = NULL; +static Eina_Hash *_edje_text_class_member_hash = NULL; + +static Eina_Rbtree *_edje_box_layout_registry = NULL; + +char *_edje_fontset_append = NULL; +FLOAT_T _edje_scale = ZERO; +Eina_Bool _edje_password_show_last = EINA_FALSE; +FLOAT_T _edje_password_show_last_timeout = ZERO; +int _edje_freeze_val = 0; +int _edje_freeze_calc_count = 0; +Eina_List *_edje_freeze_calc_list = NULL; + +typedef struct _Edje_List_Foreach_Data Edje_List_Foreach_Data; +struct _Edje_List_Foreach_Data +{ + Eina_List *list; +}; + +typedef struct _Edje_List_Refcount Edje_List_Refcount; +struct _Edje_List_Refcount +{ + EINA_REFCOUNT; + + Eina_List *lookup; +}; + +static Eina_Bool _edje_color_class_list_foreach(const Eina_Hash *hash, const void *key, void *data, void *fdata); +static Eina_Bool _edje_text_class_list_foreach(const Eina_Hash *hash, const void *key, void *data, void *fdata); +static void _edje_object_image_preload_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); +static void _edje_object_signal_preload_cb(void *data, Evas_Object *obj, const char *emission, const char *source); + +Edje_Real_Part *_edje_real_part_recursive_get_helper(const Edje *ed, char **path); + + +static void +_edje_class_member_direct_del(const char *class, Edje_List_Refcount *lookup, Eina_Hash *hash) +{ + Eina_List *members; + + members = eina_hash_find(hash, class); + members = eina_list_remove_list(members, lookup->lookup); + eina_hash_set(hash, class, members); + free(lookup); +} + +static void +_edje_class_member_add(Edje *ed, Eina_Hash **ehash, Eina_Hash **ghash, const char *class) +{ + Edje_List_Refcount *lookup; + Eina_List *members; + + if ((!ed) || (!ehash) || (!ghash) || (!class)) return; + + lookup = eina_hash_find(*ehash, class); + if (lookup) + { + EINA_REFCOUNT_REF(lookup); + return; + } + + lookup = malloc(sizeof (Edje_List_Refcount)); + if (!lookup) return ; + EINA_REFCOUNT_INIT(lookup); + + /* Get members list */ + members = eina_hash_find(*ghash, class); + + /* Update the member list */ + lookup->lookup = members = eina_list_prepend(members, ed); + + /* Don't loose track of members list */ + if (!*ehash) + *ehash = eina_hash_string_small_new(NULL); + eina_hash_add(*ehash, class, lookup); + + /* Reset the member list to the right pointer */ + if (!*ghash) + *ghash = eina_hash_string_superfast_new(NULL); + eina_hash_set(*ghash, class, members); +} + +static void +_edje_class_member_del(Eina_Hash **ehash, Eina_Hash **ghash, const char *class) +{ + Edje_List_Refcount *lookup; + Eina_List *members; + + if ((!ehash) || (!ghash) || (!class)) return; + members = eina_hash_find(*ghash, class); + if (!members) return; + + lookup = eina_hash_find(*ehash, class); + if (!lookup) return ; + + EINA_REFCOUNT_UNREF(lookup) + { + members = eina_list_remove_list(members, lookup->lookup); + eina_hash_set(*ghash, class, members); + + eina_hash_del(*ehash, class, lookup); + free(lookup); + } +} + +static Eina_Bool +member_list_free(const Eina_Hash *hash __UNUSED__, const void *key __UNUSED__, void *data, void *fdata __UNUSED__) +{ + eina_list_free(data); + return EINA_TRUE; +} + +static void +_edje_class_members_free(Eina_Hash **ghash) +{ + if (!ghash || !*ghash) return; + eina_hash_foreach(*ghash, member_list_free, NULL); + eina_hash_free(*ghash); + *ghash = NULL; +} + +/************************** API Routines **************************/ + +#define FASTFREEZE 1 + +EAPI void +edje_freeze(void) +{ +#ifdef FASTFREEZE + _edje_freeze_val++; + INF("fr ++ ->%i", _edje_freeze_val); +#else +// FIXME: could just have a global freeze instead of per object +// above i tried.. but this broke some things. notable e17's menus. why? + Eina_List *l; + Evas_Object *data; + + EINA_LIST_FOREACH(_edje_edjes, l, data) + edje_object_freeze(data); +#endif +} + +#ifdef FASTFREEZE +static void +_edje_thaw_edje(Edje *ed) +{ + unsigned int i; + + for (i = 0; i < ed->table_parts_size; i++) + { + Edje_Real_Part *rp; + + rp = ed->table_parts[i]; + if (rp->part->type == EDJE_PART_TYPE_GROUP && rp->swallowed_object) + { + Edje *ed2; + + ed2 = _edje_fetch(rp->swallowed_object); + if (ed2) _edje_thaw_edje(ed2); + } + } + if ((ed->recalc) && (ed->freeze <= 0)) _edje_recalc_do(ed); +} +#endif + +EAPI void +edje_thaw(void) +{ +#ifdef FASTFREEZE + _edje_freeze_val--; + INF("fr -- ->%i", _edje_freeze_val); + if ((_edje_freeze_val <= 0) && (_edje_freeze_calc_count > 0)) + { + Edje *ed; + + _edje_freeze_calc_count = 0; + EINA_LIST_FREE(_edje_freeze_calc_list, ed) + { + _edje_thaw_edje(ed); + ed->freeze_calc = 0; + } + } +#else + Evas_Object *data; + +// FIXME: could just have a global freeze instead of per object +// comment as above.. why? + Eina_List *l; + + EINA_LIST_FOREACH(_edje_edjes, l, data) + edje_object_thaw(data); +#endif +} + +EAPI void +edje_fontset_append_set(const char *fonts) +{ + if (_edje_fontset_append) + free(_edje_fontset_append); + _edje_fontset_append = fonts ? strdup(fonts) : NULL; +} + +EAPI const char * +edje_fontset_append_get(void) +{ + return _edje_fontset_append; +} + +EAPI void +edje_scale_set(double scale) +{ + Eina_List *l; + Evas_Object *data; + + if (_edje_scale == FROM_DOUBLE(scale)) return; + _edje_scale = FROM_DOUBLE(scale); + EINA_LIST_FOREACH(_edje_edjes, l, data) + edje_object_calc_force(data); +} + +EAPI double +edje_scale_get(void) +{ + return TO_DOUBLE(_edje_scale); +} + +EAPI void +edje_password_show_last_set(Eina_Bool password_show_last) +{ + if (_edje_password_show_last == password_show_last) return; + _edje_password_show_last = password_show_last; +} + +EAPI void +edje_password_show_last_timeout_set(double password_show_last_timeout) +{ + if (_edje_password_show_last_timeout == FROM_DOUBLE(password_show_last_timeout)) return; + _edje_password_show_last_timeout = FROM_DOUBLE(password_show_last_timeout); +} + +EAPI Eina_Bool +edje_object_scale_set(Evas_Object *obj, double scale) +{ + Edje *ed; + + ed = _edje_fetch(obj); + if (!ed) return EINA_FALSE; + if (ed->scale == scale) return EINA_TRUE; + ed->scale = FROM_DOUBLE(scale); + edje_object_calc_force(obj); + return EINA_TRUE; +} + +EAPI double +edje_object_scale_get(const Evas_Object *obj) +{ + Edje *ed; + + ed = _edje_fetch(obj); + if (!ed) return 0.0; + return TO_DOUBLE(ed->scale); +} + +EAPI Eina_Bool +edje_object_mirrored_get(const Evas_Object *obj) +{ + Edje *ed; + + ed = _edje_fetch(obj); + if (!ed) return EINA_FALSE; + + return ed->is_rtl; +} + +void +_edje_object_orientation_inform(Evas_Object *obj) +{ + if (edje_object_mirrored_get(obj)) + edje_object_signal_emit(obj, "edje,state,rtl", "edje"); + else + edje_object_signal_emit(obj, "edje,state,ltr", "edje"); +} + +EAPI void +edje_object_mirrored_set(Evas_Object *obj, Eina_Bool rtl) +{ + Edje *ed; + unsigned int i; + + ed = _edje_fetch(obj); + if (!ed) return; + if (ed->is_rtl == rtl) return; + + ed->is_rtl = rtl; + + for (i = 0 ; i < ed->table_parts_size ; i++) + { + Edje_Real_Part *ep; + const char *s; + double v; + + ep = ed->table_parts[i]; + s = ep->param1.description->state.name, + v = ep->param1.description->state.value; + _edje_part_description_apply(ed, ep, s, v , NULL, 0.0); + ep->chosen_description = ep->param1.description; + } + _edje_recalc_do(ed); + + _edje_object_orientation_inform(obj); + + return; +} + +EAPI const char * +edje_object_data_get(const Evas_Object *obj, const char *key) +{ + Edje *ed; + + ed = _edje_fetch(obj); + if ((!ed) || (!key)) + return NULL; + if (!ed->collection) return NULL; + if (!ed->collection->data) return NULL; + return edje_string_get(eina_hash_find(ed->collection->data, key)); +} + +EAPI int +edje_object_freeze(Evas_Object *obj) +{ + Edje *ed; + unsigned int i; + + ed = _edje_fetch(obj); + if (!ed) return 0; + for (i = 0; i < ed->table_parts_size; i++) + { + Edje_Real_Part *rp; + rp = ed->table_parts[i]; + if (rp->part->type == EDJE_PART_TYPE_GROUP && rp->swallowed_object) + edje_object_freeze(rp->swallowed_object); + } + return _edje_freeze(ed); +} + +EAPI int +edje_object_thaw(Evas_Object *obj) +{ + Edje *ed; + unsigned int i; + + ed = _edje_fetch(obj); + if (!ed) return 0; + for (i = 0; i < ed->table_parts_size; i++) + { + Edje_Real_Part *rp; + + rp = ed->table_parts[i]; + if (rp->part->type == EDJE_PART_TYPE_GROUP && rp->swallowed_object) + edje_object_thaw(rp->swallowed_object); + } + return _edje_thaw(ed); +} + +EAPI 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) +{ + Eina_List *members; + Edje_Color_Class *cc; + + if (!color_class) return EINA_FALSE; + + cc = eina_hash_find(_edje_color_class_hash, color_class); + if (!cc) + { + cc = calloc(1, sizeof(Edje_Color_Class)); + if (!cc) return EINA_FALSE; + cc->name = eina_stringshare_add(color_class); + if (!cc->name) + { + free(cc); + return EINA_FALSE; + } + if (!_edje_color_class_hash) + _edje_color_class_hash = eina_hash_string_superfast_new(NULL); + eina_hash_add(_edje_color_class_hash, color_class, cc); + } + + if (r < 0) r = 0; + else if (r > 255) r = 255; + if (g < 0) g = 0; + else if (g > 255) g = 255; + if (b < 0) b = 0; + else if (b > 255) b = 255; + if (a < 0) a = 0; + else if (a > 255) a = 255; + if ((cc->r == r) && (cc->g == g) && + (cc->b == b) && (cc->a == a) && + (cc->r2 == r2) && (cc->g2 == g2) && + (cc->b2 == b2) && (cc->a2 == a2) && + (cc->r3 == r3) && (cc->g3 == g3) && + (cc->b3 == b3) && (cc->a3 == a3)) + return EINA_TRUE; + cc->r = r; + cc->g = g; + cc->b = b; + cc->a = a; + cc->r2 = r2; + cc->g2 = g2; + cc->b2 = b2; + cc->a2 = a2; + cc->r3 = r3; + cc->g3 = g3; + cc->b3 = b3; + cc->a3 = a3; + + members = eina_hash_find(_edje_color_class_member_hash, color_class); + while (members) + { + Edje *ed; + + ed = eina_list_data_get(members); + ed->dirty = 1; +#ifdef EDJE_CALC_CACHE + ed->all_part_change = 1; +#endif + _edje_recalc(ed); + _edje_emit(ed, "color_class,set", color_class); + members = eina_list_next(members); + } + return EINA_TRUE; +} + +EAPI 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) +{ + Edje_Color_Class *cc; + + if (!color_class) + cc = NULL; + else + cc = eina_hash_find(_edje_color_class_hash, color_class); + + if (cc) + { +#define X(C) if (C) *C = cc->C +#define S(_r, _g, _b, _a) X(_r); X(_g); X(_b); X(_a) + S(r, g, b, a); + S(r2, g2, b2, a2); + S(r3, g3, b3, a3); +#undef S +#undef X + return EINA_TRUE; + } + else + { +#define X(C) if (C) *C = 0 +#define S(_r, _g, _b, _a) X(_r); X(_g); X(_b); X(_a) + S(r, g, b, a); + S(r2, g2, b2, a2); + S(r3, g3, b3, a3); +#undef S +#undef X + return EINA_FALSE; + } +} + +void +edje_color_class_del(const char *color_class) +{ + Edje_Color_Class *cc; + Eina_List *members; + + if (!color_class) return; + + cc = eina_hash_find(_edje_color_class_hash, color_class); + if (!cc) return; + + eina_hash_del(_edje_color_class_hash, color_class, cc); + eina_stringshare_del(cc->name); + free(cc); + + members = eina_hash_find(_edje_color_class_member_hash, color_class); + while (members) + { + Edje *ed; + + ed = eina_list_data_get(members); + ed->dirty = 1; +#ifdef EDJE_CALC_CACHE + ed->all_part_change = 1; +#endif + _edje_recalc(ed); + _edje_emit(ed, "color_class,del", color_class); + members = eina_list_next(members); + } +} + +Eina_List * +edje_color_class_list(void) +{ + Edje_List_Foreach_Data fdata; + + if (!_edje_color_class_member_hash) return NULL; + + memset(&fdata, 0, sizeof(Edje_List_Foreach_Data)); + eina_hash_foreach(_edje_color_class_member_hash, + _edje_color_class_list_foreach, &fdata); + + return fdata.list; +} + +static Eina_Bool +_edje_color_class_list_foreach(const Eina_Hash *hash __UNUSED__, const void *key, void *data __UNUSED__, void *fdata) +{ + Edje_List_Foreach_Data *fd; + + fd = fdata; + fd->list = eina_list_append(fd->list, strdup(key)); + return EINA_TRUE; +} + +EAPI 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) +{ + Edje *ed; + Eina_List *l; + Edje_Color_Class *cc; + unsigned int i; + + ed = _edje_fetch(obj); + if ((!ed) || (!color_class)) return EINA_FALSE; + if (r < 0) r = 0; + else if (r > 255) r = 255; + if (g < 0) g = 0; + else if (g > 255) g = 255; + if (b < 0) b = 0; + else if (b > 255) b = 255; + if (a < 0) a = 0; + else if (a > 255) a = 255; + color_class = eina_stringshare_add(color_class); + if (!color_class) return EINA_FALSE; + EINA_LIST_FOREACH(ed->color_classes, l, cc) + { + if (cc->name == color_class) + { + eina_stringshare_del(color_class); + + if ((cc->r == r) && (cc->g == g) && + (cc->b == b) && (cc->a == a) && + (cc->r2 == r2) && (cc->g2 == g2) && + (cc->b2 == b2) && (cc->a2 == a2) && + (cc->r3 == r3) && (cc->g3 == g3) && + (cc->b3 == b3) && (cc->a3 == a3)) + return EINA_TRUE; + cc->r = r; + cc->g = g; + cc->b = b; + cc->a = a; + cc->r2 = r2; + cc->g2 = g2; + cc->b2 = b2; + cc->a2 = a2; + cc->r3 = r3; + cc->g3 = g3; + cc->b3 = b3; + cc->a3 = a3; + ed->dirty = 1; +#ifdef EDJE_CALC_CACHE + ed->all_part_change = 1; +#endif + _edje_recalc(ed); + return EINA_TRUE; + } + } + cc = malloc(sizeof(Edje_Color_Class)); + if (!cc) + { + eina_stringshare_del(color_class); + return EINA_FALSE; + } + cc->name = color_class; + cc->r = r; + cc->g = g; + cc->b = b; + cc->a = a; + cc->r2 = r2; + cc->g2 = g2; + cc->b2 = b2; + cc->a2 = a2; + cc->r3 = r3; + cc->g3 = g3; + cc->b3 = b3; + cc->a3 = a3; + ed->color_classes = eina_list_append(ed->color_classes, cc); + ed->dirty = 1; +#ifdef EDJE_CALC_CACHE + ed->all_part_change = 1; +#endif + + for (i = 0; i < ed->table_parts_size; i++) + { + Edje_Real_Part *rp; + + rp = ed->table_parts[i]; + if (rp->part->type == EDJE_PART_TYPE_GROUP && rp->swallowed_object) + edje_object_color_class_set(rp->swallowed_object, color_class, + r, g, b, a, r2, g2, b2, a2, r3, g3, b3, + a3); + } + + _edje_recalc(ed); + _edje_emit(ed, "color_class,set", color_class); + return EINA_TRUE; +} + +EAPI Eina_Bool +edje_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) +{ + Edje *ed = _edje_fetch(obj); + Edje_Color_Class *cc = _edje_color_class_find(ed, color_class); + + if (cc) + { +#define X(C) if (C) *C = cc->C +#define S(_r, _g, _b, _a) X(_r); X(_g); X(_b); X(_a) + S(r, g, b, a); + S(r2, g2, b2, a2); + S(r3, g3, b3, a3); +#undef S +#undef X + return EINA_TRUE; + } + else + { +#define X(C) if (C) *C = 0 +#define S(_r, _g, _b, _a) X(_r); X(_g); X(_b); X(_a) + S(r, g, b, a); + S(r2, g2, b2, a2); + S(r3, g3, b3, a3); +#undef S +#undef X + return EINA_FALSE; + } +} + +void +edje_object_color_class_del(Evas_Object *obj, const char *color_class) +{ + Edje *ed; + Eina_List *l; + Edje_Color_Class *cc = NULL; + unsigned int i; + + if (!color_class) return; + + ed = _edje_fetch(obj); + EINA_LIST_FOREACH(ed->color_classes, l, cc) + { + if (!strcmp(cc->name, color_class)) + { + ed->color_classes = eina_list_remove(ed->color_classes, cc); + eina_stringshare_del(cc->name); + free(cc); + break; + } + } + + for (i = 0; i < ed->table_parts_size; i++) + { + Edje_Real_Part *rp; + + rp = ed->table_parts[i]; + if (rp->part->type == EDJE_PART_TYPE_GROUP && rp->swallowed_object) + edje_object_color_class_del(rp->swallowed_object, color_class); + } + + ed->dirty = 1; +#ifdef EDJE_CALC_CACHE + ed->all_part_change = 1; +#endif + _edje_recalc(ed); + _edje_emit(ed, "color_class,del", color_class); +} + +EAPI Eina_Bool +edje_text_class_set(const char *text_class, const char *font, Evas_Font_Size size) +{ + Eina_List *members; + Edje_Text_Class *tc; + + if (!text_class) return EINA_FALSE; + if (!font) font = ""; + + tc = eina_hash_find(_edje_text_class_hash, text_class); + /* Create new text class */ + if (!tc) + { + tc = calloc(1, sizeof(Edje_Text_Class)); + if (!tc) return EINA_FALSE; + tc->name = eina_stringshare_add(text_class); + if (!tc->name) + { + free(tc); + return EINA_FALSE; + } + if (!_edje_text_class_hash) _edje_text_class_hash = eina_hash_string_superfast_new(NULL); + eina_hash_add(_edje_text_class_hash, text_class, tc); + + tc->font = eina_stringshare_add(font); + tc->size = size; + return EINA_FALSE; + } + + /* If the class found is the same just return */ + if ((tc->size == size) && (tc->font) && (!strcmp(tc->font, font))) + return EINA_TRUE; + + /* Update the class found */ + eina_stringshare_del(tc->font); + tc->font = eina_stringshare_add(font); + if (!tc->font) + { + eina_hash_del(_edje_text_class_hash, text_class, tc); + free(tc); + return EINA_FALSE; + } + tc->size = size; + + /* Tell all members of the text class to recalc */ + members = eina_hash_find(_edje_text_class_member_hash, text_class); + while (members) + { + Edje *ed; + + ed = eina_list_data_get(members); + ed->dirty = 1; + _edje_textblock_style_all_update(ed); +#ifdef EDJE_CALC_CACHE + ed->text_part_change = 1; +#endif + _edje_recalc(ed); + members = eina_list_next(members); + } + return EINA_TRUE; +} + +void +edje_text_class_del(const char *text_class) +{ + Edje_Text_Class *tc; + Eina_List *members; + + if (!text_class) return; + + tc = eina_hash_find(_edje_text_class_hash, text_class); + if (!tc) return; + + eina_hash_del(_edje_text_class_hash, text_class, tc); + eina_stringshare_del(tc->name); + eina_stringshare_del(tc->font); + free(tc); + + members = eina_hash_find(_edje_text_class_member_hash, text_class); + while (members) + { + Edje *ed; + + ed = eina_list_data_get(members); + ed->dirty = 1; + _edje_textblock_style_all_update(ed); +#ifdef EDJE_CALC_CACHE + ed->text_part_change = 1; +#endif + _edje_recalc(ed); + members = eina_list_next(members); + } +} + +Eina_List * +edje_text_class_list(void) +{ + Edje_List_Foreach_Data fdata; + + memset(&fdata, 0, sizeof(Edje_List_Foreach_Data)); + eina_hash_foreach(_edje_text_class_member_hash, + _edje_text_class_list_foreach, &fdata); + return fdata.list; +} + +static Eina_Bool +_edje_text_class_list_foreach(const Eina_Hash *hash __UNUSED__, const void *key, void *data __UNUSED__, void *fdata) +{ + Edje_List_Foreach_Data *fd; + + fd = fdata; + fd->list = eina_list_append(fd->list, eina_stringshare_add(key)); + return EINA_TRUE; +} + +EAPI Eina_Bool +edje_object_text_class_set(Evas_Object *obj, const char *text_class, const char *font, Evas_Font_Size size) +{ + Edje *ed; + Eina_List *l; + Edje_Text_Class *tc; + unsigned int i; + + ed = _edje_fetch(obj); + if ((!ed) || (!text_class)) return EINA_FALSE; + + /* for each text_class in the edje */ + EINA_LIST_FOREACH(ed->text_classes, l, tc) + { + if ((tc->name) && (!strcmp(tc->name, text_class))) + { + /* Match and the same, return */ + if ((tc->font) && (font) && (!strcmp(tc->font, font)) && + (tc->size == size)) + return EINA_TRUE; + + /* No font but size is the same, return */ + if ((!tc->font) && (!font) && (tc->size == size)) return EINA_TRUE; + + /* Update new text class properties */ + if (tc->font) eina_stringshare_del(tc->font); + if (font) tc->font = eina_stringshare_add(font); + else tc->font = NULL; + tc->size = size; + + /* Update edje */ + ed->dirty = 1; +#ifdef EDJE_CALC_CACHE + ed->text_part_change = 1; +#endif + _edje_recalc(ed); + return EINA_TRUE; + } + } + + /* No matches, create a new text class */ + tc = calloc(1, sizeof(Edje_Text_Class)); + if (!tc) return EINA_FALSE; + tc->name = eina_stringshare_add(text_class); + if (!tc->name) + { + free(tc); + return EINA_FALSE; + } + if (font) tc->font = eina_stringshare_add(font); + else tc->font = NULL; + tc->size = size; + + for (i = 0; i < ed->table_parts_size; i++) + { + Edje_Real_Part *rp; + + rp = ed->table_parts[i]; + if (rp->part->type == EDJE_PART_TYPE_GROUP && rp->swallowed_object) + edje_object_text_class_set(rp->swallowed_object, text_class, + font, size); + } + + /* Add to edje's text class list */ + ed->text_classes = eina_list_append(ed->text_classes, tc); + ed->dirty = 1; +#ifdef EDJE_CALC_CACHE + ed->text_part_change = 1; +#endif + _edje_textblock_style_all_update(ed); + _edje_recalc(ed); + return EINA_TRUE; +} + +EAPI Eina_Bool +edje_object_part_exists(const Evas_Object *obj, const char *part) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return EINA_FALSE; + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp) return EINA_FALSE; + return EINA_TRUE; +} + +EAPI const Evas_Object * +edje_object_part_object_get(const Evas_Object *obj, const char *part) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return NULL; + + /* Need to recalc before providing the object. */ + _edje_recalc_do(ed); + + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp) return NULL; + return rp->object; +} + +EAPI 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 ) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) + { + if (x) *x = 0; + if (y) *y = 0; + if (w) *w = 0; + if (h) *h = 0; + return EINA_FALSE; + } + + /* Need to recalc before providing the object. */ + _edje_recalc_do(ed); + + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp) + { + if (x) *x = 0; + if (y) *y = 0; + if (w) *w = 0; + if (h) *h = 0; + return EINA_FALSE; + } + if (x) *x = rp->x; + if (y) *y = rp->y; + if (w) *w = rp->w; + if (h) *h = rp->h; + return EINA_TRUE; +} + +EAPI void +edje_object_item_provider_set(Evas_Object *obj, Edje_Item_Provider_Cb func, void *data) +{ + Edje *ed; + + ed = _edje_fetch(obj); + if (!ed) return; + ed->item_provider.func = func; + ed->item_provider.data = data; +} + +/* FIXDOC: New Function */ +EAPI void +edje_object_text_change_cb_set(Evas_Object *obj, Edje_Text_Change_Cb func, void *data) +{ + Edje *ed; + unsigned int i; + + ed = _edje_fetch(obj); + if (!ed) return; + ed->text_change.func = func; + ed->text_change.data = data; + + for (i = 0; i < ed->table_parts_size; i++) + { + Edje_Real_Part *rp; + + rp = ed->table_parts[i]; + if ((rp->part->type == EDJE_PART_TYPE_GROUP) && (rp->swallowed_object)) + edje_object_text_change_cb_set(rp->swallowed_object, func, data); + } +} + +Eina_Bool +_edje_object_part_text_raw_set(Evas_Object *obj, Edje_Real_Part *rp, const char *part, const char *text) +{ + if ((!rp->text.text) && (!text)) + return EINA_FALSE; + if ((rp->text.text) && (text) && + (!strcmp(rp->text.text, text))) + return EINA_FALSE; + if (rp->text.text) + { + eina_stringshare_del(rp->text.text); + rp->text.text = NULL; + } + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + _edje_entry_text_markup_set(rp, text); + else + if (text) rp->text.text = eina_stringshare_add(text); + rp->edje->dirty = 1; +#ifdef EDJE_CALC_CACHE + rp->invalidate = 1; +#endif + _edje_recalc(rp->edje); + if (rp->edje->text_change.func) + rp->edje->text_change.func(rp->edje->text_change.data, obj, part); + return EINA_TRUE; +} + +Eina_Bool +_edje_object_part_text_raw_append(Evas_Object *obj, Edje_Real_Part *rp, const char *part, const char *text) +{ + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + _edje_entry_text_markup_append(rp, text); + else if (text) + { + if (rp->text.text) + { + char *new = NULL; + int len_added = strlen(text); + int len_old = strlen(rp->text.text); + new = malloc(len_old + len_added + 1); + memcpy(new, rp->text.text, len_old); + memcpy(new + len_old, text, len_added); + new[len_old + len_added] = '\0'; + eina_stringshare_replace(&rp->text.text, new); + free(new); + } + else + { + eina_stringshare_replace(&rp->text.text, text); + } + } + rp->edje->dirty = 1; +#ifdef EDJE_CALC_CACHE + rp->invalidate = 1; +#endif + _edje_recalc(rp->edje); + if (rp->edje->text_change.func) + rp->edje->text_change.func(rp->edje->text_change.data, obj, part); + return EINA_TRUE; +} + +EAPI Eina_Bool +edje_object_part_text_set(Evas_Object *obj, const char *part, const char *text) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return EINA_FALSE; + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp) return EINA_FALSE; + if ((rp->part->type != EDJE_PART_TYPE_TEXT) && + (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) return EINA_FALSE; + return _edje_object_part_text_raw_set(obj, rp, part, text); +} + +EAPI const char * +edje_object_part_text_get(const Evas_Object *obj, const char *part) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return NULL; + + /* Need to recalc before providing the object. */ + _edje_recalc_do(ed); + + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp) return NULL; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + return _edje_entry_text_get(rp); + else + { + if (rp->part->type == EDJE_PART_TYPE_TEXT) return rp->text.text; + if (rp->part->type == EDJE_PART_TYPE_TEXTBLOCK) + return evas_object_textblock_text_markup_get(rp->object); + } + return NULL; +} + +char * +_edje_text_escape(const char *text) +{ + Eina_Strbuf *txt; + char *ret; + const char *text_end; + size_t text_len; + + if (!text) return NULL; + + txt = eina_strbuf_new(); + text_len = strlen(text); + + text_end = text + text_len; + while (text < text_end) + { + int advance; + const char *escaped = evas_textblock_string_escape_get(text, &advance); + if (!escaped) + { + eina_strbuf_append_char(txt, text[0]); + advance = 1; + } + else + eina_strbuf_append(txt, escaped); + + text += advance; + } + + ret = eina_strbuf_string_steal(txt); + eina_strbuf_free(txt); + return ret; +} + +char * +_edje_text_unescape(const char *text) +{ + Eina_Strbuf *txt; + char *ret; + const char *text_end, *last, *escape_start; + size_t text_len; + + if (!text) return NULL; + + txt = eina_strbuf_new(); + text_len = strlen(text); + + text_end = text + text_len; + last = text; + escape_start = NULL; + for (; text < text_end; text++) + { + if (*text == '&') + { + size_t len; + const char *str; + + if (last) + { + len = text - last; + str = last; + } + else + { + len = text - escape_start; + str = escape_start; + } + + if (len > 0) + eina_strbuf_append_n(txt, str, len); + + escape_start = text; + last = NULL; + } + else if ((*text == ';') && (escape_start)) + { + size_t len; + const char *str = evas_textblock_escape_string_range_get(escape_start, text); + + if (str) + len = strlen(str); + else + { + str = escape_start; + len = text + 1 - escape_start; + } + + eina_strbuf_append_n(txt, str, len); + + escape_start = NULL; + last = text + 1; + } + } + + if (!last && escape_start) + last = escape_start; + + if (last && (text > last)) + { + size_t len = text - last; + eina_strbuf_append_n(txt, last, len); + } + + ret = eina_strbuf_string_steal(txt); + eina_strbuf_free(txt); + return ret; +} + +EAPI Eina_Bool +edje_object_part_text_unescaped_set(Evas_Object *obj, const char *part, const char *text_to_escape) +{ + Edje *ed; + Edje_Real_Part *rp; + Eina_Bool ret = EINA_FALSE; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return ret; + rp = _edje_real_part_recursive_get(ed, part); + if (!rp) return ret; + if (rp->part->type == EDJE_PART_TYPE_TEXT) + ret = _edje_object_part_text_raw_set(obj, rp, part, text_to_escape); + else if (rp->part->type == EDJE_PART_TYPE_TEXTBLOCK) + { + char *text = _edje_text_escape(text_to_escape); + + ret = _edje_object_part_text_raw_set(obj, rp, part, text); + free(text); + } + return ret; +} + +EAPI char * +edje_object_part_text_unescaped_get(const Evas_Object *obj, const char *part) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return NULL; + + /* Need to recalc before providing the object. */ + _edje_recalc_do(ed); + + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp) return NULL; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + { + const char *t = _edje_entry_text_get(rp); + return _edje_text_unescape(t); + } + else + { + if (rp->part->type == EDJE_PART_TYPE_TEXT) return strdup(rp->text.text); + if (rp->part->type == EDJE_PART_TYPE_TEXTBLOCK) + { + const char *t = evas_object_textblock_text_markup_get(rp->object); + return _edje_text_unescape(t); + } + } + return NULL; +} + +EAPI const char * +edje_object_part_text_selection_get(const Evas_Object *obj, const char *part) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return NULL; + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp) return NULL; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + return _edje_entry_selection_get(rp); + return NULL; +} + +EAPI void +edje_object_part_text_select_none(const Evas_Object *obj, const char *part) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return; + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp) return; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + _edje_entry_select_none(rp); +} + +EAPI void +edje_object_part_text_select_all(const Evas_Object *obj, const char *part) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return; + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp) return; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + _edje_entry_select_all(rp); +} + +EAPI void +edje_object_part_text_insert(Evas_Object *obj, const char *part, const char *text) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return; + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp) return; + if ((rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) return; + if (rp->part->entry_mode <= EDJE_ENTRY_EDIT_MODE_NONE) return; + _edje_entry_text_markup_insert(rp, text); + rp->edje->dirty = 1; +#ifdef EDJE_CALC_CACHE + rp->invalidate = 1; +#endif + _edje_recalc(rp->edje); + if (rp->edje->text_change.func) + rp->edje->text_change.func(rp->edje->text_change.data, obj, part); +} + +EAPI void +edje_object_part_text_append(Evas_Object *obj, const char *part, const char *text) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return; + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp) return; + if ((rp->part->type != EDJE_PART_TYPE_TEXTBLOCK)) return; + _edje_object_part_text_raw_append(obj, rp, part, text); + rp->edje->dirty = 1; +#ifdef EDJE_CALC_CACHE + rp->invalidate = 1; +#endif + _edje_recalc(rp->edje); + if (rp->edje->text_change.func) + rp->edje->text_change.func(rp->edje->text_change.data, obj, part); +} + +EAPI const Eina_List * +edje_object_part_text_anchor_list_get(const Evas_Object *obj, const char *part) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return NULL; + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp) return NULL; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + return _edje_entry_anchors_list(rp); + return NULL; +} + +EAPI const Eina_List * +edje_object_part_text_anchor_geometry_get(const Evas_Object *obj, const char *part, const char *anchor) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return NULL; + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp) return NULL; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + return _edje_entry_anchor_geometry_get(rp, anchor); + return NULL; +} + +EAPI const Eina_List * +edje_object_part_text_item_list_get(const Evas_Object *obj, const char *part) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return NULL; + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp) return NULL; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + return _edje_entry_items_list(rp); + return NULL; +} + +EAPI 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) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return EINA_FALSE; + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp) return EINA_FALSE; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + return _edje_entry_item_geometry_get(rp, item, cx, cy, cw, ch); + return EINA_FALSE; +} + +EAPI 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) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if (x) *x = 0; + if (y) *y = 0; + if (w) *w = 0; + if (h) *h = 0; + if ((!ed) || (!part)) return; + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp) return; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + { + _edje_entry_cursor_geometry_get(rp, x, y, w, h); + if (x) *x -= rp->edje->x; + if (y) *y -= rp->edje->y; + } + return; +} + +EAPI void +edje_object_part_text_select_allow_set(const Evas_Object *obj, const char *part, Eina_Bool allow) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return; + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp) return; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + _edje_entry_select_allow_set(rp, allow); +} + +EAPI void +edje_object_part_text_select_abort(const Evas_Object *obj, const char *part) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return; + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp) return; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + _edje_entry_select_abort(rp); +} + +EAPI void +edje_object_part_text_select_begin(const Evas_Object *obj, const char *part) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return; + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp) return; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + _edje_entry_select_begin(rp); +} + +EAPI void +edje_object_part_text_select_extend(const Evas_Object *obj, const char *part) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return; + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp) return; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + _edje_entry_select_extend(rp); +} + +EAPI Eina_Bool +edje_object_part_text_cursor_next(Evas_Object *obj, const char *part, Edje_Cursor cur) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return EINA_FALSE; + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp) return EINA_FALSE; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + { + return _edje_entry_cursor_next(rp, cur); + } + return EINA_FALSE; +} + +EAPI Eina_Bool +edje_object_part_text_cursor_prev(Evas_Object *obj, const char *part, Edje_Cursor cur) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return EINA_FALSE; + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp) return EINA_FALSE; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + { + return _edje_entry_cursor_prev(rp, cur); + } + return EINA_FALSE; +} + +EAPI Eina_Bool +edje_object_part_text_cursor_up(Evas_Object *obj, const char *part, Edje_Cursor cur) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return EINA_FALSE; + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp) return EINA_FALSE; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + { + return _edje_entry_cursor_up(rp, cur); + } + return EINA_FALSE; +} + +EAPI Eina_Bool +edje_object_part_text_cursor_down(Evas_Object *obj, const char *part, Edje_Cursor cur) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return EINA_FALSE; + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp) return EINA_FALSE; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + { + return _edje_entry_cursor_down(rp, cur); + } + return EINA_FALSE; +} + +EAPI void +edje_object_part_text_cursor_begin_set(Evas_Object *obj, const char *part, Edje_Cursor cur) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return; + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp) return; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + { + _edje_entry_cursor_begin(rp, cur); + } +} + +EAPI void +edje_object_part_text_cursor_end_set(Evas_Object *obj, const char *part, Edje_Cursor cur) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return; + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp) return; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + { + _edje_entry_cursor_end(rp, cur); + } +} + +EAPI void +edje_object_part_text_cursor_copy(Evas_Object *obj, const char *part, Edje_Cursor src, Edje_Cursor dst) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return; + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp) return; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + { + _edje_entry_cursor_copy(rp, src, dst); + } +} + +EAPI void +edje_object_part_text_cursor_line_begin_set(Evas_Object *obj, const char *part, Edje_Cursor cur) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return; + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp) return; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + { + _edje_entry_cursor_line_begin(rp, cur); + } +} + +EAPI void +edje_object_part_text_cursor_line_end_set(Evas_Object *obj, const char *part, Edje_Cursor cur) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return; + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp) return; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + { + _edje_entry_cursor_line_end(rp, cur); + } +} + +EAPI Eina_Bool +edje_object_part_text_cursor_coord_set(Evas_Object *obj, const char *part, + Edje_Cursor cur, Evas_Coord x, Evas_Coord y) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return EINA_FALSE; + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp) return EINA_FALSE; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + { + return _edje_entry_cursor_coord_set(rp, cur, x, y); + } + return EINA_FALSE; +} + +EAPI Eina_Bool +edje_object_part_text_cursor_is_format_get(const Evas_Object *obj, const char *part, Edje_Cursor cur) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return EINA_FALSE; + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp) return EINA_FALSE; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + { + return _edje_entry_cursor_is_format_get(rp, cur); + } + return EINA_FALSE; +} + +EAPI Eina_Bool +edje_object_part_text_cursor_is_visible_format_get(const Evas_Object *obj, const char *part, Edje_Cursor cur) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return 0; + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp) return 0; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + { + return _edje_entry_cursor_is_visible_format_get(rp, cur); + } + return 0; +} + +EAPI const char * +edje_object_part_text_cursor_content_get(const Evas_Object *obj, const char *part, Edje_Cursor cur) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return NULL; + rp = _edje_real_part_recursive_get(ed, part); + if (!rp) return NULL; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + { + return _edje_entry_cursor_content_get(rp, cur); + } + return NULL; +} + +EAPI void +edje_object_part_text_cursor_pos_set(Evas_Object *obj, const char *part, Edje_Cursor cur, int pos) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return; + rp = _edje_real_part_recursive_get(ed, part); + if (!rp) return; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + { + _edje_entry_cursor_pos_set(rp, cur, pos); + } +} + +EAPI int +edje_object_part_text_cursor_pos_get(const Evas_Object *obj, const char *part, Edje_Cursor cur) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return 0; + rp = _edje_real_part_recursive_get(ed, part); + if (!rp) return 0; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + { + return _edje_entry_cursor_pos_get(rp, cur); + } + return 0; +} + +EAPI void +edje_object_part_text_input_panel_layout_set(const Evas_Object *obj, const char *part, Edje_Input_Panel_Layout layout) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return; + rp = _edje_real_part_recursive_get(ed, part); + if (!rp) return; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + { + return _edje_entry_input_panel_layout_set(rp, layout); + } +} + +EAPI Edje_Input_Panel_Layout +edje_object_part_text_input_panel_layout_get(const Evas_Object *obj, const char *part) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return EDJE_INPUT_PANEL_LAYOUT_INVALID; + rp = _edje_real_part_recursive_get(ed, part); + if (!rp) return EINA_FALSE; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + { + return _edje_entry_input_panel_layout_get(rp); + } + return EDJE_INPUT_PANEL_LAYOUT_INVALID; +} + +EAPI void +edje_object_part_text_autocapital_type_set(const Evas_Object *obj, const char *part, Edje_Text_Autocapital_Type autocapital_type) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return; + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp) return; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + { + _edje_entry_autocapital_type_set(rp, autocapital_type); + } +} + +EAPI Edje_Text_Autocapital_Type +edje_object_part_text_autocapital_type_get(const Evas_Object *obj, const char *part) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return EDJE_TEXT_AUTOCAPITAL_TYPE_NONE; + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp) return EDJE_TEXT_AUTOCAPITAL_TYPE_NONE; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + { + return _edje_entry_autocapital_type_get(rp); + } + return EDJE_TEXT_AUTOCAPITAL_TYPE_NONE; +} + +EAPI void +edje_object_part_text_input_panel_enabled_set(const Evas_Object *obj, const char *part, Eina_Bool enabled) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return; + rp = _edje_real_part_recursive_get(ed, part); + if (!rp) return; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + { + return _edje_entry_input_panel_enabled_set(rp, enabled); + } +} + +EAPI Eina_Bool +edje_object_part_text_input_panel_enabled_get(const Evas_Object *obj, const char *part) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return EINA_FALSE; + rp = _edje_real_part_recursive_get(ed, part); + if (!rp) return EINA_FALSE; + if (rp->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) + { + return _edje_entry_input_panel_enabled_get(rp); + } + return EINA_FALSE; +} + +EAPI void +edje_object_text_insert_filter_callback_add(Evas_Object *obj, const char *part, Edje_Text_Filter_Cb func, void *data) +{ + Edje *ed; + Edje_Text_Insert_Filter_Callback *cb; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return; + cb = calloc(1, sizeof(Edje_Text_Insert_Filter_Callback)); + cb->part = eina_stringshare_add(part); + cb->func = func; + cb->data = (void *)data; + ed->text_insert_filter_callbacks = + eina_list_append(ed->text_insert_filter_callbacks, cb); +} + +EAPI void * +edje_object_text_insert_filter_callback_del(Evas_Object *obj, const char *part, Edje_Text_Filter_Cb func) +{ + Edje *ed; + Edje_Text_Insert_Filter_Callback *cb; + Eina_List *l; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return NULL; + EINA_LIST_FOREACH(ed->text_insert_filter_callbacks, l, cb) + { + if ((!strcmp(cb->part, part)) && (cb->func == func)) + { + void *data = cb->data; + ed->text_insert_filter_callbacks = + eina_list_remove_list(ed->text_insert_filter_callbacks, l); + eina_stringshare_del(cb->part); + free(cb); + return data; + } + } + return NULL; +} + +EAPI void * +edje_object_text_insert_filter_callback_del_full(Evas_Object *obj, const char *part, Edje_Text_Filter_Cb func, void *data) +{ + Edje *ed; + Edje_Text_Insert_Filter_Callback *cb; + Eina_List *l; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return NULL; + EINA_LIST_FOREACH(ed->text_insert_filter_callbacks, l, cb) + { + if ((!strcmp(cb->part, part)) && (cb->func == func) && + (cb->data == data)) + { + void *tmp = cb->data; + ed->text_insert_filter_callbacks = + eina_list_remove_list(ed->text_insert_filter_callbacks, l); + eina_stringshare_del(cb->part); + free(cb); + return tmp; + } + } + return NULL; +} + +EAPI Eina_Bool +edje_object_part_swallow(Evas_Object *obj, const char *part, Evas_Object *obj_swallow) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return EINA_FALSE; + + /* Need to recalc before providing the object. */ + // XXX: I guess this is not required, removing for testing purposes + // XXX: uncomment if you see glitches in e17 or others. + // XXX: by Gustavo, January 21th 2009. + // XXX: I got a backtrace with over 30000 calls without this, + // XXX: only with 32px shelves. The problem is probably somewhere else, + // XXX: but until it's found, leave this here. + // XXX: by Sachiel, January 21th 2009, 19:30 UTC + _edje_recalc_do(ed); + + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp) return EINA_FALSE; + if (rp->part->type != EDJE_PART_TYPE_SWALLOW) + { + ERR("cannot swallow part %s: not swallow type!", rp->part->name); + return EINA_FALSE; + } + _edje_real_part_swallow(rp, obj_swallow, EINA_TRUE); + return EINA_TRUE; +} + +static void +_recalc_extern_parent(Evas_Object *obj) +{ + Evas_Object *parent; + Edje *ed; + + parent = evas_object_smart_parent_get(obj); + ed = _edje_fetch(parent); + + ed->dirty = 1; + _edje_recalc(ed); +} + +EAPI void +edje_extern_object_min_size_set(Evas_Object *obj, Evas_Coord minw, Evas_Coord minh) +{ + Edje_Real_Part *rp; + + evas_object_size_hint_min_set(obj, minw, minh); + rp = evas_object_data_get(obj, "\377 edje.swallowing_part"); + if (rp) + { + rp->swallow_params.min.w = minw; + rp->swallow_params.min.h = minh; + + _recalc_extern_parent(obj); + } +} + +EAPI void +edje_extern_object_max_size_set(Evas_Object *obj, Evas_Coord maxw, Evas_Coord maxh) +{ + Edje_Real_Part *rp; + + evas_object_size_hint_max_set(obj, maxw, maxh); + rp = evas_object_data_get(obj, "\377 edje.swallowing_part"); + if (rp) + { + rp->swallow_params.max.w = maxw; + rp->swallow_params.max.h = maxh; + + _recalc_extern_parent(obj); + } +} + +EAPI void +edje_extern_object_aspect_set(Evas_Object *obj, Edje_Aspect_Control aspect, Evas_Coord aw, Evas_Coord ah) +{ + Edje_Real_Part *rp; + Evas_Aspect_Control asp; + + asp = EVAS_ASPECT_CONTROL_NONE; + switch (aspect) + { + case EDJE_ASPECT_CONTROL_NONE: asp = EVAS_ASPECT_CONTROL_NONE; break; + case EDJE_ASPECT_CONTROL_NEITHER: asp = EVAS_ASPECT_CONTROL_NEITHER; break; + case EDJE_ASPECT_CONTROL_HORIZONTAL: asp = EVAS_ASPECT_CONTROL_HORIZONTAL; break; + case EDJE_ASPECT_CONTROL_VERTICAL: asp = EVAS_ASPECT_CONTROL_VERTICAL; break; + case EDJE_ASPECT_CONTROL_BOTH: asp = EVAS_ASPECT_CONTROL_BOTH; break; + default: break; + } + if (aw < 1) aw = 1; + if (ah < 1) ah = 1; + evas_object_size_hint_aspect_set(obj, asp, aw, ah); + rp = evas_object_data_get(obj, "\377 edje.swallowing_part"); + if (rp) + { + rp->swallow_params.aspect.mode = aspect; + rp->swallow_params.aspect.w = aw; + rp->swallow_params.aspect.h = ah; + _recalc_extern_parent(obj); + } +} + +struct edje_box_layout_builtin { + const char *name; + Evas_Object_Box_Layout cb; +}; + +static Evas_Object_Box_Layout +_edje_box_layout_builtin_find(const char *name) +{ + const struct edje_box_layout_builtin _edje_box_layout_builtin[] = { + {"horizontal", evas_object_box_layout_horizontal}, + {"horizontal_flow", evas_object_box_layout_flow_horizontal}, + {"horizontal_homogeneous", evas_object_box_layout_homogeneous_horizontal}, + {"horizontal_max", evas_object_box_layout_homogeneous_max_size_horizontal}, + {"stack", evas_object_box_layout_stack}, + {"vertical", evas_object_box_layout_vertical}, + {"vertical_flow", evas_object_box_layout_flow_vertical}, + {"vertical_homogeneous", evas_object_box_layout_homogeneous_vertical}, + {"vertical_max", evas_object_box_layout_homogeneous_max_size_vertical}, + {NULL, NULL} + }; + const struct edje_box_layout_builtin *base; + + switch (name[0]) + { + case 'h': + base = _edje_box_layout_builtin + 0; + break; + case 's': + base = _edje_box_layout_builtin + 4; + break; + case 'v': + base = _edje_box_layout_builtin + 5; + break; + default: + return NULL; + } + + for (; (base->name) && (base->name[0] == name[0]); base++) + if (strcmp(base->name, name) == 0) + return base->cb; + + return NULL; +} + +static Eina_Rbtree_Direction +_edje_box_layout_external_node_cmp(const Eina_Rbtree *left, const Eina_Rbtree *right, __UNUSED__ void *data) +{ + Edje_Box_Layout *l = (Edje_Box_Layout *)left; + Edje_Box_Layout *r = (Edje_Box_Layout *)right; + + if (strcmp(l->name, r->name) < 0) + return EINA_RBTREE_RIGHT; + else + return EINA_RBTREE_LEFT; +} + +static int +_edje_box_layout_external_find_cmp(const Eina_Rbtree *node, const void *key, __UNUSED__ int length, __UNUSED__ void *data) +{ + Edje_Box_Layout *l = (Edje_Box_Layout *)node; + return strcmp(key, l->name); +} + +static Edje_Box_Layout * +_edje_box_layout_external_find(const char *name) +{ + return (Edje_Box_Layout *)eina_rbtree_inline_lookup + (_edje_box_layout_registry, name, 0, _edje_box_layout_external_find_cmp, + NULL); +} + +Eina_Bool +_edje_box_layout_find(const char *name, Evas_Object_Box_Layout *cb, void **data, void (**free_data)(void *data)) +{ + const Edje_Box_Layout *l; + + if (!name) return EINA_FALSE; + + *cb = _edje_box_layout_builtin_find(name); + if (*cb) + { + *free_data = NULL; + *data = NULL; + return EINA_TRUE; + } + + l = _edje_box_layout_external_find(name); + if (!l) return EINA_FALSE; + + *cb = l->func; + *free_data = l->layout_data_free; + if (l->layout_data_get) + *data = l->layout_data_get(l->data); + else + *data = NULL; + + return EINA_TRUE; +} + +static void +_edje_box_layout_external_free(Eina_Rbtree *node, __UNUSED__ void *data) +{ + Edje_Box_Layout *l = (Edje_Box_Layout *)node; + + if (l->data && l->free_data) + l->free_data(l->data); + free(l); +} + +static Edje_Box_Layout * +_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) +{ + Edje_Box_Layout *l; + size_t name_len; + + name_len = strlen(name) + 1; + l = malloc(sizeof(Edje_Box_Layout) + name_len); + if (!l) + { + perror("malloc"); + return NULL; + } + + l->func = func; + l->layout_data_get = layout_data_get; + l->layout_data_free = layout_data_free; + l->free_data = free_data; + l->data = data; + + memcpy(l->name, name, name_len); + + return l; +} + +EAPI 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) +{ + Edje_Box_Layout *l; + + if (!name) return; + + if (_edje_box_layout_builtin_find(name)) + { + ERR("Cannot register layout '%s': would override builtin!", + name); + + if (data && free_data) free_data(data); + return; + } + + l = _edje_box_layout_external_find(name); + if (!l) + { + if (!func) + { + if (data && free_data) free_data(data); + return; + } + + l = _edje_box_layout_external_new + (name, func, layout_data_get, layout_data_free, free_data, data); + if (!l) + return; + + _edje_box_layout_registry = eina_rbtree_inline_insert + (_edje_box_layout_registry, (Eina_Rbtree *)l, + _edje_box_layout_external_node_cmp, NULL); + } + else + { + if (func) + { + if (l->data && l->free_data) l->free_data(l->data); + + l->func = func; + l->layout_data_get = layout_data_get; + l->layout_data_free = layout_data_free; + l->free_data = free_data; + l->data = data; + } + else + { + if (data && free_data) free_data(data); + + _edje_box_layout_registry = eina_rbtree_inline_remove + (_edje_box_layout_registry, (Eina_Rbtree *)l, + _edje_box_layout_external_node_cmp, NULL); + _edje_box_layout_external_free((Eina_Rbtree *)l, NULL); + } + } +} + +EAPI void +edje_object_part_unswallow(Evas_Object *obj __UNUSED__, Evas_Object *obj_swallow) +{ + Edje_Real_Part *rp; + + if (!obj_swallow) return; + + rp = (Edje_Real_Part *)evas_object_data_get(obj_swallow, "\377 edje.swallowing_part"); + if (!rp) + return; + if (rp->part->type != EDJE_PART_TYPE_SWALLOW) + { + ERR("cannot unswallow part %s: not swallow type!", rp->part->name); + return; + } + if (rp->swallowed_object == obj_swallow) + { + evas_object_smart_member_del(rp->swallowed_object); + evas_object_event_callback_del_full(rp->swallowed_object, + EVAS_CALLBACK_FREE, + _edje_object_part_swallow_free_cb, + rp->edje->obj); + evas_object_event_callback_del_full(rp->swallowed_object, + EVAS_CALLBACK_CHANGED_SIZE_HINTS, + _edje_object_part_swallow_changed_hints_cb, + rp); + evas_object_clip_unset(rp->swallowed_object); + evas_object_data_del(rp->swallowed_object, "\377 edje.swallowing_part"); + + if (rp->part->mouse_events) + _edje_callbacks_del(rp->swallowed_object, rp->edje); + _edje_callbacks_focus_del(rp->swallowed_object, rp->edje); + + rp->swallowed_object = NULL; + rp->swallow_params.min.w = 0; + rp->swallow_params.min.h = 0; + rp->swallow_params.max.w = 0; + rp->swallow_params.max.h = 0; + rp->edje->dirty = 1; +#ifdef EDJE_CALC_CACHE + rp->invalidate = 1; +#endif + _edje_recalc_do(rp->edje); + return; + } +} + +EAPI Evas_Object * +edje_object_part_swallow_get(const Evas_Object *obj, const char *part) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return NULL; + + /* Need to recalc before providing the object. */ + _edje_recalc_do(ed); + + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp) return NULL; + return rp->swallowed_object; +} + +EAPI void +edje_object_size_min_get(const Evas_Object *obj, Evas_Coord *minw, Evas_Coord *minh) +{ + Edje *ed; + + ed = _edje_fetch(obj); + if ((!ed) || (!ed->collection)) + { + if (minw) *minw = 0; + if (minh) *minh = 0; + return; + } + if (minw) *minw = ed->collection->prop.min.w; + if (minh) *minh = ed->collection->prop.min.h; +} + +EAPI void +edje_object_size_max_get(const Evas_Object *obj, Evas_Coord *maxw, Evas_Coord *maxh) +{ + Edje *ed; + + ed = _edje_fetch(obj); + if ((!ed) || (!ed->collection)) + { + if (maxw) *maxw = 0; + if (maxh) *maxh = 0; + return; + } + + /* Need to recalc before providing the object. */ + _edje_recalc_do(ed); + + if (ed->collection->prop.max.w == 0) + { + /* XXX TODO: convert maxw to 0, fix things that break. */ + if (maxw) *maxw = EDJE_INF_MAX_W; + } + else + { + if (maxw) *maxw = ed->collection->prop.max.w; + } + if (ed->collection->prop.max.h == 0) + { + /* XXX TODO: convert maxh to 0, fix things that break. */ + if (maxh) *maxh = EDJE_INF_MAX_H; + } + else + { + if (maxh) *maxh = ed->collection->prop.max.h; + } +} + +EAPI void +edje_object_calc_force(Evas_Object *obj) +{ + Edje *ed; + int pf, pf2; + + ed = _edje_fetch(obj); + if (!ed) return; + ed->dirty = 1; +#ifdef EDJE_CALC_CACHE + ed->all_part_change = 1; +#endif + + pf2 = _edje_freeze_val; + pf = ed->freeze; + + _edje_freeze_val = 0; + ed->freeze = 0; + + _edje_recalc_do(ed); + + ed->freeze = pf; + _edje_freeze_val = pf2; +} + +EAPI void +edje_object_size_min_calc(Evas_Object *obj, Evas_Coord *minw, Evas_Coord *minh) +{ + edje_object_size_min_restricted_calc(obj, minw, minh, 0, 0); +} + +EAPI Eina_Bool +edje_object_parts_extends_calc(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h) +{ + Edje *ed; + Evas_Coord x1 = INT_MAX, y1 = INT_MAX; + Evas_Coord x2 = 0, y2 = 0; + unsigned int i; + + ed = _edje_fetch(obj); + if (!ed) + { + if (x) *x = 0; + if (y) *y = 0; + if (w) *w = 0; + if (h) *h = 0; + return EINA_FALSE; + } + + ed->calc_only = 1; + + /* Need to recalc before providing the object. */ + ed->dirty = 1; + _edje_recalc_do(ed); + + for (i = 0; i < ed->table_parts_size; i++) + { + Edje_Real_Part *rp; + Evas_Coord rpx1, rpy1; + Evas_Coord rpx2, rpy2; + + rp = ed->table_parts[i]; + + rpx1 = rp->x; + rpy1 = rp->y; + rpx2 = rpx1 + rp->w; + rpy2 = rpy1 + rp->h; + + if (x1 > rpx1) x1 = rpx1; + if (y1 > rpy1) y1 = rpy1; + if (x2 < rpx2) x2 = rpx2; + if (y2 < rpy2) y2 = rpy2; + } + + ed->calc_only = 0; + + if (x) *x = x1; + if (y) *y = y1; + if (w) *w = x2 - x1; + if (h) *h = y2 - y1; + + return EINA_TRUE; +} + +EAPI void +edje_object_size_min_restricted_calc(Evas_Object *obj, Evas_Coord *minw, Evas_Coord *minh, Evas_Coord restrictedw, Evas_Coord restrictedh) +{ + Edje *ed; + Evas_Coord pw, ph; + int maxw, maxh; + int okw, okh; + int reset_maxwh; + Edje_Real_Part *pep = NULL; + Eina_Bool has_non_fixed_tb = EINA_FALSE; + + ed = _edje_fetch(obj); + if ((!ed) || (!ed->collection)) + { + if (minw) *minw = restrictedw; + if (minh) *minh = restrictedh; + return; + } + reset_maxwh = 1; + ed->calc_only = 1; + pw = ed->w; + ph = ed->h; + + again: + ed->w = restrictedw; + ed->h = restrictedh; + + maxw = 0; + maxh = 0; + + do + { + unsigned int i; + + okw = okh = 0; + ed->dirty = 1; +#ifdef EDJE_CALC_CACHE + ed->all_part_change = 1; +#endif + _edje_recalc_do(ed); + if (reset_maxwh) + { + maxw = 0; + maxh = 0; + } + pep = NULL; + for (i = 0; i < ed->table_parts_size; i++) + { + Edje_Real_Part *ep; + int w, h; + int didw; + + ep = ed->table_parts[i]; + w = ep->w - ep->req.w; + h = ep->h - ep->req.h; + didw = 0; + if (ep->chosen_description) + { + if (!ep->chosen_description->fixed.w) + { + if ((ep->part->type == EDJE_PART_TYPE_TEXTBLOCK)) + { + Evas_Coord tb_mw; + evas_object_textblock_size_formatted_get(ep->object, + &tb_mw, NULL); + tb_mw -= ep->req.w; + if (tb_mw > w) + { + w = tb_mw; + } + has_non_fixed_tb = EINA_TRUE; + } + if (w > maxw) + { + maxw = w; + okw = 1; + pep = ep; + didw = 1; + } + } + if (!ep->chosen_description->fixed.h) + { + if (!((ep->part->type == EDJE_PART_TYPE_TEXTBLOCK) && + (!((Edje_Part_Description_Text *)ep->chosen_description)->text.min_x) && + (didw))) + { + if (h > maxh) + { + maxh = h; + okh = 1; + pep = ep; + } + } + + if (ep->part->type == EDJE_PART_TYPE_TEXTBLOCK) + { + has_non_fixed_tb = EINA_TRUE; + } + } + } + } + if (okw) + { + ed->w += maxw; + if (ed->w < restrictedw) ed->w = restrictedw; + } + if (okh) + { + ed->h += maxh; + if (ed->h < restrictedh) ed->h = restrictedh; + } + if ((ed->w > 4000) || (ed->h > 4000)) + { + /* Only print it if we have a non-fixed textblock. + * We should possibly avoid all of this if in this case, but in + * the meanwhile, just doing this. */ + if (!has_non_fixed_tb) + { + if (pep) + ERR("file %s, group %s has a non-fixed part '%s'. Adding 'fixed: 1 1;' to source EDC may help. Continuing discarding faulty part.", + ed->path, ed->group, pep->part->name); + else + ERR("file %s, group %s overflowed 4000x4000 with minimum size of %dx%d. Continuing discarding faulty parts.", + ed->path, ed->group, ed->w, ed->h); + } + + if (reset_maxwh) + { + reset_maxwh = 0; + goto again; + } + } + } + while (okw || okh); + ed->min.w = ed->w; + ed->min.h = ed->h; + + if (minw) *minw = ed->min.w; + if (minh) *minh = ed->min.h; + + ed->w = pw; + ed->h = ph; + ed->dirty = 1; +#ifdef EDJE_CALC_CACHE + ed->all_part_change = 1; +#endif + _edje_recalc(ed); + ed->calc_only = 0; +} + +/* FIXME: Correctly return other states */ +EAPI const char * +edje_object_part_state_get(const Evas_Object *obj, const char *part, double *val_ret) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) + { + if (val_ret) *val_ret = 0; + return ""; + } + + /* Need to recalc before providing the object. */ + _edje_recalc_do(ed); + + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp) + { + if (val_ret) *val_ret = 0; + INF("part not found"); + return ""; + } + if (rp->chosen_description) + { + if (val_ret) *val_ret = rp->chosen_description->state.value; + if (rp->chosen_description->state.name) + return rp->chosen_description->state.name; + return "default"; + } + else + { + if (rp->param1.description) + { + if (val_ret) *val_ret = rp->param1.description->state.value; + if (rp->param1.description->state.name) + return rp->param1.description->state.name; + return "default"; + } + } + if (val_ret) *val_ret = 0; + return ""; +} + +EAPI Edje_Drag_Dir +edje_object_part_drag_dir_get(const Evas_Object *obj, const char *part) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return EDJE_DRAG_DIR_NONE; + + /* Need to recalc before providing the object. */ + _edje_recalc_do(ed); + + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp) return EDJE_DRAG_DIR_NONE; + if ((rp->part->dragable.x) && (rp->part->dragable.y)) return EDJE_DRAG_DIR_XY; + else if (rp->part->dragable.x) return EDJE_DRAG_DIR_X; + else if (rp->part->dragable.y) return EDJE_DRAG_DIR_Y; + return EDJE_DRAG_DIR_NONE; +} + +EAPI Eina_Bool +edje_object_part_drag_value_set(Evas_Object *obj, const char *part, double dx, double dy) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return EINA_FALSE; + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp) return EINA_FALSE; + if (!rp->drag) return EINA_FALSE; + if (rp->drag->down.count > 0) return EINA_FALSE; + if (rp->part->dragable.confine_id != -1) + { + dx = CLAMP(dx, 0.0, 1.0); + dy = CLAMP(dy, 0.0, 1.0); + } + if (rp->part->dragable.x < 0) dx = 1.0 - dx; + if (rp->part->dragable.y < 0) dy = 1.0 - dy; + if ((rp->drag->val.x == FROM_DOUBLE(dx)) && (rp->drag->val.y == FROM_DOUBLE(dy))) return EINA_TRUE; + rp->drag->val.x = FROM_DOUBLE(dx); + rp->drag->val.y = FROM_DOUBLE(dy); +#ifdef EDJE_CALC_CACHE + rp->invalidate = 1; +#endif + _edje_dragable_pos_set(rp->edje, rp, rp->drag->val.x, rp->drag->val.y); + _edje_emit(rp->edje, "drag,set", rp->part->name); + return EINA_TRUE; +} + +/* FIXME: Should this be x and y instead of dx/dy? */ +EAPI Eina_Bool +edje_object_part_drag_value_get(const Evas_Object *obj, const char *part, double *dx, double *dy) +{ + Edje *ed; + Edje_Real_Part *rp; + double ddx, ddy; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) + { + if (dx) *dx = 0; + if (dy) *dy = 0; + return EINA_FALSE; + } + + /* Need to recalc before providing the object. */ + _edje_recalc_do(ed); + + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp || !rp->drag) + { + if (dx) *dx = 0; + if (dy) *dy = 0; + return EINA_FALSE; + } + ddx = TO_DOUBLE(rp->drag->val.x); + ddy = TO_DOUBLE(rp->drag->val.y); + if (rp->part->dragable.x < 0) ddx = 1.0 - ddx; + if (rp->part->dragable.y < 0) ddy = 1.0 - ddy; + if (dx) *dx = ddx; + if (dy) *dy = ddy; + return EINA_TRUE; +} + +EAPI Eina_Bool +edje_object_part_drag_size_set(Evas_Object *obj, const char *part, double dw, double dh) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return EINA_FALSE; + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp) return EINA_FALSE; + if (!rp->drag) return EINA_FALSE; + if (dw < 0.0) dw = 0.0; + else if (dw > 1.0) dw = 1.0; + if (dh < 0.0) dh = 0.0; + else if (dh > 1.0) dh = 1.0; + if ((rp->drag->size.x == FROM_DOUBLE(dw)) && (rp->drag->size.y == FROM_DOUBLE(dh))) return EINA_TRUE; + rp->drag->size.x = FROM_DOUBLE(dw); + rp->drag->size.y = FROM_DOUBLE(dh); + rp->edje->dirty = 1; +#ifdef EDJE_CALC_CACHE + rp->invalidate = 1; +#endif + _edje_recalc(rp->edje); + return EINA_TRUE; +} + +EAPI Eina_Bool +edje_object_part_drag_size_get(const Evas_Object *obj, const char *part, double *dw, double *dh) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) + { + if (dw) *dw = 0; + if (dh) *dh = 0; + return EINA_FALSE; + } + + /* Need to recalc before providing the object. */ + _edje_recalc_do(ed); + + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp || !rp->drag) + { + if (dw) *dw = 0; + if (dh) *dh = 0; + return EINA_FALSE; + } + if (dw) *dw = TO_DOUBLE(rp->drag->size.x); + if (dh) *dh = TO_DOUBLE(rp->drag->size.y); + return EINA_TRUE; +} + +EAPI Eina_Bool +edje_object_part_drag_step_set(Evas_Object *obj, const char *part, double dx, double dy) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return EINA_FALSE; + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp) return EINA_FALSE; + if (!rp->drag) return EINA_FALSE; + if (dx < 0.0) dx = 0.0; + else if (dx > 1.0) dx = 1.0; + if (dy < 0.0) dy = 0.0; + else if (dy > 1.0) dy = 1.0; + rp->drag->step.x = FROM_DOUBLE(dx); + rp->drag->step.y = FROM_DOUBLE(dy); +#ifdef EDJE_CALC_CACHE + rp->invalidate = 1; +#endif + return EINA_TRUE; +} + +EAPI Eina_Bool +edje_object_part_drag_step_get(const Evas_Object *obj, const char *part, double *dx, double *dy) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) + { + if (dx) *dx = 0; + if (dy) *dy = 0; + return EINA_FALSE; + } + + /* Need to recalc before providing the object. */ + _edje_recalc_do(ed); + + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp || !rp->drag) + { + if (dx) *dx = 0; + if (dy) *dy = 0; + return EINA_FALSE; + } + if (dx) *dx = TO_DOUBLE(rp->drag->step.x); + if (dy) *dy = TO_DOUBLE(rp->drag->step.y); + return EINA_TRUE; +} + +EAPI Eina_Bool +edje_object_part_drag_page_set(Evas_Object *obj, const char *part, double dx, double dy) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return EINA_FALSE; + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp) return EINA_FALSE; + if (!rp->drag) return EINA_FALSE; + if (dx < 0.0) dx = 0.0; + else if (dx > 1.0) dx = 1.0; + if (dy < 0.0) dy = 0.0; + else if (dy > 1.0) dy = 1.0; + rp->drag->page.x = FROM_DOUBLE(dx); + rp->drag->page.y = FROM_DOUBLE(dy); +#ifdef EDJE_CALC_CACHE + rp->invalidate = 1; +#endif + return EINA_TRUE; +} + +EAPI Eina_Bool +edje_object_part_drag_page_get(const Evas_Object *obj, const char *part, double *dx, double *dy) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) + { + if (dx) *dx = 0; + if (dy) *dy = 0; + return EINA_FALSE; + } + + /* Need to recalc before providing the object. */ + _edje_recalc_do(ed); + + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp || !rp->drag) + { + if (dx) *dx = 0; + if (dy) *dy = 0; + return EINA_FALSE; + } + if (dx) *dx = TO_DOUBLE(rp->drag->page.x); + if (dy) *dy = TO_DOUBLE(rp->drag->page.y); + return EINA_TRUE; +} + +EAPI Eina_Bool +edje_object_part_drag_step(Evas_Object *obj, const char *part, double dx, double dy) +{ + Edje *ed; + Edje_Real_Part *rp; + FLOAT_T px, py; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return EINA_FALSE; + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp) return EINA_FALSE; + if (!rp->drag) return EINA_FALSE; + if (rp->drag->down.count > 0) return EINA_FALSE; + px = rp->drag->val.x; + py = rp->drag->val.y; + rp->drag->val.x = ADD(px, MUL(FROM_DOUBLE(dx), + MUL(rp->drag->step.x, rp->part->dragable.x))); + rp->drag->val.y = ADD(py, MUL(FROM_DOUBLE(dy), + MUL(rp->drag->step.y, rp->part->dragable.y))); + rp->drag->val.x = CLAMP (rp->drag->val.x, ZERO, FROM_DOUBLE(1.0)); + rp->drag->val.y = CLAMP (rp->drag->val.y, ZERO, FROM_DOUBLE(1.0)); + if ((px == rp->drag->val.x) && (py == rp->drag->val.y)) return EINA_TRUE; +#ifdef EDJE_CALC_CACHE + rp->invalidate = 1; +#endif + _edje_dragable_pos_set(rp->edje, rp, rp->drag->val.x, rp->drag->val.y); + _edje_emit(rp->edje, "drag,step", rp->part->name); + return EINA_TRUE; +} + +EAPI Eina_Bool +edje_object_part_drag_page(Evas_Object *obj, const char *part, double dx, double dy) +{ + Edje *ed; + Edje_Real_Part *rp; + FLOAT_T px, py; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return EINA_FALSE; + rp = _edje_real_part_recursive_get(ed, (char *)part); + if (!rp) return EINA_FALSE; + if (!rp->drag) return EINA_FALSE; + if (rp->drag->down.count > 0) return EINA_FALSE; + px = rp->drag->val.x; + py = rp->drag->val.y; + rp->drag->val.x = ADD(px, MUL(FROM_DOUBLE(dx), MUL(rp->drag->page.x, rp->part->dragable.x))); + rp->drag->val.y = ADD(py, MUL(FROM_DOUBLE(dy), MUL(rp->drag->page.y, rp->part->dragable.y))); + rp->drag->val.x = CLAMP (rp->drag->val.x, ZERO, FROM_DOUBLE(1.0)); + rp->drag->val.y = CLAMP (rp->drag->val.y, ZERO, FROM_DOUBLE(1.0)); + if ((px == rp->drag->val.x) && (py == rp->drag->val.y)) return EINA_TRUE; +#ifdef EDJE_CALC_CACHE + rp->invalidate = 1; +#endif + _edje_dragable_pos_set(rp->edje, rp, rp->drag->val.x, rp->drag->val.y); + _edje_emit(rp->edje, "drag,page", rp->part->name); + return EINA_TRUE; +} + +void +_edje_box_init(void) +{ + +} + +void +_edje_box_shutdown(void) +{ + if (!_edje_box_layout_registry) + return; + + eina_rbtree_delete + (_edje_box_layout_registry, _edje_box_layout_external_free, NULL); + _edje_box_layout_registry = NULL; +} + +EAPI Eina_Bool +edje_object_part_box_append(Evas_Object *obj, const char *part, Evas_Object *child) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part) || (!child)) return EINA_FALSE; + + rp = _edje_real_part_recursive_get(ed, part); + if (!rp) return EINA_FALSE; + if (rp->part->type != EDJE_PART_TYPE_BOX) return EINA_FALSE; + + return _edje_real_part_box_append(rp, child); +} + +EAPI Eina_Bool +edje_object_part_box_prepend(Evas_Object *obj, const char *part, Evas_Object *child) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return EINA_FALSE; + + rp = _edje_real_part_recursive_get(ed, part); + if (!rp) return EINA_FALSE; + if (rp->part->type != EDJE_PART_TYPE_BOX) return EINA_FALSE; + + return _edje_real_part_box_prepend(rp, child); +} + +EAPI Eina_Bool +edje_object_part_box_insert_before(Evas_Object *obj, const char *part, Evas_Object *child, const Evas_Object *reference) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return EINA_FALSE; + + rp = _edje_real_part_recursive_get(ed, part); + if (!rp) return EINA_FALSE; + if (rp->part->type != EDJE_PART_TYPE_BOX) return EINA_FALSE; + + return _edje_real_part_box_insert_before(rp, child, reference); +} + +EAPI Eina_Bool +edje_object_part_box_insert_at(Evas_Object *obj, const char *part, Evas_Object *child, unsigned int pos) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return EINA_FALSE; + + rp = _edje_real_part_recursive_get(ed, part); + if (!rp) return EINA_FALSE; + if (rp->part->type != EDJE_PART_TYPE_BOX) return EINA_FALSE; + + return _edje_real_part_box_insert_at(rp, child, pos); +} + +EAPI Evas_Object * +edje_object_part_box_remove(Evas_Object *obj, const char *part, Evas_Object *child) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return NULL; + + rp = _edje_real_part_recursive_get(ed, part); + if (!rp) return NULL; + if (rp->part->type != EDJE_PART_TYPE_BOX) return NULL; + + return _edje_real_part_box_remove(rp, child); +} + +EAPI Evas_Object * +edje_object_part_box_remove_at(Evas_Object *obj, const char *part, unsigned int pos) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return NULL; + + rp = _edje_real_part_recursive_get(ed, part); + if (!rp) return NULL; + if (rp->part->type != EDJE_PART_TYPE_BOX) return NULL; + + return _edje_real_part_box_remove_at(rp, pos); +} + +EAPI Eina_Bool +edje_object_part_box_remove_all(Evas_Object *obj, const char *part, Eina_Bool clear) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return EINA_FALSE; + + rp = _edje_real_part_recursive_get(ed, part); + if (!rp) return EINA_FALSE; + if (rp->part->type != EDJE_PART_TYPE_BOX) return EINA_FALSE; + + return _edje_real_part_box_remove_all(rp, clear); + +} + +static void +_edje_box_child_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *child __UNUSED__, void *einfo __UNUSED__) +{ + Edje_Real_Part *rp = data; + + rp->edje->dirty = 1; +#ifdef EDJE_CALC_CACHE + rp->invalidate = 1; +#endif + _edje_recalc(rp->edje); +} + +static void +_edje_box_child_add(Edje_Real_Part *rp, Evas_Object *child) +{ + evas_object_event_callback_add + (child, EVAS_CALLBACK_DEL, _edje_box_child_del_cb, rp); + + rp->edje->dirty = 1; +#ifdef EDJE_CALC_CACHE + rp->invalidate = 1; +#endif + _edje_recalc(rp->edje); +} + +static void +_edje_box_child_remove(Edje_Real_Part *rp, Evas_Object *child) +{ + evas_object_event_callback_del_full + (child, EVAS_CALLBACK_DEL, _edje_box_child_del_cb, rp); + + rp->edje->dirty = 1; +#ifdef EDJE_CALC_CACHE + rp->invalidate = 1; +#endif + _edje_recalc(rp->edje); +} + +Eina_Bool +_edje_real_part_box_append(Edje_Real_Part *rp, Evas_Object *child_obj) +{ + Evas_Object_Box_Option *opt; + + opt = evas_object_box_append(rp->object, child_obj); + if (!opt) return EINA_FALSE; + + if (!_edje_box_layout_add_child(rp, child_obj)) + { + evas_object_box_remove(rp->object, child_obj); + return EINA_FALSE; + } + + _edje_box_child_add(rp, child_obj); + + return EINA_TRUE; +} + +Eina_Bool +_edje_real_part_box_prepend(Edje_Real_Part *rp, Evas_Object *child_obj) +{ + Evas_Object_Box_Option *opt; + + opt = evas_object_box_prepend(rp->object, child_obj); + if (!opt) return EINA_FALSE; + + if (!_edje_box_layout_add_child(rp, child_obj)) + { + evas_object_box_remove(rp->object, child_obj); + return EINA_FALSE; + } + + _edje_box_child_add(rp, child_obj); + + return EINA_TRUE; +} + +Eina_Bool +_edje_real_part_box_insert_before(Edje_Real_Part *rp, Evas_Object *child_obj, const Evas_Object *ref) +{ + Evas_Object_Box_Option *opt; + + opt = evas_object_box_insert_before(rp->object, child_obj, ref); + if (!opt) return EINA_FALSE; + + if (!_edje_box_layout_add_child(rp, child_obj)) + { + evas_object_box_remove(rp->object, child_obj); + return EINA_FALSE; + } + + _edje_box_child_add(rp, child_obj); + + return EINA_TRUE; +} + +Eina_Bool +_edje_real_part_box_insert_at(Edje_Real_Part *rp, Evas_Object *child_obj, unsigned int pos) +{ + Evas_Object_Box_Option *opt; + + opt = evas_object_box_insert_at(rp->object, child_obj, pos); + if (!opt) return EINA_FALSE; + + if (!_edje_box_layout_add_child(rp, child_obj)) + { + evas_object_box_remove(rp->object, child_obj); + return EINA_FALSE; + } + + _edje_box_child_add(rp, child_obj); + + return EINA_TRUE; +} + +Evas_Object * +_edje_real_part_box_remove(Edje_Real_Part *rp, Evas_Object *child_obj) +{ + if (evas_object_data_get(child_obj, "\377 edje.box_item")) return NULL; + if (!evas_object_box_remove(rp->object, child_obj)) return NULL; + _edje_box_layout_remove_child(rp, child_obj); + _edje_box_child_remove(rp, child_obj); + return child_obj; +} + +Evas_Object * +_edje_real_part_box_remove_at(Edje_Real_Part *rp, unsigned int pos) +{ + Evas_Object_Box_Option *opt; + Evas_Object_Box_Data *priv; + Evas_Object *child_obj; + + priv = evas_object_smart_data_get(rp->object); + opt = eina_list_nth(priv->children, pos); + if (!opt) return NULL; + child_obj = opt->obj; + if (evas_object_data_get(child_obj, "\377 edje.box_item")) return NULL; + if (!evas_object_box_remove_at(rp->object, pos)) return NULL; + _edje_box_layout_remove_child(rp, child_obj); + _edje_box_child_remove(rp, child_obj); + return child_obj; +} + +Eina_Bool +_edje_real_part_box_remove_all(Edje_Real_Part *rp, Eina_Bool clear) +{ + Eina_List *children; + int i = 0; + + children = evas_object_box_children_get(rp->object); + while (children) + { + Evas_Object *child_obj = children->data; + if (evas_object_data_get(child_obj, "\377 edje.box_item")) + i++; + else + { + _edje_box_layout_remove_child(rp, child_obj); + _edje_box_child_remove(rp, child_obj); + if (!evas_object_box_remove_at(rp->object, i)) + return EINA_FALSE; + if (clear) + evas_object_del(child_obj); + } + children = eina_list_remove_list(children, children); + } + return EINA_TRUE; +} + +static void +_edje_table_child_del_cb(void *data, Evas *e __UNUSED__, Evas_Object *child __UNUSED__, void *einfo __UNUSED__) +{ + Edje_Real_Part *rp = data; + + rp->edje->dirty = 1; +#ifdef EDJE_CALC_CACHE + rp->invalidate = 1; +#endif + _edje_recalc(rp->edje); +} + +static void +_edje_table_child_add(Edje_Real_Part *rp, Evas_Object *child) +{ + evas_object_event_callback_add + (child, EVAS_CALLBACK_DEL, _edje_table_child_del_cb, rp); + + rp->edje->dirty = 1; +#ifdef EDJE_CALC_CACHE + rp->invalidate = 1; +#endif + _edje_recalc(rp->edje); +} + +static void +_edje_table_child_remove(Edje_Real_Part *rp, Evas_Object *child) +{ + evas_object_event_callback_del_full + (child, EVAS_CALLBACK_DEL, _edje_table_child_del_cb, rp); + + rp->edje->dirty = 1; +#ifdef EDJE_CALC_CACHE + rp->invalidate = 1; +#endif + _edje_recalc(rp->edje); +} + +EAPI Evas_Object * +edje_object_part_table_child_get(Evas_Object *obj, const char *part, unsigned int col, unsigned int row) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return NULL; + + rp = _edje_real_part_recursive_get(ed, part); + if (!rp) return NULL; + if (rp->part->type != EDJE_PART_TYPE_TABLE) return NULL; + + return evas_object_table_child_get(rp->object, col, row); +} + +EAPI 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) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return EINA_FALSE; + + rp = _edje_real_part_recursive_get(ed, part); + if (!rp) return EINA_FALSE; + if (rp->part->type != EDJE_PART_TYPE_TABLE) return EINA_FALSE; + + return _edje_real_part_table_pack(rp, child_obj, col, row, colspan, rowspan); +} + +EAPI Eina_Bool +edje_object_part_table_unpack(Evas_Object *obj, const char *part, Evas_Object *child_obj) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return EINA_FALSE; + + rp = _edje_real_part_recursive_get(ed, part); + if (!rp) return EINA_FALSE; + if (rp->part->type != EDJE_PART_TYPE_TABLE) return EINA_FALSE; + + return _edje_real_part_table_unpack(rp, child_obj); +} + +EAPI Eina_Bool +edje_object_part_table_col_row_size_get(const Evas_Object *obj, const char *part, int *cols, int *rows) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return EINA_FALSE; + + rp = _edje_real_part_recursive_get(ed, part); + if (!rp) return EINA_FALSE; + if (rp->part->type != EDJE_PART_TYPE_TABLE) return EINA_FALSE; + + evas_object_table_col_row_size_get(rp->object, cols, rows); + return EINA_TRUE; +} + +EAPI Eina_Bool +edje_object_part_table_clear(Evas_Object *obj, const char *part, Eina_Bool clear) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return EINA_FALSE; + + rp = _edje_real_part_recursive_get(ed, part); + if (!rp) return EINA_FALSE; + if (rp->part->type != EDJE_PART_TYPE_TABLE) return EINA_FALSE; + + _edje_real_part_table_clear(rp, clear); + return EINA_TRUE; +} + +static void +_edje_perspective_obj_del(void *data, __UNUSED__ Evas *e, __UNUSED__ Evas_Object *obj, __UNUSED__ void *event_info) +{ + Edje_Perspective *ps = data; + Evas_Object *o; + + EINA_LIST_FREE(ps->users, o) + { + Edje *ed; + + ed = evas_object_smart_data_get(o); + if (!ed) continue; + ed->persp = NULL; + ed->dirty = 1; + _edje_recalc_do(ed); + } + free(ps); +} + +EAPI Edje_Perspective * +edje_perspective_new(Evas *e) +{ + Edje_Perspective *ps; + Evas_Coord vx, vy, vw, vh; + + if (!e) return NULL; + ps = calloc(1, sizeof(Edje_Perspective)); + ps->obj = evas_object_rectangle_add(e); + evas_object_data_set(ps->obj, "_edje_perspective", ps); + evas_object_event_callback_add(ps->obj, EVAS_CALLBACK_DEL, _edje_perspective_obj_del, ps); + evas_output_viewport_get(e, &vx, &vy, &vw, &vh); + ps->e = e; + ps->px = vx + (vw / 2); + ps->py = vy + (vh / 2); + ps->z0 = 0; + ps->foc = 1000; + return ps; +} + +EAPI void +edje_perspective_free(Edje_Perspective *ps) +{ + if (!ps) return; + evas_object_del(ps->obj); +} + +EAPI void +edje_perspective_set(Edje_Perspective *ps, Evas_Coord px, Evas_Coord py, Evas_Coord z0, Evas_Coord foc) +{ + Eina_List *l; + Evas_Object *o; + + if (!ps) return; + if ((ps->px == px) && (ps->py == py) && (ps->z0 == z0) && (ps->foc == foc)) return; + ps->px = px; + ps->py = py; + ps->z0 = z0; + ps->foc = foc; + EINA_LIST_FOREACH(ps->users, l, o) + { + Edje *ed; + + ed = evas_object_smart_data_get(o); + if (!ed) continue; + if (!ed->persp) + { + ed->dirty = 1; + _edje_recalc_do(ed); + } + } + if (ps->global) + { + EINA_LIST_FOREACH(_edje_edjes, l, o) + { + Edje *ed; + + ed = evas_object_smart_data_get(o); + if (!ed) continue; + if (!ed->persp) + { + ed->dirty = 1; + _edje_recalc_do(ed); + } + } + } +} + +EAPI void +edje_perspective_global_set(Edje_Perspective *ps, Eina_Bool global) +{ + Evas_Object *o; + Eina_List *l; + + if (!ps) return; + if (ps->global == global) return; + if (global) + { + o = evas_object_name_find(evas_object_evas_get(ps->obj), + "_edje_perspective"); + if (o) evas_object_name_set(o, NULL); + evas_object_name_set(ps->obj, "_edje_perspective"); + } + else + evas_object_name_set(ps->obj, NULL); + ps->global = global; + EINA_LIST_FOREACH(_edje_edjes, l, o) + { + Edje *ed; + + ed = evas_object_smart_data_get(o); + if (!ed) continue; + if (!ed->persp) + { + ed->dirty = 1; + _edje_recalc_do(ed); + } + } +} + +EAPI Eina_Bool +edje_perspective_global_get(const Edje_Perspective *ps) +{ + if (!ps) return EINA_FALSE; + return ps->global; +} + +EAPI const Edje_Perspective * +edje_evas_global_perspective_get(const Evas *e) +{ + Evas_Object *obj; + + if (!e) return NULL; + obj = evas_object_name_find(e, "_edje_perspective"); + if (!obj) return NULL; + return evas_object_data_get(obj, "_edje_perspective"); +} + +EAPI void +edje_object_perspective_set(Evas_Object *obj, Edje_Perspective *ps) +{ + Edje *ed; + + ed = evas_object_smart_data_get(obj); + if (!ed) return; + if (ed->persp == ps) return; + if (ed->persp != ps) + { + if (ed->persp) + ed->persp->users = eina_list_remove(ed->persp->users, obj); + } + ed->persp = ps; + if (ps) ps->users = eina_list_append(ps->users, obj); + ed->dirty = 1; + _edje_recalc_do(ed); +} + +EAPI const Edje_Perspective * +edje_object_perspective_get(const Evas_Object *obj) +{ + Edje *ed; + + ed = evas_object_smart_data_get(obj); + if (!ed) return NULL; + return ed->persp; +} + +#define EDJE_PRELOAD_EMISSION "preload,done" +#define EDJE_PRELOAD_SOURCE NULL + +EAPI Eina_Bool +edje_object_preload(Evas_Object *obj, Eina_Bool cancel) +{ + Edje *ed; + int count; + unsigned int i; + + ed = _edje_fetch(obj); + if (!ed) return EINA_FALSE; + + _edje_recalc_do(ed); + + for (i = 0, count = 0; i < ed->table_parts_size; i++) + { + Edje_Real_Part *rp; + Edje_Part *ep; + + rp = ed->table_parts[i]; + ep = rp->part; + + if (ep->type == EDJE_PART_TYPE_IMAGE || + (ep->type == EDJE_PART_TYPE_GROUP && rp->swallowed_object)) + count++; + } + + ed->preload_count = count; + + if (count > 0) + { + for (i = 0; i < ed->table_parts_size; i++) + { + Edje_Real_Part *rp; + Edje_Part *ep; + + rp = ed->table_parts[i]; + ep = rp->part; + + if (ep->type == EDJE_PART_TYPE_IMAGE) + { + const char *file = NULL; + const char *key = NULL; + + evas_object_event_callback_del_full(rp->object, EVAS_CALLBACK_IMAGE_PRELOADED, _edje_object_image_preload_cb, ed); + + evas_object_image_file_get(rp->object, &file, &key); + if (!file && !key) + { + ed->preload_count--; + } + else + { + evas_object_event_callback_add(rp->object, EVAS_CALLBACK_IMAGE_PRELOADED, _edje_object_image_preload_cb, ed); + evas_object_image_preload(rp->object, cancel); + } + count--; + } + else if (ep->type == EDJE_PART_TYPE_GROUP) + { + if (rp->swallowed_object) { + edje_object_signal_callback_del(rp->swallowed_object, EDJE_PRELOAD_EMISSION, EDJE_PRELOAD_SOURCE, _edje_object_signal_preload_cb); + edje_object_signal_callback_add(rp->swallowed_object, EDJE_PRELOAD_EMISSION, EDJE_PRELOAD_SOURCE, _edje_object_signal_preload_cb, ed); + edje_object_preload(rp->swallowed_object, cancel); + + count--; + } + } + } + } + else + { + _edje_emit(ed, EDJE_PRELOAD_EMISSION, EDJE_PRELOAD_SOURCE); + } + + return EINA_TRUE; +} + +Eina_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) +{ + Eina_Bool ret = + evas_object_table_pack(rp->object, child_obj, col, row, colspan, rowspan); + + _edje_table_child_add(rp, child_obj); + + return ret; +} + +Eina_Bool +_edje_real_part_table_unpack(Edje_Real_Part *rp, Evas_Object *child_obj) +{ + Eina_Bool ret = evas_object_table_unpack(rp->object, child_obj); + + if (ret) + _edje_table_child_remove(rp, child_obj); + + return ret; +} + +void +_edje_real_part_table_clear(Edje_Real_Part *rp, Eina_Bool clear) +{ + Eina_List *children; + + children = evas_object_table_children_get(rp->object); + while (children) + { + Evas_Object *child_obj = children->data; + + _edje_table_child_remove(rp, child_obj); + if (!evas_object_data_get(child_obj, "\377 edje.table_item")) + { + evas_object_table_unpack(rp->object, child_obj); + if (clear) + evas_object_del(child_obj); + } + children = eina_list_remove_list(children, children); + } +} + +Edje_Real_Part * +_edje_real_part_recursive_get(const Edje *ed, const char *part) +{ + Edje_Real_Part *rp; + char **path; + + path = eina_str_split(part, EDJE_PART_PATH_SEPARATOR_STRING, 0); + if (!path) return NULL; + + rp = _edje_real_part_recursive_get_helper(ed, path); + + free(*path); + free(path); + return rp; +} + +Evas_Object * +_edje_children_get(Edje_Real_Part *rp, const char *partid) +{ + Evas_Object *child; + Eina_List *l; + long int v; + char *p; + + if (!partid) return NULL; + + switch (rp->part->type) + { + case EDJE_PART_TYPE_EXTERNAL: + return _edje_external_content_get(rp->swallowed_object, partid); + case EDJE_PART_TYPE_BOX: + l = evas_object_box_children_get(rp->object); + break; + case EDJE_PART_TYPE_TABLE: + l = evas_object_table_children_get(rp->object); + break; + default: + return NULL; + } + + v = strtol(partid, &p, 10); + if ((*p == '\0') && (v >= 0)) + { + child = eina_list_nth(l, v); + } + else + { + Evas_Object *cur; + child = NULL; + EINA_LIST_FREE(l, cur) + { + const char *name = evas_object_name_get(cur); + if ((name) && (!strcmp(name, partid))) + { + child = cur; + break; + } + } + } + eina_list_free(l); + + return child; +} + +/* rebuild alternative path */ +char * +_edje_merge_path(const char *alias, char * const *path) +{ + char *tmp; + unsigned int length = 1; + unsigned int alias_length; + unsigned int i; + + if (!alias) return NULL; + + alias_length = strlen(alias); + + for (i = 0; path[i]; i++) + length += strlen(path[i]) + 1; + + tmp = malloc(sizeof (char) * (length + alias_length + 2)); + memcpy(tmp, alias, alias_length); + tmp[alias_length] = '\0'; + + for (i = 0; path[i]; i++) + { + strcat(tmp, EDJE_PART_PATH_SEPARATOR_STRING); + strcat(tmp, path[i]); + } + + return tmp; +} + + +Edje_Real_Part * +_edje_real_part_recursive_get_helper(const Edje *ed, char **path) +{ + Edje_Real_Part *rp; + Evas_Object *child; + char *idx = NULL; + + if (!path[0]) + return NULL; + + if (ed->collection && ed->collection->alias) + { + char *alias; + + alias = _edje_merge_path(eina_hash_find(ed->collection->alias, path[0]), path + 1); + if (alias) { + rp = _edje_real_part_recursive_get(ed, alias); + free(alias); + return rp; + } + } + + //printf(" lookup: %s on %s\n", path[0], ed->parent ? ed->parent : "-"); + idx = strchr(path[0], EDJE_PART_PATH_SEPARATOR_INDEXL); + if (idx) + { + char *end; + + end = strchr(idx + 1, EDJE_PART_PATH_SEPARATOR_INDEXR); + if (end) + { + *end = '\0'; + *idx = '\0'; + idx++; + } + } + + rp = _edje_real_part_get(ed, path[0]); + if (!path[1] && !idx) return rp; + if (!rp) return NULL; + + switch (rp->part->type) + { + case EDJE_PART_TYPE_GROUP: + if (!rp->swallowed_object) return NULL; + ed = _edje_fetch(rp->swallowed_object); + if (!ed) return NULL; + path++; + return _edje_real_part_recursive_get_helper(ed, path); + case EDJE_PART_TYPE_BOX: + case EDJE_PART_TYPE_TABLE: + case EDJE_PART_TYPE_EXTERNAL: + if (!idx) return rp; + path++; + + child = _edje_children_get(rp, idx); + + ed = _edje_fetch(child); + + if (!ed) return NULL; + return _edje_real_part_recursive_get_helper(ed, path); + default: + return NULL; + } +} + +/* Private Routines */ +Edje_Real_Part * +_edje_real_part_get(const Edje *ed, const char *part) +{ + unsigned int i; + + if (!part) return NULL; + + for (i = 0; i < ed->table_parts_size; i++) + { + Edje_Real_Part *rp; + + rp = ed->table_parts[i]; + if ((rp->part->name) && (!strcmp(rp->part->name, part))) return rp; + } + return NULL; +} + +Edje_Color_Class * +_edje_color_class_find(Edje *ed, const char *color_class) +{ + Eina_List *l; + Edje_Color_Class *cc = NULL; + + if ((!ed) || (!color_class)) return NULL; + + /* first look through the object scope */ + EINA_LIST_FOREACH(ed->color_classes, l, cc) + if ((cc->name) && (!strcmp(color_class, cc->name))) return cc; + + /* next look through the global scope */ + cc = eina_hash_find(_edje_color_class_hash, color_class); + if (cc) return cc; + + /* finally, look through the file scope */ + EINA_LIST_FOREACH(ed->file->color_classes, l, cc) + if ((cc->name) && (!strcmp(color_class, cc->name))) return cc; + + return NULL; +} + +void +_edje_color_class_member_add(Edje *ed, const char *color_class) +{ + _edje_class_member_add(ed, &ed->members.color_class, &_edje_color_class_member_hash, color_class); +} + +void +_edje_color_class_member_direct_del(const char *color_class, void *l) +{ + _edje_class_member_direct_del(color_class, l, _edje_color_class_member_hash); +} + +void +_edje_color_class_member_del(Edje *ed, const char *color_class) +{ + if ((!ed) || (!color_class)) return; + + _edje_class_member_del(&ed->members.color_class, &_edje_color_class_member_hash, color_class); +} + +void +_edje_color_class_members_free(void) +{ + if (!_edje_color_class_member_hash) return; + eina_hash_foreach(_edje_color_class_member_hash, member_list_free, NULL); + eina_hash_free(_edje_color_class_member_hash); + _edje_color_class_member_hash = NULL; +} + +static Eina_Bool +color_class_hash_list_free(const Eina_Hash *hash __UNUSED__, const void *key __UNUSED__, void *data, void *fdata __UNUSED__) +{ + Edje_Color_Class *cc; + + cc = data; + if (cc->name) eina_stringshare_del(cc->name); + free(cc); + return EINA_TRUE; +} + +void +_edje_color_class_hash_free(void) +{ + if (!_edje_color_class_hash) return; + eina_hash_foreach(_edje_color_class_hash, color_class_hash_list_free, NULL); + eina_hash_free(_edje_color_class_hash); + _edje_color_class_hash = NULL; +} + +void +_edje_color_class_on_del(Edje *ed, Edje_Part *ep) +{ + unsigned int i; + + if ((ep->default_desc) && (ep->default_desc->color_class)) + _edje_color_class_member_del(ed, ep->default_desc->color_class); + + for (i = 0; i < ep->other.desc_count; ++i) + if (ep->other.desc[i]->color_class) + _edje_color_class_member_del(ed, ep->other.desc[i]->color_class); +} + +Edje_Text_Class * +_edje_text_class_find(Edje *ed, const char *text_class) +{ + Eina_List *l; + Edje_Text_Class *tc; + + if ((!ed) || (!text_class)) return NULL; + EINA_LIST_FOREACH(ed->text_classes, l, tc) + if ((tc->name) && (!strcmp(text_class, tc->name))) return tc; + return eina_hash_find(_edje_text_class_hash, text_class); +} + +void +_edje_text_class_member_direct_del(const char *text_class, + void *l) +{ + _edje_class_member_direct_del(text_class, l, _edje_text_class_member_hash); +} + +void +_edje_text_class_member_add(Edje *ed, const char *text_class) +{ + _edje_class_member_add(ed, &ed->members.text_class, &_edje_text_class_member_hash, text_class); +} + +void +_edje_text_class_member_del(Edje *ed, const char *text_class) +{ + if ((!ed) || (!text_class)) return; + + _edje_class_member_del(&ed->members.text_class, &_edje_text_class_member_hash, text_class); +} + +void +_edje_text_class_members_free(void) +{ + _edje_class_members_free(&_edje_text_class_member_hash); +} + +static Eina_Bool +text_class_hash_list_free(const Eina_Hash *hash __UNUSED__, const void *key __UNUSED__, void *data, void *fdata __UNUSED__) +{ + Edje_Text_Class *tc; + + tc = data; + if (tc->name) eina_stringshare_del(tc->name); + if (tc->font) eina_stringshare_del(tc->font); + free(tc); + return EINA_TRUE; +} + +void +_edje_text_class_hash_free(void) +{ + if (!_edje_text_class_hash) return; + eina_hash_foreach(_edje_text_class_hash, text_class_hash_list_free, NULL); + eina_hash_free(_edje_text_class_hash); + _edje_text_class_hash = NULL; +} + +Edje * +_edje_fetch(const Evas_Object *obj) +{ + Edje *ed; + + if (!evas_object_smart_type_check(obj, "edje")) + return NULL; + ed = evas_object_smart_data_get(obj); + if ((ed) && (ed->delete_me)) return NULL; + return ed; +} + +int +_edje_freeze(Edje *ed) +{ + ed->freeze++; +// printf("FREEZE %i\n", ed->freeze); + return ed->freeze; +} + +int +_edje_thaw(Edje *ed) +{ + ed->freeze--; + if (ed->freeze < 0) + { +// printf("-------------########### OVER THAW\n"); + ed->freeze = 0; + } + if ((ed->freeze == 0) && (ed->recalc)) + { +// printf("thaw recalc\n"); + _edje_recalc(ed); + } + return ed->freeze; +} + +int +_edje_block(Edje *ed) +{ + _edje_ref(ed); + ed->block++; + return ed->block; +} + +int +_edje_unblock(Edje *ed) +{ + int ret = 0; + + if (!ed) return ret; + + ed->block--; + if (ed->block == 0) ed->block_break = 0; + ret = ed->block; + _edje_unref(ed); + return ret; +} + +int +_edje_block_break(Edje *ed) +{ + if (ed->block_break) return 1; + return 0; +} + +void +_edje_block_violate(Edje *ed) +{ + if (ed->block > 0) ed->block_break = 1; +} + +void +_edje_object_part_swallow_free_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__) +{ + Evas_Object *edje_obj; + + edje_obj = data; + edje_object_part_unswallow(edje_obj, obj); + return; +} + +static void +_edje_real_part_swallow_hints_update(Edje_Real_Part *rp) +{ + const char *type; + + type = evas_object_type_get(rp->swallowed_object); + + rp->swallow_params.min.w = 0; + rp->swallow_params.min.h = 0; + rp->swallow_params.max.w = -1; + rp->swallow_params.max.h = -1; + if ((type) && (!strcmp(type, "edje"))) + { + Evas_Coord w, h; + + edje_object_size_min_get(rp->swallowed_object, &w, &h); + rp->swallow_params.min.w = w; + rp->swallow_params.min.h = h; + edje_object_size_max_get(rp->swallowed_object, &w, &h); + rp->swallow_params.max.w = w; + rp->swallow_params.max.h = h; + } + else if ((type) && ((!strcmp(type, "text")) || (!strcmp(type, "polygon")) || + (!strcmp(type, "line")))) + { + Evas_Coord w, h; + + evas_object_geometry_get(rp->swallowed_object, NULL, NULL, &w, &h); + rp->swallow_params.min.w = w; + rp->swallow_params.min.h = h; + rp->swallow_params.max.w = w; + rp->swallow_params.max.h = h; + } + { + Evas_Coord w1, h1, w2, h2, aw, ah; + Evas_Aspect_Control am; + + evas_object_size_hint_min_get(rp->swallowed_object, &w1, &h1); + evas_object_size_hint_max_get(rp->swallowed_object, &w2, &h2); + evas_object_size_hint_aspect_get(rp->swallowed_object, &am, &aw, &ah); + rp->swallow_params.min.w = w1; + rp->swallow_params.min.h = h1; + if (w2 > 0) rp->swallow_params.max.w = w2; + if (h2 > 0) rp->swallow_params.max.h = h2; + switch (am) + { + case EVAS_ASPECT_CONTROL_NONE: + rp->swallow_params.aspect.mode = EDJE_ASPECT_CONTROL_NONE; + break; + case EVAS_ASPECT_CONTROL_NEITHER: + rp->swallow_params.aspect.mode = EDJE_ASPECT_CONTROL_NEITHER; + break; + case EVAS_ASPECT_CONTROL_HORIZONTAL: + rp->swallow_params.aspect.mode = EDJE_ASPECT_CONTROL_HORIZONTAL; + break; + case EVAS_ASPECT_CONTROL_VERTICAL: + rp->swallow_params.aspect.mode = EDJE_ASPECT_CONTROL_VERTICAL; + break; + case EVAS_ASPECT_CONTROL_BOTH: + rp->swallow_params.aspect.mode = EDJE_ASPECT_CONTROL_BOTH; + break; + default: + break; + } + rp->swallow_params.aspect.w = aw; + rp->swallow_params.aspect.h = ah; + evas_object_data_set(rp->swallowed_object, "\377 edje.swallowing_part", rp); + } + +#ifdef EDJE_CALC_CACHE + rp->invalidate = 1; +#endif +} + +void +_edje_object_part_swallow_changed_hints_cb(void *data, __UNUSED__ Evas *e, __UNUSED__ Evas_Object *obj, __UNUSED__ void *event_info) +{ + Edje_Real_Part *rp; + + rp = data; + _edje_real_part_swallow_hints_update(rp); + rp->edje->dirty = 1; + _edje_recalc(rp->edje); + return; +} + +void +_edje_real_part_swallow(Edje_Real_Part *rp, + Evas_Object *obj_swallow, + Eina_Bool hints_update) +{ + if (rp->swallowed_object) + { + if (rp->swallowed_object != obj_swallow) + { + _edje_real_part_swallow_clear(rp); + rp->swallowed_object = NULL; + } + else + { + if (hints_update) + _edje_real_part_swallow_hints_update(rp); + rp->edje->dirty = 1; + _edje_recalc(rp->edje); + return; + } + } +#ifdef EDJE_CALC_CACHE + rp->invalidate = 1; +#endif + if (!obj_swallow) return; + rp->swallowed_object = obj_swallow; + evas_object_smart_member_add(rp->swallowed_object, rp->edje->obj); + if (rp->clip_to) + evas_object_clip_set(rp->swallowed_object, rp->clip_to->object); + else evas_object_clip_set(rp->swallowed_object, rp->edje->base.clipper); + evas_object_stack_above(rp->swallowed_object, rp->object); + evas_object_event_callback_add(rp->swallowed_object, + EVAS_CALLBACK_DEL, + _edje_object_part_swallow_free_cb, + rp->edje->obj); + evas_object_event_callback_add(rp->swallowed_object, + EVAS_CALLBACK_CHANGED_SIZE_HINTS, + _edje_object_part_swallow_changed_hints_cb, + rp); + + if (hints_update) + _edje_real_part_swallow_hints_update(rp); + + if (rp->part->mouse_events) + { + _edje_callbacks_add(obj_swallow, rp->edje, rp); + if (rp->part->repeat_events) + evas_object_repeat_events_set(obj_swallow, 1); + if (rp->part->pointer_mode != EVAS_OBJECT_POINTER_MODE_AUTOGRAB) + evas_object_pointer_mode_set(obj_swallow, rp->part->pointer_mode); + evas_object_pass_events_set(obj_swallow, 0); + } + else + evas_object_pass_events_set(obj_swallow, 1); + _edje_callbacks_focus_add(rp->swallowed_object, rp->edje, rp); + + if (rp->part->precise_is_inside) + evas_object_precise_is_inside_set(obj_swallow, 1); + + rp->edje->dirty = 1; + _edje_recalc(rp->edje); +} + +void +_edje_real_part_swallow_clear(Edje_Real_Part *rp) +{ + evas_object_smart_member_del(rp->swallowed_object); + evas_object_event_callback_del_full(rp->swallowed_object, + EVAS_CALLBACK_FREE, + _edje_object_part_swallow_free_cb, + rp->edje->obj); + evas_object_event_callback_del_full(rp->swallowed_object, + EVAS_CALLBACK_CHANGED_SIZE_HINTS, + _edje_object_part_swallow_changed_hints_cb, + rp); + evas_object_clip_unset(rp->swallowed_object); + evas_object_data_del(rp->swallowed_object, "\377 edje.swallowing_part"); + if (rp->part->mouse_events) + _edje_callbacks_del(rp->swallowed_object, rp->edje); + _edje_callbacks_focus_del(rp->swallowed_object, rp->edje); +} + +static void +_edje_object_preload(Edje *ed) +{ + ed->preload_count--; + if (!ed->preload_count) + _edje_emit(ed, EDJE_PRELOAD_EMISSION, EDJE_PRELOAD_SOURCE); +} + +static void +_edje_object_image_preload_cb(void *data, __UNUSED__ Evas *e, Evas_Object *obj, __UNUSED__ void *event_info) +{ + Edje *ed = data; + + evas_object_event_callback_del_full(obj, EVAS_CALLBACK_IMAGE_PRELOADED, _edje_object_image_preload_cb, ed); + _edje_object_preload(ed); +} + +static void +_edje_object_signal_preload_cb(void *data, Evas_Object *obj, __UNUSED__ const char *emission, __UNUSED__ const char *source) +{ + Edje *ed = data; + + edje_object_signal_callback_del(obj, EDJE_PRELOAD_EMISSION, EDJE_PRELOAD_SOURCE, _edje_object_signal_preload_cb); + _edje_object_preload(ed); +} + +/** + * @internal + * + * for edje_cc + */ +EAPI void +_edje_program_remove(Edje_Part_Collection *edc, Edje_Program *p) +{ + Edje_Program ***array; + unsigned int *count; + unsigned int i; + + if (!p->signal && !p->source) + { + array = &edc->programs.nocmp; + count = &edc->programs.nocmp_count; + } + else if (p->signal && !strpbrk(p->signal, "*?[\\") + && p->source && !strpbrk(p->source, "*?[\\")) + { + array = &edc->programs.strcmp; + count = &edc->programs.strcmp_count; + } + else if (p->signal && edje_program_is_strncmp(p->signal) + && p->source && edje_program_is_strncmp(p->source)) + { + array = &edc->programs.strncmp; + count = &edc->programs.strncmp_count; + } + else if (p->signal && edje_program_is_strrncmp(p->signal) + && p->source && edje_program_is_strrncmp(p->source)) + { + array = &edc->programs.strrncmp; + count = &edc->programs.strrncmp_count; + } + else + { + array = &edc->programs.fnmatch; + count = &edc->programs.fnmatch_count; + } + + for (i = 0; i < *count; ++i) + if ((*array)[i] == p) + { + memmove(*array + i, *array + i + 1, sizeof (Edje_Program *) * (*count - i -1)); + (*count)--; + break; + } +} + +/** + * @internal + * + * for edje_cc + */ +EAPI void +_edje_program_insert(Edje_Part_Collection *edc, Edje_Program *p) +{ + Edje_Program ***array; + unsigned int *count; + + if (!p->signal && !p->source) + { + array = &edc->programs.nocmp; + count = &edc->programs.nocmp_count; + } + else if (p->signal && !strpbrk(p->signal, "*?[\\") + && p->source && !strpbrk(p->source, "*?[\\")) + { + array = &edc->programs.strcmp; + count = &edc->programs.strcmp_count; + } + else if (p->signal && edje_program_is_strncmp(p->signal) + && p->source && edje_program_is_strncmp(p->source)) + { + array = &edc->programs.strncmp; + count = &edc->programs.strncmp_count; + } + else if (p->signal && edje_program_is_strrncmp(p->signal) + && p->source && edje_program_is_strrncmp(p->source)) + { + array = &edc->programs.strrncmp; + count = &edc->programs.strrncmp_count; + } + else + { + array = &edc->programs.fnmatch; + count = &edc->programs.fnmatch_count; + } + + *array = realloc(*array, sizeof (Edje_Program *) * (*count + 1)); + (*array)[(*count)++] = p; +} + +const char * +edje_string_get(const Edje_String *es) +{ + /* FIXME: Handle localization here */ + if (!es) return NULL; + return es->str; +} + +const char * +edje_string_id_get(const Edje_String *es) +{ + /* FIXME: Handle localization here */ + if (!es) return NULL; + return es->str; +} + +static void +_cb_subobj_del(void *data, __UNUSED__ Evas *e, Evas_Object *obj, __UNUSED__ void *event_info) +{ + Edje *ed = data; + ed->subobjs = eina_list_remove(ed->subobjs, obj); + evas_object_event_callback_del_full(obj, EVAS_CALLBACK_DEL, + _cb_subobj_del, ed); +} + +void +_edje_subobj_register(Edje *ed, Evas_Object *ob) +{ + ed->subobjs = eina_list_append(ed->subobjs, ob); + evas_object_event_callback_add(ob, EVAS_CALLBACK_DEL, + _cb_subobj_del, ed); +} + +/* 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 @@ +#include "edje_private.h" + +static Eina_Bool _edje_var_timer_cb(void *data); +static Eina_Bool _edje_var_anim_cb(void *data); + +static Ecore_Animator *_edje_animator = NULL; +static Eina_List *_edje_anim_list = NULL; + +static Eina_Bool +_edje_var_timer_cb(void *data) +{ + Edje_Var_Timer *et; + Edje *ed; + Embryo_Function fn; + + et = data; + if (!et) return ECORE_CALLBACK_CANCEL; + ed = et->edje; +// _edje_embryo_script_reset(ed); + embryo_program_vm_push(ed->collection->script); + _edje_embryo_globals_init(ed); + embryo_parameter_cell_push(ed->collection->script, (Embryo_Cell)et->val); + ed->var_pool->timers = eina_list_remove(ed->var_pool->timers, et); + fn = et->func; + free(et); + { + void *pdata; + int ret; + + pdata = embryo_program_data_get(ed->collection->script); + embryo_program_data_set(ed->collection->script, ed); + embryo_program_max_cycle_run_set(ed->collection->script, 5000000); + ret = embryo_program_run(ed->collection->script, fn); + if (ret == EMBRYO_PROGRAM_FAIL) + { + ERR("ERROR with embryo script (timer callback). " + "OBJECT NAME: '%s', " + "OBJECT FILE: '%s', " + "ERROR: '%s'", + ed->collection->part, + ed->file->path, + embryo_error_string_get(embryo_program_error_get(ed->collection->script))); + } + else if (ret == EMBRYO_PROGRAM_TOOLONG) + { + ERR("ERROR with embryo script (timer callback). " + "OBJECT NAME: '%s', " + "OBJECT FILE: '%s', " + "ERROR: 'Script exceeded maximum allowed cycle count of %i'", + ed->collection->part, + ed->file->path, + embryo_program_max_cycle_run_get(ed->collection->script)); + } + embryo_program_data_set(ed->collection->script, pdata); + embryo_program_vm_pop(ed->collection->script); + _edje_recalc(ed); + } + return ECORE_CALLBACK_CANCEL; +} + +static Eina_Bool +_edje_var_anim_cb(void *data __UNUSED__) +{ + Eina_List *l, *tl = NULL; + double t; + const void *tmp; + + t = ecore_loop_time_get(); + EINA_LIST_FOREACH(_edje_anim_list, l, tmp) + tl = eina_list_append(tl, tmp); + while (tl) + { + Edje *ed; + Eina_List *tl2; + Edje_Var_Animator *ea; + + ed = eina_list_data_get(tl); + _edje_ref(ed); + _edje_block(ed); + _edje_freeze(ed); + tl = eina_list_remove(tl, ed); + if (!ed->var_pool) continue; + tl2 = NULL; + EINA_LIST_FOREACH(ed->var_pool->animators, l, tmp) + tl2 = eina_list_append(tl2, tmp); + ed->var_pool->walking_list++; + while (tl2) + { + ea = eina_list_data_get(tl2); + if ((ed->var_pool) && (!ea->delete_me)) + { + if ((!ed->paused) && (!ed->delete_me)) + { + Embryo_Function fn; + float v; + int ret; + + v = (t - ea->start) / ea->len; + if (v > 1.0) v= 1.0; +// _edje_embryo_script_reset(ed); + embryo_program_vm_push(ed->collection->script); + _edje_embryo_globals_init(ed); + embryo_parameter_cell_push(ed->collection->script, (Embryo_Cell)ea->val); + embryo_parameter_cell_push(ed->collection->script, EMBRYO_FLOAT_TO_CELL(v)); + fn = ea->func; + { + void *pdata; + + pdata = embryo_program_data_get(ed->collection->script); + embryo_program_data_set(ed->collection->script, ed); + embryo_program_max_cycle_run_set(ed->collection->script, 5000000); + ret = embryo_program_run(ed->collection->script, fn); + if (ret == EMBRYO_PROGRAM_FAIL) + { + ERR("ERROR with embryo script (anim callback). " + "OBJECT NAME: '%s', " + "OBJECT FILE: '%s', " + "ERROR: '%s'", + ed->collection->part, + ed->file->path, + embryo_error_string_get(embryo_program_error_get(ed->collection->script))); + } + else if (ret == EMBRYO_PROGRAM_TOOLONG) + { + ERR("ERROR with embryo script (anim callback). " + "OBJECT NAME: '%s', " + "OBJECT FILE: '%s', " + "ERROR: 'Script exceeded maximum allowed cycle count of %i'", + ed->collection->part, + ed->file->path, + embryo_program_max_cycle_run_get(ed->collection->script)); + } + embryo_program_data_set(ed->collection->script, pdata); + embryo_program_vm_pop(ed->collection->script); + _edje_recalc(ed); + } + if (v == 1.0) ea->delete_me = 1; + } + } + tl2 = eina_list_remove(tl2, ea); + if (ed->block_break) + { + eina_list_free(tl2); + break; + } + } + ed->var_pool->walking_list--; + EINA_LIST_FOREACH(ed->var_pool->animators, l, ea) + { + if (ea->delete_me) + { + l = eina_list_next(l); + ed->var_pool->animators = eina_list_remove(ed->var_pool->animators, ea); + free(ea); + } + else + l = eina_list_next(l); + } + if (!ed->var_pool->animators) + _edje_anim_list = eina_list_remove(_edje_anim_list, ed); + _edje_unblock(ed); + _edje_thaw(ed); + _edje_unref(ed); + } + if (!_edje_anim_list) + { + if (_edje_animator) + { + ecore_animator_del(_edje_animator); + _edje_animator = NULL; + } + } + return !!_edje_animator; +} + +Edje_Var * +_edje_var_new(void) +{ + return calloc(1, sizeof(Edje_Var)); +} + +void +_edje_var_free(Edje_Var *var) +{ + if (var->type == EDJE_VAR_STRING) + { + if (var->data.s.v) + { + free(var->data.s.v); + } + } + free(var); +} + +void +_edje_var_init(Edje *ed) +{ + if (!ed) return; + if (!ed->collection) return; + if (!ed->collection->script) return; + if (ed->var_pool) return; + ed->var_pool = calloc(1, sizeof(Edje_Var_Pool)); + if (!ed->var_pool) return; + embryo_program_vm_push(ed->collection->script); + ed->var_pool->size = embryo_program_variable_count_get(ed->collection->script); + embryo_program_vm_pop(ed->collection->script); + if (ed->var_pool->size > 0) + ed->var_pool->vars = calloc(1, sizeof(Edje_Var) * ed->var_pool->size); +} + +void +_edje_var_shutdown(Edje *ed) +{ + if (!ed->var_pool) return; + if (ed->var_pool->vars) + { + int i; + + for (i = 0; i < ed->var_pool->size; i++) + { + if (ed->var_pool->vars[i].type == EDJE_VAR_STRING) + { + if (ed->var_pool->vars[i].data.s.v) + { + free(ed->var_pool->vars[i].data.s.v); + ed->var_pool->vars[i].data.s.v = NULL; + } + } + else if (ed->var_pool->vars[i].type == EDJE_VAR_LIST) + { + while (ed->var_pool->vars[i].data.l.v) + { + _edje_var_free(eina_list_data_get(ed->var_pool->vars[i].data.l.v)); + 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); + } + } + } + free(ed->var_pool->vars); + } + while (ed->var_pool->timers) + { + Edje_Var_Timer *et; + + et = eina_list_data_get(ed->var_pool->timers); + ecore_timer_del(et->timer); + free(et); + ed->var_pool->timers = eina_list_remove(ed->var_pool->timers, et); + } + if (ed->var_pool->animators) + { + _edje_anim_list = eina_list_remove(_edje_anim_list, ed); + if (!_edje_anim_list) + { + if (_edje_animator) + { + ecore_animator_del(_edje_animator); + _edje_animator = NULL; + } + } + } + while (ed->var_pool->animators) + { + Edje_Var_Animator *ea; + + ea = eina_list_data_get(ed->var_pool->animators); + free(ea); + ed->var_pool->animators = eina_list_remove(ed->var_pool->animators, ea); + } + free(ed->var_pool); + ed->var_pool = NULL; +} + +int +_edje_var_string_id_get(Edje *ed, const char *string) +{ + Embryo_Cell cell, *cptr; + + if (!ed) return 0; + if (!ed->collection) return 0; + if (!ed->collection->script) return 0; + if (!string) return 0; + cell = embryo_program_variable_find(ed->collection->script, (char *)string); + if (cell == EMBRYO_CELL_NONE) return 0; + cptr = embryo_data_address_get(ed->collection->script, cell); + if (!cptr) return 0; + return (int)(*cptr); +} + +int +_edje_var_var_int_get(Edje *ed __UNUSED__, Edje_Var *var) +{ + /* auto-cast */ + if (var->type == EDJE_VAR_STRING) + { + if (var->data.s.v) + { + double f; + + f = atof(var->data.s.v); + free(var->data.s.v); + var->data.s.v = NULL; + var->data.i.v = (int)f; + } + var->type = EDJE_VAR_INT; + } + else if (var->type == EDJE_VAR_FLOAT) + { + var->data.i.v = (int)(var->data.f.v); + var->type = EDJE_VAR_INT; + } + else if (var->type == EDJE_VAR_NONE) + { + var->type = EDJE_VAR_INT; + } + else if (var->type == EDJE_VAR_LIST) + { + return 0; + } + else if (var->type == EDJE_VAR_HASH) + { + return 0; + } + return var->data.i.v; +} + +void +_edje_var_var_int_set(Edje *ed __UNUSED__, Edje_Var *var, int v) +{ + /* auto-cast */ + if (var->type == EDJE_VAR_STRING) + { + if (var->data.s.v) + { + free(var->data.s.v); + var->data.s.v = NULL; + } + var->type = EDJE_VAR_INT; + } + else if (var->type == EDJE_VAR_FLOAT) + { + var->type = EDJE_VAR_INT; + } + else if (var->type == EDJE_VAR_NONE) + { + var->type = EDJE_VAR_INT; + } + else if (var->type == EDJE_VAR_LIST) + { + return; + } + else if (var->type == EDJE_VAR_HASH) + { + return; + } + var->data.i.v = v; +} + +double +_edje_var_var_float_get(Edje *ed __UNUSED__, Edje_Var *var) +{ + /* auto-cast */ + if (var->type == EDJE_VAR_STRING) + { + if (var->data.s.v) + { + double f; + + f = atof(var->data.s.v); + free(var->data.s.v); + var->data.s.v = NULL; + var->data.f.v = f; + } + var->type = EDJE_VAR_FLOAT; + } + else if (var->type == EDJE_VAR_INT) + { + var->data.f.v = (double)(var->data.i.v); + var->type = EDJE_VAR_FLOAT; + } + else if (var->type == EDJE_VAR_NONE) + { + var->type = EDJE_VAR_FLOAT; + } + else if (var->type == EDJE_VAR_LIST) + { + return 0.0; + } + else if (var->type == EDJE_VAR_HASH) + { + return 0.0; + } + return var->data.f.v; +} + +void +_edje_var_var_float_set(Edje *ed __UNUSED__, Edje_Var *var, double v) +{ + /* auto-cast */ + if (var->type == EDJE_VAR_STRING) + { + if (var->data.s.v) + { + free(var->data.s.v); + var->data.s.v = NULL; + } + var->type = EDJE_VAR_FLOAT; + } + else if (var->type == EDJE_VAR_INT) + { + var->data.f.v = 0; + var->type = EDJE_VAR_FLOAT; + } + else if (var->type == EDJE_VAR_NONE) + { + var->type = EDJE_VAR_FLOAT; + } + else if (var->type == EDJE_VAR_LIST) + { + return; + } + else if (var->type == EDJE_VAR_HASH) + { + return; + } + var->data.f.v = v; +} + +const char * +_edje_var_var_str_get(Edje *ed __UNUSED__, Edje_Var *var) +{ + /* auto-cast */ + if (var->type == EDJE_VAR_INT) + { + char buf[64]; + + snprintf(buf, sizeof(buf), "%i", var->data.i.v); + var->data.s.v = strdup(buf); + var->type = EDJE_VAR_STRING; + } + else if (var->type == EDJE_VAR_FLOAT) + { + char buf[64]; + + snprintf(buf, sizeof(buf), "%f", var->data.f.v); + var->data.s.v = strdup(buf); + var->type = EDJE_VAR_STRING; + } + else if (var->type == EDJE_VAR_NONE) + { + var->data.s.v = strdup(""); + var->type = EDJE_VAR_STRING; + } + else if (var->type == EDJE_VAR_LIST) + { + return NULL; + } + else if (var->type == EDJE_VAR_HASH) + { + return NULL; + } + return var->data.s.v; +} + +void +_edje_var_var_str_set(Edje *ed __UNUSED__, Edje_Var *var, const char *str) +{ + /* auto-cast */ + if (var->type == EDJE_VAR_STRING) + { + if (var->data.s.v) + { + free(var->data.s.v); + var->data.s.v = NULL; + } + } + else if (var->type == EDJE_VAR_INT) + { + var->type = EDJE_VAR_STRING; + } + else if (var->type == EDJE_VAR_FLOAT) + { + var->type = EDJE_VAR_STRING; + } + else if (var->type == EDJE_VAR_NONE) + { + var->type = EDJE_VAR_STRING; + } + else if (var->type == EDJE_VAR_LIST) + { + return; + } + else if (var->type == EDJE_VAR_HASH) + { + return; + } + var->data.s.v = strdup(str); +} + +int +_edje_var_int_get(Edje *ed, int id) +{ + if (!ed) return 0; + if (!ed->var_pool) return 0; + id -= EDJE_VAR_MAGIC_BASE; + if ((id < 0) || (id >= ed->var_pool->size)) return 0; + return _edje_var_var_int_get(ed, &(ed->var_pool->vars[id])); +} + +void +_edje_var_int_set(Edje *ed, int id, int v) +{ + if (!ed) return; + if (!ed->var_pool) return; + id -= EDJE_VAR_MAGIC_BASE; + if ((id < 0) || (id >= ed->var_pool->size)) return; + _edje_var_var_int_set(ed, &(ed->var_pool->vars[id]), v); +} + +double +_edje_var_float_get(Edje *ed, int id) +{ + if (!ed) return 0; + if (!ed->var_pool) return 0; + id -= EDJE_VAR_MAGIC_BASE; + if ((id < 0) || (id >= ed->var_pool->size)) return 0; + return _edje_var_var_float_get(ed, &(ed->var_pool->vars[id])); +} + +void +_edje_var_float_set(Edje *ed, int id, double v) +{ + if (!ed) return; + if (!ed->var_pool) return; + id -= EDJE_VAR_MAGIC_BASE; + if ((id < 0) || (id >= ed->var_pool->size)) return; + _edje_var_var_float_set(ed, &(ed->var_pool->vars[id]), v); +} + +const char * +_edje_var_str_get(Edje *ed, int id) +{ + if (!ed) return NULL; + if (!ed->var_pool) return NULL; + id -= EDJE_VAR_MAGIC_BASE; + if ((id < 0) || (id >= ed->var_pool->size)) return NULL; + return _edje_var_var_str_get(ed, &(ed->var_pool->vars[id])); +} + +void +_edje_var_str_set(Edje *ed, int id, const char *str) +{ + if (!ed) return; + if (!ed->var_pool) return; + if (!str) return; + id -= EDJE_VAR_MAGIC_BASE; + if ((id < 0) || (id >= ed->var_pool->size)) return; + _edje_var_var_str_set(ed, &(ed->var_pool->vars[id]), str); +} + +/* list stuff */ + +void +_edje_var_list_var_append(Edje *ed, int id, Edje_Var *var) +{ + if (!ed) return; + if (!ed->var_pool) return; + id -= EDJE_VAR_MAGIC_BASE; + if ((id < 0) || (id >= ed->var_pool->size)) return; + if (ed->var_pool->vars[id].type != EDJE_VAR_LIST) return; + ed->var_pool->vars[id].data.l.v = eina_list_append(ed->var_pool->vars[id].data.l.v, var); +} + +void +_edje_var_list_var_prepend(Edje *ed, int id, Edje_Var *var) +{ + if (!ed) return; + if (!ed->var_pool) return; + id -= EDJE_VAR_MAGIC_BASE; + if ((id < 0) || (id >= ed->var_pool->size)) return; + if (ed->var_pool->vars[id].type != EDJE_VAR_LIST) return; + ed->var_pool->vars[id].data.l.v = eina_list_prepend(ed->var_pool->vars[id].data.l.v, var); +} + +void +_edje_var_list_var_append_relative(Edje *ed, int id, Edje_Var *var, Edje_Var *relative) +{ + if (!ed) return; + if (!ed->var_pool) return; + id -= EDJE_VAR_MAGIC_BASE; + if ((id < 0) || (id >= ed->var_pool->size)) return; + if (ed->var_pool->vars[id].type != EDJE_VAR_LIST) return; + ed->var_pool->vars[id].data.l.v = eina_list_append_relative(ed->var_pool->vars[id].data.l.v, var, relative); +} + +void +_edje_var_list_var_prepend_relative(Edje *ed, int id, Edje_Var *var, Edje_Var *relative) +{ + if (!ed) return; + if (!ed->var_pool) return; + id -= EDJE_VAR_MAGIC_BASE; + if ((id < 0) || (id >= ed->var_pool->size)) return; + if (ed->var_pool->vars[id].type != EDJE_VAR_LIST) return; + ed->var_pool->vars[id].data.l.v = eina_list_prepend_relative(ed->var_pool->vars[id].data.l.v, var, relative); +} + +Edje_Var * +_edje_var_list_nth(Edje *ed, int id, int n) +{ + if (!ed) return NULL; + if (!ed->var_pool) return NULL; + id -= EDJE_VAR_MAGIC_BASE; + if ((id < 0) || (id >= ed->var_pool->size)) return NULL; + if (ed->var_pool->vars[id].type != EDJE_VAR_LIST) return NULL; + return eina_list_nth(ed->var_pool->vars[id].data.l.v, n); +} + +int +_edje_var_list_count_get(Edje *ed, int id) +{ + if (!ed) return 0; + if (!ed->var_pool) return 0; + id -= EDJE_VAR_MAGIC_BASE; + if ((id < 0) || (id >= ed->var_pool->size)) return 0; + if (ed->var_pool->vars[id].type == EDJE_VAR_NONE) + ed->var_pool->vars[id].type = EDJE_VAR_LIST; + else if (ed->var_pool->vars[id].type != EDJE_VAR_LIST) return 0; + return eina_list_count(ed->var_pool->vars[id].data.l.v); +} + +void +_edje_var_list_remove_nth(Edje *ed, int id, int n) +{ + if (!ed) return; + if (!ed->var_pool) return; + id -= EDJE_VAR_MAGIC_BASE; + if ((id < 0) || (id >= ed->var_pool->size)) return; + if (ed->var_pool->vars[id].type == EDJE_VAR_NONE) + ed->var_pool->vars[id].type = EDJE_VAR_LIST; + else if (ed->var_pool->vars[id].type != EDJE_VAR_LIST) return; + { + Eina_List *nth; + + nth = eina_list_nth_list(ed->var_pool->vars[id].data.l.v, n); + if (nth) + { + _edje_var_free(eina_list_data_get(nth)); + ed->var_pool->vars[id].data.l.v = eina_list_remove_list(ed->var_pool->vars[id].data.l.v, nth); + } + } +} + +int +_edje_var_list_nth_int_get(Edje *ed, int id, int n) +{ + if (!ed) return 0; + if (!ed->var_pool) return 0; + id -= EDJE_VAR_MAGIC_BASE; + if ((id < 0) || (id >= ed->var_pool->size)) return 0; + if (ed->var_pool->vars[id].type == EDJE_VAR_NONE) + ed->var_pool->vars[id].type = EDJE_VAR_LIST; + else if (ed->var_pool->vars[id].type != EDJE_VAR_LIST) return 0; + { + Edje_Var *var; + + id += EDJE_VAR_MAGIC_BASE; + var = _edje_var_list_nth(ed, id, n); + if (!var) return 0; + return _edje_var_var_int_get(ed, var); + } +} + +void +_edje_var_list_nth_int_set(Edje *ed, int id, int n, int v) +{ + if (!ed) return; + if (!ed->var_pool) return; + id -= EDJE_VAR_MAGIC_BASE; + if ((id < 0) || (id >= ed->var_pool->size)) return; + if (ed->var_pool->vars[id].type == EDJE_VAR_NONE) + ed->var_pool->vars[id].type = EDJE_VAR_LIST; + else if (ed->var_pool->vars[id].type != EDJE_VAR_LIST) return; + { + Edje_Var *var; + + id += EDJE_VAR_MAGIC_BASE; + var = _edje_var_list_nth(ed, id, n); + if (!var) return; + _edje_var_var_int_set(ed, var, v); + } +} + +void +_edje_var_list_int_append(Edje *ed, int id, int v) +{ + if (!ed) return; + if (!ed->var_pool) return; + id -= EDJE_VAR_MAGIC_BASE; + if ((id < 0) || (id >= ed->var_pool->size)) return; + if (ed->var_pool->vars[id].type == EDJE_VAR_NONE) + ed->var_pool->vars[id].type = EDJE_VAR_LIST; + else if (ed->var_pool->vars[id].type != EDJE_VAR_LIST) return; + { + Edje_Var *var; + + var = _edje_var_new(); + if (!var) return; + id += EDJE_VAR_MAGIC_BASE; + _edje_var_var_int_set(ed, var, v); + _edje_var_list_var_append(ed, id, var); + } +} + +void +_edje_var_list_int_prepend(Edje *ed, int id, int v) +{ + if (!ed) return; + if (!ed->var_pool) return; + id -= EDJE_VAR_MAGIC_BASE; + if ((id < 0) || (id >= ed->var_pool->size)) return; + if (ed->var_pool->vars[id].type == EDJE_VAR_NONE) + ed->var_pool->vars[id].type = EDJE_VAR_LIST; + else if (ed->var_pool->vars[id].type != EDJE_VAR_LIST) return; + { + Edje_Var *var; + + var = _edje_var_new(); + if (!var) return; + id += EDJE_VAR_MAGIC_BASE; + _edje_var_var_int_set(ed, var, v); + _edje_var_list_var_prepend(ed, id, var); + } +} + +void +_edje_var_list_int_insert(Edje *ed, int id, int n, int v) +{ + if (!ed) return; + if (!ed->var_pool) return; + id -= EDJE_VAR_MAGIC_BASE; + if ((id < 0) || (id >= ed->var_pool->size)) return; + if (ed->var_pool->vars[id].type == EDJE_VAR_NONE) + ed->var_pool->vars[id].type = EDJE_VAR_LIST; + else if (ed->var_pool->vars[id].type != EDJE_VAR_LIST) return; + { + Edje_Var *var, *var_rel; + + var = _edje_var_new(); + if (!var) return; + id += EDJE_VAR_MAGIC_BASE; + _edje_var_var_int_set(ed, var, v); + var_rel = _edje_var_list_nth(ed, id, n); + if (!var_rel) + _edje_var_list_var_append(ed, id, var); + else + _edje_var_list_var_prepend_relative(ed, id, var, var_rel); + } +} + +double +_edje_var_list_nth_float_get(Edje *ed, int id, int n) +{ + if (!ed) return 0; + if (!ed->var_pool) return 0; + id -= EDJE_VAR_MAGIC_BASE; + if ((id < 0) || (id >= ed->var_pool->size)) return 0; + if (ed->var_pool->vars[id].type == EDJE_VAR_NONE) + ed->var_pool->vars[id].type = EDJE_VAR_LIST; + else if (ed->var_pool->vars[id].type != EDJE_VAR_LIST) return 0; + { + Edje_Var *var; + + id += EDJE_VAR_MAGIC_BASE; + var = _edje_var_list_nth(ed, id, n); + if (!var) return 0; + return _edje_var_var_float_get(ed, var); + } +} + +void +_edje_var_list_nth_float_set(Edje *ed, int id, int n, double v) +{ + if (!ed) return; + if (!ed->var_pool) return; + id -= EDJE_VAR_MAGIC_BASE; + if ((id < 0) || (id >= ed->var_pool->size)) return; + if (ed->var_pool->vars[id].type == EDJE_VAR_NONE) + ed->var_pool->vars[id].type = EDJE_VAR_LIST; + else if (ed->var_pool->vars[id].type != EDJE_VAR_LIST) return; + { + Edje_Var *var; + + id += EDJE_VAR_MAGIC_BASE; + var = _edje_var_list_nth(ed, id, n); + if (!var) return; + _edje_var_var_float_set(ed, var, v); + } +} + +void +_edje_var_list_float_append(Edje *ed, int id, double v) +{ + if (!ed) return; + if (!ed->var_pool) return; + id -= EDJE_VAR_MAGIC_BASE; + if ((id < 0) || (id >= ed->var_pool->size)) return; + if (ed->var_pool->vars[id].type == EDJE_VAR_NONE) + ed->var_pool->vars[id].type = EDJE_VAR_LIST; + else if (ed->var_pool->vars[id].type != EDJE_VAR_LIST) return; + { + Edje_Var *var; + + var = _edje_var_new(); + if (!var) return; + id += EDJE_VAR_MAGIC_BASE; + _edje_var_var_float_set(ed, var, v); + _edje_var_list_var_append(ed, id, var); + } +} + +void +_edje_var_list_float_prepend(Edje *ed, int id, double v) +{ + if (!ed) return; + if (!ed->var_pool) return; + id -= EDJE_VAR_MAGIC_BASE; + if ((id < 0) || (id >= ed->var_pool->size)) return; + if (ed->var_pool->vars[id].type == EDJE_VAR_NONE) + ed->var_pool->vars[id].type = EDJE_VAR_LIST; + else if (ed->var_pool->vars[id].type != EDJE_VAR_LIST) return; + { + Edje_Var *var; + + var = _edje_var_new(); + if (!var) return; + id += EDJE_VAR_MAGIC_BASE; + _edje_var_var_float_set(ed, var, v); + _edje_var_list_var_prepend(ed, id, var); + } +} + +void +_edje_var_list_float_insert(Edje *ed, int id, int n, double v) +{ + if (!ed) return; + if (!ed->var_pool) return; + id -= EDJE_VAR_MAGIC_BASE; + if ((id < 0) || (id >= ed->var_pool->size)) return; + if (ed->var_pool->vars[id].type == EDJE_VAR_NONE) + ed->var_pool->vars[id].type = EDJE_VAR_LIST; + else if (ed->var_pool->vars[id].type != EDJE_VAR_LIST) return; + { + Edje_Var *var, *var_rel; + + var = _edje_var_new(); + if (!var) return; + id += EDJE_VAR_MAGIC_BASE; + _edje_var_var_float_set(ed, var, v); + var_rel = _edje_var_list_nth(ed, id, n); + if (!var_rel) + _edje_var_list_var_append(ed, id, var); + else + _edje_var_list_var_prepend_relative(ed, id, var, var_rel); + } +} + +const char * +_edje_var_list_nth_str_get(Edje *ed, int id, int n) +{ + if (!ed) return NULL; + if (!ed->var_pool) return NULL; + id -= EDJE_VAR_MAGIC_BASE; + if ((id < 0) || (id >= ed->var_pool->size)) return NULL; + if (ed->var_pool->vars[id].type == EDJE_VAR_NONE) + ed->var_pool->vars[id].type = EDJE_VAR_LIST; + else if (ed->var_pool->vars[id].type != EDJE_VAR_LIST) return NULL; + { + Edje_Var *var; + + id += EDJE_VAR_MAGIC_BASE; + var = _edje_var_list_nth(ed, id, n); + if (!var) return NULL; + return _edje_var_var_str_get(ed, var); + } +} + +void +_edje_var_list_nth_str_set(Edje *ed, int id, int n, const char *v) +{ + if (!ed) return; + if (!ed->var_pool) return; + id -= EDJE_VAR_MAGIC_BASE; + if ((id < 0) || (id >= ed->var_pool->size)) return; + if (ed->var_pool->vars[id].type == EDJE_VAR_NONE) + ed->var_pool->vars[id].type = EDJE_VAR_LIST; + else if (ed->var_pool->vars[id].type != EDJE_VAR_LIST) return; + { + Edje_Var *var; + + id += EDJE_VAR_MAGIC_BASE; + var = _edje_var_list_nth(ed, id, n); + if (!var) return; + _edje_var_var_str_set(ed, var, v); + } +} + +void +_edje_var_list_str_append(Edje *ed, int id, const char *v) +{ + if (!ed) return; + if (!ed->var_pool) return; + id -= EDJE_VAR_MAGIC_BASE; + if ((id < 0) || (id >= ed->var_pool->size)) return; + if (ed->var_pool->vars[id].type == EDJE_VAR_NONE) + ed->var_pool->vars[id].type = EDJE_VAR_LIST; + else if (ed->var_pool->vars[id].type != EDJE_VAR_LIST) return; + { + Edje_Var *var; + + var = _edje_var_new(); + if (!var) return; + id += EDJE_VAR_MAGIC_BASE; + _edje_var_var_str_set(ed, var, v); + _edje_var_list_var_append(ed, id, var); + } +} + +void +_edje_var_list_str_prepend(Edje *ed, int id, const char *v) +{ + if (!ed) return; + if (!ed->var_pool) return; + id -= EDJE_VAR_MAGIC_BASE; + if ((id < 0) || (id >= ed->var_pool->size)) return; + if (ed->var_pool->vars[id].type == EDJE_VAR_NONE) + ed->var_pool->vars[id].type = EDJE_VAR_LIST; + else if (ed->var_pool->vars[id].type != EDJE_VAR_LIST) return; + { + Edje_Var *var; + + var = _edje_var_new(); + if (!var) return; + id += EDJE_VAR_MAGIC_BASE; + _edje_var_var_str_set(ed, var, v); + _edje_var_list_var_prepend(ed, id, var); + } +} + +void +_edje_var_list_str_insert(Edje *ed, int id, int n, const char *v) +{ + if (!ed) return; + if (!ed->var_pool) return; + id -= EDJE_VAR_MAGIC_BASE; + if ((id < 0) || (id >= ed->var_pool->size)) return; + if (ed->var_pool->vars[id].type == EDJE_VAR_NONE) + ed->var_pool->vars[id].type = EDJE_VAR_LIST; + else if (ed->var_pool->vars[id].type != EDJE_VAR_LIST) return; + { + Edje_Var *var, *var_rel; + + var = _edje_var_new(); + if (!var) return; + id += EDJE_VAR_MAGIC_BASE; + _edje_var_var_str_set(ed, var, v); + var_rel = _edje_var_list_nth(ed, id, n); + if (!var_rel) + _edje_var_list_var_append(ed, id, var); + else + _edje_var_list_var_prepend_relative(ed, id, var, var_rel); + } +} + +int +_edje_var_timer_add(Edje *ed, double in, const char *fname, int val) +{ + Edje_Var_Timer *et; + Embryo_Function fn; + + if (!ed->var_pool) return 0; + fn = embryo_program_function_find(ed->collection->script, (char *)fname); + if (fn == EMBRYO_FUNCTION_NONE) return 0; + et = calloc(1, sizeof(Edje_Var_Timer)); + if (!et) return 0; + et->id = ++ed->var_pool->id_count; + et->edje = ed; + et->func = fn; + et->val = val; + et->timer = ecore_timer_add(in, _edje_var_timer_cb, et); + if (!et->timer) + { + free(et); + return 0; + } + ed->var_pool->timers = eina_list_prepend(ed->var_pool->timers, et); + return et->id; +} + +static Edje_Var_Timer * +_edje_var_timer_find(Edje *ed, int id) +{ + Eina_List *l; + Edje_Var_Timer *et; + + if (!ed->var_pool) return NULL; + + EINA_LIST_FOREACH(ed->var_pool->timers, l, et) + if (et->id == id) return et; + + return NULL; +} + +void +_edje_var_timer_del(Edje *ed, int id) +{ + Edje_Var_Timer *et; + + et = _edje_var_timer_find(ed, id); + if (!et) return; + + ed->var_pool->timers = eina_list_remove(ed->var_pool->timers, et); + ecore_timer_del(et->timer); + free(et); +} + +int +_edje_var_anim_add(Edje *ed, double len, const char *fname, int val) +{ + Edje_Var_Animator *ea; + Embryo_Function fn; + + if (!ed->var_pool) return 0; + if (len <= 0.0) return 0; + fn = embryo_program_function_find(ed->collection->script, (char *)fname); + if (fn == EMBRYO_FUNCTION_NONE) return 0; + ea = calloc(1, sizeof(Edje_Var_Animator)); + if (!ea) return 0; + ea->start = ecore_loop_time_get(); + ea->len = len; + ea->id = ++ed->var_pool->id_count; + ea->edje = ed; + ea->func = fn; + ea->val = val; + if (!ed->var_pool->animators) + _edje_anim_list = eina_list_append(_edje_anim_list, ed); + ed->var_pool->animators = eina_list_prepend(ed->var_pool->animators, ea); + if (!_edje_animator) + _edje_animator = ecore_animator_add(_edje_var_anim_cb, NULL); + return ea->id; +} + +static Edje_Var_Animator * +_edje_var_anim_find(Edje *ed, int id) +{ + Eina_List *l; + Edje_Var_Animator *ea; + + if (!ed->var_pool) return NULL; + + EINA_LIST_FOREACH(ed->var_pool->animators, l, ea) + if (ea->id == id) return ea; + + return NULL; +} + +void +_edje_var_anim_del(Edje *ed, int id) +{ + Edje_Var_Animator *ea; + + ea = _edje_var_anim_find(ed, id); + if (!ea) return; + + if (ed->var_pool->walking_list) + { + ea->delete_me = 1; + return; + } + + ed->var_pool->animators = eina_list_remove(ed->var_pool->animators, ea); + free(ea); + + if (ed->var_pool->animators) return; + + _edje_anim_list = eina_list_remove(_edje_anim_list, ed); + if (!_edje_anim_list) + { + if (_edje_animator) + { + ecore_animator_del(_edje_animator); + _edje_animator = NULL; + } + } +} -- cgit v1.1