From: David Steele Date: Fri, 26 May 2017 17:30:30 +0000 (+0000) Subject: Merge "Removal of unnecessary set and map wrappers" into devel/master X-Git-Tag: dali_1.2.42~7 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=c207c7aae76e4a6111656669fbed81052513b460;hp=a7c41c76922b4da643a6a9651e5808f16fc41fac Merge "Removal of unnecessary set and map wrappers" into devel/master --- diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.cpp index 8f70228..0d54096 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.cpp @@ -21,6 +21,7 @@ #include #include #include +#include namespace Dali { @@ -105,7 +106,7 @@ DummyControlImpl::~DummyControlImpl() 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() ) @@ -116,7 +117,7 @@ void DummyControlImpl::RegisterVisual( Property::Index index, Toolkit::Visual::B 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() ) @@ -127,7 +128,7 @@ void DummyControlImpl::RegisterVisual( Property::Index index, Toolkit::Visual::B 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() ) @@ -138,22 +139,22 @@ void DummyControlImpl::UnregisterVisual( Property::Index index ) 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 ) diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.h index d4b8b18..7b43bd0 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.h @@ -2,7 +2,7 @@ #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. @@ -28,6 +28,12 @@ namespace Toolkit { class DummyControlImpl; +class TransitionData; + +namespace Visual +{ +class Base; +} /** * Control does not have a New method so use this dummy class for the handle. diff --git a/dali-toolkit/devel-api/controls/control-devel.cpp b/dali-toolkit/devel-api/controls/control-devel.cpp index 648602f..77b2368 100644 --- a/dali-toolkit/devel-api/controls/control-devel.cpp +++ b/dali-toolkit/devel-api/controls/control-devel.cpp @@ -18,9 +18,13 @@ // CLASS HEADER #include "control-devel.h" +// EXTERNAL INCLUDES +#include + // INTERNAL INCLUDES #include #include +#include namespace Dali { @@ -33,7 +37,6 @@ namespace DevelControl ResourceReadySignalType& ResourceReadySignal( Control& control ) { - Internal::Control& internalControl = Toolkit::Internal::GetImplementation(control); Internal::Control::Impl& controlImpl = Internal::Control::Impl::Get( internalControl ); @@ -48,6 +51,48 @@ bool IsResourceReady( const Control& control ) 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 diff --git a/dali-toolkit/devel-api/controls/control-devel.h b/dali-toolkit/devel-api/controls/control-devel.h index 63f5cf9..7795df1 100644 --- a/dali-toolkit/devel-api/controls/control-devel.h +++ b/dali-toolkit/devel-api/controls/control-devel.h @@ -2,7 +2,7 @@ #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. @@ -27,6 +27,13 @@ namespace Dali namespace Toolkit { +class TransitionData; + +namespace Visual +{ +class Base; +} + namespace DevelControl { @@ -121,7 +128,7 @@ typedef Signal ResourceReadySignalType; * 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. @@ -129,7 +136,86 @@ ResourceReadySignalType& ResourceReadySignal( Control& control ); * @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 diff --git a/dali-toolkit/devel-api/controls/control-wrapper-impl.cpp b/dali-toolkit/devel-api/controls/control-wrapper-impl.cpp index d3fcc56..fbbfa2e 100755 --- a/dali-toolkit/devel-api/controls/control-wrapper-impl.cpp +++ b/dali-toolkit/devel-api/controls/control-wrapper-impl.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -26,6 +26,7 @@ // INTERNAL INCLUDES #include +#include #include #include #include @@ -121,37 +122,37 @@ bool ControlWrapper::RelayoutDependentOnChildrenBase( Dimension::Type dimension 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() diff --git a/dali-toolkit/devel-api/controls/control-wrapper-impl.h b/dali-toolkit/devel-api/controls/control-wrapper-impl.h index 33905a5..85bc26c 100755 --- a/dali-toolkit/devel-api/controls/control-wrapper-impl.h +++ b/dali-toolkit/devel-api/controls/control-wrapper-impl.h @@ -2,7 +2,7 @@ #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. @@ -28,6 +28,13 @@ namespace Dali namespace Toolkit { +class TransitionData; + +namespace Visual +{ +class Base; +} + namespace Internal { @@ -104,37 +111,37 @@ public: // From CustomActorImpl 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 ); diff --git a/dali-toolkit/internal/controls/buttons/button-impl.cpp b/dali-toolkit/internal/controls/buttons/button-impl.cpp index d580457..b52e46c 100644 --- a/dali-toolkit/internal/controls/buttons/button-impl.cpp +++ b/dali-toolkit/internal/controls/buttons/button-impl.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -385,7 +386,7 @@ void Button::MergeWithExistingLabelProperties( const Property::Map& inMap, Prope * 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"); @@ -451,13 +452,13 @@ void Button::CreateVisualsForComponent( Property::Index index, const Property::V 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 ); @@ -467,7 +468,7 @@ bool Button::GetPropertyMapForVisual( Property::Index visualIndex, Property::Map { 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 ); @@ -787,7 +788,7 @@ Vector3 Button::GetNaturalSize() 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 ) { @@ -802,7 +803,7 @@ Vector3 Button::GetNaturalSize() { 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 ) { @@ -830,7 +831,7 @@ Vector3 Button::GetNaturalSize() // 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 ) { @@ -883,9 +884,9 @@ void Button::OnRelayout( const Vector2& size, RelayoutContainer& container ) { 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; @@ -1006,7 +1007,7 @@ void Button::OnRelayout( const Vector2& size, RelayoutContainer& container ) 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 ) { @@ -1101,7 +1102,7 @@ void Button::SelectRequiredVisual( Property::Index visualIndex ) { 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 ) @@ -1109,11 +1110,11 @@ 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 ); } } @@ -1511,7 +1512,7 @@ void Button::SetBackgroundImage( const std::string& filename ) } else { - UnregisterVisual( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL ); + DevelControl::UnregisterVisual( *this, Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL ); } } @@ -1528,7 +1529,7 @@ void Button::SetSelectedBackgroundImage( const std::string& filename ) } else { - UnregisterVisual( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL ); + DevelControl::UnregisterVisual( *this, Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL ); } } @@ -1559,7 +1560,7 @@ void Button::SetDisabledSelectedImage( const std::string& filename ) // 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 ) diff --git a/dali-toolkit/internal/controls/buttons/toggle-button-impl.cpp b/dali-toolkit/internal/controls/buttons/toggle-button-impl.cpp index 0e2b58c..36366cb 100755 --- a/dali-toolkit/internal/controls/buttons/toggle-button-impl.cpp +++ b/dali-toolkit/internal/controls/buttons/toggle-button-impl.cpp @@ -29,6 +29,7 @@ // INTERNAL INCLUDES #include #include +#include #include #include #include @@ -304,13 +305,13 @@ const std::vector& ToggleButton::GetToggleTooltips() const 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; diff --git a/dali-toolkit/internal/controls/control/control-data-impl.cpp b/dali-toolkit/internal/controls/control/control-data-impl.cpp index 38c9a57..f20e489 100644 --- a/dali-toolkit/internal/controls/control/control-data-impl.cpp +++ b/dali-toolkit/internal/controls/control/control-data-impl.cpp @@ -21,6 +21,7 @@ // EXTERNAL INCLUDES #include #include +#include #include #include #include @@ -93,6 +94,21 @@ Toolkit::DevelVisual::Type GetVisualTypeFromMap( const Property::Map& map ) 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& stateVisualsToAdd, Dictionary& stateVisualsToChange, DictionaryKeys& stateVisualsToRemove) @@ -113,6 +129,25 @@ void FindChangableVisuals( Dictionary& stateVisualsToAdd, } } +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. @@ -225,8 +260,6 @@ TypeAction registerAction( typeRegistration, ACTION_ACCESSIBILITY_ACTIVATED, &Do DALI_TYPE_REGISTRATION_END() - - } // unnamed namespace @@ -285,28 +318,6 @@ const Control::Impl& Control::Impl::Get( const Internal::Control& internalContro 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) { @@ -369,6 +380,139 @@ bool Control::Impl::IsResourceReady() const } 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 ); @@ -385,14 +529,70 @@ void Control::Impl::StartObservingVisual( Toolkit::Visual::Base& 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 ) ); @@ -537,7 +737,7 @@ void Control::Impl::SetProperty( BaseObject* object, Property::Index index, cons 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 ); } } @@ -566,12 +766,6 @@ void Control::Impl::SetProperty( BaseObject* object, Property::Index index, cons } } -/** - * 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; @@ -637,7 +831,7 @@ Property::Value Control::Impl::GetProperty( BaseObject* object, Property::Index { 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 ); @@ -655,7 +849,7 @@ Property::Value Control::Impl::GetProperty( BaseObject* object, Property::Index 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 ); @@ -725,12 +919,6 @@ void Control::Impl::RemoveVisuals( RegisteredVisualContainer& visuals, Dictionar } } - -/** - * 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& stateVisualsToChange, Dictionary& instancedProperties ) { diff --git a/dali-toolkit/internal/controls/control/control-data-impl.h b/dali-toolkit/internal/controls/control/control-data-impl.h index 4adfe65..2ee216f 100644 --- a/dali-toolkit/internal/controls/control/control-data-impl.h +++ b/dali-toolkit/internal/controls/control/control-data-impl.h @@ -2,7 +2,7 @@ #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. @@ -60,56 +60,193 @@ typedef Dali::OwnerContainer< RegisteredVisual* > RegisteredVisualContainer; /** - * 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& 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& 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& stateVisualsToChange, Dictionary& 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; @@ -121,7 +258,6 @@ public: 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 @@ -158,7 +294,6 @@ public: static const PropertyRegistration PROPERTY_10; static const PropertyRegistration PROPERTY_11; static const PropertyRegistration PROPERTY_12; - }; diff --git a/dali-toolkit/internal/controls/effects-view/effects-view-impl.cpp b/dali-toolkit/internal/controls/effects-view/effects-view-impl.cpp index 08cfc16..db76861 100644 --- a/dali-toolkit/internal/controls/effects-view/effects-view-impl.cpp +++ b/dali-toolkit/internal/controls/effects-view/effects-view-impl.cpp @@ -33,6 +33,7 @@ // INTERNAL INCLUDES #include #include +#include #include #include #include @@ -193,7 +194,7 @@ void EffectsView::SetType( Toolkit::EffectsView::EffectType type ) 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; @@ -427,7 +428,7 @@ void EffectsView::AllocateResources() 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 ); diff --git a/dali-toolkit/internal/controls/image-view/image-view-impl.cpp b/dali-toolkit/internal/controls/image-view/image-view-impl.cpp index 80f1ee4..65e043e 100644 --- a/dali-toolkit/internal/controls/image-view/image-view-impl.cpp +++ b/dali-toolkit/internal/controls/image-view/image-view-impl.cpp @@ -1,4 +1,19 @@ -// 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" @@ -11,6 +26,7 @@ // INTERNAL INCLUDES #include +#include #include #include #include @@ -79,7 +95,7 @@ void ImageView::SetImage( Image image ) mPropertyMap.Clear(); mVisual = Toolkit::VisualFactory::Get().CreateVisual( image ); - RegisterVisual( Toolkit::ImageView::Property::IMAGE, mVisual ); + DevelControl::RegisterVisual( *this, Toolkit::ImageView::Property::IMAGE, mVisual ); RelayoutRequest(); } @@ -92,7 +108,7 @@ void ImageView::SetImage( const Property::Map& map ) mImage.Reset(); mVisual = Toolkit::VisualFactory::Get().CreateVisual( mPropertyMap ); - RegisterVisual( Toolkit::ImageView::Property::IMAGE, mVisual ); + DevelControl::RegisterVisual( *this, Toolkit::ImageView::Property::IMAGE, mVisual ); RelayoutRequest(); } @@ -105,7 +121,7 @@ void ImageView::SetImage( const std::string& url, ImageDimensions size ) mPropertyMap.Clear(); mVisual = Toolkit::VisualFactory::Get().CreateVisual( url, size ); - RegisterVisual( Toolkit::ImageView::Property::IMAGE, mVisual ); + DevelControl::RegisterVisual( *this, Toolkit::ImageView::Property::IMAGE, mVisual ); RelayoutRequest(); } diff --git a/dali-toolkit/internal/controls/progress-bar/progress-bar-impl.cpp b/dali-toolkit/internal/controls/progress-bar/progress-bar-impl.cpp index cddfa35..24b1aa4 100755 --- a/dali-toolkit/internal/controls/progress-bar/progress-bar-impl.cpp +++ b/dali-toolkit/internal/controls/progress-bar/progress-bar-impl.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -131,11 +132,11 @@ void ProgressBar::OnRelayout( const Vector2& size, RelayoutContainer& container 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 ) { @@ -197,8 +198,8 @@ void ProgressBar::OnRelayout( const Vector2& size, RelayoutContainer& container 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; @@ -275,7 +276,7 @@ float ProgressBar::GetSecondaryProgressValue() const 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 ) { @@ -316,7 +317,7 @@ void ProgressBar::PlayIndeterminateVisualTransition() mIndeterminateVisualAni.Clear(); } - mIndeterminateVisualAni = CreateTransition( mIndeterminateVisualTransition ); + mIndeterminateVisualAni = DevelControl::CreateTransition( *this, mIndeterminateVisualTransition ); if( mIndeterminate && mIndeterminateVisualAni ) { @@ -377,23 +378,23 @@ void ProgressBar::CreateVisualsForComponent( Property::Index index, const Proper 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 ) { @@ -468,7 +469,7 @@ void ProgressBar::SetProperty( BaseObject* object, Property::Index propertyIndex { // 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 ) { diff --git a/dali-toolkit/internal/controls/super-blur-view/super-blur-view-impl.cpp b/dali-toolkit/internal/controls/super-blur-view/super-blur-view-impl.cpp index a93257d..581b87e 100644 --- a/dali-toolkit/internal/controls/super-blur-view/super-blur-view-impl.cpp +++ b/dali-toolkit/internal/controls/super-blur-view/super-blur-view-impl.cpp @@ -30,6 +30,7 @@ #include // INTERNAL_INCLUDES +#include #include #include @@ -173,7 +174,7 @@ void SuperBlurView::SetImage(Image inputImage) 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. @@ -282,7 +283,7 @@ void SuperBlurView::OnSizeSet( const Vector3& targetSize ) 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] ); } diff --git a/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp index babd0eb..597fee1 100644 --- a/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -352,7 +353,7 @@ Property::Value TextSelectionPopup::GetProperty( BaseObject* object, Property::I 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 ); @@ -841,7 +842,7 @@ std::string TextSelectionPopup::GetPressedImage() const 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() ) { @@ -849,7 +850,7 @@ void TextSelectionPopup::CreateBackgroundBorder( Property::Map& propertyMap ) if( visual ) { - RegisterVisual( Toolkit::TextSelectionPopup::Property::BACKGROUND_BORDER, visual ); + DevelControl::RegisterVisual( *this, Toolkit::TextSelectionPopup::Property::BACKGROUND_BORDER, visual ); visual.SetDepthIndex( DepthIndex::CONTENT ); } } diff --git a/dali-toolkit/public-api/controls/control-impl.cpp b/dali-toolkit/public-api/controls/control-impl.cpp index 525a02e..a41a6f3 100644 --- a/dali-toolkit/public-api/controls/control-impl.cpp +++ b/dali-toolkit/public-api/controls/control-impl.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include #include @@ -66,40 +65,6 @@ DALI_ENUM_TO_STRING_WITH_SCOPE( ClippingMode, DISABLED ) 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 @@ -159,7 +124,7 @@ void Control::SetBackground( const Property::Map& map ) 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. @@ -172,14 +137,14 @@ void Control::SetBackgroundImage( Image image ) 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. @@ -329,202 +294,6 @@ void Control::KeyboardEnter() 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 @@ -808,7 +577,7 @@ void Control::OnPropertySet( Property::Index index, Property::Value propertyValu 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 ); @@ -848,7 +617,7 @@ void Control::OnRelayout( const Vector2& size, RelayoutContainer& container ) 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 @@ -861,7 +630,7 @@ void Control::OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dime 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; diff --git a/dali-toolkit/public-api/controls/control-impl.h b/dali-toolkit/public-api/controls/control-impl.h index 7b81c67..9a1e560 100644 --- a/dali-toolkit/public-api/controls/control-impl.h +++ b/dali-toolkit/public-api/controls/control-impl.h @@ -41,12 +41,6 @@ namespace Toolkit */ class StyleManager; -class TransitionData; - -namespace Visual -{ -class Base; -} namespace Internal { @@ -301,90 +295,6 @@ public: 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. diff --git a/dali-toolkit/public-api/dali-toolkit-version.cpp b/dali-toolkit/public-api/dali-toolkit-version.cpp index cd5325d..c4d336c 100644 --- a/dali-toolkit/public-api/dali-toolkit-version.cpp +++ b/dali-toolkit/public-api/dali-toolkit-version.cpp @@ -31,7 +31,7 @@ namespace Toolkit const unsigned int TOOLKIT_MAJOR_VERSION = 1; const unsigned int TOOLKIT_MINOR_VERSION = 2; -const unsigned int TOOLKIT_MICRO_VERSION = 40; +const unsigned int TOOLKIT_MICRO_VERSION = 41; const char * const TOOLKIT_BUILD_DATE = __DATE__ " " __TIME__; #ifdef DEBUG_ENABLED diff --git a/packaging/dali-toolkit.spec b/packaging/dali-toolkit.spec index f9f3ac9..39f269b 100644 --- a/packaging/dali-toolkit.spec +++ b/packaging/dali-toolkit.spec @@ -1,6 +1,6 @@ Name: dali-toolkit Summary: The OpenGLES Canvas Core Library Toolkit -Version: 1.2.40 +Version: 1.2.41 Release: 1 Group: System/Libraries License: Apache-2.0 and BSD-3-Clause and MIT