utc-Dali-VisualFactory.cpp
utc-Dali-ImageAtlas.cpp
utc-Dali-VideoView.cpp
+ utc-Dali-WebView.cpp
utc-Dali-AsyncImageLoader.cpp
utc-Dali-SyncImageLoader.cpp
utc-Dali-ControlWrapper.cpp
dali-toolkit-test-utils/toolkit-tts-player.cpp
dali-toolkit-test-utils/toolkit-native-image-source.cpp
dali-toolkit-test-utils/toolkit-video-player.cpp
+ dali-toolkit-test-utils/toolkit-web-engine.cpp
dali-toolkit-test-utils/toolkit-trigger-event-factory.cpp
dali-toolkit-test-utils/dali-test-suite-utils.cpp
dali-toolkit-test-utils/dummy-control.cpp
return layout;
}
-void CustomLayout::MeasureChildren( Dali::Toolkit::Internal::LayoutItemPtr childLayout, MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpec, int resultingWidth, int resultingHeight )
+void CustomLayout::MeasureChildren( Dali::Toolkit::Internal::LayoutItemPtr childLayout, MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpec, LayoutLength resultingWidth, LayoutLength resultingHeight )
{
// Initially use the measure spec of the child's parent
auto childWidthMeasureSpec = widthMeasureSpec;
MeasureChild( childLayout, childWidthMeasureSpec, childHeightMeasureSpec );
resultingWidth += childLayout->GetMeasuredWidth();
- resultingHeight = std::max( childLayout->GetMeasuredHeight().mValue, resultingHeight );
+ resultingHeight = std::max( childLayout->GetMeasuredHeight(), resultingHeight );
}
void CustomLayout::OnMeasure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpec )
LayoutLength childLeft( 0 );
// We want to vertically align the children to the middle
- auto height = bottom - top;
- auto middle = height / 2;
+ LayoutLength height = bottom - top;
+ LayoutLength middle = height / 2;
auto owner = GetOwner();
auto actor = Actor::DownCast(owner);
// Horizontally align the children to the left
int count = actor.GetChildCount();
- int currentLeft = 0;
+ LayoutLength currentLeft = 0;
for( int i = 0; i < count; i++)
{
{
Dali::Toolkit::Internal::LayoutItem& childLayoutImpl = GetImplementation( childLayout );
- auto childWidth = childLayoutImpl.GetMeasuredWidth();
- auto childHeight = childLayoutImpl.GetMeasuredHeight();
+ LayoutLength childWidth = childLayoutImpl.GetMeasuredWidth();
+ LayoutLength childHeight = childLayoutImpl.GetMeasuredHeight();
- childTop = middle - (childHeight / 2);
+ childTop = middle - childHeight / 2;
childLayoutImpl.Layout( currentLeft, childTop, currentLeft + childWidth, childTop + childHeight );
currentLeft += childWidth;
}
* @param[out] resultingWidth resulting width of layout after children are measured
* @param[out] resultingHeight resulting height of layout after children are measured
*/
- void MeasureChildren( Dali::Toolkit::Internal::LayoutItemPtr childLayout, MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpec, int resultingWidth, int resultingHeight );
+ void MeasureChildren( Dali::Toolkit::Internal::LayoutItemPtr childLayout, MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpec, LayoutLength resultingWidth, LayoutLength resultingHeight );
private:
--- /dev/null
+/*
+ * Copyright (c) 2018 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 "toolkit-timer.h"
+
+#include <dali/devel-api/adaptor-framework/web-engine.h>
+#include <dali/public-api/object/any.h>
+#include <dali/public-api/object/base-object.h>
+#include <dali/public-api/adaptor-framework/native-image-source.h>
+#include <dali/public-api/images/native-image.h>
+#include <toolkit-application.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace Adaptor
+{
+
+class WebEngine;
+
+namespace
+{
+static WebEngine* gInstance = NULL;
+static int gInstanceCount = 0;
+
+bool OnGoBack();
+bool OnGoForward();
+bool OnLoadUrl();
+bool OnClearHistory();
+
+static void ConnectToGlobalSignal( bool (*func)() )
+{
+ Dali::Timer timer = Dali::Timer::New( 0 );
+ timer.TickSignal().Connect( func );
+}
+
+static void DisconnectFromGlobalSignal( bool (*func)() )
+{
+ Dali::Timer timer = Dali::Timer::New( 0 );
+ timer.TickSignal().Disconnect( func );
+}
+}
+
+class WebEngine: public Dali::BaseObject
+{
+public:
+
+ WebEngine()
+ : mUrl()
+ , mCurrentPlusOnePos( 0 )
+ {
+ gInstanceCount++;
+ gInstance = this;
+ }
+
+ virtual ~WebEngine()
+ {
+ gInstanceCount--;
+ if ( !gInstanceCount )
+ {
+ gInstance = NULL;
+ }
+ }
+
+ void LoadUrl( const std::string& url )
+ {
+ mUrl = url;
+ ConnectToGlobalSignal( &OnLoadUrl );
+ }
+
+ const std::string& GetUrl() const
+ {
+ return mUrl;
+ }
+
+ bool CanGoForward() const
+ {
+ return mHistory.size() > mCurrentPlusOnePos;
+ }
+
+ void GoForward()
+ {
+ ConnectToGlobalSignal( &OnGoForward );
+ }
+
+ bool CanGoBack() const
+ {
+ return mCurrentPlusOnePos > 1;
+ }
+
+ void GoBack()
+ {
+ ConnectToGlobalSignal( &OnGoBack );
+ }
+
+ void ClearHistory()
+ {
+ ConnectToGlobalSignal( &OnClearHistory );
+ }
+
+ Dali::WebEnginePlugin::WebEngineSignalType& PageLoadStartedSignal()
+ {
+ return mPageLoadStartedSignal;
+ }
+
+ Dali::WebEnginePlugin::WebEngineSignalType& PageLoadFinishedSignal()
+ {
+ return mPageLoadFinishedSignal;
+ }
+
+ std::string mUrl;
+ std::vector< std::string > mHistory;
+ size_t mCurrentPlusOnePos;
+ Dali::WebEnginePlugin::WebEngineSignalType mPageLoadStartedSignal;
+ Dali::WebEnginePlugin::WebEngineSignalType mPageLoadFinishedSignal;
+};
+
+inline WebEngine& GetImplementation( Dali::WebEngine& webEngine )
+{
+ DALI_ASSERT_ALWAYS( webEngine && "WebEngine handle is empty." );
+ BaseObject& handle = webEngine.GetBaseObject();
+ return static_cast< Internal::Adaptor::WebEngine& >( handle );
+}
+
+inline const WebEngine& GetImplementation( const Dali::WebEngine& webEngine )
+{
+ DALI_ASSERT_ALWAYS( webEngine && "WebEngine handle is empty." );
+ const BaseObject& handle = webEngine.GetBaseObject();
+ return static_cast< const Internal::Adaptor::WebEngine& >( handle );
+}
+
+namespace
+{
+
+bool OnGoBack()
+{
+ DisconnectFromGlobalSignal( &OnGoBack );
+
+ if ( gInstance && gInstance->CanGoBack() )
+ {
+ gInstance->mCurrentPlusOnePos--;
+ }
+ return false;
+}
+
+bool OnGoForward()
+{
+ DisconnectFromGlobalSignal( &OnGoForward );
+
+ if ( gInstance && gInstance->CanGoForward() )
+ {
+ gInstance->mCurrentPlusOnePos++;
+ }
+ return false;
+}
+
+bool OnLoadUrl()
+{
+ DisconnectFromGlobalSignal( &OnLoadUrl );
+
+ if ( gInstance )
+ {
+ if ( gInstance->mHistory.size() > gInstance->mCurrentPlusOnePos )
+ {
+ gInstance->mHistory.erase( gInstance->mHistory.begin() + gInstance->mCurrentPlusOnePos, gInstance->mHistory.end() );
+ }
+ gInstance->mHistory.push_back( gInstance->mUrl );
+ gInstance->mCurrentPlusOnePos++;
+ gInstance->mPageLoadStartedSignal.Emit( gInstance->mUrl );
+ gInstance->mPageLoadFinishedSignal.Emit( gInstance->mUrl );
+ }
+
+ return false;
+}
+
+bool OnClearHistory()
+{
+ DisconnectFromGlobalSignal( &OnClearHistory );
+
+ if ( gInstance && gInstance->mCurrentPlusOnePos ) {
+ std::string url = gInstance->mHistory[ gInstance->mCurrentPlusOnePos - 1 ];
+ std::vector< std::string >().swap( gInstance->mHistory );
+ gInstance->mHistory.push_back( url );
+ gInstance->mCurrentPlusOnePos = 1;
+ }
+ return false;
+}
+} // namespace
+
+} // namespace Adaptor
+
+} // namespace Internal
+
+
+// Dali::WebEngine Implementation
+WebEngine::WebEngine()
+{
+}
+
+WebEngine::WebEngine( Internal::Adaptor::WebEngine* internal )
+: BaseHandle( internal )
+{
+}
+
+WebEngine::~WebEngine()
+{
+}
+
+WebEngine WebEngine::New()
+{
+ Internal::Adaptor::WebEngine* baseObject = new Internal::Adaptor::WebEngine();
+
+ return WebEngine( baseObject );
+}
+
+WebEngine::WebEngine( const WebEngine& WebEngine )
+: BaseHandle( WebEngine )
+{
+}
+
+WebEngine& WebEngine::operator=( const WebEngine& webEngine )
+{
+ BaseHandle::operator=( webEngine );
+ return *this;
+}
+
+WebEngine WebEngine::DownCast( BaseHandle handle )
+{
+ return WebEngine( dynamic_cast< Internal::Adaptor::WebEngine* >( handle.GetObjectPtr() ) );
+}
+
+void WebEngine::Create( int width, int height, const std::string& locale, const std::string& timezoneId )
+{
+}
+
+void WebEngine::Destroy()
+{
+}
+
+void WebEngine::LoadUrl( const std::string& url )
+{
+ return Internal::Adaptor::GetImplementation( *this ).LoadUrl( url );
+}
+
+const std::string& WebEngine::GetUrl()
+{
+ return Internal::Adaptor::GetImplementation( *this ).GetUrl();
+}
+
+NativeImageInterfacePtr WebEngine::GetNativeImageSource()
+{
+ Any source;
+ Dali::NativeImageSourcePtr sourcePtr = Dali::NativeImageSource::New( source );
+ return sourcePtr;
+}
+
+void WebEngine::LoadHTMLString( const std::string& htmlString )
+{
+}
+
+void WebEngine::Reload()
+{
+}
+
+void WebEngine::StopLoading()
+{
+}
+
+bool WebEngine::CanGoForward()
+{
+ return Internal::Adaptor::GetImplementation( *this ).CanGoForward();
+}
+
+void WebEngine::GoForward()
+{
+ Internal::Adaptor::GetImplementation( *this ).GoForward();
+}
+
+bool WebEngine::CanGoBack()
+{
+ return Internal::Adaptor::GetImplementation( *this ).CanGoBack();
+}
+
+void WebEngine::GoBack()
+{
+ Internal::Adaptor::GetImplementation( *this ).GoBack();
+}
+
+void WebEngine::EvaluateJavaScript( const std::string& script )
+{
+}
+
+void WebEngine::AddJavaScriptInterface( const std::string& exposedObjectName, const std::string& jsFunctionName, std::function< std::string(const std::string&) > cb )
+{
+}
+
+void WebEngine::RemoveJavascriptInterface( const std::string& exposedObjectName, const std::string& jsFunctionName )
+{
+}
+
+void WebEngine::ClearHistory()
+{
+ Internal::Adaptor::GetImplementation( *this ).ClearHistory();
+}
+
+void WebEngine::ClearCache()
+{
+}
+
+void WebEngine::SetSize( int width, int height )
+{
+}
+
+bool WebEngine::SendTouchEvent( const TouchData& touch )
+{
+ return true;
+}
+
+bool WebEngine::SendKeyEvent( const KeyEvent& event )
+{
+ return true;
+}
+
+Dali::WebEnginePlugin::WebEngineSignalType& WebEngine::PageLoadStartedSignal()
+{
+ return Internal::Adaptor::GetImplementation( *this ).PageLoadStartedSignal();
+}
+
+Dali::WebEnginePlugin::WebEngineSignalType& WebEngine::PageLoadFinishedSignal()
+{
+ return Internal::Adaptor::GetImplementation( *this ).PageLoadFinishedSignal();
+}
+
+} // namespace Dali;
+
test_return_value = TET_PASS;
}
+int UtcDaliLayouting_LayoutLength_Types(void)
+{
+ tet_infoline("UtcDaliLayouting_LayoutLength Types");
+
+ // testing that operators return correct type
+ // operator+
+ {
+ auto value = LayoutLength( 10 ) + LayoutLength();
+ DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
+ }
+ {
+ auto value = LayoutLength( 10 ) + 20;
+ DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
+ }
+ {
+ auto value = 22 + LayoutLength( 10 );
+ DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
+ }
+ {
+ auto value = LayoutLength( 10 ) + 2.1f;
+ DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
+ }
+ {
+ auto value = 2.2f + LayoutLength( 10 );
+ DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
+ }
+ // operator-
+ {
+ auto value = LayoutLength() - LayoutLength( 10 );
+ DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
+ }
+ {
+ auto value = LayoutLength( 10 ) - 99;
+ DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
+ }
+ {
+ auto value = 20 - LayoutLength( 10 );
+ DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
+ }
+ {
+ auto value = LayoutLength( 10 ) - 9.9f;
+ DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
+ }
+ {
+ auto value = 2.0f - LayoutLength( 10 );
+ DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
+ }
+
+ // operator*
+ {
+ auto value = LayoutLength() * LayoutLength( 10 );
+ DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
+ }
+ {
+ auto value = LayoutLength( 10 ) * 2;
+ DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
+ }
+ {
+ auto value = 10 * LayoutLength( 10 );
+ DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
+ }
+ {
+ auto value = LayoutLength( 10 ) * 2.1f;
+ DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
+ }
+ {
+ auto value = 1.0f * LayoutLength( 10 );
+ DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
+ }
+ // operator/
+ {
+ auto value = LayoutLength( 10 ) / 2.0f;
+ DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
+ }
+
+ // combinations
+ {
+ auto value = ( LayoutLength( 10 ) * 2.0f ) / 1.5f;
+ DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
+ }
+ {
+ auto value = 20 + ( LayoutLength( 10 ) * 2.0f ) / 1.5f;
+ DALI_TEST_EQUALS( typeid(value).name(), typeid(LayoutLength).name(), TEST_LOCATION );
+ }
+
+ END_TEST;
+}
+
+int UtcDaliLayouting_LayoutLength_Values(void)
+{
+ tet_infoline("UtcDaliLayouting_LayoutLength Values");
+
+ // operator+
+ {
+ LayoutLength value = LayoutLength( 10 ) + LayoutLength();
+ DALI_TEST_EQUALS( value.AsInteger(), 10.0f, 0.0001f, TEST_LOCATION );
+ }
+ {
+ LayoutLength value = LayoutLength( 10 ) + 20;
+ DALI_TEST_EQUALS( value.AsInteger(), 30.0f, 0.0001f, TEST_LOCATION );
+ }
+ {
+ LayoutLength value = 22 - LayoutLength( 10 );
+ DALI_TEST_EQUALS( value.AsInteger(), 12.0f, 0.0001f, TEST_LOCATION );
+ }
+ {
+ LayoutLength value = LayoutLength( 10 ) + 2.1f;
+ DALI_TEST_EQUALS( value.AsDecimal(), 12.1f, 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( value.AsTruncated(), 12.0f, 0.0001f, TEST_LOCATION );
+ }
+ {
+ LayoutLength value = 2.3f - LayoutLength( 10 );
+ DALI_TEST_EQUALS( value.AsDecimal(), -7.7f, 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( value.AsInteger(), -8.0f, 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( value.AsTruncated(), -7.0f, 0.0001f, TEST_LOCATION );
+ }
+ // operator-
+ {
+ LayoutLength value = LayoutLength() - LayoutLength( 10 );
+ DALI_TEST_EQUALS( value.AsInteger(), -10.0f, 0.0001f, TEST_LOCATION );
+ }
+ {
+ LayoutLength value = LayoutLength( 10 ) - 99;
+ DALI_TEST_EQUALS( value.AsInteger(), -89.0f, 0.0001f, TEST_LOCATION );
+ }
+ {
+ LayoutLength value = 20 - LayoutLength( 10 );
+ DALI_TEST_EQUALS( value.AsInteger(), 10.0f, 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( value.AsTruncated(), 10.f, 0.0001f, TEST_LOCATION );
+ }
+ {
+ LayoutLength value = LayoutLength( 10 ) - 9.9f;
+ DALI_TEST_EQUALS( value.AsInteger(), 0.0f, 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( value.AsDecimal(), 0.1f, 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( value.AsTruncated(), 0.0f, 0.0001f, TEST_LOCATION );
+ }
+ {
+ LayoutLength value = 10.9f - LayoutLength( 10 );
+ DALI_TEST_EQUALS( value.AsInteger(), 1.0f, 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( value.AsDecimal(), 0.9f, 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( value.AsTruncated(), 0.0f, 0.0001f, TEST_LOCATION );
+ }
+ // operator*
+ {
+ LayoutLength value = LayoutLength() * LayoutLength( 10 );
+ DALI_TEST_EQUALS( value.AsInteger(), 0.0f, 0.0001f, TEST_LOCATION );
+ }
+ {
+ LayoutLength value = LayoutLength(1) * 10;
+ DALI_TEST_EQUALS( value.AsInteger(), 10.0f, 0.0001f, TEST_LOCATION );
+ }
+ {
+ LayoutLength value = 11 * LayoutLength( 10 );
+ DALI_TEST_EQUALS( value.AsInteger(), 110.0f, 0.0001f, TEST_LOCATION );
+ }
+ {
+ LayoutLength value = LayoutLength( 10 ) * 2.12f;
+ DALI_TEST_EQUALS( value.AsDecimal(), 21.2f, 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( value.AsInteger(), 21.0f, 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( value.AsTruncated(), 21.0f, 0.0001f, TEST_LOCATION );
+ }
+ {
+ LayoutLength value = 2.189f * LayoutLength( 10 );
+ DALI_TEST_EQUALS( value.AsDecimal(), 21.89f, 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( value.AsInteger(), 22.0f, 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( value.AsTruncated(), 21.0f, 0.0001f, TEST_LOCATION );
+ }
+ // operator/
+ {
+ LayoutLength value = LayoutLength( 11 ) / 2.0f;
+ DALI_TEST_EQUALS( value.AsDecimal(), 5.5f, 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( value.AsInteger(), 6.0f, 0.0001f, TEST_LOCATION );
+ }
+
+ // combinations
+ {
+ LayoutLength value;
+ value = 20 + ( LayoutLength( 10 ) * 2.0f ) / 1.5f;
+ DALI_TEST_EQUALS( value.AsInteger(), 33.0f, 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( value.AsDecimal(), 33.3333f, 0.0001f, TEST_LOCATION );
+ }
+ {
+ uint16_t padding( 1 );
+ LayoutLength right(35), left(10), mTotalLength(2);
+ LayoutLength value;
+ value = padding + ( right - left - mTotalLength ) / 2.0f;
+ // = 1 + ( 35 - 10 - 2 ) / 2
+ DALI_TEST_EQUALS( value.AsInteger(), 13.0f, 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( value.AsDecimal(), 12.5f, 0.0001f, TEST_LOCATION );
+ }
+ {
+ uint16_t padding = 1, top = 2, bottom = 3;
+ LayoutLength childSpace( 44 ), childHeight( 23 );
+ LayoutLength value;
+ value = padding + ( ( childSpace - childHeight ) / 2.0f ) + top - bottom;
+ // = 1 + ( ( 44 - 23 ) / 2 ) + 2 - 3
+ DALI_TEST_EQUALS( value.AsInteger(), 11.0f, 0.0001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( value.AsDecimal(), 10.5f, 0.0001f, TEST_LOCATION );
+ }
+
+ END_TEST;
+}
+
+int UtcDaliLayouting_LayoutLength_Operators(void)
+{
+ tet_infoline("UtcDaliLayouting_LayoutLength operators");
+
+ {
+ LayoutLength value = 10;
+ DALI_TEST_EQUALS( (int)value.AsInteger(), 10, TEST_LOCATION );
+ value += 1;
+ DALI_TEST_EQUALS( (int)value.AsInteger(), 11, TEST_LOCATION );
+ value -= 12;
+ DALI_TEST_EQUALS( (int)value.AsInteger(), -1, TEST_LOCATION );
+ LayoutLength value2 = value;
+ DALI_TEST_EQUALS( value == value2, true, TEST_LOCATION );
+ value2 = 123;
+ DALI_TEST_EQUALS( value != value2, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( value < value2, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( value <= value2, true, TEST_LOCATION );
+ value = 456;
+ DALI_TEST_EQUALS( value > value2, true, TEST_LOCATION );
+ DALI_TEST_EQUALS( value >= value2, true, TEST_LOCATION );
+ }
+
+ {
+ LayoutLength value( 123 );
+ std::stringstream ss;
+ ss << value;
+ DALI_TEST_EQUALS( ss.str(), "123", TEST_LOCATION );
+ }
+ {
+ LayoutLength value( 0.123f );
+ std::stringstream ss;
+ ss << value;
+ DALI_TEST_EQUALS( ss.str(), "0.123", TEST_LOCATION );
+ }
+ END_TEST;
+}
+
int UtcDaliLayouting_HboxLayout01(void)
{
ToolkitTestApplication application;
--- /dev/null
+/*
+ * Copyright (c) 2018 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 <iostream>
+#include <stdlib.h>
+
+#include <dali-toolkit-test-suite-utils.h>
+#include "dali-toolkit-test-utils/toolkit-timer.h"
+
+#include <dali.h>
+#include <dali/integration-api/events/key-event-integ.h>
+#include <dali/integration-api/events/touch-event-integ.h>
+#include <dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h>
+#include <dali-toolkit/devel-api/controls/web-view/web-view.h>
+
+
+using namespace Dali;
+using namespace Toolkit;
+
+namespace
+{
+
+const char* const TEST_URL1( "http://www.somewhere.valid1.com" );
+const char* const TEST_URL2( "http://www.somewhere.valid2.com" );
+
+static int gPageLoadStartedCallbackCalled = 0;
+static int gPageLoadFinishedCallbackCalled = 0;
+static bool gTouched = false;
+
+struct CallbackFunctor
+{
+ CallbackFunctor(bool* callbackFlag)
+ : mCallbackFlag( callbackFlag )
+ {
+ }
+
+ void operator()()
+ {
+ *mCallbackFlag = true;
+ }
+ bool* mCallbackFlag;
+};
+
+static void OnPageLoadStarted( WebView view, const std::string& url )
+{
+ gPageLoadStartedCallbackCalled++;
+}
+
+static void OnPageLoadFinished( WebView view, const std::string& url )
+{
+ gPageLoadFinishedCallbackCalled++;
+}
+
+static bool OnTouched( Actor actor, const Dali::TouchData& touch )
+{
+ gTouched = true;
+ return true;
+}
+
+} // namespace
+
+void web_view_startup(void)
+{
+ test_return_value = TET_UNDEF;
+}
+
+void web_view_cleanup(void)
+{
+ test_return_value = TET_PASS;
+}
+
+int UtcDaliWebViewBasics(void)
+{
+ ToolkitTestApplication application;
+
+ // Copy and Assignment Test
+ tet_infoline( "UtcDaliWebViewBasic Copy and Assignment Test" );
+ WebView view = WebView::New();
+ DALI_TEST_CHECK( view );
+
+ WebView copy( view );
+ DALI_TEST_CHECK( view == copy );
+
+ WebView assign;
+ DALI_TEST_CHECK( !assign );
+
+ assign = copy;
+ DALI_TEST_CHECK( assign == view );
+
+
+ // DownCast Test
+ tet_infoline( "UtcDaliWebViewBasic DownCast Test" );
+ BaseHandle handle(view);
+
+ WebView view2 = WebView::DownCast( handle );
+ DALI_TEST_CHECK( view );
+ DALI_TEST_CHECK( view2 );
+ DALI_TEST_CHECK( view == view2 );
+
+
+ // TypeRegistry Test
+ tet_infoline( "UtcDaliWebViewBasic TypeRegistry Test" );
+ TypeRegistry typeRegistry = TypeRegistry::Get();
+ DALI_TEST_CHECK( typeRegistry );
+
+ TypeInfo typeInfo = typeRegistry.GetTypeInfo( "WebView" );
+ DALI_TEST_CHECK( typeInfo );
+
+ BaseHandle handle2 = typeInfo.CreateInstance();
+ DALI_TEST_CHECK( handle2 );
+
+ WebView view3 = WebView::DownCast( handle2 );
+ DALI_TEST_CHECK( view3 );
+
+ END_TEST;
+}
+
+int UtcDaliWebViewPageNavigation(void)
+{
+ ToolkitTestApplication application;
+
+ WebView view = WebView::New();
+ view.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ view.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ view.SetPosition( 0, 0 );
+ view.SetSize( 800, 600 );
+ Stage::GetCurrent().Add( view );
+ application.SendNotification();
+ application.Render();
+ DALI_TEST_CHECK( view );
+
+ ConnectionTracker* testTracker = new ConnectionTracker();
+ view.PageLoadStartedSignal().Connect( &OnPageLoadStarted );
+ view.PageLoadFinishedSignal().Connect( &OnPageLoadFinished );
+ bool signal1 = false;
+ bool signal2 = false;
+ bool signal3 = false;
+ view.ConnectSignal( testTracker, "pageLoadStarted", CallbackFunctor(&signal1) );
+ view.ConnectSignal( testTracker, "pageLoadFinished", CallbackFunctor(&signal2) );
+ view.ConnectSignal( testTracker, "invalidname", CallbackFunctor(&signal3) );
+ DALI_TEST_EQUALS( gPageLoadStartedCallbackCalled, 0, TEST_LOCATION );
+ DALI_TEST_EQUALS( gPageLoadFinishedCallbackCalled, 0, TEST_LOCATION );
+
+
+ view.LoadUrl( TEST_URL1 );
+ view.GetNaturalSize();
+ Test::EmitGlobalTimerSignal();
+ DALI_TEST_CHECK( view.GetUrl().find( TEST_URL1 ) != std::string::npos );
+ DALI_TEST_EQUALS( view.CanGoBack(), false, TEST_LOCATION );
+ DALI_TEST_EQUALS( gPageLoadStartedCallbackCalled, 1, TEST_LOCATION );
+ DALI_TEST_EQUALS( gPageLoadFinishedCallbackCalled, 1, TEST_LOCATION );
+ DALI_TEST_CHECK( signal1 & signal2 );
+ DALI_TEST_CHECK( !signal3 );
+
+ view.LoadUrl( TEST_URL2 );
+ view.SetSize( 400, 300 );
+ application.SendNotification();
+ application.Render();
+ Test::EmitGlobalTimerSignal();
+ DALI_TEST_CHECK( view.GetUrl().find( TEST_URL2 ) != std::string::npos );
+ DALI_TEST_EQUALS( view.CanGoBack(), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( view.CanGoForward(), false, TEST_LOCATION );
+ DALI_TEST_EQUALS( gPageLoadStartedCallbackCalled, 2, TEST_LOCATION );
+ DALI_TEST_EQUALS( gPageLoadFinishedCallbackCalled, 2, TEST_LOCATION );
+
+ view.GoBack();
+ Test::EmitGlobalTimerSignal();
+ DALI_TEST_CHECK( !view.CanGoBack() );
+ DALI_TEST_CHECK( view.CanGoForward() );
+
+ view.GoForward();
+ Test::EmitGlobalTimerSignal();
+ DALI_TEST_CHECK( view.CanGoBack() );
+ DALI_TEST_CHECK( !view.CanGoForward() );
+
+ view.Reload();
+ view.StopLoading();
+ view.ClearHistory();
+ view.ClearCache();
+ Test::EmitGlobalTimerSignal();
+ DALI_TEST_CHECK( !view.CanGoBack() );
+ DALI_TEST_CHECK( !view.CanGoForward() );
+
+ END_TEST;
+}
+
+int UtcDaliWebViewTouchAndKeys(void)
+{
+ ToolkitTestApplication application;
+
+ WebView view = WebView::New();
+ view.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ view.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ view.SetPosition( 0, 0 );
+ view.SetSize( 800, 600 );
+
+ Stage::GetCurrent().Add( view );
+ application.SendNotification();
+ application.Render();
+
+ view.GetNaturalSize();
+ view.TouchSignal().Connect( &OnTouched );
+
+ // Touch event
+ Dali::Integration::TouchEvent event;
+ Dali::Integration::Point pointDown, pointUp;
+
+ event = Dali::Integration::TouchEvent();
+ pointDown.SetState( PointState::DOWN );
+ pointDown.SetScreenPosition( Vector2( 10, 10 ) );
+ event.AddPoint( pointDown );
+ application.ProcessEvent( event );
+
+ event = Dali::Integration::TouchEvent();
+ pointUp.SetState( PointState::UP );
+ pointUp.SetScreenPosition( Vector2( 10, 10 ) );
+ event.AddPoint( pointUp );
+ application.ProcessEvent( event );
+
+ // Key event
+ Toolkit::KeyboardFocusManager::Get().SetCurrentFocusActor( view );
+ application.ProcessEvent( Integration::KeyEvent( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Down, "", "", Device::Class::NONE, Device::Subclass::NONE ) );
+ application.SendNotification();
+
+ DALI_TEST_CHECK( gTouched );
+ DALI_TEST_CHECK( view );
+
+ END_TEST;
+}
+
+int UtcDaliWebViewProperty1(void)
+{
+ ToolkitTestApplication application;
+
+ WebView view = WebView::New();
+ DALI_TEST_CHECK( view );
+
+ std::string local;
+ view.SetProperty( WebView::Property::URL, TEST_URL1 );
+ Property::Value val = view.GetProperty( WebView::Property::URL );
+ DALI_TEST_CHECK( val.Get( local ) );
+ DALI_TEST_EQUALS( local, TEST_URL1, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliWebViewMethodsForCoverage(void)
+{
+ ToolkitTestApplication application;
+
+ WebView view = WebView::New( "ko-KR", "Asia/Seoul" );
+
+ view.LoadHTMLString( "<body>Hello World!</body>" );
+ view.AddJavaScriptInterface( "jsObject", "jsFunction",
+ []( const std::string& arg ) -> std::string {
+ return arg + " World!";
+ }
+ );
+ view.EvaluateJavaScript( "jsObject.jsFunction('Hello')" );
+ view.RemoveJavascriptInterface( "jsObject", "jsFunction" );
+
+ DALI_TEST_CHECK( view );
+
+ END_TEST;
+}
develapipopupdir = $(develapicontrolsdir)/popup
develapishadowviewdir = $(develapicontrolsdir)/shadow-view
develapisuperblurviewdir = $(develapicontrolsdir)/super-blur-view
+develapiwebviewdir = $(develapicontrolsdir)/web-view
develapifocusmanagerdir = $(develapidir)/focus-manager
develapiimageloaderdir = $(develapidir)/image-loader
develapilayoutingdir = $(develapidir)/layouting
develapishadereffects_HEADERS = $(devel_api_shader_effects_header_files)
develapistyling_HEADERS = $(devel_api_styling_header_files)
develapisuperblurview_HEADERS = $(devel_api_super_blur_view_header_files)
+develapiwebview_HEADERS = $(devel_api_web_view_header_files)
develapitoolbar_HEADERS = $(devel_api_tool_bar_header_files)
develapitooltip_HEADERS = $(devel_api_tooltip_header_files)
develapitransitioneffects_HEADERS = $(devel_api_transition_effects_header_files)
--- /dev/null
+/*
+ * Copyright (c) 2018 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.
+ *
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/devel-api/controls/web-view/web-view.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/controls/web-view/web-view-impl.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+WebView::WebView()
+{
+}
+
+WebView::WebView( const WebView& WebView )
+: Control( WebView )
+{
+}
+
+WebView& WebView::operator=( const WebView& view )
+{
+ if( &view != this )
+ {
+ Control::operator=( view );
+ }
+
+ return *this;
+}
+
+WebView::~WebView()
+{
+}
+
+WebView WebView::New()
+{
+ return Internal::WebView::New();
+}
+
+WebView WebView::New( const std::string& locale, const std::string& timezoneId )
+{
+ return Internal::WebView::New( locale, timezoneId );
+}
+
+WebView WebView::DownCast( BaseHandle handle )
+{
+ return Control::DownCast< WebView, Internal::WebView >( handle );
+}
+
+void WebView::LoadUrl( const std::string& url )
+{
+ Dali::Toolkit::GetImpl( *this ).LoadUrl( url );
+}
+
+const std::string& WebView::GetUrl()
+{
+ return Dali::Toolkit::GetImpl( *this ).GetUrl();
+}
+
+void WebView::LoadHTMLString( const std::string& htmlString )
+{
+ Dali::Toolkit::GetImpl( *this ).LoadHTMLString( htmlString );
+}
+
+void WebView::Reload()
+{
+ Dali::Toolkit::GetImpl( *this ).Reload();
+}
+
+void WebView::StopLoading()
+{
+ Dali::Toolkit::GetImpl( *this ).StopLoading();
+}
+
+bool WebView::CanGoForward()
+{
+ return Dali::Toolkit::GetImpl( *this ).CanGoForward();
+}
+
+void WebView::GoForward()
+{
+ Dali::Toolkit::GetImpl( *this ).GoForward();
+}
+
+bool WebView::CanGoBack()
+{
+ return Dali::Toolkit::GetImpl( *this ).CanGoBack();
+}
+
+void WebView::GoBack()
+{
+ Dali::Toolkit::GetImpl( *this ).GoBack();
+}
+
+void WebView::EvaluateJavaScript( const std::string& script )
+{
+ Dali::Toolkit::GetImpl( *this ).EvaluateJavaScript( script );
+}
+
+void WebView::AddJavaScriptInterface( const std::string& exposedObjectName, const std::string& jsFunctionName, std::function< std::string(const std::string&) > callback )
+{
+ Dali::Toolkit::GetImpl( *this ).AddJavaScriptInterface( exposedObjectName, jsFunctionName, callback );
+}
+
+void WebView::RemoveJavascriptInterface( const std::string& exposedObjectName, const std::string& jsFunctionName )
+{
+ Dali::Toolkit::GetImpl( *this ).RemoveJavascriptInterface( exposedObjectName, jsFunctionName );
+}
+
+void WebView::ClearHistory()
+{
+ Dali::Toolkit::GetImpl( *this ).ClearHistory();
+}
+
+void WebView::ClearCache()
+{
+ Dali::Toolkit::GetImpl( *this ).ClearCache();
+}
+
+WebView::WebViewSignalType& WebView::PageLoadStartedSignal()
+{
+ return Dali::Toolkit::GetImpl( *this ).PageLoadStartedSignal();
+}
+
+WebView::WebViewSignalType& WebView::PageLoadFinishedSignal()
+{
+ return Dali::Toolkit::GetImpl( *this ).PageLoadFinishedSignal();
+}
+
+WebView::WebView( Internal::WebView& implementation )
+: Control( implementation )
+{
+}
+
+WebView::WebView( Dali::Internal::CustomActor* internal )
+: Control( internal )
+{
+ VerifyCustomActorPointer< Internal::WebView >( internal );
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_TOOLKIT_WEB_VIEW_H
+#define DALI_TOOLKIT_WEB_VIEW_H
+
+/*
+ * Copyright (c) 2018 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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <functional>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/controls/control.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal DALI_INTERNAL
+{
+ class WebView;
+} // namespace Internal
+
+/**
+ * @addtogroup dali_toolkit_controls_web_view
+ * @{
+ */
+
+/**
+ * @brief WebView is a control for displaying web content.
+ *
+ * This enables embedding web pages in the application.
+ *
+ * For working WebView, a web engine plugin for a platform should be provided.
+ *
+ */
+class DALI_TOOLKIT_API WebView : public Control
+{
+public:
+
+ /**
+ * @brief Enumeration for the start and end property ranges for this control.
+ */
+ enum PropertyRange
+ {
+ PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,
+ PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000,
+ };
+
+ /**
+ * @brief Enumeration for the instance of properties belonging to the WebView class.
+ */
+ struct Property
+ {
+ enum
+ {
+ /**
+ * @brief name "url", type string
+ *
+ * @details Sets the url to load
+ */
+ URL = PROPERTY_START_INDEX
+ };
+ };
+
+ typedef Signal< void ( WebView, const std::string& ) > WebViewSignalType;
+
+public:
+
+ /**
+ * @brief Creates an initialized WebView.
+ * @return A handle to a newly allocated Dali WebView
+ *
+ * @note WebView will not display anything
+ */
+ static WebView New();
+
+ /**
+ * @brief Creates an initialized WebView.
+ *
+ * @param [in] locale The locale of Web
+ * @param [in] timezoneId The timezoneId of Web
+ */
+ static WebView New( const std::string& locale, const std::string& timezoneId );
+
+ /**
+ * @brief Creates an uninitialized WebView.
+ */
+ WebView();
+
+ /**
+ * @brief Destructor.
+ *
+ * This is non-virtual since derived Handel types must not contain data or virtual methods.
+ */
+ ~WebView();
+
+ /*
+ * @brief Copy constructor.
+ *
+ * @param[in] WebView WebView to copy. The copied WebView will point at the same implementation
+ */
+ WebView( const WebView& WebView );
+
+ /**
+ * @brief Assignment operator.
+ *
+ * @param[in] WebView The WebView to assign from
+ * @return The updated WebView
+ */
+ WebView& operator=( const WebView& WebView );
+
+ /**
+ * @brief Downcasts a handle to WebView handle.
+ *
+ * If handle points to a WebView, the downcast produces valid handle.
+ * If not, the returned handle is left uninitialized.
+ *
+ * @param[in] handle Handle to an object
+ * @return Handle to a WebView or an uninitialized handle
+ */
+ static WebView DownCast( BaseHandle handle );
+
+ /**
+ * @brief Loads a web page based on a given URL.
+ *
+ * @param [in] url The URL of the resource to load
+ */
+ void LoadUrl( const std::string& url );
+
+ /**
+ * @brief Returns the URL of the Web.
+ *
+ * @return Url of string type
+ */
+ const std::string& GetUrl();
+
+ /**
+ * @brief Loads a given string as web contents.
+ *
+ * @param [in] htmlString The string to use as the contents of the web page
+ */
+ void LoadHTMLString( const std::string& htmlString );
+
+ /**
+ * @brief Reloads the Web.
+ */
+ void Reload();
+
+ /**
+ * @brief Stops loading web contents on the current page.
+ */
+ void StopLoading();
+
+ /**
+ * @brief Returns whether forward is possible.
+ *
+ * @return True if forward is possible, false otherwise
+ */
+ bool CanGoForward();
+
+ /**
+ * @brief Goes forward in the navigation history.
+ */
+ void GoForward();
+
+ /**
+ * @brief Returns whether backward is possible.
+ *
+ * @return True if backward is possible, false otherwise
+ */
+ bool CanGoBack();
+
+ /**
+ * @brief Goes back in the navigation history.
+ */
+ void GoBack();
+
+ /**
+ * @brief Evaluates JavaScript code represented as a string.
+ *
+ * @param[in] script The JavaScript code
+ */
+ void EvaluateJavaScript( const std::string& script );
+
+ /**
+ * @brief Adds a JavaScript interface.
+ *
+ * @param[in] exposedObjectName The name of exposed object
+ * @param[in] jsFunctionName The name of JavaScript function
+ * @param[in] callback The callback function
+ */
+ void AddJavaScriptInterface( const std::string& exposedObjectName, const std::string& jsFunctionName, std::function< std::string(const std::string&) > callback );
+
+ /**
+ * @brief Removes a JavaScript interface.
+ *
+ * @param[in] exposedObjectName The name of exposed object
+ * @param[in] jsFunctionName The name of JavaScript function
+ */
+ void RemoveJavascriptInterface( const std::string& exposedObjectName, const std::string& jsFunctionName );
+
+ /**
+ * @brief Clears the history of Web.
+ */
+ void ClearHistory();
+
+ /**
+ * @brief Clears the cache of Web.
+ */
+ void ClearCache();
+
+ /**
+ * @brief Connects to this signal to be notified when page loading is started.
+ *
+ * @return A signal object to connect with
+ */
+ WebViewSignalType& PageLoadStartedSignal();
+
+ /**
+ * @brief Connects to this signal to be notified when page loading is finished.
+ *
+ * @return A signal object to connect with
+ */
+ WebViewSignalType& PageLoadFinishedSignal();
+
+public: // Not intended for application developers
+
+ /// @cond internal
+ /**
+ * @brief Creates a handle using the Toolkit::Internal implementation.
+ *
+ * @param[in] implementation The WebView implementation
+ */
+ DALI_INTERNAL WebView( Internal::WebView& implementation );
+
+ /**
+ * @brief Allows the creation of this WebView from an Internal::CustomActor pointer.
+ *
+ * @param[in] internal A pointer to the internal CustomActor
+ */
+ explicit DALI_INTERNAL WebView( Dali::Internal::CustomActor* internal );
+ /// @endcond
+
+};
+
+/**
+ * @}
+ */
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_WEB_VIEW_H
$(devel_api_src_dir)/controls/text-controls/text-selection-popup.cpp \
$(devel_api_src_dir)/controls/text-controls/text-selection-toolbar.cpp \
$(devel_api_src_dir)/controls/tool-bar/tool-bar.cpp \
+ $(devel_api_src_dir)/controls/web-view/web-view.cpp \
$(devel_api_src_dir)/focus-manager/keyinput-focus-manager.cpp \
$(devel_api_src_dir)/focus-manager/keyboard-focus-manager-devel.cpp \
$(devel_api_src_dir)/image-loader/async-image-loader-devel.cpp \
devel_api_gaussian_blur_view_header_files = \
$(devel_api_src_dir)/controls/gaussian-blur-view/gaussian-blur-view.h
+
+devel_api_web_view_header_files = \
+ $(devel_api_src_dir)/controls/web-view/web-view.h
void LayoutGroup::OnSetChildProperties( Handle& handle, Property::Index index, Property::Value value )
{
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::OnSetChildProperties property(%s)\n", handle.GetPropertyName(index).c_str());
+ DALI_LOG_STREAM( gLogFilter, Debug::Verbose, "LayoutGroup::OnSetChildProperties property(" << handle.GetPropertyName(index) << ")\n" );
if ( ( ( index >= CHILD_PROPERTY_REGISTRATION_START_INDEX ) &&
( index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX ) )
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::MeasureChildWithMargins desiredWidth(%d)\n", desiredWidth );
MeasureSpec childWidthMeasureSpec = GetChildMeasureSpec( parentWidthMeasureSpec,
- padding.start + padding.end +
+ LayoutLength( padding.start + padding.end ) +
widthUsed, desiredWidth );
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::MeasureChildWithMargins desiredHeight(%d)\n", desiredHeight );
MeasureSpec childHeightMeasureSpec = GetChildMeasureSpec( parentHeightMeasureSpec,
- padding.top + padding.bottom +
+ LayoutLength( padding.top + padding.bottom )+
heightUsed, desiredHeight );
child->Measure( childWidthMeasureSpec, childHeightMeasureSpec );
auto specMode = measureSpec.GetMode();
LayoutLength specSize = measureSpec.GetSize();
- auto size = std::max( LayoutLength(0), specSize - padding ); // reduce available size by the owners padding
+ LayoutLength size = std::max( LayoutLength(0), specSize - padding ); // reduce available size by the owners padding
- MeasureSpec::IntType resultSize = 0;
+ LayoutLength resultSize = 0;
MeasureSpec::Mode resultMode = MeasureSpec::Mode::UNSPECIFIED;
switch( specMode )
}
}
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::GetChildMeasureSpec resultSize(%u)\n", resultSize );
-
+ DALI_LOG_STREAM( gLogFilter, Debug::Verbose, "LayoutGroup::GetChildMeasureSpec resultSize(" << resultSize << ")\n" );
//noinspection ResourceType
return MeasureSpec( resultSize, resultMode );
}
childLayout->SetAnimateLayout( IsLayoutAnimated() ); // @todo this essentially forces animation inheritance. Bad?
- DALI_LOG_STREAM( gLogFilter, Debug::Verbose, "LayoutGroup::ChildAddedToOwner control:" << control.GetName().c_str() <<
- " desiredWidth: " << control.GetNaturalSize().width <<
- " desiredHeight:" << control.GetNaturalSize().height
- );
+ DALI_LOG_STREAM( gLogFilter, Debug::Verbose, "LayoutGroup::ChildAddedToOwner control:" << control.GetName() <<
+ " desiredWidth: " << control.GetNaturalSize().width << " desiredHeight:" << control.GetNaturalSize().height );
childControlDataImpl.SetLayout( *childLayout.Get() );
// Get size of child
MeasureChild( childLayout, widthMeasureSpec, heightMeasureSpec );
- auto childWidth = childLayout->GetMeasuredWidth();
- auto childHeight = childLayout->GetMeasuredHeight();
- auto childMargin = childLayout->GetMargin();
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::OnMeasure child width[%d] height(%d)\n", childWidth.mValue, childHeight.mValue );
+ LayoutLength childWidth = childLayout->GetMeasuredWidth();
+ LayoutLength childHeight = childLayout->GetMeasuredHeight();
+ Extents childMargin = childLayout->GetMargin();
+ DALI_LOG_STREAM( gLogFilter, Debug::Verbose, "LayoutGroup::OnMeasure child width[" << childWidth << "] height[" << childHeight << "]\n" );
layoutWidth = std::max( layoutWidth, childWidth + childMargin.start + childMargin.end );
layoutHeight = std::max( layoutHeight, childHeight + childMargin.top + childMargin.bottom );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutGroup::OnMeasure calculated child width[%d] calculated height(%d)\n", layoutWidth.mValue, layoutHeight.mValue );
+ DALI_LOG_STREAM( gLogFilter, Debug::Verbose, "LayoutGroup::OnMeasure calculated child width[" << layoutWidth << "] height[" << layoutHeight << "]\n" );
}
else
{
layoutHeight = heightSpecSize;
}
- DALI_LOG_INFO( gLogFilter, Debug::General, "LayoutGroup::OnMeasure Measured size(%d,%d) for : %s \n", layoutWidth.mValue, layoutHeight.mValue, Actor::DownCast(GetOwner()).GetName().c_str() );
+ DALI_LOG_STREAM( gLogFilter, Debug::General, "LayoutGroup::OnMeasure Measured size(" << layoutWidth << "," << layoutHeight << ") for : " << Actor::DownCast(GetOwner()).GetName() << " \n" );
SetMeasuredDimensions( MeasuredSize( layoutWidth ), MeasuredSize( layoutHeight ) );
}
{
auto childOwner = childLayout->GetOwner();
- auto childWidth = childLayout->GetMeasuredWidth();
- auto childHeight = childLayout->GetMeasuredHeight();
- auto childMargin = childLayout->GetMargin();
+ LayoutLength childWidth = childLayout->GetMeasuredWidth();
+ LayoutLength childHeight = childLayout->GetMeasuredHeight();
+ Extents childMargin = childLayout->GetMargin();
auto control = Toolkit::Control::DownCast( childOwner );
Extents padding = GetPadding();
auto childPosition = control.GetProperty< Vector3 >( Actor::Property::POSITION );
auto anchorPoint = control.GetProperty< Vector3 >( Actor::Property::ANCHOR_POINT );
- DALI_LOG_INFO( gLogFilter, Debug::General, "LayoutGroup::OnLayout child[%s] position(%f,%f) child width[%d] height(%d)\n",
- control.GetName().c_str(),
- childPosition.x, childPosition.y,
- childWidth.mValue, childHeight.mValue
- );
+ DALI_LOG_STREAM( gLogFilter, Debug::General, "LayoutGroup::OnLayout child[" << control.GetName() <<
+ "] position(" << childPosition << ") child width[" << childWidth << "] height[" << childHeight << "]\n" );
// Margin and Padding only supported when child anchor point is TOP_LEFT.
int paddingAndMarginOffsetX = ( AnchorPoint::TOP_LEFT == anchorPoint ) ? ( padding.top + childMargin.top ) : 0;
void LayoutItem::SetMeasuredDimensions( MeasuredSize measuredWidth, MeasuredSize measuredHeight )
{
- DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::SetMeasuredDimensions width(%d) height(%d) \n",
- MeasureSpec::IntType( measuredWidth.GetSize() ),
- MeasureSpec::IntType( measuredHeight.GetSize() )
- );
+ DALI_LOG_STREAM( gLayoutFilter, Debug::Verbose, "LayoutItem::SetMeasuredDimensions width(" << measuredWidth.GetSize() << ") height(" << measuredHeight.GetSize() << ") \n" );
mImpl->SetPrivateFlag( Impl::PRIVATE_FLAG_MEASURED_DIMENSION_SET );
mImpl->mMeasuredWidth = measuredWidth;
auto actor = Actor::DownCast(owner);
auto naturalSize = actor ? actor.GetNaturalSize() : Vector3::ZERO;
- return std::max( mImpl->mMinimumSize.GetWidth(), LayoutLength::IntType( naturalSize.width ) );
+ return std::max( mImpl->mMinimumSize.GetWidth(), LayoutLength( naturalSize.width ) );
}
LayoutLength LayoutItem::GetSuggestedMinimumHeight() const
auto actor = Actor::DownCast(owner);
auto naturalSize = actor ? actor.GetNaturalSize() : Vector3::ZERO;
- return std::max( mImpl->mMinimumSize.GetHeight(), LayoutLength::IntType(naturalSize.height) );
+ return std::max( mImpl->mMinimumSize.GetHeight(), LayoutLength( naturalSize.height ) );
}
MeasuredSize LayoutItem::ResolveSizeAndState( LayoutLength size, MeasureSpec measureSpec, MeasuredSize::State childMeasuredState )
{
bool changed = false;
- DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::SetFrame enter(%d, %d, %d, %d)\n", left.mValue, top.mValue, right.mValue, bottom.mValue );
+ DALI_LOG_STREAM( gLayoutFilter, Debug::Verbose, "LayoutItem::SetFrame enter(" << left << ", " << top << ", " << right << ", " << bottom << ")\n" );
if( mImpl->mLeft != left || mImpl->mRight != right || mImpl->mTop != top || mImpl->mBottom != bottom || !mImpl->GetPrivateFlag( Impl::PRIVATE_FLAG_FORCE_SET_FRAME ) )
{
changed = true;
- auto oldWidth = mImpl->mRight - mImpl->mLeft;
- auto oldHeight = mImpl->mBottom - mImpl->mTop;
- auto newWidth = right - left;
- auto newHeight = bottom - top;
+ LayoutLength oldWidth = mImpl->mRight - mImpl->mLeft;
+ LayoutLength oldHeight = mImpl->mBottom - mImpl->mTop;
+ LayoutLength newWidth = right - left;
+ LayoutLength newHeight = bottom - top;
bool sizeChanged = (newWidth != oldWidth) || (newHeight != oldHeight);
mImpl->mLeft = left;
auto actor = Actor::DownCast(owner);
if( actor )
{
- DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::SetFrame owner(%s) (%d, %d, %d, %d)\n", actor.GetName().c_str(),
- left.mValue, top.mValue, right.mValue, bottom.mValue );
+ DALI_LOG_STREAM( gLayoutFilter, Debug::Verbose, "LayoutItem::SetFrame owner(" << left << ", " << top << ", " << right << ", " << bottom << ")\n" );
+
if( mImpl->mAnimated )
{
auto animation = Animation::New( 0.5f );
- animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), float( left.mValue ) );
- animation.AnimateTo( Property( actor, Actor::Property::POSITION_Y ), float( top.mValue ) );
+ animation.AnimateTo( Property( actor, Actor::Property::POSITION_X ), left.AsInteger() );
+ animation.AnimateTo( Property( actor, Actor::Property::POSITION_Y ), top.AsInteger() );
- animation.AnimateTo( Property( actor, Actor::Property::SIZE_WIDTH ), float( newWidth ) );
- animation.AnimateTo( Property( actor, Actor::Property::SIZE_HEIGHT ), float( newHeight ) );
+ animation.AnimateTo( Property( actor, Actor::Property::SIZE_WIDTH ), newWidth.AsInteger() );
+ animation.AnimateTo( Property( actor, Actor::Property::SIZE_HEIGHT ), newHeight.AsInteger() );
animation.FinishedSignal().Connect( mSlotDelegate, &LayoutItem::OnLayoutAnimationFinished );
animation.Play();
else
{
// @todo Collate into list of Property & Property::Value pairs.
- actor.SetX( float( left.mValue ) );
- actor.SetY( float( top.mValue ) );
- actor.SetProperty( Actor::Property::SIZE_WIDTH, float( newWidth ) );
- actor.SetProperty( Actor::Property::SIZE_HEIGHT, float( newHeight ) );
+ actor.SetX( left.AsInteger() );
+ actor.SetY( top.AsInteger() );
+ actor.SetProperty( Actor::Property::SIZE_WIDTH, newWidth.AsInteger() );
+ actor.SetProperty( Actor::Property::SIZE_HEIGHT, newHeight.AsInteger() );
}
}
}
}
- DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::SetFrame exit(%d, %d, %d, %d)\n", left.mValue, top.mValue, right.mValue, bottom.mValue );
+ DALI_LOG_STREAM( gLayoutFilter, Debug::Verbose, "LayoutItem::SetFrame exit(" << left << ", " << top << ", " << right << ", " << bottom << ")\n" );
return changed;
}
auto actor = Actor::DownCast(owner);
if( actor )
{
- actor.SetSize( Vector3( mImpl->mRight-mImpl->mLeft, mImpl->mBottom-mImpl->mTop, 0.0f ) );
+ actor.SetSize( Vector3( mImpl->mRight.AsInteger() - mImpl->mLeft.AsInteger(), mImpl->mBottom.AsInteger() - mImpl->mTop.AsInteger(), 0.0f ) );
}
}
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
+// EXTERNAL INCLUDES
#include <cstdint>
+#include <cmath>
#include <iostream>
namespace Dali
{
+
namespace Toolkit
{
/**
* @brief A type that represents a layout length.
*
- * Currently, this implies pixels, but could be extended to handle device dependant sizes, etc.
+ * Currently, this implies pixels, but could be extended to handle device dependent sizes, etc.
*/
class LayoutLength
{
public:
- using IntType = int;
- LayoutLength( IntType value )
+ /**
+ * @brief default constructor, initialises to 0
+ */
+ LayoutLength()
+ : mValue( 0 )
+ {
+ }
+
+ /**
+ * @brief constructor
+ *
+ * @param value the value to initialise with
+ */
+ LayoutLength( int value )
: mValue( value )
{
}
+ /**
+ * @brief constructor from float
+ *
+ * @param value the value to initialise with
+ */
+ LayoutLength( float value )
+ : mValue( value )
+ {
+ }
+
+ /**
+ * @brief constructor
+ *
+ * @param layoutLength the value to initialise with
+ */
LayoutLength( const LayoutLength& layoutLength )
: mValue( layoutLength.mValue )
{
}
- LayoutLength& operator=(const LayoutLength& rhs)
+ /**
+ * @brief assignment operator
+ *
+ * @param rhs LayoutLength to assign
+ * @return reference to itself
+ */
+ LayoutLength& operator=( const LayoutLength& rhs )
{
if( this != &rhs )
{
return *this;
}
- bool operator==( const LayoutLength& rhs )
+ /**
+ * @brief assignment operator from int
+ *
+ * @param value the value to assign
+ * @return reference to itself
+ */
+ LayoutLength& operator=( int value )
{
- return mValue == rhs.mValue;
+ mValue = value;
+ return *this;
}
- bool operator==( LayoutLength::IntType rhs )
+ /**
+ * @brief assignment operator from float
+ *
+ * @param value the value to assign
+ * @return reference to itself
+ */
+ LayoutLength& operator=( float value )
{
- return mValue == rhs;
+ mValue = value;
+ return *this;
}
- bool operator!=( const LayoutLength& rhs )
+ /**
+ * @brief plus equals operator
+ *
+ * @param rhs to add to this
+ * @return reference to itself
+ */
+ LayoutLength& operator+=( LayoutLength rhs )
{
- return !operator==(rhs);
+ mValue += rhs.mValue;
+ return *this;
}
- bool operator<( const LayoutLength& rhs )
+ /**
+ * @brief minus equals operator
+ *
+ * @param rhs to subtract from this
+ * @return reference to itself
+ */
+ LayoutLength& operator-=( LayoutLength rhs )
{
- return mValue < rhs.mValue;
+ mValue -= rhs.mValue;
+ return *this;
}
- bool operator<( const LayoutLength rhs ) const
+ /**
+ * @brief return value as decimal value (full raw value)
+ *
+ * @return the LayoutLength as full decimal value
+ */
+ float AsDecimal() const
{
- return mValue < rhs.mValue;
+ return mValue;
}
- bool operator<=( const LayoutLength& rhs )
+ /**
+ * @brief return value as rounded integer value (whole number)
+ *
+ * @return the LayoutLength rounded to next integer value
+ */
+ float AsInteger() const
{
- return mValue <= rhs.mValue;
- }
- bool operator<=( LayoutLength rhs )
- {
- return mValue <= rhs.mValue;
- }
- bool operator>( const LayoutLength& rhs )
- {
- return mValue > rhs.mValue;
- }
- bool operator>( LayoutLength rhs )
- {
- return mValue > rhs.mValue;
- }
- bool operator>=( const LayoutLength& rhs )
- {
- return mValue >= rhs.mValue;
- }
- bool operator>=( LayoutLength rhs )
- {
- return mValue >= rhs.mValue;
+ return round( mValue );
}
- LayoutLength operator+( const LayoutLength& rhs )
+ /**
+ * @brief return value as truncated integral value (whole number)
+ *
+ * @return the LayoutLength rounded to next integral value
+ */
+ float AsTruncated() const
{
- return mValue + rhs.mValue;
+ return trunc( mValue );
}
- LayoutLength operator+( LayoutLength::IntType rhs )
- {
- return mValue + rhs;
- }
+private:
- LayoutLength operator-( const LayoutLength& rhs )
- {
- return mValue - rhs.mValue;
- }
- LayoutLength operator-( LayoutLength::IntType rhs )
- {
- return mValue - rhs;
- }
+ float mValue;
- LayoutLength& operator+=( const LayoutLength& rhs )
- {
- mValue += rhs.mValue;
- return *this;
- }
- LayoutLength& operator+=( LayoutLength::IntType rhs )
- {
- mValue += rhs;
- return *this;
- }
+};
- LayoutLength& operator-=( const LayoutLength& rhs )
- {
- mValue -= rhs.mValue;
- return *this;
- }
+/**
+ * @brief equal to operator
+ *
+ * @param lhs value to compare
+ * @param rhs value to compare against
+ * @note Using value instead of reference to allow conversions from int and float
+ * @return true if identical, false otherwise
+ */
+inline bool operator==( LayoutLength lhs, LayoutLength rhs )
+{
+ return lhs.AsDecimal() == rhs.AsDecimal();
+}
- LayoutLength& operator-=( LayoutLength::IntType rhs )
- {
- mValue -= rhs;
- return *this;
- }
+/**
+ * @brief not equal to operator
+ *
+ * @param lhs value to compare
+ * @param rhs value to compare against
+ * @note Using value instead of reference to allow conversions from int and float
+ * @return true if value is not identical, false otherwise
+ */
+inline bool operator!=( LayoutLength lhs, LayoutLength rhs )
+{
+ return !operator==( lhs, rhs );
+}
- LayoutLength operator/( const LayoutLength& rhs )
- {
- return mValue / rhs.mValue;
- }
- LayoutLength operator/( LayoutLength::IntType rhs )
- {
- return mValue / rhs;
- }
+/**
+ * @brief less than operator
+ *
+ * @param lhs value to compare
+ * @param rhs value to compare against
+ * @note Using value instead of reference to allow conversions from int and float
+ * @return true if lhs value is less, false otherwise
+ */
+inline bool operator<( LayoutLength lhs, LayoutLength rhs )
+{
+ return lhs.AsDecimal() < rhs.AsDecimal();
+}
- LayoutLength operator*( const LayoutLength& rhs )
- {
- return mValue * rhs.mValue;
- }
- LayoutLength operator*( LayoutLength::IntType rhs )
- {
- return mValue * rhs;
- }
- LayoutLength operator*( float rhs )
- {
- return LayoutLength(LayoutLength::IntType(float(mValue) * rhs));
- }
+/**
+ * @brief greater than operator
+ *
+ * @param lhs value to compare
+ * @param rhs value to compare against
+ * @note Using value instead of reference to allow conversions from int and float
+ * @return true if lhs value is greater, false otherwise
+ */
+inline bool operator>( LayoutLength lhs, LayoutLength rhs )
+{
+ return rhs < lhs;
+}
- operator float()
- {
- return float( mValue );
- }
+/**
+ * @brief less than or equal to operator
+ *
+ * @param lhs value to compare
+ * @param rhs value to compare against
+ * @note Using value instead of reference to allow conversions from int and float
+ * @return true if lhs value is less than or equal to, false otherwise
+ */
+inline bool operator<=( LayoutLength lhs, LayoutLength rhs )
+{
+ return !(lhs > rhs);
+}
- IntType mValue;
-};
+/**
+ * @brief greater than or equal to operator
+ *
+ * @param lhs value to compare
+ * @param rhs value to compare against
+ * @note Using value instead of reference to allow conversions from int and float
+ * @return true if lhs value is greater than or equal to, false otherwise
+ */
+inline bool operator>=( LayoutLength lhs, LayoutLength rhs )
+{
+ return !(lhs < rhs);
+}
+
+/**
+ * @brief add two LayoutLengths
+ *
+ * @param lhs The LayoutLength to add
+ * @param rhs The LayoutLength to add
+ * @note Using value instead of reference to allow conversions from int and float
+ * @return the resulting LayoutLength
+ */
+inline LayoutLength operator+( LayoutLength lhs, LayoutLength rhs )
+{
+ return lhs.AsDecimal() + rhs.AsDecimal();
+}
+
+/**
+ * @brief subtract two LayoutLengths
+ *
+ * @param lhs The LayoutLength to subtract from
+ * @param rhs The LayoutLength to subtract
+ * @note Using value instead of reference to allow conversions from int and float
+ * @return the resulting LayoutLength
+ */
+inline LayoutLength operator-( LayoutLength lhs, LayoutLength rhs )
+{
+ return lhs.AsDecimal() - rhs.AsDecimal();
+}
+
+/**
+ * @brief multiply two LayoutLengths
+ *
+ * @param lhs The LayoutLength to multiply
+ * @param rhs The LayoutLength to multiply
+ * @note Using value instead of reference to allow conversions from int and float
+ * @return the resulting LayoutLength
+ */
+inline LayoutLength operator*( LayoutLength lhs, LayoutLength rhs )
+{
+ return lhs.AsDecimal() * rhs.AsDecimal();
+}
+
+/**
+ * @brief divide LayoutLength by a LayoutLength
+ *
+ * @param lhs The LayoutLength to divide
+ * @param rhs The LayoutLength to divide by
+ * @note Using value instead of reference to allow conversions from int and float
+ * @return the resulting value as float
+ */
+inline LayoutLength operator/( LayoutLength lhs, LayoutLength rhs )
+{
+ return lhs.AsDecimal() / rhs.AsDecimal();
+}
/**
* @brief Prints a LayoutLength
*/
inline std::ostream& operator<<( std::ostream& o, const LayoutLength& layoutLength )
{
- return o<<layoutLength.mValue;
+ return o << layoutLength.AsDecimal();
}
} // namespace Toolkit
{
public:
LayoutSize()
- : x(0u),
- y(0u)
+ : x( 0 ),
+ y( 0 )
{
}
- LayoutSize( LayoutLength::IntType anX, LayoutLength::IntType aY )
+ LayoutSize( LayoutLength anX, LayoutLength aY )
: x( anX ),
y( aY )
{
return *this;
}
- LayoutLength::IntType GetWidth()
+ void SetWidth( LayoutLength value )
{
- return width;
+ width = value;
}
- LayoutLength::IntType GetHeight()
+ LayoutLength GetWidth()
{
- return height;
+ return width;
}
- void SetWidth(LayoutLength::IntType value)
- {
- width=value;
- }
- void SetHeight(LayoutLength::IntType value)
+ void SetHeight( LayoutLength value )
{
- height=value;
+ height = value;
}
- void SetWidth(LayoutLength value)
- {
- width=value.mValue;
- }
- void SetHeight(LayoutLength value)
+
+ LayoutLength GetHeight()
{
- height=value.mValue;
+ return height;
}
bool operator==( const LayoutSize& rhs )
union
{
- LayoutLength::IntType x;
- LayoutLength::IntType width;
+ LayoutLength x;
+ LayoutLength width;
};
union
{
- LayoutLength::IntType y;
- LayoutLength::IntType height;
+ LayoutLength y;
+ LayoutLength height;
};
};
* limitations under the License.
*/
+// EXTERNAL INCLUDES
+#include <sstream>
#include <dali/public-api/common/dali-common.h>
+
+// INTERNAL INCLUDES
#include <dali-toolkit/devel-api/layouting/layout-length.h>
#include <dali-toolkit/public-api/dali-toolkit-common.h>
-#include <sstream>
-
namespace Dali
{
namespace Toolkit
class DALI_TOOLKIT_API MeasureSpec
{
public:
- using IntType = LayoutLength::IntType;
enum class Mode
{
};
MeasureSpec( LayoutLength measureSpec, MeasureSpec::Mode mode )
- : mSize( measureSpec.mValue ),
+ : mSize( measureSpec ),
mMode( mode )
{
}
- MeasureSpec( IntType measureSpec )
+ MeasureSpec( LayoutLength measureSpec )
: mSize( measureSpec ),
mMode( Mode::UNSPECIFIED )
{
}
/**
+ * @brief Set the mode of the measure spec.
+ *
+ * @param mode The mode to set
+ */
+ void SetMode( MeasureSpec::Mode mode )
+ {
+ mMode = mode;
+ }
+
+ /**
* @brief Get the mode of the measure spec.
*
* @return The mode of the measure spec
}
/**
+ * @brief Set the size of the measure spec
+ *
+ * @param size the size to set
+ */
+ void SetSize( LayoutLength size )
+ {
+ mSize = size;
+ }
+
+ /**
* @brief Get the size of the measure spec
*
* @return the size of the measure spec
*/
- IntType GetSize() const
+ LayoutLength GetSize() const
{
return mSize;
}
return MeasureSpec( size, MeasureSpec::Mode::UNSPECIFIED );
}
- if( delta < 0 && measureSpec.mSize < static_cast<IntType>(abs(delta)) )
+ if( delta < 0 && measureSpec.mSize < abs(delta) )
{
size = 0;
}
return MeasureSpec( size, mode );
}
-public:
- IntType mSize; ///< The specified size
+private:
+
+ LayoutLength mSize; ///< The specified size
Mode mMode; ///< The measure mode
+
};
inline std::ostream& operator<< (std::ostream& o, const MeasureSpec& measureSpec )
};
MeasuredSize()
- : mMeasuredSize( 0u ),
+ : mMeasuredSize( 0 ),
mState ( MeasuredSize::State::MEASURED_SIZE_OK )
{
}
return *this;
}
- MeasuredSize& operator=( LayoutLength::IntType rhs )
+ MeasuredSize& operator=( LayoutLength rhs )
{
this->mMeasuredSize = rhs;
this->mState = State::MEASURED_SIZE_OK;
return mMeasuredSize != value.mMeasuredSize;
}
- inline operator LayoutLength::IntType()
- {
- return mMeasuredSize.mValue;
- }
-
inline void SetState( MeasuredSize::State state )
{
mState = state;
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
Add( ColorVisual::Property::MIX_COLOR, Color::TRANSPARENT ) );
// Enable the clipping property.
- mStencil.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
+ mStencil.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
mStencil.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
self.Add( mStencil );
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
Add( ColorVisual::Property::MIX_COLOR, Color::TRANSPARENT ) );
// Enable the clipping property.
- mStencil.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
+ mStencil.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX );
mStencil.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
Self().Add( mStencil );
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
Actor self = Self();
self.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS );
self.SetProperty( Actor::Property::COLOR_ALPHA, 0.0f );
-
- // The Popup Control background is a nine-patch image. We clip against this so the
- // contents are correctly clipped against the edges of the nine-patch.
- self.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
}
void TextSelectionPopup::HideAnimationFinished( Animation& animation )
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
mScrollView.SetAxisAutoLock( true );
mScrollView.ScrollStartedSignal().Connect( this, &TextSelectionToolbar::OnScrollStarted );
mScrollView.ScrollCompletedSignal().Connect( this, &TextSelectionToolbar::OnScrollCompleted );
+ mScrollView.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_TO_BOUNDING_BOX ); // In a new layer, so clip to scroll-view's bounding box
mRulerX = new DefaultRuler(); // IntrusivePtr which is unreferenced when ScrollView is destroyed.
--- /dev/null
+/*
+ * Copyright (c) 2018 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.
+ *
+ */
+
+// CLASS HEADER
+#include "web-view-impl.h"
+
+// EXTERNAL INCLUDES
+#include <cstring>
+#include <dali/public-api/common/stage.h>
+#include <dali/public-api/images/native-image.h>
+#include <dali/public-api/adaptor-framework/native-image-source.h>
+#include <dali/public-api/object/type-registry.h>
+#include <dali/public-api/object/type-registry-helper.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/controls/control-devel.h>
+#include <dali-toolkit/internal/visuals/visual-factory-impl.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+namespace
+{
+
+BaseHandle Create()
+{
+ return Toolkit::WebView::New();
+}
+
+DALI_TYPE_REGISTRATION_BEGIN( Toolkit::WebView, Toolkit::Control, Create );
+
+DALI_PROPERTY_REGISTRATION( Toolkit, WebView, "url", STRING, URL );
+
+DALI_SIGNAL_REGISTRATION( Toolkit, WebView, "pageLoadStarted", PAGE_LOAD_STARTED_SIGNAL );
+DALI_SIGNAL_REGISTRATION( Toolkit, WebView, "pageLoadFinished", PAGE_LOAD_FINISHED_SIGNAL );
+
+DALI_TYPE_REGISTRATION_END()
+
+} // anonymous namepsace
+
+WebView::WebView( const std::string& locale, const std::string& timezoneId )
+: Control( ControlBehaviour( ACTOR_BEHAVIOUR_DEFAULT | DISABLE_STYLE_CHANGE_SIGNALS ) ),
+ mUrl(),
+ mWebViewSize( Stage::GetCurrent().GetSize() )
+{
+ mWebEngine = Dali::WebEngine::New();
+ if ( mWebEngine )
+ {
+ mWebEngine.Create( mWebViewSize.width, mWebViewSize.height, locale, timezoneId );
+ }
+}
+
+WebView::WebView()
+: WebView( "", "" )
+{
+}
+
+WebView::~WebView()
+{
+}
+
+Toolkit::WebView WebView::New()
+{
+ WebView* impl = new WebView();
+ Toolkit::WebView handle = Toolkit::WebView( *impl );
+
+ impl->Initialize();
+ return handle;
+}
+
+Toolkit::WebView WebView::New( const std::string& locale, const std::string& timezoneId )
+{
+ WebView* impl = new WebView( locale, timezoneId );
+ Toolkit::WebView handle = Toolkit::WebView( *impl );
+
+ impl->Initialize();
+ return handle;
+}
+
+void WebView::OnInitialize()
+{
+ Self().SetKeyboardFocusable( true );
+ Self().TouchSignal().Connect( this, &WebView::OnTouchEvent );
+
+ if ( mWebEngine )
+ {
+ mWebEngine.PageLoadStartedSignal().Connect( this, &WebView::OnPageLoadStarted );
+ mWebEngine.PageLoadFinishedSignal().Connect( this, &WebView::OnPageLoadFinished );
+ }
+}
+
+void WebView::LoadUrl( const std::string& url )
+{
+ mUrl = url;
+ if ( mWebEngine )
+ {
+ Dali::Image image = Dali::NativeImage::New( *mWebEngine.GetNativeImageSource() );
+ mVisual = Toolkit::VisualFactory::Get().CreateVisual( image );
+
+ if ( mVisual )
+ {
+ // Clean up previously registered visual and add new one.
+ DevelControl::RegisterVisual( *this, Toolkit::WebView::Property::URL, mVisual );
+ mWebEngine.LoadUrl( url );
+ }
+ }
+}
+
+const std::string& WebView::GetUrl()
+{
+ return mWebEngine ? mWebEngine.GetUrl() : mUrl;
+}
+
+void WebView::LoadHTMLString( const std::string& htmlString )
+{
+ if ( mWebEngine )
+ {
+ Dali::Image image = Dali::NativeImage::New( *mWebEngine.GetNativeImageSource() );
+ mVisual = Toolkit::VisualFactory::Get().CreateVisual( image );
+
+ if ( mVisual )
+ {
+ DevelControl::RegisterVisual( *this, Toolkit::WebView::Property::URL, mVisual );
+ mWebEngine.LoadHTMLString( htmlString );
+ }
+ }
+}
+
+void WebView::Reload()
+{
+ if ( mWebEngine )
+ {
+ mWebEngine.Reload();
+ }
+}
+
+void WebView::StopLoading()
+{
+ if ( mWebEngine )
+ {
+ mWebEngine.StopLoading();
+ }
+}
+
+bool WebView::CanGoForward()
+{
+ return mWebEngine ? mWebEngine.CanGoForward() : false;
+}
+
+void WebView::GoForward()
+{
+ if ( mWebEngine )
+ {
+ mWebEngine.GoForward();
+ }
+}
+
+bool WebView::CanGoBack()
+{
+ return mWebEngine ? mWebEngine.CanGoBack() : false;
+}
+
+void WebView::GoBack()
+{
+ if ( mWebEngine )
+ {
+ mWebEngine.GoBack();
+ }
+}
+
+void WebView::EvaluateJavaScript( const std::string& script )
+{
+ if ( mWebEngine )
+ {
+ mWebEngine.EvaluateJavaScript( script );
+ }
+}
+
+void WebView::AddJavaScriptInterface( const std::string& exposedObjectName, const std::string& jsFunctionName, std::function< std::string(const std::string&) > callback )
+{
+ if ( mWebEngine )
+ {
+ mWebEngine.AddJavaScriptInterface( exposedObjectName, jsFunctionName, callback );
+ }
+}
+
+void WebView::RemoveJavascriptInterface( const std::string& exposedObjectName, const std::string& jsFunctionName )
+{
+ if ( mWebEngine )
+ {
+ mWebEngine.RemoveJavascriptInterface( exposedObjectName, jsFunctionName );
+ }
+}
+
+void WebView::ClearHistory()
+{
+ if ( mWebEngine )
+ {
+ mWebEngine.ClearHistory();
+ }
+}
+
+void WebView::ClearCache()
+{
+ if ( mWebEngine )
+ {
+ mWebEngine.ClearCache();
+ }
+}
+
+Dali::Toolkit::WebView::WebViewSignalType& WebView::PageLoadStartedSignal()
+{
+ return mPageLoadStartedSignal;
+}
+
+Dali::Toolkit::WebView::WebViewSignalType& WebView::PageLoadFinishedSignal()
+{
+ return mPageLoadFinishedSignal;
+}
+
+void WebView::OnPageLoadStarted( const std::string& url )
+{
+ if( !mPageLoadStartedSignal.Empty() )
+ {
+ Dali::Toolkit::WebView handle( GetOwner() );
+ mPageLoadStartedSignal.Emit( handle, url );
+ }
+}
+
+void WebView::OnPageLoadFinished( const std::string& url )
+{
+ if( !mPageLoadFinishedSignal.Empty() )
+ {
+ Dali::Toolkit::WebView handle( GetOwner() );
+ mPageLoadFinishedSignal.Emit( handle, url );
+ }
+}
+
+bool WebView::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
+{
+ Dali::BaseHandle handle( object );
+
+ bool connected = false;
+ Toolkit::WebView webView = Toolkit::WebView::DownCast( handle );
+
+ if( 0 == strcmp( signalName.c_str(), PAGE_LOAD_STARTED_SIGNAL ) )
+ {
+ webView.PageLoadStartedSignal().Connect( tracker, functor );
+ connected = true;
+ }
+ else if( 0 == strcmp( signalName.c_str(), PAGE_LOAD_FINISHED_SIGNAL ) )
+ {
+ webView.PageLoadFinishedSignal().Connect( tracker, functor );
+ connected = true;
+ }
+
+ return connected;
+}
+
+Vector3 WebView::GetNaturalSize()
+{
+ if( mVisual )
+ {
+ Vector2 rendererNaturalSize;
+ mVisual.GetNaturalSize( rendererNaturalSize );
+ return Vector3( rendererNaturalSize );
+ }
+
+ return Vector3( mWebViewSize );
+}
+
+void WebView::OnRelayout( const Vector2& size, RelayoutContainer& container )
+{
+ Control::OnRelayout( size, container );
+
+ if( size.width > 0 && size.height > 0 && mWebViewSize != size )
+ {
+ mWebViewSize = size;
+
+ if( mWebEngine )
+ {
+ mWebEngine.SetSize( size.width, size.height );
+ }
+ }
+}
+
+void WebView::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
+{
+ Toolkit::WebView webView = Toolkit::WebView::DownCast( Dali::BaseHandle( object ) );
+
+ if( webView )
+ {
+ WebView& impl = GetImpl( webView );
+ switch( index )
+ {
+ case Toolkit::WebView::Property::URL:
+ {
+ std::string url;
+ if( value.Get( url ) )
+ {
+ impl.LoadUrl( url );
+ }
+ break;
+ }
+ }
+ }
+}
+
+Property::Value WebView::GetProperty( BaseObject* object, Property::Index propertyIndex )
+{
+ Property::Value value;
+
+ Toolkit::WebView webView = Toolkit::WebView::DownCast( Dali::BaseHandle( object ) );
+
+ if( webView )
+ {
+ WebView& impl = GetImpl( webView );
+ switch( propertyIndex )
+ {
+ case Toolkit::WebView::Property::URL:
+ {
+ value = impl.GetUrl();
+ break;
+ }
+ }
+ }
+
+ return value;
+}
+
+bool WebView::OnTouchEvent( Actor actor, const Dali::TouchData& touch )
+{
+ bool result = false;
+
+ if ( mWebEngine )
+ {
+ result = mWebEngine.SendTouchEvent( touch );
+ }
+ return result;
+}
+
+bool WebView::OnKeyEvent( const Dali::KeyEvent& event )
+{
+ bool result = false;
+
+ if ( mWebEngine )
+ {
+ result = mWebEngine.SendKeyEvent( event );
+ }
+ return result;
+}
+
+} // namespace Internal
+
+} // namespace Toolkit
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_TOOLKIT_INTERNAL_WEB_VIEW_H
+#define DALI_TOOLKIT_INTERNAL_WEB_VIEW_H
+
+/*
+ * Copyright (c) 2018 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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/web-engine.h>
+#include <dali/public-api/images/image-operations.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/visual-factory/visual-base.h>
+#include <dali-toolkit/public-api/controls/control-impl.h>
+#include <dali-toolkit/devel-api/controls/web-view/web-view.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+class KeyEvent;
+class TouchData;
+class WebView;
+
+namespace Internal
+{
+
+class WebView : public Control
+{
+protected:
+
+ WebView();
+
+ WebView( const std::string& locale, const std::string& timezoneId );
+
+ virtual ~WebView();
+
+public:
+
+ /**
+ * @copydoc Dali::Toolkit::WebView::New()
+ */
+ static Toolkit::WebView New();
+
+ /**
+ * @copydoc Dali::Toolkit::WebView::New( const std::string&, const std::string& )
+ */
+ static Toolkit::WebView New( const std::string& locale, const std::string& timezoneId );
+
+ /**
+ * @copydoc Dali::Toolkit::WebView::LoadUrl()
+ */
+ void LoadUrl( const std::string& url );
+
+ /**
+ * @copydoc Dali::Toolkit::WebView::GetUrl()
+ */
+ const std::string& GetUrl();
+
+ /**
+ * @copydoc Dali::WebEngine::LoadHTMLString()
+ */
+ void LoadHTMLString( const std::string& htmlString );
+
+ /**
+ * @copydoc Dali::WebEngine::Reload()
+ */
+ void Reload();
+
+ /**
+ * @copydoc Dali::WebEngine::StopLoading()
+ */
+ void StopLoading();
+
+ /**
+ * @copydoc Dali::WebEngine::CanGoForward()
+ */
+ bool CanGoForward();
+
+ /**
+ * @copydoc Dali::WebEngine::GoForward()
+ */
+ void GoForward();
+
+ /**
+ * @copydoc Dali::WebEngine::CanGoBack()
+ */
+ bool CanGoBack();
+
+ /**
+ * @copydoc Dali::WebEngine::GoBack()
+ */
+ void GoBack();
+
+ /**
+ * @copydoc Dali::WebEngine::EvaluateJavaScript()
+ */
+ void EvaluateJavaScript( const std::string& script );
+
+ /**
+ * @copydoc Dali::WebEngine::AddJavaScriptInterface()
+ */
+ void AddJavaScriptInterface( const std::string& exposedObjectName, const std::string& jsFunctionName, std::function< std::string(const std::string&) > callback );
+
+ /**
+ * @copydoc Dali::WebEngine::RemoveJavascriptInterface()
+ */
+ void RemoveJavascriptInterface( const std::string& exposedObjectName, const std::string& jsFunctionName );
+
+ /**
+ * @copydoc Dali::WebEngine::ClearHistory()
+ */
+ void ClearHistory();
+
+ /**
+ * @copydoc Dali::WebEngine::ClearCache()
+ */
+ void ClearCache();
+
+ /**
+ * @copydoc Dali::Toolkit::WebView::PageLoadStartedSignal()
+ */
+ Dali::Toolkit::WebView::WebViewSignalType& PageLoadStartedSignal();
+
+ /**
+ * @copydoc Dali::Toolkit::WebView::PageLoadFinishedSignal()
+ */
+ Dali::Toolkit::WebView::WebViewSignalType& PageLoadFinishedSignal();
+
+public: // Properties
+
+ /**
+ * @brief Called when a property of an object of this type is set.
+ *
+ * @param[in] object The object whose property is set.
+ * @param[in] index The property index.
+ * @param[in] value The new property value.
+ */
+ static void SetProperty( Dali::BaseObject* object, Dali::Property::Index index, const Dali::Property::Value& value );
+
+ /**
+ * @brief Called to retrieve a property of an object of this type.
+ *
+ * @param[in] object The object whose property is to be retrieved.
+ * @param[in] index The property index.
+ * @return The current value of the property.
+ */
+ static Dali::Property::Value GetProperty( Dali::BaseObject* object, Dali::Property::Index propertyIndex );
+
+ /**
+ * Connects a callback function with the object's signals.
+ * @param[in] object The object providing the signal.
+ * @param[in] tracker Used to disconnect the signal.
+ * @param[in] signalName The signal to connect to.
+ * @param[in] functor A newly allocated FunctorDelegate.
+ * @return True if the signal was connected.
+ * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the c
+ */
+ static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
+
+private: // From Control
+
+ /**
+ * @copydoc Toolkit::Control::OnInitialize()
+ */
+ virtual void OnInitialize();
+
+ /**
+ * @copydoc Toolkit::Control::GetNaturalSize
+ */
+ virtual Vector3 GetNaturalSize();
+
+ /**
+ * @copydoc Toolkit::Control::OnRelayout()
+ */
+ virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
+
+ /**
+ * Signal occurs when the Web View has been touched.
+ * @param[in] actor The Actor Touched
+ * @param[in] touch The Touch Data.
+ * @return Whether to consume event or not.
+ */
+ bool OnTouchEvent( Actor actor, const Dali::TouchData& touch );
+
+ /**
+ * @copydoc Toolkit::Control::OnKeyEvent()
+ */
+ virtual bool OnKeyEvent( const Dali::KeyEvent& event );
+
+private:
+
+ // Undefined
+ WebView( const WebView& webView );
+
+ WebView& operator=( const WebView& webView );
+
+ void OnPageLoadStarted( const std::string& url );
+
+ void OnPageLoadFinished( const std::string& url );
+
+private:
+
+ std::string mUrl;
+ Dali::Toolkit::Visual::Base mVisual;
+ Dali::Size mWebViewSize;
+ Dali::WebEngine mWebEngine;
+ Dali::Toolkit::WebView::WebViewSignalType mPageLoadStartedSignal;
+ Dali::Toolkit::WebView::WebViewSignalType mPageLoadFinishedSignal;
+};
+
+} // namespace Internal
+
+inline Toolkit::Internal::WebView& GetImpl( Toolkit::WebView& handle )
+{
+ DALI_ASSERT_ALWAYS( handle );
+ Dali::RefObject& impl = handle.GetImplementation();
+ return static_cast< Toolkit::Internal::WebView& >( impl );
+}
+
+inline const Toolkit::Internal::WebView& GetImpl( const Toolkit::WebView& handle )
+{
+ DALI_ASSERT_ALWAYS( handle );
+ const Dali::RefObject& impl = handle.GetImplementation();
+ return static_cast< const Toolkit::Internal::WebView& >( impl );
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_INTERNAL_WEB_VIEW_H
$(toolkit_src_dir)/controls/tool-bar/tool-bar-impl.cpp \
$(toolkit_src_dir)/controls/tooltip/tooltip.cpp \
$(toolkit_src_dir)/controls/video-view/video-view-impl.cpp \
+ $(toolkit_src_dir)/controls/web-view/web-view-impl.cpp \
$(toolkit_src_dir)/accessibility-manager/accessibility-manager-impl.cpp \
\
$(toolkit_src_dir)/feedback/feedback-style.cpp \
MeasuredSize::State heightState;
} childState = { MeasuredSize::State::MEASURED_SIZE_OK, MeasuredSize::State::MEASURED_SIZE_OK };
- auto minPosition = Vector3( Vector3::ZERO );
- auto maxPosition = Vector3( Vector3::ZERO );
+ LayoutLength minPositionX( 0 );
+ LayoutLength minPositionY( 0 );
+ LayoutLength maxPositionX( 0 );
+ LayoutLength maxPositionY( 0 );
// measure children
for( unsigned int i=0; i<GetChildCount(); ++i )
// Get size of child
MeasureChild( childLayout, widthMeasureSpec, heightMeasureSpec );
- auto childWidth = childLayout->GetMeasuredWidth();
- auto childHeight = childLayout->GetMeasuredHeight();
+ LayoutLength childWidth = childLayout->GetMeasuredWidth();
+ LayoutLength childHeight = childLayout->GetMeasuredHeight();
// Determine the width and height needed by the children using their given position and size.
// Children could overlap so find the left most and right most child.
auto childPosition = childOwner.GetProperty< Vector3 >( Actor::Property::POSITION );
- minPosition.x = std::min( minPosition.x, childPosition.x );
- maxPosition.x = std::max( maxPosition.x, childPosition.x + childWidth );
+ LayoutLength childLeft = childPosition.x;
+ LayoutLength childTop = childPosition.y;
+
+ minPositionX = std::min( minPositionX, childLeft );
+ maxPositionX = std::max( maxPositionX, childLeft + childWidth );
// Children could overlap so find the highest and lowest child.
- minPosition.y = std::min( minPosition.y, childPosition.y );
- maxPosition.y = std::max( maxPosition.y, childPosition.y + childHeight );
+ minPositionY = std::min( minPositionY, childTop );
+ maxPositionY = std::max( maxPositionY, childTop + childHeight );
// Store current width and height needed to contain all children.
- totalWidth = maxPosition.x - minPosition.x;
- totalHeight = maxPosition.y - minPosition.y;
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "AbsoluteLayout::OnMeasure child width(%f) height(%f) \n", (float)totalWidth, (float)totalHeight );
+ totalWidth = maxPositionX - minPositionX;
+ totalHeight = maxPositionY - minPositionY;
+ DALI_LOG_INFO( gLogFilter, Debug::Concise, "AbsoluteLayout::OnMeasure child width(%f) height(%f) \n", totalWidth.AsDecimal(), totalHeight.AsDecimal() );
if( childLayout->GetMeasuredWidthAndState().GetState() == MeasuredSize::State::MEASURED_SIZE_TOO_SMALL )
{
if( childLayout != nullptr )
{
auto childOwner = childLayout->GetOwner();
- auto childWidth = childLayout->GetMeasuredWidth();
- auto childHeight = childLayout->GetMeasuredHeight();
+ LayoutLength childWidth = childLayout->GetMeasuredWidth();
+ LayoutLength childHeight = childLayout->GetMeasuredHeight();
auto childPosition = childOwner.GetProperty< Vector3 >( Actor::Property::POSITION );
- auto childTop = childPosition.y;
- auto childLeft = childPosition.x;
+ LayoutLength childTop = childPosition.y;
+ LayoutLength childLeft = childPosition.x;
- DALI_LOG_INFO( gLogFilter, Debug::General, "AbsoluteLayout::OnLayout child[%s] position(%f,%f) child width[%d] height(%d)\n",
- Toolkit::Control::DownCast( childOwner ).GetName().c_str(),
- childPosition.x, childPosition.y,
- childWidth.mValue, childHeight.mValue
- );
+ DALI_LOG_STREAM( gLogFilter, Debug::General,
+ "AbsoluteLayout::OnLayout child[" << Toolkit::Control::DownCast( childOwner ).GetName().c_str() <<
+ "] position(" << childPosition << ") child width[" << childWidth << "] height[" << childHeight << "]\n" );
childLayout->Layout( childLeft, childTop, childLeft + childWidth, childTop + childHeight );
}
if( widthMeasureSpec.GetMode() == MeasureSpec::Mode::EXACTLY )
{
- width = widthMeasureSpec.GetSize();
+ width = widthMeasureSpec.GetSize().AsDecimal();
YGNodeStyleSetWidth( mRoot, width );
}
else if( widthMeasureSpec.GetMode() == MeasureSpec::Mode::AT_MOST )
{
- width = widthMeasureSpec.GetSize();
+ width = widthMeasureSpec.GetSize().AsDecimal();
YGNodeStyleSetMaxWidth( mRoot, width );
}
if ( heightMeasureSpec.GetMode() == MeasureSpec::Mode::EXACTLY )
{
- height = heightMeasureSpec.GetSize();
+ height = heightMeasureSpec.GetSize().AsDecimal();
YGNodeStyleSetHeight( mRoot, height );
}
else if ( heightMeasureSpec.GetMode() == MeasureSpec::Mode::AT_MOST )
{
- height = heightMeasureSpec.GetSize();
+ height = heightMeasureSpec.GetSize().AsDecimal();
YGNodeStyleSetMaxHeight( mRoot, height );
}
auto owner = GetOwner();
auto actor = Actor::DownCast(owner);
bool isLayoutRtl = actor ? actor.GetProperty( Actor::Property::LAYOUT_DIRECTION ).Get<int>() == LayoutDirection::RIGHT_TO_LEFT: false;
- auto width = right - left;
- auto height = bottom - top;
+ LayoutLength width = right - left;
+ LayoutLength height = bottom - top;
#if defined(DEBUG_ENABLED)
std::ostringstream oss;
DALI_LOG_INFO( gLogFilter, Debug::Concise, oss.str().c_str() );
#endif
- YGNodeCalculateLayout( mRoot, width, height, isLayoutRtl ? YGDirectionRTL : YGDirectionLTR );
+ YGNodeCalculateLayout( mRoot, width.AsDecimal(), height.AsDecimal(), isLayoutRtl ? YGDirectionRTL : YGDirectionLTR );
auto count = GetChildCount();
for( unsigned int childIndex = 0; childIndex < count; childIndex++)
if( childLayout != nullptr )
{
YGNodeRef node = YGNodeGetChild(mRoot, childIndex);
- auto childLeft = YGNodeLayoutGetLeft( node ) + left;
- auto childTop = YGNodeLayoutGetTop( node ) + top;
- auto childWidth = YGNodeLayoutGetWidth( node );
- auto childHeight = YGNodeLayoutGetHeight( node );
+ LayoutLength childLeft = LayoutLength( YGNodeLayoutGetLeft( node ) )+ left;
+ LayoutLength childTop = LayoutLength( YGNodeLayoutGetTop( node ) ) + top;
+ LayoutLength childWidth = LayoutLength( YGNodeLayoutGetWidth( node ) );
+ LayoutLength childHeight = LayoutLength( YGNodeLayoutGetHeight( node ) );
childLayout->Layout( childLeft, childTop, childLeft + childWidth, childTop + childHeight );
}
}
auto childOwner = childLayout->GetOwner();
auto desiredWidth = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION );
auto desiredHeight = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION );
- auto parentWidthMeasureSpec = MeasureSpec( 0 );
+ MeasureSpec parentWidthMeasureSpec( 0 );
if ( innerWidth != YGUndefined )
{
parentWidthMeasureSpec = MeasureSpec( innerWidth, static_cast<MeasureSpec::Mode>(widthMode) );
// Remove padding here since Yoga doesn't consider it as a part of the node size
Extents padding = childLayout->GetPadding();
- auto measuredWidth = childLayout->GetMeasuredWidth() - padding.end - padding.start;
- auto measuredHeight = childLayout->GetMeasuredHeight() - padding.bottom - padding.top;
+ LayoutLength measuredWidth = childLayout->GetMeasuredWidth() - padding.end - padding.start;
+ LayoutLength measuredHeight = childLayout->GetMeasuredHeight() - padding.bottom - padding.top;
return YGSize{
- .width = measuredWidth,
- .height = measuredHeight,
+ .width = measuredWidth.AsDecimal(),
+ .height = measuredHeight.AsDecimal(),
};
}
return mNumColumns;
}
-void Grid::DetermineNumberOfColumns( int availableSpace )
+void Grid::DetermineNumberOfColumns( LayoutLength availableSpace )
{
if( mRequestedNumColumns == AUTO_FIT )
{
if( availableSpace > 0 )
{
// Can only calculate number of columns if a column width has been set
- mNumColumns = ( mRequestedColumnWidth > 0 ) ? ( availableSpace / mRequestedColumnWidth ) : 1;
+ mNumColumns = ( mRequestedColumnWidth > 0 ) ? ( availableSpace.AsInteger() / mRequestedColumnWidth ) : 1;
}
}
}
LayoutLength widthSize = widthMeasureSpec.GetSize();
LayoutLength heightSize = heightMeasureSpec.GetSize();
- int availableContentWidth(0);
- int availableContentHeight(0);
+ LayoutLength availableContentWidth( 0 );
+ LayoutLength availableContentHeight( 0 );
LayoutLength desiredChildHeight( 0 );
LayoutLength desiredChildWidth( 0 );
desiredChildWidth += childMargin.start + childMargin.end;
mTotalWidth = desiredChildWidth * mNumColumns;
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Grid::OnMeasure TotalDesiredWidth(%d) \n", mTotalWidth.mValue );
+ DALI_LOG_STREAM( gLogFilter, Debug::Verbose, "Grid::OnMeasure TotalDesiredWidth(" << mTotalWidth << ") \n" );
} // Child is LayoutItem
} // Child exists
availableContentWidth = mTotalWidth - gridLayoutPadding.start - gridLayoutPadding.end;
widthSize = mTotalWidth;
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Grid::OnMeasure availableContentWidth(%d) mTotalWidth(%d) \n",
- availableContentWidth,
- mTotalWidth.mValue );
+ DALI_LOG_STREAM( gLogFilter, Debug::Verbose, "Grid::OnMeasure availableContentWidth" << availableContentWidth << " mTotalWidth(" << mTotalWidth << ") \n" );
// HEIGHT SPECIFICATIONS
// heightMode EXACTLY so grid must be the given height
{
mTotalHeight += desiredChildHeight;
}
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Grid::OnMeasure TotalDesiredHeight(%d) \n",
- mTotalHeight.mValue );
+ DALI_LOG_STREAM( gLogFilter, Debug::Verbose, "Grid::OnMeasure TotalDesiredHeight(" << mTotalHeight << ") \n" );
// Ensure ourHeight does not exceed specified atmost height
mTotalHeight = std::min( mTotalHeight, heightSize );
DetermineNumberOfColumns( availableContentWidth );
// Locations define the start, end,top and bottom of each cell.
- mLocations->CalculateLocations( mNumColumns, availableContentWidth, availableContentHeight, childCount, 0, 0 );
+ mLocations->CalculateLocations( mNumColumns, availableContentWidth.AsInteger(), availableContentHeight.AsInteger(), childCount, 0, 0 );
SetMeasuredDimensions( ResolveSizeAndState( widthSize, widthMeasureSpec, MeasuredSize::State::MEASURED_SIZE_OK ),
* For the given availableSpace, calculate or retreive the number of required columns.
* @param[in] availableSpace the space available for a child in each column.
*/
- void DetermineNumberOfColumns( int availableSpace );
+ void DetermineNumberOfColumns( LayoutLength availableSpace );
private:
} // namespace Toolkit
} // namespace Dali
-#endif // DALI_TOOLKIT_INTERNAL_LAYOUTINGInner
\ No newline at end of file
+#endif // DALI_TOOLKIT_INTERNAL_LAYOUTINGInner
auto stageWidth = stage.GetSize().width;
auto stageHeight = stage.GetSize().height;
- auto widthSpec = MeasureSpec( stageWidth, MeasureSpec::Mode::EXACTLY );
- auto heightSpec = MeasureSpec( stageHeight, MeasureSpec::Mode::EXACTLY );
+ MeasureSpec widthSpec( stageWidth, MeasureSpec::Mode::EXACTLY );
+ MeasureSpec heightSpec( stageHeight, MeasureSpec::Mode::EXACTLY );
// Test how to perform a measure on each control.
MeasureHierarchy( stage.GetRootLayer(), widthSpec, heightSpec );
LayoutItem::Impl::Impl()
: mOwner( nullptr ),
mLayoutParent( nullptr ),
- mOldWidthMeasureSpec( 0u ),
- mOldHeightMeasureSpec( 0u ),
+ mOldWidthMeasureSpec( 0 ),
+ mOldHeightMeasureSpec( 0 ),
mMinimumSize(),
- mMeasuredWidth(0u),
- mMeasuredHeight(0u),
+ mMeasuredWidth(0),
+ mMeasuredHeight(0),
mLeft( 0 ),
mRight( 0 ),
mTop( 0 ),
LayoutLength alternativeMaxHeight = 0;
LayoutLength weightedMaxHeight = 0;
float totalWeight = 0;
- int usedExcessSpace = 0;
+ LayoutLength usedExcessSpace = 0;
struct
{
MeasuredSize::State widthState;
if( childLayout )
{
auto childOwner = childLayout->GetOwner();
- auto desiredHeight = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION );
- auto desiredWidth = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION );
- auto childWeight = childOwner.GetProperty<float>( Toolkit::LinearLayout::ChildProperty::WEIGHT );
- auto childMargin = childLayout->GetMargin();
+ LayoutLength desiredHeight = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION );
+ LayoutLength desiredWidth = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION );
+ float childWeight = childOwner.GetProperty<float>( Toolkit::LinearLayout::ChildProperty::WEIGHT );
+ Extents childMargin = childLayout->GetMargin();
totalWeight += childWeight;
// this child is only laid out using excess space. Measure
// using WRAP_CONTENT so that we can find out the view's
// optimal width.
- auto padding = GetPadding();
+ Extents padding = GetPadding();
const MeasureSpec childWidthMeasureSpec = GetChildMeasureSpec( widthMeasureSpec, padding.start + padding.end, Toolkit::ChildLayoutData::WRAP_CONTENT );
const MeasureSpec childHeightMeasureSpec = GetChildMeasureSpec( heightMeasureSpec, padding.top + padding.bottom, desiredHeight );
childLayout->Measure( childWidthMeasureSpec, childHeightMeasureSpec );
childWidth = childLayout->GetMeasuredWidth();
}
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LinearLayout::OnMeasure childWidth(%d)\n", MeasureSpec::IntType( childWidth ) );
- auto length = childWidth + LayoutLength::IntType( childMargin.start + childMargin.end );
- auto cellPadding = i < GetChildCount() - 1 ? mCellPadding.width : 0;
+ DALI_LOG_STREAM( gLogFilter, Debug::Verbose, "LinearLayout::OnMeasure childWidth(" << childWidth << ")\n" );
+ LayoutLength length = childWidth + childMargin.start + childMargin.end;
+ LayoutLength cellPadding = i < GetChildCount() - 1 ? mCellPadding.width : 0;
if( isExactly )
{
mTotalLength += length;
}
else
{
- auto totalLength = mTotalLength;
+ LayoutLength totalLength = mTotalLength;
mTotalLength = std::max( totalLength, totalLength + length + cellPadding );
}
}
matchHeightLocally = true;
}
- auto marginHeight = LayoutLength( childMargin.top + childMargin.bottom );
- auto childHeight = childLayout->GetMeasuredHeight() + marginHeight;
+ LayoutLength marginHeight = childMargin.top + childMargin.bottom;
+ LayoutLength childHeight = childLayout->GetMeasuredHeight() + marginHeight;
if( childLayout->GetMeasuredWidthAndState().GetState() == MeasuredSize::State::MEASURED_SIZE_TOO_SMALL )
{
Extents padding = GetPadding();
mTotalLength += padding.start + padding.end;
- auto widthSize = mTotalLength;
+ LayoutLength widthSize = mTotalLength;
widthSize = std::max( widthSize, GetSuggestedMinimumWidth() );
MeasuredSize widthSizeAndState = ResolveSizeAndState( widthSize, widthMeasureSpec, MeasuredSize::State::MEASURED_SIZE_OK);
widthSize = widthSizeAndState.GetSize();
// We cycle through weighted children now (children with weight > 0).
// The children are measured with exact size equal to their share of the available space based on their weights.
// mTotalLength is updated to include weighted children measured sizes.
- int remainingExcess = widthSize - mTotalLength + usedExcessSpace;
+ LayoutLength remainingExcess = widthSize - mTotalLength + usedExcessSpace;
if( remainingExcess != 0 && totalWeight > 0 )
{
float remainingWeightSum = totalWeight;
{
auto childLayout = GetChildAt( i );
auto childOwner = childLayout->GetOwner();
- auto desiredWidth = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION );
- auto desiredHeight = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION );
- auto childWeight = childOwner.GetProperty<float>( Toolkit::LinearLayout::ChildProperty::WEIGHT );
- auto childMargin = childLayout->GetMargin();
+ LayoutLength desiredWidth = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION );
+ LayoutLength desiredHeight = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION );
+ float childWeight = childOwner.GetProperty<float>( Toolkit::LinearLayout::ChildProperty::WEIGHT );
+ Extents childMargin = childLayout->GetMargin();
LayoutLength childWidth = 0;
if( childWeight > 0 )
{
- int share = static_cast<int>( childWeight * remainingExcess / remainingWeightSum );
+ LayoutLength share = ( childWeight * remainingExcess ) / remainingWeightSum;
remainingExcess -= share;
remainingWeightSum -= childWeight;
}
}
- auto length = childLayout->GetMeasuredWidth() + LayoutLength::IntType( childMargin.start + childMargin.end );
- auto cellPadding = i < GetChildCount() - 1 ? mCellPadding.width : 0;
+ LayoutLength length = childLayout->GetMeasuredWidth() + LayoutLength( childMargin.start + childMargin.end );
+ LayoutLength cellPadding = i < GetChildCount() - 1 ? mCellPadding.width : 0;
if( isExactly )
{
mTotalLength += length;
}
else
{
- auto totalLength = mTotalLength;
+ LayoutLength totalLength = mTotalLength;
mTotalLength = std::max( totalLength, totalLength + length + cellPadding );
}
bool matchHeightLocally = heightMode != MeasureSpec::Mode::EXACTLY && desiredHeight == Toolkit::ChildLayoutData::MATCH_PARENT;
- auto marginHeight = LayoutLength( childMargin.top + childMargin.bottom );
- auto childHeight = childLayout->GetMeasuredHeight() + marginHeight;
+ LayoutLength marginHeight = childMargin.top + childMargin.bottom;
+ LayoutLength childHeight = childLayout->GetMeasuredHeight() + marginHeight;
maxHeight = std::max( maxHeight, childHeight );
alternativeMaxHeight = std::max( alternativeMaxHeight, matchHeightLocally ? marginHeight : childHeight );
// Pretend that the linear layout has an exact size. This is the measured height of
// ourselves. The measured height should be the max height of the children, changed
// to accommodate the heightMeasureSpec from the parent
- auto uniformMeasureSpec = MeasureSpec( GetMeasuredHeight(), MeasureSpec::Mode::EXACTLY );
+ MeasureSpec uniformMeasureSpec( GetMeasuredHeight(), MeasureSpec::Mode::EXACTLY );
for (int i = 0; i < count; ++i)
{
LayoutItemPtr childLayout = GetChildAt(i);
if( childLayout != nullptr )
{
auto childOwner = childLayout->GetOwner();
- auto desiredWidth = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION );
- auto desiredHeight = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION );
+ LayoutLength desiredWidth = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION );
+ LayoutLength desiredHeight = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION );
if( desiredHeight == Toolkit::ChildLayoutData::MATCH_PARENT )
{
// Temporarily force children to reuse their old measured width
- int oldWidth = desiredWidth;
- childOwner.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, childLayout->GetMeasuredWidth().mValue );
+ LayoutLength oldWidth = desiredWidth;
+ childOwner.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, childLayout->GetMeasuredWidth().AsInteger() );
// Remeasure with new dimensions
- MeasureChildWithMargins( childLayout, widthMeasureSpec, 0, uniformMeasureSpec, 0);
+ MeasureChildWithMargins( childLayout, widthMeasureSpec, 0, uniformMeasureSpec, 0 );
- childOwner.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, oldWidth );
+ childOwner.SetProperty( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION, oldWidth.AsInteger() );
}
}
}
LayoutLength childLeft( padding.start );
// Where bottom of child should go
- auto height = bottom - top;
+ LayoutLength height = bottom - top;
// Space available for child
- auto childSpace = height - padding.top - padding.bottom;
+ LayoutLength childSpace = height - padding.top - padding.bottom;
auto count = GetChildCount();
{
// mTotalLength contains the padding already
// In case of RTL map BEGIN alignment to the right edge
- if ( isLayoutRtl ) {
+ if ( isLayoutRtl )
+ {
childLeft = LayoutLength( padding.start ) + right - left - mTotalLength;
}
- else {
+ else
+ {
childLeft = LayoutLength( padding.start );
}
break;
{
// mTotalLength contains the padding already
// In case of RTL map END alignment to the left edge
- if ( isLayoutRtl ) {
+ if ( isLayoutRtl )
+ {
childLeft = LayoutLength( padding.start );
}
- else {
+ else
+ {
childLeft = LayoutLength( padding.start ) + right - left - mTotalLength;
}
break;
case Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL:
{
// mTotalLength contains the padding already
- childLeft = LayoutLength( padding.start ) + ( right - left - mTotalLength ) / 2;
+ childLeft = padding.start + ( right - left - mTotalLength ) / 2.0f;
break;
}
}
int dir = 1;
// In case of RTL, start drawing from the last child.
- if( isLayoutRtl ) {
+ if( isLayoutRtl )
+ {
start = count - 1;
dir = -1;
}
LayoutItemPtr childLayout = GetChildAt( childIndex );
if( childLayout != nullptr )
{
- auto childWidth = childLayout->GetMeasuredWidth();
- auto childHeight = childLayout->GetMeasuredHeight();
- auto childMargin = childLayout->GetMargin();
+ LayoutLength childWidth = childLayout->GetMeasuredWidth();
+ LayoutLength childHeight = childLayout->GetMeasuredHeight();
+ Extents childMargin = childLayout->GetMargin();
switch ( mAlignment & VERTICAL_ALIGNMENT_MASK )
{
childTop = height - padding.bottom - childHeight - childMargin.bottom;
break;
}
- case Dali::Toolkit::LinearLayout::Alignment::CENTER_VERTICAL:
+ case Dali::Toolkit::LinearLayout::Alignment::CENTER_VERTICAL: // FALLTHROUGH
default:
{
- childTop = LayoutLength( padding.top ) + ( ( childSpace - childHeight ) / 2 ) + childMargin.top - childMargin.bottom;
+ childTop = padding.top + ( ( childSpace - childHeight ) / 2.0f ) + childMargin.top - childMargin.bottom;
break;
}
}
LayoutLength alternativeMaxWidth = 0;
LayoutLength weightedMaxWidth = 0;
float totalWeight = 0;
- int usedExcessSpace = 0;
+ LayoutLength usedExcessSpace = 0;
struct
{
MeasuredSize::State widthState;
if( childLayout )
{
auto childOwner = childLayout->GetOwner();
- auto desiredWidth = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION );
- auto desiredHeight = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION );
- auto childWeight = childOwner.GetProperty<float>( Toolkit::LinearLayout::ChildProperty::WEIGHT );
- auto childMargin = childLayout->GetMargin();
+ LayoutLength desiredWidth = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION );
+ LayoutLength desiredHeight = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION );
+ float childWeight = childOwner.GetProperty<float>( Toolkit::LinearLayout::ChildProperty::WEIGHT );
+ Extents childMargin = childLayout->GetMargin();
totalWeight += childWeight;
// using WRAP_CONTENT so that we can find out the view's
// optimal height. We'll restore the original height of 0
// after measurement.
- auto padding = GetPadding();
+ Extents padding = GetPadding();
const MeasureSpec childWidthMeasureSpec = GetChildMeasureSpec( widthMeasureSpec, padding.start + padding.end, desiredWidth );
const MeasureSpec childHeightMeasureSpec = GetChildMeasureSpec( heightMeasureSpec, padding.top + padding.bottom, Toolkit::ChildLayoutData::WRAP_CONTENT );
childLayout->Measure( childWidthMeasureSpec, childHeightMeasureSpec );
childHeight = childLayout->GetMeasuredHeight();
}
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LinearLayout::MeasureVertical childHeight(%d)\n", MeasureSpec::IntType( childHeight ) );
+ DALI_LOG_STREAM( gLogFilter, Debug::Verbose, "LinearLayout::MeasureVertical childHeight(" << childHeight << ")\n" );
- auto length = childHeight + LayoutLength::IntType( childMargin.top + childMargin.bottom );
- auto cellPadding = i < GetChildCount() - 1 ? mCellPadding.height : 0;
- auto totalLength = mTotalLength;
+ LayoutLength length = childHeight + childMargin.top + childMargin.bottom;
+ LayoutLength cellPadding = i < GetChildCount() - 1 ? mCellPadding.height : 0;
+ LayoutLength totalLength = mTotalLength;
mTotalLength = std::max( totalLength, totalLength + length + cellPadding );
}
matchWidthLocally = true;
}
- auto marginWidth = LayoutLength( childMargin.start + childMargin.end );
- auto childWidth = childLayout->GetMeasuredWidth() + marginWidth;
+ LayoutLength marginWidth = childMargin.start + childMargin.end;
+ LayoutLength childWidth = childLayout->GetMeasuredWidth() + marginWidth;
// was combineMeasuredStates()
if( childLayout->GetMeasuredWidthAndState().GetState() == MeasuredSize::State::MEASURED_SIZE_TOO_SMALL )
Extents padding = GetPadding();
mTotalLength += padding.top + padding.bottom;
- auto heightSize = mTotalLength;
+ LayoutLength heightSize = mTotalLength;
heightSize = std::max( heightSize, GetSuggestedMinimumHeight() );
MeasuredSize heightSizeAndState = ResolveSizeAndState( heightSize, heightMeasureSpec, MeasuredSize::State::MEASURED_SIZE_OK);
heightSize = heightSizeAndState.GetSize();
// We cycle through weighted children now (children with weight > 0).
// The children are measured with exact size equal to their share of the available space based on their weights.
// mTotalLength is updated to include weighted children measured sizes.
- int remainingExcess = heightSize - mTotalLength + usedExcessSpace;
+ LayoutLength remainingExcess = heightSize - mTotalLength + usedExcessSpace;
if( remainingExcess != 0 && totalWeight > 0.0f )
{
float remainingWeightSum = totalWeight;
{
auto childLayout = GetChildAt( i );
auto childOwner = childLayout->GetOwner();
- auto desiredWidth = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION );
- auto desiredHeight = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION );
- auto childWeight = childOwner.GetProperty<float>( Toolkit::LinearLayout::ChildProperty::WEIGHT );
- auto childMargin = childLayout->GetMargin();
+ LayoutLength desiredWidth = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION );
+ LayoutLength desiredHeight = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION );
+ float childWeight = childOwner.GetProperty<float>( Toolkit::LinearLayout::ChildProperty::WEIGHT );
+ Extents childMargin = childLayout->GetMargin();
LayoutLength childHeight = 0;
if( childWeight > 0 )
{
- int share = static_cast<int>( childWeight * remainingExcess / remainingWeightSum );
+ LayoutLength share = ( childWeight * remainingExcess ) / remainingWeightSum;
remainingExcess -= share;
remainingWeightSum -= childWeight;
matchWidthLocally = true;
}
- auto marginWidth = LayoutLength( childMargin.start + childMargin.end );
- auto childWidth = childLayout->GetMeasuredWidth() + marginWidth;
+ LayoutLength marginWidth = childMargin.start + childMargin.end;
+ LayoutLength childWidth = childLayout->GetMeasuredWidth() + marginWidth;
maxWidth = std::max( maxWidth, childWidth );
allFillParent = allFillParent && desiredWidth == Toolkit::ChildLayoutData::MATCH_PARENT;
alternativeMaxWidth = std::max( alternativeMaxWidth, matchWidthLocally ? marginWidth : childWidth );
childHeight = childLayout->GetMeasuredHeight();
- auto length = childHeight + LayoutLength::IntType( childMargin.top + childMargin.bottom );
- auto cellPadding = i < GetChildCount() - 1 ? mCellPadding.height : 0;
- auto totalLength = mTotalLength;
+ LayoutLength length = childHeight + childMargin.top + childMargin.bottom;
+ LayoutLength cellPadding = i < GetChildCount() - 1 ? mCellPadding.height : 0;
+ LayoutLength totalLength = mTotalLength;
mTotalLength = std::max( totalLength, totalLength + length + cellPadding );
}
void LinearLayout::ForceUniformWidth( int count, MeasureSpec heightMeasureSpec )
{
// Pretend that the linear layout has an exact size.
- auto uniformMeasureSpec = MeasureSpec( GetMeasuredWidth(), MeasureSpec::Mode::EXACTLY );
+ MeasureSpec uniformMeasureSpec( GetMeasuredWidth(), MeasureSpec::Mode::EXACTLY );
for (int i = 0; i < count; ++i)
{
LayoutItemPtr childLayout = GetChildAt(i);
if( childLayout != nullptr )
{
auto childOwner = childLayout->GetOwner();
- auto desiredWidth = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION );
- auto desiredHeight = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION );
+ LayoutLength desiredWidth = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION );
+ LayoutLength desiredHeight = childOwner.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION );
if( desiredWidth == Toolkit::ChildLayoutData::MATCH_PARENT )
{
// Temporarily force children to reuse their old measured height
- int oldHeight = desiredHeight;
- childOwner.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, childLayout->GetMeasuredHeight().mValue );
+ LayoutLength oldHeight = desiredHeight;
+ childOwner.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, childLayout->GetMeasuredHeight().AsInteger() );
// Remeasure with new dimensions
MeasureChildWithMargins( childLayout, uniformMeasureSpec, 0, heightMeasureSpec, 0 );
- childOwner.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, oldHeight );
+ childOwner.SetProperty( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION, oldHeight.AsInteger() );
}
}
}
LayoutLength childLeft( padding.start );
// Where end of child should go
- auto width = right - left;
+ LayoutLength width = right - left;
// Space available for child
- auto childSpace = width - padding.start - padding.end;
+ LayoutLength childSpace = width - padding.start - padding.end;
auto count = GetChildCount();
switch ( mAlignment & VERTICAL_ALIGNMENT_MASK )
default:
{
// mTotalLength contains the padding already
- childTop = LayoutLength( padding.top ) + ( bottom - top - mTotalLength ) / 2;
+ childTop = padding.top + ( bottom - top - mTotalLength ) / 2.0f;
break;
}
}
LayoutItemPtr childLayout = GetChildAt( childIndex );
if( childLayout != nullptr )
{
- auto childWidth = childLayout->GetMeasuredWidth();
- auto childHeight = childLayout->GetMeasuredHeight();
- auto childMargin = childLayout->GetMargin();
+ LayoutLength childWidth = childLayout->GetMeasuredWidth();
+ LayoutLength childHeight = childLayout->GetMeasuredHeight();
+ Extents childMargin = childLayout->GetMargin();
childTop += childMargin.top;
switch ( mAlignment & HORIZONTAL_ALIGNMENT_MASK )
}
case Dali::Toolkit::LinearLayout::Alignment::CENTER_HORIZONTAL:
{
- childLeft = LayoutLength( padding.start ) + ( childSpace - childWidth ) / 2 + childMargin.start - childMargin.end;
+ childLeft = padding.start + ( childSpace - childWidth ) / 2.0f + childMargin.start - childMargin.end;
break;
}
}
const unsigned int TOOLKIT_MAJOR_VERSION = 1;
const unsigned int TOOLKIT_MINOR_VERSION = 3;
-const unsigned int TOOLKIT_MICRO_VERSION = 40;
+const unsigned int TOOLKIT_MICRO_VERSION = 42;
const char * const TOOLKIT_BUILD_DATE = __DATE__ " " __TIME__;
#ifdef DEBUG_ENABLED
Name: dali-toolkit
Summary: Dali 3D engine Toolkit
-Version: 1.3.40
+Version: 1.3.42
Release: 1
Group: System/Libraries
License: Apache-2.0 and BSD-3-Clause and MIT