Add property updated flag to text label
authorBowon Ryu <bowon.ryu@samsung.com>
Tue, 9 Jul 2024 02:05:39 +0000 (11:05 +0900)
committerBowon Ryu <bowon.ryu@samsung.com>
Tue, 9 Jul 2024 02:05:39 +0000 (11:05 +0900)
Change-Id: If1483a411a7b4a0ef4c71fe633b4eccc19d03113
Signed-off-by: Bowon Ryu <bowon.ryu@samsung.com>
dali-toolkit/internal/controls/text-controls/text-label-impl.cpp
dali-toolkit/internal/controls/text-controls/text-label-impl.h

index 388212c..3bcc076 100644 (file)
@@ -304,11 +304,13 @@ void TextLabel::SetProperty(BaseObject* object, Property::Index index, const Pro
 
         DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextLabel::SetProperty Property::FONT_FAMILY newFont(%s)\n", fontFamily.c_str());
         impl.mController->SetDefaultFontFamily(fontFamily);
+        impl.mIsPropertyUpdated = true;
         break;
       }
       case Toolkit::TextLabel::Property::FONT_STYLE:
       {
         SetFontStyleProperty(impl.mController, value, Text::FontStyle::DEFAULT);
+        impl.mIsPropertyUpdated = true;
         break;
       }
       case Toolkit::TextLabel::Property::POINT_SIZE:
@@ -318,12 +320,14 @@ void TextLabel::SetProperty(BaseObject* object, Property::Index index, const Pro
         if(!Equals(impl.mController->GetDefaultFontSize(Text::Controller::POINT_SIZE), pointSize))
         {
           impl.mController->SetDefaultFontSize(pointSize, Text::Controller::POINT_SIZE);
+          impl.mIsPropertyUpdated = true;
         }
         break;
       }
       case Toolkit::TextLabel::Property::MULTI_LINE:
       {
         impl.mController->SetMultiLineEnabled(value.Get<bool>());
+        impl.mIsPropertyUpdated = true;
         break;
       }
       case Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT:
@@ -332,6 +336,7 @@ void TextLabel::SetProperty(BaseObject* object, Property::Index index, const Pro
         if(Text::GetHorizontalAlignmentEnumeration(value, alignment))
         {
           impl.mController->SetHorizontalAlignment(alignment);
+          impl.mIsPropertyUpdated = true;
         }
         break;
       }
@@ -341,6 +346,7 @@ void TextLabel::SetProperty(BaseObject* object, Property::Index index, const Pro
         if(Text::GetVerticalAlignmentEnumeration(value, alignment))
         {
           impl.mController->SetVerticalAlignment(alignment);
+          impl.mIsPropertyUpdated = true;
         }
         break;
       }
@@ -380,6 +386,7 @@ void TextLabel::SetProperty(BaseObject* object, Property::Index index, const Pro
           {
             impl.mController->SetAutoScrollEnabled(enableAutoScroll);
           }
+          impl.mIsPropertyUpdated = true;
         }
         break;
       }
@@ -450,6 +457,7 @@ void TextLabel::SetProperty(BaseObject* object, Property::Index index, const Pro
         if(!Equals(impl.mController->GetDefaultFontSize(Text::Controller::PIXEL_SIZE), pixelSize))
         {
           impl.mController->SetDefaultFontSize(pixelSize, Text::Controller::PIXEL_SIZE);
+          impl.mIsPropertyUpdated = true;
         }
         break;
       }
@@ -459,6 +467,7 @@ void TextLabel::SetProperty(BaseObject* object, Property::Index index, const Pro
         DALI_LOG_INFO(gLogFilter, Debug::General, "TextLabel %p ELLIPSIS %d\n", impl.mController.Get(), ellipsis);
 
         impl.mController->SetTextElideEnabled(ellipsis);
+        impl.mIsPropertyUpdated = true;
         break;
       }
       case Toolkit::TextLabel::Property::LINE_WRAP_MODE:
