Adding Character Spacing 90/260890/78
authorSara Samara <sara.samara@samsung.com>
Tue, 6 Jul 2021 08:48:26 +0000 (11:48 +0300)
committerssabah <s.sabah@samsung.com>
Mon, 24 Jan 2022 14:56:03 +0000 (16:56 +0200)
commit895806b4ad86de88dcc731aeb8e3dbe453ce4202
tree7fd02495616c1fed879ed0f189dabf39a6d62eab
parent6c542cda6eb2ae887cb7a8a6c5d77e2f9659cbf7
Adding Character Spacing

***********************************************************
Description:
Adding the CHARACTER_SPACING for text-editor, text-field and text-label.
CHARACTER_SPACING determines the spaces between characters.
A positive value will make the characters far apart (expanded) and a negative value will bring them closer (condensed).
The sample code below can be used to test the CHARACTER_SPACING.
***********************************************************

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

    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 long text that exceeds the editor's width.");
    mEditor.SetProperty(DevelTextEditor::Property::CHARACTER_SPACING, 15.0f);

    // mLabel = TextLabel::New();
    // mLabel.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER);
    // mLabel.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER);
    // mLabel.SetProperty(Actor::Property::POSITION, Vector3(0.f, 0.0f, 0.f));
    // mLabel.SetProperty(Actor::Property::SIZE, Vector2(400.f, 200.0f));
    // mLabel.SetProperty(TextLabel::Property::TEXT_COLOR, Color::BLACK);
    // mLabel.SetProperty(TextLabel::Property::TEXT, "A long text text text that exceeds the label's width.");
    // mLabel.SetProperty(DevelTextLabel::Property::CHARACTER_SPACING, 10.0f);
    // mLabel.SetProperty(TextLabel::Property::ELLIPSIS, false);

    // mField = TextField::New();
    // mField.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER);
    // mField.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER);
    // mField.SetProperty(Actor::Property::POSITION, Vector3(0.f, 0.0f, 0.f));
    // mField.SetProperty(Actor::Property::SIZE, Vector2(200.f, 100.0f));
    // mField.SetProperty(TextField::Property::TEXT, "A long text text text that exceeds the field's width.");
    // mField.SetProperty(DevelTextField::Property::CHARACTER_SPACING, 10.0f);
    // mField.SetProperty(TextField::Property::ELLIPSIS, false);

    //window.Add(mLabel);
    window.Add(mEditor);
    //window.Add(mField);

  }

  bool OnButtonClicked(Button button)
  {
    if (button == mButton)
    {
      Vector3 originalSize = mEditor.GetNaturalSize();
    }
    return true;
  }

private:
  Application &mApplication;
  TextEditor mEditor;
  PushButton mButton;
  TextField mField;
  TextLabel mLabel;
};

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

  return 0;
}

Change-Id: Ibd89f1398e391dc56e3a230c7a136cfe07edc37a
50 files changed:
automated-tests/src/dali-toolkit-internal/CMakeLists.txt
automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/toolkit-text-utils.cpp
automated-tests/src/dali-toolkit-internal/dali-toolkit-test-utils/toolkit-text-utils.h
automated-tests/src/dali-toolkit-internal/utc-Dali-BidirectionalSupport.cpp
automated-tests/src/dali-toolkit-internal/utc-Dali-LogicalModel.cpp
automated-tests/src/dali-toolkit-internal/utc-Dali-Text-CharacterSpacing.cpp [new file with mode: 0644]
automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Cursor.cpp
automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Hyphen-Wrapping.cpp
automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Layout.cpp
automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Shaping.cpp
automated-tests/src/dali-toolkit-internal/utc-Dali-VisualModel.cpp
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
dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h
dali-toolkit/devel-api/controls/text-controls/text-field-devel.h
dali-toolkit/devel-api/controls/text-controls/text-label-devel.h
dali-toolkit/devel-api/text/text-utils-devel.cpp
dali-toolkit/devel-api/visuals/text-visual-properties-devel.h
dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp
dali-toolkit/internal/controls/text-controls/text-editor-property-handler.cpp
dali-toolkit/internal/controls/text-controls/text-field-impl.cpp
dali-toolkit/internal/controls/text-controls/text-field-property-handler.cpp
dali-toolkit/internal/controls/text-controls/text-label-impl.cpp
dali-toolkit/internal/file.list
dali-toolkit/internal/text/cursor-helper-functions.cpp
dali-toolkit/internal/text/glyph-metrics-helper.cpp
dali-toolkit/internal/text/glyph-metrics-helper.h
dali-toolkit/internal/text/layouts/layout-engine-helper-functions.cpp [new file with mode: 0644]
dali-toolkit/internal/text/layouts/layout-engine-helper-functions.h [new file with mode: 0644]
dali-toolkit/internal/text/layouts/layout-engine.cpp
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-background-actor.cpp
dali-toolkit/internal/text/text-controller-background-actor.h
dali-toolkit/internal/text/text-controller-impl.cpp
dali-toolkit/internal/text/text-controller-impl.h
dali-toolkit/internal/text/text-controller.cpp
dali-toolkit/internal/text/text-controller.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-selection-handle-controller.cpp
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