From: David Steele Date: Mon, 25 Apr 2016 16:46:23 +0000 (+0100) Subject: Moved StyleManager to the public API X-Git-Tag: dali_1.1.32~5^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=93c1881a3d13228479ebb96fd6bbdbf1984c2cff Moved StyleManager to the public API Cleaned up the API (removed Orientation code), fixed comments, added @SINCE_1_1.32 macros, doxygen groups. Change-Id: I954f627a3db63714471d8440b65fc1afbc8dc44e Signed-off-by: David Steele --- diff --git a/automated-tests/.gitignore b/automated-tests/.gitignore index 39d9377..b12e784 100644 --- a/automated-tests/.gitignore +++ b/automated-tests/.gitignore @@ -2,4 +2,5 @@ build build.log tct*core.h +CMakeLists.txt results_xml.* diff --git a/automated-tests/CMakeLists.txt b/automated-tests/CMakeLists.txt.in similarity index 65% rename from automated-tests/CMakeLists.txt rename to automated-tests/CMakeLists.txt.in index 9e15203..0a0b958 100644 --- a/automated-tests/CMakeLists.txt +++ b/automated-tests/CMakeLists.txt.in @@ -4,8 +4,10 @@ PROJECT(tct_coreapi_utc) INCLUDE(FindPkgConfig) SET(BIN_DIR "/opt/usr/bin") +ADD_DEFINITIONS(-DDALI_STYLE_DIR="@dataReadOnlyDir@/toolkit/styles/") + INCLUDE_DIRECTORIES( - src/common + src/common ) ADD_SUBDIRECTORY(src) 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 e463e2f..d82faf3 100644 --- a/automated-tests/src/dali-toolkit-styling/utc-Dali-StyleManager.cpp +++ b/automated-tests/src/dali-toolkit-styling/utc-Dali-StyleManager.cpp @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include @@ -163,93 +162,67 @@ void dali_style_manager_cleanup(void) test_return_value = TET_PASS; } -int UtcDaliStyleManagerGet(void) + +int UtcDaliStyleManagerConstructorP(void) { ToolkitTestApplication application; - tet_infoline(" UtcDaliStyleManagerGet"); - - // Register Type - TypeInfo type; - type = TypeRegistry::Get().GetTypeInfo( "StyleManager" ); - DALI_TEST_CHECK( type ); - BaseHandle handle = type.CreateInstance(); - DALI_TEST_CHECK( handle ); - - StyleManager manager; - - manager = StyleManager::Get(); - DALI_TEST_CHECK(manager); - - StyleManager newManager = StyleManager::Get(); - DALI_TEST_CHECK(newManager); - - // Check that focus manager is a singleton - DALI_TEST_CHECK(manager == newManager); + tet_infoline(" UtcDaliStyleManagerConstructorP"); + StyleManager styleManager; + DALI_TEST_CHECK( !styleManager); END_TEST; } -int UtcDaliStyleManagerSetOrientationValue(void) +int UtcDaliStyleManagerCopyConstructorP(void) { - ToolkitTestApplication application; - - tet_infoline( " UtcDaliStyleManagerSetOrientationValue" ); + TestApplication application; - StyleManager manager = StyleManager::Get(); - - int orientation1 = 0; - manager.SetOrientationValue( orientation1 ); - DALI_TEST_CHECK( manager.GetOrientationValue() == orientation1 ); - - int orientation2 = 180; - manager.SetOrientationValue( orientation2 ); - DALI_TEST_CHECK( manager.GetOrientationValue() == orientation2 ); + StyleManager styleManager = StyleManager::Get(); + StyleManager copyOfStyleManager( styleManager ); + DALI_TEST_CHECK( copyOfStyleManager ); END_TEST; } -int UtcDaliStyleManagerSetOrientation(void) +int UtcDaliStyleManagerAssignmentOperatorP(void) { - ToolkitTestApplication application; - - tet_infoline( " UtcDaliStyleManagerSetOrientation" ); + TestApplication application; - StyleManager manager = StyleManager::Get(); - - Orientation orientation; - - manager.SetOrientation( orientation ); - - DALI_TEST_CHECK( manager.GetOrientation() == orientation ); + StyleManager styleManager = StyleManager::Get(); + StyleManager copyOfStyleManager = styleManager; + DALI_TEST_CHECK( copyOfStyleManager ); + DALI_TEST_CHECK( copyOfStyleManager == styleManager ); END_TEST; } -int UtcDaliStyleManagerSetStyleConstant(void) +int UtcDaliStyleManagerGet(void) { ToolkitTestApplication application; - tet_infoline( " UtcDaliStyleManagerSetStyleConstant" ); - - StyleManager manager = StyleManager::Get(); - - std::string key( "key" ); - Property::Value value( 100 ); + tet_infoline(" UtcDaliStyleManagerGet"); - manager.SetStyleConstant( key, value ); + // Register Type + TypeInfo type; + type = TypeRegistry::Get().GetTypeInfo( "StyleManager" ); + DALI_TEST_CHECK( type ); + BaseHandle handle = type.CreateInstance(); + DALI_TEST_CHECK( handle ); - Property::Value returnedValue; - manager.GetStyleConstant( key, returnedValue ); + StyleManager manager; - DALI_TEST_CHECK( value.Get() == returnedValue.Get() ); + manager = StyleManager::Get(); + DALI_TEST_CHECK(manager); - std::string key2( "key2" ); - Property::Value returnedValue2; - DALI_TEST_CHECK( !manager.GetStyleConstant( key2, returnedValue2 ) ); + StyleManager newManager = StyleManager::Get(); + DALI_TEST_CHECK(newManager); + // Check that focus manager is a singleton + DALI_TEST_CHECK(manager == newManager); END_TEST; } + namespace { class StyleChangedSignalChecker : public ConnectionTracker @@ -276,11 +249,11 @@ public: } // anonymous namespace -int UtcDaliStyleManagerPropertyOverride(void) +int UtcDaliStyleManagerApplyTheme(void) { ToolkitTestApplication application; - tet_infoline( "Testing StyleManager property overrides" ); + tet_infoline( "Testing StyleManager ApplyTheme" ); const char* json1 = "{\n" @@ -323,9 +296,9 @@ int UtcDaliStyleManagerPropertyOverride(void) tet_infoline("Apply the style"); - Test::StyleMonitor::SetThemeFileOutput(json1); std::string themeFile("ThemeOne"); - StyleManager::Get().RequestThemeChange(themeFile); + Test::StyleMonitor::SetThemeFileOutput(themeFile, json1); + StyleManager::Get().ApplyTheme(themeFile); Property::Value bgColor( testButton.GetProperty(Test::TestButton::Property::BACKGROUND_COLOR) ); Property::Value fgColor( testButton.GetProperty(Test::TestButton::Property::FOREGROUND_COLOR) ); @@ -350,7 +323,7 @@ int UtcDaliStyleManagerPropertyOverride(void) tet_infoline("Apply the style again"); styleChangedSignalHandler.signalCount = 0; - StyleManager::Get().RequestThemeChange(themeFile); + StyleManager::Get().ApplyTheme(themeFile); bgColor = testButton.GetProperty(Test::TestButton::Property::BACKGROUND_COLOR); fgColor = testButton.GetProperty(Test::TestButton::Property::FOREGROUND_COLOR); @@ -364,11 +337,11 @@ int UtcDaliStyleManagerPropertyOverride(void) tet_infoline( "Load a different stylesheet"); tet_infoline("Apply the new style"); - Test::StyleMonitor::SetThemeFileOutput(json2); + std::string themeFile2("ThemeTwo"); + Test::StyleMonitor::SetThemeFileOutput(themeFile2, json2); styleChangedSignalHandler.signalCount = 0; - std::string themeFile2("ThemeTwo"); - StyleManager::Get().RequestThemeChange(themeFile2); + StyleManager::Get().ApplyTheme(themeFile2); bgColor = testButton.GetProperty(Test::TestButton::Property::BACKGROUND_COLOR); fgColor = testButton.GetProperty(Test::TestButton::Property::FOREGROUND_COLOR); @@ -381,10 +354,230 @@ int UtcDaliStyleManagerPropertyOverride(void) END_TEST; } -int UtcDaliStyleManagerFontSizeChange(void) + +int UtcDaliStyleManagerApplyDefaultTheme(void) +{ + tet_infoline( "Testing StyleManager ApplyTheme" ); + + const char* defaultTheme = + "{\n" + " \"styles\":\n" + " {\n" + " \"testbutton\":\n" + " {\n" + " \"backgroundColor\":[1.0,1.0,0.0,1.0],\n" + " \"foregroundColor\":[0.0,0.0,1.0,1.0]\n" + " }\n" + " }\n" + "}\n"; + // Bg: Yellow, Fg: Blue + + const char* appTheme = + "{\n" + " \"styles\":\n" + " {\n" + " \"testbutton\":\n" + " {\n" + " \"backgroundColor\":[1.0,0.0,1.0,1.0],\n" + " \"foregroundColor\":[0.0,1.0,0.0,1.0]\n" + " }\n" + " }\n" + "}\n"; + // Bg::Magenta, Fg:Green + + std::string filepath(TEST_RESOURCE_DIR ""); + + Test::StyleMonitor::SetThemeFileOutput( DALI_STYLE_DIR "dali-toolkit-default-theme.json", + defaultTheme); + ToolkitTestApplication application; + + Test::TestButton testButton = Test::TestButton::New(); + Stage::GetCurrent().Add( testButton ); + StyleChangedSignalChecker styleChangedSignalHandler; + StyleManager styleManager = StyleManager::Get(); + + styleManager.StyleChangedSignal().Connect(&styleChangedSignalHandler, &StyleChangedSignalChecker::OnStyleChanged); + + // Render and notify + application.SendNotification(); + application.Render(); + + // Get the default: + Property::Value defaultBgColor( testButton.GetProperty(Test::TestButton::Property::BACKGROUND_COLOR) ); + Property::Value defaultFgColor( testButton.GetProperty(Test::TestButton::Property::FOREGROUND_COLOR) ); + + tet_infoline("Apply the style"); + + std::string themeFile("ThemeOne"); + Test::StyleMonitor::SetThemeFileOutput(themeFile, appTheme); + StyleManager::Get().ApplyTheme(themeFile); + + Property::Value bgColor( testButton.GetProperty(Test::TestButton::Property::BACKGROUND_COLOR) ); + Property::Value fgColor( testButton.GetProperty(Test::TestButton::Property::FOREGROUND_COLOR) ); + + DALI_TEST_EQUALS( bgColor, Property::Value(Color::MAGENTA), 0.001, TEST_LOCATION ); + DALI_TEST_EQUALS( fgColor, Property::Value(Color::GREEN), 0.001, TEST_LOCATION ); + + tet_infoline("Testing that the signal handler is called only once"); + DALI_TEST_EQUALS( styleChangedSignalHandler.signalCount, 1, TEST_LOCATION ); + tet_infoline("Revert the style"); + + styleChangedSignalHandler.signalCount = 0; + StyleManager::Get().ApplyDefaultTheme(); + + bgColor = testButton.GetProperty(Test::TestButton::Property::BACKGROUND_COLOR); + fgColor = testButton.GetProperty(Test::TestButton::Property::FOREGROUND_COLOR); + + tet_infoline("Check that the property is reverted"); + DALI_TEST_EQUALS( bgColor, defaultBgColor, 0.001, TEST_LOCATION ); + DALI_TEST_EQUALS( fgColor, defaultFgColor, 0.001, TEST_LOCATION ); + DALI_TEST_EQUALS( bgColor, Property::Value(Color::YELLOW), 0.001, TEST_LOCATION ); + DALI_TEST_EQUALS( fgColor, Property::Value(Color::BLUE), 0.001, TEST_LOCATION ); + tet_infoline("Testing that the signal handler is called only once"); + DALI_TEST_EQUALS( styleChangedSignalHandler.signalCount, 1, TEST_LOCATION ); + + END_TEST; +} + + +int UtcDaliStyleManagerSetStyleConstantP(void) +{ + ToolkitTestApplication application; + + tet_infoline( " UtcDaliStyleManagerSetStyleConstantP" ); + + StyleManager manager = StyleManager::Get(); + + std::string key( "key" ); + Property::Value value( 100 ); + + manager.SetStyleConstant( key, value ); + + Property::Value returnedValue; + manager.GetStyleConstant( key, returnedValue ); + + DALI_TEST_CHECK( value.Get() == returnedValue.Get() ); + END_TEST; +} + + +int UtcDaliStyleManagerGetStyleConstantP(void) +{ + ToolkitTestApplication application; + + tet_infoline( " UtcDaliStyleManagerGetStyleConstantP" ); + + StyleManager manager = StyleManager::Get(); + + std::string key( "key" ); + Property::Value value( 100 ); + + manager.SetStyleConstant( key, value ); + + Property::Value returnedValue; + manager.GetStyleConstant( key, returnedValue ); + + DALI_TEST_CHECK( value.Get() == returnedValue.Get() ); + END_TEST; +} + +int UtcDaliStyleManagerGetStyleConstantN(void) +{ + ToolkitTestApplication application; + + tet_infoline( " UtcDaliStyleManagerGetStyleConstantN" ); + + StyleManager manager = StyleManager::Get(); + + std::string key2( "key2" ); + Property::Value returnedValue2; + DALI_TEST_CHECK( !manager.GetStyleConstant( key2, returnedValue2 ) ); + + END_TEST; +} + +int UtcDaliStyleManagerApplyStyle(void) +{ + ToolkitTestApplication application; + + tet_infoline( "UtcDaliStyleManagerApplyStyle - test that a style can be applied to a single button" ); + + const char* json1 = + "{\n" + " \"styles\":\n" + " {\n" + " \"testbutton\":\n" + " {\n" + " \"backgroundColor\":[1.0,1.0,0.0,1.0],\n" + " \"foregroundColor\":[0.0,0.0,1.0,1.0]\n" + " }\n" + " }\n" + "}\n"; + + const char* json2 = + "{\n" + " \"styles\":\n" + " {\n" + " \"testbutton\":\n" + " {\n" + " \"backgroundColor\":[1.0,0.0,0.0,1.0],\n" + " \"foregroundColor\":[0.0,1.0,1.0,1.0]\n" + " }\n" + " }\n" + "}\n"; + + // Add 2 buttons + Test::TestButton testButton = Test::TestButton::New(); + Test::TestButton testButton2 = Test::TestButton::New(); + Stage::GetCurrent().Add( testButton ); + Stage::GetCurrent().Add( testButton2 ); + StyleChangedSignalChecker styleChangedSignalHandler; + StyleManager styleManager = StyleManager::Get(); + + styleManager.StyleChangedSignal().Connect(&styleChangedSignalHandler, &StyleChangedSignalChecker::OnStyleChanged); + + tet_infoline("Apply the style"); + + std::string themeFile("ThemeOne"); + Test::StyleMonitor::SetThemeFileOutput(themeFile, json1); + styleManager.ApplyTheme(themeFile); + + // Render and notify + application.SendNotification(); + application.Render(); + + Property::Value themedBgColor( testButton.GetProperty(Test::TestButton::Property::BACKGROUND_COLOR) ); + Property::Value themedFgColor( testButton.GetProperty(Test::TestButton::Property::FOREGROUND_COLOR) ); + + // Apply the style to the test button: + std::string themeFile2("ThemeTwo"); + Test::StyleMonitor::SetThemeFileOutput(themeFile2, json2); + styleManager.ApplyStyle( testButton, themeFile2, "testbutton" ); + + tet_infoline("Check that the properties change for the first button"); + Property::Value bgColor = testButton.GetProperty(Test::TestButton::Property::BACKGROUND_COLOR); + Property::Value fgColor = testButton.GetProperty(Test::TestButton::Property::FOREGROUND_COLOR); + DALI_TEST_EQUALS( bgColor, Property::Value(Color::RED), 0.001, TEST_LOCATION ); + DALI_TEST_EQUALS( fgColor, Property::Value(Color::CYAN), 0.001, TEST_LOCATION ); + + DALI_TEST_NOT_EQUALS( bgColor, themedBgColor, 0.001, TEST_LOCATION ); + DALI_TEST_NOT_EQUALS( fgColor, themedFgColor, 0.001, TEST_LOCATION ); + + tet_infoline("Check that the properties remain the same for the second button"); + bgColor = testButton2.GetProperty(Test::TestButton::Property::BACKGROUND_COLOR); + fgColor = testButton2.GetProperty(Test::TestButton::Property::FOREGROUND_COLOR); + DALI_TEST_EQUALS( bgColor, themedBgColor, 0.001, TEST_LOCATION ); + DALI_TEST_EQUALS( fgColor, themedFgColor, 0.001, TEST_LOCATION ); + + END_TEST; +} + + +int UtcDaliStyleManagerStyleChangedSignal(void) { tet_infoline("Test that the StyleChange signal is fired when the font size is altered" ); - Test::StyleMonitor::SetThemeFileOutput(defaultTheme); + Test::StyleMonitor::SetThemeFileOutput( DALI_STYLE_DIR "dali-toolkit-default-theme.json", + defaultTheme ); ToolkitTestApplication application; diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dali-test-suite-utils.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dali-test-suite-utils.h index 5e10efe..7f81872 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dali-test-suite-utils.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dali-test-suite-utils.h @@ -272,6 +272,23 @@ inline void DALI_TEST_EQUALS(Type value1, Type value2, float epsilon, const char } } +template +inline void DALI_TEST_NOT_EQUALS(Type value1, Type value2, float epsilon, const char* location) +{ + if( CompareType(value1, value2, epsilon) ) + { + std::ostringstream o; + o << value1 << " != " << value2 << std::endl; + fprintf(stderr, "%s, checking %s", location, o.str().c_str()); + tet_result(TET_FAIL); + } + else + { + tet_result(TET_PASS); + } +} + + /** * Test whether two TimePeriods are within a certain distance of each other. * @param[in] value1 The first value diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.cpp index c4dac4e..873c8d2 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.cpp @@ -17,7 +17,7 @@ #include "dummy-control.h" -#include +#include namespace Dali { diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-style-monitor.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-style-monitor.cpp index ba0469d..3d85457 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-style-monitor.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-style-monitor.cpp @@ -40,6 +40,19 @@ const char* DEFAULT_THEME= " }\n" "}\n"; +struct NamedTheme +{ + NamedTheme( const std::string& name, const std::string& theme ) + : name(name), theme(theme) + { + } + + std::string name; + std::string theme; +}; +typedef std::vector< NamedTheme > NamedThemes; +NamedThemes gThemes; + std::string gTheme; std::string gFontFamily = Dali::StyleMonitor::DEFAULT_FONT_FAMILY; std::string gFontStyle = Dali::StyleMonitor::DEFAULT_FONT_STYLE; @@ -81,9 +94,8 @@ public: // Signals private: Dali::StyleMonitor::StyleChangeSignalType mStyleChangeSignal; static Dali::StyleMonitor mToolkitStyleMonitor; - std::string mTheme; - std::string mOutput; //<<< Test output. Use SetThemeFileOutput in a testharness to use it. + std::string mTheme; ///<< Current theme name }; Dali::StyleMonitor StyleMonitor::mToolkitStyleMonitor; @@ -135,6 +147,16 @@ void StyleMonitor::SetTheme(std::string path) bool StyleMonitor::LoadThemeFile( const std::string& filename, std::string& output ) { + for( NamedThemes::iterator iter = gThemes.begin(); iter != gThemes.end(); ++iter ) + { + NamedTheme& theme = *iter; + if( theme.name == filename ) + { + output = theme.theme; + return true; + } + } + if( !gTheme.empty() ) { output = gTheme; @@ -246,9 +268,19 @@ namespace Test namespace StyleMonitor { -void SetThemeFileOutput( const std::string& output ) +void SetThemeFileOutput( const std::string& name, const std::string& output ) { - gTheme = output; + for( NamedThemes::iterator iter = gThemes.begin(); iter != gThemes.end(); ++iter ) + { + NamedTheme& theme = *iter; + if( theme.name == name ) + { + theme.theme = output; + return; + } + } + + gThemes.push_back( NamedTheme( name, output ) ); } void SetDefaultFontFamily(const std::string& family) diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-style-monitor.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-style-monitor.h index 9bdb67c..b69a7db 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-style-monitor.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-style-monitor.h @@ -79,7 +79,7 @@ namespace Test { namespace StyleMonitor { -void SetThemeFileOutput( const std::string& output ); +void SetThemeFileOutput( const std::string& name, const std::string& output ); void SetDefaultFontFamily(const std::string& family); void SetDefaultFontStyle(const std::string& style); void SetDefaultFontSize( float size ); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ControlImpl.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ControlImpl.cpp index 7eb5f48..264a125 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ControlImpl.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ControlImpl.cpp @@ -34,7 +34,6 @@ #include #include -#include #include "dummy-control.h" @@ -934,7 +933,3 @@ int UtcDaliControlImplGetNextKeyboardFocusableActorP(void) END_TEST; } - - - - diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp index 4bb5f56..809b07b 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp @@ -23,7 +23,6 @@ #include #include #include ///< @todo to be removed when text-editor is added to the dali-toolkit.h -#include using namespace Dali; using namespace Toolkit; @@ -372,7 +371,7 @@ int utcDaliTextEditorAtlasRenderP(void) ToolkitTestApplication application; tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP"); StyleManager styleManager = StyleManager::Get(); - styleManager.RequestDefaultTheme(); + styleManager.ApplyDefaultTheme(); TextEditor editor = TextEditor::New(); DALI_TEST_CHECK( editor ); diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp index 982dffe..2498c57 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp @@ -22,7 +22,6 @@ #include #include #include -#include using namespace Dali; using namespace Toolkit; @@ -425,7 +424,7 @@ int utcDaliTextFieldAtlasRenderP(void) ToolkitTestApplication application; tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP"); StyleManager styleManager = StyleManager::Get(); - styleManager.RequestDefaultTheme(); + styleManager.ApplyDefaultTheme(); TextField field = TextField::New(); DALI_TEST_CHECK( field ); diff --git a/build/tizen/configure.ac b/build/tizen/configure.ac index a861a17..67156bb 100644 --- a/build/tizen/configure.ac +++ b/build/tizen/configure.ac @@ -168,6 +168,7 @@ AC_CONFIG_FILES([ dali-toolkit.pc docs/Makefile docs/dali.doxy + ../../automated-tests/CMakeLists.txt ]) AC_OUTPUT diff --git a/build/tizen/dali-toolkit/Makefile.am b/build/tizen/dali-toolkit/Makefile.am index f803a93..f967eb5 100644 --- a/build/tizen/dali-toolkit/Makefile.am +++ b/build/tizen/dali-toolkit/Makefile.am @@ -110,7 +110,6 @@ develapiimageatlasdir = $(develapidir)/image-atlas develapiscriptingdir = $(develapidir)/scripting develapishadereffectsdir = $(develapidir)/shader-effects develapitransitioneffectsdir = $(develapidir)/transition-effects -develapistylingdir = $(develapidir)/styling develapitoolbardir = $(develapicontrolsdir)/tool-bar develapitextselectionpopupdir = $(develapicontrolsdir)/text-controls @@ -130,7 +129,6 @@ develapiscripting_HEADERS = $(devel_api_scripting_header_files) develapishadowview_HEADERS = $(devel_api_shadow_view_header_files) develapishadereffects_HEADERS = $(devel_api_shader_effects_header_files) develapislider_HEADERS = $(devel_api_slider_header_files) -develapistyling_HEADERS = $(devel_api_styling_header_files) develapisuperblurview_HEADERS = $(devel_api_super_blur_view_header_files) develapitoolbar_HEADERS = $(devel_api_tool_bar_header_files) develapitransitioneffects_HEADERS = $(devel_api_transition_effects_header_files) @@ -151,6 +149,7 @@ publicapiscrollbardir = $(publicapicontrolsdir)/scroll-bar publicapiscrollabledir = $(publicapicontrolsdir)/scrollable publicapiscrollviewdir = $(publicapicontrolsdir)/scrollable/scroll-view publicapiitemviewdir = $(publicapicontrolsdir)/scrollable/item-view +publicapistylingdir = $(publicapidir)/styling publicapitableviewdir = $(publicapicontrolsdir)/table-view publicapitextcontrolsdir = $(publicapicontrolsdir)/text-controls publicapifocusmanagerdir = $(publicapidir)/focus-manager @@ -171,6 +170,7 @@ publicapipageturnview_HEADERS = $(public_api_page_turn_view_header_files publicapiscrollbar_HEADERS = $(public_api_scroll_bar_header_files) publicapiscrollable_HEADERS = $(public_api_scrollable_header_files) publicapiscrollview_HEADERS = $(public_api_scroll_view_header_files) +publicapistyling_HEADERS = $(public_api_styling_header_files) publicapitableview_HEADERS = $(public_api_table_view_header_files) publicapitextcontrols_HEADERS = $(public_api_text_controls_header_files) publicapifocusmanager_HEADERS = $(public_api_focus_manager_header_files) diff --git a/dali-toolkit/dali-toolkit.h b/dali-toolkit/dali-toolkit.h index 19a1993..36484f1 100644 --- a/dali-toolkit/dali-toolkit.h +++ b/dali-toolkit/dali-toolkit.h @@ -51,6 +51,7 @@ #include #include #include +#include #include #include #include diff --git a/dali-toolkit/devel-api/file.list b/dali-toolkit/devel-api/file.list index 8987002..f28fa71 100755 --- a/dali-toolkit/devel-api/file.list +++ b/dali-toolkit/devel-api/file.list @@ -22,7 +22,6 @@ devel_api_src_files = \ $(devel_api_src_dir)/controls/tool-bar/tool-bar.cpp \ $(devel_api_src_dir)/focus-manager/keyinput-focus-manager.cpp \ $(devel_api_src_dir)/image-atlas/image-atlas.cpp \ - $(devel_api_src_dir)/styling/style-manager.cpp \ $(devel_api_src_dir)/scripting/script.cpp \ $(devel_api_src_dir)/transition-effects/cube-transition-cross-effect.cpp \ $(devel_api_src_dir)/transition-effects/cube-transition-effect.cpp \ @@ -74,9 +73,6 @@ devel_api_focus_manager_header_files = \ devel_api_image_atlas_header_files = \ $(devel_api_src_dir)/image-atlas/image-atlas.h -devel_api_styling_header_files = \ - $(devel_api_src_dir)/styling/style-manager.h - devel_api_scripting_header_files = \ $(devel_api_src_dir)/scripting/script.h \ $(devel_api_src_dir)/scripting/script-plugin.h @@ -123,4 +119,3 @@ devel_api_transition_effects_header_files = \ $(devel_api_src_dir)/transition-effects/cube-transition-cross-effect.h \ $(devel_api_src_dir)/transition-effects/cube-transition-fold-effect.h \ $(devel_api_src_dir)/transition-effects/cube-transition-wave-effect.h - 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 8301a08..660e823 100644 --- a/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp @@ -807,7 +807,7 @@ void TextEditor::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange: case StyleChange::DEFAULT_FONT_CHANGE: { DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor::OnStyleChange DEFAULT_FONT_CHANGE\n"); - std::string newFont = styleManager.GetDefaultFontFamily(); + const std::string& newFont = GetImpl( styleManager ).GetDefaultFontFamily(); // Property system did not set the font so should update it. mController->UpdateAfterFontChange( newFont ); break; 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 ef00fc3..efec327 100644 --- a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp @@ -1029,7 +1029,7 @@ void TextField::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange:: case StyleChange::DEFAULT_FONT_CHANGE: { DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnStyleChange DEFAULT_FONT_CHANGE\n"); - std::string newFont = styleManager.GetDefaultFontFamily(); + const std::string& newFont = GetImpl( styleManager ).GetDefaultFontFamily(); // Property system did not set the font so should update it. mController->UpdateAfterFontChange( newFont ); break; 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 cc633b1..e7bac78 100644 --- a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp @@ -493,7 +493,7 @@ void TextLabel::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange:: case StyleChange::DEFAULT_FONT_CHANGE: { // Property system did not set the font so should update it. - std::string newFont = styleManager.GetDefaultFontFamily(); + 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 ); break; diff --git a/dali-toolkit/internal/styling/style-manager-impl.cpp b/dali-toolkit/internal/styling/style-manager-impl.cpp index f9569b9..a550a11 100644 --- a/dali-toolkit/internal/styling/style-manager-impl.cpp +++ b/dali-toolkit/internal/styling/style-manager-impl.cpp @@ -26,7 +26,7 @@ // INTERNAL INCLUDES #include #include -#include +#include #include namespace @@ -98,8 +98,7 @@ Toolkit::StyleManager StyleManager::Get() } StyleManager::StyleManager() -: mOrientationDegrees( 0 ), // Portrait - mDefaultFontSize( -1 ), +: mDefaultFontSize( -1 ), mDefaultFontFamily(""), mFeedbackStyle( NULL ) { @@ -123,43 +122,18 @@ StyleManager::~StyleManager() delete mFeedbackStyle; } -void StyleManager::SetOrientationValue( int orientation ) +void StyleManager::ApplyTheme( const std::string& themeFile ) { - if( orientation != mOrientationDegrees ) - { - mOrientationDegrees = orientation; - // TODO: if orientation changed, apply the new style to all controls - // dont want to really do the whole load from file again if the bundle contains both portrait & landscape - SetTheme( mThemeFile ); - } -} - -int StyleManager::GetOrientationValue() -{ - return mOrientationDegrees; -} - -void StyleManager::SetOrientation( Orientation orientation ) -{ - if( mOrientation ) - { - mOrientation.ChangedSignal().Disconnect( this, &StyleManager::OnOrientationChanged ); - } - - OnOrientationChanged( orientation ); - - if( mOrientation ) - { - mOrientation.ChangedSignal().Connect( this, &StyleManager::OnOrientationChanged ); - } + SetTheme( themeFile ); } -Orientation StyleManager::GetOrientation() +void StyleManager::ApplyDefaultTheme() { - return mOrientation; + std::string empty; + SetTheme( empty ); } -std::string StyleManager::GetDefaultFontFamily() const +const std::string& StyleManager::GetDefaultFontFamily() const { return mDefaultFontFamily; } @@ -181,22 +155,11 @@ bool StyleManager::GetStyleConstant( const std::string& key, Property::Value& va return false; } -void StyleManager::RequestThemeChange( const std::string& themeFile ) -{ - SetTheme( themeFile ); -} - -void StyleManager::RequestDefaultTheme() -{ - std::string empty; - SetTheme( empty ); -} - void StyleManager::ApplyThemeStyle( Toolkit::Control control ) { if( !mThemeBuilder ) { - RequestDefaultTheme(); + ApplyDefaultTheme(); } if( mThemeBuilder ) @@ -328,13 +291,7 @@ bool StyleManager::LoadJSON( Toolkit::Builder builder, const std::string& jsonFi void StyleManager::CollectQualifiers( StringList& qualifiersOut ) { // Append the relevant qualifier for orientation - int orientation = mOrientationDegrees; - - if( mOrientation ) - { - orientation = mOrientation.GetDegrees(); - } - + int orientation = 0; // Get the orientation from the system switch( orientation ) { case 90: @@ -405,15 +362,6 @@ void StyleManager::ApplyStyle( Toolkit::Builder builder, Toolkit::Control contro } } -void StyleManager::OnOrientationChanged( Orientation orientation ) -{ - mOrientation = orientation; - // TODO: if orientation changed, apply the new style to all controls - // dont want to really do the whole load from file again if the bundle contains both portrait & landscape - SetTheme( mThemeFile ); -} - - Toolkit::Builder StyleManager::FindCachedBuilder( const std::string& key ) { BuilderMap::iterator builderIt = mBuilderCache.find( key ); diff --git a/dali-toolkit/internal/styling/style-manager-impl.h b/dali-toolkit/internal/styling/style-manager-impl.h index 283cf96..f0c217c 100644 --- a/dali-toolkit/internal/styling/style-manager-impl.h +++ b/dali-toolkit/internal/styling/style-manager-impl.h @@ -27,7 +27,7 @@ #include // INTERNAL INCLUDES -#include +#include #include namespace Dali @@ -67,30 +67,20 @@ protected: public: // Public API - /** - * @copydoc Toolkit::StyleManager::SetOrientationValue - */ - void SetOrientationValue( int orientation ); - - /** - * @copydoc Toolkit::StyleManager::GetOrientationValue - */ - int GetOrientationValue(); - - /** - * @copydoc Toolkit::StyleManager::SetOrientation( Orientation orientation ) +/** + * @copydoc Toolkit::StyleManager::ApplyTheme */ - void SetOrientation( Orientation orientation ); + void ApplyTheme( const std::string& themeFile ); /** - * @copydoc Toolkit::StyleManager::GetOrientation + * @copydoc Toolkit::StyleManager::ApplyDefaultTheme */ - Orientation GetOrientation(); + void ApplyDefaultTheme(); /** * @copydoc Toolkit::StyleManager::GetDefaultFontFamily */ - std::string GetDefaultFontFamily() const; + const std::string& GetDefaultFontFamily() const; /** * @copydoc Toolkit::StyleManager::SetStyleConstant @@ -103,16 +93,6 @@ public: // Public API bool GetStyleConstant( const std::string& key, Property::Value& valueOut ); /** - * @copydoc Toolkit::StyleManager::RequestThemeChange - */ - void RequestThemeChange( const std::string& themeFile ); - - /** - * @copydoc Toolkit::StyleManager::RequestDefaultTheme - */ - void RequestDefaultTheme(); - - /** * @brief Apply the theme style to a control. * * @param[in] control The control to apply style. @@ -210,13 +190,6 @@ private: void ApplyStyle( Toolkit::Builder builder, Toolkit::Control control ); /** - * @brief Callback for orientation changes - * - * @param[in] orientation The orientation object - */ - void OnOrientationChanged( Orientation orientation ); - - /** * Search for a builder in the cache * * @param[in] key The key the builder was cached under @@ -259,9 +232,6 @@ private: Toolkit::Builder mThemeBuilder; ///< Builder for all default theme properties StyleMonitor mStyleMonitor; ///< Style monitor handle - Orientation mOrientation; ///< Handle to application orientation object - int mOrientationDegrees; ///< Directly set value of orientation - int mDefaultFontSize; ///< Logical size, not a point-size std::string mDefaultFontFamily; std::string mThemeFile; ///< The full path of the current theme file diff --git a/dali-toolkit/public-api/controls/control-impl.cpp b/dali-toolkit/public-api/controls/control-impl.cpp index 2019553..45fbe44 100644 --- a/dali-toolkit/public-api/controls/control-impl.cpp +++ b/dali-toolkit/public-api/controls/control-impl.cpp @@ -34,10 +34,10 @@ // INTERNAL INCLUDES #include #include +#include #include #include #include -#include #include #include diff --git a/dali-toolkit/public-api/file.list b/dali-toolkit/public-api/file.list index 73d06a4..16d923f 100755 --- a/dali-toolkit/public-api/file.list +++ b/dali-toolkit/public-api/file.list @@ -27,6 +27,7 @@ public_api_src_files = \ $(public_api_src_dir)/controls/text-controls/text-label.cpp \ $(public_api_src_dir)/controls/text-controls/text-field.cpp \ $(public_api_src_dir)/controls/gaussian-blur-view/gaussian-blur-view.cpp \ + $(public_api_src_dir)/styling/style-manager.cpp \ $(public_api_src_dir)/accessibility-manager/accessibility-manager.cpp \ $(public_api_src_dir)/focus-manager/keyboard-focus-manager.cpp \ $(public_api_src_dir)/dali-toolkit-version.cpp \ @@ -88,6 +89,9 @@ public_api_scroll_view_header_files = \ $(public_api_src_dir)/controls/scrollable/scroll-view/scroll-view-page-path-effect.h \ $(public_api_src_dir)/controls/scrollable/scroll-view/scroll-view.h +public_api_styling_header_files = \ + $(public_api_src_dir)/styling/style-manager.h + public_api_table_view_header_files = \ $(public_api_src_dir)/controls/table-view/table-view.h diff --git a/dali-toolkit/devel-api/styling/style-manager.cpp b/dali-toolkit/public-api/styling/style-manager.cpp similarity index 66% rename from dali-toolkit/devel-api/styling/style-manager.cpp rename to dali-toolkit/public-api/styling/style-manager.cpp index 01be6ba..e7231d6 100644 --- a/dali-toolkit/devel-api/styling/style-manager.cpp +++ b/dali-toolkit/public-api/styling/style-manager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. @@ -16,7 +16,7 @@ // CLASS HEADER -#include +#include // EXTERNAL INCLUDES @@ -43,29 +43,14 @@ StyleManager StyleManager::Get() return Internal::StyleManager::Get(); } -void StyleManager::SetOrientationValue( int orientation ) +void StyleManager::ApplyTheme( const std::string& themeFile ) { - GetImpl(*this).SetOrientationValue( orientation ); + GetImpl(*this).ApplyTheme( themeFile ); } -int StyleManager::GetOrientationValue() +void StyleManager::ApplyDefaultTheme() { - return GetImpl(*this).GetOrientationValue(); -} - -void StyleManager::SetOrientation( Orientation orientation ) -{ - GetImpl(*this).SetOrientation( orientation ); -} - -std::string StyleManager::GetDefaultFontFamily() const -{ - return GetImpl(*this).GetDefaultFontFamily(); -} - -Orientation StyleManager::GetOrientation() -{ - return GetImpl(*this).GetOrientation(); + GetImpl(*this).ApplyDefaultTheme(); } void StyleManager::SetStyleConstant( const std::string& key, const Property::Value& value ) @@ -83,24 +68,14 @@ void StyleManager::ApplyStyle( Toolkit::Control control, const std::string& json GetImpl(*this).ApplyStyle( control, jsonFileName, styleName ); } -StyleManager::StyleManager( Internal::StyleManager *impl ) - : BaseHandle( impl ) -{ -} - StyleManager::StyleChangedSignalType& StyleManager::StyleChangedSignal() { return GetImpl( *this ).StyleChangedSignal(); } -void StyleManager::RequestThemeChange( const std::string& themeFile ) -{ - GetImpl(*this).RequestThemeChange( themeFile ); -} - -void StyleManager::RequestDefaultTheme() +StyleManager::StyleManager( Internal::StyleManager *impl ) + : BaseHandle( impl ) { - GetImpl(*this).RequestDefaultTheme(); } } // namespace Toolkit diff --git a/dali-toolkit/devel-api/styling/style-manager.h b/dali-toolkit/public-api/styling/style-manager.h similarity index 59% rename from dali-toolkit/devel-api/styling/style-manager.h rename to dali-toolkit/public-api/styling/style-manager.h index 2d790a4..54191e4 100644 --- a/dali-toolkit/devel-api/styling/style-manager.h +++ b/dali-toolkit/public-api/styling/style-manager.h @@ -2,7 +2,7 @@ #define __DALI_TOOLKIT_STYLE_MANAGER_H__ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. @@ -18,7 +18,6 @@ */ // EXTERNAL INCLUDES -#include #include // INTERNAL INCLUDES @@ -36,28 +35,43 @@ class StyleManager; } /** - * @brief StyleManager provides the following functionalities: + * @addtogroup dali_toolkit_managers + * @{ + */ + +/** + * @brief StyleManager informs applications of system theme change, + * and supports application theme change at runtime. * * Applies various styles to Controls using the properties system. - * On theme change a signal is raised that controls can be configured to listen to. * - * The default theme is automatically loaded and applied. + * On theme change, it automatically updates all controls, then raises + * a signal to inform the application. + * + * The default theme is automatically loaded and applied, followed by + * any application specific theme defined in Application::New(). * * If the application wants to customize the theme, RequestThemeChange - * needs to be called. Internal::Control can be configured to - * register for the signals that are required from StyleManager, such - * as theme change. + * needs to be called. + * + * Signals + * | %Signal Name | Method | + * |------------------------------------------------------------| + * | styleChanged | @ref StyleChangedSignal() | + * @SINCE_1_1.32 */ class DALI_IMPORT_API StyleManager : public BaseHandle { public: - // Signals + /// @brief Style Changed signal. Emitted after controls have been updated typedef Signal< void ( StyleManager, StyleChange::Type ) > StyleChangedSignalType; /** * @brief Create a StyleManager handle; this can be initialised with StyleManager::Get() + * * Calling member functions with an uninitialised handle is not allowed. + * @SINCE_1_1.32 */ StyleManager(); @@ -65,71 +79,54 @@ public: * @brief Destructor * * This is non-virtual since derived Handle types must not contain data or virtual methods. + * @SINCE_1_1.32 */ ~StyleManager(); /** * @brief Get the singleton of StyleManager object. * + * @SINCE_1_1.32 * @return A handle to the StyleManager control. */ static StyleManager Get(); /** - * @brief Specify the orientation value directly for the style manager + * @brief Apply a new theme to the application. This will be merged + * on top of the default Toolkit theme. * - * @param[in] orientation The orientation in degrees - */ - void SetOrientationValue( int orientation ); - - /** - * @brief Return the orientation value + * If the application theme file doesn't style all controls that the + * application uses, then the default Toolkit theme will be used + * instead for those controls. * - * @return The orientation value - */ - int GetOrientationValue(); - - /** - * @brief Set the orientation object. This will take precedence over setting the orientation value. + * On application startup, it is suggested that the theme file name is + * passed to Application::New instead of using this API to prevent + * controls being styled more than once. + * @sa Application::New() * - * @param[in] orientation Device orientation + * @SINCE_1_1.32 + * @param[in] themeFile If a relative path is specified, then this is relative + * to the directory returned by app_get_resource_path(). */ - void SetOrientation( Orientation orientation ); + void ApplyTheme( const std::string& themeFile ); /** - * @brief Return the orientation object + * @brief Apply the default Toolkit theme. * - * @return The orientation. - */ - 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 - * on in the event processing finished callback. + * Request that any application specific styling is removed + * and that the default Toolkit theme is re-applied. * - * @param[in] themeFile This is just the JSON theme file name and not the full path. + * @SINCE_1_1.32 */ - void RequestThemeChange( const std::string& themeFile ); - - /** - * @brief Request a change to the default theme - */ - void RequestDefaultTheme(); + void ApplyDefaultTheme(); /** * @brief Set a constant for use when building styles * - * A constant is used in JSON files e.g. "myImage":"{ROOT_PATH}/mypath/image.jpg" - * where the string "{ROOT_PATH}" is substituted with the value. + * A constant is used in JSON files e.g. "myImage":"{RELATIVE_PATH}/image.jpg" + * where the string "{RELATIVE_PATH}" is substituted with the value. * + * @SINCE_1_1.32 * @param[in] key The key of the constant * @param[in] value The value of the constant */ @@ -138,6 +135,7 @@ public: /** * @brief Return the style constant set for a specific key * + * @SINCE_1_1.32 * @param[in] key The key of the constant * @param[out] valueOut The value of the constant if it exists * @@ -148,11 +146,11 @@ public: /** * @brief Apply the specified style to the control. * - * The JSON file will be cached and subsequent calls using the same JSON file name will - * use the already loaded cached values instead. - * - * @param[in] control The control to apply style. - * @param[in] jsonFileName The name of the JSON style file to apply. + * @SINCE_1_1.32 + * @param[in] control The control to which to apply the style. + * @param[in] jsonFileName The name of the JSON style file to apply. If a + * relative path is specified, then this is relative to the directory + * returned by app_get_resource_path(). * @param[in] styleName The name of the style within the JSON file to apply. */ void ApplyStyle( Toolkit::Control control, const std::string& jsonFileName, const std::string& styleName ); @@ -163,6 +161,7 @@ public: // Signals * @brief This signal is emitted after the style (e.g. theme/font change) has changed * and the controls have been informed. * + * @SINCE_1_1.32 * A callback of the following type may be connected: * @code * void YourCallbackName( StyleManager styleManager, StyleChange change ); @@ -174,14 +173,19 @@ public: // Signals public: /** - * @brief Creates a new handle from the implementation. + * @brief Allows the creation of a StyleManager handle from an internal pointer. * + * @note Not intended for application developers + * @SINCE_1_1.32 * @param[in] impl A pointer to the object. */ explicit DALI_INTERNAL StyleManager( Internal::StyleManager *impl ); }; // class StyleManager +/** + * @} + */ } // namespace Toolkit } // namespace Dali