forked from enlightenment/efl
cxx: Fix bg examples
One uses the Bg widget and the other one uses the part.
This commit is contained in:
parent
63725d71fd
commit
e738c5e869
|
@ -1,17 +1,25 @@
|
||||||
#define EFL_EO_API_SUPPORT
|
|
||||||
|
|
||||||
#include <Elementary.hh>
|
#include <Elementary.hh>
|
||||||
|
|
||||||
|
using efl::eo::instantiate;
|
||||||
|
|
||||||
EAPI_MAIN int
|
EAPI_MAIN int
|
||||||
elm_main (int argc EINA_UNUSED, char **argv EINA_UNUSED)
|
elm_main (int argc EINA_UNUSED, char **argv EINA_UNUSED)
|
||||||
{
|
{
|
||||||
efl::ui::Win win;
|
efl::ui::Win win(instantiate);
|
||||||
win.text_set("Bg Plain");
|
win.text_set("Window Background");
|
||||||
win.autohide_set(true);
|
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});
|
// Clean exit
|
||||||
//win.size_set(320,320);
|
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
|
||||||
win.visible_set(true);
|
efl::eolian::event_add(efl::ui::Win::delete_request_event, win,
|
||||||
|
std::bind([&](){ win = nullptr; }));
|
||||||
|
|
||||||
elm_run();
|
elm_run();
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -9,27 +9,31 @@
|
||||||
|
|
||||||
#include <Elementary.hh>
|
#include <Elementary.hh>
|
||||||
|
|
||||||
#include <sstream>
|
|
||||||
|
|
||||||
using efl::eo::instantiate;
|
using efl::eo::instantiate;
|
||||||
|
|
||||||
efl::ui::Win win;
|
static efl::ui::Win win;
|
||||||
|
|
||||||
EAPI_MAIN void
|
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);
|
win = efl::ui::Win(instantiate);
|
||||||
::efl_ref(win._eo_ptr()); // FIXME: Window is doing BAD THINGS™!
|
|
||||||
win.text_set("Bg Image");
|
win.text_set("Bg Image");
|
||||||
win.autohide_set(true);
|
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);
|
efl::ui::Bg bg(instantiate, win);
|
||||||
bg.scale_type_set(EFL_UI_IMAGE_SCALE_TYPE_FILL);
|
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.content_set(bg);
|
||||||
|
|
||||||
win.size_set({640, 400});
|
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()
|
EFL_MAIN()
|
||||||
|
|
Loading…
Reference in New Issue