From: t.dakowicz Date: Fri, 4 Sep 2015 15:25:46 +0000 (+0200) Subject: Implemented ZoomUI service X-Git-Tag: submit/tizen_tv/20151011.233324 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Ftags%2Fsubmit%2Ftizen_tv%2F20151011.233324;p=profile%2Ftv%2Fapps%2Fweb%2Fbrowser.git Implemented ZoomUI service [Issue#] https://bugs.tizen.org/jira/browse/TT-133 [Problem] Page zoom implementation [Cause] N/A [Solution] New ZoomUI service [Verify] Open a new page -> MoreMenu -> Screen Zoom Check if zooming/navigating the page works. Change-Id: I1c47d5fd37927e0a8f88f8952af1350791eac02f --- diff --git a/core/AbstractWebEngine/AbstractWebEngine.h b/core/AbstractWebEngine/AbstractWebEngine.h index ea0e663..99f19c9 100644 --- a/core/AbstractWebEngine/AbstractWebEngine.h +++ b/core/AbstractWebEngine/AbstractWebEngine.h @@ -275,6 +275,17 @@ public: virtual bool isDesktopMode() const = 0; /** + * Sets an absolute scroll of the given view. + * + * Both values are from zero to the contents size minus the viewport + * size. + * + * @param x horizontal position to scroll + * @param y vertical position to scroll + */ + virtual void scrollView(const int& dx, const int& dy) = 0; + + /** * FavIcon of current page changed */ boost::signals2::signal)> favIconChanged; diff --git a/services/CMakeLists.txt b/services/CMakeLists.txt index 975dd93..8ff9167 100644 --- a/services/CMakeLists.txt +++ b/services/CMakeLists.txt @@ -14,3 +14,4 @@ add_subdirectory(HistoryService) add_subdirectory(PlatformInputManager) add_subdirectory(SessionStorage) add_subdirectory(BookmarkService) +add_subdirectory(ZoomUI) diff --git a/services/MoreMenuUI/MoreMenuUI.cpp b/services/MoreMenuUI/MoreMenuUI.cpp index a550e06..f623118 100644 --- a/services/MoreMenuUI/MoreMenuUI.cpp +++ b/services/MoreMenuUI/MoreMenuUI.cpp @@ -529,6 +529,7 @@ void MoreMenuUI::_thumbSelected(void* data, Evas_Object*, void*) break; #endif case SCREEN_ZOOM: + itemData->moreMenuUI->zoomUIClicked(); break; #ifdef START_MINIBROWSER_ENABLED case START_MINIBROWSER: diff --git a/services/MoreMenuUI/MoreMenuUI.h b/services/MoreMenuUI/MoreMenuUI.h index f60d7af..72ce2d6 100644 --- a/services/MoreMenuUI/MoreMenuUI.h +++ b/services/MoreMenuUI/MoreMenuUI.h @@ -85,6 +85,7 @@ public: boost::signals2::signal historyUIClicked; boost::signals2::signal settingsClicked; boost::signals2::signal closeMoreMenuClicked; + boost::signals2::signal zoomUIClicked; boost::signals2::signal switchToMobileMode; boost::signals2::signal switchToDesktopMode; boost::signals2::signal isBookmark; diff --git a/services/SimpleUI/CMakeLists.txt b/services/SimpleUI/CMakeLists.txt index fe55ea3..02f8aed 100644 --- a/services/SimpleUI/CMakeLists.txt +++ b/services/SimpleUI/CMakeLists.txt @@ -34,6 +34,7 @@ include_directories(${CMAKE_SOURCE_DIR}/services/HistoryUI) include_directories(${CMAKE_SOURCE_DIR}/services/MainUI) include_directories(${CMAKE_SOURCE_DIR}/services/SettingsUI) include_directories(${CMAKE_SOURCE_DIR}/services/TabUI) +include_directories(${CMAKE_SOURCE_DIR}/services/ZoomUI) include_directories(${CMAKE_SOURCE_DIR}/services/PlatformInputManager) include_directories(${CMAKE_SOURCE_DIR}/services/SessionStorage) @@ -52,6 +53,7 @@ add_dependencies(${PROJECT_NAME} MainUI) add_dependencies(${PROJECT_NAME} HistoryUI) add_dependencies(${PROJECT_NAME} TabUI) add_dependencies(${PROJECT_NAME} SettingsUI) +add_dependencies(${PROJECT_NAME} ZoomUI) add_dependencies(${PROJECT_NAME} PlatformInputManager) add_dependencies(${PROJECT_NAME} SessionStorage) target_link_libraries(${PROJECT_NAME} WebPageUI) @@ -63,6 +65,7 @@ target_link_libraries(${PROJECT_NAME} HistoryUI) target_link_libraries(${PROJECT_NAME} TabUI) target_link_libraries(${PROJECT_NAME} SettingsUI) target_link_libraries(${PROJECT_NAME} BookmarkManagerUI) +target_link_libraries(${PROJECT_NAME} ZoomUI) target_link_libraries(${PROJECT_NAME} PlatformInputManager) target_link_libraries(${PROJECT_NAME} SessionStorage) target_link_libraries(${PROJECT_NAME} ${EFL_LDFLAGS}) diff --git a/services/SimpleUI/SimpleUI.cpp b/services/SimpleUI/SimpleUI.cpp index 472c528..189c284 100644 --- a/services/SimpleUI/SimpleUI.cpp +++ b/services/SimpleUI/SimpleUI.cpp @@ -221,6 +221,11 @@ void SimpleUI::loadUIServices() std::dynamic_pointer_cast (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.bookmarkmanagerui")); + + m_zoomUI = + std::dynamic_pointer_cast + + (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.zoomui")); } void SimpleUI::connectUISignals() @@ -279,11 +284,15 @@ void SimpleUI::connectUISignals() m_moreMenuUI->addToBookmarkClicked.connect(boost::bind(&SimpleUI::addToBookmarks, this, _1)); m_moreMenuUI->isBookmark.connect(boost::bind(&SimpleUI::checkBookmark, this)); m_moreMenuUI->deleteBookmark.connect(boost::bind(&SimpleUI::deleteBookmark, this)); + m_moreMenuUI->zoomUIClicked.connect(boost::bind(&SimpleUI::showZoomUI, this)); M_ASSERT(m_bookmarkManagerUI.get()); m_bookmarkManagerUI->closeBookmarkManagerClicked.connect(boost::bind(&SimpleUI::closeBookmarkManagerUI, this)); m_bookmarkManagerUI->bookmarkItemClicked.connect(boost::bind(&SimpleUI::onBookmarkClicked, this, _1)); + M_ASSERT(m_zoomUI.get()); + m_zoomUI->setZoom.connect(boost::bind(&SimpleUI::setZoomFactor, this, _1)); + m_zoomUI->scrollView.connect(boost::bind(&SimpleUI::scrollView, this, _1, _2)); } void SimpleUI::loadModelServices() @@ -341,6 +350,9 @@ void SimpleUI::initUIServices() M_ASSERT(m_bookmarkManagerUI.get()); m_bookmarkManagerUI->init(m_viewManager->getContent()); + + M_ASSERT(m_zoomUI.get()); + m_zoomUI->init(m_viewManager->getContent()); } void SimpleUI::initModelServices() @@ -365,7 +377,9 @@ void SimpleUI::connectModelSignals() m_webEngine->uriChanged.connect(boost::bind(&SimpleUI::webEngineURLChanged, this, _1)); m_webEngine->uriChanged.connect(boost::bind(&URIEntry::changeUri, &m_webPageUI->getURIEntry(), _1)); + m_webEngine->uriChanged.connect(boost::bind(&MoreMenuUI::setURL, m_moreMenuUI.get(), _1)); m_webEngine->uriOnTabChanged.connect(boost::bind(&SimpleUI::checkTabId,this,_1)); + m_webEngine->uriOnTabChanged.connect(boost::bind(&SimpleUI::closeZoomUI, this)); m_webEngine->webViewClicked.connect(boost::bind(&URIEntry::clearFocus, &m_webPageUI->getURIEntry())); m_webEngine->backwardEnableChanged.connect(boost::bind(&WebPageUI::setBackButtonEnabled, m_webPageUI.get(), _1)); m_webEngine->forwardEnableChanged.connect(boost::bind(&WebPageUI::setForwardButtonEnabled, m_webPageUI.get(), _1)); @@ -380,7 +394,6 @@ void SimpleUI::connectModelSignals() m_webEngine->IMEStateChanged.connect(boost::bind(&SimpleUI::setwvIMEStatus, this, _1)); m_webEngine->favIconChanged.connect(boost::bind(&MoreMenuUI::setFavIcon, m_moreMenuUI.get(), _1)); m_webEngine->titleChanged.connect(boost::bind(&MoreMenuUI::setWebTitle, m_moreMenuUI.get(), _1)); - m_webEngine->uriChanged.connect(boost::bind(&MoreMenuUI::setURL, m_moreMenuUI.get(), _1)); m_favoriteService->bookmarkAdded.connect(boost::bind(&SimpleUI::onBookmarkAdded, this,_1)); m_favoriteService->bookmarkDeleted.connect(boost::bind(&SimpleUI::onBookmarkRemoved, this, _1)); @@ -661,6 +674,37 @@ void SimpleUI::webEngineURLChanged(const std::string url) m_webPageUI->getURIEntry().clearFocus(); } +void SimpleUI::showZoomUI() +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if(! m_webPageUI->isHomePageActive()) { + M_ASSERT(m_viewManager); + m_viewManager->popStackTo(m_webPageUI.get()); + m_webPageUI->showTabUI.connect(boost::bind(&SimpleUI::closeZoomUI, this)); + m_webPageUI->showMoreMenu.connect(boost::bind(&SimpleUI::closeZoomUI, this)); + m_zoomUI->show(m_window.get()); + } +} + +void SimpleUI::closeZoomUI() +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + M_ASSERT(m_zoomUI); + m_webPageUI->showTabUI.disconnect(boost::bind(&SimpleUI::closeZoomUI, this)); + m_webPageUI->showMoreMenu.disconnect(boost::bind(&SimpleUI::closeZoomUI, this)); + m_zoomUI->hideUI(); +} + +void SimpleUI::setZoomFactor(int level) +{ + m_webEngine->setZoomFactor(level); +} + +void SimpleUI::scrollView(const int& dx, const int& dy) +{ + m_webEngine->scrollView(dx, dy); +} + void SimpleUI::showTabUI() { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); diff --git a/services/SimpleUI/SimpleUI.h b/services/SimpleUI/SimpleUI.h index 5b62197..0e8c58a 100644 --- a/services/SimpleUI/SimpleUI.h +++ b/services/SimpleUI/SimpleUI.h @@ -40,6 +40,7 @@ #include "SettingsUI.h" #include "MainUI.h" #include "TabUI.h" +#include "ZoomUI.h" #include "HistoryService.h" #include "BookmarkManagerUI.h" #include "PlatformInputManager.h" @@ -183,6 +184,14 @@ private: */ void deleteBookmark(void); + /** + * @brief show Zoom Menu + */ + void showZoomUI(); + void closeZoomUI(); + void setZoomFactor(int level); + void scrollView(const int& dx, const int& dy); + void showTabUI(); void closeTabUI(); void showMoreMenu(); @@ -232,6 +241,7 @@ private: std::shared_ptr m_platformInputManager; std::shared_ptr m_sessionService; Session::Session m_currentSession; + std::shared_ptr m_zoomUI; std::shared_ptr m_bookmarks_manager; bool m_initialised; int m_tabLimit; diff --git a/services/WebKitEngineService/WebKitEngineService.cpp b/services/WebKitEngineService/WebKitEngineService.cpp index f88b5da..2e0df96 100644 --- a/services/WebKitEngineService/WebKitEngineService.cpp +++ b/services/WebKitEngineService/WebKitEngineService.cpp @@ -525,6 +525,11 @@ bool WebKitEngineService::isDesktopMode() const return m_currentWebView->isDesktopMode(); } +void WebKitEngineService::scrollView(const int& dx, const int& dy) +{ + m_currentWebView->scrollView(dx, dy); +} + } /* end of webkitengine_service */ } /* end of basic_webengine */ } /* end of tizen_browser */ diff --git a/services/WebKitEngineService/WebKitEngineService.h b/services/WebKitEngineService/WebKitEngineService.h index 4f586cb..ed1fc6d 100644 --- a/services/WebKitEngineService/WebKitEngineService.h +++ b/services/WebKitEngineService/WebKitEngineService.h @@ -163,6 +163,8 @@ public: void switchToDesktopMode(); bool isDesktopMode() const; + void scrollView(const int& dx, const int& dy); + private: // callbacks from WebView void _favIconChanged(std::shared_ptr bi); diff --git a/services/WebKitEngineService/WebView.cpp b/services/WebKitEngineService/WebView.cpp index 60d7a4e..fd78851 100644 --- a/services/WebKitEngineService/WebView.cpp +++ b/services/WebKitEngineService/WebView.cpp @@ -823,11 +823,16 @@ void WebView::setZoomFactor(double zoomFactor) if(m_ewkView){ //using zoomFactor = 0 sets zoom "fit to screen" - ewk_view_page_zoom_set(m_ewkView, zoomFactor); + if(zoomFactor != getZoomFactor()) + ewk_view_page_zoom_set(m_ewkView, zoomFactor); } #endif } +void WebView::scrollView(const int& dx, const int& dy) +{ + ewk_view_scroll_by(m_ewkView, dx, dy); +} const TabId& WebView::getTabId(){ return m_tabId; diff --git a/services/WebKitEngineService/WebView.h b/services/WebKitEngineService/WebView.h index 1672438..224e657 100644 --- a/services/WebKitEngineService/WebView.h +++ b/services/WebKitEngineService/WebView.h @@ -43,7 +43,6 @@ public: virtual ~WebView(); void init(bool desktopMode, Evas_Object * opener = NULL); - void setURI(const std::string &); std::string getURI(void); @@ -131,6 +130,17 @@ public: */ std::shared_ptr getFavicon(); + /** + * Sets an absolute scroll of the given view. + * + * Both values are from zero to the contents size minus the viewport + * size. + * + * @param x horizontal position to scroll + * @param y vertical position to scroll + */ + void scrollView(const int& dx, const int& dy); + // signals boost::signals2::signal)> favIconChanged; boost::signals2::signal titleChanged; diff --git a/services/ZoomUI/CMakeLists.txt b/services/ZoomUI/CMakeLists.txt new file mode 100644 index 0000000..d8b752c --- /dev/null +++ b/services/ZoomUI/CMakeLists.txt @@ -0,0 +1,36 @@ +project(ZoomUI) + +set(ZoomUI_SRCS + ZoomUI.cpp + ) + +set(ZoomUI_HEADERS + ZoomUI.h + ) + +include(Coreheaders) +include(EFLHelpers) + +include_directories(${CMAKE_SOURCE_DIR}/services/FavoriteService) + +add_library(${PROJECT_NAME} SHARED ${ZoomUI_SRCS}) + +if(TIZEN_BUILD) + target_link_libraries(${PROJECT_NAME} ${pkgs_LDFLAGS}) +endif(TIZEN_BUILD) + +install(TARGETS ${PROJECT_NAME} + LIBRARY DESTINATION services + ARCHIVE DESTINATION services/static) + +#please do not add edc/ directory +set(edcFiles + ZoomUI.edc + ) + +foreach(edec ${edcFiles}) + string(REPLACE ".edc" ".edj" target_name ${edec}) + EDJ_TARGET(${target_name} + ${CMAKE_CURRENT_SOURCE_DIR}/edc/${edec} + ${CMAKE_CURRENT_BINARY_DIR}) +endforeach(edec) diff --git a/services/ZoomUI/ZoomUI.cpp b/services/ZoomUI/ZoomUI.cpp new file mode 100644 index 0000000..dcbe068 --- /dev/null +++ b/services/ZoomUI/ZoomUI.cpp @@ -0,0 +1,322 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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 + +#include "ZoomUI.h" +#include "BrowserLogger.h" +#include "ServiceManager.h" + +#define DX 50 +#define iDX -50 + +namespace tizen_browser{ +namespace base_ui{ + +EXPORT_SERVICE(ZoomUI, "org.tizen.browser.zoomui") + +ZoomUI::ZoomUI() + : m_layout(nullptr) + , m_nav_layout(nullptr) + , m_zoom_slider(nullptr) + , m_current_translation_x(0) + , m_current_translation_y(0) +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + m_edjFilePath = EDJE_DIR; + m_edjFilePath.append("ZoomUI/ZoomUI.edj"); + elm_theme_extension_add(nullptr, m_edjFilePath.c_str()); +} + +ZoomUI::~ZoomUI() {} + +void ZoomUI::init(Evas_Object* parent) +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + M_ASSERT(parent); + m_parent = parent; +} + +Evas_Object* ZoomUI::getContent() +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + M_ASSERT(m_parent); + if(!m_layout) + createLayout(m_parent); + return m_layout; +} + +void ZoomUI::showUI() +{ + evas_object_show(m_layout); + evas_object_show(m_nav_layout); + evas_object_show(m_zoom_slider); +} + +void ZoomUI::hideUI() +{ + evas_object_hide(m_zoom_slider); + evas_object_hide(m_nav_layout); + evas_object_hide(m_layout); +} + +void ZoomUI::show(Evas_Object* parent) +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + init(parent); + createLayout(parent); + showUI(); +} + +void ZoomUI::createLayout(Evas_Object *parent) +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + m_layout = elm_layout_add(parent); + elm_layout_file_set(m_layout, m_edjFilePath.c_str(), "zoom-layout"); + evas_object_size_hint_weight_set(m_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(m_layout, EVAS_HINT_FILL, EVAS_HINT_FILL); + + createZoomSlider(); + createNavigationButtons(); +} + +void ZoomUI::createZoomSlider() +{ + m_zoom_slider = elm_slider_add(m_layout); + evas_object_size_hint_weight_set(m_zoom_slider, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(m_zoom_slider, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_smart_callback_add(m_zoom_slider, "changed", _zoom_slider_changed, this); + elm_object_style_set(m_zoom_slider, "default"); + elm_slider_horizontal_set(m_zoom_slider, EINA_TRUE); + elm_slider_min_max_set(m_zoom_slider, 1, 6); + elm_slider_step_set(m_zoom_slider, 1); + elm_slider_value_set(m_zoom_slider, 3); + elm_slider_indicator_format_set(m_zoom_slider, "%1.0f"); + + elm_object_part_content_set(m_layout, "slider_swallow", m_zoom_slider); +} + +void ZoomUI::createNavigationButtons() +{ + m_nav_layout = elm_layout_add(m_layout); + elm_layout_file_set(m_nav_layout, m_edjFilePath.c_str(), "nav-layout"); + evas_object_size_hint_weight_set(m_nav_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(m_nav_layout, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_object_part_content_set(m_layout, "nav_buttons", m_nav_layout); + + Evas_Object* icon = elm_icon_add(m_nav_layout); + setImageFile(icon, LEFT, false); + evas_object_smart_callback_add(icon, "clicked", _left_button_clicked, this); + evas_object_event_callback_add(icon, EVAS_CALLBACK_MOUSE_IN, _cb_focus_in_left_button, this); + evas_object_event_callback_add(icon, EVAS_CALLBACK_MOUSE_OUT, _cb_focus_out_left_button, this); + elm_object_part_content_set(m_nav_layout, "left_button", icon); + + icon = elm_icon_add(m_nav_layout); + setImageFile(icon, RIGHT, false); + evas_object_smart_callback_add(icon, "clicked", _right_button_clicked, this); + evas_object_event_callback_add(icon, EVAS_CALLBACK_MOUSE_IN, _cb_focus_in_right_button, this); + evas_object_event_callback_add(icon, EVAS_CALLBACK_MOUSE_OUT, _cb_focus_out_right_button, this); + elm_object_part_content_set(m_nav_layout, "right_button", icon); + + icon = elm_icon_add(m_nav_layout); + setImageFile(icon, DOWN, false); + evas_object_smart_callback_add(icon, "clicked", _down_button_clicked, this); + evas_object_event_callback_add(icon, EVAS_CALLBACK_MOUSE_IN, _cb_focus_in_down_button, this); + evas_object_event_callback_add(icon, EVAS_CALLBACK_MOUSE_OUT, _cb_focus_out_down_button, this); + elm_object_part_content_set(m_nav_layout, "down_button", icon); + + icon = elm_icon_add(m_nav_layout); + setImageFile(icon, UP, false); + evas_object_smart_callback_add(icon, "clicked", _up_button_clicked, this); + evas_object_event_callback_add(icon, EVAS_CALLBACK_MOUSE_IN, _cb_focus_in_up_button, this); + evas_object_event_callback_add(icon, EVAS_CALLBACK_MOUSE_OUT, _cb_focus_out_up_button, this); + elm_object_part_content_set(m_nav_layout, "up_button", icon); +} + +void ZoomUI::clearItems() +{ + evas_object_del(m_layout); + setZoom(ZOOM_DEFAULT); +} + +void ZoomUI::setImageFile(Evas_Object* obj, int direction, bool focused) +{ + switch (direction) { + case LEFT: elm_image_file_set(obj, m_edjFilePath.c_str(), focused ? "ic_zoom_indicator_left_foc.png" : "ic_zoom_indicator_left_nor.png"); + break; + case RIGHT: elm_image_file_set(obj, m_edjFilePath.c_str(), focused ? "ic_zoom_indicator_right_foc.png" : "ic_zoom_indicator_right_nor.png"); + break; + case DOWN: elm_image_file_set(obj, m_edjFilePath.c_str(), focused ? "ic_zoom_indicator_down_foc.png" : "ic_zoom_indicator_down_nor.png"); + break; + case UP: elm_image_file_set(obj, m_edjFilePath.c_str(), focused ? "ic_zoom_indicator_up_foc.png" : "ic_zoom_indicator_up_nor.png"); + break; + default: BROWSER_LOGD("[%s:%d] Warning: Unhandled button", __PRETTY_FUNCTION__, __LINE__); + break; + } +} + +void ZoomUI::_zoom_slider_changed(void *data, Evas_Object *obj, void *event_info) +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if(data && obj) { + int val = elm_slider_value_get(obj); + int zoomLevel = ZOOM_DEFAULT; + ZoomUI *zoomUI = static_cast(data); + + switch (val) { + case 1: zoomLevel = ZOOM_50; + break; + case 2: zoomLevel = ZOOM_75; + break; + case 3: zoomLevel = ZOOM_DEFAULT; + break; + case 4: zoomLevel = ZOOM_150; + break; + case 5: zoomLevel = ZOOM_200; + break; + case 6: zoomLevel = ZOOM_300; + break; + default:BROWSER_LOGD("[%s:%d] Warning: Unhandled zoom level", __PRETTY_FUNCTION__, __LINE__); + break; + } + zoomUI->setZoom(zoomLevel); + } +} + +void ZoomUI::_left_button_clicked(void * data, Evas_Object * obj, void * event_info) +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data && obj) { + ZoomUI *zoomUI = static_cast(data); + zoomUI->scrollView(iDX, 0); + } +} + +void ZoomUI::_right_button_clicked(void * data, Evas_Object * obj, void * event_info) +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data && obj) { + ZoomUI *zoomUI = static_cast(data); + zoomUI->scrollView(DX, 0); + } +} + +void ZoomUI::_up_button_clicked(void * data, Evas_Object * obj, void * event_info) +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data && obj) { + ZoomUI *zoomUI = static_cast(data); + zoomUI->scrollView(0, iDX); + } +} + +void ZoomUI::_down_button_clicked(void * data, Evas_Object * obj, void * event_info) +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data && obj) { + ZoomUI *zoomUI = static_cast(data); + zoomUI->scrollView(0, DX); + } +} + +void ZoomUI::_cb_focus_in_left_button(void * data, Evas *, Evas_Object *obj, void *) +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data && obj) { + elm_object_focus_set(obj, EINA_TRUE); + ZoomUI *zoomUI = static_cast(data); + zoomUI->setImageFile(obj, LEFT, true); + } +} + +void ZoomUI::_cb_focus_out_left_button(void * data, Evas *, Evas_Object *obj, void *) +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data && obj) { + elm_object_focus_set(obj, EINA_FALSE); + ZoomUI *zoomUI = static_cast(data); + zoomUI->setImageFile(obj, LEFT, false); + } +} + +void ZoomUI::_cb_focus_in_right_button(void * data, Evas *, Evas_Object *obj, void *) +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data && obj) { + elm_object_focus_set(obj, EINA_TRUE); + ZoomUI *zoomUI = static_cast(data); + zoomUI->setImageFile(obj, RIGHT, true); + } +} + +void ZoomUI::_cb_focus_out_right_button(void * data, Evas *, Evas_Object *obj, void *) +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data && obj) { + elm_object_focus_set(obj, EINA_FALSE); + ZoomUI *zoomUI = static_cast(data); + zoomUI->setImageFile(obj, RIGHT, false); + } +} + +void ZoomUI::_cb_focus_in_up_button(void * data, Evas *, Evas_Object *obj, void *) +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data && obj) { + elm_object_focus_set(obj, EINA_TRUE); + ZoomUI *zoomUI = static_cast(data); + zoomUI->setImageFile(obj, UP, true); + } +} + +void ZoomUI::_cb_focus_out_up_button(void * data, Evas *, Evas_Object *obj, void *) +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data && obj) { + elm_object_focus_set(obj, EINA_FALSE); + ZoomUI *zoomUI = static_cast(data); + zoomUI->setImageFile(obj, UP, false); + } +} + +void ZoomUI::_cb_focus_in_down_button(void * data, Evas *, Evas_Object *obj, void *) +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data && obj) { + elm_object_focus_set(obj, EINA_TRUE); + ZoomUI *zoomUI = static_cast(data); + zoomUI->setImageFile(obj, DOWN, true); + } +} + +void ZoomUI::_cb_focus_out_down_button(void * data, Evas *, Evas_Object *obj, void *) +{ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data && obj) { + elm_object_focus_set(obj, EINA_FALSE); + ZoomUI *zoomUI = static_cast(data); + zoomUI->setImageFile(obj, DOWN, false); + } +} + + +} +} diff --git a/services/ZoomUI/ZoomUI.h b/services/ZoomUI/ZoomUI.h new file mode 100644 index 0000000..e6206a8 --- /dev/null +++ b/services/ZoomUI/ZoomUI.h @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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 ZOOMUI_H +#define ZOOMUI_H + +#include +#include + +#include "AbstractUIComponent.h" +#include "AbstractService.h" +#include "ServiceFactory.h" +#include "service_macros.h" + +namespace tizen_browser{ +namespace base_ui{ + +class BROWSER_EXPORT ZoomUI + : public tizen_browser::interfaces::AbstractUIComponent + , public tizen_browser::core::AbstractService +{ +public: + ZoomUI(); + ~ZoomUI(); + + //AbstractUIComponent interface methods + void init(Evas_Object* parent); + Evas_Object* getContent(); + void showUI(); + void hideUI(); + std::string getName(); + + void show(Evas_Object* parent); + void clearItems(); + + boost::signals2::signal closeZoomUI; + boost::signals2::signal setZoom; + boost::signals2::signal scrollView; +private: + void createLayout(Evas_Object* parent); + void createZoomSlider(); + void createNavigationButtons(); + void setImageFile(Evas_Object* obj, int direction, bool focused); + + static void _zoom_slider_changed(void * data, Evas_Object * obj, void * event_info); + static void _left_button_clicked(void * data, Evas_Object * obj, void * event_info); + static void _right_button_clicked(void * data, Evas_Object * obj, void * event_info); + static void _up_button_clicked(void * data, Evas_Object * obj, void * event_info); + static void _down_button_clicked(void * data, Evas_Object * obj, void * event_info); + static void _close_button_clicked(void * data, Evas_Object * obj, void * event_info); + static void _cb_focus_in_left_button(void * data, Evas *, Evas_Object *obj, void *); + static void _cb_focus_out_left_button(void * data, Evas *, Evas_Object *obj, void *); + static void _cb_focus_in_right_button(void * data, Evas *, Evas_Object *obj, void *); + static void _cb_focus_out_right_button(void * data, Evas *, Evas_Object *obj, void *); + static void _cb_focus_in_up_button(void * data, Evas *, Evas_Object *obj, void *); + static void _cb_focus_out_up_button(void * data, Evas *, Evas_Object *obj, void *); + static void _cb_focus_in_down_button(void * data, Evas *, Evas_Object *obj, void *); + static void _cb_focus_out_down_button(void * data, Evas *, Evas_Object *obj, void *); + + std::string m_edjFilePath; + Evas_Object* m_layout; + Evas_Object* m_zoom_slider; + Evas_Object* m_nav_layout; + Evas_Object* m_parent; + + int m_current_translation_x; + int m_current_translation_y; + + enum ZoomLevel { + ZOOM_50 = 50, + ZOOM_75 = 75, + ZOOM_100 = 100, + ZOOM_150 = 150, + ZOOM_200 = 200, + ZOOM_300 = 300, + + ZOOM_MIN = ZOOM_50, + ZOOM_DEFAULT = ZOOM_100, + ZOOM_MAX = ZOOM_300 + }; + enum ArrowType { + LEFT = 1, + RIGHT = 2, + UP = 3, + DOWN = 4 + }; +}; + +} +} + +#endif // ZOOMUI_H diff --git a/services/ZoomUI/edc/ZoomUI.edc b/services/ZoomUI/edc/ZoomUI.edc new file mode 100644 index 0000000..e3da119 --- /dev/null +++ b/services/ZoomUI/edc/ZoomUI.edc @@ -0,0 +1,277 @@ +#define RESOURCE_IMAGE_LOSSY( FILE_NAME ) \ + group { \ + name: FILE_NAME; \ + images.image: FILE_NAME LOSSY 100; \ + parts { \ + part { name: "image"; \ + description { \ + state: "default" 0.0; \ + image.normal: FILE_NAME; \ + aspect: 1 1; \ + aspect_preference: BOTH; \ + } \ + } \ + } \ + } + + +collections { + +#define WIDTH 1920 +#define HEIGHT 976 + +RESOURCE_IMAGE_LOSSY("ic_zoom_indicator_down_foc.png"); +RESOURCE_IMAGE_LOSSY("ic_zoom_indicator_down_nor.png"); +RESOURCE_IMAGE_LOSSY("ic_zoom_indicator_left_foc.png"); +RESOURCE_IMAGE_LOSSY("ic_zoom_indicator_left_nor.png"); +RESOURCE_IMAGE_LOSSY("ic_zoom_indicator_right_foc.png"); +RESOURCE_IMAGE_LOSSY("ic_zoom_indicator_right_nor.png"); +RESOURCE_IMAGE_LOSSY("ic_zoom_indicator_up_foc.png"); +RESOURCE_IMAGE_LOSSY("ic_zoom_indicator_up_nor.png"); + + group { + name: "zoom-layout"; + data.item: "contents" "close_button"; + + parts { + + part { name: "bg"; + type: RECT; + mouse_events: 1; + description { state: "default" 0.0; + color: 0 0 0 50; + visible: 1; + min: WIDTH HEIGHT; + max: WIDTH HEIGHT; + align: 0.0 0.0; + rel1 {relative: 0.0 0.0; offset: 0 104;} + rel2 {relative: 1.0 1.0;} + } + } + + part { name: "zoom_rect"; + type: RECT; + mouse_events: 1; + description { state: "default" 0.0; + color: 230 230 230 255; + min: 700 300; + max: 700 300; + visible: 1; + align: 0.0 1.0; + rel1 { + to: "bg"; + offset: 0 0; + relative: 0.0 0.0; + } + rel2 { + to: "bg"; + relative: 1.0 1.0; + } + } + } + + part { name: "slider_swallow"; + type: SWALLOW; + description { + min: 500 100; + max: 500 100; + visible: 1; + fixed: 1 1; + align: 0.0 0.0; + rel1 { + relative: 0.15 0.4; + to: "zoom_rect"; + } + rel2 { + relative: 0.0 0.0; + to: "zoom_rect"; + } + } + } + + part { name: "zoom_text"; + type: TEXT; + description { + visible: 1; + min: 200 122; + max: 200 122; + align: 0.0 0.0; + fixed: 1 1; + color: 51 51 51 255; + rel1 { + to: "zoom_rect"; + relative: 0.45 0.0; + offset: 0 0; + } + rel2 { + to: "zoom_rect"; + relative: 1.0 1.0; + } + text { + text: "Zoom"; + font: "Sans"; + size: 32; + align: 0 0.5; + } + } + } + + part { name: "slider_begin_text"; + type: TEXT; + description { + visible: 1; + min: 100 122; + max: 100 122; + align: 0.0 0.0; + fixed: 1 1; + color: 51 51 51 255; + rel1 { + to: "slider_swallow"; + relative: 0.0 0.0; + offset: -50 -10; + } + rel2 { + to: "slider_swallow"; + relative: 1.0 1.0; + offset: 0 0; + } + text { + text: "50%"; + font: "Sans"; + size: 22; + align: 0 0.5; + } + } + } + + part { name: "slider_end_text"; + type: TEXT; + description { + visible: 1; + min: 100 122; + max: 100 122; + align: 0.0 0.0; + fixed: 1 1; + color: 51 51 51 255; + rel1 { + to: "slider_swallow"; + relative: 1.0 0.0; + offset: 5 -10; + } + rel2 { + to: "slider_swallow"; + relative: 1.0 1.0; + offset: 0 0; + } + text { + text: "300%"; + font: "Sans"; + size: 22; + align: 0 0.5; + } + } + } + + + part { + name: "nav_buttons"; + type : SWALLOW; + scale: 1; + description { + state: "default" 0.0; + visible: 1; + min: WIDTH HEIGHT; + max: WIDTH HEIGHT; + align: 0.0 0.0; + fixed: 0 0; + rel1 { relative: 0.0 0.0; to: "bg"; } + rel2 { relative: 1.0 1.0; to: "bg"; } + } + } + + } + } + + group { + name: "nav-layout"; + min: WIDTH HEIGHT; + max: WIDTH HEIGHT; + data.item: "contents" "left_button right_button up_button down_button"; + parts { + part { + name: "left_button"; + type: SWALLOW; + mouse_events: 1; + scale: 1; + description { + state: "default" 0.0; + visible: 1; + align: 0 0.5; + fixed: 1 1; + min: 90 90; + max: 90 90; + rel1 { relative: 0.0 0.0; offset: 38 0;} + rel2 { relative: 1.0 1.0;} + } + } + part { + name: "right_button"; + type: SWALLOW; + scale: 1; + mouse_events: 1; + description { + state: "default" 0.0; + visible: 1; + align: 1 0.5; + fixed: 1 1; + min: 90 90; + max: 90 90; + rel1 { relative: 0.0 0.0; } + rel2 { relative: 1.0 1.0; offset: -38 0; } + } + } + part { + name: "up_button"; + type: SWALLOW; + scale: 1; + mouse_events: 1; + description { + state: "default" 0.0; + visible: 1; + align: 0.5 0; + fixed: 1 1; + min: 90 90; + max: 90 90; + rel1 { relative: 0.0 0.0; offset: 0 38; } + rel2 { relative: 1.0 1.0; } + } + } + part { + name: "down_button"; + type: SWALLOW; + scale: 1; + mouse_events: 1; + description { + state: "default" 0.0; + visible: 1; + align: 0.5 1; + fixed: 1 1; + min: 90 90; + max: 90 90; + rel1 { relative: 0.0 0.0; } + rel2 { relative: 1.0 1.0; offset: 0 -38; } + } + } + } + programs{ + program { + name: "mouse_click"; + signal: "mouse,clicked,1"; + source: "*"; + script { + emit("elm,action,click", ""); + } + } + } + } +} \ No newline at end of file diff --git a/services/ZoomUI/images/ic_zoom_indicator_down_foc.png b/services/ZoomUI/images/ic_zoom_indicator_down_foc.png new file mode 100644 index 0000000..797738c Binary files /dev/null and b/services/ZoomUI/images/ic_zoom_indicator_down_foc.png differ diff --git a/services/ZoomUI/images/ic_zoom_indicator_down_nor.png b/services/ZoomUI/images/ic_zoom_indicator_down_nor.png new file mode 100644 index 0000000..1ec7c1a Binary files /dev/null and b/services/ZoomUI/images/ic_zoom_indicator_down_nor.png differ diff --git a/services/ZoomUI/images/ic_zoom_indicator_left_foc.png b/services/ZoomUI/images/ic_zoom_indicator_left_foc.png new file mode 100644 index 0000000..d224bb1 Binary files /dev/null and b/services/ZoomUI/images/ic_zoom_indicator_left_foc.png differ diff --git a/services/ZoomUI/images/ic_zoom_indicator_left_nor.png b/services/ZoomUI/images/ic_zoom_indicator_left_nor.png new file mode 100644 index 0000000..bdc35fe Binary files /dev/null and b/services/ZoomUI/images/ic_zoom_indicator_left_nor.png differ diff --git a/services/ZoomUI/images/ic_zoom_indicator_right_foc.png b/services/ZoomUI/images/ic_zoom_indicator_right_foc.png new file mode 100644 index 0000000..2509aa1 Binary files /dev/null and b/services/ZoomUI/images/ic_zoom_indicator_right_foc.png differ diff --git a/services/ZoomUI/images/ic_zoom_indicator_right_nor.png b/services/ZoomUI/images/ic_zoom_indicator_right_nor.png new file mode 100644 index 0000000..0825b13 Binary files /dev/null and b/services/ZoomUI/images/ic_zoom_indicator_right_nor.png differ diff --git a/services/ZoomUI/images/ic_zoom_indicator_up_foc.png b/services/ZoomUI/images/ic_zoom_indicator_up_foc.png new file mode 100644 index 0000000..ee95dee Binary files /dev/null and b/services/ZoomUI/images/ic_zoom_indicator_up_foc.png differ diff --git a/services/ZoomUI/images/ic_zoom_indicator_up_nor.png b/services/ZoomUI/images/ic_zoom_indicator_up_nor.png new file mode 100644 index 0000000..ecd4be4 Binary files /dev/null and b/services/ZoomUI/images/ic_zoom_indicator_up_nor.png differ