GetImpl(*this).SetOrientation( orientation );
}
+std::string StyleManager::GetDefaultFontFamily() const
+{
+ return GetImpl(*this).GetDefaultFontFamily();
+}
+
Orientation StyleManager::GetOrientation()
{
return GetImpl(*this).GetOrientation();
Orientation GetOrientation();
/**
+ * @brief Retrieves the default font family.
+ * @return The default font family.
+ */
+ std::string GetDefaultFontFamily() const;
+
+ /**
* @brief Make a request to set the theme JSON file to one that exists in the Toolkit package.
*
* Multiple requests per event processing cycle can be made, but only the final one will be acted
{
Toolkit::TextField textField = Toolkit::TextField::DownCast( Dali::BaseHandle( object ) );
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField SetProperty\n");
+
+
if( textField )
{
TextField& impl( GetImpl( textField ) );
if( impl.mController->GetDefaultFontFamily() != fontFamily )
{
- impl.mController->SetDefaultFontFamily( fontFamily );
+ impl.mController->SetDefaultFontFamily( fontFamily, true ); // "true" as SetProperty means user defined font so don't change when system font changes.
}
}
break;
{
case StyleChange::DEFAULT_FONT_CHANGE:
{
- DALI_LOG_INFO( gLogFilter, Debug::General, "TextField::OnStyleChange StyleChange::DEFAULT_FONT_CHANGE\n");
- if ( mController->GetDefaultFontFamily() == "" )
- {
- // Property system did not set the font so should update it.
- // todo instruct text-controller to update model
- }
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnStyleChange DEFAULT_FONT_CHANGE\n");
+ std::string newFont = styleManager.GetDefaultFontFamily();
+ // Property system did not set the font so should update it.
+ mController->UpdateAfterFontChange( newFont );
break;
}
void TextField::OnRelayout( const Vector2& size, RelayoutContainer& container )
{
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField OnRelayout\n");
+
if( mController->Relayout( size ) ||
!mRenderer )
{
if( impl.mController->GetDefaultFontFamily() != fontFamily )
{
- impl.mController->SetDefaultFontFamily( fontFamily );
+ impl.mController->SetDefaultFontFamily( fontFamily, true );
}
}
break;
StyleManager::StyleManager()
: mOrientationDegrees( 0 ), // Portrait
mDefaultFontSize( -1 ),
+ mDefaultFontFamily(""),
mThemeFile( DEFAULT_THEME ),
mFeedbackStyle( NULL )
{
}
}
+std::string StyleManager::GetDefaultFontFamily() const
+{
+ return mDefaultFontFamily;
+}
+
Orientation StyleManager::GetOrientation()
{
return mOrientation;
{
case StyleChange::DEFAULT_FONT_CHANGE:
{
+ mDefaultFontFamily = styleMonitor.GetDefaultFontFamily();
break;
}
Orientation GetOrientation();
/**
+ * @copydoc Toolkit::StyleManager::GetDefaultFontFamily
+ */
+ std::string GetDefaultFontFamily() const;
+
+ /**
* @copydoc Toolkit::StyleManager::SetStyleConstant
*/
void SetStyleConstant( const std::string& key, const Property::Value& value );
int mDefaultFontSize; ///< Logical size, not a point-size
+ std::string mDefaultFontFamily;
+
std::string mThemeFile; ///< The full path of the current theme file
Property::Map mThemeBuilderConstants; ///< Contants to give the theme builder
// Copy the fonts set by application developers.
const Length numberOfFontRuns = fonts.Count();
- const Vector<FontRun> definedFonts = fonts;
+ const Vector<FontRun> userSetFonts = fonts;
fonts.Clear();
// Traverse the characters and validate/set the fonts.
TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
// Iterators of the font and script runs.
- Vector<FontRun>::ConstIterator fontRunIt = definedFonts.Begin();
- Vector<FontRun>::ConstIterator fontRunEndIt = definedFonts.End();
+ Vector<FontRun>::ConstIterator fontRunIt = userSetFonts.Begin();
+ Vector<FontRun>::ConstIterator fontRunEndIt = userSetFonts.End();
Vector<ScriptRun>::ConstIterator scriptRunIt = scripts.Begin();
Vector<ScriptRun>::ConstIterator scriptRunEndIt = scripts.End();
// EXTERNAL INCLUDES
#include <dali/devel-api/adaptor-framework/clipboard.h>
#include <dali/devel-api/text-abstraction/font-client.h>
+#include <iostream>
// INTERNAL INCLUDES
#include <dali-toolkit/internal/text/layouts/layout-engine.h>
struct FontDefaults
{
FontDefaults()
- : mDefaultPointSize(0.0f),
+ : mDefaultFontFamily(""),
+ mDefaultFontStyle(""),
+ mDefaultPointSize(0.0f),
mFontId(0u)
{
}
mAlignmentOffset(),
mOperationsPending( NO_OPERATION ),
mMaximumNumberOfCharacters( 50 ),
- mRecalculateNaturalSize( true )
+ mRecalculateNaturalSize( true ),
+ mUserDefinedFontFamily( false)
{
mLogicalModel = LogicalModel::New();
mVisualModel = VisualModel::New();
Vector2 mAlignmentOffset; ///< Vertical and horizontal offset of the whole text inside the control due to alignment.
OperationsMask mOperationsPending; ///< Operations pending to be done to layout the text.
Length mMaximumNumberOfCharacters; ///< Maximum number of characters that can be inserted.
+
bool mRecalculateNaturalSize:1; ///< Whether the natural size needs to be recalculated.
+ bool mUserDefinedFontFamily:1; ///< Whether the Font family was Set by the user instead of being left as sytem default
};
} // namespace Text
void Controller::SetText( const std::string& text )
{
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::SetText\n" );
+
// Remove the previously set text
ResetText();
return mImpl->mMaximumNumberOfCharacters;
}
-void Controller::SetDefaultFontFamily( const std::string& defaultFontFamily )
+void Controller::SetDefaultFontFamily( const std::string& defaultFontFamily, bool userDefined )
{
if( !mImpl->mFontDefaults )
{
}
mImpl->mFontDefaults->mDefaultFontFamily = defaultFontFamily;
-
+ mImpl->mUserDefinedFontFamily = userDefined;
// Clear the font-specific data
ClearFontData();
return 0.0f;
}
+void Controller::UpdateAfterFontChange( std::string& newDefaultFont )
+{
+ DALI_LOG_INFO( gLogFilter, Debug::Concise, "Controller::UpdateAfterFontChange");
+
+ ClearFontData();
+
+ if ( !mImpl->mUserDefinedFontFamily ) // If user defined font then should not update when system font changes
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::Concise, "Controller::UpdateAfterFontChange newDefaultFont(%s)\n", newDefaultFont.c_str() );
+ mImpl->mFontDefaults->mDefaultFontFamily=newDefaultFont;
+ mImpl->UpdateModel( ALL_OPERATIONS );
+ mImpl->QueueModifyEvent( ModifyEvent::TEXT_REPLACED );
+ mImpl->mRecalculateNaturalSize = true;
+ mImpl->RequestRelayout();
+ }
+}
+
void Controller::SetTextColor( const Vector4& textColor )
{
mImpl->mTextColor = textColor;
* @brief Set the default font family.
*
* @param[in] defaultFontFamily The default font family.
+ * @param[in] userDefined If set by the user
*/
- void SetDefaultFontFamily( const std::string& defaultFontFamily );
+ void SetDefaultFontFamily( const std::string& defaultFontFamily, bool userDefined );
/**
* @brief Retrieve the default font family.
float GetDefaultPointSize() const;
/**
+ * @ brief Update the text after a font change
+ * @param[in] newDefaultFont The new font to change to
+ */
+ void UpdateAfterFontChange( std::string& newDefaultFont );
+
+ /**
* @brief Set the text color
*
* @param textColor The text color