editor.SetProperty(TextEditor::Property::HORIZONTAL_ALIGNMENT, "END");
DALI_TEST_EQUALS(editor.GetProperty<std::string>(TextEditor::Property::HORIZONTAL_ALIGNMENT), "END", TEST_LOCATION);
+ // Check that the Alignment properties can be correctly set
+ editor.SetProperty(DevelTextEditor::Property::VERTICAL_ALIGNMENT, "BOTTOM");
+ DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::VERTICAL_ALIGNMENT), "BOTTOM", TEST_LOCATION);
+ editor.SetProperty(DevelTextEditor::Property::VERTICAL_ALIGNMENT, "CENTER");
+ DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::VERTICAL_ALIGNMENT), "CENTER", TEST_LOCATION);
+ editor.SetProperty(DevelTextEditor::Property::VERTICAL_ALIGNMENT, "TOP");
+ DALI_TEST_EQUALS(editor.GetProperty<std::string>(DevelTextEditor::Property::VERTICAL_ALIGNMENT), "TOP", TEST_LOCATION);
+
// Check scroll properties.
editor.SetProperty(TextEditor::Property::SCROLL_THRESHOLD, 1.f);
DALI_TEST_EQUALS(editor.GetProperty<float>(TextEditor::Property::SCROLL_THRESHOLD), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
* @note If the value is less than 1, the lines could to be overlapped.
*/
RELATIVE_LINE_SIZE,
+
+ /**
+ * @brief The line vertical alignment.
+ * @details Name "verticalAlignment", type Property::STRING or type VerticalAlignment::Type (Property::INTEGER).
+ * Values "TOP", "CENTER", "BOTTOM", default TOP.
+ * @note Return type is Property::STRING
+ */
+ VERTICAL_ALIGNMENT,
};
} // namespace Property
DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextEditor, "inputStrikethrough", MAP, INPUT_STRIKETHROUGH )
DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextEditor, "characterSpacing", FLOAT, CHARACTER_SPACING )
DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextEditor, "relativeLineSize", FLOAT, RELATIVE_LINE_SIZE )
+DALI_DEVEL_PROPERTY_REGISTRATION(Toolkit, TextEditor, "verticalAlignment", STRING, VERTICAL_ALIGNMENT )
DALI_SIGNAL_REGISTRATION(Toolkit, TextEditor, "textChanged", SIGNAL_TEXT_CHANGED )
DALI_SIGNAL_REGISTRATION(Toolkit, TextEditor, "inputStyleChanged", SIGNAL_INPUT_STYLE_CHANGED )
}
break;
}
+ case Toolkit::DevelTextEditor::Property::VERTICAL_ALIGNMENT:
+ {
+ Toolkit::Text::VerticalAlignment::Type alignment(static_cast<Text::VerticalAlignment::Type>(-1)); // Set to invalid value to ensure a valid mode does get set
+ if(Text::GetVerticalAlignmentEnumeration(value, alignment))
+ {
+ impl.mController->SetVerticalAlignment(alignment);
+ DALI_LOG_INFO(gTextEditorLogFilter, Debug::General, "TextEditor %p VERTICAL_ALIGNMENT %d\n", impl.mController.Get(), alignment);
+ }
+ break;
+ }
case Toolkit::TextEditor::Property::SCROLL_THRESHOLD:
{
const float threshold = value.Get<float>();
}
break;
}
+ case Toolkit::DevelTextEditor::Property::VERTICAL_ALIGNMENT:
+ {
+ const char* name = Text::GetVerticalAlignmentString(impl.mController->GetVerticalAlignment());
+
+ if(name)
+ {
+ value = std::string(name);
+ }
+ break;
+ }
case Toolkit::TextEditor::Property::SCROLL_THRESHOLD:
{
value = impl.mDecorator->GetScrollThreshold();
}
}
+void UpdateCursorPositionForAlignment(Controller::Impl& impl, bool needFullAlignment)
+{
+ EventData* eventData = impl.mEventData;
+
+ // Set the flag to redo the alignment operation
+ impl.mOperationsPending = static_cast<Controller::OperationsMask>(impl.mOperationsPending | Controller::OperationsMask::ALIGN);
+
+ if(eventData)
+ {
+ // Note: mUpdateAlignment is currently only needed for horizontal alignment
+ eventData->mUpdateAlignment = needFullAlignment;
+
+ // Update the cursor if it's in editing mode
+ if(EventData::IsEditingState(eventData->mState))
+ {
+ impl.ChangeState(EventData::EDITING);
+ eventData->mUpdateCursorPosition = true;
+ }
+ }
+}
+
} // unnamed Namespace
EventData::EventData(DecoratorPtr decorator, InputMethodContext& inputMethodContext)
{
mModel->mScrollPosition.y = mModel->mVisualModel->mControlSize.height - positionEndY;
}
+ else if(mModel->mLogicalModel->mText.Count() == 0u)
+ {
+ Relayouter::CalculateVerticalOffset(*this, mModel->mVisualModel->mControlSize);
+ }
}
}
{
// Set the alignment.
mModel->mHorizontalAlignment = alignment;
-
- // Set the flag to redo the alignment operation.
- mOperationsPending = static_cast<OperationsMask>(mOperationsPending | ALIGN);
-
- if(mEventData)
- {
- mEventData->mUpdateAlignment = true;
-
- // Update the cursor if it's in editing mode
- if(EventData::IsEditingState(mEventData->mState))
- {
- ChangeState(EventData::EDITING);
- mEventData->mUpdateCursorPosition = true;
- }
- }
-
+ UpdateCursorPositionForAlignment(*this, true);
RequestRelayout();
}
}
{
// Set the alignment.
mModel->mVerticalAlignment = alignment;
- mOperationsPending = static_cast<OperationsMask>(mOperationsPending | ALIGN);
+ UpdateCursorPositionForAlignment(*this, false);
RequestRelayout();
}
}
if(!isEditable || !controller.IsMultiLineEnabled())
{
// After doing the text layout, the vertical offset to place the actor in the desired position can be calculated.
- CalculateVerticalOffset(controller, size);
+ CalculateVerticalOffset(impl, size);
+ }
+ else // TextEditor
+ {
+ // If layoutSize is bigger than size, vertical align has no meaning.
+ if(layoutSize.y < size.y)
+ {
+ CalculateVerticalOffset(impl, size);
+ if(impl.mEventData)
+ {
+ impl.mEventData->mScrollAfterDelete = false;
+ }
+ }
}
if(isEditable)
}
}
-void Controller::Relayouter::CalculateVerticalOffset(Controller& controller, const Size& controlSize)
+void Controller::Relayouter::CalculateVerticalOffset(Controller::Impl& impl, const Size& controlSize)
{
- Controller::Impl& impl = *controller.mImpl;
ModelPtr& model = impl.mModel;
VisualModelPtr& visualModel = model->mVisualModel;
Size layoutSize = model->mVisualModel->GetLayoutSize();
/**
* @brief Called by the Controller to calculate the veritcal offset give the control size.
*
- * @param[in] controller A reference to the controller class
+ * @param[in] impl A reference to the controller impl class
* @param[in] controlSize The control size
*/
- static void CalculateVerticalOffset(Controller& controller, const Size& controlSize);
+ static void CalculateVerticalOffset(Controller::Impl& impl, const Size& controlSize);
/**
* @brief Calculates the layout size of control according to @p requestedControllerSize and @p requestedOperationsMask