jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=e738c5e869e135e599c84001dc3ca3ea0a1b3971

commit e738c5e869e135e599c84001dc3ca3ea0a1b3971
Author: Jean-Philippe Andre <[email protected]>
Date:   Thu Nov 23 14:10:24 2017 +0900

    cxx: Fix bg examples
    
    One uses the Bg widget and the other one uses the part.
---
 src/examples/elementary/bg_cxx_example_01.cc | 22 +++++++++++++++-------
 src/examples/elementary/bg_cxx_example_02.cc | 20 ++++++++++++--------
 2 files changed, 27 insertions(+), 15 deletions(-)

diff --git a/src/examples/elementary/bg_cxx_example_01.cc 
b/src/examples/elementary/bg_cxx_example_01.cc
index 8fcb78c0ea..c852b07c90 100644
--- a/src/examples/elementary/bg_cxx_example_01.cc
+++ b/src/examples/elementary/bg_cxx_example_01.cc
@@ -1,17 +1,25 @@
-#define EFL_EO_API_SUPPORT
-
 #include <Elementary.hh>
 
+using efl::eo::instantiate;
+
 EAPI_MAIN int
 elm_main (int argc EINA_UNUSED, char **argv EINA_UNUSED)
 {
-   efl::ui::Win win;
-   win.text_set("Bg Plain");
+   efl::ui::Win win(instantiate);
+   win.text_set("Window Background");
    win.autohide_set(true);
+   win.size_set({320,320});
+   try {
+      auto bg = efl::eo::downcast<efl::ui::win::Part>(win.part("background"));
+      bg.color_set(139, 69, 19, 255);
+   } catch (std::exception const&e) {
+      std::cerr << "Failed to set bg color: " << e.what() << std::endl;
+   }
 
-   win.eo_cxx::efl::Gfx::size_set({320,320});
-   //win.size_set(320,320);
-   win.visible_set(true);
+   // Clean exit
+   elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
+   efl::eolian::event_add(efl::ui::Win::delete_request_event, win,
+                          std::bind([&](){ win = nullptr; }));
 
    elm_run();
    return 0;
diff --git a/src/examples/elementary/bg_cxx_example_02.cc 
b/src/examples/elementary/bg_cxx_example_02.cc
index eb71693242..775b8bb92e 100644
--- a/src/examples/elementary/bg_cxx_example_02.cc
+++ b/src/examples/elementary/bg_cxx_example_02.cc
@@ -9,27 +9,31 @@
 
 #include <Elementary.hh>
 
-#include <sstream>
-
 using efl::eo::instantiate;
 
-efl::ui::Win win;
+static efl::ui::Win win;
 
 EAPI_MAIN void
-efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
+efl_main(void *data EINA_UNUSED, const Efl_Event *ev)
 {
+   Efl_Loop_Arguments *args = static_cast<Efl_Loop_Arguments *>(ev->info);
+
    win = efl::ui::Win(instantiate);
-   ::efl_ref(win._eo_ptr()); // FIXME: Window is doing BAD THINGS™!
    win.text_set("Bg Image");
    win.autohide_set(true);
+   win.delete_request_event_cb_add([](){ win = nullptr; efl_exit(0); });
+
+   std::string path;
+   if (eina_array_count(args->argv) > 0)
+     path = static_cast<const char *>(eina_array_data_get(args->argv, 0));
+   else
+     path = "performance/background.png";
 
    efl::ui::Bg bg(instantiate, win);
    bg.scale_type_set(EFL_UI_IMAGE_SCALE_TYPE_FILL);
-   bg.file_set("performance/background.png", nullptr);
+   bg.file_set(path, nullptr);
    win.content_set(bg);
 
    win.size_set({640, 400});
-   std::cout << "win " << win._eo_ptr() << std::endl;
-   win.delete_request_event_cb_add([](){ win = nullptr; efl_exit(0); });
 }
 EFL_MAIN()

-- 


Reply via email to