From c19b6d90c38cdc0d5b336ede42ccce0e28af56db Mon Sep 17 00:00:00 2001 From: "jk7744.park" Date: Sat, 24 Oct 2015 15:49:41 +0900 Subject: [PATCH] tizen 2.4 release --- CMakeLists.txt | 2 + packaging/libwidget_viewer.spec | 43 +- widget_viewer/include/debug.h | 4 +- widget_viewer/include/util.h | 1 - widget_viewer/include/widget_viewer.h | 6 +- widget_viewer/src/client.c | 17 +- widget_viewer/src/util.c | 13 - widget_viewer/src/widget.c | 11 +- widget_viewer/src/widget_internal.c | 2 +- widget_viewer_dali/CMakeLists.txt | 68 +++ widget_viewer_dali/LICENSE | 206 +++++++++ widget_viewer_dali/include/widget_dali.h | 97 ++++ widget_viewer_dali/include/widget_dali_impl.h | 161 +++++++ widget_viewer_dali/include/widget_dali_list.h | 52 +++ widget_viewer_dali/include/widget_viewer_dali.h | 73 +++ .../include/widget_viewer_dali_const.h | 113 +++++ .../include/widget_viewer_dali_generic.h | 102 +++++ widget_viewer_dali/res/image/btn_delete_nor.png | Bin 0 -> 2436 bytes widget_viewer_dali/res/image/btn_delete_press.png | Bin 0 -> 2598 bytes .../src/common/widget_viewer_dali_const.cpp | 147 ++++++ widget_viewer_dali/src/widget_dali.cpp | 209 +++++++++ widget_viewer_dali/src/widget_dali_impl.cpp | 491 +++++++++++++++++++++ widget_viewer_dali/src/widget_dali_list.cpp | 113 +++++ widget_viewer_dali/src/widget_viewer_dali.cpp | 426 ++++++++++++++++++ widget_viewer_dali/widget_viewer_dali.pc.in | 12 + widget_viewer_evas/doc/widget_viewer_evas_doc.h | 4 + widget_viewer_evas/include/widget_viewer_evas.h | 96 +++- .../include/widget_viewer_evas_internal.h | 3 + widget_viewer_evas/src/widget_viewer_evas.c | 319 ++++++++++--- widget_viewer_sdk/include/debug.h | 4 +- widget_viewer_sdk/org.tizen.widget_viewer_sdk.efl | 8 +- widget_viewer_sdk/src/main.c | 4 + 32 files changed, 2700 insertions(+), 107 deletions(-) mode change 100644 => 100755 CMakeLists.txt mode change 100644 => 100755 packaging/libwidget_viewer.spec mode change 100644 => 100755 widget_viewer/include/widget_viewer.h create mode 100755 widget_viewer_dali/CMakeLists.txt create mode 100755 widget_viewer_dali/LICENSE create mode 100755 widget_viewer_dali/include/widget_dali.h create mode 100755 widget_viewer_dali/include/widget_dali_impl.h create mode 100755 widget_viewer_dali/include/widget_dali_list.h create mode 100755 widget_viewer_dali/include/widget_viewer_dali.h create mode 100755 widget_viewer_dali/include/widget_viewer_dali_const.h create mode 100755 widget_viewer_dali/include/widget_viewer_dali_generic.h create mode 100755 widget_viewer_dali/res/image/btn_delete_nor.png create mode 100755 widget_viewer_dali/res/image/btn_delete_press.png create mode 100755 widget_viewer_dali/src/common/widget_viewer_dali_const.cpp create mode 100755 widget_viewer_dali/src/widget_dali.cpp create mode 100755 widget_viewer_dali/src/widget_dali_impl.cpp create mode 100755 widget_viewer_dali/src/widget_dali_list.cpp create mode 100755 widget_viewer_dali/src/widget_viewer_dali.cpp create mode 100755 widget_viewer_dali/widget_viewer_dali.pc.in diff --git a/CMakeLists.txt b/CMakeLists.txt old mode 100644 new mode 100755 index b289f6d..71ab3f7 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,8 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) ADD_SUBDIRECTORY(widget_viewer) ADD_SUBDIRECTORY(widget_viewer_evas) ADD_SUBDIRECTORY(widget_viewer_sdk) +#ADD_SUBDIRECTORY(widget_viewer_dali) ADD_DEPENDENCIES(widget_viewer_evas widget_viewer) +#ADD_DEPENDENCIES(widget_viewer_dali widget_viewer) ADD_DEPENDENCIES(widget_viewer_sdk widget_viewer_evas) diff --git a/packaging/libwidget_viewer.spec b/packaging/libwidget_viewer.spec old mode 100644 new mode 100755 index d1273d0..8d139cc --- a/packaging/libwidget_viewer.spec +++ b/packaging/libwidget_viewer.spec @@ -2,7 +2,7 @@ Name: libwidget_viewer Summary: Library for developing the application -Version: 1.2.1 +Version: 1.2.2 Release: 1 Group: Applications/Core Applications License: Flora-1.1 @@ -25,6 +25,9 @@ BuildRequires: pkgconfig(capi-appfw-application) BuildRequires: pkgconfig(appcore-efl) BuildRequires: pkgconfig(capi-system-info) BuildRequires: pkgconfig(efl-extension) +#BuildRequires: pkgconfig(dali) +#BuildRequires: pkgconfig(dali-core) +#BuildRequires: pkgconfig(dali-toolkit) %if %{with wayland} BuildRequires: pkgconfig(wayland-client) @@ -32,6 +35,8 @@ BuildRequires: pkgconfig(libtbm) %else BuildRequires: pkgconfig(x11) BuildRequires: pkgconfig(xext) +BuildRequires: pkgconfig(ecore-x) +BuildRequires: pkgconfig(ecore) %endif %description @@ -90,6 +95,27 @@ rm -rf %{buildroot} %{_libdir}/pkgconfig/widget_viewer.pc ################################################# +## libwidget_viewer_dali +#%package -n %{name}_dali +#Summary: Library for developing the widget viewer dali +#Group: Applications/Core Applications +#License: Flora-1.1 +# +#%description -n %{name}_dali +#Provider APIs to develop the widget viewer Dali application. +# +#%package -n %{name}_dali-devel +#Summary: Widget viewer application development library (dev) (Dali version) +#Group: Development/Libraries +#Requires: %{name}_dali +# +#%description -n %{name}_dali-devel +#Header & package configuration files to support development of the widget viewer applications. (for Dali app) +# +#%post -n %{name}_dali -p /sbin/ldconfig +#%postun -n %{name}_dali -p /sbin/ldconfig +# +################################################# # libwidget_viewer_evas %package -n %{name}_evas Summary: Library for developing the widget viewer evas @@ -125,6 +151,21 @@ While developing the widget applications, this viewer will load it and execute i %post -n org.tizen.widget_viewer_sdk -p /sbin/ldconfig %postun -n org.tizen.widget_viewer_sdk -p /sbin/ldconfig +#%files -n %{name}_dali +#%manifest %{name}.manifest +#%defattr(-,root,root,-) +#%{_libdir}/%{name}_dali.so* +#%{_datadir}/widget_viewer_dali/* +#%{_datarootdir}/license/%{name}_dali +# +#%files -n %{name}_dali-devel +#%manifest %{name}.manifest +#%defattr(-,root,root,-) +#%{_includedir}/widget_viewer_dali/widget_viewer_dali.h +#%{_includedir}/widget_viewer_dali/widget_dali.h +#%{_includedir}/widget_viewer_dali/widget_viewer_dali_generic.h +#%{_libdir}/pkgconfig/widget_viewer_dali.pc + %files -n %{name}_evas %manifest %{name}.manifest %defattr(-,root,root,-) diff --git a/widget_viewer/include/debug.h b/widget_viewer/include/debug.h index a6563ee..483309e 100644 --- a/widget_viewer/include/debug.h +++ b/widget_viewer/include/debug.h @@ -19,9 +19,9 @@ #define ErrPrint(format, arg...) SECURE_LOGE(format, ##arg) #else extern FILE *__file_log_fp; -#define DbgPrint(format, arg...) do { fprintf(__file_log_fp, "[LOG] [%s/%s:%d] " format, util_basename(__FILE__), __func__, __LINE__, ##arg); fflush(__file_log_fp); } while (0) +#define DbgPrint(format, arg...) do { fprintf(__file_log_fp, "[LOG] [%s/%s:%d] " format, widget_util_basename(__FILE__), __func__, __LINE__, ##arg); fflush(__file_log_fp); } while (0) -#define ErrPrint(format, arg...) do { fprintf(__file_log_fp, "[ERR] [%s/%s:%d] " format, util_basename(__FILE__), __func__, __LINE__, ##arg); fflush(__file_log_fp); } while (0) +#define ErrPrint(format, arg...) do { fprintf(__file_log_fp, "[ERR] [%s/%s:%d] " format, widget_util_basename(__FILE__), __func__, __LINE__, ##arg); fflush(__file_log_fp); } while (0) #endif diff --git a/widget_viewer/include/util.h b/widget_viewer/include/util.h index 498a249..b463568 100644 --- a/widget_viewer/include/util.h +++ b/widget_viewer/include/util.h @@ -16,7 +16,6 @@ extern int util_check_extension(const char *filename, const char *check_ptr); extern double util_timestamp(void); -extern const char *util_basename(const char *name); extern const char *util_uri_to_path(const char *uri); extern int util_unlink(const char *filename); diff --git a/widget_viewer/include/widget_viewer.h b/widget_viewer/include/widget_viewer.h old mode 100644 new mode 100755 index 6c7a81c..be29dcd --- a/widget_viewer/include/widget_viewer.h +++ b/widget_viewer/include/widget_viewer.h @@ -48,6 +48,10 @@ typedef struct widget *widget_h; */ #define WIDGET_DEFAULT_PERIOD -1.0f +#define WIDGET_VIEWER_CLICK_BUTTON_LEFT "clicked" +#define WIDGET_VIEWER_CLICK_BUTTON_RIGHT "clicked,1" +#define WIDGET_VIEWER_CLICK_BUTTON_CENTER "clicked,2" + /** * @internal * @brief Enumeration for Mouse & Key event for buffer type widget or Glance Bar. @@ -654,7 +658,7 @@ extern int widget_viewer_resize_widget(widget_h handle, widget_size_type_e type, * @retval #WIDGET_STATUS_ERROR_FAULT Unrecoverable error occurred * @retval #WIDGET_STATUS_ERROR_NONE Successfully done */ -extern int widget_viewer_send_click_event(widget_h handle, double x, double y); +extern int widget_viewer_send_click_event(widget_h handle, const char *event, double x, double y); /** * @internal diff --git a/widget_viewer/src/client.c b/widget_viewer/src/client.c index 70e7eac..9609dff 100644 --- a/widget_viewer/src/client.c +++ b/widget_viewer/src/client.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include "debug.h" @@ -729,7 +730,7 @@ static struct packet *master_extra_updated(pid_t pid, int handle, const struct p if (!conf_manual_sync()) { ret = _widget_sync_widget_fb(common); if (ret != (int)WIDGET_ERROR_NONE) { - ErrPrint("Failed to do sync FB (%s - %s) (%d)\n", pkgname, util_basename(util_uri_to_path(id)), ret); + ErrPrint("Failed to do sync FB (%s - %s) (%d)\n", pkgname, widget_util_basename(util_uri_to_path(id)), ret); } } else { ret = WIDGET_ERROR_NONE; @@ -822,7 +823,7 @@ static struct packet *master_widget_updated(pid_t pid, int handle, const struct if (!conf_manual_sync()) { ret = _widget_sync_widget_fb(common); if (ret != (int)WIDGET_ERROR_NONE) { - ErrPrint("Failed to do sync FB (%s - %s) (%d)\n", pkgname, util_basename(util_uri_to_path(id)), ret); + ErrPrint("Failed to do sync FB (%s - %s) (%d)\n", pkgname, widget_util_basename(util_uri_to_path(id)), ret); } } else { ret = WIDGET_ERROR_NONE; @@ -915,7 +916,7 @@ static struct packet *master_gbar_created(pid_t pid, int handle, const struct pa ret = _widget_sync_gbar_fb(common); if (ret < 0) { - ErrPrint("Failed to do sync FB (%s - %s)\n", pkgname, util_basename(util_uri_to_path(id))); + ErrPrint("Failed to do sync FB (%s - %s)\n", pkgname, widget_util_basename(util_uri_to_path(id))); } } } @@ -1015,7 +1016,7 @@ static struct packet *master_gbar_destroyed(pid_t pid, int handle, const struct switch (fb_type(_widget_get_gbar_fb(common))) { case WIDGET_FB_TYPE_FILE: case WIDGET_FB_TYPE_SHM: - widget_service_destroy_lock(common->gbar.lock); + widget_service_destroy_lock(common->gbar.lock, 0); common->gbar.lock = NULL; break; case WIDGET_FB_TYPE_PIXMAP: @@ -1089,7 +1090,7 @@ static struct packet *master_gbar_updated(pid_t pid, int handle, const struct pa if (!conf_manual_sync()) { ret = _widget_sync_gbar_fb(common); if (ret < 0) { - ErrPrint("Failed to do sync FB (%s - %s), %d\n", pkgname, util_basename(util_uri_to_path(id)), ret); + ErrPrint("Failed to do sync FB (%s - %s), %d\n", pkgname, widget_util_basename(util_uri_to_path(id)), ret); } else { dlist_foreach(common->widget_list, l, handler) { _widget_invoke_event_handler(handler, WIDGET_EVENT_GBAR_UPDATED); @@ -1470,7 +1471,7 @@ static struct packet *master_size_changed(pid_t pid, int handle, const struct pa ret = _widget_sync_widget_fb(common); if (ret < 0) { - ErrPrint("Failed to do sync FB (%s - %s)\n", pkgname, util_basename(util_uri_to_path(id))); + ErrPrint("Failed to do sync FB (%s - %s)\n", pkgname, widget_util_basename(util_uri_to_path(id))); } /* Just update the size info only. */ @@ -1791,7 +1792,7 @@ static struct packet *master_created(pid_t pid, int handle, const struct packet ret = _widget_sync_widget_fb(common); if (ret < 0) { - ErrPrint("Failed to do sync FB (%s - %s)\n", pkgname, util_basename(util_uri_to_path(id))); + ErrPrint("Failed to do sync FB (%s - %s)\n", pkgname, widget_util_basename(util_uri_to_path(id))); } break; case WIDGET_TYPE_TEXT: @@ -1815,7 +1816,7 @@ static struct packet *master_created(pid_t pid, int handle, const struct packet ret = _widget_sync_gbar_fb(common); if (ret < 0) { - ErrPrint("Failed to do sync FB (%s - %s)\n", pkgname, util_basename(util_uri_to_path(id))); + ErrPrint("Failed to do sync FB (%s - %s)\n", pkgname, widget_util_basename(util_uri_to_path(id))); } /*! diff --git a/widget_viewer/src/util.c b/widget_viewer/src/util.c index c9cc01d..eac5a75 100644 --- a/widget_viewer/src/util.c +++ b/widget_viewer/src/util.c @@ -91,19 +91,6 @@ double util_timestamp(void) #endif } -const char *util_basename(const char *name) -{ - int length; - length = name ? strlen(name) : 0; - if (!length) { - return "."; - } - - while (--length > 0 && name[length] != '/'); - - return length <= 0 ? name : name + length + (name[length] == '/'); -} - const char *util_uri_to_path(const char *uri) { int len; diff --git a/widget_viewer/src/widget.c b/widget_viewer/src/widget.c index 0adcd84..fa5fba2 100644 --- a/widget_viewer/src/widget.c +++ b/widget_viewer/src/widget.c @@ -1216,7 +1216,7 @@ static void _job_del_cb(widget_h handle, int type, void *data) } } - DbgPrint("Send delete request\n"); + DbgPrint("Send delete request [%s]\n", handle->common->id); _widget_send_delete(handle, type, cb, data); } else { if (cb) { @@ -1841,7 +1841,7 @@ EAPI int widget_viewer_resize_widget(widget_h handle, widget_size_type_e type, w return ret; } -EAPI int widget_viewer_send_click_event(widget_h handle, double x, double y) +EAPI int widget_viewer_send_click_event(widget_h handle, const char *event, double x, double y) { struct packet *packet; double timestamp; @@ -1858,6 +1858,11 @@ EAPI int widget_viewer_send_click_event(widget_h handle, double x, double y) return WIDGET_ERROR_INVALID_PARAMETER; } + if (!event || (strcmp(event, WIDGET_VIEWER_CLICK_BUTTON_LEFT) && strcmp(event, WIDGET_VIEWER_CLICK_BUTTON_RIGHT) && strcmp(event, WIDGET_VIEWER_CLICK_BUTTON_CENTER))) { + ErrPrint("Unknown event: (%s)\n", event); + return WIDGET_ERROR_INVALID_PARAMETER; + } + if (!handle->common->id) { ErrPrint("Handler is not valid\n"); return WIDGET_ERROR_INVALID_PARAMETER; @@ -1875,7 +1880,7 @@ EAPI int widget_viewer_send_click_event(widget_h handle, double x, double y) timestamp = util_timestamp(); DbgPrint("CLICKED: %lf\n", timestamp); - packet = packet_create_noack((const char *)&cmd, "sssddd", handle->common->pkgname, handle->common->id, "clicked", timestamp, x, y); + packet = packet_create_noack((const char *)&cmd, "sssddd", handle->common->pkgname, handle->common->id, event, timestamp, x, y); if (!packet) { ErrPrint("Failed to build param\n"); return WIDGET_ERROR_FAULT; diff --git a/widget_viewer/src/widget_internal.c b/widget_viewer/src/widget_internal.c index a767b12..acd4db6 100644 --- a/widget_viewer/src/widget_internal.c +++ b/widget_viewer/src/widget_internal.c @@ -754,7 +754,7 @@ widget_h _widget_unref(widget_h handler, int destroy_common) * \note * Lock file should be deleted after all callbacks are processed. */ - (void)widget_service_destroy_lock(handler->common->widget.lock); + (void)widget_service_destroy_lock(handler->common->widget.lock, 0); handler->common->widget.lock = NULL; _widget_destroy_common_handle(handler->common); } diff --git a/widget_viewer_dali/CMakeLists.txt b/widget_viewer_dali/CMakeLists.txt new file mode 100755 index 0000000..e8e6988 --- /dev/null +++ b/widget_viewer_dali/CMakeLists.txt @@ -0,0 +1,68 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(widget_viewer_dali CXX) + +SET(PREFIX "${CMAKE_INSTALL_PREFIX}") +SET(EXEC_PREFIX "\${prefix}") +SET(PROJECT_NAME "${PROJECT_NAME}") +SET(LIBDIR ${LIB_INSTALL_DIR}) +SET(INCLUDEDIR "\${prefix}/include/${PROJECT_NAME}") +SET(VERSION_MAJOR 1) +SET(VERSION "${VERSION_MAJOR}.0.0") +SET(EDJDIR "/usr/share/${PROJECT_NAME}/res/edje") +SET(RESDIR "/usr/share/${PROJECT_NAME}/res") +SET(IMGDIR "/usr/share/${PROJECT_NAME}/res/image") + +INCLUDE(FindPkgConfig) +pkg_check_modules(viewer_dali REQUIRED + dlog + widget_service + dali + dali-core + dali-toolkit +) + +IF (X11_SUPPORT) +pkg_check_modules(viewer_dali_extra REQUIRED + ecore-x +) + +SET(BUILD_SOURCE + src/widget_viewer_dali.cpp + src/widget_dali.cpp + src/widget_dali_impl.cpp + src/widget_dali_list.cpp + src/common/widget_viewer_dali_const.cpp +) +ENDIF (X11_SUPPORT) + +FOREACH(flag ${viewer_dali_CFLAGS} ${viewer_dali_extra_CFLAGS}) + SET(EXTRA_CXX_FLAGS "${EXTRA_CXX_FLAGS} ${flag}") +ENDFOREACH(flag) + +SET(EXTRA_CXX_FLAGS "${EXTRA_CXX_FLAGS} -fvisibility=hidden -Wall -Werror -Winline -g") + +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CXX_FLAGS}") +SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g") +SET(CMAKE_CXX_FLAGS_RELEASE "-O2") + +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/widget_viewer/include) + +ADD_LIBRARY(${PROJECT_NAME} SHARED ${BUILD_SOURCE}) +SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${VERSION_MAJOR}) +SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${VERSION}) + +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${viewer_dali_LDFLAGS} ${viewer_dali_extra_LDFLAGS} "-lpthread" widget_viewer) + +CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY) +SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${PROJECT_NAME}.pc") + +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR}) +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/${PROJECT_NAME}.h DESTINATION include/${PROJECT_NAME}) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/widget_dali.h DESTINATION include/${PROJECT_NAME}) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/widget_viewer_dali_generic.h DESTINATION include/${PROJECT_NAME}) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE DESTINATION /usr/share/license RENAME "lib${PROJECT_NAME}") +INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/res/image DESTINATION "${RESDIR}") + +ADD_SUBDIRECTORY(res) diff --git a/widget_viewer_dali/LICENSE b/widget_viewer_dali/LICENSE new file mode 100755 index 0000000..571fe79 --- /dev/null +++ b/widget_viewer_dali/LICENSE @@ -0,0 +1,206 @@ +Flora License + +Version 1.1, April, 2013 + +http://floralicense.org/license/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, +and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by +the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and +all other entities that control, are controlled by, or are +under common control with that entity. For the purposes of +this definition, "control" means (i) the power, direct or indirect, +to cause the direction or management of such entity, +whether by contract or otherwise, or (ii) ownership of fifty percent (50%) +or more of the outstanding shares, or (iii) beneficial ownership of +such entity. + +"You" (or "Your") shall mean an individual or Legal Entity +exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, +including but not limited to software source code, documentation source, +and configuration files. + +"Object" form shall mean any form resulting from mechanical +transformation or translation of a Source form, including but +not limited to compiled object code, generated documentation, +and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, +made available under the License, as indicated by a copyright notice +that is included in or attached to the work (an example is provided +in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, +that is based on (or derived from) the Work and for which the editorial +revisions, annotations, elaborations, or other modifications represent, +as a whole, an original work of authorship. For the purposes of this License, +Derivative Works shall not include works that remain separable from, +or merely link (or bind by name) to the interfaces of, the Work and +Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original +version of the Work and any modifications or additions to that Work or +Derivative Works thereof, that is intentionally submitted to Licensor +for inclusion in the Work by the copyright owner or by an individual or +Legal Entity authorized to submit on behalf of the copyright owner. +For the purposes of this definition, "submitted" means any form of +electronic, verbal, or written communication sent to the Licensor or +its representatives, including but not limited to communication on +electronic mailing lists, source code control systems, and issue +tracking systems that are managed by, or on behalf of, the Licensor +for the purpose of discussing and improving the Work, but excluding +communication that is conspicuously marked or otherwise designated +in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity +on behalf of whom a Contribution has been received by Licensor and +subsequently incorporated within the Work. + +"Tizen Certified Platform" shall mean a software platform that complies +with the standards set forth in the Tizen Compliance Specification +and passes the Tizen Compliance Tests as defined from time to time +by the Tizen Technical Steering Group and certified by the Tizen +Association or its designated agent. + +2. Grant of Copyright License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the +Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +(except as stated in this section) patent license to make, have made, +use, offer to sell, sell, import, and otherwise transfer the Work +solely as incorporated into a Tizen Certified Platform, where such +license applies only to those patent claims licensable by such +Contributor that are necessarily infringed by their Contribution(s) +alone or by combination of their Contribution(s) with the Work solely +as incorporated into a Tizen Certified Platform to which such +Contribution(s) was submitted. If You institute patent litigation +against any entity (including a cross-claim or counterclaim +in a lawsuit) alleging that the Work or a Contribution incorporated +within the Work constitutes direct or contributory patent infringement, +then any patent licenses granted to You under this License for that +Work shall terminate as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the +Work or Derivative Works thereof pursuant to the copyright license +above, in any medium, with or without modifications, and in Source or +Object form, provided that You meet the following conditions: + + 1. You must give any other recipients of the Work or Derivative Works + a copy of this License; and + 2. You must cause any modified files to carry prominent notices stating + that You changed the files; and + 3. You must retain, in the Source form of any Derivative Works that + You distribute, all copyright, patent, trademark, and attribution + notices from the Source form of the Work, excluding those notices + that do not pertain to any part of the Derivative Works; and + 4. If the Work includes a "NOTICE" text file as part of its distribution, + then any Derivative Works that You distribute must include a readable + copy of the attribution notices contained within such NOTICE file, + excluding those notices that do not pertain to any part of + the Derivative Works, in at least one of the following places: + within a NOTICE text file distributed as part of the Derivative Works; + within the Source form or documentation, if provided along with the + Derivative Works; or, within a display generated by the Derivative Works, + if and wherever such third-party notices normally appear. + The contents of the NOTICE file are for informational purposes only + and do not modify the License. You may add Your own attribution notices + within Derivative Works that You distribute, alongside or as an addendum + to the NOTICE text from the Work, provided that such additional attribution + notices cannot be construed as modifying the License. You may add Your own + copyright statement to Your modifications and may provide additional or + different license terms and conditions for use, reproduction, or + distribution of Your modifications, or for any such Derivative Works + as a whole, provided Your use, reproduction, and distribution of + the Work otherwise complies with the conditions stated in this License + and your own copyright statement or terms and conditions do not conflict + the conditions stated in the License including section 3. + +5. Submission of Contributions. Unless You explicitly state otherwise, +any Contribution intentionally submitted for inclusion in the Work +by You to the Licensor shall be under the terms and conditions of +this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify +the terms of any separate license agreement you may have executed +with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade +names, trademarks, service marks, or product names of the Licensor, +except as required for reasonable and customary use in describing the +origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or +agreed to in writing, Licensor provides the Work (and each +Contributor provides its Contributions) on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +implied, including, without limitation, any warranties or conditions +of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A +PARTICULAR PURPOSE. You are solely responsible for determining the +appropriateness of using or redistributing the Work and assume any +risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, +whether in tort (including negligence), contract, or otherwise, +unless required by applicable law (such as deliberate and grossly +negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, +incidental, or consequential damages of any character arising as a +result of this License or out of the use or inability to use the +Work (including but not limited to damages for loss of goodwill, +work stoppage, computer failure or malfunction, or any and all +other commercial damages or losses), even if such Contributor +has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing +the Work or Derivative Works thereof, You may choose to offer, +and charge a fee for, acceptance of support, warranty, indemnity, +or other liability obligations and/or rights consistent with this +License. However, in accepting such obligations, You may act only +on Your own behalf and on Your sole responsibility, not on behalf +of any other Contributor, and only if You agree to indemnify, +defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason +of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Flora License to your work + +To apply the Flora License to your work, attach the following +boilerplate notice, with the fields enclosed by brackets "[]" +replaced with your own identifying information. (Don't include +the brackets!) The text should be enclosed in the appropriate +comment syntax for the file format. We also recommend that a +file or class name and description of purpose be included on the +same "printed page" as the copyright notice for easier +identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Flora License, Version 1.1 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://floralicense.org/license/ + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/widget_viewer_dali/include/widget_dali.h b/widget_viewer_dali/include/widget_dali.h new file mode 100755 index 0000000..9b63e3a --- /dev/null +++ b/widget_viewer_dali/include/widget_dali.h @@ -0,0 +1,97 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __WIDGET_H__ +#define __WIDGET_H__ + +#include +#include + +#include "widget_viewer_dali_generic.h" + +using namespace Dali; + +namespace WidgetViewerDali +{ + +namespace Internal +{ +class CWidget; +} + +class CWidget : public Dali::Toolkit::Control +{ +public: + typedef Signal DeletedSignal; + typedef Signal TouchedSignal; + typedef Signal TappedSignal; + typedef Signal LongpressedSignal; + typedef Signal ReloadSignal; + +public: + CWidget(); + CWidget(const CWidget& widget); + CWidget(Internal::CWidget&); + CWidget(Dali::Internal::CustomActor*); + + ~CWidget(); + + static WidgetViewerDali::CWidget New(unsigned int id, void* handle, const char *pkgname, widget_size_type_e size, double period); + + CWidget& operator=( const CWidget& widget ); + static CWidget DownCast( BaseHandle handle ); + + void Initialize(); + + void UpdateByPixmap(unsigned int pixmap); + + int GetRowLen(); + int GetColLen(); + + void SetGridPosition(int row, int col); + void GetGridPosition(int *row, int *col); + + unsigned int GetPixmap(); + void SetPixmap(unsigned int pixmap); + unsigned int GetWidgetId(); + void SetWidgetId(unsigned int id); + + void SetEditMode(bool mode); + void SetTouchable(bool able); + void CancelTouchOperation(); + + DeletedSignal& SignalDeleted(); + TouchedSignal& SignalTouched(); + TappedSignal& SignalTapped(); + LongpressedSignal& SignalLongpressed(); + ReloadSignal& SignalReload(); + + std::string GetPkgName(); + double GetPeriod(); + void SetWidgetHandler(void* handle); + void* GetWidgetHandle(); + widget_size_type_e GetSizeType(); + + bool IsFaulted(); + void SetFault(bool fault); + + bool OnTouch(const TouchEvent& event); + void OnFault(); +}; + +} + +#endif diff --git a/widget_viewer_dali/include/widget_dali_impl.h b/widget_viewer_dali/include/widget_dali_impl.h new file mode 100755 index 0000000..034a130 --- /dev/null +++ b/widget_viewer_dali/include/widget_dali_impl.h @@ -0,0 +1,161 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __WIDGET_IMPL_H__ +#define __WIDGET_IMPL_H__ + +#include + +#include "widget_viewer_dali_generic.h" +#include "widget_dali.h" + +using namespace Dali; + +namespace WidgetViewerDali +{ + +namespace Internal +{ + +class CWidget; +typedef IntrusivePtr WidgetInternalPtr; + +class CWidget : public Dali::Toolkit::Internal::Control +{ +public: + CWidget(unsigned int id, void* handle, const char *pkgname, widget_size_type_e size, double period); + + CWidget(const CWidget&); + CWidget(Internal::CWidget&); + + virtual ~CWidget(); + + static WidgetViewerDali::CWidget New(unsigned int id, void* handler, const char *pkgname, widget_size_type_e size, double period); + + void Initialize(); + + void UpdateByPixmap(unsigned int pixmap); + + int GetRowLen() { return mRowLen; } + int GetColLen() { return mColLen; } + + void SetGridPosition(int row, int col); + void GetGridPosition(int *row, int *col); + + unsigned int GetPixmap() { return mPixmap; } + void SetPixmap(unsigned int pixmap); + + unsigned int GetWidgetId(); + void SetWidgetId(unsigned int id); + + void SetEditMode(bool mode); + void SetTouchable(bool able); + void CancelTouchOperation(); + + std::string GetPkgName() { return mPkgName; } + double GetPeriod() { return mPeriod; } + void SetWidgetHandler(void* handle); + void* GetWidgetHandle() { return mHandler; } + widget_size_type_e GetSizeType() { return mSize; } + bool IsFaulted() { return mIsFaulted; } + void SetFault(bool fault); + void OnFault(); + + WidgetViewerDali::CWidget::DeletedSignal& SignalDeleted() { return mSignalDeleted; } + WidgetViewerDali::CWidget::TouchedSignal& SignalTouched() { return mSignalTouched; }; + WidgetViewerDali::CWidget::TappedSignal& SignalTapped() { return mSignalTapped; }; + WidgetViewerDali::CWidget::LongpressedSignal& SignalLongpressed() { return mSignalLongpressed; }; + WidgetViewerDali::CWidget::ReloadSignal& SignalReload() { return mSignalReload; } + + bool OnTouch(const TouchEvent& event); + +private: + CWidget& operator=(const CWidget& rhs); + + bool _OnDeleteButtonClicked( Dali::Toolkit::Button button ); + bool _OnEventAreaTouchEvent(Dali::Actor actor, const TouchEvent& event); + + Vector3 _GetScreenPosition(); + void _ConnectTouchSignal(bool isConnect); + bool _OnLongTapTimerComplete(); + void _OnWidgetTapped(); + +private: + void* mHandler; + widget_size_type_e mSize; + unsigned int mPixmap; + int mRow; + int mCol; + unsigned int mRowLen; + unsigned int mColLen; + unsigned int mId; + + PixmapImagePtr mPixmapImage; + NativeImage mBaseNativeImageData; + ImageActor mBaseImage; + + Toolkit::TextLabel mLoadingTextLabel; + Toolkit::TextLabel mFaultedTextLabel; + Dali::Toolkit::PushButton mDeleteButton; + + Actor mEventArea; + + WidgetViewerDali::CWidget::DeletedSignal mSignalDeleted; + WidgetViewerDali::CWidget::TouchedSignal mSignalTouched; + WidgetViewerDali::CWidget::TappedSignal mSignalTapped; + WidgetViewerDali::CWidget::LongpressedSignal mSignalLongpressed; + WidgetViewerDali::CWidget::ReloadSignal mSignalReload; + + std::string mPkgName; + double mPeriod; + bool mIsTouched; + bool mIsTouchable; + bool mIsConnectedTouchSignal; + + bool mIsFaulted; + + Timer mLongTapTimer; + Vector2 mDownPos; + + bool mIsEditMode; + ImageActor mFaultDimBg; + +}; + +} + +inline WidgetViewerDali::Internal::CWidget& GetImpl(WidgetViewerDali::CWidget& widget) +{ + DALI_ASSERT_ALWAYS(widget); + + Dali::RefObject& handle = widget.GetImplementation(); + + return static_cast(handle); +} + +inline const WidgetViewerDali::Internal::CWidget& GetImpl(const WidgetViewerDali::CWidget& widget) +{ + DALI_ASSERT_ALWAYS(widget); + + const Dali::RefObject& handle = widget.GetImplementation(); + + return static_cast(handle); +} + +} + +#endif + diff --git a/widget_viewer_dali/include/widget_dali_list.h b/widget_viewer_dali/include/widget_dali_list.h new file mode 100755 index 0000000..ee99a97 --- /dev/null +++ b/widget_viewer_dali/include/widget_dali_list.h @@ -0,0 +1,52 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __WIDGET_LIST_H__ +#define __WIDGET_LIST_H__ + +#include + +#include "widget_viewer_dali_generic.h" +#include "widget_dali.h" + +using namespace Dali; + +namespace WidgetViewerDali +{ + +class CWidgetList +{ +public: + CWidgetList(); + + ~CWidgetList(); + + int Add(void* handle, CWidget widget); + void Remove(void* handle); + CWidget GetWidget(unsigned int id); + unsigned int GetWidgetId(void *handle); + std::vector GetWidgetList(const char * pkgname); + void Update(void* handle, void* newHandle, CWidget widget); + +private: + std::map m_mWidgetList; +}; + +} + +#endif + + diff --git a/widget_viewer_dali/include/widget_viewer_dali.h b/widget_viewer_dali/include/widget_viewer_dali.h new file mode 100755 index 0000000..9037656 --- /dev/null +++ b/widget_viewer_dali/include/widget_viewer_dali.h @@ -0,0 +1,73 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __WIDGET_VIEWER_DALI_H__ +#define __WIDGET_VIEWER_DALI_H__ + +#include + +#include "widget_viewer_dali_generic.h" +#include "widget_dali.h" + +using namespace Dali; + +namespace WidgetViewerDali +{ +class CWidgetList; + +class CWidgetManager : public ConnectionTracker +{ +public: + /* + * Signals + */ + typedef Dali::Signal WidgetAddedSignal; + typedef Dali::Signal WidgetDeletedSignal; + +public: + CWidgetManager(); + ~CWidgetManager(); + + static CWidgetManager* GetInstance(); + + void Initialize(); + + WidgetAddedSignal& GetSignalWidgetAdded() { return mSignalWidgetAdded; } + WidgetDeletedSignal& GetSignalWidgetDeleted() { return mSignalWidgetDeleted; } + + int AddWidget(unsigned int id, const char *pkgname, const char *name, widget_size_type_e type, const char *content, + const char *icon, int pid, double period, int allow_duplicate); + + void WidgetEventCreated(void *handler); + void WidgetEventUpdated(void *handler); + void WidgetEventDeleted(void *handler); + void WidgetFaulted(const char *pkgname); + void EventPixmapAcquired(void *handler, unsigned int pixmapId); + + bool OnWidgetDeleted(WidgetViewerDali::CWidget& widget); + bool OnWidgetReload(WidgetViewerDali::CWidget& widget); + +private: + static CWidgetManager* m_pInstance; + + WidgetAddedSignal mSignalWidgetAdded; + WidgetDeletedSignal mSignalWidgetDeleted; + + CWidgetList* mWidgetList; +}; +} + +#endif \ No newline at end of file diff --git a/widget_viewer_dali/include/widget_viewer_dali_const.h b/widget_viewer_dali/include/widget_viewer_dali_const.h new file mode 100755 index 0000000..f120c5c --- /dev/null +++ b/widget_viewer_dali/include/widget_viewer_dali_const.h @@ -0,0 +1,113 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _WIDGET_VIEWER_DALI_CONST_H_ +#define _WIDGET_VIEWER_DALI_CONST_H_ + +#include +#include + +#define BASE_HEIGHT CWidgetDaliConst::GetBaseHeight() +#define BASE_WIDTH CWidgetDaliConst::GetBaseWidth() + +#define SCREEN_HEIGHT CWidgetDaliConst::GetScreenHeight() +#define SCREEN_WIDTH CWidgetDaliConst::GetScreenWidth() + +#define SCREEN_RESOLUTION_TYPE CWidgetDaliConst::GetScreenResolutionType() + +#define INDICATOR_H CWidgetDaliConst::GetIndicatorHeight() + +#define WIDGET_LOADING_TEXT_WIDTH CWidgetDaliConst::GetWidgetLoadingTextWidth() +#define WIDGET_LOADING_TEXT_SIZE CWidgetDaliConst::GetWidgetLoadingTextSize() +#define WIDGET_DELETE_BUTTON_WIDTH CWidgetDaliConst::GetWidgetDeleteButtonWidth() +#define WIDGET_DELETE_BUTTON_HEIGHT CWidgetDaliConst::GetWidgetDeleteButtonHeight() +#define WIDGET_DELETE_BUTTON_X CWidgetDaliConst::GetWidgetDeleteButtonX() +#define WIDGET_DELETE_BUTTON_Y CWidgetDaliConst::GetWidgetDeleteButtonY() +#define WIDGET_DELETE_BUTTON_Z CWidgetDaliConst::GetWidgetDeleteButtonZ() + +#define TAPPED_BOUNDARY_WIDTH CWidgetDaliConst::GetTappedBoundaryWidth() +#define TAPPED_BOUNDARY_HEIGHT CWidgetDaliConst::GetTappedBoundaryHeight() + +using namespace Dali; + +namespace WidgetViewerDali +{ +class CWidgetDaliConst +{ +public: + typedef enum + { + RESOLUTION_BASE_480X640 = 0, /* 3 : 4 */ + RESOLUTION_BASE_320X480, /* 2 : 3 */ + RESOLUTION_BASE_480X800, /* 3 : 5 */ + RESOLUTION_BASE_540X960, /* 9 : 16 */ + RESOLUTION_BASE_MAX + } ScreenResolutionType; + +public: + static void SetScreenSize(Vector2 size); + static const int GetBaseWidth() { return mBaseWidth; } + static const int GetBaseHeight() { return mBaseHeight; } + static const float GetScreenWidth() { return mScreenSize.width; } + static const float GetScreenHeight() { return mScreenSize.height; } + static const unsigned int GetScreenResolutionType() { return mScreenResolutionType; } + + static const float GetIndicatorHeight(); + + static const float GetWidgetLoadingTextWidth(); + static const float GetWidgetLoadingTextSize(); + + static const float GetWidgetDeleteButtonWidth(); + static const float GetWidgetDeleteButtonHeight(); + static const float GetWidgetDeleteButtonX(); + static const float GetWidgetDeleteButtonY(); + static const float GetWidgetDeleteButtonZ(); + + static const float GetTappedBoundaryWidth(); + static const float GetTappedBoundaryHeight(); + +private : + CWidgetDaliConst(); + static void _SetBaseScreenSize(int width, int height); + static const unsigned int _GetResolutionType(int x, int y); + + static const float _GetX(float xPos) { return floor(xPos * SCREEN_WIDTH / BASE_WIDTH); } + static const float _GetY(float yPos) { return floor(yPos * SCREEN_HEIGHT / BASE_HEIGHT); } + static const float _GetZ(float zPos) { return zPos * SCREEN_WIDTH / BASE_WIDTH; } + static const float _GetWidth(float width) { return width * SCREEN_WIDTH / BASE_WIDTH; } + static const float _GetHeight(float height) { return height * SCREEN_HEIGHT / BASE_HEIGHT; } + + static Vector2 mScreenSize; + static int mBaseWidth; + static int mBaseHeight; + static unsigned int mScreenResolutionType; + + static float mIndicatorHeight[RESOLUTION_BASE_MAX]; + + static float mWidgetLoadingTextWidth[RESOLUTION_BASE_MAX]; + static float mWidgetLoadingTextSize[RESOLUTION_BASE_MAX]; + static float mWidgetDeleteButtonWidth[RESOLUTION_BASE_MAX]; + static float mWidgetDeleteButtonHeight[RESOLUTION_BASE_MAX]; + static float mWidgetDeleteButtonX[RESOLUTION_BASE_MAX]; + static float mWidgetDeleteButtonY[RESOLUTION_BASE_MAX]; + static float mWidgetDeleteButtonZ[RESOLUTION_BASE_MAX]; + static float mTappedBoundaryWidth[RESOLUTION_BASE_MAX]; + static float mTappedBoundaryHeight[RESOLUTION_BASE_MAX]; +}; +} +#endif /* _WIDGET_VIEWER_DALI_CONST_H_ */ + + diff --git a/widget_viewer_dali/include/widget_viewer_dali_generic.h b/widget_viewer_dali/include/widget_viewer_dali_generic.h new file mode 100755 index 0000000..1f17b60 --- /dev/null +++ b/widget_viewer_dali/include/widget_viewer_dali_generic.h @@ -0,0 +1,102 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + #ifndef __WIDGET_VIEWER_DALI_GENERIC_H__ +#define __WIDGET_VIEWER_DALI_GENERIC_H__ + +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include + +#define HS_KEY_MENU "XF86Menu" +#define HS_KEY_BACK "XF86Back" +#define HS_KEY_HOME "XF86Home" +#define HS_KEY_APPS "XF86Apps" + +#if !defined(EAPI) +#define EAPI __attribute__((visibility("default"))) +#endif + +#if defined(LOG_TAG) +#undef LOG_TAG +#endif + +#define LOG_TAG "WIDGET_DALI" + +#if !defined(SECURE_LOGD) +#define SECURE_LOGD LOGD +#endif + +#if !defined(SECURE_LOGW) +#define SECURE_LOGW LOGW +#endif + +#if !defined(SECURE_LOGE) +#define SECURE_LOGE LOGE +#endif + +#if !defined(S_) +#define S_(str) dgettext("sys_string", str) +#endif + +#if !defined(T_) +#define T_(str) dgettext(PKGNAME, str) +#endif + +#if !defined(N_) +#define N_(str) (str) +#endif + +#if !defined(_) +#define _(str) gettext(str) +#endif + + +#if !defined(DbgPrint) +#define DbgPrint(format, arg...) SECURE_LOGD(format, ##arg) +#endif + +#if !defined(ErrPrint) +#define ErrPrint(format, arg...) SECURE_LOGE(format, ##arg) +#endif + +#if !defined(WarnPrint) +#define WarnPrint(format, arg...) SECURE_LOGW(format, ##arg) +#endif + +#if !defined(WIDGET_VIEWER_RESDIR) +#define WIDGET_VIEWER_RESDIR "/usr/share/widget_viewer_dali/res" +#endif + +#if !defined(WIDGET_VIEWER_ICONDIR) +#define WIDGET_VIEWER_ICONDIR WIDGET_VIEWER_RESDIR"/image" +#endif + +#endif /* __WIDGET_VIEWER_DALI_GENERIC_H__ */ + diff --git a/widget_viewer_dali/res/image/btn_delete_nor.png b/widget_viewer_dali/res/image/btn_delete_nor.png new file mode 100755 index 0000000000000000000000000000000000000000..526e12cc7fc833becdf4fc6d625932eb00913367 GIT binary patch literal 2436 zcmaJ@dpwi-A77*-L?T`7Y?6}Mu(2V=jA3Y$QDn9UJ8aL|<~El|xfF`g5h|A)IXQCI zehwl5-bzkpuM7kN zkt10XDB@9b{gd7z{wJ(GV2Ou4d`l|d3H0U%(YOEv&j7suD2YY$0Vn{C5pwP+U<`ps z!kErfK9y{Tqk}92Z5@LMW^u%92*lVlm_wuc0eq+z;KO8_z@}>IVNfQ+1m=P!Bgq^K zz?W$)-~vtpduO`9kB())Opim2gK=U37Qm-LgIWG;9xm7f_E{Gvp097~z@VQYd_NP| z-$_x)j!+Ab3qa8bJ#9J?g@R%*2$Vh=gFzjG>LO9PI!N)0(MIXx&={Pq0rblQ6G!7R zym1r)@k=c6$^_=i=W}p6Izd4}h#)-#$o0`dVX@eC4P9MrF+!Uc!sgS0wb?xQh5`ZL z(YZ_xp9!*|>xwilFo16Y6KDE&2`tW6SvK#>F^LaMCz!_3K_QUqC2au7P8iX>2+`BACF$3J4~Xfx}{umX=7OA=1#Ch(cNFn-dI?M12cO zv^iD}gGUiJxCD?MzyjF(4KCv!F7}(;bt|wq;>ZMm%M1h}`&pB7i~TANu;N=teanPL4)i6O8BkTzBS-uX$HX^d@xsoiyytaXBE!ECIg zOs6VYMb)k8qT2Toc?uWzs-J0QnTz0aGs-W@7b^-Xf$oU2Qh#I`GiSobLI(?`uw&u3 zc?utI@9S!q%7VO))ZTRq;u5JBUN7qjv3Y3p(AZ3}8`Q_|jx>PkqtWQK@n?Bwo12>6 z%E-yh&(F>(iA17p$R}~M^!%q!pI%B%PG*YE3^=*Cxa_#r5R@0`s+xyZ8k+7q)T6Gq zW;W!=WKK-EySslHpBJ?EwNPis=gyr|p2mkM-X85LicOwaDay_sS{NT6mt8ZHRO<-| z38|0lQl0#r27l9Tq^YS{Sy#7)_V5wfuNB-h(<4O@jA~wVe3)}eNIzeg7@d!{tzK4|NC#p8ez$r%6&~nr|q3}JUoBQ zi{^32ep;st(Ea=MjE#+_CMPq@_cfkBR&n?4xWj4rUlS99Ib-(5nkplYGxqk4zMdL* z9IdDr1EN_hOtXrL$|)tp^;b=ETAeK|&%yEq|EQ|AG5DRHoWiyrlFO?4-X~?&2W;=S zo(kRU9zFKwg{&%eCHA19dV@n#YZ)BJ9ko`>^uN}gESsU{db;NI^ZtDX2_q1TXV0jA z%^bQ{m7bNgsx-{F(ZK3n+EG3kde|OXpJ_1YQGH6;`kWkEYFqBvqGAsdA@0Dfe+hcCM8nUiMIrN-dtxs1;bgPw z2rB62pys3l9$CAZo(f~^$nGMqPW6AkN&dLZyHiw*Nf=&Pf}W4xEP6Z8QP>p|8yk8< z*B7QKVKVl__4S?nJrN!1v$GvjOKWSI*+0o_gTb-)QX?ZFi)nt{y*)j`scR~dDRq{X zr@Ev?54Y~v53_22^e7tq>C$!J$#={vCy(9?j(R9m&MN|&Eq|o*mZhEF zy;6rpqI6LqzAiss&5rBupO6!KOs_#o;YXV)`IcQrJG1a^qCXx)F22QYT717J@MomS zfn|?+Ho2@gNvUCNEus-tIg=>e4WiUhnr;@ zH!|De8Me0Dhjp1J1v{0LwB9Lq1D7PO9yInvG>(jQ(rRrgUoTy|HuL^%rdPMXn_ z`sd@*E^k@w9vGXkS5a@PJLAJv*oa_Vq+;$MbGW&Bn?`X_;YesHIi+KDEg z3@_#E^4#3qF7I$$psYyEFp@CVmB-4a#NkRqBU)OJ_SHhAMqAsMn_ydOYpe9u+~QuX zK~}8Ae3zu8WIORLKn^wPYhhrT9};^Fjf_4?pON?tcQq_6E$z?>HN{jeZ*(7?P0E@&SQ?buliiUFU^x zJ*-!Mjl}B=w@o*9QYId04m%1SD!QFqxg44d8!XM?Shv)& zGUw8cm6_eFOszbnrZ$}2QuxZVBiy}#jEYrXILz3a!fhZelXKo_bD0)Y(t ze93h6Xg&MQ*HZuYf2-!Jhh+eT0jv|o0y36_3nFoZFf=3`))yso5Zqo2OjFVkd9`L<~2MCvZoO);1y$JdQgu93O-U68UiB zdA`XK?z-gQPQSOfXu1i$UXSdNv#CHgg;Ewz& zDMk?IA_xQ&)(KA_VC@k&3>JsRs9%Bu)`^HG5OL0k9}iL;O~Q#K z(#g~xvD7PfWIO_Q9?-^8tdxnI;(-hIj9j1QiT9u$sGhzvpEGaSIU;~ zL;z1HK+Gz#VuXo+J5rtLUnTHGKV=2dAIGFVFtnT{LSs>w*^=gfK|%i?%IE(?O949f z?|lEKuryR5;-cwXsW4H(RyQuzY&MjL=p*5>0HGvQDBL`EinMqkAe6=nMF^jD1cY@s zPrwn%q&DC2K|w@6ffQf~*jzudJ5sHH;_)~{R~&^zaP-DtT)e4REX9e0r;xmzNmv4j zN_BF<6Xv*NAv=-J6##Qw&fi?@FS)Z;;EU9e$y^C9iOZo%gnY#Jl8L-u=0c+UQttSWNfjs34i&uyvQGdulhTlM0n@wo!E+av0!czSxv^w`L? z`*OABVEcJCWcX={=*kuf?<7{=t7>&vxSE|8XgP8JKCLnA93R}-bp9wa>~iG0f=$)z)+`k$ro*>; z^QT?4vQZCOSlB0VWaKe76soRVdmgx`>&>P_0I0&_@o7V2^5hp6HNEO9K`m`Zqaz{| z3*YLgg(Gg|-YXqj^+%CHp*WJ5n0WT-)2IJrtSOB`g+w=QnJ%rbuQv-jH))|$=;fk( za?Yrj9+5acaC^eW#^%Azg9{62s*0p{Jr1BUjgSUJ&cr-j&}(Dm*I4X};p;;a*EBUX zmpeg&vO7m$=>hpPCBt$&At3>M<6ncZ;1rx9HTA@!zP>)qPH`*-LQ%E$9|>E(e*LcG1N|fG24K*=rp#0(D06ahM`}q; z%@^tYFUW%nzx9)*E=1QhY=f-Dbm@KYGY zg29!p+sNm_J2usOZLzZV3v61_-QCTK)6{Q#}IOU5;Uke24 zvUO$VSpm+IQx6b)DIB;6T~SMIQ~`z#gwozICUq)MsOz=^}F$76&$X_Uzf# z9h$ON`jX5ny7a`dihC~tu~M?$p4DE=>kFVIii+~`a*gCCIc@ttAL{j;#+ajQ3ng~< zDy0Tcqw#Q>)d<|V3$#;AH$Il96kh+1uQOdxF0gU_6{h`myxv#?a*L=xzS^KlYyaO4HOF9@=5O2cmq&% zH+4W-oPU2o(%xQUN}PeEdo65Ki7H0jN<&VCZ8-lJ&iVp0G^jj!FL@ao;FVO!pv>g3 z=f0PIIg4e{(a%PyXU4QuN$p8FPDf=Q$}#f>mdBT@rPB{0?d1N_#h%JbCiu$)x%DMJG<2AQ#Z8Pg``onLK2BuPcejNY>ug99JjNz_2{|6KMrHM9)K~ulSG%Rs_M3J?i<#Ro@z;GZdsJR zBflc1{DlYD+0lY|6XBy-TwH7yem>G7w`~w1#+iiP5Etd^sRAw0CePzK^1Clbo)^gF z)!KqY<7RG7^!c!_F^Q17Zc#=DvjRv;N8b!HCM=@*_LT0uQnLZ`^=mF_Y`k~7*ky1i w=T)TF74Y%O(lqn?mcAUK4$xBi=Zr1}G_Aaz*+EEXp1ryGQG&@AyqVkn1H9BZ1^@s6 literal 0 HcmV?d00001 diff --git a/widget_viewer_dali/src/common/widget_viewer_dali_const.cpp b/widget_viewer_dali/src/common/widget_viewer_dali_const.cpp new file mode 100755 index 0000000..9bd2c2e --- /dev/null +++ b/widget_viewer_dali/src/common/widget_viewer_dali_const.cpp @@ -0,0 +1,147 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "widget_viewer_dali_const.h" + +using namespace Dali; +using namespace WidgetViewerDali; + +namespace WidgetViewerDali +{ + +const float SCREEN_RATIO[4] = { (4.0f/3.0f), (3.0f/2.0f), (5.0f/3.0f), (16.0f/9.0f) }; +const int SCREEN_RESOLUTION[4][2] = { {480, 640}, {320, 480}, {480, 800}, {540, 960} }; + +Vector2 CWidgetDaliConst::mScreenSize = Vector2(BASE_WIDTH, BASE_HEIGHT); +int CWidgetDaliConst::mBaseWidth = 480; +int CWidgetDaliConst::mBaseHeight = 800; +unsigned int CWidgetDaliConst::mScreenResolutionType = CWidgetDaliConst::RESOLUTION_BASE_480X800; + +/* + 0 : 480x640 - unsupported + 1 : 320x480 - unsupported + 2 : 480x800 - WVGA + 3 : 540x960 - qHD +*/ +float CWidgetDaliConst::mIndicatorHeight[CWidgetDaliConst::RESOLUTION_BASE_MAX] = { 0.0f, 0.0f, 33.33f, 40.0f }; +float CWidgetDaliConst::mWidgetLoadingTextWidth[CWidgetDaliConst::RESOLUTION_BASE_MAX] = { 0.0f, 0.0f, 470.0f, 528.75f }; +float CWidgetDaliConst::mWidgetLoadingTextSize[CWidgetDaliConst::RESOLUTION_BASE_MAX] = { 0.0f, 0.0f, 18.0f, 21.65f }; +float CWidgetDaliConst::mWidgetDeleteButtonWidth[CWidgetDaliConst::RESOLUTION_BASE_MAX] = { 0.0f, 0.0f, 40.0f, 45.0f }; +float CWidgetDaliConst::mWidgetDeleteButtonHeight[CWidgetDaliConst::RESOLUTION_BASE_MAX] = { 0.0f, 0.0f, 40.0f, 48.0f }; +float CWidgetDaliConst::mWidgetDeleteButtonX[CWidgetDaliConst::RESOLUTION_BASE_MAX] = { 0.0f, 0.0f, 15.0f, 16.875f }; +float CWidgetDaliConst::mWidgetDeleteButtonY[CWidgetDaliConst::RESOLUTION_BASE_MAX] = { 0.0f, 0.0f, 15.0f, 18.0f }; +float CWidgetDaliConst::mWidgetDeleteButtonZ[CWidgetDaliConst::RESOLUTION_BASE_MAX] = { 0.0f, 0.0f, 3.5f, 3.9375f }; +float CWidgetDaliConst::mTappedBoundaryWidth[CWidgetDaliConst::RESOLUTION_BASE_MAX] = { 0.0f, 0.0f, 10.0f, 11.5f }; +float CWidgetDaliConst::mTappedBoundaryHeight[CWidgetDaliConst::RESOLUTION_BASE_MAX] = { 0.0f, 0.0f, 10.0f, 12.0f }; + +CWidgetDaliConst::CWidgetDaliConst() +{ +} + +void CWidgetDaliConst::SetScreenSize(Vector2 size) +{ + mScreenSize = size; + + _SetBaseScreenSize(size.x, size.y); +} + +void CWidgetDaliConst::_SetBaseScreenSize(int width, int height) +{ + unsigned int type = _GetResolutionType(width, height); + + if( width < height ) + { + mBaseWidth = SCREEN_RESOLUTION[type][0]; + mBaseHeight = SCREEN_RESOLUTION[type][1]; + } + else + { + mBaseWidth = SCREEN_RESOLUTION[type][1]; + mBaseHeight = SCREEN_RESOLUTION[type][0]; + } + + mScreenResolutionType = type; +} + +const unsigned int CWidgetDaliConst::_GetResolutionType(int x, int y) +{ + if(x > y) + return CWidgetDaliConst::_GetResolutionType(y, x); + + float ratio = (float) y / (float) x; + + unsigned int type=0; + for(type=0; type < RESOLUTION_BASE_MAX - 1; type++) + { + if( fabs(ratio - SCREEN_RATIO[type]) < fabs(ratio - SCREEN_RATIO[type+1]) ) + break; + } + + return type; +} + +const float CWidgetDaliConst::GetIndicatorHeight() +{ + return _GetHeight(mIndicatorHeight[mScreenResolutionType]); +} + +const float CWidgetDaliConst::GetWidgetLoadingTextWidth() +{ + return _GetWidth(mWidgetLoadingTextWidth[mScreenResolutionType]); +} + +const float CWidgetDaliConst::GetWidgetLoadingTextSize() +{ + return _GetHeight(mWidgetLoadingTextSize[mScreenResolutionType]); +} + +const float CWidgetDaliConst::GetWidgetDeleteButtonWidth() +{ + return _GetWidth(mWidgetDeleteButtonWidth[mScreenResolutionType]); +} + +const float CWidgetDaliConst::GetWidgetDeleteButtonHeight() +{ + return _GetHeight(mWidgetDeleteButtonHeight[mScreenResolutionType]); +} + +const float CWidgetDaliConst::GetWidgetDeleteButtonX() +{ + return _GetX(mWidgetDeleteButtonX[mScreenResolutionType]); +} + +const float CWidgetDaliConst::GetWidgetDeleteButtonY() +{ + return _GetY(mWidgetDeleteButtonY[mScreenResolutionType]); +} + +const float CWidgetDaliConst::GetWidgetDeleteButtonZ() +{ + return _GetZ(mWidgetDeleteButtonZ[mScreenResolutionType]); +} + +const float CWidgetDaliConst::GetTappedBoundaryWidth() +{ + return _GetWidth(mTappedBoundaryWidth[mScreenResolutionType]); +} + +const float CWidgetDaliConst::GetTappedBoundaryHeight() +{ + return _GetHeight(mTappedBoundaryHeight[mScreenResolutionType]); +} + +} + diff --git a/widget_viewer_dali/src/widget_dali.cpp b/widget_viewer_dali/src/widget_dali.cpp new file mode 100755 index 0000000..99b8f3e --- /dev/null +++ b/widget_viewer_dali/src/widget_dali.cpp @@ -0,0 +1,209 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include "widget_viewer_dali_generic.h" +#include "widget_dali.h" +#include "widget_dali_impl.h" +#include "debug.h" + +using namespace Dali; +using namespace WidgetViewerDali; + +namespace WidgetViewerDali +{ + +EAPI CWidget::CWidget() +{ +} + +EAPI CWidget::CWidget(const CWidget& widget) +: Dali::Toolkit::Control(widget) +{ +} + +EAPI CWidget::CWidget(Internal::CWidget& impl) +: Dali::Toolkit::Control(impl) +{ +} + +EAPI CWidget::CWidget(Dali::Internal::CustomActor* implementation) +: Dali::Toolkit::Control(implementation) +{ + VerifyCustomActorPointer(implementation); +} + +EAPI CWidget::~CWidget() +{ +} + +CWidget CWidget::New(unsigned int id, void* handle, const char *pkgname, widget_size_type_e size, double period) +{ + return Internal::CWidget::New(id, handle, pkgname, size, period); +} + +void CWidget::Initialize() +{ + GetImpl(*this).Initialize(); +} + +EAPI CWidget& CWidget::operator=( const CWidget& widget ) +{ + if( &widget != this ) + { + Dali::Toolkit::Control::operator=( widget ); + } + + return *this; +} + +EAPI CWidget CWidget::DownCast( BaseHandle handle ) +{ + return Dali::Toolkit::Control::DownCast(handle); +} + +EAPI int CWidget::GetRowLen() +{ + return GetImpl(*this).GetRowLen(); +} + +EAPI int CWidget::GetColLen() +{ + return GetImpl(*this).GetColLen(); +} + +EAPI void CWidget::SetGridPosition(int row, int col) +{ + GetImpl(*this).SetGridPosition(row, col); +} + +EAPI void CWidget::GetGridPosition(int *row, int *col) +{ + GetImpl(*this).GetGridPosition(row, col); +} + +unsigned int CWidget::GetPixmap() +{ + return GetImpl(*this).GetPixmap(); +} + +void CWidget::SetPixmap(unsigned int pixmap) +{ + GetImpl(*this).SetPixmap(pixmap); +} + +EAPI unsigned int CWidget::GetWidgetId() +{ + return GetImpl(*this).GetWidgetId(); +} + +void CWidget::SetWidgetId(unsigned int id) +{ + GetImpl(*this).SetWidgetId(id); +} + +void CWidget::UpdateByPixmap(unsigned int pixmap) +{ + GetImpl(*this).UpdateByPixmap(pixmap); +} + +EAPI void CWidget::SetEditMode(bool mode) +{ + GetImpl(*this).SetEditMode(mode); +} + +EAPI void CWidget::SetTouchable(bool able) +{ + GetImpl(*this).SetTouchable(able); +} + +EAPI void CWidget::CancelTouchOperation() +{ + GetImpl(*this).CancelTouchOperation(); +} + +CWidget::DeletedSignal& CWidget::SignalDeleted() +{ + return GetImpl(*this).SignalDeleted(); +} + +EAPI CWidget::TouchedSignal& CWidget::SignalTouched() +{ + return GetImpl(*this).SignalTouched(); +} + +EAPI CWidget::TappedSignal& CWidget::SignalTapped() +{ + return GetImpl(*this).SignalTapped(); +} + +EAPI CWidget::LongpressedSignal& CWidget::SignalLongpressed() +{ + return GetImpl(*this).SignalLongpressed(); +} + +CWidget::ReloadSignal& CWidget::SignalReload() +{ + return GetImpl(*this).SignalReload(); +} + +std::string CWidget::GetPkgName() +{ + return GetImpl(*this).GetPkgName(); +} + +double CWidget::GetPeriod() +{ + return GetImpl(*this).GetPeriod(); +} + +bool CWidget::IsFaulted() +{ + return GetImpl(*this).IsFaulted(); +} + +void CWidget::SetFault(bool fault) +{ + GetImpl(*this).SetFault(fault); +} + +void CWidget::SetWidgetHandler(void* handle) +{ + GetImpl(*this).SetWidgetHandler(handle); +} + +void* CWidget::GetWidgetHandle() +{ + return GetImpl(*this).GetWidgetHandle(); +} + +widget_size_type_e CWidget::GetSizeType() +{ + return GetImpl(*this).GetSizeType(); +} + +EAPI bool CWidget::OnTouch(const TouchEvent& event) +{ + return GetImpl(*this).OnTouch(event); +} + +void CWidget::OnFault() +{ + GetImpl(*this).OnFault(); +} + +} diff --git a/widget_viewer_dali/src/widget_dali_impl.cpp b/widget_viewer_dali/src/widget_dali_impl.cpp new file mode 100755 index 0000000..ad9f7f7 --- /dev/null +++ b/widget_viewer_dali/src/widget_dali_impl.cpp @@ -0,0 +1,491 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#include "widget_viewer_dali_generic.h" +#include "widget_viewer_dali_const.h" +#include "widget_dali_impl.h" +#include "debug.h" + +#if defined(LOG_TAG) +#undef LOG_TAG +#endif + +#define LOG_TAG "WIDGET_DALI" + +using namespace Dali; +using namespace WidgetViewerDali; + +namespace WidgetViewerDali +{ + +namespace Internal +{ + +EAPI CWidget::CWidget(unsigned int id, void* handle, const char *pkgname, widget_size_type_e size, double period) +: Dali::Toolkit::Internal::Control(ControlBehaviour(REQUIRES_TOUCH_EVENTS)), + mHandler(handle), + mSize(size), + mPixmap(0), + mRowLen(1), + mColLen(1), + mId(id), + mPkgName(pkgname), + mPeriod(period), + mIsTouched(false), + mIsTouchable(true), + mIsConnectedTouchSignal(false), + mIsFaulted(false), + mIsEditMode(false) +{ +} + +EAPI CWidget::~CWidget() +{ +} + +EAPI WidgetViewerDali::CWidget CWidget::New(unsigned int id, void* handler, const char *pkgname, widget_size_type_e size, double period) +{ + WidgetInternalPtr pWidget(new CWidget(id, handler, pkgname, size, period)); + + WidgetViewerDali::CWidget handle(*pWidget); + + pWidget->Initialize(); + + return handle; +} + +void CWidget::Initialize() +{ + DbgPrint("%x", mSize); + Actor self = Self(); + + self.SetParentOrigin( ParentOrigin::TOP_CENTER ); + self.SetAnchorPoint( AnchorPoint::TOP_CENTER ); + + mBaseImage = ImageActor::New(); + mBaseImage.SetParentOrigin( ParentOrigin::TOP_LEFT ); + mBaseImage.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + Constraint constraint = Constraint::New( mBaseImage, Actor::Property::SIZE, EqualToConstraint() ); + constraint.AddSource( ParentSource(Actor::Property::SIZE) ); + constraint.Apply(); + + self.Add(mBaseImage); + + mEventArea = Actor::New(); + + Constraint eventAreaConstraint = Constraint::New( mEventArea, Actor::Property::SIZE, EqualToConstraint() ); + eventAreaConstraint.AddSource( ParentSource(Actor::Property::SIZE) ); + eventAreaConstraint.Apply(); + + mEventArea.SetAnchorPoint(AnchorPoint::CENTER); + mEventArea.SetParentOrigin(ParentOrigin::CENTER); + mEventArea.SetPosition(0.0f, 0.0f, 0.5f); + + self.Add(mEventArea); + + /* supporting to operate normal and edit mode */ + mEventArea.TouchedSignal().Connect(this, &Internal::CWidget::_OnEventAreaTouchEvent); + mEventArea.SetLeaveRequired(true); + mIsConnectedTouchSignal = true; + + Vector2 resolution = Stage::GetCurrent().GetDpi(); + mLoadingTextLabel = Toolkit::TextLabel::New(_("IDS_ST_BODY_LOADING_ING")); + mLoadingTextLabel.SetProperty(Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER"); + mLoadingTextLabel.SetProperty(Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER"); + mLoadingTextLabel.SetProperty(Toolkit::TextLabel::Property::POINT_SIZE, WIDGET_LOADING_TEXT_SIZE * 72.0f/resolution.y); + mLoadingTextLabel.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Vector4(1.0f, 1.0f, 1.0f, 1.0f)); + mLoadingTextLabel.SetParentOrigin(ParentOrigin::CENTER); + mLoadingTextLabel.SetAnchorPoint(AnchorPoint::CENTER); + mLoadingTextLabel.SetSize(WIDGET_LOADING_TEXT_WIDTH, WIDGET_LOADING_TEXT_SIZE * 3); + mLoadingTextLabel.SetPosition(Vector3(0.0f, 0.0f, 0.0f)); + mBaseImage.Add(mLoadingTextLabel); + + Image iconImage; + mDeleteButton = Dali::Toolkit::PushButton::New(); + iconImage = ResourceImage::New(WIDGET_VIEWER_ICONDIR"/btn_delete_nor.png"); + mDeleteButton.SetButtonImage(iconImage); + iconImage = ResourceImage::New(WIDGET_VIEWER_ICONDIR"/btn_delete_press.png"); + mDeleteButton.SetSelectedImage(iconImage); + mDeleteButton.SetSize(Vector2(WIDGET_DELETE_BUTTON_WIDTH, WIDGET_DELETE_BUTTON_HEIGHT)); + mDeleteButton.SetAnchorPoint(AnchorPoint::TOP_LEFT); + mDeleteButton.SetParentOrigin(AnchorPoint::TOP_LEFT); + mDeleteButton.SetPosition(Vector3(WIDGET_DELETE_BUTTON_X, WIDGET_DELETE_BUTTON_Y, WIDGET_DELETE_BUTTON_Z)); + mDeleteButton.SetOpacity(0.0f); + + mDeleteButton.ClickedSignal().Connect( this, &Internal::CWidget::_OnDeleteButtonClicked ); + + mBaseImage.Add(mDeleteButton); + + switch (mSize) { + case WIDGET_SIZE_TYPE_1x1 : + mRowLen = 1; + mColLen = 1; + break; + case WIDGET_SIZE_TYPE_2x1 : + mRowLen = 1; + mColLen = 2; + break; + case WIDGET_SIZE_TYPE_2x2 : + mRowLen = 2; + mColLen = 2; + break; + case WIDGET_SIZE_TYPE_4x1 : + mRowLen = 1; + mColLen = 4; + break; + case WIDGET_SIZE_TYPE_4x2 : + mRowLen = 2; + mColLen = 4; + break; + case WIDGET_SIZE_TYPE_4x3 : + mRowLen = 3; + mColLen = 4; + break; + case WIDGET_SIZE_TYPE_4x4 : + mRowLen = 4; + mColLen = 4; + break; + case WIDGET_SIZE_TYPE_4x5 : + mRowLen = 5; + mColLen = 4; + break; + case WIDGET_SIZE_TYPE_4x6 : + mRowLen = 6; + mColLen = 4; + break; + default: + mRowLen = 1; + mColLen = 1; + break; + } + + if (!mLongTapTimer) + { + mLongTapTimer = Timer::New(1000); + mLongTapTimer.TickSignal().Connect(this, &Internal::CWidget::_OnLongTapTimerComplete); + } + + DbgPrint("rowLen, colLen [%d, %d]", mRowLen, mColLen); +} + +void CWidget::UpdateByPixmap(unsigned int pixmap) +{ + DbgPrint("Update widget by pixmap[%d]", pixmap); + mPixmap = pixmap; + mPixmapImage = PixmapImage::New(mPixmap); + mBaseNativeImageData = NativeImage::New(*mPixmapImage); + + if(mLoadingTextLabel) + { + mBaseImage.Remove(mLoadingTextLabel); + mLoadingTextLabel.Reset(); + } + + if(mFaultDimBg) + { + mFaultDimBg.SetOpacity(0.0f); + } + + mBaseImage.SetImage(mBaseNativeImageData); + + mIsFaulted = false; +} + +void CWidget::SetPixmap(unsigned int pixmap) +{ + DbgPrint("Set [%d]", pixmap); + mPixmap = pixmap; +} + +void CWidget::SetWidgetId(unsigned int id) +{ + DbgPrint("Set [%d]", id); + mId = id; +} + +unsigned int CWidget::GetWidgetId() +{ + DbgPrint("Get Id [%d]", mId); + return mId; +} + +void CWidget::SetWidgetHandler(void* handle) +{ + mHandler = handle; +} + +void CWidget::SetEditMode(bool mode) +{ + mIsEditMode = mode; + CancelTouchOperation(); + + mDeleteButton.SetOpacity(mode ? 1.0f : 0.0f); + + _ConnectTouchSignal(!mode); +} + +void CWidget::SetTouchable(bool able) +{ + mIsTouchable = able; + _ConnectTouchSignal(able); +} + +void CWidget::_ConnectTouchSignal(bool isConnect) +{ + if(isConnect && mIsTouchable) + { + mEventArea.TouchedSignal().Connect(this, &Internal::CWidget::_OnEventAreaTouchEvent); + mIsConnectedTouchSignal = true; + } + else if(mIsConnectedTouchSignal) + { + mEventArea.TouchedSignal().Disconnect(this, &Internal::CWidget::_OnEventAreaTouchEvent); + mIsConnectedTouchSignal = false; + } +} + +void CWidget::CancelTouchOperation() +{ + if (mLongTapTimer.IsRunning()) + { + mLongTapTimer.Stop(); + } + + if(mIsTouched) + { + mIsTouched = false; + + TouchEvent event; + Vector3 screenposition = _GetScreenPosition(); + event.points.push_back( TouchPoint ( 0, Dali::TouchPoint::Leave, screenposition.x, screenposition.y ) ); + DbgPrint("cancel x, y [%.2f, %.2f]", screenposition.x, screenposition.y); + _OnEventAreaTouchEvent(Self(), event); + } +} + +bool CWidget::_OnDeleteButtonClicked( Dali::Toolkit::Button button ) +{ + Actor self = Self(); + + WidgetViewerDali::CWidget handle ( GetOwner() ); + + mSignalDeleted.Emit(handle); + + return true; +} + +bool CWidget::_OnEventAreaTouchEvent(Dali::Actor actor, const TouchEvent& event) +{ + DbgPrint("_OnEventAreaTouchEvent!! widget id[%d]", mId); + WidgetViewerDali::CWidget handle ( GetOwner() ); + + mSignalTouched.Emit(handle, event.GetPoint(0).state, event.GetPoint(0).screen); + + if(event.GetPoint(0).state == Dali::TouchPoint::Down) + { + mLongTapTimer.Start(); + } + + Actor self = Self(); + + struct widget_mouse_event_info info; + + Vector3 screenposition = _GetScreenPosition(); + info.x = event.GetPoint(0).screen.x - screenposition.x; + info.y = event.GetPoint(0).screen.y - screenposition.y; + + info.ratio_w = 1.0f; + info.ratio_h = 1.0f; + info.device = 0; + + if(event.GetPoint(0).state == Dali::TouchPoint::Down) + { + mIsTouched = true; + mLongTapTimer.Start(); + mDownPos.x = info.x; + mDownPos.y = info.y; + + widget_viewer_feed_mouse_event(static_cast(mHandler), WIDGET_MOUSE_ENTER, &info); + widget_viewer_feed_mouse_event(static_cast(mHandler), WIDGET_MOUSE_DOWN, &info); + } + else if(event.GetPoint(0).state == Dali::TouchPoint::Up) + { + if(mIsTouched) + { + float gapX = fabs(info.x - mDownPos.x); + float gapY = fabs(info.y - mDownPos.y); + + if(gapX <= TAPPED_BOUNDARY_WIDTH && gapY <= TAPPED_BOUNDARY_HEIGHT) + { + mSignalTapped.Emit(handle, event.GetPoint(0).screen); + _OnWidgetTapped(); + } + } + mIsTouched = false; + + if (mLongTapTimer.IsRunning()) + { + mLongTapTimer.Stop(); + } + + widget_viewer_feed_mouse_event(static_cast(mHandler), WIDGET_MOUSE_UP, &info); + widget_viewer_feed_mouse_event(static_cast(mHandler), WIDGET_MOUSE_LEAVE, &info); + } + else if(event.GetPoint(0).state == Dali::TouchPoint::Motion) + { + if(mIsTouched && mLongTapTimer.IsRunning()) + { + float gapX = fabs(info.x - mDownPos.x); + float gapY = fabs(info.y - mDownPos.y); + + if(gapX > TAPPED_BOUNDARY_WIDTH || gapY > TAPPED_BOUNDARY_HEIGHT) + { + mLongTapTimer.Stop(); + } + } + widget_viewer_feed_mouse_event(static_cast(mHandler), WIDGET_MOUSE_MOVE, &info); + } + else if(event.GetPoint(0).state == Dali::TouchPoint::Leave || event.GetPoint(0).state == Dali::TouchPoint::Interrupted) + { + mIsTouched = false; + + if (mLongTapTimer.IsRunning()) + { + mLongTapTimer.Stop(); + } + + /*widget_viewer_feed_mouse_event(static_cast(mHandler), WIDGET_MOUSE_UP, &info);*/ + widget_viewer_feed_mouse_event(static_cast(mHandler), WIDGET_MOUSE_LEAVE, &info); + } + + return false; +} + +bool CWidget::OnTouch(const TouchEvent& event) +{ + return _OnEventAreaTouchEvent(Self(), event); +} + +void CWidget::_OnWidgetTapped() +{ + if(!mIsFaulted) + return ; + + if(mFaultedTextLabel) + { + mFaultedTextLabel.SetProperty(Toolkit::TextLabel::Property::TEXT, _("IDS_ST_BODY_LOADING_ING")); + } + + WidgetViewerDali::CWidget handle ( GetOwner() ); + mSignalReload.Emit(handle); +} + +void CWidget::SetGridPosition(int row, int col) +{ + mRow = row; + mCol = col; +} + +void CWidget::GetGridPosition(int *row, int *col) +{ + *row = mRow; + *col = mCol; +} + +Vector3 CWidget::_GetScreenPosition() +{ + Actor self = Self(); + Vector3 position = self.GetCurrentPosition(); + Actor actor = self.GetParent(); + + while(actor) + { + position += actor.GetCurrentPosition(); + + actor = actor.GetParent(); + + } + + return position; +} + +void CWidget::SetFault(bool fault) +{ + mIsFaulted = fault; +} + +bool CWidget::_OnLongTapTimerComplete() +{ + WidgetViewerDali::CWidget handle ( GetOwner() ); + mSignalLongpressed.Emit(handle, mDownPos); + return false; +} + +void CWidget::OnFault() +{ + mIsFaulted = true; + if(mLoadingTextLabel) + { + mLoadingTextLabel.SetOpacity(0.0f); + } + + if(!mFaultDimBg) + { + mFaultDimBg = Toolkit::CreateSolidColorActor(Vector4(0.3, 0.3, 0.3, 0.85)); + mFaultDimBg.SetZ(0.1f); + mFaultDimBg.SetParentOrigin(ParentOrigin::CENTER); + mFaultDimBg.SetAnchorPoint(AnchorPoint::CENTER); + + Constraint constraint = Constraint::New( mFaultDimBg, Actor::Property::SIZE, EqualToConstraint() ); + constraint.AddSource( ParentSource(Actor::Property::SIZE) ); + constraint.Apply(); + + mBaseImage.Add(mFaultDimBg); + } + + if(!mFaultedTextLabel) + { + Vector2 resolution = Stage::GetCurrent().GetDpi(); + mFaultedTextLabel = Toolkit::TextLabel::New(_("IDS_HS_BODY_UNABLE_TO_LOAD_DATA_TAP_TO_RETRY")); + mFaultedTextLabel.SetProperty(Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER"); + mFaultedTextLabel.SetProperty(Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER"); + mFaultedTextLabel.SetProperty(Toolkit::TextLabel::Property::POINT_SIZE, WIDGET_LOADING_TEXT_SIZE * 72.0f/resolution.y); + mFaultedTextLabel.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Vector4(1.0f, 1.0f, 1.0f, 1.0f)); + + mFaultedTextLabel.SetAnchorPoint(AnchorPoint::CENTER); + mFaultedTextLabel.SetParentOrigin(ParentOrigin::CENTER); + + mFaultedTextLabel.SetSize(WIDGET_LOADING_TEXT_WIDTH, WIDGET_LOADING_TEXT_SIZE * 3); + mFaultedTextLabel.SetPosition(Vector3(0.0f, 0.0f, 0.0f)); + + mFaultedTextLabel.SetZ(0.1f); + + mFaultDimBg.Add(mFaultedTextLabel); + } + else + { + mFaultedTextLabel.SetProperty(Toolkit::TextLabel::Property::TEXT, _("IDS_HS_BODY_UNABLE_TO_LOAD_DATA_TAP_TO_RETRY")); + } + + mFaultDimBg.SetOpacity(mIsEditMode ? 0.0f : 1.0f); +} + +} +} + diff --git a/widget_viewer_dali/src/widget_dali_list.cpp b/widget_viewer_dali/src/widget_dali_list.cpp new file mode 100755 index 0000000..73ce68a --- /dev/null +++ b/widget_viewer_dali/src/widget_dali_list.cpp @@ -0,0 +1,113 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include "widget_dali_list.h" + +using namespace Dali; +using namespace WidgetViewerDali; + +namespace WidgetViewerDali +{ + +CWidgetList::CWidgetList() +{ + m_mWidgetList.clear(); +} + +CWidgetList::~CWidgetList() +{ +} + +int CWidgetList::Add(void* handle, CWidget widget) +{ + DbgPrint("size[%d]", m_mWidgetList.size()); + + m_mWidgetList[handle] = widget; + + DbgPrint("size[%d]", m_mWidgetList.size()); + + return m_mWidgetList.size(); +} + +void CWidgetList::Remove(void* handle) +{ + DbgPrint("size[%d]", m_mWidgetList.size()); + + std::map::iterator iter = m_mWidgetList.find(handle); + + m_mWidgetList.erase(iter); + + DbgPrint("size[%d]", m_mWidgetList.size()); +} + +CWidget CWidgetList::GetWidget(unsigned int id) +{ + std::map::iterator iter; + for(iter = m_mWidgetList.begin(); iter!= m_mWidgetList.end(); iter++) + { + if(iter->second.GetWidgetId() == id) + { + DbgPrint("Get id[%d]", id); + return iter->second; + } + } + + return NULL; +} + +unsigned int CWidgetList::GetWidgetId(void *handle) +{ + std::map::iterator iter; + for(iter = m_mWidgetList.begin(); iter!= m_mWidgetList.end(); iter++) + { + if(iter->first == handle) + { + return iter->second.GetWidgetId(); + } + } + + ErrPrint("Widget is wrong!"); + return 0; +} + +std::vector CWidgetList::GetWidgetList(const char * pkgname) +{ + std::vector list; + std::map::iterator iter; + for(iter = m_mWidgetList.begin(); iter!= m_mWidgetList.end(); iter++) + { + if(!iter->second.GetPkgName().compare(pkgname)) + { + list.push_back(iter->second); + } + } + + return list; +} + +void CWidgetList::Update(void* handle, void* newHandle, CWidget widget) +{ + DbgPrint("handle %p, newhandle %p", handle, newHandle); + + widget.SetWidgetHandler(newHandle); + m_mWidgetList[newHandle] = widget; + Remove(handle); +} + +} + diff --git a/widget_viewer_dali/src/widget_viewer_dali.cpp b/widget_viewer_dali/src/widget_viewer_dali.cpp new file mode 100755 index 0000000..24451c8 --- /dev/null +++ b/widget_viewer_dali/src/widget_viewer_dali.cpp @@ -0,0 +1,426 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include + +#include + +#include "widget_viewer_dali_generic.h" +#include "widget_viewer_dali.h" +#include "widget_dali_list.h" +#include "debug.h" + +#define WIDGET_DEFAULT_CLUSTER "user,created" +#define WIDGET_DEFAULT_CATEGORY "default" + +#define FAULT_RETRY_MAX_COUNT 3 + + using namespace Dali; + using namespace WidgetViewerDali; + +CWidgetManager* CWidgetManager::m_pInstance = NULL; + +static int widget_is_exists(const char *pkgname) +{ + int ret=1; + char *widget; + widget = widget_service_get_widget_id(pkgname); + if(!widget) { + ret = 0; + } + free(widget); + return ret; +} + +static int WidgetProviderWidgetEventCB(widget_h handler, widget_event_type_e event, void *data) +{ + CWidgetManager *pWidgeProvider = static_cast(data); + + if(handler == NULL) + { + return EXIT_FAILURE; + } + + if(event == WIDGET_EVENT_WIDGET_UPDATED) + { + DbgPrint("handler : %p, event : update[%d]", handler, event); + pWidgeProvider->WidgetEventUpdated(handler); + } + else if(event == WIDGET_EVENT_DELETED) + { + DbgPrint("handler : %p, event : deleted[%d]", handler, event); + pWidgeProvider->WidgetEventDeleted(handler); + } + else if(event == WIDGET_EVENT_HOLD_SCROLL) + { + DbgPrint("handler : %p, event : hold scroll[%d]", handler, event); + /*pWidgeProvider->WidgetEventScrollLocked(handler, false);*/ + } + else if(event == WIDGET_EVENT_RELEASE_SCROLL) + { + DbgPrint("handler : %p, event : release scroll[%d]", handler, event); + /*pWidgeProvider->WidgetEventScrollLocked(handler, true);*/ + } + else + { + DbgPrint("Not supported event : %d", event); + } + + return EXIT_SUCCESS; +} + +static void WidgetProviderWidgetActivateCB(widget_h handle, int ret, void *data) +{ + if(ret == 0) + { + /* Success */ + DbgPrint("handle : %p, Activate", handle); + } + else + { + ErrPrint("Failed to widget_activate[%x]", ret); + } +} + +static int WidgetProviderWidgetFaultCB(widget_fault_type_e event, const char *pkgname, const char *filename, const char *funcname, void *data) +{ + CWidgetManager *pWidgeProvider = static_cast(data); + + if(pWidgeProvider && event == WIDGET_FAULT_DEACTIVATED) + { + DbgPrint("event[%d], pkgname[%s]", event, pkgname); + widget_viewer_activate_faulted_widget(pkgname, WidgetProviderWidgetActivateCB, data); + + pWidgeProvider->WidgetFaulted(pkgname); + } + else if(pWidgeProvider && event == WIDGET_FAULT_PROVIDER_DISCONNECTED) + { + /*pWidgeProvider->WidgetProviderDisconnected();*/ + } + + return EXIT_SUCCESS; +} + +static void WidgetProviderWidgetAddCB(widget_h handle, int ret, void *data) +{ + CWidgetManager *pWidgeProvider = static_cast(data); + + if(pWidgeProvider == NULL) + { + ErrPrint("invalid add callback data"); + return; + } + + switch (ret) { + case WIDGET_ERROR_NONE: + DbgPrint("handle : %p, Add", handle); + pWidgeProvider->WidgetEventCreated(handle); + break; + case WIDGET_ERROR_ALREADY_EXIST: + /*ret = notification_status_message_post("Dynamic Box is already exists"); + if(ret != NOTIFICATION_ERROR_NONE) + { + ErrPrint("Failed to make notification"); + } + pWidgeProvider->WidgetEventDeleted(handle);*/ + break; + case -1: /*fall through*/ + /* Temporarly used */ + pWidgeProvider->WidgetEventDeleted(handle); + break; + default: + /*ErrPrint("Failed to widget_viewer_add_widget[%d][%p]", ret, handle); + widgetDataProvider->WidgetEventDeleted(handle); + + pWidgeProvider->WidgetAddFailed(handle, ret);*/ + break; + } +} + +static void WidgetProviderWidgetDeleteCB(widget_h handle, int ret, void *data) +{ + if(ret == 0) + { + /* Success */ + DbgPrint("handle : %p, Delete", handle); + CWidgetManager *pWidgeProvider = static_cast(data); + + pWidgeProvider->WidgetEventDeleted(handle); + } + else + { + ErrPrint("Failed to widget_viewer_delete_widget[%d]", ret); + } +} + +static void WidgetProviderWidgetPixmapAcquiredCB(widget_h handle, int pixmapId, void *data) +{ + CWidgetManager *pWidgeProvider = static_cast(data); + pWidgeProvider->EventPixmapAcquired(handle, (unsigned int)pixmapId); +} + +namespace WidgetViewerDali +{ +CWidgetManager::CWidgetManager() +{ + widget_viewer_set_option(WIDGET_OPTION_DIRECT_UPDATE, 1); + /* initialize widget, (XDisplay, prevent_overwrite, event_filtering, use_thread) */ + widget_viewer_init(ecore_x_display_get(), 1, 0.01f, 1); + widget_viewer_add_event_handler(WidgetProviderWidgetEventCB, this); + widget_viewer_add_fault_handler(WidgetProviderWidgetFaultCB, this); +} + +CWidgetManager::~CWidgetManager() +{ + widget_viewer_remove_fault_handler(WidgetProviderWidgetFaultCB); + widget_viewer_remove_event_handler(WidgetProviderWidgetEventCB); + + widget_viewer_fini(); +} + +EAPI void CWidgetManager::Initialize() +{ + DbgPrint("Initialize"); + mWidgetList = new CWidgetList; +} + +EAPI int CWidgetManager::AddWidget(unsigned int id, const char *pkgname, const char *name, widget_size_type_e type, const char *content, + const char *icon, int pid, double period, int allow_duplicate) +{ + if(1 == widget_is_exists(pkgname)) + { + void* handle = widget_viewer_add_widget(pkgname, NULL, WIDGET_DEFAULT_CLUSTER, WIDGET_DEFAULT_CATEGORY, period, type, WidgetProviderWidgetAddCB, this); + + if(handle != NULL) + { + CWidget widget = CWidget::New(id, handle, pkgname, type, period); + widget.SignalDeleted().Connect(this, &CWidgetManager::OnWidgetDeleted); + widget.SignalReload().Connect(this, &CWidgetManager::OnWidgetReload); + mWidgetList->Add(handle, widget); + + mSignalWidgetAdded.Emit(widget); + } + + return 0; + } + + return -1; +} + +bool CWidgetManager::OnWidgetDeleted(WidgetViewerDali::CWidget& widget) +{ + unsigned int id = widget.GetWidgetId(); + DbgPrint("widget[%d] deleted", id); + + if(1 == widget_is_exists(widget.GetPkgName().c_str())) + { + if(widget.GetWidgetHandle()) + { + int ret = widget_viewer_delete_widget(static_cast(widget.GetWidgetHandle()), WIDGET_DELETE_PERMANENTLY, WidgetProviderWidgetDeleteCB, this); + DbgPrint("call widget_viewer_delete_widget[%d]", ret); + } + } + else + { + mWidgetList->Remove(widget.GetWidgetHandle()); + } + + mSignalWidgetDeleted.Emit(widget); + + return true; +} + +bool CWidgetManager::OnWidgetReload(WidgetViewerDali::CWidget& widget) +{ + unsigned int id = widget.GetWidgetId(); + DbgPrint("widget[%d] reload", id); + + if(1 == widget_is_exists(widget.GetPkgName().c_str())) + { + widget_viewer_activate_faulted_widget(widget.GetPkgName().c_str(), WidgetProviderWidgetActivateCB, this); + + void* handle = widget_viewer_add_widget(widget.GetPkgName().c_str(), widget.GetPkgName().c_str(), WIDGET_DEFAULT_CLUSTER, WIDGET_DEFAULT_CATEGORY, widget.GetPeriod(), widget.GetSizeType(), WidgetProviderWidgetAddCB, this); + + if(widget.GetWidgetHandle()) + { + int ret = widget_viewer_delete_widget(static_cast(widget.GetWidgetHandle()), WIDGET_DELETE_PERMANENTLY, WidgetProviderWidgetDeleteCB, this); + DbgPrint("call widget_viewer_delete_widget[%d]", ret); + } + + if(handle != NULL) + { + mWidgetList->Update(widget.GetWidgetHandle(), handle, widget); + } + } + + return true; +} + +void CWidgetManager::WidgetEventCreated(void *handler) +{ + widget_h hWidget = static_cast(handler); + widget_viewer_set_visibility(hWidget, WIDGET_SHOW); +} + +void CWidgetManager::WidgetEventUpdated(void *handler) +{ + unsigned int id = mWidgetList->GetWidgetId(handler); + + DbgPrint("WidgetEventUpdated [%d]\n", id); + + if(!id) + { + ErrPrint("widget is not valid"); + return; + } + + CWidget widget = mWidgetList->GetWidget(id); + + unsigned int resource_id =0; + widget_viewer_get_resource_id(static_cast(handler), 0, &resource_id); + DbgPrint("resource_id, pixmap [%d,%d]", resource_id, widget.GetPixmap()); + if(resource_id != widget.GetPixmap()) + { + if(widget_viewer_acquire_resource_id(static_cast(handler), 0, WidgetProviderWidgetPixmapAcquiredCB, this) < 0) + { + DbgPrint("Failed to acquire pixmap\n"); + } + } + else + { + if(resource_id != 0) + { + widget.UpdateByPixmap(resource_id); + } + else + { + ErrPrint("Failed to get widget"); + return; + } + } +} + +void CWidgetManager::WidgetEventDeleted(void *handler) +{ + unsigned int id = mWidgetList->GetWidgetId(handler); + + DbgPrint("WidgetEventDeleted [%p] [%d]", handler, id); + + if(!id) + { + ErrPrint("widget is not valid"); + return; + } + + CWidget widget = mWidgetList->GetWidget(id); + + if(widget.IsFaulted()) + { + widget.OnFault(); + + if(widget.GetPixmap() != 0) { + widget_viewer_release_resource_id((widget_h)handler, 0, widget.GetPixmap()); + widget.SetPixmap(0); + } + } + else + { + if(widget.GetPixmap() != 0) { + widget_viewer_release_resource_id((widget_h)handler, 0, widget.GetPixmap()); + widget.SetPixmap(0); + } + + mWidgetList->Remove(widget.GetWidgetHandle()); + } + +} + + +void CWidgetManager::WidgetFaulted(const char *pkgname) +{ + if(!pkgname) + { + ErrPrint("invalid pkgname"); + return; + } + + std::vector list = mWidgetList->GetWidgetList(pkgname); + std::vector::iterator iter; + + if(list.empty()) + { + DbgPrint("No boxes that pkgname is[%s]", pkgname); + } + else + { + for (iter = list.begin(); iter != list.end(); iter++) + { + if(iter->IsFaulted()) + { + DbgPrint("Already faulted widget[%d][%s]", iter->GetWidgetId(), iter->GetPkgName().c_str()); + } + else + { + DbgPrint("Set faulted widget[%d][%s]", iter->GetWidgetId(), iter->GetPkgName().c_str()); + iter->SetFault(true); + } + } + } +} + +void CWidgetManager::EventPixmapAcquired(void *handler, unsigned int pixmapId) +{ + DbgPrint("EventPixmapAcquired [%p] [%d]\n", handler, pixmapId); + unsigned int id = mWidgetList->GetWidgetId(handler); + + if(!id) + { + ErrPrint("widget is not valid"); + return; + } + + CWidget widget = mWidgetList->GetWidget(id); + + if(widget.GetPixmap()) + { + ErrPrint("Release pixmap [%d]", widget.GetPixmap()); + widget_viewer_release_resource_id(static_cast(handler), 0, widget.GetPixmap()); + } + + if(pixmapId != 0) + { + widget.UpdateByPixmap(pixmapId); + } + else + { + ErrPrint("Failed to get widget"); + return; + } +} + +EAPI CWidgetManager* CWidgetManager::GetInstance() +{ + if(m_pInstance == NULL) + { + m_pInstance = new CWidgetManager; + } + + return m_pInstance; +} + +} diff --git a/widget_viewer_dali/widget_viewer_dali.pc.in b/widget_viewer_dali/widget_viewer_dali.pc.in new file mode 100755 index 0000000..f93096f --- /dev/null +++ b/widget_viewer_dali/widget_viewer_dali.pc.in @@ -0,0 +1,12 @@ +prefix=@PREFIX@ +exec_prefix=@EXEC_PREFIX@ +libdir=@LIBDIR@ +includedir=@INCLUDEDIR@ + +Name: widget_viewer_dali +Description: Support development of the widget Viewer DALi library +Version: @VERSION@ +Requires: widget_service widget_viewer +Libs: -L${libdir} -lwidget_viewer_dali +Cflags: -I${includedir} +cppflags: -I${includedir} diff --git a/widget_viewer_evas/doc/widget_viewer_evas_doc.h b/widget_viewer_evas/doc/widget_viewer_evas_doc.h index 8fbaef5..0fdcbe1 100644 --- a/widget_viewer_evas/doc/widget_viewer_evas_doc.h +++ b/widget_viewer_evas/doc/widget_viewer_evas_doc.h @@ -29,4 +29,8 @@ * * First of all, the Tizen Platform uses the EFL as a core UIFW. * So this API set also based on the EFL. + * + * @section CAPI_WIDGET_VIEWER_EVAS_MODULE_FEATURE Related Features + * This API is related with the following feature: + * - http://tizen.org/feature/shell.appwidget */ diff --git a/widget_viewer_evas/include/widget_viewer_evas.h b/widget_viewer_evas/include/widget_viewer_evas.h index 48540bd..68982f2 100644 --- a/widget_viewer_evas/include/widget_viewer_evas.h +++ b/widget_viewer_evas/include/widget_viewer_evas.h @@ -48,21 +48,91 @@ extern "C" { /** * @since_tizen 2.3.1 - * @brief Event names for smart callback of widget events. You can listen some events from widget by calling evas_object_smart_callback_add. + * @brief Event name for smart callback of widget events: Widget creation is aborted * @see #widget_evas_event_info_s * @see evas_object_smart_callback_add */ -#define WIDGET_SMART_SIGNAL_WIDGET_CREATE_ABORTED "widget,create,aborted" /**< Widget creation is aborted */ -#define WIDGET_SMART_SIGNAL_WIDGET_CREATED "widget,created" /**< Widget is created */ -#define WIDGET_SMART_SIGNAL_WIDGET_RESIZE_ABORTED "widget,resize,aborted" /**< Resizing widget is aborted */ -#define WIDGET_SMART_SIGNAL_WIDGET_RESIZED "widget,resized" /**< Widget is resized */ -#define WIDGET_SMART_SIGNAL_WIDGET_FAULTED "widget,faulted" /**< Widget has faulted */ -#define WIDGET_SMART_SIGNAL_UPDATED "updated" /**< Widget content is updated */ -#define WIDGET_SMART_SIGNAL_EXTRA_INFO_UPDATED "info,updated" /**< Widget extra info is updated */ -#define WIDGET_SMART_SIGNAL_PROVIDER_DISCONNECTED "provider,disconnected" /**< Provider is disconnected */ -#define WIDGET_SMART_SIGNAL_CONTROL_SCROLLER "control,scroller" /**< Control Scroller */ -#define WIDGET_SMART_SIGNAL_WIDGET_DELETED "widget,deleted" /**< Widget is deleted */ -#define WIDGET_SMART_SIGNAL_PERIOD_CHANGED "widget,period,changed" /**< Period is changed */ +#define WIDGET_SMART_SIGNAL_WIDGET_CREATE_ABORTED "widget,create,aborted" + +/** + * @since_tizen 2.3.1 + * @brief Event name for smart callback of widget events: Widget is created + * @see #widget_evas_event_info_s + * @see evas_object_smart_callback_add + */ +#define WIDGET_SMART_SIGNAL_WIDGET_CREATED "widget,created" + +/** + * @since_tizen 2.3.1 + * @brief Event name for smart callback of widget events: Resizing widget is aborted + * @see #widget_evas_event_info_s + * @see evas_object_smart_callback_add + */ +#define WIDGET_SMART_SIGNAL_WIDGET_RESIZE_ABORTED "widget,resize,aborted" + +/** + * @since_tizen 2.3.1 + * @brief Event name for smart callback of widget events: Widget is resized + * @see #widget_evas_event_info_s + * @see evas_object_smart_callback_add + */ +#define WIDGET_SMART_SIGNAL_WIDGET_RESIZED "widget,resized" + +/** + * @since_tizen 2.3.1 + * @brief Event name for smart callback of widget events: Widget has faulted + * @see #widget_evas_event_info_s + * @see evas_object_smart_callback_add + */ +#define WIDGET_SMART_SIGNAL_WIDGET_FAULTED "widget,faulted" + +/** + * @since_tizen 2.3.1 + * @brief Event name for smart callback of widget events: Widget content is updated + * @see #widget_evas_event_info_s + * @see evas_object_smart_callback_add + */ +#define WIDGET_SMART_SIGNAL_UPDATED "updated" + +/** + * @since_tizen 2.3.1 + * @brief Event name for smart callback of widget events: Widget extra info is updated + * @see #widget_evas_event_info_s + * @see evas_object_smart_callback_add + */ +#define WIDGET_SMART_SIGNAL_EXTRA_INFO_UPDATED "info,updated" + +/** + * @since_tizen 2.3.1 + * @brief Event name for smart callback of widget events: Provider is disconnected + * @see #widget_evas_event_info_s + * @see evas_object_smart_callback_add + */ +#define WIDGET_SMART_SIGNAL_PROVIDER_DISCONNECTED "provider,disconnected" + +/** + * @since_tizen 2.3.1 + * @brief Event name for smart callback of widget events: Control Scroller + * @see #widget_evas_event_info_s + * @see evas_object_smart_callback_add + */ +#define WIDGET_SMART_SIGNAL_CONTROL_SCROLLER "control,scroller" + +/** + * @since_tizen 2.3.1 + * @brief Event name for smart callback of widget events: Widget is deleted + * @see #widget_evas_event_info_s + * @see evas_object_smart_callback_add + */ +#define WIDGET_SMART_SIGNAL_WIDGET_DELETED "widget,deleted" + +/** + * @since_tizen 2.3.1 + * @brief Event name for smart callback of widget events: Period is changed + * @see #widget_evas_event_info_s + * @see evas_object_smart_callback_add + */ +#define WIDGET_SMART_SIGNAL_PERIOD_CHANGED "widget,period,changed" /** * @since_tizen 2.3.1 @@ -285,7 +355,7 @@ extern double widget_viewer_evas_get_period(Evas_Object *widget); */ extern void widget_viewer_evas_cancel_click_event(Evas_Object *widget); -/* +/** * @brief Hides the preview of the widget * @remarks This function should be called right after create the widget object before resizing it * @since_tizen 2.3.1 diff --git a/widget_viewer_evas/include/widget_viewer_evas_internal.h b/widget_viewer_evas/include/widget_viewer_evas_internal.h index 2e12237..5faae3b 100644 --- a/widget_viewer_evas/include/widget_viewer_evas_internal.h +++ b/widget_viewer_evas/include/widget_viewer_evas_internal.h @@ -34,6 +34,8 @@ extern "C" { #define WIDGET_VIEWER_EVAS_SHARED_CONTENT 0x0002 /**< Multiple instances will share the content of one real instance */ #define WIDGET_VIEWER_EVAS_SUPPORT_GBAR 0x0004 /**< GBAR will be used */ +#define WIDGET_VIEWER_EVAS_DISABLE_SCROLLER 0x4000 + typedef enum widget_access_result { WIDGET_ACCESS_RESULT_DONE = 0x00, WIDGET_ACCESS_RESULT_FIRST = 0x01, @@ -269,6 +271,7 @@ extern int widget_viewer_evas_set_preview_image(Evas_Object *widget, widget_size */ extern int widget_viewer_evas_hide_overlay(Evas_Object *widget); +extern int widget_viewer_evas_hide_faulted_overlay_once(Evas_Object *widget); #ifdef __cplusplus } #endif diff --git a/widget_viewer_evas/src/widget_viewer_evas.c b/widget_viewer_evas/src/widget_viewer_evas.c index 4e5efc2..c7e72bc 100644 --- a/widget_viewer_evas/src/widget_viewer_evas.c +++ b/widget_viewer_evas/src/widget_viewer_evas.c @@ -78,7 +78,6 @@ #define _(str) gettext(str) #endif - #if !defined(DbgPrint) #define DbgPrint(format, arg...) SECURE_LOGD(format, ##arg) #endif @@ -156,6 +155,12 @@ int errno; */ #define CLICK_REGION WIDGET_CONF_CLICK_REGION +#if defined(__LP64__) || defined(_LP64) +#define PTR_TYPE(a) ((long long)(a)) +#else +#define PTR_TYPE(a) ((int)(a)) +#endif + static struct { Evas_Smart_Class sc; Evas_Smart *smart; @@ -183,8 +188,9 @@ static struct { unsigned int render_animator:1; unsigned int auto_render_selector:1; unsigned int skip_acquire:1; + unsigned int disable_internal_scroller: 1; - unsigned int reserved:18; + unsigned int reserved:17; } field; unsigned int mask; } conf; @@ -195,6 +201,8 @@ static struct { Eina_List *gbar_dirty_objects; Eina_List *subscribed_category_list; Eina_List *subscribed_group_list; + Eina_List *updated_pixmap_list; + Eina_List *updated_pixmap_lock_list; int initialized; } s_info = { @@ -216,6 +224,8 @@ static struct { .gbar_dirty_objects = NULL, .subscribed_category_list = NULL, .subscribed_group_list = NULL, + .updated_pixmap_list = NULL, + .updated_pixmap_lock_list = NULL, .initialized = 0, }; @@ -355,7 +365,11 @@ struct widget_data { unsigned int hide_overlay_manually:1; - unsigned int reserved: 1; + /** + * @note + * Do not raise up the overlay for faulted. + */ + unsigned int hide_faulted_overlay: 1; } field; /* Do we really have the performance loss because of bit fields? */ unsigned int flags; @@ -974,11 +988,6 @@ struct widget_data *widget_unref(struct widget_data *data) data->overlay_timer = NULL; } - if (data->stage) { - DbgPrint("Remove Stage\n"); - evas_object_del(data->stage); - } - if (data->widget_layout) { Evas_Object *content; @@ -1005,6 +1014,8 @@ struct widget_data *widget_unref(struct widget_data *data) DbgPrint("Remove WIDGET Layout\n"); evas_object_del(data->widget_layout); + } else { + DbgPrint("Layout is already deleted\n"); } if (data->gbar_layout) { @@ -1020,6 +1031,15 @@ struct widget_data *widget_unref(struct widget_data *data) } DbgPrint("Remove GBAR Layout\n"); evas_object_del(data->gbar_layout); + } else { + DbgPrint("GBar layout is already deleted\n"); + } + + if (data->stage) { + DbgPrint("Remove Stage\n"); + evas_object_del(data->stage); + } else { + DbgPrint("Stage is already deleted\n"); } if (data->widget_fb) { @@ -2793,6 +2813,20 @@ static void gbar_create_pixmap_object(struct widget_data *data) } } +static void gbar_layout_del_cb(void *_data, Evas *e, Evas_Object *obj, void *event_info) +{ + struct widget_data *data = _data; + DbgPrint("GBar layout is deleted(%p - %p)\n", data->gbar_layout, obj); + /** + * @note + * We should not access the data->gbar_layout in this function. + * We can only believe the "obj" now.. + */ + evas_object_smart_member_del(obj); + evas_object_clip_unset(obj); + data->gbar_layout = NULL; +} + static void __widget_create_gbar_cb(struct widget *handle, int ret, void *cbdata) { struct widget_data *data = cbdata; @@ -2852,6 +2886,7 @@ static void __widget_create_gbar_cb(struct widget *handle, int ret, void *cbdata widget_unref(data); return; } + evas_object_event_callback_add(data->gbar_layout, EVAS_CALLBACK_DEL, gbar_layout_del_cb, data); if (elm_layout_file_set(data->gbar_layout, WIDGET_VIEWER_EVAS_RESOURCE_EDJ, WIDGET_VIEWER_EVAS_RESOURCE_GBAR) == EINA_FALSE) { ErrPrint("Failed to load edje object: %s(%s)\n", WIDGET_VIEWER_EVAS_RESOURCE_EDJ, WIDGET_VIEWER_EVAS_RESOURCE_GBAR); @@ -3187,7 +3222,7 @@ static void __widget_up_cb(void *cbdata, Evas *e, Evas_Object *obj, void *event_ data = widget_unref(data); } } else if (data->is.field.cancel_click == CANCEL_DISABLED) { - ret = widget_viewer_send_click_event(data->handle, minfo.x, minfo.y); + ret = widget_viewer_send_click_event(data->handle, WIDGET_VIEWER_CLICK_BUTTON_LEFT, minfo.x, minfo.y); } } @@ -3513,6 +3548,28 @@ static void __widget_overlay_clicked_cb(void *cbdata, Evas_Object *obj, const ch } } +static void widget_layout_del_cb(void *_data, Evas *e, Evas_Object *obj, void *event_info) +{ + struct widget_data *data = _data; + DbgPrint("Layout is deleted (%p - %p)\n", data->widget_layout, obj); + evas_object_smart_member_del(obj); + evas_object_clip_unset(obj); + data->widget_layout = NULL; +} + +static void stage_del_cb(void *_data, Evas *e, Evas_Object *obj, void *event_info) +{ + struct widget_data *data = _data; + + DbgPrint("Stage is deleted (%p - %p)\n", data->stage, obj); + if (data->widget_layout) { + evas_object_clip_unset(data->widget_layout); + } + + evas_object_smart_member_del(obj); + data->stage = NULL; +} + static void __widget_data_setup(struct widget_data *data) { data->e = evas_object_evas_get(data->widget); @@ -3551,7 +3608,7 @@ static void __widget_data_setup(struct widget_data *data) return; } - if (s_info.conf.field.is_scroll_x || s_info.conf.field.is_scroll_y) { + if (!s_info.conf.field.disable_internal_scroller && (s_info.conf.field.is_scroll_x || s_info.conf.field.is_scroll_y)) { Evas_Object *scroller; scroller = elm_scroller_add(data->parent); if (scroller) { @@ -3606,6 +3663,8 @@ static void __widget_data_setup(struct widget_data *data) evas_object_smart_member_add(data->widget_layout, data->widget); evas_object_clip_set(data->widget_layout, data->stage); + evas_object_event_callback_add(data->widget_layout, EVAS_CALLBACK_DEL, widget_layout_del_cb, data); + evas_object_event_callback_add(data->stage, EVAS_CALLBACK_DEL, stage_del_cb, data); } static Eina_Bool renderer_cb(void *_data) @@ -3638,7 +3697,7 @@ static void append_widget_dirty_object_list(struct widget_data *data, int idx) } if (widget_viewer_get_visibility(data->handle) != WIDGET_SHOW) { - DbgPrint("Box is not visible\n"); + DbgPrint("Box[%s] is not visible\n", data->widget_id); return; } @@ -3899,7 +3958,7 @@ static void __widget_del(Evas_Object *widget) } else { delete_type = WIDGET_DELETE_TEMPORARY; } - DbgPrint("Send delete request (0x%X)\n", delete_type); + DbgPrint("Send delete request (0x%X) - %s\n", delete_type, data->widget_id); if (data->is.field.created) { if (widget_viewer_delete_widget(data->handle, delete_type, __widget_destroy_widget_cb, widget_ref(data)) < 0) { @@ -4761,6 +4820,12 @@ static void acquire_widget_pixmap_cb(struct widget *handle, int pixmap, void *cb if (!s_info.conf.field.skip_acquire) { free(acquire_data); } + + if (WIDGET_CONF_ENABLE_RESOURCE_LOCK) { + if (!eina_list_data_find(s_info.updated_pixmap_list, (void *)(PTR_TYPE(pixmap)))) { + s_info.updated_pixmap_list = eina_list_append(s_info.updated_pixmap_list, (void *)(PTR_TYPE(pixmap))); + } + } } static void __widget_update_pixmap_object(struct widget_data *data, Evas_Object *widget_content, int w, int h) @@ -4769,53 +4834,71 @@ static void __widget_update_pixmap_object(struct widget_data *data, Evas_Object struct acquire_data *acquire_data; if (data->widget_latest_idx == WIDGET_PRIMARY_BUFFER) { - unsigned int resource_id; + unsigned int resource_id = 0u; + + if (widget_viewer_get_resource_id(data->handle, 0, &resource_id) < 0) { + ErrPrint("Failed to get resource_id\n"); + } else if (resource_id > 0) { + if (data->widget_pixmap == resource_id) { + if (data->widget_extra) { + /* Just replace the pixmap in this case, do not release old pixmap */ + replace_pixmap(NULL, 0, widget_content, data->widget_pixmap); + } + + update_widget_pixmap(widget_content, w, h); - widget_viewer_get_resource_id(data->handle, 0, &resource_id); - if (data->widget_pixmap == resource_id) { - if (data->widget_extra) { - /* Just replace the pixmap in this case, do not release old pixmap */ - replace_pixmap(NULL, 0, widget_content, data->widget_pixmap); + if (WIDGET_CONF_ENABLE_RESOURCE_LOCK) { + if (!eina_list_data_find(s_info.updated_pixmap_list, (void *)(PTR_TYPE(resource_id)))) { + s_info.updated_pixmap_list = eina_list_append(s_info.updated_pixmap_list, (void *)(PTR_TYPE(resource_id))); + } + } + return; } - update_widget_pixmap(widget_content, w, h); - return; - } + if (s_info.conf.field.skip_acquire && resource_id != 0) { + struct acquire_data local_acquire_data = { + .data = widget_ref(data), + .content = widget_content, + .w = w, + .h = h, + }; - if (s_info.conf.field.skip_acquire && resource_id != 0) { - struct acquire_data local_acquire_data = { - .data = widget_ref(data), - .content = widget_content, - .w = w, - .h = h, - }; + /** + * @note + * Resource lock will be acquired from below callback. + */ + acquire_widget_pixmap_cb(data->handle, resource_id, &local_acquire_data); + return; + } - acquire_widget_pixmap_cb(data->handle, resource_id, &local_acquire_data); - return; - } + if (data->is.field.widget_pixmap_acquire_requested) { + DbgPrint("Pixmap is not acquired (in-process)\n"); + return; + } - if (data->is.field.widget_pixmap_acquire_requested) { - DbgPrint("Pixmap is not acquired\n"); - return; - } + acquire_data = malloc(sizeof(*acquire_data)); + if (!acquire_data) { + ErrPrint("malloc: %d\n", errno); + return; + } - acquire_data = malloc(sizeof(*acquire_data)); - if (!acquire_data) { - ErrPrint("malloc: %d\n", errno); - return; - } + acquire_data->data = widget_ref(data); + acquire_data->content = widget_content; + acquire_data->w = w; + acquire_data->h = h; - acquire_data->data = widget_ref(data); - acquire_data->content = widget_content; - acquire_data->w = w; - acquire_data->h = h; + ret = widget_viewer_acquire_resource_id(data->handle, 0, acquire_widget_pixmap_cb, acquire_data); + if (ret != WIDGET_ERROR_NONE) { + widget_unref(data); + free(acquire_data); + } else { + data->is.field.widget_pixmap_acquire_requested = 1; + } - ret = widget_viewer_acquire_resource_id(data->handle, 0, acquire_widget_pixmap_cb, acquire_data); - if (ret != WIDGET_ERROR_NONE) { - widget_unref(data); - free(acquire_data); - } else { - data->is.field.widget_pixmap_acquire_requested = 1; + /** + * @note + * Resource lock should be acquired from acquire_widget_pixmap_cb + */ } } else { if (!data->widget_extra) { @@ -4825,7 +4908,13 @@ static void __widget_update_pixmap_object(struct widget_data *data, Evas_Object replace_pixmap(NULL, 0, widget_content, data->widget_extra[data->widget_latest_idx]); update_widget_pixmap(widget_content, w, h); + if (WIDGET_CONF_ENABLE_RESOURCE_LOCK) { + if (!eina_list_data_find(s_info.updated_pixmap_list, (void *)(PTR_TYPE(data->widget_extra[data->widget_latest_idx])))) { + s_info.updated_pixmap_list = eina_list_append(s_info.updated_pixmap_list, (void *)(PTR_TYPE(data->widget_extra[data->widget_latest_idx]))); + } + } } + } static int widget_system_created(struct widget *handle, struct widget_data *data) @@ -4921,11 +5010,21 @@ static void __widget_created_cb(struct widget *handle, int ret, void *cbdata) if (!data->is.field.faulted) { data->is.field.faulted = 1; + + DbgPrint("Display tap to load (%p) [%s]\n", data, data->widget_id); + smart_callback_call(data, WIDGET_SMART_SIGNAL_WIDGET_CREATE_ABORTED, &fault_event); + __widget_overlay_faulted(data); - } + } else { + smart_callback_call(data, WIDGET_SMART_SIGNAL_WIDGET_CREATE_ABORTED, &fault_event); - DbgPrint("Display tap to load (%p) [%s]\n", data, data->widget_id); - smart_callback_call(data, WIDGET_SMART_SIGNAL_WIDGET_CREATE_ABORTED, &fault_event); + /** + * @note + * While processing the faulted smart callback, the user can request hide_faulted_overlay + * So we should reset it from here. in other cases, the widget_overlay_faulted function deals with this. + */ + data->is.field.hide_faulted_overlay = 0; + } ret = WIDGET_ERROR_FAULT; } else { @@ -5318,6 +5417,12 @@ static void __widget_overlay_faulted(struct widget_data *data) Evas_Object *overlay; widget_type_e widget_type; + if (data->is.field.hide_faulted_overlay == 1) { + DbgPrint("Faulted overlay is hidden by request (%s)\n", data->widget_id); + data->is.field.hide_faulted_overlay = 0; + return; + } + if (data->is.field.widget_overlay_loaded) { __widget_overlay_disable(data, 1, 1); } @@ -6668,11 +6773,14 @@ static int widget_fault_handler(enum widget_fault_type fault, const char *pkgnam if (!strcmp(data->widget_id, pkgname)) { DbgPrint("Faulted: %s (%p)\n", pkgname, data); data->is.field.faulted = 1; - __widget_overlay_faulted(data); + info.error = WIDGET_ERROR_FAULT; info.widget_app_id = data->widget_id; info.event = WIDGET_FAULT_DEACTIVATED; + smart_callback_call(data, WIDGET_SMART_SIGNAL_WIDGET_FAULTED, &info); + + __widget_overlay_faulted(data); } } break; @@ -6686,11 +6794,14 @@ static int widget_fault_handler(enum widget_fault_type fault, const char *pkgnam if (!strcmp(data->widget_id, pkgname)) { DbgPrint("Disconnected: %s (%p)\n", pkgname, data); data->is.field.faulted = 1; - __widget_overlay_faulted(data); + info.error = WIDGET_ERROR_FAULT; info.widget_app_id = data->widget_id; info.event = WIDGET_FAULT_PROVIDER_DISCONNECTED; + smart_callback_call(data, WIDGET_SMART_SIGNAL_PROVIDER_DISCONNECTED, &info); + + __widget_overlay_faulted(data); } } break; @@ -6700,6 +6811,32 @@ static int widget_fault_handler(enum widget_fault_type fault, const char *pkgnam return 0; } +static void evas_render_post_cb(void *data, Evas *e, void *event_info) +{ + widget_resource_lock_t handle; + + EINA_LIST_FREE(s_info.updated_pixmap_lock_list, handle) { + widget_service_release_resource_lock(handle); + widget_service_destroy_resource_lock(handle, 0); + } +} + +static void evas_render_pre_cb(void *data, Evas *e, void *event_info) +{ + widget_resource_lock_t handle; + void *pixmap; + + EINA_LIST_FREE(s_info.updated_pixmap_list, pixmap) { + handle = widget_service_create_resource_lock((unsigned int)(PTR_TYPE(pixmap)), WIDGET_LOCK_READ); + if (handle) { + widget_service_acquire_resource_lock(handle); + s_info.updated_pixmap_lock_list = eina_list_append(s_info.updated_pixmap_lock_list, handle); + } else { + ErrPrint("Failed to create a resource lock\n"); + } + } +} + EAPI int widget_viewer_evas_init(Evas_Object *win) { int ret; @@ -6755,6 +6892,15 @@ EAPI int widget_viewer_evas_init(Evas_Object *win) s_info.conf.field.force_to_buffer = 0; s_info.win = win; + if (WIDGET_CONF_ENABLE_RESOURCE_LOCK) { + Evas *e; + e = evas_object_evas_get(win); + if (e) { + evas_event_callback_add(e, EVAS_CALLBACK_RENDER_PRE, evas_render_pre_cb, NULL); + evas_event_callback_add(e, EVAS_CALLBACK_RENDER_POST, evas_render_post_cb, NULL); + } + } + return ret; } @@ -6767,6 +6913,15 @@ EAPI int widget_viewer_evas_fini(void) } if (s_info.initialized) { + if (WIDGET_CONF_ENABLE_RESOURCE_LOCK && s_info.win) { + Evas *e; + e = evas_object_evas_get(s_info.win); + if (e) { + evas_event_callback_del(e, EVAS_CALLBACK_RENDER_PRE, evas_render_pre_cb); + evas_event_callback_del(e, EVAS_CALLBACK_RENDER_POST, evas_render_post_cb); + } + } + widget_viewer_remove_event_handler(widget_event_handler); widget_viewer_remove_fault_handler(widget_fault_handler); widget_viewer_fini(); @@ -7034,6 +7189,10 @@ EAPI int widget_viewer_evas_set_option(widget_evas_conf_e type, int value) s_info.conf.field.skip_acquire = !!value; DbgPrint("Turn %s skip-acquire option\n", s_info.conf.field.skip_acquire ? "on" : "off"); break; + case WIDGET_VIEWER_EVAS_DISABLE_SCROLLER: + s_info.conf.field.disable_internal_scroller = !!value; + DbgPrint("Turn %s internal_scroller option\n", s_info.conf.field.disable_internal_scroller ? "off" : "on"); + break; default: ret = WIDGET_ERROR_INVALID_PARAMETER; break; @@ -8277,4 +8436,54 @@ EAPI int widget_viewer_evas_hide_overlay(Evas_Object *widget) return WIDGET_ERROR_NONE; } +/** + * @note + * This function must has to be called after the object is faulted. + * And this will not reset the faulted flag. it just dislable the faulted overlay if it is exists. + * + * The best usage of this function is called from smart-callback. + * Any faulted smart callback can call this. + * Then the widget_viewer_evas will check the flag to decide whether enable the faulted overlay or not. + */ +EAPI int widget_viewer_evas_hide_faulted_overlay_once(Evas_Object *widget) +{ + struct widget_data *data; + + if (!is_widget_feature_enabled()) { + return WIDGET_ERROR_NOT_SUPPORTED; + } + + if (!s_info.initialized) { + return WIDGET_ERROR_FAULT; + } + + data = get_smart_data(widget); + if (!data) { + ErrPrint("Invalid object\n"); + return WIDGET_ERROR_INVALID_PARAMETER; + } + + if (data->is.field.faulted == 0) { + ErrPrint("Object is not faulted\n"); + return WIDGET_ERROR_INVALID_PARAMETER; + } + + /** + * @note + * If the overlay (faulted) is already enabled, + * Turn it off first. + */ + if (data->is.field.widget_overlay_loaded) { + DbgPrint("Faulted overlay is disabled\n"); + __widget_overlay_disable(data, 1, 1); + } + + /** + * This flag will be checked before enable the faulted overlay. + * And this will be reset'd right after ignore the faulted overlay. + */ + data->is.field.hide_faulted_overlay = 1; + return WIDGET_ERROR_NONE; +} + /* End of a file */ diff --git a/widget_viewer_sdk/include/debug.h b/widget_viewer_sdk/include/debug.h index a6563ee..483309e 100644 --- a/widget_viewer_sdk/include/debug.h +++ b/widget_viewer_sdk/include/debug.h @@ -19,9 +19,9 @@ #define ErrPrint(format, arg...) SECURE_LOGE(format, ##arg) #else extern FILE *__file_log_fp; -#define DbgPrint(format, arg...) do { fprintf(__file_log_fp, "[LOG] [%s/%s:%d] " format, util_basename(__FILE__), __func__, __LINE__, ##arg); fflush(__file_log_fp); } while (0) +#define DbgPrint(format, arg...) do { fprintf(__file_log_fp, "[LOG] [%s/%s:%d] " format, widget_util_basename(__FILE__), __func__, __LINE__, ##arg); fflush(__file_log_fp); } while (0) -#define ErrPrint(format, arg...) do { fprintf(__file_log_fp, "[ERR] [%s/%s:%d] " format, util_basename(__FILE__), __func__, __LINE__, ##arg); fflush(__file_log_fp); } while (0) +#define ErrPrint(format, arg...) do { fprintf(__file_log_fp, "[ERR] [%s/%s:%d] " format, widget_util_basename(__FILE__), __func__, __LINE__, ##arg); fflush(__file_log_fp); } while (0) #endif diff --git a/widget_viewer_sdk/org.tizen.widget_viewer_sdk.efl b/widget_viewer_sdk/org.tizen.widget_viewer_sdk.efl index f5f5250..7179ee4 100644 --- a/widget_viewer_sdk/org.tizen.widget_viewer_sdk.efl +++ b/widget_viewer_sdk/org.tizen.widget_viewer_sdk.efl @@ -8,7 +8,6 @@ org.tizen.widget_viewer_sdk sound_server rw---- ------ org.tizen.widget_viewer_sdk syspopup::db rw---- ------ org.tizen.widget_viewer_sdk dbus rwx--- ------ org.tizen.widget_viewer_sdk pulseaudio rwxat- ------ -org.tizen.widget_viewer_sdk ail::db rw---- ------ org.tizen.widget_viewer_sdk connman r----- ------ org.tizen.widget_viewer_sdk system rwx--- ------ org.tizen.widget_viewer_sdk immvibed rw---- ------ @@ -16,15 +15,9 @@ org.tizen.widget_viewer_sdk svi-data r-x--- ------ org.tizen.widget_viewer_sdk org.tizen.clocksetting rwx--- ------ org.tizen.widget_viewer_sdk org.tizen.clocksetting::default-resources r-x--- ------ org.tizen.widget_viewer_sdk e17 r-x--- ------ -org.tizen.widget_viewer_sdk system::vconf rwx--- ------ -org.tizen.widget_viewer_sdk system::vconf_setting rw---- ------ -org.tizen.widget_viewer_sdk system::vconf_inhouse rw---- ------ -org.tizen.widget_viewer_sdk system::vconf_multimedia rw---- ------ org.tizen.widget_viewer_sdk deviced rwx--- ------ org.tizen.widget_viewer_sdk deviced::display rw---- ------ -org.tizen.widget_viewer_sdk testmode::vconf r----- ------ org.tizen.widget_viewer_sdk data-provider-master::db rw---- ------ -org.tizen.widget_viewer_sdk data-provider-master::share rwxat- ------ org.tizen.widget_viewer_sdk data-provider-master::data r-x--- ------ org.tizen.widget_viewer_sdk data-provider-master::client rw---- ------ org.tizen.widget_viewer_sdk data-provider-master rw---- ------ @@ -38,3 +31,4 @@ dbus org.tizen.widget_viewer_sdk rwx--- ------ system org.tizen.widget_viewer_sdk -w---- ------ org.tizen.data-provider-slave org.tizen.widget_viewer_sdk rwx--- ------ org.tizen.widget_viewer_sdk system::homedir rwx--- ------ +org.tizen.widget_viewer_sdk tizen::vconf::setting::admin r----l ------ diff --git a/widget_viewer_sdk/src/main.c b/widget_viewer_sdk/src/main.c index c1d6861..a4032c1 100644 --- a/widget_viewer_sdk/src/main.c +++ b/widget_viewer_sdk/src/main.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -41,6 +42,9 @@ int errno; #define LAZY_WATCH_TIME 3.0f #define CR 13 #define LF 10 +#if !defined(VCONFKEY_WMS_CLOCKS_SET_IDLE) +#define VCONFKEY_WMS_CLOCKS_SET_IDLE "db/wms/clocks_set_idle" +#endif static struct info { int w; -- 2.7.4