evasapp.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2.1 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with this library; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #ifndef EVASAPP_H
  19. #define EVASAPP_H
  20. #ifndef EFL_BETA_API_SUPPORT
  21. #define EFL_BETA_API_SUPPORT
  22. #endif
  23. #ifndef EFL_EO_API_SUPPORT
  24. #define EFL_EO_API_SUPPORT
  25. #endif
  26. #include <Eo.h>
  27. #include <Efl.h>
  28. #include <Evas.h>
  29. #include <Ecore.h>
  30. #include <Ecore_Evas.h>
  31. #include <Ecore_Input.h>
  32. #include<vector>
  33. #include<string>
  34. typedef void (*appCb)(void *userData, void *extra);
  35. class EvasApp
  36. {
  37. public:
  38. EvasApp(int w, int h);
  39. void setup();
  40. void resize(int w, int h);
  41. int width() const{ return mw;}
  42. int height() const{ return mh;}
  43. void run();
  44. Ecore_Evas * ee() const{return mEcoreEvas;}
  45. Evas * evas() const {return mEvas;}
  46. void addExitCb(appCb exitcb, void *data) {mExitCb = exitcb; mExitData = data;}
  47. void addResizeCb(appCb resizecb, void *data) {mResizeCb = resizecb; mResizeData = data;}
  48. void addKeyCb(appCb keycb, void *data) {mKeyCb = keycb; mKeyData = data;}
  49. void addRenderPreCb(appCb renderPrecb, void *data) {mRenderPreCb = renderPrecb; mRenderPreData = data;}
  50. void addRenderPostCb(appCb renderPostcb, void *data) {mRenderPostCb = renderPostcb; mRenderPostData = data;}
  51. static std::vector<std::string> jsonFiles(const std::string &dir, bool recurse=false);
  52. public:
  53. int mw{0};
  54. int mh{0};
  55. Ecore_Evas *mEcoreEvas{nullptr};
  56. Evas *mEvas{nullptr};
  57. Evas_Object *mBackground{nullptr};
  58. appCb mResizeCb{nullptr};
  59. void *mResizeData{nullptr};
  60. appCb mExitCb{nullptr};
  61. void *mExitData{nullptr};
  62. appCb mKeyCb{nullptr};
  63. void *mKeyData{nullptr};
  64. appCb mRenderPreCb{nullptr};
  65. void *mRenderPreData{nullptr};
  66. appCb mRenderPostCb{nullptr};
  67. void *mRenderPostData{nullptr};
  68. };
  69. #endif //EVASAPP_H