Add setters and getters to interval for elm spinner and clock
authorBruno Dilly <bdilly@profusion.mobi>
Tue, 20 Jul 2010 21:38:17 +0000 (21:38 +0000)
committerBruno Dilly <bdilly@profusion.mobi>
Tue, 20 Jul 2010 21:38:17 +0000 (21:38 +0000)
SVN revision: 50392

src/lib/Elementary.h.in
src/lib/elm_clock.c
src/lib/elm_spinner.c

index 4c02df6..524d901 100644 (file)
@@ -653,6 +653,8 @@ extern "C" {
    EAPI Eina_Bool    elm_clock_show_am_pm_get(const Evas_Object *obj);
    EAPI void         elm_clock_show_seconds_set(Evas_Object *obj, Eina_Bool seconds);
    EAPI Eina_Bool    elm_clock_show_seconds_get(const Evas_Object *obj);
+   EAPI void        elm_clock_interval_set(Evas_Object *obj, double interval);
+   EAPI double      elm_clock_interval_get(const Evas_Object *obj);
    /* smart callbacks called:
     * "changed" - the user changed the time
     */
@@ -1304,6 +1306,8 @@ extern "C" {
    EAPI void        elm_spinner_editable_set(Evas_Object *obj, Eina_Bool editable);
    EAPI Eina_Bool    elm_spinner_editable_get(const Evas_Object *obj);
    EAPI void        elm_spinner_special_value_add(Evas_Object *obj, double value, const char *label);
+   EAPI void        elm_spinner_interval_set(Evas_Object *obj, double interval);
+   EAPI double      elm_spinner_interval_get(const Evas_Object *obj);
    /* smart callbacks called:
     * "changed" - when the spinner value changes
     * "delay,changed" - when the spinner value changed, but a small time after a change (use this if you only want to respond to a change once the spinner is held still for a short while).
index 2d4dee7..9f86fd3 100644 (file)
@@ -14,7 +14,7 @@ typedef struct _Widget_Data Widget_Data;
 struct _Widget_Data
 {
    Evas_Object *clk;
-   double interval;
+   double interval, first_interval;
    Eina_Bool seconds : 1;
    Eina_Bool am_pm : 1;
    Eina_Bool edit : 1;
@@ -265,7 +265,7 @@ _signal_clock_val_up_start(void *data, Evas_Object *obj, const char *emission __
 {
    Widget_Data *wd = elm_widget_data_get(data);
    if (!wd) return;
-   wd->interval = 0.85;
+   wd->interval = wd->first_interval;
    wd->sel_obj = obj;
    if (wd->spin) ecore_timer_del(wd->spin);
    wd->spin = ecore_timer_add(wd->interval, _signal_clock_val_up, data);
@@ -277,7 +277,7 @@ _signal_clock_val_down_start(void *data, Evas_Object *obj, const char *emission
 {
    Widget_Data *wd = elm_widget_data_get(data);
    if (!wd) return;
-   wd->interval = 0.85;
+   wd->interval = wd->first_interval;
    wd->sel_obj = obj;
    if (wd->spin) ecore_timer_del(wd->spin);
    wd->spin = ecore_timer_add(wd->interval, _signal_clock_val_down, data);
@@ -531,6 +531,7 @@ elm_clock_add(Evas_Object *parent)
    wd->cur.am_pm = EINA_TRUE;
    wd->cur.edit = EINA_TRUE;
    wd->cur.digedit = ELM_CLOCK_NONE;
+   wd->first_interval = 0.85;
 
    _time_update(obj);
    _ticker(obj);
@@ -763,3 +764,45 @@ elm_clock_show_seconds_get(const Evas_Object *obj)
    if (!wd) return EINA_FALSE;
    return wd->seconds;
 }
+
+/**
+ * Set the interval for the clock
+ *
+ * @param obj The clock object
+ * @param interval The interval value in seconds
+ *
+ * The interval value is decreased while the user increments or decrements
+ * the clock value. The next interval value is the previous interval / 1.05,
+ * so it speed up a bit. Default value is 0.85 seconds.
+ *
+ * @ingroup Clock
+ */
+EAPI void
+elm_clock_interval_set(Evas_Object *obj, double interval)
+{
+   ELM_CHECK_WIDTYPE(obj, widtype);
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return;
+   wd->first_interval = interval;
+}
+
+/**
+ * Get the interval of the clock
+ *
+ * @param obj The clock object
+ * @return The value of the first interval in seconds
+ *
+ * The interval value is decreased while the user increments or decrements
+ * the clock value. The next interval value is the previous interval / 1.05,
+ * so it speed up a bit. Default value is 0.85 seconds.
+ *
+ * @ingroup Clock
+ */
+EAPI double
+elm_clock_interval_get(const Evas_Object *obj)
+{
+   ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return 0.0;
+   return wd->first_interval;
+}
index d896b46..76e4d7b 100644 (file)
@@ -30,7 +30,7 @@ struct _Widget_Data
    Evas_Object *spinner, *ent;
    const char *label;
    double val, val_min, val_max, orig_val, step;
-   double drag_start_pos, spin_speed, interval;
+   double drag_start_pos, spin_speed, interval, first_interval;
    Ecore_Timer *delay, *spin;
    Eina_List *special_values;
    Eina_Bool wrap : 1;
@@ -391,7 +391,7 @@ _val_inc_start(Evas_Object *obj)
 {
    Widget_Data *wd = elm_widget_data_get(obj);
    if (!wd) return;
-   wd->interval = 0.85;
+   wd->interval = wd->first_interval;
    wd->spin_speed = wd->step;
    if (wd->spin) ecore_timer_del(wd->spin);
    wd->spin = ecore_timer_add(wd->interval, _spin_value, obj);
@@ -403,7 +403,7 @@ _val_inc_stop(Evas_Object *obj)
 {
    Widget_Data *wd = elm_widget_data_get(obj);
    if (!wd) return;
-   wd->interval = 0.85;
+   wd->interval = wd->first_interval;
    wd->spin_speed = 0;
    if (wd->spin) ecore_timer_del(wd->spin);
    wd->spin = NULL;
@@ -414,7 +414,7 @@ _val_dec_start(Evas_Object *obj)
 {
    Widget_Data *wd = elm_widget_data_get(obj);
    if (!wd) return;
-   wd->interval = 0.85;
+   wd->interval = wd->first_interval;
    wd->spin_speed = -wd->step;
    if (wd->spin) ecore_timer_del(wd->spin);
    wd->spin = ecore_timer_add(wd->interval, _spin_value, obj);
@@ -426,7 +426,7 @@ _val_dec_stop(Evas_Object *obj)
 {
    Widget_Data *wd = elm_widget_data_get(obj);
    if (!wd) return;
-   wd->interval = 0.85;
+   wd->interval = wd->first_interval;
    wd->spin_speed = 0;
    if (wd->spin) ecore_timer_del(wd->spin);
    wd->spin = NULL;
@@ -543,6 +543,7 @@ elm_spinner_add(Evas_Object *parent)
    wd->val_max = 100.0;
    wd->wrap = 0;
    wd->step = 1.0;
+   wd->first_interval = 0.85;
    wd->entry_visible = 0;
    wd->editable = EINA_TRUE;
 
@@ -842,3 +843,45 @@ elm_spinner_editable_get(const Evas_Object *obj)
    if (!wd) return EINA_FALSE;
    return wd->editable;
 }
+
+/**
+ * Set the interval for the spinner
+ *
+ * @param obj The spinner object
+ * @param interval The interval value in seconds
+ *
+ * The interval value is decreased while the user increments or decrements
+ * the spinner value. The next interval value is the previous interval / 1.05,
+ * so it speed up a bit. Default value is 0.85 seconds.
+ *
+ * @ingroup Spinner
+ */
+EAPI void
+elm_spinner_interval_set(Evas_Object *obj, double interval)
+{
+   ELM_CHECK_WIDTYPE(obj, widtype);
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return;
+   wd->first_interval = interval;
+}
+
+/**
+ * Get the interval of the spinner
+ *
+ * @param obj The spinner object
+ * @return The value of the first interval in seconds
+ *
+ * The interval value is decreased while the user increments or decrements
+ * the spinner value. The next interval value is the previous interval / 1.05,
+ * so it speed up a bit. Default value is 0.85 seconds.
+ *
+ * @ingroup Spinner
+ */
+EAPI double
+elm_spinner_interval_get(const Evas_Object *obj)
+{
+   ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return 0.0;
+   return wd->first_interval;
+}