const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
+const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == DevelTextEditor::Property::PLACEHOLDER_TEXT );
DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR );
DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == DevelTextEditor::Property::ENABLE_SELECTION );
+ DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == DevelTextEditor::Property::PLACEHOLDER );
END_TEST;
}
editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
+ // Check the enable selection property
editor.SetProperty( DevelTextEditor::Property::ENABLE_SELECTION, false );
DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
+ // Check the placeholder property with pixel size
+ Property::Map placeholderPixelSizeMapSet;
+ Property::Map placeholderPixelSizeMapGet;
+ Property::Map placeholderFontstyleMap;
+ placeholderPixelSizeMapSet["placeholderText"] = "Setting Placeholder Text";
+ placeholderPixelSizeMapSet["placeholderColor"] = Color::BLUE;
+ placeholderPixelSizeMapSet["placeholderFontFamily"] = "Arial";
+ placeholderPixelSizeMapSet["placeholderPixelSize"] = 15.0f;
+
+ placeholderFontstyleMap.Insert( "weight", "bold" );
+ placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
+ editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
+
+ placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>( DevelTextEditor::Property::PLACEHOLDER );
+ DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
+ DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
+
+ // Check the placeholder property with point size
+ Property::Map placeholderMapSet;
+ Property::Map placeholderMapGet;
+ placeholderMapSet["placeholderText"] = "Setting Placeholder Text";
+ placeholderMapSet["placeholderColor"] = Color::RED;
+ placeholderMapSet["placeholderFontFamily"] = "Arial";
+ placeholderMapSet["placeholderPointSize"] = 12.0f;
+
+ // Check the placeholder font style property
+ placeholderFontstyleMap.Clear();
+
+ placeholderFontstyleMap.Insert( "weight", "bold" );
+ placeholderFontstyleMap.Insert( "width", "condensed" );
+ placeholderFontstyleMap.Insert( "slant", "italic" );
+ placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
+ editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER, placeholderMapSet );
+
+ placeholderMapGet = editor.GetProperty<Property::Map>( DevelTextEditor::Property::PLACEHOLDER );
+ DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
+ DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
+
+ // Reset font style.
+ placeholderFontstyleMap.Clear();
+ placeholderFontstyleMap.Insert( "weight", "normal" );
+ placeholderFontstyleMap.Insert( "slant", "oblique" );
+ placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
+ editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER, placeholderMapSet );
+
+ placeholderMapGet = editor.GetProperty<Property::Map>( DevelTextEditor::Property::PLACEHOLDER );
+ DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
+ DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
+
+ placeholderFontstyleMap.Clear();
+ placeholderFontstyleMap.Insert( "slant", "roman" );
+ placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
+ editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER, placeholderMapSet );
+
+ placeholderMapGet = editor.GetProperty<Property::Map>( DevelTextEditor::Property::PLACEHOLDER );
+
+ placeholderFontstyleMap.Clear();
+ placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
+
+ editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER, placeholderMapSet );
+ placeholderMapGet = editor.GetProperty<Property::Map>( DevelTextEditor::Property::PLACEHOLDER );
+ DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
+ DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
+
END_TEST;
}
const char* const PROPERTY_NAME_HIDDEN_INPUT_SETTINGS = "hiddenInputSettings";
const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
+const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HIDDEN_INPUT_SETTINGS ) == DevelTextField::Property::HIDDEN_INPUT_SETTINGS );
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 );
END_TEST;
}
field.SetProperty( DevelTextField::Property::PIXEL_SIZE, 20.f );
DALI_TEST_EQUALS( field.GetProperty<float>( DevelTextField::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
+ // Check the enable selection property
field.SetProperty( DevelTextField::Property::ENABLE_SELECTION, false );
DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
+ // Check the placeholder property with pixel size
+ Property::Map placeholderPixelSizeMapSet;
+ Property::Map placeholderPixelSizeMapGet;
+ Property::Map placeholderFontstyleMap;
+ placeholderPixelSizeMapSet["placeholderText"] = "Setting Placeholder Text";
+ placeholderPixelSizeMapSet["placeholderColor"] = Color::BLUE;
+ placeholderPixelSizeMapSet["placeholderFontFamily"] = "Arial";
+ placeholderPixelSizeMapSet["placeholderPixelSize"] = 15.0f;
+
+ placeholderFontstyleMap.Insert( "weight", "bold" );
+ placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
+ field.SetProperty( DevelTextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
+
+ placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::PLACEHOLDER );
+ DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
+ DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
+
+ // Check the placeholder property with point size
+ Property::Map placeholderMapSet;
+ Property::Map placeholderMapGet;
+ placeholderMapSet["placeholderText"] = "Setting Placeholder Text";
+ placeholderMapSet["placeholderColor"] = Color::RED;
+ placeholderMapSet["placeholderFontFamily"] = "Arial";
+ placeholderMapSet["placeholderPointSize"] = 12.0f;
+
+ // Check the placeholder font style property
+ placeholderFontstyleMap.Clear();
+
+ placeholderFontstyleMap.Insert( "weight", "bold" );
+ placeholderFontstyleMap.Insert( "width", "condensed" );
+ placeholderFontstyleMap.Insert( "slant", "italic" );
+ placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
+ field.SetProperty( DevelTextField::Property::PLACEHOLDER, placeholderMapSet );
+
+ placeholderMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::PLACEHOLDER );
+ DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
+ DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
+
+ // Reset font style.
+ placeholderFontstyleMap.Clear();
+ placeholderFontstyleMap.Insert( "weight", "normal" );
+ placeholderFontstyleMap.Insert( "slant", "oblique" );
+ placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
+ field.SetProperty( DevelTextField::Property::PLACEHOLDER, placeholderMapSet );
+
+ placeholderMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::PLACEHOLDER );
+ DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
+ DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
+
+ placeholderFontstyleMap.Clear();
+ placeholderFontstyleMap.Insert( "slant", "roman" );
+ placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
+ field.SetProperty( DevelTextField::Property::PLACEHOLDER, placeholderMapSet );
+
+ placeholderMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::PLACEHOLDER );
+
+ placeholderFontstyleMap.Clear();
+ placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
+
+ field.SetProperty( DevelTextField::Property::PLACEHOLDER, placeholderMapSet );
+ placeholderMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::PLACEHOLDER );
+ DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
+ DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
+
END_TEST;
}
* @brief Enables Text selection, such as the cursor, handle, clipboard, and highlight color.
* @details name "enableSelection", type bool
*/
- ENABLE_SELECTION
+ ENABLE_SELECTION,
+
+ /**
+ * @brief Sets the placeholder : text, color, font family, font style, point size, and pixel size.
+ *
+ * @code
+ * Property::Map propertyMap;
+ * propertyMap["placeholderText"] = "Setting Placeholder Text";
+ * propertyMap["placeholderColor"] = Color::RED;
+ * propertyMap["placeholderFontFamily"] = "Arial";
+ * propertyMap["placeholderPointSize"] = 12.0f;
+ *
+ * Property::Map fontStyleMap;
+ * fontstyleMap.Insert( "weight", "bold" );
+ * fontstyleMap.Insert( "width", "condensed" );
+ * fontstyleMap.Insert( "slant", "italic" );
+ * propertyMap["placeholderFontStyle"] = fontStyleMap;
+ *
+ * editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER, propertyMap );
+ * @endcode
+ *
+ * @details name "placeholder", type MAP
+ */
+ PLACEHOLDER
};
} // namespace Property
* @brief Enables Text selection, such as the cursor, handle, clipboard, and highlight color.
* @details name "enableSelection", type bool
*/
- ENABLE_SELECTION = INPUT_OUTLINE + 3
+ ENABLE_SELECTION = INPUT_OUTLINE + 3,
+
+ /**
+ * @brief Sets the placeholder : text, color, font family, font style, point size, and pixel size.
+ *
+ * @code
+ * Property::Map propertyMap;
+ * propertyMap["placeholderText"] = "Setting Placeholder Text";
+ * propertyMap["placeholderColor"] = Color::RED;
+ * propertyMap["placeholderFontFamily"] = "Arial";
+ * propertyMap["placeholderPointSize"] = 12.0f;
+ *
+ * Property::Map fontStyleMap;
+ * fontstyleMap.Insert( "weight", "bold" );
+ * fontstyleMap.Insert( "width", "condensed" );
+ * fontstyleMap.Insert( "slant", "italic" );
+ * propertyMap["placeholderFontStyle"] = fontStyleMap;
+ *
+ * field.SetProperty( DevelTextField::Property::PLACEHOLDER, propertyMap );
+ * @endcode
+ *
+ * @details name "placeholder", type MAP
+ */
+ PLACEHOLDER = INPUT_OUTLINE + 4
};
} // namespace Property
DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "placeholderText", STRING, PLACEHOLDER_TEXT )
DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "placeholderTextColor", VECTOR4, PLACEHOLDER_TEXT_COLOR )
DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "enableSelection", BOOLEAN, ENABLE_SELECTION )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "placeholder", MAP, PLACEHOLDER )
DALI_SIGNAL_REGISTRATION( Toolkit, TextEditor, "textChanged", SIGNAL_TEXT_CHANGED )
DALI_SIGNAL_REGISTRATION( Toolkit, TextEditor, "inputStyleChanged", SIGNAL_INPUT_STYLE_CHANGED )
}
break;
}
+ case Toolkit::DevelTextEditor::Property::PLACEHOLDER:
+ {
+ const Property::Map* map = value.GetMap();
+ if( map )
+ {
+ impl.mController->SetPlaceholderProperty( *map );
+ }
+ break;
+ }
} // switch
} // texteditor
}
}
break;
}
+ case Toolkit::DevelTextEditor::Property::PLACEHOLDER:
+ {
+ Property::Map map;
+ impl.mController->GetPlaceholderProperty( map );
+ value = map;
+ break;
+ }
} //switch
}
DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "hiddenInputSettings", MAP, HIDDEN_INPUT_SETTINGS )
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_SIGNAL_REGISTRATION( Toolkit, TextField, "textChanged", SIGNAL_TEXT_CHANGED )
DALI_SIGNAL_REGISTRATION( Toolkit, TextField, "maxLengthReached", SIGNAL_MAX_LENGTH_REACHED )
}
break;
}
+ case Toolkit::DevelTextField::Property::PLACEHOLDER:
+ {
+ const Property::Map* map = value.GetMap();
+ if( map )
+ {
+ impl.mController->SetPlaceholderProperty( *map );
+ }
+ break;
+ }
} // switch
} // textfield
}
}
break;
}
+ case Toolkit::DevelTextField::Property::PLACEHOLDER:
+ {
+ Property::Map map;
+ impl.mController->GetPlaceholderProperty( map );
+ value = map;
+ break;
+ }
} //switch
}
EventData::EventData( DecoratorPtr decorator )
: mDecorator( decorator ),
mImfManager(),
+ mPlaceholderFont( NULL ),
mPlaceholderText(),
mPlaceholderTextActive(),
mPlaceholderTextInactive(),
mScrollAfterDelete( false ),
mAllTextSelected( false ),
mUpdateInputStyle( false ),
- mPasswordInput( false )
+ mPasswordInput( false ),
+ mIsPlaceholderPixelSize( false )
{
mImfManager = ImfManager::Get();
}
// Get the default font's description.
TextAbstraction::FontDescription defaultFontDescription;
TextAbstraction::PointSize26Dot6 defaultPointSize = TextAbstraction::FontClient::DEFAULT_POINT_SIZE;
- if( NULL != mFontDefaults )
+
+ if( IsShowingPlaceholderText() && ( NULL != mEventData->mPlaceholderFont ) )
+ {
+ // If the placeholder font is set specifically, only placeholder font is changed.
+ defaultFontDescription = mEventData->mPlaceholderFont->mFontDescription;
+ if( mEventData->mPlaceholderFont->sizeDefined )
+ {
+ defaultPointSize = mEventData->mPlaceholderFont->mDefaultPointSize * 64u;
+ }
+ }
+ else if( NULL != mFontDefaults )
{
+ // Set the normal font and the placeholder font.
defaultFontDescription = mFontDefaults->mFontDescription;
defaultPointSize = mFontDefaults->mDefaultPointSize * 64u;
}
//Forward declarations
struct CursorInfo;
+struct FontDefaults;
struct Event
{
DecoratorPtr mDecorator; ///< Pointer to the decorator.
ImfManager mImfManager; ///< The Input Method Framework Manager.
+ FontDefaults* mPlaceholderFont; ///< The placeholder default font.
std::string mPlaceholderText; ///< The text to display when the TextField is empty.
std::string mPlaceholderTextActive; ///< The text to display when the TextField is empty with key-input focus.
std::string mPlaceholderTextInactive; ///< The text to display when the TextField is empty and inactive.
bool mUpdateInputStyle : 1; ///< Whether to update the input style after moving the cursor.
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.
};
struct ModifyEvent
#include <dali-toolkit/internal/text/character-set-conversion.h>
#include <dali-toolkit/internal/text/layouts/layout-parameters.h>
#include <dali-toolkit/internal/text/markup-processor.h>
+#include <dali-toolkit/internal/text/multi-language-support.h>
#include <dali-toolkit/internal/text/text-controller-impl.h>
#include <dali-toolkit/internal/text/text-editable-control-interface.h>
+#include <dali-toolkit/internal/text/text-font-style.h>
namespace
{
const std::string EMPTY_STRING("");
+const char * const PLACEHOLDER_TEXT = "placeholderText";
+const char * const PLACEHOLDER_COLOR = "placeholderColor";
+const char * const PLACEHOLDER_FONT_FAMILY = "placeholderFontFamily";
+const char * const PLACEHOLDER_FONT_STYLE = "placeholderFontStyle";
+const char * const PLACEHOLDER_POINT_SIZE = "placeholderPointSize";
+const char * const PLACEHOLDER_PIXEL_SIZE = "placeholderPixelSize";
+
float ConvertToEven( float value )
{
int intValue(static_cast<int>( value ));
return EMPTY_STRING;
}
+void Controller::SetPlaceholderFontFamily( const std::string& placeholderTextFontFamily )
+{
+ if( NULL != mImpl->mEventData )
+ {
+ if( NULL == mImpl->mEventData->mPlaceholderFont )
+ {
+ mImpl->mEventData->mPlaceholderFont = new FontDefaults();
+ }
+
+ mImpl->mEventData->mPlaceholderFont->mFontDescription.family = placeholderTextFontFamily;
+ DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::SetPlaceholderFontFamily %s\n", placeholderTextFontFamily.c_str());
+ mImpl->mEventData->mPlaceholderFont->familyDefined = !placeholderTextFontFamily.empty();
+
+ mImpl->RequestRelayout();
+ }
+}
+
+const std::string& Controller::GetPlaceholderFontFamily() const
+{
+ if( ( NULL != mImpl->mEventData ) && ( NULL != mImpl->mEventData->mPlaceholderFont ) )
+ {
+ return mImpl->mEventData->mPlaceholderFont->mFontDescription.family;
+ }
+
+ return EMPTY_STRING;
+}
+
void Controller::SetDefaultFontWeight( FontWeight weight )
{
if( NULL == mImpl->mFontDefaults )
return TextAbstraction::FontWeight::NORMAL;
}
+void Controller::SetPlaceholderTextFontWeight( FontWeight weight )
+{
+ if( NULL != mImpl->mEventData )
+ {
+ if( NULL == mImpl->mEventData->mPlaceholderFont )
+ {
+ mImpl->mEventData->mPlaceholderFont = new FontDefaults();
+ }
+
+ mImpl->mEventData->mPlaceholderFont->mFontDescription.weight = weight;
+ mImpl->mEventData->mPlaceholderFont->weightDefined = true;
+
+ mImpl->RequestRelayout();
+ }
+}
+
+bool Controller::IsPlaceholderTextFontWeightDefined() const
+{
+ if( ( NULL != mImpl->mEventData ) && ( NULL != mImpl->mEventData->mPlaceholderFont ) )
+ {
+ return mImpl->mEventData->mPlaceholderFont->weightDefined;
+ }
+ return false;
+}
+
+FontWeight Controller::GetPlaceholderTextFontWeight() const
+{
+ if( ( NULL != mImpl->mEventData ) && ( NULL != mImpl->mEventData->mPlaceholderFont ) )
+ {
+ return mImpl->mEventData->mPlaceholderFont->mFontDescription.weight;
+ }
+
+ return TextAbstraction::FontWeight::NORMAL;
+}
+
void Controller::SetDefaultFontWidth( FontWidth width )
{
if( NULL == mImpl->mFontDefaults )
return TextAbstraction::FontWidth::NORMAL;
}
+void Controller::SetPlaceholderTextFontWidth( FontWidth width )
+{
+ if( NULL != mImpl->mEventData )
+ {
+ if( NULL == mImpl->mEventData->mPlaceholderFont )
+ {
+ mImpl->mEventData->mPlaceholderFont = new FontDefaults();
+ }
+
+ mImpl->mEventData->mPlaceholderFont->mFontDescription.width = width;
+ mImpl->mEventData->mPlaceholderFont->widthDefined = true;
+
+ mImpl->RequestRelayout();
+ }
+}
+
+bool Controller::IsPlaceholderTextFontWidthDefined() const
+{
+ if( ( NULL != mImpl->mEventData ) && ( NULL != mImpl->mEventData->mPlaceholderFont ) )
+ {
+ return mImpl->mEventData->mPlaceholderFont->widthDefined;
+ }
+ return false;
+}
+
+FontWidth Controller::GetPlaceholderTextFontWidth() const
+{
+ if( ( NULL != mImpl->mEventData ) && ( NULL != mImpl->mEventData->mPlaceholderFont ) )
+ {
+ return mImpl->mEventData->mPlaceholderFont->mFontDescription.width;
+ }
+
+ return TextAbstraction::FontWidth::NORMAL;
+}
+
void Controller::SetDefaultFontSlant( FontSlant slant )
{
if( NULL == mImpl->mFontDefaults )
return TextAbstraction::FontSlant::NORMAL;
}
+void Controller::SetPlaceholderTextFontSlant( FontSlant slant )
+{
+ if( NULL != mImpl->mEventData )
+ {
+ if( NULL == mImpl->mEventData->mPlaceholderFont )
+ {
+ mImpl->mEventData->mPlaceholderFont = new FontDefaults();
+ }
+
+ mImpl->mEventData->mPlaceholderFont->mFontDescription.slant = slant;
+ mImpl->mEventData->mPlaceholderFont->slantDefined = true;
+
+ mImpl->RequestRelayout();
+ }
+}
+
+bool Controller::IsPlaceholderTextFontSlantDefined() const
+{
+ if( ( NULL != mImpl->mEventData ) && ( NULL != mImpl->mEventData->mPlaceholderFont ) )
+ {
+ return mImpl->mEventData->mPlaceholderFont->slantDefined;
+ }
+ return false;
+}
+
+FontSlant Controller::GetPlaceholderTextFontSlant() const
+{
+ if( ( NULL != mImpl->mEventData ) && ( NULL != mImpl->mEventData->mPlaceholderFont ) )
+ {
+ return mImpl->mEventData->mPlaceholderFont->mFontDescription.slant;
+ }
+
+ return TextAbstraction::FontSlant::NORMAL;
+}
+
void Controller::SetDefaultFontSize( float fontSize, FontSizeType type )
{
if( NULL == mImpl->mFontDefaults )
}
case PIXEL_SIZE:
{
- // Point size = Pixel size * 72 / DPI
+ // Point size = Pixel size * 72.f / DPI
unsigned int horizontalDpi = 0u;
unsigned int verticalDpi = 0u;
TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
fontClient.GetDpi( horizontalDpi, verticalDpi );
- mImpl->mFontDefaults->mDefaultPointSize = ( fontSize * 72 ) / horizontalDpi;
+ mImpl->mFontDefaults->mDefaultPointSize = ( fontSize * 72.f ) / static_cast< float >( horizontalDpi );
mImpl->mFontDefaults->sizeDefined = true;
break;
}
- default:
- {
- DALI_ASSERT_ALWAYS( false );
- }
}
// Clear the font-specific data
}
case PIXEL_SIZE:
{
- // Pixel size = Point size * DPI / 72
+ // Pixel size = Point size * DPI / 72.f
+ unsigned int horizontalDpi = 0u;
+ unsigned int verticalDpi = 0u;
+ TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
+ fontClient.GetDpi( horizontalDpi, verticalDpi );
+
+ value = mImpl->mFontDefaults->mDefaultPointSize * static_cast< float >( horizontalDpi ) / 72.f;
+ break;
+ }
+ }
+ return value;
+ }
+
+ return value;
+}
+
+void Controller::SetPlaceholderTextFontSize( float fontSize, FontSizeType type )
+{
+ if( NULL != mImpl->mEventData )
+ {
+ if( NULL == mImpl->mEventData->mPlaceholderFont )
+ {
+ mImpl->mEventData->mPlaceholderFont = new FontDefaults();
+ }
+
+ switch( type )
+ {
+ case POINT_SIZE:
+ {
+ mImpl->mEventData->mPlaceholderFont->mDefaultPointSize = fontSize;
+ mImpl->mEventData->mPlaceholderFont->sizeDefined = true;
+ mImpl->mEventData->mIsPlaceholderPixelSize = false; // Font size flag
+ break;
+ }
+ case PIXEL_SIZE:
+ {
+ // Point size = Pixel size * 72.f / DPI
unsigned int horizontalDpi = 0u;
unsigned int verticalDpi = 0u;
TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
fontClient.GetDpi( horizontalDpi, verticalDpi );
- value = mImpl->mFontDefaults->mDefaultPointSize * horizontalDpi / 72;
+ mImpl->mEventData->mPlaceholderFont->mDefaultPointSize = ( fontSize * 72.f ) / static_cast< float >( horizontalDpi );
+ mImpl->mEventData->mPlaceholderFont->sizeDefined = true;
+ mImpl->mEventData->mIsPlaceholderPixelSize = true; // Font size flag
+ break;
+ }
+ }
+
+ mImpl->RequestRelayout();
+ }
+}
+
+float Controller::GetPlaceholderTextFontSize( FontSizeType type ) const
+{
+ float value = 0.0f;
+ if( NULL != mImpl->mEventData )
+ {
+ switch( type )
+ {
+ case POINT_SIZE:
+ {
+ if( NULL != mImpl->mEventData->mPlaceholderFont )
+ {
+ value = mImpl->mEventData->mPlaceholderFont->mDefaultPointSize;
+ }
+ else
+ {
+ // If the placeholder text font size is not set, then return the default font size.
+ value = GetDefaultFontSize( POINT_SIZE );
+ }
break;
}
- default:
+ case PIXEL_SIZE:
{
- DALI_ASSERT_ALWAYS( false );
+ if( NULL != mImpl->mEventData->mPlaceholderFont )
+ {
+ // Pixel size = Point size * DPI / 72.f
+ unsigned int horizontalDpi = 0u;
+ unsigned int verticalDpi = 0u;
+ TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
+ fontClient.GetDpi( horizontalDpi, verticalDpi );
+
+ value = mImpl->mEventData->mPlaceholderFont->mDefaultPointSize * static_cast< float >( horizontalDpi ) / 72.f;
+ }
+ else
+ {
+ // If the placeholder text font size is not set, then return the default font size.
+ value = GetDefaultFontSize( PIXEL_SIZE );
+ }
+ break;
}
}
return value;
}
}
+void Controller::SetPlaceholderProperty( const Property::Map& map )
+{
+ const Property::Map::SizeType count = map.Count();
+
+ for( Property::Map::SizeType position = 0; position < count; ++position )
+ {
+ KeyValuePair keyValue = map.GetKeyValue( position );
+ Property::Key& key = keyValue.first;
+ Property::Value& value = keyValue.second;
+
+ if( key == PLACEHOLDER_TEXT )
+ {
+ std::string text = "";
+ value.Get( text );
+ SetPlaceholderText( text );
+ }
+ else if( key == PLACEHOLDER_COLOR )
+ {
+ Vector4 textColor;
+ value.Get( textColor );
+ if( GetPlaceholderTextColor() != textColor )
+ {
+ SetPlaceholderTextColor( textColor );
+ }
+ }
+ else if( key == PLACEHOLDER_FONT_FAMILY )
+ {
+ std::string fontFamily = "";
+ value.Get( fontFamily );
+ SetPlaceholderFontFamily( fontFamily );
+ }
+ else if( key == PLACEHOLDER_FONT_STYLE )
+ {
+ SetFontStyleProperty( this, value, Text::FontStyle::PLACEHOLDER );
+ }
+ else if( key == PLACEHOLDER_POINT_SIZE )
+ {
+ float pointSize;
+ value.Get( pointSize );
+ if( !Equals( GetPlaceholderTextFontSize( Text::Controller::POINT_SIZE ), pointSize ) )
+ {
+ SetPlaceholderTextFontSize( pointSize, Text::Controller::POINT_SIZE );
+ }
+ }
+ else if( key == PLACEHOLDER_PIXEL_SIZE )
+ {
+ float pixelSize;
+ value.Get( pixelSize );
+ if( !Equals( GetPlaceholderTextFontSize( Text::Controller::PIXEL_SIZE ), pixelSize ) )
+ {
+ SetPlaceholderTextFontSize( pixelSize, Text::Controller::PIXEL_SIZE );
+ }
+ }
+ }
+}
+
+void Controller::GetPlaceholderProperty( Property::Map& map )
+{
+ if( NULL != mImpl->mEventData )
+ {
+ map[ PLACEHOLDER_TEXT ] = mImpl->mEventData->mPlaceholderText;
+ map[ PLACEHOLDER_COLOR ] = mImpl->mEventData->mPlaceholderTextColor;
+ map[ PLACEHOLDER_FONT_FAMILY ] = GetPlaceholderFontFamily();
+
+ Property::Value fontStyleMapGet;
+ GetFontStyleProperty( this, fontStyleMapGet, Text::FontStyle::PLACEHOLDER );
+ map[ PLACEHOLDER_FONT_STYLE ] = fontStyleMapGet;
+
+ // Choose font size : POINT_SIZE or PIXEL_SIZE
+ if( !mImpl->mEventData->mIsPlaceholderPixelSize )
+ {
+ map[ PLACEHOLDER_POINT_SIZE ] = GetPlaceholderTextFontSize( Text::Controller::POINT_SIZE );
+ }
+ else
+ {
+ map[ PLACEHOLDER_PIXEL_SIZE ] = GetPlaceholderTextFontSize( Text::Controller::PIXEL_SIZE );
+ }
+ }
+}
+
// public : Relayout.
Controller::UpdateTextType Controller::Relayout( const Size& size )
*/
const std::string& GetDefaultFontFamily() const;
+ /**
+ * @brief Sets the placeholder text font family.
+ * @param[in] placeholderTextFontFamily The placeholder text font family.
+ */
+ void SetPlaceholderFontFamily( const std::string& placeholderTextFontFamily );
+
+ /**
+ * @brief Retrieves the placeholder text font family.
+ *
+ * @return The placeholder text font family
+ */
+ const std::string& GetPlaceholderFontFamily() const;
+
/**
* @brief Sets the default font weight.
*
*/
FontWeight GetDefaultFontWeight() const;
+ /**
+ * @brief Sets the placeholder text font weight.
+ *
+ * @param[in] weight The font weight
+ */
+ void SetPlaceholderTextFontWeight( FontWeight weight );
+
+ /**
+ * @brief Whether the font's weight has been defined.
+ *
+ * @return True if the placeholder text font weight is defined
+ */
+ bool IsPlaceholderTextFontWeightDefined() const;
+
+ /**
+ * @brief Retrieves the placeholder text font weight.
+ *
+ * @return The placeholder text font weight
+ */
+ FontWeight GetPlaceholderTextFontWeight() const;
+
/**
* @brief Sets the default font width.
*
*/
FontWidth GetDefaultFontWidth() const;
+ /**
+ * @brief Sets the placeholder text font width.
+ *
+ * @param[in] width The font width
+ */
+ void SetPlaceholderTextFontWidth( FontWidth width );
+
+ /**
+ * @brief Whether the font's width has been defined.
+ *
+ * @return True if the placeholder text font width is defined
+ */
+ bool IsPlaceholderTextFontWidthDefined() const;
+
+ /**
+ * @brief Retrieves the placeholder text font width.
+ *
+ * @return The placeholder text font width
+ */
+ FontWidth GetPlaceholderTextFontWidth() const;
+
/**
* @brief Sets the default font slant.
*
*/
FontSlant GetDefaultFontSlant() const;
+ /**
+ * @brief Sets the placeholder text font slant.
+ *
+ * @param[in] slant The font slant
+ */
+ void SetPlaceholderTextFontSlant( FontSlant slant );
+
+ /**
+ * @brief Whether the font's slant has been defined.
+ *
+ * @return True if the placeholder text font slant is defined
+ */
+ bool IsPlaceholderTextFontSlantDefined() const;
+
+ /**
+ * @brief Retrieves the placeholder text font slant.
+ *
+ * @return The placeholder text font slant
+ */
+ FontSlant GetPlaceholderTextFontSlant() const;
+
/**
* @brief Set the default font size.
*
- * @param[in] size The default font size.
+ * @param[in] fontSize The default font size
* @param[in] type The font size type is point size or pixel size
*/
void SetDefaultFontSize( float fontSize, FontSizeType type );
*/
float GetDefaultFontSize( FontSizeType type ) const;
+ /**
+ * @brief Sets the Placeholder text font size.
+ * @param[in] fontSize The placeholder text font size
+ * @param[in] type The font size type is point size or pixel size
+ */
+ void SetPlaceholderTextFontSize( float fontSize, FontSizeType type );
+
+ /**
+ * @brief Retrieves the Placeholder text font size.
+ * @param[in] type The font size type
+ * @return The placeholder font size
+ */
+ float GetPlaceholderTextFontSize( FontSizeType type ) const;
+
/**
* @brief Sets the text's default color.
*
*/
void GetHiddenInputOption( Property::Map& options );
+ /**
+ * @brief Sets the Placeholder Properties.
+ *
+ * @param[in] map The placeholder property map
+ */
+ void SetPlaceholderProperty( const Property::Map& map );
+
+ /**
+ * @brief Retrieves the Placeholder Property map.
+ *
+ * @param[out] map The property map
+ */
+ void GetPlaceholderProperty( Property::Map& map );
+
public: // Relayout.
/**
}
break;
}
+ case FontStyle::PLACEHOLDER:
+ {
+ // Sets the placeholder text font's style values.
+ if( !weightDefined ||
+ ( weightDefined && ( controller->GetPlaceholderTextFontWeight() != weight ) ) )
+ {
+ controller->SetPlaceholderTextFontWeight( weight );
+ }
+
+ if( !widthDefined ||
+ ( widthDefined && ( controller->GetPlaceholderTextFontWidth() != width ) ) )
+ {
+ controller->SetPlaceholderTextFontWidth( width );
+ }
+
+ if( !slantDefined ||
+ ( slantDefined && ( controller->GetPlaceholderTextFontSlant() != slant ) ) )
+ {
+ controller->SetPlaceholderTextFontSlant( slant );
+ }
+ break;
+ }
} // switch
} // map not empty
else
controller->SetInputFontSlant( TextAbstraction::FontSlant::NONE );
break;
}
+ case FontStyle::PLACEHOLDER:
+ {
+ controller->SetPlaceholderTextFontWeight( TextAbstraction::FontWeight::NONE );
+ controller->SetPlaceholderTextFontWidth( TextAbstraction::FontWidth::NONE );
+ controller->SetPlaceholderTextFontSlant( TextAbstraction::FontSlant::NONE );
+ break;
+ }
} // switch
} // map.Empty()
} // controller
{
if( controller )
{
- const bool isDefaultStyle = FontStyle::DEFAULT == type;
const bool isSetbyString = controller->IsFontStyleSetByString();
bool weightDefined = false;
FontWidth width = TextAbstraction::FontWidth::NONE;
FontSlant slant = TextAbstraction::FontSlant::NONE;
- if( isDefaultStyle )
+ switch( type )
{
- weightDefined = controller->IsDefaultFontWeightDefined();
- widthDefined = controller->IsDefaultFontWidthDefined();
- slantDefined = controller->IsDefaultFontSlantDefined();
-
- if( weightDefined )
+ case FontStyle::DEFAULT:
{
- weight = controller->GetDefaultFontWeight();
- }
+ weightDefined = controller->IsDefaultFontWeightDefined();
+ widthDefined = controller->IsDefaultFontWidthDefined();
+ slantDefined = controller->IsDefaultFontSlantDefined();
- if( widthDefined )
- {
- width = controller->GetDefaultFontWidth();
- }
+ if( weightDefined )
+ {
+ weight = controller->GetDefaultFontWeight();
+ }
- if( slantDefined )
- {
- slant = controller->GetDefaultFontSlant();
- }
- }
- else
- {
- weightDefined = controller->IsInputFontWeightDefined();
- widthDefined = controller->IsInputFontWidthDefined();
- slantDefined = controller->IsInputFontSlantDefined();
+ if( widthDefined )
+ {
+ width = controller->GetDefaultFontWidth();
+ }
- if( weightDefined )
- {
- weight = controller->GetInputFontWeight();
+ if( slantDefined )
+ {
+ slant = controller->GetDefaultFontSlant();
+ }
+ break;
}
-
- if( widthDefined )
+ case FontStyle::INPUT:
{
- width = controller->GetInputFontWidth();
- }
+ weightDefined = controller->IsInputFontWeightDefined();
+ widthDefined = controller->IsInputFontWidthDefined();
+ slantDefined = controller->IsInputFontSlantDefined();
- if( slantDefined )
+ if( weightDefined )
+ {
+ weight = controller->GetInputFontWeight();
+ }
+
+ if( widthDefined )
+ {
+ width = controller->GetInputFontWidth();
+ }
+
+ if( slantDefined )
+ {
+ slant = controller->GetInputFontSlant();
+ }
+ break;
+ }
+ case FontStyle::PLACEHOLDER:
{
- slant = controller->GetInputFontSlant();
+ // The type is FontStyle::PLACEHOLDER
+ weightDefined = controller->IsPlaceholderTextFontWeightDefined();
+ widthDefined = controller->IsPlaceholderTextFontWidthDefined();
+ slantDefined = controller->IsPlaceholderTextFontSlantDefined();
+
+ if( weightDefined )
+ {
+ weight = controller->GetPlaceholderTextFontWeight();
+ }
+
+ if( widthDefined )
+ {
+ width = controller->GetPlaceholderTextFontWidth();
+ }
+
+ if( slantDefined )
+ {
+ slant = controller->GetPlaceholderTextFontSlant();
+ }
+ break;
}
}
{
enum Type
{
- DEFAULT, ///< The default font's style.
- INPUT ///< The input font's style.
+ DEFAULT, ///< The default font's style.
+ INPUT, ///< The input font's style.
+ PLACEHOLDER ///< The placeholder text font's style.
};
};
*
* @param[in] controller The text's controller.
* @param[in] value The value of the font's style.
- * @param[in] type Whether the property is for the default font's style or the input font's style.
+ * @param[in] type Whether the property is for the default font's style, the input font's style or the placeholder font's style.
*
*/
void SetFontStyleProperty( ControllerPtr controller, const Property::Value& value, FontStyle::Type type );
*
* @param[in] controller The text's controller.
* @param[out] value The value of the font's style.
- * @param[in] type Whether the property is for the default font's style or the input font's style.
+ * @param[in] type Whether the property is for the default font's style, the input font's style or the placeholder font's style.
*/
void GetFontStyleProperty( ControllerPtr controller, Property::Value& value, FontStyle::Type type );