}
}
+ virtual Vector3 GetNaturalSize()
+ {
+ return Vector3( 0.0f, 0.0f, 0.0f );
+ }
+
void SetDaliProperty(std::string s)
{
Self().SetProperty(mDaliProperty, s) ;
return Actor::New();
}
+ virtual Vector3 GetNaturalSize()
+ {
+ return Vector3( 0.0f, 0.0f, 0.0f );
+ }
+
public:
SignalType mSignal;
END_TEST;
}
+int UtcDaliActorGetNaturalSize(void)
+{
+ TestApplication application;
+
+ Actor actor = Actor::New();
+ Vector3 vector( 0.0f, 0.0f, 0.0f );
+
+ DALI_TEST_CHECK( actor.GetNaturalSize() == vector );
+
+ END_TEST;
+}
+
// SetPosition(float x, float y)
int UtcDaliActorSetPosition01(void)
{
}
}
+ virtual Vector3 GetNaturalSize()
+ {
+ return Vector3( 0.0f, 0.0f, 0.0f );
+ }
+
void SetDaliProperty(std::string s)
{
Self().SetProperty(mDaliProperty, s) ;
{
return Actor();
}
+
+ virtual Vector3 GetNaturalSize()
+ {
+ return Vector3( 0.0f, 0.0f, 0.0f );
+ }
};
} ; // namespace Impl
return GetImpl().mTargetSize;
}
+ virtual Vector3 GetNaturalSize()
+ {
+ return Vector3( 0.0f, 0.0f, 0.0f );
+ }
+
private:
TestCustomActor( Impl::TestCustomActor& impl ) : CustomActor( impl )
END_TEST;
}
+
+int UtcDaliImageActorGetNaturalSize(void)
+{
+ TestApplication application;
+
+ // Standard image
+ BitmapImage img = BitmapImage::New( 10, 10 );
+ ImageActor actor = ImageActor::New( img );
+
+ DALI_TEST_CHECK( actor.GetNaturalSize().GetVectorXY() == Vector2( 10, 10 ) );
+
+ // Pixel area set
+ ImageActor::PixelArea area( 1, 2, 3, 4 );
+ actor.SetPixelArea( area );
+
+ DALI_TEST_CHECK( actor.GetNaturalSize().GetVectorXY() == Vector2( 3, 4 ) );
+
+ END_TEST;
+}
DALI_TEST_EQUALS( indices.size(), textActor.GetPropertyCount(), TEST_LOCATION );
END_TEST;
}
+
+int UtcDaliTextActorGetNaturalSize(void)
+{
+ TestApplication application;
+
+ TextActor actor = TextActor::New();
+ std::string text( "something else" );
+ actor.SetText( text );
+
+ Font defaultFont = Font::New();
+ Vector3 naturalSize = defaultFont.MeasureText( text );
+
+ DALI_TEST_CHECK( actor.GetNaturalSize().GetVectorXY() == naturalSize.GetVectorXY() );
+
+ END_TEST;
+}
void Actor::SetSize(const Vector2& size)
{
- Vector3 volume( size );
- volume.z = std::min( size.width, size.height );
- SetSize( volume );
+ SetSize( Vector3( size.width, size.height, CalculateSizeZ( size ) ) );
+}
+
+float Actor::CalculateSizeZ( const Vector2& size ) const
+{
+ return std::min( size.width, size.height );
}
void Actor::SetSize(const Vector3& size)
return Vector3::ZERO;
}
+Vector3 Actor::GetNaturalSize() const
+{
+ // It is up to deriving classes to return the appropriate natural size
+ return Vector3( 0.0f, 0.0f, 0.0f );
+}
+
+
#ifdef DYNAMICS_SUPPORT
//--------------- Dynamics ---------------
const Vector3& GetCurrentSize() const;
/**
+ * Return the natural size of the actor
+ *
+ * @return The actor's natural size
+ */
+ virtual Vector3 GetNaturalSize() const;
+
+ /**
* Set the origin of an actor, within its parent's area.
* This is expressed in 2D unit coordinates, such that (0.0, 0.0, 0.5) is the top-left corner of the parent,
* and (1.0, 1.0, 0.5) is the bottom-right corner.
*/
bool IsNodeConnected() const;
+ /**
+ * Calculate the size of the z dimension for a 2D size
+ *
+ * @param[in] size The 2D size (X, Y) to calculate Z from
+ *
+ * @return Return the Z dimension for this size
+ */
+ float CalculateSizeZ( const Vector2& size ) const;
+
public: // Default property extensions from ProxyObject
/**
}
/**
+ * @copydoc Internal::Actor::GetNaturalSize
+ */
+ virtual Vector3 GetNaturalSize() const
+ {
+ return mImpl->GetNaturalSize();
+ }
+
+ /**
* Private constructor; see also CustomActor::New()
*/
CustomActor(CustomActorImpl& extension);
{
if( mUsingNaturalSize )
{
- // if no image then natural size is 0
- Vector2 size;
- ImagePtr image = mImageAttachment->GetImage();
- if( image )
- {
- if( IsPixelAreaSet() )
- {
- PixelArea area(GetPixelArea());
- size.width = area.width;
- size.height = area.height;
- }
- else
- {
- size = image->GetNaturalSize();
- }
- }
mInternalSetSize = true;
- SetSize( size );
+ SetSize( CalculateNaturalSize() );
mInternalSetSize = false;
}
}
+Vector3 ImageActor::GetNaturalSize() const
+{
+ Vector2 naturalSize( CalculateNaturalSize() );
+ return Vector3( naturalSize.width, naturalSize.height, CalculateSizeZ( naturalSize ) );
+}
+
+Vector2 ImageActor::CalculateNaturalSize() const
+{
+ // if no image then natural size is 0
+ Vector2 size( 0.0f, 0.0f );
+
+ ImagePtr image = mImageAttachment->GetImage();
+ if( image )
+ {
+ if( IsPixelAreaSet() )
+ {
+ PixelArea area(GetPixelArea());
+ size.width = area.width;
+ size.height = area.height;
+ }
+ else
+ {
+ size = image->GetNaturalSize();
+ }
+ }
+
+ return size;
+}
+
void ImageActor::OnSizeSet( const Vector3& targetSize )
{
if( !mInternalSetSize )
*/
virtual Property::Value GetDefaultProperty( Property::Index index ) const;
+public: // From Actor
+
+ /**
+ * @copydoc Dali::Actor::GetNaturalSize()
+ */
+ virtual Vector3 GetNaturalSize() const;
+
private: // From RenderableActor
/**
void SetNaturalSize();
/**
+ * Calculate the natural size of this image actor
+ *
+ * @return Return the natural size as a Vector2
+ */
+ Vector2 CalculateNaturalSize() const;
+
+ /**
* From Actor.
* This is called after SizeSet() has been called.
*/
}
}
+Vector3 TextActor::GetNaturalSize() const
+{
+ Vector2 naturalSize( mTextAttachment->GetNaturalTextSize() );
+ return Vector3( naturalSize.width, naturalSize.height, CalculateSizeZ( naturalSize ) );
+}
+
void TextActor::OnSizeSet(const Vector3& targetSize)
{
if( !mInternalSetSize )
*/
bool IsFontDetectionAutomatic() const;
+public: // From Actor
+
+ /**
+ * @copydoc Dali::Actor::GetNaturalSize()
+ */
+ virtual Vector3 GetNaturalSize() const;
+
private: // from Actor
/**
return GetImplementation(*this).GetCurrentSize();
}
+Vector3 Actor::GetNaturalSize() const
+{
+ return GetImplementation(*this).GetNaturalSize();
+}
+
void Actor::SetPosition(float x, float y)
{
GetImplementation(*this).SetPosition(x, y);
Vector3 GetCurrentSize() const;
/**
+ * Return the natural size of the actor.
+ *
+ * Deriving classes stipulate the natural size and by default an actor has a ZERO natural size.
+ *
+ * @return The actor's natural size
+ */
+ Vector3 GetNaturalSize() const;
+
+ /**
* @brief Sets the position of the actor.
*
* The Actor's z position will be set to 0.0f.
*/
virtual Dali::Actor GetChildByAlias(const std::string& actorAlias) = 0;
+ /**
+ * Return the natural size of the actor
+ *
+ * @return The actor's natural size
+ */
+ virtual Vector3 GetNaturalSize() = 0;
+
protected: // For derived classes
/**