X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fstyling%2Fstyle-manager-impl.cpp;h=106ec542ef0a26aa26059019d4219526f35f49ad;hb=a08597a200d87bbc9e43fce6a94a3269c972346e;hp=b38d23b0b815cc5f605086a52b853ebff024558f;hpb=b42c8d3f708366a9ce7c286f941af3bdeb054640;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/styling/style-manager-impl.cpp b/dali-toolkit/internal/styling/style-manager-impl.cpp index b38d23b..106ec54 100644 --- a/dali-toolkit/internal/styling/style-manager-impl.cpp +++ b/dali-toolkit/internal/styling/style-manager-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -34,7 +34,7 @@ namespace { -const char* LANDSCAPE_QUALIFIER = "landscape"; +//const char* LANDSCAPE_QUALIFIER = "landscape"; const char* PORTRAIT_QUALIFIER = "portrait"; const char* FONT_SIZE_QUALIFIER = "fontsize"; @@ -45,6 +45,10 @@ const char* APPLICATION_RESOURCE_PATH_KEY = "APPLICATION_RESOURCE_PATH"; const char* DEFAULT_PACKAGE_PATH = DALI_DATA_READ_ONLY_DIR "/toolkit/"; +#if defined(DEBUG_ENABLED) +Debug::Filter* gLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_STYLE"); +#endif + } // namespace namespace Dali @@ -133,8 +137,7 @@ void StyleManager::ApplyTheme( const std::string& themeFile ) void StyleManager::ApplyDefaultTheme() { - std::string empty; - SetTheme( empty ); + SetTheme( DEFAULT_THEME ); } const std::string& StyleManager::GetDefaultFontFamily() const @@ -228,31 +231,80 @@ Toolkit::StyleManager::StyleChangedSignalType& StyleManager::ControlStyleChangeS void StyleManager::SetTheme( const std::string& themeFile ) { bool themeLoaded = false; + bool loading = false; - mThemeBuilder = CreateBuilder( mThemeBuilderConstants ); - - // Always load the default theme first, then merge in the custom theme if present - themeLoaded = LoadJSON( mThemeBuilder, DEFAULT_THEME ); + // If we haven't loaded a theme, or the stored theme file is empty, or + // the previously loaded theme is different to the requested theme, + // first reset the builder and load the default theme. + if( ! mThemeBuilder || mThemeFile.empty() || mThemeFile.compare( themeFile ) != 0 ) + { + loading = true; + mThemeBuilder = CreateBuilder( mThemeBuilderConstants ); + themeLoaded = LoadJSON( mThemeBuilder, DEFAULT_THEME ); // Sets themeLoaded to true if theme exists + } - if( ! themeFile.empty() ) + if( themeFile.compare(DEFAULT_THEME) != 0 ) { - mThemeFile = themeFile; - themeLoaded = LoadJSON( mThemeBuilder, mThemeFile ); + // The theme is different to the default: Merge it + loading = true; + themeLoaded |= LoadJSON( mThemeBuilder, themeFile ); } - if( themeLoaded ) + if( loading ) { - if(mFeedbackStyle) + mThemeFile = themeFile; + + if( themeLoaded ) { - mFeedbackStyle->StyleChanged( mThemeFile, StyleChange::THEME_CHANGE ); + // We've successfully loaded the theme file + if(mFeedbackStyle) + { + mFeedbackStyle->StyleChanged( mThemeFile, StyleChange::THEME_CHANGE ); + } + + EmitStyleChangeSignals(StyleChange::THEME_CHANGE); } + else + { + // We tried to load a theme, but it failed. Ensure the builder is reset + mThemeBuilder.Reset(); + mThemeFile.clear(); + } + } +} + +const Property::Map StyleManager::GetConfigurations() +{ + DALI_LOG_STREAM( gLogFilter, Debug::Concise, "GetConfigurations()\n On entry, mThemeBuilder: " << (bool(mThemeBuilder)?"Created":"Empty") << " mThemeFile: " << mThemeFile); - EmitStyleChangeSignals(StyleChange::THEME_CHANGE); + Property::Map result; + if( mThemeBuilder ) + { + result = mThemeBuilder.GetConfigurations(); } else { - mThemeBuilder.Reset(); + DALI_LOG_STREAM( gLogFilter, Debug::Concise, "GetConfigurations() Loading default theme" ); + + bool themeLoaded = false; + + mThemeBuilder = CreateBuilder( mThemeBuilderConstants ); + + // Load default theme because this is first try to load stylesheet. + themeLoaded = LoadJSON( mThemeBuilder, DEFAULT_THEME ); + mThemeFile = DEFAULT_THEME; + + if( themeLoaded ) + { + result = mThemeBuilder.GetConfigurations(); + } + DALI_LOG_STREAM( gLogFilter, Debug::Concise, " themeLoaded" << (themeLoaded?"success":"failure") ); } + + DALI_LOG_STREAM( gLogFilter, Debug::Concise, "GetConfigurations()\n On exit, result Count: " << (result.Count() != 0) ); + DALI_LOG_STREAM( gLogFilter, Debug::Verbose, " result: " << result ); + + return result; } bool StyleManager::LoadFile( const std::string& filename, std::string& stringOut ) @@ -295,23 +347,16 @@ bool StyleManager::LoadJSON( Toolkit::Builder builder, const std::string& jsonFi static void CollectQualifiers( std::vector& qualifiersOut ) { // Append the relevant qualifier for orientation - int orientation = 0; // Get the orientation from the system - switch( orientation ) - { - case 90: - case 270: - { - qualifiersOut.push_back( std::string( LANDSCAPE_QUALIFIER ) ); - break; - } - case 180: - case 0: // fall through - default: - { - qualifiersOut.push_back( std::string( PORTRAIT_QUALIFIER ) ); - break; - } - } + // int orientation = 0; // Get the orientation from the system + /* + //// To Do ///// + Getting orientation from the system, and determine Qualifie LANDSCAPE or PORTRAIT + orientation 0, 180 : PORTRAIT_QUALIFIER (default) + orientation 90, 270 : LANDSCAPE_QUALIFIER + */ + + qualifiersOut.push_back( std::string( PORTRAIT_QUALIFIER ) ); + } /**