path: root/src/bin/elementary/test_ui_progressbar.c
diff options
authorXavi Artigas <xavierartigas@yahoo.es>2019-07-02 14:40:06 +0200
committerXavi Artigas <xavierartigas@yahoo.es>2019-07-04 19:38:20 +0200
commite776f5f0d7b6292d32c29ccb4fffe3f20063d53d (patch)
tree0191eda9933ca930e90078fc9a35762b4b71538a /src/bin/elementary/test_ui_progressbar.c
parentci: finally enable examples for mingw build (diff)
Efl.Ui.Format revamp
This class helps widgets which contain a numerical value and must display it, like Progressbar (units label), Spin, Spin_Button, Slider (both units and popup labels, in legacy), Tags (when in shrunk mode) or Calendar (year_month label). Previously this was a mix of interface and mixin: widgets had to support setting a formatting func, and the mixin offered support for formatting strings, by setting an internal formatting func. On top of that, the spinner widget supported "special values", a list of values that should be shown as certain strings instead. This has now been simplified and unified: Widgets including this mixin can use the formatted_value_get() method which accepts an Eina_Value and returns a string. Thats's it. The mixin adds three properties to the widget (format_values, format_func and format_string) which users can use to tailor formatting. The widget does not need to know which method has been used, it just retrieves the resulting string. This removes a lot of duplicated widget code, and adds functionality which was missing before. For example, all widgets support passing a list of values now. Widgets must implement the apply_formatted_value() method so they are notified of changes in the format and they can redraw anything they need. Tests have been added to the Elementary Spec suite for all cases. Legacy widgets behavior has not been modified, although a few needed some code changes.
Diffstat (limited to 'src/bin/elementary/test_ui_progressbar.c')
1 files changed, 4 insertions, 3 deletions
diff --git a/src/bin/elementary/test_ui_progressbar.c b/src/bin/elementary/test_ui_progressbar.c
index 3d50d0be61..5a1c705a03 100644
--- a/src/bin/elementary/test_ui_progressbar.c
+++ b/src/bin/elementary/test_ui_progressbar.c
@@ -119,7 +119,7 @@ _win_delete_req_cb(void *d, const Efl_Event *ev EINA_UNUSED)
-static void
+static Eina_Bool
_custom_format_cb(void *data EINA_UNUSED, Eina_Strbuf *str, const Eina_Value value)
double v;
@@ -129,6 +129,7 @@ _custom_format_cb(void *data EINA_UNUSED, Eina_Strbuf *str, const Eina_Value val
else if (v < 75.f) eina_strbuf_append_printf(str, "Getting there...");
else if (v < 100.f) eina_strbuf_append_printf(str, "Almost done...");
else eina_strbuf_append_printf(str, "Done!");
+ return EINA_TRUE;
static void
@@ -204,7 +205,7 @@ test_ui_progressbar(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, void *event_inf
efl_pack(bx, efl_added),
efl_text_set(efl_added, "Custom string"),
efl_ui_range_limits_set(efl_added, 0, 100),
- efl_ui_format_string_set(efl_added, "%d rabbits"),
+ efl_ui_format_string_set(efl_added, "%d rabbits", EFL_UI_FORMAT_STRING_TYPE_SIMPLE),
efl_gfx_hint_size_min_set(efl_added, EINA_SIZE2D(250, 20))
@@ -212,7 +213,7 @@ test_ui_progressbar(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, void *event_inf
efl_pack(bx, efl_added),
efl_text_set(efl_added, "Custom func"),
efl_ui_range_limits_set(efl_added, 0, 100),
- efl_ui_format_cb_set(efl_added, NULL, _custom_format_cb, NULL),
+ efl_ui_format_func_set(efl_added, NULL, _custom_format_cb, NULL),
efl_gfx_hint_size_min_set(efl_added, EINA_SIZE2D(250, 20))