/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2015 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.
END_TEST;
}
-int UtcDaliAlignmentOnSizeSet(void)
+int UtcDaliAlignmentSizeSetP(void)
{
ToolkitTestApplication application;
application.Render();
application.SendNotification();
- DALI_TEST_EQUALS(size, alignment.GetImplementation().GetControlSize().GetVectorXY(), TEST_LOCATION);
+ DALI_TEST_EQUALS(size, alignment.GetTargetSize().GetVectorXY(), TEST_LOCATION);
Stage::GetCurrent().Remove(alignment);
END_TEST;
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2015 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.
float width = 640.0f;
float height = test.GetHeightForWidth( width );
- DALI_TEST_CHECK( test.GetWidthForHeight( height ) == width );
+ DALI_TEST_EQUALS( 640.0f, height, TEST_LOCATION );
+ DALI_TEST_EQUALS( 640.0f, test.GetWidthForHeight( height ), TEST_LOCATION );
test.KeyEventSignal();
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2015 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.
END_TEST;
}
-int UtcDaliControlImplSizeSet(void)
+int UtcDaliControlImplSizeSetP(void)
{
ToolkitTestApplication application;
application.Render();
application.SendNotification();
- DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, true, TEST_LOCATION ); // Called from size negotiation
+ DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, false, TEST_LOCATION ); // Size not set, no onSizeSet called
Vector2 size(100.0f, 200.0f);
- dummy.SetSize(size);
+ dummy.SetSize( size );
+
+ DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, false, TEST_LOCATION ); // Size is going to get negotiated, no onSizeSet called
- application.Render();
application.SendNotification();
application.Render();
- application.SendNotification();
- DALI_TEST_EQUALS(size, dummy.GetCurrentSize().GetVectorXY(), TEST_LOCATION);
+ DALI_TEST_EQUALS( size, dummy.GetCurrentSize().GetVectorXY(), TEST_LOCATION );
DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, true, TEST_LOCATION );
Stage::GetCurrent().Remove(dummy);
}
- // Ensure full code coverage
+ END_TEST;
+}
+
+int UtcDaliControlImplSizeSet2P(void)
+{
+ ToolkitTestApplication application;
+
{
DummyControl dummy = DummyControl::New();
Stage::GetCurrent().Add(dummy);
Vector2 size(100.0f, 200.0f);
DALI_TEST_CHECK( size != dummy.GetCurrentSize().GetVectorXY() );
- application.Render();
application.SendNotification();
+ application.Render();
dummy.SetSize(size);
- application.Render();
application.SendNotification();
application.Render();
- application.SendNotification();
DALI_TEST_EQUALS(size, dummy.GetCurrentSize().GetVectorXY(), TEST_LOCATION);
END_TEST;
}
+
int UtcDaliControlImplSizeAnimation(void)
{
ToolkitTestApplication application;
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
void PageTurnView::OnControlSizeSet( const Vector3& size )
{
- // disable the SetSize of the control from the application
- Self().SetSize( mControlSize );
}
void PageTurnView::SetSpineShadowParameter( const Vector2& spineShadowParameter )
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2015 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.
self.SetProperty(Toolkit::Scrollable::Property::CAN_SCROLL_VERTICAL, mCanScrollVertical);
self.SetProperty(Toolkit::Scrollable::Property::CAN_SCROLL_HORIZONTAL, mCanScrollHorizontal);
- Vector3 size = GetControlSize();
- UpdatePropertyDomain(size);
+ UpdatePropertyDomain();
SetInternalConstraints();
}
{
mRulerX = ruler;
- Vector3 size = GetControlSize();
- UpdatePropertyDomain(size);
+ UpdatePropertyDomain();
UpdateMainInternalConstraint();
}
{
mRulerY = ruler;
- Vector3 size = GetControlSize();
- UpdatePropertyDomain(size);
+ UpdatePropertyDomain();
UpdateMainInternalConstraint();
}
-void ScrollView::UpdatePropertyDomain(const Vector3& size)
+void ScrollView::UpdatePropertyDomain()
{
Actor self = Self();
+ Vector3 size = self.GetTargetSize();
Vector2 min = mMinScroll;
Vector2 max = mMaxScroll;
bool scrollPositionChanged = false;
void ScrollView::OnSizeAnimation(Animation& animation, const Vector3& targetSize)
{
// need to update domain properties for new size
- UpdatePropertyDomain(targetSize);
+ UpdatePropertyDomain();
}
void ScrollView::OnControlSizeSet( const Vector3& size )
mMaxOvershoot = mUserMaxOvershoot;
}
}
- UpdatePropertyDomain(size);
+ UpdatePropertyDomain();
UpdateMainInternalConstraint();
if( IsOvershootEnabled() )
{
#define __DALI_TOOLKIT_INTERNAL_SCROLL_VIEW_H__
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2015 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.
* This is called internally whenever the Scroll Rulers are
* modified. This will update the properties: 'scroll-position-min'
* and 'scroll-position-max' to reflect the changes.
- *
- * @param[in] size size of the visible scroll area (ScrollView control size)
*/
- void UpdatePropertyDomain(const Vector3& size);
+ void UpdatePropertyDomain();
/**
* Called when the gesture starts.
mHandleScrolling = type;
StartScrollTimer();
}
- else if( x > mTextControlParent.GetControlSize().width - mScrollThreshold )
+ else if( x > mTextControlParent.Self().GetTargetSize().width - mScrollThreshold )
{
mScrollDirection = SCROLL_LEFT;
mHandleScrolling = type;
namespace
{
-#if defined(DEBUG_ENABLED)
-Integration::Log::Filter* gLogFilter = Integration::Log::Filter::New(Debug::NoLogging, false, "LOG_CONTROL");
-#endif
-
-const float MAX_FLOAT_VALUE( std::numeric_limits<float>::max() );
-const Vector3 MAX_SIZE( MAX_FLOAT_VALUE, MAX_FLOAT_VALUE, MAX_FLOAT_VALUE );
const float BACKGROUND_ACTOR_Z_POSITION( -0.1f );
BaseHandle Create()
{
public:
- /**
- * Size indices for mMinMaxSize array
- */
- enum
- {
- MIN_SIZE_INDEX = 0,
- MAX_SIZE_INDEX = 1
- };
-
-public:
// Construction & Destruction
Impl(Control& controlImpl)
: mControlImpl( controlImpl ),
mPanGestureDetector(),
mTapGestureDetector(),
mLongPressGestureDetector(),
- mCurrentSize(),
- mNaturalSize(),
mFlags( Control::ControlBehaviour( ACTOR_BEHAVIOUR_NONE ) ),
mIsKeyboardNavigationSupported( false ),
mIsKeyboardFocusGroup( false ),
PanGestureDetector mPanGestureDetector;
TapGestureDetector mTapGestureDetector;
LongPressGestureDetector mLongPressGestureDetector;
- // @todo change all these to Vector2 when we have a chance to sanitize the public API as well
- Vector3 mCurrentSize; ///< Stores the current control's size, this is the negotiated size
- Vector3 mNaturalSize; ///< Stores the size set through the Actor's API. This is size the actor wants to be. Useful when reset to the initial size is needed.
ControlBehaviour mFlags :CONTROL_BEHAVIOUR_FLAG_COUNT; ///< Flags passed in from constructor.
bool mIsKeyboardNavigationSupported :1; ///< Stores whether keyboard navigation is supported by the control.
Vector3 Control::GetNaturalSize()
{
- // could be overridden in derived classes.
- return mImpl->mNaturalSize;
-}
-
-float Control::CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension )
-{
- // Could be overridden in derived classes.
- return CalculateChildSizeBase( child, dimension );
-}
-
-bool Control::RelayoutDependentOnChildren( Dimension::Type dimension )
-{
- return RelayoutDependentOnChildrenBase( dimension );
+ if( mImpl->mBackground )
+ {
+ Actor actor = mImpl->mBackground->actor;
+ if( actor )
+ {
+ return actor.GetNaturalSize();
+ }
+ }
+ return Vector3();
}
float Control::GetHeightForWidth( float width )
{
- // could be overridden in derived classes.
- float height( 0.0f );
- if ( mImpl->mNaturalSize.width > 0.0f )
+ if( mImpl->mBackground )
{
- height = mImpl->mNaturalSize.height * width / mImpl->mNaturalSize.width;
+ Actor actor = mImpl->mBackground->actor;
+ if( actor )
+ {
+ return actor.GetHeightForWidth( width );
+ }
}
- return height;
+ return GetHeightForWidthBase( width );
}
float Control::GetWidthForHeight( float height )
{
- // could be overridden in derived classes.
- float width( 0.0f );
- if ( mImpl->mNaturalSize.height > 0.0f )
+ if( mImpl->mBackground )
{
- width = mImpl->mNaturalSize.width * height / mImpl->mNaturalSize.height;
+ Actor actor = mImpl->mBackground->actor;
+ if( actor )
+ {
+ return actor.GetWidthForHeight( height );
+ }
}
- return width;
-}
-
-const Vector3& Control::GetControlSize() const
-{
- return mImpl->mCurrentSize;
-}
-
-const Vector3& Control::GetSizeSet() const
-{
- return mImpl->mNaturalSize;
+ return GetWidthForHeightBase( height );
}
void Control::SetKeyInputFocus()
{
}
+float Control::CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension )
+{
+ return CalculateChildSizeBase( child, dimension );
+}
+
+bool Control::RelayoutDependentOnChildren( Dimension::Type dimension )
+{
+ return RelayoutDependentOnChildrenBase( dimension );
+}
+
void Control::EmitKeyInputFocusSignal( bool focusGained )
{
Dali::Toolkit::Control handle( GetOwner() );
void Control::OnSizeSet(const Vector3& targetSize)
{
- if( targetSize != mImpl->mNaturalSize )
- {
- // Only updates size if set through Actor's API
- mImpl->mNaturalSize = targetSize;
- }
-
- if( targetSize != mImpl->mCurrentSize )
- {
- // Update control size.
- mImpl->mCurrentSize = targetSize;
+ // Background is resized through size negotiation
- // Notify derived classes.
- OnControlSizeSet( targetSize );
- }
+ // Notify derived classes.
+ OnControlSizeSet( targetSize );
}
void Control::SignalConnected( SlotObserver* slotObserver, CallbackBase* callback )
virtual float GetWidthForHeight( float height );
/**
- * @copydoc Toolkit::Control::GetNaturalSize()
+ * @copydoc Toolkit::CustomActorImpl::GetNaturalSize()
*/
virtual Vector3 GetNaturalSize();
- /**
- * @brief Retrieves the current Control's size.
- *
- * @return The control's size.
- */
- const Vector3& GetControlSize() const;
-
- /**
- * @brief Retrieves the Control's size set by the Application / Control.
- *
- * @return The control's size.
- */
- const Vector3& GetSizeSet() const;
-
// Key Input
/**
virtual void OnStageConnection();
/**
- * @brief Calls OnControlStageDisconnection() to notify derived classed.
- *
- * @see Dali::CustomActorImpl::OnStageDisconnection()
+ * @copydoc Dali::CustomActorImpl::OnStageDisconnection()
*/
virtual void OnStageDisconnection();
/**
- * @brief Sends a request to relayout this control.
- *
- * The control will be relaid out after the
- * Dali::Stage::SignalMessageQueueFlushed() signal is emitted. It
- * calls OnControlChildAdd() to notify derived classes.
- *
- * @note This method shouldn't be overridden by derived classes.
- *
- * @param[in] child The added actor.
- *
- * @see Dali::CustomActorImpl::OnChildAdd(Actor&)
+ * @copydoc Dali::CustomActorImpl::OnChildAdd(Actor&)
*/
virtual void OnChildAdd(Actor& child);
/**
- * @brief Sends a request to relayout this control.
- *
- * The control will be relaid out after the
- * Dali::Stage::SignalMessageQueueFlushed() signal is emitted. It
- * calls OnControlChildRemove() to notify derived classes.
- *
- * @note This method shouldn't be overridden by derived classes.
- *
- * @param[in] child The removed actor.
- *
- * @see Dali::CustomActorImpl::OnChildRemove(Actor&)
+ * @copydoc Dali::CustomActorImpl::OnChildRemove(Actor&)
*/
virtual void OnChildRemove(Actor& child);
/**
- * @brief It stores the size set by size negotiation and relayout.
- *
- * It also keeps a backup of the size set through the Actor's API used in the size negotiation.
- * It calls the OnControlSizeSet() to notify derived classes.
- *
- * @param[in] targetSize The new size.
- *
- * @see Dali::CustomActorImpl::OnSizeSet(const Vector3&)
+ * @copydoc Dali::CustomActorImpl::OnSizeSet(const Vector3&)
*/
virtual void OnSizeSet(const Vector3& targetSize);