#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.
// 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] );
}
#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 );
}
}
#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.