: mOrientationDegrees( 0 ), // Portrait
mDefaultFontSize( -1 ),
mDefaultFontFamily(""),
- mThemeFile( DEFAULT_THEME ),
mFeedbackStyle( NULL )
{
// Add theme builder constants
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 );
}
}
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 )
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)
{
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 );
}
case StyleChange::THEME_CHANGE:
{
- const std::string& newTheme = styleMonitor.GetTheme();
- if( ! newTheme.empty() )
- {
- mThemeFile = newTheme;
- }
- else
- {
- mThemeFile = DEFAULT_THEME;
- }
-
- SetTheme();
+ SetTheme( styleMonitor.GetTheme() );
break;
}
}