const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
+const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == DevelTextField::Property::PIXEL_SIZE );
DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == DevelTextField::Property::ENABLE_SELECTION );
DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == DevelTextField::Property::PLACEHOLDER );
+ DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == DevelTextField::Property::ELLIPSIS );
END_TEST;
}
placeholderPixelSizeMapSet["placeholderColor"] = Color::BLUE;
placeholderPixelSizeMapSet["placeholderFontFamily"] = "Arial";
placeholderPixelSizeMapSet["placeholderPixelSize"] = 15.0f;
+ placeholderPixelSizeMapSet["placeholderEllipsis"] = true;
placeholderFontstyleMap.Insert( "weight", "bold" );
placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
placeholderMapSet["placeholderColor"] = Color::RED;
placeholderMapSet["placeholderFontFamily"] = "Arial";
placeholderMapSet["placeholderPointSize"] = 12.0f;
+ placeholderMapSet["placeholderEllipsis"] = false;
// Check the placeholder font style property
placeholderFontstyleMap.Clear();
DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
+ // Check the ellipsis property
+ DALI_TEST_CHECK( !field.GetProperty<bool>( DevelTextField::Property::ELLIPSIS ) );
+ field.SetProperty( DevelTextField::Property::ELLIPSIS, true );
+ DALI_TEST_CHECK( field.GetProperty<bool>( DevelTextField::Property::ELLIPSIS ) );
+
END_TEST;
}
* propertyMap["placeholderColor"] = Color::RED;
* propertyMap["placeholderFontFamily"] = "Arial";
* propertyMap["placeholderPointSize"] = 12.0f;
+ * propertyMap["placeholderEllipsis"] = true;
*
* Property::Map fontStyleMap;
* fontStyleMap.Insert( "weight", "bold" );
*
* @details name "placeholder", type MAP
*/
- PLACEHOLDER = INPUT_OUTLINE + 4
+ PLACEHOLDER = INPUT_OUTLINE + 4,
+
+ /**
+ * @brief Enable or disable the ellipsis.
+ * @details name "ellipsis", type Property::BOOLEAN.
+ * @note PLACEHOLDER map is used to add ellipsis to placeholder text.
+ */
+ ELLIPSIS = INPUT_OUTLINE + 5
};
} // namespace Property
DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "pixelSize", FLOAT, PIXEL_SIZE )
DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "enableSelection", BOOLEAN, ENABLE_SELECTION )
DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "placeholder", MAP, PLACEHOLDER )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "ellipsis", BOOLEAN, ELLIPSIS )
DALI_SIGNAL_REGISTRATION( Toolkit, TextField, "textChanged", SIGNAL_TEXT_CHANGED )
DALI_SIGNAL_REGISTRATION( Toolkit, TextField, "maxLengthReached", SIGNAL_MAX_LENGTH_REACHED )
}
break;
}
+ case Toolkit::DevelTextField::Property::ELLIPSIS:
+ {
+ if( impl.mController )
+ {
+ const bool ellipsis = value.Get<bool>();
+ DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p ELLIPSIS %d\n", impl.mController.Get(), ellipsis );
+
+ impl.mController->SetTextElideEnabled( ellipsis );
+ }
+ break;
+ }
} // switch
} // textfield
}
value = map;
break;
}
+ case Toolkit::DevelTextField::Property::ELLIPSIS:
+ {
+ if( impl.mController )
+ {
+ value = impl.mController->IsTextElideEnabled();
+ }
+ break;
+ }
} //switch
}
mAllTextSelected( false ),
mUpdateInputStyle( false ),
mPasswordInput( false ),
- mIsPlaceholderPixelSize( false )
+ mIsPlaceholderPixelSize( false ),
+ mIsPlaceholderElideEnabled( false ),
+ mPlaceholderEllipsisFlag( false )
{
mImfManager = ImfManager::Get();
}
bool mPasswordInput : 1; ///< True if password input is enabled.
bool mCheckScrollAmount : 1; ///< Whether to check scrolled amount after updating the position
bool mIsPlaceholderPixelSize : 1; ///< True if the placeholder font size is set as pixel size.
+ bool mIsPlaceholderElideEnabled : 1; ///< True if the placeholder text's elide is enabled.
+ bool mPlaceholderEllipsisFlag : 1; ///< True if the text controller sets the placeholder ellipsis.
};
struct ModifyEvent
const char * const PLACEHOLDER_FONT_STYLE = "placeholderFontStyle";
const char * const PLACEHOLDER_POINT_SIZE = "placeholderPointSize";
const char * const PLACEHOLDER_PIXEL_SIZE = "placeholderPixelSize";
+const char * const PLACEHOLDER_ELLIPSIS = "placeholderEllipsis";
float ConvertToEven( float value )
{
return mImpl->mModel->mElideEnabled;
}
+void Controller::SetPlaceholderTextElideEnabled( bool enabled )
+{
+ mImpl->mEventData->mIsPlaceholderElideEnabled = enabled;
+ mImpl->mEventData->mPlaceholderEllipsisFlag = true;
+
+ // Update placeholder if there is no text
+ if( mImpl->IsShowingPlaceholderText() ||
+ ( 0u == mImpl->mModel->mLogicalModel->mText.Count() ) )
+ {
+ ShowPlaceholderText();
+ }
+}
+
+bool Controller::IsPlaceholderTextElideEnabled() const
+{
+ return mImpl->mEventData->mIsPlaceholderElideEnabled;
+}
+
void Controller::SetSelectionEnabled( bool enabled )
{
mImpl->mEventData->mSelectionEnabled = enabled;
SetPlaceholderTextFontSize( pixelSize, Text::Controller::PIXEL_SIZE );
}
}
+ else if( key == PLACEHOLDER_ELLIPSIS )
+ {
+ bool ellipsis;
+ value.Get( ellipsis );
+ SetPlaceholderTextElideEnabled( ellipsis );
+ }
}
}
{
map[ PLACEHOLDER_PIXEL_SIZE ] = GetPlaceholderTextFontSize( Text::Controller::PIXEL_SIZE );
}
+
+ if( mImpl->mEventData->mPlaceholderEllipsisFlag )
+ {
+ map[ PLACEHOLDER_ELLIPSIS ] = IsPlaceholderTextElideEnabled();
+ }
}
}
COLOR );
}
+ // Set the update info to elide the text.
+ if( mImpl->mModel->mElideEnabled ||
+ ( ( NULL != mImpl->mEventData ) && mImpl->mEventData->mIsPlaceholderElideEnabled ) )
+ {
+ // Update Text layout for applying elided
+ mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
+ ALIGN |
+ LAYOUT |
+ UPDATE_LAYOUT_SIZE |
+ REORDER );
+ mImpl->mTextUpdateInfo.mFullRelayoutNeeded = true;
+ mImpl->mTextUpdateInfo.mCharacterIndex = 0u;
+ }
+
// Make sure the model is up-to-date before layouting.
ProcessModifyEvents();
bool updated = mImpl->UpdateModel( mImpl->mOperationsPending );
layoutParameters.startLineIndex = mImpl->mTextUpdateInfo.mStartLineIndex;
layoutParameters.estimatedNumberOfLines = mImpl->mTextUpdateInfo.mEstimatedNumberOfLines;
+ // Update the ellipsis
+ bool elideTextEnabled = mImpl->mModel->mElideEnabled;
+
+ if( NULL != mImpl->mEventData )
+ {
+ if( mImpl->mEventData->mPlaceholderEllipsisFlag && mImpl->IsShowingPlaceholderText() )
+ {
+ elideTextEnabled = mImpl->mEventData->mIsPlaceholderElideEnabled;
+ }
+ else if( EventData::INACTIVE != mImpl->mEventData->mState )
+ {
+ // Disable ellipsis when editing
+ elideTextEnabled = false;
+ }
+
+ // Reset the scroll position in inactive state
+ if( elideTextEnabled && ( mImpl->mEventData->mState == EventData::INACTIVE ) )
+ {
+ ResetScrollPosition();
+ }
+ }
+
// Update the visual model.
Size newLayoutSize;
viewUpdated = mImpl->mLayoutEngine.LayoutText( layoutParameters,
glyphPositions,
mImpl->mModel->mVisualModel->mLines,
newLayoutSize,
- mImpl->mModel->mElideEnabled );
+ elideTextEnabled );
viewUpdated = viewUpdated || ( newLayoutSize != layoutSize );
bool IsTextElideEnabled() const;
/**
+ * @brief Enable or disable the placeholder text elide.
+ * @param enabled Whether to enable the placeholder text elide.
+ */
+ void SetPlaceholderTextElideEnabled( bool enabled );
+
+ /**
+ * @brief Whether the placeholder text elide property is enabled.
+ * @return True if the placeholder text elide property is enabled, false otherwise.
+ */
+ bool IsPlaceholderTextElideEnabled() const;
+
+ /**
* @brief Enable or disable the text selection.
* @param[in] enabled Whether to enable the text selection.
*/