aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin/elementary/test_ui_progressbar.c
diff options
context:
space:
mode:
authorXavi Artigas <xavierartigas@yahoo.es>2019-06-28 10:08:03 +0200
committerMarcel Hollerbach <mail@bu5hm4n.de>2019-07-03 08:34:03 +0200
commit8a0cad643597b8741e5b8b1c7bc3ecfff671aeed (patch)
tree784d62c6e813ed7d68bc92b259b0e59eef944444 /src/bin/elementary/test_ui_progressbar.c
parenteina: add accessors for c arrays (diff)
downloadefl-8a0cad643597b8741e5b8b1c7bc3ecfff671aeed.tar.gz
Efl.Ui.Progressbar: Add explicit display control of progress label
Summary: Add a property (show_progress_label) to allow controlling whether the progress label displaying the exact progress is shown or not. This was possible in Legacy but the functionality was lost in Unified. Updated elementary_test to showcase this property, and also the other label formatting options, which where not tested anywhere. Added a simple progressbar unit test. It only checks that retrieved value is the same as the set value, so it is more of a placeholder for future tests. **This is needed by a future patch which will introduce more formatting options that clash with the current implementation.** The presence of a formatting function was used to decide if the progress label was shown or not. This explicit property simplifies things. Test Plan: Everything builds and passes tests. `elementary_test -to Efl.Ui.Progressbar` should show a few more bars with different formatting labels, and a checkbox to toggle rendering of one of them. Reviewers: bu5hm4n, zmike, cedric Subscribers: #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D9202
Diffstat (limited to 'src/bin/elementary/test_ui_progressbar.c')
-rw-r--r--src/bin/elementary/test_ui_progressbar.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/bin/elementary/test_ui_progressbar.c b/src/bin/elementary/test_ui_progressbar.c
index 04cb6d4c50..3d50d0be61 100644
--- a/src/bin/elementary/test_ui_progressbar.c
+++ b/src/bin/elementary/test_ui_progressbar.c
@@ -9,6 +9,10 @@ typedef struct _pbdata
Eo *win;
Eo *pb1;
Eo *pb2;
+ Eo *pb3;
+ Eo *pb4;
+ Eo *pb5;
+ Eo *check;
Eo *btn_start;
Eo *btn_stop;
Eo *btn_reset;
@@ -45,6 +49,9 @@ _pb_timer_cb(void *d)
{
progress_val += 1;
efl_ui_range_value_set(pd->pb2, progress_val);
+ efl_ui_range_value_set(pd->pb3, progress_val);
+ efl_ui_range_value_set(pd->pb4, progress_val);
+ efl_ui_range_value_set(pd->pb5, progress_val);
}
if (!_set_progress_val(pd->pb1, 0.5))
@@ -97,6 +104,9 @@ _reset_btn_clicked_cb(void *d, const Efl_Event *ev EINA_UNUSED)
efl_ui_range_value_set(pd->pb1, 0.0);
efl_ui_range_value_set(pd->pb2, 0.0);
+ efl_ui_range_value_set(pd->pb3, 0.0);
+ efl_ui_range_value_set(pd->pb4, 0.0);
+ efl_ui_range_value_set(pd->pb5, 0.0);
}
static void
@@ -109,6 +119,28 @@ _win_delete_req_cb(void *d, const Efl_Event *ev EINA_UNUSED)
free(pd);
}
+static void
+_custom_format_cb(void *data EINA_UNUSED, Eina_Strbuf *str, const Eina_Value value)
+{
+ double v;
+ eina_value_get(&value, &v);
+ if (v < 25.f) eina_strbuf_append_printf(str, "Starting up...");
+ else if (v < 50.f) eina_strbuf_append_printf(str, "Working...");
+ 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!");
+}
+
+static void
+_toggle_progress_label(void *data, const Efl_Event *ev)
+{
+ Efl_Ui_Check *check = ev->object;
+ Efl_Ui_Progressbar *pb3 = data;
+ Eina_Bool state = efl_ui_check_selected_get(check);
+
+ efl_ui_progressbar_show_progress_label_set(pb3, state);
+}
+
void
test_ui_progressbar(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
@@ -153,6 +185,37 @@ test_ui_progressbar(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, void *event_inf
efl_ui_range_value_set(efl_added, 10)
);
+ pd->pb3 = efl_add(EFL_UI_PROGRESSBAR_CLASS, bx,
+ efl_pack(bx, efl_added),
+ efl_text_set(efl_added, "Toggle progress label"),
+ efl_ui_range_limits_set(efl_added, 0, 100),
+ efl_ui_progressbar_show_progress_label_set(efl_added, EINA_FALSE),
+ efl_gfx_hint_size_min_set(efl_added, EINA_SIZE2D(250, 20))
+ );
+ pd->check = efl_add(EFL_UI_CHECK_CLASS, bx,
+ efl_pack(bx, efl_added),
+ efl_event_callback_add(efl_added, EFL_UI_CHECK_EVENT_SELECTED_CHANGED,
+ _toggle_progress_label, pd->pb3),
+ efl_gfx_hint_size_min_set(efl_added, EINA_SIZE2D(250, 20))
+ );
+ efl_text_set(pd->check, "Show progress label of above progressbar"),
+
+ pd->pb4 = efl_add(EFL_UI_PROGRESSBAR_CLASS, bx,
+ 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_gfx_hint_size_min_set(efl_added, EINA_SIZE2D(250, 20))
+ );
+
+ pd->pb5 = efl_add(EFL_UI_PROGRESSBAR_CLASS, bx,
+ 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_gfx_hint_size_min_set(efl_added, EINA_SIZE2D(250, 20))
+ );
+
btbx = efl_add(EFL_UI_BOX_CLASS, bx,
efl_pack(bx, efl_added),
efl_ui_layout_orientation_set(efl_added, EFL_UI_LAYOUT_ORIENTATION_HORIZONTAL)