2007-05-26 22:28:07 -07:00
|
|
|
/*
|
|
|
|
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
|
|
|
*/
|
2008-06-07 03:06:14 -07:00
|
|
|
|
2009-05-02 13:05:53 -07:00
|
|
|
#define _GNU_SOURCE
|
2008-10-26 10:18:19 -07:00
|
|
|
#include <string.h>
|
|
|
|
|
2003-06-23 19:33:04 -07:00
|
|
|
#include "edje_private.h"
|
|
|
|
|
2006-03-18 20:22:35 -08:00
|
|
|
static void _edje_emit_cb(Edje *ed, const char *sig, const char *src);
|
2003-08-15 06:35:25 -07:00
|
|
|
|
2004-09-05 01:11:36 -07:00
|
|
|
int _edje_anim_count = 0;
|
|
|
|
Ecore_Animator *_edje_timer = NULL;
|
2008-10-22 04:34:42 -07:00
|
|
|
Eina_List *_edje_animators = NULL;
|
2003-06-23 19:33:04 -07:00
|
|
|
|
2004-06-05 21:42:17 -07:00
|
|
|
|
2009-09-17 15:38:35 -07:00
|
|
|
/*============================================================================*
|
|
|
|
* API *
|
|
|
|
*============================================================================*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @addtogroup Edje_program_Group Program
|
|
|
|
*
|
|
|
|
* @brief These functions provide 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 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()
|
2004-06-05 21:42:17 -07:00
|
|
|
*
|
|
|
|
*/
|
2006-01-07 00:54:30 -08:00
|
|
|
EAPI void
|
2003-06-23 19:33:04 -07:00
|
|
|
edje_frametime_set(double t)
|
|
|
|
{
|
2004-09-05 01:11:36 -07:00
|
|
|
ecore_animator_frametime_set(t);
|
2003-06-23 19:33:04 -07:00
|
|
|
}
|
|
|
|
|
2009-09-17 15:38:35 -07:00
|
|
|
/**
|
|
|
|
* @brief Get edje trasitions' frame time.
|
|
|
|
*
|
|
|
|
* @return The frame time, in seconds.
|
|
|
|
*
|
|
|
|
* This function returns the edje frame time set by
|
|
|
|
* edje_frametime_set().
|
|
|
|
*
|
|
|
|
* @see edje_frametime_set()
|
2004-06-05 21:42:17 -07:00
|
|
|
*
|
|
|
|
*/
|
2006-01-07 00:54:30 -08:00
|
|
|
EAPI double
|
2003-06-23 19:33:04 -07:00
|
|
|
edje_frametime_get(void)
|
|
|
|
{
|
2004-09-05 01:11:36 -07:00
|
|
|
return ecore_animator_frametime_get();
|
2003-06-23 19:33:04 -07:00
|
|
|
}
|
|
|
|
|
2009-09-17 15:38:35 -07:00
|
|
|
/**
|
|
|
|
* @brief Add a callback for a signal emitted by @a obj.
|
|
|
|
*
|
|
|
|
* @param obj A valid Evas_Object handle.
|
|
|
|
* @param emission The signal's name.
|
|
|
|
* @param source The signal's source.
|
|
|
|
* @param func The callback function to be executed when the signal is
|
|
|
|
* emitted.
|
|
|
|
* @param data A pointer to data to pass in to the callback function.
|
2007-04-14 21:05:41 -07:00
|
|
|
*
|
|
|
|
* Connects a callback function to a signal emitted by @a obj.
|
|
|
|
* In EDC, a program can emit a signal as follows:
|
|
|
|
*
|
|
|
|
* @code
|
|
|
|
* program {
|
|
|
|
* name: "emit_example";
|
|
|
|
* action: SIGNAL_EMIT "a_signal" "a_source";
|
|
|
|
* }
|
|
|
|
* @endcode
|
|
|
|
*
|
|
|
|
* Assuming a function with the following declaration is definded:
|
|
|
|
*
|
|
|
|
* @code
|
|
|
|
* void cb_signal(void *data, Evas_Object *o, const char *emission, const char *source);
|
|
|
|
* @endcode
|
|
|
|
*
|
|
|
|
* a callback is attached using:
|
|
|
|
*
|
|
|
|
* @code
|
|
|
|
* edje_object_callback_add(obj, "a_signal", "a_source", cb_signal, data);
|
|
|
|
* @endcode
|
|
|
|
*
|
2009-09-17 15:38:35 -07:00
|
|
|
* Here, @a data is an arbitrary pointer to be used as desired. Note
|
|
|
|
* that @a emission and @a source correspond respectively to the first
|
|
|
|
* and the second parameters at the SIGNAL_EMIT action.
|
2004-06-05 21:42:17 -07:00
|
|
|
*
|
2009-09-17 15:38:35 -07:00
|
|
|
* Internal edje signals can also be attached to, and globs can occur
|
|
|
|
* in either the emission or source name, e.g.
|
2007-04-14 21:05:41 -07:00
|
|
|
*
|
|
|
|
* @code
|
|
|
|
* edje_object_callback_add(obj, "mouse,down,*", "button.*", NULL);
|
|
|
|
* @endcode
|
|
|
|
*
|
2007-09-08 11:31:56 -07:00
|
|
|
* Here, any mouse down events on an edje part whose name begins with
|
2009-09-17 15:38:35 -07:00
|
|
|
* "button." will trigger the callback. The actual signal and source
|
|
|
|
* names will be passed in to the @a emission and @a source parameters
|
|
|
|
* of the callback function (e.g. "mouse,down,2" and "button.close").
|
2004-06-05 21:42:17 -07:00
|
|
|
*/
|
2006-01-07 00:54:30 -08:00
|
|
|
EAPI void
|
2003-07-08 03:08:15 -07:00
|
|
|
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)
|
2003-06-23 19:33:04 -07:00
|
|
|
{
|
|
|
|
Edje *ed;
|
|
|
|
Edje_Signal_Callback *escb;
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2003-06-23 19:33:04 -07:00
|
|
|
if ((!emission) || (!source) || (!func)) return;
|
|
|
|
ed = _edje_fetch(obj);
|
|
|
|
if (!ed) return;
|
2003-08-25 17:16:49 -07:00
|
|
|
if (ed->delete_me) return;
|
2003-06-23 19:33:04 -07:00
|
|
|
escb = calloc(1, sizeof(Edje_Signal_Callback));
|
2009-02-07 07:45:50 -08:00
|
|
|
if (emission[0])
|
2008-10-15 07:11:11 -07:00
|
|
|
escb->signal = eina_stringshare_add(emission);
|
2009-02-07 07:45:50 -08:00
|
|
|
if (source[0])
|
2008-10-15 07:11:11 -07:00
|
|
|
escb->source = eina_stringshare_add(source);
|
2003-06-23 19:33:04 -07:00
|
|
|
escb->func = func;
|
|
|
|
escb->data = data;
|
2008-10-22 04:34:42 -07:00
|
|
|
ed->callbacks = eina_list_append(ed->callbacks, escb);
|
2003-06-26 07:04:31 -07:00
|
|
|
if (ed->walking_callbacks)
|
|
|
|
{
|
|
|
|
escb->just_added = 1;
|
|
|
|
ed->just_added_callbacks = 1;
|
|
|
|
}
|
2008-02-26 09:56:51 -08:00
|
|
|
else
|
2008-02-26 12:12:00 -08:00
|
|
|
_edje_callbacks_patterns_clean(ed);
|
2003-06-23 19:33:04 -07:00
|
|
|
}
|
|
|
|
|
2009-09-17 15:38:35 -07:00
|
|
|
/**
|
|
|
|
* @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().
|
|
|
|
*
|
2004-06-05 21:42:17 -07:00
|
|
|
*/
|
2006-01-07 00:54:30 -08:00
|
|
|
EAPI void *
|
2003-07-08 03:08:15 -07:00
|
|
|
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))
|
2003-06-23 19:33:04 -07:00
|
|
|
{
|
|
|
|
Edje *ed;
|
2008-10-22 04:34:42 -07:00
|
|
|
Eina_List *l;
|
|
|
|
Edje_Signal_Callback *escb;
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2003-06-23 19:33:04 -07:00
|
|
|
if ((!emission) || (!source) || (!func)) return NULL;
|
|
|
|
ed = _edje_fetch(obj);
|
2003-10-18 19:11:06 -07:00
|
|
|
if (!ed) return NULL;
|
2003-08-25 17:16:49 -07:00
|
|
|
if (ed->delete_me) return NULL;
|
2008-10-22 04:34:42 -07:00
|
|
|
EINA_LIST_FOREACH(ed->callbacks, l, escb)
|
2003-06-23 19:33:04 -07:00
|
|
|
{
|
2007-09-08 11:31:56 -07:00
|
|
|
if ((escb->func == func) &&
|
2007-02-13 01:58:49 -08:00
|
|
|
((!escb->signal && !emission[0]) ||
|
|
|
|
(escb->signal && !strcmp(escb->signal, emission))) &&
|
|
|
|
((!escb->source && !source[0]) ||
|
|
|
|
(escb->source && !strcmp(escb->source, source))))
|
2003-06-23 19:33:04 -07:00
|
|
|
{
|
|
|
|
void *data;
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2003-06-23 19:33:04 -07:00
|
|
|
data = escb->data;
|
2003-06-26 07:04:31 -07:00
|
|
|
if (ed->walking_callbacks)
|
|
|
|
{
|
|
|
|
escb->delete_me = 1;
|
|
|
|
ed->delete_callbacks = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-02-26 12:12:00 -08:00
|
|
|
_edje_callbacks_patterns_clean(ed);
|
2008-02-21 10:48:36 -08:00
|
|
|
|
2008-10-22 04:34:42 -07:00
|
|
|
ed->callbacks = eina_list_remove_list(ed->callbacks, l);
|
2008-10-15 07:11:11 -07:00
|
|
|
if (escb->signal) eina_stringshare_del(escb->signal);
|
|
|
|
if (escb->source) eina_stringshare_del(escb->source);
|
2003-06-26 07:04:31 -07:00
|
|
|
free(escb);
|
|
|
|
}
|
2003-06-23 19:33:04 -07:00
|
|
|
return data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-09-17 15:38:35 -07:00
|
|
|
/**
|
|
|
|
* @brief Send a signal to an edje object.
|
2004-06-05 21:42:17 -07:00
|
|
|
*
|
2009-09-17 15:38:35 -07:00
|
|
|
* @param obj A valid Evas_Object handle.
|
|
|
|
* @param emission The signal's name.
|
|
|
|
* @param source The signal's source.
|
2007-09-08 11:31:56 -07:00
|
|
|
*
|
2009-09-17 15:38:35 -07:00
|
|
|
* This function sends a signal to the object @a obj. An edje program
|
|
|
|
* can respond to a signal by specifying matching 'signal' and
|
|
|
|
* 'source' fields.
|
2007-04-14 21:05:41 -07:00
|
|
|
*
|
|
|
|
* @code
|
|
|
|
* edje_object_signal_emit(obj, "a_signal", "");
|
|
|
|
* @endcode
|
|
|
|
*
|
2009-09-17 15:38:35 -07:00
|
|
|
* will trigger a program whose EDC block is:
|
2007-04-14 21:05:41 -07:00
|
|
|
*
|
|
|
|
* @code
|
|
|
|
* program {
|
|
|
|
* name: "a_program";
|
|
|
|
* signal: "a_signal";
|
|
|
|
* source: "";
|
|
|
|
* action: ...
|
|
|
|
* }
|
|
|
|
* @endcode
|
2007-05-26 22:28:07 -07:00
|
|
|
*
|
2009-09-17 15:38:35 -07:00
|
|
|
* FIXME: should this signal be sent to children also?
|
2004-06-05 21:42:17 -07:00
|
|
|
*/
|
2006-01-07 00:54:30 -08:00
|
|
|
EAPI void
|
2003-07-08 03:08:15 -07:00
|
|
|
edje_object_signal_emit(Evas_Object *obj, const char *emission, const char *source)
|
2003-06-23 19:33:04 -07:00
|
|
|
{
|
|
|
|
Edje *ed;
|
|
|
|
|
|
|
|
if ((!emission) || (!source)) return;
|
|
|
|
ed = _edje_fetch(obj);
|
|
|
|
if (!ed) return;
|
2003-08-25 17:16:49 -07:00
|
|
|
if (ed->delete_me) return;
|
2003-06-23 19:33:04 -07:00
|
|
|
_edje_emit(ed, (char *)emission, (char *)source);
|
|
|
|
}
|
|
|
|
|
2004-06-05 21:42:17 -07:00
|
|
|
/* FIXDOC: Verify/Expand */
|
2009-09-17 15:38:35 -07:00
|
|
|
/**
|
|
|
|
* @brief Set the edje object to playing or paused states.
|
|
|
|
*
|
|
|
|
* @param obj A valid Evas_Object handle.
|
|
|
|
* @param play Object state (1 to playing, 0 to pauseed).
|
|
|
|
*
|
|
|
|
* 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().
|
2004-06-05 21:42:17 -07:00
|
|
|
*
|
|
|
|
*/
|
2006-01-07 00:54:30 -08:00
|
|
|
EAPI void
|
2003-07-08 03:08:15 -07:00
|
|
|
edje_object_play_set(Evas_Object *obj, int play)
|
2003-07-07 00:55:18 -07:00
|
|
|
{
|
|
|
|
Edje *ed;
|
|
|
|
double t;
|
2008-10-22 04:34:42 -07:00
|
|
|
Eina_List *l;
|
|
|
|
Edje_Running_Program *runp;
|
2007-05-26 22:28:07 -07:00
|
|
|
int i;
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2003-07-07 00:55:18 -07:00
|
|
|
ed = _edje_fetch(obj);
|
|
|
|
if (!ed) return;
|
2003-08-25 17:16:49 -07:00
|
|
|
if (ed->delete_me) return;
|
2003-07-07 00:55:18 -07:00
|
|
|
if (play)
|
|
|
|
{
|
|
|
|
if (!ed->paused) return;
|
|
|
|
ed->paused = 0;
|
|
|
|
t = ecore_time_get() - ed->paused_at;
|
2008-10-22 04:34:42 -07:00
|
|
|
EINA_LIST_FOREACH(ed->actions, l, runp)
|
|
|
|
runp->start_time += t;
|
2003-07-07 00:55:18 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (ed->paused) return;
|
|
|
|
ed->paused = 1;
|
|
|
|
ed->paused_at = ecore_time_get();
|
|
|
|
}
|
2007-05-26 22:28:07 -07:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
2003-07-07 00:55:18 -07:00
|
|
|
}
|
|
|
|
|
2009-09-17 15:38:35 -07:00
|
|
|
/**
|
|
|
|
* @brief Get the edje object's play/pause state.
|
|
|
|
*
|
|
|
|
* @param obj A valid Evas_Object handle.
|
|
|
|
* @return @c 0 if the object is not connected, its @c delete_me flag
|
|
|
|
* is set, or it is at paused state; @c 1 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().
|
|
|
|
*
|
2004-06-05 21:42:17 -07:00
|
|
|
*/
|
2007-09-08 11:31:56 -07:00
|
|
|
EAPI int
|
2008-08-14 11:21:27 -07:00
|
|
|
edje_object_play_get(const Evas_Object *obj)
|
2003-07-07 00:55:18 -07:00
|
|
|
{
|
|
|
|
Edje *ed;
|
|
|
|
|
|
|
|
ed = _edje_fetch(obj);
|
|
|
|
if (!ed) return 0;
|
2003-08-25 17:16:49 -07:00
|
|
|
if (ed->delete_me) return 0;
|
2003-07-07 00:55:18 -07:00
|
|
|
if (ed->paused) return 0;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2004-06-05 21:42:17 -07:00
|
|
|
/* FIXDOC: Verify/Expand */
|
2009-09-17 15:38:35 -07:00
|
|
|
/**
|
|
|
|
* @brief Set the object's animation state.
|
|
|
|
*
|
|
|
|
* @param obj A valid Evas_Object handle.
|
|
|
|
* @param on Animation State.
|
|
|
|
*
|
|
|
|
* This function starts or stops an edje object's animation. The
|
|
|
|
* information if it's runnig can be retrieved by
|
|
|
|
* edje_object_animation_get().
|
|
|
|
*
|
|
|
|
* @see edje_object_animation_get()
|
2004-06-05 21:42:17 -07:00
|
|
|
*
|
|
|
|
*/
|
2006-01-07 00:54:30 -08:00
|
|
|
EAPI void
|
2003-07-08 03:08:15 -07:00
|
|
|
edje_object_animation_set(Evas_Object *obj, int on)
|
2003-07-07 00:55:18 -07:00
|
|
|
{
|
|
|
|
Edje *ed;
|
2008-10-22 04:34:42 -07:00
|
|
|
Eina_List *l;
|
2007-05-26 22:28:07 -07:00
|
|
|
int i;
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2003-07-07 00:55:18 -07:00
|
|
|
ed = _edje_fetch(obj);
|
2007-09-08 11:31:56 -07:00
|
|
|
if (!ed) return;
|
2003-08-25 17:16:49 -07:00
|
|
|
if (ed->delete_me) return;
|
|
|
|
_edje_block(ed);
|
2003-07-07 00:55:18 -07:00
|
|
|
ed->no_anim = !on;
|
|
|
|
_edje_freeze(ed);
|
|
|
|
if (!on)
|
|
|
|
{
|
2008-10-22 04:34:42 -07:00
|
|
|
Eina_List *newl = NULL;
|
|
|
|
const void *data;
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2008-10-22 04:34:42 -07:00
|
|
|
EINA_LIST_FOREACH(ed->actions, l, data)
|
|
|
|
newl = eina_list_append(newl, data);
|
2003-07-07 00:55:18 -07:00
|
|
|
while (newl)
|
|
|
|
{
|
|
|
|
Edje_Running_Program *runp;
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2008-10-22 04:34:42 -07:00
|
|
|
runp = eina_list_data_get(newl);
|
|
|
|
newl = eina_list_remove(newl, eina_list_data_get(newl));
|
2003-07-07 00:55:18 -07:00
|
|
|
_edje_program_run_iterate(runp, runp->start_time + runp->program->tween.time);
|
2003-08-25 17:16:49 -07:00
|
|
|
if (_edje_block_break(ed))
|
|
|
|
{
|
2008-10-22 04:34:42 -07:00
|
|
|
eina_list_free(newl);
|
2003-08-25 17:16:49 -07:00
|
|
|
goto break_prog;
|
|
|
|
}
|
2003-07-07 00:55:18 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-11-23 04:56:06 -08:00
|
|
|
_edje_emit(ed, "load", NULL);
|
2003-07-07 00:55:18 -07:00
|
|
|
if (evas_object_visible_get(obj))
|
|
|
|
{
|
|
|
|
evas_object_hide(obj);
|
|
|
|
evas_object_show(obj);
|
|
|
|
}
|
|
|
|
}
|
2003-08-25 17:16:49 -07:00
|
|
|
break_prog:
|
2007-05-26 22:28:07 -07:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2003-07-07 00:55:18 -07:00
|
|
|
_edje_thaw(ed);
|
2003-08-25 17:16:49 -07:00
|
|
|
_edje_unblock(ed);
|
2003-07-07 00:55:18 -07:00
|
|
|
}
|
|
|
|
|
2009-09-17 15:38:35 -07:00
|
|
|
/**
|
|
|
|
* @brief Get the edje object's animation state.
|
|
|
|
*
|
|
|
|
* @param obj A valid Evas_Object handle.
|
|
|
|
* @return @c 0 on error or if object is not animated; @c 1 if animated.
|
|
|
|
*
|
|
|
|
* This function returns if the animation is playing or not. The
|
|
|
|
* animation state is set by edje_object_play_set().
|
|
|
|
*
|
|
|
|
* @see edje_object_animation_set().
|
|
|
|
*
|
2004-06-05 21:42:17 -07:00
|
|
|
*/
|
2009-09-17 15:38:35 -07:00
|
|
|
|
2006-01-07 00:54:30 -08:00
|
|
|
EAPI int
|
2008-08-14 11:21:27 -07:00
|
|
|
edje_object_animation_get(const Evas_Object *obj)
|
2003-07-07 00:55:18 -07:00
|
|
|
{
|
|
|
|
Edje *ed;
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2003-07-07 00:55:18 -07:00
|
|
|
ed = _edje_fetch(obj);
|
|
|
|
if (!ed) return 0;
|
2003-08-25 17:16:49 -07:00
|
|
|
if (ed->delete_me) return 0;
|
2003-07-07 00:55:18 -07:00
|
|
|
if (ed->no_anim) return 0;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2003-06-23 19:33:04 -07:00
|
|
|
/* Private Routines */
|
|
|
|
|
|
|
|
int
|
|
|
|
_edje_program_run_iterate(Edje_Running_Program *runp, double tim)
|
|
|
|
{
|
|
|
|
double t, total;
|
2008-10-22 04:34:42 -07:00
|
|
|
Eina_List *l;
|
2003-08-25 17:16:49 -07:00
|
|
|
Edje *ed;
|
2008-10-22 04:34:42 -07:00
|
|
|
Edje_Program_Target *pt;
|
|
|
|
Edje_Real_Part *rp;
|
2003-06-23 19:33:04 -07:00
|
|
|
|
2003-08-25 17:16:49 -07:00
|
|
|
ed = runp->edje;
|
|
|
|
if (ed->delete_me) return 0;
|
|
|
|
_edje_block(ed);
|
|
|
|
_edje_ref(ed);
|
|
|
|
_edje_freeze(ed);
|
2003-06-23 19:33:04 -07:00
|
|
|
t = tim - runp->start_time;
|
|
|
|
total = runp->program->tween.time;
|
|
|
|
t /= total;
|
|
|
|
if (t > 1.0) t = 1.0;
|
2008-10-22 04:34:42 -07:00
|
|
|
EINA_LIST_FOREACH(runp->program->targets, l, pt)
|
2003-06-23 19:33:04 -07:00
|
|
|
{
|
2004-04-01 07:32:17 -08:00
|
|
|
if (pt->id >= 0)
|
|
|
|
{
|
|
|
|
rp = ed->table_parts[pt->id % ed->table_parts_size];
|
2007-09-08 11:31:56 -07:00
|
|
|
if (rp) _edje_part_pos_set(ed, rp,
|
2004-04-01 07:32:17 -08:00
|
|
|
runp->program->tween.mode, t);
|
|
|
|
}
|
2003-06-23 19:33:04 -07:00
|
|
|
}
|
|
|
|
if (t >= 1.0)
|
|
|
|
{
|
2008-10-22 04:34:42 -07:00
|
|
|
Edje_Program_After *pa;
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2008-10-22 04:34:42 -07:00
|
|
|
EINA_LIST_FOREACH(runp->program->targets, l, pt)
|
|
|
|
{
|
2004-04-01 07:32:17 -08:00
|
|
|
if (pt->id >= 0)
|
2003-06-23 19:33:04 -07:00
|
|
|
{
|
2004-04-01 07:32:17 -08:00
|
|
|
rp = ed->table_parts[pt->id % ed->table_parts_size];
|
|
|
|
if (rp)
|
|
|
|
{
|
2007-09-08 11:31:56 -07:00
|
|
|
_edje_part_description_apply(ed, rp,
|
|
|
|
runp->program->state,
|
2004-04-01 07:32:17 -08:00
|
|
|
runp->program->value,
|
|
|
|
NULL,
|
|
|
|
0.0);
|
2007-09-08 11:31:56 -07:00
|
|
|
_edje_part_pos_set(ed, rp,
|
2004-04-01 07:32:17 -08:00
|
|
|
runp->program->tween.mode, 0.0);
|
|
|
|
rp->program = NULL;
|
|
|
|
}
|
2003-06-23 19:33:04 -07:00
|
|
|
}
|
|
|
|
}
|
2003-08-25 17:16:49 -07:00
|
|
|
_edje_recalc(ed);
|
2003-08-13 04:03:20 -07:00
|
|
|
runp->delete_me = 1;
|
2003-08-25 17:16:49 -07:00
|
|
|
if (!ed->walking_actions)
|
2003-08-13 04:03:20 -07:00
|
|
|
{
|
|
|
|
_edje_anim_count--;
|
2008-10-22 04:34:42 -07:00
|
|
|
ed->actions = eina_list_remove(ed->actions, runp);
|
2003-08-25 17:16:49 -07:00
|
|
|
if (!ed->actions)
|
2008-10-22 04:34:42 -07:00
|
|
|
_edje_animators = eina_list_remove(_edje_animators, ed);
|
2003-08-13 04:03:20 -07:00
|
|
|
}
|
2008-09-17 18:48:17 -07:00
|
|
|
// _edje_emit(ed, "program,stop", runp->program->name);
|
2004-02-05 19:40:15 -08:00
|
|
|
if (_edje_block_break(ed))
|
|
|
|
{
|
|
|
|
if (!ed->walking_actions) free(runp);
|
|
|
|
goto break_prog;
|
|
|
|
}
|
2008-10-22 04:34:42 -07:00
|
|
|
EINA_LIST_FOREACH(runp->program->after, l, pa)
|
2003-06-23 19:33:04 -07:00
|
|
|
{
|
|
|
|
Edje_Program *pr;
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2004-03-07 18:43:48 -08:00
|
|
|
if (pa->id >= 0)
|
2004-02-05 19:40:15 -08:00
|
|
|
{
|
2004-04-01 07:32:17 -08:00
|
|
|
pr = ed->table_programs[pa->id % ed->table_programs_size];
|
2004-03-27 21:26:17 -08:00
|
|
|
if (pr) _edje_program_run(ed, pr, 0, "", "");
|
2004-03-16 00:38:51 -08:00
|
|
|
if (_edje_block_break(ed))
|
|
|
|
{
|
|
|
|
if (!ed->walking_actions) free(runp);
|
|
|
|
goto break_prog;
|
|
|
|
}
|
2004-02-05 19:40:15 -08:00
|
|
|
}
|
2003-06-23 19:33:04 -07:00
|
|
|
}
|
2003-08-25 17:16:49 -07:00
|
|
|
_edje_thaw(ed);
|
|
|
|
_edje_unref(ed);
|
|
|
|
if (!ed->walking_actions) free(runp);
|
|
|
|
_edje_unblock(ed);
|
2003-06-23 19:33:04 -07:00
|
|
|
return 0;
|
|
|
|
}
|
2003-08-25 17:16:49 -07:00
|
|
|
break_prog:
|
|
|
|
_edje_recalc(ed);
|
|
|
|
_edje_thaw(ed);
|
|
|
|
_edje_unref(ed);
|
|
|
|
_edje_unblock(ed);
|
2003-06-23 19:33:04 -07:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_edje_program_end(Edje *ed, Edje_Running_Program *runp)
|
|
|
|
{
|
2008-10-22 04:34:42 -07:00
|
|
|
Eina_List *l;
|
|
|
|
Edje_Program_Target *pt;
|
2008-03-12 23:38:16 -07:00
|
|
|
const char *pname = NULL;
|
2005-10-04 10:54:36 -07:00
|
|
|
int free_runp = 0;
|
2003-06-23 19:33:04 -07:00
|
|
|
|
2003-08-25 17:16:49 -07:00
|
|
|
if (ed->delete_me) return;
|
|
|
|
_edje_ref(ed);
|
|
|
|
_edje_freeze(ed);
|
2008-10-22 04:34:42 -07:00
|
|
|
EINA_LIST_FOREACH(runp->program->targets, l, pt)
|
2003-06-23 19:33:04 -07:00
|
|
|
{
|
|
|
|
Edje_Real_Part *rp;
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2004-04-01 07:32:17 -08:00
|
|
|
if (pt->id >= 0)
|
2003-06-23 19:33:04 -07:00
|
|
|
{
|
2004-04-01 07:32:17 -08:00
|
|
|
rp = ed->table_parts[pt->id % ed->table_parts_size];
|
|
|
|
if (rp)
|
|
|
|
{
|
2007-09-08 11:31:56 -07:00
|
|
|
_edje_part_description_apply(ed, rp,
|
|
|
|
runp->program->state,
|
2004-04-01 07:32:17 -08:00
|
|
|
runp->program->value,
|
|
|
|
NULL,
|
|
|
|
0.0);
|
2007-09-08 11:31:56 -07:00
|
|
|
_edje_part_pos_set(ed, rp,
|
2004-04-01 07:32:17 -08:00
|
|
|
runp->program->tween.mode, 0.0);
|
|
|
|
rp->program = NULL;
|
|
|
|
}
|
2003-06-23 19:33:04 -07:00
|
|
|
}
|
|
|
|
}
|
2003-08-25 17:16:49 -07:00
|
|
|
_edje_recalc(ed);
|
2003-08-13 04:03:20 -07:00
|
|
|
runp->delete_me = 1;
|
2003-08-25 17:16:49 -07:00
|
|
|
pname = runp->program->name;
|
|
|
|
if (!ed->walking_actions)
|
2003-08-13 04:03:20 -07:00
|
|
|
{
|
|
|
|
_edje_anim_count--;
|
2008-10-22 04:34:42 -07:00
|
|
|
ed->actions = eina_list_remove(ed->actions, runp);
|
2005-10-04 10:54:36 -07:00
|
|
|
free_runp = 1;
|
2003-08-25 17:16:49 -07:00
|
|
|
if (!ed->actions)
|
|
|
|
{
|
2008-10-22 04:34:42 -07:00
|
|
|
_edje_animators = eina_list_remove(_edje_animators, ed);
|
2003-08-25 17:16:49 -07:00
|
|
|
}
|
2003-08-13 04:03:20 -07:00
|
|
|
}
|
2008-09-17 18:48:17 -07:00
|
|
|
// _edje_emit(ed, "program,stop", pname);
|
2003-08-25 17:16:49 -07:00
|
|
|
_edje_thaw(ed);
|
2007-09-08 11:31:56 -07:00
|
|
|
_edje_unref(ed);
|
2005-10-04 10:54:36 -07:00
|
|
|
if (free_runp) free(runp);
|
2003-06-23 19:33:04 -07:00
|
|
|
}
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2003-06-23 19:33:04 -07:00
|
|
|
void
|
2006-03-18 20:22:35 -08:00
|
|
|
_edje_program_run(Edje *ed, Edje_Program *pr, int force, const char *ssig, const char *ssrc)
|
2003-06-23 19:33:04 -07:00
|
|
|
{
|
2008-10-22 04:34:42 -07:00
|
|
|
Eina_List *l;
|
|
|
|
Edje_Real_Part *rp;
|
|
|
|
Edje_Program_Target *pt;
|
|
|
|
Edje_Program *pr2;
|
|
|
|
Edje_Program_After *pa;
|
2003-06-27 20:08:25 -07:00
|
|
|
/* limit self-feeding loops in programs to 64 levels */
|
|
|
|
static int recursions = 0;
|
|
|
|
static int recursion_limit = 0;
|
2003-06-23 19:33:04 -07:00
|
|
|
|
2003-08-25 17:16:49 -07:00
|
|
|
if (ed->delete_me) return;
|
2003-08-05 04:51:28 -07:00
|
|
|
if ((pr->in.from > 0.0) && (pr->in.range >= 0.0) && (!force))
|
2003-06-27 21:20:41 -07:00
|
|
|
{
|
|
|
|
Edje_Pending_Program *pp;
|
2003-08-05 04:51:28 -07:00
|
|
|
double r = 0.0;
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2003-06-27 21:20:41 -07:00
|
|
|
pp = calloc(1, sizeof(Edje_Pending_Program));
|
|
|
|
if (!pp) return;
|
|
|
|
if (pr->in.range > 0.0) r = ((double)rand() / RAND_MAX);
|
2007-09-08 11:31:56 -07:00
|
|
|
pp->timer = ecore_timer_add(pr->in.from + (pr->in.range * r),
|
2003-06-27 21:20:41 -07:00
|
|
|
_edje_pending_timer_cb, pp);
|
|
|
|
if (!pp->timer)
|
|
|
|
{
|
|
|
|
free(pp);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
pp->edje = ed;
|
|
|
|
pp->program = pr;
|
2008-10-22 04:34:42 -07:00
|
|
|
ed->pending_actions = eina_list_append(ed->pending_actions, pp);
|
2003-06-27 21:20:41 -07:00
|
|
|
return;
|
|
|
|
}
|
2003-06-27 20:08:25 -07:00
|
|
|
if ((recursions >= 64) || (recursion_limit))
|
|
|
|
{
|
2003-08-05 15:56:29 -07:00
|
|
|
printf("EDJE ERROR: programs recursing up to recursion limit of %i. Disabled.\n",
|
|
|
|
64);
|
2003-06-27 20:08:25 -07:00
|
|
|
recursion_limit = 1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
recursions++;
|
2003-08-25 17:16:49 -07:00
|
|
|
_edje_block(ed);
|
2003-06-26 07:04:31 -07:00
|
|
|
_edje_ref(ed);
|
2003-08-25 17:16:49 -07:00
|
|
|
_edje_freeze(ed);
|
2003-06-23 19:33:04 -07:00
|
|
|
if (pr->action == EDJE_ACTION_TYPE_STATE_SET)
|
|
|
|
{
|
2003-07-07 00:55:18 -07:00
|
|
|
if ((pr->tween.time > 0.0) && (!ed->no_anim))
|
2003-06-23 19:33:04 -07:00
|
|
|
{
|
|
|
|
Edje_Running_Program *runp;
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2003-06-23 19:33:04 -07:00
|
|
|
runp = calloc(1, sizeof(Edje_Running_Program));
|
2008-10-22 04:34:42 -07:00
|
|
|
EINA_LIST_FOREACH(pr->targets, l, pt)
|
2003-06-23 19:33:04 -07:00
|
|
|
{
|
2004-04-01 07:32:17 -08:00
|
|
|
if (pt->id >= 0)
|
2003-06-23 19:33:04 -07:00
|
|
|
{
|
2004-04-01 07:32:17 -08:00
|
|
|
rp = ed->table_parts[pt->id % ed->table_parts_size];
|
|
|
|
if (rp)
|
|
|
|
{
|
|
|
|
if (rp->program)
|
|
|
|
_edje_program_end(ed, rp->program);
|
2007-09-08 11:31:56 -07:00
|
|
|
_edje_part_description_apply(ed, rp,
|
2004-04-01 07:32:17 -08:00
|
|
|
rp->param1.description->state.name,
|
2007-09-08 11:31:56 -07:00
|
|
|
rp->param1.description->state.value,
|
|
|
|
pr->state,
|
2004-04-01 07:32:17 -08:00
|
|
|
pr->value);
|
|
|
|
_edje_part_pos_set(ed, rp, pr->tween.mode, 0.0);
|
|
|
|
rp->program = runp;
|
|
|
|
}
|
2003-06-23 19:33:04 -07:00
|
|
|
}
|
|
|
|
}
|
2008-09-17 18:48:17 -07:00
|
|
|
// _edje_emit(ed, "program,start", pr->name);
|
2004-03-07 18:43:48 -08:00
|
|
|
if (_edje_block_break(ed))
|
|
|
|
{
|
2008-10-22 04:34:42 -07:00
|
|
|
ed->actions = eina_list_append(ed->actions, runp);
|
2004-03-07 18:43:48 -08:00
|
|
|
goto break_prog;
|
|
|
|
}
|
2003-06-23 19:33:04 -07:00
|
|
|
if (!ed->actions)
|
2008-10-22 04:34:42 -07:00
|
|
|
_edje_animators = eina_list_append(_edje_animators, ed);
|
|
|
|
ed->actions = eina_list_append(ed->actions, runp);
|
2008-11-01 19:43:43 -07:00
|
|
|
runp->start_time = ecore_loop_time_get();
|
2003-06-23 19:33:04 -07:00
|
|
|
runp->edje = ed;
|
|
|
|
runp->program = pr;
|
|
|
|
if (!_edje_timer)
|
2004-09-05 01:11:36 -07:00
|
|
|
_edje_timer = ecore_animator_add(_edje_timer_cb, NULL);
|
2003-06-23 19:33:04 -07:00
|
|
|
_edje_anim_count++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-10-22 04:34:42 -07:00
|
|
|
EINA_LIST_FOREACH(pr->targets, l, pt)
|
2003-06-23 19:33:04 -07:00
|
|
|
{
|
2004-04-01 07:32:17 -08:00
|
|
|
if (pt->id >= 0)
|
2003-06-23 19:33:04 -07:00
|
|
|
{
|
2004-04-01 07:32:17 -08:00
|
|
|
rp = ed->table_parts[pt->id % ed->table_parts_size];
|
|
|
|
if (rp)
|
|
|
|
{
|
|
|
|
if (rp->program)
|
|
|
|
_edje_program_end(ed, rp->program);
|
2007-09-08 11:31:56 -07:00
|
|
|
_edje_part_description_apply(ed, rp,
|
|
|
|
pr->state,
|
2004-04-01 07:32:17 -08:00
|
|
|
pr->value,
|
|
|
|
NULL,
|
|
|
|
0.0);
|
|
|
|
_edje_part_pos_set(ed, rp, pr->tween.mode, 0.0);
|
|
|
|
}
|
2003-06-23 19:33:04 -07:00
|
|
|
}
|
|
|
|
}
|
2008-09-17 18:48:17 -07:00
|
|
|
// _edje_emit(ed, "program,start", pr->name);
|
2003-08-25 17:16:49 -07:00
|
|
|
if (_edje_block_break(ed)) goto break_prog;
|
2008-09-17 18:48:17 -07:00
|
|
|
// _edje_emit(ed, "program,stop", pr->name);
|
2003-08-25 17:16:49 -07:00
|
|
|
if (_edje_block_break(ed)) goto break_prog;
|
2004-03-07 18:43:48 -08:00
|
|
|
|
2008-10-22 04:34:42 -07:00
|
|
|
EINA_LIST_FOREACH(pr->after, l, pa)
|
2003-08-08 00:45:39 -07:00
|
|
|
{
|
2004-03-07 18:43:48 -08:00
|
|
|
if (pa->id >= 0)
|
|
|
|
{
|
2004-04-01 07:32:17 -08:00
|
|
|
pr2 = ed->table_programs[pa->id % ed->table_programs_size];
|
2004-03-27 21:26:17 -08:00
|
|
|
if (pr2) _edje_program_run(ed, pr2, 0, "", "");
|
2004-03-07 18:43:48 -08:00
|
|
|
if (_edje_block_break(ed)) goto break_prog;
|
|
|
|
}
|
2003-08-08 00:45:39 -07:00
|
|
|
}
|
2003-06-23 19:33:04 -07:00
|
|
|
_edje_recalc(ed);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (pr->action == EDJE_ACTION_TYPE_ACTION_STOP)
|
|
|
|
{
|
2008-09-17 18:48:17 -07:00
|
|
|
// _edje_emit(ed, "program,start", pr->name);
|
2008-10-22 04:34:42 -07:00
|
|
|
EINA_LIST_FOREACH(pr->targets, l, pt)
|
2003-06-23 19:33:04 -07:00
|
|
|
{
|
2008-10-22 04:34:42 -07:00
|
|
|
Eina_List *ll;
|
|
|
|
Edje_Running_Program *runp;
|
|
|
|
Edje_Pending_Program *pp;
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2008-10-22 04:34:42 -07:00
|
|
|
EINA_LIST_FOREACH(ed->actions, ll, runp)
|
2003-06-23 19:33:04 -07:00
|
|
|
{
|
|
|
|
if (pt->id == runp->program->id)
|
|
|
|
{
|
|
|
|
_edje_program_end(ed, runp);
|
2009-04-01 02:11:48 -07:00
|
|
|
// goto done;
|
2003-06-23 19:33:04 -07:00
|
|
|
}
|
|
|
|
}
|
2008-10-22 04:34:42 -07:00
|
|
|
EINA_LIST_FOREACH(ed->pending_actions, ll, pp)
|
2003-08-04 20:15:12 -07:00
|
|
|
{
|
|
|
|
if (pt->id == pp->program->id)
|
|
|
|
{
|
2008-10-22 04:34:42 -07:00
|
|
|
ed->pending_actions = eina_list_remove(ed->pending_actions, pp);
|
2003-08-04 20:15:12 -07:00
|
|
|
ecore_timer_del(pp->timer);
|
|
|
|
free(pp);
|
2009-04-01 02:11:48 -07:00
|
|
|
// goto done;
|
2003-08-04 20:15:12 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
done:
|
2004-01-17 05:09:35 -08:00
|
|
|
continue;
|
2003-06-23 19:33:04 -07:00
|
|
|
}
|
2008-09-17 18:48:17 -07:00
|
|
|
// _edje_emit(ed, "program,stop", pr->name);
|
2003-08-25 17:16:49 -07:00
|
|
|
if (_edje_block_break(ed)) goto break_prog;
|
2003-06-23 19:33:04 -07:00
|
|
|
}
|
|
|
|
else if (pr->action == EDJE_ACTION_TYPE_SIGNAL_EMIT)
|
|
|
|
{
|
2008-09-17 18:48:17 -07:00
|
|
|
// _edje_emit(ed, "program,start", pr->name);
|
2003-08-25 17:16:49 -07:00
|
|
|
if (_edje_block_break(ed)) goto break_prog;
|
2003-06-23 19:33:04 -07:00
|
|
|
_edje_emit(ed, pr->state, pr->state2);
|
2003-08-25 17:16:49 -07:00
|
|
|
if (_edje_block_break(ed)) goto break_prog;
|
2008-09-17 18:48:17 -07:00
|
|
|
// _edje_emit(ed, "program,stop", pr->name);
|
2003-08-25 17:16:49 -07:00
|
|
|
if (_edje_block_break(ed)) goto break_prog;
|
2003-08-05 04:51:28 -07:00
|
|
|
}
|
2003-08-31 19:53:08 -07:00
|
|
|
else if (pr->action == EDJE_ACTION_TYPE_DRAG_VAL_SET)
|
|
|
|
{
|
2008-09-17 18:48:17 -07:00
|
|
|
// _edje_emit(ed, "program,start", pr->name);
|
2003-08-31 19:53:08 -07:00
|
|
|
if (_edje_block_break(ed)) goto break_prog;
|
2008-10-22 04:34:42 -07:00
|
|
|
EINA_LIST_FOREACH(pr->targets, l, pt)
|
2003-08-31 19:53:08 -07:00
|
|
|
{
|
2004-04-01 07:32:17 -08:00
|
|
|
if (pt->id >= 0)
|
2003-08-31 19:53:08 -07:00
|
|
|
{
|
2004-04-01 07:32:17 -08:00
|
|
|
rp = ed->table_parts[pt->id % ed->table_parts_size];
|
2009-08-11 05:47:00 -07:00
|
|
|
if ((rp) && (rp->drag) && (rp->drag->down.count == 0))
|
2004-04-01 07:32:17 -08:00
|
|
|
{
|
2009-08-11 05:47:00 -07:00
|
|
|
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);
|
2004-04-01 07:32:17 -08:00
|
|
|
_edje_emit(ed, "drag,set", rp->part->name);
|
|
|
|
if (_edje_block_break(ed)) goto break_prog;
|
|
|
|
}
|
2003-08-31 19:53:08 -07:00
|
|
|
}
|
|
|
|
}
|
2008-09-17 18:48:17 -07:00
|
|
|
// _edje_emit(ed, "program,stop", pr->name);
|
2003-08-31 19:53:08 -07:00
|
|
|
if (_edje_block_break(ed)) goto break_prog;
|
|
|
|
}
|
|
|
|
else if (pr->action == EDJE_ACTION_TYPE_DRAG_VAL_STEP)
|
|
|
|
{
|
2008-09-17 18:48:17 -07:00
|
|
|
// _edje_emit(ed, "program,start", pr->name);
|
2003-08-31 19:53:08 -07:00
|
|
|
if (_edje_block_break(ed)) goto break_prog;
|
2008-10-22 04:34:42 -07:00
|
|
|
EINA_LIST_FOREACH(pr->targets, l, pt)
|
2003-08-31 19:53:08 -07:00
|
|
|
{
|
2004-04-01 07:32:17 -08:00
|
|
|
if (pt->id >= 0)
|
2003-08-31 19:53:08 -07:00
|
|
|
{
|
2004-04-01 07:32:17 -08:00
|
|
|
rp = ed->table_parts[pt->id % ed->table_parts_size];
|
2009-08-11 05:47:00 -07:00
|
|
|
if ((rp) && (rp->drag) && (rp->drag->down.count == 0))
|
2004-04-01 07:32:17 -08:00
|
|
|
{
|
2009-08-11 05:47:00 -07:00
|
|
|
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);
|
2004-04-01 07:32:17 -08:00
|
|
|
_edje_emit(ed, "drag,step", rp->part->name);
|
|
|
|
if (_edje_block_break(ed)) goto break_prog;
|
|
|
|
}
|
2003-08-31 19:53:08 -07:00
|
|
|
}
|
|
|
|
}
|
2008-09-17 18:48:17 -07:00
|
|
|
// _edje_emit(ed, "program,stop", pr->name);
|
2003-08-31 19:53:08 -07:00
|
|
|
if (_edje_block_break(ed)) goto break_prog;
|
|
|
|
}
|
|
|
|
else if (pr->action == EDJE_ACTION_TYPE_DRAG_VAL_PAGE)
|
|
|
|
{
|
2008-09-17 18:48:17 -07:00
|
|
|
// _edje_emit(ed, "program,start", pr->name);
|
2003-08-31 19:53:08 -07:00
|
|
|
if (_edje_block_break(ed)) goto break_prog;
|
2008-10-22 04:34:42 -07:00
|
|
|
EINA_LIST_FOREACH(pr->targets, l, pt)
|
2003-08-31 19:53:08 -07:00
|
|
|
{
|
2004-04-01 07:32:17 -08:00
|
|
|
if (pt->id >= 0)
|
2003-08-31 19:53:08 -07:00
|
|
|
{
|
2004-04-01 07:32:17 -08:00
|
|
|
rp = ed->table_parts[pt->id % ed->table_parts_size];
|
2009-08-11 05:47:00 -07:00
|
|
|
if ((rp) && (rp->drag) && (rp->drag->down.count == 0))
|
2004-04-01 07:32:17 -08:00
|
|
|
{
|
2009-08-11 05:47:00 -07:00
|
|
|
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);
|
2004-04-01 07:32:17 -08:00
|
|
|
_edje_emit(ed, "drag,page", rp->part->name);
|
|
|
|
if (_edje_block_break(ed)) goto break_prog;
|
|
|
|
}
|
2003-08-31 19:53:08 -07:00
|
|
|
}
|
|
|
|
}
|
2008-09-17 18:48:17 -07:00
|
|
|
// _edje_emit(ed, "program,stop", pr->name);
|
2003-08-31 19:53:08 -07:00
|
|
|
if (_edje_block_break(ed)) goto break_prog;
|
|
|
|
}
|
2004-03-27 21:26:17 -08:00
|
|
|
else if (pr->action == EDJE_ACTION_TYPE_SCRIPT)
|
|
|
|
{
|
|
|
|
char fname[128];
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2008-09-17 18:48:17 -07:00
|
|
|
// _edje_emit(ed, "program,start", pr->name);
|
2004-03-27 21:26:17 -08:00
|
|
|
if (_edje_block_break(ed)) goto break_prog;
|
|
|
|
snprintf(fname, sizeof(fname), "_p%i", pr->id);
|
|
|
|
_edje_embryo_test_run(ed, fname, ssig, ssrc);
|
2008-09-17 18:48:17 -07:00
|
|
|
// _edje_emit(ed, "program,stop", pr->name);
|
From: "Hanspeter Portner" <ventosus@airpost.net>
This concerns Ticket #109: Add Lua support for Edje
It adds Lua as scripting facility to Edje, letting Embryo untouched.
It should be easier to use and be more flexible than Embryo, imho ;-)
---
The patch
---
Lua 5.1 is used in sandboxed mode. Lua byte code is not
platform/architecture independent, Lua code is saved as text in the Edje
container and parsed at load time, therefore.
The patch goes in two directions
1) Analogous to Embryo for scripting logic, messaging and custom states.
The same things are implemented as in Embryo:
- messaging from and to C
- manual creation of timers, animators, pollers for custom events /
animations
- manual manipulation of Edje parts by means of the public
edje_object_part_* and internal functions and custom states
-> those routines are actually implemented as Lua
bindings to
functions in Edje.h and Ecore.h
-> the implementation is done in an object oriented way, so that the
interface gives the feel of an object description language, pretty
similar to EDC itself
-> combining custom states and custom animators allows
for fancy
animations and transitions, e.g circular/spline translations or
complex/conditional transitions, etc.
-> this is just the same as Embryo does, but implemented in Lua, so
nothing new here, actually
2) Dynamic object creation and manipulation
- this interface stems from the 'script_only' objects in
Edje. Those
objects are a kind of scriptable Edje counterparts to Evas_Smart
objects. The infrastructure for Embryo is already there, but has
never been used
- I added this in Lua and added some first bindings to
experiment
with
- I thought it would be useful to allow for a limited dynamic
creation of ui parts
- We can create instances of groups from within the same Edje
container and use them just like the main Edje object as
stated in
1)
- And there are some stand-alone bindings to dynamically create
Evas_Image, Evas_Table, Evas_Line, Evas_Polygon as examples
-> this may be useful to decouple the program from the ui
even more,
to be able to do things that have to be done in the program itself
atm, but actually belong to the user interface, but need dynamic
creation of objects or complex interactions
-> those objects are manipulated manually with Lua bindings
to the
corresponding edje_object_* and evas_object_* functions
---
Discussion points
---
Both stuff in 1) & 2) is functioning, but needs testing, feedback,
improvements, ...
Stuff in 1) can already fully replace Embryo scripting with Lua
scripting. There still is space for improvements/additions, though.
Of the stuff in 2), I think it may only make sense to add the dynamic
creation of groups defined in the same Edje container. Dynamic creation
of other Evas_Objects makes not much sense, as most of them can already
be used as Edje parts and be manipulated with custom states (apart from
polygons and lines) and it would make the whole theming potentially more
programing-like and much more susceptible for errors, etc.
Would this be useful, or drop it all?
The scripting should be there just for logic, conditionals, custom
states and animations, not for a whole dynamic canvas, imho.
There is a patch around with EXTERNAL Edje parts. Seems to be a better,
faster, more secure way to extend Edje with custom objects.
There would be the possibility of precompiling Lua code at compile time
(edje_cc) for faster loading, but we would have to patch and run our own
Lua version.
The Lua parser is pretty fast, though, and using
byte-converted/endianness-swapped byte-code does only pay off for Lua
chunks of some kilo lines.
Byte code also occupies much more space than text in the final Edje
container, as it includes debug symbols.
---
Cedric and Vincent told me, that the plan was to replace Embryo totally
by Lua before the official release of Edje at the end of the year? So it
would make sense to bring Lua to svn soon and look how it fits in, test,
debug, adapt it further to the themers needs, decide on its final shape,
GATHER SOME PEOPLE TO HELP ;-)
---
The Lua enhanced Edje is in sync with svn and can be get directly here
git clone git://repo.or.cz/edje_lua.git
cd edje_lua
git checkout -b lua_patch origin/lua_patch
or apply the attached patch
There are also some examples to show the usage of the things
mentioned
above
- showcase.edj: shows usage of custom animators, custom states,
messaging and the script_only object
- test.edj: test cases of script usage and bindings (custom states,
custom transitions, tween_states, animators, timers,
object_parts),
but most of it are experimental script_only objects
http://didgmo.sourceforge.net/showcase.edj
http://didgmo.sourceforge.net/test.edj
The source of showcase.edc is attached, too, to just have a glimpse at
Lua inside of EDC
---
So, what do you guys think?
Thanks and sry for the looong mail, hehe ;-)
SVN revision: 41802
2009-08-15 19:34:02 -07:00
|
|
|
if (_edje_block_break(ed)) goto break_prog;
|
|
|
|
_edje_recalc_do(ed);
|
|
|
|
}
|
|
|
|
else if (pr->action == EDJE_ACTION_TYPE_LUA_SCRIPT)
|
|
|
|
{
|
|
|
|
//printf ("running Lua program script %i\n", pr->id);
|
|
|
|
|
|
|
|
// _edje_emit(ed, "program,start", pr->name);
|
|
|
|
if (_edje_block_break(ed)) goto break_prog;
|
|
|
|
|
|
|
|
if (ed->L == NULL) /* private state does not yet exist, create it */
|
|
|
|
{
|
|
|
|
ed->L = _edje_lua_new_thread(ed->collection->L);
|
|
|
|
_edje_lua_new_reg(ed->collection->L, -1, ed->L); // freed in edje_load.c::_edje_file_del
|
|
|
|
lua_pop(ed->collection->L, 1);
|
|
|
|
}
|
|
|
|
lua_State *L = ed->L;
|
|
|
|
lua_pushnumber(L, pr->id);
|
|
|
|
lua_gettable(L, LUA_GLOBALSINDEX);
|
|
|
|
if (!lua_isnil(L, -1))
|
|
|
|
{
|
2009-08-17 04:32:56 -07:00
|
|
|
int err_code;
|
|
|
|
|
From: "Hanspeter Portner" <ventosus@airpost.net>
This concerns Ticket #109: Add Lua support for Edje
It adds Lua as scripting facility to Edje, letting Embryo untouched.
It should be easier to use and be more flexible than Embryo, imho ;-)
---
The patch
---
Lua 5.1 is used in sandboxed mode. Lua byte code is not
platform/architecture independent, Lua code is saved as text in the Edje
container and parsed at load time, therefore.
The patch goes in two directions
1) Analogous to Embryo for scripting logic, messaging and custom states.
The same things are implemented as in Embryo:
- messaging from and to C
- manual creation of timers, animators, pollers for custom events /
animations
- manual manipulation of Edje parts by means of the public
edje_object_part_* and internal functions and custom states
-> those routines are actually implemented as Lua
bindings to
functions in Edje.h and Ecore.h
-> the implementation is done in an object oriented way, so that the
interface gives the feel of an object description language, pretty
similar to EDC itself
-> combining custom states and custom animators allows
for fancy
animations and transitions, e.g circular/spline translations or
complex/conditional transitions, etc.
-> this is just the same as Embryo does, but implemented in Lua, so
nothing new here, actually
2) Dynamic object creation and manipulation
- this interface stems from the 'script_only' objects in
Edje. Those
objects are a kind of scriptable Edje counterparts to Evas_Smart
objects. The infrastructure for Embryo is already there, but has
never been used
- I added this in Lua and added some first bindings to
experiment
with
- I thought it would be useful to allow for a limited dynamic
creation of ui parts
- We can create instances of groups from within the same Edje
container and use them just like the main Edje object as
stated in
1)
- And there are some stand-alone bindings to dynamically create
Evas_Image, Evas_Table, Evas_Line, Evas_Polygon as examples
-> this may be useful to decouple the program from the ui
even more,
to be able to do things that have to be done in the program itself
atm, but actually belong to the user interface, but need dynamic
creation of objects or complex interactions
-> those objects are manipulated manually with Lua bindings
to the
corresponding edje_object_* and evas_object_* functions
---
Discussion points
---
Both stuff in 1) & 2) is functioning, but needs testing, feedback,
improvements, ...
Stuff in 1) can already fully replace Embryo scripting with Lua
scripting. There still is space for improvements/additions, though.
Of the stuff in 2), I think it may only make sense to add the dynamic
creation of groups defined in the same Edje container. Dynamic creation
of other Evas_Objects makes not much sense, as most of them can already
be used as Edje parts and be manipulated with custom states (apart from
polygons and lines) and it would make the whole theming potentially more
programing-like and much more susceptible for errors, etc.
Would this be useful, or drop it all?
The scripting should be there just for logic, conditionals, custom
states and animations, not for a whole dynamic canvas, imho.
There is a patch around with EXTERNAL Edje parts. Seems to be a better,
faster, more secure way to extend Edje with custom objects.
There would be the possibility of precompiling Lua code at compile time
(edje_cc) for faster loading, but we would have to patch and run our own
Lua version.
The Lua parser is pretty fast, though, and using
byte-converted/endianness-swapped byte-code does only pay off for Lua
chunks of some kilo lines.
Byte code also occupies much more space than text in the final Edje
container, as it includes debug symbols.
---
Cedric and Vincent told me, that the plan was to replace Embryo totally
by Lua before the official release of Edje at the end of the year? So it
would make sense to bring Lua to svn soon and look how it fits in, test,
debug, adapt it further to the themers needs, decide on its final shape,
GATHER SOME PEOPLE TO HELP ;-)
---
The Lua enhanced Edje is in sync with svn and can be get directly here
git clone git://repo.or.cz/edje_lua.git
cd edje_lua
git checkout -b lua_patch origin/lua_patch
or apply the attached patch
There are also some examples to show the usage of the things
mentioned
above
- showcase.edj: shows usage of custom animators, custom states,
messaging and the script_only object
- test.edj: test cases of script usage and bindings (custom states,
custom transitions, tween_states, animators, timers,
object_parts),
but most of it are experimental script_only objects
http://didgmo.sourceforge.net/showcase.edj
http://didgmo.sourceforge.net/test.edj
The source of showcase.edc is attached, too, to just have a glimpse at
Lua inside of EDC
---
So, what do you guys think?
Thanks and sry for the looong mail, hehe ;-)
SVN revision: 41802
2009-08-15 19:34:02 -07:00
|
|
|
lua_pushvalue(L, LUA_GLOBALSINDEX); /* set function environment from collection thread to edje object thread */
|
|
|
|
lua_setfenv(L, -2);
|
|
|
|
_edje_lua_get_reg(L, ed);
|
|
|
|
if (lua_isnil(L, -1)) /* group object does not yet exist, create it */
|
|
|
|
{
|
|
|
|
lua_pop(L, 1);
|
|
|
|
_edje_lua_group_fn_new (ed);
|
|
|
|
}
|
|
|
|
lua_pushstring(L, ssig);
|
|
|
|
lua_pushstring(L, ssrc);
|
2009-08-17 04:32:56 -07:00
|
|
|
|
|
|
|
if ((err_code = lua_pcall(L, 3, 0, 0)))
|
From: "Hanspeter Portner" <ventosus@airpost.net>
This concerns Ticket #109: Add Lua support for Edje
It adds Lua as scripting facility to Edje, letting Embryo untouched.
It should be easier to use and be more flexible than Embryo, imho ;-)
---
The patch
---
Lua 5.1 is used in sandboxed mode. Lua byte code is not
platform/architecture independent, Lua code is saved as text in the Edje
container and parsed at load time, therefore.
The patch goes in two directions
1) Analogous to Embryo for scripting logic, messaging and custom states.
The same things are implemented as in Embryo:
- messaging from and to C
- manual creation of timers, animators, pollers for custom events /
animations
- manual manipulation of Edje parts by means of the public
edje_object_part_* and internal functions and custom states
-> those routines are actually implemented as Lua
bindings to
functions in Edje.h and Ecore.h
-> the implementation is done in an object oriented way, so that the
interface gives the feel of an object description language, pretty
similar to EDC itself
-> combining custom states and custom animators allows
for fancy
animations and transitions, e.g circular/spline translations or
complex/conditional transitions, etc.
-> this is just the same as Embryo does, but implemented in Lua, so
nothing new here, actually
2) Dynamic object creation and manipulation
- this interface stems from the 'script_only' objects in
Edje. Those
objects are a kind of scriptable Edje counterparts to Evas_Smart
objects. The infrastructure for Embryo is already there, but has
never been used
- I added this in Lua and added some first bindings to
experiment
with
- I thought it would be useful to allow for a limited dynamic
creation of ui parts
- We can create instances of groups from within the same Edje
container and use them just like the main Edje object as
stated in
1)
- And there are some stand-alone bindings to dynamically create
Evas_Image, Evas_Table, Evas_Line, Evas_Polygon as examples
-> this may be useful to decouple the program from the ui
even more,
to be able to do things that have to be done in the program itself
atm, but actually belong to the user interface, but need dynamic
creation of objects or complex interactions
-> those objects are manipulated manually with Lua bindings
to the
corresponding edje_object_* and evas_object_* functions
---
Discussion points
---
Both stuff in 1) & 2) is functioning, but needs testing, feedback,
improvements, ...
Stuff in 1) can already fully replace Embryo scripting with Lua
scripting. There still is space for improvements/additions, though.
Of the stuff in 2), I think it may only make sense to add the dynamic
creation of groups defined in the same Edje container. Dynamic creation
of other Evas_Objects makes not much sense, as most of them can already
be used as Edje parts and be manipulated with custom states (apart from
polygons and lines) and it would make the whole theming potentially more
programing-like and much more susceptible for errors, etc.
Would this be useful, or drop it all?
The scripting should be there just for logic, conditionals, custom
states and animations, not for a whole dynamic canvas, imho.
There is a patch around with EXTERNAL Edje parts. Seems to be a better,
faster, more secure way to extend Edje with custom objects.
There would be the possibility of precompiling Lua code at compile time
(edje_cc) for faster loading, but we would have to patch and run our own
Lua version.
The Lua parser is pretty fast, though, and using
byte-converted/endianness-swapped byte-code does only pay off for Lua
chunks of some kilo lines.
Byte code also occupies much more space than text in the final Edje
container, as it includes debug symbols.
---
Cedric and Vincent told me, that the plan was to replace Embryo totally
by Lua before the official release of Edje at the end of the year? So it
would make sense to bring Lua to svn soon and look how it fits in, test,
debug, adapt it further to the themers needs, decide on its final shape,
GATHER SOME PEOPLE TO HELP ;-)
---
The Lua enhanced Edje is in sync with svn and can be get directly here
git clone git://repo.or.cz/edje_lua.git
cd edje_lua
git checkout -b lua_patch origin/lua_patch
or apply the attached patch
There are also some examples to show the usage of the things
mentioned
above
- showcase.edj: shows usage of custom animators, custom states,
messaging and the script_only object
- test.edj: test cases of script usage and bindings (custom states,
custom transitions, tween_states, animators, timers,
object_parts),
but most of it are experimental script_only objects
http://didgmo.sourceforge.net/showcase.edj
http://didgmo.sourceforge.net/test.edj
The source of showcase.edc is attached, too, to just have a glimpse at
Lua inside of EDC
---
So, what do you guys think?
Thanks and sry for the looong mail, hehe ;-)
SVN revision: 41802
2009-08-15 19:34:02 -07:00
|
|
|
_edje_lua_error(L, err_code);
|
|
|
|
}
|
|
|
|
|
|
|
|
// _edje_emit(ed, "program,stop", pr->name);
|
2004-03-27 21:26:17 -08:00
|
|
|
if (_edje_block_break(ed)) goto break_prog;
|
2008-11-14 03:06:15 -08:00
|
|
|
_edje_recalc_do(ed);
|
2004-03-27 21:26:17 -08:00
|
|
|
}
|
2008-10-13 02:19:04 -07:00
|
|
|
else if (pr->action == EDJE_ACTION_TYPE_FOCUS_SET)
|
|
|
|
{
|
|
|
|
if (!pr->targets)
|
|
|
|
{
|
|
|
|
ed->focused_part = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-10-22 04:34:42 -07:00
|
|
|
EINA_LIST_FOREACH(pr->targets, l, pt)
|
2008-10-13 02:19:04 -07:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-08-17 18:09:14 -07:00
|
|
|
else
|
|
|
|
{
|
2008-09-17 18:48:17 -07:00
|
|
|
// _edje_emit(ed, "program,start", pr->name);
|
|
|
|
// _edje_emit(ed, "program,stop", pr->name);
|
2004-08-17 18:09:14 -07:00
|
|
|
}
|
2007-09-08 11:31:56 -07:00
|
|
|
if (!((pr->action == EDJE_ACTION_TYPE_STATE_SET)
|
2003-09-05 00:17:54 -07:00
|
|
|
/* hmm this fucks somethgin up. must look into it later */
|
|
|
|
/* && (pr->tween.time > 0.0) && (!ed->no_anim))) */
|
|
|
|
))
|
2003-08-05 04:51:28 -07:00
|
|
|
{
|
2008-10-22 04:34:42 -07:00
|
|
|
EINA_LIST_FOREACH(pr->after, l, pa)
|
2003-08-05 04:51:28 -07:00
|
|
|
{
|
2004-03-07 18:43:48 -08:00
|
|
|
if (pa->id >= 0)
|
|
|
|
{
|
2004-04-01 07:32:17 -08:00
|
|
|
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;
|
2004-03-07 18:43:48 -08:00
|
|
|
}
|
2003-08-05 04:51:28 -07:00
|
|
|
}
|
2003-06-23 19:33:04 -07:00
|
|
|
}
|
2003-08-25 17:16:49 -07:00
|
|
|
break_prog:
|
2003-06-23 19:33:04 -07:00
|
|
|
_edje_thaw(ed);
|
2003-08-25 17:16:49 -07:00
|
|
|
_edje_unref(ed);
|
2003-06-27 20:08:25 -07:00
|
|
|
recursions--;
|
|
|
|
if (recursions == 0) recursion_limit = 0;
|
2003-08-25 17:16:49 -07:00
|
|
|
_edje_unblock(ed);
|
2003-06-23 19:33:04 -07:00
|
|
|
}
|
|
|
|
|
2004-06-30 20:46:05 -07:00
|
|
|
void
|
2006-03-18 20:22:35 -08:00
|
|
|
_edje_emit(Edje *ed, const char *sig, const char *src)
|
2004-02-04 11:41:27 -08:00
|
|
|
{
|
2004-07-01 20:24:56 -07:00
|
|
|
Edje_Message_Signal emsg;
|
2008-11-16 21:54:01 -08:00
|
|
|
Eina_List *l;
|
|
|
|
Evas_Object *obj;
|
2009-05-02 13:05:53 -07:00
|
|
|
const char *sep;
|
|
|
|
|
2004-06-30 20:46:05 -07:00
|
|
|
if (ed->delete_me) return;
|
2009-05-02 13:05:53 -07:00
|
|
|
|
|
|
|
sep = strchr(sig, ':');
|
|
|
|
if (sep)
|
|
|
|
{
|
2009-05-02 16:22:07 -07:00
|
|
|
size_t length;
|
|
|
|
char *part;
|
2009-05-02 13:05:53 -07:00
|
|
|
/* the signal contains a colon, split the signal into "group:signal",
|
|
|
|
* and deliver it to "group"
|
|
|
|
*/
|
2009-05-02 16:22:07 -07:00
|
|
|
length = strlen(sig) + 1;
|
|
|
|
part = alloca(length);
|
2009-05-02 13:05:53 -07:00
|
|
|
if (part)
|
|
|
|
{
|
2009-05-02 16:22:07 -07:00
|
|
|
char *newsig;
|
2009-05-02 13:05:53 -07:00
|
|
|
int i;
|
2009-05-02 16:22:07 -07:00
|
|
|
|
|
|
|
memcpy(part, sig, length);
|
|
|
|
newsig = part + (sep - sig);
|
2009-05-02 13:05:53 -07:00
|
|
|
*newsig = '\0';
|
|
|
|
newsig++;
|
|
|
|
|
|
|
|
for (i = 0; i < ed->table_parts_size; i++)
|
|
|
|
{
|
|
|
|
Edje_Real_Part *rp = ed->table_parts[i];
|
|
|
|
if ((rp->part->type == EDJE_PART_TYPE_GROUP) &&
|
|
|
|
(rp->swallowed_object) &&
|
|
|
|
(rp->part) && (rp->part->name) &&
|
|
|
|
(strcmp(rp->part->name, part) == 0))
|
|
|
|
{
|
|
|
|
Edje *ed2 = _edje_fetch(rp->swallowed_object);
|
|
|
|
if (ed2) _edje_emit(ed2, newsig, src);
|
|
|
|
return; /* stop processing.
|
|
|
|
* XXX maybe let signal be processed anyway?
|
|
|
|
* XXX in this case, just comment this line
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-07-01 20:24:56 -07:00
|
|
|
emsg.sig = sig;
|
|
|
|
emsg.src = src;
|
2004-07-02 03:17:25 -07:00
|
|
|
_edje_message_send(ed, EDJE_QUEUE_SCRIPT, EDJE_MESSAGE_SIGNAL, 0, &emsg);
|
2008-11-16 21:54:01 -08:00
|
|
|
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);
|
|
|
|
}
|
2004-02-04 11:41:27 -08:00
|
|
|
}
|
|
|
|
|
2008-01-17 22:34:04 -08:00
|
|
|
struct _Edje_Program_Data
|
|
|
|
{
|
|
|
|
#ifdef EDJE_PROGRAM_CACHE
|
2008-10-22 04:34:42 -07:00
|
|
|
Eina_List *matches;
|
2008-01-17 22:34:04 -08:00
|
|
|
int matched;
|
|
|
|
#endif
|
|
|
|
Edje *ed;
|
|
|
|
const char *signal;
|
|
|
|
const char *source;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int _edje_glob_callback(Edje_Program *pr, void *dt)
|
|
|
|
{
|
|
|
|
struct _Edje_Program_Data *data = dt;
|
|
|
|
|
|
|
|
#ifdef EDJE_PROGRAM_CACHE
|
|
|
|
data->matched++;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
_edje_program_run(data->ed, pr, 0, data->signal, data->source);
|
|
|
|
if (_edje_block_break(data->ed))
|
|
|
|
{
|
|
|
|
#ifdef EDJE_PROGRAM_CACHE
|
2008-10-22 04:34:42 -07:00
|
|
|
eina_list_free(data->matches);
|
2008-01-17 22:34:04 -08:00
|
|
|
data->matches = NULL;
|
|
|
|
#endif
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef EDJE_PROGRAM_CACHE
|
2008-10-22 04:34:42 -07:00
|
|
|
data->matches = eina_list_append(data->matches, pr);
|
2008-01-17 22:34:04 -08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-02-26 12:12:00 -08:00
|
|
|
|
|
|
|
void
|
|
|
|
_edje_callbacks_patterns_clean(Edje *ed)
|
|
|
|
{
|
|
|
|
_edje_signals_sources_patterns_clean(&ed->patterns.callbacks);
|
2008-11-10 08:37:52 -08:00
|
|
|
|
|
|
|
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.globing = eina_list_free(ed->patterns.callbacks.globing);
|
2008-02-26 12:12:00 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_edje_callbacks_patterns_init(Edje *ed)
|
|
|
|
{
|
|
|
|
Edje_Signals_Sources_Patterns *ssp = &ed->patterns.callbacks;
|
|
|
|
|
2008-12-05 14:32:04 -08:00
|
|
|
if ((ssp->signals_patterns) || (ssp->sources_patterns) ||
|
|
|
|
(ssp->globing) || (ssp->exact_match))
|
2008-02-26 12:12:00 -08:00
|
|
|
return;
|
|
|
|
|
2008-11-10 08:37:52 -08:00
|
|
|
ssp->globing = edje_match_callback_hash_build(ed->callbacks,
|
|
|
|
&ssp->exact_match);
|
|
|
|
|
|
|
|
ssp->signals_patterns = edje_match_callback_signal_init(ssp->globing);
|
|
|
|
ssp->sources_patterns = edje_match_callback_source_init(ssp->globing);
|
2008-02-26 12:12:00 -08:00
|
|
|
}
|
|
|
|
|
2004-06-30 20:46:05 -07:00
|
|
|
/* FIXME: what if we delete the evas object??? */
|
2003-06-23 19:33:04 -07:00
|
|
|
void
|
2006-03-18 20:22:35 -08:00
|
|
|
_edje_emit_handle(Edje *ed, const char *sig, const char *src)
|
2003-06-23 19:33:04 -07:00
|
|
|
{
|
2003-08-25 17:16:49 -07:00
|
|
|
if (ed->delete_me) return;
|
2005-11-23 06:00:39 -08:00
|
|
|
if (!sig) sig = "";
|
|
|
|
if (!src) src = "";
|
2003-08-25 21:15:07 -07:00
|
|
|
// printf("EDJE EMIT: signal: \"%s\" source: \"%s\"\n", sig, src);
|
2003-08-25 17:16:49 -07:00
|
|
|
_edje_block(ed);
|
|
|
|
_edje_ref(ed);
|
|
|
|
_edje_freeze(ed);
|
2004-06-30 20:46:05 -07:00
|
|
|
if (ed->collection)
|
2003-06-23 19:33:04 -07:00
|
|
|
{
|
2004-06-30 20:46:05 -07:00
|
|
|
Edje_Part_Collection *ec;
|
2004-03-26 01:10:05 -08:00
|
|
|
#ifdef EDJE_PROGRAM_CACHE
|
2004-06-30 20:46:05 -07:00
|
|
|
char *tmps;
|
|
|
|
int l1, l2;
|
2007-09-08 11:31:56 -07:00
|
|
|
#endif
|
2004-06-30 20:46:05 -07:00
|
|
|
int done;
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2004-06-30 20:46:05 -07:00
|
|
|
ec = ed->collection;
|
2004-03-26 01:10:05 -08:00
|
|
|
#ifdef EDJE_PROGRAM_CACHE
|
2004-06-30 20:46:05 -07:00
|
|
|
l1 = strlen(sig);
|
|
|
|
l2 = strlen(src);
|
2008-12-05 14:32:04 -08:00
|
|
|
tmps = alloca(l1 + l2 + 3); /* \0, \337, \0 */
|
2005-11-30 07:36:34 -08:00
|
|
|
strcpy(tmps, sig);
|
|
|
|
tmps[l1] = '\377';
|
|
|
|
strcpy(&(tmps[l1 + 1]), src);
|
2007-09-08 11:31:56 -07:00
|
|
|
#endif
|
2004-06-30 20:46:05 -07:00
|
|
|
done = 0;
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2004-06-30 20:46:05 -07:00
|
|
|
#ifdef EDJE_PROGRAM_CACHE
|
|
|
|
{
|
2008-10-22 04:34:42 -07:00
|
|
|
Eina_List *matches;
|
|
|
|
Eina_List *l;
|
|
|
|
Edje_Program *pr;
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2008-12-17 06:26:47 -08:00
|
|
|
if (eina_hash_find(ec->prog_cache.no_matches, tmps))
|
2003-07-19 19:08:47 -07:00
|
|
|
{
|
2004-06-30 20:46:05 -07:00
|
|
|
done = 1;
|
2003-07-19 19:08:47 -07:00
|
|
|
}
|
2008-12-17 06:26:47 -08:00
|
|
|
else if ((matches = eina_hash_find(ec->prog_cache.matches, tmps)))
|
2003-07-19 19:08:47 -07:00
|
|
|
{
|
2008-10-22 04:34:42 -07:00
|
|
|
EINA_LIST_FOREACH(matches, l, pr)
|
2003-07-19 19:08:47 -07:00
|
|
|
{
|
2004-06-30 20:46:05 -07:00
|
|
|
_edje_program_run(ed, pr, 0, sig, src);
|
|
|
|
if (_edje_block_break(ed))
|
2003-07-19 19:08:47 -07:00
|
|
|
{
|
2004-06-30 20:46:05 -07:00
|
|
|
goto break_prog;
|
2003-07-19 19:08:47 -07:00
|
|
|
}
|
|
|
|
}
|
2004-06-30 20:46:05 -07:00
|
|
|
done = 1;
|
2003-07-19 19:08:47 -07:00
|
|
|
}
|
2004-06-30 20:46:05 -07:00
|
|
|
}
|
2004-03-26 01:10:05 -08:00
|
|
|
#endif
|
2004-06-30 20:46:05 -07:00
|
|
|
if (!done)
|
|
|
|
{
|
2008-01-17 22:34:04 -08:00
|
|
|
struct _Edje_Program_Data data;
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2008-01-17 22:34:04 -08:00
|
|
|
data.ed = ed;
|
|
|
|
data.source = src;
|
|
|
|
data.signal = sig;
|
2004-03-26 01:10:05 -08:00
|
|
|
#ifdef EDJE_PROGRAM_CACHE
|
2008-01-17 22:34:04 -08:00
|
|
|
data.matched = 0;
|
|
|
|
data.matches = NULL;
|
2007-09-08 11:31:56 -07:00
|
|
|
#endif
|
2008-01-17 22:34:04 -08:00
|
|
|
if (ed->collection->programs)
|
|
|
|
{
|
2008-11-10 08:37:52 -08:00
|
|
|
const Eina_List *match;
|
|
|
|
const Eina_List *l;
|
|
|
|
Edje_Program *pr;
|
|
|
|
|
|
|
|
if (ed->patterns.programs.globing)
|
|
|
|
if (edje_match_programs_exec(ed->patterns.programs.signals_patterns,
|
|
|
|
ed->patterns.programs.sources_patterns,
|
|
|
|
sig,
|
|
|
|
src,
|
|
|
|
ed->patterns.programs.globing,
|
|
|
|
_edje_glob_callback,
|
|
|
|
&data) == 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);
|
2008-01-17 22:34:04 -08:00
|
|
|
}
|
|
|
|
|
2004-03-26 01:10:05 -08:00
|
|
|
#ifdef EDJE_PROGRAM_CACHE
|
2004-06-30 20:46:05 -07:00
|
|
|
if (tmps)
|
|
|
|
{
|
2008-09-11 04:14:39 -07:00
|
|
|
if (data.matched == 0)
|
2008-12-17 06:26:47 -08:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
2004-06-30 20:46:05 -07:00
|
|
|
else
|
2008-12-17 06:26:47 -08:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
2003-08-25 17:16:49 -07:00
|
|
|
}
|
2007-09-08 11:31:56 -07:00
|
|
|
#endif
|
2004-06-30 20:46:05 -07:00
|
|
|
}
|
|
|
|
_edje_emit_cb(ed, sig, src);
|
|
|
|
if (_edje_block_break(ed))
|
|
|
|
{
|
|
|
|
goto break_prog;
|
2003-06-23 19:33:04 -07:00
|
|
|
}
|
|
|
|
}
|
2003-08-25 17:16:49 -07:00
|
|
|
break_prog:
|
|
|
|
_edje_thaw(ed);
|
|
|
|
_edje_unref(ed);
|
|
|
|
_edje_unblock(ed);
|
2003-06-23 19:33:04 -07:00
|
|
|
}
|
2003-08-15 06:35:25 -07:00
|
|
|
|
2004-06-30 20:46:05 -07:00
|
|
|
/* FIXME: what if we delete the evas object??? */
|
2003-08-15 06:35:25 -07:00
|
|
|
static void
|
2006-03-18 20:22:35 -08:00
|
|
|
_edje_emit_cb(Edje *ed, const char *sig, const char *src)
|
2003-08-15 06:35:25 -07:00
|
|
|
{
|
2008-10-22 04:34:42 -07:00
|
|
|
Eina_List *l;
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2003-08-25 17:16:49 -07:00
|
|
|
if (ed->delete_me) return;
|
|
|
|
_edje_ref(ed);
|
2007-09-08 11:31:56 -07:00
|
|
|
_edje_freeze(ed);
|
2003-08-25 17:16:49 -07:00
|
|
|
_edje_block(ed);
|
2008-02-26 09:56:51 -08:00
|
|
|
|
|
|
|
if (ed->just_added_callbacks)
|
2008-02-26 12:12:00 -08:00
|
|
|
_edje_callbacks_patterns_clean(ed);
|
2008-02-26 09:56:51 -08:00
|
|
|
|
2003-08-15 06:35:25 -07:00
|
|
|
ed->walking_callbacks = 1;
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2008-01-17 22:34:04 -08:00
|
|
|
if (ed->callbacks)
|
|
|
|
{
|
2008-11-10 08:37:52 -08:00
|
|
|
Edje_Signal_Callback *escb;
|
|
|
|
const Eina_List *match;
|
|
|
|
const Eina_List *l;
|
|
|
|
int r = 1;
|
2008-01-17 22:34:04 -08:00
|
|
|
|
2008-02-26 12:12:00 -08:00
|
|
|
_edje_callbacks_patterns_init(ed);
|
2008-11-10 08:37:52 -08:00
|
|
|
if (ed->patterns.callbacks.globing)
|
|
|
|
r = edje_match_callback_exec(ed->patterns.callbacks.signals_patterns,
|
|
|
|
ed->patterns.callbacks.sources_patterns,
|
|
|
|
sig,
|
|
|
|
src,
|
|
|
|
ed->patterns.callbacks.globing,
|
|
|
|
ed);
|
2008-01-17 22:34:04 -08:00
|
|
|
|
|
|
|
if (!r)
|
2008-02-21 10:48:36 -08:00
|
|
|
goto break_prog;
|
2008-11-10 08:37:52 -08:00
|
|
|
|
|
|
|
match = edje_match_signal_source_hash_get(sig, src,
|
|
|
|
ed->patterns.callbacks.exact_match);
|
|
|
|
EINA_LIST_FOREACH(match, l, escb)
|
|
|
|
if ((!escb->just_added) && (!escb->delete_me))
|
|
|
|
{
|
|
|
|
escb->func(escb->data, ed->obj, sig, src);
|
|
|
|
if (_edje_block_break(ed))
|
|
|
|
goto break_prog;
|
|
|
|
}
|
2003-08-15 06:35:25 -07:00
|
|
|
}
|
2008-12-05 14:32:04 -08:00
|
|
|
break_prog:
|
2008-01-17 22:34:04 -08:00
|
|
|
|
2003-08-15 06:35:25 -07:00
|
|
|
ed->walking_callbacks = 0;
|
|
|
|
if ((ed->delete_callbacks) || (ed->just_added_callbacks))
|
|
|
|
{
|
|
|
|
ed->delete_callbacks = 0;
|
|
|
|
ed->just_added_callbacks = 0;
|
2008-12-05 14:32:04 -08:00
|
|
|
l = ed->callbacks;
|
|
|
|
while (l)
|
2003-08-15 06:35:25 -07:00
|
|
|
{
|
2008-12-05 14:32:04 -08:00
|
|
|
Edje_Signal_Callback *escb = l->data;
|
|
|
|
Eina_List *next_l = l->next;
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2003-08-15 06:35:25 -07:00
|
|
|
if (escb->just_added)
|
|
|
|
escb->just_added = 0;
|
|
|
|
if (escb->delete_me)
|
|
|
|
{
|
2008-10-22 04:34:42 -07:00
|
|
|
ed->callbacks = eina_list_remove_list(ed->callbacks, l);
|
2008-10-15 07:11:11 -07:00
|
|
|
if (escb->signal) eina_stringshare_del(escb->signal);
|
|
|
|
if (escb->source) eina_stringshare_del(escb->source);
|
2003-08-15 06:35:25 -07:00
|
|
|
free(escb);
|
|
|
|
}
|
|
|
|
l = next_l;
|
|
|
|
}
|
2008-02-26 09:56:51 -08:00
|
|
|
|
2008-02-26 12:12:00 -08:00
|
|
|
_edje_callbacks_patterns_clean(ed);
|
2003-08-15 06:35:25 -07:00
|
|
|
}
|
2003-08-25 17:16:49 -07:00
|
|
|
_edje_unblock(ed);
|
|
|
|
_edje_thaw(ed);
|
|
|
|
_edje_unref(ed);
|
2003-08-15 06:35:25 -07:00
|
|
|
}
|