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)
***********************************************************
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


No differences found