From: Richard Huang Date: Fri, 20 Oct 2017 11:43:54 +0000 (+0100) Subject: [dali_1.2.62] Merge branch 'devel/master' X-Git-Tag: dali_1.9.8~5^2~125 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=d234b59deebc2c0629b70447003199d51ef17054;hp=1b78a757a60b1eb2d74204b96646bdda62cc8c1f [dali_1.2.62] Merge branch 'devel/master' Change-Id: I68495174332895edcedbb7854d62c1619f743cc6 --- diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-compare-types.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-compare-types.h index dd6ba24..5870028 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-compare-types.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-compare-types.h @@ -105,6 +105,15 @@ inline bool CompareType(Degree q1, Degree q2, float epsilon) } template <> +inline bool CompareType(Extents extents1, Extents extents2, float epsilon) +{ + return (extents1.start == extents2.start) && + (extents1.end == extents2.end) && + (extents1.top == extents2.top) && + (extents1.bottom == extents2.bottom); +} + +template <> inline bool CompareType(Property::Value q1, Property::Value q2, float epsilon) { Property::Type type = q1.GetType(); @@ -191,6 +200,14 @@ inline bool CompareType(Property::Value q1, Property::Value q2, result = false; break; } + case Property::EXTENTS: + { + Extents a, b; + q1.Get(a); + q2.Get(b); + result = CompareType( a, b, epsilon ); + break; + } case Property::NONE: { result = false; diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-application.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-application.cpp index 034e416..ce17641 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-application.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-application.cpp @@ -87,6 +87,8 @@ std::string Application::GetResourcePath() //////////////////////////////////////////////////////////////////////////////////////////////////// +bool ToolkitApplication::DECODED_IMAGES_SUPPORTED; + ToolkitApplication::ToolkitApplication() : mApplicationStub(new Application(*this)) { diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-application.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-application.h index 7178b68..584a38c 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-application.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-application.h @@ -85,6 +85,9 @@ private: // The Application Stub Application* mApplicationStub; friend class Application; + +public: // Test static member + static bool DECODED_IMAGES_SUPPORTED; }; } // namespace Dali diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-video-player.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-video-player.cpp index eee723b..09cc438 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-video-player.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-video-player.cpp @@ -15,11 +15,10 @@ * */ -// CLASS HEADER -#include "toolkit-video-player.h" - -// EXTERNAL INCLUDES +#include #include +#include +#include namespace Dali { @@ -226,5 +225,10 @@ void VideoPlayer::Backward( int millisecond ) { } +bool VideoPlayer::IsVideoTextureSupported() const +{ + return ToolkitApplication::DECODED_IMAGES_SUPPORTED; +} + } // namespace Dali; diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-video-player.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-video-player.h deleted file mode 100644 index 199fa12..0000000 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-video-player.h +++ /dev/null @@ -1,110 +0,0 @@ -#ifndef __DALI_TOOLKIT_VIDEO_PLAYER_H__ -#define __DALI_TOOLKIT_VIDEO_PLAYER_H__ - -/* - * Copyright (c) 2016 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 -#include - -#include - -namespace Dali -{ - -class Any; - -namespace Internal -{ -namespace Adaptor -{ - -class VideoPlayer; - -} -} - -/** - * @brief VideoPlayer class is used for video playback. - * @SINCE_1_1.38 - */ -class VideoPlayer: public BaseHandle -{ -public: - - VideoPlayer(); - - ~VideoPlayer(); - - static VideoPlayer New(); - - VideoPlayer( const VideoPlayer& player ); - - VideoPlayer& operator=( const VideoPlayer& player ); - - static VideoPlayer DownCast( BaseHandle handle ); - - void SetUrl( const std::string& url ); - - std::string GetUrl(); - - void SetLooping(bool looping); - - bool IsLooping(); - - void Play(); - - void Pause(); - - void Stop(); - - void SetMute( bool mute ); - - bool IsMuted(); - - void SetVolume( float left, float right ); - - void GetVolume( float& left, float& right ); - - void SetRenderingTarget( Any target ); - - void SetPlayPosition( int millisecond ); - - int GetPlayPosition(); - - void SetDisplayArea( DisplayArea area ); - - void SetDisplayRotation( Dali::VideoPlayerPlugin::DisplayRotation rotation ); - - Dali::VideoPlayerPlugin::DisplayRotation GetDisplayRotation(); - - Dali::VideoPlayerPlugin::VideoPlayerSignalType& FinishedSignal(); - - void Forward( int millisecond ); - - void Backward( int millisecond ); - -private: - - VideoPlayer( Internal::Adaptor::VideoPlayer* internal ); - -}; - -} // namespace Dali; - -#endif diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Builder.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Builder.cpp index f134be3..511d2ef 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Builder.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Builder.cpp @@ -1727,7 +1727,8 @@ int UtcDaliBuilderTypeCasts(void) "\"sensitive\": { \"typeCast\":\"boolean\", \"value\":false }," "\"orientation\": { \"typeCast\":\"rotation\", \"value\":[10,10,10,10] }," "\"colorMode\": { \"typeCast\":\"string\", \"value\":\"USE_OWN_MULTIPLY_PARENT_COLOR\" }," - "\"clippingBox\": { \"typeCast\":\"rect\", \"value\":[10,10,10,10] }" + "\"clippingBox\": { \"typeCast\":\"rect\", \"value\":[10,10,10,10] }," + "\"padding\": { \"typeCast\":\"extents\", \"value\":[10,10,10,10] }" "}]" "}" ); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Control.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Control.cpp index ffe1ee7..bfb390c 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Control.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Control.cpp @@ -865,3 +865,53 @@ int UtcDaliControlResourcesReady(void) END_TEST; } + +int UtcDaliControlMarginProperty(void) +{ + ToolkitTestApplication application; + + Control control = Control::New(); + control.SetBackgroundColor( Color::BLUE ); + + control.SetProperty( Control::Property::MARGIN, Extents( 20, 10, 0, 0 ) ); + + Stage::GetCurrent().Add( control ); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( control.GetProperty( Control::Property::MARGIN ), Extents( 20, 10, 0, 0 ), TEST_LOCATION ); + + // Parent control has one ImageView as a Child. + ImageView image = ImageView::New(); + image.SetBackgroundColor( Color::RED ); + image.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); + image.SetProperty( Control::Property::PADDING, Extents( 10, 10, 10, 10 ) ); + control.Add( image ); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( image.GetProperty( Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliControlPaddingProperty(void) +{ + ToolkitTestApplication application; + + Control control = Control::New(); + control.SetBackgroundColor( Color::BLUE ); + + control.SetProperty( Control::Property::PADDING, Extents( 10, 10, 10, 10 ) ); + + Stage::GetCurrent().Add( control ); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( control.GetProperty( Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION ); + + END_TEST; +} diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp index b22239e..51df879 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp @@ -476,6 +476,7 @@ int UtcDaliImageViewAsyncLoadingWithAtlasing(void) ImageView imageView = ImageView::New(); imageView.SetProperty( ImageView::Property::IMAGE, imageMap ); + imageView.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10u, 10u, 10u, 10u ) ); // By default, Aysnc loading is used // loading is not started if the actor is offStage diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ImageVisual.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ImageVisual.cpp index c40af67..d0e1561 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ImageVisual.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ImageVisual.cpp @@ -19,11 +19,11 @@ #include #include #include -#include #include #include #include #include +#include #include #include "dummy-control.h" @@ -1064,6 +1064,9 @@ int UtcDaliImageVisualAlphaMask(void) DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION ); DALI_TEST_EQUALS( actor.IsResourceReady(), true, TEST_LOCATION ); + dummyImpl.UnregisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1 ); + DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION ); + END_TEST; } @@ -1179,3 +1182,433 @@ int UtcDaliImageVisualAlphaMaskCrop(void) END_TEST; } + +int UtcDaliImageVisualReleasePolicy01(void) +{ + ToolkitTestApplication application; + tet_infoline( "UtcDaliImageVisualReleasePolicy01 Detached Policy, disabling visual with this policy deletes texture" ); + + VisualFactory factory = VisualFactory::Get(); + + Property::Map propertyMap; + propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE ); + propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME ); + propertyMap.Insert( ImageVisual::Property::DESIRED_WIDTH, 20 ); + propertyMap.Insert( ImageVisual::Property::DESIRED_HEIGHT, 30 ); + propertyMap.Insert( DevelImageVisual::Property::RELEASE_POLICY, DevelImageVisual::ReleasePolicy::DETACHED ); + + Visual::Base imageVisual = factory.CreateVisual(propertyMap); + DALI_TEST_CHECK( imageVisual ); + + // Set up debug trace + TestGlAbstraction& gl = application.GetGlAbstraction(); + TraceCallStack& textureTrace = gl.GetTextureTrace(); + textureTrace.Enable(true); + + tet_infoline( "Register visual with control and ensure it has the only handle" ); + DummyControl actor = DummyControl::New(true); + Impl::DummyControl& dummyImpl = static_cast(actor.GetImplementation()); + dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, imageVisual ); + imageVisual.Reset(); + + actor.SetSize(200.f, 200.f); + + application.SendNotification(); + application.Render(0); + DALI_TEST_CHECK( actor.GetRendererCount() == 0u ); + DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION ); + + Stage::GetCurrent().Add( actor ); + + // Wait for image to load + DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION ); + + application.SendNotification(); + application.Render(0); + // Test renderer and texture created + tet_infoline( "Confirm texture created" ); + DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION ); + + tet_infoline( "Disable visual causing the texture to be deleted" ); + dummyImpl.EnableVisual( DummyControl::Property::TEST_VISUAL, false ); + + application.SendNotification(); + application.Render(0); + // Test renderer and textures removed. + DALI_TEST_CHECK( actor.GetRendererCount() == 0u ); + DALI_TEST_EQUALS( textureTrace.CountMethod("DeleteTextures"), 1, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliImageVisualReleasePolicy02(void) +{ + ToolkitTestApplication application; + tet_infoline( "UtcDaliImageVisualReleasePolicy02 Destroyed Policy, Texture should be deleted when visual destroyed" ); + + VisualFactory factory = VisualFactory::Get(); + const std::string MASK_IMAGE = TEST_REMOTE_IMAGE_FILE_NAME; + + Property::Map propertyMap; + propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE ); + propertyMap.Insert( Visual::Property::MIX_COLOR, Color::MAGENTA ); + propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME ); + propertyMap.Insert( ImageVisual::Property::DESIRED_WIDTH, 20 ); + propertyMap.Insert( ImageVisual::Property::DESIRED_HEIGHT, 30 ); + propertyMap.Insert( DevelImageVisual::Property::RELEASE_POLICY , DevelImageVisual::ReleasePolicy::DESTROYED ); + + Visual::Base imageVisual = factory.CreateVisual(propertyMap); + DALI_TEST_CHECK( imageVisual ); + + // Setup debug trace + TestGlAbstraction& gl = application.GetGlAbstraction(); + TraceCallStack& textureTrace = gl.GetTextureTrace(); + textureTrace.Enable(true); + + tet_infoline( "Register visual with control and ensure it has the only handle" ); + DummyControl actor = DummyControl::New(true); + Impl::DummyControl& dummyImpl = static_cast(actor.GetImplementation()); + dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, imageVisual ); + imageVisual.Reset(); // reduce ref count so only the control keeps the visual alive. + + actor.SetSize(200.f, 200.f); + + application.SendNotification(); + application.Render(0); + DALI_TEST_CHECK( actor.GetRendererCount() == 0u ); + DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION ); + + Stage::GetCurrent().Add( actor ); + + // Wait for image to load + DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION ); + + application.SendNotification(); + application.Render(0); + // Test renderer and texture created + DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION ); + + + DALI_TEST_CHECK( actor.GetRendererCount() == 1u ); + tet_infoline( "Destroy visual by UnRegistering visual with control, check renderer is destroyed" ); + dummyImpl.UnregisterVisual( DummyControl::Property::TEST_VISUAL ); + DALI_TEST_CHECK( actor.GetRendererCount() == 0u ); + application.SendNotification(); + application.Render(); + + // Test texture removed after visual destroyed. + tet_infoline( "Ensure texture is deleted after visual destroyed" ); + DALI_TEST_EQUALS( textureTrace.CountMethod("DeleteTextures"), 1, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliImageVisualReleasePolicy03(void) +{ + ToolkitTestApplication application; + tet_infoline( "UtcDaliImageVisualReleasePolicy03 Never Policy, texture should not be deleted after visual destroyed" ); + + VisualFactory factory = VisualFactory::Get(); + + Property::Map propertyMap; + propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE ); + propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME ); + propertyMap.Insert( ImageVisual::Property::DESIRED_WIDTH, 20 ); + propertyMap.Insert( ImageVisual::Property::DESIRED_HEIGHT, 30 ); + propertyMap.Insert( DevelImageVisual::Property::RELEASE_POLICY , DevelImageVisual::ReleasePolicy::NEVER ); + + Visual::Base imageVisual = factory.CreateVisual(propertyMap); + DALI_TEST_CHECK( imageVisual ); + + TestGlAbstraction& gl = application.GetGlAbstraction(); + TraceCallStack& textureTrace = gl.GetTextureTrace(); + textureTrace.Enable(true); + + tet_infoline( "Register visual with control and ensure it has the only handle" ); + DummyControl actor = DummyControl::New(true); + Impl::DummyControl& dummyImpl = static_cast(actor.GetImplementation()); + dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, imageVisual ); + imageVisual.Reset(); // reduce ref count so only the control keeps the visual alive. + + actor.SetSize(200.f, 200.f); + + application.SendNotification(); + application.Render(0); + DALI_TEST_CHECK( actor.GetRendererCount() == 0u ); + DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION ); + + Stage::GetCurrent().Add( actor ); + + // Wait for image to load + DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION ); + + application.SendNotification(); + application.Render(0); + // Test renderer and texture created + DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION ); + + tet_infoline( "Destroy visual by UnRegistering visual with control, check renderer is destroyed" ); + DALI_TEST_CHECK( actor.GetRendererCount() == 1u ); + dummyImpl.UnregisterVisual( DummyControl::Property::TEST_VISUAL ); + DALI_TEST_CHECK( actor.GetRendererCount() == 0u ); + application.SendNotification(); + application.Render(); + + tet_infoline( "Ensure texture is not deleted as policy is set to NEVER" ); + DALI_TEST_EQUALS( textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliImageVisualReleasePolicy04(void) +{ + ToolkitTestApplication application; + tet_infoline( "UtcDaliImageVisualReleasePolicy04 Two visuals with different policies sharing a texture" ); + + VisualFactory factory = VisualFactory::Get(); + + tet_infoline( "Create first visual with Never release policy" ); + Property::Map propertyMapNeverReleasePolicy; + propertyMapNeverReleasePolicy.Insert( Visual::Property::TYPE, Visual::IMAGE ); + propertyMapNeverReleasePolicy.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME ); + propertyMapNeverReleasePolicy.Insert( ImageVisual::Property::DESIRED_WIDTH, 20 ); + propertyMapNeverReleasePolicy.Insert( ImageVisual::Property::DESIRED_HEIGHT, 30 ); + propertyMapNeverReleasePolicy.Insert( DevelImageVisual::Property::RELEASE_POLICY , DevelImageVisual::ReleasePolicy::NEVER ); + Visual::Base imageVisualNever = factory.CreateVisual( propertyMapNeverReleasePolicy ); + + tet_infoline( "Create second visual with Destroyed release policy"); + Property::Map propertyMapDestroyedReleasePolicy; + propertyMapDestroyedReleasePolicy.Insert( Visual::Property::TYPE, Visual::IMAGE ); + propertyMapDestroyedReleasePolicy.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME ); + propertyMapDestroyedReleasePolicy.Insert( ImageVisual::Property::DESIRED_WIDTH, 20 ); + propertyMapDestroyedReleasePolicy.Insert( ImageVisual::Property::DESIRED_HEIGHT, 30 ); + propertyMapDestroyedReleasePolicy.Insert( DevelImageVisual::Property::RELEASE_POLICY , DevelImageVisual::ReleasePolicy::DESTROYED ); + Visual::Base imageVisualDestroyed = factory.CreateVisual( propertyMapDestroyedReleasePolicy ); + + // Set up trace debug + TestGlAbstraction& gl = application.GetGlAbstraction(); + TraceCallStack& textureTrace = gl.GetTextureTrace(); + textureTrace.Enable(true); + + tet_infoline( "Register visuals with control and ensure it has the only handles" ); + DummyControl actor = DummyControl::New(true); + Impl::DummyControl& dummyImpl = static_cast(actor.GetImplementation()); + dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, imageVisualNever ); + dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL2, imageVisualDestroyed ); + imageVisualNever.Reset(); // reduce ref count so only the control keeps the visual alive. + imageVisualDestroyed.Reset(); // reduce ref count so only the control keeps the visual alive. + + actor.SetSize(200.f, 200.f); + + // Test initially zero renderers + application.SendNotification(); + application.Render(0); + DALI_TEST_CHECK( actor.GetRendererCount() == 0u ); + DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION ); + + Stage::GetCurrent().Add( actor ); + + // Wait for image to load + DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION ); + + application.SendNotification(); + application.Render(0); + tet_infoline( "Ensure a texture is created, shared amongst both visuals. Each visual has its own renderer" ); + DALI_TEST_EQUALS( actor.GetRendererCount(), 2u, TEST_LOCATION ); + DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION ); + + // Test renderer removed when visual destroyed + DALI_TEST_CHECK( actor.GetRendererCount() == 2u ); + dummyImpl.UnregisterVisual( DummyControl::Property::TEST_VISUAL2 ); // TEST_VISUAL2 no longer requires the texture as release policy DESTROYED + DALI_TEST_CHECK( actor.GetRendererCount() == 1u ); + application.SendNotification(); + application.Render(); + + // Test texture was not deleted as TEST_VISUAL release policy is NEVER so it is still required. + DALI_TEST_EQUALS( textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION ); + + dummyImpl.UnregisterVisual( DummyControl::Property::TEST_VISUAL ); + DALI_TEST_CHECK( actor.GetRendererCount() == 0u ); + application.SendNotification(); + application.Render(); + + tet_infoline( "Ensure a texture is not deleted as second visual used the NEVER release policy" ); + // Test texture was not deleted as TEST_VISUAL release policy is NEVER so it is still required. + DALI_TEST_EQUALS( textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliImageVisualReleasePolicy05(void) +{ + ToolkitTestApplication application; + tet_infoline( "UtcDaliImageVisualReleasePolicy05 Testing settung by string currents correct enum" ); + + VisualFactory factory = VisualFactory::Get(); + + Property::Map propertyMapNeverReleasePolicy; + propertyMapNeverReleasePolicy.Insert( Visual::Property::TYPE, Visual::IMAGE ); + propertyMapNeverReleasePolicy.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME ); + propertyMapNeverReleasePolicy.Insert( ImageVisual::Property::DESIRED_WIDTH, 20 ); + propertyMapNeverReleasePolicy.Insert( ImageVisual::Property::DESIRED_HEIGHT, 30 ); + propertyMapNeverReleasePolicy.Insert( "releasePolicy" , "never" ); + + Visual::Base imageVisualNever = factory.CreateVisual( propertyMapNeverReleasePolicy ); + + Property::Map resultMap; + imageVisualNever.CreatePropertyMap( resultMap ); + DALI_TEST_CHECK( ! resultMap.Empty() ); + + DALI_TEST_EQUALS( ( resultMap.Find( DevelImageVisual::Property::RELEASE_POLICY ) )->Get(), (int)DevelImageVisual::ReleasePolicy::NEVER, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliImageVisualReleasePolicy06(void) +{ + ToolkitTestApplication application; + tet_infoline( "UtcDaliImageVisualReleasePolicy06 Never Policy, texture should not be affected by Disabling and Enabling visual" ); + + VisualFactory factory = VisualFactory::Get(); + + Property::Map propertyMap; + propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE ); + propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME ); + propertyMap.Insert( ImageVisual::Property::DESIRED_WIDTH, 20 ); + propertyMap.Insert( ImageVisual::Property::DESIRED_HEIGHT, 30 ); + propertyMap.Insert( DevelImageVisual::Property::RELEASE_POLICY , DevelImageVisual::ReleasePolicy::NEVER ); + + Visual::Base imageVisual = factory.CreateVisual(propertyMap); + DALI_TEST_CHECK( imageVisual ); + + TestGlAbstraction& gl = application.GetGlAbstraction(); + TraceCallStack& textureTrace = gl.GetTextureTrace(); + textureTrace.Enable(true); + + tet_infoline( "Register visual with control and ensure it has the only handle" ); + DummyControl actor = DummyControl::New(true); + Impl::DummyControl& dummyImpl = static_cast(actor.GetImplementation()); + dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, imageVisual ); + imageVisual.Reset(); // reduce ref count so only the control keeps the visual alive. + + actor.SetSize(200.f, 200.f); + + application.SendNotification(); + application.Render(0); + DALI_TEST_CHECK( actor.GetRendererCount() == 0u ); + DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION ); + + Stage::GetCurrent().Add( actor ); + + // Wait for image to load + DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION ); + + application.SendNotification(); + application.Render(0); + // Test renderer and texture created + DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION ); + DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION ); + textureTrace.Reset(); + + tet_infoline( "Disable Visual and check texture not affected" ); + dummyImpl.EnableVisual( DummyControl::Property::TEST_VISUAL, false ); + application.SendNotification(); + application.Render(0); + tet_infoline( "Check renderer is destroyed when visual off stage" ); + DALI_TEST_CHECK( actor.GetRendererCount() == 0u ); + DALI_TEST_EQUALS( textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION ); + DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION ); + textureTrace.Reset(); + + tet_infoline( "Re-enable Visual and check texture not affected" ); + dummyImpl.EnableVisual( DummyControl::Property::TEST_VISUAL, true ); + application.SendNotification(); + application.Render(0); + tet_infoline( "Check texture not affected and renderer is destroyed when visual off stage" ); + DALI_TEST_CHECK( actor.GetRendererCount() == 1u ); + DALI_TEST_EQUALS( textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION ); + DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliImageVisualReleasePolicy07(void) +{ + ToolkitTestApplication application; + tet_infoline( "UtcDaliImageVisualReleasePolicy07 Two visuals with different policies sharing a texture DETACHED and DESTROYED" ); + + VisualFactory factory = VisualFactory::Get(); + + tet_infoline( "Create first visual with DESTROYED release policy" ); + Property::Map propertyMapNeverReleasePolicy; + propertyMapNeverReleasePolicy.Insert( Visual::Property::TYPE, Visual::IMAGE ); + propertyMapNeverReleasePolicy.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME ); + propertyMapNeverReleasePolicy.Insert( ImageVisual::Property::DESIRED_WIDTH, 20 ); + propertyMapNeverReleasePolicy.Insert( ImageVisual::Property::DESIRED_HEIGHT, 30 ); + propertyMapNeverReleasePolicy.Insert( DevelImageVisual::Property::RELEASE_POLICY , DevelImageVisual::ReleasePolicy::DESTROYED ); + Visual::Base imageVisualDestroyed = factory.CreateVisual( propertyMapNeverReleasePolicy ); + + tet_infoline( "Create second visual with DETACHED release policy"); + Property::Map propertyMapDestroyedReleasePolicy; + propertyMapDestroyedReleasePolicy.Insert( Visual::Property::TYPE, Visual::IMAGE ); + propertyMapDestroyedReleasePolicy.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME ); + propertyMapDestroyedReleasePolicy.Insert( ImageVisual::Property::DESIRED_WIDTH, 20 ); + propertyMapDestroyedReleasePolicy.Insert( ImageVisual::Property::DESIRED_HEIGHT, 30 ); + propertyMapDestroyedReleasePolicy.Insert( DevelImageVisual::Property::RELEASE_POLICY , DevelImageVisual::ReleasePolicy::DETACHED ); + Visual::Base imageVisualDetached = factory.CreateVisual( propertyMapDestroyedReleasePolicy ); + + // Set up trace debug + TestGlAbstraction& gl = application.GetGlAbstraction(); + TraceCallStack& textureTrace = gl.GetTextureTrace(); + textureTrace.Enable(true); + + tet_infoline( "Register visuals with control and ensure it has the only handles" ); + DummyControl actor = DummyControl::New(true); + Impl::DummyControl& dummyImpl = static_cast(actor.GetImplementation()); + dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, imageVisualDestroyed ); + dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL2, imageVisualDetached ); + imageVisualDestroyed.Reset(); // reduce ref count so only the control keeps the visual alive. + imageVisualDetached.Reset(); // reduce ref count so only the control keeps the visual alive. + + actor.SetSize(200.f, 200.f); + + // Test initially zero renderers + application.SendNotification(); + application.Render(0); + DALI_TEST_CHECK( actor.GetRendererCount() == 0u ); + DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION ); + + Stage::GetCurrent().Add( actor ); + + // Wait for image to load + DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION ); + + application.SendNotification(); + application.Render(0); + tet_infoline( "Ensure a texture is created, shared amongst both visuals. Each visual has its own renderer" ); + DALI_TEST_EQUALS( actor.GetRendererCount(), 2u, TEST_LOCATION ); + DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION ); + + // Test renderer removed when visual destroyed + DALI_TEST_CHECK( actor.GetRendererCount() == 2u ); + dummyImpl.EnableVisual( DummyControl::Property::TEST_VISUAL2, false ); // TEST_VISUAL2 no longer requires the texture as release policy DETACHED + DALI_TEST_CHECK( actor.GetRendererCount() == 1u ); + application.SendNotification(); + application.Render(); + + // Test texture was not deleted as TEST_VISUAL release policy is DESTROYED and is still required. + DALI_TEST_EQUALS( textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION ); + + dummyImpl.EnableVisual( DummyControl::Property::TEST_VISUAL, false ); + DALI_TEST_CHECK( actor.GetRendererCount() == 0u ); + application.SendNotification(); + application.Render(); + + tet_infoline( "Ensure a texture is not deleted as second visual used the DESTROYED release policy" ); + DALI_TEST_EQUALS( textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION ); + + END_TEST; +} diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp index d93a39e..6eefd84 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp @@ -281,7 +281,17 @@ bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Ma { const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index ); - Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.stringKey ); + Property::Value* valueSet = NULL; + if ( valueGet.first.type == Property::Key::INDEX ) + { + valueSet = fontStyleMapSet.Find( valueGet.first.indexKey ); + } + else + { + // Get Key is a string so searching Set Map for a string key + valueSet = fontStyleMapSet.Find( valueGet.first.stringKey ); + } + if( NULL != valueSet ) { if( valueGet.second.Get() != valueSet->Get() ) @@ -292,7 +302,14 @@ bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Ma } else { - tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() ); + if ( valueGet.first.type == Property::Key::INDEX ) + { + tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey ); + } + else + { + tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() ); + } return false; } } @@ -796,67 +813,87 @@ int UtcDaliTextEditorSetPropertyP(void) Property::Map placeholderPixelSizeMapSet; Property::Map placeholderPixelSizeMapGet; Property::Map placeholderFontstyleMap; - placeholderPixelSizeMapSet["placeholderText"] = "Setting Placeholder Text"; - placeholderPixelSizeMapSet["placeholderTextFocused"] = "Setting Placeholder Text Focused"; - placeholderPixelSizeMapSet["placeholderColor"] = Color::BLUE; - placeholderPixelSizeMapSet["placeholderFontFamily"] = "Arial"; - placeholderPixelSizeMapSet["placeholderPixelSize"] = 15.0f; + placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text"; + placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused"; + placeholderPixelSizeMapSet["color"] = Color::BLUE; + placeholderPixelSizeMapSet["fontFamily"] = "Arial"; + placeholderPixelSizeMapSet["pixelSize"] = 15.0f; placeholderFontstyleMap.Insert( "weight", "bold" ); - placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap; + placeholderPixelSizeMapSet["fontStyle"] = placeholderFontstyleMap; editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet ); placeholderPixelSizeMapGet = editor.GetProperty( TextEditor::Property::PLACEHOLDER ); DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION ); - DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION ); + + tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value"); + Property::Map placeholderConversionMap; + placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"]; + placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ; + placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"]; + placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"]; + placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"]; + placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"]; + + DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION ); // Check the placeholder property with point size Property::Map placeholderMapSet; Property::Map placeholderMapGet; - placeholderMapSet["placeholderText"] = "Setting Placeholder Text"; - placeholderMapSet["placeholderTextFocused"] = "Setting Placeholder Text Focused"; - placeholderMapSet["placeholderColor"] = Color::RED; - placeholderMapSet["placeholderFontFamily"] = "Arial"; - placeholderMapSet["placeholderPointSize"] = 12.0f; - + placeholderMapSet["text"] = "Setting Placeholder Text"; + placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused"; + placeholderMapSet["color"] = Color::RED; + placeholderMapSet["fontFamily"] = "Arial"; + placeholderMapSet["pointSize"] = 12.0f; // Check the placeholder font style property placeholderFontstyleMap.Clear(); placeholderFontstyleMap.Insert( "weight", "bold" ); placeholderFontstyleMap.Insert( "width", "condensed" ); placeholderFontstyleMap.Insert( "slant", "italic" ); - placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap; + placeholderMapSet["fontStyle"] = placeholderFontstyleMap; editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet ); placeholderMapGet = editor.GetProperty( TextEditor::Property::PLACEHOLDER ); DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION ); - DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION ); + + tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value"); + placeholderConversionMap.Clear(); + placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderMapSet["text"]; + placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderMapSet["textFocused"] ; + placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderMapSet["color"]; + placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"]; + placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderMapSet["fontFamily"]; + placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderMapSet["pointSize"]; + DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION ); // Reset font style. placeholderFontstyleMap.Clear(); placeholderFontstyleMap.Insert( "weight", "normal" ); placeholderFontstyleMap.Insert( "slant", "oblique" ); - placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap; + placeholderMapSet["fontStyle"] = placeholderFontstyleMap; editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet ); placeholderMapGet = editor.GetProperty( TextEditor::Property::PLACEHOLDER ); DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION ); - DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION ); + placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"]; + DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION ); placeholderFontstyleMap.Clear(); placeholderFontstyleMap.Insert( "slant", "roman" ); - placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap; + placeholderMapSet["fontStyle"] = placeholderFontstyleMap; editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet ); placeholderMapGet = editor.GetProperty( TextEditor::Property::PLACEHOLDER ); placeholderFontstyleMap.Clear(); - placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap; + placeholderMapSet["fontStyle"] = placeholderFontstyleMap; editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet ); placeholderMapGet = editor.GetProperty( TextEditor::Property::PLACEHOLDER ); DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION ); - DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION ); + placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"]; + DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION ); END_TEST; } diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp index 66f1875..3e5e7b1 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp @@ -877,12 +877,12 @@ int UtcDaliTextFieldSetPropertyP(void) Property::Map placeholderPixelSizeMapSet; Property::Map placeholderPixelSizeMapGet; Property::Map placeholderFontstyleMap; - placeholderPixelSizeMapSet["placeholderText"] = "Setting Placeholder Text"; - placeholderPixelSizeMapSet["placeholderTextFocused"] = "Setting Placeholder Text Focused"; - placeholderPixelSizeMapSet["placeholderColor"] = Color::BLUE; - placeholderPixelSizeMapSet["placeholderFontFamily"] = "Arial"; - placeholderPixelSizeMapSet["placeholderPixelSize"] = 15.0f; - placeholderPixelSizeMapSet["placeholderEllipsis"] = true; + placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text"; + placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused"; + placeholderPixelSizeMapSet["color"] = Color::BLUE; + placeholderPixelSizeMapSet["fontFamily"] = "Arial"; + placeholderPixelSizeMapSet["pixelSize"] = 15.0f; + placeholderPixelSizeMapSet["ellipsis"] = true; placeholderFontstyleMap.Insert( "weight", "bold" ); placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap; @@ -890,17 +890,27 @@ int UtcDaliTextFieldSetPropertyP(void) placeholderPixelSizeMapGet = field.GetProperty( TextField::Property::PLACEHOLDER ); DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION ); - DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION ); + + tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value"); + Property::Map placeholderConversionMap; + placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"]; + placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ; + placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"]; + placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"]; + placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"]; + placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"]; + + DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION ); // Check the placeholder property with point size Property::Map placeholderMapSet; Property::Map placeholderMapGet; - placeholderMapSet["placeholderText"] = "Setting Placeholder Text"; - placeholderMapSet["placeholderTextFocused"] = "Setting Placeholder Text Focused"; - placeholderMapSet["placeholderColor"] = Color::RED; - placeholderMapSet["placeholderFontFamily"] = "Arial"; - placeholderMapSet["placeholderPointSize"] = 12.0f; - placeholderMapSet["placeholderEllipsis"] = false; + placeholderMapSet["text"] = "Setting Placeholder Text"; + placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused"; + placeholderMapSet["color"] = Color::RED; + placeholderMapSet["fontFamily"] = "Arial"; + placeholderMapSet["pointSize"] = 12.0f; + placeholderMapSet["ellipsis"] = false; // Check the placeholder font style property placeholderFontstyleMap.Clear(); @@ -908,38 +918,53 @@ int UtcDaliTextFieldSetPropertyP(void) placeholderFontstyleMap.Insert( "weight", "bold" ); placeholderFontstyleMap.Insert( "width", "condensed" ); placeholderFontstyleMap.Insert( "slant", "italic" ); - placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap; + placeholderMapSet["fontStyle"] = placeholderFontstyleMap; field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet ); placeholderMapGet = field.GetProperty( TextField::Property::PLACEHOLDER ); DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION ); - DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION ); + + placeholderConversionMap.Clear(); + placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"]; + placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ; + placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"]; + placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"]; + placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"]; + placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderPixelSizeMapSet["pointSize"]; + + DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION ); // Reset font style. placeholderFontstyleMap.Clear(); placeholderFontstyleMap.Insert( "weight", "normal" ); placeholderFontstyleMap.Insert( "slant", "oblique" ); - placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap; + placeholderMapSet["fontStyle"] = placeholderFontstyleMap; field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet ); placeholderMapGet = field.GetProperty( TextField::Property::PLACEHOLDER ); DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION ); - DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION ); + + placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"]; + DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION ); placeholderFontstyleMap.Clear(); placeholderFontstyleMap.Insert( "slant", "roman" ); - placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap; + placeholderMapSet["fontStyle"] = placeholderFontstyleMap; + placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"]; + field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet ); placeholderMapGet = field.GetProperty( TextField::Property::PLACEHOLDER ); placeholderFontstyleMap.Clear(); - placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap; + placeholderMapSet["fontStyle"] = placeholderFontstyleMap; + placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"]; field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet ); placeholderMapGet = field.GetProperty( TextField::Property::PLACEHOLDER ); DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION ); - DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION ); + + DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION ); // Check the ellipsis property DALI_TEST_CHECK( !field.GetProperty( TextField::Property::ELLIPSIS ) ); @@ -2578,3 +2603,83 @@ int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void) END_TEST; } + +int UtcDaliTextFieldSettingPlaceholder(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliTextFieldSettingPlaceholder"); + + TextField field = TextField::New(); + DALI_TEST_CHECK( field ); + Stage::GetCurrent().Add( field ); + + // Check the placeholder property with pixel size + Property::Map placeholderPixelSizeMapSet; + Property::Map placeholderPixelSizeMapGet; + Property::Map placeholderFontstyleMap; + placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text"; + placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused"; + placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::BLUE; + placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial"; + placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::PIXEL_SIZE ] = 15.0f; + placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = true; + + placeholderFontstyleMap.Insert( "weight", "bold" ); + placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap; + field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet ); + + placeholderPixelSizeMapGet = field.GetProperty( TextField::Property::PLACEHOLDER ); + DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION ); + + // Check the placeholder property with point size + Property::Map placeholderMapSet; + Property::Map placeholderMapGet; + placeholderMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text"; + placeholderMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused"; + placeholderMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::RED; + placeholderMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial"; + placeholderMapSet[ Text::PlaceHolder::Property::POINT_SIZE ] = 12.0f; + placeholderMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = false; + + // Check the placeholder font style property + placeholderFontstyleMap.Clear(); + + placeholderFontstyleMap.Insert( "weight", "bold" ); + placeholderFontstyleMap.Insert( "width", "condensed" ); + placeholderFontstyleMap.Insert( "slant", "italic" ); + placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap; + field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet ); + + placeholderMapGet = field.GetProperty( TextField::Property::PLACEHOLDER ); + DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION ); + + // Reset font style. + placeholderFontstyleMap.Clear(); + placeholderFontstyleMap.Insert( "weight", "normal" ); + placeholderFontstyleMap.Insert( "slant", "oblique" ); + placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap; + field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet ); + + placeholderMapGet = field.GetProperty( TextField::Property::PLACEHOLDER ); + DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION ); + + placeholderFontstyleMap.Clear(); + placeholderFontstyleMap.Insert( "slant", "roman" ); + placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap; + field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet ); + + placeholderMapGet = field.GetProperty( TextField::Property::PLACEHOLDER ); + + placeholderFontstyleMap.Clear(); + placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap; + + field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet ); + placeholderMapGet = field.GetProperty( TextField::Property::PLACEHOLDER ); + DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION ); + DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION ); + + END_TEST; +} diff --git a/automated-tests/src/dali-toolkit/utc-Dali-VideoView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-VideoView.cpp index 884efc4..30a7e8c 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-VideoView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-VideoView.cpp @@ -405,3 +405,38 @@ int UtcDaliVideoViewMethodsForCoverage2(void) END_TEST; } + +int UtcDaliVideoViewPropertyUnderlay(void) +{ + ToolkitTestApplication application; + ToolkitApplication::DECODED_IMAGES_SUPPORTED = true; + + VideoView view = VideoView::New(); + DALI_TEST_CHECK( view ); + + Stage::GetCurrent().Add( view ); + + application.SendNotification(); + application.Render(); + + bool isUnderlay = view.GetProperty( Toolkit::VideoView::Property::UNDERLAY ).Get< bool >(); + DALI_TEST_CHECK( isUnderlay ); + + view.SetProperty( Toolkit::VideoView::Property::UNDERLAY, false ); + isUnderlay = view.GetProperty( Toolkit::VideoView::Property::UNDERLAY ).Get< bool >(); + DALI_TEST_CHECK( !isUnderlay ); + + view.SetProperty( Toolkit::VideoView::Property::UNDERLAY, true ); + isUnderlay = view.GetProperty( Toolkit::VideoView::Property::UNDERLAY ).Get< bool >(); + DALI_TEST_CHECK( isUnderlay ); + + // If platform api doesn't provide any API or feature for decoded images of video, + // UNDERLAY should be true + ToolkitApplication::DECODED_IMAGES_SUPPORTED = false; + + view.SetProperty( Toolkit::VideoView::Property::UNDERLAY, false ); + isUnderlay = view.GetProperty( Toolkit::VideoView::Property::UNDERLAY ).Get< bool >(); + DALI_TEST_CHECK( isUnderlay ); + + END_TEST; +} diff --git a/dali-toolkit/dali-toolkit.h b/dali-toolkit/dali-toolkit.h index 6e8cc5e..c6fafad 100644 --- a/dali-toolkit/dali-toolkit.h +++ b/dali-toolkit/dali-toolkit.h @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include diff --git a/dali-toolkit/devel-api/controls/control-devel.h b/dali-toolkit/devel-api/controls/control-devel.h index 2d20ee2..f6fd3a4 100644 --- a/dali-toolkit/devel-api/controls/control-devel.h +++ b/dali-toolkit/devel-api/controls/control-devel.h @@ -54,6 +54,8 @@ enum BACKGROUND_IMAGE = Control::Property::BACKGROUND_IMAGE, KEY_INPUT_FOCUS = Control::Property::KEY_INPUT_FOCUS, BACKGROUND = Control::Property::BACKGROUND, + MARGIN = Control::Property::MARGIN, + PADDING = Control::Property::PADDING, /** * @brief Displays a tooltip when the control is hovered over. @@ -66,7 +68,7 @@ enum * @note When retrieved, a Property::MAP is returned. * @see Toolkit::Tooltip */ - TOOLTIP = BACKGROUND + 1, + TOOLTIP = PADDING + 1, /** * @brief The current state of the control. @@ -74,7 +76,7 @@ enum * * @see DevelControl::State */ - STATE = BACKGROUND + 2, + STATE = PADDING + 2, /** * @brief The current sub state of the control. @@ -82,35 +84,35 @@ enum * * @see DevelControl::State */ - SUB_STATE = BACKGROUND + 3, + SUB_STATE = PADDING + 3, /** * @brief The actor ID of the left focusable control. * @details Name "leftFocusableActorId", type Property::INTEGER. * */ - LEFT_FOCUSABLE_ACTOR_ID = BACKGROUND + 4, + LEFT_FOCUSABLE_ACTOR_ID = PADDING + 4, /** * @brief The actor ID of the right focusable control. * @details Name "rightFocusableActorId", type Property::INTEGER. * */ - RIGHT_FOCUSABLE_ACTOR_ID = BACKGROUND + 5, + RIGHT_FOCUSABLE_ACTOR_ID = PADDING + 5, /** * @brief The actor ID of the up focusable control. * @details Name "upFocusableActorId", type Property::INTEGER. * */ - UP_FOCUSABLE_ACTOR_ID = BACKGROUND + 6, + UP_FOCUSABLE_ACTOR_ID = PADDING + 6, /** * @brief The actor ID of the down focusable control. * @details Name "downFocusableActorId", type Property::INTEGER. * */ - DOWN_FOCUSABLE_ACTOR_ID = BACKGROUND + 7 + DOWN_FOCUSABLE_ACTOR_ID = PADDING + 7 }; } // namespace Property diff --git a/dali-toolkit/devel-api/file.list b/dali-toolkit/devel-api/file.list index ed9059d..f93beb1 100644 --- a/dali-toolkit/devel-api/file.list +++ b/dali-toolkit/devel-api/file.list @@ -45,6 +45,9 @@ devel_api_src_files = \ devel_api_header_files = \ $(devel_api_src_dir)/direction-enums.h +devel_api_visuals_header_files = \ + $(devel_api_src_dir)/visuals/image-visual-properties-devel.h + devel_api_controls_header_files = \ $(devel_api_src_dir)/controls/control-depth-index-ranges.h \ $(devel_api_src_dir)/controls/control-devel.h \ diff --git a/dali-toolkit/devel-api/visuals/image-visual-properties-devel.h b/dali-toolkit/devel-api/visuals/image-visual-properties-devel.h new file mode 100644 index 0000000..d0c9379 --- /dev/null +++ b/dali-toolkit/devel-api/visuals/image-visual-properties-devel.h @@ -0,0 +1,94 @@ +#ifndef DALI_TOOLKIT_DEVEL_API_VISUALS_IMAGE_VISUAL_PROPERTIES_DEVEL_H +#define DALI_TOOLKIT_DEVEL_API_VISUALS_IMAGE_VISUAL_PROPERTIES_DEVEL_H + +/* + * Copyright (c) 2017 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. + * + */ + +// INTERNAL INCLUDES +#include + +namespace Dali +{ + +namespace Toolkit +{ + +namespace DevelImageVisual +{ + + +/** + * @brief The policy determining when a image is deleted from the cache in relation to the ImageVisual lifetime. + * @note If the texture is being shared by another visual it persist if still required. + */ +namespace ReleasePolicy +{ + +/** + * @brief The available named elements that define the ReleasePolicy. + */ +enum Type +{ + DETACHED = 0, ///< Image deleted from cache when ImageVisual detached from stage. + DESTROYED, ///< Image deleted from cache when ImageVisual destroyed. + NEVER ///< Image is never deleted, will survive the lifetime of the application. +}; + +} // namespace ReleasePolicy; + +namespace Property +{ + +enum Type +{ + URL = Dali::Toolkit::ImageVisual::Property::URL, + FITTING_MODE = Dali::Toolkit::ImageVisual::Property::FITTING_MODE, + SAMPLING_MODE = Dali::Toolkit::ImageVisual::Property::SAMPLING_MODE, + DESIRED_WIDTH = Dali::Toolkit::ImageVisual::Property::DESIRED_WIDTH, + DESIRED_HEIGHT = Dali::Toolkit::ImageVisual::Property::DESIRED_HEIGHT, + SYNCHRONOUS_LOADING = Dali::Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, + BORDER_ONLY = Dali::Toolkit::ImageVisual::Property::BORDER_ONLY, + PIXEL_AREA = Dali::Toolkit::ImageVisual::Property::PIXEL_AREA, + WRAP_MODE_U = Dali::Toolkit::ImageVisual::Property::WRAP_MODE_U, + WRAP_MODE_V = Dali::Toolkit::ImageVisual::Property::WRAP_MODE_V, + BORDER = Dali::Toolkit::ImageVisual::Property::BORDER, + ATLASING = Dali::Toolkit::ImageVisual::Property::ATLASING, + ALPHA_MASK_URL = Dali::Toolkit::ImageVisual::Property::ALPHA_MASK_URL, + BATCH_SIZE = Dali::Toolkit::ImageVisual::Property::BATCH_SIZE, + CACHE_SIZE = Dali::Toolkit::ImageVisual::Property::CACHE_SIZE, + FRAME_DELAY = Dali::Toolkit::ImageVisual::Property::FRAME_DELAY, + MASK_CONTENT_SCALE = Dali::Toolkit::ImageVisual::Property::MASK_CONTENT_SCALE, + CROP_TO_MASK = Dali::Toolkit::ImageVisual::Property::CROP_TO_MASK, + + /** + * @brief The policy to determine when an image should no longer be cached. + * @details Name "releasePolicy", Type ReleasePolicy::Type (Property::INTEGER) or Property::STRING + * @note Default ReleasePolicy::DESTROYED + * @see ReleasePolicy::Type + */ + RELEASE_POLICY = CROP_TO_MASK + 2, +}; + +} //namespace Property + +} // namespace DevelImageVisual + +} // namespace Toolkit + +} // namespace Dali + +#endif // DALI_TOOLKIT_DEVEL_API_VISUALS_IMAGE_VISUAL_PROPERTIES_DEVEL_H diff --git a/dali-toolkit/internal/builder/builder-declarations.h b/dali-toolkit/internal/builder/builder-declarations.h index 03627ba..831a478 100644 --- a/dali-toolkit/internal/builder/builder-declarations.h +++ b/dali-toolkit/internal/builder/builder-declarations.h @@ -2,7 +2,7 @@ #define __DALI_TOOLKIT_BUILDER_DECLARATIONS_H__ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 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. @@ -19,6 +19,7 @@ */ // EXTERNAL INCLUDES +#include #include #include #include @@ -46,5 +47,6 @@ typedef OptionalValue OptionalString; typedef OptionalValue OptionalMatrix; typedef OptionalValue OptionalMatrix3; typedef OptionalValue > OptionalRect; +typedef OptionalValue OptionalExtents; #endif // __DALI_TOOLKIT_BUILDER_DECLARATIONS_H__ diff --git a/dali-toolkit/internal/builder/builder-get-is.inl.h b/dali-toolkit/internal/builder/builder-get-is.inl.h index ae17837..63cd31e 100644 --- a/dali-toolkit/internal/builder/builder-get-is.inl.h +++ b/dali-toolkit/internal/builder/builder-get-is.inl.h @@ -260,6 +260,24 @@ inline OptionalRect IsRect(const OptionalChild& node) return ret; } +inline OptionalExtents IsExtents(const OptionalChild& node) +{ + OptionalExtents extents; + if(node && (*node).Size()) + { + if((*node).Size() >= 4) + { + TreeNode::ConstIterator iter((*node).CBegin()); + int v[4]; + if( CopyNumbers((*node).CBegin(), 4, v) ) + { + extents = OptionalExtents(Dali::Extents(v[0], v[1], v[2], v[3])); + } + } + } + return extents; +} + // // // @@ -313,6 +331,11 @@ inline OptionalRect IsRect(const TreeNode &parent, const std::string& childName) return IsRect( IsChild(&parent, childName) ); } +inline OptionalExtents IsExtents(const TreeNode &parent, const std::string& childName) +{ + return IsExtents( IsChild(&parent, childName) ); +} + // // // @@ -366,6 +389,11 @@ inline OptionalRect IsRect(const TreeNode &node ) return IsRect( OptionalChild( node ) ); } +inline OptionalExtents IsExtents(const TreeNode &node ) +{ + return IsExtents( OptionalChild( node ) ); +} + // // // diff --git a/dali-toolkit/internal/builder/builder-set-property.cpp b/dali-toolkit/internal/builder/builder-set-property.cpp index 93a1fbe..367c527 100644 --- a/dali-toolkit/internal/builder/builder-set-property.cpp +++ b/dali-toolkit/internal/builder/builder-set-property.cpp @@ -97,6 +97,10 @@ bool Disambiguated(const TreeNode& child, { return DeterminePropertyFromNode( *childValue, Dali::Property::ARRAY, value, replacement); } + else if(*childType == "extents") + { + return DeterminePropertyFromNode( *childValue, Dali::Property::EXTENTS, value, replacement); + } } // else we failed to disambiguate @@ -317,6 +321,15 @@ bool DeterminePropertyFromNode( const TreeNode& node, Property::Type type, Prope } break; } + case Property::EXTENTS: + { + if( OptionalExtents v = replacer.IsExtents(node) ) + { + value = *v; + done = true; + } + break; + } case Property::NONE: { break; diff --git a/dali-toolkit/internal/builder/replacement.cpp b/dali-toolkit/internal/builder/replacement.cpp index 07240be..a15ef21 100644 --- a/dali-toolkit/internal/builder/replacement.cpp +++ b/dali-toolkit/internal/builder/replacement.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 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. @@ -429,7 +429,23 @@ OptionalRect Replacement::IsRect( const TreeNode & node ) const return ret; } - +OptionalExtents Replacement::IsExtents( const TreeNode & node ) const +{ + OptionalExtents extents; + if( OptionalString replace = HasFullReplacement( node ) ) + { + Property::Value value = GetFullReplacement( *replace ); + if( Property::EXTENTS == value.GetType() ) + { + extents = value.Get(); + } + } + else + { + extents = ::IsExtents( node ); + } + return extents; +} OptionalFloat Replacement::IsFloat( OptionalChild child ) const { @@ -578,6 +594,18 @@ bool Replacement::IsArray( OptionalChild child, Property::Value& out ) const return ret; } +OptionalExtents Replacement::IsExtents( OptionalChild child ) const +{ + if( child ) + { + return IsExtents( *child ); + } + else + { + return OptionalExtents(); + } +} + } // namespace Internal } // namespace Toolkit diff --git a/dali-toolkit/internal/builder/replacement.h b/dali-toolkit/internal/builder/replacement.h index 3c4d829..1c4d34c 100644 --- a/dali-toolkit/internal/builder/replacement.h +++ b/dali-toolkit/internal/builder/replacement.h @@ -2,7 +2,7 @@ #define __DALI_TOOLKIT_INTERNAL_BUILDER_REPLACEMENT__ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 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. @@ -141,6 +141,13 @@ public: /* @brief Check node for a type * + * @param node The TreeNode to check + * @return Optional value + */ + OptionalExtents IsExtents( const TreeNode & node ) const; + + /* @brief Check node for a type + * * @param child The optional child TreeNode * @return Optional value */ @@ -223,6 +230,13 @@ public: */ bool IsArray( OptionalChild child, Property::Value& out ) const; + /* @brief Check node for a type + * + * @param child The optional child TreeNode + * @return Optional value + */ + OptionalExtents IsExtents( OptionalChild child ) const; + private: // Overriding map (overrides the default map). The map is not owned. const Property::Map* const mOverrideMap; diff --git a/dali-toolkit/internal/controls/control/control-data-impl.cpp b/dali-toolkit/internal/controls/control/control-data-impl.cpp index 43f3161..57cb46d 100644 --- a/dali-toolkit/internal/controls/control/control-data-impl.cpp +++ b/dali-toolkit/internal/controls/control/control-data-impl.cpp @@ -302,14 +302,15 @@ const PropertyRegistration Control::Impl::PROPERTY_2( typeRegistration, "backgro const PropertyRegistration Control::Impl::PROPERTY_3( typeRegistration, "backgroundImage", Toolkit::Control::Property::BACKGROUND_IMAGE, Property::MAP, &Control::Impl::SetProperty, &Control::Impl::GetProperty ); const PropertyRegistration Control::Impl::PROPERTY_4( typeRegistration, "keyInputFocus", Toolkit::Control::Property::KEY_INPUT_FOCUS, Property::BOOLEAN, &Control::Impl::SetProperty, &Control::Impl::GetProperty ); const PropertyRegistration Control::Impl::PROPERTY_5( typeRegistration, "background", Toolkit::Control::Property::BACKGROUND, Property::MAP, &Control::Impl::SetProperty, &Control::Impl::GetProperty ); -const PropertyRegistration Control::Impl::PROPERTY_6( typeRegistration, "tooltip", Toolkit::DevelControl::Property::TOOLTIP, Property::MAP, &Control::Impl::SetProperty, &Control::Impl::GetProperty ); -const PropertyRegistration Control::Impl::PROPERTY_7( typeRegistration, "state", Toolkit::DevelControl::Property::STATE, Property::STRING, &Control::Impl::SetProperty, &Control::Impl::GetProperty ); -const PropertyRegistration Control::Impl::PROPERTY_8( typeRegistration, "subState", Toolkit::DevelControl::Property::SUB_STATE, Property::STRING, &Control::Impl::SetProperty, &Control::Impl::GetProperty ); -const PropertyRegistration Control::Impl::PROPERTY_9( typeRegistration, "leftFocusableActorId", Toolkit::DevelControl::Property::LEFT_FOCUSABLE_ACTOR_ID, Property::INTEGER, &Control::Impl::SetProperty, &Control::Impl::GetProperty ); -const PropertyRegistration Control::Impl::PROPERTY_10( typeRegistration, "rightFocusableActorId", Toolkit::DevelControl::Property::RIGHT_FOCUSABLE_ACTOR_ID,Property::INTEGER, &Control::Impl::SetProperty, &Control::Impl::GetProperty ); -const PropertyRegistration Control::Impl::PROPERTY_11( typeRegistration, "upFocusableActorId", Toolkit::DevelControl::Property::UP_FOCUSABLE_ACTOR_ID, Property::INTEGER, &Control::Impl::SetProperty, &Control::Impl::GetProperty ); -const PropertyRegistration Control::Impl::PROPERTY_12( typeRegistration, "downFocusableActorId", Toolkit::DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID, Property::INTEGER, &Control::Impl::SetProperty, &Control::Impl::GetProperty ); - +const PropertyRegistration Control::Impl::PROPERTY_6( typeRegistration, "margin", Toolkit::Control::Property::MARGIN, Property::EXTENTS, &Control::Impl::SetProperty, &Control::Impl::GetProperty ); +const PropertyRegistration Control::Impl::PROPERTY_7( typeRegistration, "padding", Toolkit::Control::Property::PADDING, Property::EXTENTS, &Control::Impl::SetProperty, &Control::Impl::GetProperty ); +const PropertyRegistration Control::Impl::PROPERTY_8( typeRegistration, "tooltip", Toolkit::DevelControl::Property::TOOLTIP, Property::MAP, &Control::Impl::SetProperty, &Control::Impl::GetProperty ); +const PropertyRegistration Control::Impl::PROPERTY_9( typeRegistration, "state", Toolkit::DevelControl::Property::STATE, Property::STRING, &Control::Impl::SetProperty, &Control::Impl::GetProperty ); +const PropertyRegistration Control::Impl::PROPERTY_10( typeRegistration, "subState", Toolkit::DevelControl::Property::SUB_STATE, Property::STRING, &Control::Impl::SetProperty, &Control::Impl::GetProperty ); +const PropertyRegistration Control::Impl::PROPERTY_11( typeRegistration, "leftFocusableActorId", Toolkit::DevelControl::Property::LEFT_FOCUSABLE_ACTOR_ID, Property::INTEGER, &Control::Impl::SetProperty, &Control::Impl::GetProperty ); +const PropertyRegistration Control::Impl::PROPERTY_12( typeRegistration, "rightFocusableActorId", Toolkit::DevelControl::Property::RIGHT_FOCUSABLE_ACTOR_ID,Property::INTEGER, &Control::Impl::SetProperty, &Control::Impl::GetProperty ); +const PropertyRegistration Control::Impl::PROPERTY_13( typeRegistration, "upFocusableActorId", Toolkit::DevelControl::Property::UP_FOCUSABLE_ACTOR_ID, Property::INTEGER, &Control::Impl::SetProperty, &Control::Impl::GetProperty ); +const PropertyRegistration Control::Impl::PROPERTY_14( typeRegistration, "downFocusableActorId", Toolkit::DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID, Property::INTEGER, &Control::Impl::SetProperty, &Control::Impl::GetProperty ); Control::Impl::Impl( Control& controlImpl ) @@ -323,6 +324,8 @@ Control::Impl::Impl( Control& controlImpl ) mStyleName(""), mBackgroundColor(Color::TRANSPARENT), mStartingPinchScale( NULL ), + mMargin( 0, 0, 0, 0 ), + mPadding( 0, 0, 0, 0 ), mKeyEventSignal(), mPinchGestureDetector(), mPanGestureDetector(), @@ -910,6 +913,26 @@ void Control::Impl::SetProperty( BaseObject* object, Property::Index index, cons break; } + case Toolkit::Control::Property::MARGIN: + { + Extents margin; + if( value.Get( margin ) ) + { + controlImpl.mImpl->SetMargin( margin ); + } + break; + } + + case Toolkit::Control::Property::PADDING: + { + Extents padding; + if( value.Get( padding ) ) + { + controlImpl.mImpl->SetPadding( padding ); + } + break; + } + case Toolkit::DevelControl::Property::TOOLTIP: { TooltipPtr& tooltipPtr = controlImpl.mImpl->mTooltip; @@ -918,7 +941,9 @@ void Control::Impl::SetProperty( BaseObject* object, Property::Index index, cons tooltipPtr = Tooltip::New( control ); } tooltipPtr->SetProperties( value ); + break; } + } } } @@ -1016,6 +1041,18 @@ Property::Value Control::Impl::GetProperty( BaseObject* object, Property::Index break; } + case Toolkit::Control::Property::MARGIN: + { + value = controlImpl.mImpl->GetMargin(); + break; + } + + case Toolkit::Control::Property::PADDING: + { + value = controlImpl.mImpl->GetPadding(); + break; + } + case Toolkit::DevelControl::Property::TOOLTIP: { Property::Map map; @@ -1026,7 +1063,6 @@ Property::Value Control::Impl::GetProperty( BaseObject* object, Property::Index value = map; break; } - } } @@ -1298,6 +1334,26 @@ void Control::Impl::OnStageDisconnection() mRemoveVisuals.Clear(); } +void Control::Impl::SetMargin( Extents margin ) +{ + mControlImpl.mImpl->mMargin = margin; +} + +Extents Control::Impl::GetMargin() const +{ + return mControlImpl.mImpl->mMargin; +} + +void Control::Impl::SetPadding( Extents padding ) +{ + mControlImpl.mImpl->mPadding = padding; +} + +Extents Control::Impl::GetPadding() const +{ + return mControlImpl.mImpl->mPadding; +} + } // namespace Internal } // namespace Toolkit diff --git a/dali-toolkit/internal/controls/control/control-data-impl.h b/dali-toolkit/internal/controls/control/control-data-impl.h index dc00d60..2e1d4c9 100644 --- a/dali-toolkit/internal/controls/control/control-data-impl.h +++ b/dali-toolkit/internal/controls/control/control-data-impl.h @@ -265,6 +265,30 @@ public: */ void OnStageDisconnection(); + /** + * @brief Sets the margin. + * @param[in] margin Margin is a collections of extent ( start, end, top, bottom ) + */ + void SetMargin( Extents margin ); + + /** + * @brief Returns the value of margin + * @return The value of margin + */ + Extents GetMargin() const; + + /** + * @brief Sets the padding. + * @param[in] padding Padding is a collections of extent ( start, end, top, bottom ). + */ + void SetPadding( Extents padding ); + + /** + * @brief Returns the value of padding + * @return The value of padding + */ + Extents GetPadding() const; + private: /** @@ -319,6 +343,8 @@ public: std::string mStyleName; Vector4 mBackgroundColor; ///< The color of the background visual Vector3* mStartingPinchScale; ///< The scale when a pinch gesture starts, TODO: consider removing this + Extents mMargin; ///< The margin values + Extents mPadding; ///< The padding values Toolkit::Control::KeyEventSignalType mKeyEventSignal; Toolkit::Control::KeyInputFocusSignalType mKeyInputFocusGainedSignal; Toolkit::Control::KeyInputFocusSignalType mKeyInputFocusLostSignal; @@ -352,6 +378,8 @@ public: static const PropertyRegistration PROPERTY_10; static const PropertyRegistration PROPERTY_11; static const PropertyRegistration PROPERTY_12; + static const PropertyRegistration PROPERTY_13; + static const PropertyRegistration PROPERTY_14; }; diff --git a/dali-toolkit/internal/controls/image-view/image-view-impl.cpp b/dali-toolkit/internal/controls/image-view/image-view-impl.cpp index e7514b0..37b2dd5 100644 --- a/dali-toolkit/internal/controls/image-view/image-view-impl.cpp +++ b/dali-toolkit/internal/controls/image-view/image-view-impl.cpp @@ -180,6 +180,12 @@ Vector3 ImageView::GetNaturalSize() { Vector2 rendererNaturalSize; mVisual.GetNaturalSize( rendererNaturalSize ); + + Extents padding; + padding = Self().GetProperty( Toolkit::Control::Property::PADDING ); + + rendererNaturalSize.width += ( padding.start + padding.end ); + rendererNaturalSize.height += ( padding.top + padding.bottom ); return Vector3( rendererNaturalSize ); } @@ -189,25 +195,31 @@ Vector3 ImageView::GetNaturalSize() float ImageView::GetHeightForWidth( float width ) { + Extents padding; + padding = Self().GetProperty( Toolkit::Control::Property::PADDING ); + if( mVisual ) { - return mVisual.GetHeightForWidth( width ); + return mVisual.GetHeightForWidth( width ) + padding.top + padding.bottom; } else { - return Control::GetHeightForWidth( width ); + return Control::GetHeightForWidth( width ) + padding.top + padding.bottom; } } float ImageView::GetWidthForHeight( float height ) { + Extents padding; + padding = Self().GetProperty( Toolkit::Control::Property::PADDING ); + if( mVisual ) { - return mVisual.GetWidthForHeight( height ); + return mVisual.GetWidthForHeight( height ) + padding.start + padding.end; } else { - return Control::GetWidthForHeight( height ); + return Control::GetWidthForHeight( height ) + padding.start + padding.end; } } @@ -217,9 +229,25 @@ void ImageView::OnRelayout( const Vector2& size, RelayoutContainer& container ) if( mVisual ) { - // Pass in an empty map which uses default transform values meaning our visual fills the control + Extents margin; + margin = Self().GetProperty( Toolkit::Control::Property::MARGIN ); + + Extents padding; + padding = Self().GetProperty( Toolkit::Control::Property::PADDING ); + + Property::Map transformMap = Property::Map(); + + if( ( padding.start != 0 ) || ( padding.end != 0 ) || ( padding.top != 0 ) || ( padding.bottom != 0 ) || + ( margin.start != 0 ) || ( margin.end != 0 ) || ( margin.top != 0 ) || ( margin.bottom != 0 ) ) + { + transformMap.Add( Toolkit::Visual::Transform::Property::OFFSET, Vector2( margin.start + padding.start, margin.top + padding.top ) ) + .Add( Toolkit::Visual::Transform::Property::OFFSET_POLICY, Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ) ) + .Add( Toolkit::Visual::Transform::Property::ORIGIN, Toolkit::Align::TOP_BEGIN ) + .Add( Toolkit::Visual::Transform::Property::ANCHOR_POINT, Toolkit::Align::TOP_BEGIN ); + } + // Should provide a transform that handles aspect ratio according to image size - mVisual.SetTransformAndSize( Property::Map(), size ); + mVisual.SetTransformAndSize( transformMap, size ); } } diff --git a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp index 13cf696..148462a 100644 --- a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp @@ -21,6 +21,7 @@ // EXTERNAL INCLUDES #include #include +#include #include // INTERNAL INCLUDES @@ -919,8 +920,24 @@ void TextLabel::SetUpAutoScrolling() Vector2 textureSize = textNaturalSize + Vector2(wrapGap, 0.0f); // Add the gap as a part of the texture // Create a texture of the text for scrolling + Size verifiedSize = textureSize; + const int maxTextureSize = Dali::GetMaxTextureSize(); + + //if the texture size width exceed maxTextureSize, modify the visual model size and enabled the ellipsis + if( verifiedSize.width > maxTextureSize ) + { + verifiedSize.width = maxTextureSize; + if( textNaturalSize.width > maxTextureSize ) + { + mController->SetTextElideEnabled( true ); + } + GetHeightForWidth( maxTextureSize ); + wrapGap = std::max( maxTextureSize - textNaturalSize.width, 0.0f ); + } + Text::TypesetterPtr typesetter = Text::Typesetter::New( mController->GetTextModel() ); - PixelData data = typesetter->Render( textureSize, Text::Typesetter::RENDER_TEXT_AND_STYLES, true, Pixel::RGBA8888 ); // ignore the horizontal alignment + + PixelData data = typesetter->Render( verifiedSize, Text::Typesetter::RENDER_TEXT_AND_STYLES, true, Pixel::RGBA8888 ); // ignore the horizontal alignment Texture texture = Texture::New( Dali::TextureType::TEXTURE_2D, data.GetPixelFormat(), data.GetWidth(), @@ -938,7 +955,7 @@ void TextLabel::SetUpAutoScrolling() // Set parameters for scrolling Renderer renderer = static_cast( GetImplementation( mVisual ) ).GetRenderer(); - mTextScroller->SetParameters( Self(), renderer, textureSet, controlSize, textureSize, wrapGap, direction, mController->GetHorizontalAlignment(), mController->GetVerticalAlignment() ); + mTextScroller->SetParameters( Self(), renderer, textureSet, controlSize, verifiedSize, wrapGap, direction, mController->GetHorizontalAlignment(), mController->GetVerticalAlignment() ); } void TextLabel::ScrollingFinished() diff --git a/dali-toolkit/internal/controls/video-view/video-view-impl.cpp b/dali-toolkit/internal/controls/video-view/video-view-impl.cpp index 2fdb70b..5834950 100644 --- a/dali-toolkit/internal/controls/video-view/video-view-impl.cpp +++ b/dali-toolkit/internal/controls/video-view/video-view-impl.cpp @@ -62,6 +62,7 @@ DALI_PROPERTY_REGISTRATION( Toolkit, VideoView, "video", MAP, VIDEO ) DALI_PROPERTY_REGISTRATION( Toolkit, VideoView, "looping", BOOLEAN, LOOPING ) DALI_PROPERTY_REGISTRATION( Toolkit, VideoView, "muted", BOOLEAN, MUTED ) DALI_PROPERTY_REGISTRATION( Toolkit, VideoView, "volume", MAP, VOLUME ) +DALI_PROPERTY_REGISTRATION( Toolkit, VideoView, "underlay", BOOLEAN, UNDERLAY ) DALI_SIGNAL_REGISTRATION( Toolkit, VideoView, "finished", FINISHED_SIGNAL ) @@ -75,6 +76,8 @@ DALI_TYPE_REGISTRATION_END() const char* const VOLUME_LEFT( "volumeLeft" ); const char* const VOLUME_RIGHT( "volumeRight" ); + +// 3.0 TC uses RENDERING_TARGET. It should be removed in next release const char* const RENDERING_TARGET( "renderingTarget" ); const char* const WINDOW_SURFACE_TARGET( "windowSurfaceTarget" ); const char* const NATIVE_IMAGE_TARGET( "nativeImageTarget" ); @@ -128,9 +131,9 @@ VideoView::VideoView() mUpdateTriggerPropertyIndex( Property::INVALID_INDEX), mNotification( NULL ), mCurrentVideoPlayPosition( 0 ), - mIsNativeImageTarget( true ), mIsPlay( false ), - mIsPause( false ) + mIsPause( false ), + mIsUnderlay( true ) { mVideoPlayer = Dali::VideoPlayer::New(); @@ -159,14 +162,9 @@ Toolkit::VideoView VideoView::New() void VideoView::OnInitialize() { - Any source; - Dali::NativeImageSourcePtr nativeImageSourcePtr = Dali::NativeImageSource::New( source ); - mNativeImage = Dali::NativeImage::New( *nativeImageSourcePtr ); - - mVideoPlayer.SetRenderingTarget( nativeImageSourcePtr ); - mVideoPlayer.FinishedSignal().Connect( this, &VideoView::EmitSignalFinish ); - mUpdateTriggerPropertyIndex = Self().RegisterProperty( "updateTrigger", true ); + mVideoPlayer.FinishedSignal().Connect( this, &VideoView::EmitSignalFinish ); + SetWindowSurfaceTarget(); } void VideoView::SetUrl( const std::string& url ) @@ -177,7 +175,7 @@ void VideoView::SetUrl( const std::string& url ) mPropertyMap.Clear(); } - if( mIsNativeImageTarget ) + if( !mIsUnderlay ) { Actor self( Self() ); Internal::InitializeVisual( self, mVisual, mNativeImage ); @@ -218,11 +216,13 @@ void VideoView::SetPropertyMap( Property::Map map ) if( target && target->Get( targetType ) && targetType == WINDOW_SURFACE_TARGET ) { - this->SetWindowSurfaceTarget(); + mIsUnderlay = true; + SetWindowSurfaceTarget(); } else if( target && target->Get( targetType ) && targetType == NATIVE_IMAGE_TARGET ) { - this->SetNativeImageTarget(); + mIsUnderlay = false; + SetNativeImageTarget(); } RelayoutRequest(); @@ -465,6 +465,15 @@ void VideoView::SetProperty( BaseObject* object, Property::Index index, const Pr } break; } + case Toolkit::VideoView::Property::UNDERLAY: + { + bool underlay; + if( value.Get( underlay ) ) + { + impl.SetUnderlay( underlay ); + } + break; + } } } } @@ -513,6 +522,11 @@ Property::Value VideoView::GetProperty( BaseObject* object, Property::Index prop value = map; break; } + case Toolkit::VideoView::Property::UNDERLAY: + { + value = impl.IsUnderlay(); + break; + } } } @@ -609,7 +623,22 @@ void VideoView::SetWindowSurfaceTarget() mVideoPlayer.SetRenderingTarget( Dali::Adaptor::Get().GetNativeWindowHandle() ); mVideoPlayer.SetUrl( mUrl ); - mIsNativeImageTarget = false; + if( !mRenderer ) + { + // For underlay rendering mode, video display area have to be transparent. + Geometry geometry = VisualFactoryCache::CreateQuadGeometry(); + Shader shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER ); + mRenderer = Renderer::New( geometry, shader ); + + mRenderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON ); + mRenderer.SetProperty( Renderer::Property::BLEND_FACTOR_SRC_RGB, BlendFactor::ONE ); + mRenderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_RGB, BlendFactor::ZERO ); + mRenderer.SetProperty( Renderer::Property::BLEND_FACTOR_SRC_ALPHA, BlendFactor::ONE ); + mRenderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_ALPHA, BlendFactor::ZERO ); + } + self.AddRenderer( mRenderer ); + + UpdateDisplayArea(); if( mIsPlay ) { @@ -625,22 +654,17 @@ void VideoView::SetWindowSurfaceTarget() { mVideoPlayer.SetPlayPosition( curPos ); } - - // For underlay rendering mode, video display area have to be transparent. - Geometry geometry = VisualFactoryCache::CreateQuadGeometry(); - Shader shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER ); - Renderer renderer = Renderer::New( geometry, shader ); - - renderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON ); - renderer.SetProperty( Renderer::Property::BLEND_FACTOR_SRC_RGB, BlendFactor::ONE ); - renderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_RGB, BlendFactor::ZERO ); - renderer.SetProperty( Renderer::Property::BLEND_FACTOR_SRC_ALPHA, BlendFactor::ONE ); - renderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_ALPHA, BlendFactor::ZERO ); - self.AddRenderer( renderer ); } void VideoView::SetNativeImageTarget() { + if( mVideoPlayer.IsVideoTextureSupported() == false ) + { + DALI_LOG_ERROR( "Platform doesn't support decoded video frame images\n" ); + mIsUnderlay = true; + return; + } + Actor self( Self() ); int curPos = mVideoPlayer.GetPlayPosition(); @@ -652,7 +676,7 @@ void VideoView::SetNativeImageTarget() mVideoPlayer.SetUrl( mUrl ); Internal::InitializeVisual( self, mVisual, mNativeImage ); - mIsNativeImageTarget = true; + Self().RemoveRenderer( mRenderer ); if( mIsPlay ) { @@ -672,6 +696,11 @@ void VideoView::SetNativeImageTarget() void VideoView::UpdateDisplayArea() { + if( !mIsUnderlay ) + { + return; + } + Actor self( Self() ); bool positionUsesAnchorPoint = self.GetProperty( DevelActor::Property::POSITION_USES_ANCHOR_POINT ).Get< bool >(); @@ -688,6 +717,28 @@ void VideoView::UpdateDisplayArea() mVideoPlayer.SetDisplayArea( mDisplayArea ); } +void VideoView::SetUnderlay( bool set ) +{ + if( set != mIsUnderlay ) + { + mIsUnderlay = set; + + if( mIsUnderlay ) + { + SetWindowSurfaceTarget(); + } + else + { + SetNativeImageTarget(); + } + } +} + +bool VideoView::IsUnderlay() +{ + return mIsUnderlay; +} + } // namespace Internal } // namespace toolkit diff --git a/dali-toolkit/internal/controls/video-view/video-view-impl.h b/dali-toolkit/internal/controls/video-view/video-view-impl.h index 130d2c2..d5a498a 100644 --- a/dali-toolkit/internal/controls/video-view/video-view-impl.h +++ b/dali-toolkit/internal/controls/video-view/video-view-impl.h @@ -207,11 +207,21 @@ public: */ static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor ); - /* + /** * @brief Updates video display area for window rendering target */ void UpdateDisplayArea(); + /** + * @brief Sets underlay flag and initializes new rendering target by flag. + */ + void SetUnderlay( bool set ); + + /** + * @brief Checks underlay flag. + */ + bool IsUnderlay(); + private: // From Control /** @@ -265,14 +275,15 @@ private: Dali::Toolkit::VideoView::VideoViewSignalType mFinishedSignal; std::string mUrl; Dali::DisplayArea mDisplayArea; + Dali::Renderer mRenderer; Property::Index mUpdateTriggerPropertyIndex; TriggerEventInterface* mNotification; int mCurrentVideoPlayPosition; - bool mIsNativeImageTarget; bool mIsPlay; bool mIsPause; + bool mIsUnderlay; }; } // namespace Internal diff --git a/dali-toolkit/internal/text/rendering/text-typesetter.cpp b/dali-toolkit/internal/text/rendering/text-typesetter.cpp index 3184d4a..9559460 100755 --- a/dali-toolkit/internal/text/rendering/text-typesetter.cpp +++ b/dali-toolkit/internal/text/rendering/text-typesetter.cpp @@ -609,7 +609,7 @@ Devel::PixelBuffer Typesetter::CreateImageBuffer( const unsigned int bufferWidth for( unsigned int y = underlineYOffset; y < underlineYOffset + maxUnderlineThickness; y++ ) { - if( ( y < 0 ) || ( y > bufferHeight - 1 ) ) + if( y > bufferHeight - 1 ) { // Do not write out of bounds. break; @@ -617,7 +617,7 @@ Devel::PixelBuffer Typesetter::CreateImageBuffer( const unsigned int bufferWidth for( unsigned int x = glyphData.horizontalOffset + lineExtentLeft; x <= glyphData.horizontalOffset + lineExtentRight; x++ ) { - if( ( x < 0 ) || ( x > bufferWidth - 1 ) ) + if( x > bufferWidth - 1 ) { // Do not write out of bounds. break; diff --git a/dali-toolkit/internal/text/text-controller-impl.cpp b/dali-toolkit/internal/text/text-controller-impl.cpp index d859b42..c1eb0e4 100644 --- a/dali-toolkit/internal/text/text-controller-impl.cpp +++ b/dali-toolkit/internal/text/text-controller-impl.cpp @@ -73,7 +73,7 @@ EventData::EventData( DecoratorPtr decorator ) mPlaceholderFont( NULL ), mPlaceholderTextActive(), mPlaceholderTextInactive(), - mPlaceholderTextColor( 0.8f, 0.8f, 0.8f, 0.8f ), + mPlaceholderTextColor( 0.8f, 0.8f, 0.8f, 0.8f ), // This color has been published in the Public API (placeholder-properties.h). mEventQueue(), mInputStyleChangedQueue(), mPreviousState( INACTIVE ), diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp index 99e031a..ae749e6 100755 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@ -27,6 +27,7 @@ #include // INTERNAL INCLUDES +#include #include #include #include @@ -47,14 +48,14 @@ const float MAX_FLOAT = std::numeric_limits::max(); const std::string EMPTY_STRING(""); -const char * const PLACEHOLDER_TEXT = "placeholderText"; -const char * const PLACEHOLDER_TEXT_FOCUSED = "placeholderTextFocused"; -const char * const PLACEHOLDER_COLOR = "placeholderColor"; -const char * const PLACEHOLDER_FONT_FAMILY = "placeholderFontFamily"; -const char * const PLACEHOLDER_FONT_STYLE = "placeholderFontStyle"; -const char * const PLACEHOLDER_POINT_SIZE = "placeholderPointSize"; -const char * const PLACEHOLDER_PIXEL_SIZE = "placeholderPixelSize"; -const char * const PLACEHOLDER_ELLIPSIS = "placeholderEllipsis"; +const char * const PLACEHOLDER_TEXT = "text"; +const char * const PLACEHOLDER_TEXT_FOCUSED = "textFocused"; +const char * const PLACEHOLDER_COLOR = "color"; +const char * const PLACEHOLDER_FONT_FAMILY = "fontFamily"; +const char * const PLACEHOLDER_FONT_STYLE = "fontStyle"; +const char * const PLACEHOLDER_POINT_SIZE = "pointSize"; +const char * const PLACEHOLDER_PIXEL_SIZE = "pixelSize"; +const char * const PLACEHOLDER_ELLIPSIS = "ellipsis"; float ConvertToEven( float value ) { @@ -1986,19 +1987,19 @@ void Controller::SetPlaceholderProperty( const Property::Map& map ) Property::Key& key = keyValue.first; Property::Value& value = keyValue.second; - if( key == PLACEHOLDER_TEXT ) + if( key == Toolkit::Text::PlaceHolder::Property::TEXT || key == PLACEHOLDER_TEXT ) { std::string text = ""; value.Get( text ); SetPlaceholderText( Controller::PLACEHOLDER_TYPE_INACTIVE, text ); } - else if( key == PLACEHOLDER_TEXT_FOCUSED ) + else if( key == Toolkit::Text::PlaceHolder::Property::TEXT_FOCUSED || key == PLACEHOLDER_TEXT_FOCUSED ) { std::string text = ""; value.Get( text ); SetPlaceholderText( Controller::PLACEHOLDER_TYPE_ACTIVE, text ); } - else if( key == PLACEHOLDER_COLOR ) + else if( key == Toolkit::Text::PlaceHolder::Property::COLOR || key == PLACEHOLDER_COLOR ) { Vector4 textColor; value.Get( textColor ); @@ -2007,17 +2008,17 @@ void Controller::SetPlaceholderProperty( const Property::Map& map ) SetPlaceholderTextColor( textColor ); } } - else if( key == PLACEHOLDER_FONT_FAMILY ) + else if( key == Toolkit::Text::PlaceHolder::Property::FONT_FAMILY || key == PLACEHOLDER_FONT_FAMILY ) { std::string fontFamily = ""; value.Get( fontFamily ); SetPlaceholderFontFamily( fontFamily ); } - else if( key == PLACEHOLDER_FONT_STYLE ) + else if( key == Toolkit::Text::PlaceHolder::Property::FONT_STYLE || key == PLACEHOLDER_FONT_STYLE ) { SetFontStyleProperty( this, value, Text::FontStyle::PLACEHOLDER ); } - else if( key == PLACEHOLDER_POINT_SIZE ) + else if( key == Toolkit::Text::PlaceHolder::Property::POINT_SIZE || key == PLACEHOLDER_POINT_SIZE ) { float pointSize; value.Get( pointSize ); @@ -2026,7 +2027,7 @@ void Controller::SetPlaceholderProperty( const Property::Map& map ) SetPlaceholderTextFontSize( pointSize, Text::Controller::POINT_SIZE ); } } - else if( key == PLACEHOLDER_PIXEL_SIZE ) + else if( key == Toolkit::Text::PlaceHolder::Property::PIXEL_SIZE || key == PLACEHOLDER_PIXEL_SIZE ) { float pixelSize; value.Get( pixelSize ); @@ -2035,7 +2036,7 @@ void Controller::SetPlaceholderProperty( const Property::Map& map ) SetPlaceholderTextFontSize( pixelSize, Text::Controller::PIXEL_SIZE ); } } - else if( key == PLACEHOLDER_ELLIPSIS ) + else if( key == Toolkit::Text::PlaceHolder::Property::ELLIPSIS || key == PLACEHOLDER_ELLIPSIS ) { bool ellipsis; value.Get( ellipsis ); @@ -2050,33 +2051,33 @@ void Controller::GetPlaceholderProperty( Property::Map& map ) { if( !mImpl->mEventData->mPlaceholderTextActive.empty() ) { - map[ PLACEHOLDER_TEXT_FOCUSED ] = mImpl->mEventData->mPlaceholderTextActive; + map[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = mImpl->mEventData->mPlaceholderTextActive; } if( !mImpl->mEventData->mPlaceholderTextInactive.empty() ) { - map[ PLACEHOLDER_TEXT ] = mImpl->mEventData->mPlaceholderTextInactive; + map[ Text::PlaceHolder::Property::TEXT ] = mImpl->mEventData->mPlaceholderTextInactive; } - map[ PLACEHOLDER_COLOR ] = mImpl->mEventData->mPlaceholderTextColor; - map[ PLACEHOLDER_FONT_FAMILY ] = GetPlaceholderFontFamily(); + map[ Text::PlaceHolder::Property::COLOR ] = mImpl->mEventData->mPlaceholderTextColor; + map[ Text::PlaceHolder::Property::FONT_FAMILY ] = GetPlaceholderFontFamily(); Property::Value fontStyleMapGet; GetFontStyleProperty( this, fontStyleMapGet, Text::FontStyle::PLACEHOLDER ); - map[ PLACEHOLDER_FONT_STYLE ] = fontStyleMapGet; + map[ Text::PlaceHolder::Property::FONT_STYLE ] = fontStyleMapGet; // Choose font size : POINT_SIZE or PIXEL_SIZE if( !mImpl->mEventData->mIsPlaceholderPixelSize ) { - map[ PLACEHOLDER_POINT_SIZE ] = GetPlaceholderTextFontSize( Text::Controller::POINT_SIZE ); + map[ Text::PlaceHolder::Property::POINT_SIZE ] = GetPlaceholderTextFontSize( Text::Controller::POINT_SIZE ); } else { - map[ PLACEHOLDER_PIXEL_SIZE ] = GetPlaceholderTextFontSize( Text::Controller::PIXEL_SIZE ); + map[ Text::PlaceHolder::Property::PIXEL_SIZE ] = GetPlaceholderTextFontSize( Text::Controller::PIXEL_SIZE ); } if( mImpl->mEventData->mPlaceholderEllipsisFlag ) { - map[ PLACEHOLDER_ELLIPSIS ] = IsPlaceholderTextElideEnabled(); + map[ Text::PlaceHolder::Property::ELLIPSIS ] = IsPlaceholderTextElideEnabled(); } } } diff --git a/dali-toolkit/internal/text/text-scroller.cpp b/dali-toolkit/internal/text/text-scroller.cpp index e85a2fd..dbc16eb 100644 --- a/dali-toolkit/internal/text/text-scroller.cpp +++ b/dali-toolkit/internal/text/text-scroller.cpp @@ -84,6 +84,8 @@ const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER( \n void main()\n {\n + if ( vTexCoord.y > 1.0 )\n + discard;\n gl_FragColor = texture2D( sTexture, vTexCoord );\n }\n ); diff --git a/dali-toolkit/internal/visuals/image/image-visual.cpp b/dali-toolkit/internal/visuals/image/image-visual.cpp index c83bd6e..82f7fd1 100644 --- a/dali-toolkit/internal/visuals/image/image-visual.cpp +++ b/dali-toolkit/internal/visuals/image/image-visual.cpp @@ -91,6 +91,13 @@ DALI_ENUM_TO_STRING_WITH_SCOPE( Dali::WrapMode, REPEAT ) DALI_ENUM_TO_STRING_WITH_SCOPE( Dali::WrapMode, MIRRORED_REPEAT ) DALI_ENUM_TO_STRING_TABLE_END( WRAP_MODE ) +// release policies +DALI_ENUM_TO_STRING_TABLE_BEGIN( RELEASE_POLICY ) +DALI_ENUM_TO_STRING_WITH_SCOPE( DevelImageVisual::ReleasePolicy, DETACHED ) +DALI_ENUM_TO_STRING_WITH_SCOPE( DevelImageVisual::ReleasePolicy, DESTROYED ) +DALI_ENUM_TO_STRING_WITH_SCOPE( DevelImageVisual::ReleasePolicy, NEVER ) +DALI_ENUM_TO_STRING_TABLE_END( RELEASE_POLICY ) + const Vector4 FULL_TEXTURE_RECT(0.f, 0.f, 1.f, 1.f); const char* DEFAULT_SAMPLER_TYPENAME = "sampler2D"; @@ -267,8 +274,9 @@ ImageVisual::ImageVisual( VisualFactoryCache& factoryCache, mSamplingMode( samplingMode ), mWrapModeU( WrapMode::DEFAULT ), mWrapModeV( WrapMode::DEFAULT ), + mReleasePolicy( DevelImageVisual::ReleasePolicy::DETACHED ), mAttemptAtlasing( false ), - mLoadingStatus( false ) + mLoading( false ) { } @@ -285,22 +293,32 @@ ImageVisual::ImageVisual( VisualFactoryCache& factoryCache, const Image& image ) mSamplingMode( SamplingMode::DEFAULT ), mWrapModeU( WrapMode::DEFAULT ), mWrapModeV( WrapMode::DEFAULT ), + mReleasePolicy( DevelImageVisual::ReleasePolicy::DESTROYED ), mAttemptAtlasing( false ), - mLoadingStatus( false ) + mLoading( false ) { } ImageVisual::~ImageVisual() { - if( mMaskingData && Stage::IsInstalled() ) + if( Stage::IsInstalled() ) { - // TextureManager could have been deleted before the actor that contains this - // ImageVisual is destroyed (e.g. due to stage shutdown). Ensure the stage - // is still valid before accessing texture manager. - if( mMaskingData->mAlphaMaskId != TextureManager::INVALID_TEXTURE_ID ) + if( mMaskingData ) + { + // TextureManager could have been deleted before the actor that contains this + // ImageVisual is destroyed (e.g. due to stage shutdown). Ensure the stage + // is still valid before accessing texture manager. + if( mMaskingData->mAlphaMaskId != TextureManager::INVALID_TEXTURE_ID ) + { + TextureManager& textureManager = mFactoryCache.GetTextureManager(); + textureManager.Remove( mMaskingData->mAlphaMaskId ); + } + } + + // ImageVisual destroyed so remove texture unless ReleasePolicy is set to never release + if( ( mTextureId != TextureManager::INVALID_TEXTURE_ID ) && ( mReleasePolicy != DevelImageVisual::ReleasePolicy::NEVER ) ) { - TextureManager& textureManager = mFactoryCache.GetTextureManager(); - textureManager.Remove( mMaskingData->mAlphaMaskId ); + RemoveTexture(); } } } @@ -349,22 +367,26 @@ void ImageVisual::DoSetProperties( const Property::Map& propertyMap ) { DoSetProperty( Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING, keyValue.second ); } - else if ( keyValue.first == IMAGE_ATLASING ) + else if( keyValue.first == IMAGE_ATLASING ) { DoSetProperty( Toolkit::ImageVisual::Property::ATLASING, keyValue.second ); } - else if ( keyValue.first == ALPHA_MASK_URL ) + else if( keyValue.first == ALPHA_MASK_URL ) { DoSetProperty( Toolkit::ImageVisual::Property::ALPHA_MASK_URL, keyValue.second ); } - else if ( keyValue.first == MASK_CONTENT_SCALE_NAME ) + else if( keyValue.first == MASK_CONTENT_SCALE_NAME ) { DoSetProperty( Toolkit::ImageVisual::Property::MASK_CONTENT_SCALE, keyValue.second ); } - else if ( keyValue.first == CROP_TO_MASK_NAME ) + else if( keyValue.first == CROP_TO_MASK_NAME ) { DoSetProperty( Toolkit::ImageVisual::Property::CROP_TO_MASK, keyValue.second ); } + else if( keyValue.first == RELEASE_POLICY_NAME ) + { + DoSetProperty( Toolkit::DevelImageVisual::Property::RELEASE_POLICY, keyValue.second ); + } } } } @@ -502,6 +524,14 @@ void ImageVisual::DoSetProperty( Property::Index index, const Property::Value& v } break; } + + case Toolkit::DevelImageVisual::Property::RELEASE_POLICY: + { + int releasePolicy; + Scripting::GetEnumerationProperty( value, RELEASE_POLICY_TABLE, RELEASE_POLICY_TABLE_COUNT, releasePolicy ); + mReleasePolicy = DevelImageVisual::ReleasePolicy::Type( releasePolicy ); + break; + } } } @@ -708,7 +738,7 @@ void ImageVisual::InitializeRenderer() TextureSet textures = textureManager.LoadTexture(mImageUrl, mDesiredSize, mFittingMode, mSamplingMode, mMaskingData, IsSynchronousResourceLoading(), mTextureId, - atlasRect, attemptAtlasing, mLoadingStatus, mWrapModeU, + atlasRect, attemptAtlasing, mLoading, mWrapModeU, mWrapModeV, this, this, mFactoryCache.GetAtlasManager()); if(attemptAtlasing) { @@ -735,7 +765,7 @@ void ImageVisual::InitializeRenderer() TextureSet textures = textureManager.LoadTexture(mImageUrl, mDesiredSize, mFittingMode, mSamplingMode, mMaskingData, IsSynchronousResourceLoading(), mTextureId, - atlasRect, attemptAtlasing, mLoadingStatus, mWrapModeU, mWrapModeV, this, + atlasRect, attemptAtlasing, mLoading, mWrapModeU, mWrapModeV, this, nullptr, nullptr); // no atlasing DALI_ASSERT_DEBUG(attemptAtlasing == false); CreateRenderer( textures ); @@ -767,12 +797,12 @@ void ImageVisual::DoSetOnStage( Actor& actor ) { InitializeRenderer(); } - else if ( mImage ) + else if( mImage ) { InitializeRenderer( mImage ); } - if ( !mImpl->mRenderer ) + if( !mImpl->mRenderer ) { return; } @@ -780,7 +810,7 @@ void ImageVisual::DoSetOnStage( Actor& actor ) mPlacementActor = actor; // Search the Actor tree to find if Layer UI behaviour set. Layer layer = actor.GetLayer(); - if ( layer && layer.GetBehavior() == Layer::LAYER_3D ) + if( layer && layer.GetBehavior() == Layer::LAYER_3D ) { // Layer 3D set, do not align pixels mImpl->mRenderer.RegisterProperty( PIXEL_ALIGNED_UNIFORM_NAME, PIXEL_ALIGN_OFF ); @@ -791,7 +821,7 @@ void ImageVisual::DoSetOnStage( Actor& actor ) mImpl->mRenderer.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, mPixelArea ); } - if( mLoadingStatus == false ) + if( mLoading == false ) { actor.AddRenderer( mImpl->mRenderer ); mPlacementActor.Reset(); @@ -805,14 +835,19 @@ void ImageVisual::DoSetOffStage( Actor& actor ) { // Visual::Base::SetOffStage only calls DoSetOffStage if mRenderer exists (is on onstage) - //If we own the image then make sure we release it when we go off stage + // Image release is dependent on the ReleasePolicy, renderer is destroyed. actor.RemoveRenderer( mImpl->mRenderer); + if( mReleasePolicy == DevelImageVisual::ReleasePolicy::DETACHED ) + { + RemoveTexture(); // If INVALID_TEXTURE_ID then removal will be attempted on atlas + } + if( mImageUrl.IsValid() ) { - RemoveTexture( mImageUrl.GetUrl() ); + // Legacy support for deprecated Dali::Image mImage.Reset(); } - mLoadingStatus = false; + mLoading = false; mImpl->mRenderer.Reset(); mPlacementActor.Reset(); } @@ -856,6 +891,9 @@ void ImageVisual::DoCreatePropertyMap( Property::Map& map ) const map.Insert( Toolkit::ImageVisual::Property::MASK_CONTENT_SCALE, mMaskingData->mContentScaleFactor ); map.Insert( Toolkit::ImageVisual::Property::CROP_TO_MASK, mMaskingData->mCropToMask ); } + + map.Insert( Toolkit::DevelImageVisual::Property::RELEASE_POLICY, mReleasePolicy ); + } void ImageVisual::DoCreateInstancePropertyMap( Property::Map& map ) const @@ -948,7 +986,7 @@ void ImageVisual::UploadCompleted() // reset the weak handle so that the renderer only get added to actor once mPlacementActor.Reset(); } - mLoadingStatus = false; + mLoading = false; } // From Texture Manager @@ -983,10 +1021,10 @@ void ImageVisual::UploadComplete( bool loadingSuccess, int32_t textureId, Textur ResourceReady(); } } - mLoadingStatus = false; + mLoading = false; } -void ImageVisual::RemoveTexture(const std::string& url) +void ImageVisual::RemoveTexture() { if( mTextureId != TextureManager::INVALID_TEXTURE_ID ) { diff --git a/dali-toolkit/internal/visuals/image/image-visual.h b/dali-toolkit/internal/visuals/image/image-visual.h index d56ab14..0e4009b 100644 --- a/dali-toolkit/internal/visuals/image/image-visual.h +++ b/dali-toolkit/internal/visuals/image/image-visual.h @@ -32,6 +32,7 @@ #include #include #include +#include namespace Dali { @@ -64,6 +65,7 @@ typedef IntrusivePtr< ImageVisual > ImageVisualPtr; * | pixelArea | VECTOR4 | * | wrapModeU | INTEGER OR STRING | * | wrapModeV | INTEGER OR STRING | + * | releasePolicy | INTEGER OR STRING | * * where pixelArea is a rectangular area. * In its Vector4 value, the first two elements indicate the top-left position of the area, @@ -95,6 +97,11 @@ typedef IntrusivePtr< ImageVisual > ImageVisualPtr; * "DEFAULT" * * + * where releasePolicy should be one of the following policies for when to cache the image + * "DETACHED" // Release image from cache when visual detached from stage + * "DESTROYED" // Keep image in cache until the visual is destroyed + * "NEVER" // Keep image in cache until application ends. + * * If the Visual is in a LayerUI it will pixel align the image, using a Layer3D will disable pixel alignment. * Changing layer behaviour between LayerUI to Layer3D whilst the visual is already staged will not have an effect. */ @@ -304,9 +311,9 @@ private: void SetTextureRectUniform( const Vector4& textureRect ); /** - * Remove the texture if it is not used anymore. + * Remove texture with valid TextureId */ - void RemoveTexture(const std::string& url); + void RemoveTexture(); /** * Helper method to set individual values by index key. @@ -330,8 +337,9 @@ private: Dali::SamplingMode::Type mSamplingMode:4; Dali::WrapMode::Type mWrapModeU:3; Dali::WrapMode::Type mWrapModeV:3; + DevelImageVisual::ReleasePolicy::Type mReleasePolicy; bool mAttemptAtlasing; ///< If true will attempt atlasing, otherwise create unique texture - bool mLoadingStatus; ///< True if the texture is being loaded asynchronously, or false when it has loaded. + bool mLoading; ///< True if the texture is still loading. }; diff --git a/dali-toolkit/internal/visuals/text/text-visual.cpp b/dali-toolkit/internal/visuals/text/text-visual.cpp index 6c35875..e979607 100755 --- a/dali-toolkit/internal/visuals/text/text-visual.cpp +++ b/dali-toolkit/internal/visuals/text/text-visual.cpp @@ -194,12 +194,11 @@ const char* FRAGMENT_SHADER_SINGLE_COLOR_TEXT_WITH_EMOJI = DALI_COMPOSE_SHADER( // Set the color of non-transparent pixel in text to what it is animated to. // Markup text with multiple text colors are not animated (but can be supported later on if required). // Emoji color are not animated. - mediump vec4 textColor = textTexture * textTexture.a;\n - mediump float vstep = step( 0.0001, textColor.a );\n - textColor.rgb = mix( textColor.rgb, uTextColorAnimatable.rgb, vstep * maskTexture );\n + mediump float vstep = step( 0.0001, textTexture.a );\n + textTexture.rgb = mix( textTexture.rgb, uTextColorAnimatable.rgb, vstep * maskTexture );\n // Draw the text as overlay above the style - gl_FragColor = textColor * uColor * vec4( mixColor, opacity );\n + gl_FragColor = textTexture * uColor * vec4( mixColor, opacity );\n }\n ); @@ -225,12 +224,11 @@ const char* FRAGMENT_SHADER_SINGLE_COLOR_TEXT_WITH_STYLE_AND_EMOJI = DALI_COMPOS // Set the color of non-transparent pixel in text to what it is animated to. // Markup text with multiple text colors are not animated (but can be supported later on if required). // Emoji color are not animated. - mediump vec4 textColor = textTexture * textTexture.a;\n - mediump float vstep = step( 0.0001, textColor.a );\n - textColor.rgb = mix( textColor.rgb, uTextColorAnimatable.rgb, vstep * maskTexture * ( 1.0 - uHasMultipleTextColors ) );\n + mediump float vstep = step( 0.0001, textTexture.a );\n + textTexture.rgb = mix( textTexture.rgb, uTextColorAnimatable.rgb, vstep * maskTexture * ( 1.0 - uHasMultipleTextColors ) );\n // Draw the text as overlay above the style - gl_FragColor = ( textColor + styleTexture * ( 1.0 - textTexture.a ) ) * uColor * vec4( mixColor, opacity );\n + gl_FragColor = ( textTexture + styleTexture * ( 1.0 - textTexture.a ) ) * uColor * vec4( mixColor, opacity );\n }\n ); diff --git a/dali-toolkit/internal/visuals/visual-string-constants.cpp b/dali-toolkit/internal/visuals/visual-string-constants.cpp index b3352d4..0670dd8 100644 --- a/dali-toolkit/internal/visuals/visual-string-constants.cpp +++ b/dali-toolkit/internal/visuals/visual-string-constants.cpp @@ -85,6 +85,7 @@ const char * const CACHE_SIZE_NAME("cacheSize"); const char * const FRAME_DELAY_NAME("frameDelay"); const char * const MASK_CONTENT_SCALE_NAME("maskContentScale"); const char * const CROP_TO_MASK_NAME("cropToMask"); +const char * const RELEASE_POLICY_NAME("releasePolicy"); // Text visual const char * const TEXT_PROPERTY( "text" ); diff --git a/dali-toolkit/internal/visuals/visual-string-constants.h b/dali-toolkit/internal/visuals/visual-string-constants.h index 4731f4a..9aa14a1 100644 --- a/dali-toolkit/internal/visuals/visual-string-constants.h +++ b/dali-toolkit/internal/visuals/visual-string-constants.h @@ -73,6 +73,7 @@ extern const char * const CACHE_SIZE_NAME; extern const char * const FRAME_DELAY_NAME; extern const char * const MASK_CONTENT_SCALE_NAME; extern const char * const CROP_TO_MASK_NAME; +extern const char * const RELEASE_POLICY_NAME; // Text visual extern const char * const TEXT_PROPERTY; diff --git a/dali-toolkit/public-api/controls/control-impl.cpp b/dali-toolkit/public-api/controls/control-impl.cpp index 68fd55a..d7df20a 100644 --- a/dali-toolkit/public-api/controls/control-impl.cpp +++ b/dali-toolkit/public-api/controls/control-impl.cpp @@ -83,6 +83,46 @@ void CreateClippingRenderer( Control& controlImpl ) } } +/** + * @brief Sets Control::Property::BACKGROUND visual + * @param[in] controlImpl The control implementation + * @param[in] visual The control background visual + * @param[in] size The current size + */ +void SetBackgroundVisual( Control::Impl& controlImpl, Toolkit::Visual::Base& visual, const Vector2& size ) +{ + Property::Map transformMap = Property::Map(); + + Vector2 newSize( 0.f, 0.f ); + newSize.width = size.width + ( controlImpl.mPadding.start + controlImpl.mPadding.end ); + newSize.height = size.height + ( controlImpl.mPadding.top + controlImpl.mPadding.bottom ); + + if( ( controlImpl.mMargin.start != 0 ) || + ( controlImpl.mMargin.end != 0 ) || + ( controlImpl.mMargin.top != 0 ) || + ( controlImpl.mMargin.bottom != 0 ) ) + { + transformMap.Add( Toolkit::Visual::Transform::Property::SIZE, newSize ) + .Add( Toolkit::Visual::Transform::Property::SIZE_POLICY, Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ) ) + .Add( Toolkit::Visual::Transform::Property::OFFSET, Vector2( controlImpl.mMargin.start, controlImpl.mMargin.top ) ) + .Add( Toolkit::Visual::Transform::Property::OFFSET_POLICY, Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ) ) + .Add( Toolkit::Visual::Transform::Property::ORIGIN, Toolkit::Align::TOP_BEGIN ) + .Add( Toolkit::Visual::Transform::Property::ANCHOR_POINT, Toolkit::Align::TOP_BEGIN ); + } + else if( ( controlImpl.mPadding.start != 0 ) || + ( controlImpl.mPadding.end != 0 ) || + ( controlImpl.mPadding.top != 0 ) || + ( controlImpl.mPadding.bottom != 0 ) ) + { + transformMap.Add( Toolkit::Visual::Transform::Property::SIZE, newSize ) + .Add( Toolkit::Visual::Transform::Property::SIZE_POLICY, Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ) ) + .Add( Toolkit::Visual::Transform::Property::ORIGIN, Toolkit::Align::TOP_BEGIN ) + .Add( Toolkit::Visual::Transform::Property::ANCHOR_POINT, Toolkit::Align::TOP_BEGIN ); + } + + visual.SetTransformAndSize( transformMap, newSize ); // Send an empty map as we do not want to modify the visual's set transform +} + } // unnamed namespace @@ -563,7 +603,8 @@ void Control::OnSizeSet(const Vector3& targetSize) if( visual ) { Vector2 size( targetSize ); - visual.SetTransformAndSize( Property::Map(), size ); // Send an empty map as we do not want to modify the visual's set transform + SetBackgroundVisual( *mImpl, visual, size ); + } } @@ -596,13 +637,30 @@ void Control::OnRelayout( const Vector2& size, RelayoutContainer& container ) { for( unsigned int i = 0, numChildren = Self().GetChildCount(); i < numChildren; ++i ) { - container.Add( Self().GetChildAt( i ), size ); + Actor child = Self().GetChildAt( i ); + Vector2 newChildSize( size ); + + // When set the padding or margin on the control, child should be resized and repositioned. + if( ( mImpl->mPadding.start != 0 ) || ( mImpl->mPadding.end != 0 ) || ( mImpl->mPadding.top != 0 ) || ( mImpl->mPadding.bottom != 0 ) || + ( mImpl->mMargin.start != 0 ) || ( mImpl->mMargin.end != 0 ) || ( mImpl->mMargin.top != 0 ) || ( mImpl->mMargin.bottom != 0 ) ) + { + newChildSize.width = size.width - ( mImpl->mPadding.start + mImpl->mPadding.end ); + newChildSize.height = size.height - ( mImpl->mPadding.top + mImpl->mPadding.bottom ); + + Vector3 childPosition = child.GetTargetSize(); + childPosition.x += ( mImpl->mMargin.start + mImpl->mPadding.start ); + childPosition.y += ( mImpl->mMargin.top + mImpl->mPadding.top ); + + child.SetPosition( childPosition ); + } + + container.Add( child, newChildSize ); } Toolkit::Visual::Base visual = mImpl->GetVisual( Toolkit::Control::Property::BACKGROUND ); if( visual ) { - visual.SetTransformAndSize( Property::Map(), size ); // Send an empty map as we do not want to modify the visual's set transform + SetBackgroundVisual( *mImpl, visual, size ); } } @@ -617,6 +675,8 @@ Vector3 Control::GetNaturalSize() { Vector2 naturalSize; visual.GetNaturalSize( naturalSize ); + naturalSize.width += ( mImpl->mPadding.start + mImpl->mPadding.end ); + naturalSize.height += ( mImpl->mPadding.top + mImpl->mPadding.bottom ); return Vector3( naturalSize ); } return Vector3::ZERO; diff --git a/dali-toolkit/public-api/controls/control.h b/dali-toolkit/public-api/controls/control.h index c68d41a..5fd8933 100644 --- a/dali-toolkit/public-api/controls/control.h +++ b/dali-toolkit/public-api/controls/control.h @@ -97,35 +97,64 @@ public: enum { /** - * @brief name "styleName", type std::string. + * @brief The name of the style to be applied to the control. + * @details Name "styleName", type Property::STRING. + * @see Toolkit::Control::SetStyleName() * @SINCE_1_0.0 - * @see SetStyleName */ STYLE_NAME = PROPERTY_START_INDEX, + /** * @DEPRECATED_1_1.3 - * @brief name "backgroundColor", mutually exclusive with BACKGROUND_IMAGE & BACKGROUND, type Vector4. + * @brief The background color of the control. + * + * Mutually exclusive with BACKGROUND_IMAGE & BACKGROUND. + * @details Name "backgroundColor", type Property::VECTOR4. + * @see Toolkit::Control::SetStyleName() * @SINCE_1_0.0 - * @see SetStyleName */ BACKGROUND_COLOR, + /** * @DEPRECATED_1_1.3 - * @brief name "backgroundImage", mutually exclusive with BACKGROUND_COLOR & BACKGROUND, type Map. + * @brief The background image of the control. + * + * Mutually exclusive with BACKGROUND_COLOR & BACKGROUND. + * @details Name "backgroundImage", type Property::MAP. * @SINCE_1_0.0 */ BACKGROUND_IMAGE, + /** - * @brief name "keyInputFocus", type bool. + * @brief Receives key events to the control. + * @details Name "keyInputFocus", type Property::BOOLEAN. + * @see Toolkit::Control::SetKeyInputFocus() * @SINCE_1_0.0 - * @see SetKeyInputFocus */ KEY_INPUT_FOCUS, + /** - * @brief name "background", mutually exclusive with BACKGROUND_COLOR & BACKGROUND_IMAGE, type Map or std::string for URL or Vector4 for Color. + * @brief The background of the control. + * + * Mutually exclusive with BACKGROUND_COLOR & BACKGROUND_IMAGE. + * @details Name "background", type Property::MAP or std::string for URL or Property::VECTOR4 for Color. * @SINCE_1_1.3 */ BACKGROUND, + + /** + * @brief The outer space around the control. + * @details Name "margin", type Property::EXTENTS. + * @SINCE_1_2.62 + */ + MARGIN, + + /** + * @brief The inner space of the control. + * @details Name "padding", type Property::EXTENTS. + * @SINCE_1_2.62 + */ + PADDING }; }; diff --git a/dali-toolkit/public-api/controls/progress-bar/progress-bar.h b/dali-toolkit/public-api/controls/progress-bar/progress-bar.h index 4a6ce3a..4d45740 100644 --- a/dali-toolkit/public-api/controls/progress-bar/progress-bar.h +++ b/dali-toolkit/public-api/controls/progress-bar/progress-bar.h @@ -38,27 +38,7 @@ class ProgressBar; /** * @brief ProgressBar is a control to give the user an indication of the progress of an operation. - * * - * Determinate Progress State * - * # : Progress visual - * * : Secondary Progress visual - * = : Track visual - * 40% : Label visual - * - * ============================================= - * = ###############**** 40% = - * ============================================= - * - * Indeterminate Progress State - * - * / : Indeterminate visual - * - * ============================================= - * = ///////////////////////////////////////// = - * ============================================= - * - * Also progress value percentage is shown as text inside the progress bar. * Signals * | %Signal Name | Method | * |-------------------|-------------------------------| diff --git a/dali-toolkit/public-api/controls/text-controls/placeholder-properties.h b/dali-toolkit/public-api/controls/text-controls/placeholder-properties.h new file mode 100644 index 0000000..d102d4f --- /dev/null +++ b/dali-toolkit/public-api/controls/text-controls/placeholder-properties.h @@ -0,0 +1,149 @@ +#ifndef DALI_TOOLKIT_PLACEHOLDER_PROPERTIES_H +#define DALI_TOOLKIT_PLACEHOLDER_PROPERTIES_H + +/* + * Copyright (c) 2017 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. + * + */ + +namespace Dali +{ + +namespace Toolkit +{ + +/** + * @addtogroup dali_toolkit_controls + * @{ + */ + +namespace Text +{ + +/** + * @brief Placeholder text used by Text controls to show text before any text inputed. + * @SINCE_1_2.62 + * + */ +namespace PlaceHolder +{ + +/** + * @brief Placeholder text Propeties used by Text controls to show placeholder + * @SINCE_1_2.62 + * + */ +namespace Property +{ + +/** + * @brief The configurable settings for the Placeholder text. + * @SINCE_1_2.62 + * + */ +enum Setting +{ + /** + * @brief The text to display as a placeholder. + * @details Name "text", type Property::STRING. + * @note Optional. If not provided then no placeholder text will be shown whilst control not focused. + * @SINCE_1_2.62 + */ + TEXT, + + /** + * @brief The text to display as placeholder when focused. + * @details Name "textFocused", type Property::STRING. + * @note Optional. If not provided then no placeholder text will be shown when focused. + * @SINCE_1_2.62 + */ + TEXT_FOCUSED, + + /** + * @brief The colour of the placeholder text. + * @details Name "color", type Property::VECTOR4. + * @note If color not provided then 80% white will be used. + * @SINCE_1_2.62 + */ + COLOR, + + /** + * @brief The font family to be used for placeholder text. + * @details Name "fontFamily", type Property::STRING. + * @note Optional. Default font family used if not provided. + * @SINCE_1_2.62 + */ + FONT_FAMILY, + + /** + * @brief The font style to be used for placeholder text. + * @details Name "fontStyle", type Property::MAP. + * + * Example usage: + * @code + * Property::Map fontStylePropertyMap; + * fontStylePropertyMap.Insert( "weight", "bold" ); + * fontStylePropertyMap.Insert( "width", "condensed" ); + * fontStylePropertyMap.Insert( "slant", "italic" ); + * ... + * placeholderPropertyMap[ Text::PlaceHolder::Property::FONT_STYLE] = fontStylePropertyMap; + * @endcode + * + * @note Optional. Default font style used if not provided. + * @SINCE_1_2.62 + */ + FONT_STYLE, + + /** + * @brief The font point size to be used. + * @details Name "pointSize", type Property::FLOAT. + * @note Optional. Not required if PIXEL_SIZE provided. If neither provided then the text control point size is used. + * @SINCE_1_2.62 + */ + POINT_SIZE, + + /** + * @brief The font size in pixels to be used + * @details Name "pixelSize", type Property::FLOAT. + * @note Optional. Not required if POINT_SIZE provided. If neither provided then the text control point size is used. + * @SINCE_1_2.62 + */ + PIXEL_SIZE, + + /** + * @brief If ellipsis should be used when placeholder is too long. + * @details Name "ellipsis", type Property::BOOLEAN + * @note Optional. Default is false. + * @SINCE_1_2.62 + */ + ELLIPSIS +}; + +} // namespace Property + +} // namespace PlaceHolder + + +} // namespace Text + +/** + * @} + */ + +} // namespace Toolkit + +} // namespace Dali + +#endif //DALI_TOOLKIT_PLACEHOLDER_PROPERTIES_H diff --git a/dali-toolkit/public-api/controls/text-controls/text-field.h b/dali-toolkit/public-api/controls/text-controls/text-field.h index 1fb34e0..0875753 100644 --- a/dali-toolkit/public-api/controls/text-controls/text-field.h +++ b/dali-toolkit/public-api/controls/text-controls/text-field.h @@ -439,18 +439,18 @@ public: * Example Usage: * @code * Property::Map propertyMap; - * propertyMap["placeholderText"] = "Setting Placeholder Text"; - * propertyMap["placeholderTextFocused"] = "Setting Placeholder Text Focused"; - * propertyMap["placeholderColor"] = Color::RED; - * propertyMap["placeholderFontFamily"] = "Arial"; - * propertyMap["placeholderPointSize"] = 12.0f; - * propertyMap["placeholderEllipsis"] = true; + * propertyMap[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text"; + * propertyMap[ Text::PlaceHolder::Property::TEXT_FOCUSED] = "Setting Placeholder Text Focused"; + * propertyMap[ Text::PlaceHolder::Property::COLOR] = Color::RED; + * propertyMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial"; + * propertyMap[ Text::PlaceHolder::Property::POINT_SIZE ] = 12.0f; + * propertyMap[ Text::PlaceHolder::Property::ELLIPSIS ] = true; * * Property::Map fontStyleMap; * fontStyleMap.Insert( "weight", "bold" ); * fontStyleMap.Insert( "width", "condensed" ); * fontStyleMap.Insert( "slant", "italic" ); - * propertyMap["placeholderFontStyle"] = fontStyleMap; + * propertyMap[ Text::PlaceHolder::Property::FONT_STYLE] = fontStyleMap; * * field.SetProperty( TextField::Property::PLACEHOLDER, propertyMap ); * @endcode diff --git a/dali-toolkit/public-api/controls/text-controls/text-label.h b/dali-toolkit/public-api/controls/text-controls/text-label.h index 6536746..ec6613c 100644 --- a/dali-toolkit/public-api/controls/text-controls/text-label.h +++ b/dali-toolkit/public-api/controls/text-controls/text-label.h @@ -240,6 +240,7 @@ public: * @details Name "autoScrollGap", type Property::INT. * @SINCE_1_1.35 * @note Default in style sheet but can be overridden to prevent same text being shown at start and end. + * @note Displayed gap size is not guaranteed if the text length plus gap exceeds the maximum texture size (i.e. GL_MAX_TEXTURE_SIZE). */ AUTO_SCROLL_GAP, diff --git a/dali-toolkit/public-api/controls/video-view/video-view.h b/dali-toolkit/public-api/controls/video-view/video-view.h index d6a9bdf..154d93e 100644 --- a/dali-toolkit/public-api/controls/video-view/video-view.h +++ b/dali-toolkit/public-api/controls/video-view/video-view.h @@ -66,6 +66,8 @@ public: // Signal typedef Signal< void (VideoView&) > VideoViewSignalType; ///< Video playback finished signal type @ SINCE_1_1.38 +public: + /** * @brief Enumeration for the start and end property ranges for this control. * @SINCE_1_0.0 @@ -101,7 +103,16 @@ public: * @brief name "volume", left and right volume scalar as float type, Property::Map with two values ( "left" and "right" ). * @SINCE_1_1.38 */ - VOLUME + VOLUME, + + /** + * @brief name "underlay", Video rendering by underlay, true or false + * This shows video composited underneath the window by the system. This means it may ignore rotation of the video-view + * If false, video-view shows decoded frame images sequentially. + * If Platform or video plugin doesn't support decoded frame images, this should always be true. + * @SINCE_1_2.62 + */ + UNDERLAY }; }; diff --git a/dali-toolkit/public-api/dali-toolkit-version.cpp b/dali-toolkit/public-api/dali-toolkit-version.cpp index 82e5b62..0b9f9be 100644 --- a/dali-toolkit/public-api/dali-toolkit-version.cpp +++ b/dali-toolkit/public-api/dali-toolkit-version.cpp @@ -31,7 +31,7 @@ namespace Toolkit const unsigned int TOOLKIT_MAJOR_VERSION = 1; const unsigned int TOOLKIT_MINOR_VERSION = 2; -const unsigned int TOOLKIT_MICRO_VERSION = 61; +const unsigned int TOOLKIT_MICRO_VERSION = 62; const char * const TOOLKIT_BUILD_DATE = __DATE__ " " __TIME__; #ifdef DEBUG_ENABLED diff --git a/dali-toolkit/public-api/file.list b/dali-toolkit/public-api/file.list index f29325b..e490f79 100755 --- a/dali-toolkit/public-api/file.list +++ b/dali-toolkit/public-api/file.list @@ -104,6 +104,7 @@ public_api_table_view_header_files = \ public_api_text_controls_header_files = \ $(public_api_src_dir)/controls/text-controls/hidden-input-properties.h \ + $(public_api_src_dir)/controls/text-controls/placeholder-properties.h \ $(public_api_src_dir)/controls/text-controls/text-editor.h \ $(public_api_src_dir)/controls/text-controls/text-label.h \ $(public_api_src_dir)/controls/text-controls/text-field.h diff --git a/dali-toolkit/public-api/visuals/visual-properties.h b/dali-toolkit/public-api/visuals/visual-properties.h index 5617198..54a4350 100644 --- a/dali-toolkit/public-api/visuals/visual-properties.h +++ b/dali-toolkit/public-api/visuals/visual-properties.h @@ -95,7 +95,7 @@ enum * @details Name "transform", type Property::MAP. * @SINCE_1_2.60 * @note Optional. - * @see DevelVisual::Transform::Property + * @see Toolkit::Visual::Transform::Property */ TRANSFORM, @@ -196,8 +196,8 @@ enum Type * control.SetProperty( ..., // Some visual based property * Property::Map().Add( ... ) // Properties to set up visual * .Add( Visual::Property::TRANSFORM, - * Property::Array().Add( DevelVisual::Transform::Property::OFFSET_POLICY, Vector2( Policy::ABSOLUTE, Policy::RELATIVE ) ) ) - * .Add( DevelVisual::Transform::Property::OFFSET, Vector2( 10, 1.0f ) ) ); + * Property::Array().Add( Toolkit::Visual::Transform::Property::OFFSET_POLICY, Vector2( Policy::ABSOLUTE, Policy::RELATIVE ) ) ) + * .Add( Toolkit::Visual::Transform::Property::OFFSET, Vector2( 10, 1.0f ) ) ); * @endcode * * JSON: diff --git a/doc/dali-toolkit-doc.h b/doc/dali-toolkit-doc.h index bf41fae..982583a 100644 --- a/doc/dali-toolkit-doc.h +++ b/doc/dali-toolkit-doc.h @@ -125,6 +125,10 @@ * Slider is a control to enable sliding an indicator between two values. * * + * @ref dali_toolkit_controls_progress_bar + * ProgressBar is a control to give the user an indication of the progress of an operation. + * + * * @ref dali_toolkit_managers * Singleton classes for managing application-wide functionalities. * @@ -197,6 +201,9 @@ * @defgroup dali_toolkit_controls_slider Slider * @brief Slider is a control to enable sliding an indicator between two values. + * @defgroup dali_toolkit_controls_progress_bar Progress Bar + * @brief ProgressBar is a control to give the user an indication of the progress of an operation. + * @} * @defgroup dali_toolkit_managers Managers diff --git a/packaging/dali-toolkit.spec b/packaging/dali-toolkit.spec index 9663c7a..4478a9f 100644 --- a/packaging/dali-toolkit.spec +++ b/packaging/dali-toolkit.spec @@ -1,6 +1,6 @@ Name: dali-toolkit Summary: Dali 3D engine Toolkit -Version: 1.2.61 +Version: 1.2.62 Release: 1 Group: System/Libraries License: Apache-2.0 and BSD-3-Clause and MIT