summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2017-11-28 17:24:06 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2017-12-05 15:01:45 +0900
commit08918e3285e75d6eb89df2848854a4b2d4eba3b8 (patch)
tree3c2f69a05685fee5e45e61fc995368bf38968af9
parentc9322dd56104e6ee23c6840fbb5a202c3218c1e1 (diff)
cxx: Update slider example
-rw-r--r--src/examples/elementary/slider_cxx_example.cc35
1 files changed, 20 insertions, 15 deletions
diff --git a/src/examples/elementary/slider_cxx_example.cc b/src/examples/elementary/slider_cxx_example.cc
index 036dadcd1a..959fe256f0 100644
--- a/src/examples/elementary/slider_cxx_example.cc
+++ b/src/examples/elementary/slider_cxx_example.cc
@@ -4,6 +4,7 @@
4 4
5#include <Elementary.hh> 5#include <Elementary.hh>
6 6
7using namespace std::placeholders;
7using efl::eo::instantiate; 8using efl::eo::instantiate;
8 9
9static efl::ui::Win win; 10static efl::ui::Win win;
@@ -11,10 +12,11 @@ static efl::ui::Win win;
11static void 12static void
12efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED) 13efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
13{ 14{
15 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
16
14 win = efl::ui::Win(instantiate); 17 win = efl::ui::Win(instantiate);
15 win.text_set("Slider example"); 18 win.text_set("Slider example");
16 efl::eolian::event_add(efl::ui::Win::delete_request_event, win, 19 win.delete_request_event_cb_add([](){ win._delete(); });
17 std::bind([](){ win = nullptr; ::efl_exit(0); }));
18 20
19 efl::ui::Box bx(instantiate, win); 21 efl::ui::Box bx(instantiate, win);
20 win.content_set(bx); 22 win.content_set(bx);
@@ -62,17 +64,20 @@ efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
62 bx.pack_end(sl5); 64 bx.pack_end(sl5);
63 65
64 efl::ui::Slider sl6(instantiate, win); 66 efl::ui::Slider sl6(instantiate, win);
65 sl4.direction_set(EFL_UI_DIR_HORIZONTAL); 67 sl6.direction_set(EFL_UI_DIR_HORIZONTAL);
66 68 sl6.range_min_max_set(0, 10);
67// FIXME 69 auto format_cb = std::bind([](
68// auto indicator_format = [] (double val) { 70 efl::eina::strbuf_wrapper& sb,
69// char *indicator = new char[32]; 71 efl::eina::value_view const& value) {
70// snprintf(indicator, 32, "%1.2f u", val); 72 try {
71// return indicator; 73 int d = int(efl::eina::get<double>(value));
72// }; 74 if (d >= 2) sb.append_printf("%d things", d);
73// auto indicator_free = [] (char *obj) {delete obj;} ; 75 else if (!d) sb.append("nothing");
74// sl6.indicator_format_function_set(indicator_format, indicator_free); 76 else sb.append("one thing");
75 77 } catch (std::system_error const&) {
78 sb.append(value.to_string());
79 } }, _1, _2);
80 sl6.format_cb_set(format_cb);
76 sl6.hint_align_set(0.5, EFL_GFX_SIZE_HINT_FILL); 81 sl6.hint_align_set(0.5, EFL_GFX_SIZE_HINT_FILL);
77 sl6.hint_weight_set(0, EFL_GFX_SIZE_HINT_EXPAND); 82 sl6.hint_weight_set(0, EFL_GFX_SIZE_HINT_EXPAND);
78 bx.pack_end(sl6); 83 bx.pack_end(sl6);
@@ -91,7 +96,7 @@ efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
91 { std::cout << "Delay changed to " << obj.range_value_get() << std::endl; } 96 { std::cout << "Delay changed to " << obj.range_value_get() << std::endl; }
92 , std::placeholders::_1); 97 , std::placeholders::_1);
93 98
94 efl::eolian::event_add(sl7.changed_event, sl7, changed); 99 sl7.changed_event_cb_add(changed);
95 efl::eolian::event_add(sl7.delay_changed_event, sl7, delay); 100 sl7.delay_changed_event_cb_add(delay);
96} 101}
97EFL_MAIN() 102EFL_MAIN()