@@ -468,6 +477,7 @@ void TextLabel::SetProperty(BaseObject* object, Property::Index index, const Pro
         {
           DALI_LOG_INFO(gLogFilter, Debug::General, "TextLabel %p LineWrap::MODE %d\n", impl.mController.Get(), lineWrapMode);
           impl.mController->SetLineWrapMode(lineWrapMode);
+          impl.mIsPropertyUpdated = true;
         }
         break;
       }
@@ -484,6 +494,7 @@ void TextLabel::SetProperty(BaseObject* object, Property::Index index, const Pro
 
           // No need to trigger full re-layout. Instead call UpdateRenderer() directly
           TextVisual::UpdateRenderer(impl.mVisual);
+          impl.mIsPropertyUpdated = true;
         }
         break;
       }
@@ -495,11 +506,13 @@ void TextLabel::SetProperty(BaseObject* object, Property::Index index, const Pro
       case Toolkit::DevelTextLabel::Property::IGNORE_SPACES_AFTER_TEXT:
       {
         impl.mController->SetIgnoreSpacesAfterText(value.Get<bool>());
+        impl.mIsPropertyUpdated = true;
         break;
       }
       case Toolkit::DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION:
       {
         impl.mController->SetMatchLayoutDirection(value.Get<bool>() ? DevelText::MatchLayoutDirection::LOCALE : DevelText::MatchLayoutDirection::CONTENTS);
+        impl.mIsPropertyUpdated = true;
         break;
       }
       case Toolkit::DevelTextLabel::Property::TEXT_FIT:
@@ -513,6 +526,7 @@ void TextLabel::SetProperty(BaseObject* object, Property::Index index, const Pro
 
         ParseTextFitProperty(impl.mController, value.GetMap());
         impl.mController->SetTextFitChanged(true);
+        impl.mIsPropertyUpdated = true;
         break;
       }
       case Toolkit::DevelTextLabel::Property::MIN_LINE_SIZE:
@@ -524,6 +538,7 @@ void TextLabel::SetProperty(BaseObject* object, Property::Index index, const Pro
           impl.mTextUpdateNeeded = impl.mController->SetDefaultLineSize(lineSize) || impl.mTextUpdateNeeded;
         }
         impl.mController->SetCurrentLineSize(lineSize);
+        impl.mIsPropertyUpdated = true;
         break;
       }
       case Toolkit::DevelTextLabel::Property::FONT_SIZE_SCALE:
@@ -534,6 +549,7 @@ void TextLabel::SetProperty(BaseObject* object, Property::Index index, const Pro
         if(!Equals(impl.mController->GetFontSizeScale(), scale))
         {
           impl.mController->SetFontSizeScale(scale);
+          impl.mIsPropertyUpdated = true;
         }
         break;
       }
@@ -543,6 +559,7 @@ void TextLabel::SetProperty(BaseObject* object, Property::Index index, const Pro
         if(!Equals(impl.mController->IsFontSizeScaleEnabled(), enableFontSizeScale))
         {
           impl.mController->SetFontSizeScaleEnabled(enableFontSizeScale);
+          impl.mIsPropertyUpdated = true;
         }
         break;
       }
@@ -553,6 +570,7 @@ void TextLabel::SetProperty(BaseObject* object, Property::Index index, const Pro
         {
           DALI_LOG_INFO(gLogFilter, Debug::General, "TextLabel %p EllipsisPosition::Type %d\n", impl.mController.Get(), ellipsisPositionType);
           impl.mController->SetEllipsisPosition(ellipsisPositionType);
+          impl.mIsPropertyUpdated = true;
         }
         break;
       }
