application.SendNotification();
Vector2 size( 100.0f, 200.0f );
- alignment.SetPreferredSize(size);
+ alignment.SetSize(size);
application.Render();
application.SendNotification();
Stage::GetCurrent().Add(alignment);
Animation animation = Animation::New(100.0f);
- animation.Resize(alignment, Vector3(100.0f, 150.0f, 200.0f));
+ animation.AnimateTo( Property( alignment, Actor::Property::SIZE ), Vector3( 100.0f, 150.0f, 200.0f ) );
animation.Play();
application.Render();
// First an image is set, then SetSize is called.
pushButton = PushButton::New();
+ Stage::GetCurrent().Add( pushButton );
pushButton.SetBackgroundImage( image01 );
pushButton.SetSize( 10.f, 10.f );
Image image02 = CreateSolidColorImage( Color::RED, 30, 30 );
ImageActor imageActor02 = CreateSolidColorActor( Color::RED );
imageActor02.SetSize( 40, 40 );
+ imageActor02.SetName( "imageActor02" );
Image image03 = CreateSolidColorImage( Color::RED, 50, 50 );
ImageActor imageActor03 = CreateSolidColorActor( Color::RED );
Vector3 size;
CheckBoxButton checkBoxButton = CheckBoxButton::New();
+ checkBoxButton.SetName( "UtcDaliCheckBoxButtonSetImages" );
+ Stage::GetCurrent().Add( checkBoxButton );
application.SendNotification();
application.Render();
application.SendNotification();
application.Render();
- size = checkBoxButton.GetBackgroundImage().GetCurrentSize();
+ size = checkBoxButton.GetCurrentSize();
DALI_TEST_EQUALS( size.width, 10.f, TEST_LOCATION );
DALI_TEST_EQUALS( size.height, 10.f, TEST_LOCATION );
checkBoxButton.SetBackgroundImage( imageActor01 );
- application.SendNotification();
- application.Render();
-
- size = checkBoxButton.GetBackgroundImage().GetCurrentSize();
-
- DALI_TEST_EQUALS( size.width, 20.f, TEST_LOCATION );
- DALI_TEST_EQUALS( size.height, 20.f, TEST_LOCATION );
-
- checkBoxButton.SetSelectedImage( image02 );
-
- application.SendNotification();
- application.Render();
-
- size = checkBoxButton.GetSelectedImage().GetCurrentSize();
-
- DALI_TEST_EQUALS( size.width, 30.f, TEST_LOCATION );
- DALI_TEST_EQUALS( size.height, 30.f, TEST_LOCATION );
-
- checkBoxButton.SetSelectedImage( imageActor02 );
-
- application.SendNotification();
- application.Render();
-
- size = checkBoxButton.GetSelectedImage().GetCurrentSize();
-
- DALI_TEST_EQUALS( size.width, 40.f, TEST_LOCATION );
- DALI_TEST_EQUALS( size.height, 40.f, TEST_LOCATION );
-
- checkBoxButton.SetDisabledBackgroundImage( image03 );
-
- application.SendNotification();
- application.Render();
-
- size = checkBoxButton.GetDisabledBackgroundImage().GetCurrentSize();
-
- DALI_TEST_EQUALS( size.width, 50.f, TEST_LOCATION );
- DALI_TEST_EQUALS( size.height, 50.f, TEST_LOCATION );
-
- checkBoxButton.SetDisabledBackgroundImage( imageActor03 );
-
- application.SendNotification();
- application.Render();
-
- size = checkBoxButton.GetDisabledBackgroundImage().GetCurrentSize();
-
- DALI_TEST_EQUALS( size.width, 60.f, TEST_LOCATION );
- DALI_TEST_EQUALS( size.height, 60.f, TEST_LOCATION );
-
- checkBoxButton.SetDisabledSelectedImage( image04 );
-
- application.SendNotification();
- application.Render();
-
- size = checkBoxButton.GetDisabledSelectedImage().GetCurrentSize();
-
- DALI_TEST_EQUALS( size.width, 70.f, TEST_LOCATION );
- DALI_TEST_EQUALS( size.height, 70.f, TEST_LOCATION );
-
- checkBoxButton.SetDisabledSelectedImage( imageActor04 );
-
- application.SendNotification();
- application.Render();
-
- size = checkBoxButton.GetDisabledSelectedImage().GetCurrentSize();
-
- DALI_TEST_EQUALS( size.width, 80.f, TEST_LOCATION );
- DALI_TEST_EQUALS( size.height, 80.f, TEST_LOCATION );
END_TEST;
}
DummyControl test = DummyControl::New();
test.SetSize( 0.7f, 0.7f, 0.7f );
+
+ Stage::GetCurrent().Add( test );
+
+ application.SendNotification();
+ application.Render();
+
float width = 640.0f;
float height = test.GetHeightForWidth( width );
DALI_TEST_CHECK( test.GetWidthForHeight( height ) == width );
{
DummyControl dummy = DummyControl::New(true);
dummy.SetRelayoutEnabled( true );
- dummy.SetPreferredSize( Vector2(100.0f, 100.0f ) );
+ dummy.SetSize( Vector2(100.0f, 100.0f ) );
dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
Stage::GetCurrent().Add(dummy);
{
DummyControl dummy = DummyControl::New();
dummy.SetRelayoutEnabled( true );
- dummy.SetPreferredSize( Vector2( 100.0f, 100.0f ) );
+ dummy.SetSize( Vector2( 100.0f, 100.0f ) );
dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
Stage::GetCurrent().Add(dummy);
DALI_TEST_EQUALS( dummyImpl.sizeSetCalled, true, TEST_LOCATION ); // Called from size negotiation
Vector2 size(100.0f, 200.0f);
- dummy.SetPreferredSize(size);
+ dummy.SetSize(size);
application.Render();
application.SendNotification();
application.Render();
application.SendNotification();
- dummy.SetPreferredSize(size);
+ dummy.SetSize(size);
application.Render();
application.SendNotification();
DALI_TEST_EQUALS( dummyImpl.sizeAnimationCalled, false, TEST_LOCATION );
Animation animation = Animation::New(1.0f);
- animation.Resize(dummy, Vector3(100.0f, 150.0f, 200.0f));
+ animation.AnimateTo( Property( dummy, Actor::Property::SIZE ), Vector3( 100.0f, 150.0f, 200.0f ) );
animation.Play();
application.Render();
Stage::GetCurrent().Add(dummy);
Animation animation = Animation::New(1.0f);
- animation.Resize(dummy, Vector3(100.0f, 150.0f, 200.0f));
+ animation.AnimateTo( Property( dummy, Actor::Property::SIZE ), Vector3( 100.0f, 150.0f, 200.0f ) );
animation.Play();
application.Render();
dummy.SetRelayoutEnabled( true );
DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
- dummy.SetPreferredSize( Vector2( 100.0f, 100.0f ) );
+ dummy.SetSize( Vector2( 100.0f, 100.0f ) );
dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
Stage::GetCurrent().Add(dummy);
DummyControl dummy = DummyControl::New();
dummy.SetRelayoutEnabled( true );
- dummy.SetPreferredSize( Vector2( 100.0f, 100.0f ) );
+ dummy.SetSize( Vector2( 100.0f, 100.0f ) );
dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
Stage::GetCurrent().Add(dummy);
dummy.SetRelayoutEnabled( true );
DummyControlImplOverride& dummyImpl = static_cast<DummyControlImplOverride&>(dummy.GetImplementation());
- dummy.SetPreferredSize( Vector2( 100.0f, 100.0f ) );
+ dummy.SetSize( Vector2( 100.0f, 100.0f ) );
dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
Stage::GetCurrent().Add(dummy);
DummyControl dummy = DummyControl::New();
dummy.SetRelayoutEnabled( true );
- dummy.SetPreferredSize( Vector2( 100.0f, 100.0f ) );
+ dummy.SetSize( Vector2( 100.0f, 100.0f ) );
dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
Stage::GetCurrent().Add(dummy);
factory.EnableOffscreenRendering( );
PageTurnView pageTurnView = PageTurnLandscapeView::New( factory, PAGE_SIZE );
+ pageTurnView.SetRelayoutEnabled( false );
pageTurnView.SetPositionInheritanceMode( USE_PARENT_POSITION );
Stage::GetCurrent().Add( pageTurnView );
factory.EnableOffscreenRendering( );
PageTurnView pageTurnView = PageTurnPortraitView::New( factory, PAGE_SIZE );
+ pageTurnView.SetRelayoutEnabled( false );
pageTurnView.SetParentOrigin( ParentOrigin::TOP_LEFT );
pageTurnView.SetAnchorPoint( AnchorPoint::TOP_LEFT );
Stage::GetCurrent().Add( pageTurnView );
TestPageFactory factory(application);
factory.EnableOffscreenRendering( );
PageTurnView pageTurnView = PageTurnPortraitView::New( factory, PAGE_SIZE );
+ pageTurnView.SetRelayoutEnabled( false );
pageTurnView.SetParentOrigin( ParentOrigin::TOP_LEFT );
pageTurnView.SetAnchorPoint( AnchorPoint::TOP_LEFT );
Stage::GetCurrent().Add( pageTurnView );
TestPageFactory factory(application);
Vector2 size = Stage::GetCurrent().GetSize();
PageTurnView portraitView = PageTurnPortraitView::New( factory, size );
+ portraitView.SetRelayoutEnabled( false );
portraitView.SetPositionInheritanceMode( USE_PARENT_POSITION );
Stage::GetCurrent().Add( portraitView );
PushButton button1 = PushButton::New();
PushButton button2 = PushButton::New();
- button1.SetPreferredSize(DEFAULT_BUTTON_SIZE.GetVectorXY());
+ button1.SetSize(DEFAULT_BUTTON_SIZE.GetVectorXY());
popup.AddButton(button1);
- button2.SetPreferredSize(DEFAULT_BUTTON_SIZE.GetVectorXY());
+ button2.SetSize(DEFAULT_BUTTON_SIZE.GetVectorXY());
popup.AddButton(button2);
// Showing/Hiding popup, results in all child Actors being
Actor imageActor;
Image image01 = CreateSolidColorImage( Color::RED, 10, 10 );
- ImageActor imageActor01 = CreateSolidColorActor( Color::RED );
- imageActor01.SetSize( 20.f, 20.f );
-
- Image image02 = CreateSolidColorImage( Color::RED, 30, 30 );
- ImageActor imageActor02 = CreateSolidColorActor( Color::RED );
- imageActor02.SetSize( 40.f, 40.f );
-
- Image image03 = CreateSolidColorImage( Color::RED, 50, 50 );
- ImageActor imageActor03 = CreateSolidColorActor( Color::RED );
- imageActor03.SetSize( 60.f, 60.f );
-
- Image image04 = CreateSolidColorImage( Color::RED, 70, 70 );
- ImageActor imageActor04 = CreateSolidColorActor( Color::RED );
- imageActor04.SetSize( 80.f, 80.f );
-
- Image image05 = CreateSolidColorImage( Color::RED, 90, 90 );
- ImageActor imageActor05 = CreateSolidColorActor( Color::RED );
- imageActor05.SetSize( 100.f, 100.f );
Vector3 size;
PushButton pushButton = PushButton::New();
+ Stage::GetCurrent().Add( pushButton );
application.SendNotification();
application.Render();
application.SendNotification();
application.Render();
- size = pushButton.GetButtonImage().GetCurrentSize();
+ size = pushButton.GetCurrentSize();
DALI_TEST_EQUALS( size.width, 10.f, TEST_LOCATION );
DALI_TEST_EQUALS( size.height, 10.f, TEST_LOCATION );
- pushButton.SetButtonImage( imageActor01 );
-
- application.SendNotification();
- application.Render();
-
- size = pushButton.GetButtonImage().GetCurrentSize();
-
- DALI_TEST_EQUALS( size.width, 20.f, TEST_LOCATION );
- DALI_TEST_EQUALS( size.height, 20.f, TEST_LOCATION );
-
- pushButton.SetBackgroundImage( image02 );
-
- application.SendNotification();
- application.Render();
-
- size = pushButton.GetBackgroundImage().GetCurrentSize();
-
- DALI_TEST_EQUALS( size.width, 30.f, TEST_LOCATION );
- DALI_TEST_EQUALS( size.height, 30.f, TEST_LOCATION );
-
- pushButton.SetBackgroundImage( imageActor02 );
-
- application.SendNotification();
- application.Render();
-
- size = pushButton.GetBackgroundImage().GetCurrentSize();
-
- DALI_TEST_EQUALS( size.width, 40.f, TEST_LOCATION );
- DALI_TEST_EQUALS( size.height, 40.f, TEST_LOCATION );
-
- pushButton.SetSelectedImage( image03 );
-
- application.SendNotification();
- application.Render();
-
- size = pushButton.GetSelectedImage().GetCurrentSize();
-
- DALI_TEST_EQUALS( size.width, 50.f, TEST_LOCATION );
- DALI_TEST_EQUALS( size.height, 50.f, TEST_LOCATION );
-
- pushButton.SetSelectedImage( imageActor03 );
-
- application.SendNotification();
- application.Render();
-
- size = pushButton.GetSelectedImage().GetCurrentSize();
-
- DALI_TEST_EQUALS( size.width, 60.f, TEST_LOCATION );
- DALI_TEST_EQUALS( size.height, 60.f, TEST_LOCATION );
-
- pushButton.SetDisabledBackgroundImage( image04 );
-
- application.SendNotification();
- application.Render();
-
- size = pushButton.GetDisabledBackgroundImage().GetCurrentSize();
-
- DALI_TEST_EQUALS( size.width, 70.f, TEST_LOCATION );
- DALI_TEST_EQUALS( size.height, 70.f, TEST_LOCATION );
-
- pushButton.SetDisabledBackgroundImage( imageActor04 );
-
- application.SendNotification();
- application.Render();
-
- size = pushButton.GetDisabledBackgroundImage().GetCurrentSize();
-
- DALI_TEST_EQUALS( size.width, 80.f, TEST_LOCATION );
- DALI_TEST_EQUALS( size.height, 80.f, TEST_LOCATION );
-
- pushButton.SetDisabledImage( image05 );
-
- application.SendNotification();
- application.Render();
-
- size = pushButton.GetDisabledImage().GetCurrentSize();
-
- DALI_TEST_EQUALS( size.width, 90.f, TEST_LOCATION );
- DALI_TEST_EQUALS( size.height, 90.f, TEST_LOCATION );
-
- pushButton.SetDisabledImage( imageActor05 );
-
- application.SendNotification();
- application.Render();
-
- size = pushButton.GetDisabledImage().GetCurrentSize();
-
- DALI_TEST_EQUALS( size.width, 100.f, TEST_LOCATION );
- DALI_TEST_EQUALS( size.height, 100.f, TEST_LOCATION );
END_TEST;
}
*/
static float TestOvershootSnapDuration(ToolkitTestApplication &application, ScrollView scrollView)
{
- Property::Index overshootPropertyX = scrollView.GetPropertyIndex(ScrollView::SCROLL_OVERSHOOT_X_PROPERTY_NAME);
- Property::Index overshootPropertyY = scrollView.GetPropertyIndex(ScrollView::SCROLL_OVERSHOOT_Y_PROPERTY_NAME);
-
int timeToReachOrigin = -1;
for(int i = 0;i<MAX_FRAMES_TO_TEST_OVERSHOOT;i++)
{
- float overshootXValue = scrollView.GetProperty<float>(overshootPropertyX);
- float overshootYValue = scrollView.GetProperty<float>(overshootPropertyY);
+ float overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
+ float overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
if(overshootXValue == 0.0f && overshootYValue == 0.0f)
{
break;
a.SetPosition( TEST_ACTOR_POSITION );
Wait(application);
- Property::Index scrollPositionProperty = scrollView.GetPropertyIndex(ScrollView::SCROLL_POSITION_PROPERTY_NAME);
Constraint constraint = Constraint::New<Vector3>( Actor::Property::POSITION,
- Source(scrollView, scrollPositionProperty),
+ Source(scrollView, ScrollView::Property::SCROLL_POSITION),
TestSumConstraint( TEST_CONSTRAINT_OFFSET ) );
constraint.SetRemoveAction(Constraint::Discard);
scrollView.ApplyConstraintToChildren(constraint);
a.SetPosition( TEST_ACTOR_POSITION );
Wait(application);
- Property::Index scrollPositionProperty = scrollView.GetPropertyIndex(ScrollView::SCROLL_POSITION_PROPERTY_NAME);
// apply this constraint to scrollview
Constraint constraint = Constraint::New<Vector3>( Actor::Property::POSITION,
- Source(scrollView, scrollPositionProperty),
+ Source(scrollView, ScrollView::Property::SCROLL_POSITION),
TestSumConstraint( TEST_CONSTRAINT_OFFSET ) );
constraint.SetRemoveAction(Constraint::Discard);
// 1. Scroll page in NW (-500,-500 pixels), then inspect overshoot. (don't release touch)
Vector2 currentPos = Vector2(100.0f, 100.0f);
currentPos = PerformGestureDiagonalSwipe(application, currentPos, Vector2(5.0f, 5.0f), 100, false);
- Property::Index overshootXProperty = scrollView.GetPropertyIndex(ScrollView::SCROLL_OVERSHOOT_X_PROPERTY_NAME);
- Property::Index overshootYProperty = scrollView.GetPropertyIndex(ScrollView::SCROLL_OVERSHOOT_Y_PROPERTY_NAME);
- Property::Index scrollPositionProperty = scrollView.GetPropertyIndex(ScrollView::SCROLL_POSITION_PROPERTY_NAME);
- float overshootXValue = scrollView.GetProperty<float>(overshootXProperty);
- float overshootYValue = scrollView.GetProperty<float>(overshootYProperty);
- Vector3 positionValue = scrollView.GetProperty<Vector3>(scrollPositionProperty);
+ float overshootXValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_X);
+ float overshootYValue = scrollView.GetProperty<float>(ScrollView::Property::OVERSHOOT_Y);
+ Vector3 positionValue = scrollView.GetProperty<Vector3>(ScrollView::Property::SCROLL_POSITION);
DALI_TEST_EQUALS(overshootXValue, 1.0f, TEST_LOCATION);
DALI_TEST_EQUALS(overshootYValue, 1.0f, TEST_LOCATION);
DALI_TEST_EQUALS(positionValue, Vector3::ZERO, TEST_LOCATION);
Stage::GetCurrent().Add( slider );
slider.SetParentOrigin(ParentOrigin::TOP_LEFT);
slider.SetAnchorPoint(ParentOrigin::TOP_LEFT);
- slider.SetPreferredSize( Vector2( Stage::GetCurrent().GetSize().x, 20.0f ) );
+ slider.SetSize( Vector2( Stage::GetCurrent().GetSize().x, 20.0f ) );
slider.SetPosition( 0.0f, 0.0f );
const float MIN_BOUND = 0.0f;
tet_infoline( "UtcDaliSuperBlurViewGetBlurredImage" );
SuperBlurView blurView = SuperBlurView::New( BLUR_LEVELS );
+ blurView.SetRelayoutEnabled( false );
blurView.SetSize( 100.f,100.f );
Image inputImage = CreateSolidColorImage( application, Color::GREEN, 100, 100 );
blurView.SetImage( inputImage );
DALI_TEST_CHECK( image1 );
Image image2 = blurView.GetBlurredImage( 2 );
- DALI_TEST_CHECK( image2.GetWidth() == 25 );
- DALI_TEST_CHECK( image2.GetHeight() == 25 );
+ DALI_TEST_EQUALS( image2.GetWidth(), 25, TEST_LOCATION );
+ DALI_TEST_EQUALS( image2.GetHeight(), 25, TEST_LOCATION );
Image image3 = blurView.GetBlurredImage( 3 );
DALI_TEST_CHECK( FrameBufferImage::DownCast( image2 ) );
tableView.SetRelayoutEnabled( true );
Stage::GetCurrent().Add( tableView );
- tableView.SetPreferredSize( Dali::Vector2( 100.0f, 100.0f ) );
+ tableView.SetSize( Dali::Vector2( 100.0f, 100.0f ) );
actor1 = Actor::New();
actor2 = Actor::New();
actor3 = Actor::New();
actor1.SetRelayoutEnabled( true );
- actor1.SetPreferredSize( Dali::Vector2( 10, 10 ) );
+ actor1.SetSize( Dali::Vector2( 10, 10 ) );
actor2.SetRelayoutEnabled( true );
- actor2.SetPreferredSize( Dali::Vector2( 10, 10 ) );
+ actor2.SetSize( Dali::Vector2( 10, 10 ) );
actor3.SetRelayoutEnabled( true );
- actor3.SetPreferredSize( Dali::Vector2( 10, 10 ) );
+ actor3.SetSize( Dali::Vector2( 10, 10 ) );
tableView.AddChild( actor1, TableView::CellPosition( 0, 0 ) );
tableView.AddChild( actor2, TableView::CellPosition( 0, 1 ) );
// Create a 1x1 table-view
TableView tableView = TableView::New(1,1);
- tableView.SetPreferredSize( Vector2( 100.0f, 100.0f ) );
+ tableView.SetSize( Vector2( 100.0f, 100.0f ) );
DALI_TEST_CHECK( tableView );
// Test "rows" property
try
{
ImageActor control1 = CreateSolidColorActor( Color::RED );
- control1.SetPreferredSize( Vector2( 100.f, 100.f ) );
- control1.SetResizePolicy( FIXED, ALL_DIMENSIONS );
+ control1.SetSize( Vector2( 100.f, 100.f ) );
ImageActor control2 = CreateSolidColorActor( Color::RED );
- control2.SetPreferredSize( Vector2( 100.f, 100.f ) );
- control2.SetResizePolicy( FIXED, ALL_DIMENSIONS );
+ control2.SetSize( Vector2( 100.f, 100.f ) );
ImageActor control3 = CreateSolidColorActor( Color::RED );
- control3.SetPreferredSize( Vector2( 100.f, 100.f ) );
- control3.SetResizePolicy( FIXED, ALL_DIMENSIONS );
+ control3.SetSize( Vector2( 100.f, 100.f ) );
ImageActor control4 = CreateSolidColorActor( Color::RED );
- control4.SetPreferredSize( Vector2( 100.f, 100.f ) );
- control4.SetResizePolicy( FIXED, ALL_DIMENSIONS );
+ control4.SetSize( Vector2( 100.f, 100.f ) );
ImageActor control5 = CreateSolidColorActor( Color::RED );
- control5.SetPreferredSize( Vector2( 100.f, 100.f ) );
- control5.SetResizePolicy( FIXED, ALL_DIMENSIONS );
+ control5.SetSize( Vector2( 100.f, 100.f ) );
ToolBar toolbar = ToolBar::New();
- toolbar.SetPreferredSize( Vector2( 600.f, 100.f ) );
+ toolbar.SetSize( Vector2( 600.f, 100.f ) );
application.Render();
application.SendNotification();
toolbar.AddControl( control5, 0.1f, Alignment::HorizontalRight, Alignment::Padding( 1.f, 1.f, 1.f, 1.f ) );
ImageActor control6 = CreateSolidColorActor( Color::RED );
- control6.SetPreferredSize( Vector2( 100.f, 100.f ) );
- control6.SetResizePolicy( FIXED, ALL_DIMENSIONS );
+ control6.SetSize( Vector2( 100.f, 100.f ) );
ImageActor control7 = CreateSolidColorActor( Color::RED );
- control7.SetPreferredSize( Vector2( 100.f, 100.f ) );
- control7.SetResizePolicy( FIXED, ALL_DIMENSIONS );
+ control7.SetSize( Vector2( 100.f, 100.f ) );
ImageActor control8 = CreateSolidColorActor( Color::RED );
- control8.SetPreferredSize( Vector2( 100.f, 100.f ) );
- control8.SetResizePolicy( FIXED, ALL_DIMENSIONS );
+ control8.SetSize( Vector2( 100.f, 100.f ) );
application.Render();
application.SendNotification();
view.SetRelayoutEnabled( true );
Stage::GetCurrent().Add( view );
- view.SetPreferredSize( Vector2( 480, 800 ) );
+ view.SetSize( Vector2( 480, 800 ) );
view.OrientationAnimationStartedSignal().Connect( &StartAnimation );
*/
// EXTERNAL INCLUDES
+#include <dali/public-api/actors/layer.h>
+#include <dali/public-api/actors/renderable-actor.h>
#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
*/
// EXTERNAL INCLUDES
-#include <dali.h>
+#include <dali/public-api/math/rect.h>
+#include <dali/public-api/math/vector2.h>
+#include <dali/public-api/math/vector3.h>
+#include <dali/public-api/math/vector4.h>
+#include <dali/public-api/math/matrix.h>
+#include <dali/public-api/math/matrix3.h>
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/builder/tree-node.h>
#include <sys/stat.h>
#include <boost/function.hpp>
#include <sstream>
-
+#include <dali/public-api/render-tasks/render-task-list.h>
+#include <dali/public-api/object/type-info.h>
+#include <dali/public-api/object/type-registry.h>
+#include <dali/public-api/actors/layer.h>
+#include <dali/public-api/actors/image-actor.h>
+#include <dali/public-api/actors/camera-actor.h>
+#include <dali/public-api/scripting/scripting.h>
#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
-
#include <dali-toolkit/public-api/controls/control.h>
#include <dali-toolkit/public-api/builder/json-parser.h>
#include <string>
#include <list>
#include <map>
+#include <dali/public-api/common/stage.h>
#include <dali/public-api/actors/actor.h>
#include <dali/public-api/object/base-object.h>
+#include <dali/public-api/object/property-map.h>
+#include <dali/public-api/render-tasks/render-task.h>
#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
// EXTERNAL INCLUDES
#include <sstream>
+#include <dali/public-api/adaptor-framework/color-controller.h>
// INTERNAL INCLUDES
#include <dali-toolkit/internal/builder/builder-impl.h>
*/
// EXTERNAL INCLUDES
-#include <dali/integration-api/debug.h>
#include <boost/function.hpp>
+#include <dali/public-api/actors/layer.h>
+#include <dali/public-api/object/type-info.h>
+#include <dali/public-api/object/property-notification.h>
+#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
#include <dali-toolkit/internal/builder/builder-impl.h>
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/text-controls/text-label.h>
+/**
+ * Button states and contents
+ * (3) mSelectedContent
+ * (2) mButtonContent (2) mSelectedBackgroundContent
+ * (1) mBackgroundContent (1) mBackgroundContent
+ * < unselected > ----------------------- < selected >
+ * | OnSelect() |
+ * | OnDisabled() | OnDisabled()
+ * | |
+ * < disabled > < disabled-selected >
+ * (2) mDisabledContent (2) mDisabledSelectedContent
+ * (1) mDisabledBackgroundContent (1) mDisabledBackgroundContent
+ *
+ * The drawing order of child actors is as follows.
+ *
+ * Top mLabel
+ * | mButtonContent / mSelectedContent / mDisabledContent / mDisabledSelectedContent
+ * | mSelectedBackgroundContent
+ * Bottom mBackgroundContent / mDisabledBackgroundContent
+ *
+ * Some of contents may be missed.
+ * And 2 images - fade-in image and fade-out image - in the same layer can be shown during the transition animation. Fade-in image should be above fade-out image.
+ */
+
namespace Dali
{
mNextAutoRepeatingDelay( NEXT_AUTOREPEATING_DELAY ),
mAnimationTime( 0.0f ),
mClickActionPerforming( false ),
- mState( ButtonUp )
+ mState( ButtonUp ),
+ mPaintState( UnselectedState )
{
}
{
if( disabled != mDisabled )
{
+ unsigned int backgroundIndex;
+ unsigned int buttonIndex;
+
+ bool animationStarted = false;
+
mDisabled = disabled;
- OnDisabled( mDisabled );
+ switch( mPaintState )
+ {
+ case UnselectedState:
+ {
+ buttonIndex = FindChildIndex( mLabel );
+ InsertChild( buttonIndex, mDisabledContent );
+
+ if( mBackgroundContent )
+ {
+ backgroundIndex = 1;
+ }
+ else
+ {
+ backgroundIndex = 0;
+ }
+
+ InsertChild( backgroundIndex, mDisabledBackgroundContent );
+
+ animationStarted = OnDisabled();
+
+ if( animationStarted )
+ {
+ mPaintState = UnselectedDisabledTransition;
+ }
+ else
+ {
+ mPaintState = DisabledUnselectedState;
+ }
+ break;
+ }
+ case SelectedState:
+ {
+ buttonIndex = FindChildIndex( mLabel );
+ InsertChild( buttonIndex, mDisabledSelectedContent );
+
+ if( mBackgroundContent )
+ {
+ backgroundIndex = 1;
+ }
+ else
+ {
+ backgroundIndex = 0;
+ }
+
+ InsertChild( backgroundIndex, mDisabledBackgroundContent );
+
+ animationStarted = OnDisabled();
+
+ if( animationStarted )
+ {
+ mPaintState = SelectedDisabledTransition;
+ }
+ else
+ {
+ mPaintState = DisabledSelectedState;
+ }
+ break;
+ }
+ case DisabledUnselectedState:
+ {
+ buttonIndex = FindChildIndex( mLabel );
+ InsertChild( buttonIndex, mButtonContent );
+
+ if( mDisabledBackgroundContent )
+ {
+ backgroundIndex = 1;
+ }
+ else
+ {
+ backgroundIndex = 0;
+ }
+
+ InsertChild( backgroundIndex, mBackgroundContent );
+
+ animationStarted = OnDisabled();
+
+ if( animationStarted )
+ {
+ mPaintState = DisabledUnselectedTransition;
+ }
+ else
+ {
+ mPaintState = UnselectedState;
+ }
+ break;
+ }
+ case DisabledSelectedState:
+ {
+ buttonIndex = FindChildIndex( mLabel );
+ InsertChild( buttonIndex, mSelectedContent );
+
+ if( mDisabledBackgroundContent )
+ {
+ backgroundIndex = 1;
+ }
+ else
+ {
+ backgroundIndex = 0;
+ }
+
+ InsertChild( backgroundIndex, mSelectedBackgroundContent );
+ InsertChild( backgroundIndex, mBackgroundContent );
+
+ animationStarted = OnDisabled();
+
+ if( animationStarted )
+ {
+ mPaintState = DisabledSelectedTransition;
+ }
+ else
+ {
+ mPaintState = SelectedState;
+ }
+ break;
+ }
+ case UnselectedSelectedTransition:
+ {
+ buttonIndex = FindChildIndex( mLabel );
+ InsertChild( buttonIndex, mDisabledSelectedContent );
+
+ if( mBackgroundContent )
+ {
+ backgroundIndex = 1;
+ }
+ else
+ {
+ backgroundIndex = 0;
+ }
+
+ InsertChild( backgroundIndex, mDisabledBackgroundContent );
+
+ animationStarted = OnDisabled();
+
+ if( animationStarted )
+ {
+ mPaintState = SelectedDisabledTransition;
+ }
+ else
+ {
+ mPaintState = DisabledSelectedState;
+ }
+ break;
+ }
+ case SelectedUnselectedTransition:
+ {
+ buttonIndex = FindChildIndex( mLabel );
+ InsertChild( buttonIndex, mDisabledContent );
+
+ if( mBackgroundContent )
+ {
+ backgroundIndex = 1;
+ }
+ else
+ {
+ backgroundIndex = 0;
+ }
+
+ InsertChild( backgroundIndex, mDisabledBackgroundContent );
+
+ animationStarted = OnDisabled();
+
+ if( animationStarted )
+ {
+ mPaintState = UnselectedDisabledTransition;
+ }
+ else
+ {
+ mPaintState = DisabledUnselectedState;
+ }
+ break;
+ }
+ case UnselectedDisabledTransition:
+ {
+ animationStarted = OnDisabled();
+
+ if( animationStarted )
+ {
+ mPaintState = DisabledUnselectedTransition;
+ }
+ else
+ {
+ mPaintState = UnselectedState;
+ }
+ break;
+ }
+ case DisabledUnselectedTransition:
+ {
+ animationStarted = OnDisabled();
+
+ if( animationStarted )
+ {
+ mPaintState = UnselectedDisabledTransition;
+ }
+ else
+ {
+ mPaintState = DisabledUnselectedState;
+ }
+ break;
+ }
+ case SelectedDisabledTransition:
+ {
+ animationStarted = OnDisabled();
+
+ if( animationStarted )
+ {
+ mPaintState = DisabledSelectedTransition;
+ }
+ else
+ {
+ mPaintState = SelectedState;
+ }
+ break;
+ }
+ case DisabledSelectedTransition:
+ {
+ animationStarted = OnDisabled();
+
+ if( animationStarted )
+ {
+ mPaintState = SelectedDisabledTransition;
+ }
+ else
+ {
+ mPaintState = DisabledSelectedState;
+ }
+ break;
+ }
+ }
}
}
if( mSelected )
{
// Emit a signal is not wanted, only change the appearance.
- OnSelected( false );
-
- mSelected = false;
-
- RelayoutRequest();
+ SetSelected( false, false );
}
}
}
{
if( !mDisabled && mTogglableButton && ( selected != mSelected ) )
{
- // Notifies the derived class the button has been selected.
- OnSelected( selected );
+ SetSelected( selected, true );
+ }
+}
- mSelected = selected;
+void Button::SetSelected( bool selected, bool emitSignal )
+{
+ unsigned int buttonIndex, backgroundIndex;
+ bool animationStarted = false;
+ mSelected = selected;
+
+ switch( mPaintState )
+ {
+ case UnselectedState:
+ {
+ buttonIndex = FindChildIndex( mLabel );
+ InsertChild( buttonIndex, mSelectedContent );
+
+ if( mBackgroundContent )
+ {
+ backgroundIndex = 1;
+ }
+ else
+ {
+ backgroundIndex = 0;
+ }
+
+ InsertChild( backgroundIndex, mSelectedBackgroundContent );
+
+ // Notifies the derived class the button has been selected.
+ animationStarted = OnSelected();
+
+ if( animationStarted )
+ {
+ mPaintState = UnselectedSelectedTransition;
+ }
+ else
+ {
+ mPaintState = SelectedState;
+ }
+ break;
+ }
+ case SelectedState:
+ {
+ buttonIndex = FindChildIndex( mLabel );
+ InsertChild( buttonIndex, mButtonContent );
+
+ // Notifies the derived class the button has been selected.
+ animationStarted = OnSelected();
+
+ if( animationStarted )
+ {
+ mPaintState = SelectedUnselectedTransition;
+ }
+ else
+ {
+ mPaintState = UnselectedState;
+ }
+ break;
+ }
+ case UnselectedSelectedTransition:
+ {
+ // Notifies the derived class the button has been selected.
+ animationStarted = OnSelected();
+
+ if( animationStarted )
+ {
+ mPaintState = SelectedUnselectedTransition;
+ }
+ else
+ {
+ mPaintState = UnselectedState;
+ }
+ break;
+ }
+ case SelectedUnselectedTransition:
+ {
+ // Notifies the derived class the button has been selected.
+ animationStarted = OnSelected();
+
+ if( animationStarted )
+ {
+ mPaintState = UnselectedSelectedTransition;
+ }
+ else
+ {
+ mPaintState = SelectedState;
+ }
+ break;
+ }
+ case DisabledUnselectedTransition:
+ {
+ buttonIndex = FindChildIndex( mLabel );
+ InsertChild( buttonIndex, mSelectedContent );
+
+ if( mDisabledBackgroundContent )
+ {
+ if( mBackgroundContent )
+ {
+ backgroundIndex = 2;
+ }
+ else
+ {
+ backgroundIndex = 1;
+ }
+ }
+ else if( mBackgroundContent )
+ {
+ backgroundIndex = 1;
+ }
+ else
+ {
+ backgroundIndex = 0;
+ }
+
+ InsertChild( backgroundIndex, mSelectedBackgroundContent );
+
+ // Notifies the derived class the button has been selected.
+ animationStarted = OnSelected();
+
+ if( animationStarted )
+ {
+ mPaintState = UnselectedSelectedTransition;
+ }
+ else
+ {
+ mPaintState = SelectedState;
+ }
+ break;
+ }
+ case DisabledSelectedTransition:
+ {
+ buttonIndex = FindChildIndex( mLabel );
+ InsertChild( buttonIndex, mButtonContent );
+
+ // Notifies the derived class the button has been selected.
+ animationStarted = OnSelected();
+
+ if( animationStarted )
+ {
+ mPaintState = SelectedUnselectedTransition;
+ }
+ else
+ {
+ mPaintState = UnselectedState;
+ }
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+
+ if( emitSignal )
+ {
Toolkit::Button handle( GetOwner() );
// Emit signal.
mStateChangedSignal.Emit( handle );
-
- RelayoutRequest();
}
+
+ RelayoutRequest();
}
bool Button::IsSelected() const
}
mLabel = label;
+ mLabel.SetPosition( 0.f, 0.f );
+
+ // label should be the top of the button
+ Self().Add( mLabel );
OnLabelSet();
return mLabel;
}
+void Button::SetButtonImage( Actor image )
+{
+ StopAllAnimations();
+
+ if( mButtonContent && mButtonContent.GetParent() )
+ {
+ Self().Remove( mButtonContent );
+ }
+
+ mButtonContent = image;
+
+ mButtonContent.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ mButtonContent.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ mButtonContent.SetPosition( 0.f, 0.f );
+
+ if( mPaintState == UnselectedState )
+ {
+ unsigned int index = FindChildIndex( mLabel );
+
+ Self().Insert( index, mButtonContent );
+ }
+
+ OnButtonImageSet();
+}
+
Actor Button::GetButtonImage() const
{
return mButtonContent;
return mButtonContent;
}
+void Button::SetSelectedImage( Actor image )
+{
+ StopAllAnimations();
+
+ if( mSelectedContent && mSelectedContent.GetParent() )
+ {
+ Self().Remove( mSelectedContent );
+ }
+
+ mSelectedContent = image;
+
+ mSelectedContent.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ mSelectedContent.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ mSelectedContent.SetPosition( 0.f, 0.f );
+
+ if( mPaintState == SelectedState )
+ {
+ unsigned int index = FindChildIndex( mLabel );
+
+ Self().Insert( index, mSelectedContent );
+ }
+
+ OnSelectedImageSet();
+}
+
Actor Button::GetSelectedImage() const
{
return mSelectedContent;
return mSelectedContent;
}
+void Button::SetBackgroundImage( Actor image )
+{
+ StopAllAnimations();
+
+ if( mBackgroundContent && mBackgroundContent.GetParent() )
+ {
+ Self().Remove( mBackgroundContent );
+ }
+
+ mBackgroundContent = image;
+
+ mBackgroundContent.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ mBackgroundContent.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ mBackgroundContent.SetPosition( 0.f, 0.f );
+
+ if( mPaintState == UnselectedState || mPaintState == SelectedState )
+ {
+ Self().Insert( 0, mBackgroundContent );
+ }
+
+ OnBackgroundImageSet();
+}
+
Actor Button::GetBackgroundImage() const
{
return mBackgroundContent;
return mBackgroundContent;
}
+void Button::SetSelectedBackgroundImage( Actor image )
+{
+ StopAllAnimations();
+
+ if( mSelectedBackgroundContent && mSelectedBackgroundContent.GetParent() )
+ {
+ Self().Remove( mSelectedBackgroundContent );
+ }
+
+ mSelectedBackgroundContent = image;
+
+ mSelectedBackgroundContent.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ mSelectedBackgroundContent.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ mSelectedBackgroundContent.SetPosition( 0.f, 0.f );
+
+ if( mPaintState == SelectedState )
+ {
+ if( mBackgroundContent )
+ {
+ Self().Insert( 1, mSelectedBackgroundContent );
+ }
+ else
+ {
+ Self().Insert( 0, mSelectedBackgroundContent );
+ }
+ }
+
+ OnSelectedBackgroundImageSet();
+}
+
+Actor Button::GetSelectedBackgroundImage() const
+{
+ return mSelectedBackgroundContent;
+}
+
+Actor& Button::GetSelectedBackgroundImage()
+{
+ return mSelectedBackgroundContent;
+}
+
+void Button::SetDisabledImage( Actor image )
+{
+ StopAllAnimations();
+
+ if( mDisabledContent && mDisabledContent.GetParent() )
+ {
+ Self().Remove( mDisabledContent );
+ }
+
+ mDisabledContent = image;
+
+ mDisabledContent.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ mDisabledContent.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ mDisabledContent.SetPosition( 0.f, 0.f );
+
+ if( mPaintState == DisabledUnselectedState || mPaintState == DisabledSelectedState )
+ {
+ unsigned int index = FindChildIndex( mLabel );
+
+ Self().Insert( index, mDisabledContent );
+ }
+
+ OnDisabledImageSet();
+}
+
Actor Button::GetDisabledImage() const
{
return mDisabledContent;
return mDisabledContent;
}
+void Button::SetDisabledSelectedImage( Actor image )
+{
+ StopAllAnimations();
+
+ if( mDisabledSelectedContent && mDisabledSelectedContent.GetParent() )
+ {
+ Self().Remove( mDisabledSelectedContent );
+ }
+
+ mDisabledSelectedContent = image;
+
+ mDisabledSelectedContent.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ mDisabledSelectedContent.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ mDisabledSelectedContent.SetPosition( 0.f, 0.f );
+
+ if( mPaintState == DisabledSelectedState )
+ {
+ unsigned int index = FindChildIndex( mLabel );
+
+ Self().Insert( index, mDisabledSelectedContent );
+ }
+
+ OnDisabledSelectedImageSet();
+}
+
Actor Button::GetDisabledSelectedImage() const
{
return mDisabledSelectedContent;
return mDisabledSelectedContent;
}
+void Button::SetDisabledBackgroundImage( Actor image )
+{
+ StopAllAnimations();
+
+ if( mDisabledBackgroundContent && mDisabledBackgroundContent.GetParent() )
+ {
+ Self().Remove( mDisabledBackgroundContent );
+ }
+
+ mDisabledBackgroundContent = image;
+
+ mDisabledBackgroundContent.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ mDisabledBackgroundContent.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ mDisabledBackgroundContent.SetPosition( 0.f, 0.f );
+
+ if( mPaintState == DisabledUnselectedState || mPaintState == DisabledSelectedState )
+ {
+ Self().Insert( 0, mDisabledBackgroundContent );
+ }
+
+ OnDisabledBackgroundImageSet();
+}
+
Actor Button::GetDisabledBackgroundImage() const
{
return mDisabledBackgroundContent;
}
}
+void Button::UpdatePaintTransitionState()
+{
+ switch( mPaintState )
+ {
+ case UnselectedSelectedTransition:
+ {
+ RemoveChild( mButtonContent );
+ mPaintState = SelectedState;
+ break;
+ }
+ case SelectedUnselectedTransition:
+ {
+ RemoveChild( mSelectedBackgroundContent );
+ RemoveChild( mSelectedContent );
+ mPaintState = UnselectedState;
+ break;
+ }
+ case UnselectedDisabledTransition:
+ {
+ RemoveChild( mBackgroundContent );
+ RemoveChild( mButtonContent );
+ mPaintState = DisabledUnselectedState;
+ break;
+ }
+ case DisabledUnselectedTransition:
+ {
+ RemoveChild( mDisabledBackgroundContent );
+ RemoveChild( mDisabledContent );
+ mPaintState = UnselectedState;
+ break;
+ }
+ case SelectedDisabledTransition:
+ {
+ RemoveChild( mBackgroundContent );
+ RemoveChild( mSelectedBackgroundContent );
+ RemoveChild( mSelectedContent );
+ mPaintState = DisabledSelectedState;
+ break;
+ }
+ case DisabledSelectedTransition:
+ {
+ RemoveChild( mDisabledBackgroundContent );
+ RemoveChild( mDisabledSelectedContent );
+ mPaintState = SelectedState;
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+}
+
void Button::OnButtonStageDisconnection()
{
if( ButtonDown == mState )
{
if( !mTogglableButton )
{
- Toolkit::Button handle( GetOwner() );
-
- // Notifies the derived class the button has been released.
- OnReleased();
+ Released();
if( mAutoRepeating )
{
{
Toolkit::Button handle( GetOwner() );
- // Notifies the derived class the button has been pressed.
- OnPressed();
+ Pressed();
if( mAutoRepeating )
{
}
else
{
- // Notifies the derived class the button has been clicked.
- OnReleased();
- OnClicked();
+ Released();
if( mAutoRepeating )
{
{
Toolkit::Button handle( GetOwner() );
- // Notifies the derived class the button has been released.
- OnReleased();
+ Released();
if( mAutoRepeating )
{
OnButtonInitialize();
+ self.SetDrawMode( DrawMode::OVERLAY );
self.SetKeyboardFocusable( true );
}
DoClickAction( attributes );
}
+void Button::OnControlStageDisconnection()
+{
+ OnButtonStageDisconnection(); // Notification for derived classes.
+ mState = ButtonUp;
+}
+
void Button::OnTap(Actor actor, const TapGesture& tap)
{
// Do nothing.
// Restart the autorepeat timer.
SetUpTimer( mNextAutoRepeatingDelay );
- Toolkit::Button handle( GetOwner() );
+ Pressed();
- // Notifies the derived class the button has been pressed.
- OnPressed();
+ Toolkit::Button handle( GetOwner() );
//Emit signal.
consumed = mReleasedSignal.Emit( handle );
return consumed;
}
-void Button::OnControlStageDisconnection()
+void Button::Pressed()
{
- OnButtonStageDisconnection(); // Notification for derived classes.
- mState = ButtonUp;
+ unsigned int buttonIndex, backgroundIndex;
+ bool animationStarted = false;
+
+ switch( mPaintState )
+ {
+ case UnselectedState:
+ {
+ buttonIndex = FindChildIndex( mLabel );
+ InsertChild( buttonIndex, mSelectedContent );
+
+ if( mBackgroundContent )
+ {
+ backgroundIndex = 1;
+ }
+ else
+ {
+ backgroundIndex = 0;
+ }
+
+ InsertChild( backgroundIndex, mSelectedBackgroundContent );
+
+ // Notifies the derived class the button has been pressed.
+ animationStarted = OnPressed();
+
+ if( animationStarted )
+ {
+ mPaintState = UnselectedSelectedTransition;
+ }
+ else
+ {
+ mPaintState = SelectedState;
+ }
+ break;
+ }
+ case SelectedUnselectedTransition:
+ {
+ // Notifies the derived class the button has been pressed.
+ animationStarted = OnPressed();
+
+ if( animationStarted )
+ {
+ mPaintState = UnselectedSelectedTransition;
+ }
+ else
+ {
+ mPaintState = SelectedState;
+ }
+ break;
+ }
+ case DisabledUnselectedTransition:
+ {
+ buttonIndex = FindChildIndex( mLabel );
+ InsertChild( buttonIndex, mSelectedContent );
+
+ if( mDisabledBackgroundContent )
+ {
+ if( mBackgroundContent )
+ {
+ backgroundIndex = 2;
+ }
+ else
+ {
+ backgroundIndex = 1;
+ }
+ }
+ else if( mBackgroundContent )
+ {
+ backgroundIndex = 1;
+ }
+ else
+ {
+ backgroundIndex = 0;
+ }
+
+ InsertChild( backgroundIndex, mSelectedBackgroundContent );
+
+ // Notifies the derived class the button has been pressed.
+ animationStarted = OnPressed();
+
+ if( animationStarted )
+ {
+ mPaintState = UnselectedSelectedTransition;
+ }
+ else
+ {
+ mPaintState = SelectedState;
+ }
+ break;
+ }
+ default:
+ break;
+ }
+}
+
+void Button::Released()
+{
+ unsigned int buttonIndex;
+ bool animationStarted = false;
+
+ switch( mPaintState )
+ {
+ case SelectedState:
+ {
+ buttonIndex = FindChildIndex( mLabel );
+ InsertChild( buttonIndex, mButtonContent );
+
+ // Notifies the derived class the button has been released.
+ animationStarted = OnReleased();
+
+ if( animationStarted )
+ {
+ mPaintState = SelectedUnselectedTransition;
+ }
+ else
+ {
+ mPaintState = UnselectedState;
+ }
+ break;
+ }
+ case UnselectedSelectedTransition:
+ {
+ // Notifies the derived class the button has been released.
+ animationStarted = OnReleased();
+
+ if( animationStarted )
+ {
+ mPaintState = SelectedUnselectedTransition;
+ }
+ else
+ {
+ mPaintState = UnselectedState;
+ }
+ break;
+ }
+ case DisabledSelectedTransition:
+ {
+ buttonIndex = FindChildIndex( mLabel );
+ InsertChild( buttonIndex, mButtonContent );
+
+ // Notifies the derived class the button has been released.
+ animationStarted = OnReleased();
+
+ if( animationStarted )
+ {
+ mPaintState = SelectedUnselectedTransition;
+ }
+ else
+ {
+ mPaintState = UnselectedState;
+ }
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
}
Button::ButtonState Button::GetState()
return mState;
}
+Button::PaintState Button::GetPaintState()
+{
+ return mPaintState;
+}
+
+void Button::InsertChild( unsigned int index, Actor& actor )
+{
+ if( actor )
+ {
+ Self().Insert( index, actor);
+ }
+}
+
+void Button::RemoveChild( Actor& actor )
+{
+ if( actor && actor.GetParent() )
+ {
+ Self().Remove( actor );
+ }
+}
+
+unsigned int Button::FindChildIndex( Actor& actor )
+{
+ Actor self = Self();
+ unsigned int childrenNum = self.GetChildCount();
+
+ for( unsigned int i = 0; i < childrenNum; i++ )
+ {
+ Actor child = self.GetChildAt( i );
+ if( child == actor )
+ {
+ return i;
+ }
+ }
+
+ return childrenNum;
+}
+
void Button::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
{
Toolkit::Button button = Toolkit::Button::DownCast( Dali::BaseHandle( object ) );
Actor GetLabel() const;
/**
+ * @copydoc Dali::Toolkit::PushButton::SetButtonImage( Actor image )
+ */
+ void SetButtonImage( Actor image );
+
+ /**
* @copydoc Dali::Toolkit::PushButton::GetButtonImage()
*/
Actor GetButtonImage() const;
Actor& GetButtonImage();
/**
+ * @copydoc Dali::Toolkit::PushButton::SetSelectedImage( Actor image )
+ */
+ void SetSelectedImage( Actor image );
+
+ /**
* @copydoc Dali::Toolkit::PushButton::GetSelectedImage()
*/
Actor GetSelectedImage() const;
Actor& GetSelectedImage();
/**
+ * @copydoc Dali::Toolkit::PushButton::SetBackgroundImage( Actor image )
+ */
+ void SetBackgroundImage( Actor image );
+
+ /**
* @copydoc Dali::Toolkit::PushButton::GetBackgroundImage()
*/
Actor GetBackgroundImage() const;
Actor& GetBackgroundImage();
/**
+ * @copydoc Dali::Toolkit::PushButton::SetSelectedBackgroundImage( Actor image )
+ */
+ void SetSelectedBackgroundImage( Actor image );
+
+ /**
+ * @copydoc Dali::Toolkit::PushButton::GetSelectedBackgroundImage()
+ */
+ Actor GetSelectedBackgroundImage() const;
+
+ /**
+ * Internal use only.
+ * @return A reference to the selected background image.
+ */
+ Actor& GetSelectedBackgroundImage();
+
+ /**
+ * @copydoc Dali::Toolkit::PushButton::SetDisabledImage( Actor image )
+ */
+ void SetDisabledImage( Actor image );
+
+ /**
* @copydoc Dali::Toolkit::PushButton::GetDisabledImage()
*/
Actor GetDisabledImage() const;
Actor& GetDisabledImage();
/**
+ * @copydoc Dali::Toolkit::CheckBoxButton::SetDisabledSelectedImage( Actor image )
+ */
+ void SetDisabledSelectedImage( Actor image );
+
+ /**
* @copydoc Dali::Toolkit::CheckBoxButton::GetDisabledSelectedImage()
*/
Actor GetDisabledSelectedImage() const;
Actor& GetDisabledSelectedImage();
/**
+ * @copydoc Dali::Toolkit::PushButton::SetDisabledBackgroundImage( Actor image )
+ */
+ void SetDisabledBackgroundImage( Actor image );
+
+ /**
* @copydoc Dali::Toolkit::PushButton::GetDisabledBackgroundImage()
*/
Actor GetDisabledBackgroundImage() const;
*/
static bool DoAction( BaseObject* object, const std::string& actionName, const PropertyValueContainer& attributes );
+protected:
+
/**
- * @copydoc Dali::Toolkit::PushButton::SetButtonImage( Actor image )
+ * @return A reference to the label actor.
*/
- virtual void SetButtonImage( Actor image ) {}
+ Actor& GetLabel();
/**
- * @copydoc Dali::Toolkit::PushButton::SetSelectedImage( Actor image )
+ * It changes the transition state of the push button.
*/
- virtual void SetSelectedImage( Actor image ) {}
+ void UpdatePaintTransitionState();
+
+private:
/**
- * @copydoc Dali::Toolkit::PushButton::SetBackgroundImage( Actor image )
+ * Perform the click action to click the button.
+ * @param[in] attributes The attributes to perfrom this action.
*/
- virtual void SetBackgroundImage( Actor image ) {}
+ void DoClickAction( const PropertyValueContainer& attributes );
/**
- * @copydoc Dali::Toolkit::PushButton::SetDisabledImage( Actor image )
+ * This method is called after the button initialization.
+ * Could be reimplemented in subclasses to provide specific behaviour.
*/
- virtual void SetDisabledImage( Actor image ) {}
+ virtual void OnButtonInitialize() { }
/**
- * @copydoc Dali::Toolkit::CheckBoxButton::SetDisabledSelectedImage( Actor image )
+ * This method is called when the label is set.
*/
- virtual void SetDisabledSelectedImage( Actor image ) {}
+ virtual void OnLabelSet() {}
/**
- * @copydoc Dali::Toolkit::PushButton::SetDisabledBackgroundImage( Actor image )
+ * This method is called when the button image is set
*/
- virtual void SetDisabledBackgroundImage( Actor image ) {}
+ virtual void OnButtonImageSet() {}
-protected:
+ /**
+ * This method is called when the selected image is set
+ */
+ virtual void OnSelectedImageSet() {}
/**
- * Internal use only.
- * @return A reference to the label actor.
+ * This method is called when the background image is set
*/
- Actor& GetLabel();
+ virtual void OnBackgroundImageSet() {}
-private:
+ /**
+ * This method is called when the selected background image is set
+ */
+ virtual void OnSelectedBackgroundImageSet() {}
/**
- * Perform the click action to click the button.
- * @param[in] attributes The attributes to perfrom this action.
+ * This method is called when the disabled button image is set
*/
- void DoClickAction( const PropertyValueContainer& attributes );
+ virtual void OnDisabledImageSet() {}
/**
- * This method is called after the button initialization.
- * Could be reimplemented in subclasses to provide specific behaviour.
+ * This method is called when the disabled selected image is set
*/
- virtual void OnButtonInitialize() { }
+ virtual void OnDisabledSelectedImageSet() {}
+
+ /**
+ * This method is called when the disabled background image is set
+ */
+ virtual void OnDisabledBackgroundImageSet() {}
/**
* This method is called from the OnTouchEvent method when the button is down.
virtual void OnButtonStageDisconnection();
/**
- * This method is called when the label is set.
- */
- virtual void OnLabelSet() {}
-
- /**
* This method is called when the \e selected property is changed.
+ * @return true if the transition animation is started.
*/
- virtual void OnSelected( bool selected ) {}
+ virtual bool OnSelected() { return false; }
/**
* This method is called when the \e disabled property is changed.
+ * @return true if the transition animation is started.
*/
- virtual void OnDisabled( bool disabled ) {}
+ virtual bool OnDisabled() { return false; }
/**
* This method is called when the button is pressed.
+ * @return true if the transition animation is started.
*/
- virtual void OnPressed() {}
+ virtual bool OnPressed() { return false; }
/**
* This method is called when the button is released.
+ * @return true if the transition animation is started.
*/
- virtual void OnReleased() {}
+ virtual bool OnReleased() { return false; }
/**
- * This method is called when the button is clicked
+ * This method stops all animations
*/
- virtual void OnClicked() {}
+ virtual void StopAllAnimations() {}
public:
*/
bool AutoRepeatingSlot();
+ /**
+ * Sets the button as selected or unselected.
+ * @param[in] selected \e selected property value.
+ * @param[in] emitSignal Emit a signal if this value is \e true.
+ */
+ void SetSelected( bool selected, bool emitSignal );
+
+ /**
+ * This method is called when the button is pressed.
+ */
+ void Pressed();
+
+ /**
+ * This method is called when the button is released.
+ */
+ void Released();
+
protected:
enum ButtonState
DisabledUnselectedState, ///< The button is disabled and unselected.
DisabledSelectedState, ///< The button is disabled and selected.
UnselectedSelectedTransition, ///< The button is in transition from unselected to selected.
- SelectedUnselectedTransition, ///< The push button is in transition from selected to unselected.
+ SelectedUnselectedTransition, ///< The button is in transition from selected to unselected.
UnselectedDisabledTransition, ///< The button is in transition from unselected to disabled.
DisabledUnselectedTransition, ///< The button is in transition from disabled to unselected.
SelectedDisabledTransition, ///< The button is in transition from selected to disabled.
};
ButtonState GetState();
+ PaintState GetPaintState();
+
+ /**
+ * Inserts the actor to the button.
+ */
+ void InsertChild( unsigned int index, Actor& actor );
+
+ /**
+ * Removes the actor from the button.
+ */
+ void RemoveChild( Actor& actor );
+
+ /**
+ * Finds the index of the actor.
+ * If the actor doesn't exist, return the last index + 1.
+ */
+ unsigned int FindChildIndex( Actor& actor );
private:
Actor mButtonContent; ///< Stores the unselected content.
Actor mSelectedContent; ///< Stores the selected content.
Actor mBackgroundContent; ///< Stores the background content.
+ Actor mSelectedBackgroundContent; ///< Stores the selected background content.
Actor mDisabledContent; ///< Stores the disabled content.
Actor mDisabledSelectedContent; ///< Stores the disabled selected content.
Actor mDisabledBackgroundContent; ///< Stores the disabled background content.
bool mClickActionPerforming;
ButtonState mState; ///< Stores the button state.
+ PaintState mPaintState; ///< Stores the paint state.
};
} // namespace Internal
namespace
{
-const float FOREGROUND_DEPTH( 0.5f );
-const float BACKGROUND_DEPTH( 0.25f );
-
+const float DISTANCE_BETWEEN_IMAGE_AND_LABEL( 5.0f );
const float ANIMATION_TIME( 0.26f ); // EFL checkbox tick time
-const Vector3 DISTANCE_BETWEEN_IMAGE_AND_LABEL(5.0f, 0.0f, 0.0f);
-
BaseHandle Create()
{
return Toolkit::CheckBoxButton::New();
}
CheckBoxButton::CheckBoxButton()
-: Button(),
- mPaintState( UnselectedState )
+: Button()
{
SetTogglableButton( true );
CheckBoxButton::~CheckBoxButton()
{
- if( mCheckInAnimation )
+ if( mTransitionAnimation )
{
- mCheckInAnimation.Clear();
+ mTransitionAnimation.Clear();
}
}
Self().SetResizePolicy( FIT_TO_CHILDREN, ALL_DIMENSIONS );
}
-void CheckBoxButton::SetSelectedImage( Actor image )
-{
- Actor& selectedImage = GetSelectedImage();
-
- switch( mPaintState )
- {
- case SelectedState:
- {
- if( selectedImage && selectedImage.GetParent() )
- {
- Self().Remove( selectedImage );
- }
-
- selectedImage = image;
- Self().Add( selectedImage );
- break;
- }
- case UnselectedSelectedTransition:
- {
- StopCheckInAnimation();
- Self().Remove( selectedImage );
-
- selectedImage = image;
- Self().Add( selectedImage );
-
- mPaintState = SelectedState;
- break;
- }
- default:
- {
- selectedImage = image;
- break;
- }
- }
-
- selectedImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- selectedImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
- selectedImage.SetZ( FOREGROUND_DEPTH );
-}
-
-void CheckBoxButton::SetBackgroundImage( Actor image )
-{
- Actor& backgroundImage = GetBackgroundImage();
-
- switch( mPaintState )
- {
- case UnselectedState: // FALLTHROUGH
- case SelectedState:
- case UnselectedSelectedTransition:
- {
- if( backgroundImage && backgroundImage.GetParent() )
- {
- Self().Remove( backgroundImage );
-
- Actor& label = GetLabel();
-
- if( label )
- {
- backgroundImage.Remove( label );
- image.Add( label );
- }
- }
-
- backgroundImage = image;
- Self().Add( backgroundImage );
- break;
- }
- default:
- {
- backgroundImage = image;
- break;
- }
- }
-
- backgroundImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- backgroundImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
- backgroundImage.SetZ( BACKGROUND_DEPTH );
-}
-
-void CheckBoxButton::SetDisabledSelectedImage( Actor image )
-{
- Actor& disabledSelectedImage = GetDisabledSelectedImage();
-
- switch( mPaintState )
- {
- case DisabledSelectedState:
- {
- if( disabledSelectedImage && disabledSelectedImage.GetParent() )
- {
- Self().Remove( disabledSelectedImage );
- }
-
- disabledSelectedImage = image;
- Self().Add( disabledSelectedImage );
- break;
- }
- default:
- {
- disabledSelectedImage = image;
- break;
- }
- }
-
- disabledSelectedImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- disabledSelectedImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
- disabledSelectedImage.SetZ( FOREGROUND_DEPTH );
-}
-
-void CheckBoxButton::SetDisabledBackgroundImage( Actor image )
-{
- Actor& disabledBackgroundImage = GetDisabledBackgroundImage();
-
- switch( mPaintState )
- {
- case DisabledSelectedState:
- case DisabledUnselectedState:
- {
- if( disabledBackgroundImage && disabledBackgroundImage.GetParent() )
- {
- Self().Remove( disabledBackgroundImage );
-
- Actor& label = GetLabel();
-
- if( label )
- {
- disabledBackgroundImage.Remove( label );
- image.Add( label );
- }
- }
-
- disabledBackgroundImage = image;
- Self().Add( disabledBackgroundImage );
- break;
- }
- default:
- {
- disabledBackgroundImage = image;
- break;
- }
- }
-
- disabledBackgroundImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- disabledBackgroundImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
- disabledBackgroundImage.SetZ( BACKGROUND_DEPTH );
-}
-
void CheckBoxButton::OnLabelSet()
{
Actor& label = GetLabel();
if( label )
{
- label.SetParentOrigin( ParentOrigin::CENTER_RIGHT );
+ label.SetParentOrigin( ParentOrigin::CENTER_LEFT );
label.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
- label.TranslateBy( DISTANCE_BETWEEN_IMAGE_AND_LABEL );
if( IsDisabled() && GetDisabledBackgroundImage() )
{
- GetDisabledBackgroundImage().Add( label );
+ label.SetX( GetDisabledBackgroundImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
}
else if ( GetBackgroundImage() )
{
- GetBackgroundImage().Add( label );
+ label.SetX( GetBackgroundImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
}
else
{
- Self().Add( label );
+ label.SetX( DISTANCE_BETWEEN_IMAGE_AND_LABEL );
}
}
}
-void CheckBoxButton::OnSelected( bool selected )
+bool CheckBoxButton::OnSelected()
{
Actor& selectedImage = GetSelectedImage();
- switch( mPaintState )
+ PaintState paintState = GetPaintState();
+
+ switch( paintState )
{
case UnselectedState:
{
- AddChild( selectedImage );
- StartCheckInAnimation( selectedImage ); // Animate in the check actor
-
- mPaintState = UnselectedSelectedTransition;
+ StartTransitionAnimation( selectedImage );
break;
}
case SelectedState:
{
RemoveChild( selectedImage );
-
- mPaintState = UnselectedState;
break;
}
case UnselectedSelectedTransition:
{
- StopCheckInAnimation();
+ StopTransitionAnimation( false );
RemoveChild( selectedImage );
-
- mPaintState = UnselectedState;
break;
}
default:
+ {
break;
+ }
}
+
+ if( mTransitionAnimation )
+ {
+ return true;
+ }
+
+ return false;
}
-void CheckBoxButton::OnDisabled( bool disabled )
+bool CheckBoxButton::OnDisabled()
{
Actor& backgroundImage = GetBackgroundImage();
Actor& selectedImage = GetSelectedImage();
Actor& disabledBackgroundImage = GetDisabledBackgroundImage();
Actor& disabledSelectedImage = GetDisabledSelectedImage();
- switch( mPaintState )
+ PaintState paintState = GetPaintState();
+
+ switch( paintState )
{
case UnselectedState:
{
- if( disabled )
- {
- RemoveChild( backgroundImage );
- AddChild( disabledBackgroundImage );
- mPaintState = DisabledUnselectedState;
- }
+ RemoveChild( backgroundImage );
break;
}
case SelectedState:
{
- if( disabled )
- {
- RemoveChild( backgroundImage );
- RemoveChild( selectedImage );
- AddChild( disabledBackgroundImage );
- AddChild( disabledSelectedImage );
-
- mPaintState = DisabledSelectedState;
- }
+ RemoveChild( backgroundImage );
+ RemoveChild( selectedImage );
break;
}
case DisabledUnselectedState:
{
- if( !disabled )
- {
- RemoveChild( disabledBackgroundImage );
- AddChild( backgroundImage );
-
- mPaintState = UnselectedState;
- }
+ RemoveChild( disabledBackgroundImage );
break;
}
case DisabledSelectedState:
{
- if( !disabled )
- {
- RemoveChild( disabledBackgroundImage );
- RemoveChild( disabledSelectedImage );
- AddChild( backgroundImage );
- AddChild( selectedImage );
-
- mPaintState = SelectedState;
- }
+ RemoveChild( disabledBackgroundImage );
+ RemoveChild( disabledSelectedImage );
break;
}
case UnselectedSelectedTransition:
{
- if( disabled )
- {
- StopCheckInAnimation();
-
- RemoveChild( backgroundImage );
- RemoveChild( selectedImage );
- AddChild( disabledBackgroundImage );
- AddChild( disabledSelectedImage );
+ StopTransitionAnimation();
- mPaintState = DisabledSelectedState;
- }
+ RemoveChild( backgroundImage );
+ RemoveChild( selectedImage );
break;
}
default:
+ {
break;
+ }
}
Actor& label = GetLabel();
if( label )
{
- if( label.GetParent() )
+ if( IsDisabled() && disabledBackgroundImage)
{
- label.GetParent().Remove( label );
+ label.SetX( disabledBackgroundImage.GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
}
-
- if( disabled && disabledBackgroundImage)
+ else if( backgroundImage )
{
- disabledBackgroundImage.Add( label );
+ label.SetX( backgroundImage.GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
}
- else if( backgroundImage )
+ else
{
- backgroundImage.Add( label );
+ label.SetX( DISTANCE_BETWEEN_IMAGE_AND_LABEL );
}
}
-}
-void CheckBoxButton::AddChild( Actor& actor )
-{
- if( actor )
+ if( mTransitionAnimation )
{
- Self().Add( actor);
+ return true;
}
+
+ return false;
}
-void CheckBoxButton::RemoveChild( Actor& actor )
+void CheckBoxButton::StopAllAnimations()
{
- if( actor )
- {
- Self().Remove( actor );
- }
+ StopTransitionAnimation();
}
-void CheckBoxButton::StartCheckInAnimation( Actor& actor )
+void CheckBoxButton::StartTransitionAnimation( Actor& actor )
{
if( actor )
{
mTickUVEffect.SetBottomRight( Vector2( 0.0f, 1.0f ) );
- if( !mCheckInAnimation )
+ if( !mTransitionAnimation )
{
- mCheckInAnimation = Dali::Animation::New( GetAnimationTime() );
+ mTransitionAnimation = Dali::Animation::New( GetAnimationTime() );
}
// UV anim
- mCheckInAnimation.AnimateTo( Property( mTickUVEffect, mTickUVEffect.GetBottomRightPropertyName() ), Vector2( 1.0f, 1.0f ) );
+ mTransitionAnimation.AnimateTo( Property( mTickUVEffect, mTickUVEffect.GetBottomRightPropertyName() ), Vector2( 1.0f, 1.0f ) );
// Actor size anim
- mCheckInAnimation.AnimateTo( Property( actor, Actor::Property::SCALE_X ), 1.0f );
+ mTransitionAnimation.AnimateTo( Property( actor, Actor::Property::SCALE_X ), 1.0f );
- mCheckInAnimation.FinishedSignal().Connect( this, &CheckBoxButton::CheckInAnimationFinished );
- mCheckInAnimation.Play();
+ mTransitionAnimation.FinishedSignal().Connect( this, &CheckBoxButton::TransitionAnimationFinished );
+ mTransitionAnimation.Play();
}
}
-void CheckBoxButton::StopCheckInAnimation()
+void CheckBoxButton::StopTransitionAnimation( bool remove )
{
- if( mCheckInAnimation )
+ if( mTransitionAnimation )
{
- mCheckInAnimation.Clear();
- mCheckInAnimation.Reset();
+ mTransitionAnimation.Clear();
+ mTransitionAnimation.Reset();
}
-}
-void CheckBoxButton::CheckInAnimationFinished( Dali::Animation& source )
-{
- switch( mPaintState )
+ if( remove )
{
- case UnselectedSelectedTransition:
- {
- mPaintState = SelectedState;
- break;
- }
- default:
- {
- break;
- }
+ UpdatePaintTransitionState();
}
+}
- StopCheckInAnimation();
+void CheckBoxButton::TransitionAnimationFinished( Dali::Animation& source )
+{
+ StopTransitionAnimation();
}
} // namespace Internal
*/
static Dali::Toolkit::CheckBoxButton New();
-public: // From Button
-
- /**
- * @copydoc Toolkit::Internal::Button::SetSelectedImage( Actor image )
- */
- virtual void SetSelectedImage( Actor image );
-
- /**
- * @copydoc Toolkit::Internal::Button::SetBackgroundImage( Actor image )
- */
- virtual void SetBackgroundImage( Actor image );
+private:
/**
- * @copydoc Toolkit::Internal::Button::SetDisabledSelectedImage( Actor image )
+ * Construct a new CheckBoxButton.
*/
- virtual void SetDisabledSelectedImage( Actor image );
+ CheckBoxButton();
/**
- * @copydoc Toolkit::Internal::Button::SetDisabledBackgroundImage( Actor image )
+ * A reference counted object may only be deleted by calling Unreference()
*/
- virtual void SetDisabledBackgroundImage( Actor image );
+ virtual ~CheckBoxButton();
private: // From Button
/**
* @copydoc Toolkit::Internal::Button::OnSelected()
*/
- virtual void OnSelected( bool selected );
+ virtual bool OnSelected();
/**
- * @copydoc Toolkit::Internal::Button::OnDisabled( bool disabled )
+ * @copydoc Toolkit::Internal::Button::OnDisabled()
*/
- virtual void OnDisabled( bool disabled );
-
-private:
+ virtual bool OnDisabled();
/**
- * Construct a new CheckBoxButton.
+ * @copydoc Toolkit::Internal::Button::StopAllAnimations()
*/
- CheckBoxButton();
-
- /**
- * A reference counted object may only be deleted by calling Unreference()
- */
- virtual ~CheckBoxButton();
+ virtual void StopAllAnimations();
private:
/**
- * Adds the actor to the button.
- */
- void AddChild( Actor& actor );
-
- /**
- * Removes the actor from the button.
- */
- void RemoveChild( Actor& actor );
-
- /**
- * Adds the actor to the check in animation.
- * It creates a check in animation if needed and starts the check in animation.
+ * Adds the actor to the transition animation.
+ * It creates a transition animation if needed and starts the animation.
* @param[in] actor The actor.
*/
- void StartCheckInAnimation( Actor& actor );
+ void StartTransitionAnimation( Actor& actor );
/**
- * Stops the check in animation.
+ * Stops the transition animation.
+ * @param[in] remove If true, removes the fadeout actor from root.
*/
- void StopCheckInAnimation();
+ void StopTransitionAnimation( bool remove = true );
// slots
/**
- * Called when the check in animation finishes.
- * It changes the check button paint state.
+ * Called when the transition animation finishes.
*/
- void CheckInAnimationFinished( Dali::Animation& source );
+ void TransitionAnimationFinished( Dali::Animation& source );
private:
CheckBoxButton& operator=( const CheckBoxButton& );
private:
- Animation mCheckInAnimation; ///< Animation used in the state transitions.
- ImageRegionEffect mTickUVEffect; ///< ImageRegionEffect to expand the tick across
-
- PaintState mPaintState; ///< The paint state.
+ Animation mTransitionAnimation; ///< Animation used in the state transitions.
+ ImageRegionEffect mTickUVEffect; ///< ImageRegionEffect to expand the tick across
};
} // namespace Internal
{
const float TEXT_PADDING = 12.0f;
-
-const float LABEL_DEPTH( 0.75f );
-const float FOREGROUND_DEPTH( 0.5f );
-const float BACKGROUND_DEPTH( 0.25f );
-
const float ANIMATION_TIME( 0.2f );
BaseHandle Create()
PushButton::PushButton()
: Button(),
- mSize(),
- mPaintState( UnselectedState )
+ mSize()
{
SetAnimationTime( ANIMATION_TIME );
}
{
}
-void PushButton::SetButtonImage( Actor image )
+void PushButton::OnButtonInitialize()
{
- Actor& buttonImage = GetButtonImage();
- Actor& fadeOutButtonImage = GetFadeOutButtonImage();
-
- switch( mPaintState )
- {
- case UnselectedState:
- {
- if( buttonImage && buttonImage.GetParent() )
- {
- StopFadeOutAnimation();
- FadeOutImage( Foreground, buttonImage );
-
- buttonImage = image;
-
- FadeInImage( buttonImage, 0.0f, 0 );
-
- StartFadeOutAnimation();
- StartFadeInAnimation();
- }
- else
- {
- buttonImage = image;
- Self().Insert( 0, buttonImage );
- }
- break;
- }
- case UnselectedSelectedTransition: // FALLTHROUGH
- case UnselectedDisabledTransition:
- {
- float opacity = 1.f;
- if( fadeOutButtonImage )
- {
- opacity = fadeOutButtonImage.GetCurrentOpacity();
- }
- StopFadeOutAnimation();
-
- // Replaces the button image.
- buttonImage = image;
-
- Self().Insert( 0, buttonImage );
- FadeOutImage( Foreground, buttonImage, opacity );
-
- StartFadeOutAnimation();
- break;
- }
- case SelectedUnselectedTransition: // FALLTHROUGH
- case DisabledUnselectedTransition:
- {
- StopFadeInAnimation();
- Self().Remove( buttonImage );
-
- buttonImage = image;
-
- FadeInImage( buttonImage, 0.0f, 0 );
- StartFadeInAnimation();
- break;
- }
- default:
- buttonImage = image;
- break;
- }
+ // Push button requires the Leave event.
+ Actor self = Self();
+ self.SetLeaveRequired( true );
- buttonImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- buttonImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
- buttonImage.SetPosition( 0.f, 0.f, FOREGROUND_DEPTH );
- buttonImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
- buttonImage.SetName( "BUTTON_IMAGE" );
+ // Set resize policy to natural size so that buttons will resize to background images
+ self.SetResizePolicy( USE_NATURAL_SIZE, ALL_DIMENSIONS );
}
-void PushButton::SetSelectedImage( Actor image )
+void PushButton::OnLabelSet()
{
- Actor& selectedImage = GetSelectedImage();
- Actor& fadeOutButtonImage = GetFadeOutButtonImage();
+ Actor& label = GetLabel();
- switch( mPaintState )
+ if( label )
{
- case SelectedState:
- {
- if( selectedImage && selectedImage.GetParent() )
- {
- StopFadeOutAnimation();
- FadeOutImage( Foreground, selectedImage );
-
- selectedImage = image;
+ label.SetAnchorPoint( AnchorPoint::CENTER );
+ label.SetParentOrigin( ParentOrigin::CENTER );
+ label.SetSize( mSize );
+ }
+}
- FadeInImage( selectedImage, 0.0f, 0 );
+void PushButton::OnButtonImageSet()
+{
+ Actor& buttonImage = GetButtonImage();
- StartFadeOutAnimation();
- StartFadeInAnimation();
- }
- else
- {
- selectedImage = image;
- Self().Insert( 0, selectedImage );
- }
- break;
- }
- case SelectedUnselectedTransition: // FALLTHROUGH
- case SelectedDisabledTransition:
- {
- float opacity = 1.f;
- if( fadeOutButtonImage )
- {
- opacity = fadeOutButtonImage.GetCurrentOpacity();
- }
- StopFadeOutAnimation();
+ buttonImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
- // Replaces the button image.
- selectedImage = image;
+ buttonImage.RelayoutRequestTree();
- Self().Insert( 0, selectedImage );
- FadeOutImage( Foreground, selectedImage, opacity );
+ RelayoutRequest();
+}
- StartFadeOutAnimation();
- break;
- }
- case UnselectedSelectedTransition: // FALLTHROUGH
- case DisabledSelectedTransition:
- {
- StopFadeInAnimation();
- Self().Remove( selectedImage );
+void PushButton::OnSelectedImageSet()
+{
+ Actor& selectedImage = GetSelectedImage();
- selectedImage = image;
+ selectedImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
- FadeInImage( selectedImage, 0.0f, 0 );
- StartFadeInAnimation();
- break;
- }
- default:
- selectedImage = image;
- break;
- }
+ selectedImage.RelayoutRequestTree();
- selectedImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- selectedImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
- selectedImage.SetPosition( 0.f, 0.f, FOREGROUND_DEPTH );
- selectedImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
+ RelayoutRequest();
}
-void PushButton::SetBackgroundImage( Actor image )
+void PushButton::OnBackgroundImageSet()
{
Actor& backgroundImage = GetBackgroundImage();
- Actor& fadeOutBackgroundImage = GetFadeOutBackgroundImage();
- switch( mPaintState )
- {
- case UnselectedState: // FALLTHROUGH
- case SelectedState:
- case UnselectedSelectedTransition:
- case SelectedUnselectedTransition:
- {
- if( backgroundImage && backgroundImage.GetParent() )
- {
- StopFadeOutAnimation();
- FadeOutImage( Background, backgroundImage );
-
- backgroundImage = image;
-
- FadeInImage( backgroundImage, 0.0f, 0 );
-
- StartFadeOutAnimation();
- StartFadeInAnimation();
- }
- else
- {
- backgroundImage = image;
- Self().Insert( 0, backgroundImage );
- }
- break;
- }
- case UnselectedDisabledTransition: // FALLTHROUGH
- case SelectedDisabledTransition:
- {
- float opacity = 1.f;
- if( fadeOutBackgroundImage )
- {
- opacity = fadeOutBackgroundImage.GetCurrentOpacity();
- }
- StopFadeOutAnimation();
-
- // Replaces the button image.
- backgroundImage = image;
-
- Self().Insert( 0, backgroundImage );
- FadeOutImage( Background, backgroundImage, opacity );
+ backgroundImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
- StartFadeOutAnimation();
- break;
- }
- case DisabledUnselectedTransition: // FALLTHROUGH
- case DisabledSelectedTransition:
- {
- StopFadeInAnimation();
- Self().Remove( backgroundImage );
+ backgroundImage.RelayoutRequestTree();
- backgroundImage = image;
+ RelayoutRequest();
+}
- FadeInImage( backgroundImage, 0.0f, 0 );
- StartFadeInAnimation();
- break;
- }
- default:
- backgroundImage = image;
- break;
- }
+void PushButton::OnSelectedBackgroundImageSet()
+{
+ Actor& selectedBackgroundImage = GetSelectedBackgroundImage();
- backgroundImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- backgroundImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
- backgroundImage.SetPosition( 0.f, 0.f, BACKGROUND_DEPTH );
- backgroundImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
+ selectedBackgroundImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
}
-void PushButton::SetDisabledImage( Actor image )
+void PushButton::OnDisabledImageSet()
{
Actor& disabledImage = GetDisabledImage();
- Actor& fadeOutButtonImage = GetFadeOutButtonImage();
-
- switch( mPaintState )
- {
- case DisabledUnselectedState: // FALLTHROUGH
- case DisabledSelectedState:
- {
- if( disabledImage && disabledImage.GetParent() )
- {
- StopFadeOutAnimation();
- FadeOutImage( Foreground, disabledImage );
-
- disabledImage = image;
-
- FadeInImage( disabledImage, 0.0f, 0 );
-
- StartFadeOutAnimation();
- StartFadeInAnimation();
- }
- else
- {
- disabledImage = image;
- Self().Add( disabledImage );
- }
- break;
- }
- case UnselectedDisabledTransition: // FALLTHROUGH
- case SelectedDisabledTransition:
- {
- StopFadeInAnimation();
- Self().Remove( disabledImage );
-
- disabledImage = image;
-
- FadeInImage( disabledImage, 0.0f, 0 );
- StartFadeInAnimation();
- break;
- }
- case DisabledUnselectedTransition: // FALLTHROUGH
- case DisabledSelectedTransition:
- {
- float opacity = 1.f;
- if( fadeOutButtonImage )
- {
- opacity = fadeOutButtonImage.GetCurrentOpacity();
- }
- StopFadeOutAnimation();
-
- // Replaces the button image.
- disabledImage = image;
- Self().Add( disabledImage );
- FadeOutImage( Foreground, disabledImage, opacity );
+ disabledImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
- StartFadeOutAnimation();
- break;
- }
- default:
- disabledImage = image;
- break;
- }
+ disabledImage.RelayoutRequestTree();
- disabledImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- disabledImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
- disabledImage.SetPosition( 0.f, 0.f, FOREGROUND_DEPTH );
- disabledImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
+ RelayoutRequest();
}
-void PushButton::SetDisabledBackgroundImage( Actor image )
+void PushButton::OnDisabledBackgroundImageSet()
{
Actor& disabledBackgroundImage = GetDisabledBackgroundImage();
- Actor& fadeOutBackgroundImage = GetFadeOutBackgroundImage();
-
- switch( mPaintState )
- {
- case DisabledUnselectedState: // FALLTHROUGH
- case DisabledSelectedState:
- {
- if( disabledBackgroundImage && disabledBackgroundImage.GetParent() )
- {
- StopFadeOutAnimation();
- FadeOutImage( Background, disabledBackgroundImage );
- disabledBackgroundImage = image;
-
- FadeInImage( disabledBackgroundImage, 0.0f, 0 );
-
- StartFadeOutAnimation();
- StartFadeInAnimation();
- }
- else
- {
- disabledBackgroundImage = image;
- Self().Add( disabledBackgroundImage );
- }
- break;
- }
- case UnselectedDisabledTransition: // FALLTHROUGH
- case SelectedDisabledTransition:
- {
- StopFadeInAnimation();
- Self().Remove( disabledBackgroundImage );
-
- disabledBackgroundImage = image;
-
- FadeInImage( disabledBackgroundImage, 0.0f, 0 );
- StartFadeInAnimation();
- break;
- }
- case DisabledUnselectedTransition: // FALLTHROUGH
- case DisabledSelectedTransition:
- {
- float opacity = 1.f;
- if( fadeOutBackgroundImage )
- {
- opacity = fadeOutBackgroundImage.GetCurrentOpacity();
- }
- StopFadeOutAnimation();
-
- // Replaces the button image.
- disabledBackgroundImage = image;
-
- Self().Add( disabledBackgroundImage );
- FadeOutImage( Background, disabledBackgroundImage, opacity );
-
- StartFadeOutAnimation();
- break;
- }
- default:
- disabledBackgroundImage = image;
- break;
- }
-
- disabledBackgroundImage.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- disabledBackgroundImage.SetParentOrigin( ParentOrigin::TOP_LEFT );
- disabledBackgroundImage.SetPosition( 0.f, 0.f, BACKGROUND_DEPTH );
disabledBackgroundImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
-}
-
-void PushButton::OnButtonInitialize()
-{
- // Push button requires the Leave event.
- Actor root = Self();
- root.SetLeaveRequired( true );
-
- // Set resize policy to natural size so that buttons will resize to background images
- root.SetResizePolicy( USE_NATURAL_SIZE, ALL_DIMENSIONS );
-}
-
-void PushButton::OnLabelSet()
-{
- Actor& label = GetLabel();
- if( label )
- {
- label.SetAnchorPoint( AnchorPoint::CENTER );
- label.SetParentOrigin( ParentOrigin::CENTER );
- label.SetPosition( 0.f, 0.f, LABEL_DEPTH );
- label.SetSize( mSize );
+ disabledBackgroundImage.RelayoutRequestTree();
- Self().Add( label );
- }
+ RelayoutRequest();
}
-void PushButton::OnSelected( bool selected )
+bool PushButton::OnSelected()
{
- Actor& selectedImage = GetSelectedImage();
Actor& buttonImage = GetButtonImage();
- Actor& fadeOutButtonImage = GetFadeOutButtonImage();
+ Actor& selectedImage = GetSelectedImage();
+ Actor& selectedBackgroundImage = GetSelectedBackgroundImage();
- switch( mPaintState )
+ PaintState paintState = GetPaintState();
+
+ switch( paintState )
{
case UnselectedState:
{
- StopFadeOutAnimation();
- FadeOutImage( Foreground, buttonImage );
- FadeInImage( selectedImage, 0.0f, 0 );
- StartFadeOutAnimation();
- StartFadeInAnimation();
-
- if( buttonImage || selectedImage )
- {
- mPaintState = UnselectedSelectedTransition;
- }
- else
- {
- mPaintState = SelectedState;
- }
+ FadeOutImage( buttonImage );
+ FadeInImage( selectedBackgroundImage );
+ FadeInImage( selectedImage );
+ StartTransitionAnimation();
break;
}
case SelectedState:
{
- StopFadeOutAnimation();
- FadeOutImage( Foreground, selectedImage );
- FadeInImage( buttonImage, 0.0f, 0 );
- StartFadeOutAnimation();
- StartFadeInAnimation();
-
- if( buttonImage || selectedImage )
- {
- mPaintState = SelectedUnselectedTransition;
- }
- else
- {
- mPaintState = UnselectedState;
- }
+ FadeOutImage( selectedBackgroundImage );
+ FadeOutImage( selectedImage );
+ FadeInImage( buttonImage );
+ StartTransitionAnimation();
break;
}
case UnselectedSelectedTransition:
{
float opacity = 1.f;
- if( fadeOutButtonImage )
+ if( selectedImage )
{
- opacity = fadeOutButtonImage.GetCurrentOpacity();
+ opacity = selectedImage.GetCurrentOpacity();
}
- StopFadeOutAnimation( false );
- StopFadeInAnimation();
-
- FadeOutImage( Foreground, selectedImage, 1.f - opacity );
- FadeInImage( buttonImage, opacity, 0 );
- StartFadeOutAnimation();
- StartFadeInAnimation();
-
- if( buttonImage || selectedImage )
- {
- mPaintState = SelectedUnselectedTransition;
- }
- else
- {
- mPaintState = UnselectedState;
- }
+ StopTransitionAnimation( false );
+ FadeOutImage( selectedBackgroundImage, opacity );
+ FadeOutImage( selectedImage, opacity );
+ FadeInImage( buttonImage, 1.f - opacity );
+ StartTransitionAnimation();
break;
}
case SelectedUnselectedTransition:
{
float opacity = 0.f;
- if( fadeOutButtonImage )
+ if( selectedImage )
{
- opacity = 1.f - fadeOutButtonImage.GetCurrentOpacity();
+ opacity = selectedImage.GetCurrentOpacity();
}
- StopFadeOutAnimation( false );
- StopFadeInAnimation();
-
- FadeOutImage( Foreground, buttonImage, 1.f - opacity );
- FadeInImage( selectedImage, opacity, 0 );
- StartFadeOutAnimation();
- StartFadeInAnimation();
-
- if( buttonImage || selectedImage )
- {
- mPaintState = UnselectedSelectedTransition;
- }
- else
- {
- mPaintState = SelectedState;
- }
+ StopTransitionAnimation( false );
+ FadeOutImage( buttonImage, 1.f - opacity );
+ FadeInImage( selectedBackgroundImage, opacity );
+ FadeInImage( selectedImage, opacity );
+ StartTransitionAnimation();
+ break;
+ }
+ case DisabledUnselectedTransition:
+ {
+ StopTransitionAnimation();
+ FadeOutImage( buttonImage );
+ FadeInImage( selectedBackgroundImage );
+ FadeInImage( selectedImage );
+ StartTransitionAnimation();
+ break;
+ }
+ case DisabledSelectedTransition:
+ {
+ StopTransitionAnimation();
+ FadeOutImage( selectedBackgroundImage );
+ FadeOutImage( selectedImage );
+ FadeInImage( buttonImage );
+ StartTransitionAnimation();
break;
}
default:
break;
}
}
+
+ if( mTransitionAnimation )
+ {
+ return true;
+ }
+
+ return false;
}
-void PushButton::OnDisabled( bool disabled )
+bool PushButton::OnDisabled()
{
Actor& buttonImage = GetButtonImage();
Actor& selectedImage = GetSelectedImage();
+ Actor& selectedBackgroundImage = GetSelectedBackgroundImage();
Actor& backgroundImage = GetBackgroundImage();
Actor& disabledImage = GetDisabledImage();
+ Actor& disabledSelectedImage = GetDisabledSelectedImage();
Actor& disabledBackgroundImage = GetDisabledBackgroundImage();
- Actor& fadeOutButtonImage = GetFadeOutButtonImage();
- switch( mPaintState )
- {
- case UnselectedState:
+ PaintState paintState = GetPaintState();
+
+ switch( paintState )
{
- if( disabled )
+ case UnselectedState:
{
- StopFadeOutAnimation();
- FadeOutImage( Background, backgroundImage );
- FadeOutImage( Foreground, buttonImage );
- FadeInImage( disabledBackgroundImage, 0.0f, 0 );
- FadeInImage( disabledImage, 0.0f, 0 );
- StartFadeOutAnimation();
- StartFadeInAnimation();
-
- if( buttonImage || disabledImage || backgroundImage || disabledBackgroundImage )
- {
- mPaintState = UnselectedDisabledTransition;
- }
- else
- {
- mPaintState = DisabledUnselectedState;
- }
+ FadeOutImage( backgroundImage );
+ FadeOutImage( buttonImage );
+ FadeInImage( disabledBackgroundImage );
+ FadeInImage( disabledImage );
+ StartTransitionAnimation();
+ break;
}
- break;
- }
- case SelectedState:
- {
- if( disabled )
+ case SelectedState:
{
- StopFadeOutAnimation();
- FadeOutImage( Background, backgroundImage );
- FadeOutImage( Foreground, selectedImage );
- FadeInImage( disabledBackgroundImage, 0.0f, 0 );
- FadeInImage( disabledImage, 0.0f, 0 );
- StartFadeOutAnimation();
- StartFadeInAnimation();
-
- if( selectedImage || disabledImage || backgroundImage || disabledBackgroundImage )
- {
- mPaintState = SelectedDisabledTransition;
- }
- else
- {
- mPaintState = DisabledSelectedState;
- }
+ FadeOutImage( backgroundImage );
+ FadeOutImage( selectedBackgroundImage );
+ FadeOutImage( selectedImage );
+ FadeInImage( disabledBackgroundImage );
+ FadeInImage( disabledSelectedImage );
+ StartTransitionAnimation();
+ break;
}
- break;
- }
- case DisabledUnselectedState:
- {
- if( !disabled )
+ case DisabledUnselectedState:
{
- StopFadeOutAnimation();
- FadeOutImage( Background, disabledBackgroundImage );
- FadeOutImage( Foreground, disabledImage );
- FadeInImage( backgroundImage, 0.0f, 0 );
- FadeInImage( buttonImage, 0.0f, 0 );
- StartFadeOutAnimation();
- StartFadeInAnimation();
-
- if( buttonImage || disabledImage || backgroundImage || disabledBackgroundImage )
- {
- mPaintState = DisabledUnselectedTransition;
- }
- else
- {
- mPaintState = UnselectedState;
- }
+ FadeOutImage( disabledBackgroundImage );
+ FadeOutImage( disabledImage );
+ FadeInImage( backgroundImage );
+ FadeInImage( buttonImage );
+ StartTransitionAnimation();
+ break;
}
- break;
- }
- case DisabledSelectedState:
- {
- if( !disabled )
+ case DisabledSelectedState:
{
- StopFadeOutAnimation();
- FadeOutImage( Background, disabledBackgroundImage );
- FadeOutImage( Foreground, disabledImage );
- FadeInImage( backgroundImage, 0.0f, 0 );
- FadeInImage( selectedImage, 0.0f, 0 );
- StartFadeOutAnimation();
- StartFadeInAnimation();
-
- if( selectedImage || disabledImage || backgroundImage || disabledBackgroundImage )
- {
- mPaintState = DisabledSelectedTransition;
- }
- else
- {
- mPaintState = SelectedState;
- }
+ FadeOutImage( disabledBackgroundImage );
+ FadeOutImage( disabledSelectedImage );
+ FadeInImage( backgroundImage );
+ FadeInImage( selectedBackgroundImage );
+ FadeInImage( selectedImage );
+ StartTransitionAnimation();
+ break;
}
- break;
- }
- case UnselectedSelectedTransition:
- {
- if( disabled )
+ case UnselectedSelectedTransition:
{
float opacity = 1.f;
- if( fadeOutButtonImage )
+ if( selectedImage )
{
- opacity = fadeOutButtonImage.GetCurrentOpacity();
+ opacity = selectedImage.GetCurrentOpacity();
}
- StopFadeOutAnimation();
- StopFadeInAnimation();
-
- FadeOutImage( Foreground, selectedImage, 1.f - opacity );
- FadeOutImage( Background, backgroundImage );
-
- FadeInImage( disabledImage, 0.0f, 0 );
- FadeInImage( disabledBackgroundImage, 0.0f, 0 );
- StartFadeOutAnimation();
- StartFadeInAnimation();
-
- if( selectedImage || disabledImage || backgroundImage || disabledBackgroundImage )
- {
- mPaintState = SelectedDisabledTransition;
- }
- else
- {
- mPaintState = DisabledSelectedState;
- }
+ StopTransitionAnimation();
+ FadeOutImage( backgroundImage );
+ FadeOutImage( selectedBackgroundImage, opacity );
+ FadeOutImage( selectedImage, opacity );
+ FadeInImage( disabledBackgroundImage );
+ FadeInImage( disabledSelectedImage );
+ StartTransitionAnimation();
+ break;
}
- break;
- }
- case SelectedUnselectedTransition:
- {
- if( disabled )
+ case SelectedUnselectedTransition:
{
float opacity = 1.f;
- if( fadeOutButtonImage )
+ if( buttonImage )
{
- opacity = fadeOutButtonImage.GetCurrentOpacity();
+ opacity = buttonImage.GetCurrentOpacity();
}
- StopFadeOutAnimation();
- StopFadeInAnimation();
-
- FadeOutImage( Foreground, buttonImage, 1.f - opacity );
- FadeOutImage( Background, backgroundImage );
-
- FadeInImage( disabledImage, 0.0f, 0);
- FadeInImage( disabledBackgroundImage, 0.0f, 0 );
-
- StartFadeOutAnimation();
- StartFadeInAnimation();
- if( buttonImage || disabledImage || backgroundImage || disabledBackgroundImage )
- {
- mPaintState = UnselectedDisabledTransition;
- }
- else
- {
- mPaintState = DisabledUnselectedState;
- }
+ StopTransitionAnimation();
+ FadeOutImage( backgroundImage );
+ FadeOutImage( buttonImage, opacity );
+ FadeInImage( disabledBackgroundImage );
+ FadeInImage( disabledImage );
+ StartTransitionAnimation();
+ break;
}
- break;
- }
- case UnselectedDisabledTransition:
- {
- if( !disabled )
+ case UnselectedDisabledTransition:
{
float opacity = 1.f;
- if( fadeOutButtonImage )
+ if( disabledImage )
{
- opacity = fadeOutButtonImage.GetCurrentOpacity();
+ opacity = disabledImage.GetCurrentOpacity();
}
- StopFadeOutAnimation( false );
- StopFadeInAnimation();
- FadeOutImage( Foreground, disabledImage, 1.f - opacity );
- FadeOutImage( Background, disabledBackgroundImage, 1.f - opacity );
- FadeInImage( buttonImage, opacity, 0 );
- FadeInImage( backgroundImage, opacity, 0 );
-
- StartFadeOutAnimation();
- StartFadeInAnimation();
-
- if( buttonImage || disabledImage || backgroundImage || disabledBackgroundImage )
- {
- mPaintState = DisabledUnselectedTransition;
- }
- else
- {
- mPaintState = UnselectedState;
- }
+ StopTransitionAnimation( false );
+ FadeOutImage( disabledBackgroundImage, opacity );
+ FadeOutImage( disabledImage, opacity );
+ FadeInImage( backgroundImage, 1.f - opacity );
+ FadeInImage( buttonImage, 1.f - opacity );
+ StartTransitionAnimation();
+ break;
}
- break;
- }
- case DisabledUnselectedTransition:
- {
- if( disabled )
+ case DisabledUnselectedTransition:
{
float opacity = 1.f;
- if( fadeOutButtonImage )
+ if( buttonImage )
{
- opacity = fadeOutButtonImage.GetCurrentOpacity();
+ opacity = buttonImage.GetCurrentOpacity();
}
- StopFadeOutAnimation( false );
- StopFadeInAnimation();
-
- FadeOutImage( Foreground, buttonImage, 1.f - opacity );
- FadeOutImage( Background, backgroundImage, 1.f - opacity );
- FadeInImage( disabledImage, opacity, 0 );
- FadeInImage( disabledBackgroundImage, opacity, 0 );
-
- StartFadeOutAnimation();
- StartFadeInAnimation();
- if( buttonImage || disabledImage || backgroundImage || disabledBackgroundImage )
- {
- mPaintState = UnselectedDisabledTransition;
- }
- else
- {
- mPaintState = DisabledUnselectedState;
- }
+ StopTransitionAnimation( false );
+ FadeOutImage( backgroundImage, opacity );
+ FadeOutImage( buttonImage, opacity );
+ FadeInImage( disabledBackgroundImage, 1.f - opacity );
+ FadeInImage( disabledImage, 1.f - opacity );
+ StartTransitionAnimation();
+ break;
}
- break;
- }
- case SelectedDisabledTransition:
- {
- if( !disabled )
+ case SelectedDisabledTransition:
{
float opacity = 1.f;
- if( fadeOutButtonImage )
+ if( disabledSelectedImage )
{
- opacity = fadeOutButtonImage.GetCurrentOpacity();
+ opacity = disabledSelectedImage.GetCurrentOpacity();
}
- StopFadeOutAnimation( false );
- StopFadeInAnimation();
- FadeOutImage( Foreground, disabledImage, 1.f - opacity );
- FadeOutImage( Background, disabledBackgroundImage, 1.f - opacity );
- FadeInImage( selectedImage, opacity, 0 );
- FadeInImage( backgroundImage, opacity, 0 );
-
- StartFadeOutAnimation();
- StartFadeInAnimation();
-
- if( selectedImage || disabledImage || backgroundImage || disabledBackgroundImage )
- {
- mPaintState = DisabledSelectedTransition;
- }
- else
- {
- mPaintState = SelectedState;
- }
+ StopTransitionAnimation( false );
+ FadeOutImage( disabledBackgroundImage, opacity );
+ FadeOutImage( disabledSelectedImage, opacity );
+ FadeInImage( backgroundImage, 1.f - opacity );
+ FadeInImage( selectedBackgroundImage, 1.f - opacity );
+ FadeInImage( selectedImage, 1.f - opacity );
+ StartTransitionAnimation();
+ break;
}
- break;
- }
- case DisabledSelectedTransition:
- {
- if( disabled )
+ case DisabledSelectedTransition:
{
float opacity = 1.f;
- if( fadeOutButtonImage )
+ if( selectedImage )
{
- opacity = fadeOutButtonImage.GetCurrentOpacity();
+ opacity = selectedImage.GetCurrentOpacity();
}
- StopFadeOutAnimation( false );
- StopFadeInAnimation();
-
- FadeOutImage( Foreground, selectedImage, 1.f - opacity );
- FadeOutImage( Background, backgroundImage, 1.f - opacity );
- FadeInImage( disabledImage, opacity, 0 );
- FadeInImage( disabledBackgroundImage, opacity, 0 );
- StartFadeOutAnimation();
- StartFadeInAnimation();
-
- if( selectedImage || disabledImage || backgroundImage || disabledBackgroundImage )
- {
- mPaintState = SelectedDisabledTransition;
- }
- else
- {
- mPaintState = DisabledSelectedState;
- }
+ StopTransitionAnimation( false );
+ FadeOutImage( backgroundImage, opacity );
+ FadeOutImage( selectedBackgroundImage, opacity );
+ FadeOutImage( selectedImage, opacity );
+ FadeInImage( disabledBackgroundImage, 1.f - opacity );
+ FadeInImage( disabledSelectedImage, 1.f - opacity );
+ StartTransitionAnimation();
+ break;
}
- break;
}
- default:
- break;
+
+ if( mTransitionAnimation )
+ {
+ return true;
}
+
+ return false;
}
-void PushButton::OnPressed()
+bool PushButton::OnPressed()
{
- Actor& selectedImage = GetSelectedImage();
Actor& buttonImage = GetButtonImage();
- Actor& fadeOutButtonImage = GetFadeOutButtonImage();
+ Actor& selectedImage = GetSelectedImage();
+ Actor& selectedBackgroundImage = GetSelectedBackgroundImage();
+
+ PaintState paintState = GetPaintState();
- switch( mPaintState )
+ switch( paintState )
{
case UnselectedState:
{
- StopFadeOutAnimation();
- FadeOutImage( Foreground, buttonImage );
- FadeInImage( selectedImage, 0.0f, 0 );
- StartFadeOutAnimation();
- StartFadeInAnimation();
-
- if( buttonImage || selectedImage )
- {
- mPaintState = UnselectedSelectedTransition;
- }
- else
- {
- mPaintState = SelectedState;
- }
+ FadeOutImage( buttonImage );
+ FadeInImage( selectedBackgroundImage );
+ FadeInImage( selectedImage );
+ StartTransitionAnimation();
break;
}
- case UnselectedSelectedTransition:
+ case SelectedUnselectedTransition:
{
- if( !IsAutoRepeating() )
+ float opacity = 1.f;
+ if( buttonImage )
{
- mPaintState = SelectedUnselectedTransition;
+ opacity = buttonImage.GetCurrentOpacity();
}
+
+ StopTransitionAnimation( false );
+ FadeOutImage( buttonImage, opacity );
+ FadeInImage( selectedBackgroundImage, 1.f - opacity );
+ FadeInImage( selectedImage, 1.f - opacity );
+ StartTransitionAnimation();
break;
}
- case SelectedUnselectedTransition:
+ case DisabledUnselectedTransition:
{
float opacity = 1.f;
- if( fadeOutButtonImage )
+ if( buttonImage )
{
- opacity = fadeOutButtonImage.GetCurrentOpacity();
+ opacity = buttonImage.GetCurrentOpacity();
}
- StopFadeOutAnimation( false );
- StopFadeInAnimation();
-
- FadeOutImage( Foreground, buttonImage, 1.f - opacity );
- FadeInImage( selectedImage, opacity, 0 );
- StartFadeOutAnimation();
- StartFadeInAnimation();
-
- if( buttonImage || selectedImage )
- {
- mPaintState = UnselectedSelectedTransition;
- }
- else
- {
- mPaintState = SelectedState;
- }
+ StopTransitionAnimation();
+ FadeOutImage( buttonImage, opacity );
+ FadeInImage( selectedBackgroundImage );
+ FadeInImage( selectedImage );
+ StartTransitionAnimation();
break;
}
default:
break;
}
+
+ if( mTransitionAnimation )
+ {
+ return true;
+ }
+
+ return false;
}
-void PushButton::OnReleased()
+bool PushButton::OnReleased()
{
- Actor& selectedImage = GetSelectedImage();
Actor& buttonImage = GetButtonImage();
- Actor& fadeOutButtonImage = GetFadeOutButtonImage();
+ Actor& selectedImage = GetSelectedImage();
+ Actor& selectedBackgroundImage = GetSelectedBackgroundImage();
+
+ PaintState paintState = GetPaintState();
- switch( mPaintState )
+ switch( paintState )
{
case SelectedState:
{
- StopFadeOutAnimation();
- FadeOutImage( Foreground, selectedImage );
- FadeInImage( buttonImage, 0.0f, 0 );
- StartFadeOutAnimation();
- StartFadeInAnimation();
-
- if( buttonImage || selectedImage )
- {
- mPaintState = SelectedUnselectedTransition;
- }
- else
- {
- mPaintState = UnselectedState;
- }
+ FadeOutImage( selectedBackgroundImage );
+ FadeOutImage( selectedImage );
+ FadeInImage( buttonImage );
+ StartTransitionAnimation();
break;
}
case UnselectedSelectedTransition:
{
float opacity = 1.f;
- if( fadeOutButtonImage )
+ if( selectedImage )
{
- opacity = fadeOutButtonImage.GetCurrentOpacity();
+ opacity = selectedImage.GetCurrentOpacity();
}
- StopFadeOutAnimation( false );
- StopFadeInAnimation();
-
- FadeOutImage( Foreground, selectedImage, 1.f - opacity );
- FadeInImage( buttonImage, opacity, 0 );
- StartFadeOutAnimation();
- StartFadeInAnimation();
-
- if( buttonImage || selectedImage )
- {
- mPaintState = SelectedUnselectedTransition;
- }
- else
+ StopTransitionAnimation( false );
+ FadeOutImage( selectedBackgroundImage, opacity );
+ FadeOutImage( selectedImage, opacity );
+ FadeInImage( buttonImage, 1.f - opacity );
+ StartTransitionAnimation();
+ break;
+ }
+ case DisabledSelectedTransition:
+ {
+ float opacity = 1.f;
+ if( selectedImage )
{
- mPaintState = UnselectedState;
+ opacity = selectedImage.GetCurrentOpacity();
}
+
+ StopTransitionAnimation();
+ FadeOutImage( selectedBackgroundImage, opacity );
+ FadeOutImage( selectedImage, opacity );
+ FadeInImage( buttonImage );
+ StartTransitionAnimation();
break;
}
default:
break;
}
}
+
+ if( mTransitionAnimation )
+ {
+ return true;
+ }
+
+ return false;
}
-void PushButton::OnClicked()
+void PushButton::StopAllAnimations()
{
- OnReleased();
+ StopTransitionAnimation();
}
void PushButton::OnControlSizeSet( const Vector3& targetSize )
Vector3 PushButton::GetNaturalSize()
{
- Vector3 size = Control::GetNaturalSize();
-
- const bool widthIsZero = EqualsZero( size.width );
- const bool heightIsZero = EqualsZero( size.height );
-
- if( widthIsZero || heightIsZero )
- {
- // If background and background not scale9 try get size from that
- ImageActor imageActor = FindImageActor( GetButtonImage() );
- if( imageActor && imageActor.GetStyle() != ImageActor::STYLE_NINE_PATCH )
- {
- Vector3 imageSize = imageActor.GetNaturalSize();
-
- if( widthIsZero )
- {
- size.width = imageSize.width;
- }
-
- if( heightIsZero )
- {
- size.height = imageSize.height;
- }
- }
-
- ImageActor backgroundImageActor = FindImageActor( GetBackgroundImage() );
- if( backgroundImageActor && backgroundImageActor.GetStyle() != ImageActor::STYLE_NINE_PATCH )
- {
- Vector3 imageSize = backgroundImageActor.GetNaturalSize();
-
- if( widthIsZero )
- {
- size.width = std::max( size.width, imageSize.width );
- }
-
- if( heightIsZero )
- {
- size.height = std::max( size.height, imageSize.height );
- }
- }
-
- // If label, test against it's size
- Toolkit::TextLabel textLabel = Toolkit::TextLabel::DownCast( GetLabel() );
- if( textLabel )
- {
- Vector3 textLabelSize = textLabel.GetNaturalSize();
-
- if( widthIsZero )
- {
- size.width = std::max( size.width, textLabelSize.width + TEXT_PADDING * 2.0f );
- }
-
- if( heightIsZero )
- {
- size.height = std::max( size.height, textLabelSize.height + TEXT_PADDING * 2.0f );
- }
- }
- }
-
- return size;
-}
-
-Actor& PushButton::GetFadeOutButtonImage()
-{
- return mFadeOutButtonContent;
-}
+ Vector3 size;
-Actor& PushButton::GetFadeOutBackgroundImage()
-{
- return mFadeOutBackgroundContent;
-}
-
-void PushButton::AddToFadeInAnimation( const Actor& actor )
-{
- if( !mFadeInAnimation )
+ // If background and background not scale9 try get size from that
+ ImageActor imageActor = FindImageActor( GetButtonImage() );
+ if( imageActor && imageActor.GetStyle() != ImageActor::STYLE_NINE_PATCH )
{
- mFadeInAnimation = Dali::Animation::New( GetAnimationTime() );
+ size.width = imageActor.GetRelayoutSize( WIDTH );
+ size.height = imageActor.GetRelayoutSize( HEIGHT );
}
- mFadeInAnimation.OpacityTo( actor, 1.f );
-}
-
-void PushButton::StartFadeInAnimation()
-{
- if( mFadeInAnimation )
+ ImageActor backgroundImageActor = FindImageActor( GetBackgroundImage() );
+ if( backgroundImageActor && backgroundImageActor.GetStyle() != ImageActor::STYLE_NINE_PATCH )
{
- mFadeInAnimation.FinishedSignal().Connect( this, &PushButton::FadeInAnimationFinished );
- mFadeInAnimation.Play();
+ size.width = std::max( size.width, backgroundImageActor.GetRelayoutSize( WIDTH ) );
+ size.height = std::max( size.height, backgroundImageActor.GetRelayoutSize( HEIGHT ) );
}
-}
-void PushButton::StopFadeInAnimation()
-{
- if( mFadeInAnimation )
+ // If label, test against it's size
+ Toolkit::TextLabel label = Toolkit::TextLabel::DownCast( GetLabel() );
+ if( label )
{
- mFadeInAnimation.Clear();
- mFadeInAnimation.Reset();
- }
-}
+ Vector3 labelSize = label.GetNaturalSize();
-void PushButton::AddToFadeOutAnimation( const Actor& actor )
-{
- if( !mFadeOutAnimation )
- {
- mFadeOutAnimation = Dali::Animation::New( GetAnimationTime() );
+ size.width = std::max( size.width, labelSize.width + TEXT_PADDING * 2.0f );
+ size.height = std::max( size.height, labelSize.height + TEXT_PADDING * 2.0f );
}
- mFadeOutAnimation.OpacityTo( actor, 0.f );
+ return size;
}
-void PushButton::StartFadeOutAnimation()
+void PushButton::StartTransitionAnimation()
{
- if( mFadeOutAnimation )
+ if( mTransitionAnimation )
{
- mFadeOutAnimation.FinishedSignal().Connect( this, &PushButton::FadeOutAnimationFinished );
- mFadeOutAnimation.Play();
+ mTransitionAnimation.FinishedSignal().Connect( this, &PushButton::TransitionAnimationFinished );
+ mTransitionAnimation.Play();
}
}
-void PushButton::StopFadeOutAnimation( bool remove )
+void PushButton::StopTransitionAnimation( bool remove )
{
- if( mFadeOutAnimation )
+ if( mTransitionAnimation )
{
- mFadeOutAnimation.Clear();
- mFadeOutAnimation.Reset();
+ mTransitionAnimation.Clear();
+ mTransitionAnimation.Reset();
}
if( remove )
{
- Actor& fadeOutButtonImage = GetFadeOutButtonImage();
- Actor& fadeOutBackgroundImage = GetFadeOutBackgroundImage();
-
- if( fadeOutButtonImage && fadeOutButtonImage.GetParent() )
- {
- fadeOutButtonImage.GetParent().Remove( fadeOutButtonImage );
- }
-
- if( fadeOutBackgroundImage && fadeOutBackgroundImage.GetParent() )
- {
- fadeOutBackgroundImage.GetParent().Remove( fadeOutBackgroundImage );
- }
-
- fadeOutButtonImage.Reset();
- fadeOutBackgroundImage.Reset();
+ UpdatePaintTransitionState();
}
}
-void PushButton::FadeInImage( Actor& image, float opacity, int priority )
+void PushButton::FadeInImage( Actor& image, float opacity, Vector3 scale )
{
if( image )
{
image.SetOpacity( opacity );
- if( !image.GetParent() )
+ image.SetScale( scale );
+
+ if( !mTransitionAnimation )
{
- if( priority > -1 )
- {
- Self().Insert( priority, image );
- }
- else
- {
- Self().Add( image );
- }
+ mTransitionAnimation = Dali::Animation::New( GetAnimationTime() );
}
- AddToFadeInAnimation( image );
+ mTransitionAnimation.AnimateTo( Property( image, Actor::Property::COLOR_ALPHA ), 1.f );
}
}
-void PushButton::FadeOutImage( ImageLayer layer, Actor& image, float opacity )
+void PushButton::FadeOutImage( Actor& image, float opacity, Vector3 scale )
{
if( image )
{
- Actor& fadeOutButtonImage = GetFadeOutButtonImage();
- Actor& fadeOutBackgroundImage = GetFadeOutBackgroundImage();
-
- Actor& actorLayer = ( ( Background == layer ) ? fadeOutBackgroundImage : fadeOutButtonImage );
-
- actorLayer = image;
- actorLayer.SetOpacity( opacity );
-
- AddToFadeOutAnimation( actorLayer );
- }
-}
+ image.SetOpacity( opacity );
+ image.SetScale( scale );
-void PushButton::FadeOutAnimationFinished( Dali::Animation& source )
-{
- switch( mPaintState )
- {
- case UnselectedSelectedTransition:
- {
- mPaintState = SelectedState;
- break;
- }
- case SelectedUnselectedTransition:
- {
- mPaintState = UnselectedState;
- break;
- }
- case UnselectedDisabledTransition:
- {
- mPaintState = DisabledUnselectedState;
- break;
- }
- case DisabledUnselectedTransition:
- {
- mPaintState = UnselectedState;
- break;
- }
- case SelectedDisabledTransition:
- {
- mPaintState = DisabledSelectedState;
- break;
- }
- case DisabledSelectedTransition:
- {
- mPaintState = SelectedState;
- break;
- }
- default:
+ if( !mTransitionAnimation )
{
- break;
+ mTransitionAnimation = Dali::Animation::New( GetAnimationTime() );
}
- }
- StopFadeOutAnimation();
+ mTransitionAnimation.AnimateTo( Property( image, Actor::Property::COLOR_ALPHA ), 0.f );
+ }
}
-void PushButton::FadeInAnimationFinished( Dali::Animation& source )
+void PushButton::TransitionAnimationFinished( Dali::Animation& source )
{
- switch( mPaintState )
- {
- case UnselectedSelectedTransition:
- {
- mPaintState = SelectedState;
- break;
- }
- case SelectedUnselectedTransition:
- {
- mPaintState = UnselectedState;
- break;
- }
- case UnselectedDisabledTransition:
- {
- mPaintState = DisabledUnselectedState;
- break;
- }
- case DisabledUnselectedTransition:
- {
- mPaintState = UnselectedState;
- break;
- }
- case SelectedDisabledTransition:
- {
- mPaintState = DisabledSelectedState;
- break;
- }
- case DisabledSelectedTransition:
- {
- mPaintState = SelectedState;
- break;
- }
- default:
- {
- break;
- }
- }
-
- StopFadeInAnimation();
+ StopTransitionAnimation();
}
} // namespace Internal
*/
virtual ~PushButton();
-public: // From Button
+private: // From Button
/**
- * @copydoc Toolkit::Internal::Button::SetButtonImage( Actor image )
+ * @copydoc Toolkit::Internal::Button::OnButtonInitialize()
*/
- virtual void SetButtonImage( Actor image );
+ virtual void OnButtonInitialize();
/**
- * @copydoc Toolkit::Internal::Button::SetSelectedImage( Actor image )
+ * @copydoc Toolkit::Internal::Button::OnLabelSet()
*/
- virtual void SetSelectedImage( Actor image );
+ virtual void OnLabelSet();
/**
- * @copydoc Toolkit::Internal::Button::SetBackgroundImage( Actor image )
+ * @copydoc Toolkit::Internal::Button::OnButtonImageSet()
*/
- virtual void SetBackgroundImage( Actor image );
+ virtual void OnButtonImageSet();
/**
- * @copydoc Toolkit::Internal::Button::SetDisabledImage( Actor image )
+ * @copydoc Toolkit::Internal::Button::OnSelectedImageSet()
*/
- virtual void SetDisabledImage( Actor image );
+ virtual void OnSelectedImageSet();
/**
- * @copydoc Toolkit::Internal::Button::SetDisabledBackgroundImage( Actor image )
+ * @copydoc Toolkit::Internal::Button::OnBackgroundImage()
*/
- virtual void SetDisabledBackgroundImage( Actor image );
+ virtual void OnBackgroundImageSet();
-private: // From Button
+ /**
+ * @copydoc Toolkit::Internal::Button::OnSelectedBackgroundImageSet()
+ */
+ virtual void OnSelectedBackgroundImageSet();
/**
- * @copydoc Toolkit::Internal::Button::OnButtonInitialize()
+ * @copydoc Toolkit::Internal::Button::OnDisabledImageSet()
*/
- virtual void OnButtonInitialize();
+ virtual void OnDisabledImageSet();
/**
- * @copydoc Toolkit::Internal::Button::OnLabelSet()
+ * @copydoc Toolkit::Internal::Button::OnDisabledBackgroundImageSet()
*/
- virtual void OnLabelSet();
+ virtual void OnDisabledBackgroundImageSet();
/**
* @copydoc Toolkit::Internal::Button::OnSelected()
*/
- virtual void OnSelected( bool selected );
+ virtual bool OnSelected();
/**
- * @copydoc Toolkit::Internal::Button::OnDisabled( bool disabled )
+ * @copydoc Toolkit::Internal::Button::OnDisabled()
*/
- virtual void OnDisabled( bool disabled );
+ virtual bool OnDisabled();
/**
* @copydoc Toolkit::Internal::Button::OnPressed()
*/
- virtual void OnPressed();
+ virtual bool OnPressed();
/**
* @copydoc Toolkit::Internal::Button::OnReleased()
*/
- virtual void OnReleased();
+ virtual bool OnReleased();
/**
- * @copydoc Toolkit::Internal::Button::OnClicked()
+ * @copydoc Toolkit::Internal::Button::StopAllAnimations()
*/
- virtual void OnClicked();
+ virtual void StopAllAnimations();
private: // From Control
private:
/**
- * Used in the FadeOut functions.
- */
- enum ImageLayer
- {
- Background, ///< Fade out the background.
- Foreground ///< Fade out the foreground.
- };
-
- /**
- * Gets the button image that is fading out.
- * @return A reference to the button image that is fading out.
+ * Starts the transition animation.
+ * PushButton::TransitionAnimationFinished slot is called when the animation finishes.
*/
- Actor& GetFadeOutButtonImage();
+ void StartTransitionAnimation();
/**
- * Gets the background image that is fading out.
- * @return A reference to the background image that is fading out.
- */
- Actor& GetFadeOutBackgroundImage();
-
- /**
- * Adds the actor to the fade in animation. It creates a fade in animation if needed.
- * @param[in] actor The actor.
- */
- void AddToFadeInAnimation( const Actor& actor );
-
- /**
- * Starts the fade in animation.
- * PushButton::FadeInAnimationFinished slot is called when the animation finishes.
- */
- void StartFadeInAnimation();
-
- /**
- * Stops the fade in animation.
- */
- void StopFadeInAnimation();
-
- /**
- * Adds the actor to the fade out animation. It creates a fade out animation if needed.
- */
- void AddToFadeOutAnimation( const Actor& actor );
-
- /**
- * Starts the fade out animation.
- * PushButton::FadeOutAnimationFinished slot is called when the animation finishes.
- */
- void StartFadeOutAnimation();
-
- /**
- * Stops the fade out animation.
- * It removes the actor stored in PushButton::mFadeOutBackgroundImage and PushButton::mFadeOutCheckedImage.
+ * Stops the transition animation.
* @param[in] remove If true, removes the fadeout actor from root.
*/
- void StopFadeOutAnimation( bool remove = true );
+ void StopTransitionAnimation( bool remove = true );
/**
* It adds the actor to the root actor and to the fade in animation.
* @param[inout] image The actor.
* @param[in] opacity The initial opacity.
+ * @param[in] scale The initial scale.
*/
- void FadeInImage( Actor& image, float opacity = 0.f, int priority = -1 );
+ void FadeInImage( Actor& image, float opacity = 0.f, Vector3 scale = Vector3( 1.f, 1.f, 1.f ) );
/**
* It adds the actor fade out animation and stores it to be removed when the animation finishes.
* @param[in] layer Defines if the actor is going to be stored in the mFadeOutBackgroundImage or mFadeOutCheckedImage member.
* @param[inout] image The actor.
* @param[in] opacity The initial opacity.
+ * @param[in] scale The initial scale.
*/
- void FadeOutImage( ImageLayer layer, Actor& image, float opacity = 1.f );
+ void FadeOutImage( Actor& image, float opacity = 1.f, Vector3 scale = Vector3( 1.f, 1.f, 1.f ) );
// slots
/**
- * Called when the fade out animation finishes.
- * It changes the check button paint state and removes actors from the root.
+ * Called when the transition animation finishes.
*/
- void FadeOutAnimationFinished( Dali::Animation& source );
-
- /**
- * Called when the fade in animation finishes.
- * It changes the check button paint state.
- */
- void FadeInAnimationFinished( Dali::Animation& source );
+ void TransitionAnimationFinished( Dali::Animation& source );
private:
private:
- Animation mFadeInAnimation; ///< Animation used in the state transitions.
- Animation mFadeOutAnimation; ///< Animation used in the state transitions.
-
- Actor mFadeOutButtonContent; ///< Stores a foreground content, which is in a fade out animation, to be removed when the animation finishes.
- Actor mFadeOutBackgroundContent; ///< Stores a background content, which is in a fade out animation, to be removed when the animation finishes.
-
+ Animation mTransitionAnimation; ///< Animation used in the state transitions.
Vector3 mSize; ///< The button's size.
-
- PaintState mPaintState; ///< The paint state.
};
} // namespace Internal
const char* const UNSELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "radio-button-unselected.png";
const char* const SELECTED_BUTTON_IMAGE_DIR = DALI_IMAGE_DIR "radio-button-selected.png";
-const float DISTANCE_BETWEEN_IMAGE_AND_LABEL = 5.0f;
+const float DISTANCE_BETWEEN_IMAGE_AND_LABEL( 5.0f );
}
Dali::Toolkit::RadioButton RadioButton::New()
{
}
-void RadioButton::SetImage( Actor image )
-{
- mLayoutContainer.RemoveChildAt( Toolkit::TableView::CellPosition( 0, 0 ) );
- mLayoutContainer.AddChild( image, Toolkit::TableView::CellPosition( 0, 0 ) );
-
- RelayoutRequest();
-}
-
-void RadioButton::SetButtonImage( Actor image )
-{
- Actor& buttonImage = GetButtonImage();
- buttonImage = image;
-}
-
-void RadioButton::SetSelectedImage( Actor image )
-{
- Actor& selectedImage = GetSelectedImage();
- selectedImage = image;
-}
-
void RadioButton::OnButtonInitialize()
{
Actor self = Self();
// Wrap size of radio button around all its children
self.SetResizePolicy( FIT_TO_CHILDREN, ALL_DIMENSIONS );
- // Create the layout container empty at first
- mLayoutContainer = Toolkit::TableView::New( 0, 0 );
- mLayoutContainer.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- mLayoutContainer.SetParentOrigin( ParentOrigin::TOP_LEFT );
- mLayoutContainer.SetResizePolicy( FIT_TO_CHILDREN, ALL_DIMENSIONS );
- self.Add( mLayoutContainer );
-
Image buttonImage = Dali::ResourceImage::New( UNSELECTED_BUTTON_IMAGE_DIR );
Image selectedImage = Dali::ResourceImage::New( SELECTED_BUTTON_IMAGE_DIR );
SetButtonImage( ImageActor::New( buttonImage ) );
SetSelectedImage( ImageActor::New( selectedImage ) );
- SetImage( GetButtonImage() );
-
RelayoutRequest();
}
if( label )
{
- // Add padding to the left of the label to create distance from the image
- label.SetPadding( Padding( DISTANCE_BETWEEN_IMAGE_AND_LABEL, 0.0f, 0.0f, 0.0f ) );
+ label.SetParentOrigin( ParentOrigin::CENTER_LEFT );
+ label.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
- mLayoutContainer.RemoveChildAt( Toolkit::TableView::CellPosition( 0, 1 ) );
- mLayoutContainer.AddChild( label, Toolkit::TableView::CellPosition( 0, 1 ) );
+ if( IsSelected() )
+ {
+ label.SetX( GetSelectedImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
+ }
+ else
+ {
+ label.SetX( GetButtonImage().GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
+ }
}
}
-void RadioButton::OnSelected( bool selected )
+bool RadioButton::OnSelected()
{
- if( selected )
+ Actor& buttonImage = GetButtonImage();
+ Actor& selectedImage = GetSelectedImage();
+ Actor& label = GetLabel();
+
+ PaintState paintState = GetPaintState();
+
+ switch( paintState )
{
- Actor parent = Self().GetParent();
- if( parent )
+ case UnselectedState:
{
- for( unsigned int i = 0; i < parent.GetChildCount(); ++i )
+ Actor parent = Self().GetParent();
+ if( parent )
{
- Dali::Toolkit::RadioButton radioButtonChild = Dali::Toolkit::RadioButton::DownCast( parent.GetChildAt( i ) );
- if( radioButtonChild )
+ for( unsigned int i = 0; i < parent.GetChildCount(); ++i )
{
- radioButtonChild.SetSelected( false );
+ Dali::Toolkit::RadioButton radioButtonChild = Dali::Toolkit::RadioButton::DownCast( parent.GetChildAt( i ) );
+ if( radioButtonChild && radioButtonChild != Self() )
+ {
+ radioButtonChild.SetSelected( false );
+ }
}
}
+
+ RemoveChild( buttonImage );
+
+ if( label )
+ {
+ label.SetX( selectedImage.GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
+ }
+ break;
}
+ case SelectedState:
+ {
+ RemoveChild( selectedImage );
- SetImage( GetSelectedImage() );
- }
- else
- {
- SetImage( GetButtonImage() );
+ if( label )
+ {
+ label.SetX( buttonImage.GetNaturalSize().width + DISTANCE_BETWEEN_IMAGE_AND_LABEL );
+ }
+ break;
+ }
+ default:
+ {
+ break;
+ }
}
+
+ // there is no animation
+ return false;
}
} // namespace Internal
/**
* Create a new RadioButton.
*
- * @return A smart-pointer to the newly allocated PushButton.
+ * @return A smart-pointer to the newly allocated RadioButton.
*/
static Dali::Toolkit::RadioButton New();
- /**
- * Construct a new PushButton.
- */
- RadioButton();
-
- /**
- * Construct a new PushButton with label.
- */
- RadioButton( const std::string& label );
+private:
/**
- * Construct a new PushButton with label.
+ * Construct a new RadioButton.
*/
- RadioButton( Actor label );
+ RadioButton();
/**
* A reference counted object may only be deleted by calling Unreference()
*/
virtual ~RadioButton();
-public: // From Button
-
- /**
- * @copydoc Toolkit::Internal::Button::SetButtonImage( Actor image )
- */
- virtual void SetButtonImage( Actor image );
-
- /**
- * @copydoc Toolkit::Internal::Button::SetSelectedImage( Actor image )
- */
- virtual void SetSelectedImage( Actor image );
-
private: // From Button
/**
/**
* @copydoc Toolkit::Internal::Button::OnSelected()
*/
- virtual void OnSelected( bool selected );
+ virtual bool OnSelected();
/**
* @copydoc Toolkit::Internal::Button::OnLabelSet()
private:
- /**
- * @brief Set the image to display
- *
- * @param[in] image The image to set
- */
- void SetImage( Actor image );
-
-private:
-
// Undefined
RadioButton( const RadioButton& origin );
// Undefined
RadioButton& operator=( const RadioButton& origin );
-
-private:
-
- Toolkit::TableView mLayoutContainer; ///< Container to position button images and labels
-
};
} // namespace Internal
if( animationDuration > 0.f )
{
Animation animation = Animation::New(animationDuration);
- animation.MoveTo( actor, position, alpha, durationSeconds.delaySeconds, durationSeconds.durationSeconds );
- animation.Resize( actor, size, alpha, durationSeconds.delaySeconds, durationSeconds.durationSeconds );
+ animation.AnimateTo( Property( actor, Actor::Property::POSITION ), position, alpha, TimePeriod( durationSeconds.delaySeconds, durationSeconds.durationSeconds ) );
+ animation.AnimateTo( Property( actor, Actor::Property::SIZE ), size, alpha, TimePeriod( durationSeconds.delaySeconds, durationSeconds.durationSeconds ) );
animation.Play();
}
else
if( animationDuration > 0.f )
{
Animation animation = Animation::New(animationDuration);
- animation.MoveTo( actor, position, alpha, durationSeconds.delaySeconds, durationSeconds.durationSeconds );
- animation.Resize( actor, size, alpha, durationSeconds.delaySeconds, durationSeconds.durationSeconds );
- animation.RotateTo( actor, rotation, alpha, durationSeconds.delaySeconds, durationSeconds.durationSeconds );
- animation.ScaleTo( actor, scale, alpha, durationSeconds.delaySeconds, durationSeconds.durationSeconds );
+ animation.AnimateTo( Property( actor, Actor::Property::POSITION ), position, alpha, TimePeriod( durationSeconds.delaySeconds, durationSeconds.durationSeconds ) );
+ animation.AnimateTo( Property( actor, Actor::Property::SIZE ), size, alpha, TimePeriod( durationSeconds.delaySeconds, durationSeconds.durationSeconds ) );
+ animation.AnimateTo( Property( actor, Actor::Property::ORIENTATION ), rotation, alpha, TimePeriod( durationSeconds.delaySeconds, durationSeconds.durationSeconds ) );
+ animation.AnimateTo( Property( actor, Actor::Property::SCALE ), scale, alpha, TimePeriod( durationSeconds.delaySeconds, durationSeconds.durationSeconds ) );
animation.Play();
}
else
}
}
+ Actor self = Self();
Animation animation = Animation::New( mOrientationAnimationDuration );
- animation.RotateTo( Self(), Degree( -angle ), Vector3::ZAXIS, mOrientationAnimationAlphaFunc );
+ animation.AnimateTo( Property( self, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree( -angle ) ), Vector3::ZAXIS ), mOrientationAnimationAlphaFunc );
animation.Play();
- Self().SetSize( targetSize );
+ self.SetSize( targetSize );
RelayoutRequest();
}
// OnDialogTouched only consume the event. It prevents the touch event to be caught by the backing.
mBackgroundImage.TouchedSignal().Connect( this, &Popup::OnDialogTouched );
- mBackgroundImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
+ mBackgroundImage.SetResizePolicy( SIZE_FIXED_OFFSET_FROM_PARENT, ALL_DIMENSIONS );
mBackgroundImage.SetAnchorPoint( AnchorPoint::CENTER );
mBackgroundImage.SetParentOrigin( ParentOrigin::CENTER );
- mBackgroundImage.SetSizeMode( SIZE_FIXED_OFFSET_FROM_PARENT );
Vector3 border( mPopupStyle->backgroundOuterBorder.x, mPopupStyle->backgroundOuterBorder.z, 0.0f );
mBackgroundImage.SetSizeModeFactor( border );
{
mTitle.SetPadding( Padding( 0.0f, 0.0f, mPopupStyle->margin, mPopupStyle->margin ) );
mTitle.SetResizePolicy( FILL_TO_PARENT, WIDTH );
- mTitle.SetDimensionDependency( HEIGHT, WIDTH ); // HeightForWidth
+ mTitle.SetResizePolicy( DIMENSION_DEPENDENCY, HEIGHT );
mPopupLayout.AddChild( mTitle, Toolkit::TableView::CellPosition( 0, 0 ) );
}
void ScrollBar::Show()
{
+ Actor self = Self();
+
// Cancel any animation
if(mAnimation)
{
if(mIndicatorShowDuration > 0.0f)
{
mAnimation = Animation::New( mIndicatorShowDuration );
- mAnimation.OpacityTo( Self(), 1.0f, AlphaFunctions::EaseIn );
+ mAnimation.AnimateTo( Property( self, Actor::Property::COLOR_ALPHA ), 1.0f, AlphaFunctions::EaseIn );
mAnimation.Play();
}
else
{
- Self().SetOpacity(1.0f);
+ self.SetOpacity(1.0f);
}
}
void ScrollBar::Hide()
{
+ Actor self = Self();
+
// Cancel any animation
if(mAnimation)
{
if(mIndicatorHideDuration > 0.0f)
{
mAnimation = Animation::New( mIndicatorHideDuration );
- mAnimation.OpacityTo( Self(), 0.0f, AlphaFunctions::EaseIn );
+ mAnimation.AnimateTo( Property( self, Actor::Property::COLOR_ALPHA ), 0.0f, AlphaFunctions::EaseIn );
mAnimation.Play();
}
else
{
- Self().SetOpacity(0.0f);
+ self.SetOpacity(0.0f);
}
}
// target the container to observe for scrolling
Actor target = mContainer.Self();
Constraint constraint = Constraint::New<bool>( Actor::Property::VISIBLE,
- Source( target, vertical ? target.GetPropertyIndex(Scrollable::SCROLLABLE_CAN_SCROLL_VERTICAL) : target.GetPropertyIndex(Scrollable::SCROLLABLE_CAN_SCROLL_HORIZONTAL)),
+ Source( target, vertical ? Toolkit::Scrollable::Property::CAN_SCROLL_VERTICAL : Toolkit::Scrollable::Property::CAN_SCROLL_HORIZONTAL),
ScrollBarInternalVisibilityConstraint );
mSlider.ApplyConstraint( constraint );
mSliderWrap.ApplyConstraint( constraint );
constraint = Constraint::New<Vector3>( Actor::Property::SIZE,
- Source( target, target.GetPropertyIndex( Toolkit::Scrollable::SCROLL_POSITION_MIN_PROPERTY_NAME ) ),
- Source( target, target.GetPropertyIndex( Toolkit::Scrollable::SCROLL_POSITION_MAX_PROPERTY_NAME ) ),
- Source( target, target.GetPropertyIndex( Toolkit::Scrollable::SCROLL_DIRECTION_PROPERTY_NAME ) ),
+ Source( target, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ),
+ Source( target, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ),
+ Source( target, Toolkit::Scrollable::Property::SCROLL_DIRECTION ),
Source( target, Actor::Property::SIZE ),
ScrollBarInternalSizeConstraint( vertical ) );
mSlider.ApplyConstraint( constraint );
mSliderWrap.ApplyConstraint( constraint );
constraint = Constraint::New<Quaternion>( Actor::Property::ORIENTATION,
- Source( target, target.GetPropertyIndex( Toolkit::Scrollable::SCROLL_DIRECTION_PROPERTY_NAME ) ),
+ Source( target, Toolkit::Scrollable::Property::SCROLL_DIRECTION ),
ScrollBarInternalRotationConstraint( vertical ) );
mSlider.ApplyConstraint( constraint );
mSliderWrap.ApplyConstraint( constraint );
constraint = Constraint::New<Vector3>( Actor::Property::POSITION,
Source( mSlider, Actor::Property::SIZE),
- Source( target, target.GetPropertyIndex( Toolkit::Scrollable::SCROLL_RELATIVE_POSITION_PROPERTY_NAME ) ),
- Source( target, target.GetPropertyIndex( Toolkit::Scrollable::SCROLL_POSITION_MIN_PROPERTY_NAME ) ),
- Source( target, target.GetPropertyIndex( Toolkit::Scrollable::SCROLL_POSITION_MAX_PROPERTY_NAME ) ),
- Source( target, target.GetPropertyIndex( Toolkit::Scrollable::SCROLL_DIRECTION_PROPERTY_NAME ) ),
+ Source( target, Toolkit::Scrollable::Property::SCROLL_RELATIVE_POSITION ),
+ Source( target, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ),
+ Source( target, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ),
+ Source( target, Toolkit::Scrollable::Property::SCROLL_DIRECTION ),
Source( target, Actor::Property::SIZE ),
ScrollBarInternalPositionConstraint(vertical) );
constraint = Constraint::New<Vector3>( Actor::Property::POSITION,
Source( mSlider, Actor::Property::SIZE),
- Source( target, target.GetPropertyIndex( Toolkit::Scrollable::SCROLL_RELATIVE_POSITION_PROPERTY_NAME ) ),
- Source( target, target.GetPropertyIndex( Toolkit::Scrollable::SCROLL_POSITION_MIN_PROPERTY_NAME ) ),
- Source( target, target.GetPropertyIndex( Toolkit::Scrollable::SCROLL_POSITION_MAX_PROPERTY_NAME ) ),
- Source( target, target.GetPropertyIndex( Toolkit::Scrollable::SCROLL_DIRECTION_PROPERTY_NAME ) ),
+ Source( target, Toolkit::Scrollable::Property::SCROLL_RELATIVE_POSITION ),
+ Source( target, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ),
+ Source( target, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ),
+ Source( target, Toolkit::Scrollable::Property::SCROLL_DIRECTION ),
Source( target, Actor::Property::SIZE ),
ScrollBarInternalPositionConstraint(vertical, true) );
mSliderWrap.ApplyConstraint( constraint );
mContainer.AddOverlay( mHitArea );
constraint = Constraint::New<Vector3>( Actor::Property::SIZE,
- Source( target, target.GetPropertyIndex( Toolkit::Scrollable::SCROLL_DIRECTION_PROPERTY_NAME ) ),
+ Source( target, Toolkit::Scrollable::Property::SCROLL_DIRECTION ),
Source( target, Actor::Property::SIZE ),
ScrollBarInternalHitSizeConstraint(vertical, BAR_TAB_SIZE.width) );
mHitArea.ApplyConstraint( constraint );
}
mAnimation = Animation::New( BAR_SHOW_TIME );
- mAnimation.OpacityTo( mSlider, 1.0f, AlphaFunctions::EaseIn );
- mAnimation.OpacityTo( mSliderWrap, 1.0f, AlphaFunctions::EaseIn );
+ mAnimation.AnimateTo( Property( mSlider, Actor::Property::COLOR_ALPHA ), 1.0f, AlphaFunctions::EaseIn );
+ mAnimation.AnimateTo( Property( mSliderWrap, Actor::Property::COLOR_ALPHA ), 1.0f, AlphaFunctions::EaseIn );
mAnimation.Play();
DestructTimer();
}
mAnimation = Animation::New( BAR_HIDE_TIME );
- mAnimation.OpacityTo( mSlider, 0.0f, AlphaFunctions::EaseIn );
- mAnimation.OpacityTo( mSliderWrap, 0.0f, AlphaFunctions::EaseIn );
+ mAnimation.AnimateTo( Property( mSlider, Actor::Property::COLOR_ALPHA ), 0.0f, AlphaFunctions::EaseIn );
+ mAnimation.AnimateTo( Property( mSliderWrap, Actor::Property::COLOR_ALPHA ), 0.0f, AlphaFunctions::EaseIn );
mAnimation.Play();
}
void ItemView::OnInitialize()
{
- RegisterCommonProperties();
-
Actor self = Self();
// Disable size negotiation for item views
EnableScrollComponent(Toolkit::Scrollable::OvershootIndicator);
- Constraint constraint = Constraint::New<Vector3>(mPropertyRelativePosition,
+ Constraint constraint = Constraint::New<Vector3>(Toolkit::Scrollable::Property::SCROLL_RELATIVE_POSITION,
LocalSource(mPropertyPosition),
- LocalSource(mPropertyPositionMin),
- LocalSource(mPropertyPositionMax),
+ LocalSource(Toolkit::Scrollable::Property::SCROLL_POSITION_MIN),
+ LocalSource(Toolkit::Scrollable::Property::SCROLL_POSITION_MAX),
LocalSource(Actor::Property::SIZE),
RelativePositionConstraint);
self.ApplyConstraint(constraint);
if(mActiveLayout->GetItemSize(itemId, targetSize, size))
{
// resize immediately
- actor.SetResizePolicy( FIXED, ALL_DIMENSIONS );
- actor.SetPreferredSize( size.GetVectorXY() );
+ actor.SetSize( size.GetVectorXY() );
}
mActiveLayout->ApplyConstraints(actor, itemId, durationSeconds, mScrollPositionObject, Self() );
Radian scrollDirection(mActiveLayout->GetScrollDirection());
float orientation = static_cast<float>(mActiveLayout->GetOrientation());
- self.SetProperty(mPropertyScrollDirection, Vector3(sinf(scrollDirection), cosf(scrollDirection), orientation));
+ self.SetProperty(Toolkit::Scrollable::Property::SCROLL_DIRECTION, Vector3(sinf(scrollDirection), cosf(scrollDirection), orientation));
self.SetProperty(mPropertyScrollSpeed, mScrollSpeed);
Vector3 size;
if( mActiveLayout->GetItemSize( item.first, mActiveLayoutTargetSize, size ) )
{
- item.second.SetResizePolicy( FIXED, ALL_DIMENSIONS );
- item.second.SetPreferredSize( size.GetVectorXY() );
+ item.second.SetSize( size.GetVectorXY() );
}
mActiveLayout->ApplyConstraints( item.second, item.first, durationSeconds, mScrollPositionObject, Self() );
if(IsHorizontal(mActiveLayout->GetOrientation()))
{
- self.SetProperty(mPropertyPositionMin, Vector3(0.0f, firstItemPosition.x, 0.0f));
- self.SetProperty(mPropertyPositionMax, Vector3(0.0f, lastItemPosition.x, 0.0f));
+ self.SetProperty(Toolkit::Scrollable::Property::SCROLL_POSITION_MIN, Vector3(0.0f, firstItemPosition.x, 0.0f));
+ self.SetProperty(Toolkit::Scrollable::Property::SCROLL_POSITION_MAX, Vector3(0.0f, lastItemPosition.x, 0.0f));
domainSize = fabs(firstItemPosition.x - lastItemPosition.x);
}
else
{
- self.SetProperty(mPropertyPositionMin, Vector3(0.0f, firstItemPosition.y, 0.0f));
- self.SetProperty(mPropertyPositionMax, Vector3(0.0f, lastItemPosition.y, 0.0f));
+ self.SetProperty(Toolkit::Scrollable::Property::SCROLL_POSITION_MIN, Vector3(0.0f, firstItemPosition.y, 0.0f));
+ self.SetProperty(Toolkit::Scrollable::Property::SCROLL_POSITION_MAX, Vector3(0.0f, lastItemPosition.y, 0.0f));
domainSize = fabs(firstItemPosition.y - lastItemPosition.y);
}
mScrollConnector.SetScrollDomain(minLayoutPosition, 0.0f, domainSize);
bool isLayoutScrollable = IsLayoutScrollable(layoutSize);
- self.SetProperty(mPropertyCanScrollVertical, isLayoutScrollable);
- self.SetProperty(mPropertyCanScrollHorizontal, false);
+ self.SetProperty(Toolkit::Scrollable::Property::CAN_SCROLL_VERTICAL, isLayoutScrollable);
+ self.SetProperty(Toolkit::Scrollable::Property::CAN_SCROLL_HORIZONTAL, false);
}
}
{
Actor self = Self();
- float minScrollPosition = self.GetProperty<float>(mPropertyPositionMin);
- float maxScrollPosition = self.GetProperty<float>(mPropertyPositionMax);
+ float minScrollPosition = self.GetProperty<float>(Toolkit::Scrollable::Property::SCROLL_POSITION_MIN);
+ float maxScrollPosition = self.GetProperty<float>(Toolkit::Scrollable::Property::SCROLL_POSITION_MAX);
return Vector3(0.0f, fabs(maxScrollPosition - minScrollPosition), 0.0f);
}
self.Add(mOvershootOverlay);
Constraint constraint = Constraint::New<Vector3>( Actor::Property::SIZE,
- ParentSource( mPropertyScrollDirection ),
+ ParentSource( Toolkit::Scrollable::Property::SCROLL_DIRECTION ),
Source( mScrollPositionObject, ScrollConnector::OVERSHOOT ),
ParentSource( Actor::Property::SIZE ),
OvershootOverlaySizeConstraint() );
mOvershootOverlay.SetSize(OVERSHOOT_BOUNCE_ACTOR_DEFAULT_SIZE.width, OVERSHOOT_BOUNCE_ACTOR_DEFAULT_SIZE.height);
constraint = Constraint::New<Quaternion>( Actor::Property::ORIENTATION,
- ParentSource( mPropertyScrollDirection ),
+ ParentSource( Toolkit::Scrollable::Property::SCROLL_DIRECTION ),
Source( mScrollPositionObject, ScrollConnector::OVERSHOOT ),
OvershootOverlayRotationConstraint() );
mOvershootOverlay.ApplyConstraint(constraint);
constraint = Constraint::New<Vector3>( Actor::Property::POSITION,
ParentSource( Actor::Property::SIZE ),
- ParentSource( mPropertyScrollDirection ),
+ ParentSource( Toolkit::Scrollable::Property::SCROLL_DIRECTION ),
Source( mScrollPositionObject, ScrollConnector::OVERSHOOT ),
OvershootOverlayPositionConstraint() );
mOvershootOverlay.ApplyConstraint(constraint);
constraint = Constraint::New<bool>( Actor::Property::VISIBLE,
- ParentSource( mPropertyCanScrollVertical ),
+ ParentSource( Toolkit::Scrollable::Property::CAN_SCROLL_VERTICAL ),
OvershootOverlayVisibilityConstraint() );
mOvershootOverlay.ApplyConstraint(constraint);
if(mOvershootAnimationSpeed > Math::MACHINE_EPSILON_0)
{
float currentOvershoot = mScrollPositionObject.GetProperty<float>(ScrollConnector::OVERSHOOT);
- float duration = mOvershootOverlay.GetCurrentSize().height * (animatingOn ? (1.0f - fabsf(currentOvershoot)) : fabsf(currentOvershoot)) / mOvershootAnimationSpeed;
+ float duration = 0.0f;
+
+ if (mOvershootOverlay)
+ {
+ duration = mOvershootOverlay.GetCurrentSize().height * (animatingOn ? (1.0f - fabsf(currentOvershoot)) : fabsf(currentOvershoot)) / mOvershootAnimationSpeed;
+ }
RemoveAnimation(mScrollOvershootAnimation);
mScrollOvershootAnimation = Animation::New(duration);
// ScrollBase
///////////////////////////////////////////////////////////////////////////////////////////////////
-const char* const ScrollBase::SCROLL_DOMAIN_OFFSET_PROPERTY_NAME = "domain-offset";
-
ScrollBase::ScrollBase()
: Scrollable(),
mParent(NULL),
- mPropertyTime(Property::INVALID_INDEX),
- mPropertyPrePosition(Property::INVALID_INDEX),
- mPropertyPosition(Property::INVALID_INDEX),
- mPropertyOvershootX(Property::INVALID_INDEX),
- mPropertyOvershootY(Property::INVALID_INDEX),
- mPropertyWrap(Property::INVALID_INDEX),
- mPropertyPanning(Property::INVALID_INDEX),
- mPropertyScrolling(Property::INVALID_INDEX),
- mPropertyFinal(Property::INVALID_INDEX),
- mPropertyDomainOffset(Property::INVALID_INDEX),
- mPropertyPositionDelta(Property::INVALID_INDEX),
- mPropertyScrollStartPagePosition(Property::INVALID_INDEX),
mDelay(0.0f)
{
}
mParent = parent;
}
-void ScrollBase::RegisterProperties()
-{
- Actor self = Self();
-
- // Register common properties
- RegisterCommonProperties();
-
- // Register Scroll Properties.
- mPropertyTime = self.RegisterProperty(Toolkit::ScrollView::SCROLL_TIME_PROPERTY_NAME, 0.0f);
- mPropertyPrePosition = self.RegisterProperty(Toolkit::ScrollView::SCROLL_PRE_POSITION_PROPERTY_NAME, Vector3::ZERO);
- mPropertyPosition = self.RegisterProperty(Toolkit::ScrollView::SCROLL_POSITION_PROPERTY_NAME, Vector3::ZERO);
- mPropertyOvershootX = self.RegisterProperty(Toolkit::ScrollView::SCROLL_OVERSHOOT_X_PROPERTY_NAME, 0.0f);
- mPropertyOvershootY = self.RegisterProperty(Toolkit::ScrollView::SCROLL_OVERSHOOT_Y_PROPERTY_NAME, 0.0f);
- mPropertyFinal = self.RegisterProperty(Toolkit::ScrollView::SCROLL_FINAL_PROPERTY_NAME, Vector3::ZERO);
- mPropertyWrap = self.RegisterProperty(Toolkit::ScrollView::SCROLL_WRAP_PROPERTY_NAME, false);
- mPropertyPanning = self.RegisterProperty(Toolkit::ScrollView::SCROLL_PANNING_PROPERTY_NAME, false);
- mPropertyScrolling = self.RegisterProperty(Toolkit::ScrollView::SCROLL_SCROLLING_PROPERTY_NAME, false);
- mPropertyDomainOffset = self.RegisterProperty(SCROLL_DOMAIN_OFFSET_PROPERTY_NAME, Vector3::ZERO);
- mPropertyPositionDelta = self.RegisterProperty(Toolkit::ScrollView::SCROLL_POSITION_DELTA_PROPERTY_NAME, Vector3::ZERO);
- mPropertyScrollStartPagePosition = self.RegisterProperty(Toolkit::ScrollView::SCROLL_START_PAGE_POSITION_PROPERTY_NAME, Vector3::ZERO);
-}
-
void ScrollBase::BindActor(Actor child)
{
FindAndUnbindActor(child);
*/
ScrollBase();
- /**
- * 2nd-phase initialization.
- */
- void RegisterProperties();
-
protected:
ScrollBase *mParent; ///< Pointer to ScrollBase parent, if exists.
- Property::Index mPropertyTime; ///< Scroll Time (0 to animationDuration while animating, otherwise 0)
- Property::Index mPropertyPrePosition; ///< Scroll Position ("scroll-position") [function of scroll-x, scroll-y]
- Property::Index mPropertyPosition; ///< Scroll Position ("scroll-position") [function of scroll-pre-position]
- Property::Index mPropertyOvershootX; ///< Scroll Overshoot ("scroll-overshoot-x") [function of scroll-pre-position, scroll-position]
- Property::Index mPropertyOvershootY; ///< Scroll Overshoot ("scroll-overshoot-y") [function of scroll-pre-position, scroll-position]
- Property::Index mPropertyWrap; ///< Scroll Wrap ("scroll-wrap")
- Property::Index mPropertyPanning; ///< Whether we are panning
- Property::Index mPropertyScrolling; ///< Whether we are scrolling
- Property::Index mPropertyFinal; ///< Scroll Final Position ("scroll-final") [scroll-position + f(scroll-overshoot)]
- Property::Index mPropertyDomainOffset; ///< Scroll Domain Offset ("scroll-domain-offset") keeps track of scroll position as it wraps domains
- Property::Index mPropertyPositionDelta; ///< Scroll Position Delta ("scroll-position-delta")
- Property::Index mPropertyScrollStartPagePosition; ///< Scroll Start Page Position ("scroll-start-page-position")
private:
void ScrollOvershootEffectRipple::Apply()
{
Actor self = mAttachedScrollView.Self();
- mOvershootProperty = self.GetPropertyIndex(IsVertical() ? Toolkit::ScrollView::SCROLL_OVERSHOOT_Y_PROPERTY_NAME : Toolkit::ScrollView::SCROLL_OVERSHOOT_X_PROPERTY_NAME);
+ mOvershootProperty = IsVertical() ? Toolkit::ScrollView::Property::OVERSHOOT_Y : Toolkit::ScrollView::Property::OVERSHOOT_X;
// make sure height is set, since we only create a constraint for image width
mOvershootOverlay.SetSize(OVERSHOOT_BOUNCE_ACTOR_DEFAULT_SIZE.width, OVERSHOOT_BOUNCE_ACTOR_DEFAULT_SIZE.height);
* @param[in] positionProperty The Actor's Position.
* @param[in] scaleProperty The Actor's Scale.
* @param[in] sizeProperty The Actor's Size
- * @param[in] scrollPositionProperty The scroll-view's position property (SCROLL_POSITION_PROPERTY_NAME)
+ * @param[in] scrollPositionProperty The scroll-view's position property (SCROLL_POSITION)
* @param[in] scrollSizeProperty The size of the scroll-view (scrollView SIZE)
* @return The new visibility of this Actor.
*/
* @param[in] positionProperty The Actor's Position.
* @param[in] scaleProperty The Actor's Scale.
* @param[in] sizeProperty The Actor's Size
- * @param[in] scrollPositionProperty The scroll-view's position property (SCROLL_POSITION_PROPERTY_NAME)
+ * @param[in] scrollPositionProperty The scroll-view's position property (SCROLL_POSITION)
* @param[in] scrollSizeProperty The size of the scroll-view (scrollView SIZE)
* @param[in] activateProperty Activation value (0 - normal, 1.0 - full effect)
* @return The new orientation of this Actor.
* @param[in] current The current position of this Actor
* @param[in] scaleProperty The Actor's Scale.
* @param[in] sizeProperty The Actor's Size
- * @param[in] scrollPositionProperty The scroll-view's position property (SCROLL_POSITION_PROPERTY_NAME)
+ * @param[in] scrollPositionProperty The scroll-view's position property (SCROLL_POSITION)
* @param[in] scrollSizeProperty The size of the scroll-view (scrollView SIZE)
* @param[in] activateProperty Activation value (0 - normal, 1.0 - full effect)
* @return The new position of this Actor.
LocalSource( Actor::Property::POSITION ),
LocalSource( Actor::Property::SCALE ),
LocalSource( Actor::Property::SIZE ),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_POSITION_PROPERTY_NAME ) ),
+ Source(scrollView, Toolkit::ScrollView::Property::SCROLL_POSITION ),
Source(scrollView, Actor::Property::SIZE ),
Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollViewCarouselEffect::EFFECT_ACTIVATE ) ),
boost::bind( &ScrollCarouselEffectInfo::VisibilityConstraint, info, _1, _2, _3, _4, _5, _6) );
LocalSource( Actor::Property::POSITION ),
LocalSource( Actor::Property::SCALE ),
LocalSource( Actor::Property::SIZE ),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_POSITION_PROPERTY_NAME ) ),
+ Source(scrollView, Toolkit::ScrollView::Property::SCROLL_POSITION ),
Source(scrollView, Actor::Property::SIZE ),
Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollViewCarouselEffect::EFFECT_ACTIVATE ) ),
boost::bind( &ScrollCarouselEffectInfo::RotationConstraint, info, _1, _2, _3, _4, _5, _6, _7) );
constraint = Constraint::New<Vector3>( Actor::Property::POSITION,
LocalSource( Actor::Property::SCALE ),
LocalSource( Actor::Property::SIZE ),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_POSITION_PROPERTY_NAME ) ),
+ Source(scrollView, Toolkit::ScrollView::Property::SCROLL_POSITION ),
Source(scrollView, Actor::Property::SIZE ),
Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollViewCarouselEffect::EFFECT_ACTIVATE ) ),
boost::bind( &ScrollCarouselEffectInfo::PositionConstraint, info, _1, _2, _3, _4, _5, _6) );
/**
* @param[in] current The current orientation of this Actor
* @param[in] pagePositionProperty The page's position.
- * @param[in] scrollPositionProperty The scroll-view's position property (SCROLL_POSITION_PROPERTY_NAME)
- * @param[in] scrollPositionMin The minimum extent of this scroll domain. (SCROLL_POSITION_MIN_PROPERTY_NAME)
- * @param[in] scrollPositionMax The maximum extent of this scroll domain. (SCROLL_POSITION_MIN_PROPERTY_NAME)
+ * @param[in] scrollPositionProperty The scroll-view's position property (SCROLL_POSITION)
+ * @param[in] scrollPositionMin The minimum extent of this scroll domain. (SCROLL_POSITION_MIN)
+ * @param[in] scrollPositionMax The maximum extent of this scroll domain. (SCROLL_POSITION_MAX)
* @param[in] pageSizeProperty The size of the page. (scrollView SIZE)
- * @param[in] scrollWrap Whether scroll wrap has been enabled or not (SCROLL_WRAP_PROPERTY_NAME)
+ * @param[in] scrollWrap Whether scroll wrap has been enabled or not (WRAP)
* @return The new orientation of this Actor.
*/
Quaternion RotationConstraint(const Quaternion& current,
/**
* @param[in] current The current color of this Actor
* @param[in] pagePositionProperty The page's position.
- * @param[in] scrollPositionProperty The scroll-view's position property (SCROLL_POSITION_PROPERTY_NAME)
- * @param[in] scrollPositionMin The minimum extent of this scroll domain. (SCROLL_POSITION_MIN_PROPERTY_NAME)
- * @param[in] scrollPositionMax The maximum extent of this scroll domain. (SCROLL_POSITION_MIN_PROPERTY_NAME)
+ * @param[in] scrollPositionProperty The scroll-view's position property (SCROLL_POSITION)
+ * @param[in] scrollPositionMin The minimum extent of this scroll domain. (SCROLL_POSITION_MIN)
+ * @param[in] scrollPositionMax The maximum extent of this scroll domain. (SCROLL_POSITION_MAX)
* @param[in] pageSizeProperty The size of the page. (scrollView SIZE)
- * @param[in] scrollWrap Whether scroll wrap has been enabled or not (SCROLL_WRAP_PROPERTY_NAME)
+ * @param[in] scrollWrap Whether scroll wrap has been enabled or not (WRAP)
* @return The new color of this Actor.
*/
Vector4 ColorConstraint(const Vector4& current,
/**
* @param[in] current The current position
* @param[in] pagePositionProperty The page's position.
- * @param[in] scrollPositionProperty The scroll-view's position property (SCROLL_POSITION_PROPERTY_NAME)
- * @param[in] scrollPositionMin The minimum extent of this scroll domain. (SCROLL_POSITION_MIN_PROPERTY_NAME)
- * @param[in] scrollPositionMax The maximum extent of this scroll domain. (SCROLL_POSITION_MIN_PROPERTY_NAME)
+ * @param[in] scrollPositionProperty The scroll-view's position property (SCROLL_POSITION)
+ * @param[in] scrollPositionMin The minimum extent of this scroll domain. (SCROLL_POSITION_MIN)
+ * @param[in] scrollPositionMax The maximum extent of this scroll domain. (SCROLL_POSITION_MAX)
* @param[in] pageSizeProperty The size of the page. (scrollView SIZE)
- * @param[in] scrollWrap Whether scroll wrap has been enabled or not (SCROLL_WRAP_PROPERTY_NAME)
+ * @param[in] scrollWrap Whether scroll wrap has been enabled or not (WRAP)
* @return The new position of this Actor.
*/
Vector3 PositionConstraint(const Vector3& current,
Constraint constraint;
constraint = Constraint::New<Quaternion>( Actor::Property::ORIENTATION,
Source(parentPage, Actor::Property::POSITION),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_FINAL_PROPERTY_NAME ) ),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_POSITION_MIN_PROPERTY_NAME ) ),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_POSITION_MAX_PROPERTY_NAME ) ),
+ Source(scrollView, Toolkit::ScrollView::Property::SCROLL_FINAL ),
+ Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ),
+ Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ),
Source(scrollView, Actor::Property::SIZE ),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_WRAP_PROPERTY_NAME ) ),
+ Source(scrollView, Toolkit::ScrollView::Property::WRAP ),
boost::bind( &ScrollCubeEffectInfo::RotationConstraint, info, _1, _2, _3, _4, _5, _6, _7) );
constraint.SetRemoveAction( Constraint::Discard );
constraint = Constraint::New<Vector4>( Actor::Property::COLOR,
Source(parentPage, Actor::Property::POSITION),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_FINAL_PROPERTY_NAME ) ),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_POSITION_MIN_PROPERTY_NAME ) ),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_POSITION_MAX_PROPERTY_NAME ) ),
+ Source(scrollView, Toolkit::ScrollView::Property::SCROLL_FINAL ),
+ Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ),
+ Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ),
Source(scrollView, Actor::Property::SIZE ),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_WRAP_PROPERTY_NAME ) ),
+ Source(scrollView, Toolkit::ScrollView::Property::WRAP ),
boost::bind( &ScrollCubeEffectInfo::ColorConstraint, info, _1, _2, _3, _4, _5, _6, _7) );
constraint.SetRemoveAction( Constraint::Discard );
constraint = Constraint::New<Vector3>( Actor::Property::POSITION,
Source(parentPage, Actor::Property::POSITION),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_FINAL_PROPERTY_NAME ) ),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_POSITION_MIN_PROPERTY_NAME ) ),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_POSITION_MAX_PROPERTY_NAME ) ),
+ Source(scrollView, Toolkit::ScrollView::Property::SCROLL_FINAL ),
+ Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ),
+ Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ),
Source(scrollView, Actor::Property::SIZE ),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_WRAP_PROPERTY_NAME ) ),
+ Source(scrollView, Toolkit::ScrollView::Property::WRAP ),
boost::bind( &ScrollCubeEffectInfo::PositionConstraint, info, _1, _2, _3, _4, _5, _6, _7) );
constraint.SetRemoveAction( Constraint::Discard );
/**
* @param[in] current The current scale
* @param[in] pagePositionProperty The page's position.
- * @param[in] scrollPositionProperty The scroll-view's position property (SCROLL_POSITION_PROPERTY_NAME)
- * @param[in] scrollPositionMin The minimum extent of this scroll domain. (SCROLL_POSITION_MIN_PROPERTY_NAME)
- * @param[in] scrollPositionMax The maximum extent of this scroll domain. (SCROLL_POSITION_MIN_PROPERTY_NAME)
+ * @param[in] scrollPositionProperty The scroll-view's position property (SCROLL_POSITION)
+ * @param[in] scrollPositionMin The minimum extent of this scroll domain. (SCROLL_POSITION_MIN)
+ * @param[in] scrollPositionMax The maximum extent of this scroll domain. (SCROLL_POSITION_MAX)
* @param[in] pageSizeProperty The size of the page. (scrollView SIZE)
- * @param[in] scrollWrap Whether scroll wrap has been enabled or not (SCROLL_WRAP_PROPERTY_NAME)
+ * @param[in] scrollWrap Whether scroll wrap has been enabled or not (WRAP)
* @return The new scale of this Actor.
*/
Vector3 operator()(const Vector3& currentScale,
/**
* @param[in] current The current position
* @param[in] pagePositionProperty The page's position.
- * @param[in] scrollPositionProperty The scroll-view's position property (SCROLL_POSITION_PROPERTY_NAME)
- * @param[in] scrollPositionMin The minimum extent of this scroll domain. (SCROLL_POSITION_MIN_PROPERTY_NAME)
- * @param[in] scrollPositionMax The maximum extent of this scroll domain. (SCROLL_POSITION_MIN_PROPERTY_NAME)
+ * @param[in] scrollPositionProperty The scroll-view's position property (SCROLL_POSITION)
+ * @param[in] scrollPositionMin The minimum extent of this scroll domain. (SCROLL_POSITION_MIN)
+ * @param[in] scrollPositionMax The maximum extent of this scroll domain. (SCROLL_POSITION_MAX)
* @param[in] pageSizeProperty The size of the page. (scrollView SIZE)
- * @param[in] scrollWrap Whether scroll wrap has been enabled or not (SCROLL_WRAP_PROPERTY_NAME)
+ * @param[in] scrollWrap Whether scroll wrap has been enabled or not (WRAP)
* @return The new position of this Actor.
*/
Vector3 operator()(const Vector3& currentPosition,
Constraint constraint = Constraint::New<Vector3>( Actor::Property::SCALE,
LocalSource(Actor::Property::POSITION),
ParentSource(Actor::Property::POSITION),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_POSITION_PROPERTY_NAME ) ),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_POSITION_MIN_PROPERTY_NAME ) ),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_POSITION_MAX_PROPERTY_NAME ) ),
+ Source(scrollView, Toolkit::ScrollView::Property::SCROLL_POSITION ),
+ Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ),
+ Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ),
Source(scrollView, Actor::Property::SIZE ),
ScrollDepthScaleConstraint( positionExtent, offsetExtent, positionScale, scaleExtent ) );
constraint.SetRemoveAction( Constraint::Discard );
// Position Constraint (apply last as other constraints use Actor::POSITION as a function input)
constraint = Constraint::New<Vector3>( Actor::Property::POSITION,
ParentSource(Actor::Property::POSITION),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_POSITION_PROPERTY_NAME ) ),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_POSITION_MIN_PROPERTY_NAME ) ),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_POSITION_MAX_PROPERTY_NAME ) ),
+ Source(scrollView, Toolkit::ScrollView::Property::SCROLL_POSITION ),
+ Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ),
+ Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ),
Source(scrollView, Actor::Property::SIZE ),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_WRAP_PROPERTY_NAME ) ),
+ Source(scrollView, Toolkit::ScrollView::Property::WRAP ),
ScrollDepthPositionConstraint( positionExtent, offsetExtent, positionScale ) );
constraint.SetRemoveAction( Constraint::Discard );
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/scrollable/scroll-component-impl.h>
+#include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view.h>
#include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view-constraints.h>
#include <dali-toolkit/internal/controls/scrollable/scroll-view/scroll-overshoot-indicator-impl.h>
#include <dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-effect-impl.h>
// Setup properties, signals and actions using the type-registry.
DALI_TYPE_REGISTRATION_BEGIN( Toolkit::ScrollView, Toolkit::Scrollable, Create )
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( ScrollView, "scroll-position", VECTOR3, SCROLL_POSITION)
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( ScrollView, "scroll-pre-position", VECTOR3, SCROLL_PRE_POSITION)
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( ScrollView, "overshoot-x", FLOAT, OVERSHOOT_X)
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( ScrollView, "overshoot-y", FLOAT, OVERSHOOT_Y)
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( ScrollView, "scroll-final", VECTOR3, SCROLL_FINAL)
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( ScrollView, "wrap", BOOLEAN, WRAP)
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( ScrollView, "panning", BOOLEAN, PANNING)
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( ScrollView, "scrolling", BOOLEAN, SCROLLING)
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( ScrollView, "scroll-domain-offset", VECTOR3, SCROLL_DOMAIN_OFFSET)
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( ScrollView, "scroll-position-delta", VECTOR3, SCROLL_POSITION_DELTA)
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( ScrollView, "start-page-position", VECTOR3, START_PAGE_POSITION)
+
DALI_SIGNAL_REGISTRATION( ScrollView, "value-changed", SIGNAL_SNAP_STARTED )
DALI_TYPE_REGISTRATION_END()
/**
* This constraint updates the X overshoot property using the difference
- * mPropertyPrePosition.x and mPropertyPosition.x, returning a relative value between 0.0f and 1.0f
+ * SCROLL_PRE_POSITION.x and SCROLL_POSITION.x, returning a relative value between 0.0f and 1.0f
*/
struct OvershootXConstraint
{
/**
* This constraint updates the Y overshoot property using the difference
- * mPropertyPrePosition.y and mPropertyPosition.y, returning a relative value between 0.0f and 1.0f
+ * SCROLL_PRE_POSITION.y and SCROLL_POSITION.y, returning a relative value between 0.0f and 1.0f
*/
struct OvershootYConstraint
{
mAlterChild = true;
- // Register Scroll Properties.
- RegisterProperties();
-
mScrollPostPosition = mScrollPrePosition = Vector3::ZERO;
mMouseWheelScrollDistanceStep = Stage::GetCurrent().GetSize() * DEFAULT_MOUSE_WHEEL_SCROLL_DISTANCE_STEP_PROPORTION;
EnableScrollComponent(Toolkit::Scrollable::OvershootIndicator);
+ self.SetProperty(Toolkit::Scrollable::Property::CAN_SCROLL_VERTICAL, mCanScrollVertical);
+ self.SetProperty(Toolkit::Scrollable::Property::CAN_SCROLL_HORIZONTAL, mCanScrollHorizontal);
+
Vector3 size = GetControlSize();
UpdatePropertyDomain(size);
SetInternalConstraints();
if( mCanScrollVertical != canScrollVertical )
{
mCanScrollVertical = canScrollVertical;
- self.SetProperty(mPropertyCanScrollVertical, canScrollVertical);
+ self.SetProperty(Toolkit::Scrollable::Property::CAN_SCROLL_VERTICAL, canScrollVertical);
}
if( mCanScrollHorizontal != canScrollHorizontal )
{
mCanScrollHorizontal = canScrollHorizontal;
- self.SetProperty(mPropertyCanScrollHorizontal, canScrollHorizontal);
+ self.SetProperty(Toolkit::Scrollable::Property::CAN_SCROLL_HORIZONTAL, canScrollHorizontal);
}
if( scrollPositionChanged )
{
- DALI_LOG_SCROLL_STATE("[0x%X] Domain Changed, setting mPropertyPrePosition To[%.2f, %.2f]", this, mScrollPrePosition.x, mScrollPrePosition.y );
- self.SetProperty(mPropertyPrePosition, mScrollPrePosition);
+ DALI_LOG_SCROLL_STATE("[0x%X] Domain Changed, setting SCROLL_PRE_POSITION To[%.2f, %.2f]", this, mScrollPrePosition.x, mScrollPrePosition.y );
+ self.SetProperty(Toolkit::ScrollView::Property::SCROLL_PRE_POSITION, mScrollPrePosition);
}
if( domainChanged )
{
mMinScroll = min;
mMaxScroll = max;
- self.SetProperty(mPropertyPositionMin, mMinScroll );
- self.SetProperty(mPropertyPositionMax, mMaxScroll );
+ self.SetProperty(Toolkit::Scrollable::Property::SCROLL_POSITION_MIN, mMinScroll );
+ self.SetProperty(Toolkit::Scrollable::Property::SCROLL_POSITION_MAX, mMaxScroll );
}
}
void ScrollView::SetWrapMode(bool enable)
{
mWrapMode = enable;
- Self().SetProperty(mPropertyWrap, enable);
+ Self().SetProperty(Toolkit::ScrollView::Property::WRAP, enable);
}
int ScrollView::GetScrollUpdateDistance() const
this, position.x, position.y, duration, int(horizontalBias), int(verticalBias));
Vector3 currentScrollPosition = GetCurrentScrollPosition();
- self.SetProperty( mPropertyScrollStartPagePosition, currentScrollPosition );
+ self.SetProperty( Toolkit::ScrollView::Property::START_PAGE_POSITION, currentScrollPosition );
if( mScrolling ) // are we interrupting a current scroll?
{
DALI_LOG_SCROLL_STATE("[0x%X] Interrupting Pan, set to false", this );
mPanning = false;
mGestureStackDepth = 0;
- self.SetProperty( mPropertyPanning, false );
+ self.SetProperty( Toolkit::ScrollView::Property::PANNING, false );
if( mScrollMainInternalPrePositionConstraint )
{
}
}
- self.SetProperty(mPropertyScrolling, true);
+ self.SetProperty(Toolkit::ScrollView::Property::SCROLLING, true);
mScrolling = true;
DALI_LOG_SCROLL_STATE("[0x%X] mScrollStartedSignal 1 [%.2f, %.2f]", this, currentScrollPosition.x, currentScrollPosition.y);
if(!animating)
{
// if not animating, then this pan has completed right now.
- self.SetProperty(mPropertyScrolling, false);
+ self.SetProperty(Toolkit::ScrollView::Property::SCROLLING, false);
mScrolling = false;
// If we have no duration, then in the next update frame, we will be at the position specified as we just set.
if(child)
{
- Vector3 position = Self().GetProperty<Vector3>(mPropertyPosition);
+ Vector3 position = Self().GetProperty<Vector3>(Toolkit::ScrollView::Property::SCROLL_POSITION);
// Get center-point of the Actor.
Vector3 childPosition = GetPositionOfAnchor(child, AnchorPoint::CENTER);
if( !(mScrollStateFlags & SCROLL_ANIMATION_FLAGS) )
{
- DALI_LOG_SCROLL_STATE("[0x%X] Setting mPropertyPrePosition To[%.2f, %.2f]", this, mScrollTargetPosition.x, mScrollTargetPosition.y );
- self.SetProperty(mPropertyPrePosition, mScrollTargetPosition);
+ DALI_LOG_SCROLL_STATE("[0x%X] Setting SCROLL_PRE_POSITION To[%.2f, %.2f]", this, mScrollTargetPosition.x, mScrollTargetPosition.y );
+ self.SetProperty(Toolkit::ScrollView::Property::SCROLL_PRE_POSITION, mScrollTargetPosition);
mScrollPrePosition = mScrollTargetPosition;
mScrollPostPosition = mScrollTargetPosition;
WrapPosition(mScrollPostPosition);
}
DALI_LOG_SCROLL_STATE("[0x%X] position-changed, mScrollTargetPosition[%.2f, %.2f], mScrollPrePosition[%.2f, %.2f], mScrollPostPosition[%.2f, %.2f]", this, mScrollTargetPosition.x, mScrollTargetPosition.y, mScrollPrePosition.x, mScrollPrePosition.y, mScrollPostPosition.x, mScrollPostPosition.y );
- DALI_LOG_SCROLL_STATE("[0x%X] mPropertyPrePosition[%.2f, %.2f], mPropertyPosition[%.2f, %.2f]", this, self.GetProperty( mPropertyPrePosition ).Get<Vector3>().x, self.GetProperty( mPropertyPrePosition ).Get<Vector3>().y, self.GetProperty( mPropertyPosition ).Get<Vector3>().x, self.GetProperty( mPropertyPosition ).Get<Vector3>().y );
+ DALI_LOG_SCROLL_STATE("[0x%X] SCROLL_PRE_POSITION[%.2f, %.2f], SCROLL_POSITION[%.2f, %.2f]", this, self.GetProperty( Toolkit::ScrollView::Property::SCROLL_PRE_POSITION ).Get<Vector3>().x, self.GetProperty( Toolkit::ScrollView::Property::SCROLL_PRE_POSITION ).Get<Vector3>().y, self.GetProperty( Toolkit::ScrollView::Property::SCROLL_POSITION ).Get<Vector3>().x, self.GetProperty( Toolkit::ScrollView::Property::SCROLL_POSITION ).Get<Vector3>().y );
}
SetScrollUpdateNotification(true);
Vector3 ScrollView::GetPropertyPrePosition() const
{
- Vector3 position = Self().GetProperty<Vector3>(mPropertyPrePosition);
+ Vector3 position = Self().GetProperty<Vector3>(Toolkit::ScrollView::Property::SCROLL_PRE_POSITION);
WrapPosition(position);
return position;
}
Vector3 ScrollView::GetPropertyPosition() const
{
- Vector3 position = Self().GetProperty<Vector3>(mPropertyPosition);
+ Vector3 position = Self().GetProperty<Vector3>(Toolkit::ScrollView::Property::SCROLL_POSITION);
WrapPosition(position);
return position;
// Emit Signal that scrolling has completed.
mScrolling = false;
Actor self = Self();
- self.SetProperty(mPropertyScrolling, false);
+ self.SetProperty(Toolkit::ScrollView::Property::SCROLLING, false);
Vector3 deltaPosition(mScrollPrePosition);
UpdateLocalScrollProperties();
WrapPosition(mScrollPrePosition);
- DALI_LOG_SCROLL_STATE("[0x%X] Setting mPropertyPrePosition To[%.2f, %.2f]", this, mScrollPrePosition.x, mScrollPrePosition.y );
- self.SetProperty(mPropertyPrePosition, mScrollPrePosition);
+ DALI_LOG_SCROLL_STATE("[0x%X] Setting SCROLL_PRE_POSITION To[%.2f, %.2f]", this, mScrollPrePosition.x, mScrollPrePosition.y );
+ self.SetProperty(Toolkit::ScrollView::Property::SCROLL_PRE_POSITION, mScrollPrePosition);
Vector3 currentScrollPosition = GetCurrentScrollPosition();
DALI_LOG_SCROLL_STATE("[0x%X] mScrollCompletedSignal 3 current[%.2f, %.2f], mScrollTargetPosition[%.2f, %.2f]", this, currentScrollPosition.x, currentScrollPosition.y, -mScrollTargetPosition.x, -mScrollTargetPosition.y );
mScrollCompletedSignal.Emit( currentScrollPosition );
mDomainOffset += deltaPosition - mScrollPostPosition;
- self.SetProperty(mPropertyDomainOffset, mDomainOffset);
+ self.SetProperty(Toolkit::ScrollView::Property::SCROLL_DOMAIN_OFFSET, mDomainOffset);
HandleStoppedAnimation();
}
if( enabled && !mScrollUpdatedSignal.Empty())
{
// Only set up the notification when the application has connected to the updated signal
- mScrollXUpdateNotification = self.AddPropertyNotification(mPropertyPosition, 0, StepCondition(mScrollUpdateDistance, 0.0f));
+ mScrollXUpdateNotification = self.AddPropertyNotification(Toolkit::ScrollView::Property::SCROLL_POSITION, 0, StepCondition(mScrollUpdateDistance, 0.0f));
mScrollXUpdateNotification.NotifySignal().Connect( this, &ScrollView::OnScrollUpdateNotification );
}
if( mScrollYUpdateNotification )
if( enabled && !mScrollUpdatedSignal.Empty())
{
// Only set up the notification when the application has connected to the updated signal
- mScrollYUpdateNotification = self.AddPropertyNotification(mPropertyPosition, 1, StepCondition(mScrollUpdateDistance, 0.0f));
+ mScrollYUpdateNotification = self.AddPropertyNotification(Toolkit::ScrollView::Property::SCROLL_POSITION, 1, StepCondition(mScrollUpdateDistance, 0.0f));
mScrollYUpdateNotification.NotifySignal().Connect( this, &ScrollView::OnScrollUpdateNotification );
}
}
UnbindActor(child);
}
-void ScrollView::OnPropertySet( Property::Index index, Property::Value propertyValue )
-{
- Actor self = Self();
- if( index == mPropertyPrePosition )
- {
- DALI_LOG_SCROLL_STATE("[0x%X]: mPropertyPrePosition[%.2f, %.2f]", this, propertyValue.Get<Vector3>().x, propertyValue.Get<Vector3>().y);
- propertyValue.Get(mScrollPrePosition);
- }
-}
-
void ScrollView::StartTouchDownTimer()
{
if ( !mTouchDownTimer )
mScrollInterrupted = true;
// reset domain offset as scrolling from original plane.
mDomainOffset = Vector3::ZERO;
- Self().SetProperty(mPropertyDomainOffset, Vector3::ZERO);
+ Self().SetProperty(Toolkit::ScrollView::Property::SCROLL_DOMAIN_OFFSET, Vector3::ZERO);
UpdateLocalScrollProperties();
Vector3 currentScrollPosition = GetCurrentScrollPosition();
void ScrollView::ResetScrolling()
{
Actor self = Self();
- self.GetProperty(mPropertyPosition).Get(mScrollPostPosition);
+ self.GetProperty(Toolkit::ScrollView::Property::SCROLL_POSITION).Get(mScrollPostPosition);
mScrollPrePosition = mScrollPostPosition;
- DALI_LOG_SCROLL_STATE("[0x%X] Setting mPropertyPrePosition To[%.2f, %.2f]", this, mScrollPostPosition.x, mScrollPostPosition.y );
- self.SetProperty(mPropertyPrePosition, mScrollPostPosition);
+ DALI_LOG_SCROLL_STATE("[0x%X] Setting SCROLL_PRE_POSITION To[%.2f, %.2f]", this, mScrollPostPosition.x, mScrollPostPosition.y );
+ self.SetProperty(Toolkit::ScrollView::Property::SCROLL_PRE_POSITION, mScrollPostPosition);
}
void ScrollView::UpdateLocalScrollProperties()
{
Actor self = Self();
- self.GetProperty(mPropertyPrePosition).Get(mScrollPrePosition);
- self.GetProperty(mPropertyPosition).Get(mScrollPostPosition);
+ self.GetProperty(Toolkit::ScrollView::Property::SCROLL_PRE_POSITION).Get(mScrollPrePosition);
+ self.GetProperty(Toolkit::ScrollView::Property::SCROLL_POSITION).Get(mScrollPostPosition);
}
// private functions
void ScrollView::PreAnimatedScrollSetup()
{
- // mPropertyPrePosition is our unclamped property with wrapping
- // mPropertyPosition is our final scroll position after clamping
+ // SCROLL_PRE_POSITION is our unclamped property with wrapping
+ // SCROLL_POSITION is our final scroll position after clamping
Actor self = Self();
Vector3 deltaPosition(mScrollPostPosition);
WrapPosition(mScrollPostPosition);
mDomainOffset += deltaPosition - mScrollPostPosition;
- Self().SetProperty(mPropertyDomainOffset, mDomainOffset);
+ Self().SetProperty(Toolkit::ScrollView::Property::SCROLL_DOMAIN_OFFSET, mDomainOffset);
if( mScrollStateFlags & SCROLL_X_STATE_MASK )
{
if( duration > Math::MACHINE_EPSILON_10 )
{
Actor self = Self();
- DALI_LOG_SCROLL_STATE("[0x%X], Animating from[%.2f] to[%.2f]", this, self.GetProperty(mPropertyPrePosition).Get<Vector3>().x, position );
+ DALI_LOG_SCROLL_STATE("[0x%X], Animating from[%.2f] to[%.2f]", this, self.GetProperty(Toolkit::ScrollView::Property::SCROLL_PRE_POSITION).Get<Vector3>().x, position );
mInternalXAnimation = Animation::New(duration);
DALI_LOG_SCROLL_STATE("[0x%X], mInternalXAnimation[0x%X]", this, mInternalXAnimation.GetObjectPtr() );
mInternalXAnimation.FinishedSignal().Connect(this, &ScrollView::OnScrollAnimationFinished);
- mInternalXAnimation.AnimateTo( Property(self, mPropertyPrePosition, 0), position, alpha, duration);
+ mInternalXAnimation.AnimateTo( Property(self, Toolkit::ScrollView::Property::SCROLL_PRE_POSITION, 0), position, alpha, duration);
mInternalXAnimation.Play();
// erase current state flags
if( duration > Math::MACHINE_EPSILON_10 )
{
Actor self = Self();
- DALI_LOG_SCROLL_STATE("[0x%X], Animating from[%.2f] to[%.2f]", this, self.GetProperty(mPropertyPrePosition).Get<Vector3>().y, position );
+ DALI_LOG_SCROLL_STATE("[0x%X], Animating from[%.2f] to[%.2f]", this, self.GetProperty(Toolkit::ScrollView::Property::SCROLL_PRE_POSITION).Get<Vector3>().y, position );
mInternalYAnimation = Animation::New(duration);
DALI_LOG_SCROLL_STATE("[0x%X], mInternalYAnimation[0x%X]", this, mInternalYAnimation.GetObjectPtr() );
mInternalYAnimation.FinishedSignal().Connect(this, &ScrollView::OnScrollAnimationFinished);
- mInternalYAnimation.AnimateTo( Property(self, mPropertyPrePosition, 1), position, alpha, TimePeriod(duration));
+ mInternalYAnimation.AnimateTo( Property(self, Toolkit::ScrollView::Property::SCROLL_PRE_POSITION, 1), position, alpha, TimePeriod(duration));
mInternalYAnimation.Play();
// erase current state flags
if( source == mInternalXAnimation )
{
- DALI_LOG_SCROLL_STATE("[0x%X] mInternalXAnimation[0x%X], expected[%.2f], actual[%.2f], post[%.2f]", this, mInternalXAnimation.GetObjectPtr(), mScrollTargetPosition.x, Self().GetProperty(mPropertyPrePosition).Get<Vector3>().x, mScrollPostPosition.x );
+ DALI_LOG_SCROLL_STATE("[0x%X] mInternalXAnimation[0x%X], expected[%.2f], actual[%.2f], post[%.2f]", this, mInternalXAnimation.GetObjectPtr(), mScrollTargetPosition.x, Self().GetProperty(SCROLL_PRE_POSITION).Get<Vector3>().x, mScrollPostPosition.x );
if( !(mScrollStateFlags & AnimatingInternalY) )
{
{
const RulerDomain rulerDomain = mRulerX->GetDomain();
mScrollPrePosition.x = -WrapInDomain(-mScrollPrePosition.x, rulerDomain.min, rulerDomain.max);
- DALI_LOG_SCROLL_STATE("[0x%X] Setting mPropertyPrePosition To[%.2f, %.2f]", this, mScrollPrePosition.x, mScrollPrePosition.y );
- handle.SetProperty(mPropertyPrePosition, mScrollPrePosition);
+ DALI_LOG_SCROLL_STATE("[0x%X] Setting SCROLL_PRE_POSITION To[%.2f, %.2f]", this, mScrollPrePosition.x, mScrollPrePosition.y );
+ handle.SetProperty(Toolkit::ScrollView::Property::SCROLL_PRE_POSITION, mScrollPrePosition);
}
SnapInternalXTo(mScrollPostPosition.x);
}
if( source == mInternalYAnimation )
{
- DALI_LOG_SCROLL_STATE("[0x%X] mInternalYAnimation[0x%X], expected[%.2f], actual[%.2f], post[%.2f]", this, mInternalYAnimation.GetObjectPtr(), mScrollTargetPosition.y, Self().GetProperty(mPropertyPrePosition).Get<Vector3>().y, mScrollPostPosition.y );
+ DALI_LOG_SCROLL_STATE("[0x%X] mInternalYAnimation[0x%X], expected[%.2f], actual[%.2f], post[%.2f]", this, mInternalYAnimation.GetObjectPtr(), mScrollTargetPosition.y, Self().GetProperty(SCROLL_PRE_POSITION).Get<Vector3>().y, mScrollPostPosition.y );
if( !(mScrollStateFlags & AnimatingInternalX) )
{
// wrap pre scroll y position and set it
const RulerDomain rulerDomain = mRulerY->GetDomain();
mScrollPrePosition.y = -WrapInDomain(-mScrollPrePosition.y, rulerDomain.min, rulerDomain.max);
- DALI_LOG_SCROLL_STATE("[0x%X] Setting mPropertyPrePosition To[%.2f, %.2f]", this, mScrollPrePosition.x, mScrollPrePosition.y );
- handle.SetProperty(mPropertyPrePosition, mScrollPrePosition);
+ DALI_LOG_SCROLL_STATE("[0x%X] Setting SCROLL_PRE_POSITION To[%.2f, %.2f]", this, mScrollPrePosition.x, mScrollPrePosition.y );
+ handle.SetProperty(Toolkit::ScrollView::Property::SCROLL_PRE_POSITION, mScrollPrePosition);
}
SnapInternalYTo(mScrollPostPosition.y);
}
mInternalXAnimation = Animation::New(duration);
mInternalXAnimation.FinishedSignal().Connect(this, &ScrollView::OnSnapInternalPositionFinished);
- mInternalXAnimation.AnimateTo(Property(self, mPropertyPrePosition, 0), position);
+ mInternalXAnimation.AnimateTo(Property(self, Toolkit::ScrollView::Property::SCROLL_PRE_POSITION, 0), position);
mInternalXAnimation.Play();
// add internal animation state flag
mInternalYAnimation = Animation::New(duration);
mInternalYAnimation.FinishedSignal().Connect(this, &ScrollView::OnSnapInternalPositionFinished);
- mInternalYAnimation.AnimateTo(Property(self, mPropertyPrePosition, 1), position);
+ mInternalYAnimation.AnimateTo(Property(self, Toolkit::ScrollView::Property::SCROLL_PRE_POSITION, 1), position);
mInternalYAnimation.Play();
// add internal animation state flag
UpdateLocalScrollProperties();
GestureStarted();
mPanning = true;
- self.SetProperty( mPropertyPanning, true );
- self.SetProperty( mPropertyScrollStartPagePosition, Vector3(gesture.position.x, gesture.position.y, 0.0f) );
+ self.SetProperty( Toolkit::ScrollView::Property::PANNING, true );
+ self.SetProperty( Toolkit::ScrollView::Property::START_PAGE_POSITION, Vector3(gesture.position.x, gesture.position.y, 0.0f) );
UpdateMainInternalConstraint();
break;
UpdateLocalScrollProperties();
mLastVelocity = gesture.velocity;
mPanning = false;
- self.SetProperty( mPropertyPanning, false );
+ self.SetProperty( Toolkit::ScrollView::Property::PANNING, false );
if( mScrollMainInternalPrePositionConstraint )
{
if(state == Gesture::Started)
{
Vector3 currentScrollPosition = GetCurrentScrollPosition();
- Self().SetProperty(mPropertyScrolling, true);
+ Self().SetProperty(Toolkit::ScrollView::Property::SCROLLING, true);
mScrolling = true;
DALI_LOG_SCROLL_STATE("[0x%X] mScrollStartedSignal 2 [%.2f, %.2f]", this, currentScrollPosition.x, currentScrollPosition.y);
mScrollStartedSignal.Emit( currentScrollPosition );
// if not animating, then this pan has completed right now.
SetScrollUpdateNotification(false);
mScrolling = false;
- Self().SetProperty(mPropertyScrolling, false);
+ Self().SetProperty(Toolkit::ScrollView::Property::SCROLLING, false);
if( fabs(mScrollPrePosition.x - mScrollTargetPosition.x) > Math::MACHINE_EPSILON_10 )
{
if( mPanning )
{
- constraint = Constraint::New<Vector3>( mPropertyPrePosition,
+ constraint = Constraint::New<Vector3>( Toolkit::ScrollView::Property::SCROLL_PRE_POSITION,
Source( detector, PanGestureDetector::Property::LOCAL_POSITION ),
Source( self, Actor::Property::SIZE ),
InternalPrePositionConstraint( mPanStartPosition, initialPanMask, mAxisAutoLock, mAxisAutoLockGradient, mLockAxis, mMaxOvershoot, mRulerX->GetDomain(), mRulerY->GetDomain() ) );
}
// 2. Second calculate the clamped position (actual position)
- constraint = Constraint::New<Vector3>( mPropertyPosition,
- LocalSource( mPropertyPrePosition ),
- LocalSource( mPropertyPositionMin ),
- LocalSource( mPropertyPositionMax ),
+ constraint = Constraint::New<Vector3>( Toolkit::ScrollView::Property::SCROLL_POSITION,
+ LocalSource( Toolkit::ScrollView::Property::SCROLL_PRE_POSITION ),
+ LocalSource( Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ),
+ LocalSource( Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ),
Source( self, Actor::Property::SIZE ),
InternalPositionConstraint( mRulerX->GetDomain(),
mRulerY->GetDomain(), mWrapMode ) );
mScrollMainInternalPositionConstraint = self.ApplyConstraint( constraint );
- constraint = Constraint::New<Vector3>( mPropertyPositionDelta,
- LocalSource( mPropertyPosition ),
- LocalSource( mPropertyDomainOffset ),
+ constraint = Constraint::New<Vector3>( Toolkit::ScrollView::Property::SCROLL_POSITION_DELTA,
+ LocalSource( Toolkit::ScrollView::Property::SCROLL_POSITION ),
+ LocalSource( Toolkit::ScrollView::Property::SCROLL_DOMAIN_OFFSET ),
InternalPositionDeltaConstraint );
mScrollMainInternalDeltaConstraint = self.ApplyConstraint( constraint );
- constraint = Constraint::New<Vector3>( mPropertyFinal,
- LocalSource( mPropertyPosition ),
- LocalSource( mPropertyOvershootX ),
- LocalSource( mPropertyOvershootY ),
+ constraint = Constraint::New<Vector3>( Toolkit::ScrollView::Property::SCROLL_FINAL,
+ LocalSource( Toolkit::ScrollView::Property::SCROLL_POSITION ),
+ LocalSource( Toolkit::ScrollView::Property::OVERSHOOT_X ),
+ LocalSource( Toolkit::ScrollView::Property::OVERSHOOT_Y ),
InternalFinalConstraint( FinalDefaultAlphaFunction,
FinalDefaultAlphaFunction ) );
mScrollMainInternalFinalConstraint = self.ApplyConstraint( constraint );
- constraint = Constraint::New<Vector3>( mPropertyRelativePosition,
- LocalSource( mPropertyPosition ),
- LocalSource( mPropertyPositionMin ),
- LocalSource( mPropertyPositionMax ),
+ constraint = Constraint::New<Vector3>( Toolkit::Scrollable::Property::SCROLL_RELATIVE_POSITION,
+ LocalSource( Toolkit::ScrollView::Property::SCROLL_POSITION ),
+ LocalSource( Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ),
+ LocalSource( Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ),
LocalSource( Actor::Property::SIZE ),
InternalRelativePositionConstraint );
mScrollMainInternalRelativeConstraint = self.ApplyConstraint( constraint );
}
if( enabled )
{
- Constraint constraint = Constraint::New<float>( mPropertyOvershootX,
- LocalSource( mPropertyPrePosition ),
- LocalSource( mPropertyPosition ),
- LocalSource( mPropertyCanScrollHorizontal ),
+ Constraint constraint = Constraint::New<float>( Toolkit::ScrollView::Property::OVERSHOOT_X,
+ LocalSource( Toolkit::ScrollView::Property::SCROLL_PRE_POSITION ),
+ LocalSource( Toolkit::ScrollView::Property::SCROLL_POSITION ),
+ LocalSource( Toolkit::Scrollable::Property::CAN_SCROLL_HORIZONTAL ),
OvershootXConstraint(mMaxOvershoot.x) );
mScrollMainInternalOvershootXConstraint = self.ApplyConstraint( constraint );
- constraint = Constraint::New<float>( mPropertyOvershootY,
- LocalSource( mPropertyPrePosition ),
- LocalSource( mPropertyPosition ),
- LocalSource( mPropertyCanScrollVertical ),
+ constraint = Constraint::New<float>( Toolkit::ScrollView::Property::OVERSHOOT_Y,
+ LocalSource( Toolkit::ScrollView::Property::SCROLL_PRE_POSITION ),
+ LocalSource( Toolkit::ScrollView::Property::SCROLL_POSITION ),
+ LocalSource( Toolkit::Scrollable::Property::CAN_SCROLL_VERTICAL ),
OvershootYConstraint(mMaxOvershoot.y) );
mScrollMainInternalOvershootYConstraint = self.ApplyConstraint( constraint );
}
else
{
- self.SetProperty(mPropertyOvershootX, 0.0f);
- self.SetProperty(mPropertyOvershootY, 0.0f);
+ self.SetProperty(Toolkit::ScrollView::Property::OVERSHOOT_X, 0.0f);
+ self.SetProperty(Toolkit::ScrollView::Property::OVERSHOOT_Y, 0.0f);
}
}
// MoveActor (scrolling)
constraint = Constraint::New<Vector3>( Actor::Property::POSITION,
- Source( self, mPropertyPosition ),
+ Source( self, Toolkit::ScrollView::Property::SCROLL_POSITION ),
MoveActorConstraint );
constraint.SetRemoveAction(Constraint::Discard);
ApplyConstraintToBoundActors(constraint);
LocalSource( Actor::Property::SCALE ),
LocalSource( Actor::Property::ANCHOR_POINT ),
LocalSource( Actor::Property::SIZE ),
- Source( self, mPropertyPositionMin ),
- Source( self, mPropertyPositionMax ),
- Source( self, mPropertyWrap ),
+ Source( self, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ),
+ Source( self, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ),
+ Source( self, Toolkit::ScrollView::Property::WRAP ),
WrapActorConstraint );
constraint.SetRemoveAction(Constraint::Discard);
ApplyConstraintToBoundActors(constraint);
virtual void OnChildRemove(Actor& child);
/**
- * @copydoc Dali::CustomActorImpl::OnPropertySet( Property::Index index, Property::Value propertyValue )
- */
- virtual void OnPropertySet( Property::Index index, Property::Value propertyValue );
-
- /**
* From CustomActorImpl; called after a touch-signal is received by the owning actor.
*
* We don't listen to these events as content within the contain may consume events.
/**
* Called whenever a snap animation has completed
* @param[in] source the Animation instance that has completed.
- * Resets all scrolling animations and states, leaving current scroll position at mPropertyPosition
+ * Resets all scrolling animations and states, leaving current scroll position at SCROLL_POSITION
*/
void ResetScrolling();
void OnScrollAnimationFinished( Animation& source );
/**
- * Called when either the X or Y internal scroll positions have finished snapping back to mPropertyPrePosition
+ * Called when either the X or Y internal scroll positions have finished snapping back to SCROLL_PRE_POSITION
*
* @param[in] source the Animation instance that has completed.
*/
/**
* @param[in] current The current color of this Actor
* @param[in] pagePositionProperty The page's position.
- * @param[in] scrollPositionProperty The scroll-view's position property (SCROLL_POSITION_PROPERTY_NAME)
- * @param[in] scrollPositionMin The minimum extent of this scroll domain. (SCROLL_POSITION_MIN_PROPERTY_NAME)
- * @param[in] scrollPositionMax The maximum extent of this scroll domain. (SCROLL_POSITION_MIN_PROPERTY_NAME)
+ * @param[in] scrollPositionProperty The scroll-view's position property (SCROLL_POSITION)
+ * @param[in] scrollPositionMin The minimum extent of this scroll domain. (SCROLL_POSITION_MIN)
+ * @param[in] scrollPositionMax The maximum extent of this scroll domain. (SCROLL_POSITION_MAX)
* @param[in] pageSizeProperty The size of the page. (scrollView SIZE)
- * @param[in] scrollWrap Whether scroll wrap has been enabled or not (SCROLL_WRAP_PROPERTY_NAME)
+ * @param[in] scrollWrap Whether scroll wrap has been enabled or not (WRAP)
* @return The new color of this Actor.
*/
Vector4 ColorConstraint(const Vector4& current,
/**
* @param[in] current The current position
* @param[in] pagePositionProperty The page's position.
- * @param[in] scrollPositionProperty The scroll-view's position property (SCROLL_POSITION_PROPERTY_NAME)
- * @param[in] scrollPositionMin The minimum extent of this scroll domain. (SCROLL_POSITION_MIN_PROPERTY_NAME)
- * @param[in] scrollPositionMax The maximum extent of this scroll domain. (SCROLL_POSITION_MIN_PROPERTY_NAME)
+ * @param[in] scrollPositionProperty The scroll-view's position property (SCROLL_POSITION)
+ * @param[in] scrollPositionMin The minimum extent of this scroll domain. (SCROLL_POSITION_MIN)
+ * @param[in] scrollPositionMax The maximum extent of this scroll domain. (SCROLL_POSITION_MAX)
* @param[in] pageSizeProperty The size of the page. (scrollView SIZE)
- * @param[in] scrollWrap Whether scroll wrap has been enabled or not (SCROLL_WRAP_PROPERTY_NAME)
+ * @param[in] scrollWrap Whether scroll wrap has been enabled or not (WRAP)
* @return The new position of this Actor.
*/
Vector3 PositionConstraint(const Vector3& current,
Constraint constraint;
constraint = Constraint::New<Vector4>( Actor::Property::COLOR,
LocalSource(Actor::Property::POSITION),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_FINAL_PROPERTY_NAME ) ),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_POSITION_MIN_PROPERTY_NAME ) ),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_POSITION_MAX_PROPERTY_NAME ) ),
+ Source(scrollView, Toolkit::ScrollView::Property::SCROLL_FINAL ),
+ Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ),
+ Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ),
Source(scrollView, Actor::Property::SIZE ),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_WRAP_PROPERTY_NAME ) ),
+ Source(scrollView, Toolkit::ScrollView::Property::WRAP ),
boost::bind( &ScrollPageCarouselEffectInfo::ColorConstraint, info, _1, _2, _3, _4, _5, _6, _7) );
constraint.SetRemoveAction( Constraint::Discard );
constraint = Constraint::New<Vector3>( Actor::Property::POSITION,
LocalSource(Actor::Property::POSITION),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_FINAL_PROPERTY_NAME ) ),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_POSITION_MIN_PROPERTY_NAME ) ),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_POSITION_MAX_PROPERTY_NAME ) ),
+ Source(scrollView, Toolkit::ScrollView::Property::SCROLL_FINAL ),
+ Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ),
+ Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ),
Source(scrollView, Actor::Property::SIZE ),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_WRAP_PROPERTY_NAME ) ),
+ Source(scrollView, Toolkit::ScrollView::Property::WRAP ),
boost::bind( &ScrollPageCarouselEffectInfo::PositionConstraint, info, _1, _2, _3, _4, _5, _6, _7) );
constraint.SetRemoveAction( Constraint::Discard );
/**
* @param[in] current The current orientation of this Actor
* @param[in] pagePositionProperty The page's position.
- * @param[in] scrollPositionProperty The scroll-view's position property (SCROLL_POSITION_PROPERTY_NAME)
- * @param[in] scrollPositionMin The minimum extent of this scroll domain. (SCROLL_POSITION_MIN_PROPERTY_NAME)
- * @param[in] scrollPositionMax The maximum extent of this scroll domain. (SCROLL_POSITION_MIN_PROPERTY_NAME)
+ * @param[in] scrollPositionProperty The scroll-view's position property (SCROLL_POSITION)
+ * @param[in] scrollPositionMin The minimum extent of this scroll domain. (SCROLL_POSITION_MIN)
+ * @param[in] scrollPositionMax The maximum extent of this scroll domain. (SCROLL_POSITION_MAX)
* @param[in] pageSizeProperty The size of the page. (scrollView SIZE)
- * @param[in] scrollWrap Whether scroll wrap has been enabled or not (SCROLL_WRAP_PROPERTY_NAME)
+ * @param[in] scrollWrap Whether scroll wrap has been enabled or not (WRAP)
* @return The new orientation of this Actor.
*/
Quaternion RotationConstraint(const Quaternion& current,
/**
* @param[in] current The current color of this Actor
* @param[in] pagePositionProperty The page's position.
- * @param[in] scrollPositionProperty The scroll-view's position property (SCROLL_POSITION_PROPERTY_NAME)
- * @param[in] scrollPositionMin The minimum extent of this scroll domain. (SCROLL_POSITION_MIN_PROPERTY_NAME)
- * @param[in] scrollPositionMax The maximum extent of this scroll domain. (SCROLL_POSITION_MIN_PROPERTY_NAME)
+ * @param[in] scrollPositionProperty The scroll-view's position property (SCROLL_POSITION)
+ * @param[in] scrollPositionMin The minimum extent of this scroll domain. (SCROLL_POSITION_MIN)
+ * @param[in] scrollPositionMax The maximum extent of this scroll domain. (SCROLL_POSITION_MAX)
* @param[in] pageSizeProperty The size of the page. (scrollView SIZE)
- * @param[in] scrollWrap Whether scroll wrap has been enabled or not (SCROLL_WRAP_PROPERTY_NAME)
+ * @param[in] scrollWrap Whether scroll wrap has been enabled or not (WRAP)
* @return The new color of this Actor.
*/
Vector4 ColorConstraint(const Vector4& current,
/**
* @param[in] current The current position
* @param[in] pagePositionProperty The page's position.
- * @param[in] scrollPositionProperty The scroll-view's position property (SCROLL_POSITION_PROPERTY_NAME)
- * @param[in] scrollPositionMin The minimum extent of this scroll domain. (SCROLL_POSITION_MIN_PROPERTY_NAME)
- * @param[in] scrollPositionMax The maximum extent of this scroll domain. (SCROLL_POSITION_MIN_PROPERTY_NAME)
+ * @param[in] scrollPositionProperty The scroll-view's position property (SCROLL_POSITION)
+ * @param[in] scrollPositionMin The minimum extent of this scroll domain. (SCROLL_POSITION_MIN)
+ * @param[in] scrollPositionMax The maximum extent of this scroll domain. (SCROLL_POSITION_MAX)
* @param[in] pageSizeProperty The size of the page. (scrollView SIZE)
- * @param[in] scrollWrap Whether scroll wrap has been enabled or not (SCROLL_WRAP_PROPERTY_NAME)
+ * @param[in] scrollWrap Whether scroll wrap has been enabled or not (WRAP)
* @return The new position of this Actor.
*/
Vector3 PositionConstraint(const Vector3& current,
Constraint constraint;
constraint = Constraint::New<Quaternion>( Actor::Property::ORIENTATION,
LocalSource(Actor::Property::POSITION),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_FINAL_PROPERTY_NAME ) ),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_POSITION_MIN_PROPERTY_NAME ) ),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_POSITION_MAX_PROPERTY_NAME ) ),
+ Source(scrollView, Toolkit::ScrollView::Property::SCROLL_FINAL ),
+ Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ),
+ Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ),
Source(scrollView, Actor::Property::SIZE ),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_WRAP_PROPERTY_NAME ) ),
+ Source(scrollView, Toolkit::ScrollView::Property::WRAP ),
boost::bind( &ScrollPageCubeEffectInfo::RotationConstraint, info, _1, _2, _3, _4, _5, _6, _7) );
constraint.SetRemoveAction( Constraint::Discard );
constraint = Constraint::New<Vector4>( Actor::Property::COLOR,
LocalSource(Actor::Property::POSITION),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_FINAL_PROPERTY_NAME ) ),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_POSITION_MIN_PROPERTY_NAME ) ),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_POSITION_MAX_PROPERTY_NAME ) ),
+ Source(scrollView, Toolkit::ScrollView::Property::SCROLL_FINAL ),
+ Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ),
+ Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ),
Source(scrollView, Actor::Property::SIZE ),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_WRAP_PROPERTY_NAME ) ),
+ Source(scrollView, Toolkit::ScrollView::Property::WRAP ),
boost::bind( &ScrollPageCubeEffectInfo::ColorConstraint, info, _1, _2, _3, _4, _5, _6, _7) );
constraint.SetRemoveAction( Constraint::Discard );
constraint = Constraint::New<Vector3>( Actor::Property::POSITION,
LocalSource(Actor::Property::POSITION),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_FINAL_PROPERTY_NAME ) ),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_POSITION_MIN_PROPERTY_NAME ) ),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_POSITION_MAX_PROPERTY_NAME ) ),
+ Source(scrollView, Toolkit::ScrollView::Property::SCROLL_FINAL ),
+ Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ),
+ Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ),
Source(scrollView, Actor::Property::SIZE ),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_WRAP_PROPERTY_NAME ) ),
+ Source(scrollView, Toolkit::ScrollView::Property::WRAP ),
boost::bind( &ScrollPageCubeEffectInfo::PositionConstraint, info, _1, _2, _3, _4, _5, _6, _7) );
constraint.SetRemoveAction( Constraint::Discard );
/**
* @param[in] current The current orientation of this Actor
* @param[in] pagePositionProperty The page's position.
- * @param[in] scrollPositionProperty The scroll-view's position property (SCROLL_POSITION_PROPERTY_NAME)
- * @param[in] scrollPositionMin The minimum extent of this scroll domain. (SCROLL_POSITION_MIN_PROPERTY_NAME)
- * @param[in] scrollPositionMax The maximum extent of this scroll domain. (SCROLL_POSITION_MIN_PROPERTY_NAME)
+ * @param[in] scrollPositionProperty The scroll-view's position property (SCROLL_POSITION)
+ * @param[in] scrollPositionMin The minimum extent of this scroll domain. (SCROLL_POSITION_MIN)
+ * @param[in] scrollPositionMax The maximum extent of this scroll domain. (SCROLL_POSITION_MAX)
* @param[in] pageSizeProperty The size of the page. (scrollView SIZE)
- * @param[in] scrollPageStartPositionProperty The position of the page where scrolling started. (SCROLL_START_PAGE_POSITION_PROPERTY_NAME)
+ * @param[in] scrollPageStartPositionProperty The position of the page where scrolling started. (START_PAGE_POSITION)
* @return The new orientation of this Actor.
*/
Quaternion RotationConstraint(const Quaternion& current,
/**
* @param[in] current The current color of this Actor
* @param[in] pagePositionProperty The page's position.
- * @param[in] scrollPositionProperty The scroll-view's position property (SCROLL_POSITION_PROPERTY_NAME)
- * @param[in] scrollPositionMin The minimum extent of this scroll domain. (SCROLL_POSITION_MIN_PROPERTY_NAME)
- * @param[in] scrollPositionMax The maximum extent of this scroll domain. (SCROLL_POSITION_MIN_PROPERTY_NAME)
+ * @param[in] scrollPositionProperty The scroll-view's position property (SCROLL_POSITION)
+ * @param[in] scrollPositionMin The minimum extent of this scroll domain. (SCROLL_POSITION_MIN)
+ * @param[in] scrollPositionMax The maximum extent of this scroll domain. (SCROLL_POSITION_MAX)
* @param[in] pageSizeProperty The size of the page. (scrollView SIZE)
- * @param[in] scrollPageStartPositionProperty The position of the page where scrolling started. (SCROLL_START_PAGE_POSITION_PROPERTY_NAME)
+ * @param[in] scrollPageStartPositionProperty The position of the page where scrolling started. (START_PAGE_POSITION)
* @return The new color of this Actor.
*/
Vector4 ColorConstraint(const Vector4& current,
/**
* @param[in] current The current position
* @param[in] pagePositionProperty The page's position.
- * @param[in] scrollPositionProperty The scroll-view's position property (SCROLL_POSITION_PROPERTY_NAME)
- * @param[in] scrollPositionMin The minimum extent of this scroll domain. (SCROLL_POSITION_MIN_PROPERTY_NAME)
- * @param[in] scrollPositionMax The maximum extent of this scroll domain. (SCROLL_POSITION_MIN_PROPERTY_NAME)
+ * @param[in] scrollPositionProperty The scroll-view's position property (SCROLL_POSITION)
+ * @param[in] scrollPositionMin The minimum extent of this scroll domain. (SCROLL_POSITION_MIN)
+ * @param[in] scrollPositionMax The maximum extent of this scroll domain. (SCROLL_POSITION_MAX)
* @param[in] pageSizeProperty The size of the page. (scrollView SIZE)
- * @param[in] scrollPageStartPositionProperty The position of the page where scrolling started. (SCROLL_START_PAGE_POSITION_PROPERTY_NAME)
+ * @param[in] scrollPageStartPositionProperty The position of the page where scrolling started. (START_PAGE_POSITION)
* @return The new position of this Actor.
*/
Vector3 PositionConstraint(const Vector3& current,
Constraint constraint;
constraint = Constraint::New<Quaternion>( Actor::Property::ORIENTATION,
LocalSource(Actor::Property::POSITION),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_FINAL_PROPERTY_NAME ) ),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_POSITION_MIN_PROPERTY_NAME ) ),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_POSITION_MAX_PROPERTY_NAME ) ),
+ Source(scrollView, Toolkit::ScrollView::Property::SCROLL_FINAL ),
+ Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ),
+ Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ),
Source(scrollView, Actor::Property::SIZE ),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_START_PAGE_POSITION_PROPERTY_NAME ) ),
+ Source(scrollView, Toolkit::ScrollView::Property::START_PAGE_POSITION ),
boost::bind( &ScrollPageSpiralEffectInfo::RotationConstraint, info, _1, _2, _3, _4, _5, _6, _7) );
constraint.SetRemoveAction( Constraint::Discard );
constraint = Constraint::New<Vector4>( Actor::Property::COLOR,
LocalSource(Actor::Property::POSITION),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_FINAL_PROPERTY_NAME ) ),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_POSITION_MIN_PROPERTY_NAME ) ),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_POSITION_MAX_PROPERTY_NAME ) ),
+ Source(scrollView, Toolkit::ScrollView::Property::SCROLL_FINAL ),
+ Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ),
+ Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ),
Source(scrollView, Actor::Property::SIZE ),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_START_PAGE_POSITION_PROPERTY_NAME ) ),
+ Source(scrollView, Toolkit::ScrollView::Property::START_PAGE_POSITION ),
boost::bind( &ScrollPageSpiralEffectInfo::ColorConstraint, info, _1, _2, _3, _4, _5, _6, _7) );
constraint.SetRemoveAction( Constraint::Discard );
constraint = Constraint::New<Vector3>( Actor::Property::POSITION,
LocalSource(Actor::Property::POSITION),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_FINAL_PROPERTY_NAME ) ),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_POSITION_MIN_PROPERTY_NAME ) ),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_POSITION_MAX_PROPERTY_NAME ) ),
+ Source(scrollView, Toolkit::ScrollView::Property::SCROLL_FINAL ),
+ Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ),
+ Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ),
Source(scrollView, Actor::Property::SIZE ),
- Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollView::SCROLL_START_PAGE_POSITION_PROPERTY_NAME ) ),
+ Source(scrollView, Toolkit::ScrollView::Property::START_PAGE_POSITION ),
boost::bind( &ScrollPageSpiralEffectInfo::PositionConstraint, info, _1, _2, _3, _4, _5, _6, _7) );
constraint.SetRemoveAction( Constraint::Discard );
void ScrollViewWobbleEffect::AttachActor(Actor actor)
{
- Property::Index propertyPosition = actor.GetPropertyIndex(Toolkit::ScrollView::SCROLL_POSITION_PROPERTY_NAME);
- Property::Index propertyOvershootX = actor.GetPropertyIndex(Toolkit::ScrollView::SCROLL_OVERSHOOT_X_PROPERTY_NAME);
- Property::Index propertyOvershootY = actor.GetPropertyIndex(Toolkit::ScrollView::SCROLL_OVERSHOOT_Y_PROPERTY_NAME);
-
// Create effect-overshoot property if not already created.
Property::Index propertyEffectOvershoot = actor.GetPropertyIndex(Toolkit::ScrollViewWobbleEffect::EFFECT_OVERSHOOT);
if(propertyEffectOvershoot == Property::INVALID_INDEX)
Constraint constraint = Constraint::New<Vector3>( propertyEffectOvershoot,
Source(scrollView, mPropertyTime),
- Source(actor, propertyPosition),
- Source(actor, propertyOvershootX),
- Source(actor, propertyOvershootY),
+ Source(actor, Toolkit::ScrollView::Property::SCROLL_POSITION),
+ Source(actor, Toolkit::ScrollView::Property::OVERSHOOT_X),
+ Source(actor, Toolkit::ScrollView::Property::OVERSHOOT_Y),
ScrollViewWobbleEffectConstraint(*this) );
actor.ApplyConstraint(constraint);
}
DALI_PROPERTY_REGISTRATION( Scrollable, "overshoot-effect-color", VECTOR4, OVERSHOOT_EFFECT_COLOR )
DALI_PROPERTY_REGISTRATION( Scrollable, "overshoot-animation-speed", FLOAT, OVERSHOOT_ANIMATION_SPEED )
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( Scrollable, "scroll-relative-position", VECTOR3, SCROLL_RELATIVE_POSITION)
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( Scrollable, "scroll-position-min", VECTOR3, SCROLL_POSITION_MIN)
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( Scrollable, "scroll-position-max", VECTOR3, SCROLL_POSITION_MAX)
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( Scrollable, "scroll-direction", VECTOR3, SCROLL_DIRECTION)
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( Scrollable, "can-scroll-vertical", BOOLEAN, CAN_SCROLL_VERTICAL)
+DALI_ANIMATABLE_PROPERTY_REGISTRATION( Scrollable, "can-scroll-horizontal", BOOLEAN, CAN_SCROLL_HORIZONTAL)
+
DALI_SIGNAL_REGISTRATION( Scrollable, "scroll-started", SIGNAL_SCROLL_STARTED )
DALI_SIGNAL_REGISTRATION( Scrollable, "scroll-completed", SIGNAL_SCROLL_COMPLETED )
DALI_SIGNAL_REGISTRATION( Scrollable, "scroll-updated", SIGNAL_SCROLL_UPDATED )
}
-const char* const Scrollable::SCROLLABLE_CAN_SCROLL_VERTICAL = "scrollable-can-scroll-vertical";
-const char* const Scrollable::SCROLLABLE_CAN_SCROLL_HORIZONTAL = "scrollable-can-scroll-horizontal";
-
///////////////////////////////////////////////////////////////////////////////////////////////////
// Scrollable
///////////////////////////////////////////////////////////////////////////////////////////////////
: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS | NO_SIZE_NEGOTIATION ) ),
mOvershootEffectColor( DEFAULT_OVERSHOOT_COLOUR ),
mOvershootAnimationSpeed ( DEFAULT_OVERSHOOT_ANIMATION_SPEED ),
- mPropertyRelativePosition(Property::INVALID_INDEX),
- mPropertyPositionMin(Property::INVALID_INDEX),
- mPropertyPositionMax(Property::INVALID_INDEX),
- mPropertyScrollDirection(Property::INVALID_INDEX),
- mPropertyCanScrollVertical(Property::INVALID_INDEX),
- mPropertyCanScrollHorizontal(Property::INVALID_INDEX),
mOvershootEnabled(false)
{
}
mComponents.clear();
}
-void Scrollable::RegisterCommonProperties()
-{
- Actor self = Self();
-
- // Register properties.
- mPropertyRelativePosition = self.RegisterProperty(Toolkit::Scrollable::SCROLL_RELATIVE_POSITION_PROPERTY_NAME, Vector3::ZERO);
- mPropertyPositionMin = self.RegisterProperty(Toolkit::Scrollable::SCROLL_POSITION_MIN_PROPERTY_NAME, Vector3::ZERO);
- mPropertyPositionMax = self.RegisterProperty(Toolkit::Scrollable::SCROLL_POSITION_MAX_PROPERTY_NAME, Vector3::ZERO);
- mPropertyScrollDirection = self.RegisterProperty(Toolkit::Scrollable::SCROLL_DIRECTION_PROPERTY_NAME, Vector3::ZERO);
- mPropertyCanScrollVertical = self.RegisterProperty(SCROLLABLE_CAN_SCROLL_VERTICAL, true);
- mPropertyCanScrollHorizontal = self.RegisterProperty(SCROLLABLE_CAN_SCROLL_HORIZONTAL, true);
-}
-
bool Scrollable::IsScrollComponentEnabled(Toolkit::Scrollable::ScrollComponentType type) const
{
if(type == Toolkit::Scrollable::OvershootIndicator)
class Scrollable : public Control
{
public:
- static const char* const SCROLLABLE_CAN_SCROLL_VERTICAL;
- static const char* const SCROLLABLE_CAN_SCROLL_HORIZONTAL;
-
- /**
- * Create a new Scrollable.
- * @return A public handle to the newly allocated Scrollable.
- */
-// static Dali::Toolkit::Scrollable New();
-
-public:
/**
* @copydoc Dali::Toolkit::Scrollable::IsScrollComponentEnabled(Scrollable::ScrollComponentType type)
*/
virtual ~Scrollable();
- /**
- * Register common properties
- */
- void RegisterCommonProperties();
-
private:
/**
Vector4 mOvershootEffectColor; ///<The color of the overshoot bouncing effect
float mOvershootAnimationSpeed; ///<The speed of the overshoot animation (pixels per second)
- Property::Index mPropertyRelativePosition;///< Scroll Relative Position ("scroll-relative-position") [range from 0.0f - 1.0f in each axes]
- Property::Index mPropertyPositionMin; ///< Scroll Domain Minimum ("position-min")
- Property::Index mPropertyPositionMax; ///< Scroll Domain Maximum ("position-max")
- Property::Index mPropertyScrollDirection; ///< Scroll direction ("scroll-direction")
- Property::Index mPropertyCanScrollVertical; ///< Whether the current scroll domain is large enough to scroll vertically
- Property::Index mPropertyCanScrollHorizontal; ///< Whether the current scroll domain is large enough to scroll horizontally
-
std::map<Toolkit::Scrollable::ScrollComponentType, ScrollComponentPtr> mComponent; ///< ScrollComponent (such as a scrollbar/page indicator/status)
Toolkit::Scrollable::ScrollStartedSignalType mScrollStartedSignal;
mShadowPlaneBg = shadowPlane;
mShadowPlane = ImageActor::New();
+ mShadowPlane.SetName( "SHADOW_PLANE" );
mShadowPlane.SetParentOrigin(ParentOrigin::CENTER);
mShadowPlane.SetAnchorPoint(AnchorPoint::CENTER);
mBlurFilter.SetPixelFormat(Pixel::RGBA8888);
mBlurRootActor = Actor::New();
-
+ mBlurRootActor.SetName( "BLUR_ROOT_ACTOR" );
mBlurRootActor.SetRelayoutEnabled( true );
+
// Turn off inheritance to ensure filter renders properly
mBlurRootActor.SetPositionInheritanceMode(USE_PARENT_POSITION);
mBlurRootActor.SetInheritOrientation(false);
// Use height-for-width negotiation by default
self.SetResizePolicy( FILL_TO_PARENT, WIDTH );
- self.SetDimensionDependency( HEIGHT, WIDTH );
+ self.SetResizePolicy( DIMENSION_DEPENDENCY, HEIGHT );
}
void TextLabel::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange change )
textSize.width = std::min( textSize.width, OPTION_MAX_WIDTH - 2.f * OPTION_MARGIN_WIDTH );
// Set the size to the text. Text will be ellipsized if exceeds the max width.
- captionTextLabel.SetPreferredSize( textSize.GetVectorXY() );
- pressedCaptionTextLabel.SetPreferredSize( textSize.GetVectorXY() );
+ captionTextLabel.SetSize( textSize.GetVectorXY() );
+ pressedCaptionTextLabel.SetSize( textSize.GetVectorXY() );
// 4. Calculate the size of option.
const Vector2 optionSize( std::min( OPTION_MAX_WIDTH, std::max( OPTION_MIN_WIDTH, std::max( textSize.width, OPTION_ICON_SIZE.width ) + 2.f * OPTION_MARGIN_WIDTH ) ),
DEFAULT_POPUP_MAX_SIZE.height - mNinePatchMargins.z - mNinePatchMargins.w );
- optionContainer.SetPreferredSize( optionSize );
- optionPressedContainer.SetPreferredSize( optionSize );
+ optionContainer.SetSize( optionSize );
+ optionPressedContainer.SetSize( optionSize );
// 5. Create a option.
Toolkit::PushButton option = Toolkit::PushButton::New();
option.SetResizePolicy( FIXED, ALL_DIMENSIONS );
- option.SetPreferredSize( optionSize );
+ option.SetSize( optionSize );
option.SetAnchorPoint( AnchorPoint::TOP_LEFT );
option.SetX( mContentSize.width );
option.SetName( name );
ImageActor divider = Toolkit::CreateSolidColorActor( Color::WHITE );
divider.SetResizePolicy( FIXED, ALL_DIMENSIONS );
- divider.SetPreferredSize( size );
+ divider.SetSize( size );
divider.SetParentOrigin( ParentOrigin::TOP_LEFT );
divider.SetAnchorPoint( AnchorPoint::TOP_LEFT );
divider.SetPosition( mContentSize.width - POPUP_DIVIDER_WIDTH, 0.0f );
stencil.SetRelayoutEnabled( true );
self.SetResizePolicy( FIXED, ALL_DIMENSIONS );
- self.SetPreferredSize( mRequiredPopUpSize ); // control matches stencil size
+ self.SetSize( mRequiredPopUpSize ); // control matches stencil size
mStencilLayer.SetResizePolicy( FIXED, ALL_DIMENSIONS );
- mStencilLayer.SetPreferredSize( size ); // matches stencil size
+ mStencilLayer.SetSize( size ); // matches stencil size
stencil.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
scrollview.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
// ToolBar image
background.SetParentOrigin( Dali::ParentOrigin::TOP_CENTER );
background.SetAnchorPoint( Dali::AnchorPoint::TOP_CENTER );
- background.SetPreferredSize( Vector2( mToolBarSize.width, mToolBarSize.height ) );
+ background.SetSize( Vector2( mToolBarSize.width, mToolBarSize.height ) );
RenderableActor renderableActor = RenderableActor::DownCast( background );
if ( renderableActor )
void ToolBar::OnControlSizeSet( const Vector3& targetSize )
{
mToolBarSize = targetSize;
- mBackground.SetPreferredSize( Vector2( mToolBarSize.width, mToolBarSize.height ) );
+ mBackground.SetSize( Vector2( mToolBarSize.width, mToolBarSize.height ) );
}
} // namespace Internal
void View::OrientationChanged( Dali::Orientation orientation )
{
+ Actor self = Self();
+
// Nothing to do if orientation doesn't really change.
if ( orientation.GetDegrees() == mOrientation || !mAutoRotateEnabled )
{
// has parent so we expect it to be on stage
mRotateAnimation = Animation::New( ROTATION_ANIMATION_DURATION );
- mRotateAnimation.RotateTo( Self(), Degree( -orientation.GetDegrees() ), Vector3::ZAXIS, AlphaFunctions::EaseOut );
+ mRotateAnimation.AnimateTo( Property( self, Actor::Property::ORIENTATION ), Quaternion( -orientation.GetRadians(), Vector3::ZAXIS ), AlphaFunctions::EaseOut );
// Resize the view
if( mFullScreen )
{
const Vector2& stageSize( Stage::GetCurrent().GetSize() );
- const Vector3& currentSize( Self().GetCurrentSize() );
+ const Vector3& currentSize( self.GetCurrentSize() );
float minSize = std::min( stageSize.width, stageSize.height );
float maxSize = std::max( stageSize.width, stageSize.height );
{
// width grows, shrink height faster
Vector3 shrink( currentSize );shrink.height = targetSize.height;
- mRotateAnimation.Resize( Self(), shrink, AlphaFunctions::EaseOut, 0.0f, ROTATION_ANIMATION_DURATION * 0.5f );
- mRotateAnimation.Resize( Self(), targetSize, AlphaFunctions::EaseIn, 0.0f, ROTATION_ANIMATION_DURATION );
+ mRotateAnimation.AnimateTo( Property( self, Actor::Property::SIZE ), shrink, AlphaFunctions::EaseOut, TimePeriod( 0.0f, ROTATION_ANIMATION_DURATION * 0.5f ) );
+ mRotateAnimation.AnimateTo( Property( self, Actor::Property::SIZE ), targetSize, AlphaFunctions::EaseIn, TimePeriod( 0.0f, ROTATION_ANIMATION_DURATION ) );
}
else
{
// height grows, shrink width faster
Vector3 shrink( currentSize );shrink.width = targetSize.width;
- mRotateAnimation.Resize( Self(), shrink, AlphaFunctions::EaseOut, 0.0f, ROTATION_ANIMATION_DURATION * 0.5f );
- mRotateAnimation.Resize( Self(), targetSize, AlphaFunctions::EaseIn, 0.0f, ROTATION_ANIMATION_DURATION );
+ mRotateAnimation.AnimateTo( Property( self, Actor::Property::SIZE ), shrink, AlphaFunctions::EaseOut, TimePeriod( 0.0f, ROTATION_ANIMATION_DURATION * 0.5f ) );
+ mRotateAnimation.AnimateTo( Property( self, Actor::Property::SIZE ), targetSize, AlphaFunctions::EaseIn, TimePeriod( 0.0f, ROTATION_ANIMATION_DURATION ) );
}
}
// create actor to render input with applied emboss effect
mActorForInput = ImageActor::New( mInputImage );
mActorForInput.SetParentOrigin( ParentOrigin::CENTER );
- mActorForInput.SetSize(mTargetSize);
+ mActorForInput.SetSize( mTargetSize );
mActorForInput.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) );
// create internal offscreen for result of horizontal pass
// create an actor to render mImageForHorz for vertical blur pass
mActorForHorz = ImageActor::New( mImageForHorz );
mActorForHorz.SetParentOrigin( ParentOrigin::CENTER );
- mActorForHorz.SetSize(mTargetSize);
+ mActorForHorz.SetSize( mTargetSize );
mActorForHorz.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) );
// create internal offscreen for result of the two pass blurred image
// create an actor to blend the blurred image and the input image with the given blur strength
mActorForBlending = ImageActor::New( mBlurredImage );
mActorForBlending.SetParentOrigin( ParentOrigin::CENTER );
- mActorForBlending.SetSize(mTargetSize);
+ mActorForBlending.SetSize( mTargetSize );
mActorForBlending.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) );
mRootActor.Add( mActorForInput );
* limitations under the License.
*
*/
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/base-object.h>
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/scripting/script.h>
#endif
mGrabArea.SetParentOrigin( ParentOrigin::TOP_CENTER );
mGrabArea.SetAnchorPoint( AnchorPoint::TOP_CENTER );
- mGrabArea.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
- mGrabArea.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
+ mGrabArea.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS );
mGrabArea.SetSizeModeFactor( DEFAULT_GRAB_HANDLE_RELATIVE_SIZE );
mGrabHandle.Add( mGrabArea );
#ifdef DECORATOR_DEBUG
primary.grabArea.SetName("SelectionHandleOneGrabArea");
#endif
- primary.grabArea.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
+ primary.grabArea.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS );
primary.grabArea.SetSizeModeFactor( DEFAULT_SELECTION_HANDLE_RELATIVE_SIZE );
primary.grabArea.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
#ifdef DECORATOR_DEBUG
secondary.grabArea.SetName("SelectionHandleTwoGrabArea");
#endif
- secondary.grabArea.SetSizeMode( SIZE_RELATIVE_TO_PARENT );
+ secondary.grabArea.SetResizePolicy( SIZE_RELATIVE_TO_PARENT, ALL_DIMENSIONS );
secondary.grabArea.SetSizeModeFactor( DEFAULT_SELECTION_HANDLE_RELATIVE_SIZE );
secondary.grabArea.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION );
mTiles[mContainerIndex][actorIndex].TranslateBy( resetTranslation );
mTiles[mContainerIndex][actorIndex].SetOrientation( Radian( angle), axis );
}
- mAnimation.RotateTo( mBoxes[actorIndex], Radian( -angle ), axis, AlphaFunctions::EaseInOutSine );
+ mAnimation.AnimateTo( Property( mBoxes[actorIndex], Actor::Property::ORIENTATION ), Quaternion( Radian( -angle ), axis ), AlphaFunctions::EaseInOutSine );
Vector3 position(mBoxes[actorIndex].GetCurrentPosition());
- mAnimation.MoveTo(mBoxes[actorIndex], position*mDisplacementRatio+Vector3(0.f,0.f,mCubeDisplacement), AlphaFunctions::Bounce);
- mAnimation.ColorTo( mTiles[mContainerIndex^1][actorIndex], HALF_BRIGHTNESS, AlphaFunctions::EaseOut );
- mAnimation.ColorTo( mTiles[mContainerIndex][actorIndex], FULL_BRIGHTNESS, AlphaFunctions::EaseIn );
+ mAnimation.AnimateTo( Property( mBoxes[actorIndex], Actor::Property::POSITION ), position * mDisplacementRatio + Vector3( 0.f, 0.f, mCubeDisplacement ), AlphaFunctions::Bounce );
+ mAnimation.AnimateTo( Property( mTiles[mContainerIndex^1][actorIndex], Actor::Property::COLOR ), HALF_BRIGHTNESS, AlphaFunctions::EaseOut );
+ mAnimation.AnimateTo( Property( mTiles[mContainerIndex][actorIndex], Actor::Property::COLOR ), FULL_BRIGHTNESS, AlphaFunctions::EaseIn );
}
} // namespace Internal
// helper actor to create a off-screen image using shader effect
mEmptyImage = ImageActor::New( placeHolder );
+ mEmptyImage.SetRelayoutEnabled( false );
mEmptyImage.SetSize(Stage::GetCurrent().GetSize());
mEmptyImage.SetParentOrigin( ParentOrigin::CENTER );
mEmptyImage.SetAnchorPoint( AnchorPoint::CENTER );
- mEmptyImage.SetRelayoutEnabled( false );
mFullImageCreator = FullAreaImageCreator::New();
mEmptyImage.SetShaderEffect( mFullImageCreator );
Stage::GetCurrent().Add(mEmptyImage);
ImageActor CubeTransitionEffect::CreateTile( Image image, const Vector4& color )
{
ImageActor tile = ImageActor::New( image );
+ tile.SetRelayoutEnabled( false );
tile.SetParentOrigin( ParentOrigin::CENTER );
tile.SetAnchorPoint( AnchorPoint::CENTER );
- tile.SetRelayoutEnabled( false );
tile.SetSize( mTileSize );
tile.SetColorMode( Dali::USE_OWN_COLOR );
tile.SetColor( color );
sideTile.TranslateBy( resetTranslation );
sideTile.SetOrientation( Radian( angle), Vector3::YAXIS );
}
- mAnimation.RotateTo( currentCube, Radian( -angle ), Vector3::YAXIS, AlphaFunctions::Linear );
+ mAnimation.AnimateTo( Property( currentCube, Actor::Property::ORIENTATION ), Quaternion( Radian( -angle ), Vector3::YAXIS ), AlphaFunctions::Linear );
Vector3 position(currentCube.GetCurrentPosition());
- mAnimation.MoveTo(currentCube, Vector3( position.x*mDisplacementRatio, position.y, position.z ), AlphaFunctions::Bounce);
- mAnimation.ColorTo( frontTile, HALF_BRIGHTNESS, AlphaFunctions::EaseOut );
- mAnimation.ColorTo( sideTile, FULL_BRIGHTNESS, AlphaFunctions::EaseIn );
+ mAnimation.AnimateTo( Property( currentCube, Actor::Property::POSITION ), Vector3( position.x*mDisplacementRatio, position.y, position.z ), AlphaFunctions::Bounce );
+ mAnimation.AnimateTo( Property( frontTile, Actor::Property::COLOR ), HALF_BRIGHTNESS, AlphaFunctions::EaseOut );
+ mAnimation.AnimateTo( Property( sideTile, Actor::Property::COLOR ), FULL_BRIGHTNESS, AlphaFunctions::EaseIn );
}
} // namespace Internal
// the delay value is within 0.f ~ 2.f*thirdAnimationDuration
float delay = thirdAnimationDuration * CalculateDelay(x*mTileSize.width,y*mTileSize.height);
- mAnimation.RotateTo( mBoxes[idx], Degree( -angle ), Vector3::YAXIS,
- AlphaFunctions::EaseOutSine, delay, thirdAnimationDuration );
- mAnimation.MoveBy( mBoxes[idx], Vector3(0.f,0.f,-mCubeDisplacement),
- AlphaFunctions::Bounce, delay, thirdAnimationDuration );
- mAnimation.ColorTo( mTiles[anotherIndex][idx], HALF_BRIGHTNESS,
- AlphaFunctions::EaseOut, delay, thirdAnimationDuration );
- mAnimation.ColorTo( mTiles[mContainerIndex][idx], FULL_BRIGHTNESS,
- AlphaFunctions::EaseIn, delay, thirdAnimationDuration );
+ mAnimation.AnimateTo( Property( mBoxes[idx], Actor::Property::ORIENTATION ), Quaternion( Radian( Degree( -angle ) ), Vector3::YAXIS ),
+ AlphaFunctions::EaseOutSine, TimePeriod( delay, thirdAnimationDuration ) );
+ mAnimation.AnimateBy( Property( mBoxes[idx], Actor::Property::POSITION ), Vector3( 0.f, 0.f, -mCubeDisplacement ),
+ AlphaFunctions::Bounce, TimePeriod( delay, thirdAnimationDuration ) );
+ mAnimation.AnimateTo( Property( mTiles[anotherIndex][idx], Actor::Property::COLOR ), HALF_BRIGHTNESS,
+ AlphaFunctions::EaseOut, TimePeriod( delay, thirdAnimationDuration ) );
+ mAnimation.AnimateTo( Property( mTiles[mContainerIndex][idx], Actor::Property::COLOR ), FULL_BRIGHTNESS,
+ AlphaFunctions::EaseIn, TimePeriod( delay, thirdAnimationDuration ) );
}
}
void PushButton::SetButtonImage( Image image )
{
- Dali::Toolkit::GetImplementation( *this ).SetButtonImage( ImageActor::New( image ) );
+ Actor imageActor = ImageActor::New( image );
+ imageActor.SetResizePolicy( USE_NATURAL_SIZE, ALL_DIMENSIONS );
+ Dali::Toolkit::GetImplementation( *this ).SetButtonImage( imageActor );
}
void PushButton::SetButtonImage( Actor image )
void PushButton::SetBackgroundImage( Image image )
{
- Dali::Toolkit::GetImplementation( *this ).SetBackgroundImage( ImageActor::New( image ) );
+ Actor imageActor = ImageActor::New( image );
+ imageActor.SetResizePolicy( USE_NATURAL_SIZE, ALL_DIMENSIONS );
+ Dali::Toolkit::GetImplementation( *this ).SetBackgroundImage( imageActor );
}
void PushButton::SetBackgroundImage( Actor image )
void PushButton::SetSelectedImage( Image image )
{
- Dali::Toolkit::GetImplementation( *this ).SetSelectedImage( ImageActor::New( image ) );
+ Actor imageActor = ImageActor::New( image );
+ imageActor.SetResizePolicy( USE_NATURAL_SIZE, ALL_DIMENSIONS );
+ Dali::Toolkit::GetImplementation( *this ).SetSelectedImage( imageActor );
}
void PushButton::SetSelectedImage( Actor image )
return Dali::Toolkit::GetImplementation( *this ).GetSelectedImage();
}
+void PushButton::SetSelectedBackgroundImage( Image image )
+{
+ Dali::Toolkit::GetImplementation( *this ).SetSelectedBackgroundImage( ImageActor::New( image ) );
+}
+
+void PushButton::SetSelectedBackgroundImage( Actor image )
+{
+ Dali::Toolkit::GetImplementation( *this ).SetSelectedBackgroundImage( image );
+}
+
+Actor PushButton::GetSelectedBackgroundImage() const
+{
+ return Dali::Toolkit::GetImplementation( *this ).GetSelectedBackgroundImage();
+}
+
void PushButton::SetDisabledBackgroundImage( Image image )
{
- Dali::Toolkit::GetImplementation( *this ).SetDisabledBackgroundImage( ImageActor::New( image ) );
+ Actor imageActor = ImageActor::New( image );
+ imageActor.SetResizePolicy( USE_NATURAL_SIZE, ALL_DIMENSIONS );
+ Dali::Toolkit::GetImplementation( *this ).SetDisabledBackgroundImage( imageActor );
}
void PushButton::SetDisabledBackgroundImage( Actor image )
void PushButton::SetDisabledImage( Image image )
{
- Dali::Toolkit::GetImplementation( *this ).SetDisabledImage( ImageActor::New( image ) );
+ Actor imageActor = ImageActor::New( image );
+ imageActor.SetResizePolicy( USE_NATURAL_SIZE, ALL_DIMENSIONS );
+ Dali::Toolkit::GetImplementation( *this ).SetDisabledImage( imageActor );
}
void PushButton::SetDisabledImage( Actor image )
Actor GetSelectedImage() const;
/**
+ * @brief Sets the selected background image.
+ *
+ * @param[in] image The selected background image.
+ */
+ void SetSelectedBackgroundImage( Image image );
+
+ /**
+ * @copydoc SetSelectedBackgroundImage( Image image )
+ */
+ void SetSelectedBackgroundImage( Actor image );
+
+ /**
+ * @brief Gets the selected background image.
+ *
+ * @return An actor with the selected background image.
+ */
+ Actor GetSelectedBackgroundImage() const;
+
+ /**
* @brief Sets the disabled background image.
*
* @param[in] image The disabled background image.
actor.SetPositionInheritanceMode( USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
actor.SetZ( BACKGROUND_ACTOR_Z_POSITION );
- actor.SetRelayoutEnabled( true );
- actor.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
+ actor.SetRelayoutEnabled( false );
+
+ Constraint constraint = Constraint::New<Vector3>( constrainingIndex,
+ ParentSource( Actor::Property::SIZE ),
+ EqualToConstraint() );
+ actor.ApplyConstraint( constraint );
}
} // unnamed namespace
{
if(animation)
{
- animation.Resize(actor, size);
+ animation.AnimateTo( Property( actor, Actor::Property::SIZE ), size );
}
}
// Do a nonlinear size animation to shrink the actor first when the actor size changes,
// so that we can avoid the actors overlapping during orientation change.
- animation.Resize( actor, shrink, AlphaFunctions::EaseOut, 0.0f, durationSeconds * 0.5f );
- animation.Resize( actor, size, AlphaFunctions::EaseIn, 0.0f, durationSeconds );
+ animation.AnimateTo( Property( actor, Actor::Property::SIZE ), shrink, AlphaFunctions::EaseOut, TimePeriod( 0.0f, durationSeconds * 0.5f ) );
+ animation.AnimateTo( Property( actor, Actor::Property::SIZE ), size, AlphaFunctions::EaseIn, TimePeriod( 0.0f, durationSeconds ) );
}
}
{
if(animation)
{
- animation.Resize(actor, size);
+ animation.AnimateTo( Property( actor, Actor::Property::SIZE ), size );
}
}
// ScrollView
///////////////////////////////////////////////////////////////////////////////////////////////////
-const std::string ScrollView::SCROLL_TIME_PROPERTY_NAME( "scroll-time" );
-const std::string ScrollView::SCROLL_POSITION_PROPERTY_NAME( "scroll-position" );
-const std::string ScrollView::SCROLL_PRE_POSITION_PROPERTY_NAME( "scroll-pre-position" );
-const std::string ScrollView::SCROLL_OVERSHOOT_X_PROPERTY_NAME( "scroll-overshoot-x" );
-const std::string ScrollView::SCROLL_OVERSHOOT_Y_PROPERTY_NAME( "scroll-overshoot-y" );
-const std::string ScrollView::SCROLL_FINAL_PROPERTY_NAME( "scroll-final" );
-const std::string ScrollView::SCROLL_WRAP_PROPERTY_NAME( "scroll-wrap" );
-const std::string ScrollView::SCROLL_PANNING_PROPERTY_NAME( "scroll-panning" );
-const std::string ScrollView::SCROLL_SCROLLING_PROPERTY_NAME( "scroll-scrolling" );
-const std::string ScrollView::SCROLL_POSITION_DELTA_PROPERTY_NAME( "scroll-position-delta" );
-const std::string ScrollView::SCROLL_START_PAGE_POSITION_PROPERTY_NAME( "scroll-start-page-position" );
-
const float ScrollView::DEFAULT_SLOW_SNAP_ANIMATION_DURATION(0.5f);
const float ScrollView::DEFAULT_FAST_SNAP_ANIMATION_DURATION(0.25f);
const float ScrollView::DEFAULT_SNAP_OVERSHOOT_DURATION(0.5f);
{
public:
- // Custom properties
-
- static const std::string SCROLL_TIME_PROPERTY_NAME; ///< Property, name "scroll-time", type float
- static const std::string SCROLL_POSITION_PROPERTY_NAME; ///< Property, name "scroll-position", type Vector3
- static const std::string SCROLL_PRE_POSITION_PROPERTY_NAME; ///< Property, name "scroll-pre-position", type Vector3
- static const std::string SCROLL_OVERSHOOT_X_PROPERTY_NAME; ///< Property, name "scroll-overshoot-x", type float
- static const std::string SCROLL_OVERSHOOT_Y_PROPERTY_NAME; ///< Property, name "scroll-overshoot-y", type float
- static const std::string SCROLL_FINAL_PROPERTY_NAME; ///< Property, name "scroll-final", type Vector3
- static const std::string SCROLL_WRAP_PROPERTY_NAME; ///< Property, name "scroll-wrap", type bool
- static const std::string SCROLL_PANNING_PROPERTY_NAME; ///< Property, name "scroll-panning", type bool
- static const std::string SCROLL_SCROLLING_PROPERTY_NAME; ///< Property, name "scroll-scrolling", type bool
- static const std::string SCROLL_POSITION_DELTA_PROPERTY_NAME; ///< Property, name "scroll-position-delta" type Vector3
- static const std::string SCROLL_START_PAGE_POSITION_PROPERTY_NAME; ///< Property, name "scroll-start-page-position" type Vector3
-
// Default settings
static const float DEFAULT_SLOW_SNAP_ANIMATION_DURATION; ///< Default Drag-Release animation time.
float duration; ///< Duration of snap animation.
};
+ /**
+ * @brief The start and end property ranges for this control.
+ */
+ enum PropertyRange
+ {
+ ANIMATABLE_PROPERTY_START_INDEX = Toolkit::Scrollable::ANIMATABLE_PROPERTY_END_INDEX + 1,
+ ANIMATABLE_PROPERTY_END_INDEX = ANIMATABLE_PROPERTY_START_INDEX + 1000 ///< Reserve animatable property indices
+ };
+
+ /**
+ * @brief An enumeration of properties belonging to the ScrollView class.
+ */
+ struct Property
+ {
+ enum
+ {
+ SCROLL_POSITION = ANIMATABLE_PROPERTY_START_INDEX, ///< Property, name "scroll-position", type Vector3
+ SCROLL_PRE_POSITION, ///< Property, name "scroll-pre-position", type Vector3
+ OVERSHOOT_X, ///< Property, name "overshoot-x", type float
+ OVERSHOOT_Y, ///< Property, name "overshoot-y", type float
+ SCROLL_FINAL, ///< Property, name "scroll-final", type Vector3
+ WRAP, ///< Property, name "wrap", type bool
+ PANNING, ///< Property, name "panning", type bool
+ SCROLLING, ///< Property, name "scrolling", type bool
+ SCROLL_DOMAIN_OFFSET, ///< Property, name "scroll-domain-offset" type Vector3
+ SCROLL_POSITION_DELTA, ///< Property, name "scroll-position-delta" type Vector3
+ START_PAGE_POSITION ///< Property, name "start-page-position" type Vector3
+ };
+ };
+
typedef Signal< void ( const SnapEvent& ) > SnapStartedSignalType; ///< SnapStarted signal type
/**
namespace Toolkit
{
-const std::string Scrollable::SCROLL_RELATIVE_POSITION_PROPERTY_NAME( "scroll-relative-position" );
-const std::string Scrollable::SCROLL_POSITION_MIN_PROPERTY_NAME( "scroll-position-min" );
-const std::string Scrollable::SCROLL_POSITION_MAX_PROPERTY_NAME( "scroll-position-max" );
-const std::string Scrollable::SCROLL_DIRECTION_PROPERTY_NAME( "scroll-direction" );
-
Scrollable::Scrollable()
{
}
OvershootIndicator,
};
- // Custom properties
-
- static const std::string SCROLL_RELATIVE_POSITION_PROPERTY_NAME; ///< Property, name "scroll-relative-position", type Vector3
- static const std::string SCROLL_POSITION_MIN_PROPERTY_NAME; ///< Property, name "scroll-position-min", type Vector3
- static const std::string SCROLL_POSITION_MAX_PROPERTY_NAME; ///< Property, name "scroll-position-max", type Vector3
- static const std::string SCROLL_DIRECTION_PROPERTY_NAME; ///< Property, name "scroll-direction", type Vector2
-
/**
* @brief The start and end property ranges for this control.
*/
enum PropertyRange
{
PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1,
- PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000 ///< Reserve property indices
+ PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000, ///< Reserve property indices
+
+ ANIMATABLE_PROPERTY_START_INDEX = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX,
+ ANIMATABLE_PROPERTY_END_INDEX = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1000 ///< Reserve animatable property indices
};
/**
{
enum
{
+ // Event side properties
OVERSHOOT_EFFECT_COLOR = PROPERTY_START_INDEX, ///< Property, name "overshoot-effect-color", @see SetOvershootEffectColor(), type Vector4
OVERSHOOT_ANIMATION_SPEED, ///< Property, name "overshoot-animation-speed", @see SetOvershootAnimationSpeed(), type float
+
+ // Animatable properties
+ SCROLL_RELATIVE_POSITION = ANIMATABLE_PROPERTY_START_INDEX, ///< Property, name "scroll-relative-position", type Vector3
+ SCROLL_POSITION_MIN, ///< Property, name "scroll-position-min", type Vector3
+ SCROLL_POSITION_MAX, ///< Property, name "scroll-position-max", type Vector3
+ SCROLL_DIRECTION, ///< Property, name "scroll-direction", type Vector2
+ CAN_SCROLL_VERTICAL, ///< Property, name "can-scroll-vertical", type bool
+ CAN_SCROLL_HORIZONTAL ///< Property, name "can-scroll-horizontal", type bool
};
};
const unsigned int TOOLKIT_MAJOR_VERSION = 1;
const unsigned int TOOLKIT_MINOR_VERSION = 0;
-const unsigned int TOOLKIT_MICRO_VERSION = 35;
+const unsigned int TOOLKIT_MICRO_VERSION = 36;
const char * const TOOLKIT_BUILD_DATE = __DATE__ " " __TIME__;
#ifdef DEBUG_ENABLED
*
*/
-// INTERNAL INCLUDES
+// EXTERNAL INCLUDES
#include <dali/public-api/common/dali-common.h>
-#include <dali.h>
+#include <dali/public-api/object/base-handle.h>
namespace Dali
{
Here we add the animators, these are the building blocks (functions) of the animation and define what we want to see
@code
- myAnimation.OpacityTo(actor, 1.0f);
- myAnimation.MoveTo(actor, x, y, z);
+ myAnimation.AnimateTo(Property(actor, Actor::Property::OPACITY), 1.0f);
+ myAnimation.AnimateTo(Property(actor, Actor::Property::POSITION), Vector3(x, y, z));
@endcode
start animation, when this is called we want the animation to start playing so here the actor will move whilst the opacity changes.
@endcode
\section advanced-anims Adding more advanced animators, if simply moving the actor is not enough we have further animations methods.
- For actor there exists a range of methods ranging from Move, Rotate, Scale, Opacity, Color to Resize. The API explains in detail what each does and the parameters to these methods but there are some points worth noting;
-
- xxxxBy and xxxxTo, method names are appended by 'By' or 'To' either animate to a supplied value or animate by a supplied value. For example an actor at (10,10,10) calling MoveBy(actor, 50,0,0) would mean its location is (60,0,0) whilst MoveTo(actor, 50,0,0) would result in a location (50,0,0).
+ AnimateBy and AnimateTo, method names are appended by 'By' or 'To' either animate to a supplied value or animate by a supplied value. For example an actor at (10,10,10) calling AnimateBy(Property(actor, Actor::Property::POSITION), 50,0,0) would mean its location is (60,0,0) whilst AnimateTo(Property(actor, Actor::Property::POSITION), 50,0,0) would result in a location (50,0,0).
Dali::AlphaFunctions can be used to give interesting effects to the animation, for example the MOVEment of an actor on screen can speed up and slow down following a sine curve by using the Dali::AlphaFunctions::EaseInOutSine instead of AlphaFunctions::Linear.
@code
- myAnimation.MoveTo(actor, Vector3(x, y, z), AlphaFunctions::Linear, delay, ANIMATOR_DURATION);
- myAnimation.Resize(actor, actorSize, AlphaFunctions::EaseIn, delay, ANIMATOR_DURATION);
+ myAnimation.AnimateTo(Property(actor, Actor::Property::POSITION), Vector3(x, y, z), AlphaFunctions::Linear, delay, ANIMATOR_DURATION);
+ myAnimation.AnimateTo(Property(actor, Actor::Property::SIZE), actorSize, AlphaFunctions::EaseIn, delay, ANIMATOR_DURATION);
@endcode
\section playback-control Controlling a playing animation
* actor.RotateBy(q);
* @endcode
*
- * The Dali::Animation class provides several RotateTo methods that
- * use \ref Dali::Quaternion "Quaternions" directly. The other
- * RotateTo methods are specified using Axis+Angle, and these convert
- * to Quaternion internally. You will only need to use the quaternion
- * based methods when you are doing something more complex than
- * initialising with Axis+Angle, such as applying several rotations
- * together.
+ * The Dali::Animation class provides several AnimateTo methods that
+ * use \ref Dali::Quaternion "Quaternions" directly to change the orientation.
+ *
* @code
* mAnimation = Animation::New(5.0f); // 5 seconds
* Quaternion q(Radian(Degree(45.0f)).value, Vector3::YAXIS);
* Quaternion r(Radian(Degree(30.0f)).value, Vector3::ZAXIS);
* q *= r;
- * mAnimation.RotateTo(mActor, q, AlphaFunctions::EaseInOut);
+ * mAnimation.AnimateTo(Property(mActor, Actor::Property::ORIENTATION), q, AlphaFunctions::EaseInOut);
* mAnimation.Play();
* @endcode
*/
* body.SetKinematic( true );
* // create a second animation to move the actor 100 units to the right
* Animation animation( Animation::New( 1 ) );
- * animation.MoveBy( actor, Vector3( 100, 0, 0 ), AlphaFunctions::Linear );
+ * animation.AnimateBy( Property( actor, Actor::Property::POSITION ), Vector3( 100, 0, 0 ), AlphaFunctions::Linear );
* animation.Play();
* \endcode
* <hr>
@endcode
The popup control is added to the layer and a background image is specified to fill the size of the popup and add a border by the following.
@code
-mBackgroundImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
-mBackgroundImage.SetSizeMode( SIZE_FIXED_OFFSET_FROM_PARENT );
+mBackgroundImage.SetResizePolicy( SIZE_FIXED_OFFSET_FROM_PARENT, ALL_DIMENSIONS );
Vector3 border( mPopupStyle->backgroundOuterBorder.x, mPopupStyle->backgroundOuterBorder.z, 0.0f );
mBackgroundImage.SetSizeModeFactor( border );
@endcode
The ResizePolicy enum specifies a range of options for controlling the way actors resize. These are powerful rules that enable much automatic
resizing behaviour. They are as following:
-- FIXED: This is the option to use when you want the specific definite size as set by SetPreferredSize
+- FIXED: This is the option to use when you want the specific definite size as set by SetSize (This is the default for all actors)
- USE_NATURAL_SIZE: Use this option for objects such as images or text to get their natural size e.g. The dimensions of the image, or the size of the text without wrapping. Also use this on TableViews when the size of the table is dependent on its children.
- FILL_TO_PARENT: Size will fill up to the size of its parent's size, taking a size factor into account to allow proportionate filling
+- SIZE_RELATIVE_TO_PARENT: Fill up the parent with a relative scale. Use SetSizeModeFactor to specify the ratio to fill up to the parent.
+- SIZE_FIXED_OFFSET_FROM_PARENT: Fill up the parent and add a fixed offset using SetSizeModeFactor.
- FIT_TO_CHILDREN: Size will scale around the size of the actor's children. E.g. A popup's height may resize itself around it's contents.
- DIMENSION_DEPENDENCY: This covers rules such as width-for-height and height-for-width. You specify that one dimension depends on another.
<h3>Enabling Size Negotiation</h3>
The first thing to do is to specify whether you want an actor to be included or excluded from the relayout process. The following method is used to enable or disable the relayout
-for an individual actor.
+for an individual actor. Make sure this is the first thing that is called after the actor is created otherwise the actor may still be negotiated.
@code void SetRelayoutEnabled( bool enabled ) @endcode
Text and image actors have relayout enabled by default, while a plain Actor is disabled. Be aware that if desiring to use an Actor in relayout
then relayout needs to be explicitly enabled first.
<h3>Specifying Size Policies</h3>
+Actors have different size policies by default. For example ImageActor is set to USE_NATURAL_SIZE. This ensures that when an image actor is
+placed on the stage it will use its natural size by default. However if the user calls SetSize with non-zero sizes on the image actor then the current
+size policy is overridden by the FIXED size policy and the actor will take on the size specified.
+
The next step is to specify how an actor will be size negotiated. The resize policies for an actor may be specified by the following method:
@code void SetResizePolicy( ResizePolicy policy, Dimension dimension ) @endcode
It is common to specifiy different policies for the different dimensions of width and height to achive different layouts. Different actors have
This example shows an actor rootActor set to expand to its parent's width and contract/expand around its child's height. The child image actor
is set to natural size which means it will display at the acutal size of the image.
-To specify that a dimension has a dependency on another dimension use the following method. Calling this method will automatically set the resize policy to be DIMENSION_DEPENDENCY
-for the given dimension.
-@code void SetDimensionDependency( Dimension dimension, Dimension dependency ) @endcode
-For example if dimension is HEIGHT and dependency is WIDTH then there is a height-for-width dependency in effect. The classic use case for this
+To specify that a dimension has a dependency on another dimension use DIMENSION_DEPENDENCY. For example if dimension is HEIGHT and dependency is
+WIDTH then there is a height-for-width dependency in effect. The classic use case for this
is a text view that wraps its text. The following example snippet shows a text view that expands its width to the size of its parent, wraps its
contents and then determines its height based on the width.
@code
TextView text = TextView::New( "Example" );
text.SetMultilinePolicy( SplitByWord );
text.SetResizePolicy( FILL_TO_PARENT, WIDTH );
-text.SetDimensionDependency( HEIGHT, WIDTH );
+text.SetResizePolicy( DIMENSION_DEPENDENCY, HEIGHT );
@endcode
<h3>Specifying Sizes and Size Limits</h3>
-When wanting a specific fixed size for an actor then specify the resize policy to be FIXED and set the desired, or preferred size using the following method.
-This method is to be used instead of SetSize when wishing to specify a size for an actor being size negotiated.
-@code void SetPreferredSize( const Vector2& size ) @endcode
+When wanting a specific fixed size for an actor then specify the resize policy to be FIXED and set the desired, or preferred size using SetSize.
If only one dimension is FIXED then the other value in the size parameter will be ignored, so it is safe to set it to zero.
To constrain the final negotiated size of an actor, set the following for minimum and maximum sizes respectively.
<h3>Altering Negotiated Size</h3>
-The following method specifies a size mode to use. Use one of: USE_OWN_SIZE, SIZE_RELATIVE_TO_PARENT or SIZE_FIXED_OFFSET_FROM_PARENT. SIZE_RELATIVE_TO_PARENT will
-scale the image relative to it's parent size when the resize policy of FILL_TO_PARENT is in effect. While SIZE_FIXED_OFFSET_FROM_PARENT will
-add an offset to this parent size, for example when wanting an image to act as a border around its parent.
-@code void SetSizeMode( const SizeMode mode ) @endcode
-
-Use the following with SetSizeMode to specify either the size relative to parent or the fixed offset to apply.
-@code void SetSizeModeFactor( const Vector3& factor ) @endcode
-
When an actor is required to maintain the aspect ratio of its natural size the following method can be used. This is useful for size negotiating images
to ensure they maintain their aspect ratio while still fitting within the bounds they have been allocated. This can be one of USE_SIZE_SET, FIT_WITH_ASPECT_RATIO
or FILL_WITH_ASPECT_RATIO. The first is the default. The second will fit the actor within the bounds it has been allocated while maintaining aspect ratio. The
text.SetWidthExceedPolicy( Toolkit::TextView::Split );
text.SetLineJustification( Toolkit::TextView::Left );
text.SetResizePolicy( FILL_TO_PARENT, WIDTH );
-text.SetDimensionDependency( HEIGHT, WIDTH );
+text.SetResizePolicy( DIMENSION_DEPENDENCY, HEIGHT );
content.AddChild( text, Toolkit::TableView::CellPosition( 0, 0 ) );
// Image
ImageActor image = ImageActor::New( ResourceImage::New( IMAGE1 ) );
image.SetResizePolicy( FILL_TO_PARENT, WIDTH );
-image.SetDimensionDependency( HEIGHT, WIDTH );
+image.SetResizePolicy( DIMENSION_DEPENDENCY, HEIGHT );
image.SetPadding( Padding( 20.0f, 0.0f, 0.0f, 0.0f ) );
content.AddChild( image, Toolkit::TableView::CellPosition( 0, 1 ) );
Toolkit::CheckBoxButton checkBox = Toolkit::CheckBoxButton::New();
checkBox.SetBackgroundImage( unchecked );
checkBox.SetSelectedImage( checked );
-checkBox.SetPreferredSize( Vector2( 48, 48 ) );
-checkBox.SetResizePolicy( FIXED, ALL_DIMENSIONS );
+checkBox.SetSize( Vector2( 48, 48 ) );
root.AddChild( checkBox, Toolkit::TableView::CellPosition( 0, 0 ) );
height based on its new width. The table view will then fit its height taking the height of the text view into account.
@code
text.SetResizePolicy( FILL_TO_PARENT, WIDTH );
-text.SetDimensionDependency( HEIGHT, WIDTH );
+text.SetResizePolicy( DIMENSION_DEPENDENCY, HEIGHT );
@endcode
The image view performs a similar relayout. It fits its width to the size of the cell and calculates its height based on the new
width. Some padding is added to the left of it as well to center it more.
@code
image.SetResizePolicy( FILL_TO_PARENT, WIDTH );
-image.SetDimensionDependency( HEIGHT, WIDTH );
+image.SetResizePolicy( DIMENSION_DEPENDENCY, HEIGHT );
image.SetPadding( Padding( 20.0f, 0.0f, 0.0f, 0.0f ) );
@endcode
The sub table view is similar as well in that it expands its width to the size of its cell. When it is added to the table view it
Name: dali-toolkit
Summary: The OpenGLES Canvas Core Library Toolkit
-Version: 1.0.35
+Version: 1.0.36
Release: 1
Group: System/Libraries
License: Apache-2.0
{ "CULL_BACK_FACE", CullBack },
{ "CULL_FRONT_AND_BACK_FACE", CullFrontAndBack },
- { "USE_OWN_SIZE", USE_OWN_SIZE },
- { "SIZE_RELATIVE_TO_PARENT", SIZE_RELATIVE_TO_PARENT },
- { "SIZE_FIXED_OFFSET_FROM_PARENT", SIZE_FIXED_OFFSET_FROM_PARENT },
-
{ "CAMERA_FREE_LOOK" , Camera::FREE_LOOK },
{ "CAMERA_LOOK_AT_TARGET" , Camera::LOOK_AT_TARGET },
{ "CAMERA_PERSPECTIVE_PROJECTION" , Camera::PERSPECTIVE_PROJECTION },