From dccb5d402b072bcd9d76fc2c073b53abe72275a6 Mon Sep 17 00:00:00 2001 From: "huayong.xu" Date: Tue, 5 Jan 2021 15:00:51 +0800 Subject: [PATCH] Support scroll in web engine. Some APIs related to scroll are supported. Change-Id: Ie97364cf57bd40d7a5a855387a188c2e23f7f074 --- .../adaptor-framework/web-engine-plugin.h | 59 +++++++++++++++++++--- dali/devel-api/adaptor-framework/web-engine.cpp | 30 +++++++++++ dali/devel-api/adaptor-framework/web-engine.h | 32 ++++++++++++ .../internal/web-engine/common/web-engine-impl.cpp | 30 +++++++++++ dali/internal/web-engine/common/web-engine-impl.h | 30 +++++++++++ 5 files changed, 175 insertions(+), 6 deletions(-) mode change 100644 => 100755 dali/devel-api/adaptor-framework/web-engine-plugin.h mode change 100644 => 100755 dali/devel-api/adaptor-framework/web-engine.h mode change 100644 => 100755 dali/internal/web-engine/common/web-engine-impl.cpp diff --git a/dali/devel-api/adaptor-framework/web-engine-plugin.h b/dali/devel-api/adaptor-framework/web-engine-plugin.h old mode 100644 new mode 100755 index 5914637..c3b9389 --- a/dali/devel-api/adaptor-framework/web-engine-plugin.h +++ b/dali/devel-api/adaptor-framework/web-engine-plugin.h @@ -45,6 +45,14 @@ public: */ typedef Signal WebEnginePageLoadErrorSignalType; + // forward declaration. + enum class ScrollEdge; + + /** + * @brief WebView signal type related with scroll edge reached. + */ + typedef Signal< void( const ScrollEdge )> WebEngineScrollEdgeReachedSignalType; + /** * @brief Enumeration for cache model options. */ @@ -88,18 +96,25 @@ public: }; /** - * @brief Constructor. + * @brief Enumeration for the scroll edge. */ - WebEnginePlugin() + enum class ScrollEdge { - } + LEFT, ///< Left edge reached. + RIGHT, ///< Right edge reached. + TOP, ///< Top edge reached. + BOTTOM, ///< Bottom edge reached. + }; + + /** + * @brief Constructor. + */ + WebEnginePlugin() = default; /** * @brief Destructor. */ - virtual ~WebEnginePlugin() - { - } + virtual ~WebEnginePlugin() = default; /** * @brief Creates WebEngine instance. @@ -163,6 +178,31 @@ public: virtual void Resume() = 0; /** + * @brief Scrolls the webpage of view by deltaX and deltaY. + */ + virtual void ScrollBy( int deltaX, int deltaY ) = 0; + + /** + * @brief Scroll to the specified position of the given view. + */ + virtual void SetScrollPosition( int x, int y ) = 0; + + /** + * @brief Gets the current scroll position of the given view. + */ + virtual void GetScrollPosition( int& x, int& y ) const = 0; + + /** + * @brief Gets the possible scroll size of the given view. + */ + virtual void GetScrollSize( int& width, int& height ) const = 0; + + /** + * @brief Gets the last known content's size. + */ + virtual void GetContentSize( int& width, int& height ) const = 0; + + /** * @brief Returns whether forward is possible. * * @return True if forward is possible, false otherwise @@ -355,6 +395,13 @@ public: * @return A signal object to connect with. */ virtual WebEnginePageLoadErrorSignalType& PageLoadErrorSignal() = 0; + + /** + * @brief Connects to this signal to be notified when scroll edge is reached. + * + * @return A signal object to connect with. + */ + virtual WebEngineScrollEdgeReachedSignalType& ScrollEdgeReachedSignal() = 0; }; } // namespace Dali diff --git a/dali/devel-api/adaptor-framework/web-engine.cpp b/dali/devel-api/adaptor-framework/web-engine.cpp index 69c2b79..efdc38c 100755 --- a/dali/devel-api/adaptor-framework/web-engine.cpp +++ b/dali/devel-api/adaptor-framework/web-engine.cpp @@ -112,6 +112,31 @@ void WebEngine::Resume() GetImplementation(*this).Resume(); } +void WebEngine::ScrollBy( int deltaX, int deltaY ) +{ + GetImplementation( *this ).ScrollBy( deltaX, deltaY ); +} + +void WebEngine::SetScrollPosition( int x, int y ) +{ + GetImplementation( *this ).SetScrollPosition( x, y ); +} + +void WebEngine::GetScrollPosition( int& x, int& y ) const +{ + GetImplementation( *this ).GetScrollPosition( x, y ); +} + +void WebEngine::GetScrollSize( int& width, int& height ) const +{ + GetImplementation( *this ).GetScrollSize( width, height ); +} + +void WebEngine::GetContentSize( int& width, int& height ) const +{ + GetImplementation( *this ).GetContentSize( width, height ); +} + bool WebEngine::CanGoForward() { return GetImplementation(*this).CanGoForward(); @@ -262,4 +287,9 @@ Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType& WebEngine::PageLoadErro return GetImplementation(*this).PageLoadErrorSignal(); } +Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType& WebEngine::ScrollEdgeReachedSignal() +{ + return GetImplementation( *this ).ScrollEdgeReachedSignal(); +} + } // namespace Dali diff --git a/dali/devel-api/adaptor-framework/web-engine.h b/dali/devel-api/adaptor-framework/web-engine.h old mode 100644 new mode 100755 index f3622ab..adebcd7 --- a/dali/devel-api/adaptor-framework/web-engine.h +++ b/dali/devel-api/adaptor-framework/web-engine.h @@ -146,6 +146,31 @@ public: void Resume(); /** + * @brief Scrolls the webpage of view by deltaX and deltaY. + */ + void ScrollBy( int deltaX, int deltaY ); + + /** + * @brief Sets an absolute scroll of the given view. + */ + void SetScrollPosition( int x, int y ); + + /** + * @brief Gets the current scroll position of the given view. + */ + void GetScrollPosition( int& x, int& y ) const; + + /** + * @brief Gets the possible scroll size of the given view. + */ + void GetScrollSize( int& width, int& height ) const; + + /** + * @brief Gets the last known content's size. + */ + void GetContentSize( int& width, int& height ) const; + + /** * @brief Returns whether forward is possible. * * @return True if forward is possible, false otherwise @@ -339,6 +364,13 @@ public: */ Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType& PageLoadErrorSignal(); + /** + * @brief Connects to this signal to be notified when scroll edge is reached. + * + * @return A signal object to connect with. + */ + Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType& ScrollEdgeReachedSignal(); + private: // Not intended for application developers /** * @brief Internal constructor diff --git a/dali/internal/web-engine/common/web-engine-impl.cpp b/dali/internal/web-engine/common/web-engine-impl.cpp old mode 100644 new mode 100755 index 8e2d55d..d3718ef --- a/dali/internal/web-engine/common/web-engine-impl.cpp +++ b/dali/internal/web-engine/common/web-engine-impl.cpp @@ -213,6 +213,31 @@ void WebEngine::Resume() mPlugin->Resume(); } +void WebEngine::ScrollBy( int deltaX, int deltaY ) +{ + mPlugin->ScrollBy( deltaX, deltaY ); +} + +void WebEngine::SetScrollPosition( int x, int y ) +{ + mPlugin->SetScrollPosition( x, y ); +} + +void WebEngine::GetScrollPosition( int& x, int& y ) const +{ + mPlugin->GetScrollPosition( x, y ); +} + +void WebEngine::GetScrollSize( int& width, int& height ) const +{ + mPlugin->GetScrollSize( width, height ); +} + +void WebEngine::GetContentSize( int& width, int& height ) const +{ + mPlugin->GetContentSize( width, height ); +} + bool WebEngine::CanGoForward() { return mPlugin->CanGoForward(); @@ -363,6 +388,11 @@ Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType& WebEngine::PageLoadErro return mPlugin->PageLoadErrorSignal(); } +Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType& WebEngine::ScrollEdgeReachedSignal() +{ + return mPlugin->ScrollEdgeReachedSignal(); +} + } // namespace Adaptor; } // namespace Internal; } // namespace Dali; diff --git a/dali/internal/web-engine/common/web-engine-impl.h b/dali/internal/web-engine/common/web-engine-impl.h index a9a9928..18bb93c 100755 --- a/dali/internal/web-engine/common/web-engine-impl.h +++ b/dali/internal/web-engine/common/web-engine-impl.h @@ -103,6 +103,31 @@ public: void Resume(); /** + * @copydoc Dali::WebEngine::ScrollBy() + */ + void ScrollBy( int deltaX, int deltaY ); + + /** + * @copydoc Dali::WebEngine::SetScrollPosition() + */ + void SetScrollPosition( int x, int y ); + + /** + * @copydoc Dali::WebEngine::GetScrollPosition() + */ + void GetScrollPosition( int& x, int& y ) const; + + /** + * @copydoc Dali::WebEngine::GetScrollSize() + */ + void GetScrollSize( int& width, int& height ) const; + + /** + * @copydoc Dali::WebEngine::GetContentSize() + */ + void GetContentSize( int& width, int& height ) const; + + /** * @copydoc Dali::WebEngine::CanGoForward() */ bool CanGoForward(); @@ -252,6 +277,11 @@ public: */ Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType& PageLoadErrorSignal(); + /** + * @copydoc Dali::WebEngine::ScrollEdgeReachedSignal() + */ + Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType& ScrollEdgeReachedSignal(); + private: /** -- 2.7.4