@@ -565,6 +583,7 @@ void TextLabel::SetProperty(BaseObject* object, Property::Index index, const Pro
       {
         const float characterSpacing = value.Get<float>();
         impl.mController->SetCharacterSpacing(characterSpacing);
+        impl.mIsPropertyUpdated = true;
         break;
       }
       case Toolkit::DevelTextLabel::Property::RELATIVE_LINE_SIZE:
@@ -573,6 +592,7 @@ void TextLabel::SetProperty(BaseObject* object, Property::Index index, const Pro
         DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextLabel %p RELATIVE_LINE_SIZE %f\n", impl.mController.Get(), relativeLineSize);
 
         impl.mController->SetRelativeLineSize(relativeLineSize);
+        impl.mIsPropertyUpdated = true;
         break;
       }
       case Toolkit::DevelTextLabel::Property::ANCHOR_COLOR:
@@ -599,12 +619,14 @@ void TextLabel::SetProperty(BaseObject* object, Property::Index index, const Pro
       {
         const bool remove = value.Get<bool>();
         impl.mController->SetRemoveFrontInset(remove);
+        impl.mIsPropertyUpdated = true;
         break;
       }
       case Toolkit::DevelTextLabel::Property::REMOVE_BACK_INSET:
       {
         const bool remove = value.Get<bool>();
         impl.mController->SetRemoveBackInset(remove);
+        impl.mIsPropertyUpdated = true;
         break;
       }
       case Toolkit::DevelTextLabel::Property::CUTOUT:
@@ -618,6 +640,7 @@ void TextLabel::SetProperty(BaseObject* object, Property::Index index, const Pro
 
         // No need to trigger full re-layout. Instead call UpdateRenderer() directly
         TextVisual::UpdateRenderer(impl.mVisual);
+        impl.mIsPropertyUpdated = true;
         break;
       }
     }
@@ -629,6 +652,7 @@ void TextLabel::SetProperty(BaseObject* object, Property::Index index, const Pro
     {
       // need to request relayout as size of text may have changed
       impl.RequestTextRelayout();
+      impl.mIsPropertyUpdated = true;
     }
   }
 }
@@ -1093,6 +1117,7 @@ void TextLabel::OnPropertySet(Property::Index index, const Property::Value& prop
       {
         mController->SetDefaultColor(textColor);
         mTextUpdateNeeded = true;
+        mIsPropertyUpdated = true;
       }
       break;
     }
@@ -1114,6 +1139,7 @@ void TextLabel::OnPropertySet(Property::Index index, const Property::Value& prop
         {
           EnableControlBackground(false);
         }
+        mIsPropertyUpdated = true;
       }
       break;
     }
@@ -1137,11 +1163,13 @@ void TextLabel::OnPropertySet(Property::Index index, const Property::Value& prop
         EnableControlBackground(!cutoutEnabled);
         TextVisual::SetRequireRender(mVisual, cutoutEnabled);
       }
+      mIsPropertyUpdated = true;
       break;
     }
     default:
     {
       Control::OnPropertySet(index, propertyValue); // up call to control for non-handled properties
+      mIsPropertyUpdated = true;
       break;
     }
   }
@@ -1212,9 +1240,15 @@ void TextLabel::OnRelayout(const Vector2& size, RelayoutContainer& container)
       // When auto scroll is playing, a text load request is made only if a text update is absolutely necessary.
       return;
     }
+    if(!mIsPropertyUpdated)
+    {
+      return;
+    }
+
     AsyncTextParameters parameters = GetAsyncTextParameters(contentSize, padding, layoutDirection);
     TextVisual::UpdateAsyncRenderer(mVisual, parameters);
     mTextUpdateNeeded = false;
+    mIsPropertyUpdated = false;
     return;
   }
 
@@ -1537,7 +1571,8 @@ TextLabel::TextLabel(ControlBehaviour additionalBehaviour)
   mRenderingBackend(DEFAULT_RENDERING_BACKEND),
   mTextUpdateNeeded(false),
   mLastAutoScrollEnabled(false),
-  mControlBackgroundEnabeld(true)
+  mControlBackgroundEnabeld(true),
+  mIsPropertyUpdated(false)
 {
 }
 
index a6bf159..ccda7d1 100644 (file)
@@ -406,6 +406,8 @@ private: // Data
   bool mLastAutoScrollEnabled : 1;
   bool mControlBackgroundEnabeld : 1;
 
+  bool mIsPropertyUpdated : 1;
+
 protected:
   /**
    * @brief This structure is to connect TextLabel with Accessible functions.