From f950b22d3cb695337678869d767979dede0d90b1 Mon Sep 17 00:00:00 2001 From: Adeel Kazmi Date: Thu, 23 Mar 2017 11:04:47 +0000 Subject: [PATCH] Ensure Text Controls do an up-call on-style-change & trigger a relayout The up-call is required as per the control writing guidelines. A relayout request is required so that the control's fonts and size can be recalculated. A similar fix has already been pushed to the product branch. Change-Id: Ib23baeef60d6fb6fb3e68105defba9a30b458b5f --- .../dali-toolkit-styling/utc-Dali-StyleManager.cpp | 21 ++++++++++++++++++--- .../controls/text-controls/text-editor-impl.cpp | 7 ++++++- .../controls/text-controls/text-field-impl.cpp | 7 ++++++- .../controls/text-controls/text-label-impl.cpp | 7 ++++++- dali-toolkit/public-api/controls/control-impl.cpp | 2 +- 5 files changed, 37 insertions(+), 7 deletions(-) diff --git a/automated-tests/src/dali-toolkit-styling/utc-Dali-StyleManager.cpp b/automated-tests/src/dali-toolkit-styling/utc-Dali-StyleManager.cpp index dc95a8e..20de8e8 100644 --- a/automated-tests/src/dali-toolkit-styling/utc-Dali-StyleManager.cpp +++ b/automated-tests/src/dali-toolkit-styling/utc-Dali-StyleManager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 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. @@ -642,8 +642,11 @@ int UtcDaliStyleManagerStyleChangedSignalFontFamily(void) Toolkit::TextLabel label = Toolkit::TextLabel::New(labelStr); Stage::GetCurrent().Add( label ); - Toolkit::TextLabel label2 = Toolkit::TextLabel::New(labelStr); - Stage::GetCurrent().Add( label2 ); + Toolkit::TextField field = Toolkit::TextField::New(); + Stage::GetCurrent().Add( field ); + + Toolkit::TextEditor editor = Toolkit::TextEditor::New(); + Stage::GetCurrent().Add( editor ); StyleChangedSignalChecker styleChangedSignalHandler; Dali::StyleMonitor styleMonitor = Dali::StyleMonitor::Get(); @@ -666,6 +669,18 @@ int UtcDaliStyleManagerStyleChangedSignalFontFamily(void) DALI_TEST_EQUALS( familyStr, "Times New Roman", TEST_LOCATION); + // Check that the field's font style has been altered + family = field.GetProperty(TextField::Property::FONT_FAMILY); + family.Get( familyStr ); + + DALI_TEST_EQUALS( familyStr, "Times New Roman", TEST_LOCATION); + + // Check that the editor's font style has been altered + family = editor.GetProperty(TextEditor::Property::FONT_FAMILY); + family.Get( familyStr ); + + DALI_TEST_EQUALS( familyStr, "Times New Roman", TEST_LOCATION); + END_TEST; } diff --git a/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp index fc86c7e..c08b897 100644 --- a/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp @@ -1098,20 +1098,25 @@ void TextEditor::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange: const std::string& newFont = GetImpl( styleManager ).GetDefaultFontFamily(); // Property system did not set the font so should update it. mController->UpdateAfterFontChange( newFont ); + RelayoutRequest(); break; } case StyleChange::DEFAULT_FONT_SIZE_CHANGE: { GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) ); + RelayoutRequest(); break; } case StyleChange::THEME_CHANGE: { - GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) ); + // Nothing to do, let control base class handle this break; } } + + // Up call to Control + Control::OnStyleChange( styleManager, change ); } Vector3 TextEditor::GetNaturalSize() diff --git a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp index bafa08e..2e300b1 100644 --- a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp @@ -1209,20 +1209,25 @@ void TextField::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange:: const std::string& newFont = GetImpl( styleManager ).GetDefaultFontFamily(); // Property system did not set the font so should update it. mController->UpdateAfterFontChange( newFont ); + RelayoutRequest(); break; } case StyleChange::DEFAULT_FONT_SIZE_CHANGE: { GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) ); + RelayoutRequest(); break; } case StyleChange::THEME_CHANGE: { - GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) ); + // Nothing to do, let control base class handle this break; } } + + // Up call to Control + Control::OnStyleChange( styleManager, change ); } Vector3 TextField::GetNaturalSize() diff --git a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp index b6b5db0..3d161e0 100644 --- a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp @@ -672,19 +672,24 @@ void TextLabel::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange:: const std::string& newFont = GetImpl( styleManager ).GetDefaultFontFamily(); DALI_LOG_INFO( gLogFilter, Debug::General, "TextLabel::OnStyleChange StyleChange::DEFAULT_FONT_CHANGE newFont(%s)\n", newFont.c_str() ); mController->UpdateAfterFontChange( newFont ); + RelayoutRequest(); break; } case StyleChange::DEFAULT_FONT_SIZE_CHANGE: { GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) ); + RelayoutRequest(); break; } case StyleChange::THEME_CHANGE: { - GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) ); + // Nothing to do, let control base class handle this break; } } + + // Up call to Control + Control::OnStyleChange( styleManager, change ); } Vector3 TextLabel::GetNaturalSize() diff --git a/dali-toolkit/public-api/controls/control-impl.cpp b/dali-toolkit/public-api/controls/control-impl.cpp index 19be9ba..c4ee219 100644 --- a/dali-toolkit/public-api/controls/control-impl.cpp +++ b/dali-toolkit/public-api/controls/control-impl.cpp @@ -1500,8 +1500,8 @@ void Control::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Ty if( styleManager && change == StyleChange::THEME_CHANGE ) { GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) ); + RelayoutRequest(); } - RelayoutRequest(); } void Control::OnPinch(const PinchGesture& pinch) -- 2.7.4