From 0881fe06ae09336371906b89fdb6bb35378c804a Mon Sep 17 00:00:00 2001 From: seoz Date: Wed, 7 Mar 2012 14:35:18 +0000 Subject: [PATCH] elm clock: Reviewed clock. Signed-off-by: Daniel Juyung Seo git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/elementary@68962 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/bin/test_clock.c | 20 +++++++------- src/examples/clock_example.c | 4 +-- src/lib/elm_clock.c | 31 +++++++++++---------- src/lib/elm_clock.h | 50 ++++++++++++++++----------------- src/lib/elm_deprecated.h | 66 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 119 insertions(+), 52 deletions(-) diff --git a/src/bin/test_clock.c b/src/bin/test_clock.c index 24336ed..6940242 100644 --- a/src/bin/test_clock.c +++ b/src/bin/test_clock.c @@ -48,16 +48,16 @@ set_api_state(api_data *api) break; case CLOCK_EDIT_MIN: - elm_clock_edit_set(ck, ELM_CLOCK_MIN_DECIMAL | ELM_CLOCK_MIN_UNIT); + elm_clock_edit_set(ck, ELM_CLOCK_EDIT_MIN_DECIMAL | ELM_CLOCK_EDIT_MIN_UNIT); break; case CLOCK_EDIT_HOUR: - elm_clock_edit_set(ck, ELM_CLOCK_NONE); - elm_clock_edit_set(ck, ELM_CLOCK_HOUR_DECIMAL | ELM_CLOCK_HOUR_UNIT); + elm_clock_edit_set(ck, ELM_CLOCK_EDIT_DEFAULT); + elm_clock_edit_set(ck, ELM_CLOCK_EDIT_HOUR_DECIMAL | ELM_CLOCK_EDIT_HOUR_UNIT); break; case CLOCK_EDIT_ALL: - elm_clock_edit_set(ck, ELM_CLOCK_ALL); + elm_clock_edit_set(ck, ELM_CLOCK_EDIT_ALL); break; case CLOCK_EDIT_ALL_ARMY: @@ -169,8 +169,8 @@ test_clock(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info ck = elm_clock_add(win); elm_clock_show_seconds_set(ck, EINA_TRUE); elm_clock_edit_set(ck, EINA_TRUE); - digedit = ELM_CLOCK_HOUR_UNIT | ELM_CLOCK_MIN_UNIT | ELM_CLOCK_SEC_UNIT; - elm_clock_digit_edit_set(ck, digedit); + digedit = ELM_CLOCK_EDIT_HOUR_UNIT | ELM_CLOCK_EDIT_MIN_UNIT | ELM_CLOCK_EDIT_SEC_UNIT; + elm_clock_edit_mode_set(ck, digedit); elm_box_pack_end(bx, ck); elm_clock_time_set(ck, 0, 0, 0); evas_object_show(ck); @@ -246,7 +246,7 @@ test_clock2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info ck = elm_clock_add(win); elm_clock_time_set(ck, 0, 15, 3); - elm_clock_digit_edit_set(ck, ELM_CLOCK_NONE); + elm_clock_edit_mode_set(ck, ELM_CLOCK_EDIT_DEFAULT); elm_clock_show_seconds_set(ck, EINA_TRUE); elm_clock_show_am_pm_set(ck, EINA_TRUE); elm_box_pack_end(bx, ck); @@ -304,21 +304,21 @@ test_clock3(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info ck = elm_clock_add(win); elm_clock_show_seconds_set(ck, 1); elm_clock_edit_set(ck, EINA_TRUE); - elm_clock_interval_set(ck, 0.4); + elm_clock_first_interval_set(ck, 0.4); elm_box_pack_end(bx, ck); evas_object_show(ck); ck = elm_clock_add(win); elm_clock_show_seconds_set(ck, 1); elm_clock_edit_set(ck, EINA_TRUE); - elm_clock_interval_set(ck, 1.2); + elm_clock_first_interval_set(ck, 1.2); elm_box_pack_end(bx, ck); evas_object_show(ck); ck = elm_clock_add(win); elm_clock_show_seconds_set(ck, 1); elm_clock_edit_set(ck, EINA_TRUE); - elm_clock_interval_set(ck, 2.0); + elm_clock_first_interval_set(ck, 2.0); elm_box_pack_end(bx, ck); evas_object_show(ck); diff --git a/src/examples/clock_example.c b/src/examples/clock_example.c index 43df3e1..b510b17 100644 --- a/src/examples/clock_example.c +++ b/src/examples/clock_example.c @@ -75,8 +75,8 @@ elm_main(int argc __UNUSED__, char **argv __UNUSED__) ck = elm_clock_add(win); elm_clock_show_seconds_set(ck, EINA_TRUE); elm_clock_edit_set(ck, EINA_TRUE); - digedit = ELM_CLOCK_HOUR_UNIT | ELM_CLOCK_MIN_UNIT | ELM_CLOCK_SEC_UNIT; - elm_clock_digit_edit_set(ck, digedit); + digedit = ELM_CLOCK_EDIT_HOUR_UNIT | ELM_CLOCK_EDIT_MIN_UNIT | ELM_CLOCK_EDIT_SEC_UNIT; + elm_clock_edit_mode_set(ck, digedit); elm_box_pack_end(bx, ck); evas_object_show(ck); diff --git a/src/lib/elm_clock.c b/src/lib/elm_clock.c index ad8565b..3bd0b2d 100644 --- a/src/lib/elm_clock.c +++ b/src/lib/elm_clock.c @@ -1,6 +1,7 @@ #include #include "elm_priv.h" +#define DEFAULT_FIRST_INTERVAL 0.85 typedef struct _Widget_Data Widget_Data; struct _Widget_Data @@ -10,7 +11,7 @@ struct _Widget_Data Eina_Bool seconds : 1; Eina_Bool am_pm : 1; Eina_Bool edit : 1; - Elm_Clock_Digedit digedit; + Elm_Clock_Edit_Mode digedit; int hrs, min, sec, timediff; Evas_Object *digit[6]; Evas_Object *ampm; @@ -23,7 +24,7 @@ struct _Widget_Data Eina_Bool seconds : 1; Eina_Bool am_pm : 1; Eina_Bool edit : 1; - Elm_Clock_Digedit digedit; + Elm_Clock_Edit_Mode digedit; } cur; }; @@ -541,8 +542,8 @@ elm_clock_add(Evas_Object *parent) wd->cur.seconds = EINA_TRUE; wd->cur.am_pm = EINA_TRUE; wd->cur.edit = EINA_TRUE; - wd->cur.digedit = ELM_CLOCK_NONE; - wd->first_interval = 0.85; + wd->cur.digedit = ELM_CLOCK_EDIT_DEFAULT; + wd->first_interval = DEFAULT_FIRST_INTERVAL; wd->timediff = 0; _time_update(obj); @@ -586,8 +587,8 @@ elm_clock_edit_set(Evas_Object *obj, Eina_Bool edit) wd->edit = edit; if (!edit) _timediff_set(wd); - if ((edit) && (wd->digedit == ELM_CLOCK_NONE)) - elm_clock_digit_edit_set(obj, ELM_CLOCK_ALL); + if ((edit) && (wd->digedit == ELM_CLOCK_EDIT_DEFAULT)) + elm_clock_edit_mode_set(obj, ELM_CLOCK_EDIT_ALL); else _time_update(obj); } @@ -602,20 +603,20 @@ elm_clock_edit_get(const Evas_Object *obj) } EAPI void -elm_clock_digit_edit_set(Evas_Object *obj, Elm_Clock_Digedit digedit) +elm_clock_edit_mode_set(Evas_Object *obj, Elm_Clock_Edit_Mode digedit) { ELM_CHECK_WIDTYPE(obj, widtype); Widget_Data *wd = elm_widget_data_get(obj); if (!wd) return; wd->digedit = digedit; - if (digedit == ELM_CLOCK_NONE) + if (digedit == ELM_CLOCK_EDIT_DEFAULT) elm_clock_edit_set(obj, EINA_FALSE); else _time_update(obj); } -EAPI Elm_Clock_Digedit -elm_clock_digit_edit_get(const Evas_Object *obj) +EAPI Elm_Clock_Edit_Mode +elm_clock_edit_mode_get(const Evas_Object *obj) { ELM_CHECK_WIDTYPE(obj, widtype) 0; Widget_Data *wd = elm_widget_data_get(obj); @@ -629,7 +630,7 @@ elm_clock_show_am_pm_set(Evas_Object *obj, Eina_Bool am_pm) ELM_CHECK_WIDTYPE(obj, widtype); Widget_Data *wd = elm_widget_data_get(obj); if (!wd) return; - wd->am_pm = am_pm; + wd->am_pm = !!am_pm; _time_update(obj); } @@ -648,7 +649,7 @@ elm_clock_show_seconds_set(Evas_Object *obj, Eina_Bool seconds) ELM_CHECK_WIDTYPE(obj, widtype); Widget_Data *wd = elm_widget_data_get(obj); if (!wd) return; - wd->seconds = seconds; + wd->seconds = !!seconds; _time_update(obj); } @@ -662,16 +663,16 @@ elm_clock_show_seconds_get(const Evas_Object *obj) } EAPI void -elm_clock_interval_set(Evas_Object *obj, double interval) +elm_clock_first_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; + wd->first_interval = !!interval; } EAPI double -elm_clock_interval_get(const Evas_Object *obj) +elm_clock_first_interval_get(const Evas_Object *obj) { ELM_CHECK_WIDTYPE(obj, widtype) 0.0; Widget_Data *wd = elm_widget_data_get(obj); diff --git a/src/lib/elm_clock.h b/src/lib/elm_clock.h index 7cf0620..ecf5c1f 100644 --- a/src/lib/elm_clock.h +++ b/src/lib/elm_clock.h @@ -52,19 +52,19 @@ * make a mask, naturally. * * @see elm_clock_edit_set() - * @see elm_clock_digit_edit_set() + * @see elm_clock_edit_mode_set() */ typedef enum { - ELM_CLOCK_NONE = 0, /**< Default value. Means that all digits are editable, when in edition mode. */ - ELM_CLOCK_HOUR_DECIMAL = 1 << 0, /**< Decimal algarism of hours value should be editable */ - ELM_CLOCK_HOUR_UNIT = 1 << 1, /**< Unit algarism of hours value should be editable */ - ELM_CLOCK_MIN_DECIMAL = 1 << 2, /**< Decimal algarism of minutes value should be editable */ - ELM_CLOCK_MIN_UNIT = 1 << 3, /**< Unit algarism of minutes value should be editable */ - ELM_CLOCK_SEC_DECIMAL = 1 << 4, /**< Decimal algarism of seconds value should be editable */ - ELM_CLOCK_SEC_UNIT = 1 << 5, /**< Unit algarism of seconds value should be editable */ - ELM_CLOCK_ALL = (1 << 6) - 1 /**< All digits should be editable */ -} Elm_Clock_Digedit; + ELM_CLOCK_EDIT_DEFAULT = 0, /**< Default value. Means that all digits are editable, when in edition mode. */ + ELM_CLOCK_EDIT_HOUR_DECIMAL = 1 << 0, /**< Decimal algarism of hours value should be editable */ + ELM_CLOCK_EDIT_HOUR_UNIT = 1 << 1, /**< Unit algarism of hours value should be editable */ + ELM_CLOCK_EDIT_MIN_DECIMAL = 1 << 2, /**< Decimal algarism of minutes value should be editable */ + ELM_CLOCK_EDIT_MIN_UNIT = 1 << 3, /**< Unit algarism of minutes value should be editable */ + ELM_CLOCK_EDIT_SEC_DECIMAL = 1 << 4, /**< Decimal algarism of seconds value should be editable */ + ELM_CLOCK_EDIT_SEC_UNIT = 1 << 5, /**< Unit algarism of seconds value should be editable */ + ELM_CLOCK_EDIT_ALL = (1 << 6) - 1 /**< All digits should be editable */ +} Elm_Clock_Edit_Mode; /** * Add a new clock widget to the given parent Elementary @@ -133,7 +133,7 @@ EAPI void elm_clock_time_get(const Evas_Object *obj, int *hrs, int * This function makes a clock's time to be editable or not by * user interaction. When in edition mode, clocks @b stop * ticking, until one brings them back to canonical mode. The - * elm_clock_digit_edit_set() function will influence which digits + * elm_clock_edit_mode_set() function will influence which digits * of the clock will be editable. By default, all of them will be * (#ELM_CLOCK_NONE). * @@ -168,17 +168,17 @@ EAPI Eina_Bool elm_clock_edit_get(const Evas_Object *obj); * * @param obj The clock object * @param digedit Bit mask indicating the digits to be editable - * (values in #Elm_Clock_Digedit). + * (values in #Elm_Clock_Edit_Mode). * * If the @p digedit param is #ELM_CLOCK_NONE, editing will be * disabled on @p obj (same effect as elm_clock_edit_set(), with @c * EINA_FALSE). * - * @see elm_clock_digit_edit_get() + * @see elm_clock_edit_mode_get() * * @ingroup Clock */ -EAPI void elm_clock_digit_edit_set(Evas_Object *obj, Elm_Clock_Digedit digedit); +EAPI void elm_clock_edit_mode_set(Evas_Object *obj, Elm_Clock_Edit_Mode digedit); /** * Retrieve what digits of the given clock widget should be @@ -186,13 +186,13 @@ EAPI void elm_clock_digit_edit_set(Evas_Object *obj, Elm_Clock_Dige * * @param obj The clock object * @return Bit mask indicating the digits to be editable - * (values in #Elm_Clock_Digedit). + * (values in #Elm_Clock_Edit_Mode). * - * @see elm_clock_digit_edit_set() for more details + * @see elm_clock_edit_mode_set() for more details * * @ingroup Clock */ -EAPI Elm_Clock_Digedit elm_clock_digit_edit_get(const Evas_Object *obj); +EAPI Elm_Clock_Edit_Mode elm_clock_edit_mode_get(const Evas_Object *obj); /** * Set if the given clock widget must show hours in military or @@ -262,11 +262,11 @@ EAPI void elm_clock_show_seconds_set(Evas_Object *obj, Eina_Bool se EAPI Eina_Bool elm_clock_show_seconds_get(const Evas_Object *obj); /** - * Set the interval on time updates for a user mouse button hold + * Set the first interval on time updates for a user mouse button hold * on clock widgets' time edition. * * @param obj The clock object - * @param interval The (first) interval value in seconds + * @param interval The first interval value in seconds * * This interval value is @b decreased while the user holds the * mouse pointer either incrementing or decrementing a given the @@ -283,24 +283,24 @@ EAPI Eina_Bool elm_clock_show_seconds_get(const Evas_Object *obj); * The default starting interval value for automatic flips is * @b 0.85 seconds. * - * @see elm_clock_interval_get() + * @see elm_clock_first_interval_get() * * @ingroup Clock */ -EAPI void elm_clock_interval_set(Evas_Object *obj, double interval); +EAPI void elm_clock_first_interval_set(Evas_Object *obj, double interval); /** - * Get the interval on time updates for a user mouse button hold + * Get the first interval on time updates for a user mouse button hold * on clock widgets' time edition. * * @param obj The clock object - * @return The (first) interval value, in seconds, set on it + * @return The first interval value, in seconds, set on it * - * @see elm_clock_interval_set() for more details + * @see elm_clock_first_interval_set() for more details * * @ingroup Clock */ -EAPI double elm_clock_interval_get(const Evas_Object *obj); +EAPI double elm_clock_first_interval_get(const Evas_Object *obj); /** * @} diff --git a/src/lib/elm_deprecated.h b/src/lib/elm_deprecated.h index 1a96b9d..a365c6c 100644 --- a/src/lib/elm_deprecated.h +++ b/src/lib/elm_deprecated.h @@ -6012,6 +6012,72 @@ EINA_DEPRECATED EAPI void elm_toolbar_no_select_mode_set */ EINA_DEPRECATED EAPI Eina_Bool elm_toolbar_no_select_mode_get(const Evas_Object *obj); +/* + * Set the interval on time updates for a user mouse button hold + * on clock widgets' time edition. + * + * @param obj The clock object + * @param interval The (first) interval value in seconds + * + * This interval value is @b decreased while the user holds the + * mouse pointer either incrementing or decrementing a given the + * clock digit's value. + * + * This helps the user to get to a given time distant from the + * current one easier/faster, as it will start to flip quicker and + * quicker on mouse button holds. + * + * The calculation for the next flip interval value, starting from + * the one set with this call, is the previous interval divided by + * 1.05, so it decreases a little bit. + * + * The default starting interval value for automatic flips is + * @b 0.85 seconds. + * + * @deprecated elm_clock_first_interval_set() + * + */ +EINA_DEPRECATED EAPI void elm_clock_interval_set(Evas_Object *obj, double interval); + +/** + * Get the interval on time updates for a user mouse button hold + * on clock widgets' time edition. + * + * @param obj The clock object + * @return The (first) interval value, in seconds, set on it + * + * @elm_clock_first_interval_get() + */ +EINA_DEPRECATED EAPI double elm_clock_interval_get(const Evas_Object *obj); + +/** + * Set what digits of the given clock widget should be editable + * when in edition mode. + * + * @param obj The clock object + * @param digedit Bit mask indicating the digits to be editable + * (values in #Elm_Clock_Edit_Mode). + * + * If the @p digedit param is #ELM_CLOCK_NONE, editing will be + * disabled on @p obj (same effect as elm_clock_edit_set(), with @c + * EINA_FALSE). + * + * @deprecated elm_clock_edit_mode_set() + */ +EINA_DEPRECATED EAPI void elm_clock_digit_edit_set(Evas_Object *obj, Elm_Clock_Edit_Mode digedit); + +/** + * Retrieve what digits of the given clock widget should be + * editable when in edition mode. + * + * @param obj The clock object + * @return Bit mask indicating the digits to be editable + * (values in #Elm_Clock_Edit_Mode). + * + * @deprecated elm_clock_edit_mode_get() + */ +EINA_DEPRECATED EAPI Elm_Clock_Edit_Mode elm_clock_digit_edit_get(const Evas_Object *obj); + /** * @} */ -- 2.7.4