5 _on_resize(Ecore_Evas *ee)
7 EvasApp *app = (EvasApp *)ecore_evas_data_get(ee, "app");
9 ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
12 app->mResizeCb(app->mResizeData, nullptr);
16 _on_delete(Ecore_Evas *ee)
18 EvasApp *app = (EvasApp *)ecore_evas_data_get(ee, "app");
20 app->mExitCb(app->mExitData, nullptr);
22 ecore_main_loop_quit();
27 on_key_down(void *data, int type, void *event)
29 Ecore_Event_Key *keyData = (Ecore_Event_Key *)event;
31 EvasApp *app = (EvasApp *) data;
32 if (app && app->mKeyCb)
33 app->mKeyCb(app->mKeyData, (void *)keyData->key);
39 on_pre_render(Ecore_Evas *ee)
41 EvasApp *app = (EvasApp *)ecore_evas_data_get(ee, "app");
42 if (app->mRenderPreCb)
43 app->mRenderPreCb(app->mRenderPreData, nullptr);
47 on_post_render(Ecore_Evas *ee)
49 EvasApp *app = (EvasApp *)ecore_evas_data_get(ee, "app");
50 if (app && app->mRenderPostCb)
51 app->mRenderPostCb(app->mRenderPostData, nullptr);
54 EvasApp::EvasApp(int w, int h)
56 if (!ecore_evas_init())
60 //setenv("ECORE_EVAS_ENGINE", "opengl_x11", 1);
61 mEcoreEvas = ecore_evas_new(NULL, 0, 0, mw, mh, NULL);
62 if (!mEcoreEvas) return;
68 ecore_evas_data_set(mEcoreEvas, "app", this);
69 ecore_evas_callback_resize_set(mEcoreEvas, _on_resize);
70 ecore_evas_callback_delete_request_set(mEcoreEvas, _on_delete);
71 ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, on_key_down, this);
72 ecore_evas_callback_pre_render_set(mEcoreEvas, on_pre_render);
73 ecore_evas_callback_post_render_set(mEcoreEvas, on_post_render);
75 ecore_evas_show(mEcoreEvas);
76 mEvas = ecore_evas_get(mEcoreEvas);
77 mBackground = evas_object_rectangle_add(mEvas);
78 evas_object_color_set(mBackground, 70, 70, 70, 255);
79 evas_object_show(mBackground);
83 EvasApp::resize(int w, int h)
85 evas_object_resize(mBackground, w, h);
93 ecore_main_loop_begin();
94 ecore_evas_shutdown();
97 static bool isJsonFile(const char *filename) {
98 const char *dot = strrchr(filename, '.');
99 if(!dot || dot == filename) return false;
100 return !strcmp(dot + 1, "json");
103 std::vector<std::string>
104 EvasApp::jsonFiles(const std::string &dirName, bool recurse)
108 std::vector<std::string> result;
109 d = opendir(dirName.c_str());
111 while ((dir = readdir(d)) != NULL) {
112 if (isJsonFile(dir->d_name))
113 result.push_back(dirName + dir->d_name);