Extending Text Styles - Adding Dashed/Double Underline 30/257630/38
authorSara Samara <sara.samara@samsung.com>
Wed, 28 Apr 2021 11:13:54 +0000 (14:13 +0300)
committerssabah <s.sabah@samsung.com>
Tue, 11 Jan 2022 15:57:30 +0000 (17:57 +0200)
commit29a52105283ce8ced672ed92545daeacf882316a
treefce910225a1cf15112f9be0c5d2249625759ef82
parent70fdb1a1e8e2660c383079ae49bc94fbe14943d1
Extending Text Styles - Adding Dashed/Double Underline

***********************************************************
Description:
Adding the dashed & double underlines for the text-editor and the text-label.
The sample code below can be used to test the underline using the property maps.
the type can be specified to be DASHED or DOUBLE and if left unspecified,
the default is the SOLID underline.
Other params can be specified such as the color, color2, type, width
and gap. Their defaults are respectively: black, black, SOLID, 2 and 1.
***********************************************************

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();
    window.SetBackgroundColor(Vector4(0.04f, 0.345f, 0.392f, 1.0f));

    //text editor dashed underline
    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, "Sara");

    //label code
    // TextLabel label = TextLabel::New();
    // label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER);
    // label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER);
    // label.SetProperty(Actor::Property::POSITION, Vector3(0.f, 0.0f, 0.f));
    // label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 100.0f));
    // label.SetBackgroundColor(Vector4(0.04f, 0.345f, 0.392f, 1.0f));
    // label.SetProperty(TextEditor::Property::TEXT, "Sara");

    // use the code below for the text-editor
    Property::Map underlineMapSet;
    underlineMapSet.Insert("enable", true);
    underlineMapSet.Insert("color", Color::RED);
    underlineMapSet.Insert("height", 1);
    underlineMapSet.Insert("type", Text::Underline::DASHED);
    underlineMapSet.Insert("dashWidth", 5);
    underlineMapSet.Insert("dashGap", 3);
    mEditor.SetProperty(TextEditor::Property::UNDERLINE, underlineMapSet);

    //use the code below for the text-label
    // Property::Map underlineMapSet;
    // underlineMapSet.Insert("enable",true);
    // underlineMapSet.Insert("color", Color::RED);
    // underlineMapSet.Insert("height", 1);
    // underlineMapSet.Insert("type", Text::Underline::DASHED);
    // underlineMapSet.Insert("dashWidth", 5);
    // underlineMapSet.Insert("dashGap", 3);
    // label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);

    //window.Add(label);
    window.Add(mEditor);
  }

   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: Ie89bcf532ffc3d5ad19d7b39261ac10f4f1b2fda
26 files changed:
automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp
automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp
automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp
automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp
dali-toolkit/devel-api/controls/text-controls/text-style-properties-devel.h
dali-toolkit/internal/text/markup-processor-helper-functions.cpp
dali-toolkit/internal/text/markup-processor-helper-functions.h
dali-toolkit/internal/text/rendering/atlas/text-atlas-renderer.cpp
dali-toolkit/internal/text/rendering/text-typesetter.cpp
dali-toolkit/internal/text/rendering/view-model.cpp
dali-toolkit/internal/text/rendering/view-model.h
dali-toolkit/internal/text/text-controller.cpp
dali-toolkit/internal/text/text-controller.h
dali-toolkit/internal/text/text-effects-style.cpp
dali-toolkit/internal/text/text-effects-style.h
dali-toolkit/internal/text/text-enumerations-impl.cpp
dali-toolkit/internal/text/text-enumerations-impl.h
dali-toolkit/internal/text/text-model-interface.h
dali-toolkit/internal/text/text-model.cpp
dali-toolkit/internal/text/text-model.h
dali-toolkit/internal/text/text-view-interface.h
dali-toolkit/internal/text/text-view.cpp
dali-toolkit/internal/text/text-view.h
dali-toolkit/internal/text/visual-model-impl.cpp
dali-toolkit/internal/text/visual-model-impl.h
dali-toolkit/public-api/text/text-enumerations.h