These functions change the range of the value displayed on the progress bar with elm_progressbar_unit_format_set. At the moment the value displayed is in the range of 0 to 100. These functions allow you to change the upper range to something else. This is useful if the value represented by the progress bar is something else than percent, such as hours left.
Signed-off-by: Daniel Willmann <d.willm...@samsung.com> --- trunk/elementary/src/lib/elm_progressbar.c | 27 ++++++++++++++++++++++++++- trunk/elementary/src/lib/elm_progressbar.h | 26 ++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/trunk/elementary/src/lib/elm_progressbar.c b/trunk/elementary/src/lib/elm_progressbar.c index 61f2b64..6d7316a 100644 --- a/trunk/elementary/src/lib/elm_progressbar.c +++ b/trunk/elementary/src/lib/elm_progressbar.c @@ -18,6 +18,7 @@ struct _Elm_Progressbar_Smart_Data Evas_Coord size; double val; + double maxunit; Eina_Bool horizontal : 1; Eina_Bool inverted : 1; @@ -78,7 +79,7 @@ _units_set(Evas_Object *obj) { char buf[1024]; - snprintf(buf, sizeof(buf), sd->units, 100 * sd->val); + snprintf(buf, sizeof(buf), sd->units, sd->maxunit * sd->val); elm_layout_text_set(obj, "elm.text.status", buf); } else elm_layout_text_set(obj, "elm.text.status", NULL); @@ -227,6 +228,7 @@ _elm_progressbar_smart_add(Evas_Object *obj) priv->pulse_state = EINA_FALSE; priv->units = eina_stringshare_add("%.0f %%"); priv->val = MIN_RATIO_LVL; + priv->maxunit = 100; elm_layout_theme_set (obj, "progressbar", "horizontal", elm_widget_style_get(obj)); @@ -365,6 +367,29 @@ elm_progressbar_value_get(const Evas_Object *obj) } EAPI void +elm_progressbar_maxunit_set(Evas_Object *obj, + double maxunit) +{ + ELM_PROGRESSBAR_CHECK(obj); + ELM_PROGRESSBAR_DATA_GET(obj, sd); + + if (sd->maxunit == maxunit) return; + + sd->maxunit = maxunit; + + _units_set(obj); +} + +EAPI double +elm_progressbar_maxunit_get(const Evas_Object *obj) +{ + ELM_PROGRESSBAR_CHECK(obj) 0.0; + ELM_PROGRESSBAR_DATA_GET(obj, sd); + + return sd->maxunit; +} + +EAPI void elm_progressbar_span_size_set(Evas_Object *obj, Evas_Coord size) { diff --git a/trunk/elementary/src/lib/elm_progressbar.h b/trunk/elementary/src/lib/elm_progressbar.h index 5ee2aff..49ee65a 100644 --- a/trunk/elementary/src/lib/elm_progressbar.h +++ b/trunk/elementary/src/lib/elm_progressbar.h @@ -154,6 +154,32 @@ EAPI void elm_progressbar_value_set(Evas_Object *obj, do EAPI double elm_progressbar_value_get(const Evas_Object *obj); /** + * Set the range of the value displayed on a given progress bar + * widget + * + * @param obj The progress bar object + * @param scalemax The maximum value + * + * This sets the range of the value that is displayed on a progress bar + * to go from 0 to @p scalemax. + * + * @ingroup Progressbar + */ +EAPI void elm_progressbar_maxunit_set(Evas_Object *obj, double maxunit); + +/** + * Get the range of the value displayed on a given progress bar + * + * @param obj The progress bar object + * @return The value current range + * + * @see elm_progressbar_maxunit_set() for more details + * + * @ingroup Progressbar + */ +EAPI double elm_progressbar_maxunit_get(const Evas_Object *obj); + +/** * Set the (exact) length of the bar region of a given progress bar * widget * -- 1.7.9.5 ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ enlightenment-devel mailing list enlightenment-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-devel