2009-12-05 17:22:54 -08:00
|
|
|
#include "private.h"
|
|
|
|
|
|
|
|
typedef struct _Elm_Params_Button
|
|
|
|
{
|
|
|
|
Elm_Params base;
|
2010-10-21 15:03:43 -07:00
|
|
|
const char *label;
|
2009-12-05 17:22:54 -08:00
|
|
|
Evas_Object *icon;
|
2012-01-27 08:59:03 -08:00
|
|
|
double autorepeat_initial;
|
|
|
|
double autorepeat_gap;
|
|
|
|
Eina_Bool autorepeat:1;
|
|
|
|
Eina_Bool autorepeat_exists:1;
|
|
|
|
Eina_Bool autorepeat_gap_exists:1;
|
|
|
|
Eina_Bool autorepeat_initial_exists:1;
|
2009-12-05 17:22:54 -08:00
|
|
|
} Elm_Params_Button;
|
|
|
|
|
|
|
|
static void
|
2014-01-06 06:30:02 -08:00
|
|
|
external_button_state_set(void *data EINA_UNUSED, Evas_Object *obj, const void *from_params, const void *to_params, float pos EINA_UNUSED)
|
2009-12-05 17:22:54 -08:00
|
|
|
{
|
2010-03-25 13:17:34 -07:00
|
|
|
const Elm_Params_Button *p;
|
2009-12-05 17:22:54 -08:00
|
|
|
|
2010-03-25 13:17:34 -07:00
|
|
|
if (to_params) p = to_params;
|
|
|
|
else if (from_params) p = from_params;
|
|
|
|
else return;
|
2009-12-05 17:22:54 -08:00
|
|
|
|
2010-10-21 15:03:43 -07:00
|
|
|
if (p->label)
|
2011-06-29 18:33:38 -07:00
|
|
|
elm_object_text_set(obj, p->label);
|
2010-03-25 13:17:34 -07:00
|
|
|
if (p->icon)
|
2011-11-17 13:02:31 -08:00
|
|
|
elm_object_part_content_set(obj, "icon", p->icon);
|
2012-01-27 08:59:03 -08:00
|
|
|
if (p->autorepeat_gap_exists)
|
|
|
|
elm_button_autorepeat_gap_timeout_set(obj, p->autorepeat_gap);
|
|
|
|
if (p->autorepeat_initial_exists)
|
|
|
|
elm_button_autorepeat_initial_timeout_set(obj, p->autorepeat_initial);
|
|
|
|
if (p->autorepeat_exists)
|
|
|
|
elm_button_autorepeat_set(obj, p->autorepeat);
|
2009-12-05 17:22:54 -08:00
|
|
|
}
|
|
|
|
|
Port to new Edje EXTERNAL API goodies!
Now it is possible to change labels and lots of other parameters
directly through Edje's API.
BIG FAT NOTE: this is a convenience that comes with a reasonable
price. If you have hot paths, like loops, then avoid calling this
and use the object directly. This functions add a cost to check
edje, then find the part, then get the type, then get the
param_set/param_get methods, then calling it, then finding the
parameters using strcmp(), then checking the type and just then it
will call the actual method. So whenever possible, just call the
method directly.
Due the reasoning of the "big fat note" I'm adding this inside edje
externals only. The code would be almost the same to expose it in
Elementary.h as elm_widget_property_set/get, but then I know people
would misuse it... actually this kind of stuff could be easily ported
to Evas smart object, but then abuse and slowness will hunt us
foreveeeeer...
SVN revision: 47457
2010-03-25 11:10:25 -07:00
|
|
|
static Eina_Bool
|
2014-01-06 06:30:02 -08:00
|
|
|
external_button_param_set(void *data EINA_UNUSED, Evas_Object *obj, const Edje_External_Param *param)
|
Port to new Edje EXTERNAL API goodies!
Now it is possible to change labels and lots of other parameters
directly through Edje's API.
BIG FAT NOTE: this is a convenience that comes with a reasonable
price. If you have hot paths, like loops, then avoid calling this
and use the object directly. This functions add a cost to check
edje, then find the part, then get the type, then get the
param_set/param_get methods, then calling it, then finding the
parameters using strcmp(), then checking the type and just then it
will call the actual method. So whenever possible, just call the
method directly.
Due the reasoning of the "big fat note" I'm adding this inside edje
externals only. The code would be almost the same to expose it in
Elementary.h as elm_widget_property_set/get, but then I know people
would misuse it... actually this kind of stuff could be easily ported
to Evas smart object, but then abuse and slowness will hunt us
foreveeeeer...
SVN revision: 47457
2010-03-25 11:10:25 -07:00
|
|
|
{
|
|
|
|
if (!strcmp(param->name, "label"))
|
|
|
|
{
|
|
|
|
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
|
|
|
|
{
|
2011-06-29 18:33:38 -07:00
|
|
|
elm_object_text_set(obj, param->s);
|
Port to new Edje EXTERNAL API goodies!
Now it is possible to change labels and lots of other parameters
directly through Edje's API.
BIG FAT NOTE: this is a convenience that comes with a reasonable
price. If you have hot paths, like loops, then avoid calling this
and use the object directly. This functions add a cost to check
edje, then find the part, then get the type, then get the
param_set/param_get methods, then calling it, then finding the
parameters using strcmp(), then checking the type and just then it
will call the actual method. So whenever possible, just call the
method directly.
Due the reasoning of the "big fat note" I'm adding this inside edje
externals only. The code would be almost the same to expose it in
Elementary.h as elm_widget_property_set/get, but then I know people
would misuse it... actually this kind of stuff could be easily ported
to Evas smart object, but then abuse and slowness will hunt us
foreveeeeer...
SVN revision: 47457
2010-03-25 11:10:25 -07:00
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "icon"))
|
|
|
|
{
|
|
|
|
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
|
|
|
|
{
|
|
|
|
Evas_Object *icon = external_common_param_icon_get(obj, param);
|
2010-06-16 13:58:01 -07:00
|
|
|
if ((strcmp(param->s, "")) && (!icon)) return EINA_FALSE;
|
2011-11-17 13:02:31 -08:00
|
|
|
elm_object_part_content_set(obj, "icon", icon);
|
2010-06-16 13:58:01 -07:00
|
|
|
return EINA_TRUE;
|
Port to new Edje EXTERNAL API goodies!
Now it is possible to change labels and lots of other parameters
directly through Edje's API.
BIG FAT NOTE: this is a convenience that comes with a reasonable
price. If you have hot paths, like loops, then avoid calling this
and use the object directly. This functions add a cost to check
edje, then find the part, then get the type, then get the
param_set/param_get methods, then calling it, then finding the
parameters using strcmp(), then checking the type and just then it
will call the actual method. So whenever possible, just call the
method directly.
Due the reasoning of the "big fat note" I'm adding this inside edje
externals only. The code would be almost the same to expose it in
Elementary.h as elm_widget_property_set/get, but then I know people
would misuse it... actually this kind of stuff could be easily ported
to Evas smart object, but then abuse and slowness will hunt us
foreveeeeer...
SVN revision: 47457
2010-03-25 11:10:25 -07:00
|
|
|
}
|
|
|
|
}
|
2012-01-27 08:59:03 -08:00
|
|
|
else if (!strcmp(param->name, "autorepeat_initial"))
|
|
|
|
{
|
|
|
|
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE)
|
|
|
|
{
|
|
|
|
elm_button_autorepeat_initial_timeout_set(obj, param->d);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "autorepeat_gap"))
|
|
|
|
{
|
|
|
|
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE)
|
|
|
|
{
|
|
|
|
elm_button_autorepeat_gap_timeout_set(obj, param->d);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "autorepeat"))
|
|
|
|
{
|
|
|
|
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
|
|
|
|
{
|
|
|
|
elm_button_autorepeat_set(obj, param->i);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
}
|
Port to new Edje EXTERNAL API goodies!
Now it is possible to change labels and lots of other parameters
directly through Edje's API.
BIG FAT NOTE: this is a convenience that comes with a reasonable
price. If you have hot paths, like loops, then avoid calling this
and use the object directly. This functions add a cost to check
edje, then find the part, then get the type, then get the
param_set/param_get methods, then calling it, then finding the
parameters using strcmp(), then checking the type and just then it
will call the actual method. So whenever possible, just call the
method directly.
Due the reasoning of the "big fat note" I'm adding this inside edje
externals only. The code would be almost the same to expose it in
Elementary.h as elm_widget_property_set/get, but then I know people
would misuse it... actually this kind of stuff could be easily ported
to Evas smart object, but then abuse and slowness will hunt us
foreveeeeer...
SVN revision: 47457
2010-03-25 11:10:25 -07:00
|
|
|
|
|
|
|
ERR("unknown parameter '%s' of type '%s'",
|
|
|
|
param->name, edje_external_param_type_str(param->type));
|
|
|
|
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
2014-01-06 06:30:02 -08:00
|
|
|
external_button_param_get(void *data EINA_UNUSED, const Evas_Object *obj, Edje_External_Param *param)
|
Port to new Edje EXTERNAL API goodies!
Now it is possible to change labels and lots of other parameters
directly through Edje's API.
BIG FAT NOTE: this is a convenience that comes with a reasonable
price. If you have hot paths, like loops, then avoid calling this
and use the object directly. This functions add a cost to check
edje, then find the part, then get the type, then get the
param_set/param_get methods, then calling it, then finding the
parameters using strcmp(), then checking the type and just then it
will call the actual method. So whenever possible, just call the
method directly.
Due the reasoning of the "big fat note" I'm adding this inside edje
externals only. The code would be almost the same to expose it in
Elementary.h as elm_widget_property_set/get, but then I know people
would misuse it... actually this kind of stuff could be easily ported
to Evas smart object, but then abuse and slowness will hunt us
foreveeeeer...
SVN revision: 47457
2010-03-25 11:10:25 -07:00
|
|
|
{
|
|
|
|
if (!strcmp(param->name, "label"))
|
|
|
|
{
|
|
|
|
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_STRING)
|
|
|
|
{
|
2011-06-29 18:33:38 -07:00
|
|
|
param->s = elm_object_text_get(obj);
|
Port to new Edje EXTERNAL API goodies!
Now it is possible to change labels and lots of other parameters
directly through Edje's API.
BIG FAT NOTE: this is a convenience that comes with a reasonable
price. If you have hot paths, like loops, then avoid calling this
and use the object directly. This functions add a cost to check
edje, then find the part, then get the type, then get the
param_set/param_get methods, then calling it, then finding the
parameters using strcmp(), then checking the type and just then it
will call the actual method. So whenever possible, just call the
method directly.
Due the reasoning of the "big fat note" I'm adding this inside edje
externals only. The code would be almost the same to expose it in
Elementary.h as elm_widget_property_set/get, but then I know people
would misuse it... actually this kind of stuff could be easily ported
to Evas smart object, but then abuse and slowness will hunt us
foreveeeeer...
SVN revision: 47457
2010-03-25 11:10:25 -07:00
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "icon"))
|
|
|
|
{
|
|
|
|
/* not easy to get icon name back from live object */
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
2012-01-27 08:59:03 -08:00
|
|
|
else if (!strcmp(param->name, "autorepeat_initial"))
|
|
|
|
{
|
|
|
|
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE)
|
|
|
|
{
|
|
|
|
param->d = elm_button_autorepeat_initial_timeout_get(obj);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "autorepeat_gap"))
|
|
|
|
{
|
|
|
|
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_DOUBLE)
|
|
|
|
{
|
|
|
|
param->d = elm_button_autorepeat_gap_timeout_get(obj);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "autorepeat"))
|
|
|
|
{
|
|
|
|
if (param->type == EDJE_EXTERNAL_PARAM_TYPE_BOOL)
|
|
|
|
{
|
|
|
|
param->i = elm_button_autorepeat_get(obj);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
}
|
Port to new Edje EXTERNAL API goodies!
Now it is possible to change labels and lots of other parameters
directly through Edje's API.
BIG FAT NOTE: this is a convenience that comes with a reasonable
price. If you have hot paths, like loops, then avoid calling this
and use the object directly. This functions add a cost to check
edje, then find the part, then get the type, then get the
param_set/param_get methods, then calling it, then finding the
parameters using strcmp(), then checking the type and just then it
will call the actual method. So whenever possible, just call the
method directly.
Due the reasoning of the "big fat note" I'm adding this inside edje
externals only. The code would be almost the same to expose it in
Elementary.h as elm_widget_property_set/get, but then I know people
would misuse it... actually this kind of stuff could be easily ported
to Evas smart object, but then abuse and slowness will hunt us
foreveeeeer...
SVN revision: 47457
2010-03-25 11:10:25 -07:00
|
|
|
|
|
|
|
ERR("unknown parameter '%s' of type '%s'",
|
|
|
|
param->name, edje_external_param_type_str(param->type));
|
|
|
|
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
2009-12-05 17:22:54 -08:00
|
|
|
static void *
|
2014-01-06 06:30:02 -08:00
|
|
|
external_button_params_parse(void *data EINA_UNUSED, Evas_Object *obj, const Eina_List *params)
|
2009-12-05 17:22:54 -08:00
|
|
|
{
|
|
|
|
Elm_Params_Button *mem;
|
2010-10-21 15:03:43 -07:00
|
|
|
Edje_External_Param *param;
|
|
|
|
const Eina_List *l;
|
2009-12-05 17:22:54 -08:00
|
|
|
|
2010-11-22 04:46:58 -08:00
|
|
|
mem = ELM_NEW(Elm_Params_Button);
|
2009-12-05 17:22:54 -08:00
|
|
|
if (!mem)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
external_common_icon_param_parse(&mem->icon, obj, params);
|
|
|
|
|
2010-10-21 15:03:43 -07:00
|
|
|
EINA_LIST_FOREACH(params, l, param)
|
|
|
|
{
|
2012-01-27 08:59:03 -08:00
|
|
|
if (!strcmp(param->name, "autorepeat_initial"))
|
|
|
|
{
|
|
|
|
mem->autorepeat_initial = param->d;
|
|
|
|
mem->autorepeat_initial_exists = EINA_TRUE;
|
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "autorepeat_gap"))
|
|
|
|
{
|
|
|
|
mem->autorepeat_gap = param->d;
|
|
|
|
mem->autorepeat_gap_exists = EINA_TRUE;
|
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "autorepeat"))
|
|
|
|
{
|
|
|
|
mem->autorepeat = !!param->i;
|
|
|
|
mem->autorepeat_exists = EINA_TRUE;
|
|
|
|
}
|
|
|
|
else if (!strcmp(param->name, "label"))
|
|
|
|
mem->label = eina_stringshare_add(param->s);
|
2010-10-21 15:03:43 -07:00
|
|
|
}
|
|
|
|
|
2009-12-05 17:22:54 -08:00
|
|
|
return mem;
|
|
|
|
}
|
|
|
|
|
2014-01-06 06:30:02 -08:00
|
|
|
static Evas_Object *external_button_content_get(void *data EINA_UNUSED,
|
|
|
|
const Evas_Object *obj EINA_UNUSED, const char *content EINA_UNUSED)
|
2010-08-01 10:29:20 -07:00
|
|
|
{
|
2010-10-20 05:40:36 -07:00
|
|
|
ERR("No content.");
|
2010-08-01 10:29:20 -07:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-06-16 13:57:33 -07:00
|
|
|
static void
|
2009-12-05 17:22:54 -08:00
|
|
|
external_button_params_free(void *params)
|
|
|
|
{
|
2010-10-21 15:03:43 -07:00
|
|
|
Elm_Params_Button *mem = params;
|
|
|
|
if (mem->label)
|
|
|
|
eina_stringshare_del(mem->label);
|
|
|
|
free(params);
|
2009-12-05 17:22:54 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static Edje_External_Param_Info external_button_params[] = {
|
|
|
|
DEFINE_EXTERNAL_COMMON_PARAMS,
|
2010-10-21 15:03:43 -07:00
|
|
|
EDJE_EXTERNAL_PARAM_INFO_STRING("label"),
|
2009-12-05 17:22:54 -08:00
|
|
|
EDJE_EXTERNAL_PARAM_INFO_STRING("icon"),
|
2012-01-27 08:59:03 -08:00
|
|
|
EDJE_EXTERNAL_PARAM_INFO_DOUBLE("autorepeat_initial"),
|
|
|
|
EDJE_EXTERNAL_PARAM_INFO_DOUBLE("autorepeat_gap"),
|
|
|
|
EDJE_EXTERNAL_PARAM_INFO_BOOL("autorepeat"),
|
2009-12-05 17:22:54 -08:00
|
|
|
EDJE_EXTERNAL_PARAM_INFO_SENTINEL
|
|
|
|
};
|
|
|
|
|
2010-01-22 12:07:47 -08:00
|
|
|
DEFINE_EXTERNAL_ICON_ADD(button, "button");
|
2009-12-05 17:22:54 -08:00
|
|
|
DEFINE_EXTERNAL_TYPE_SIMPLE(button, "Button");
|