Slider
This feature is supported in wearable applications only.
The slider component contains a draggable bar that is used to select a value within a certain range. It is used with rectangular UI components.
For more information, see the Slider API.
Figure: Slider component
Figure: Slider hierarchy
Adding a Slider Component
To create a slider object:
Evas_Object *slider, *parent; slider = elm_slider_add(parent);
Using the Slider Styles
The slider has the following styles:
- default
Configuring the Slider
To configure the slider:
-
Set icons (elm.swallow.icon partname), a label, a unit label, and an indicator label to the slider:
Evas_Object *icon1, *icon2; // Set the icons elm_object_part_content_set(slider, "elm.swallow.icon", icon1); // Set the unit format elm_slider_unit_format_set(slider, "%1.2f meters");
-
Set the minimum and maximum values to the slider with the elm_slider_min_max_set() function. The current value is set with the elm_slider_value_set() function. The following example sets the minimum value to 0, the maximum value to 100, and the current value to 50.
elm_slider_min_max_set(slider, 0.0, 100.0); elm_slider_value_set(slider, 50.0);
-
Set the slider span with the elm_slider_span_size_set() function. The span of the slider represents its length horizontally. The span is scaled by the object or applications scaling factor.
-
Retrieve the current value of the slider:
double value = elm_slider_value_get(slider);
-
Disable the slider indicator size.
By default, the slider indicator becomes bigger when the user drags it. This can be disabled if you want the slider indicator to keep its default size. The following example sets the state of the indicator enlargement and then inverts the behavior.
// Get the current state of the indicator Eina_Bool enlarge = elm_slider_indicator_show_get(slider); // Invert the behavior elm_slider_indicator_show_set(slider, !enlarge);
Using the Slider Callbacks
The slider component emits the following signals:
- changed: The user changes the slider value.
- slider,drag,start: Dragging the slider indicator around starts.
- slider,drag,stop: Dragging the slider indicator around stops.
- delay,changed: A short time after the user changes the value. This is called only when the user stops dragging for a very short period or when releases the finger or mouse, so that it avoids possibly expensive reactions to the value change.
For all these signals, event_info is NULL.
The following example shows how to register a callback on the changed signal.
{ evas_object_smart_callback_add(slider, "changed", changed_cb, data); } // Callback function for the "changed" signal // This callback is called when the slider value changes void changed_cb(void *data, Evas_Object *obj, void *event_info) { dlog_print(DLOG_INFO, LOG_TAG, "The slider has changed\n"); }
Note |
---|
Except as noted, this content is licensed under LGPLv2.1+. |