{
}
-void ConstraintAppliedCheck::operator()( ActiveConstraint& constraint )
+void ConstraintAppliedCheck::operator()( Constraint& constraint )
{
mSignalReceived = true;
}
struct ConstraintAppliedCheck
{
ConstraintAppliedCheck( bool& signalReceived );
- void operator()( ActiveConstraint& constraint );
+ void operator()( Constraint& constraint );
void Reset();
void CheckSignalReceived();
void CheckSignalNotReceived();
/**
* @param[in] current The current base value
- * @param[in] property The property to be added to current.
+ * @param[in] inputs Contains the property to be added to current.
* @return The new current Vector.
*/
- Vector3 operator()(const Vector3& current)
+ void operator()( Vector3& current, const PropertyInputContainer& inputs )
{
- gConstraintResult = current + mOffset;
- return gConstraintResult;
- }
-
- /**
- * @param[in] current The current base value
- * @param[in] property The property to be added to current.
- * @return The new current Vector.
- */
- Vector3 operator()(const Vector3& current,
- const PropertyInput& property)
- {
- gConstraintResult = current + property.GetVector3() + mOffset;
- return gConstraintResult;
+ gConstraintResult = current + inputs[0]->GetVector3() + mOffset;
+ current = gConstraintResult;
}
Vector3 mOffset;
a.SetPosition( TEST_ACTOR_POSITION );
Wait(application);
- Constraint constraint = Constraint::New<Vector3>( Actor::Property::POSITION,
- Source(scrollView, ScrollView::Property::SCROLL_POSITION),
- TestSumConstraint( TEST_CONSTRAINT_OFFSET ) );
+ Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, TestSumConstraint( TEST_CONSTRAINT_OFFSET ) );
+ constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) );
constraint.SetRemoveAction(Constraint::Discard);
scrollView.ApplyConstraintToChildren(constraint);
Wait(application);
Wait(application);
// apply this constraint to scrollview
- Constraint constraint = Constraint::New<Vector3>( Actor::Property::POSITION,
- Source(scrollView, ScrollView::Property::SCROLL_POSITION),
- TestSumConstraint( TEST_CONSTRAINT_OFFSET ) );
-
+ Constraint constraint = Constraint::New<Vector3>( scrollView, Actor::Property::POSITION, TestSumConstraint( TEST_CONSTRAINT_OFFSET ) );
+ constraint.AddSource( Source(scrollView, ScrollView::Property::SCROLL_POSITION) );
constraint.SetRemoveAction(Constraint::Discard);
scrollView.ApplyConstraintToChildren(constraint);
ScrollView SetupTestScrollView(int rows, int columns, Vector2 size)
{
+ Constraint constraint;
+
ScrollView scrollView = ScrollView::New();
scrollView.SetSize(size);
scrollView.SetAnchorPoint(AnchorPoint::CENTER);
scrollView.SetParentOrigin(ParentOrigin::CENTER);
- scrollView.ApplyConstraint( Constraint::New<Dali::Vector3>( Dali::Actor::Property::SIZE, Dali::ParentSource( Dali::Actor::Property::SIZE ), Dali::EqualToConstraint() ) );
+
+ constraint = Constraint::New<Dali::Vector3>( scrollView, Dali::Actor::Property::SIZE, Dali::EqualToConstraint() );
+ constraint.AddSource( Dali::ParentSource( Dali::Actor::Property::SIZE ) );
+ constraint.Apply();
+
scrollView.SetWrapMode(false);
scrollView.ScrollStartedSignal().Connect( &OnScrollStart );
scrollView.ScrollUpdatedSignal().Connect( &OnScrollUpdate );
container.SetAnchorPoint(AnchorPoint::CENTER);
container.SetSize( size );
scrollView.Add( container );
- container.ApplyConstraint( Constraint::New<Vector3>( Actor::Property::SIZE, ParentSource( Actor::Property::SIZE ), EqualToConstraint() ) );
+
+ constraint = Constraint::New<Vector3>( container, Actor::Property::SIZE, EqualToConstraint() );
+ constraint.AddSource( Dali::ParentSource( Dali::Actor::Property::SIZE ) );
+ constraint.Apply();
gPages.clear();
for(int row = 0;row<rows;row++)
for(int column = 0;column<columns;column++)
{
Actor page = Actor::New();
- page.ApplyConstraint( Constraint::New<Vector3>( Actor::Property::SIZE, ParentSource( Actor::Property::SIZE ), EqualToConstraint() ) );
+
+ constraint = Constraint::New<Vector3>( page, Actor::Property::SIZE, EqualToConstraint() );
+ constraint.AddSource( Dali::ParentSource( Dali::Actor::Property::SIZE ) );
+ constraint.Apply();
page.SetParentOrigin( ParentOrigin::CENTER );
page.SetAnchorPoint( AnchorPoint::CENTER );
page.SetPosition( column * size.x, row * size.y );
{
Actor page = *pageIter;
page.RemoveConstraints();
- page.ApplyConstraint( Constraint::New<Vector3>( Actor::Property::SIZE, ParentSource( Actor::Property::SIZE ), EqualToConstraint() ) );
+
+ Constraint constraint = Constraint::New<Vector3>( page, Actor::Property::SIZE, EqualToConstraint() );
+ constraint.AddSource( ParentSource( Actor::Property::SIZE ) );
+ constraint.Apply();
effect.ApplyToPage(page, Vector2(Math::PI_2, 0.0f));
}
Wait(application);
{
Actor page = *pageIter;
page.RemoveConstraints();
- page.ApplyConstraint( Constraint::New<Vector3>( Actor::Property::SIZE, ParentSource( Actor::Property::SIZE ), EqualToConstraint() ) );
+ Constraint constraint = Constraint::New<Vector3>( page, Actor::Property::SIZE, EqualToConstraint() );
+ constraint.AddSource( ParentSource( Actor::Property::SIZE ) );
+ constraint.Apply();
effect.ApplyToPage(page, Vector2(Math::PI_2, 0.0f));
}
Wait(application);
{
Actor page = *pageIter;
page.RemoveConstraints();
- page.ApplyConstraint( Constraint::New<Vector3>( Actor::Property::SIZE, ParentSource( Actor::Property::SIZE ), EqualToConstraint() ) );
+ Constraint constraint = Constraint::New<Vector3>( page, Actor::Property::SIZE, EqualToConstraint() );
+ constraint.AddSource( ParentSource( Actor::Property::SIZE ) );
+ constraint.Apply();
effect.ApplyToPage(page);
}
Wait(application);
/**
* function operator to apply the parent size
*/
- Dali::Vector3 operator()(const Dali::Vector3& current)
+ void operator()( Dali::Vector3& current, const PropertyInputContainer& /* inputs */ )
{
- return Dali::Vector3( 100.0f, 100.0f, 100.0f );
+ current.x = current.y = current.z = 100.0f;
}
};
// Create a 10x10 table-view
TableView tableView = TableView::New(10,10);
- tableView.ApplyConstraint( Constraint::New<Vector3>( Actor::Property::SIZE, Constraint100() ) );
+ Constraint constraint = Constraint::New<Vector3>( tableView, Actor::Property::SIZE, Constraint100() );
+ constraint.Apply();
DALI_TEST_CHECK( tableView );
// Create a child actor with the custom properties
$(DALI_CFLAGS) \
$(DLOG_CFLAGS) \
$(script_plugin_v8_includes) \
+ $(V8_CFLAGS) \
-Werror -Wall
libdali_script_plugin_v8_la_LIBADD = \
// EXTERNAL INCLUDES
#include <sstream>
#include <iomanip>
-#include <dali/public-api/animation/active-constraint.h>
#include <dali/public-api/animation/constraint.h>
#include <dali/public-api/animation/constraints.h>
#include <dali/public-api/common/stage.h>
}
/**
- * EqualToConstraintFloat
- *
- * f(current, property) = property
- */
-struct EqualToConstraintFloat
-{
- EqualToConstraintFloat(){}
-
- float operator()(const float current, const PropertyInput& property) {return property.GetFloat();}
-};
-
-/**
* RecipOneMinusConstraint
*
* f(current, property) = property
{
RecipOneMinusConstraint(){}
- float operator()(const float current, const PropertyInput& property)
+ void operator()( float& current, const PropertyInputContainer& inputs )
{
- return 1.0f / (1.0f - property.GetFloat());
+ current = 1.0f / ( 1.0f - inputs[0]->GetFloat() );
}
};
// Register a property that the user can control to change the bloom threshold
mBloomThresholdPropertyIndex = self.RegisterProperty(BLOOM_THRESHOLD_PROPERTY_NAME, BLOOM_THRESHOLD_DEFAULT);
Property::Index shaderBloomThresholdPropertyIndex = mBloomExtractShader.GetPropertyIndex(BLOOM_THRESHOLD_PROPERTY_NAME);
- Constraint bloomThresholdConstraint = Constraint::New<float>(shaderBloomThresholdPropertyIndex, Source(self, mBloomThresholdPropertyIndex), EqualToConstraintFloat());
- mBloomExtractShader.ApplyConstraint(bloomThresholdConstraint);
+ Constraint bloomThresholdConstraint = Constraint::New<float>( mBloomExtractShader, shaderBloomThresholdPropertyIndex, EqualToConstraint());
+ bloomThresholdConstraint.AddSource( Source(self, mBloomThresholdPropertyIndex) );
+ bloomThresholdConstraint.Apply();
// precalc 1.0 / (1.0 - threshold) on CPU to save shader insns, using constraint to tie to the normal threshold property
Property::Index shaderRecipOneMinusBloomThresholdPropertyIndex = mBloomExtractShader.GetPropertyIndex(RECIP_ONE_MINUS_BLOOM_THRESHOLD_PROPERTY_NAME);
- Constraint thresholdConstraint = Constraint::New<float>( shaderRecipOneMinusBloomThresholdPropertyIndex, LocalSource(shaderBloomThresholdPropertyIndex), RecipOneMinusConstraint());
- mBloomExtractShader.ApplyConstraint(thresholdConstraint);
+ Constraint thresholdConstraint = Constraint::New<float>( mBloomExtractShader, shaderRecipOneMinusBloomThresholdPropertyIndex, RecipOneMinusConstraint());
+ thresholdConstraint.AddSource( LocalSource(shaderBloomThresholdPropertyIndex) );
+ thresholdConstraint.Apply();
////////////////////////////////////////////
// Register a property that the user can control to fade the blur in / out via internal GaussianBlurView object
mBlurStrengthPropertyIndex = self.RegisterProperty(BLOOM_BLUR_STRENGTH_PROPERTY_NAME, BLOOM_BLUR_STRENGTH_DEFAULT);
- Constraint blurStrengthConstraint = Constraint::New<float>( mGaussianBlurView.GetBlurStrengthPropertyIndex(), Source(self, mBlurStrengthPropertyIndex), EqualToConstraintFloat());
- mGaussianBlurView.ApplyConstraint(blurStrengthConstraint);
+ Constraint blurStrengthConstraint = Constraint::New<float>( mGaussianBlurView, mGaussianBlurView.GetBlurStrengthPropertyIndex(), EqualToConstraint());
+ blurStrengthConstraint.AddSource( Source(self, mBlurStrengthPropertyIndex) );
+ blurStrengthConstraint.Apply();
////////////////////////////////////////////
mBloomIntensityPropertyIndex = self.RegisterProperty(BLOOM_INTENSITY_PROPERTY_NAME, BLOOM_INTENSITY_DEFAULT);
mCompositeShader.SetUniform( BLOOM_INTENSITY_PROPERTY_NAME, BLOOM_INTENSITY_DEFAULT );
Property::Index shaderBloomIntensityPropertyIndex = mCompositeShader.GetPropertyIndex(BLOOM_INTENSITY_PROPERTY_NAME);
- Constraint bloomIntensityConstraint = Constraint::New<float>( shaderBloomIntensityPropertyIndex, Source(self, mBloomIntensityPropertyIndex), EqualToConstraintFloat());
- mCompositeShader.ApplyConstraint(bloomIntensityConstraint);
+ Constraint bloomIntensityConstraint = Constraint::New<float>( mCompositeShader, shaderBloomIntensityPropertyIndex, EqualToConstraint());
+ bloomIntensityConstraint.AddSource( Source(self, mBloomIntensityPropertyIndex) );
+ bloomIntensityConstraint.Apply();
////////////////////////////////////////////
mBloomSaturationPropertyIndex = self.RegisterProperty(BLOOM_SATURATION_PROPERTY_NAME, BLOOM_SATURATION_DEFAULT);
mCompositeShader.SetUniform( BLOOM_SATURATION_PROPERTY_NAME, BLOOM_SATURATION_DEFAULT );
Property::Index shaderBloomSaturationPropertyIndex = mCompositeShader.GetPropertyIndex(BLOOM_SATURATION_PROPERTY_NAME);
- Constraint bloomSaturationConstraint = Constraint::New<float>( shaderBloomSaturationPropertyIndex, Source(self, mBloomSaturationPropertyIndex), EqualToConstraintFloat());
- mCompositeShader.ApplyConstraint(bloomSaturationConstraint);
+ Constraint bloomSaturationConstraint = Constraint::New<float>( mCompositeShader, shaderBloomSaturationPropertyIndex, EqualToConstraint());
+ bloomSaturationConstraint.AddSource( Source(self, mBloomSaturationPropertyIndex) );
+ bloomSaturationConstraint.Apply();
////////////////////////////////////////////
mImageIntensityPropertyIndex = self.RegisterProperty(IMAGE_INTENSITY_PROPERTY_NAME, IMAGE_INTENSITY_DEFAULT);
mCompositeShader.SetUniform( IMAGE_INTENSITY_PROPERTY_NAME, IMAGE_INTENSITY_DEFAULT );
Property::Index shaderImageIntensityPropertyIndex = mCompositeShader.GetPropertyIndex(IMAGE_INTENSITY_PROPERTY_NAME);
- Constraint imageIntensityConstraint = Constraint::New<float>( shaderImageIntensityPropertyIndex, Source(self, mImageIntensityPropertyIndex), EqualToConstraintFloat());
- mCompositeShader.ApplyConstraint(imageIntensityConstraint);
+ Constraint imageIntensityConstraint = Constraint::New<float>( mCompositeShader, shaderImageIntensityPropertyIndex, EqualToConstraint());
+ imageIntensityConstraint.AddSource( Source(self, mImageIntensityPropertyIndex) );
+ imageIntensityConstraint.Apply();
////////////////////////////////////////////
mImageSaturationPropertyIndex = self.RegisterProperty(IMAGE_SATURATION_PROPERTY_NAME, IMAGE_SATURATION_DEFAULT);
mCompositeShader.SetUniform( IMAGE_SATURATION_PROPERTY_NAME, IMAGE_SATURATION_DEFAULT );
Property::Index shaderImageSaturationPropertyIndex = mCompositeShader.GetPropertyIndex(IMAGE_SATURATION_PROPERTY_NAME);
- Constraint imageSaturationConstraint = Constraint::New<float>( shaderImageSaturationPropertyIndex, Source(self, mImageSaturationPropertyIndex), EqualToConstraintFloat());
- mCompositeShader.ApplyConstraint(imageSaturationConstraint);
+ Constraint imageSaturationConstraint = Constraint::New<float>( mCompositeShader, shaderImageSaturationPropertyIndex, EqualToConstraint());
+ imageSaturationConstraint.AddSource( Source(self, mImageSaturationPropertyIndex) );
+ imageSaturationConstraint.Apply();
}
} // namespace Internal
{
/**
- * Find the first image actor in the actor hierarchy
+ * Get size of Actor if larger than given size
+ * @param[in] root the actor to get the size of
+ * @param[out] size the greater of the given size or the size of the Actor
*/
-ImageActor FindImageActor( Actor root )
+void SizeOfActorIfLarger( Actor root, Vector3& size )
{
- ImageActor imageActor = ImageActor::DownCast( root );
- if( !imageActor && root )
+ if ( root )
{
- for( unsigned int i = 0, numChildren = root.GetChildCount(); i < numChildren; ++i )
- {
- ImageActor childImageActor = FindImageActor( root.GetChildAt( i ) );
- if( childImageActor )
- {
- return childImageActor;
- }
- }
+ // RelayoutSize retreived for Actor to use any padding set to it.
+ size.width = std::max( root.GetRelayoutSize( WIDTH ), size.width );
+ size.height = std::max( root.GetRelayoutSize( HEIGHT ), size.height );
}
-
- return imageActor;
}
} // unnamed namespace
{
Vector3 size;
- // If background and background not scale9 try get size from that
- ImageActor imageActor = FindImageActor( GetButtonImage() );
- if( imageActor && imageActor.GetStyle() != ImageActor::STYLE_NINE_PATCH )
- {
- size.width = imageActor.GetRelayoutSize( WIDTH );
- size.height = imageActor.GetRelayoutSize( HEIGHT );
- }
-
- ImageActor backgroundImageActor = FindImageActor( GetBackgroundImage() );
- if( backgroundImageActor && backgroundImageActor.GetStyle() != ImageActor::STYLE_NINE_PATCH )
- {
- size.width = std::max( size.width, backgroundImageActor.GetRelayoutSize( WIDTH ) );
- size.height = std::max( size.height, backgroundImageActor.GetRelayoutSize( HEIGHT ) );
- }
+ // Check Image and Background image and use the largest size as the control's Natural size.
+ SizeOfActorIfLarger( GetButtonImage(), size );
+ SizeOfActorIfLarger( GetBackgroundImage(), size );
// If label, test against it's size
Toolkit::TextLabel label = Toolkit::TextLabel::DownCast( GetLabel() );
#include "effects-view-impl.h"
// EXTERNAL INCLUDES
-#include <dali/public-api/animation/active-constraint.h>
#include <dali/public-api/animation/constraint.h>
#include <dali/public-api/animation/constraints.h>
#include <dali/public-api/common/stage.h>
mEffectStrengthPropertyIndex = self.RegisterProperty(EFFECT_STRENGTH_PROPERTY_NAME, EFFECT_STRENGTH_DEFAULT, Property::READ_WRITE);
mEffectOffsetPropertyIndex = self.RegisterProperty(EFFECT_OFFSET_PROPERTY_NAME, EFFECT_OFFSET_DEFAULT);
mEffectColorPropertyIndex = self.RegisterProperty(EFFECT_COLOR_PROPERTY_NAME, EFFECT_COLOR_DEFAULT);
- mActorPostFilter.ApplyConstraint( Constraint::New<Vector3>( Actor::Property::POSITION, Source( self, mEffectOffsetPropertyIndex ), EqualToConstraint() ) );
- mActorPostFilter.ApplyConstraint( Constraint::New<Vector4>( Actor::Property::COLOR, Source( self, mEffectColorPropertyIndex ), EqualToConstraint() ) );
+
+ Constraint positionConstraint = Constraint::New<Vector3>( mActorPostFilter, Actor::Property::POSITION, EqualToConstraint() );
+ positionConstraint.AddSource( Source( self, mEffectOffsetPropertyIndex ) );
+ positionConstraint.Apply();
+
+ Constraint colorConstraint = Constraint::New<Vector4>( mActorPostFilter, Actor::Property::COLOR, EqualToConstraint() );
+ colorConstraint.AddSource( Source( self, mEffectColorPropertyIndex ) );
+ colorConstraint.Apply();
}
void EffectsView::SetBackgroundColor( const Vector4& color )
// EXTERNAL INCLUDES
#include <sstream>
#include <iomanip>
-#include <dali/public-api/animation/active-constraint.h>
#include <dali/public-api/animation/constraint.h>
#include <dali/public-api/animation/constraints.h>
#include <dali/public-api/common/stage.h>
// Private methods
//
-/**
- * EqualToConstraintFloat
- *
- * f(current, property) = property
- */
-struct EqualToConstraintFloat
-{
- EqualToConstraintFloat(){}
-
- float operator()(const float current, const PropertyInput& property) {return property.GetFloat();}
-};
-
void GaussianBlurView::OnInitialize()
{
// root actor to parent all user added actors, needed to allow us to set that subtree as exclusive for our child render task
mImageActorComposite.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) ); // FIXME
mImageActorComposite.SetOpacity(GAUSSIAN_BLUR_VIEW_DEFAULT_BLUR_STRENGTH); // ensure alpha is enabled for this object and set default value
- Constraint blurStrengthConstraint = Constraint::New<float>( Actor::Property::COLOR_ALPHA, ParentSource(mBlurStrengthPropertyIndex), EqualToConstraintFloat());
- mImageActorComposite.ApplyConstraint(blurStrengthConstraint);
+ Constraint blurStrengthConstraint = Constraint::New<float>( mImageActorComposite, Actor::Property::COLOR_ALPHA, EqualToConstraint());
+ blurStrengthConstraint.AddSource( ParentSource(mBlurStrengthPropertyIndex) );
+ blurStrengthConstraint.Apply();
// Create an ImageActor for holding final result, i.e. the blurred image. This will get rendered to screen later, via default / user render task
mTargetActor = ImageActor::New();
// EXTERNAL INCLUDES
#include <sstream>
-#include <dali/public-api/animation/active-constraint.h>
#include <dali/public-api/animation/constraint.h>
#include <dali/public-api/animation/constraints.h>
#include <dali/public-api/common/stage.h>
" gl_FragColor = texture2D(sTexture, vTexCoord) * vec4(1,1,1,mask.a); \n"
"}";
-Vector2 EqualToConstraintVector2( const Vector2& current, const PropertyInput& property )
-{
- return property.GetVector2();
-}
-
Vector2 GetSizeForAspectRatio( const Vector2& targetSize, float aspectRatio )
{
Vector2 sizeToKeepAspectRatio( targetSize );
mRenderTask.SetInputEnabled( false );
mRenderTask.SetExclusive( true );
mRenderTask.SetClearEnabled( true );
- mRenderTask.ApplyConstraint( Constraint::New<Vector4>( RenderTask::Property::CLEAR_COLOR,
- Source( self, mCustomProperties[ Dali::Toolkit::MaskedImageView::BACKGROUND_COLOR ] ),
- EqualToConstraint() ) );
+
+ Constraint clearColorConstraint = Constraint::New<Vector4>( mRenderTask, RenderTask::Property::CLEAR_COLOR, EqualToConstraint() );
+ clearColorConstraint.AddSource( Source( self, mCustomProperties[ Dali::Toolkit::MaskedImageView::BACKGROUND_COLOR ] ) );
+ clearColorConstraint.Apply();
mRenderTask.FinishedSignal().Connect( this, &MaskedImageView::OnRenderTaskFinished );
// Edit mode initialization
ShaderEffect::GeometryHints( ShaderEffect::HINT_BLENDING ) );
shader.SetUniform( "uTargetSize", mTargetSize );
+
shader.SetUniform( "uSourceSize", mTargetSize );
- shader.ApplyConstraint( Constraint::New<Vector2>( shader.GetPropertyIndex( "uSourceSize" ),
- Source( self, mCustomProperties[ Dali::Toolkit::MaskedImageView::SOURCE_SIZE ] ),
- EqualToConstraintVector2 ) );
+ Constraint sourceSizeConstraint = Constraint::New<Vector2>( shader, shader.GetPropertyIndex( "uSourceSize" ), EqualToConstraint() );
+ sourceSizeConstraint.AddSource( Source( self, mCustomProperties[ Dali::Toolkit::MaskedImageView::SOURCE_SIZE ] ) );
+ sourceSizeConstraint.Apply();
+
shader.SetUniform( "uSourceOffset", Vector2::ZERO );
- shader.ApplyConstraint( Constraint::New<Vector2>( shader.GetPropertyIndex( "uSourceOffset" ),
- Source( self, mCustomProperties[ Dali::Toolkit::MaskedImageView::SOURCE_OFFSET ] ),
- EqualToConstraintVector2 ) );
+ Constraint sourceOffsetConstraint = Constraint::New<Vector2>( shader, shader.GetPropertyIndex( "uSourceOffset" ), EqualToConstraint() );
+ sourceOffsetConstraint.AddSource( Source( self, mCustomProperties[ Dali::Toolkit::MaskedImageView::SOURCE_OFFSET ] ) );
+ sourceOffsetConstraint.Apply();
+
shader.SetUniform( "uMaskSize", mTargetSize );
- shader.ApplyConstraint( Constraint::New<Vector2>( shader.GetPropertyIndex( "uMaskSize" ),
- Source( self, mCustomProperties[ Dali::Toolkit::MaskedImageView::MASK_SIZE ] ),
- EqualToConstraintVector2 ) );
+ Constraint maskSizeConstraint = Constraint::New<Vector2>( shader, shader.GetPropertyIndex( "uMaskSize" ), EqualToConstraint() );
+ maskSizeConstraint.AddSource( Source( self, mCustomProperties[ Dali::Toolkit::MaskedImageView::MASK_SIZE ] ) );
+ maskSizeConstraint.Apply();
+
shader.SetUniform( "uMaskOffset", mTargetSize );
- shader.ApplyConstraint( Constraint::New<Vector2>( shader.GetPropertyIndex( "uMaskOffset" ),
- Source( self, mCustomProperties[ Dali::Toolkit::MaskedImageView::MASK_OFFSET ] ),
- EqualToConstraintVector2 ) );
+ Constraint maskOffsetConstraint = Constraint::New<Vector2>( shader, shader.GetPropertyIndex( "uMaskOffset" ), EqualToConstraint() );
+ maskOffsetConstraint.AddSource( Source( self, mCustomProperties[ Dali::Toolkit::MaskedImageView::MASK_OFFSET ] ) );
+ maskOffsetConstraint.Apply();
shader.SetEffectImage( mMaskImage );
mSourceImageActor.SetShaderEffect( shader );
#include <dali-toolkit/internal/controls/magnifier/magnifier-impl.h>
// EXTERNAL INCLUDES
-#include <dali/public-api/animation/active-constraint.h>
#include <dali/public-api/animation/constraint.h>
#include <dali/public-api/animation/constraints.h>
#include <dali/public-api/common/stage.h>
const float IMAGE_BORDER_INDENT = 14.0f; ///< Indent of border in pixels.
-/**
- * ImageBorderSizeConstraint
- */
-struct ImageBorderSizeConstraint
-{
- ImageBorderSizeConstraint()
- : mSizeOffset(Vector3(IMAGE_BORDER_INDENT - 1, IMAGE_BORDER_INDENT - 1, 0.0f) * 2.0f)
- {
- }
-
- Vector3 operator()(const Vector3& current,
- const PropertyInput& referenceSizeProperty)
- {
- const Vector3& referenceSize = referenceSizeProperty.GetVector3();
-
- return referenceSize + mSizeOffset;
- }
-
- Vector3 mSizeOffset; ///< The amount to offset the size from referenceSize
-};
-
struct CameraActorPositionConstraint
{
CameraActorPositionConstraint(const Vector2& stageSize, float defaultCameraDistance = 0.0f)
{
}
- Vector3 operator()(const Vector3& current,
- const PropertyInput& sourcePositionProperty)
+ void operator()( Vector3& current, const PropertyInputContainer& inputs )
{
- const Vector3& sourcePosition = sourcePositionProperty.GetVector3();
+ const Vector3& sourcePosition = inputs[0]->GetVector3();
- return Vector3( sourcePosition.x + mStageSize.x * 0.5f,
- sourcePosition.y + mStageSize.y * 0.5f,
- sourcePosition.z + mDefaultCameraDistance);
+ current.x = sourcePosition.x + mStageSize.x * 0.5f;
+ current.y = sourcePosition.y + mStageSize.y * 0.5f;
+ current.z = sourcePosition.z + mDefaultCameraDistance;
}
Vector2 mStageSize;
{
}
- Vector2 operator()(const Vector2& current,
- const PropertyInput& positionProperty,
- const PropertyInput& magnifierSizeProperty,
- const PropertyInput& magnifierScaleProperty)
+ void operator()( Vector2& current, const PropertyInputContainer& inputs )
{
- Vector2 position(positionProperty.GetVector3()); // World position?
-
- //position -= mStageSize * 0.5f;
+ current = inputs[0]->GetVector3(); // World position?
// should be updated when:
// Magnifier's world position/size/scale/parentorigin/anchorpoint changes.
// or Magnifier camera's world position changes.
- Vector3 size = magnifierSizeProperty.GetVector3() * magnifierScaleProperty.GetVector3();
+ Vector3 size = inputs[1]->GetVector3() * inputs[2]->GetVector3(); /* magnifier-size * magnifier-scale */
// Reposition, and resize viewport to reflect the world bounds of this Magnifier actor.
- position.x += (mStageSize.width - size.width) * 0.5f;
- position.y += (mStageSize.height - size.height) * 0.5f;
-
- return position;
+ current.x += ( mStageSize.width - size.width ) * 0.5f;
+ current.y += ( mStageSize.height - size.height ) * 0.5f;
}
Vector2 mStageSize;
{
}
- Vector2 operator()(const Vector2& current,
- const PropertyInput& magnifierSizeProperty,
- const PropertyInput& magnifierScaleProperty)
+ void operator()( Vector2& current, const PropertyInputContainer& inputs )
{
- return Vector2(magnifierSizeProperty.GetVector3() * magnifierScaleProperty.GetVector3());
+ current = inputs[0]->GetVector3() * inputs[1]->GetVector3(); /* magnifier-size * magnifier-scale */
}
};
mSourceActor = Actor::New();
Stage().GetCurrent().Add(mSourceActor);
mSourceActor.SetParentOrigin(ParentOrigin::CENTER);
- Constraint constraint = Constraint::New<Vector3>( Actor::Property::POSITION,
- Source( self, mPropertySourcePosition ),
- EqualToConstraint() );
- mSourceActor.ApplyConstraint(constraint);
+ Constraint constraint = Constraint::New<Vector3>( mSourceActor, Actor::Property::POSITION, EqualToConstraint() );
+ constraint.AddSource( Source( self, mPropertySourcePosition ) );
+ constraint.Apply();
// create the render task this will render content on top of everything
// based on camera source position.
// at the end of the update cycle i.e. after constraints have been applied.)
//Property::Index propertySourcePositionDelayed = mCameraActor.RegisterProperty("delayed-source-position", Vector3::ZERO);
- constraint = Constraint::New<Vector3>( Actor::Property::POSITION,
- Source( mSourceActor, Actor::Property::WORLD_POSITION ),
- CameraActorPositionConstraint(stageSize, mDefaultCameraDistance) );
- mCameraActor.ApplyConstraint(constraint);
+ constraint = Constraint::New<Vector3>( mCameraActor, Actor::Property::POSITION, CameraActorPositionConstraint(stageSize, mDefaultCameraDistance) );
+ constraint.AddSource( Source( mSourceActor, Actor::Property::WORLD_POSITION ) );
+ constraint.Apply();
// Apply constraint to render-task viewport position
- constraint = Constraint::New<Vector2>( RenderTask::Property::VIEWPORT_POSITION,
- Source( self, Actor::Property::WORLD_POSITION ),//mPropertySourcePosition ),
- Source( self, Actor::Property::SIZE ),
- Source( self, Actor::Property::WORLD_SCALE ),
- RenderTaskViewportPositionConstraint(stageSize) );
- mTask.ApplyConstraint(constraint);
+ constraint = Constraint::New<Vector2>( mTask, RenderTask::Property::VIEWPORT_POSITION, RenderTaskViewportPositionConstraint(stageSize) );
+ constraint.AddSource( Source( self, Actor::Property::WORLD_POSITION ) );
+ constraint.AddSource( Source( self, Actor::Property::SIZE ) );
+ constraint.AddSource( Source( self, Actor::Property::WORLD_SCALE ) );
+ constraint.Apply();
// Apply constraint to render-task viewport position
- constraint = Constraint::New<Vector2>( RenderTask::Property::VIEWPORT_SIZE,
- Source( self, Actor::Property::SIZE ),
- Source( self, Actor::Property::WORLD_SCALE ),
- RenderTaskViewportSizeConstraint() );
- mTask.ApplyConstraint(constraint);
+ constraint = Constraint::New<Vector2>( mTask, RenderTask::Property::VIEWPORT_SIZE, RenderTaskViewportSizeConstraint() );
+ constraint.AddSource( Source( self, Actor::Property::SIZE ) );
+ constraint.AddSource( Source( self, Actor::Property::WORLD_SCALE ) );
+ constraint.Apply();
}
Magnifier::~Magnifier()
mFrame.SetPositionInheritanceMode(DONT_INHERIT_POSITION);
mFrame.SetInheritScale(true);
- Constraint constraint = Constraint::New<Vector3>( Actor::Property::POSITION,
- ParentSource( Actor::Property::WORLD_POSITION ),
- EqualToConstraint() );
- mFrame.ApplyConstraint( constraint );
+ Constraint constraint = Constraint::New<Vector3>( mFrame, Actor::Property::POSITION, EqualToConstraint() );
+ constraint.AddSource( ParentSource( Actor::Property::WORLD_POSITION ) );
+ constraint.Apply();
mFrame.SetNinePatchBorder( Vector4::ONE * IMAGE_BORDER_INDENT );
self.Add(mFrame);
// EXTERNAL INCLUDES
#include <dali/public-api/animation/animation.h>
-#include <dali/public-api/animation/active-constraint.h>
#include <dali/public-api/animation/constraint.h>
#include <dali/public-api/events/hit-test-algorithm.h>
#include <dali/public-api/object/type-registry.h>
mDirection = offset / mDistance;
}
- Vector2 operator()(const Vector2& current, const PropertyInput& panDisplacement)
+ void operator()( Vector2& current, const PropertyInputContainer& inputs )
{
- float displacement = panDisplacement.GetFloat();
+ float displacement = inputs[0]->GetFloat();
if( displacement < mDistance )
{
- return mOldCenter + mDirection * displacement;
+ current = mOldCenter + mDirection * displacement;
}
else
{
- return mNewCenter + Vector2(0.25f*(displacement-mDistance), 0.f);
+ current = mNewCenter + Vector2(0.25f*(displacement-mDistance), 0.f);
}
}
mRotation = isTurnBack ? Quaternion( -Math::PI, Vector3::YAXIS ) : Quaternion( 0.f, Vector3::YAXIS );
}
- Quaternion operator()( const Quaternion& current, const PropertyInput& panDisplacement )
+ void operator()( Quaternion& current, const PropertyInputContainer& inputs )
{
- float displacement = panDisplacement.GetFloat();
- float angle;
+ float displacement = inputs[0]->GetFloat();
if( displacement < mDistance)
{
- return mRotation;
+ current = mRotation;
}
else
{
float coef = std::max(-1.0f, mStep*(mDistance-displacement));
- angle = Math::PI*( mConst + mSign*coef );
- return Quaternion( angle, Vector3::YAXIS );
+ float angle = Math::PI * ( mConst + mSign * coef );
+ current = Quaternion( angle, Vector3::YAXIS );
}
}
*/
struct CurrentCenterConstraint
{
- CurrentCenterConstraint( float pageWidth)
+ CurrentCenterConstraint( float pageWidth )
: mPageWidth( pageWidth )
{
mThres = pageWidth * PAGE_TURN_OVER_THRESHOLD_RATIO * 0.5f;
}
- Vector2 operator()( const Vector2& current, const PropertyInput& center, const PropertyInput& originalCenter )
+ void operator()( Vector2& current, const PropertyInputContainer& inputs )
{
- Vector2 centerPosition = center.GetVector2();
+ const Vector2& centerPosition = inputs[0]->GetVector2();
if( centerPosition.x > 0.f )
{
- return Vector2( mThres+centerPosition.x*0.5f , centerPosition.y);
+ current.x = mThres+centerPosition.x * 0.5f;
+ current.y = centerPosition.y;
}
else
{
- Vector2 centerOrigin = originalCenter.GetVector2();
+ const Vector2& centerOrigin = inputs[1]->GetVector2();
Vector2 direction = centerOrigin - Vector2(mThres, centerPosition.y);
float coef = 1.f+(centerPosition.x*2.f / mPageWidth);
// Todo: when coef <= 0, the page is flat, slow down the last moment of the page stretch by 10 times to avoid a small bounce
{
coef = (coef+0.225f)/10.0f;
}
- return centerOrigin - direction * coef;
+ current = centerOrigin - direction * coef;
}
}
: mThres( thres )
{}
- float operator()( const float current, const PropertyInput& currentCenter, const PropertyInput& originalCenter, const PropertyInput& panDisplacement)
+ void operator()( float& blurStrength, const PropertyInputContainer& inputs )
{
- float displacement = panDisplacement.GetFloat();
- float blurStrength;
+ float displacement = inputs[2]->GetFloat();
if( EqualsZero(displacement))
{
- Vector2 cur = currentCenter.GetVector2();
- Vector2 ori = originalCenter.GetVector2();
+ const Vector2& cur = inputs[0]->GetVector2();
+ const Vector2& ori = inputs[1]->GetVector2();
blurStrength = 5.f*(ori-cur).Length() / mThres;
}
else
}
blurStrength = blurStrength > 1.f ? 1.f : ( blurStrength < 0.f ? 0.f : blurStrength );
- return blurStrength;
}
float mThres;
mShadowView.RemoveConstraints();
Actor self = Self();
self.SetProperty( mPropertyPanDisplacement[mIndex], 0.f );
- Constraint shadowBlurStrengthConstraint = Constraint::New<float>( mShadowView.GetBlurStrengthPropertyIndex(),
- Source(mTurnEffect[mIndex], mTurnEffect[mIndex].GetPropertyIndex(mTurnEffect[mIndex].PageTurnEffect::GetCurrentCenterPropertyName())),
- Source(mTurnEffect[mIndex], mTurnEffect[mIndex].GetPropertyIndex(mTurnEffect[mIndex].PageTurnEffect::GetOriginalCenterPropertyName())),
- Source( self, mPropertyPanDisplacement[mIndex] ),
- ShadowBlurStrengthConstraint( mPageSize.width*PAGE_TURN_OVER_THRESHOLD_RATIO ) );
- mShadowView.ApplyConstraint( shadowBlurStrengthConstraint );
+
+ Constraint shadowBlurStrengthConstraint = Constraint::New<float>( mShadowView, mShadowView.GetBlurStrengthPropertyIndex(), ShadowBlurStrengthConstraint( mPageSize.width*PAGE_TURN_OVER_THRESHOLD_RATIO ) );
+ shadowBlurStrengthConstraint.AddSource( Source(mTurnEffect[mIndex], mTurnEffect[mIndex].GetPropertyIndex(mTurnEffect[mIndex].PageTurnEffect::GetCurrentCenterPropertyName())) );
+ shadowBlurStrengthConstraint.AddSource( Source(mTurnEffect[mIndex], mTurnEffect[mIndex].GetPropertyIndex(mTurnEffect[mIndex].PageTurnEffect::GetOriginalCenterPropertyName())) );
+ shadowBlurStrengthConstraint.AddSource( Source( self, mPropertyPanDisplacement[mIndex] ) );
+ shadowBlurStrengthConstraint.Apply();
}
}
else
/( offset.x*offset.x + offset.y*offset.y );
offset *= k;
Actor self = Self();
- Source source(self, mPropertyPanDisplacement[mIndex]);
Property::Index shaderOriginalCenterPropertyIndex = mTurnEffect[mIndex].GetPropertyIndex(mTurnEffect[mIndex].PageTurnEffect::GetOriginalCenterPropertyName());
- Constraint originalCenterConstraint = Constraint::New<Vector2>( shaderOriginalCenterPropertyIndex ,
- source,
- OriginalCenterConstraint( mOriginalCenter, offset ));
- mTurnEffect[mIndex].ApplyConstraint( originalCenterConstraint );
+ Constraint originalCenterConstraint = Constraint::New<Vector2>( mTurnEffect[mIndex], shaderOriginalCenterPropertyIndex, OriginalCenterConstraint( mOriginalCenter, offset ));
+ originalCenterConstraint.AddSource( Source( self, mPropertyPanDisplacement[mIndex] ) );
+ originalCenterConstraint.Apply();
Property::Index shaderCurrentCenterPropertyIndex = mTurnEffect[mIndex].GetPropertyIndex(mTurnEffect[mIndex].PageTurnEffect::GetCurrentCenterPropertyName());
- Constraint currentCenterConstraint = Constraint::New<Vector2>( shaderCurrentCenterPropertyIndex,
- Source(self, mPropertyCurrentCenter[mIndex]),
- Source(mTurnEffect[mIndex], shaderOriginalCenterPropertyIndex),
- CurrentCenterConstraint(mPageSize.width));
- mTurnEffect[mIndex].ApplyConstraint( currentCenterConstraint );
+ Constraint currentCenterConstraint = Constraint::New<Vector2>( mTurnEffect[mIndex], shaderCurrentCenterPropertyIndex, CurrentCenterConstraint(mPageSize.width));
+ currentCenterConstraint.AddSource( Source(self, mPropertyCurrentCenter[mIndex]) );
+ currentCenterConstraint.AddSource( Source(mTurnEffect[mIndex], shaderOriginalCenterPropertyIndex) );
+ currentCenterConstraint.Apply();
GetImpl( mTurnEffect[mIndex] ).ApplyInternalConstraint();
float distance = offset.Length();
- Constraint rotationConstraint = Constraint::New<Quaternion>( Actor::Property::ORIENTATION,
- Source( self, mPropertyPanDisplacement[mIndex] ),
- RotationConstraint(distance, mPageSize.width, mIsTurnBack[mPanActor]));
- mPanActor.ApplyConstraint( rotationConstraint );
+ Constraint rotationConstraint = Constraint::New<Quaternion>( mPanActor, Actor::Property::ORIENTATION, RotationConstraint(distance, mPageSize.width, mIsTurnBack[mPanActor]));
+ rotationConstraint.AddSource( Source( self, mPropertyPanDisplacement[mIndex] ) );
+ rotationConstraint.Apply();
mConstraints = false;
}
/**
* Constraint operator
- * @param[in] current The current indicator position
- * @param[in] indicatorSizeProperty The size of indicator.
- * @param[in] parentSizeProperty The parent size of indicator.
- * @param[in] scrollPositionProperty The scroll position of the scrollable container // (from 0.0 -> 1.0 in each axis)
+ * @param[in,out] current The current indicator position
+ * @param[in] inputs Contains the size of indicator, the size of indicator's parent, and the scroll position of the scrollable container (from 0.0 -> 1.0 in each axis)
* @return The new indicator position is returned.
*/
- Vector3 operator()(const Vector3& current,
- const PropertyInput& indicatorSizeProperty,
- const PropertyInput& parentSizeProperty,
- const PropertyInput& scrollPositionProperty)
+ void operator()( Vector3& current, const PropertyInputContainer& inputs )
{
- Vector3 indicatorSize = indicatorSizeProperty.GetVector3();
- Vector3 parentSize = parentSizeProperty.GetVector3();
- float scrollPosition = scrollPositionProperty.GetFloat();
+ const Vector3& indicatorSize = inputs[0]->GetVector3();
+ const Vector3& parentSize = inputs[1]->GetVector3();
+ float scrollPosition = inputs[2]->GetFloat();
const float domainSize = fabs(mMaxPosition - mMinPosition);
float relativePosition = (mMaxPosition - scrollPosition) / domainSize;
- return Vector3(current.x, relativePosition * (parentSize.height - indicatorSize.height), DEFAULT_SLIDER_DEPTH);
+
+ current.y = relativePosition * ( parentSize.height - indicatorSize.height );
+ current.z = DEFAULT_SLIDER_DEPTH;
}
float mMinPosition; ///< The minimum scroll position
{
if( mScrollConnector )
{
- Constraint constraint;
-
- if(mIndicatorSizeConstraint)
- {
- mIndicator.RemoveConstraint(mIndicatorSizeConstraint);
- }
-
// Set indicator height according to the indicator's height policy
if(mIndicatorHeightPolicy == Toolkit::ScrollBar::Fixed)
{
if(mIndicatorPositionConstraint)
{
- mIndicator.RemoveConstraint(mIndicatorPositionConstraint);
+ mIndicatorPositionConstraint.Remove();
}
- constraint = Constraint::New<Vector3>( Actor::Property::POSITION,
- LocalSource( Actor::Property::SIZE ),
- ParentSource( Actor::Property::SIZE ),
- Source( mScrollPositionObject, Toolkit::ScrollConnector::SCROLL_POSITION ),
- IndicatorPositionConstraint( mScrollConnector.GetMinLimit(), mScrollConnector.GetMaxLimit() ) );
- mIndicatorPositionConstraint = mIndicator.ApplyConstraint( constraint );
+ mIndicatorPositionConstraint = Constraint::New<Vector3>( mIndicator, Actor::Property::POSITION, IndicatorPositionConstraint( mScrollConnector.GetMinLimit(), mScrollConnector.GetMaxLimit() ) );
+ mIndicatorPositionConstraint.AddSource( LocalSource( Actor::Property::SIZE ) );
+ mIndicatorPositionConstraint.AddSource( ParentSource( Actor::Property::SIZE ) );
+ mIndicatorPositionConstraint.AddSource( Source( mScrollPositionObject, Toolkit::ScrollConnector::SCROLL_POSITION ) );
+ mIndicatorPositionConstraint.Apply();
}
}
// EXTERNAL INCLUDES
#include <dali/public-api/adaptor-framework/timer.h>
#include <dali/public-api/actors/image-actor.h>
-#include <dali/public-api/animation/active-constraint.h>
+#include <dali/public-api/animation/constraint.h>
#include <dali/public-api/animation/animation.h>
#include <dali/public-api/object/property-notification.h>
ScrollPositionNotifiedSignalType mScrollPositionNotifiedSignal;
- ActiveConstraint mIndicatorSizeConstraint;
- ActiveConstraint mIndicatorPositionConstraint;
+ Constraint mIndicatorPositionConstraint;
};
} // namespace Internal
#include <dali-toolkit/internal/controls/scroll-component/scroll-bar-internal-impl.h>
// EXTERNAL INCLUDES
-#include <dali/public-api/animation/active-constraint.h>
#include <dali/public-api/animation/constraint.h>
#include <dali/public-api/object/property-input.h>
#include <dali/public-api/object/type-registry.h>
* ScrollBarInternal Visibility Constraint
* Returns whether scroll bar is visible
*/
-bool ScrollBarInternalVisibilityConstraint(const bool& current,
- const PropertyInput& canScrollProperty)
+void ScrollBarInternalVisibilityConstraint( bool& current, const PropertyInputContainer& inputs )
{
- bool canScroll = canScrollProperty.GetBoolean();
- return canScroll;
+ current = inputs[0]->GetBoolean();
}
/**
/**
* Constraint operator
- * @param[in] current The current ScrollBarInternal size
- * @param[in] scrollMinProperty The container's minimum position.
- * @param[in] scrollMaxProperty The container's maximum position.
- * @param[in] scrollDirectionProperty The container's scroll direction.
- * @param[in] scrollSizeProperty The container's size of viewport.
+ * @param[in,out] current The current ScrollBarInternal size
+ * @param[in] inputs Contains the container's minimum position, its maximum position, its scroll direction & its size of viewport.
* @return The new ScrollBarInternal position is returned.
*/
- Vector3 operator()(const Vector3& current,
- const PropertyInput& scrollMinProperty,
- const PropertyInput& scrollMaxProperty,
- const PropertyInput& scrollDirectionProperty,
- const PropertyInput& scrollSizeProperty)
+ void operator()( Vector3& current, const PropertyInputContainer& inputs )
{
- const Vector3& min = scrollMinProperty.GetVector3();
- const Vector3& max = scrollMaxProperty.GetVector3();
- const Vector3& scrollDirection = scrollDirectionProperty.GetVector3();
+ const Vector3& min = inputs[0]->GetVector3();
+ const Vector3& max = inputs[1]->GetVector3();
+ const Vector3& scrollDirection = inputs[2]->GetVector3();
const Toolkit::ControlOrientation::Type& orientation = static_cast<Toolkit::ControlOrientation::Type>(scrollDirection.z);
- const Vector3& size = scrollSizeProperty.GetVector3();
+ const Vector3& size = inputs[3]->GetVector3();
const Vector3 domainSize = max - min;
if (mVertical && Toolkit::IsVertical(orientation))
{
- float mod = fabsf(domainSize.height) > size.height ? size.height * ( size.height / fabsf(domainSize.height) ) : size.height * ( (size.height - fabsf(domainSize.height * 0.5f)) / size.height);
- return Vector3( current.width, mod, current.depth );
+ current.height = fabsf(domainSize.height) > size.height ? size.height * ( size.height / fabsf(domainSize.height) ) : size.height * ( (size.height - fabsf(domainSize.height * 0.5f)) / size.height);
}
else
{
- float mod = fabsf(domainSize.height) > size.width ? size.width * ( size.width / fabsf(domainSize.height) ) : size.width * ( (size.width - fabsf(domainSize.height * 0.5f)) / size.width);
- return Vector3( current.width, mod, current.depth );
+ current.height = fabsf(domainSize.height) > size.width ? size.width * ( size.width / fabsf(domainSize.height) ) : size.width * ( (size.width - fabsf(domainSize.height * 0.5f)) / size.width);
}
}
/**
* Constraint operator
- * @param[in] current The current ScrollBarInternal rotation
+ * @param[in,out] current The current ScrollBarInternal rotation
* @param[in] scrollDirectionProperty The container's scroll direction.
* @return The new ScrollBarInternal rotation is returned.
*/
- Quaternion operator()(const Quaternion& current,
- const PropertyInput& scrollDirectionProperty)
+ void operator()( Quaternion& current, const PropertyInputContainer& inputs )
{
- const Vector3& scrollDirection = scrollDirectionProperty.GetVector3();
+ const Vector3& scrollDirection = inputs[0]->GetVector3();
const Toolkit::ControlOrientation::Type& orientation = static_cast<Toolkit::ControlOrientation::Type>(scrollDirection.z);
if( (mVertical && Toolkit::IsVertical(orientation)) || (!mVertical && Toolkit::IsHorizontal(orientation)) )
{
- return Quaternion(0.0f, Vector3::ZAXIS);
+ current = Quaternion(0.0f, Vector3::ZAXIS);
}
else
{
- return Quaternion(0.5f * Math::PI, Vector3::ZAXIS);
+ current = Quaternion(0.5f * Math::PI, Vector3::ZAXIS);
}
}
/**
* Constraint operator
- * @param[in] current The current ScrollBarInternal position
- * @param[in] scrollBarSizeProperty ScrollBarInternal size
- * @param[in] scrollRelativePositionProperty The container's relative position (from 0.0 -> 1.0 in each axis)
- * @param[in] scrollMinProperty The container's minimum position.
- * @param[in] scrollMaxProperty The container's maximum position.
- * @param[in] scrollDirectionProperty The container's scroll direction.
- * @param[in] scrollSizeProperty The container's size of viewport.
+ * @param[in] finalPosition The current ScrollBarInternal position
+ * @param[in] inputs Contains:
+ * The ScrollBarInternal size,
+ * The container's relative position (from 0.0 -> 1.0 in each axis),
+ * The container's minimum position,
+ * The container's maximum position,
+ * The container's scroll direction,
+ * The container's size of viewport.
* @return The new ScrollBarInternal position is returned.
*/
- Vector3 operator()(const Vector3& current,
- const PropertyInput& scrollBarSizeProperty,
- const PropertyInput& scrollRelativePositionProperty,
- const PropertyInput& scrollMinProperty,
- const PropertyInput& scrollMaxProperty,
- const PropertyInput& scrollDirectionProperty,
- const PropertyInput& scrollSizeProperty)
+ void operator()( Vector3& finalPosition, const PropertyInputContainer& inputs )
{
- Vector3 barSize = scrollBarSizeProperty.GetVector3();
- Vector3 relativePosition = scrollRelativePositionProperty.GetVector3();
- Vector3 size = scrollSizeProperty.GetVector3();
- const Vector3& min = scrollMinProperty.GetVector3();
- const Vector3& max = scrollMaxProperty.GetVector3();
- const Vector3& scrollDirection = scrollDirectionProperty.GetVector3();
+ const Vector3& barSize = inputs[0]->GetVector3();
+ const Vector3& relativePosition = inputs[1]->GetVector3();
+ const Vector3& min = inputs[2]->GetVector3();
+ const Vector3& max = inputs[3]->GetVector3();
+ const Vector3& scrollDirection = inputs[4]->GetVector3();
+ const Vector3& size = inputs[5]->GetVector3();
const Toolkit::ControlOrientation::Type& orientation = static_cast<Toolkit::ControlOrientation::Type>(scrollDirection.z);
Vector3 domainSize = max - min;
Vector3 maskedRelativePosition = Toolkit::IsVertical(orientation) ? Vector3(relativePosition.x * (size.x-barSize.y), relativePosition.y * (size.y-barSize.y), 0.0f) * mask
: Vector3(relativePosition.y * (size.x-barSize.y), relativePosition.x * (size.y-barSize.y), 0.0f) * mask;
- Vector3 finalPosition = relativeOffset * size + absoluteOffset + maskedRelativePosition;
+ finalPosition = relativeOffset * size + absoluteOffset + maskedRelativePosition;
// If Wrapped Slider, then position 1 domain either before or after current slider.
if(mWrap)
finalPosition.y -= size.y;
}
}
-
- return finalPosition;
}
bool mVertical; ///< Whether vertical or horizontal.
/**
* Constraint operator
* @param[in] current The current HitSize
- * @param[in] scrollDirectionProperty The container's scroll direction.
- * @param[in] scrollSizeProperty The container's size of viewport.
+ * @param[in] inputs Contains the container's scroll direction and size of its viewport.
* @return The new ScrollBarInternal Hit Area size is returned.
*/
- Vector3 operator()(const Vector3& current,
- const PropertyInput& scrollDirectionProperty,
- const PropertyInput& scrollSizeProperty)
+ void operator()( Vector3& current, const PropertyInputContainer& inputs )
{
- const Vector3& scrollDirection = scrollDirectionProperty.GetVector3();
+ const Vector3& scrollDirection = inputs[0]->GetVector3();
const Toolkit::ControlOrientation::Type& orientation = static_cast<Toolkit::ControlOrientation::Type>(scrollDirection.z);
- Vector3 size = scrollSizeProperty.GetVector3();
+ const Vector3& size = inputs[1]->GetVector3();
Vector3 mask; // Mask size aspect of hit area.
Vector3 offset; // Add Offset size.
offset = Vector3::YAXIS * mThickness;
}
- return size * mask + offset;
+ current = size * mask + offset;
}
bool mVertical; ///< Whether vertical or horizontal.
// target the container to observe for scrolling
Actor target = mContainer.Self();
- Constraint constraint = Constraint::New<bool>( Actor::Property::VISIBLE,
- 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, 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, 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, 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) );
-
- mSlider.ApplyConstraint( constraint );
-
- constraint = Constraint::New<Vector3>( Actor::Property::POSITION,
- Source( mSlider, Actor::Property::SIZE),
- 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 );
+ Constraint constraint = Constraint::New<bool>( mSlider, Actor::Property::VISIBLE, ScrollBarInternalVisibilityConstraint );
+ constraint.AddSource( Source( target, vertical ? Toolkit::Scrollable::Property::CAN_SCROLL_VERTICAL : Toolkit::Scrollable::Property::CAN_SCROLL_HORIZONTAL ) );
+ constraint.Apply();
+
+ constraint = constraint.Clone( mSliderWrap );
+ constraint.Apply();
+
+ constraint = Constraint::New<Vector3>( mSlider, Actor::Property::SIZE, ScrollBarInternalSizeConstraint( vertical ) );
+ constraint.AddSource( Source( target, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ) );
+ constraint.AddSource( Source( target, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ) );
+ constraint.AddSource( Source( target, Toolkit::Scrollable::Property::SCROLL_DIRECTION ) );
+ constraint.AddSource( Source( target, Actor::Property::SIZE ) );
+ constraint.Apply();
+
+ constraint = constraint.Clone( mSliderWrap );
+ constraint.Apply();
+
+ constraint = Constraint::New<Quaternion>( mSlider, Actor::Property::ORIENTATION, ScrollBarInternalRotationConstraint( vertical ) );
+ constraint.AddSource( Source( target, Toolkit::Scrollable::Property::SCROLL_DIRECTION ) );
+ constraint.Apply();
+
+ constraint = constraint.Clone( mSliderWrap );
+ constraint.Apply();
+
+ constraint = Constraint::New<Vector3>( mSlider, Actor::Property::POSITION, ScrollBarInternalPositionConstraint(vertical) );
+ constraint.AddSource( Source( mSlider, Actor::Property::SIZE) );
+ constraint.AddSource( Source( target, Toolkit::Scrollable::Property::SCROLL_RELATIVE_POSITION ) );
+ constraint.AddSource( Source( target, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ) );
+ constraint.AddSource( Source( target, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ) );
+ constraint.AddSource( Source( target, Toolkit::Scrollable::Property::SCROLL_DIRECTION ) );
+ constraint.AddSource( Source( target, Actor::Property::SIZE ) );
+ constraint.Apply();
+
+ constraint = Constraint::New<Vector3>( mSliderWrap, Actor::Property::POSITION, ScrollBarInternalPositionConstraint(vertical, true) );
+ constraint.AddSource( Source( mSlider, Actor::Property::SIZE) );
+ constraint.AddSource( Source( target, Toolkit::Scrollable::Property::SCROLL_RELATIVE_POSITION ) );
+ constraint.AddSource( Source( target, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ) );
+ constraint.AddSource( Source( target, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ) );
+ constraint.AddSource( Source( target, Toolkit::Scrollable::Property::SCROLL_DIRECTION ) );
+ constraint.AddSource( Source( target, Actor::Property::SIZE ) );
+ constraint.Apply();
// Add Sliders to internal Actor, to avoid mixing up with regular
// Actors added by user.
mHitArea.SetPosition(0.0f, 0.0f, 0.2f);
mContainer.AddOverlay( mHitArea );
- constraint = Constraint::New<Vector3>( Actor::Property::SIZE,
- Source( target, Toolkit::Scrollable::Property::SCROLL_DIRECTION ),
- Source( target, Actor::Property::SIZE ),
- ScrollBarInternalHitSizeConstraint(vertical, BAR_TAB_SIZE.width) );
- mHitArea.ApplyConstraint( constraint );
+ constraint = Constraint::New<Vector3>( mHitArea, Actor::Property::SIZE, ScrollBarInternalHitSizeConstraint(vertical, BAR_TAB_SIZE.width) );
+ constraint.AddSource( Source( target, Toolkit::Scrollable::Property::SCROLL_DIRECTION ) );
+ constraint.AddSource( Source( target, Actor::Property::SIZE ) );
+ constraint.Apply();
if(vertical)
{
// EXTERNAL INCLUDES
#include <math.h>
#include <dali/public-api/actors/mesh-actor.h>
-#include <dali/public-api/animation/active-constraint.h>
#include <dali/public-api/animation/constraint.h>
#include <dali/public-api/geometry/animatable-mesh.h>
#include <dali/public-api/shader-effects/shader-effect.h>
{
}
- Vector3 operator()( const Vector3& current, const PropertyInput& bounceCoef )
+ void operator()( Vector3& current, const PropertyInputContainer& inputs )
{
- float positionY = mInitialY + mRange * fabsf(bounceCoef.GetFloat());
- return Vector3( current.x, positionY, current.z );
+ current.y = mInitialY + mRange * fabsf( inputs[0]->GetFloat() );
}
float mInitialY;
for( size_t i=0;i<NUM_LAYERS;i++ )
{
size_t j=i*4;
- mesh.ApplyConstraint( Constraint::New<Vector3>( mesh.GetPropertyIndex(j+2, AnimatableVertex::Property::POSITION ),
- Source(meshActor, bouncePropertyIndex),
- VertexPositionConstraint(-0.5f, LAYER_HEIGHTS[i]) ) );
- mesh.ApplyConstraint( Constraint::New<Vector3>( mesh.GetPropertyIndex(j+3, AnimatableVertex::Property::POSITION),
- Source(meshActor, bouncePropertyIndex),
- VertexPositionConstraint(-0.5f, LAYER_HEIGHTS[i]) ) );
+ Constraint constraint = Constraint::New<Vector3>( mesh, mesh.GetPropertyIndex(j+2, AnimatableVertex::Property::POSITION ), VertexPositionConstraint(-0.5f, LAYER_HEIGHTS[i]) );
+ constraint.AddSource( Source(meshActor, bouncePropertyIndex) );
+ constraint.Apply();
+
+ constraint = Constraint::New<Vector3>( mesh, mesh.GetPropertyIndex(j+3, AnimatableVertex::Property::POSITION), VertexPositionConstraint(-0.5f, LAYER_HEIGHTS[i]) );
+ constraint.AddSource( Source(meshActor, bouncePropertyIndex) );
+ constraint.Apply();
}
return meshActor;
// EXTERNAL INCLUDES
#include <algorithm>
-#include <dali/public-api/animation/active-constraint.h>
#include <dali/public-api/animation/constraint.h>
#include <dali/public-api/animation/constraints.h>
#include <dali/public-api/common/set-wrapper.h>
}
// Overshoot overlay constraints
-
-struct OvershootOverlaySizeConstraint
+void OvershootOverlaySizeConstraint( Vector3& current, const PropertyInputContainer& inputs )
{
- Vector3 operator()(const Vector3& current,
- const PropertyInput& parentScrollDirectionProperty,
- const PropertyInput& parentOvershootProperty,
- const PropertyInput& parentSizeProperty)
- {
- const Vector3 parentScrollDirection = parentScrollDirectionProperty.GetVector3();
- const Vector3 parentSize = parentSizeProperty.GetVector3();
- const Toolkit::ControlOrientation::Type& parentOrientation = static_cast<Toolkit::ControlOrientation::Type>(parentScrollDirection.z);
+ const Vector3& parentScrollDirection = inputs[0]->GetVector3();
+ const Vector3& parentSize = inputs[1]->GetVector3();
+ const Toolkit::ControlOrientation::Type& parentOrientation = static_cast<Toolkit::ControlOrientation::Type>(parentScrollDirection.z);
- float overlayWidth;
-
- if(Toolkit::IsVertical(parentOrientation))
- {
- overlayWidth = fabsf(parentScrollDirection.y) > Math::MACHINE_EPSILON_1 ? parentSize.x : parentSize.y;
- }
- else
- {
- overlayWidth = fabsf(parentScrollDirection.x) > Math::MACHINE_EPSILON_1 ? parentSize.y : parentSize.x;
- }
-
- float overlayHeight = (overlayWidth > OVERSHOOT_BOUNCE_ACTOR_RESIZE_THRESHOLD) ? OVERSHOOT_BOUNCE_ACTOR_DEFAULT_SIZE.height : OVERSHOOT_BOUNCE_ACTOR_DEFAULT_SIZE.height*0.5f;
-
- return Vector3( overlayWidth, overlayHeight, current.depth );
+ if(Toolkit::IsVertical(parentOrientation))
+ {
+ current.width = fabsf(parentScrollDirection.y) > Math::MACHINE_EPSILON_1 ? parentSize.x : parentSize.y;
}
-};
+ else
+ {
+ current.width = fabsf(parentScrollDirection.x) > Math::MACHINE_EPSILON_1 ? parentSize.y : parentSize.x;
+ }
+
+ current.height = ( current.width > OVERSHOOT_BOUNCE_ACTOR_RESIZE_THRESHOLD ) ? OVERSHOOT_BOUNCE_ACTOR_DEFAULT_SIZE.height : OVERSHOOT_BOUNCE_ACTOR_DEFAULT_SIZE.height*0.5f;
+}
-struct OvershootOverlayRotationConstraint
+void OvershootOverlayRotationConstraint( Quaternion& current, const PropertyInputContainer& inputs )
{
- Quaternion operator()(const Quaternion& current,
- const PropertyInput& parentScrollDirectionProperty,
- const PropertyInput& parentOvershootProperty)
- {
- const Vector3 parentScrollDirection = parentScrollDirectionProperty.GetVector3();
- const float parentOvershoot = parentOvershootProperty.GetFloat();
- const Toolkit::ControlOrientation::Type& parentOrientation = static_cast<Toolkit::ControlOrientation::Type>(parentScrollDirection.z);
+ const Vector3& parentScrollDirection = inputs[0]->GetVector3();
+ const float parentOvershoot = inputs[1]->GetFloat();
+ const Toolkit::ControlOrientation::Type& parentOrientation = static_cast<Toolkit::ControlOrientation::Type>(parentScrollDirection.z);
- float multiplier = 0;
- if(Toolkit::IsVertical(parentOrientation))
+ float multiplier = 0;
+ if(Toolkit::IsVertical(parentOrientation))
+ {
+ if(fabsf(parentScrollDirection.y) <= Math::MACHINE_EPSILON_1)
{
- if(fabsf(parentScrollDirection.y) <= Math::MACHINE_EPSILON_1)
- {
- if( (parentOrientation == Toolkit::ControlOrientation::Up && parentOvershoot < Math::MACHINE_EPSILON_0)
- || (parentOrientation == Toolkit::ControlOrientation::Down && parentOvershoot > Math::MACHINE_EPSILON_0) )
- {
- multiplier = 0.5f;
- }
- else
- {
- multiplier = 1.5f;
- }
- }
- else if( (parentOvershoot > Math::MACHINE_EPSILON_0 && parentScrollDirection.y > Math::MACHINE_EPSILON_0)
- || (parentOvershoot < Math::MACHINE_EPSILON_0 && parentScrollDirection.y < Math::MACHINE_EPSILON_0) )
+ if( (parentOrientation == Toolkit::ControlOrientation::Up && parentOvershoot < Math::MACHINE_EPSILON_0)
+ || (parentOrientation == Toolkit::ControlOrientation::Down && parentOvershoot > Math::MACHINE_EPSILON_0) )
{
- multiplier = 0.0f;
+ multiplier = 0.5f;
}
else
{
- multiplier = 1.0f;
+ multiplier = 1.5f;
}
}
+ else if( (parentOvershoot > Math::MACHINE_EPSILON_0 && parentScrollDirection.y > Math::MACHINE_EPSILON_0)
+ || (parentOvershoot < Math::MACHINE_EPSILON_0 && parentScrollDirection.y < Math::MACHINE_EPSILON_0) )
+ {
+ multiplier = 0.0f;
+ }
else
{
- if(fabsf(parentScrollDirection.x) <= Math::MACHINE_EPSILON_1)
- {
- if( (parentOrientation == Toolkit::ControlOrientation::Left && parentOvershoot > Math::MACHINE_EPSILON_0)
- ||(parentOrientation == Toolkit::ControlOrientation::Right && parentOvershoot < Math::MACHINE_EPSILON_0) )
- {
- multiplier = 1.0f;
- }
- else
- {
- multiplier = 0.0f;
- }
- }
- else if( (parentOvershoot > Math::MACHINE_EPSILON_0 && parentScrollDirection.x > Math::MACHINE_EPSILON_0)
- || (parentOvershoot < Math::MACHINE_EPSILON_0 && parentScrollDirection.x < Math::MACHINE_EPSILON_0) )
+ multiplier = 1.0f;
+ }
+ }
+ else
+ {
+ if(fabsf(parentScrollDirection.x) <= Math::MACHINE_EPSILON_1)
+ {
+ if( (parentOrientation == Toolkit::ControlOrientation::Left && parentOvershoot > Math::MACHINE_EPSILON_0)
+ ||(parentOrientation == Toolkit::ControlOrientation::Right && parentOvershoot < Math::MACHINE_EPSILON_0) )
{
- multiplier = 1.5f;
+ multiplier = 1.0f;
}
else
{
- multiplier = 0.5f;
+ multiplier = 0.0f;
}
}
-
- Quaternion rotation( Radian( multiplier * Math::PI ), Vector3::ZAXIS );
-
- return rotation;
+ else if( (parentOvershoot > Math::MACHINE_EPSILON_0 && parentScrollDirection.x > Math::MACHINE_EPSILON_0)
+ || (parentOvershoot < Math::MACHINE_EPSILON_0 && parentScrollDirection.x < Math::MACHINE_EPSILON_0) )
+ {
+ multiplier = 1.5f;
+ }
+ else
+ {
+ multiplier = 0.5f;
+ }
}
-};
-struct OvershootOverlayPositionConstraint
+ current = Quaternion( Radian( multiplier * Math::PI ), Vector3::ZAXIS );
+}
+
+void OvershootOverlayPositionConstraint( Vector3& current, const PropertyInputContainer& inputs )
{
- Vector3 operator()(const Vector3& current,
- const PropertyInput& parentSizeProperty,
- const PropertyInput& parentScrollDirectionProperty,
- const PropertyInput& parentOvershootProperty)
- {
- const Vector3 parentScrollDirection = parentScrollDirectionProperty.GetVector3();
- const float parentOvershoot = parentOvershootProperty.GetFloat();
- const Vector3 parentSize = parentSizeProperty.GetVector3();
- const Toolkit::ControlOrientation::Type& parentOrientation = static_cast<Toolkit::ControlOrientation::Type>(parentScrollDirection.z);
+ const Vector3& parentSize = inputs[0]->GetVector3();
+ const Vector3& parentScrollDirection = inputs[1]->GetVector3();
+ const float parentOvershoot = inputs[2]->GetFloat();
+ const Toolkit::ControlOrientation::Type& parentOrientation = static_cast<Toolkit::ControlOrientation::Type>(parentScrollDirection.z);
- Vector3 relativeOffset;
+ Vector3 relativeOffset;
- if(Toolkit::IsVertical(parentOrientation))
+ if(Toolkit::IsVertical(parentOrientation))
+ {
+ if(fabsf(parentScrollDirection.y) <= Math::MACHINE_EPSILON_1)
{
- if(fabsf(parentScrollDirection.y) <= Math::MACHINE_EPSILON_1)
+ if( (parentOrientation == Toolkit::ControlOrientation::Up && parentOvershoot < Math::MACHINE_EPSILON_0)
+ || (parentOrientation == Toolkit::ControlOrientation::Down && parentOvershoot > Math::MACHINE_EPSILON_0) )
{
- if( (parentOrientation == Toolkit::ControlOrientation::Up && parentOvershoot < Math::MACHINE_EPSILON_0)
- || (parentOrientation == Toolkit::ControlOrientation::Down && parentOvershoot > Math::MACHINE_EPSILON_0) )
- {
- relativeOffset = Vector3(1.0f, 0.0f, 0.0f);
- }
- else
- {
- relativeOffset =Vector3(0.0f, 1.0f, 0.0f);
- }
- }
- else if( (parentOvershoot > Math::MACHINE_EPSILON_0 && parentScrollDirection.y > Math::MACHINE_EPSILON_0)
- || (parentOvershoot < Math::MACHINE_EPSILON_0 && parentScrollDirection.y < Math::MACHINE_EPSILON_0) )
- {
- relativeOffset = Vector3(0.0f, 0.0f, 0.0f);
+ relativeOffset = Vector3(1.0f, 0.0f, 0.0f);
}
else
{
- relativeOffset = Vector3(1.0f, 1.0f, 0.0f);
+ relativeOffset =Vector3(0.0f, 1.0f, 0.0f);
}
}
+ else if( (parentOvershoot > Math::MACHINE_EPSILON_0 && parentScrollDirection.y > Math::MACHINE_EPSILON_0)
+ || (parentOvershoot < Math::MACHINE_EPSILON_0 && parentScrollDirection.y < Math::MACHINE_EPSILON_0) )
+ {
+ relativeOffset = Vector3(0.0f, 0.0f, 0.0f);
+ }
else
{
- if(fabsf(parentScrollDirection.x) <= Math::MACHINE_EPSILON_1)
- {
- if( (parentOrientation == Toolkit::ControlOrientation::Left && parentOvershoot < Math::MACHINE_EPSILON_0)
- || (parentOrientation == Toolkit::ControlOrientation::Right && parentOvershoot > Math::MACHINE_EPSILON_0) )
- {
- relativeOffset = Vector3(0.0f, 0.0f, 0.0f);
- }
- else
- {
- relativeOffset = Vector3(1.0f, 1.0f, 0.0f);
- }
- }
- else if( (parentOvershoot > Math::MACHINE_EPSILON_0 && parentScrollDirection.x > Math::MACHINE_EPSILON_0)
- || (parentOvershoot < Math::MACHINE_EPSILON_0 && parentScrollDirection.x < Math::MACHINE_EPSILON_0) )
+ relativeOffset = Vector3(1.0f, 1.0f, 0.0f);
+ }
+ }
+ else
+ {
+ if(fabsf(parentScrollDirection.x) <= Math::MACHINE_EPSILON_1)
+ {
+ if( (parentOrientation == Toolkit::ControlOrientation::Left && parentOvershoot < Math::MACHINE_EPSILON_0)
+ || (parentOrientation == Toolkit::ControlOrientation::Right && parentOvershoot > Math::MACHINE_EPSILON_0) )
{
- relativeOffset = Vector3(0.0f, 1.0f, 0.0f);
+ relativeOffset = Vector3(0.0f, 0.0f, 0.0f);
}
else
{
- relativeOffset = Vector3(1.0f, 0.0f, 0.0f);
+ relativeOffset = Vector3(1.0f, 1.0f, 0.0f);
}
}
-
- return relativeOffset * parentSize;
-
+ else if( (parentOvershoot > Math::MACHINE_EPSILON_0 && parentScrollDirection.x > Math::MACHINE_EPSILON_0)
+ || (parentOvershoot < Math::MACHINE_EPSILON_0 && parentScrollDirection.x < Math::MACHINE_EPSILON_0) )
+ {
+ relativeOffset = Vector3(0.0f, 1.0f, 0.0f);
+ }
+ else
+ {
+ relativeOffset = Vector3(1.0f, 0.0f, 0.0f);
+ }
}
-};
-struct OvershootOverlayVisibilityConstraint
-{
- bool operator()(const bool& current,
- const PropertyInput& parentLayoutScrollableProperty)
- {
- const bool parentLayoutScrollable = parentLayoutScrollableProperty.GetBoolean();
+ current = relativeOffset * parentSize;
+}
- return parentLayoutScrollable;
- }
-};
+void OvershootOverlayVisibilityConstraint( bool& current, const PropertyInputContainer& inputs )
+{
+ current = inputs[0]->GetBoolean();
+}
/**
* Relative position Constraint
* Generates the relative position value of the item view based on the layout position,
* and it's relation to the layout domain. This is a value from 0.0f to 1.0f in each axis.
*/
-Vector3 RelativePositionConstraint(const Vector3& current,
- const PropertyInput& scrollPositionProperty,
- const PropertyInput& scrollMinProperty,
- const PropertyInput& scrollMaxProperty,
- const PropertyInput& layoutSizeProperty)
+void RelativePositionConstraint( Vector3& current, const PropertyInputContainer& inputs )
{
- const Vector3& position = Vector3(0.0f, scrollPositionProperty.GetFloat(), 0.0f);
- const Vector3& min = scrollMinProperty.GetVector3();
- const Vector3& max = scrollMaxProperty.GetVector3();
+ const Vector3& position = Vector3(0.0f, inputs[0]->GetFloat(), 0.0f);
+ const Vector3& min = inputs[1]->GetVector3();
+ const Vector3& max = inputs[2]->GetVector3();
- Vector3 relativePosition;
Vector3 domainSize = max - min;
- relativePosition.x = fabsf(domainSize.x) > Math::MACHINE_EPSILON_1 ? ((min.x - position.x) / fabsf(domainSize.x)) : 0.0f;
- relativePosition.y = fabsf(domainSize.y) > Math::MACHINE_EPSILON_1 ? ((min.y - position.y) / fabsf(domainSize.y)) : 0.0f;
-
- return relativePosition;
+ current.x = fabsf(domainSize.x) > Math::MACHINE_EPSILON_1 ? ((min.x - position.x) / fabsf(domainSize.x)) : 0.0f;
+ current.y = fabsf(domainSize.y) > Math::MACHINE_EPSILON_1 ? ((min.y - position.y) / fabsf(domainSize.y)) : 0.0f;
+ current.z = 0.0f;
}
} // unnamed namespace
EnableScrollComponent(Toolkit::Scrollable::OvershootIndicator);
- Constraint constraint = Constraint::New<Vector3>(Toolkit::Scrollable::Property::SCROLL_RELATIVE_POSITION,
- LocalSource(mPropertyPosition),
- LocalSource(Toolkit::Scrollable::Property::SCROLL_POSITION_MIN),
- LocalSource(Toolkit::Scrollable::Property::SCROLL_POSITION_MAX),
- LocalSource(Actor::Property::SIZE),
- RelativePositionConstraint);
- self.ApplyConstraint(constraint);
+ Constraint constraint = Constraint::New<Vector3>( self, Toolkit::Scrollable::Property::SCROLL_RELATIVE_POSITION, RelativePositionConstraint );
+ constraint.AddSource( LocalSource( mPropertyPosition ) );
+ constraint.AddSource( LocalSource( Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ) );
+ constraint.AddSource( LocalSource( Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ) );
+ constraint.Apply();
Vector2 stageSize = Stage::GetCurrent().GetSize();
mMouseWheelScrollDistanceStep = stageSize.y * DEFAULT_MOUSE_WHEEL_SCROLL_DISTANCE_STEP_PROPORTION;
mOvershootOverlay.SetDrawMode(DrawMode::OVERLAY);
self.Add(mOvershootOverlay);
- Constraint constraint = Constraint::New<Vector3>( Actor::Property::SIZE,
- ParentSource( Toolkit::Scrollable::Property::SCROLL_DIRECTION ),
- Source( mScrollPositionObject, ScrollConnector::OVERSHOOT ),
- ParentSource( Actor::Property::SIZE ),
- OvershootOverlaySizeConstraint() );
- mOvershootOverlay.ApplyConstraint(constraint);
+ Constraint constraint = Constraint::New<Vector3>( mOvershootOverlay, Actor::Property::SIZE, OvershootOverlaySizeConstraint );
+ constraint.AddSource( ParentSource( Toolkit::Scrollable::Property::SCROLL_DIRECTION ) );
+ constraint.AddSource( ParentSource( Actor::Property::SIZE ) );
+ constraint.Apply();
+
mOvershootOverlay.SetSize(OVERSHOOT_BOUNCE_ACTOR_DEFAULT_SIZE.width, OVERSHOOT_BOUNCE_ACTOR_DEFAULT_SIZE.height);
- constraint = Constraint::New<Quaternion>( Actor::Property::ORIENTATION,
- 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( Toolkit::Scrollable::Property::SCROLL_DIRECTION ),
- Source( mScrollPositionObject, ScrollConnector::OVERSHOOT ),
- OvershootOverlayPositionConstraint() );
- mOvershootOverlay.ApplyConstraint(constraint);
-
- constraint = Constraint::New<bool>( Actor::Property::VISIBLE,
- ParentSource( Toolkit::Scrollable::Property::CAN_SCROLL_VERTICAL ),
- OvershootOverlayVisibilityConstraint() );
- mOvershootOverlay.ApplyConstraint(constraint);
-
- constraint = Constraint::New<float>( effectOvershootPropertyIndex,
- Source( mScrollPositionObject, ScrollConnector::OVERSHOOT ),
- EqualToConstraint() );
- mOvershootOverlay.ApplyConstraint(constraint);
+ constraint = Constraint::New<Quaternion>( mOvershootOverlay, Actor::Property::ORIENTATION, OvershootOverlayRotationConstraint );
+ constraint.AddSource( ParentSource( Toolkit::Scrollable::Property::SCROLL_DIRECTION ) );
+ constraint.AddSource( Source( mScrollPositionObject, ScrollConnector::OVERSHOOT ) );
+ constraint.Apply();
+
+ constraint = Constraint::New<Vector3>( mOvershootOverlay, Actor::Property::POSITION, OvershootOverlayPositionConstraint );
+ constraint.AddSource( ParentSource( Actor::Property::SIZE ) );
+ constraint.AddSource( ParentSource( Toolkit::Scrollable::Property::SCROLL_DIRECTION ) );
+ constraint.AddSource( Source( mScrollPositionObject, ScrollConnector::OVERSHOOT ) );
+ constraint.Apply();
+
+ constraint = Constraint::New<bool>( mOvershootOverlay, Actor::Property::VISIBLE, OvershootOverlayVisibilityConstraint );
+ constraint.AddSource( ParentSource( Toolkit::Scrollable::Property::CAN_SCROLL_VERTICAL ) );
+ constraint.Apply();
+
+ constraint = Constraint::New<float>( mOvershootOverlay, effectOvershootPropertyIndex, EqualToConstraint() );
+ constraint.AddSource( Source( mScrollPositionObject, ScrollConnector::OVERSHOOT ) );
+ constraint.Apply();
}
else
{
// EXTERNAL INCLUDES
// TODO - Replace list with dali-vector.h
#include <list>
-#include <dali/public-api/animation/active-constraint.h>
#include <dali/public-api/animation/constraint.h>
// INTERNAL INCLUDES
*/
void ApplyConstraint(Constraint constraint)
{
- ActiveConstraint activeConstraint = mActor.ApplyConstraint( constraint );
- mConstraints.push_back( activeConstraint );
+ Constraint clone = constraint.Clone( mActor );
+ clone.Apply();
+ mConstraints.push_back( clone );
}
/**
*/
void RemoveConstraints()
{
- std::vector<ActiveConstraint>::iterator it = mConstraints.begin();
- std::vector<ActiveConstraint>::iterator end = mConstraints.end();
+ std::vector<Constraint>::iterator it = mConstraints.begin();
+ std::vector<Constraint>::iterator end = mConstraints.end();
for(;it!=end;++it)
{
- mActor.RemoveConstraint(*it);
+ it->Remove();
}
mConstraints.clear();
}
Actor mActor; ///< The Actor that this ActorInfo represents.
- std::vector<ActiveConstraint> mConstraints; ///< A list keeping track of constraints applied to the actor via this delegate.
+ std::vector<Constraint> mConstraints; ///< A list keeping track of constraints applied to the actor via this delegate.
};
typedef IntrusivePtr<ActorInfo> ActorInfoPtr;
// CLASS HEADER
#include <dali-toolkit/internal/controls/scrollable/scroll-view/scroll-overshoot-indicator-impl.h>
-// EXTERNAL INCLUDES
-#include <boost/bind.hpp>
-
// INTERNAL INCLUDES
#include <dali-toolkit/internal/controls/scrollable/scrollable-impl.h>
#include <dali-toolkit/internal/controls/scrollable/bouncing-effect-actor.h>
*/
// EXTERNAL INCLUDES
-#include <boost/bind.hpp>
-#include <dali/public-api/animation/active-constraint.h>
#include <dali/public-api/animation/constraint.h>
#include <dali/public-api/object/property-input.h>
}
/**
- * @param[in] current The current 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)
- * @param[in] scrollSizeProperty The size of the scroll-view (scrollView SIZE)
+ * @param[in,out] current The current visibility of this Actor
+ * @param[in] inputs Contains:
+ * The Actor's Position
+ * The Actor's Scale
+ * The Actor's Size
+ * The scroll-view's position property (SCROLL_POSITION)
+ * The size of the scroll-view (scrollView SIZE)
* @return The new visibility of this Actor.
*/
- bool VisibilityConstraint(const bool& current,
- const PropertyInput& positionProperty,
- const PropertyInput& scaleProperty,
- const PropertyInput& sizeProperty,
- const PropertyInput& scrollPositionProperty,
- const PropertyInput& scrollSizeProperty)
+ void VisibilityConstraint( bool& current, const PropertyInputContainer& inputs )
{
const Vector2& anchor(AnchorPoint::CENTER.GetVectorXY());
- Vector2 position(positionProperty.GetVector3() + scrollPositionProperty.GetVector3());
- Vector2 scaledSize(sizeProperty.GetVector3() * scaleProperty.GetVector3());
+ Vector2 position( inputs[0]->GetVector3() + inputs[3]->GetVector3());
+ Vector2 scaledSize( inputs[2]->GetVector3() * inputs[1]->GetVector3());
- Vector2 domain(scrollSizeProperty.GetVector3());
+ Vector2 domain( inputs[4]->GetVector3() );
position -= (anchor - mVisibilityThreshold) * scaledSize;
domain -= (Vector2::ONE - mVisibilityThreshold * 2.0f) * scaledSize;
- return ( position.x >= 0 &&
- position.x <= domain.x &&
- position.y >= 0 &&
- position.y <= domain.y );
+ current = ( position.x >= 0 &&
+ position.x <= domain.x &&
+ position.y >= 0 &&
+ position.y <= domain.y );
}
/**
- * @param[in] current The current orientation 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)
- * @param[in] scrollSizeProperty The size of the scroll-view (scrollView SIZE)
- * @param[in] activateProperty Activation value (0 - normal, 1.0 - full effect)
+ * @param[in,out] current The current orientation of this Actor
+ * @param[in] inputs Contains:
+ * The Actor's Position.
+ * The Actor's Scale.
+ * The Actor's Size
+ * The scroll-view's position property (SCROLL_POSITION)
+ * The size of the scroll-view (scrollView SIZE)
+ * Activation value (0 - normal, 1.0 - full effect)
* @return The new orientation of this Actor.
*/
- Quaternion RotationConstraint(const Quaternion& current,
- const PropertyInput& positionProperty,
- const PropertyInput& scaleProperty,
- const PropertyInput& sizeProperty,
- const PropertyInput& scrollPositionProperty,
- const PropertyInput& scrollSizeProperty,
- const PropertyInput& activateProperty)
+ void RotationConstraint( Quaternion& current, const PropertyInputContainer& inputs )
{
- const float activate(activateProperty.GetFloat());
+ const float activate(inputs[5]->GetFloat());
if(activate <= Math::MACHINE_EPSILON_0)
{
- return current;
+ return;
}
const Vector2& anchor(AnchorPoint::CENTER.GetVectorXY());
- Vector2 position(positionProperty.GetVector3() + scrollPositionProperty.GetVector3());
- Vector2 scaledSize(sizeProperty.GetVector3() * scaleProperty.GetVector3());
- Vector2 domain(scrollSizeProperty.GetVector3());
+ Vector2 position(inputs[0]->GetVector3() + inputs[3]->GetVector3());
+ Vector2 scaledSize(inputs[2]->GetVector3() * inputs[1]->GetVector3());
+ Vector2 domain(inputs[4]->GetVector3());
position -= (anchor - mCanvasMargin) * scaledSize;
domain -= (Vector2::ONE - mCanvasMargin * 2.0f) * scaledSize;
angle *= activate;
- return Quaternion(-angle.x, Vector3::YAXIS) *
- Quaternion(angle.y, Vector3::XAXIS) *
- current;
+ current = Quaternion(-angle.x, Vector3::YAXIS) *
+ Quaternion(angle.y, Vector3::XAXIS) *
+ current;
}
/**
- * @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)
- * @param[in] scrollSizeProperty The size of the scroll-view (scrollView SIZE)
- * @param[in] activateProperty Activation value (0 - normal, 1.0 - full effect)
+ * @param[in,out] current The current position of this Actor
+ * @param[in] inputs Contains:
+ * The Actor's Scale.
+ * The Actor's Size
+ * The scroll-view's position property (SCROLL_POSITION)
+ * The size of the scroll-view (scrollView SIZE)
+ * Activation value (0 - normal, 1.0 - full effect)
* @return The new position of this Actor.
*/
- Vector3 PositionConstraint(const Vector3& current,
- const PropertyInput& scaleProperty,
- const PropertyInput& sizeProperty,
- const PropertyInput& scrollPositionProperty,
- const PropertyInput& scrollSizeProperty,
- const PropertyInput& activateProperty)
+ void PositionConstraint( Vector3& position, const PropertyInputContainer& inputs )
{
- const float activate(activateProperty.GetFloat());
- Vector3 position(current + scrollPositionProperty.GetVector3());
+ const float activate(inputs[4]->GetFloat());
if(activate <= Math::MACHINE_EPSILON_0)
{
- return position;
+ return;
}
+ position += inputs[2]->GetVector3();
+
const Vector2& anchor(AnchorPoint::CENTER.GetVectorXY());
- Vector2 scaledSize(sizeProperty.GetVector3() * scaleProperty.GetVector3());
- Vector2 domain(scrollSizeProperty.GetVector3());
+ Vector2 scaledSize(inputs[1]->GetVector3() * inputs[0]->GetVector3());
+ Vector2 domain(inputs[3]->GetVector3());
position.GetVectorXY() -= (anchor - mCanvasMargin) * scaledSize;
domain -= (Vector2::ONE - mCanvasMargin * 2.0f) * scaledSize;
}
position.GetVectorXY() += (anchor - mCanvasMargin) * scaledSize;
-
- return position;
}
Vector2 mAngleSwing; ///< Maximum amount in X and Y axes to rotate.
// Apply constraints to this actor //
Constraint constraint;
- constraint = Constraint::New<bool>( Actor::Property::VISIBLE,
- LocalSource( Actor::Property::POSITION ),
- LocalSource( Actor::Property::SCALE ),
- LocalSource( Actor::Property::SIZE ),
- 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) );
+ constraint = Constraint::New<bool>( child, Actor::Property::VISIBLE, info, &ScrollCarouselEffectInfo::VisibilityConstraint );
+ constraint.AddSource( LocalSource( Actor::Property::POSITION ) );
+ constraint.AddSource( LocalSource( Actor::Property::SCALE ) );
+ constraint.AddSource( LocalSource( Actor::Property::SIZE ) );
+ constraint.AddSource( Source( scrollView, Toolkit::ScrollView::Property::SCROLL_POSITION ) );
+ constraint.AddSource( Source( scrollView, Actor::Property::SIZE ) );
+ constraint.AddSource( Source( scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollViewCarouselEffect::EFFECT_ACTIVATE ) ) );
constraint.SetRemoveAction( Constraint::Discard );
- child.ApplyConstraint( constraint );
-
- constraint = Constraint::New<Quaternion>( Actor::Property::ORIENTATION,
- LocalSource( Actor::Property::POSITION ),
- LocalSource( Actor::Property::SCALE ),
- LocalSource( Actor::Property::SIZE ),
- 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.Apply();
+
+ constraint = Constraint::New<Quaternion>( child, Actor::Property::ORIENTATION, info, &ScrollCarouselEffectInfo::RotationConstraint );
+ constraint.AddSource( LocalSource( Actor::Property::POSITION ) );
+ constraint.AddSource( LocalSource( Actor::Property::SCALE ) );
+ constraint.AddSource( LocalSource( Actor::Property::SIZE ) );
+ constraint.AddSource( Source( scrollView, Toolkit::ScrollView::Property::SCROLL_POSITION ) );
+ constraint.AddSource( Source( scrollView, Actor::Property::SIZE ) );
+ constraint.AddSource( Source( scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollViewCarouselEffect::EFFECT_ACTIVATE ) ) );
constraint.SetRemoveAction( Constraint::Discard );
- child.ApplyConstraint( constraint );
-
- constraint = Constraint::New<Vector3>( Actor::Property::POSITION,
- LocalSource( Actor::Property::SCALE ),
- LocalSource( Actor::Property::SIZE ),
- 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) );
-
+ constraint.Apply();
+
+ constraint = Constraint::New<Vector3>( child, Actor::Property::POSITION, info, &ScrollCarouselEffectInfo::PositionConstraint );
+ constraint.AddSource( LocalSource( Actor::Property::SCALE ) );
+ constraint.AddSource( LocalSource( Actor::Property::SIZE ) );
+ constraint.AddSource( Source(scrollView, Toolkit::ScrollView::Property::SCROLL_POSITION ) );
+ constraint.AddSource( Source(scrollView, Actor::Property::SIZE ) );
+ constraint.AddSource( Source(scrollView, scrollView.GetPropertyIndex( Toolkit::ScrollViewCarouselEffect::EFFECT_ACTIVATE ) ) );
constraint.SetRemoveAction( Constraint::Discard );
- child.ApplyConstraint( constraint );
+ constraint.Apply();
}
} // unnamed namespace
*/
// EXTERNAL INCLUDES
-#include <boost/bind.hpp>
-#include <dali/public-api/animation/active-constraint.h>
#include <dali/public-api/animation/constraint.h>
#include <dali/public-api/object/property-input.h>
}
/**
- * @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)
- * @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 (WRAP)
+ * @param[in,out] current The current orientation of this Actor
+ * @param[in] inputs Contains:
+ * The page's position.
+ * The scroll-view's position property (SCROLL_POSITION)
+ * The minimum extent of this scroll domain. (SCROLL_POSITION_MIN)
+ * The maximum extent of this scroll domain. (SCROLL_POSITION_MIN)
+ * The size of the page. (scrollView SIZE)
+ * Whether scroll wrap has been enabled or not (SCROLL_WRAP)
* @return The new orientation of this Actor.
*/
- Quaternion RotationConstraint(const Quaternion& current,
- const PropertyInput& pagePositionProperty,
- const PropertyInput& scrollPositionProperty,
- const PropertyInput& scrollPositionMin,
- const PropertyInput& scrollPositionMax,
- const PropertyInput& pageSizeProperty,
- const PropertyInput& scrollWrap)
+ void RotationConstraint( Quaternion& current, const PropertyInputContainer& inputs )
{
- const Vector3& pagePosition = pagePositionProperty.GetVector3();
- const Vector3& scrollPosition = scrollPositionProperty.GetVector3();
+ const Vector3& pagePosition = inputs[0]->GetVector3();
+ const Vector3& scrollPosition = inputs[1]->GetVector3();
// Get position of page.
Vector3 position = pagePosition + scrollPosition;
// short circuit: for orthognal view.
if( (fabsf(position.x) < Math::MACHINE_EPSILON_1) && (fabsf(position.y) < Math::MACHINE_EPSILON_1) )
{
- return current;
+ return;
}
- const Vector3& pageSize = pageSizeProperty.GetVector3();
- bool wrap = scrollWrap.GetBoolean();
+ const Vector3& pageSize = inputs[4]->GetVector3();
+ bool wrap = inputs[5]->GetBoolean();
if(wrap)
{
- const Vector3& min = scrollPositionMin.GetVector3();
- const Vector3& max = scrollPositionMax.GetVector3();
+ const Vector3& min = inputs[2]->GetVector3();
+ const Vector3& max = inputs[3]->GetVector3();
if(fabsf(min.x - max.x) > Math::MACHINE_EPSILON_1)
{
// short circuit: for pages outside of view.
if( (fabsf(position.x) >= pageSize.x) || (fabsf(position.y) >= pageSize.y) )
{
- return current;
+ return;
}
position.x /= pageSize.x;
Vector2 angle( Clamp(position.x, -1.0f,1.0f),
Clamp(position.y, -1.0f,1.0f) );
- Quaternion rotation = Quaternion(angle.x * mAngleSwing.x, Vector3::YAXIS) *
+ current = Quaternion( angle.x * mAngleSwing.x, Vector3::YAXIS) *
Quaternion(-angle.y * mAngleSwing.y, Vector3::XAXIS) *
current;
-
- return rotation;
}
/**
- * @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)
- * @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 (WRAP)
+ * @param[in,out] current The current color of this Actor
+ * @param[in] inputs Contains:
+ * The page's position.
+ * The scroll-view's position property (SCROLL_POSITION)
+ * The minimum extent of this scroll domain. (SCROLL_POSITION_MIN)
+ * The maximum extent of this scroll domain. (SCROLL_POSITION_MIN)
+ * The size of the page. (scrollView SIZE)
+ * Whether scroll wrap has been enabled or not (SCROLL_WRAP)
* @return The new color of this Actor.
*/
- Vector4 ColorConstraint(const Vector4& current,
- const PropertyInput& pagePositionProperty,
- const PropertyInput& scrollPositionProperty,
- const PropertyInput& scrollPositionMin,
- const PropertyInput& scrollPositionMax,
- const PropertyInput& pageSizeProperty,
- const PropertyInput& scrollWrap)
+ void ColorConstraint( Vector4& current, const PropertyInputContainer& inputs )
{
- const Vector3& pagePosition = pagePositionProperty.GetVector3();
- const Vector3& scrollPosition = scrollPositionProperty.GetVector3();
+ const Vector3& pagePosition = inputs[0]->GetVector3();
+ const Vector3& scrollPosition = inputs[1]->GetVector3();
// Get position of page.
Vector3 position = pagePosition + scrollPosition;
// short circuit: for orthognal view.
if( (fabsf(position.x) < Math::MACHINE_EPSILON_1) && (fabsf(position.y) < Math::MACHINE_EPSILON_1) )
{
- return current;
+ return;
}
- const Vector3& pageSize = pageSizeProperty.GetVector3();
- bool wrap = scrollWrap.GetBoolean();
+ const Vector3& pageSize = inputs[4]->GetVector3();
+ bool wrap = inputs[5]->GetBoolean();
if(wrap)
{
- const Vector3& min = scrollPositionMin.GetVector3();
- const Vector3& max = scrollPositionMax.GetVector3();
+ const Vector3& min = inputs[2]->GetVector3();
+ const Vector3& max = inputs[3]->GetVector3();
if(fabsf(min.x - max.x) > Math::MACHINE_EPSILON_1)
{
{
// note preserve color channels incase there is a shader/further constraint
// that wishes to do something with that information.
- return Vector4(current.r, current.g, current.b, 0.0f);
+ current.a = 0.0f;
+ return;
}
position.x /= pageSize.x;
float f = (1.0f - fabsf(angle.x)) * (1.0f - fabsf(angle.y));
f = f*f;
- Vector4 color = current;
- color.a *= f;
-
- return color;
+ current.a *= f;
}
/**
- * @param[in] current The current position
- * @param[in] pagePositionProperty The page's position.
- * @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 (WRAP)
+ * @param[in,out] current The current position
+ * @param[in] inputs Contains:
+ * The page's position.
+ * The scroll-view's position property (SCROLL_POSITION)
+ * The minimum extent of this scroll domain. (SCROLL_POSITION_MIN)
+ * The maximum extent of this scroll domain. (SCROLL_POSITION_MIN)
+ * The size of the page. (scrollView SIZE)
+ * Whether scroll wrap has been enabled or not (SCROLL_WRAP)
* @return The new position of this Actor.
*/
- Vector3 PositionConstraint(const Vector3& current,
- const PropertyInput& pagePositionProperty,
- const PropertyInput& scrollPositionProperty,
- const PropertyInput& scrollPositionMin,
- const PropertyInput& scrollPositionMax,
- const PropertyInput& pageSizeProperty,
- const PropertyInput& scrollWrap)
+ void PositionConstraint( Vector3& current, const PropertyInputContainer& inputs )
{
- const Vector3& pagePosition = pagePositionProperty.GetVector3();
- const Vector3& scrollPosition = scrollPositionProperty.GetVector3();
+ const Vector3& pagePosition = inputs[0]->GetVector3();
+ const Vector3& scrollPosition = inputs[1]->GetVector3();
// Get position of page.
Vector3 relativePosition = pagePosition + scrollPosition;
// short circuit: for orthognal view.
if( (fabsf(relativePosition.x) < Math::MACHINE_EPSILON_1) && (fabsf(relativePosition.y) < Math::MACHINE_EPSILON_1) )
{
- return current + scrollPosition;
+ current += scrollPosition;
+ return;
}
- const Vector3& pageSize = pageSizeProperty.GetVector3();
- bool wrap = scrollWrap.GetBoolean();
+ const Vector3& pageSize = inputs[4]->GetVector3();
+ bool wrap = inputs[5]->GetBoolean();
if(wrap)
{
- const Vector3& min = scrollPositionMin.GetVector3();
- const Vector3& max = scrollPositionMax.GetVector3();
+ const Vector3& min = inputs[2]->GetVector3();
+ const Vector3& max = inputs[3]->GetVector3();
if(fabsf(min.x - max.x) > Math::MACHINE_EPSILON_1)
{
{
// position actors at: scrollposition (Property) + pagePosition (Parent) + current (this)
// they will be invisible so doesn't have to be precise, just away from stage.
- return current + scrollPosition;
+ current += scrollPosition;
+ return;
}
relativePosition.x /= pageSize.x;
position += mAnchor;
position += relativePosition * mPositionSwing;
- return position - pagePosition;
+ current = position - pagePosition;
}
Vector3 mAnchor; ///< Anchor point where Actor should rotate about.
{
// Apply constraints to this actor //
Constraint constraint;
- constraint = Constraint::New<Quaternion>( Actor::Property::ORIENTATION,
- Source(parentPage, Actor::Property::POSITION),
- 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, Toolkit::ScrollView::Property::WRAP ),
- boost::bind( &ScrollCubeEffectInfo::RotationConstraint, info, _1, _2, _3, _4, _5, _6, _7) );
-
+ constraint = Constraint::New<Quaternion>( child, Actor::Property::ORIENTATION, info, &ScrollCubeEffectInfo::RotationConstraint );
+ constraint.AddSource( Source(parentPage, Actor::Property::POSITION) );
+ constraint.AddSource( Source(scrollView, Toolkit::ScrollView::Property::SCROLL_FINAL ) );
+ constraint.AddSource( Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ) );
+ constraint.AddSource( Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ) );
+ constraint.AddSource( Source(scrollView, Actor::Property::SIZE ) );
+ constraint.AddSource( Source(scrollView, Toolkit::ScrollView::Property::WRAP ) );
constraint.SetRemoveAction( Constraint::Discard );
- child.ApplyConstraint( constraint );
-
- constraint = Constraint::New<Vector4>( Actor::Property::COLOR,
- Source(parentPage, Actor::Property::POSITION),
- 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, Toolkit::ScrollView::Property::WRAP ),
- boost::bind( &ScrollCubeEffectInfo::ColorConstraint, info, _1, _2, _3, _4, _5, _6, _7) );
-
+ constraint.Apply();
+
+ constraint = Constraint::New<Vector4>( child, Actor::Property::COLOR, info, &ScrollCubeEffectInfo::ColorConstraint );
+ constraint.AddSource( Source(parentPage, Actor::Property::POSITION) );
+ constraint.AddSource( Source(scrollView, Toolkit::ScrollView::Property::SCROLL_FINAL ) );
+ constraint.AddSource( Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ) );
+ constraint.AddSource( Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ) );
+ constraint.AddSource( Source(scrollView, Actor::Property::SIZE ) );
+ constraint.AddSource( Source(scrollView, Toolkit::ScrollView::Property::WRAP ) );
constraint.SetRemoveAction( Constraint::Discard );
- child.ApplyConstraint( constraint );
-
- constraint = Constraint::New<Vector3>( Actor::Property::POSITION,
- Source(parentPage, Actor::Property::POSITION),
- 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, Toolkit::ScrollView::Property::WRAP ),
- boost::bind( &ScrollCubeEffectInfo::PositionConstraint, info, _1, _2, _3, _4, _5, _6, _7) );
-
+ constraint.Apply();
+
+ constraint = Constraint::New<Vector3>( child, Actor::Property::POSITION, info, &ScrollCubeEffectInfo::PositionConstraint );
+ constraint.AddSource( Source(parentPage, Actor::Property::POSITION) );
+ constraint.AddSource( Source(scrollView, Toolkit::ScrollView::Property::SCROLL_FINAL ) );
+ constraint.AddSource( Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ) );
+ constraint.AddSource( Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ) );
+ constraint.AddSource( Source(scrollView, Actor::Property::SIZE ) );
+ constraint.AddSource( Source(scrollView, Toolkit::ScrollView::Property::WRAP ) );
constraint.SetRemoveAction( Constraint::Discard );
- child.ApplyConstraint( constraint );
+ constraint.Apply();
}
} // unnamed namespace
*/
// EXTERNAL INCLUDES
-#include <dali/public-api/animation/active-constraint.h>
#include <dali/public-api/animation/constraint.h>
#include <dali/public-api/object/property-input.h>
}
/**
- * @param[in] current The current scale
- * @param[in] pagePositionProperty The page's position.
- * @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 (WRAP)
+ * @param[in,out] current The current scale
+ * @param[in] inputs Contains:
+ * The page's position.
+ * The scroll-view's position property (SCROLL_POSITION)
+ * The minimum extent of this scroll domain. (SCROLL_POSITION_MIN)
+ * The maximum extent of this scroll domain. (SCROLL_POSITION_MIN)
+ * The size of the page. (scrollView SIZE)
+ * Whether scroll wrap has been enabled or not (SCROLL_WRAP)
* @return The new scale of this Actor.
*/
- Vector3 operator()(const Vector3& currentScale,
- const PropertyInput& currentPositionProperty,
- const PropertyInput& pagePositionProperty,
- const PropertyInput& scrollPositionProperty,
- const PropertyInput& scrollPositionMin,
- const PropertyInput& scrollPositionMax,
- const PropertyInput& pageSizeProperty)
+ void operator()( Vector3& currentScale, const PropertyInputContainer& inputs )
{
- const Vector3& currentPosition = currentPositionProperty.GetVector3();
- const Vector3& pagePosition = pagePositionProperty.GetVector3();
- const Vector3& scrollPosition = scrollPositionProperty.GetVector3();
+ const Vector3& currentPosition = inputs[0]->GetVector3();
+ const Vector3& pagePosition = inputs[1]->GetVector3();
+ const Vector3& scrollPosition = inputs[2]->GetVector3();
// Get position of page.
Vector3 position = pagePosition + scrollPosition;
// short circuit: for orthognal view.
if( (fabsf(position.x) < Math::MACHINE_EPSILON_1) && (fabsf(position.y) < Math::MACHINE_EPSILON_1) )
{
- return currentScale;
+ return;
}
- const Vector3& pageSize = pageSizeProperty.GetVector3();
+ const Vector3& pageSize = inputs[5]->GetVector3();
// Don't have enough parameters, to provide Wrap mode (need a way of having 'uniforms' instead of scrollWrap.GetBoolean())
- const Vector3& min = scrollPositionMin.GetVector3();
- const Vector3& max = scrollPositionMax.GetVector3();
+ const Vector3& min = inputs[3]->GetVector3();
+ const Vector3& max = inputs[4]->GetVector3();
if(fabsf(min.x - max.x) > Math::MACHINE_EPSILON_1)
{
// short circuit: for pages outside of view.
if( (fabsf(position.x) >= pageSize.x) || (fabsf(position.y) >= pageSize.y) )
{
- return currentScale;
+ return;
}
// Calculate scale ////////////////////////////////////////////////////////
float f = mScaleExtent + cos(position.x * Math::PI_2) * cos(position.y * Math::PI_2) * (1.0f - mScaleExtent);
- return currentScale * f;
+ currentScale *= f;
}
const Vector2 mPositionExtent; ///< Determines how much of the Actor's X and Y position affects exponent value.
}
/**
- * @param[in] current The current position
- * @param[in] pagePositionProperty The page's position.
- * @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 (WRAP)
+ * @param[in,out] current The current position
+ * @param[in] inputs Contains:
+ * The page's position.
+ * The scroll-view's position property (SCROLL_POSITION)
+ * The minimum extent of this scroll domain. (SCROLL_POSITION_MIN)
+ * The maximum extent of this scroll domain. (SCROLL_POSITION_MIN)
+ * The size of the page. (scrollView SIZE)
+ * Whether scroll wrap has been enabled or not (SCROLL_WRAP)
* @return The new position of this Actor.
*/
- Vector3 operator()(const Vector3& currentPosition,
- const PropertyInput& pagePositionProperty,
- const PropertyInput& scrollPositionProperty,
- const PropertyInput& scrollPositionMin,
- const PropertyInput& scrollPositionMax,
- const PropertyInput& pageSizeProperty,
- const PropertyInput& scrollWrap)
+ void operator()( Vector3& currentPosition, const PropertyInputContainer& inputs )
{
- const Vector3& pagePosition = pagePositionProperty.GetVector3();
- const Vector3& scrollPosition = scrollPositionProperty.GetVector3();
+ const Vector3& pagePosition = inputs[0]->GetVector3();
+ const Vector3& scrollPosition = inputs[1]->GetVector3();
// Get position of page.
Vector3 position = pagePosition + scrollPosition;
// short circuit: for orthognal view.
if( (fabsf(position.x) < Math::MACHINE_EPSILON_1) && (fabsf(position.y) < Math::MACHINE_EPSILON_1) )
{
- return currentPosition + scrollPosition;
+ currentPosition += scrollPosition;
+ return;
}
- const Vector3& pageSize = pageSizeProperty.GetVector3();
- bool wrap = scrollWrap.GetBoolean();
+ const Vector3& pageSize = inputs[4]->GetVector3();
+ bool wrap = inputs[5]->GetBoolean();
if(wrap)
{
- const Vector3& min = scrollPositionMin.GetVector3();
- const Vector3& max = scrollPositionMax.GetVector3();
+ const Vector3& min = inputs[2]->GetVector3();
+ const Vector3& max = inputs[3]->GetVector3();
if(fabsf(min.x - max.x) > Math::MACHINE_EPSILON_1)
{
{
// position actors at: scrollposition (Property) + pagePosition (Parent) + current (this)
// they will be invisible so doesn't have to be precise, just away from stage.
- return currentPosition + scrollPosition;
+ currentPosition += scrollPosition;
+ return;
}
// Calculate position /////////////////////////////////////////////////////
position *= mPositionScale;
- Vector3 finalPosition(currentPosition - pagePosition);
-
Vector3 relCurrentPosition = currentPosition;
relCurrentPosition.x = relCurrentPosition.x / pageSize.x + 0.5f;
relCurrentPosition.y = relCurrentPosition.y / pageSize.y + 0.5f;
position.x = RampFunction(position.x, mOffsetExtent.x + extent.x);
position.y = RampFunction(position.y, mOffsetExtent.y + extent.y);
- finalPosition += pageSize * position;
-
- return finalPosition;
+ currentPosition -= pagePosition;
+ currentPosition += pageSize * position;
}
const Vector2 mPositionExtent; ///< Determines how much of the Actor's X and Y position affects exponent value.
float scaleExtent)
{
// Scale Constraint
- Constraint constraint = Constraint::New<Vector3>( Actor::Property::SCALE,
- LocalSource(Actor::Property::POSITION),
- ParentSource(Actor::Property::POSITION),
- 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 constraint = Constraint::New<Vector3>( child, Actor::Property::SCALE, ScrollDepthScaleConstraint( positionExtent, offsetExtent, positionScale, scaleExtent ) );
+ constraint.AddSource( LocalSource( Actor::Property::POSITION ) );
+ constraint.AddSource( ParentSource( Actor::Property::POSITION ) );
+ constraint.AddSource( Source( scrollView, Toolkit::ScrollView::Property::SCROLL_POSITION ) );
+ constraint.AddSource( Source( scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ) );
+ constraint.AddSource( Source( scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ) );
+ constraint.AddSource( Source( scrollView, Actor::Property::SIZE ) );
constraint.SetRemoveAction( Constraint::Discard );
- child.ApplyConstraint( constraint );
+ constraint.Apply();
// 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, 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, Toolkit::ScrollView::Property::WRAP ),
- ScrollDepthPositionConstraint( positionExtent, offsetExtent, positionScale ) );
-
+ constraint = Constraint::New<Vector3>( child, Actor::Property::POSITION, ScrollDepthPositionConstraint( positionExtent, offsetExtent, positionScale ) );
+ constraint.AddSource( ParentSource(Actor::Property::POSITION) );
+ constraint.AddSource( Source(scrollView, Toolkit::ScrollView::Property::SCROLL_POSITION ) );
+ constraint.AddSource( Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ) );
+ constraint.AddSource( Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ) );
+ constraint.AddSource( Source(scrollView, Actor::Property::SIZE ) );
+ constraint.AddSource( Source(scrollView, Toolkit::ScrollView::Property::WRAP ) );
constraint.SetRemoveAction( Constraint::Discard );
- child.ApplyConstraint( constraint );
+ constraint.Apply();
}
} // unnamed namespace
* scroll domain. This is a value from 0.0f to 1.0f in each
* scroll position axis.
*/
-Vector3 InternalRelativePositionConstraint(const Vector3& current,
- const PropertyInput& scrollPositionProperty,
- const PropertyInput& scrollMinProperty,
- const PropertyInput& scrollMaxProperty,
- const PropertyInput& scrollSizeProperty)
+void InternalRelativePositionConstraint( Vector3& relativePosition, const PropertyInputContainer& inputs)
{
- Vector3 position = -scrollPositionProperty.GetVector3();
- const Vector3& min = scrollMinProperty.GetVector3();
- const Vector3& max = scrollMaxProperty.GetVector3();
- const Vector3& size = scrollSizeProperty.GetVector3();
+ Vector3 position = -inputs[0]->GetVector3();
+ const Vector3& min = inputs[1]->GetVector3();
+ const Vector3& max = inputs[2]->GetVector3();
+ const Vector3& size = inputs[3]->GetVector3();
position.x = WrapInDomain(position.x, min.x, max.x);
position.y = WrapInDomain(position.y, min.y, max.y);
- Vector3 relativePosition;
Vector3 domainSize = (max - min) - size;
relativePosition.x = domainSize.x > Math::MACHINE_EPSILON_1 ? fabsf((position.x - min.x) / domainSize.x) : 0.0f;
relativePosition.y = domainSize.y > Math::MACHINE_EPSILON_1 ? fabsf((position.y - min.y) / domainSize.y) : 0.0f;
-
- return relativePosition;
+ relativePosition.z = 0.0f;
}
} // unnamed namespace
{
}
- Vector3 operator()(const Vector3& current,
- const PropertyInput& gesturePositionProperty,
- const PropertyInput& sizeProperty)
+ void operator()( Vector3& scrollPostPosition, const PropertyInputContainer& inputs )
{
- Vector3 scrollPostPosition = current;
- Vector2 panPosition = gesturePositionProperty.GetVector2();
+ const Vector2& panPosition = inputs[0]->GetVector2();
if(!mWasPanning)
{
- mPrePosition = current;
+ mPrePosition = scrollPostPosition;
mCurrentPanMask = mInitialPanMask;
mWasPanning = true;
}
// Calculate Deltas...
- Vector2 currentPosition = gesturePositionProperty.GetVector2();
+ const Vector2& currentPosition = panPosition;
Vector2 panDelta( currentPosition - mLocalStart );
// Axis Auto Lock - locks the panning to the horizontal or vertical axis if the pan
scrollPostPosition.GetVectorXY() += panDelta;
// if no wrapping then clamp preposition to maximum overshoot amount
- const Vector3& size = sizeProperty.GetVector3();
+ const Vector3& size = inputs[1]->GetVector3();
if( mClampX )
{
float newXPosition = Clamp(scrollPostPosition.x, (mDomainMax.x + size.x) - mMaxOvershoot.x, mDomainMin.x + mMaxOvershoot.x );
}
scrollPostPosition.y = newYPosition;
}
-
- return scrollPostPosition;
}
Vector3 mPrePosition;
{
}
- Vector3 operator()(const Vector3& current,
- const PropertyInput& scrollPositionProperty,
- const PropertyInput& scrollMinProperty,
- const PropertyInput& scrollMaxProperty,
- const PropertyInput& scrollSizeProperty)
+ void operator()( Vector3& position, const PropertyInputContainer& inputs )
{
- Vector3 position = scrollPositionProperty.GetVector3();
- const Vector2& size = scrollSizeProperty.GetVector3().GetVectorXY();
- const Vector3& min = scrollMinProperty.GetVector3();
- const Vector3& max = scrollMaxProperty.GetVector3();
+ position = inputs[0]->GetVector3();
+ const Vector2& size = inputs[3]->GetVector3().GetVectorXY();
+ const Vector3& min = inputs[1]->GetVector3();
+ const Vector3& max = inputs[2]->GetVector3();
if( mWrap )
{
position.x = mClampX ? Clamp(position.x, mDomainMax.x + size.x, mDomainMin.x ) : position.x;
position.y = mClampY ? Clamp(position.y, mDomainMax.y + size.y, mDomainMin.y ) : position.y;
}
-
- return position;
}
Vector2 mDomainMin;
{
OvershootXConstraint(float maxOvershoot) : mMaxOvershoot(maxOvershoot) {}
- float operator()(const float& current,
- const PropertyInput& scrollPrePositionProperty,
- const PropertyInput& scrollPostPositionProperty,
- const PropertyInput& canScrollProperty)
+ void operator()( float& current, const PropertyInputContainer& inputs )
{
- if( canScrollProperty.GetBoolean() )
+ if( inputs[2]->GetBoolean() )
{
- const Vector3& scrollPrePosition = scrollPrePositionProperty.GetVector3();
- const Vector3& scrollPostPosition = scrollPostPositionProperty.GetVector3();
+ const Vector3& scrollPrePosition = inputs[0]->GetVector3();
+ const Vector3& scrollPostPosition = inputs[1]->GetVector3();
float newOvershoot = scrollPrePosition.x - scrollPostPosition.x;
- return (newOvershoot > 0.0f ? std::min(newOvershoot, mMaxOvershoot) : std::max(newOvershoot, -mMaxOvershoot)) / mMaxOvershoot;
+ current = (newOvershoot > 0.0f ? std::min(newOvershoot, mMaxOvershoot) : std::max(newOvershoot, -mMaxOvershoot)) / mMaxOvershoot;
+ }
+ else
+ {
+ current = 0.0f;
}
- return 0.0f;
}
float mMaxOvershoot;
{
OvershootYConstraint(float maxOvershoot) : mMaxOvershoot(maxOvershoot) {}
- float operator()(const float& current,
- const PropertyInput& scrollPrePositionProperty,
- const PropertyInput& scrollPostPositionProperty,
- const PropertyInput& canScrollProperty)
+ void operator()( float& current, const PropertyInputContainer& inputs )
{
- if( canScrollProperty.GetBoolean() )
+ if( inputs[2]->GetBoolean() )
{
- const Vector3& scrollPrePosition = scrollPrePositionProperty.GetVector3();
- const Vector3& scrollPostPosition = scrollPostPositionProperty.GetVector3();
+ const Vector3& scrollPrePosition = inputs[0]->GetVector3();
+ const Vector3& scrollPostPosition = inputs[1]->GetVector3();
float newOvershoot = scrollPrePosition.y - scrollPostPosition.y;
- return (newOvershoot > 0.0f ? std::min(newOvershoot, mMaxOvershoot) : std::max(newOvershoot, -mMaxOvershoot)) / mMaxOvershoot;
+ current = (newOvershoot > 0.0f ? std::min(newOvershoot, mMaxOvershoot) : std::max(newOvershoot, -mMaxOvershoot)) / mMaxOvershoot;
+ }
+ else
+ {
+ current = 0.0f;
}
- return 0.0f;
}
float mMaxOvershoot;
*
* Generates position-delta property based on scroll-position + scroll-offset properties.
*/
-Vector3 InternalPositionDeltaConstraint(const Vector3& current,
- const PropertyInput& scrollPositionProperty,
- const PropertyInput& scrollOffsetProperty)
+void InternalPositionDeltaConstraint( Vector3& current, const PropertyInputContainer& inputs )
{
- const Vector3& scrollPosition = scrollPositionProperty.GetVector3();
- const Vector3& scrollOffset = scrollOffsetProperty.GetVector3();
+ const Vector3& scrollPosition = inputs[0]->GetVector3();
+ const Vector3& scrollOffset = inputs[1]->GetVector3();
- return scrollPosition + scrollOffset;
+ current = scrollPosition + scrollOffset;
}
/**
{
}
- Vector3 operator()(const Vector3& current,
- const PropertyInput& scrollPositionProperty,
- const PropertyInput& scrollOvershootXProperty,
- const PropertyInput& scrollOvershootYProperty)
+ void operator()( Vector3& current, const PropertyInputContainer& inputs )
{
- const float& overshootx = scrollOvershootXProperty.GetFloat();
- const float& overshooty = scrollOvershootYProperty.GetFloat();
+ const float& overshootx = inputs[1]->GetFloat();
+ const float& overshooty = inputs[2]->GetFloat();
Vector3 offset( mFunctionX(overshootx),
mFunctionY(overshooty),
0.0f);
- return scrollPositionProperty.GetVector3() - offset;
+ current = inputs[0]->GetVector3() - offset;
}
AlphaFunction mFunctionX;
mInternalActor = Actor::New();
mInternalActor.SetDrawMode(DrawMode::OVERLAY);
self.Add(mInternalActor);
- mInternalActor.ApplyConstraint( Constraint::New<Vector3>( Actor::Property::SIZE, ParentSource( Actor::Property::SIZE ), EqualToConstraint() ) );
+ Constraint constraint = Constraint::New<Vector3>( mInternalActor, Actor::Property::SIZE, EqualToConstraint() );
+ constraint.AddSource( ParentSource( Actor::Property::SIZE ) );
+ constraint.Apply();
mInternalActor.SetParentOrigin(ParentOrigin::CENTER);
mInternalActor.SetAnchorPoint(AnchorPoint::CENTER);
if( mScrollMainInternalPrePositionConstraint )
{
- self.RemoveConstraint(mScrollMainInternalPrePositionConstraint);
+ mScrollMainInternalPrePositionConstraint.Remove();
}
}
if( mScrollMainInternalPrePositionConstraint )
{
- self.RemoveConstraint(mScrollMainInternalPrePositionConstraint);
+ mScrollMainInternalPrePositionConstraint.Remove();
}
if( mOvershootIndicator )
if(mScrollMainInternalPositionConstraint)
{
- self.RemoveConstraint(mScrollMainInternalPositionConstraint);
- self.RemoveConstraint(mScrollMainInternalDeltaConstraint);
- self.RemoveConstraint(mScrollMainInternalFinalConstraint);
- self.RemoveConstraint(mScrollMainInternalRelativeConstraint);
+ mScrollMainInternalPositionConstraint.Remove();
+ mScrollMainInternalDeltaConstraint.Remove();
+ mScrollMainInternalFinalConstraint.Remove();
+ mScrollMainInternalRelativeConstraint.Remove();
}
if( mScrollMainInternalPrePositionConstraint )
{
- self.RemoveConstraint(mScrollMainInternalPrePositionConstraint);
+ mScrollMainInternalPrePositionConstraint.Remove();
}
// TODO: It's probably better to use a local displacement value as this will give a displacement when scrolling just commences
{
initialPanMask.x = 0.0f;
}
- Constraint constraint;
if( mPanning )
{
- 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() ) );
- mScrollMainInternalPrePositionConstraint = self.ApplyConstraint( constraint );
+ mScrollMainInternalPrePositionConstraint = Constraint::New<Vector3>( self,
+ Toolkit::ScrollView::Property::SCROLL_PRE_POSITION,
+ InternalPrePositionConstraint( mPanStartPosition,
+ initialPanMask,
+ mAxisAutoLock,
+ mAxisAutoLockGradient,
+ mLockAxis,
+ mMaxOvershoot,
+ mRulerX->GetDomain(),
+ mRulerY->GetDomain() ) );
+ mScrollMainInternalPrePositionConstraint.AddSource( Source( detector, PanGestureDetector::Property::LOCAL_POSITION ) );
+ mScrollMainInternalPrePositionConstraint.AddSource( Source( self, Actor::Property::SIZE ) );
+ mScrollMainInternalPrePositionConstraint.Apply();
}
// 2. Second calculate the clamped position (actual position)
- 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>( 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>( 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>( 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 );
+ mScrollMainInternalPositionConstraint = Constraint::New<Vector3>( self,
+ Toolkit::ScrollView::Property::SCROLL_POSITION,
+ InternalPositionConstraint( mRulerX->GetDomain(),
+ mRulerY->GetDomain(),
+ mWrapMode ) );
+ mScrollMainInternalPositionConstraint.AddSource( LocalSource( Toolkit::ScrollView::Property::SCROLL_PRE_POSITION ) );
+ mScrollMainInternalPositionConstraint.AddSource( LocalSource( Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ) );
+ mScrollMainInternalPositionConstraint.AddSource( LocalSource( Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ) );
+ mScrollMainInternalPositionConstraint.AddSource( Source( self, Actor::Property::SIZE ) );
+ mScrollMainInternalPositionConstraint.Apply();
+
+ mScrollMainInternalDeltaConstraint = Constraint::New<Vector3>( self, Toolkit::ScrollView::Property::SCROLL_POSITION_DELTA, InternalPositionDeltaConstraint );
+ mScrollMainInternalDeltaConstraint.AddSource( LocalSource( Toolkit::ScrollView::Property::SCROLL_POSITION ) );
+ mScrollMainInternalDeltaConstraint.AddSource( LocalSource( Toolkit::ScrollView::Property::SCROLL_DOMAIN_OFFSET ) );
+ mScrollMainInternalDeltaConstraint.Apply();
+
+ mScrollMainInternalFinalConstraint = Constraint::New<Vector3>( self, Toolkit::ScrollView::Property::SCROLL_FINAL,
+ InternalFinalConstraint( FinalDefaultAlphaFunction,
+ FinalDefaultAlphaFunction ) );
+ mScrollMainInternalFinalConstraint .AddSource( LocalSource( Toolkit::ScrollView::Property::SCROLL_POSITION ) );
+ mScrollMainInternalFinalConstraint .AddSource( LocalSource( Toolkit::ScrollView::Property::OVERSHOOT_X ) );
+ mScrollMainInternalFinalConstraint .AddSource( LocalSource( Toolkit::ScrollView::Property::OVERSHOOT_Y ) );
+ mScrollMainInternalFinalConstraint.Apply();
+
+ mScrollMainInternalRelativeConstraint = Constraint::New<Vector3>( self, Toolkit::Scrollable::Property::SCROLL_RELATIVE_POSITION, InternalRelativePositionConstraint );
+ mScrollMainInternalRelativeConstraint.AddSource( LocalSource( Toolkit::ScrollView::Property::SCROLL_POSITION ) );
+ mScrollMainInternalRelativeConstraint.AddSource( LocalSource( Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ) );
+ mScrollMainInternalRelativeConstraint.AddSource( LocalSource( Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ) );
+ mScrollMainInternalRelativeConstraint.AddSource( LocalSource( Actor::Property::SIZE ) );
+ mScrollMainInternalRelativeConstraint.Apply();
// When panning we want to make sure overshoot values are affected by pre position and post position
SetOvershootConstraintsEnabled(!mWrapMode);
// remove and reset, it may now be in wrong order with the main internal constraints
if( mScrollMainInternalOvershootXConstraint )
{
- self.RemoveConstraint(mScrollMainInternalOvershootXConstraint);
+ mScrollMainInternalOvershootXConstraint.Remove();
mScrollMainInternalOvershootXConstraint.Reset();
- self.RemoveConstraint(mScrollMainInternalOvershootYConstraint);
+ mScrollMainInternalOvershootYConstraint.Remove();
mScrollMainInternalOvershootYConstraint.Reset();
}
if( enabled )
{
- 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 );
+ mScrollMainInternalOvershootXConstraint= Constraint::New<float>( self, Toolkit::ScrollView::Property::OVERSHOOT_X, OvershootXConstraint(mMaxOvershoot.x) );
+ mScrollMainInternalOvershootXConstraint.AddSource( LocalSource( Toolkit::ScrollView::Property::SCROLL_PRE_POSITION ) );
+ mScrollMainInternalOvershootXConstraint.AddSource( LocalSource( Toolkit::ScrollView::Property::SCROLL_POSITION ) );
+ mScrollMainInternalOvershootXConstraint.AddSource( LocalSource( Toolkit::Scrollable::Property::CAN_SCROLL_HORIZONTAL ) );
+ mScrollMainInternalOvershootXConstraint.Apply();
- 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 );
+ mScrollMainInternalOvershootYConstraint = Constraint::New<float>( self, Toolkit::ScrollView::Property::OVERSHOOT_Y, OvershootYConstraint(mMaxOvershoot.y) );
+ mScrollMainInternalOvershootYConstraint.AddSource( LocalSource( Toolkit::ScrollView::Property::SCROLL_PRE_POSITION ) );
+ mScrollMainInternalOvershootYConstraint.AddSource( LocalSource( Toolkit::ScrollView::Property::SCROLL_POSITION ) );
+ mScrollMainInternalOvershootYConstraint.AddSource( LocalSource( Toolkit::Scrollable::Property::CAN_SCROLL_VERTICAL ) );
+ mScrollMainInternalOvershootYConstraint.Apply();
}
else
{
Constraint constraint;
// MoveActor (scrolling)
- constraint = Constraint::New<Vector3>( Actor::Property::POSITION,
- Source( self, Toolkit::ScrollView::Property::SCROLL_POSITION ),
- MoveActorConstraint );
+ constraint = Constraint::New<Vector3>( self, Actor::Property::POSITION, MoveActorConstraint );
+ constraint.AddSource( Source( self, Toolkit::ScrollView::Property::SCROLL_POSITION ) );
constraint.SetRemoveAction(Constraint::Discard);
ApplyConstraintToBoundActors(constraint);
// WrapActor (wrap functionality)
- constraint = Constraint::New<Vector3>( Actor::Property::POSITION,
- LocalSource( Actor::Property::SCALE ),
- LocalSource( Actor::Property::ANCHOR_POINT ),
- LocalSource( Actor::Property::SIZE ),
- Source( self, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ),
- Source( self, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ),
- Source( self, Toolkit::ScrollView::Property::WRAP ),
- WrapActorConstraint );
+ constraint = Constraint::New<Vector3>( self, Actor::Property::POSITION, WrapActorConstraint );
+ constraint.AddSource( LocalSource( Actor::Property::SCALE ) );
+ constraint.AddSource( LocalSource( Actor::Property::ANCHOR_POINT ) );
+ constraint.AddSource( LocalSource( Actor::Property::SIZE ) );
+ constraint.AddSource( Source( self, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ) );
+ constraint.AddSource( Source( self, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ) );
+ constraint.AddSource( Source( self, Toolkit::ScrollView::Property::WRAP ) );
constraint.SetRemoveAction(Constraint::Discard);
ApplyConstraintToBoundActors(constraint);
}
Vector2 mMouseWheelScrollDistanceStep; ///< The step of scroll distance in actor coordinates in X and Y axes for each mouse wheel event received.
//ScrollInternalConstraintsPtr mScrollInternalConstraints;
- ActiveConstraint mScrollMainInternalPrePositionConstraint;
- ActiveConstraint mScrollMainInternalPositionConstraint;
- ActiveConstraint mScrollMainInternalOvershootXConstraint;
- ActiveConstraint mScrollMainInternalOvershootYConstraint;
- ActiveConstraint mScrollMainInternalDeltaConstraint;
- ActiveConstraint mScrollMainInternalFinalConstraint;
- ActiveConstraint mScrollMainInternalRelativeConstraint;
+ Constraint mScrollMainInternalPrePositionConstraint;
+ Constraint mScrollMainInternalPositionConstraint;
+ Constraint mScrollMainInternalOvershootXConstraint;
+ Constraint mScrollMainInternalOvershootYConstraint;
+ Constraint mScrollMainInternalDeltaConstraint;
+ Constraint mScrollMainInternalFinalConstraint;
+ Constraint mScrollMainInternalRelativeConstraint;
ScrollOvershootIndicatorPtr mOvershootIndicator;
#include <dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-page-carousel-effect-impl.h>
// EXTERNAL INCLUDES
-#include <boost/bind.hpp>
-#include <dali/public-api/animation/active-constraint.h>
#include <dali/public-api/animation/constraint.h>
#include <dali/public-api/object/property-input.h>
}
/**
- * @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)
- * @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 (WRAP)
+ * @param[in,out] current The current color of this Actor
+ * @param[in] inputs Contains:
+ * The page's position.
+ * The scroll-view's position property (SCROLL_POSITION)
+ * The minimum extent of this scroll domain. (SCROLL_POSITION_MIN)
+ * The maximum extent of this scroll domain. (SCROLL_POSITION_MIN)
+ * The size of the page. (scrollView SIZE)
+ * Whether scroll wrap has been enabled or not (SCROLL_WRAP)
* @return The new color of this Actor.
*/
- Vector4 ColorConstraint(const Vector4& current,
- const PropertyInput& pagePositionProperty,
- const PropertyInput& scrollPositionProperty,
- const PropertyInput& scrollPositionMin,
- const PropertyInput& scrollPositionMax,
- const PropertyInput& pageSizeProperty,
- const PropertyInput& scrollWrap)
+ void ColorConstraint( Vector4& current, const PropertyInputContainer& inputs )
{
- const Vector3& pagePosition = pagePositionProperty.GetVector3();
- const Vector3& scrollPosition = scrollPositionProperty.GetVector3();
+ const Vector3& pagePosition = inputs[0]->GetVector3();
+ const Vector3& scrollPosition = inputs[1]->GetVector3();
// Get position of page.
Vector3 position = pagePosition + scrollPosition;
// short circuit: if we're looking straight on at the page.
if( IsStraightOnView( position ) )
{
- return current;
+ return;
}
- const Vector3& pageSize = pageSizeProperty.GetVector3();
+ const Vector3& pageSize = inputs[4]->GetVector3();
- if( scrollWrap.GetBoolean() )
+ if( inputs[5]->GetBoolean() )
{
- WrapPositionWithinDomain( position, pageSize, scrollPositionMin.GetVector3(), scrollPositionMax.GetVector3() );
+ WrapPositionWithinDomain( position, pageSize, inputs[2]->GetVector3(), inputs[3]->GetVector3() );
}
// short circuit: for pages outside of view.
{
// note preserve color channels incase there is a shader/further constraint
// that wishes to do something with that information.
- return Vector4(current.r, current.g, current.b, 0.0f);
+ current.a = 0.0f;
+ return;
}
- Vector4 color( current );
Vector2 distance( position / pageSize * PAGE_SIZE_MULTIPLIER );
- color.a = Clamp( 1.0f - distance.Length(), 0.0f, 1.0f );
-
- return color;
+ current.a = Clamp( 1.0f - distance.Length(), 0.0f, 1.0f );
}
/**
- * @param[in] current The current position
- * @param[in] pagePositionProperty The page's position.
- * @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 (WRAP)
+ * @param[in,out] current The current position
+ * @param[in] inputs Contains:
+ * The page's position.
+ * The scroll-view's position property (SCROLL_POSITION)
+ * The minimum extent of this scroll domain. (SCROLL_POSITION_MIN)
+ * The maximum extent of this scroll domain. (SCROLL_POSITION_MIN)
+ * The size of the page. (scrollView SIZE)
+ * Whether scroll wrap has been enabled or not (SCROLL_WRAP)
* @return The new position of this Actor.
*/
- Vector3 PositionConstraint(const Vector3& current,
- const PropertyInput& pagePositionProperty,
- const PropertyInput& scrollPositionProperty,
- const PropertyInput& scrollPositionMin,
- const PropertyInput& scrollPositionMax,
- const PropertyInput& pageSizeProperty,
- const PropertyInput& scrollWrap)
+ void PositionConstraint( Vector3& current, const PropertyInputContainer& inputs )
{
- const Vector3& pagePosition = pagePositionProperty.GetVector3();
- const Vector3& scrollPosition = scrollPositionProperty.GetVector3();
+ const Vector3& pagePosition = inputs[0]->GetVector3();
+ const Vector3& scrollPosition = inputs[1]->GetVector3();
// Get position of page.
Vector3 position = pagePosition + scrollPosition;
// short circuit: if we're looking straight on at the page.
if( IsStraightOnView( position ) )
{
- return current + scrollPosition;
+ current += scrollPosition;
+ return;
}
- const Vector3& pageSize = pageSizeProperty.GetVector3();
+ const Vector3& pageSize = inputs[4]->GetVector3();
- if( scrollWrap.GetBoolean() )
+ if( inputs[5]->GetBoolean() )
{
- WrapPositionWithinDomain( position, pageSize, scrollPositionMin.GetVector3(), scrollPositionMax.GetVector3() );
+ WrapPositionWithinDomain( position, pageSize, inputs[2]->GetVector3(), inputs[3]->GetVector3() );
}
// short circuit: for pages outside of view.
{
// position actors at: scrollposition (Property) + pagePosition (Parent) + current (this)
// they will be invisible so doesn't have to be precise, just away from stage.
- return current + scrollPosition;
+ current += scrollPosition;
+ return;
}
Vector3 angle( position / pageSize * PAGE_SIZE_MULTIPLIER );
zMovement *= mPositionToPageSizeRatio;
position.z = - ( ( zMovement.x - ( zMovement.x * cos( angle.x ) ) ) + ( zMovement.y - ( zMovement.y * cos( angle.y ) ) ) );
- return position;
+ current = position;
}
const Vector2 mPositionToPageSizeRatio; ///< The page will move its position according to this ratio.
{
// Apply constraints to this actor //
Constraint constraint;
- constraint = Constraint::New<Vector4>( Actor::Property::COLOR,
- LocalSource(Actor::Property::POSITION),
- 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, Toolkit::ScrollView::Property::WRAP ),
- boost::bind( &ScrollPageCarouselEffectInfo::ColorConstraint, info, _1, _2, _3, _4, _5, _6, _7) );
-
+ constraint = Constraint::New<Vector4>( child, Actor::Property::COLOR, info, &ScrollPageCarouselEffectInfo::ColorConstraint );
+ constraint.AddSource( LocalSource(Actor::Property::POSITION) );
+ constraint.AddSource( Source(scrollView, Toolkit::ScrollView::Property::SCROLL_FINAL ) );
+ constraint.AddSource( Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ) );
+ constraint.AddSource( Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ) );
+ constraint.AddSource( Source(scrollView, Actor::Property::SIZE ) );
+ constraint.AddSource( Source(scrollView, Toolkit::ScrollView::Property::WRAP ) );
constraint.SetRemoveAction( Constraint::Discard );
- child.ApplyConstraint( constraint );
-
- constraint = Constraint::New<Vector3>( Actor::Property::POSITION,
- LocalSource(Actor::Property::POSITION),
- 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, Toolkit::ScrollView::Property::WRAP ),
- boost::bind( &ScrollPageCarouselEffectInfo::PositionConstraint, info, _1, _2, _3, _4, _5, _6, _7) );
-
+ constraint.Apply();
+
+ constraint = Constraint::New<Vector3>( child, Actor::Property::POSITION, info, &ScrollPageCarouselEffectInfo::PositionConstraint );
+ constraint.AddSource( LocalSource(Actor::Property::POSITION) );
+ constraint.AddSource( Source(scrollView, Toolkit::ScrollView::Property::SCROLL_FINAL ) );
+ constraint.AddSource( Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ) );
+ constraint.AddSource( Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ) );
+ constraint.AddSource( Source(scrollView, Actor::Property::SIZE ) );
+ constraint.AddSource( Source(scrollView, Toolkit::ScrollView::Property::WRAP ) );
constraint.SetRemoveAction( Constraint::Discard );
- child.ApplyConstraint( constraint );
+ constraint.Apply();
}
} // unnamed namespace
#include <dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-page-cube-effect-impl.h>
// EXTERNAL INCLUDES
-#include <boost/bind.hpp>
-#include <dali/public-api/animation/active-constraint.h>
#include <dali/public-api/animation/constraint.h>
#include <dali/public-api/object/property-input.h>
}
/**
- * @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)
- * @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 (WRAP)
+ * @param[in,out] current The current orientation of this Actor
+ * @param[in] inputs Contains:
+ * The page's position.
+ * The scroll-view's position property (SCROLL_POSITION)
+ * The minimum extent of this scroll domain. (SCROLL_POSITION_MIN)
+ * The maximum extent of this scroll domain. (SCROLL_POSITION_MIN)
+ * The size of the page. (scrollView SIZE)
+ * Whether scroll wrap has been enabled or not (SCROLL_WRAP)
* @return The new orientation of this Actor.
*/
- Quaternion RotationConstraint(const Quaternion& current,
- const PropertyInput& pagePositionProperty,
- const PropertyInput& scrollPositionProperty,
- const PropertyInput& scrollPositionMin,
- const PropertyInput& scrollPositionMax,
- const PropertyInput& pageSizeProperty,
- const PropertyInput& scrollWrap)
+ void RotationConstraint( Quaternion& current, const PropertyInputContainer& inputs )
{
- const Vector3& pagePosition = pagePositionProperty.GetVector3();
- const Vector3& scrollPosition = scrollPositionProperty.GetVector3();
+ const Vector3& pagePosition = inputs[0]->GetVector3();
+ const Vector3& scrollPosition = inputs[1]->GetVector3();
// Get position of page.
Vector3 position = pagePosition + scrollPosition;
// short circuit: if we're looking straight on at the page.
if( IsStraightOnView( position ) )
{
- return current;
+ return;
}
- const Vector3& pageSize = pageSizeProperty.GetVector3();
+ const Vector3& pageSize = inputs[4]->GetVector3();
- if( scrollWrap.GetBoolean() )
+ if( inputs[5]->GetBoolean() )
{
- WrapPositionWithinDomain( position, pageSize, scrollPositionMin.GetVector3(), scrollPositionMax.GetVector3() );
+ WrapPositionWithinDomain( position, pageSize, inputs[2]->GetVector3(), inputs[3]->GetVector3() );
}
// short circuit: for pages outside of view.
if( IsOutsideView( position, pageSize ) )
{
- return current;
+ return;
}
// Our target is a 90 degree (PI/2) rotation per page, so calculate the angle we should be rotate
// our page by calculating the amount we've moved as a fraction of the total size of the page.
Vector2 angle( position / pageSize * Dali::Math::PI_2 );
- Quaternion rotation = Quaternion( -angle.x * mAngleSwing.x, Vector3::YAXIS ) *
- Quaternion( angle.y * mAngleSwing.y, Vector3::XAXIS ) *
- current;
-
- return rotation;
+ current = Quaternion( -angle.x * mAngleSwing.x, Vector3::YAXIS ) *
+ Quaternion( angle.y * mAngleSwing.y, Vector3::XAXIS ) *
+ 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)
- * @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 (WRAP)
+ * @param[in,out] current The current color of this Actor
+ * @param[in] inputs Contains:
+ * The page's position.
+ * The scroll-view's position property (SCROLL_POSITION)
+ * The minimum extent of this scroll domain. (SCROLL_POSITION_MIN)
+ * The maximum extent of this scroll domain. (SCROLL_POSITION_MIN)
+ * The size of the page. (scrollView SIZE)
+ * Whether scroll wrap has been enabled or not (SCROLL_WRAP)
* @return The new color of this Actor.
*/
- Vector4 ColorConstraint(const Vector4& current,
- const PropertyInput& pagePositionProperty,
- const PropertyInput& scrollPositionProperty,
- const PropertyInput& scrollPositionMin,
- const PropertyInput& scrollPositionMax,
- const PropertyInput& pageSizeProperty,
- const PropertyInput& scrollWrap)
+ void ColorConstraint( Vector4& current, const PropertyInputContainer& inputs )
{
- const Vector3& pagePosition = pagePositionProperty.GetVector3();
- const Vector3& scrollPosition = scrollPositionProperty.GetVector3();
+ const Vector3& pagePosition = inputs[0]->GetVector3();
+ const Vector3& scrollPosition = inputs[1]->GetVector3();
// Get position of page.
Vector3 position = pagePosition + scrollPosition;
// short circuit: if we're looking straight on at the page.
if( IsStraightOnView( position ) )
{
- return current;
+ return;
}
- const Vector3& pageSize = pageSizeProperty.GetVector3();
+ const Vector3& pageSize = inputs[4]->GetVector3();
- if( scrollWrap.GetBoolean() )
+ if( inputs[5]->GetBoolean() )
{
- WrapPositionWithinDomain( position, pageSize, scrollPositionMin.GetVector3(), scrollPositionMax.GetVector3() );
+ WrapPositionWithinDomain( position, pageSize, inputs[2]->GetVector3(), inputs[3]->GetVector3() );
}
// short circuit: for pages outside of view.
{
// note preserve color channels incase there is a shader/further constraint
// that wishes to do something with that information.
- return Vector4(current.r, current.g, current.b, 0.0f);
+ current.a = 0.0f;
+ return;
}
// Calculate the distance of this page from our view and ensure it falls within the appropriate
if ( distanceFactor > 1.0f )
{
- return Vector4(current.r, current.g, current.b, 0.0f);
+ current.a = 0.0f;
}
-
- return 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)
- * @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 (WRAP)
+ * @param[in,out] current The current position
+ * @param[in] inputs Contains:
+ * The page's position.
+ * The scroll-view's position property (SCROLL_POSITION)
+ * The minimum extent of this scroll domain. (SCROLL_POSITION_MIN)
+ * The maximum extent of this scroll domain. (SCROLL_POSITION_MIN)
+ * The size of the page. (scrollView SIZE)
+ * Whether scroll wrap has been enabled or not (SCROLL_WRAP)
* @return The new position of this Actor.
*/
- Vector3 PositionConstraint(const Vector3& current,
- const PropertyInput& pagePositionProperty,
- const PropertyInput& scrollPositionProperty,
- const PropertyInput& scrollPositionMin,
- const PropertyInput& scrollPositionMax,
- const PropertyInput& pageSizeProperty,
- const PropertyInput& scrollWrap)
+ void PositionConstraint( Vector3& current, const PropertyInputContainer& inputs )
{
- const Vector3& pagePosition = pagePositionProperty.GetVector3();
- const Vector3& scrollPosition = scrollPositionProperty.GetVector3();
+ const Vector3& pagePosition = inputs[0]->GetVector3();
+ const Vector3& scrollPosition = inputs[1]->GetVector3();
// Get position of page.
Vector3 position = pagePosition + scrollPosition;
// short circuit: if we're looking straight on at the page.
if( IsStraightOnView( position ) )
{
- return current + scrollPosition;
+ current += scrollPosition;
+ return;
}
- const Vector3& pageSize = pageSizeProperty.GetVector3();
+ const Vector3& pageSize = inputs[4]->GetVector3();
- if( scrollWrap.GetBoolean() )
+ if( inputs[5]->GetBoolean() )
{
- WrapPositionWithinDomain( position, pageSize, scrollPositionMin.GetVector3(), scrollPositionMax.GetVector3() );
+ WrapPositionWithinDomain( position, pageSize, inputs[2]->GetVector3(), inputs[3]->GetVector3() );
}
// short circuit: for pages outside of view.
{
// position actors at: scrollposition (Property) + pagePosition (Parent) + current (this)
// they will be invisible so doesn't have to be precise, just away from stage.
- return current + scrollPosition;
+ current += scrollPosition;
+ return;
}
// Our target when scrolling is moving from the origin to the following points around a curve:
Vector2 angle( position / pageSize * Dali::Math::PI_2 );
Vector2 radius( pageSize * 0.5 );
- position.x = radius.x * sin( angle.x );
- position.y = radius.y * sin( angle.y );
- position.z = ( radius.x - ( radius.x * cos( angle.x ) ) ) + ( radius.y - ( radius.y * cos( angle.y ) ) );
-
- return position;
+ current.x = radius.x * sin( angle.x );
+ current.y = radius.y * sin( angle.y );
+ current.z = ( radius.x - ( radius.x * cos( angle.x ) ) ) + ( radius.y - ( radius.y * cos( angle.y ) ) );
}
Vector2 mAngleSwing; ///< Maximum amount in X and Y axes to rotate.
{
// Apply constraints to this actor //
Constraint constraint;
- constraint = Constraint::New<Quaternion>( Actor::Property::ORIENTATION,
- LocalSource(Actor::Property::POSITION),
- 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, Toolkit::ScrollView::Property::WRAP ),
- boost::bind( &ScrollPageCubeEffectInfo::RotationConstraint, info, _1, _2, _3, _4, _5, _6, _7) );
-
+ constraint = Constraint::New<Quaternion>( child, Actor::Property::ORIENTATION, info, &ScrollPageCubeEffectInfo::RotationConstraint );
+ constraint.AddSource( LocalSource(Actor::Property::POSITION) );
+ constraint.AddSource( Source(scrollView, Toolkit::ScrollView::Property::SCROLL_FINAL ) );
+ constraint.AddSource( Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ) );
+ constraint.AddSource( Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ) );
+ constraint.AddSource( Source(scrollView, Actor::Property::SIZE ) );
+ constraint.AddSource( Source(scrollView, Toolkit::ScrollView::Property::WRAP ) );
constraint.SetRemoveAction( Constraint::Discard );
- child.ApplyConstraint( constraint );
-
- constraint = Constraint::New<Vector4>( Actor::Property::COLOR,
- LocalSource(Actor::Property::POSITION),
- 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, Toolkit::ScrollView::Property::WRAP ),
- boost::bind( &ScrollPageCubeEffectInfo::ColorConstraint, info, _1, _2, _3, _4, _5, _6, _7) );
-
+ constraint.Apply();
+
+ constraint = Constraint::New<Vector4>( child, Actor::Property::COLOR, info, &ScrollPageCubeEffectInfo::ColorConstraint );
+ constraint.AddSource( LocalSource(Actor::Property::POSITION) );
+ constraint.AddSource( Source(scrollView, Toolkit::ScrollView::Property::SCROLL_FINAL ) );
+ constraint.AddSource( Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ) );
+ constraint.AddSource( Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ) );
+ constraint.AddSource( Source(scrollView, Actor::Property::SIZE ) );
+ constraint.AddSource( Source(scrollView, Toolkit::ScrollView::Property::WRAP ) );
constraint.SetRemoveAction( Constraint::Discard );
- child.ApplyConstraint( constraint );
-
- constraint = Constraint::New<Vector3>( Actor::Property::POSITION,
- LocalSource(Actor::Property::POSITION),
- 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, Toolkit::ScrollView::Property::WRAP ),
- boost::bind( &ScrollPageCubeEffectInfo::PositionConstraint, info, _1, _2, _3, _4, _5, _6, _7) );
-
+ constraint.Apply();
+
+ constraint = Constraint::New<Vector3>( child, Actor::Property::POSITION, info, &ScrollPageCubeEffectInfo::PositionConstraint );
+ constraint.AddSource( LocalSource(Actor::Property::POSITION) );
+ constraint.AddSource( Source(scrollView, Toolkit::ScrollView::Property::SCROLL_FINAL ) );
+ constraint.AddSource( Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ) );
+ constraint.AddSource( Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ) );
+ constraint.AddSource( Source(scrollView, Actor::Property::SIZE ) );
+ constraint.AddSource( Source(scrollView, Toolkit::ScrollView::Property::WRAP ) );
constraint.SetRemoveAction( Constraint::Discard );
- child.ApplyConstraint( constraint );
+ constraint.Apply();
}
} // unnamed namespace
// CLASS HEADER
#include <dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-page-spiral-effect-impl.h>
-// EXTERNAL INCLUDES
-#include <boost/bind.hpp>
-
// INTERNAL INCLUDES
#include <dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-helper-functions.h>
#include <dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.h>
}
/**
- * @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)
- * @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. (START_PAGE_POSITION)
+ * @param[in,out] current The current orientation of this Actor
+ * @param[in] inputs Contains:
+ * The page's position.
+ * The scroll-view's position property (SCROLL_POSITION)
+ * The minimum extent of this scroll domain. (SCROLL_POSITION_MIN)
+ * The maximum extent of this scroll domain. (SCROLL_POSITION_MIN)
+ * The size of the page. (scrollView SIZE)
+ * The position of the page where scrolling started. (SCROLL_START_PAGE_POSITION)
* @return The new orientation of this Actor.
*/
- Quaternion RotationConstraint(const Quaternion& current,
- const PropertyInput& pagePositionProperty,
- const PropertyInput& scrollPositionProperty,
- const PropertyInput& scrollPositionMin,
- const PropertyInput& scrollPositionMax,
- const PropertyInput& pageSizeProperty,
- const PropertyInput& scrollStartPagePositionProperty)
+ void RotationConstraint( Quaternion& current, const PropertyInputContainer& inputs )
{
- const Vector3& pagePosition = pagePositionProperty.GetVector3();
- const Vector3& scrollPosition = scrollPositionProperty.GetVector3();
- const Vector3& scrollStartPagePosition = scrollStartPagePositionProperty.GetVector3();
+ const Vector3& pagePosition = inputs[0]->GetVector3();
+ const Vector3& scrollPosition = inputs[1]->GetVector3();
+ const Vector3& scrollStartPagePosition = inputs[5]->GetVector3();
// Get position of page.
Vector3 position = pagePosition + scrollPosition;
// short circuit: if we're looking straight on at the page.
if( IsStraightOnView( position ) )
{
- return current;
+ return;
}
- const Vector3& pageSize = pageSizeProperty.GetVector3();
- const Vector3& minScrollPosition( scrollPositionMin.GetVector3() );
- const Vector3& maxScrollPosition( scrollPositionMax.GetVector3() );
+ const Vector3& pageSize = inputs[4]->GetVector3();
+ const Vector3& minScrollPosition( inputs[2]->GetVector3() );
+ const Vector3& maxScrollPosition( inputs[3]->GetVector3() );
if( mScrollWrap )
{
// short circuit: for pages outside of view.
if( IsOutsideView( position, pageSize ) )
{
- return current;
+ return;
}
Vector2 angle( position / ( pageSize * PAGE_SIZE_RELATIVE_ANGLE_FACTOR ) * Vector3( mSpiralAngle ) );
}
ClampInPlace( angle.y, -angleMaxMin.y, angleMaxMin.y );
- Quaternion rotation = Quaternion( angle.x, Vector3::YAXIS ) *
- Quaternion( angle.y, Vector3::XAXIS ) *
- current;
-
- return rotation;
+ current = Quaternion( angle.x, Vector3::YAXIS ) *
+ Quaternion( angle.y, Vector3::XAXIS ) *
+ 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)
- * @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. (START_PAGE_POSITION)
+ * @param[in,out] current The current color of this Actor
+ * @param[in] inputs Contains:
+ * The page's position.
+ * The scroll-view's position property (SCROLL_POSITION)
+ * The minimum extent of this scroll domain. (SCROLL_POSITION_MIN)
+ * The maximum extent of this scroll domain. (SCROLL_POSITION_MIN)
+ * The size of the page. (scrollView SIZE)
+ * The position of the page where scrolling started. (SCROLL_START_PAGE_POSITION)
* @return The new color of this Actor.
*/
- Vector4 ColorConstraint(const Vector4& current,
- const PropertyInput& pagePositionProperty,
- const PropertyInput& scrollPositionProperty,
- const PropertyInput& scrollPositionMin,
- const PropertyInput& scrollPositionMax,
- const PropertyInput& pageSizeProperty,
- const PropertyInput& scrollStartPagePositionProperty)
+ void ColorConstraint( Vector4& color, const PropertyInputContainer& inputs )
{
- const Vector3& pagePosition = pagePositionProperty.GetVector3();
- const Vector3& scrollPosition = scrollPositionProperty.GetVector3();
- const Vector3& scrollStartPagePosition = scrollStartPagePositionProperty.GetVector3();
+ const Vector3& pagePosition = inputs[0]->GetVector3();
+ const Vector3& scrollPosition = inputs[1]->GetVector3();
+ const Vector3& scrollStartPagePosition = inputs[5]->GetVector3();
// Get position of page.
Vector3 position = pagePosition + scrollPosition;
// short circuit: if we're looking straight on at the page.
if( IsStraightOnView( position ) )
{
- return current;
+ return;
}
- const Vector3& pageSize = pageSizeProperty.GetVector3();
- const Vector3& minScrollPosition( scrollPositionMin.GetVector3() );
- const Vector3& maxScrollPosition( scrollPositionMax.GetVector3() );
+ const Vector3& pageSize = inputs[4]->GetVector3();
+ const Vector3& minScrollPosition( inputs[2]->GetVector3() );
+ const Vector3& maxScrollPosition( inputs[3]->GetVector3() );
if( mScrollWrap )
{
{
// note preserve color channels incase there is a shader/further constraint
// that wishes to do something with that information.
- return Vector4(current.r, current.g, current.b, 0.0f);
+ color.a = 0.0f;
+ return;
}
- Vector4 color( current );
Vector2 distance( position / pageSize );
float distanceLength( distance.Length() );
const Vector2 epsilon( pageSize * PAGE_EPSILON_FACTOR );
{
color.a = 0.0f;
}
-
- return color;
}
/**
- * @param[in] current The current position
- * @param[in] pagePositionProperty The page's position.
- * @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. (START_PAGE_POSITION)
+ * @param[in,out] current The current position
+ * @param[in] inputs Contains:
+ * The page's position.
+ * The scroll-view's position property (SCROLL_POSITION)
+ * The minimum extent of this scroll domain. (SCROLL_POSITION_MIN)
+ * The maximum extent of this scroll domain. (SCROLL_POSITION_MIN)
+ * The size of the page. (scrollView SIZE)
+ * The position of the page where scrolling started. (SCROLL_START_PAGE_POSITION)
* @return The new position of this Actor.
*/
- Vector3 PositionConstraint(const Vector3& current,
- const PropertyInput& pagePositionProperty,
- const PropertyInput& scrollPositionProperty,
- const PropertyInput& scrollPositionMin,
- const PropertyInput& scrollPositionMax,
- const PropertyInput& pageSizeProperty,
- const PropertyInput& scrollStartPagePositionProperty)
+ void PositionConstraint( Vector3& current, const PropertyInputContainer& inputs )
{
- const Vector3& pagePosition = pagePositionProperty.GetVector3();
- const Vector3& scrollPosition = scrollPositionProperty.GetVector3();
- const Vector3& scrollStartPagePosition = scrollStartPagePositionProperty.GetVector3();
+ const Vector3& pagePosition = inputs[0]->GetVector3();
+ const Vector3& scrollPosition = inputs[1]->GetVector3();
+ const Vector3& scrollStartPagePosition = inputs[5]->GetVector3();
// Get position of page.
Vector3 position = pagePosition + scrollPosition;
// short circuit: if we're looking straight on at the page.
if( IsStraightOnView( position ) )
{
- return current + scrollPosition;
+ current += scrollPosition;
+ return;
}
- const Vector3& pageSize = pageSizeProperty.GetVector3();
- const Vector3& minScrollPosition( scrollPositionMin.GetVector3() );
- const Vector3& maxScrollPosition( scrollPositionMax.GetVector3() );
+ const Vector3& pageSize = inputs[4]->GetVector3();
+ const Vector3& minScrollPosition( inputs[2]->GetVector3() );
+ const Vector3& maxScrollPosition( inputs[3]->GetVector3() );
if( mScrollWrap )
{
{
// position actors at: scrollposition (Property) + pagePosition (Parent) + current (this)
// they will be invisible so doesn't have to be precise, just away from stage.
- return current + scrollPosition;
+ current += scrollPosition;
+ return;
}
const Vector2 angle( position / pageSize * ( Dali::Math::PI_4 ) );
position.z += fabsf( position.y ) * NON_SCROLL_PAGE_Z_POSITION_FACTOR;
}
- return position;
+ current = position;
}
Vector2 mSpiralAngle; ///< The angle of the spirald page
{
// Apply constraints to this actor //
Constraint constraint;
- constraint = Constraint::New<Quaternion>( Actor::Property::ORIENTATION,
- LocalSource(Actor::Property::POSITION),
- 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, Toolkit::ScrollView::Property::START_PAGE_POSITION ),
- boost::bind( &ScrollPageSpiralEffectInfo::RotationConstraint, info, _1, _2, _3, _4, _5, _6, _7) );
-
+ constraint = Constraint::New<Quaternion>( child, Actor::Property::ORIENTATION, info, &ScrollPageSpiralEffectInfo::RotationConstraint );
+ constraint.AddSource( LocalSource(Actor::Property::POSITION) );
+ constraint.AddSource( Source(scrollView, Toolkit::ScrollView::Property::SCROLL_FINAL ) );
+ constraint.AddSource( Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ) );
+ constraint.AddSource( Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ) );
+ constraint.AddSource( Source(scrollView, Actor::Property::SIZE ) );
+ constraint.AddSource( Source(scrollView, Toolkit::ScrollView::Property::START_PAGE_POSITION ) );
constraint.SetRemoveAction( Constraint::Discard );
- child.ApplyConstraint( constraint );
-
- constraint = Constraint::New<Vector4>( Actor::Property::COLOR,
- LocalSource(Actor::Property::POSITION),
- 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, Toolkit::ScrollView::Property::START_PAGE_POSITION ),
- boost::bind( &ScrollPageSpiralEffectInfo::ColorConstraint, info, _1, _2, _3, _4, _5, _6, _7) );
-
+ constraint.Apply();
+
+ constraint = Constraint::New<Vector4>( child, Actor::Property::COLOR, info, &ScrollPageSpiralEffectInfo::ColorConstraint );
+ constraint.AddSource( LocalSource(Actor::Property::POSITION) );
+ constraint.AddSource( Source(scrollView, Toolkit::ScrollView::Property::SCROLL_FINAL ) );
+ constraint.AddSource( Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ) );
+ constraint.AddSource( Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ) );
+ constraint.AddSource( Source(scrollView, Actor::Property::SIZE ) );
+ constraint.AddSource( Source(scrollView, Toolkit::ScrollView::Property::START_PAGE_POSITION ) );
constraint.SetRemoveAction( Constraint::Discard );
- child.ApplyConstraint( constraint );
-
- constraint = Constraint::New<Vector3>( Actor::Property::POSITION,
- LocalSource(Actor::Property::POSITION),
- 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, Toolkit::ScrollView::Property::START_PAGE_POSITION ),
- boost::bind( &ScrollPageSpiralEffectInfo::PositionConstraint, info, _1, _2, _3, _4, _5, _6, _7) );
-
+ constraint.Apply();
+
+ constraint = Constraint::New<Vector3>( child, Actor::Property::POSITION, info, &ScrollPageSpiralEffectInfo::PositionConstraint );
+ constraint.AddSource( LocalSource(Actor::Property::POSITION) );
+ constraint.AddSource( Source(scrollView, Toolkit::ScrollView::Property::SCROLL_FINAL ) );
+ constraint.AddSource( Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ) );
+ constraint.AddSource( Source(scrollView, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ) );
+ constraint.AddSource( Source(scrollView, Actor::Property::SIZE ) );
+ constraint.AddSource( Source(scrollView, Toolkit::ScrollView::Property::START_PAGE_POSITION ) );
constraint.SetRemoveAction( Constraint::Discard );
- child.ApplyConstraint( constraint );
+ constraint.Apply();
}
} // unnamed namespace
}
/**
- * @param[out] current The new wobble value
- * @param[in] propertyTime The current time since the wobble effect started
- * @param[in] propertyPosition The scroll-position
- * @param[in] propertyOffset The scroll-overshoot
+ * @param[in,out] direction The new wobble value
+ * @param[in] inputs Contains:
+ * The current time since the wobble effect started
+ * The scroll-position
+ * The scroll-overshoot x & y
*/
- Vector3 operator()(const Vector3& current,
- const PropertyInput& propertyTime,
- const PropertyInput& propertyPosition,
- const PropertyInput& propertyOffsetX,
- const PropertyInput& propertyOffsetY)
+ void operator()( Vector3& direction, const PropertyInputContainer& inputs )
{
- Vector3 dir;
-
if(mStabilized)
{
// check if animation cycle id has changed (if so then this spells
else
{
// not stable (i.e. wobbling)
- Vector3 offset(propertyOffsetX.GetFloat(), propertyOffsetY.GetFloat(), 0.0f);
- const Vector3& position = propertyPosition.GetVector3() - offset;
- const float time = propertyTime.GetFloat();
+ Vector3 offset(inputs[2]->GetFloat(), inputs[3]->GetFloat(), 0.0f);
+ const Vector3& position = inputs[1]->GetVector3() - offset;
+ const float time = inputs[0]->GetFloat();
const float timePassed = time - mTime;
mTime = time;
}
}
- dir.x = propertyPosition.GetVector3().x - mChase.x;
- dir.y = propertyPosition.GetVector3().y - mChase.y;
+ direction.x = position.x - mChase.x;
+ direction.y = position.y - mChase.y;
} // end else
-
- return dir;
}
Vector3 mChase; ///< Chaser position
Actor scrollView = GetScrollView();
- Constraint constraint = Constraint::New<Vector3>( propertyEffectOvershoot,
- Source(scrollView, mPropertyTime),
- 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);
+ Constraint constraint = Constraint::New<Vector3>( actor, propertyEffectOvershoot, ScrollViewWobbleEffectConstraint(*this) );
+ constraint.AddSource( Source( scrollView, mPropertyTime ) );
+ constraint.AddSource( Source( actor, Toolkit::ScrollView::Property::SCROLL_POSITION ) );
+ constraint.AddSource( Source( actor, Toolkit::ScrollView::Property::OVERSHOOT_X ) );
+ constraint.AddSource( Source( actor, Toolkit::ScrollView::Property::OVERSHOOT_Y ) );
+ constraint.Apply();
}
void ScrollViewWobbleEffect::DetachActor(Actor actor)
// EXTERNAL INCLUDES
#include <sstream>
#include <iomanip>
-#include <dali/public-api/animation/active-constraint.h>
#include <dali/public-api/animation/constraint.h>
#include <dali/public-api/common/stage.h>
#include <dali/public-api/object/type-registry.h>
" gl_FragColor = vec4(uShadowColor.rgb, uShadowColor.a * alpha);\n"
"}\n";
-// TODO: Add this to dali-core constraints.h
-/**
- * EqualToConstraintMatrix
- *
- * f(current, property) = property
- */
-struct EqualToConstraintMatrix
-{
- EqualToConstraintMatrix(){}
-
- Dali::Matrix operator()(const Dali::Matrix& current, const PropertyInput& property) {return property.GetMatrix();}
-};
-
} // namespace
ShadowView::ShadowView( float downsampleWidthScale, float downsampleHeightScale )
// Constrain camera to look directly at center of shadow plane. (mPointLight position
// is under control of application, can't use transform inheritance)
- Constraint cameraOrientationConstraint =
- Constraint::New<Quaternion> ( Actor::Property::ORIENTATION,
- Source( mShadowPlane, Actor::Property::WORLD_POSITION ),
- Source( mPointLight, Actor::Property::WORLD_POSITION ),
- Source( mShadowPlane, Actor::Property::WORLD_ORIENTATION ),
- &LookAt );
+ Constraint cameraOrientationConstraint = Constraint::New<Quaternion> ( mCameraActor, Actor::Property::ORIENTATION, &LookAt );
+ cameraOrientationConstraint.AddSource( Source( mShadowPlane, Actor::Property::WORLD_POSITION ) );
+ cameraOrientationConstraint.AddSource( Source( mPointLight, Actor::Property::WORLD_POSITION ) );
+ cameraOrientationConstraint.AddSource( Source( mShadowPlane, Actor::Property::WORLD_ORIENTATION ) );
+ cameraOrientationConstraint.Apply();
- mCameraActor.ApplyConstraint( cameraOrientationConstraint );
-
- Constraint pointLightPositionConstraint = Constraint::New<Vector3>( Actor::Property::POSITION, Source( mPointLight, Actor::Property::WORLD_POSITION ), EqualToConstraint() );
-
- mCameraActor.ApplyConstraint( pointLightPositionConstraint );
+ Constraint pointLightPositionConstraint = Constraint::New<Vector3>( mCameraActor, Actor::Property::POSITION, EqualToConstraint() );
+ pointLightPositionConstraint.AddSource( Source( mPointLight, Actor::Property::WORLD_POSITION ) );
+ pointLightPositionConstraint.Apply();
}
}
Property::Index lightCameraProjectionMatrixPropertyIndex = mShadowRenderShader.GetPropertyIndex(SHADER_LIGHT_CAMERA_PROJECTION_MATRIX_PROPERTY_NAME);
Property::Index lightCameraViewMatrixPropertyIndex = mShadowRenderShader.GetPropertyIndex(SHADER_LIGHT_CAMERA_VIEW_MATRIX_PROPERTY_NAME);
- Constraint projectionMatrixConstraint = Constraint::New<Dali::Matrix>( lightCameraProjectionMatrixPropertyIndex, Source( mCameraActor, CameraActor::Property::PROJECTION_MATRIX ), EqualToConstraintMatrix());
- Constraint viewMatrixConstraint = Constraint::New<Dali::Matrix>( lightCameraViewMatrixPropertyIndex, Source( mCameraActor, CameraActor::Property::VIEW_MATRIX ), EqualToConstraintMatrix());
+ Constraint projectionMatrixConstraint = Constraint::New<Dali::Matrix>( mShadowRenderShader, lightCameraProjectionMatrixPropertyIndex, EqualToConstraint() );
+ projectionMatrixConstraint.AddSource( Source( mCameraActor, CameraActor::Property::PROJECTION_MATRIX ) );
- mShadowRenderShader.ApplyConstraint(projectionMatrixConstraint);
- mShadowRenderShader.ApplyConstraint(viewMatrixConstraint);
+ Constraint viewMatrixConstraint = Constraint::New<Dali::Matrix>( mShadowRenderShader, lightCameraViewMatrixPropertyIndex, EqualToConstraint() );
+ viewMatrixConstraint.AddSource( Source( mCameraActor, CameraActor::Property::VIEW_MATRIX ) );
+
+ projectionMatrixConstraint.Apply();
+ viewMatrixConstraint.Apply();
// Register a property that the user can use to control the blur in the internal object
mBlurStrengthPropertyIndex = self.RegisterProperty(BLUR_STRENGTH_PROPERTY_NAME, BLUR_STRENGTH_DEFAULT);
- mBlurFilter.GetHandleForAnimateBlurStrength().ApplyConstraint( Constraint::New<float>( mBlurFilter.GetBlurStrengthPropertyIndex() ,
- Source( self, mBlurStrengthPropertyIndex),
- EqualToConstraint()) );
+
+ Constraint blurStrengthConstraint = Constraint::New<float>( mBlurFilter.GetHandleForAnimateBlurStrength(), mBlurFilter.GetBlurStrengthPropertyIndex(), EqualToConstraint() );
+ blurStrengthConstraint.AddSource( Source( self, mBlurStrengthPropertyIndex) );
+ blurStrengthConstraint.Apply();
// Register a property that the user can use to control the color of the shadow.
Property::Index index = mShadowRenderShader.GetPropertyIndex(SHADER_SHADOW_COLOR_PROPERTY_NAME);
mShadowColorPropertyIndex = self.RegisterProperty(SHADOW_COLOR_PROPERTY_NAME, mCachedShadowColor);
- mShadowRenderShader.ApplyConstraint(Constraint::New<Dali::Vector4>( index, Source( self, mShadowColorPropertyIndex ), EqualToConstraint()) );
+ Constraint shadowRenderShaderConstraint = Constraint::New<Dali::Vector4>( mShadowRenderShader, index, EqualToConstraint() );
+ shadowRenderShaderConstraint.AddSource( Source( self, mShadowColorPropertyIndex ) );
+ shadowRenderShaderConstraint.Apply();
}
} // namespace Internal
// EXTERNAL INCLUDES
#include <cmath>
-#include <dali/public-api/animation/active-constraint.h>
#include <dali/public-api/animation/constraint.h>
#include <dali/public-api/common/stage.h>
#include <dali/public-api/object/type-registry.h>
mRange = Vector2( index*rangeLength, (index+1.f)*rangeLength );
}
- float operator()( float current, const PropertyInput& blurProperty )
+ void operator()( float& current, const PropertyInputContainer& inputs )
{
- float blurStrength = blurProperty.GetFloat();
+ float blurStrength = inputs[0]->GetFloat();
if(blurStrength <= mRange.x)
{
- return 1.f;
+ current = 1.f;
}
else if(blurStrength > mRange.y)
{
- return 0.f;
+ current = 0.f;
}
else
{
- return (mRange.y - blurStrength)/(mRange.y-mRange.x);
+ current = ( mRange.y - blurStrength) / ( mRange.y - mRange.x );
}
}
for(unsigned int i=0; i < mBlurLevels; i++)
{
- mImageActors[i].ApplyConstraint( Constraint::New<float>( Actor::Property::COLOR_ALPHA, ParentSource( mBlurStrengthPropertyIndex ), ActorOpacityConstraint(mBlurLevels, i) ) );
+ Constraint constraint = Constraint::New<float>( mImageActors[i], Actor::Property::COLOR_ALPHA, ActorOpacityConstraint(mBlurLevels, i) );
+ constraint.AddSource( ParentSource( mBlurStrengthPropertyIndex ) );
+ constraint.Apply();
}
Self().SetSize(Stage::GetCurrent().GetSize());
// EXTERNAL HEADERS
#include <sstream>
-#include <dali/public-api/animation/active-constraint.h>
#include <dali/public-api/animation/constraint.h>
#include <dali/public-api/common/stage.h>
// when the vanishing point is very far away(pageHeight*THRESHOLD), make it infinitely, in this case, the page bent horizontally
const float THRESHOLD(20.0);
-struct CommonParametersConstraint
+void CommonParametersConstraint( Matrix& current, const PropertyInputContainer& inputs )
{
- Matrix operator()( const Matrix& current,
- const PropertyInput& originalCenterProperty,
- const PropertyInput& currentCenterProperty,
- const PropertyInput& pageSizeProperty)
+ const Vector2& originalCenter = inputs[0]->GetVector2();
+ Vector2 currentCenter = inputs[1]->GetVector2();
+ const Vector2& pageSize = inputs[2]->GetVector2();
+
+ // calculate the curve direction and the vanishing point
+ // here, the vanishing point is the intersection of spine with the line passing through original center and vertical to curve direction
+ Vector2 curveDirection( currentCenter - originalCenter );
+ curveDirection.Normalize();
+ if( fabs(curveDirection.y) < 0.01f) // eliminate the possibility of division by zero in the next step
{
- const Vector2& originalCenter = originalCenterProperty.GetVector2();
- Vector2 currentCenter = currentCenterProperty.GetVector2();
- const Vector2& pageSize = pageSizeProperty.GetVector2();
-
- // calculate the curve direction and the vanishing point
- // here, the vanishing point is the intersection of spine with the line passing through original center and vertical to curve direction
- Vector2 curveDirection( currentCenter - originalCenter );
- curveDirection.Normalize();
- if( fabs(curveDirection.y) < 0.01f) // eliminate the possibility of division by zero in the next step
- {
- curveDirection.y = 0.01f;
- }
- float vanishingPointY = originalCenter.y + curveDirection.x * originalCenter.x / curveDirection.y;
-
- float curveEndY, cosTheta ,sinTheta ,translateX, translateY;
- // when the vanishing point is very far away, make it infinitely, in this case, the page bent horizontally
- if( fabs(vanishingPointY-pageSize.y*0.5f) >= pageSize.y*THRESHOLD )
- {
- curveDirection = Vector2(-1.f,0.f);
- currentCenter.y = originalCenter.y;
-
- curveEndY = originalCenter.y;
- cosTheta = 1.f;
- sinTheta = 0.f;
- translateX = currentCenter.x - originalCenter.x;
- translateY = vanishingPointY;
- }
- else
- {
- curveEndY = currentCenter.y - curveDirection.y * (currentCenter.x/curveDirection.x) ;
- Vector2 v1( currentCenter.x, currentCenter.y - vanishingPointY );
- v1.Normalize();
- Vector2 v2( originalCenter.x, originalCenter.y - vanishingPointY );
- v2.Normalize();
- cosTheta = v1.x*v2.x + v1.y*v2.y;
- sinTheta = ( vanishingPointY > pageSize.y*0.5f ) ? sqrt(1.0-cosTheta*cosTheta) : -sqrt(1.0-cosTheta*cosTheta);
- translateX = currentCenter.x - cosTheta*originalCenter.x - sinTheta*( originalCenter.y-vanishingPointY );
- translateY = currentCenter.y + sinTheta*originalCenter.x - cosTheta*( originalCenter.y-vanishingPointY );
- }
+ curveDirection.y = 0.01f;
+ }
+ float vanishingPointY = originalCenter.y + curveDirection.x * originalCenter.x / curveDirection.y;
- float originalLength = fabs(originalCenter.x/curveDirection.x);
- float currentLength = fabs(currentCenter.x/curveDirection.x);
- float curveHeight = 0.45f*sqrt(originalLength*originalLength - currentLength*currentLength);
-
- Matrix commonParameters( false );
- float* parameterArray = commonParameters.AsFloat();
- parameterArray[0] = cosTheta;
- parameterArray[1] = -sinTheta;
- parameterArray[2] = originalCenter.x;
- parameterArray[3] = originalCenter.y;
- parameterArray[4] = sinTheta;
- parameterArray[5] = cosTheta;
- parameterArray[6] = currentCenter.x;
- parameterArray[7] = currentCenter.y;
- parameterArray[8] = translateX;
- parameterArray[9] = translateY;
- parameterArray[10] = vanishingPointY;
- parameterArray[11] = curveEndY;
- parameterArray[12] = curveDirection.x;
- parameterArray[13] = curveDirection.y;
- parameterArray[14] = curveHeight;
- parameterArray[15] = currentLength;
-
- return commonParameters;
+ float curveEndY, cosTheta ,sinTheta ,translateX, translateY;
+ // when the vanishing point is very far away, make it infinitely, in this case, the page bent horizontally
+ if( fabs(vanishingPointY-pageSize.y*0.5f) >= pageSize.y*THRESHOLD )
+ {
+ curveDirection = Vector2(-1.f,0.f);
+ currentCenter.y = originalCenter.y;
+
+ curveEndY = originalCenter.y;
+ cosTheta = 1.f;
+ sinTheta = 0.f;
+ translateX = currentCenter.x - originalCenter.x;
+ translateY = vanishingPointY;
+ }
+ else
+ {
+ curveEndY = currentCenter.y - curveDirection.y * (currentCenter.x/curveDirection.x) ;
+ Vector2 v1( currentCenter.x, currentCenter.y - vanishingPointY );
+ v1.Normalize();
+ Vector2 v2( originalCenter.x, originalCenter.y - vanishingPointY );
+ v2.Normalize();
+ cosTheta = v1.x*v2.x + v1.y*v2.y;
+ sinTheta = ( vanishingPointY > pageSize.y*0.5f ) ? sqrt(1.0-cosTheta*cosTheta) : -sqrt(1.0-cosTheta*cosTheta);
+ translateX = currentCenter.x - cosTheta*originalCenter.x - sinTheta*( originalCenter.y-vanishingPointY );
+ translateY = currentCenter.y + sinTheta*originalCenter.x - cosTheta*( originalCenter.y-vanishingPointY );
}
-};
+
+ float originalLength = fabs(originalCenter.x/curveDirection.x);
+ float currentLength = fabs(currentCenter.x/curveDirection.x);
+ float curveHeight = 0.45f*sqrt(originalLength*originalLength - currentLength*currentLength);
+
+ float* parameterArray = current.AsFloat();
+ parameterArray[0] = cosTheta;
+ parameterArray[1] = -sinTheta;
+ parameterArray[2] = originalCenter.x;
+ parameterArray[3] = originalCenter.y;
+ parameterArray[4] = sinTheta;
+ parameterArray[5] = cosTheta;
+ parameterArray[6] = currentCenter.x;
+ parameterArray[7] = currentCenter.y;
+ parameterArray[8] = translateX;
+ parameterArray[9] = translateY;
+ parameterArray[10] = vanishingPointY;
+ parameterArray[11] = curveEndY;
+ parameterArray[12] = curveDirection.x;
+ parameterArray[13] = curveDirection.y;
+ parameterArray[14] = curveHeight;
+ parameterArray[15] = currentLength;
+}
}//namespace
shaderImpl->mOriginalCenterPropertyIndex = handle.RegisterProperty( ORIGINAL_CENTER_PROPERTY_NAME, Vector2( defaultPageSize[0], defaultPageSize[1]*0.5f ) );
shaderImpl->mCurrentCenterPropertyIndex = handle.RegisterProperty( CURRENT_CENTER_PROPERTY_NAME, Vector2( defaultPageSize[0], defaultPageSize[1]*0.5f ) );
- shaderImpl->mInternalConstraint = Constraint::New<Matrix>( handle.GetPropertyIndex( "uCommonParameters" ),
- LocalSource( shaderImpl->mOriginalCenterPropertyIndex ),
- LocalSource( shaderImpl->mCurrentCenterPropertyIndex ),
- LocalSource( handle.GetPropertyIndex( PAGE_SIZE_PROPERTY_NAME ) ),
- CommonParametersConstraint() );
- handle.ApplyConstraint( shaderImpl->mInternalConstraint );
+
+ shaderImpl->ApplyInternalConstraint();
// setting isTurningBack to -1.0f here means turning page forward
handle.SetUniform( IS_TURNING_BACK_PROPERTY_NAME, -1.0f );
void PageTurnEffect::ApplyInternalConstraint()
{
- mShaderEffect.ApplyConstraint( mInternalConstraint );
+ Constraint constraint = Constraint::New<Matrix>( mShaderEffect, mShaderEffect.GetPropertyIndex( "uCommonParameters" ), CommonParametersConstraint );
+ constraint.AddSource( LocalSource( mOriginalCenterPropertyIndex ) );
+ constraint.AddSource( LocalSource( mCurrentCenterPropertyIndex ) );
+ constraint.AddSource( LocalSource( mShaderEffect.GetPropertyIndex( PAGE_SIZE_PROPERTY_NAME ) ) );
+ constraint.Apply();
}
const std::string& PageTurnEffect::GetPageSizePropertyName() const
Property::Index mOriginalCenterPropertyIndex;
Property::Index mCurrentCenterPropertyIndex;
- Constraint mInternalConstraint;
private:
//undefined copy constructor.
void SetButtonImage( Image image );
/**
- * @copydoc SetButtonImage( Image image )
+ * @brief SetButtonImage
+ *
+ * @param[in] image The Actor to be used as the button image.
+ *
+ * The natural size of the button would be the size of this Actor
+ * if it's larger than the background and label
*/
void SetButtonImage( Actor image );
void SetBackgroundImage( Image image );
/**
- * @copydoc SetBackgroundImage( Image image )
+ * @brief SetBackgroundImage
+ *
+ * @param[in] image The Actor to be used as the background image.
+ *
+ * The natural size of the button would be the size of this Actor
+ * if it's larger than the button and label
*/
void SetBackgroundImage( Actor image );
#include <stack>
#include <dali/public-api/actors/image-actor.h>
#include <dali/public-api/actors/mesh-actor.h>
-#include <dali/public-api/animation/active-constraint.h>
#include <dali/public-api/animation/constraint.h>
#include <dali/public-api/animation/constraints.h>
#include <dali/public-api/geometry/mesh.h>
actor.SetZ( BACKGROUND_ACTOR_Z_POSITION );
actor.SetRelayoutEnabled( false );
- Constraint constraint = Constraint::New<Vector3>( constrainingIndex,
- ParentSource( Actor::Property::SIZE ),
+ Constraint constraint = Constraint::New<Vector3>( actor,
+ constrainingIndex,
EqualToConstraint() );
- actor.ApplyConstraint( constraint );
+ constraint.AddSource( ParentSource( Actor::Property::SIZE ) );
+ constraint.Apply();
}
} // unnamed namespace
#include <dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h>
// EXTERNAL INCLUDES
-#include <dali/public-api/animation/active-constraint.h>
+#include <dali/public-api/animation/animation.h>
#include <dali/public-api/animation/constraint.h>
#include <dali/public-api/animation/time-period.h>
namespace
{
- // Functors which wrap constraint functions with stored item IDs
- struct WrappedQuaternionConstraint
+// Lerps between current and target using the progress
+template< typename Type >
+void Lerp( Type& current, const Type& target, float progress )
+{
+ current += ((target - current) * progress);
+}
+
+// Functors which wrap constraint functions with stored item IDs
+struct WrappedQuaternionConstraint
+{
+ WrappedQuaternionConstraint( Dali::Toolkit::ItemLayout::QuaternionFunction wrapMe, unsigned int itemId )
+ :mWrapMe(wrapMe),
+ mItemId(itemId)
{
- WrappedQuaternionConstraint(Dali::Toolkit::ItemLayout::QuaternionFunction wrapMe, unsigned int itemId)
- :mWrapMe(wrapMe),
- mItemId(itemId)
- {
- }
+ }
- Dali::Quaternion operator()(const Dali::Quaternion& current, const Dali::PropertyInput& layoutPosition, const Dali::PropertyInput& scrollSpeed, const Dali::PropertyInput& layoutSize)
- {
- float offsetLayoutPosition = layoutPosition.GetFloat() + static_cast<float>(mItemId);
+ void operator()( Dali::Quaternion& current, const Dali::PropertyInputContainer& inputs )
+ {
+ float offsetLayoutPosition = inputs[0]->GetFloat() + static_cast<float>(mItemId);
+ float weight = inputs[3]->GetFloat();
- return mWrapMe(current, offsetLayoutPosition, scrollSpeed.GetFloat(), layoutSize.GetVector3());
- }
+ current = Dali::Quaternion::Slerp( current, mWrapMe( current, offsetLayoutPosition, inputs[1]->GetFloat(), inputs[2]->GetVector3() ), weight );
+ }
- Dali::Toolkit::ItemLayout::QuaternionFunction mWrapMe;
- unsigned int mItemId;
- };
+ Dali::Toolkit::ItemLayout::QuaternionFunction mWrapMe;
+ unsigned int mItemId;
+};
- struct WrappedVector3Constraint
+struct WrappedVector3Constraint
+{
+ WrappedVector3Constraint( Dali::Toolkit::ItemLayout::Vector3Function wrapMe, unsigned int itemId )
+ : mWrapMe(wrapMe),
+ mItemId(itemId)
{
- WrappedVector3Constraint(Dali::Toolkit::ItemLayout::Vector3Function wrapMe, unsigned int itemId)
- : mWrapMe(wrapMe),
- mItemId(itemId)
- {
- }
+ }
- Dali::Vector3 operator()(const Dali::Vector3& current, const Dali::PropertyInput& layoutPosition, const Dali::PropertyInput& scrollSpeed, const Dali::PropertyInput& layoutSize)
- {
- float offsetLayoutPosition = layoutPosition.GetFloat() + static_cast<float>(mItemId);
+ void operator()( Dali::Vector3& current, const Dali::PropertyInputContainer& inputs )
+ {
+ float offsetLayoutPosition = inputs[0]->GetFloat() + static_cast<float>(mItemId);
+ float weight = inputs[3]->GetFloat();
- return mWrapMe(current, offsetLayoutPosition, scrollSpeed.GetFloat(), layoutSize.GetVector3());
- }
+ Lerp( current, mWrapMe( current, offsetLayoutPosition, inputs[1]->GetFloat(), inputs[2]->GetVector3() ), weight );
+ }
- Dali::Toolkit::ItemLayout::Vector3Function mWrapMe;
- unsigned int mItemId;
- };
+ Dali::Toolkit::ItemLayout::Vector3Function mWrapMe;
+ unsigned int mItemId;
+};
- struct WrappedVector4Constraint
+struct WrappedVector4Constraint
+{
+ WrappedVector4Constraint( Dali::Toolkit::ItemLayout::Vector4Function wrapMe, unsigned int itemId )
+ : mWrapMe(wrapMe),
+ mItemId(itemId)
{
- WrappedVector4Constraint(Dali::Toolkit::ItemLayout::Vector4Function wrapMe, unsigned int itemId)
- : mWrapMe(wrapMe),
- mItemId(itemId)
- {
- }
+ }
- Dali::Vector4 operator()(const Dali::Vector4& current, const Dali::PropertyInput& layoutPosition, const Dali::PropertyInput& scrollSpeed, const Dali::PropertyInput& layoutSize)
- {
- float offsetLayoutPosition = layoutPosition.GetFloat() + static_cast<float>(mItemId);
+ void operator()( Dali::Vector4& current, const Dali::PropertyInputContainer& inputs )
+ {
+ float offsetLayoutPosition = inputs[0]->GetFloat() + static_cast<float>(mItemId);
+ float weight = inputs[3]->GetFloat();
- return mWrapMe(current, offsetLayoutPosition, scrollSpeed.GetFloat(), layoutSize.GetVector3());
- }
+ Lerp( current, mWrapMe( current, offsetLayoutPosition, inputs[1]->GetFloat(), inputs[2]->GetVector3() ), weight );
+ }
- Dali::Toolkit::ItemLayout::Vector4Function mWrapMe;
- unsigned int mItemId;
- };
+ Dali::Toolkit::ItemLayout::Vector4Function mWrapMe;
+ unsigned int mItemId;
+};
- struct WrappedBoolConstraint
+struct WrappedBoolConstraint
+{
+ WrappedBoolConstraint( Dali::Toolkit::ItemLayout::BoolFunction wrapMe, unsigned int itemId )
+ : mWrapMe(wrapMe),
+ mItemId(itemId)
{
- WrappedBoolConstraint(Dali::Toolkit::ItemLayout::BoolFunction wrapMe, unsigned int itemId)
- : mWrapMe(wrapMe),
- mItemId(itemId)
- {
- }
+ }
- bool operator()(const bool& current, const Dali::PropertyInput& layoutPosition, const Dali::PropertyInput& scrollSpeed, const Dali::PropertyInput& layoutSize)
- {
- float offsetLayoutPosition = layoutPosition.GetFloat() + static_cast<float>(mItemId);
+ void operator()( bool& current, const Dali::PropertyInputContainer& inputs )
+ {
+ float weight = inputs[3]->GetFloat();
- return mWrapMe(current, offsetLayoutPosition, scrollSpeed.GetFloat(), layoutSize.GetVector3());
+ if ( weight >= 1.0f )
+ {
+ float offsetLayoutPosition = inputs[0]->GetFloat() + static_cast<float>(mItemId);
+ current = mWrapMe( current, offsetLayoutPosition, inputs[1]->GetFloat(), inputs[2]->GetVector3() );
}
+ }
- Dali::Toolkit::ItemLayout::BoolFunction mWrapMe;
- unsigned int mItemId;
- };
+ Dali::Toolkit::ItemLayout::BoolFunction mWrapMe;
+ unsigned int mItemId;
+};
} //Unnamed namespace
{
ItemLayout::ItemLayout()
-: mOrientation(ControlOrientation::Up),
- mAlphaFunction(Dali::Constraint::DEFAULT_ALPHA_FUNCTION)
+: mOrientation( ControlOrientation::Up ),
+ mAlphaFunction( AlphaFunctions::Linear ),
+ mWeightObject()
{
}
Property::Index scrollSpeedProperty = itemView.GetPropertyIndex("item-view-scroll-speed");
Property::Index scrollPositionProperty = scrollPositionObject.GetPropertyIndex("scroll-position");
+ // We want to animate the layout in so use a weight object to do this
+ if ( !mWeightObject )
+ {
+ mWeightObject = WeightObject::New();
+ }
+
ItemLayout::Vector3Function positionConstraint;
if (GetPositionConstraint(itemId, positionConstraint))
{
WrappedVector3Constraint wrapped(positionConstraint, itemId);
- Constraint constraint = Constraint::New<Vector3>( Actor::Property::POSITION,
- Source( scrollPositionObject, scrollPositionProperty ),
- ParentSource( scrollSpeedProperty ),
- ParentSource( Actor::Property::SIZE ),
- wrapped );
- constraint.SetApplyTime(durationSeconds);
- constraint.SetAlphaFunction(mAlphaFunction);
- actor.ApplyConstraint(constraint);
+ Constraint constraint = Constraint::New<Vector3>( actor, Actor::Property::POSITION, wrapped );
+ constraint.AddSource( Source( scrollPositionObject, scrollPositionProperty ) );
+ constraint.AddSource( ParentSource( scrollSpeedProperty ) );
+ constraint.AddSource( ParentSource( Actor::Property::SIZE ) );
+ constraint.AddSource( Source( mWeightObject, WeightObject::WEIGHT ) );
+ constraint.Apply();
}
ItemLayout::QuaternionFunction rotationConstraint;
{
WrappedQuaternionConstraint wrapped(rotationConstraint, itemId);
- Constraint constraint = Constraint::New<Quaternion>( Actor::Property::ORIENTATION,
- Source( scrollPositionObject, scrollPositionProperty ),
- ParentSource( scrollSpeedProperty ),
- ParentSource( Actor::Property::SIZE ),
- wrapped );
- constraint.SetApplyTime(durationSeconds);
- constraint.SetAlphaFunction(mAlphaFunction);
-
- actor.ApplyConstraint(constraint);
+ Constraint constraint = Constraint::New<Quaternion>( actor, Actor::Property::ORIENTATION, wrapped );
+ constraint.AddSource( Source( scrollPositionObject, scrollPositionProperty ) );
+ constraint.AddSource( ParentSource( scrollSpeedProperty ) );
+ constraint.AddSource( ParentSource( Actor::Property::SIZE ) );
+ constraint.AddSource( Source( mWeightObject, WeightObject::WEIGHT ) );
+ constraint.Apply();
}
ItemLayout::Vector3Function scaleConstraint;
{
WrappedVector3Constraint wrapped(scaleConstraint, itemId);
- Constraint constraint = Constraint::New<Vector3>( Actor::Property::SCALE,
- Source( scrollPositionObject, scrollPositionProperty ),
- ParentSource( scrollSpeedProperty ),
- ParentSource( Actor::Property::SIZE ),
- wrapped );
- constraint.SetApplyTime(durationSeconds);
- constraint.SetAlphaFunction(mAlphaFunction);
-
- actor.ApplyConstraint(constraint);
+ Constraint constraint = Constraint::New<Vector3>( actor, Actor::Property::SCALE, wrapped );
+ constraint.AddSource( Source( scrollPositionObject, scrollPositionProperty ) );
+ constraint.AddSource( ParentSource( scrollSpeedProperty ) );
+ constraint.AddSource( ParentSource( Actor::Property::SIZE ) );
+ constraint.AddSource( Source( mWeightObject, WeightObject::WEIGHT ) );
+ constraint.Apply();
}
ItemLayout::Vector4Function colorConstraint;
{
WrappedVector4Constraint wrapped(colorConstraint, itemId);
- Constraint constraint = Constraint::New<Vector4>( Actor::Property::COLOR,
- Source( scrollPositionObject, scrollPositionProperty ),
- ParentSource( scrollSpeedProperty ),
- ParentSource( Actor::Property::SIZE ),
- wrapped );
-
- constraint.SetApplyTime(durationSeconds);
- constraint.SetAlphaFunction(mAlphaFunction);
+ Constraint constraint = Constraint::New<Vector4>( actor, Actor::Property::COLOR, wrapped );
+ constraint.AddSource( Source( scrollPositionObject, scrollPositionProperty ) );
+ constraint.AddSource( ParentSource( scrollSpeedProperty ) );
+ constraint.AddSource( ParentSource( Actor::Property::SIZE ) );
+ constraint.AddSource( Source( mWeightObject, WeightObject::WEIGHT ) );
constraint.SetRemoveAction(Dali::Constraint::Discard);
-
- actor.ApplyConstraint(constraint);
+ constraint.Apply();
}
ItemLayout::BoolFunction visibilityConstraint;
{
WrappedBoolConstraint wrapped(visibilityConstraint, itemId);
- Constraint constraint = Constraint::New<bool>( Actor::Property::VISIBLE,
- Source( scrollPositionObject, scrollPositionProperty ),
- ParentSource( scrollSpeedProperty ),
- ParentSource( Actor::Property::SIZE ),
- wrapped );
-
- constraint.SetApplyTime(durationSeconds);
- constraint.SetAlphaFunction(mAlphaFunction);
+ Constraint constraint = Constraint::New<bool>( actor, Actor::Property::VISIBLE, wrapped );
+ constraint.AddSource( Source( scrollPositionObject, scrollPositionProperty ) );
+ constraint.AddSource( ParentSource( scrollSpeedProperty ) );
+ constraint.AddSource( ParentSource( Actor::Property::SIZE ) );
+ constraint.AddSource( Source( mWeightObject, WeightObject::WEIGHT ) );
// Release visibility constraints the same time as the color constraint
constraint.SetRemoveAction(Dali::Constraint::Discard);
- actor.ApplyConstraint(constraint);
+ constraint.Apply();
}
+
+ KeyFrames keyFrames = KeyFrames::New();
+ keyFrames.Add( 0.0f, 0.0f );
+ keyFrames.Add( 1.0f, 1.0f );
+
+ Animation applyAnimation = Dali::Animation::New( durationSeconds );
+ applyAnimation.AnimateBetween( Property( mWeightObject, WeightObject::WEIGHT ), keyFrames, mAlphaFunction, durationSeconds );
+ applyAnimation.Play();
}
}
protected:
ControlOrientation::Type mOrientation; ///< the orientation of the layout.
- AlphaFunction mAlphaFunction; ///<Alpha function to be applied when removing/adding constraints
+ AlphaFunction mAlphaFunction; ///< Alpha function to be applied when removing/adding constraints
+ Handle mWeightObject; ///< Weight object gets created to apply the constraints over a certain time
};
} // namespace Toolkit
namespace Toolkit
{
-Vector3 MoveActorConstraint(const Vector3& current,
- const PropertyInput& scrollPositionProperty)
+void MoveActorConstraint( Vector3& current, const PropertyInputContainer& inputs )
{
- return current + scrollPositionProperty.GetVector3();
+ current += inputs[0]->GetVector3();
}
-Vector3 WrapActorConstraint(const Vector3& current,
- const PropertyInput& actorScaleProperty,
- const PropertyInput& actorAnchorPointProperty,
- const PropertyInput& actorSizeProperty,
- const PropertyInput& scrollPositionMin,
- const PropertyInput& scrollPositionMax,
- const PropertyInput& scrollWrap)
+void WrapActorConstraint( Vector3& position, const PropertyInputContainer& inputs )
{
- Vector3 position = current;
- bool wrap = scrollWrap.GetBoolean();
+ bool wrap = inputs[5]->GetBoolean();
if(wrap)
{
- const Vector3& min = scrollPositionMin.GetVector3();
- const Vector3& max = scrollPositionMax.GetVector3();
+ const Vector3& min = inputs[3]->GetVector3();
+ const Vector3& max = inputs[4]->GetVector3();
- const Vector3& anchor = actorAnchorPointProperty.GetVector3();
- const Vector3 scale = actorScaleProperty.GetVector3();
- const Vector3 size = actorSizeProperty.GetVector3();
+ const Vector3& anchor = inputs[1]->GetVector3();
+ const Vector3 scale = inputs[0]->GetVector3();
+ const Vector3 size = inputs[2]->GetVector3();
if(fabsf(min.x - max.x) > Math::MACHINE_EPSILON_1)
{
position.y = WrapInDomain(position.y + offsetY, min.y, max.y) - offsetY;
}
}
-
- return position;
}
} // namespace Toolkit
*/
// EXTERNAL INCLUDES
-
-// INTERNAL INCLUDES
+#include <dali/public-api/animation/constraint.h>
namespace Dali
{
*
* Moves an Actor in accordance to scroll position.
*/
-DALI_IMPORT_API Vector3 MoveActorConstraint(const Vector3& current,
- const PropertyInput& scrollPositionProperty);
+DALI_IMPORT_API void MoveActorConstraint( Vector3& current, const PropertyInputContainer& inputs );
/**
* Wrap Actor constraint.
*
* Wraps an Actors position in accordance to min/max bounds of domain.
*/
-DALI_IMPORT_API Vector3 WrapActorConstraint(const Vector3& current,
- const PropertyInput& actorScaleProperty,
- const PropertyInput& actorAnchorPointProperty,
- const PropertyInput& actorSizeProperty,
- const PropertyInput& scrollPositionMin,
- const PropertyInput& scrollPositionMax,
- const PropertyInput& scrollWrap);
+DALI_IMPORT_API void WrapActorConstraint( Vector3& position, const PropertyInputContainer& inputs );
} // namespace Toolkit
* Layer contentLayer = Layer::New();
* contentLayer.SetAnchorPoint( AnchorPoint::CENTER );
* contentLayer.SetParentOrigin( ParentOrigin::CENTER );
- * contentLayer.ApplyConstraint( ParentConstraint::Size::New( ParentSize() ) );
* view.AddContentLayer( contentLayer );
* \endcode
*
#include <dali-toolkit/public-api/shader-effects/motion-blur-effect.h>
// EXTERNAL INCLUDES
-#include <dali/public-api/animation/active-constraint.h>
#include <dali/public-api/animation/constraint.h>
#include <dali/public-api/animation/constraints.h>
Dali::Property::Index uModelProperty = newEffect.GetPropertyIndex( MOTION_BLUR_MODEL_LASTFRAME );
- Constraint constraint = Constraint::New<Matrix>( uModelProperty,
- Source( renderable, Actor::Property::WORLD_MATRIX ),
- EqualToConstraint() );
+ Constraint constraint = Constraint::New<Matrix>( newEffect, uModelProperty, EqualToConstraint() );
+ constraint.AddSource( Source( renderable, Actor::Property::WORLD_MATRIX ) );
// and set up constraint.
- newEffect.ApplyConstraint( constraint );
+ constraint.Apply();
return newEffect;
}
#include <dali-toolkit/public-api/shader-effects/motion-stretch-effect.h>
// EXTERNAL INCLUDES
-#include <dali/public-api/animation/active-constraint.h>
#include <dali/public-api/animation/constraint.h>
#include <dali/public-api/animation/constraints.h>
Dali::Property::Index uModelProperty = newEffect.GetPropertyIndex( MOTION_STRETCH_MODELVIEW_LASTFRAME );
- Constraint constraint = Constraint::New<Matrix>( uModelProperty,
- Source( renderable, Actor::Property::WORLD_MATRIX ),
- EqualToConstraint() );
+ Constraint constraint = Constraint::New<Matrix>( newEffect, uModelProperty, EqualToConstraint() );
+ constraint.AddSource( Source( renderable, Actor::Property::WORLD_MATRIX ) );
// and set up constraint.
- newEffect.ApplyConstraint(constraint);
+ constraint.Apply();
return newEffect;
}
#include <dali-toolkit/public-api/shader-effects/nine-patch-mask-effect.h>
// EXTERNAL INCLUDES
-#include <dali/public-api/animation/active-constraint.h>
#include <dali/public-api/animation/constraint.h>
#include <dali/public-api/object/property-input.h>
#include <dali/public-api/shader-effects/shader-effect.h>
namespace NinePatchMaskEffect
{
-struct NinePatchMaskEffectSizeConstraint
+namespace
{
- Vector2 operator()( const Vector2& current, const PropertyInput& property )
- {
- const Vector3& actorSize = property.GetVector3();
- return Vector2( actorSize.x, actorSize.y );
- }
-};
+
+void NinePatchMaskEffectSizeConstraint( Vector2& current, const PropertyInputContainer& inputs )
+{
+ const Vector3& actorSize = inputs[0]->GetVector3();
+ current.x = actorSize.x;
+ current.y = actorSize.y;
+}
+
+} // unnamed namespace
static void DoApply( ImageActor actor, const std::string& maskImage, const Vector2& maskSize, Vector4 maskBorder )
{
maskEffect.SetEffectImage( ResourceImage::New( maskImage ) );
maskEffect.SetUniform( "uImageSize", Vector2(0,0) /*Constrained to actor size*/ );
- maskEffect.ApplyConstraint( Constraint::New<Vector2>( maskEffect.GetPropertyIndex("uImageSize"),
- Source(actor, Actor::Property::SIZE),
- NinePatchMaskEffectSizeConstraint() ) );
+
+ Constraint constraint = Constraint::New<Vector2>( maskEffect, maskEffect.GetPropertyIndex("uImageSize"), NinePatchMaskEffectSizeConstraint );
+ constraint.AddSource( Source(actor, Actor::Property::SIZE) );
+ constraint.Apply();
maskEffect.SetUniform( "uMaskSize", maskSize );
*/
// EXTERNAL INCLUDES
-#include <dali/public-api/animation/active-constraint.h>
#include <dali/public-api/animation/constraint.h>
#include <dali/public-api/object/property-input.h>
} // namespace
/**
- * ReciprocalConstraint
+ * InverseConstraint
*
* f(current, property) = 1.0 / property
*/
-struct ReciprocalConstraint
+void InverseConstraint( float& current, const PropertyInputContainer& inputs )
{
- ReciprocalConstraint(){}
-
- float operator()(const float current, const PropertyInput& property)
- {
- return 1.0f / property.GetFloat();
- }
-};
-
+ current = 1.0f / inputs[0]->GetFloat();
+}
////////////////////////////////////////////////////
//
// precalc 1.0 / uInsideCircleSizeScale on CPU to save shader insns, using constraint to tie to the normal property
Dali::Property::Index insideCircleSizeScalePropertyIndex = handle.GetPropertyIndex(SOFT_BUTTON_INSIDE_SHAPE_SIZE_SCALE_PROPERTY_NAME);
Dali::Property::Index recipInsideCircleSizeScalePropertyIndex = handle.GetPropertyIndex(SOFT_BUTTON_RECIP_INSIDE_SHAPE_SIZE_SCALE_PROPERTY_NAME);
- Constraint constraint = Constraint::New<float>( recipInsideCircleSizeScalePropertyIndex, LocalSource(insideCircleSizeScalePropertyIndex), ReciprocalConstraint());
- handle.ApplyConstraint(constraint);
+ Constraint constraint = Constraint::New<float>( handle, recipInsideCircleSizeScalePropertyIndex, InverseConstraint );
+ constraint.AddSource( LocalSource(insideCircleSizeScalePropertyIndex) );
+ constraint.Apply();
}
return handle;