Fixing the issue where characters were being drawn at the same location whenever... 86/253286/11
authorSara Samara <sara.samara@samsung.com>
Mon, 8 Feb 2021 09:48:08 +0000 (11:48 +0200)
committerSara Samara <sara.samara@samsung.com>
Thu, 1 Apr 2021 16:05:59 +0000 (19:05 +0300)
commitc570552b94d9532440de9440b845c4fc06f8d411
tree6390a62116b2b1b1ff84e6b942835d8456fe3bb3
parent2181d2ac56e0efca21307dd75b1ecc46bee57b9f
Fixing the issue where characters were being drawn at the same location whenever GetNaturalSize was called.

*********************************************************************************
Description:
GetNaturalSize method was updating a copy by reference of the pending operations mask.
The value of the mask was being updated to Layout and Render.
After calling GetNaturalSize and giving focus to the editor by tapping it, the UpdateModel was attempting to perform an update based on the mask but had no update details stored in the the object and this caused all the characters to be pushed to the same paragraph.
The change stored a back-up of the mask as soon as it entered the GetNaturalSize so that its value can be restored before exiting GetNaturalSize. This ensured that no modifications made on the mask copy while getting the natural size were reflected on the original mask.
The utc checks on the line count before calling GetNaturalSize and tapping the text-editor and after doing so. The line count is expected to not change.
*********************************************************************************

using namespace Dali;
using namespace Dali::Toolkit;

class SimpleApp : public ConnectionTracker
{
public:
  SimpleApp(Application& application)
  : mApplication(application)
  {
    mApplication.InitSignal().Connect(this, &SimpleApp::Create);
  }
  void Create(Application& application)
  {
    Window window = application.GetWindow();
    mEditor = TextEditor::New();
    mEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER);
    mEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER);
    mEditor.SetProperty(Actor::Property::POSITION, Vector3(0.f, 0.0f, 0.f));
    mEditor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 100.0f));
    mEditor.SetBackgroundColor(Vector4(0.04f, 0.345f, 0.392f, 1.0f));
    mEditor.SetProperty(TextEditor::Property::TEXT, "A\na\n");

    mButton = PushButton::New();
    mButton.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
    mButton.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
    mButton.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.0f));
    mButton.SetProperty(Actor::Property::POSITION, Vector3(0.f, 0.0f, 0.f));
    mButton.SetProperty(Button::Property::LABEL, "click");
    mButton.SetBackgroundColor(Vector4(0.5f, 0.5f, 0.5f, 1.0f));
    mButton.ClickedSignal().Connect(this, &SimpleApp::OnButtonClicked);

    window.Add(mButton);
    window.Add(mEditor);
  }
  std::string str1,str2;

  bool OnButtonClicked(Button button)
  {
    if(button == mButton)
    {
      Vector3 originalSize = mEditor.GetNaturalSize();
    }
    return true;
  }
private:
  Application& mApplication;
  TextEditor mEditor;
  PushButton mButton;
};

int DALI_EXPORT_API main(int argc, char** argv)
{
  Application application = Application::New(&argc, &argv);
  SimpleApp test(application);
  application.MainLoop();

  return 0;
}

Change-Id: I287f2f195d861a2cebbb256195d25cb653702dc7
automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp
dali-toolkit/internal/text/text-controller-relayouter.cpp