#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
#include <dali-toolkit/devel-api/align-enums.h>
+#include <dali-toolkit/devel-api/controls/control-devel.h>
namespace Dali
{
void DummyControlImpl::RegisterVisual( Property::Index index, Toolkit::Visual::Base visual )
{
- Control::RegisterVisual( index, visual );
+ DevelControl::RegisterVisual( *this, index, visual );
VisualIndices::iterator iter = std::find( mRegisteredVisualIndices.begin(), mRegisteredVisualIndices.end(), index );
if( iter == mRegisteredVisualIndices.end() )
void DummyControlImpl::RegisterVisual( Property::Index index, Toolkit::Visual::Base visual, bool enabled )
{
- Control::RegisterVisual( index, visual, enabled );
+ DevelControl::RegisterVisual( *this, index, visual, enabled );
VisualIndices::iterator iter = std::find( mRegisteredVisualIndices.begin(), mRegisteredVisualIndices.end(), index );
if( iter == mRegisteredVisualIndices.end() )
void DummyControlImpl::UnregisterVisual( Property::Index index )
{
- Control::UnregisterVisual( index );
+ DevelControl::UnregisterVisual( *this, index );
VisualIndices::iterator iter = std::find( mRegisteredVisualIndices.begin(), mRegisteredVisualIndices.end(), index );
if( iter != mRegisteredVisualIndices.end() )
Toolkit::Visual::Base DummyControlImpl::GetVisual( Property::Index index )
{
- return Control::GetVisual( index );
+ return DevelControl::GetVisual( *this, index );
}
void DummyControlImpl::EnableVisual( Property::Index index, bool enabled )
{
- Control::EnableVisual( index, enabled );
+ DevelControl::EnableVisual( *this, index, enabled );
}
bool DummyControlImpl::IsVisualEnabled( Property::Index index )
{
- return Control::IsVisualEnabled( index );
+ return DevelControl::IsVisualEnabled( *this, index );
}
Animation DummyControlImpl::CreateTransition( const Toolkit::TransitionData& transition )
{
- return Control::CreateTransition( transition );
+ return DevelControl::CreateTransition( *this, transition );
}
void DummyControlImpl::SetProperty( BaseObject* object, Dali::Property::Index index, const Dali::Property::Value& value )
#define __DALI_TOOLKIT_TEST_DUMMY_CONTROL_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.
{
class DummyControlImpl;
+class TransitionData;
+
+namespace Visual
+{
+class Base;
+}
/**
* Control does not have a New method so use this dummy class for the handle.
const char* TEST_LARGE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/tbcol.png";
const char* TEST_SMALL_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/icon-edit.png";
const char* TEST_REMOTE_IMAGE_FILE_NAME = "https://www.tizen.org/sites/all/themes/tizen_theme/logo.png";
+const char* TEST_INVALID_FILE_NAME = TEST_RESOURCE_DIR "/invalid.jpg";
+const char* TEST_REMOTE_INVALID_FILE_NAME = "https://www.tizen.org/invalid.png";
}
END_TEST;
}
+
+int UtcDaliImageVisualSetInvalidAsyncImage(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "Request image visual with invalid images - should draw broken.png" );
+
+ VisualFactory factory = VisualFactory::Get();
+ DALI_TEST_CHECK( factory );
+
+ Property::Map propertyMap;
+ propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
+ propertyMap.Insert( ImageVisual::Property::URL, TEST_INVALID_FILE_NAME );
+
+ Visual::Base visual = factory.CreateVisual( propertyMap );
+ DALI_TEST_CHECK( visual );
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
+
+ DummyControl actor = DummyControl::New();
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
+ dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
+
+ actor.SetSize( 200.f, 200.f );
+ DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
+
+ Stage::GetCurrent().Add( actor );
+
+ application.SendNotification();
+ DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
+ DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
+
+ Stage::GetCurrent().Remove( actor );
+ DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
+
+ END_TEST;
+}
+
+int UtcDaliImageVisualSetInvalidSyncImage(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "Request image visual with invalid images - should draw broken.png" );
+
+ VisualFactory factory = VisualFactory::Get();
+ DALI_TEST_CHECK( factory );
+
+ Property::Map propertyMap;
+ propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
+ propertyMap.Insert( ImageVisual::Property::URL, TEST_INVALID_FILE_NAME );
+ propertyMap.Insert( ImageVisual::Property::SYNCHRONOUS_LOADING, true );
+
+ Visual::Base visual = factory.CreateVisual( propertyMap );
+ DALI_TEST_CHECK( visual );
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
+
+ DummyControl actor = DummyControl::New();
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
+ dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
+
+ actor.SetSize( 200.f, 200.f );
+ DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
+
+ Stage::GetCurrent().Add( actor );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
+ DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
+
+ Stage::GetCurrent().Remove( actor );
+ DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
+
+ END_TEST;
+}
+
+int UtcDaliImageVisualSetInvalidRemoteImage(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "Request image visual with invalid images - should draw broken.png" );
+
+ VisualFactory factory = VisualFactory::Get();
+ DALI_TEST_CHECK( factory );
+
+ // Local invalid file, asynchronous loading
+ Property::Map propertyMap;
+ propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
+ propertyMap.Insert( ImageVisual::Property::URL, TEST_REMOTE_INVALID_FILE_NAME );
+
+ Visual::Base visual = factory.CreateVisual( propertyMap );
+ DALI_TEST_CHECK( visual );
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
+
+ DummyControl actor = DummyControl::New();
+ DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
+ dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
+
+ actor.SetSize( 200.f, 200.f );
+ DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
+
+ Stage::GetCurrent().Add( actor );
+
+ application.SendNotification();
+ DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
+ DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
+
+ Stage::GetCurrent().Remove( actor );
+ DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
+
+ END_TEST;
+}
END_TEST;
}
+
+int utcDaliTextEditorFontStylePropertyStringP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
+
+ TextEditor editor = TextEditor::New();
+
+ std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
+
+ Stage::GetCurrent().Add( editor );
+
+ editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
+
+ Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
+ std::string result;
+ value.Get(result);
+
+ DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
+
+ END_TEST;
+}
/*
- * Copyright (c) 2016 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.
fontStyleMapSet.Insert( "weight", "thin" );
fontStyleMapSet.Insert( "width", "expanded" );
fontStyleMapSet.Insert( "slant", "oblique" );
+ const std::string strFontStyle = "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}";
label.SetProperty( TextLabel::Property::FONT_STYLE, "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}" );
- fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
- DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
- DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
+ std::string getFontStyle = label.GetProperty<std::string>( TextLabel::Property::FONT_STYLE );
+ DALI_TEST_EQUALS( getFontStyle, strFontStyle, TEST_LOCATION );
label.SetProperty( TextLabel::Property::POINT_SIZE, 10.f );
DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
ToolkitTestApplication application;
tet_infoline(" UtcDaliToolkitTextLabelScrollingP");
TextLabel labelImmediate = TextLabel::New("Some text to scroll");
- TextLabel labelFinished = TextLabel::New("Some text to scroll");
+ TextLabel labelFinished = TextLabel::New("مرحبا بالعالم");
DALI_TEST_CHECK( labelImmediate );
DALI_TEST_CHECK( labelFinished );
END_TEST;
}
+int UtcDaliToolkitTextlabelScrollingCenterAlignP(void)
+{
+ ToolkitTestApplication application;
+ TextLabel labelShort = TextLabel::New("Some text to scroll");
+ TextLabel labelLong = TextLabel::New("Some text to scroll that is greater than the width of the text. The quick brown fox jumps over the lazy dog. Hello World, we meet again!");
+
+ DALI_TEST_CHECK( labelShort );
+ DALI_TEST_CHECK( labelLong );
+ // Avoid a crash when core load gl resources.
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
+ Stage::GetCurrent().Add( labelShort );
+ // Turn on all the effects
+ labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
+ labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
+ labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
+ labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
+ labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
+ labelShort.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::IMMEDIATE );
+
+ Stage::GetCurrent().Add( labelLong );
+ // Turn on all the effects
+ labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
+ labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
+ labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
+ labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
+ labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
+ labelLong.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::FINISH_LOOP );
+
+ try
+ {
+ // Render some text with the shared atlas backend
+ labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
+ labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
+ application.SendNotification();
+ application.Render();
+
+ labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
+ labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
+ application.SendNotification();
+ application.Render();
+
+ }
+ catch( ... )
+ {
+ tet_result(TET_FAIL);
+ }
+
+ END_TEST;
+}
+
+int UtcDaliToolkitTextlabelScrollingCenterAlignRTLP(void)
+{
+ ToolkitTestApplication application;
+ TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
+ TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
+
+ DALI_TEST_CHECK( labelShort );
+ DALI_TEST_CHECK( labelLong );
+ // Avoid a crash when core load gl resources.
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
+ Stage::GetCurrent().Add( labelShort );
+ // Turn on all the effects
+ labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
+ labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
+ labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
+ labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
+ labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
+ labelShort.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::IMMEDIATE );
+
+ Stage::GetCurrent().Add( labelLong );
+ // Turn on all the effects
+ labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
+ labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
+ labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
+ labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
+ labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
+ labelLong.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::FINISH_LOOP );
+
+ try
+ {
+ // Render some text with the shared atlas backend
+ labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
+ labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
+ application.SendNotification();
+ application.Render();
+
+ labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
+ labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
+ application.SendNotification();
+ application.Render();
+
+ }
+ catch( ... )
+ {
+ tet_result(TET_FAIL);
+ }
+
+ END_TEST;
+}
+
+int UtcDaliToolkitTextlabelScrollingEndAlignP(void)
+{
+ ToolkitTestApplication application;
+ TextLabel labelShort = TextLabel::New("Some text to scroll");
+ TextLabel labelLong = TextLabel::New("Some text to scroll that is greater than the width of the text. The quick brown fox jumps over the lazy dog. Hello World, we meet again!");
+
+ DALI_TEST_CHECK( labelShort );
+ DALI_TEST_CHECK( labelLong );
+ // Avoid a crash when core load gl resources.
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
+ Stage::GetCurrent().Add( labelShort );
+ // Turn on all the effects
+ labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
+ labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
+ labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
+ labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
+ labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
+ labelShort.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::IMMEDIATE );
+
+ Stage::GetCurrent().Add( labelLong );
+ // Turn on all the effects
+ labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
+ labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
+ labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
+ labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
+ labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
+ labelLong.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::FINISH_LOOP );
+
+ try
+ {
+ // Render some text with the shared atlas backend
+ labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
+ labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
+ application.SendNotification();
+ application.Render();
+
+ labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
+ labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
+ application.SendNotification();
+ application.Render();
+
+ }
+ catch( ... )
+ {
+ tet_result(TET_FAIL);
+ }
+
+ END_TEST;
+}
+
+int UtcDaliToolkitTextlabelScrollingEndAlignRTLP(void)
+{
+ ToolkitTestApplication application;
+ TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
+ TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
+
+ DALI_TEST_CHECK( labelShort );
+ DALI_TEST_CHECK( labelLong );
+ // Avoid a crash when core load gl resources.
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
+ Stage::GetCurrent().Add( labelShort );
+ // Turn on all the effects
+ labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
+ labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
+ labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
+ labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
+ labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
+ labelShort.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::IMMEDIATE );
+
+ Stage::GetCurrent().Add( labelLong );
+ // Turn on all the effects
+ labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
+ labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
+ labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
+ labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
+ labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
+ labelLong.SetProperty( DevelTextLabel::Property::AUTO_SCROLL_STOP_MODE, DevelTextLabel::AutoScrollStopMode::FINISH_LOOP );
+
+ try
+ {
+ // Render some text with the shared atlas backend
+ labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
+ labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
+ application.SendNotification();
+ application.Render();
+
+ labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
+ labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
+ application.SendNotification();
+ application.Render();
+
+ }
+ catch( ... )
+ {
+ tet_result(TET_FAIL);
+ }
+
+ END_TEST;
+}
+
int UtcDaliToolkitTextlabelScrollingInterruptedP(void)
{
ToolkitTestApplication application;
// CLASS HEADER
#include "control-devel.h"
+// EXTERNAL INCLUDES
+#include <dali/public-api/animation/animation.h>
+
// INTERNAL INCLUDES
#include <dali-toolkit/internal/controls/control/control-data-impl.h>
#include <dali-toolkit/public-api/controls/control-impl.h>
+#include <dali-toolkit/devel-api/visual-factory/transition-data.h>
namespace Dali
{
ResourceReadySignalType& ResourceReadySignal( Control& control )
{
-
Internal::Control& internalControl = Toolkit::Internal::GetImplementation(control);
Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get( internalControl );
return controlImpl.IsResourceReady();
}
+void RegisterVisual( Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual )
+{
+ Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get( control );
+ controlImpl.RegisterVisual( index, visual );
+}
+
+void RegisterVisual( Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual, bool enabled )
+{
+ Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get( control );
+ controlImpl.RegisterVisual( index, visual, enabled );
+}
+
+void UnregisterVisual( Internal::Control& control, Dali::Property::Index index )
+{
+ Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get( control );
+ controlImpl.UnregisterVisual( index );
+}
+
+Toolkit::Visual::Base GetVisual( const Internal::Control& control, Dali::Property::Index index )
+{
+ const Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get( control );
+ return controlImpl.GetVisual( index );
+}
+
+void EnableVisual( Internal::Control& control, Dali::Property::Index index, bool enable )
+{
+ Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get( control );
+ controlImpl.EnableVisual( index, enable );
+}
+
+bool IsVisualEnabled( const Internal::Control& control, Dali::Property::Index index )
+{
+ const Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get( control );
+ return controlImpl.IsVisualEnabled( index );
+}
+
+Dali::Animation CreateTransition( Internal::Control& control, const Toolkit::TransitionData& handle )
+{
+ Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get( control );
+ return controlImpl.CreateTransition( handle );
+}
+
} // namespace DevelControl
#define DALI_TOOLKIT_CONTROL_DEVEL_H
/*
- * Copyright (c) 2016 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.
namespace Toolkit
{
+class TransitionData;
+
+namespace Visual
+{
+class Base;
+}
+
namespace DevelControl
{
* void YourCallbackName( Control control );
* @endcode
*/
-ResourceReadySignalType& ResourceReadySignal( Control& control );
+DALI_IMPORT_API ResourceReadySignalType& ResourceReadySignal( Control& control );
/**
* @brief Query if all resources required by a control are loaded and ready.
* @return true if the resources are loaded and ready, false otherwise
*
*/
-bool IsResourceReady( const Control& control );
+DALI_IMPORT_API bool IsResourceReady( const Control& control );
+
+/**
+ * @brief Register a visual by Property Index, linking an Actor to visual when required.
+ * In the case of the visual being an actor or control deeming visual not required then visual should be an empty handle.
+ * No parenting is done during registration, this should be done by derived class.
+ *
+ * @param[in] control The control
+ * @param[in] index The Property index of the visual, used to reference visual
+ * @param[in] visual The visual to register
+ * @note Derived class should not call visual.SetOnStage(actor). It is the responsibility of the base class to connect/disconnect registered visual to stage.
+ * Use below API with enabled set to false if derived class wishes to control when visual is staged.
+ */
+DALI_IMPORT_API void RegisterVisual( Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual );
+
+/**
+ * @brief Register a visual by Property Index, linking an Actor to visual when required.
+ *
+ * In the case of the visual being an actor or control deeming visual not required then visual should be an empty handle.
+ * If enabled is false then the visual is not set on stage until enabled by the derived class.
+ * @see EnableVisual
+ *
+ * @param[in] control The control
+ * @param[in] index The Property index of the visual, used to reference visual
+ * @param[in] visual The visual to register
+ * @param[in] enabled false if derived class wants to control when visual is set on stage.
+ *
+ */
+DALI_IMPORT_API void RegisterVisual( Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual, bool enabled );
+
+/**
+ * @brief Erase the entry matching the given index from the list of registered visuals
+ *
+ * @param[in] control The control
+ * @param[in] index The Property index of the visual, used to reference visual
+ */
+DALI_IMPORT_API void UnregisterVisual( Internal::Control& control, Dali::Property::Index index );
+
+/**
+ * @brief Retrieve the visual associated with the given property index.
+ *
+ * @param[in] control The control
+ * @param[in] index The Property index of the visual.
+ * @return The registered visual if exist, otherwise empty handle.
+ * @note For managing object life-cycle, do not store the returned visual as a member which increments its reference count.
+ */
+DALI_IMPORT_API Toolkit::Visual::Base GetVisual( const Internal::Control& control, Dali::Property::Index index );
+
+/**
+ * @brief Sets the given visual to be displayed or not when parent staged.
+ *
+ * @param[in] control The control
+ * @param[in] index The Property index of the visual
+ * @param[in] enable flag to set enabled or disabled.
+ */
+DALI_IMPORT_API void EnableVisual( Internal::Control& control, Dali::Property::Index index, bool enable );
+
+/**
+ * @brief Queries if the given visual is to be displayed when parent staged.
+ *
+ * @param[in] control The control
+ * @param[in] index The Property index of the visual
+ * @return bool whether visual is enabled or not
+ */
+DALI_IMPORT_API bool IsVisualEnabled( const Internal::Control& control, Dali::Property::Index index );
+
+/**
+ * @brief Create a transition effect on the control.
+ *
+ * Only generates an animation if the properties described in the transition
+ * data are staged (e.g. the visual is Enabled and the control is on stage).
+ * Otherwise the target values are stored, and will get set onto the properties
+ * when the visual is next staged.
+ *
+ * @param[in] control The control
+ * @param[in] transitionData The transition data describing the effect to create
+ * @return A handle to an animation defined with the given effect, or an empty
+ * handle if no properties match.
+ */
+DALI_IMPORT_API Dali::Animation CreateTransition( Internal::Control& control, const Toolkit::TransitionData& transitionData );
} // namespace DevelControl
/*
- * Copyright (c) 2016 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.
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/control-impl.h>
+#include <dali-toolkit/devel-api/controls/control-devel.h>
#include <dali-toolkit/devel-api/visual-factory/visual-base.h>
#include <dali-toolkit/public-api/styling/style-manager.h>
#include <dali-toolkit/internal/styling/style-manager-impl.h>
void ControlWrapper::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual )
{
- Control::RegisterVisual( index, visual );
+ DevelControl::RegisterVisual( *this, index, visual );
}
void ControlWrapper::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, bool enabled )
{
- Control::RegisterVisual( index, visual, enabled );
+ DevelControl::RegisterVisual( *this, index, visual, enabled );
}
void ControlWrapper::UnregisterVisual( Property::Index index )
{
- Control::UnregisterVisual( index );
+ DevelControl::UnregisterVisual( *this, index );
}
Toolkit::Visual::Base ControlWrapper::GetVisual( Property::Index index ) const
{
- return Control::GetVisual( index );
+ return DevelControl::GetVisual( *this, index );
}
void ControlWrapper::EnableVisual( Property::Index index, bool enable )
{
- Control::EnableVisual( index, enable );
+ DevelControl::EnableVisual( *this, index, enable );
}
bool ControlWrapper::IsVisualEnabled( Property::Index index ) const
{
- return Control::IsVisualEnabled( index );
+ return DevelControl::IsVisualEnabled( *this, index );
}
Dali::Animation ControlWrapper::CreateTransition( const Toolkit::TransitionData& handle )
{
- return Control::CreateTransition( handle );
+ return DevelControl::CreateTransition( *this, handle );
}
void ControlWrapper::ApplyThemeStyle()
#define DALI_TOOLKIT_INTERNAL_CONTROL_WRAPPER_H
/*
- * Copyright (c) 2016 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.
namespace Toolkit
{
+class TransitionData;
+
+namespace Visual
+{
+class Base;
+}
+
namespace Internal
{
public: // From Control
/**
- * @copydoc Dali::Toolkit::Internal::Control::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual )
+ * @ref Dali::Toolkit::DevelControl::RegisterVisual()
*/
void RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual );
/**
- * @copydoc Dali::Toolkit::Internal::Control::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, bool enabled )
+ * @ref Dali::Toolkit::DevelControl::RegisterVisual()
*/
void RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, bool enabled );
/**
- * @copydoc Dali::Toolkit::Internal::Control::UnregisterVisual()
+ * @ref Dali::Toolkit::DevelControl::UnregisterVisual()
*/
void UnregisterVisual( Property::Index index );
/**
- * @copydoc Dali::Toolkit::Internal::Control::GetVisual()
+ * @ref Dali::Toolkit::DevelControl::GetVisual()
*/
Toolkit::Visual::Base GetVisual( Property::Index index ) const;
/**
- * @copydoc Dali::Toolkit::Internal::Control::EnableVisual()
+ * @ref Dali::Toolkit::DevelControl::EnableVisual()
*/
void EnableVisual( Property::Index index, bool enable );
/**
- * @copydoc Dali::Toolkit::Internal::Control::IsVisualEnabled()
+ * @ref Dali::Toolkit::DevelControl::IsVisualEnabled()
*/
bool IsVisualEnabled( Property::Index index ) const;
/**
- * @copydoc Dali::Toolkit::Internal::Control::CreateTransition()
+ * @ref Dali::Toolkit::DevelControl::CreateTransition()
*/
Dali::Animation CreateTransition( const Toolkit::TransitionData& transitionData );
#include <dali-toolkit/public-api/visuals/image-visual-properties.h>
#include <dali-toolkit/devel-api/align-enums.h>
#include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
+#include <dali-toolkit/devel-api/controls/control-devel.h>
#include <dali-toolkit/devel-api/controls/buttons/button-devel.h>
#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
#include <dali-toolkit/internal/visuals/text/text-visual.h>
* 3) Merge with new properties ( settings )
* 4) Return new merged map
*/
- Toolkit::Visual::Base visual = GetVisual( Toolkit::Button::Property::LABEL );
+ Toolkit::Visual::Base visual = DevelControl::GetVisual( *this, Toolkit::Button::Property::LABEL );
if ( visual )
{
DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "MergeLabelProperties Visual already exists, retrieving existing map\n");
if ( buttonVisual )
{
DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "CreateVisualsForComponent RegisterVisual index(%d) enabled(%s)\n",
- index, IsVisualEnabled( index )?"true":"false" );
+ index, DevelControl::IsVisualEnabled( *this, index )?"true":"false" );
buttonVisual.SetDepthIndex( visualDepth );
- RegisterVisual( index, buttonVisual, IsVisualEnabled( index ) );
+ DevelControl::RegisterVisual( *this, index, buttonVisual, DevelControl::IsVisualEnabled( *this, index ) );
}
else
{
- UnregisterVisual( index );
+ DevelControl::UnregisterVisual( *this, index );
DALI_LOG_INFO( gLogButtonFilter, Debug::General, "CreateVisualsForComponent Visual not created or empty map (clearing visual).(%d)\n", index);
}
PerformFunctionOnVisualsInState( &Button::SelectRequiredVisual, mButtonState );
{
DALI_LOG_INFO( gLogButtonFilter, Debug::General, "GetPropertyMapForVisual visual(%d)\n", visualIndex);
bool success = false;
- Toolkit::Visual::Base visual = GetVisual( visualIndex );
+ Toolkit::Visual::Base visual = DevelControl::GetVisual( *this, visualIndex );
if ( visual )
{
visual.CreatePropertyMap( retreivedMap );
for ( int state = Button::UNSELECTED_STATE; state < Button::STATE_COUNT; state++ )
{
- Toolkit::Visual::Base visual = GetVisual( GET_VISUAL_INDEX_FOR_STATE[state][FOREGROUND] );
+ Toolkit::Visual::Base visual = DevelControl::GetVisual( *this, GET_VISUAL_INDEX_FOR_STATE[state][FOREGROUND] );
Size visualSize;
if ( visual )
{
{
for ( int state = Button::UNSELECTED_STATE; state < Button::STATE_COUNT; state++ )
{
- Toolkit::Visual::Base visual = GetVisual( GET_VISUAL_INDEX_FOR_STATE[state][BACKGROUND] );
+ Toolkit::Visual::Base visual = DevelControl::GetVisual( *this, GET_VISUAL_INDEX_FOR_STATE[state][BACKGROUND] );
Size visualSize;
if ( visual )
{
// Get natural size of label if text has been set
if ( mTextStringSetFlag )
{
- Toolkit::Visual::Base visual = GetVisual( Toolkit::Button::Property::LABEL );
+ Toolkit::Visual::Base visual = DevelControl::GetVisual( *this, Toolkit::Button::Property::LABEL );
if ( visual )
{
{
DALI_LOG_INFO( gLogButtonFilter, Debug::General, "OnRelayout targetSize(%f,%f) ptr(%p) state[%d]\n", size.width, size.height, this, mButtonState );
- Toolkit::Visual::Base currentVisual = GetVisual( GET_VISUAL_INDEX_FOR_STATE[mButtonState][FOREGROUND] );
+ Toolkit::Visual::Base currentVisual = DevelControl::GetVisual( *this, GET_VISUAL_INDEX_FOR_STATE[mButtonState][FOREGROUND] );
- Toolkit::Visual::Base currentBackGroundVisual = GetVisual( GET_VISUAL_INDEX_FOR_STATE[mButtonState][BACKGROUND] );
+ Toolkit::Visual::Base currentBackGroundVisual = DevelControl::GetVisual( *this, GET_VISUAL_INDEX_FOR_STATE[mButtonState][BACKGROUND] );
// Sizes and padding set to zero, if not present then values will no effect calculations.
Vector2 visualPosition = Vector2::ZERO;
if ( mTextStringSetFlag )
{
- Toolkit::Visual::Base textVisual = GetVisual( Toolkit::Button::Property::LABEL ); // No need to search for Label visual if no text set.
+ Toolkit::Visual::Base textVisual = DevelControl::GetVisual( *this, Toolkit::Button::Property::LABEL ); // No need to search for Label visual if no text set.
if ( textVisual )
{
{
DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "Button::SelectRequiredVisual index(%d) state(%d)\n", visualIndex, mButtonState );
- EnableVisual( visualIndex, true );
+ DevelControl::EnableVisual( *this, visualIndex, true );
}
void Button::RemoveVisual( Property::Index visualIndex )
// Use OnButtonVisualRemoval if want button developer to have the option to override removal.
DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "Button::RemoveVisual index(%d) state(%d)\n", visualIndex, mButtonState );
- Toolkit::Visual::Base visual = GetVisual( visualIndex );
+ Toolkit::Visual::Base visual = DevelControl::GetVisual( *this, visualIndex );
if( visual )
{
- EnableVisual( visualIndex, false );
+ DevelControl::EnableVisual( *this, visualIndex, false );
}
}
}
else
{
- UnregisterVisual( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL );
+ DevelControl::UnregisterVisual( *this, Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL );
}
}
}
else
{
- UnregisterVisual( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL );
+ DevelControl::UnregisterVisual( *this, Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL );
}
}
// Used by Deprecated Properties which don't use the Visual Property maps for setting and getting
std::string Button::GetUrlForImageVisual( const Property::Index index ) const
{
- Toolkit::Visual::Base visual = GetVisual( index );
+ Toolkit::Visual::Base visual = DevelControl::GetVisual( *this, index );
std::string result;
if ( visual )
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/image-view/image-view.h>
#include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
+#include <dali-toolkit/devel-api/controls/control-devel.h>
#include <dali-toolkit/devel-api/controls/buttons/button-devel.h>
#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
void ToggleButton::PrepareVisual(Property::Index index, Toolkit::Visual::Base& visual)
{
- RegisterVisual( index, visual, true );
- EnableVisual( index, false );
+ DevelControl::RegisterVisual( *this, index, visual, true );
+ DevelControl::EnableVisual( *this, index, false );
}
void ToggleButton::RelayoutVisual( Property::Index index, const Vector2& size )
{
- Toolkit::Visual::Base visual = GetVisual( index );
+ Toolkit::Visual::Base visual = DevelControl::GetVisual( *this, index );
if ( visual )
{
Size visualSize = Size::ZERO;
// EXTERNAL INCLUDES
#include <dali/public-api/common/dali-common.h>
#include <dali/integration-api/debug.h>
+#include <dali/devel-api/object/handle-devel.h>
#include <dali/devel-api/scripting/enum-helper.h>
#include <dali/devel-api/scripting/scripting.h>
#include <dali/integration-api/debug.h>
return type;
}
+/**
+ * Finds visual in given array, returning true if found along with the iterator for that visual as a out parameter
+ */
+bool FindVisual( Property::Index targetIndex, const RegisteredVisualContainer& visuals, RegisteredVisualContainer::Iterator& iter )
+{
+ for ( iter = visuals.Begin(); iter != visuals.End(); iter++ )
+ {
+ if ( (*iter)->index == targetIndex )
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
void FindChangableVisuals( Dictionary<Property::Map>& stateVisualsToAdd,
Dictionary<Property::Map>& stateVisualsToChange,
DictionaryKeys& stateVisualsToRemove)
}
}
+Toolkit::Visual::Base GetVisualByName(
+ const RegisteredVisualContainer& visuals,
+ const std::string& visualName )
+{
+ Toolkit::Visual::Base visualHandle;
+
+ RegisteredVisualContainer::Iterator iter;
+ for ( iter = visuals.Begin(); iter != visuals.End(); iter++ )
+ {
+ Toolkit::Visual::Base visual = (*iter)->visual;
+ if( visual && visual.GetName() == visualName )
+ {
+ visualHandle = visual;
+ break;
+ }
+ }
+ return visualHandle;
+}
+
/**
* Performs actions as requested using the action name.
* @param[in] object The object on which to perform the action.
DALI_TYPE_REGISTRATION_END()
-
-
} // unnamed namespace
return *internalControl.mImpl;
}
-
-
-
-Toolkit::Visual::Base Control::Impl::GetVisualByName(
- RegisteredVisualContainer& visuals,
- const std::string& visualName )
-{
- Toolkit::Visual::Base visualHandle;
-
- RegisteredVisualContainer::Iterator iter;
- for ( iter = visuals.Begin(); iter != visuals.End(); iter++ )
- {
- Toolkit::Visual::Base visual = (*iter)->visual;
- if( visual && visual.GetName() == visualName )
- {
- visualHandle = visual;
- break;
- }
- }
- return visualHandle;
-}
-
// Gesture Detection Methods
void Control::Impl::PinchDetected(Actor actor, const PinchGesture& pinch)
{
}
return true;
}
+
+void Control::Impl::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual )
+{
+ RegisterVisual( index, visual, true );
+}
+
+void Control::Impl::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, bool enabled )
+{
+ bool visualReplaced ( false );
+ Actor self = mControlImpl.Self();
+
+ if( !mVisuals.Empty() )
+ {
+ RegisteredVisualContainer::Iterator iter;
+ // Check if visual (index) is already registered. Replace if so.
+ if ( FindVisual( index, mVisuals, iter ) )
+ {
+ if( (*iter)->visual && self.OnStage() )
+ {
+ Toolkit::GetImplementation((*iter)->visual).SetOffStage( self );
+ }
+
+ StopObservingVisual( (*iter)->visual );
+ StartObservingVisual( visual );
+
+ (*iter)->visual = visual;
+ visualReplaced = true;
+ }
+ }
+
+ // If not set, set the name of the visual to the same name as the control's property.
+ // ( If the control has been type registered )
+ if( visual.GetName().empty() )
+ {
+ // Check if the control has been type registered:
+ TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid( mControlImpl ) );
+ if( typeInfo )
+ {
+ // Check if the property index has been registered:
+ Property::IndexContainer indices;
+ typeInfo.GetPropertyIndices( indices );
+ Property::IndexContainer::Iterator iter = std::find( indices.Begin(), indices.End(), index );
+ if( iter != indices.End() )
+ {
+ // If it has, then get it's name and use that for the visual
+ std::string visualName = typeInfo.GetPropertyName( index );
+ visual.SetName( visualName );
+ }
+ }
+ }
+
+ if( !visualReplaced ) // New registration entry
+ {
+ mVisuals.PushBack( new RegisteredVisual( index, visual, enabled ) );
+
+ // monitor when the visuals resources are ready
+ StartObservingVisual( visual );
+
+ }
+
+ if( visual && self.OnStage() && enabled )
+ {
+ Toolkit::GetImplementation(visual).SetOnStage( self );
+ }
+
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::RegisterVisual() Registered %s(%d), enabled:%s\n", visual.GetName().c_str(), index, enabled?"T":"F" );
+}
+
+void Control::Impl::UnregisterVisual( Property::Index index )
+{
+ RegisteredVisualContainer::Iterator iter;
+ if ( FindVisual( index, mVisuals, iter ) )
+ {
+ // stop observing visual
+ StopObservingVisual( (*iter)->visual );
+
+ Actor self( mControlImpl.Self() );
+ Toolkit::GetImplementation((*iter)->visual).SetOffStage( self );
+ (*iter)->visual.Reset();
+ mVisuals.Erase( iter );
+ }
+}
+
+Toolkit::Visual::Base Control::Impl::GetVisual( Property::Index index ) const
+{
+ RegisteredVisualContainer::Iterator iter;
+ if ( FindVisual( index, mVisuals, iter ) )
+ {
+ return (*iter)->visual;
+ }
+
+ return Toolkit::Visual::Base();
+}
+
+void Control::Impl::EnableVisual( Property::Index index, bool enable )
+{
+ RegisteredVisualContainer::Iterator iter;
+ if ( FindVisual( index, mVisuals, iter ) )
+ {
+ if ( (*iter)->enabled == enable )
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::EnableVisual Visual %s(%d) already %s\n", (*iter)->visual.GetName().c_str(), index, enable?"enabled":"disabled");
+ return;
+ }
+
+ (*iter)->enabled = enable;
+ Actor parentActor = mControlImpl.Self();
+ if ( mControlImpl.Self().OnStage() ) // If control not on Stage then Visual will be added when StageConnection is called.
+ {
+ if ( enable )
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::EnableVisual Setting %s(%d) on stage \n", (*iter)->visual.GetName().c_str(), index );
+ Toolkit::GetImplementation((*iter)->visual).SetOnStage( parentActor );
+ }
+ else
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::EnableVisual Setting %s(%d) off stage \n", (*iter)->visual.GetName().c_str(), index );
+ Toolkit::GetImplementation((*iter)->visual).SetOffStage( parentActor ); // No need to call if control not staged.
+ }
+ }
+ }
+}
+
+bool Control::Impl::IsVisualEnabled( Property::Index index ) const
+{
+ RegisteredVisualContainer::Iterator iter;
+ if ( FindVisual( index, mVisuals, iter ) )
+ {
+ return (*iter)->enabled;
+ }
+ return false;
+}
+
void Control::Impl::StopObservingVisual( Toolkit::Visual::Base& visual )
{
Internal::Visual::Base& visualImpl = Toolkit::GetImplementation( visual );
visualImpl.AddResourceObserver( *this );
}
-// Properties
+Dali::Animation Control::Impl::CreateTransition( const Toolkit::TransitionData& handle )
+{
+ Dali::Animation transition;
+ const Internal::TransitionData& transitionData = Toolkit::GetImplementation( handle );
+
+ if( transitionData.Count() > 0 )
+ {
+ // Setup a Transition from TransitionData.
+ TransitionData::Iterator end = transitionData.End();
+ for( TransitionData::Iterator iter = transitionData.Begin() ;
+ iter != end; ++iter )
+ {
+ TransitionData::Animator* animator = (*iter);
+
+ Toolkit::Visual::Base visual = GetVisualByName( mVisuals, animator->objectName );
+
+ if( visual )
+ {
+ Internal::Visual::Base& visualImpl = Toolkit::GetImplementation( visual );
+ visualImpl.AnimateProperty( transition, *animator );
+ }
+ else
+ {
+ // Otherwise, try any actor children of control (Including the control)
+ Actor child = mControlImpl.Self().FindChildByName( animator->objectName );
+ if( child )
+ {
+ Property::Index propertyIndex = DevelHandle::GetPropertyIndex( child, animator->propertyKey );
+ if( propertyIndex != Property::INVALID_INDEX )
+ {
+ if( animator->animate == false )
+ {
+ if( animator->targetValue.GetType() != Property::NONE )
+ {
+ child.SetProperty( propertyIndex, animator->targetValue );
+ }
+ }
+ else // animate the property
+ {
+ if( animator->initialValue.GetType() != Property::NONE )
+ {
+ child.SetProperty( propertyIndex, animator->initialValue );
+ }
+
+ if( ! transition )
+ {
+ transition = Dali::Animation::New( 0.1f );
+ }
+
+ transition.AnimateTo( Property( child, propertyIndex ),
+ animator->targetValue,
+ animator->alphaFunction,
+ TimePeriod( animator->timePeriodDelay,
+ animator->timePeriodDuration ) );
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return transition;
+}
-/**
- * Called when a property of an object of this type is set.
- * @param[in] object The object whose property is set.
- * @param[in] index The property index.
- * @param[in] value The new property value.
- */
void Control::Impl::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
{
Toolkit::Control control = Toolkit::Control::DownCast( BaseHandle( object ) );
Toolkit::Visual::Base visual = Toolkit::VisualFactory::Get().CreateVisual( url, ImageDimensions() );
if( visual )
{
- controlImpl.RegisterVisual( Toolkit::Control::Property::BACKGROUND, visual );
+ controlImpl.mImpl->RegisterVisual( Toolkit::Control::Property::BACKGROUND, visual );
visual.SetDepthIndex( DepthIndex::BACKGROUND );
}
}
}
}
-/**
- * Called to retrieve a property of an object of this type.
- * @param[in] object The object whose property is to be retrieved.
- * @param[in] index The property index.
- * @return The current value of the property.
- */
Property::Value Control::Impl::GetProperty( BaseObject* object, Property::Index index )
{
Property::Value value;
{
DALI_LOG_WARNING( "BACKGROUND_IMAGE property is deprecated. Use BACKGROUND property instead\n" );
Property::Map map;
- Toolkit::Visual::Base visual = controlImpl.GetVisual( Toolkit::Control::Property::BACKGROUND );
+ Toolkit::Visual::Base visual = controlImpl.mImpl->GetVisual( Toolkit::Control::Property::BACKGROUND );
if( visual )
{
visual.CreatePropertyMap( map );
case Toolkit::Control::Property::BACKGROUND:
{
Property::Map map;
- Toolkit::Visual::Base visual = controlImpl.GetVisual( Toolkit::Control::Property::BACKGROUND );
+ Toolkit::Visual::Base visual = controlImpl.mImpl->GetVisual( Toolkit::Control::Property::BACKGROUND );
if( visual )
{
visual.CreatePropertyMap( map );
}
}
-
-/**
- * Go through the list of visuals that are common to both states.
- * If they are different types, or are both image types with different
- * URLs, then the existing visual needs moving and the new visual creating
- */
void Control::Impl::RecreateChangedVisuals( Dictionary<Property::Map>& stateVisualsToChange,
Dictionary<Property::Map>& instancedProperties )
{
#define DALI_TOOLKIT_CONTROL_DATA_IMPL_H
/*
- * Copyright (c) 2016 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.
/**
- * Holds the Implementation for the internal control class
+ * @brief Holds the Implementation for the internal control class
*/
class Control::Impl : public ConnectionTracker, public Visual::ResourceObserver
{
public:
+ /**
+ * @brief Retrieves the implementation of the internal control class.
+ * @param[in] internalControl A ref to the control whose internal implementation is required
+ * @return The internal implementation
+ */
static Control::Impl& Get( Internal::Control& internalControl );
+ /**
+ * @copydoc Get( Internal::Control& )
+ */
static const Control::Impl& Get( const Internal::Control& internalControl );
-
+ /**
+ * @brief Constructor.
+ * @param[in] controlImpl The control which own this implementation
+ */
Impl( Control& controlImpl );
+ /**
+ * @brief Destructor.
+ */
~Impl();
+ /**
+ * @brief Called when a pinch is detected.
+ * @param[in] actor The actor the pinch occurred on
+ * @param[in] pinch The pinch gesture details
+ */
void PinchDetected(Actor actor, const PinchGesture& pinch);
+ /**
+ * @brief Called when a pan is detected.
+ * @param[in] actor The actor the pan occurred on
+ * @param[in] pinch The pan gesture details
+ */
void PanDetected(Actor actor, const PanGesture& pan);
+ /**
+ * @brief Called when a tap is detected.
+ * @param[in] actor The actor the tap occurred on
+ * @param[in] pinch The tap gesture details
+ */
void TapDetected(Actor actor, const TapGesture& tap);
+ /**
+ * @brief Called when a long-press is detected.
+ * @param[in] actor The actor the long-press occurred on
+ * @param[in] pinch The long-press gesture details
+ */
void LongPressDetected(Actor actor, const LongPressGesture& longPress);
- void ResourceReady( Visual::Base& object);
-
+ /**
+ * @brief Called when a resource is ready.
+ * @param[in] object The visual whose resources are ready
+ * @note Overriding method in Visual::ResourceObserver.
+ */
+ virtual void ResourceReady( Visual::Base& object );
+
+ /**
+ * @copydoc Dali::Toolkit::DevelControl::RegisterVisual()
+ */
+ void RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual );
+
+ /**
+ * @copydoc Dali::Toolkit::DevelControl::RegisterVisual()
+ */
+ void RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, bool enabled );
+
+ /**
+ * @copydoc Dali::Toolkit::DevelControl::UnregisterVisual()
+ */
+ void UnregisterVisual( Property::Index index );
+
+ /**
+ * @copydoc Dali::Toolkit::DevelControl::GetVisual()
+ */
+ Toolkit::Visual::Base GetVisual( Property::Index index ) const;
+
+ /**
+ * @copydoc Dali::Toolkit::DevelControl::EnableVisual()
+ */
+ void EnableVisual( Property::Index index, bool enable );
+
+ /**
+ * @copydoc Dali::Toolkit::DevelControl::IsVisualEnabled()
+ */
+ bool IsVisualEnabled( Property::Index index ) const;
+
+ /**
+ * @brief Stops observing the given visual.
+ * @param[in] visual The visual to stop observing
+ */
void StopObservingVisual( Toolkit::Visual::Base& visual );
+ /**
+ * @brief Starts observing the given visual.
+ * @param[in] visual The visual to start observing
+ */
void StartObservingVisual( Toolkit::Visual::Base& visual);
+ /**
+ * @copydoc Dali::Toolkit::DevelControl::CreateTransition()
+ */
+ Dali::Animation CreateTransition( const Toolkit::TransitionData& transitionData );
+
+ /**
+ * @brief Function used to set control properties.
+ * @param[in] object The object whose property to set
+ * @param[in] index The index of the property to set
+ * @param[in] value The value of the property to set
+ */
static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
+ /**
+ * @brief Function used to retrieve the value of control properties.
+ * @param[in] object The object whose property to get
+ * @param[in] index The index of the property to get
+ * @return The value of the property
+ */
static Property::Value GetProperty( BaseObject* object, Property::Index index );
+ /**
+ * @brief Sets the state of the control.
+ * @param[in] newState The state to set
+ * @param[in] withTransitions Whether to show a transition when changing to the new state
+ */
void SetState( DevelControl::State newState, bool withTransitions=true );
+ /**
+ * @brief Sets the sub-state of the control.
+ * @param[in] newState The sub-state to set
+ * @param[in] withTransitions Whether to show a transition when changing to the new sub-state
+ */
void SetSubState( const std::string& subStateName, bool withTransitions=true );
+ /**
+ * @brief Replaces visuals and properties from the old state to the new state.
+ * @param[in] oldState The old state
+ * @param[in] newState The new state
+ * @param[in] subState The current sub state
+ */
void ReplaceStateVisualsAndProperties( const StylePtr oldState, const StylePtr newState, const std::string& subState );
+ /**
+ * @brief Removes a visual from the control's container.
+ * @param[in] visuals The container of visuals
+ * @param[in] visualName The name of the visual to remove
+ */
void RemoveVisual( RegisteredVisualContainer& visuals, const std::string& visualName );
+ /**
+ * @brief Removes several visuals from the control's container.
+ * @param[in] visuals The container of visuals
+ * @param[in] removeVisuals The visuals to remove
+ */
void RemoveVisuals( RegisteredVisualContainer& visuals, DictionaryKeys& removeVisuals );
- void CopyInstancedProperties( RegisteredVisualContainer& visuals, Dictionary<Property::Map>& instancedProperties );
-
+ /**
+ * @brief Copies the visual properties that are specific to the control instance into the instancedProperties container.
+ * @param[in] visuals The control's visual container
+ * @param[out] instancedProperties The instanced properties are added to this container
+ */
+ void CopyInstancedProperties( RegisteredVisualContainer& visuals, Dictionary<Property::Map>& instancedProperties );
+
+ /**
+ * @brief On state change, ensures visuals are moved or created appropriately.
+ *
+ * Go through the list of visuals that are common to both states.
+ * If they are different types, or are both image types with different
+ * URLs, then the existing visual needs moving and the new visual needs creating
+ *
+ * @param[in] stateVisualsToChange The visuals to change
+ * @param[in] instancedProperties The instanced properties @see CopyInstancedProperties
+ */
void RecreateChangedVisuals( Dictionary<Property::Map>& stateVisualsToChange, Dictionary<Property::Map>& instancedProperties );
- Toolkit::Visual::Base GetVisualByName( RegisteredVisualContainer& visuals, const std::string& visualName );
-
+ /**
+ * @brief Whether the resource is ready
+ * @return True if the resource is read.
+ */
bool IsResourceReady() const;
Control& mControlImpl;
int mUpFocusableActorId; ///< Actor ID of Up focusable control.
int mDownFocusableActorId; ///< Actor ID of Down focusable control.
-
RegisteredVisualContainer mVisuals; ///< Stores visuals needed by the control, non trivial type so std::vector used.
std::string mStyleName;
Vector4 mBackgroundColor; ///< The color of the background visual
static const PropertyRegistration PROPERTY_10;
static const PropertyRegistration PROPERTY_11;
static const PropertyRegistration PROPERTY_12;
-
};
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/visuals/visual-properties.h>
#include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
+#include <dali-toolkit/devel-api/controls/control-devel.h>
#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
#include <dali-toolkit/internal/filters/blur-two-pass-filter.h>
#include <dali-toolkit/internal/filters/emboss-filter.h>
FrameBufferImage dummyImage = FrameBufferImage::New( mTargetSize.width, mTargetSize.height, mPixelFormat );
Internal::InitializeVisual( self, mVisualPostFilter, dummyImage );
- RegisterVisual( POST_FILTER_VISUAL, mVisualPostFilter );
+ DevelControl::RegisterVisual( *this, POST_FILTER_VISUAL, mVisualPostFilter );
Property::Map customShader;
customShader[ Toolkit::Visual::Shader::Property::VERTEX_SHADER ] = EFFECTS_VIEW_VERTEX_SOURCE;
mImageForChildren = FrameBufferImage::New( mTargetSize.width, mTargetSize.height, mPixelFormat );
Internal::InitializeVisual( self, mVisualForChildren, mImageForChildren );
- RegisterVisual( CHILD_VISUAL, mVisualForChildren );
+ DevelControl::RegisterVisual( *this, CHILD_VISUAL, mVisualForChildren );
mVisualForChildren.SetDepthIndex( DepthIndex::CONTENT+1 );
mImagePostFilter = FrameBufferImage::New( mTargetSize.width, mTargetSize.height, mPixelFormat );
-// Copyright (c) 2016 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
// CLASS HEADER
#include "image-view-impl.h"
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/image-view/image-view.h>
+#include <dali-toolkit/devel-api/controls/control-devel.h>
#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
#include <dali-toolkit/internal/visuals/visual-string-constants.h>
mPropertyMap.Clear();
mVisual = Toolkit::VisualFactory::Get().CreateVisual( image );
- RegisterVisual( Toolkit::ImageView::Property::IMAGE, mVisual );
+ DevelControl::RegisterVisual( *this, Toolkit::ImageView::Property::IMAGE, mVisual );
RelayoutRequest();
}
mImage.Reset();
mVisual = Toolkit::VisualFactory::Get().CreateVisual( mPropertyMap );
- RegisterVisual( Toolkit::ImageView::Property::IMAGE, mVisual );
+ DevelControl::RegisterVisual( *this, Toolkit::ImageView::Property::IMAGE, mVisual );
RelayoutRequest();
}
mPropertyMap.Clear();
mVisual = Toolkit::VisualFactory::Get().CreateVisual( url, size );
- RegisterVisual( Toolkit::ImageView::Property::IMAGE, mVisual );
+ DevelControl::RegisterVisual( *this, Toolkit::ImageView::Property::IMAGE, mVisual );
RelayoutRequest();
}
#include <dali/public-api/size-negotiation/relayout-container.h>
#include <dali/public-api/math/math-utils.h>
#include <dali-toolkit/devel-api/align-enums.h>
+#include <dali-toolkit/devel-api/controls/control-devel.h>
#include <dali-toolkit/devel-api/visual-factory/visual-base.h>
#include <dali-toolkit/public-api/visuals/color-visual-properties.h>
#include <dali-toolkit/public-api/visuals/image-visual-properties.h>
trackSize.width = std::max( 0.0f, size.width ); // Ensure we don't go negative
- Toolkit::Visual::Base trackVisual = GetVisual( Toolkit::ProgressBar::Property::TRACK_VISUAL );
- Toolkit::Visual::Base secondProgressVisual = GetVisual( Toolkit::ProgressBar::Property::SECONDARY_PROGRESS_VISUAL );
- Toolkit::Visual::Base progressVisual = GetVisual( Toolkit::ProgressBar::Property::PROGRESS_VISUAL );
- Toolkit::Visual::Base labelVisual = GetVisual( Toolkit::ProgressBar::Property::LABEL_VISUAL );
- Toolkit::Visual::Base indeterminateVisual = GetVisual( Toolkit::ProgressBar::Property::INDETERMINATE_VISUAL );
+ Toolkit::Visual::Base trackVisual = DevelControl::GetVisual( *this, Toolkit::ProgressBar::Property::TRACK_VISUAL );
+ Toolkit::Visual::Base secondProgressVisual = DevelControl::GetVisual( *this, Toolkit::ProgressBar::Property::SECONDARY_PROGRESS_VISUAL );
+ Toolkit::Visual::Base progressVisual = DevelControl::GetVisual( *this, Toolkit::ProgressBar::Property::PROGRESS_VISUAL );
+ Toolkit::Visual::Base labelVisual = DevelControl::GetVisual( *this, Toolkit::ProgressBar::Property::LABEL_VISUAL );
+ Toolkit::Visual::Base indeterminateVisual = DevelControl::GetVisual( *this, Toolkit::ProgressBar::Property::INDETERMINATE_VISUAL );
if( trackVisual )
{
Vector3 ProgressBar::GetNaturalSize()
{
// Return the bigger size after comparing trackVisual naturalSize and labelVisual naturalSize
- Toolkit::Visual::Base trackVisual = GetVisual( Toolkit::ProgressBar::Property::TRACK_VISUAL );
- Toolkit::Visual::Base labelVisual = GetVisual( Toolkit::ProgressBar::Property::LABEL_VISUAL );
+ Toolkit::Visual::Base trackVisual = DevelControl::GetVisual( *this, Toolkit::ProgressBar::Property::TRACK_VISUAL );
+ Toolkit::Visual::Base labelVisual = DevelControl::GetVisual( *this, Toolkit::ProgressBar::Property::LABEL_VISUAL );
Size trackSize;
Size labelSize;
void ProgressBar::SetIndeterminate( bool value )
{
mIndeterminate = value;
- EnableVisual( Toolkit::ProgressBar::Property::INDETERMINATE_VISUAL, mIndeterminate );
+ DevelControl::EnableVisual( *this, Toolkit::ProgressBar::Property::INDETERMINATE_VISUAL, mIndeterminate );
if( mIndeterminate )
{
mIndeterminateVisualAni.Clear();
}
- mIndeterminateVisualAni = CreateTransition( mIndeterminateVisualTransition );
+ mIndeterminateVisualAni = DevelControl::CreateTransition( *this, mIndeterminateVisualTransition );
if( mIndeterminate && mIndeterminateVisualAni )
{
progressVisual.SetDepthIndex( visualDepth );
if( index == Toolkit::ProgressBar::Property::INDETERMINATE_VISUAL )
{
- RegisterVisual( index, progressVisual, mIndeterminate );
+ DevelControl::RegisterVisual( *this, index, progressVisual, mIndeterminate );
}
else
{
- RegisterVisual( index, progressVisual, true );
+ DevelControl::RegisterVisual( *this, index, progressVisual, true );
}
}
else
{
- UnregisterVisual( index );
+ DevelControl::UnregisterVisual( *this, index );
}
}
bool ProgressBar::GetPropertyMapForVisual( Property::Index visualIndex, Property::Map& retreivedMap ) const
{
bool success = false;
- Toolkit::Visual::Base visual = GetVisual( visualIndex );
+ Toolkit::Visual::Base visual = DevelControl::GetVisual( *this, visualIndex );
if ( visual )
{
{
// set new text string as TEXT property
Property::Map newTextMap;
- Toolkit::Visual::Base label = progressBarImpl.GetVisual( Toolkit::ProgressBar::Property::LABEL_VISUAL );
+ Toolkit::Visual::Base label = DevelControl::GetVisual( progressBarImpl, Toolkit::ProgressBar::Property::LABEL_VISUAL );
if( label )
{
#include <dali/integration-api/debug.h>
// INTERNAL_INCLUDES
+#include <dali-toolkit/devel-api/controls/control-devel.h>
#include <dali-toolkit/internal/visuals/visual-base-impl.h>
#include <dali-toolkit/internal/visuals/visual-factory-impl.h>
Actor self( Self() );
mVisuals[0] = Toolkit::VisualFactory::Get().CreateVisual( mInputImage );
- RegisterVisual( 0, mVisuals[0] ); // Will clean up previously registered visuals for this index.
+ DevelControl::RegisterVisual( *this, 0, mVisuals[0] ); // Will clean up previously registered visuals for this index.
mVisuals[0].SetDepthIndex(0);
// custom shader is not applied on the original image.
GAUSSIAN_BLUR_RENDER_TARGET_PIXEL_FORMAT );
mVisuals[i] = Toolkit::VisualFactory::Get().CreateVisual( mBlurredImage[i - 1] );
- RegisterVisual( i, mVisuals[i] ); // Will clean up existing visual with same index.
+ DevelControl::RegisterVisual( *this, i, mVisuals[i] ); // Will clean up existing visual with same index.
mVisuals[i].SetDepthIndex( i );
SetShaderEffect( mVisuals[i] );
}
{
if( impl.mTextScroller )
{
- impl.mTextScroller->SetLoopCount( 0 ); // Causes the current animation to finish playing (0)
+ impl.mTextScroller->StopScrolling();
}
}
// If request is enable (true) then start autoscroll as not already running
// If speed, loopCount or gap not set via property system then will need to create a TextScroller with defaults
mTextScroller = Text::TextScroller::New( *this );
}
- mTextScroller->SetParameters( mRenderableActor, controlSize, offScreenSize, direction, alignmentOffset );
+ mTextScroller->SetParameters( mRenderableActor, controlSize, offScreenSize, direction, alignmentOffset, mController->GetHorizontalAlignment() );
Actor self = Self();
self.Add( mTextScroller->GetScrollingText() );
#include <dali-toolkit/public-api/controls/text-controls/text-label.h>
#include <dali-toolkit/devel-api/controls/buttons/button-devel.h>
#include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
+#include <dali-toolkit/devel-api/controls/control-devel.h>
#include <dali-toolkit/devel-api/controls/text-controls/text-selection-popup-callback-interface.h>
#include <dali-toolkit/devel-api/visuals/text-visual-properties.h>
#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
case Toolkit::TextSelectionPopup::Property::BACKGROUND_BORDER:
{
Property::Map map;
- Toolkit::Visual::Base visual = impl.GetVisual( Toolkit::TextSelectionPopup::Property::BACKGROUND_BORDER );
+ Toolkit::Visual::Base visual = DevelControl::GetVisual( impl, Toolkit::TextSelectionPopup::Property::BACKGROUND_BORDER );
if( visual )
{
visual.CreatePropertyMap( map );
void TextSelectionPopup::CreateBackgroundBorder( Property::Map& propertyMap )
{
// Removes previous image if necessary
- UnregisterVisual( Toolkit::TextSelectionPopup::Property::BACKGROUND_BORDER );
+ DevelControl::UnregisterVisual( *this, Toolkit::TextSelectionPopup::Property::BACKGROUND_BORDER );
if( ! propertyMap.Empty() )
{
if( visual )
{
- RegisterVisual( Toolkit::TextSelectionPopup::Property::BACKGROUND_BORDER, visual );
+ DevelControl::RegisterVisual( *this, Toolkit::TextSelectionPopup::Property::BACKGROUND_BORDER, visual );
visual.SetDepthIndex( DepthIndex::CONTENT );
}
}
{
bool success = false;
+ Actor currentFocusedActor = GetCurrentFocusActor();
+
+ // If developer set focus on same actor, doing nothing
+ if( actor == currentFocusedActor )
+ {
+ if( !actor )
+ {
+ return false;
+ }
+ return true;
+ }
+
// Check whether the actor is in the stage and is keyboard focusable.
if( actor && actor.IsKeyboardFocusable() && actor.OnStage() )
{
{
actor.Add( GetFocusIndicatorActor() );
}
- // Send notification for the change of focus actor
- Actor currentFocusedActor = GetCurrentFocusActor();
+ // Send notification for the change of focus actor
if( !mFocusChangedSignal.Empty() )
{
mFocusChangedSignal.Emit(currentFocusedActor, actor);
void StyleManager::ApplyDefaultTheme()
{
- std::string empty;
- SetTheme( empty );
+ SetTheme( DEFAULT_THEME );
}
const std::string& StyleManager::GetDefaultFontFamily() const
// Always load the default theme first, then merge in the custom theme if present
themeLoaded = LoadJSON( mThemeBuilder, DEFAULT_THEME );
+ mThemeFile = themeFile;
- if( ! themeFile.empty() )
+ if( themeFile.compare(DEFAULT_THEME) != 0 )
{
- mThemeFile = themeFile;
themeLoaded = LoadJSON( mThemeBuilder, mThemeFile );
}
#define DALI_TOOLKIT_TEXT_LAYOUT_ALIGNMENT_H
/*
- * Copyright (c) 2016 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.
VERTICAL_ALIGN_BOTTOM
};
+enum AlignmentCount
+{
+ HORIZONTAL_ALIGN_COUNT = HORIZONTAL_ALIGN_END + 1,
+ VERTICAL_ALIGN_COUNT = VERTICAL_ALIGN_BOTTOM + 1
+};
+
} // namespace Layout
} // namespace Text
mIsAutoScrollEnabled( false ),
mAutoScrollDirectionRTL( false ),
mUnderlineSetByString( false ),
- mShadowSetByString( false )
+ mShadowSetByString( false ),
+ mFontStyleSetByString( false )
{
mModel = Model::New();
bool mUnderlineSetByString:1; ///< Set when underline is set by string (legacy) instead of map
bool mShadowSetByString:1; ///< Set when shadow is set by string (legacy) instead of map
+ bool mFontStyleSetByString:1; ///< Set when font style is set by string (legacy) instead of map
};
} // namespace Text
mImpl->mShadowSetByString = setByString;
}
+bool Controller::IsFontStyleSetByString()
+{
+ return mImpl->mFontStyleSetByString;
+}
+
+void Controller::FontStyleSetByString( bool setByString )
+{
+ mImpl->mFontStyleSetByString = setByString;
+}
+
// public : Queries & retrieves.
Layout::Engine& Controller::GetLayoutEngine()
*/
void ShadowSetByString( bool setByString );
+ /**
+ * @brief Query if font style settings were provided by string or map
+ * @return bool true if set by string
+ */
+ bool IsFontStyleSetByString();
+
+ /**
+ * Set method font style setting were set by
+ * @param[in] bool, true if set by string
+ */
+ void FontStyleSetByString( bool setByString );
+
public: // Update.
/**
const std::string& fontStyleProperties = value.Get<std::string>();
ParsePropertyString( fontStyleProperties, map );
+ controller->FontStyleSetByString( true );
+
}
else
{
map = value.Get<Property::Map>();
+ controller->FontStyleSetByString( false );
}
if( !map.Empty() )
if( controller )
{
const bool isDefaultStyle = FontStyle::DEFAULT == type;
+ const bool isSetbyString = controller->IsFontStyleSetByString();
bool weightDefined = false;
bool widthDefined = false;
}
}
- Property::Map map;
-
- if( weightDefined )
+ if( !isSetbyString )
{
- if( TextAbstraction::FontWeight::NONE != weight )
+ Property::Map map;
+
+ if( weightDefined )
{
- const std::string weightStr( GetEnumerationName( weight,
- FONT_WEIGHT_STRING_TABLE,
- FONT_WEIGHT_STRING_TABLE_COUNT ) );
+ if( TextAbstraction::FontWeight::NONE != weight )
+ {
+ const std::string weightStr( GetEnumerationName( weight,
+ FONT_WEIGHT_STRING_TABLE,
+ FONT_WEIGHT_STRING_TABLE_COUNT ) );
- map.Insert( WEIGHT_KEY, weightStr );
+ map.Insert( WEIGHT_KEY, weightStr );
+ }
}
- }
- if( widthDefined )
- {
- if( TextAbstraction::FontWidth::NONE != width )
+ if( widthDefined )
+ {
+ if( TextAbstraction::FontWidth::NONE != width )
+ {
+ const std::string widthStr( GetEnumerationName( width,
+ FONT_WIDTH_STRING_TABLE,
+ FONT_WIDTH_STRING_TABLE_COUNT ) );
+
+ map.Insert( WIDTH_KEY, widthStr );
+ }
+ }
+
+ if( slantDefined )
{
- const std::string widthStr( GetEnumerationName( width,
- FONT_WIDTH_STRING_TABLE,
- FONT_WIDTH_STRING_TABLE_COUNT ) );
+ if( TextAbstraction::FontSlant::NONE != slant )
+ {
+ const std::string slantStr( GetEnumerationName( slant,
+ FONT_SLANT_STRING_TABLE,
+ FONT_SLANT_STRING_TABLE_COUNT ) );
- map.Insert( WIDTH_KEY, widthStr );
+ map.Insert( SLANT_KEY, slantStr );
+ }
}
- }
- if( slantDefined )
+ value = map;
+ } // SetbyMAP
+ else
{
- if( TextAbstraction::FontSlant::NONE != slant )
+ std::string fontStyleProperties = "{";
+
+ if( weightDefined )
{
- const std::string slantStr( GetEnumerationName( slant,
- FONT_SLANT_STRING_TABLE,
- FONT_SLANT_STRING_TABLE_COUNT ) );
+ if( TextAbstraction::FontWeight::NONE != weight )
+ {
+ const std::string weightStr( GetEnumerationName( weight,
+ FONT_WEIGHT_STRING_TABLE,
+ FONT_WEIGHT_STRING_TABLE_COUNT ) );
- map.Insert( SLANT_KEY, slantStr );
+ fontStyleProperties += "\"weight\":\"" + weightStr + "\",";
+ }
}
- }
- value = map;
- }
+ if( widthDefined )
+ {
+ if( TextAbstraction::FontWidth::NONE != width )
+ {
+ const std::string widthStr( GetEnumerationName( width,
+ FONT_WIDTH_STRING_TABLE,
+ FONT_WIDTH_STRING_TABLE_COUNT ) );
+ fontStyleProperties += "\"width\":\"" + widthStr + "\",";
+ }
+ }
+
+ if( slantDefined )
+ {
+ if( TextAbstraction::FontSlant::NONE != slant )
+ {
+ const std::string slantStr( GetEnumerationName( slant,
+ FONT_SLANT_STRING_TABLE,
+ FONT_SLANT_STRING_TABLE_COUNT ) );
+
+ fontStyleProperties += "\"slant\":\"" + slantStr + "\"";
+ }
+ }
+
+ // If last character is comma, it will be removed.
+ if((*fontStyleProperties.rbegin()) == ',' )
+ {
+ fontStyleProperties = fontStyleProperties.substr( 0, fontStyleProperties.size()-1 );
+ }
+ fontStyleProperties += "}";
+
+ value = fontStyleProperties;
+ } // SetbyString
+ }// controller
}
FontWeight StringToWeight( const char* const weightStr )
/*
- * Copyright (c) 2016 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.
uniform mediump float uDelta;\n
uniform mediump vec2 uTextureSize;
uniform mediump float uGap;\n
- uniform mediump float uRtl;\n
+ uniform mediump float uAlign;\n
\n
void main()\n
{\n
float smallTextPadding = max(uSize.x - uTextureSize.x, 0. );\n
float gap = max( uGap, smallTextPadding );\n
float delta = floor ( uDelta ) + 0.5;
- vTexCoord.x = ( delta + ( uRtl * ( uTextureSize.x - uSize.x ) ) + ( aPosition.x * uSize.x ) )/ ( uTextureSize.x + gap );\n
+ vTexCoord.x = ( delta + ( uAlign * ( uTextureSize.x - uSize.x ) ) + ( aPosition.x * uSize.x ) )/ ( uTextureSize.x + gap );\n
vTexCoord.y = ( 0.5 + floor( aPosition.y * uSize.y ) )/ ( uTextureSize.y ) ;\n
vRatio = uTextureSize.x / ( uTextureSize.x + gap );\n
gl_Position = uProjection * vertexPosition;
);
/**
+ * @brief How the text should be aligned when scrolling the text.
+ *
+ * 0.0f aligns the text to the left, 1.0f aligns the text to the right.
+ * The final alignment depends on three factors:
+ * 1) The alignment value of the text label (Use Text::Layout::HorizontalAlignment enumerations).
+ * 2) The text direction, i.e. whether it's LTR or RTL (0 = LTR, 1 = RTL).
+ * 3) Whether the text is greater than the size of the control ( 0 = Text width <= Control width, 1 = Text width > Control width ).
+ */
+const float ALIGNMENT_TABLE[ Text::Layout::HORIZONTAL_ALIGN_COUNT ][ 2 ][ 2 ] =
+{
+ // HORIZONTAL_ALIGN_BEGIN
+ {
+ { // LTR
+ 0.0f, // Text width <= Control width
+ 0.0f // Text width > Control width
+ },
+ { // RTL
+ 1.0f, // Text width <= Control width
+ 1.0f // Text width > Control width
+ }
+ },
+
+ // HORIZONTAL_ALIGN_CENTER
+ {
+ { // LTR
+ 0.5f, // Text width <= Control width
+ 0.0f // Text width > Control width
+ },
+ { // RTL
+ 0.5f, // Text width <= Control width
+ 1.0f // Text width > Control width
+ }
+ },
+
+ // HORIZONTAL_ALIGN_END
+ {
+ { // LTR
+ 1.0f, // Text width <= Control width
+ 0.0f // Text width > Control width
+ },
+ { // RTL
+ 0.0f, // Text width <= Control width
+ 1.0f // Text width > Control width
+ }
+ }
+};
+
+/**
* @brief Create and set up a camera for the render task to use
*
* @param[in] sizeOfTarget size of the source camera to look at
void TextScroller::SetLoopCount( int loopCount )
{
- if ( loopCount > 0 )
+ if ( loopCount >= 0 )
{
mLoopCount = loopCount;
}
- if ( mScrollAnimation && mScrollAnimation.GetState() == Animation::PLAYING )
- {
- if ( loopCount == 0 ) // Request to stop looping
- {
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextScroller::SetLoopCount Single loop forced\n" );
- switch( mStopMode )
- {
- case DevelTextLabel::AutoScrollStopMode::IMMEDIATE:
- {
- mScrollAnimation.Stop();
- break;
- }
- case DevelTextLabel::AutoScrollStopMode::FINISH_LOOP:
- {
- mScrollAnimation.SetLoopCount( 1 ); // As animation already playing this allows the current animation to finish instead of trying to stop mid-way
- break;
- }
- default:
- {
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Undifined AutoScrollStopMode\n" );
- }
- }
- }
- }
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextScroller::SetLoopCount [%d] Status[%s]\n", mLoopCount, (loopCount)?"looping":"stop" );
}
mStopMode = stopMode;
}
+void TextScroller::StopScrolling()
+{
+ if ( mScrollAnimation && mScrollAnimation.GetState() == Animation::PLAYING )
+ {
+ switch( mStopMode )
+ {
+ case DevelTextLabel::AutoScrollStopMode::IMMEDIATE:
+ {
+ mScrollAnimation.Stop();
+ break;
+ }
+ case DevelTextLabel::AutoScrollStopMode::FINISH_LOOP:
+ {
+ mScrollAnimation.SetLoopCount( 1 ); // As animation already playing this allows the current animation to finish instead of trying to stop mid-way
+ break;
+ }
+ default:
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Undifined AutoScrollStopMode\n" );
+ }
+ }
+ }
+}
+
DevelTextLabel::AutoScrollStopMode::Type TextScroller::GetStopMode() const
{
return mStopMode;
CleanUp();
}
-void TextScroller::SetParameters( Actor sourceActor, const Size& controlSize, const Size& offScreenSize, CharacterDirection direction, float alignmentOffset )
+void TextScroller::SetParameters( Actor sourceActor, const Size& controlSize, const Size& offScreenSize, CharacterDirection direction, float alignmentOffset, Layout::HorizontalAlignment horizontalAlignment )
{
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextScroller::SetParameters controlSize[%f,%f] offscreenSize[%f,%f] direction[%d] alignmentOffset[%f]\n",
controlSize.x, controlSize.y, offScreenSize.x, offScreenSize.y, direction, alignmentOffset );
CreateRenderer( offscreenRenderTargetForText, renderer );
CreateRenderTask( sourceActor, mOffscreenCameraActor, offscreenRenderTargetForText, mRenderTask );
- // Reposition camera to match alignment of target, RTL text has direction=true
- if ( direction )
+ float xPosition = 0.0f;
+ switch( horizontalAlignment )
{
- mOffscreenCameraActor.SetX( alignmentOffset + offScreenSize.width*0.5f );
- }
- else
- {
- mOffscreenCameraActor.SetX( offScreenSize.width * 0.5f );
+ case Layout::HORIZONTAL_ALIGN_BEGIN:
+ {
+ // Reposition camera to match alignment of target, RTL text has direction=true
+ if ( direction )
+ {
+ xPosition = alignmentOffset + offScreenSize.width * 0.5f;
+ }
+ else
+ {
+ xPosition = offScreenSize.width * 0.5f;
+ }
+ break;
+ }
+
+ case Layout::HORIZONTAL_ALIGN_CENTER:
+ {
+ xPosition = controlSize.width * 0.5f;
+ break;
+ }
+
+ case Layout::HORIZONTAL_ALIGN_END:
+ {
+ // Reposition camera to match alignment of target, RTL text has direction=true
+ if ( direction )
+ {
+ xPosition = offScreenSize.width * 0.5f;
+ }
+ else
+ {
+ xPosition = alignmentOffset + offScreenSize.width * 0.5f;
+ }
+ break;
+ }
}
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextScroller::SetParameters xPosition[%f]\n", xPosition );
+
+ mOffscreenCameraActor.SetX( xPosition );
mOffscreenCameraActor.SetY( offScreenSize.height * 0.5f );
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextScroller::SetParameters mWrapGap[%f]\n", mWrapGap )
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextScroller::SetParameters mWrapGap[%f]\n", mWrapGap );
+
+ const float align = ALIGNMENT_TABLE[ horizontalAlignment ][ direction ][ offScreenSize.width > controlSize.width ];
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextScroller::SetParameters align[%f]\n", align );
mScrollingTextActor = Actor::New();
mScrollingTextActor.AddRenderer( renderer );
mScrollingTextActor.RegisterProperty( "uTextureSize", offScreenSize );
- mScrollingTextActor.RegisterProperty( "uRtl", ((direction)?1.0f:0.0f) );
+ mScrollingTextActor.RegisterProperty( "uAlign", align );
mScrollingTextActor.RegisterProperty( "uGap", mWrapGap );
mScrollingTextActor.SetSize( controlSize.width, std::min( offScreenSize.height, controlSize.height ) );
mScrollDeltaIndex = mScrollingTextActor.RegisterProperty( "uDelta", 0.0f );
#define __DALI_TOOLKIT_TEXT_SCROLLER_H__
/*
- * Copyright (c) 2016 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.
#include <dali/public-api/actors/camera-actor.h>
#include <dali/public-api/animation/animation.h>
#include <dali/public-api/render-tasks/render-task.h>
-#include <dali-toolkit/devel-api/controls/text-controls/text-label-devel.h>
// INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/controls/text-controls/text-label-devel.h>
#include <dali-toolkit/internal/text/text-definitions.h>
+#include <dali-toolkit/internal/text/layouts/layout-alignment.h>
namespace Dali
{
* @param[in] alignmentOffset alignment of source text
*
*/
- void SetParameters( Actor sourceActor, const Size& controlSize, const Size& offScreenSize, CharacterDirection direction, float alignmentOffset );
+ void SetParameters( Actor sourceActor, const Size& controlSize, const Size& offScreenSize, CharacterDirection direction, float alignmentOffset, Layout::HorizontalAlignment horizontalAlignment );
/**
* @brief Set the gap distance to elapse before the text wraps around
void SetStopMode( DevelTextLabel::AutoScrollStopMode::Type stopMode );
/**
+ * @brief Stop the auto scrolling.
+ */
+ void StopScrolling();
+
+ /**
* @brief Get the mode of scrolling stop
* @return stopMode type when text scrolling is stoped.
*/
else if( mImageUrl.IsValid() && mImageUrl.GetLocation() == VisualUrl::LOCAL )
{
ImageDimensions dimensions = Dali::GetClosestImageSize( mImageUrl.GetUrl() );
- naturalSize.x = dimensions.GetWidth();
- naturalSize.y = dimensions.GetHeight();
+
+ if( dimensions != ImageDimensions( 0, 0 ) )
+ {
+ naturalSize.x = dimensions.GetWidth();
+ naturalSize.y = dimensions.GetHeight();
+ }
+ else
+ {
+ Image brokenImage = VisualFactoryCache::GetBrokenVisualImage();
+
+ naturalSize.x = brokenImage.GetWidth();
+ naturalSize.y = brokenImage.GetWidth();
+ }
return;
}
else
{
Image brokenImage = VisualFactoryCache::GetBrokenVisualImage();
+
+ textureSet = TextureSet::New();
+ mImpl->mRenderer.SetTextures( textureSet );
+
ApplyImageToSampler( brokenImage );
}
// Image loaded and ready to display
#include <dali/public-api/animation/constraint.h>
#include <dali/public-api/object/type-registry-helper.h>
#include <dali/public-api/size-negotiation/relayout-container.h>
-#include <dali/devel-api/object/handle-devel.h>
#include <dali/devel-api/scripting/scripting.h>
#include <dali/integration-api/debug.h>
DALI_ENUM_TO_STRING_WITH_SCOPE( ClippingMode, CLIP_CHILDREN )
DALI_ENUM_TO_STRING_TABLE_END( CLIPPING_MODE )
-/**
- * Finds visual in given array, returning true if found along with the iterator for that visual as a out parameter
- */
-bool FindVisual( Property::Index targetIndex, RegisteredVisualContainer& visuals, RegisteredVisualContainer::Iterator& iter )
-{
- for ( iter = visuals.Begin(); iter != visuals.End(); iter++ )
- {
- if ( (*iter)->index == targetIndex )
- {
- return true;
- }
- }
- return false;
-}
-
-Toolkit::Visual::Base GetVisualByName(
- RegisteredVisualContainer& visuals,
- const std::string& visualName )
-{
- Toolkit::Visual::Base visualHandle;
-
- RegisteredVisualContainer::Iterator iter;
- for ( iter = visuals.Begin(); iter != visuals.End(); iter++ )
- {
- Toolkit::Visual::Base visual = (*iter)->visual;
- if( visual && visual.GetName() == visualName )
- {
- visualHandle = visual;
- break;
- }
- }
- return visualHandle;
-}
-
} // unnamed namespace
Toolkit::Visual::Base visual = Toolkit::VisualFactory::Get().CreateVisual( map );
if( visual )
{
- RegisterVisual( Toolkit::Control::Property::BACKGROUND, visual );
+ mImpl->RegisterVisual( Toolkit::Control::Property::BACKGROUND, visual );
visual.SetDepthIndex( DepthIndex::BACKGROUND );
// Trigger a size negotiation request that may be needed by the new visual to relayout its contents.
Toolkit::Visual::Base visual = Toolkit::VisualFactory::Get().CreateVisual( image );
if( visual )
{
- RegisterVisual( Toolkit::Control::Property::BACKGROUND, visual );
+ mImpl->RegisterVisual( Toolkit::Control::Property::BACKGROUND, visual );
visual.SetDepthIndex( DepthIndex::BACKGROUND );
}
}
void Control::ClearBackground()
{
- UnregisterVisual( Toolkit::Control::Property::BACKGROUND );
+ mImpl->UnregisterVisual( Toolkit::Control::Property::BACKGROUND );
mImpl->mBackgroundColor = Color::TRANSPARENT;
// Trigger a size negotiation request that may be needed when unregistering a visual.
OnKeyboardEnter();
}
-void Control::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual )
-{
- RegisterVisual( index, visual, true );
-}
-
-void Control::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, bool enabled )
-{
- bool visualReplaced ( false );
- Actor self = Self();
-
- if( !mImpl->mVisuals.Empty() )
- {
- RegisteredVisualContainer::Iterator iter;
- // Check if visual (index) is already registered. Replace if so.
- if ( FindVisual( index, mImpl->mVisuals, iter ) )
- {
- if( (*iter)->visual && self.OnStage() )
- {
- Toolkit::GetImplementation((*iter)->visual).SetOffStage( self );
- }
-
- mImpl->StopObservingVisual( (*iter)->visual );
- mImpl->StartObservingVisual( visual );
-
- (*iter)->visual = visual;
- visualReplaced = true;
- }
- }
-
- // If not set, set the name of the visual to the same name as the control's property.
- // ( If the control has been type registered )
- if( visual.GetName().empty() )
- {
- // Check if the control has been type registered:
- TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(*this) );
- if( typeInfo )
- {
- // Check if the property index has been registered:
- Property::IndexContainer indices;
- typeInfo.GetPropertyIndices( indices );
- Property::IndexContainer::Iterator iter = std::find( indices.Begin(), indices.End(), index );
- if( iter != indices.End() )
- {
- // If it has, then get it's name and use that for the visual
- std::string visualName = typeInfo.GetPropertyName( index );
- visual.SetName( visualName );
- }
- }
- }
-
- if( !visualReplaced ) // New registration entry
- {
- mImpl->mVisuals.PushBack( new RegisteredVisual( index, visual, enabled ) );
-
- // monitor when the visuals resources are ready
- mImpl->StartObservingVisual( visual );
-
- }
-
- if( visual && self.OnStage() && enabled )
- {
- Toolkit::GetImplementation(visual).SetOnStage( self );
- }
-
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::RegisterVisual() Registered %s(%d), enabled:%s\n", visual.GetName().c_str(), index, enabled?"T":"F" );
-}
-
-void Control::UnregisterVisual( Property::Index index )
-{
- RegisteredVisualContainer::Iterator iter;
- if ( FindVisual( index, mImpl->mVisuals, iter ) )
- {
- // stop observing visual
- mImpl->StopObservingVisual( (*iter)->visual );
-
- Actor self( Self() );
- Toolkit::GetImplementation((*iter)->visual).SetOffStage( self );
- (*iter)->visual.Reset();
- mImpl->mVisuals.Erase( iter );
- }
-}
-
-Toolkit::Visual::Base Control::GetVisual( Property::Index index ) const
-{
- RegisteredVisualContainer::Iterator iter;
- if ( FindVisual( index, mImpl->mVisuals, iter ) )
- {
- return (*iter)->visual;
- }
-
- return Toolkit::Visual::Base();
-}
-
-void Control::EnableVisual( Property::Index index, bool enable )
-{
- RegisteredVisualContainer::Iterator iter;
- if ( FindVisual( index, mImpl->mVisuals, iter ) )
- {
- if ( (*iter)->enabled == enable )
- {
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::EnableVisual Visual %s(%d) already %s\n", (*iter)->visual.GetName().c_str(), index, enable?"enabled":"disabled");
- return;
- }
-
- (*iter)->enabled = enable;
- Actor parentActor = Self();
- if ( Self().OnStage() ) // If control not on Stage then Visual will be added when StageConnection is called.
- {
- if ( enable )
- {
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::EnableVisual Setting %s(%d) on stage \n", (*iter)->visual.GetName().c_str(), index );
- Toolkit::GetImplementation((*iter)->visual).SetOnStage( parentActor );
- }
- else
- {
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::EnableVisual Setting %s(%d) off stage \n", (*iter)->visual.GetName().c_str(), index );
- Toolkit::GetImplementation((*iter)->visual).SetOffStage( parentActor ); // No need to call if control not staged.
- }
- }
- }
-}
-
-bool Control::IsVisualEnabled( Property::Index index ) const
-{
- RegisteredVisualContainer::Iterator iter;
- if ( FindVisual( index, mImpl->mVisuals, iter ) )
- {
- return (*iter)->enabled;
- }
- return false;
-}
-
-Dali::Animation Control::CreateTransition( const Toolkit::TransitionData& handle )
-{
- Dali::Animation transition;
- const Internal::TransitionData& transitionData = Toolkit::GetImplementation( handle );
-
- if( transitionData.Count() > 0 )
- {
- // Setup a Transition from TransitionData.
- TransitionData::Iterator end = transitionData.End();
- for( TransitionData::Iterator iter = transitionData.Begin() ;
- iter != end; ++iter )
- {
- TransitionData::Animator* animator = (*iter);
-
- Toolkit::Visual::Base visual = GetVisualByName( mImpl->mVisuals, animator->objectName );
-
- if( visual )
- {
- Internal::Visual::Base& visualImpl = Toolkit::GetImplementation( visual );
- visualImpl.AnimateProperty( transition, *animator );
- }
- else
- {
- // Otherwise, try any actor children of control (Including the control)
- Actor child = Self().FindChildByName( animator->objectName );
- if( child )
- {
- Property::Index propertyIndex = DevelHandle::GetPropertyIndex( child, animator->propertyKey );
- if( propertyIndex != Property::INVALID_INDEX )
- {
- if( animator->animate == false )
- {
- if( animator->targetValue.GetType() != Property::NONE )
- {
- child.SetProperty( propertyIndex, animator->targetValue );
- }
- }
- else // animate the property
- {
- if( animator->initialValue.GetType() != Property::NONE )
- {
- child.SetProperty( propertyIndex, animator->initialValue );
- }
-
- if( ! transition )
- {
- transition = Dali::Animation::New( 0.1f );
- }
-
- transition.AnimateTo( Property( child, propertyIndex ),
- animator->targetValue,
- animator->alphaFunction,
- TimePeriod( animator->timePeriodDelay,
- animator->timePeriodDuration ) );
- }
- }
- }
- }
- }
- }
-
- return transition;
-}
-
bool Control::OnAccessibilityActivated()
{
return false; // Accessibility activation is not handled by default
void Control::OnSizeSet(const Vector3& targetSize)
{
- Toolkit::Visual::Base visual = GetVisual( Toolkit::Control::Property::BACKGROUND );
+ Toolkit::Visual::Base visual = mImpl->GetVisual( Toolkit::Control::Property::BACKGROUND );
if( visual )
{
Vector2 size( targetSize );
container.Add( Self().GetChildAt( i ), size );
}
- Toolkit::Visual::Base visual = GetVisual( Toolkit::Control::Property::BACKGROUND );
+ 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
Vector3 Control::GetNaturalSize()
{
- Toolkit::Visual::Base visual = GetVisual( Toolkit::Control::Property::BACKGROUND );
+ Toolkit::Visual::Base visual = mImpl->GetVisual( Toolkit::Control::Property::BACKGROUND );
if( visual )
{
Vector2 naturalSize;
*/
class StyleManager;
-class TransitionData;
-
-namespace Visual
-{
-class Base;
-}
namespace Internal
{
protected: // For derived classes to call
/**
- * @brief Register a visual by Property Index, linking an Actor to visual when required.
- * In the case of the visual being an actor or control deeming visual not required then visual should be an empty handle.
- * No parenting is done during registration, this should be done by derived class.
- *
- * @SINCE_1_2.0
- *
- * @param[in] index The Property index of the visual, used to reference visual
- * @param[in] visual The visual to register
- * @note Derived class should not call visual.SetOnStage(actor). It is the responsibility of the base class to connect/disconnect registered visual to stage.
- * Use below API with enabled set to false if derived class wishes to control when visual is staged.
- */
- void RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual );
-
- /**
- * @brief Register a visual by Property Index, linking an Actor to visual when required.
- * In the case of the visual being an actor or control deeming visual not required then visual should be an empty handle.
- * If enabled is false then the visual is not set on stage until enabled by the derived class.
- * @see EnableVisual
- *
- * @SINCE_1_2.11
- *
- * @param[in] index The Property index of the visual, used to reference visual
- * @param[in] visual The visual to register
- * @param[in] enabled false if derived class wants to control when visual is set on stage.
- *
- */
- void RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, bool enabled );
-
- /**
- * @brief Erase the entry matching the given index from the list of registered visuals
- * @param[in] index The Property index of the visual, used to reference visual
- *
- * @SINCE_1_2.0
- */
- void UnregisterVisual( Property::Index index );
-
- /**
- * @brief Retrieve the visual associated with the given property index.
- *
- * @SINCE_1_2.2
- *
- * @param[in] index The Property index of the visual.
- * @return The registered visual if exist, otherwise empty handle.
- * @note For managing object life-cycle, do not store the returned visual as a member which increments its reference count.
- */
- Toolkit::Visual::Base GetVisual( Property::Index index ) const;
-
- /**
- * @brief Sets the given visual to be displayed or not when parent staged.
- *
- * @SINCE_1_2.11
- *
- * @param[in] index The Property index of the visual
- * @param[in] enable flag to set enabled or disabled.
- */
- void EnableVisual( Property::Index index, bool enable );
-
- /**
- * @brief Queries if the given visual is to be displayed when parent staged.
- *
- * @SINCE_1_2.11
- *
- * @param[in] index The Property index of the visual
- * @return bool whether visual is enabled or not
- */
- bool IsVisualEnabled( Property::Index index ) const;
-
- /**
- * @brief Create a transition effect on the control.
- *
- * Only generates an animation if the properties described in the transition
- * data are staged (e.g. the visual is Enabled and the control is on stage).
- * Otherwise the target values are stored, and will get set onto the properties
- * when the visual is next staged.
- *
- * @SINCE_1_2.12
- *
- * @param[in] transitionData The transition data describing the effect to create
- * @return A handle to an animation defined with the given effect, or an empty
- * handle if no properties match.
- */
- Dali::Animation CreateTransition( const Toolkit::TransitionData& transitionData );
-
- /**
* @brief Emits KeyInputFocusGained signal if true else emits KeyInputFocusLost signal.
*
* Should be called last by the control after it acts on the Input Focus change.
const unsigned int TOOLKIT_MAJOR_VERSION = 1;
const unsigned int TOOLKIT_MINOR_VERSION = 2;
-const unsigned int TOOLKIT_MICRO_VERSION = 41;
+const unsigned int TOOLKIT_MICRO_VERSION = 42;
const char * const TOOLKIT_BUILD_DATE = __DATE__ " " __TIME__;
#ifdef DEBUG_ENABLED
Name: dali-toolkit
Summary: The OpenGLES Canvas Core Library Toolkit
-Version: 1.2.41
+Version: 1.2.42
Release: 1
Group: System/Libraries
License: Apache-2.0 and BSD-3-Clause and MIT
mkdir -p %{buildroot}%{dali_toolkit_style_files}/1920x1080
cp -r dali-toolkit/styles/1920x1080/* %{buildroot}%{dali_toolkit_style_files}/1920x1080
+# Copy default feedback theme
+cp dali-toolkit/styles/default-feedback-theme.json %{buildroot}%{dali_toolkit_style_files}
+
##############################
# Post Install
##############################
%{dali_toolkit_image_files}/*
%{dali_toolkit_sound_files}/*
%{dali_toolkit_style_files}/480x800/*
+%{dali_toolkit_style_files}/default-feedback-theme.json
%{_datadir}/locale/*/LC_MESSAGES/*
%files resources_720x1280
%{dali_toolkit_image_files}/*
%{dali_toolkit_sound_files}/*
%{dali_toolkit_style_files}/720x1280/*
+%{dali_toolkit_style_files}/default-feedback-theme.json
%{_datadir}/locale/*/LC_MESSAGES/*
%files resources_1920x1080
%{dali_toolkit_image_files}/*
%{dali_toolkit_sound_files}/*
%{dali_toolkit_style_files}/1920x1080/*
+%{dali_toolkit_style_files}/default-feedback-theme.json
%{_datadir}/locale/*/LC_MESSAGES/*
/*
- * Copyright (c) 2015 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.
void GarbageCollector::Register( BaseWrappedObject* object )
{
- mObjectMap.insert( object );
+ mObjectMap.PushBack( object );
};
void GarbageCollector::UnRegister( BaseWrappedObject* object )
{
- mObjectMap.erase( object );
+ for( ObjectMap::Iterator iter = mObjectMap.Begin(); iter != mObjectMap.End(); ++iter )
+ {
+ if( *iter == object )
+ {
+ mObjectMap.Erase( iter );
+ return;
+ }
+ }
}
void GarbageCollector::GarbageCollect()
{
- for( ObjectMap::iterator iter = mObjectMap.begin(); iter != mObjectMap.end(); )
+ for( ObjectMap::Iterator iter = mObjectMap.Begin(); iter != mObjectMap.End(); ++iter )
{
BaseWrappedObject* object = *iter;
- iter++; // iterator will be invalidated if we delete the object first.
delete object; // object will call GarbageCollector.UnRegister
}
-
+ mObjectMap.Clear();
}
} // V8Plugin
#define __DALI_V8PLUGIN_GARBAGE_COLLECTOR_H__
/*
- * Copyright (c) 2015 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.
*
*/
+// EXTERNAL INCLUDES
+#include <dali/public-api/common/dali-vector.h>
// INTERNAL INCLUDES
#include <interfaces/garbage-collector-interface.h>
-#include <dali/devel-api/common/set-wrapper.h>
-
namespace Dali
{
*/
virtual void GarbageCollect();
-
private:
/**
* Map between dali wrapped object (void *)
*/
- typedef std::set< BaseWrappedObject* > ObjectMap;
+ typedef Dali::Vector< BaseWrappedObject* > ObjectMap;
ObjectMap mObjectMap; ///< lookup
};