Hello all,
I just made my first attempt to improve Elementary.
The attached patch adds an indicator format callback function for
showing a more versatile indicator string. It also sends drag
start/stop signals when the dragging starts and ends.
This is useful for showing a music playback progress slider.
When the slider indicator is being dragged, the indicator would show
the "seek position" in time. When the dragging is stopped, the music
player can then seek to the correct position.
I couldn't figure out how to do this with elm_slider, so I just added
these lines.
I don't know if this is the proper way to submit patches. Advices are
welcome. :-)
Brian
--
brian
------------------
Cool-Karaoke - The smallest recording studio, in your palm, open-sourced
http://cool-idea.com.tw/
iMaGiNaTiOn iS mOrE iMpOrTaNt tHaN kNoWlEdGe
Index: elementary/src/lib/elm_slider.c
===================================================================
--- elementary/src/lib/elm_slider.c (revision 43175)
+++ elementary/src/lib/elm_slider.c (working copy)
@@ -16,6 +16,10 @@
* period or when they release their finger/mouse, so it avoids possibly
* expensive reactions to the value change.
*
+ * slider,drag,start - dragging the slider indicator around has started
+ *
+ * slider,drag,stop - dragging the slider indicator around has stopped
+ *
* A slider can be horizontal or vertical. It can contain an Icon and has a
* primary label as well as a units label (that is formatted with floating
* point values and thus accepts a printf-style format string, like
@@ -45,6 +49,7 @@
const char *label;
const char *units;
const char *indicator;
+ const char *(*indicator_format_func)(double val);
Eina_Bool horizontal : 1;
Eina_Bool inverted : 1;
double val, val_min, val_max;
@@ -206,8 +211,15 @@
_indicator_set(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
- if (wd->indicator)
+ if (wd->indicator_format_func)
{
+ const char *buf;
+
+ buf = wd->indicator_format_func(wd->val);
+ edje_object_part_text_set(wd->slider, "elm.indicator", buf);
+ }
+ else if (wd->indicator)
+ {
char buf[1024];
snprintf(buf, sizeof(buf), wd->indicator, wd->val);
@@ -229,6 +241,7 @@
_drag_start(void *data, Evas_Object *obj, const char *emission, const char *source)
{
_val_fetch(data);
+ evas_object_smart_callback_call(data, "slider,drag,start", NULL);
_units_set(data);
_indicator_set(data);
}
@@ -237,6 +250,7 @@
_drag_stop(void *data, Evas_Object *obj, const char *emission, const char *source)
{
_val_fetch(data);
+ evas_object_smart_callback_call(data, "slider,drag,stop", NULL);
_units_set(data);
_indicator_set(data);
}
@@ -579,3 +593,24 @@
_units_set(obj);
_indicator_set(obj);
}
+
+/**
+ * Set the format function pointer for the inducator area
+ *
+ * Set the callback function to format the indicator string.
+ * See elm_slider_indicator_format_set() for more info on how this works.
+ *
+ * @param obj The slider object
+ * @param indicator The format string for the indicator display
+ * @param func The indicator format function
+ *
+ * @ingroup Slider
+ */
+EAPI void
+elm_slider_indicator_format_function_set(Evas_Object *obj, const char *(*func)(double val))
+{
+ Widget_Data *wd = elm_widget_data_get(obj);
+ wd->indicator_format_func = func;
+ _indicator_set(obj);
+}
+
Index: elementary/src/lib/Elementary.h.in
===================================================================
--- elementary/src/lib/Elementary.h.in (revision 43175)
+++ elementary/src/lib/Elementary.h.in (working copy)
@@ -709,6 +709,7 @@
EAPI void elm_slider_span_size_set(Evas_Object *obj, Evas_Coord size);
EAPI void elm_slider_unit_format_set(Evas_Object *obj, const char *format);
EAPI void elm_slider_indicator_format_set(Evas_Object *obj, const char *indicator);
+ EAPI void elm_slider_indicator_format_function_set(Evas_Object *obj, const char *(*func)(double val));
EAPI void elm_slider_horizontal_set(Evas_Object *obj, Eina_Bool horizontal);
EAPI void elm_slider_min_max_set(Evas_Object *obj, double min, double max);
EAPI void elm_slider_value_set(Evas_Object *obj, double val);
@@ -717,6 +718,8 @@
/* smart callbacks called:
* "changed" - when the slider value changes
* "delay,changed" - when the slider value changed, but a small time after a change (use this if you only want to respond to a change once the slider is held still for a short while).
+ * "slider,drag,start" - dragging the slider indicator around has started
+ * "slider,drag,stop" - dragging the slider indicator around has stopped
*/
typedef enum _Elm_Genlist_Item_Flags
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel