X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fstyling%2Fstyle-manager-impl.cpp;h=85aa069419ab16130630ce99990eb4e268868d08;hp=5178020ddd838ff6681c3b9ccf756d09372e3d29;hb=4ff601968ee16e6d401977900d2aed328bdc6707;hpb=2f5d4ba8f28af430695ea2a6692fb3d11310af99;ds=sidebyside diff --git a/dali-toolkit/internal/styling/style-manager-impl.cpp b/dali-toolkit/internal/styling/style-manager-impl.cpp index 5178020..85aa069 100644 --- a/dali-toolkit/internal/styling/style-manager-impl.cpp +++ b/dali-toolkit/internal/styling/style-manager-impl.cpp @@ -101,7 +101,6 @@ StyleManager::StyleManager() : mOrientationDegrees( 0 ), // Portrait mDefaultFontSize( -1 ), mDefaultFontFamily(""), - mThemeFile( DEFAULT_THEME ), mFeedbackStyle( NULL ) { // Add theme builder constants @@ -131,7 +130,7 @@ void StyleManager::SetOrientationValue( int orientation ) 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(); + SetTheme( mThemeFile ); } } @@ -184,15 +183,13 @@ bool StyleManager::GetStyleConstant( const std::string& key, Property::Value& va void StyleManager::RequestThemeChange( const std::string& themeFile ) { - mThemeFile = themeFile; - - // need to do style change synchronously as app might create a UI control on the next line - SetTheme(); + SetTheme( themeFile ); } void StyleManager::RequestDefaultTheme() { - RequestThemeChange( DEFAULT_THEME ); + std::string empty; + SetTheme( empty ); } void StyleManager::ApplyThemeStyle( Toolkit::Control control ) @@ -256,12 +253,22 @@ Toolkit::StyleManager::StyleChangeSignalType& StyleManager::StyleChangeSignal() return mStyleChangeSignal; } - -void StyleManager::SetTheme() +void StyleManager::SetTheme( const std::string& themeFile ) { + bool themeLoaded = false; + mThemeBuilder = CreateBuilder( mThemeBuilderConstants ); - if( LoadJSON( mThemeBuilder, mThemeFile ) ) + // Always load the default theme first, then merge in the custom theme if present + themeLoaded = LoadJSON( mThemeBuilder, DEFAULT_THEME ); + + if( ! themeFile.empty() ) + { + mThemeFile = themeFile; + themeLoaded = LoadJSON( mThemeBuilder, mThemeFile ); + } + + if( themeLoaded ) { if(mFeedbackStyle) { @@ -398,7 +405,7 @@ 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(); + SetTheme( mThemeFile ); } @@ -436,17 +443,7 @@ void StyleManager::StyleMonitorChange( StyleMonitor styleMonitor, StyleChange::T case StyleChange::THEME_CHANGE: { - const std::string& newTheme = styleMonitor.GetTheme(); - if( ! newTheme.empty() ) - { - mThemeFile = newTheme; - } - else - { - mThemeFile = DEFAULT_THEME; - } - - SetTheme(); + SetTheme( styleMonitor.GetTheme() ); break; } }