/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/controls/text-controls/placeholder-properties.h>
+#include <dali-toolkit/internal/text/character-set-conversion.h>
#include <dali-toolkit/internal/text/text-controller-impl.h>
#include <dali-toolkit/internal/text/text-font-style.h>
+#include <dali-toolkit/public-api/controls/text-controls/placeholder-properties.h>
namespace
{
-
#if defined(DEBUG_ENABLED)
Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, true, "LOG_TEXT_CONTROLS");
#endif
const std::string EMPTY_STRING("");
-const char * const PLACEHOLDER_TEXT = "text";
-const char * const PLACEHOLDER_TEXT_FOCUSED = "textFocused";
-const char * const PLACEHOLDER_COLOR = "color";
-const char * const PLACEHOLDER_FONT_FAMILY = "fontFamily";
-const char * const PLACEHOLDER_FONT_STYLE = "fontStyle";
-const char * const PLACEHOLDER_POINT_SIZE = "pointSize";
-const char * const PLACEHOLDER_PIXEL_SIZE = "pixelSize";
-const char * const PLACEHOLDER_ELLIPSIS = "ellipsis";
+const char* const PLACEHOLDER_TEXT = "text";
+const char* const PLACEHOLDER_TEXT_FOCUSED = "textFocused";
+const char* const PLACEHOLDER_COLOR = "color";
+const char* const PLACEHOLDER_FONT_FAMILY = "fontFamily";
+const char* const PLACEHOLDER_FONT_STYLE = "fontStyle";
+const char* const PLACEHOLDER_POINT_SIZE = "pointSize";
+const char* const PLACEHOLDER_PIXEL_SIZE = "pixelSize";
+const char* const PLACEHOLDER_ELLIPSIS = "ellipsis";
} // namespace
namespace Dali
{
-
namespace Toolkit
{
-
namespace Text
{
-
void Controller::PlaceholderHandler::SetPlaceholderTextElideEnabled(Controller& controller, bool enabled)
{
controller.mImpl->mEventData->mIsPlaceholderElideEnabled = enabled;
- controller.mImpl->mEventData->mPlaceholderEllipsisFlag = true;
+ controller.mImpl->mEventData->mPlaceholderEllipsisFlag = true;
// Update placeholder if there is no text
- if( controller.mImpl->IsShowingPlaceholderText() ||
- ( 0u == controller.mImpl->mModel->mLogicalModel->mText.Count() ) )
+ if(controller.mImpl->IsShowingPlaceholderText() ||
+ (0u == controller.mImpl->mModel->mLogicalModel->mText.Count()))
{
controller.ShowPlaceholderText();
}
void Controller::PlaceholderHandler::SetPlaceholderText(Controller& controller, PlaceholderType type, const std::string& text)
{
- if( NULL != controller.mImpl->mEventData )
+ if(NULL != controller.mImpl->mEventData)
{
- if( PLACEHOLDER_TYPE_INACTIVE == type )
+ if(PLACEHOLDER_TYPE_INACTIVE == type)
{
controller.mImpl->mEventData->mPlaceholderTextInactive = text;
}
}
// Update placeholder if there is no text
- if( controller.mImpl->IsShowingPlaceholderText() ||
- ( 0u == controller.mImpl->mModel->mLogicalModel->mText.Count() ) )
+ if(controller.mImpl->IsShowingPlaceholderText() ||
+ (0u == controller.mImpl->mModel->mLogicalModel->mText.Count()))
{
controller.ShowPlaceholderText();
}
void Controller::PlaceholderHandler::GetPlaceholderText(const Controller& controller, PlaceholderType type, std::string& text)
{
- if( NULL != controller.mImpl->mEventData )
+ if(NULL != controller.mImpl->mEventData)
{
- if( PLACEHOLDER_TYPE_INACTIVE == type )
+ if(PLACEHOLDER_TYPE_INACTIVE == type)
{
text = controller.mImpl->mEventData->mPlaceholderTextInactive;
}
void Controller::PlaceholderHandler::SetPlaceholderFontFamily(Controller& controller, const std::string& placeholderTextFontFamily)
{
- if( NULL != controller.mImpl->mEventData )
+ if(NULL != controller.mImpl->mEventData)
{
- if( NULL == controller.mImpl->mEventData->mPlaceholderFont )
+ if(NULL == controller.mImpl->mEventData->mPlaceholderFont)
{
controller.mImpl->mEventData->mPlaceholderFont = new FontDefaults();
}
controller.mImpl->mEventData->mPlaceholderFont->mFontDescription.family = placeholderTextFontFamily;
- DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::SetPlaceholderFontFamily %s\n", placeholderTextFontFamily.c_str());
+ DALI_LOG_INFO(gLogFilter, Debug::General, "Controller::SetPlaceholderFontFamily %s\n", placeholderTextFontFamily.c_str());
controller.mImpl->mEventData->mPlaceholderFont->familyDefined = !placeholderTextFontFamily.empty();
controller.mImpl->RequestRelayout();
const std::string& Controller::PlaceholderHandler::GetPlaceholderFontFamily(const Controller& controller)
{
- if( ( NULL != controller.mImpl->mEventData ) && ( NULL != controller.mImpl->mEventData->mPlaceholderFont ) )
+ if((NULL != controller.mImpl->mEventData) && (NULL != controller.mImpl->mEventData->mPlaceholderFont))
{
return controller.mImpl->mEventData->mPlaceholderFont->mFontDescription.family;
}
void Controller::PlaceholderHandler::SetPlaceholderTextFontWeight(Controller& controller, FontWeight weight)
{
- if( NULL != controller.mImpl->mEventData )
+ if(NULL != controller.mImpl->mEventData)
{
- if( NULL == controller.mImpl->mEventData->mPlaceholderFont )
+ if(NULL == controller.mImpl->mEventData->mPlaceholderFont)
{
controller.mImpl->mEventData->mPlaceholderFont = new FontDefaults();
}
controller.mImpl->mEventData->mPlaceholderFont->mFontDescription.weight = weight;
- controller.mImpl->mEventData->mPlaceholderFont->weightDefined = true;
+ controller.mImpl->mEventData->mPlaceholderFont->weightDefined = true;
controller.mImpl->RequestRelayout();
}
bool Controller::PlaceholderHandler::IsPlaceholderTextFontWeightDefined(const Controller& controller)
{
- if( ( NULL != controller.mImpl->mEventData ) && ( NULL != controller.mImpl->mEventData->mPlaceholderFont ) )
+ if((NULL != controller.mImpl->mEventData) && (NULL != controller.mImpl->mEventData->mPlaceholderFont))
{
return controller.mImpl->mEventData->mPlaceholderFont->weightDefined;
}
FontWeight Controller::PlaceholderHandler::GetPlaceholderTextFontWeight(const Controller& controller)
{
- if( ( NULL != controller.mImpl->mEventData ) && ( NULL != controller.mImpl->mEventData->mPlaceholderFont ) )
+ if((NULL != controller.mImpl->mEventData) && (NULL != controller.mImpl->mEventData->mPlaceholderFont))
{
return controller.mImpl->mEventData->mPlaceholderFont->mFontDescription.weight;
}
void Controller::PlaceholderHandler::SetPlaceholderTextFontWidth(Controller& controller, FontWidth width)
{
- if( NULL != controller.mImpl->mEventData )
+ if(NULL != controller.mImpl->mEventData)
{
- if( NULL == controller.mImpl->mEventData->mPlaceholderFont )
+ if(NULL == controller.mImpl->mEventData->mPlaceholderFont)
{
controller.mImpl->mEventData->mPlaceholderFont = new FontDefaults();
}
controller.mImpl->mEventData->mPlaceholderFont->mFontDescription.width = width;
- controller.mImpl->mEventData->mPlaceholderFont->widthDefined = true;
+ controller.mImpl->mEventData->mPlaceholderFont->widthDefined = true;
controller.mImpl->RequestRelayout();
}
bool Controller::PlaceholderHandler::IsPlaceholderTextFontWidthDefined(const Controller& controller)
{
- if( ( NULL != controller.mImpl->mEventData ) && ( NULL != controller.mImpl->mEventData->mPlaceholderFont ) )
+ if((NULL != controller.mImpl->mEventData) && (NULL != controller.mImpl->mEventData->mPlaceholderFont))
{
return controller.mImpl->mEventData->mPlaceholderFont->widthDefined;
}
FontWidth Controller::PlaceholderHandler::GetPlaceholderTextFontWidth(const Controller& controller)
{
- if( ( NULL != controller.mImpl->mEventData ) && ( NULL != controller.mImpl->mEventData->mPlaceholderFont ) )
+ if((NULL != controller.mImpl->mEventData) && (NULL != controller.mImpl->mEventData->mPlaceholderFont))
{
return controller.mImpl->mEventData->mPlaceholderFont->mFontDescription.width;
}
void Controller::PlaceholderHandler::SetPlaceholderTextFontSlant(Controller& controller, FontSlant slant)
{
- if( NULL != controller.mImpl->mEventData )
+ if(NULL != controller.mImpl->mEventData)
{
- if( NULL == controller.mImpl->mEventData->mPlaceholderFont )
+ if(NULL == controller.mImpl->mEventData->mPlaceholderFont)
{
controller.mImpl->mEventData->mPlaceholderFont = new FontDefaults();
}
controller.mImpl->mEventData->mPlaceholderFont->mFontDescription.slant = slant;
- controller.mImpl->mEventData->mPlaceholderFont->slantDefined = true;
+ controller.mImpl->mEventData->mPlaceholderFont->slantDefined = true;
controller.mImpl->RequestRelayout();
}
bool Controller::PlaceholderHandler::IsPlaceholderTextFontSlantDefined(const Controller& controller)
{
- if( ( NULL != controller.mImpl->mEventData ) && ( NULL != controller.mImpl->mEventData->mPlaceholderFont ) )
+ if((NULL != controller.mImpl->mEventData) && (NULL != controller.mImpl->mEventData->mPlaceholderFont))
{
return controller.mImpl->mEventData->mPlaceholderFont->slantDefined;
}
FontSlant Controller::PlaceholderHandler::GetPlaceholderTextFontSlant(const Controller& controller)
{
- if( ( NULL != controller.mImpl->mEventData ) && ( NULL != controller.mImpl->mEventData->mPlaceholderFont ) )
+ if((NULL != controller.mImpl->mEventData) && (NULL != controller.mImpl->mEventData->mPlaceholderFont))
{
return controller.mImpl->mEventData->mPlaceholderFont->mFontDescription.slant;
}
void Controller::PlaceholderHandler::SetPlaceholderTextFontSize(Controller& controller, float fontSize, FontSizeType type)
{
- if( NULL != controller.mImpl->mEventData )
+ if(NULL != controller.mImpl->mEventData)
{
- if( NULL == controller.mImpl->mEventData->mPlaceholderFont )
+ if(NULL == controller.mImpl->mEventData->mPlaceholderFont)
{
controller.mImpl->mEventData->mPlaceholderFont = new FontDefaults();
}
- switch( type )
+ switch(type)
{
case POINT_SIZE:
{
controller.mImpl->mEventData->mPlaceholderFont->mDefaultPointSize = fontSize;
- controller.mImpl->mEventData->mPlaceholderFont->sizeDefined = true;
- controller.mImpl->mEventData->mIsPlaceholderPixelSize = false; // Font size flag
+ controller.mImpl->mEventData->mPlaceholderFont->sizeDefined = true;
+ controller.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 );
-
- controller.mImpl->mEventData->mPlaceholderFont->mDefaultPointSize = ( fontSize * 72.f ) / static_cast< float >( horizontalDpi );
- controller.mImpl->mEventData->mPlaceholderFont->sizeDefined = true;
- controller.mImpl->mEventData->mIsPlaceholderPixelSize = true; // Font size flag
+ unsigned int horizontalDpi = 0u;
+ unsigned int verticalDpi = 0u;
+ TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
+ fontClient.GetDpi(horizontalDpi, verticalDpi);
+
+ controller.mImpl->mEventData->mPlaceholderFont->mDefaultPointSize = (fontSize * 72.f) / static_cast<float>(horizontalDpi);
+ controller.mImpl->mEventData->mPlaceholderFont->sizeDefined = true;
+ controller.mImpl->mEventData->mIsPlaceholderPixelSize = true; // Font size flag
break;
}
}
}
}
-float Controller::PlaceholderHandler::GetPlaceholderTextFontSize(const Controller& controller, FontSizeType type )
+float Controller::PlaceholderHandler::GetPlaceholderTextFontSize(const Controller& controller, FontSizeType type)
{
float value = 0.0f;
- if( NULL != controller.mImpl->mEventData )
+ if(NULL != controller.mImpl->mEventData)
{
- switch( type )
+ switch(type)
{
case POINT_SIZE:
{
- if( NULL != controller.mImpl->mEventData->mPlaceholderFont )
+ if(NULL != controller.mImpl->mEventData->mPlaceholderFont)
{
value = controller.mImpl->mEventData->mPlaceholderFont->mDefaultPointSize;
}
else
{
// If the placeholder text font size is not set, then return the default font size.
- value = controller.GetDefaultFontSize( POINT_SIZE );
+ value = controller.GetDefaultFontSize(POINT_SIZE);
}
break;
}
case PIXEL_SIZE:
{
- if( NULL != controller.mImpl->mEventData->mPlaceholderFont )
+ if(NULL != controller.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 );
+ unsigned int horizontalDpi = 0u;
+ unsigned int verticalDpi = 0u;
+ TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
+ fontClient.GetDpi(horizontalDpi, verticalDpi);
- value = controller.mImpl->mEventData->mPlaceholderFont->mDefaultPointSize * static_cast< float >( horizontalDpi ) / 72.f;
+ value = controller.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 = controller.GetDefaultFontSize( PIXEL_SIZE );
+ value = controller.GetDefaultFontSize(PIXEL_SIZE);
}
break;
}
return value;
}
-void Controller::PlaceholderHandler::SetPlaceholderTextColor(Controller& controller, const Vector4& textColor )
+void Controller::PlaceholderHandler::SetPlaceholderTextColor(Controller& controller, const Vector4& textColor)
{
- if( NULL != controller.mImpl->mEventData )
+ if(NULL != controller.mImpl->mEventData)
{
controller.mImpl->mEventData->mPlaceholderTextColor = textColor;
}
- if( controller.mImpl->IsShowingPlaceholderText() )
+ if(controller.mImpl->IsShowingPlaceholderText())
{
- controller.mImpl->mModel->mVisualModel->SetTextColor( textColor );
+ controller.mImpl->mModel->mVisualModel->SetTextColor(textColor);
controller.mImpl->RequestRelayout();
}
}
const Vector4& Controller::PlaceholderHandler::GetPlaceholderTextColor(const Controller& controller)
{
- if( NULL != controller.mImpl->mEventData )
+ if(NULL != controller.mImpl->mEventData)
{
return controller.mImpl->mEventData->mPlaceholderTextColor;
}
return Color::BLACK;
}
-void Controller::PlaceholderHandler::SetPlaceholderProperty(Controller& controller, const Property::Map& map )
+void Controller::PlaceholderHandler::SetPlaceholderProperty(Controller& controller, const Property::Map& map)
{
const Property::Map::SizeType count = map.Count();
- for( Property::Map::SizeType position = 0; position < count; ++position )
+ for(Property::Map::SizeType position = 0; position < count; ++position)
{
- KeyValuePair keyValue = map.GetKeyValue( position );
- Property::Key& key = keyValue.first;
- Property::Value& value = keyValue.second;
+ KeyValuePair keyValue = map.GetKeyValue(position);
+ Property::Key& key = keyValue.first;
+ Property::Value& value = keyValue.second;
- if( key == Toolkit::Text::PlaceHolder::Property::TEXT || key == PLACEHOLDER_TEXT )
+ if(key == Toolkit::Text::PlaceHolder::Property::TEXT || key == PLACEHOLDER_TEXT)
{
std::string text = "";
- value.Get( text );
+ value.Get(text);
SetPlaceholderText(controller, Controller::PLACEHOLDER_TYPE_INACTIVE, text);
}
- else if( key == Toolkit::Text::PlaceHolder::Property::TEXT_FOCUSED || key == PLACEHOLDER_TEXT_FOCUSED )
+ else if(key == Toolkit::Text::PlaceHolder::Property::TEXT_FOCUSED || key == PLACEHOLDER_TEXT_FOCUSED)
{
std::string text = "";
- value.Get( text );
+ value.Get(text);
SetPlaceholderText(controller, Controller::PLACEHOLDER_TYPE_ACTIVE, text);
}
- else if( key == Toolkit::Text::PlaceHolder::Property::COLOR || key == PLACEHOLDER_COLOR )
+ else if(key == Toolkit::Text::PlaceHolder::Property::COLOR || key == PLACEHOLDER_COLOR)
{
Vector4 textColor;
- value.Get( textColor );
- if( GetPlaceholderTextColor(controller) != textColor )
+ value.Get(textColor);
+ if(GetPlaceholderTextColor(controller) != textColor)
{
SetPlaceholderTextColor(controller, textColor);
}
}
- else if( key == Toolkit::Text::PlaceHolder::Property::FONT_FAMILY || key == PLACEHOLDER_FONT_FAMILY )
+ else if(key == Toolkit::Text::PlaceHolder::Property::FONT_FAMILY || key == PLACEHOLDER_FONT_FAMILY)
{
std::string fontFamily = "";
- value.Get( fontFamily );
+ value.Get(fontFamily);
SetPlaceholderFontFamily(controller, fontFamily);
}
- else if( key == Toolkit::Text::PlaceHolder::Property::FONT_STYLE || key == PLACEHOLDER_FONT_STYLE )
+ else if(key == Toolkit::Text::PlaceHolder::Property::FONT_STYLE || key == PLACEHOLDER_FONT_STYLE)
{
- SetFontStyleProperty( &controller, value, Text::FontStyle::PLACEHOLDER );
+ SetFontStyleProperty(&controller, value, Text::FontStyle::PLACEHOLDER);
}
- else if( key == Toolkit::Text::PlaceHolder::Property::POINT_SIZE || key == PLACEHOLDER_POINT_SIZE )
+ else if(key == Toolkit::Text::PlaceHolder::Property::POINT_SIZE || key == PLACEHOLDER_POINT_SIZE)
{
float pointSize;
- value.Get( pointSize );
- if( !Equals(GetPlaceholderTextFontSize(controller, Text::Controller::POINT_SIZE), pointSize) )
+ value.Get(pointSize);
+ if(!Equals(GetPlaceholderTextFontSize(controller, Text::Controller::POINT_SIZE), pointSize))
{
SetPlaceholderTextFontSize(controller, pointSize, Text::Controller::POINT_SIZE);
}
}
- else if( key == Toolkit::Text::PlaceHolder::Property::PIXEL_SIZE || key == PLACEHOLDER_PIXEL_SIZE )
+ else if(key == Toolkit::Text::PlaceHolder::Property::PIXEL_SIZE || key == PLACEHOLDER_PIXEL_SIZE)
{
float pixelSize;
- value.Get( pixelSize );
- if( !Equals(GetPlaceholderTextFontSize(controller, Text::Controller::PIXEL_SIZE), pixelSize) )
+ value.Get(pixelSize);
+ if(!Equals(GetPlaceholderTextFontSize(controller, Text::Controller::PIXEL_SIZE), pixelSize))
{
SetPlaceholderTextFontSize(controller, pixelSize, Text::Controller::PIXEL_SIZE);
}
}
- else if( key == Toolkit::Text::PlaceHolder::Property::ELLIPSIS || key == PLACEHOLDER_ELLIPSIS )
+ else if(key == Toolkit::Text::PlaceHolder::Property::ELLIPSIS || key == PLACEHOLDER_ELLIPSIS)
{
bool ellipsis;
- value.Get( ellipsis );
+ value.Get(ellipsis);
SetPlaceholderTextElideEnabled(controller, ellipsis);
}
}
void Controller::PlaceholderHandler::GetPlaceholderProperty(Controller& controller, Property::Map& map)
{
- if( NULL != controller.mImpl->mEventData )
+ if(NULL != controller.mImpl->mEventData)
{
- if( !controller.mImpl->mEventData->mPlaceholderTextActive.empty() )
+ if(!controller.mImpl->mEventData->mPlaceholderTextActive.empty())
{
- map[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = controller.mImpl->mEventData->mPlaceholderTextActive;
+ map[Text::PlaceHolder::Property::TEXT_FOCUSED] = controller.mImpl->mEventData->mPlaceholderTextActive;
}
- if( !controller.mImpl->mEventData->mPlaceholderTextInactive.empty() )
+ if(!controller.mImpl->mEventData->mPlaceholderTextInactive.empty())
{
- map[ Text::PlaceHolder::Property::TEXT ] = controller.mImpl->mEventData->mPlaceholderTextInactive;
+ map[Text::PlaceHolder::Property::TEXT] = controller.mImpl->mEventData->mPlaceholderTextInactive;
}
- map[ Text::PlaceHolder::Property::COLOR ] = controller.mImpl->mEventData->mPlaceholderTextColor;
- map[ Text::PlaceHolder::Property::FONT_FAMILY ] = GetPlaceholderFontFamily(controller);
+ map[Text::PlaceHolder::Property::COLOR] = controller.mImpl->mEventData->mPlaceholderTextColor;
+ map[Text::PlaceHolder::Property::FONT_FAMILY] = GetPlaceholderFontFamily(controller);
Property::Value fontStyleMapGet;
- GetFontStyleProperty( &controller, fontStyleMapGet, Text::FontStyle::PLACEHOLDER );
- map[ Text::PlaceHolder::Property::FONT_STYLE ] = fontStyleMapGet;
+ GetFontStyleProperty(&controller, fontStyleMapGet, Text::FontStyle::PLACEHOLDER);
+ map[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleMapGet;
// Choose font size : POINT_SIZE or PIXEL_SIZE
- if( !controller.mImpl->mEventData->mIsPlaceholderPixelSize )
+ if(!controller.mImpl->mEventData->mIsPlaceholderPixelSize)
{
- map[ Text::PlaceHolder::Property::POINT_SIZE ] = GetPlaceholderTextFontSize(controller, Text::Controller::POINT_SIZE);
+ map[Text::PlaceHolder::Property::POINT_SIZE] = GetPlaceholderTextFontSize(controller, Text::Controller::POINT_SIZE);
}
else
{
- map[ Text::PlaceHolder::Property::PIXEL_SIZE ] = GetPlaceholderTextFontSize(controller, Text::Controller::PIXEL_SIZE);
+ map[Text::PlaceHolder::Property::PIXEL_SIZE] = GetPlaceholderTextFontSize(controller, Text::Controller::PIXEL_SIZE);
+ }
+
+ if(controller.mImpl->mEventData->mPlaceholderEllipsisFlag)
+ {
+ map[Text::PlaceHolder::Property::ELLIPSIS] = IsPlaceholderTextElideEnabled(controller);
}
+ }
+}
- if( controller.mImpl->mEventData->mPlaceholderEllipsisFlag )
+void Controller::PlaceholderHandler::ShowPlaceholderText(Controller& controller)
+{
+ Controller::Impl& impl = *controller.mImpl;
+
+ if(impl.IsPlaceholderAvailable())
+ {
+ EventData*& eventData = impl.mEventData;
+ DALI_ASSERT_DEBUG(eventData && "No placeholder text available");
+
+ if(NULL == eventData)
{
- map[ Text::PlaceHolder::Property::ELLIPSIS ] = IsPlaceholderTextElideEnabled(controller);
+ return;
}
+
+ eventData->mIsShowingPlaceholderText = true;
+
+ // Disable handles when showing place-holder text
+ DecoratorPtr& decorator = eventData->mDecorator;
+ decorator->SetHandleActive(GRAB_HANDLE, false);
+ decorator->SetHandleActive(LEFT_SELECTION_HANDLE, false);
+ decorator->SetHandleActive(RIGHT_SELECTION_HANDLE, false);
+
+ const char* text(NULL);
+ size_t size(0);
+
+ // TODO - Switch Placeholder text when changing state
+ std::string& placeholderTextActive = eventData->mPlaceholderTextActive;
+ if((EventData::INACTIVE != eventData->mState) &&
+ (0u != placeholderTextActive.c_str()))
+ {
+ text = placeholderTextActive.c_str();
+ size = placeholderTextActive.size();
+ }
+ else
+ {
+ std::string& placeholderTextInactive = eventData->mPlaceholderTextInactive;
+ text = placeholderTextInactive.c_str();
+ size = placeholderTextInactive.size();
+ }
+
+ TextUpdateInfo& textUpdateInfo = impl.mTextUpdateInfo;
+ textUpdateInfo.mCharacterIndex = 0u;
+ textUpdateInfo.mNumberOfCharactersToRemove = textUpdateInfo.mPreviousNumberOfCharacters;
+
+ // Reset model for showing placeholder.
+ ModelPtr& model = impl.mModel;
+ LogicalModelPtr& logicalModel = model->mLogicalModel;
+ logicalModel->mText.Clear();
+ model->mVisualModel->SetTextColor(eventData->mPlaceholderTextColor);
+
+ // Convert text into UTF-32
+ Vector<Character>& utf32Characters = logicalModel->mText;
+ utf32Characters.Resize(size);
+
+ // This is a bit horrible but std::string returns a (signed) char*
+ const uint8_t* utf8 = reinterpret_cast<const uint8_t*>(text);
+
+ // Transform a text array encoded in utf8 into an array encoded in utf32.
+ // It returns the actual number of characters.
+ const Length characterCount = Utf8ToUtf32(utf8, size, utf32Characters.Begin());
+ utf32Characters.Resize(characterCount);
+
+ // The characters to be added.
+ textUpdateInfo.mNumberOfCharactersToAdd = characterCount;
+
+ // Reset the cursor position
+ eventData->mPrimaryCursorPosition = 0;
+
+ // The natural size needs to be re-calculated.
+ impl.mRecalculateNaturalSize = true;
+
+ // The text direction needs to be updated.
+ impl.mUpdateTextDirection = true;
+
+ // Apply modifications to the model
+ impl.mOperationsPending = ALL_OPERATIONS;
+
+ // Update the rest of the model during size negotiation
+ impl.QueueModifyEvent(ModifyEvent::TEXT_REPLACED);
}
}