slider cleanups and support for special values.
Special values enables showing different label for some values, for example, 0 may mean "undefined", "never"... cleanup -Wextra was done as well. SVN revision: 47144
This commit is contained in:
parent
369d93736e
commit
2e246ac1be
|
@ -10,6 +10,8 @@
|
||||||
#define INTERNAL_ENTRY E_Smart_Data *sd; sd = evas_object_smart_data_get(obj); if (!sd) return;
|
#define INTERNAL_ENTRY E_Smart_Data *sd; sd = evas_object_smart_data_get(obj); if (!sd) return;
|
||||||
typedef struct _E_Smart_Data E_Smart_Data;
|
typedef struct _E_Smart_Data E_Smart_Data;
|
||||||
|
|
||||||
|
typedef struct _E_Slider_Special_Value E_Slider_Special_Value;
|
||||||
|
|
||||||
struct _E_Smart_Data
|
struct _E_Smart_Data
|
||||||
{
|
{
|
||||||
Evas_Coord x, y, w, h;
|
Evas_Coord x, y, w, h;
|
||||||
|
@ -22,6 +24,14 @@ struct _E_Smart_Data
|
||||||
const char *format;
|
const char *format;
|
||||||
Evas_Coord minw, minh;
|
Evas_Coord minw, minh;
|
||||||
Ecore_Timer *set_timer;
|
Ecore_Timer *set_timer;
|
||||||
|
Eina_List *special_values;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _E_Slider_Special_Value
|
||||||
|
{
|
||||||
|
double value;
|
||||||
|
double error;
|
||||||
|
const char *label;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* local subsystem functions */
|
/* local subsystem functions */
|
||||||
|
@ -216,6 +226,21 @@ e_slider_edje_object_get(Evas_Object *obj)
|
||||||
return sd->edje_obj;
|
return sd->edje_obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EAPI void
|
||||||
|
e_slider_special_value_add(Evas_Object *obj, double value, double error, const char *label)
|
||||||
|
{
|
||||||
|
E_Slider_Special_Value *sv;
|
||||||
|
API_ENTRY return;
|
||||||
|
|
||||||
|
sv = malloc(sizeof(E_Slider_Special_Value));
|
||||||
|
if (!sv) return;
|
||||||
|
sv->value = value;
|
||||||
|
sv->error = error;
|
||||||
|
sv->label = eina_stringshare_add(label);
|
||||||
|
|
||||||
|
sd->special_values = eina_list_append(sd->special_values, sv);
|
||||||
|
_e_smart_format_update(sd);
|
||||||
|
}
|
||||||
|
|
||||||
/* local subsystem functions */
|
/* local subsystem functions */
|
||||||
static int
|
static int
|
||||||
|
@ -301,23 +326,31 @@ _e_smart_value_limit(E_Smart_Data *sd)
|
||||||
static void
|
static void
|
||||||
_e_smart_format_update(E_Smart_Data *sd)
|
_e_smart_format_update(E_Smart_Data *sd)
|
||||||
{
|
{
|
||||||
|
const E_Slider_Special_Value *sv;
|
||||||
|
const Eina_List *l;
|
||||||
|
|
||||||
|
EINA_LIST_FOREACH(sd->special_values, l, sv)
|
||||||
|
if (fabs(sd->val - sv->value) <= sv->error)
|
||||||
|
{
|
||||||
|
edje_object_part_text_set(sd->edje_obj, "e.text.label", sv->label);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (sd->format)
|
if (sd->format)
|
||||||
{
|
{
|
||||||
char buf[256];
|
char buf[256];
|
||||||
|
|
||||||
snprintf(buf, sizeof(buf), sd->format, sd->val);
|
snprintf(buf, sizeof(buf), sd->format, sd->val);
|
||||||
edje_object_part_text_set(sd->edje_obj, "e.text.label", buf);
|
edje_object_part_text_set(sd->edje_obj, "e.text.label", buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_e_smart_signal_cb_drag(void *data, Evas_Object *obj, const char *emission, const char *source)
|
_e_smart_signal_cb_drag(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
|
||||||
{
|
{
|
||||||
E_Smart_Data *sd;
|
E_Smart_Data *sd = data;
|
||||||
double pval;
|
double pval = sd->val;
|
||||||
|
|
||||||
sd = data;
|
|
||||||
pval = sd->val;
|
|
||||||
_e_smart_value_fetch(sd);
|
_e_smart_value_fetch(sd);
|
||||||
_e_smart_value_limit(sd);
|
_e_smart_value_limit(sd);
|
||||||
_e_smart_format_update(sd);
|
_e_smart_format_update(sd);
|
||||||
|
@ -326,13 +359,11 @@ _e_smart_signal_cb_drag(void *data, Evas_Object *obj, const char *emission, cons
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_e_smart_signal_cb_drag_start(void *data, Evas_Object *obj, const char *emission, const char *source)
|
_e_smart_signal_cb_drag_start(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
|
||||||
{
|
{
|
||||||
E_Smart_Data *sd;
|
E_Smart_Data *sd = data;
|
||||||
double pval;
|
double pval = sd->val;
|
||||||
|
|
||||||
sd = data;
|
|
||||||
pval = sd->val;
|
|
||||||
_e_smart_value_fetch(sd);
|
_e_smart_value_fetch(sd);
|
||||||
_e_smart_value_limit(sd);
|
_e_smart_value_limit(sd);
|
||||||
_e_smart_format_update(sd);
|
_e_smart_format_update(sd);
|
||||||
|
@ -341,13 +372,11 @@ _e_smart_signal_cb_drag_start(void *data, Evas_Object *obj, const char *emission
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_e_smart_signal_cb_drag_stop(void *data, Evas_Object *obj, const char *emission, const char *source)
|
_e_smart_signal_cb_drag_stop(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
|
||||||
{
|
{
|
||||||
E_Smart_Data *sd;
|
E_Smart_Data *sd = data;
|
||||||
double pval;
|
double pval = sd->val;
|
||||||
|
|
||||||
sd = data;
|
|
||||||
pval = sd->val;
|
|
||||||
_e_smart_value_fetch(sd);
|
_e_smart_value_fetch(sd);
|
||||||
_e_smart_value_limit(sd);
|
_e_smart_value_limit(sd);
|
||||||
_e_smart_format_update(sd);
|
_e_smart_format_update(sd);
|
||||||
|
@ -357,13 +386,11 @@ _e_smart_signal_cb_drag_stop(void *data, Evas_Object *obj, const char *emission,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_e_smart_event_key_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
_e_smart_event_key_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
|
||||||
{
|
{
|
||||||
Evas_Event_Key_Down *ev;
|
Evas_Event_Key_Down *ev = event_info;
|
||||||
E_Smart_Data *sd;
|
E_Smart_Data *sd = data;
|
||||||
|
|
||||||
sd = data;
|
|
||||||
ev = event_info;
|
|
||||||
if ((!strcmp(ev->keyname, "Up")) ||
|
if ((!strcmp(ev->keyname, "Up")) ||
|
||||||
(!strcmp(ev->keyname, "KP_Up")) ||
|
(!strcmp(ev->keyname, "KP_Up")) ||
|
||||||
(!strcmp(ev->keyname, "Left")) ||
|
(!strcmp(ev->keyname, "Left")) ||
|
||||||
|
@ -460,10 +487,17 @@ _e_smart_add(Evas_Object *obj)
|
||||||
static void
|
static void
|
||||||
_e_smart_del(Evas_Object *obj)
|
_e_smart_del(Evas_Object *obj)
|
||||||
{
|
{
|
||||||
|
E_Slider_Special_Value *sv;
|
||||||
|
|
||||||
INTERNAL_ENTRY;
|
INTERNAL_ENTRY;
|
||||||
evas_object_del(sd->edje_obj);
|
evas_object_del(sd->edje_obj);
|
||||||
if (sd->format) eina_stringshare_del(sd->format);
|
if (sd->format) eina_stringshare_del(sd->format);
|
||||||
if (sd->set_timer) ecore_timer_del(sd->set_timer);
|
if (sd->set_timer) ecore_timer_del(sd->set_timer);
|
||||||
|
EINA_LIST_FREE(sd->special_values, sv)
|
||||||
|
{
|
||||||
|
eina_stringshare_del(sv->label);
|
||||||
|
free(sv);
|
||||||
|
}
|
||||||
free(sd);
|
free(sd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -529,24 +563,19 @@ _e_smart_init(void)
|
||||||
{
|
{
|
||||||
if (_e_smart) return;
|
if (_e_smart) return;
|
||||||
{
|
{
|
||||||
static const Evas_Smart_Class sc =
|
static Evas_Smart_Class sc = EVAS_SMART_CLASS_INIT_NAME_VERSION(SMART_NAME);
|
||||||
|
if (!sc.add)
|
||||||
{
|
{
|
||||||
SMART_NAME,
|
sc.add = _e_smart_add;
|
||||||
EVAS_SMART_CLASS_VERSION,
|
sc.del = _e_smart_del;
|
||||||
_e_smart_add,
|
sc.move = _e_smart_move;
|
||||||
_e_smart_del,
|
sc.resize = _e_smart_resize;
|
||||||
_e_smart_move,
|
sc.show = _e_smart_show;
|
||||||
_e_smart_resize,
|
sc.hide = _e_smart_hide;
|
||||||
_e_smart_show,
|
sc.color_set = _e_smart_color_set;
|
||||||
_e_smart_hide,
|
sc.clip_set = _e_smart_clip_set;
|
||||||
_e_smart_color_set,
|
sc.clip_unset = _e_smart_clip_unset;
|
||||||
_e_smart_clip_set,
|
}
|
||||||
_e_smart_clip_unset,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
_e_smart = evas_smart_class_new(&sc);
|
_e_smart = evas_smart_class_new(&sc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,5 +23,7 @@ EAPI void e_slider_direction_set (Evas_Object *obj, int rever
|
||||||
EAPI int e_slider_direction_get (Evas_Object *obj);
|
EAPI int e_slider_direction_get (Evas_Object *obj);
|
||||||
EAPI void e_slider_size_min_get (Evas_Object *obj, Evas_Coord *minw, Evas_Coord *minh);
|
EAPI void e_slider_size_min_get (Evas_Object *obj, Evas_Coord *minw, Evas_Coord *minh);
|
||||||
EAPI Evas_Object *e_slider_edje_object_get (Evas_Object *obj);
|
EAPI Evas_Object *e_slider_edje_object_get (Evas_Object *obj);
|
||||||
|
|
||||||
|
EAPI void e_slider_special_value_add (Evas_Object *obj, double value, double error, const char *label);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -147,6 +147,15 @@ e_widget_slider_value_int_get(Evas_Object *slider, int *ival)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EAPI void
|
||||||
|
e_widget_slider_special_value_add(Evas_Object *obj, double value, double error, const char *label)
|
||||||
|
{
|
||||||
|
E_Widget_Data *wd;
|
||||||
|
|
||||||
|
wd = e_widget_data_get(obj);
|
||||||
|
e_slider_special_value_add(wd->o_slider, value, error, label);
|
||||||
|
}
|
||||||
|
|
||||||
/* Private functions */
|
/* Private functions */
|
||||||
static void
|
static void
|
||||||
_e_wid_del_hook(Evas_Object *obj)
|
_e_wid_del_hook(Evas_Object *obj)
|
||||||
|
@ -176,13 +185,13 @@ _e_wid_focus_hook(Evas_Object *obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_e_wid_focus_steal(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
_e_wid_focus_steal(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
||||||
{
|
{
|
||||||
e_widget_focus_steal(data);
|
e_widget_focus_steal(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_e_wid_cb_changed(void *data, Evas_Object *obj, void *event_info)
|
_e_wid_cb_changed(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
||||||
{
|
{
|
||||||
E_Widget_Data *wd;
|
E_Widget_Data *wd;
|
||||||
|
|
||||||
|
|
|
@ -12,5 +12,7 @@ EAPI int e_widget_slider_value_int_set(Evas_Object *slider, int ival);
|
||||||
EAPI int e_widget_slider_value_double_get(Evas_Object *slider, double *dval);
|
EAPI int e_widget_slider_value_double_get(Evas_Object *slider, double *dval);
|
||||||
EAPI int e_widget_slider_value_int_get(Evas_Object *slider, int *ival);
|
EAPI int e_widget_slider_value_int_get(Evas_Object *slider, int *ival);
|
||||||
|
|
||||||
|
EAPI void e_widget_slider_special_value_add(Evas_Object *obj, double value, double error, const char *label);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue