projects
/
platform
/
core
/
uifw
/
dali-toolkit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge "Control to call Init derived classes before applying style" into devel/master
[platform/core/uifw/dali-toolkit.git]
/
dali-toolkit
/
public-api
/
controls
/
control-impl.cpp
diff --git
a/dali-toolkit/public-api/controls/control-impl.cpp
b/dali-toolkit/public-api/controls/control-impl.cpp
index
7393a3a
..
0d7a2f0
100644
(file)
--- a/
dali-toolkit/public-api/controls/control-impl.cpp
+++ b/
dali-toolkit/public-api/controls/control-impl.cpp
@@
-34,7
+34,7
@@
#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/
public
-api/focus-manager/keyinput-focus-manager.h>
+#include <dali-toolkit/
devel
-api/focus-manager/keyinput-focus-manager.h>
#include <dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h>
#include <dali-toolkit/public-api/controls/control.h>
#include <dali-toolkit/devel-api/styling/style-manager.h>
#include <dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h>
#include <dali-toolkit/public-api/controls/control.h>
#include <dali-toolkit/devel-api/styling/style-manager.h>
@@
-49,8
+49,6
@@
namespace Toolkit
namespace
{
namespace
{
-const float BACKGROUND_ACTOR_Z_POSITION( -0.1f );
-
/**
* Creates control through type registry
*/
/**
* Creates control through type registry
*/
@@
-67,7
+65,7
@@
BaseHandle Create()
* @return true if action has been accepted by this control
*/
const char* ACTION_CONTROL_ACTIVATED = "control-activated";
* @return true if action has been accepted by this control
*/
const char* ACTION_CONTROL_ACTIVATED = "control-activated";
-static bool DoAction( BaseObject* object, const std::string& actionName, const Property
ValueContainer
& attributes )
+static bool DoAction( BaseObject* object, const std::string& actionName, const Property
::Map
& attributes )
{
bool ret = false;
{
bool ret = false;
@@
-224,7
+222,6
@@
void SetupBackgroundActor( Actor actor, const Vector4& color )
actor.SetColor( color );
actor.SetPositionInheritanceMode( USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
actor.SetColor( color );
actor.SetPositionInheritanceMode( USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
- actor.SetZ( BACKGROUND_ACTOR_Z_POSITION );
actor.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
}
actor.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
}
@@
-240,7
+237,6
@@
void SetupBackgroundActorConstrained( Actor actor, Property::Index constrainingI
actor.SetColor( color );
actor.SetPositionInheritanceMode( USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
actor.SetColor( color );
actor.SetPositionInheritanceMode( USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
- actor.SetZ( BACKGROUND_ACTOR_Z_POSITION );
Constraint constraint = Constraint::New<Vector3>( actor,
constrainingIndex,
Constraint constraint = Constraint::New<Vector3>( actor,
constrainingIndex,
@@
-271,7
+267,8
@@
public:
mLongPressGestureDetector(),
mFlags( Control::ControlBehaviour( ACTOR_BEHAVIOUR_NONE ) ),
mIsKeyboardNavigationSupported( false ),
mLongPressGestureDetector(),
mFlags( Control::ControlBehaviour( ACTOR_BEHAVIOUR_NONE ) ),
mIsKeyboardNavigationSupported( false ),
- mIsKeyboardFocusGroup( false )
+ mIsKeyboardFocusGroup( false ),
+ mAddRemoveBackgroundChild( false )
{
}
{
}
@@
-466,6
+463,7
@@
public:
ControlBehaviour mFlags :CONTROL_BEHAVIOUR_FLAG_COUNT; ///< Flags passed in from constructor.
bool mIsKeyboardNavigationSupported :1; ///< Stores whether keyboard navigation is supported by the control.
bool mIsKeyboardFocusGroup :1; ///< Stores whether the control is a focus group.
ControlBehaviour mFlags :CONTROL_BEHAVIOUR_FLAG_COUNT; ///< Flags passed in from constructor.
bool mIsKeyboardNavigationSupported :1; ///< Stores whether keyboard navigation is supported by the control.
bool mIsKeyboardFocusGroup :1; ///< Stores whether the control is a focus group.
+ bool mAddRemoveBackgroundChild:1; ///< Flag to know when we are adding or removing our own actor to avoid call to OnControlChildAdd
// Properties - these need to be members of Internal::Control::Impl as they need to function within this class.
static PropertyRegistration PROPERTY_1;
// Properties - these need to be members of Internal::Control::Impl as they need to function within this class.
static PropertyRegistration PROPERTY_1;
@@
-533,9
+531,12
@@
void Control::SetBackgroundColor( const Vector4& color )
SetupBackgroundActorConstrained( meshActor, Actor::Property::SCALE, color );
SetupBackgroundActorConstrained( meshActor, Actor::Property::SCALE, color );
- // Set the background actor before adding so that we do not inform deriving classes
background.actor = meshActor;
background.actor = meshActor;
- Self().Add( meshActor );
+ // Set the flag to avoid notifying children
+ mImpl->mAddRemoveBackgroundChild = true;
+ // use insert to guarantee its the first child (so that OVERLAY mode works)
+ Self().Insert( 0, meshActor );
+ mImpl->mAddRemoveBackgroundChild = false;
}
background.color = color;
}
background.color = color;
@@
-556,8
+557,10
@@
void Control::SetBackgroundImage( Image image )
if ( background.actor )
{
if ( background.actor )
{
- // Remove Current actor, unset AFTER removal so that we do not inform deriving classes
+ // Remove Current actor, unset AFTER removal
+ mImpl->mAddRemoveBackgroundChild = true;
Self().Remove( background.actor );
Self().Remove( background.actor );
+ mImpl->mAddRemoveBackgroundChild = false;
background.actor.Reset();
}
background.actor.Reset();
}
@@
-566,7
+569,10
@@
void Control::SetBackgroundImage( Image image )
// Set the background actor before adding so that we do not inform derived classes
background.actor = imageActor;
// Set the background actor before adding so that we do not inform derived classes
background.actor = imageActor;
- Self().Add( imageActor );
+ mImpl->mAddRemoveBackgroundChild = true;
+ // use insert to guarantee its the first child (so that OVERLAY mode works)
+ Self().Insert( 0, imageActor );
+ mImpl->mAddRemoveBackgroundChild = false;
}
void Control::ClearBackground()
}
void Control::ClearBackground()
@@
-574,7
+580,9
@@
void Control::ClearBackground()
if ( mImpl->mBackground )
{
Background& background( mImpl->GetBackground() );
if ( mImpl->mBackground )
{
Background& background( mImpl->GetBackground() );
+ mImpl->mAddRemoveBackgroundChild = true;
Self().Remove( background.actor );
Self().Remove( background.actor );
+ mImpl->mAddRemoveBackgroundChild = false;
delete mImpl->mBackground;
mImpl->mBackground = NULL;
delete mImpl->mBackground;
mImpl->mBackground = NULL;
@@
-734,7
+742,7
@@
bool Control::OnAccessibilityValueChange(bool isIncrease)
return false; // Accessibility value change action is not handled by default
}
return false; // Accessibility value change action is not handled by default
}
-Actor Control::GetNextKeyboardFocusableActor(Actor currentFocusedActor, Toolkit::Control::KeyboardFocus
Navigation
Direction direction, bool loopEnabled)
+Actor Control::GetNextKeyboardFocusableActor(Actor currentFocusedActor, Toolkit::Control::KeyboardFocus
::
Direction direction, bool loopEnabled)
{
return Actor();
}
{
return Actor();
}
@@
-789,6
+797,9
@@
Control::Control( ControlBehaviour behaviourFlags )
void Control::Initialize()
{
void Control::Initialize()
{
+ // Call deriving classes so initialised before styling is applied to them.
+ OnInitialize();
+
if( mImpl->mFlags & REQUIRES_STYLE_CHANGE_SIGNALS )
{
Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
if( mImpl->mFlags & REQUIRES_STYLE_CHANGE_SIGNALS )
{
Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
@@
-796,7
+807,7
@@
void Control::Initialize()
// Register for style changes
styleManager.StyleChangeSignal().Connect( this, &Control::OnStyleChange );
// Register for style changes
styleManager.StyleChangeSignal().Connect( this, &Control::OnStyleChange );
- //
SetThem
e
+ //
Apply the current styl
e
GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
}
GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
}
@@
-804,9
+815,6
@@
void Control::Initialize()
{
SetKeyboardNavigationSupport( true );
}
{
SetKeyboardNavigationSupport( true );
}
-
- // Calling deriving classes
- OnInitialize();
}
void Control::OnInitialize()
}
void Control::OnInitialize()
@@
-900,8
+908,8
@@
void Control::OnKeyInputFocusLost()
void Control::OnChildAdd(Actor& child)
{
void Control::OnChildAdd(Actor& child)
{
- // If this is the background actor, then we do not want to
relayout or
inform deriving classes
- if ( mImpl->m
Background && ( child == mImpl->mBackground->actor )
)
+ // If this is the background actor, then we do not want to inform deriving classes
+ if ( mImpl->m
AddRemoveBackgroundChild
)
{
return;
}
{
return;
}
@@
-912,8
+920,8
@@
void Control::OnChildAdd(Actor& child)
void Control::OnChildRemove(Actor& child)
{
void Control::OnChildRemove(Actor& child)
{
- // If this is the background actor, then we do not want to
relayout or
inform deriving classes
- if ( mImpl->m
Background && ( child == mImpl->mBackground->actor )
)
+ // If this is the background actor, then we do not want to inform deriving classes
+ if ( mImpl->m
AddRemoveBackgroundChild
)
{
return;
}
{
return;
}
@@
-947,7
+955,7
@@
bool Control::OnKeyEvent(const KeyEvent& event)
return false; // Do not consume
}
return false; // Do not consume
}
-bool Control::On
MouseWheelEvent(const Mouse
WheelEvent& event)
+bool Control::On
WheelEvent(const
WheelEvent& event)
{
return false; // Do not consume
}
{
return false; // Do not consume
}