#include <dali/internal/event/actor-attachments/renderable-attachment-impl.h>
#include <dali/internal/event/actor-attachments/actor-attachment-declarations.h>
#include <dali/internal/event/text/font-declarations.h>
-#include <dali/internal/common/text-array.h>
#include <dali/internal/event/text/text-request-helper.h>
#include <dali/internal/event/text/resource/glyph-texture-observer.h>
#include <dali/internal/common/owner-pointer.h>
+#include <dali/integration-api/text-array.h>
namespace Dali
{
/**
* Create a new TextAttachment.
+ * @param[in] stage The stage to use for messaging
* @param[in] parentNode The node to attach a scene-object to.
* @param [in] text The text which will be displayed.
* @param [in] font The font which will be used for the text.
- * @param [in] isLeftToRight Text is displayed from left to right if true, otherwise from right to left.
* @return A smart-pointer to the newly allocated TextAttachment.
*/
- static TextAttachmentPtr New( const SceneGraph::Node& parentNode, const TextArray& text, FontPointer font, bool isLeftToRight );
+ static TextAttachmentPtr New( Stage& stage, const SceneGraph::Node& parentNode, const Integration::TextArray& text, FontPointer font );
/**
* Set the text label displayed by the attachment
* @param [in] text The new text label
*/
- void SetText(const TextArray& text);
+ void SetText(const Integration::TextArray& text);
/**
* Get the text label displayed by the attachment
* @return The text label
*/
- const TextArray& GetText() const
+ const Integration::TextArray& GetText() const
{
// This is not animatable; the cached value is up-to-date.
return mText;
}
/**
- * @copydoc Dali::TextActor::SetGradientColor()
+ * Set the text color
+ * @param[in] color The text color
*/
- void SetGradientColor( const Vector4& color );
+ void SetTextColor(const Vector4& color);
/**
- * @copydoc Dali::TextActor::GetGradientColor()
+ * Get the text color
+ * @return The text color
*/
- const Vector4& GetGradientColor() const;
+ Vector4 GetTextColor() const;
/**
- * @copydoc Dali::TextActor::SetGradientStartPoint()
+ * Resets to default the text color.
*/
- void SetGradientStartPoint( const Vector2& position );
+ void ResetTextColor();
/**
- * @copydoc Dali::TextActor::GetGradientStartPoint()
+ * @copydoc Dali::TextActor::SetWeight()
*/
- const Vector2& GetGradientStartPoint() const;
+ void SetWeight( TextStyle::Weight weight );
/**
- * @copydoc Dali::TextActor::SetGradientEndPoint()
+ * @copydoc Dali::TextActor::GetWeight()
*/
- void SetGradientEndPoint( const Vector2& position );
+ TextStyle::Weight GetWeight() const;
/**
- * @copydoc Dali::TextActor::GetGradientEndPoint()
+ * Resets to default the text weight.
*/
- const Vector2& GetGradientEndPoint() const;
+ void ResetWeight();
/**
* @copydoc Dali::TextActor::SetSmoothEdge(const float)
*/
- void SetSmoothEdge(const float smoothEdge);
+ void SetSmoothEdge( float smoothEdge );
/**
* Retrieve the smooth edge value.
float GetSmoothEdge() const;
/**
+ * Resets to default the smooth edge.
+ */
+ void ResetSmoothEdge();
+
+ /**
+ * Enable italics on the text actor, the text will be sheared by the given angle.
+ * @param[in] angle Italics angle in radians.
+ */
+ void SetItalics( Radian angle );
+
+ /**
+ * @copydoc Dali::TextActor::GetItalics()
+ */
+ bool GetItalics() const;
+
+ /**
+ * @copydoc Dali::TextActor::GetItalicsAngle()
+ */
+ Radian GetItalicsAngle() const;
+
+ /**
+ * Resets to default the italics.
+ */
+ void ResetItalics();
+
+ /**
+ * @copydoc Dali::TextActor::SetUnderline()
+ */
+ void SetUnderline( bool enable, float thickness, float position );
+
+ /**
+ * @copydoc Dali::TextActor::GetUnderline()
+ */
+ bool GetUnderline() const;
+
+ /**
+ * @copydoc Internal::TextActor::GetUnderlineThickness()
+ */
+ float GetUnderlineThickness() const;
+
+ /**
+ * @copydoc Internal::TextActor::GetUnderlinePosition()
+ */
+ float GetUnderlinePosition() const;
+
+ /**
+ * Resets to default the text underline.
+ */
+ void ResetUnderline();
+
+ /**
* @copydoc Dali::TextActor::SetOutline(const bool,const Vector4&,const Vector2&)
*/
void SetOutline( bool enable, const Vector4& color, const Vector2& thickness );
void GetOutlineParams( Vector4& color, Vector2& thickness ) const;
/**
+ * Resets to default the text outline.
+ */
+ void ResetOutline();
+
+ /**
* @copydoc Dali::TextActor::SetGlow(const bool,const Vector4&,const float)
*/
- void SetGlow( bool enable, const Vector4& color, const float intensity);
+ void SetGlow( bool enable, const Vector4& color, float intensity );
/**
* Get glow state.
void GetGlowParams( Vector4& color, float& intensity ) const;
/**
+ * Resets to default the text glow.
+ */
+ void ResetGlow();
+
+ /**
* @copydoc Dali::TextActor::SetShadow(const bool,const Vector4&,const Vector2&,const float)
*/
- void SetShadow( bool enable, const Vector4& color, const Vector2& offset, const float size);
+ void SetShadow( bool enable, const Vector4& color, const Vector2& offset, float size );
/**
* Retrieve the shadow state.
void GetShadowParams( Vector4& color, Vector2& offset, float& size ) const;
/**
- * Set the text color
- * @param[in] color The text color
+ * Resets to default the text shadow.
*/
- void SetTextColor(const Vector4& color);
+ void ResetShadow();
/**
- * Get the text color
- * @return The text color
+ * @see Dali::TextActor::SetGradientColor()
+ * @see Dali::TextActor::SetGradientStartPoint()
+ * @see Dali::TextActor::SetGradientEndPoint()
*/
- Vector4 GetTextColor() const;
+ void SetGradient( const Vector4& color, const Vector2& startPoint, const Vector2& endPoint );
/**
- * Enable italics on the text actor, the text will be sheared by the given angle.
- * @param[in] angle Italics angle in radians.
- */
- void SetItalics( const Radian& angle );
-
- /**
- * @copydoc Dali::TextActor::GetItalics()
- */
- const Radian& GetItalics() const;
-
- /**
- * @copydoc Dali::TextActor::SetUnderline()
- */
- void SetUnderline( bool enable, float thickness, float position );
-
- /**
- * @copydoc Dali::TextActor::GetUnderline()
+ * @copydoc Dali::TextActor::GetGradientColor()
*/
- bool GetUnderline() const;
+ const Vector4& GetGradientColor() const;
/**
- * @copydoc Internal::TextActor::GetUnderlineThickness()
+ * @copydoc Dali::TextActor::GetGradientStartPoint()
*/
- float GetUnderlineThickness() const;
+ const Vector2& GetGradientStartPoint() const;
/**
- * @copydoc Internal::TextActor::GetUnderlinePosition()
+ * @copydoc Dali::TextActor::GetGradientEndPoint()
*/
- float GetUnderlinePosition() const;
+ const Vector2& GetGradientEndPoint() const;
/**
- * @copydoc Dali::TextActor::SetWeight()
+ * Resets to default the text gradient.
*/
- void SetWeight( TextStyle::Weight weight );
+ void ResetGradient();
/**
- * @copydoc Dali::TextActor::GetWeight()
+ * Retrieves the text style.
+ *
+ * @param[out] style The text style.
*/
- TextStyle::Weight GetWeight() const;
+ void GetTextStyle( TextStyle& style ) const;
/**
* Measure the natural size of a text string, as displayed in this font.
*/
bool IsTextLoaded();
+ /**
+ * Calculates the weighted smoothing value.
+ */
+ void CalculateWeightedSmoothing( TextStyle::Weight weight, float smoothEdge );
+
public: // glyph texture observer
/**
bool IsTextModified();
/**
- * Allocate a TextParameters object on this TextAttachment if one does not exist
- */
- void AllocateTextParameters();
-
- /**
* First stage construction of a TextAttachment.
* @param[in] stage Used to send messages to scene-graph.
*/
*/
void SetTextChanges();
- /**
- * Send new texture-id message
- */
- void SendTextureIdMessage();
-
- /**
- * Make a request to load the current text
- * @param uniqueText the text to request to be loaded
- */
- void RequestText( const TextArray& uniqueText );
-
protected:
/**
const SceneGraph::TextAttachment* mSceneObject; ///< Not owned
- TextRequestHelper mTextRequestHelper; ///< Text request helper
- FontPointer mFont; ///< The font resource
-
+ TextRequestHelper mTextRequestHelper; ///< Text request helper
+ FontPointer mFont; ///< The font resource
+ Vector4* mTextColor; ///< on demand storage for text color
+ TextStyle mStyle; ///< on demand storage for text effects parameters ( do not store font parameters and color )
+ ///< Font parameters are stored in the FontPointer member. Inside the TextStyle, font parameters and color are allocated in the same struct,
+ ///< so store the text color in the style will allocate space for the font parameters as well, wasting space.
// Cached values for public getters
- TextArray mText;
+ Integration::TextArray mText;
- bool mUnderlineEnabled:1; ///< whether the text is underlined
- bool mIsLeftToRight:1; ///< whether the text is left to right
bool mTextChanged:1; ///< whether the text has changed
bool mFontChanged:1; ///< whether the font has changed
bool mUnderlineChanged:1; ///< whether the underline has changed
bool mItalicsChanged:1; ///< whether the italics has changed
- bool mItalicsEnabled:1; ///< whether italics are enabled
bool mTextureIdSet:1; ///< flag to signify if the texture id has been set on the scene-graph text-attachment
unsigned int mTextureId; ///< the texture id of the glyph atlas being used
- float mSmoothing; ///< edge smoothing for the font
- Radian mItalicsAngle; ///< font italics angle
- float mUnderlineThickness; ///< The underline's thickness.
- float mUnderlinePosition; ///< The underline's position.
Vector2 mTextSize; ///< text natural size
- TextStyle::Weight mWeight; ///< font weight
OwnerPointer< TextVertexBuffer > mVertexBuffer; ///< vertex data to display the text
- OwnerPointer< TextParameters > mTextParameters; ///< on demand storage for text effect parameters
- Vector4* mTextColor; ///< on demand storage for text color
};
} // namespace Internal