lottie/example: updated evasapp to handle keyevent propagation. 91/184291/1
authorsubhransu mohanty <sub.mohanty@samsung.com>
Tue, 17 Jul 2018 04:58:17 +0000 (13:58 +0900)
committersubhransu mohanty <sub.mohanty@samsung.com>
Tue, 17 Jul 2018 04:58:51 +0000 (13:58 +0900)
Change-Id: Iecc3479ef011e64e113a50f3914676e0a6341f49

example/demo.cpp
example/evasapp.cpp
example/evasapp.h
example/lottieviewtest.cpp

index fcf544b..e56e395 100644 (file)
@@ -5,7 +5,7 @@
 using namespace std;
 
 static void
-onExitCb(void *data)
+onExitCb(void *data, void *extra)
 {
     LottieView *view = (LottieView *)data;
     delete view;
index 4f4762e..1463a61 100644 (file)
@@ -8,7 +8,7 @@ _on_resize(Ecore_Evas *ee)
    ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);
    app->resize(w, h);
    if (app->mResizeCb)
-       app->mResizeCb(app->mResizeData);
+       app->mResizeCb(app->mResizeData, nullptr);
 }
 
 static void
@@ -16,12 +16,24 @@ _on_delete(Ecore_Evas *ee)
 {
    EvasApp *app = (EvasApp *)ecore_evas_data_get(ee, "app");
    if (app->mExitCb)
-       app->mExitCb(app->mExitData);
+       app->mExitCb(app->mExitData, nullptr);
 
    ecore_main_loop_quit();
    ecore_evas_free(ee);
 }
 
+static Eina_Bool
+on_key_down(void *data, int type, void *event)
+{
+    Ecore_Event_Key *keyData = (Ecore_Event_Key *)event;
+
+    EvasApp *app = (EvasApp *) data;
+    if (app && app->mKeyCb)
+        app->mKeyCb(app->mKeyData, (void *)keyData->key);
+
+    return false;
+}
+
 EvasApp::EvasApp(int w, int h)
 {
     if (!ecore_evas_init())
@@ -39,6 +51,7 @@ EvasApp::setup()
     ecore_evas_data_set(mEcoreEvas, "app", this);
     ecore_evas_callback_resize_set(mEcoreEvas, _on_resize);
     ecore_evas_callback_delete_request_set(mEcoreEvas, _on_delete);
+    ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, on_key_down, this);
 
     ecore_evas_show(mEcoreEvas);
     mEvas = ecore_evas_get(mEcoreEvas);
index c7d18cf..ddb9615 100644 (file)
@@ -14,8 +14,9 @@
 #include <Evas.h>
 #include <Ecore.h>
 #include <Ecore_Evas.h>
+#include <Ecore_Input.h>
 
-typedef void (*appCb)(void *userData);
+typedef void (*appCb)(void *userData, void *extra);
 class EvasApp
 {
 public:
@@ -30,6 +31,7 @@ public:
     Efl_VG * root() const {return mRoot;}
     void addExitCb(appCb exitcb, void *data) {mExitCb = exitcb; mExitData = data;}
     void addResizeCb(appCb resizecb, void *data) {mResizeCb = resizecb; mResizeData = data;}
+    void addKeyCb(appCb keycb, void *data) {mKeyCb = keycb; mKeyData = data;}
 public:
     int           mw;
     int           mh;
@@ -42,5 +44,7 @@ public:
     void        *mResizeData;
     appCb        mExitCb;
     void        *mExitData;
+    appCb        mKeyCb;
+    void        *mKeyData;
 };
 #endif //EVASAPP_H
index f11e280..6fc6e94 100644 (file)
@@ -88,7 +88,7 @@ public:
 };
 
 static void
-onExitCb(void *data)
+onExitCb(void *data, void *extra)
 {
     LottieViewTest *view = (LottieViewTest *)data;
     delete view;