, mDefaultTextEncodingName()
, mDefaultFontSize( 16 )
, mEvaluating( false )
+ , mScrollPosition( 0, 0 )
+ , mScrollSize( 500, 500 )
+ , mContentSize( 500, 500 )
{
gInstanceCount++;
gInstance = this;
mDefaultFontSize = defaultFontSize;
}
+ void ScrollBy( int dx, int dy )
+ {
+ mScrollPosition += Dali::Vector2( dx, dy );
+ if ( mScrollPosition.y + mScrollSize.height > mContentSize.height )
+ {
+ gInstance->mScrollEdgeReachedSignal.Emit( Dali::WebEnginePlugin::ScrollEdge::BOTTOM );
+ }
+ }
+
+ void SetScrollPosition( int x, int y )
+ {
+ mScrollPosition.x = x;
+ mScrollPosition.y = y;
+ }
+
+ void GetScrollPosition( int& x, int& y ) const
+ {
+ x = mScrollPosition.x;
+ y = mScrollPosition.y;
+ }
+
+ void GetScrollSize( int& w, int& h ) const
+ {
+ w = mScrollSize.width;
+ h = mScrollSize.height;
+ }
+
+ void GetContentSize( int& w, int& h ) const
+ {
+ w = mContentSize.width;
+ h = mContentSize.height;
+ }
+
Dali::WebEnginePlugin::WebEnginePageLoadSignalType& PageLoadStartedSignal()
{
return mPageLoadStartedSignal;
return mPageLoadErrorSignal;
}
+ Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType& ScrollEdgeReachedSignal()
+ {
+ return mScrollEdgeReachedSignal;
+ }
+
std::string mUrl;
std::vector< std::string > mHistory;
size_t mCurrentPlusOnePos;
Dali::WebEnginePlugin::WebEnginePageLoadErrorSignalType mPageLoadErrorSignal;
std::vector< std::function< void( const std::string& ) > > mResultCallbacks;
bool mEvaluating;
+
+ Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType mScrollEdgeReachedSignal;
+ Dali::Vector2 mScrollPosition;
+ Dali::Vector2 mScrollSize;
+ Dali::Vector2 mContentSize;
};
inline WebEngine& GetImplementation( Dali::WebEngine& webEngine )
Internal::Adaptor::GetImplementation( *this ).SetDefaultFontSize( defaultFontSize );
}
+void WebEngine::ScrollBy( int dx, int dy )
+{
+ Internal::Adaptor::GetImplementation( *this ).ScrollBy( dx, dy );
+}
+
+void WebEngine::SetScrollPosition( int x, int y )
+{
+ Internal::Adaptor::GetImplementation( *this ).SetScrollPosition( x, y );
+}
+
+void WebEngine::GetScrollPosition( int& x, int& y ) const
+{
+ Internal::Adaptor::GetImplementation( *this ).GetScrollPosition( x, y );
+}
+
+void WebEngine::GetScrollSize( int& w, int& h ) const
+{
+ Internal::Adaptor::GetImplementation( *this ).GetScrollSize( w, h );
+}
+
+void WebEngine::GetContentSize( int& w, int& h ) const
+{
+ Internal::Adaptor::GetImplementation( *this ).GetContentSize( w, h );
+}
+
void WebEngine::SetSize( int width, int height )
{
}
return Internal::Adaptor::GetImplementation( *this ).PageLoadErrorSignal();
}
+Dali::WebEnginePlugin::WebEngineScrollEdgeReachedSignalType& WebEngine::ScrollEdgeReachedSignal()
+{
+ return Internal::Adaptor::GetImplementation( *this ).ScrollEdgeReachedSignal();
+}
+
} // namespace Dali;
static int gPageLoadStartedCallbackCalled = 0;
static int gPageLoadFinishedCallbackCalled = 0;
+static int gScrollEdgeReachedCallbackCalled = 0;
static int gEvaluateJavaScriptCallbackCalled = 0;
static bool gTouched = false;
gPageLoadFinishedCallbackCalled++;
}
+static void OnScrollEdgeReached( WebView view, Dali::WebEnginePlugin::ScrollEdge edge )
+{
+ gScrollEdgeReachedCallbackCalled++;
+}
+
static void OnPageLoadError( WebView view, const std::string& url, WebView::LoadErrorCode errorCode )
{
}
END_TEST;
}
+int UtcDaliWebViewProperty9(void)
+{
+ // SCROLL_POSITION
+ ToolkitTestApplication application;
+
+ WebView view = WebView::New();
+ DALI_TEST_CHECK( view );
+
+ // Check default value
+ Dali::Vector2 output = Dali::Vector2::ONE;
+ view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
+ DALI_TEST_CHECK( output.x == 0 && output.y == 0 );
+
+ // Check Set/GetProperty
+ Dali::Vector2 testValue = Dali::Vector2( 100, 100 );
+ view.SetProperty( WebView::Property::SCROLL_POSITION, testValue );
+ view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
+ DALI_TEST_EQUALS( output, testValue, TEST_LOCATION );
+
+ // Check default value of scroll size
+ output = Dali::Vector2::ONE;
+ view.GetProperty( WebView::Property::SCROLL_SIZE ).Get( output );
+ DALI_TEST_CHECK( output.x == 500 && output.y == 500 );
+
+ // Check default value of content size
+ output = Dali::Vector2::ONE;
+ view.GetProperty( WebView::Property::CONTENT_SIZE ).Get( output );
+ DALI_TEST_CHECK( output.x == 500 && output.y == 500 );
+
+ END_TEST;
+}
+
+int UtcDaliWebViewScrollBy(void)
+{
+ ToolkitTestApplication application;
+
+ WebView view = WebView::New();
+ DALI_TEST_CHECK( view );
+
+ // load url.
+ ConnectionTracker* testTracker = new ConnectionTracker();
+ view.ScrollEdgeReachedSignal().Connect( &OnScrollEdgeReached );
+ bool signal1 = false;
+ view.ConnectSignal( testTracker, "scrollEdgeReached", CallbackFunctor(&signal1) );
+ DALI_TEST_EQUALS( gScrollEdgeReachedCallbackCalled, 0, TEST_LOCATION );
+
+ view.LoadUrl( TEST_URL1 );
+ Test::EmitGlobalTimerSignal();
+
+ // set scroll position.
+ Dali::Vector2 output = Dali::Vector2::ONE;
+ Dali::Vector2 testValue = Dali::Vector2( 100, 100 );
+ view.SetProperty( WebView::Property::SCROLL_POSITION, testValue );
+ view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
+ DALI_TEST_EQUALS( output, testValue, TEST_LOCATION );
+
+ // scroll by and trigger scrollEdgeReached event.
+ view.ScrollBy( 50, 50 );
+ view.GetProperty( WebView::Property::SCROLL_POSITION ).Get( output );
+ DALI_TEST_CHECK( output.x == 150 && output.y == 150 );
+ DALI_TEST_EQUALS( gScrollEdgeReachedCallbackCalled, 1, TEST_LOCATION );
+ DALI_TEST_CHECK( signal1 );
+
+ END_TEST;
+}
+
int UtcDaliWebViewEvaluteJavaScript(void)
{
ToolkitTestApplication application;
Dali::Toolkit::GetImpl(*this).Resume();
}
+void WebView::ScrollBy( int deltaX, int deltaY )
+{
+ Dali::Toolkit::GetImpl( *this ).ScrollBy( deltaX, deltaY );
+}
+
bool WebView::CanGoForward()
{
return Dali::Toolkit::GetImpl(*this).CanGoForward();
return Dali::Toolkit::GetImpl(*this).PageLoadErrorSignal();
}
+WebView::WebViewScrollEdgeReachedSignalType& WebView::ScrollEdgeReachedSignal()
+{
+ return Dali::Toolkit::GetImpl( *this ).ScrollEdgeReachedSignal();
+}
+
WebView::WebView(Internal::WebView& implementation)
: Control(implementation)
{
#include <functional>
// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/web-engine-plugin.h>
#include <dali-toolkit/public-api/controls/control.h>
namespace Dali
* @details Name "defaultFontSize", type Property::INT.
* @note Default is 16.
*/
- DEFAULT_FONT_SIZE
+ DEFAULT_FONT_SIZE,
+
+ /**
+ * @brief The current position of scroll.
+ * @details Name "scrollPosition", type Property::VECTOR2.
+ */
+ SCROLL_POSITION,
+
+ /**
+ * @brief The current position of scroll.
+ * @details Name "scrollSize", type Property::VECTOR2. Read-only.
+ */
+ SCROLL_SIZE,
+
+ /**
+ * @brief The current position of scroll.
+ * @details Name "contentSize", type Property::VECTOR2. Read-only.
+ */
+ CONTENT_SIZE,
};
};
*/
typedef Signal<void(WebView, const std::string&, LoadErrorCode)> WebViewPageLoadErrorSignalType;
+ /**
+ * @brief WebView signal type related with scroll edge reached.
+ */
+ typedef Signal<void(WebView, Dali::WebEnginePlugin::ScrollEdge)> WebViewScrollEdgeReachedSignalType;
+
public:
/**
* @brief Creates an initialized WebView.
void Resume();
/**
+ * @brief Scrolls the webpage of view by deltaX and deltaY.
+ * @param[in] deltaX The delta x of scroll
+ * @param[in] deltaY The delta y of scroll
+ */
+ void ScrollBy( int deltaX, int deltaY );
+
+ /**
* @brief Returns whether forward is possible.
*
* @return True if forward is possible, false otherwise
*/
WebViewPageLoadErrorSignalType& PageLoadErrorSignal();
+ /**
+ * @brief Connects to this signal to be notified when scroll edge is reached.
+ *
+ * @return A signal object to connect with.
+ */
+ WebViewScrollEdgeReachedSignalType& ScrollEdgeReachedSignal();
+
public: // Not intended for application developers
/// @cond internal
/**
DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "loadImagesAutomatically", BOOLEAN, LOAD_IMAGES_AUTOMATICALLY )
DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "defaultTextEncodingName", STRING, DEFAULT_TEXT_ENCODING_NAME )
DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "defaultFontSize", INTEGER, DEFAULT_FONT_SIZE )
+DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "scrollPosition", VECTOR2, SCROLL_POSITION )
+DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "scrollSize", VECTOR2, SCROLL_SIZE )
+DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "contentSize", VECTOR2, CONTENT_SIZE )
DALI_SIGNAL_REGISTRATION( Toolkit, WebView, "pageLoadStarted", PAGE_LOAD_STARTED_SIGNAL )
DALI_SIGNAL_REGISTRATION( Toolkit, WebView, "pageLoadFinished", PAGE_LOAD_FINISHED_SIGNAL )
DALI_SIGNAL_REGISTRATION( Toolkit, WebView, "pageLoadError", PAGE_LOAD_ERROR_SIGNAL )
+DALI_SIGNAL_REGISTRATION( Toolkit, WebView, "scrollEdgeReached", SCROLL_EDGE_REACHED_SIGNAL )
DALI_TYPE_REGISTRATION_END()
mWebEngine.PageLoadStartedSignal().Connect( this, &WebView::OnPageLoadStarted );
mWebEngine.PageLoadFinishedSignal().Connect( this, &WebView::OnPageLoadFinished );
mWebEngine.PageLoadErrorSignal().Connect( this, &WebView::OnPageLoadError );
+ mWebEngine.ScrollEdgeReachedSignal().Connect( this, &WebView::OnScrollEdgeReached );
}
}
}
}
+void WebView::ScrollBy( int deltaX, int deltaY )
+{
+ if ( mWebEngine )
+ {
+ mWebEngine.ScrollBy( deltaX, deltaY );
+ }
+}
+
bool WebView::CanGoForward()
{
return mWebEngine ? mWebEngine.CanGoForward() : false;
return mPageLoadErrorSignal;
}
+Dali::Toolkit::WebView::WebViewScrollEdgeReachedSignalType& WebView::ScrollEdgeReachedSignal()
+{
+ return mScrollEdgeReachedSignal;
+}
+
void WebView::OnPageLoadStarted( const std::string& url )
{
if( !mPageLoadStartedSignal.Empty() )
}
}
+void WebView::OnScrollEdgeReached( Dali::WebEnginePlugin::ScrollEdge edge )
+{
+ if( !mScrollEdgeReachedSignal.Empty() )
+ {
+ Dali::Toolkit::WebView handle( GetOwner() );
+ mScrollEdgeReachedSignal.Emit( handle, edge );
+ }
+}
+
bool WebView::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
{
Dali::BaseHandle handle( object );
webView.PageLoadErrorSignal().Connect( tracker, functor );
connected = true;
}
+ else if( 0 == strcmp( signalName.c_str(), SCROLL_EDGE_REACHED_SIGNAL ) )
+ {
+ webView.ScrollEdgeReachedSignal().Connect( tracker, functor );
+ connected = true;
+ }
return connected;
}
}
break;
}
+ case Toolkit::WebView::Property::SCROLL_POSITION:
+ {
+ Vector2 input;
+ if ( value.Get( input ) )
+ {
+ impl.SetScrollPosition( input.x, input.y );
+ }
+ break;
+ }
}
}
}
value = impl.GetDefaultFontSize();
break;
}
+ case Toolkit::WebView::Property::SCROLL_POSITION:
+ {
+ int x, y;
+ impl.GetScrollPosition( x, y );
+ value = Vector2( x, y );
+ break;
+ }
+ case Toolkit::WebView::Property::SCROLL_SIZE:
+ {
+ int width, height;
+ impl.GetScrollSize( width, height );
+ value = Vector2( width, height );
+ break;
+ }
+ case Toolkit::WebView::Property::CONTENT_SIZE:
+ {
+ int width, height;
+ impl.GetContentSize( width, height );
+ value = Vector2( width, height );
+ break;
+ }
default:
break;
}
EmitKeyInputFocusSignal( false ); // Calls back into the Control hence done last.
}
+void WebView::SetScrollPosition( int x, int y )
+{
+ if( mWebEngine )
+ {
+ mWebEngine.SetScrollPosition( x, y );
+ }
+}
+
+void WebView::GetScrollPosition( int& x, int& y ) const
+{
+ if( mWebEngine )
+ {
+ mWebEngine.GetScrollPosition( x, y );
+ }
+}
+
+void WebView::GetScrollSize( int& width, int& height ) const
+{
+ if( mWebEngine )
+ {
+ mWebEngine.GetScrollSize( width, height );
+ }
+}
+
+void WebView::GetContentSize( int& width, int& height ) const
+{
+ if( mWebEngine )
+ {
+ mWebEngine.GetContentSize( width, height );
+ }
+}
+
Toolkit::WebView::CacheModel::Type WebView::GetCacheModel() const
{
return mWebEngine ? static_cast< Toolkit::WebView::CacheModel::Type >( mWebEngine.GetCacheModel() ) : Toolkit::WebView::CacheModel::DOCUMENT_VIEWER;
void Resume();
/**
+ * @copydoc Dali::Toolkit::WebView::ScrollBy()
+ */
+ void ScrollBy( int deltaX, int deltaY );
+
+ /**
* @copydoc Dali::Toolkit::WebView::CanGoForward()
*/
bool CanGoForward();
*/
Dali::Toolkit::WebView::WebViewPageLoadErrorSignalType& PageLoadErrorSignal();
+ /**
+ * @copydoc Dali::Toolkit::WebView::ScrollEdgeReachedSignal()
+ */
+ Dali::Toolkit::WebView::WebViewScrollEdgeReachedSignalType& ScrollEdgeReachedSignal();
+
public: // Properties
/**
WebView& operator=( const WebView& webView );
/**
+ * @brief Sets an absolute scroll of the given view.
+ * @param[in] x The coordinate x of scroll
+ * @param[in] y The coordinate y of scroll
+ */
+ void SetScrollPosition( int x, int y );
+
+ /**
+ * @brief Gets the current scroll position of the given view.
+ * @param[out] x The coordinate x of scroll
+ * @param[out] y The coordinate y of scroll
+ */
+ void GetScrollPosition( int& x, int& y ) const;
+
+ /**
+ * @brief Gets the possible scroll size of the given view.
+ * @param[out] width The width of scroll size
+ * @param[out] height The height of scroll size
+ */
+ void GetScrollSize( int& width, int& height ) const;
+
+ /**
+ * @brief Gets the last known content's size.
+ * @param[out] width The width of content's size
+ * @param[out] height The height of content's size
+ */
+ void GetContentSize( int& width, int& height ) const;
+
+ /**
* @brief Get cache model option. The default isToolkit::WebView::CacheModel::DOCUMENT_VIEWER.
* @see Toolkit::WebView::CacheModel::Type
*/
*/
void OnPageLoadError( const std::string& url, int errorCode );
+ /**
+ * @brief Callback function to be called when scroll edge is reached.
+ * @param[in] e The scroll edge reached.
+ */
+ void OnScrollEdgeReached( Dali::WebEnginePlugin::ScrollEdge edge );
+
private:
std::string mUrl;
Dali::Toolkit::WebView::WebViewPageLoadSignalType mPageLoadStartedSignal;
Dali::Toolkit::WebView::WebViewPageLoadSignalType mPageLoadFinishedSignal;
Dali::Toolkit::WebView::WebViewPageLoadErrorSignalType mPageLoadErrorSignal;
+ Dali::Toolkit::WebView::WebViewScrollEdgeReachedSignalType mScrollEdgeReachedSignal;
};
} // namespace Internal