Merge "Follow the include-order coding conventions" into tizen
[platform/core/uifw/dali-core.git] / dali / internal / event / actors / text-actor-impl.cpp
index 42dd751..c8957f9 100644 (file)
@@ -59,7 +59,13 @@ const Property::Index TextActor::TEXT_COLOR                 = Internal::DEFAULT_
 namespace
 {
 
-const std::string DEFAULT_TEXT_ACTOR_PROPERTY_NAMES[] =
+// Signals
+
+const char* const SIGNAL_TEXT_LOADING_FINISHED = "text-loading-finished";
+
+// Default property names
+
+const char* DEFAULT_TEXT_ACTOR_PROPERTY_NAMES[] =
 {
   "text",
   "font",
@@ -84,7 +90,7 @@ const std::string DEFAULT_TEXT_ACTOR_PROPERTY_NAMES[] =
   "shadow-size",
   "text-color"
 };
-const int DEFAULT_TEXT_ACTOR_PROPERTY_COUNT = sizeof( DEFAULT_TEXT_ACTOR_PROPERTY_NAMES ) / sizeof( std::string );
+const int DEFAULT_TEXT_ACTOR_PROPERTY_COUNT = sizeof( DEFAULT_TEXT_ACTOR_PROPERTY_NAMES ) / sizeof( DEFAULT_TEXT_ACTOR_PROPERTY_NAMES[0] );
 
 const Property::Type DEFAULT_TEXT_ACTOR_PROPERTY_TYPES[DEFAULT_TEXT_ACTOR_PROPERTY_COUNT] =
 {
@@ -116,8 +122,6 @@ const Property::Type DEFAULT_TEXT_ACTOR_PROPERTY_TYPES[DEFAULT_TEXT_ACTOR_PROPER
 
 namespace Internal
 {
-bool TextActor::mFirstInstance = true;
-Actor::DefaultPropertyLookup* TextActor::mDefaultTextActorPropertyLookup = NULL;
 
 namespace
 {
@@ -129,7 +133,7 @@ BaseHandle Create()
 
 TypeRegistration mType( typeid(Dali::TextActor), typeid(Dali::RenderableActor), Create );
 
-SignalConnectorType s1( mType, Dali::TextActor::SIGNAL_TEXT_LOADING_FINISHED, &TextActor::DoConnectSignal );
+SignalConnectorType s1( mType, SIGNAL_TEXT_LOADING_FINISHED, &TextActor::DoConnectSignal );
 
 }
 
@@ -146,7 +150,8 @@ TextActorPtr TextActor::New( const Integration::TextArray& utfCodes, const TextA
   actor->Initialize();
 
   //create the attachment
-  actor->mTextAttachment = TextAttachment::New( *actor->mNode, Integration::TextArray(), fontPtr );
+  actor->mTextAttachment = TextAttachment::New( *actor->mStage, *actor->mNode, Integration::TextArray(), fontPtr );
+  actor->Attach(*actor->mTextAttachment);
 
   // Note: SetTextStyle() MUST be called before SetText(), to ensure
   //       that a single ResourceRequest for the glyphs is made. Calling
@@ -170,16 +175,6 @@ TextActor::TextActor(bool fontDetection)
 
 void TextActor::OnInitialize()
 {
-  if(TextActor::mFirstInstance)
-  {
-    mDefaultTextActorPropertyLookup = new DefaultPropertyLookup();
-    const int start = DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT;
-    for ( int i = 0; i < DEFAULT_TEXT_ACTOR_PROPERTY_COUNT; ++i )
-    {
-      (*mDefaultTextActorPropertyLookup)[DEFAULT_TEXT_ACTOR_PROPERTY_NAMES[i]] = i + start;
-    }
-    TextActor::mFirstInstance = false ;
-  }
 }
 
 TextActor::~TextActor()
@@ -475,6 +470,7 @@ void TextActor::SetTextStyle( const TextStyle& style, TextRequestMode mode )
   {
     mTextAttachment->ResetGradient();
   }
+  TextChanged();
 }
 
 TextStyle TextActor::GetTextStyle() const
@@ -579,7 +575,7 @@ bool TextActor::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface*
   bool connected( true );
   TextActor* textActor = dynamic_cast<TextActor*>(object);
 
-  if( Dali::TextActor::SIGNAL_TEXT_LOADING_FINISHED == signalName )
+  if( 0 == strcmp( signalName.c_str(), SIGNAL_TEXT_LOADING_FINISHED ) )
   {
     textActor->TextAvailableSignal().Connect( tracker, functor );
   }
@@ -630,7 +626,7 @@ bool TextActor::CheckTextLoadState()
 
     // emit text available signal
 
-    mLoadingFinishedV2.Emit( Dali::TextActor( this ) );
+    mLoadingFinished.Emit( Dali::TextActor( this ) );
 
     return true;
   }
@@ -657,7 +653,7 @@ void TextActor::GetDefaultPropertyIndices( Property::IndexContainer& indices ) c
   }
 }
 
-const std::string& TextActor::GetDefaultPropertyName( Property::Index index ) const
+const char* TextActor::GetDefaultPropertyName( Property::Index index ) const
 {
   if(index < DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT)
   {
@@ -673,9 +669,7 @@ const std::string& TextActor::GetDefaultPropertyName( Property::Index index ) co
     }
     else
     {
-      // index out-of-bounds
-      static const std::string INVALID_PROPERTY_NAME;
-      return INVALID_PROPERTY_NAME;
+      return NULL;
     }
   }
 }
@@ -684,17 +678,19 @@ Property::Index TextActor::GetDefaultPropertyIndex(const std::string& name) cons
 {
   Property::Index index = Property::INVALID_INDEX;
 
-  DALI_ASSERT_DEBUG( NULL != mDefaultTextActorPropertyLookup );
-
-  // Look for name in current class' default properties
-  DefaultPropertyLookup::const_iterator result = mDefaultTextActorPropertyLookup->find( name );
-  if ( mDefaultTextActorPropertyLookup->end() != result )
+  // Look for name in default properties
+  for( int i = 0; i < DEFAULT_TEXT_ACTOR_PROPERTY_COUNT; ++i )
   {
-    index = result->second;
+    if( 0 == strcmp( name.c_str(), DEFAULT_TEXT_ACTOR_PROPERTY_NAMES[ i ] ) ) // dont want to convert rhs to string
+    {
+      index = i + DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT;
+      break;
+    }
   }
-  else
+
+  // If not found, check in base class
+  if( Property::INVALID_INDEX == index )
   {
-    // If not found, check in base class
     index = RenderableActor::GetDefaultPropertyIndex( name );
   }
 
@@ -709,7 +705,7 @@ bool TextActor::IsDefaultPropertyWritable( Property::Index index ) const
   }
   else
   {
-    return true ;
+    return true;
   }
 }
 
@@ -721,7 +717,7 @@ bool TextActor::IsDefaultPropertyAnimatable( Property::Index index ) const
   }
   else
   {
-    return false ;
+    return false;
   }
 }