aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmitesh Singh <amitesh.sh@samsung.com>2016-03-23 12:38:56 +0530
committerAmitesh Singh <amitesh.sh@samsung.com>2016-03-23 15:12:25 +0530
commit8df09156348d7e095fc1120fc8f39b6971e2961c (patch)
treee3387eec3f33a71048ef5881e022ee47af149e29
parentslider: add test for range (diff)
downloadelementary-devs/ami/range.tar.gz
slider: rename APIsdevs/ami/range
range_set/get --> property range_enabled_set/get
-rw-r--r--src/bin/test_slider.c107
-rw-r--r--src/lib/elm_slider.c51
-rw-r--r--src/lib/elm_slider.eo25
3 files changed, 135 insertions, 48 deletions
diff --git a/src/bin/test_slider.c b/src/bin/test_slider.c
index b9fa0ba0a..6038dac3c 100644
--- a/src/bin/test_slider.c
+++ b/src/bin/test_slider.c
@@ -58,10 +58,20 @@ _step_size_calculate(double min, double max)
return step;
}
+static void
+_change_range_print_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
+{
+ double from, to;
+
+ elm_slider_range_get(obj, &from, &to);
+
+ printf("range values:- from: %f, to: %f\n", from, to);
+}
+
void
test_slider(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
- Evas_Object *win, *fr, *bx, *sl, *ic, *sl1, *bx2, *bx3, *bt;
+ Evas_Object *win, *fr, *bx, *sl, *ic, *sl1, *bx2, *bx3, *bx4, *bt;
double step;
char buf[PATH_MAX];
@@ -264,7 +274,6 @@ test_slider(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
elm_slider_span_size_set(sl, 60);
evas_object_size_hint_align_set(sl, 0.5, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(sl, 0.0, EVAS_HINT_EXPAND);
- elm_slider_indicator_show_set(sl, EINA_FALSE);
elm_slider_value_set(sl, 0.2);
elm_object_scale_set(sl, 1.0);
elm_slider_horizontal_set(sl, EINA_FALSE);
@@ -323,8 +332,8 @@ test_slider(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, 0.0);
elm_object_disabled_set(sl, EINA_TRUE);
- elm_slider_range_enable_set(sl, EINA_TRUE);
- elm_slider_range_value_set(sl, 20, 100);
+ elm_slider_range_enabled_set(sl, EINA_TRUE);
+ elm_slider_range_set(sl, 20, 100);
elm_box_pack_end(bx3, sl);
evas_object_show(sl);
@@ -337,8 +346,8 @@ test_slider(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
elm_slider_indicator_format_set(sl, "%1.5f");
elm_slider_span_size_set(sl, 160);
elm_slider_value_set(sl, 0.7);
- elm_slider_range_enable_set(sl, EINA_TRUE);
- elm_slider_range_value_set(sl, 0.4, 0.9);
+ elm_slider_range_enabled_set(sl, EINA_TRUE);
+ elm_slider_range_set(sl, 0.4, 0.9);
elm_box_pack_end(bx3, sl);
evas_object_show(sl);
@@ -352,7 +361,7 @@ test_slider(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
elm_slider_step_set(sl, step);
evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, 0.0);
- elm_slider_range_enable_set(sl, EINA_TRUE);
+ elm_slider_range_enabled_set(sl, EINA_TRUE);
elm_box_pack_end(bx3, sl);
evas_object_show(sl);
@@ -367,7 +376,7 @@ test_slider(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
elm_slider_indicator_show_on_focus_set(sl, EINA_TRUE);
evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, 0.0);
- elm_slider_range_enable_set(sl, EINA_TRUE);
+ elm_slider_range_enabled_set(sl, EINA_TRUE);
elm_box_pack_end(bx3, sl);
evas_object_show(sl);
@@ -385,11 +394,10 @@ test_slider(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
elm_slider_span_size_set(sl, 120);
evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, 0.0);
- elm_slider_range_enable_set(sl, EINA_TRUE);
+ elm_slider_range_enabled_set(sl, EINA_TRUE);
elm_box_pack_end(bx3, sl);
evas_object_show(sl);
-
ic = elm_icon_add(bx3);
snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
elm_image_file_set(ic, buf, NULL);
@@ -406,9 +414,7 @@ test_slider(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
elm_slider_inverted_set(sl, EINA_TRUE);
evas_object_size_hint_align_set(sl, 0.5, 0.5);
evas_object_size_hint_weight_set(sl, 0.0, 0.0);
- //TODO:
- //evas_object_smart_callback_add(sl, "delay,changed", _delay_change_cb, NULL);
- elm_slider_range_enable_set(sl, EINA_TRUE);
+ elm_slider_range_enabled_set(sl, EINA_TRUE);
elm_box_pack_end(bx3, sl);
evas_object_show(sl);
@@ -428,7 +434,7 @@ test_slider(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
elm_object_disabled_set(sl, EINA_TRUE);
evas_object_size_hint_align_set(sl, 0.5, 0.5);
evas_object_size_hint_weight_set(sl, 0.0, 0.0);
- elm_slider_range_enable_set(sl, EINA_TRUE);
+ elm_slider_range_enabled_set(sl, EINA_TRUE);
elm_slider_inverted_set(sl, EINA_TRUE);
elm_box_pack_end(bx3, sl);
evas_object_show(sl);
@@ -444,10 +450,79 @@ test_slider(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
elm_slider_min_max_set(sl, 50, 150);
elm_slider_value_set(sl, 80);
elm_object_scale_set(sl, 2.0);
- elm_slider_range_enable_set(sl, EINA_TRUE);
- elm_slider_range_value_set(sl, 100, 145);
+ elm_slider_range_enabled_set(sl, EINA_TRUE);
+ elm_slider_range_set(sl, 100, 145);
elm_box_pack_end(bx3, sl);
evas_object_show(sl);
+ //Vertical
+ bx4 = elm_box_add(bx);
+ evas_object_size_hint_weight_set(bx4, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(bx4, 0.5, EVAS_HINT_FILL);
+ elm_box_horizontal_set(bx4, EINA_TRUE);
+ elm_box_pack_end(bx3, bx4);
+ evas_object_show(bx4);
+
+ sl = elm_slider_add(bx4);
+ elm_slider_range_enabled_set(sl, EINA_TRUE);
+ elm_slider_range_set(sl, 0.2, 0.9);
+ elm_slider_horizontal_set(sl, EINA_FALSE);
+ elm_object_text_set(sl, "Vertical");
+ elm_slider_unit_format_set(sl, "%1.1f units");
+ elm_slider_span_size_set(sl, 60);
+ evas_object_size_hint_align_set(sl, 0.5, EVAS_HINT_FILL);
+ evas_object_size_hint_weight_set(sl, 0.0, EVAS_HINT_EXPAND);
+ elm_slider_indicator_format_set(sl, "%1.1f");
+ elm_object_scale_set(sl, 1.0);
+ evas_object_smart_callback_add(sl, "changed", _change_range_print_cb, sl);
+ elm_box_pack_end(bx4, sl);
+ evas_object_show(sl);
+
+ ic = elm_icon_add(bx4);
+ snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
+ elm_image_file_set(ic, buf, NULL);
+ evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_HORIZONTAL, 1, 1);
+ evas_object_show(ic);
+
+ sl = elm_slider_add(bx4);
+ elm_slider_unit_format_set(sl, "%1.1f units");
+ elm_object_text_set(sl, "Vertical inverted");
+ elm_slider_inverted_set(sl, EINA_TRUE);
+ elm_slider_span_size_set(sl, 60);
+ evas_object_size_hint_align_set(sl, 0.5, EVAS_HINT_FILL);
+ evas_object_size_hint_weight_set(sl, 0.0, EVAS_HINT_EXPAND);
+ elm_slider_indicator_format_set(sl, "%1.1f");
+ elm_slider_value_set(sl, 0.2);
+ elm_object_scale_set(sl, 1.0);
+ elm_slider_horizontal_set(sl, EINA_FALSE);
+ elm_slider_range_enabled_set(sl, EINA_TRUE);
+ elm_box_pack_end(bx4, sl);
+ evas_object_show(sl);
+ elm_slider_min_max_set(sl, 50, 150);
+ elm_slider_range_set(sl, 100, 130);
+
+ ic = elm_icon_add(bx4);
+ snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
+ elm_image_file_set(ic, buf, NULL);
+ evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_HORIZONTAL, 1, 1);
+ evas_object_show(ic);
+
+ sl = elm_slider_add(bx4);
+ elm_object_part_content_set(sl, "icon", ic);
+ elm_object_text_set(sl, "Disabled vertical");
+ elm_slider_inverted_set(sl, EINA_TRUE);
+ elm_slider_unit_format_set(sl, "%1.1f units");
+ elm_slider_span_size_set(sl, 100);
+ evas_object_size_hint_align_set(sl, 0.5, EVAS_HINT_FILL);
+ evas_object_size_hint_weight_set(sl, 0.0, EVAS_HINT_EXPAND);
+ elm_slider_indicator_format_set(sl, "%1.1f");
+ elm_object_scale_set(sl, 1.0);
+ elm_slider_horizontal_set(sl, EINA_FALSE);
+ elm_object_disabled_set(sl, EINA_TRUE);
+ elm_slider_range_enabled_set(sl, EINA_TRUE);
+ elm_slider_range_set(sl, 0.2, 0.9);
+ elm_box_pack_end(bx4, sl);
+ evas_object_show(sl);
+
evas_object_show(win);
}
diff --git a/src/lib/elm_slider.c b/src/lib/elm_slider.c
index 3cabaff94..773630564 100644
--- a/src/lib/elm_slider.c
+++ b/src/lib/elm_slider.c
@@ -208,7 +208,16 @@ _units_set(Evas_Object *obj)
{
char buf[1024];
- snprintf(buf, sizeof(buf), sd->units, sd->val);
+ if (!sd->range_enable)
+ snprintf(buf, sizeof(buf), sd->units, sd->val);
+ else
+ {
+ double v1, v2;
+
+ elm_slider_range_get(obj, &v1, &v2);
+ snprintf(buf, sizeof(buf), sd->units, v2 - v1);
+ }
+
elm_layout_text_set(obj, "elm.units", buf);
if (!sd->units_show)
{
@@ -737,6 +746,11 @@ _elm_slider_elm_widget_theme_apply(Eo *obj, Elm_Slider_Data *sd)
(sd->spacer, 1, (double)sd->size * elm_widget_scale_get(obj) *
elm_config_scale_get());
+ if (sd->range_enable)
+ elm_layout_signal_emit(obj, "elm,slider,range,enable", "elm");
+ else
+ elm_layout_signal_emit(obj, "elm,slider,range,disable", "elm");
+
if (sd->inverted)
{
elm_layout_signal_emit(obj, "elm,state,inverted,on", "elm");
@@ -753,6 +767,7 @@ _elm_slider_elm_widget_theme_apply(Eo *obj, Elm_Slider_Data *sd)
if (sd->popup2)
edje_object_signal_emit(sd->popup2, "elm,state,val,show", "elm");
}
+
_min_max_set(obj);
_units_set(obj);
_indicator_set(obj);
@@ -790,6 +805,7 @@ _spacer_down_cb(void *data,
{
ELM_SLIDER_DATA_GET(data, sd);
+ //TODO: implement for range too
if (sd->range_enable) return;
Evas_Event_Mouse_Down *ev = event_info;
@@ -833,6 +849,7 @@ _spacer_move_cb(void *data,
{
ELM_SLIDER_DATA_GET(data, sd);
+ //TODO: implement for range too
if (sd->range_enable) return;
Evas_Coord x, y, w, h;
@@ -900,6 +917,7 @@ _spacer_up_cb(void *data,
{
ELM_SLIDER_DATA_GET(data, sd);
+ //TODO: implement for range too
if (sd->range_enable) return;
if (!sd->spacer_down) return;
if (sd->spacer_down) sd->spacer_down = EINA_FALSE;
@@ -1105,13 +1123,13 @@ _elm_slider_elm_layout_content_aliases_get(Eo *obj EINA_UNUSED, Elm_Slider_Data
}
EOLIAN static Eina_Bool
-_elm_slider_range_enable_get(Eo *obj EINA_UNUSED, Elm_Slider_Data *pd)
+_elm_slider_range_enabled_get(Eo *obj EINA_UNUSED, Elm_Slider_Data *pd)
{
return pd->range_enable;
}
EOLIAN static void
-_elm_slider_range_enable_set(Eo *obj, Elm_Slider_Data *sd, Eina_Bool enable)
+_elm_slider_range_enabled_set(Eo *obj, Elm_Slider_Data *sd, Eina_Bool enable)
{
if (sd->range_enable == enable) return;
@@ -1131,23 +1149,24 @@ _elm_slider_range_enable_set(Eo *obj, Elm_Slider_Data *sd, Eina_Bool enable)
}
EOLIAN static void
-_elm_slider_range_value_get(Eo *obj EINA_UNUSED, Elm_Slider_Data *pd, double *from, double *to)
+_elm_slider_range_get(Eo *obj EINA_UNUSED, Elm_Slider_Data *pd, double *from, double *to)
{
- if (from) *from = pd->range_from;
- if (to) *to = pd->range_to;
+ if (from) *from = fmin(pd->range_from, pd->range_to);
+ if (to) *to = fmax(pd->range_from, pd->range_to);
}
-EOLIAN static Eina_Bool
-_elm_slider_range_value_set(Eo *obj, Elm_Slider_Data *pd, double from, double to)
+EOLIAN static void
+_elm_slider_range_set(Eo *obj, Elm_Slider_Data *pd, double from, double to)
{
pd->range_from = from;
//TODO: remove val later
pd->val = from;
pd->range_to = to;
- _visuals_refresh(obj);
+ if (pd->range_from < pd->val_min) pd->range_from = pd->val_min;
+ if (pd->range_to > pd->val_max) pd->range_to = pd->val_max;
- return EINA_TRUE;
+ _visuals_refresh(obj);
}
EAPI Evas_Object *
@@ -1213,6 +1232,8 @@ _elm_slider_unit_format_set(Eo *obj, Elm_Slider_Data *sd, const char *units)
edje_object_message_signal_process(wd->resize_obj);
if (sd->popup)
edje_object_signal_emit(sd->popup, "elm,state,units,visible", "elm");
+ if (sd->popup2)
+ edje_object_signal_emit(sd->popup2, "elm,state,units,visible", "elm");
}
else
{
@@ -1220,6 +1241,8 @@ _elm_slider_unit_format_set(Eo *obj, Elm_Slider_Data *sd, const char *units)
edje_object_message_signal_process(wd->resize_obj);
if (sd->popup)
edje_object_signal_emit(sd->popup, "elm,state,units,hidden", "elm");
+ if (sd->popup2)
+ edje_object_signal_emit(sd->popup2, "elm,state,units,hidden", "elm");
}
evas_object_smart_changed(obj);
}
@@ -1294,13 +1317,7 @@ _elm_slider_value_set(Eo *obj, Elm_Slider_Data *sd, double val)
EOLIAN static double
_elm_slider_value_get(Eo *obj EINA_UNUSED, Elm_Slider_Data *sd)
{
- double val;
-
- if (!sd->range_enable)
- val = sd->val;
- else
- val = sd->range_to - sd->range_from;
- return val;
+ return sd->val;
}
EOLIAN static void
diff --git a/src/lib/elm_slider.eo b/src/lib/elm_slider.eo
index 305d64fbe..213fd44ee 100644
--- a/src/lib/elm_slider.eo
+++ b/src/lib/elm_slider.eo
@@ -263,7 +263,7 @@ class Elm.Slider (Elm.Layout, Elm.Interface_Atspi_Value,
free_func: slider_freefunc_type @nullable; [[The freeing function for the format string.]]
}
}
- @property range_enable {
+ @property range_enabled {
set {
[[Enable range]]
}
@@ -274,21 +274,16 @@ class Elm.Slider (Elm.Layout, Elm.Interface_Atspi_Value,
enable: Eina_Bool;
}
}
- range_value_get {
- [[Get range between two indicator
- ]]
- params {
- @out from: double;
- @out to: double;
+ @property range {
+ set {
+ [[Set range between two indicators.]]
}
- }
- range_value_set {
- [[Set range between two indicators from to to
- ]]
- return: Eina_Bool;
- params {
- @in from: double;
- @in to: double;
+ get {
+ [[Get range between two indicator.]]
+ }
+ values {
+ from: double; [[]]
+ to: double; [[]]
}
}
}