From 7d1d83b6d0af227e5887cad6121344fe0ea2b145 Mon Sep 17 00:00:00 2001 From: Paul Wisbey Date: Fri, 10 Jul 2015 10:46:38 +0100 Subject: [PATCH] Apply default theme if no THEME_CHANGE occurs Change-Id: I46d061d3ba3d289aac94d596da64a9a381136d45 --- .../src/dali-toolkit/utc-Dali-TextField.cpp | 35 +++++----------------- .../src/dali-toolkit/utc-Dali-TextLabel.cpp | 17 +---------- .../text-controls/text-selection-popup-impl.cpp | 4 --- .../internal/styling/style-manager-impl.cpp | 5 ++++ 4 files changed, 13 insertions(+), 48 deletions(-) diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp index 1c3f5f1..b8fd9db 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp @@ -267,30 +267,7 @@ int UtcDaliTextFieldSetPropertyP(void) TextField field = TextField::New(); DALI_TEST_CHECK( field ); - // Check defaults. - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::RENDERING_BACKEND ), DEFAULT_RENDERING_BACKEND, TEST_LOCATION ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::TEXT ), std::string(""), TEST_LOCATION ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::PLACEHOLDER_TEXT ), std::string(""), TEST_LOCATION ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED ), std::string(""), TEST_LOCATION ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::FONT_FAMILY ), std::string(""), TEST_LOCATION ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::FONT_STYLE ), std::string(""), TEST_LOCATION ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::POINT_SIZE ), 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::MAX_LENGTH ), 50u, TEST_LOCATION ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::EXCEED_POLICY ), TextField::EXCEED_POLICY_CLIP, TEST_LOCATION ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::HORIZONTAL_ALIGNMENT ), "BEGIN", TEST_LOCATION ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::VERTICAL_ALIGNMENT ), "TOP", TEST_LOCATION ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::TEXT_COLOR ), Color::BLACK, TEST_LOCATION ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::SHADOW_OFFSET ), Vector2::ZERO, TEST_LOCATION ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::PLACEHOLDER_TEXT_COLOR ), PLACEHOLDER_TEXT_COLOR, TEST_LOCATION ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::SHADOW_COLOR ), Color::BLACK, TEST_LOCATION ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::BLACK, TEST_LOCATION ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLACK, TEST_LOCATION ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::ENABLE_CURSOR_BLINK ), true, TEST_LOCATION ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::CURSOR_BLINK_INTERVAL ), CURSOR_BLINK_INTERVAL * TO_SECONDS, TEST_LOCATION ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::CURSOR_BLINK_DURATION ), 0.f, TEST_LOCATION ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::SCROLL_THRESHOLD ), SCROLL_THRESHOLD, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::SCROLL_SPEED ), SCROLL_SPEED, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - DALI_TEST_EQUALS( field.GetProperty( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), LIGHT_BLUE, TEST_LOCATION ); + // Note - we can't check the defaults since the stylesheets are platform-specific // Check the render backend property. field.SetProperty( TextField::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS ); @@ -610,6 +587,7 @@ int utcDaliTextFieldEvent02(void) // Checks if the right number of actors are created. TextField field = TextField::New(); + field.SetProperty( TextField::Property::POINT_SIZE, 10.f ); DALI_TEST_CHECK( field ); Stage::GetCurrent().Add( field ); @@ -711,7 +689,7 @@ int utcDaliTextFieldEvent02(void) DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2. - // Try to tap at the end. + // Tap away from the start position. application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 13.f, 25.0f ) ) ); application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 13.0f, 25.0f ) ) ); @@ -719,14 +697,14 @@ int utcDaliTextFieldEvent02(void) application.SendNotification(); application.Render(); - // Cursor position should be the same than position1. Vector3 position5 = cursor.GetCurrentPosition(); - DALI_TEST_EQUALS( position1, position5, TEST_LOCATION ); // Should be in the same position1. + DALI_TEST_CHECK( position5.x > position4.x ); - // Remove some text. + // Remove all the text. application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) ); application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) ); + field.SetProperty( TextField::Property::TEXT, "" ); // Render and notify application.SendNotification(); @@ -756,6 +734,7 @@ int utcDaliTextFieldEvent03(void) Stage::GetCurrent().Add( field ); field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." ); + field.SetProperty( TextField::Property::POINT_SIZE, 10.f ); field.SetSize( 30.f, 50.f ); field.SetParentOrigin( ParentOrigin::TOP_LEFT ); field.SetAnchorPoint( AnchorPoint::TOP_LEFT ); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp index f295b33..a44081d 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp @@ -161,22 +161,7 @@ int UtcDaliToolkitTextLabelSetPropertyP(void) TextLabel label = TextLabel::New(); DALI_TEST_CHECK( label ); - // Check defaults - DALI_TEST_EQUALS( label.GetProperty( TextLabel::Property::RENDERING_BACKEND ), DEFAULT_RENDERING_BACKEND, TEST_LOCATION ); - DALI_TEST_EQUALS( label.GetProperty( TextLabel::Property::TEXT ), std::string(""), TEST_LOCATION ); - DALI_TEST_EQUALS( label.GetProperty( TextLabel::Property::FONT_FAMILY ), std::string(""), TEST_LOCATION ); - DALI_TEST_EQUALS( label.GetProperty( TextLabel::Property::FONT_STYLE ), std::string(""), TEST_LOCATION ); - DALI_TEST_EQUALS( label.GetProperty( TextLabel::Property::POINT_SIZE ), 0.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION ); - DALI_TEST_EQUALS( label.GetProperty( TextLabel::Property::MULTI_LINE ), false, TEST_LOCATION ); - DALI_TEST_EQUALS( label.GetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT ), "BEGIN", TEST_LOCATION ); - DALI_TEST_EQUALS( label.GetProperty( TextLabel::Property::VERTICAL_ALIGNMENT ), "TOP", TEST_LOCATION ); - DALI_TEST_EQUALS( label.GetProperty( TextLabel::Property::TEXT_COLOR ), Color::BLACK, TEST_LOCATION ); - DALI_TEST_EQUALS( label.GetProperty( TextLabel::Property::SHADOW_OFFSET ), Vector2::ZERO, TEST_LOCATION ); - DALI_TEST_EQUALS( label.GetProperty( TextLabel::Property::SHADOW_COLOR ), Color::BLACK, TEST_LOCATION ); - DALI_TEST_EQUALS( label.GetProperty( TextLabel::Property::UNDERLINE_ENABLED ), false, TEST_LOCATION ); - DALI_TEST_EQUALS( label.GetProperty( TextLabel::Property::UNDERLINE_COLOR ), Color::BLACK, TEST_LOCATION ); - DALI_TEST_EQUALS( label.GetProperty( TextLabel::Property::UNDERLINE_HEIGHT ), 0.0f, TEST_LOCATION ); - + // Note - we can't check the defaults since the stylesheets are platform-specific label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS ); DALI_TEST_EQUALS( label.GetProperty( TextLabel::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION ); diff --git a/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp index ad9871b..1b61bbb 100644 --- a/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp @@ -53,8 +53,6 @@ const Dali::Vector4 DEFAULT_POPUP_DIVIDER_COLOR( Dali::Vector4( 0.23f, 0.72f, 0. const Dali::Vector4 DEFAULT_OPTION_ICON( Dali::Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) ); const Dali::Vector4 DEFAULT_OPTION_PRESSED_COLOR( Dali::Vector4( 0.24f, 0.72f, 0.8f, 0.11f ) ); -const float DEFAULT_CAPTION_POINT_SIZE = 8.0f; // todo This should be from the style sheet not fixed. - const std::string DEFAULT_POPUP_BACKGROUND_IMAGE( DALI_IMAGE_DIR "selection-popup-bg#.png" ); const std::string OPTION_ICON_CLIPBOARD( DALI_IMAGE_DIR "copy_paste_icon_clipboard.png" ); const std::string OPTION_ICON_COPY( DALI_IMAGE_DIR "copy_paste_icon_copy.png" ); @@ -615,13 +613,11 @@ Dali::Image TextSelectionPopup::GetButtonImage( Toolkit::TextSelectionPopup::But Toolkit::TextLabel captionTextLabel = Toolkit::TextLabel::New(); captionTextLabel.SetStyleName( TEXT_SELECTION_POPUP_LABEL ); captionTextLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, caption ); - captionTextLabel.SetProperty( Toolkit::TextLabel::Property::POINT_SIZE, DEFAULT_CAPTION_POINT_SIZE ); captionTextLabel.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); Toolkit::TextLabel pressedCaptionTextLabel = Toolkit::TextLabel::New(); pressedCaptionTextLabel.SetStyleName( TEXT_SELECTION_POPUP_LABEL ); pressedCaptionTextLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, caption ); - pressedCaptionTextLabel.SetProperty( Toolkit::TextLabel::Property::POINT_SIZE, DEFAULT_CAPTION_POINT_SIZE ); pressedCaptionTextLabel.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); Padding padding; diff --git a/dali-toolkit/internal/styling/style-manager-impl.cpp b/dali-toolkit/internal/styling/style-manager-impl.cpp index 814421e..e0e1d4c 100644 --- a/dali-toolkit/internal/styling/style-manager-impl.cpp +++ b/dali-toolkit/internal/styling/style-manager-impl.cpp @@ -282,6 +282,11 @@ void StyleManager::ApplyStyle( Toolkit::Builder builder, Toolkit::Control contro void StyleManager::ApplyThemeStyle( Toolkit::Control control ) { + if( !mThemeBuilder ) + { + RequestDefaultTheme(); + } + if( mThemeBuilder ) { ApplyStyle( mThemeBuilder, control ); -- 2.7.4