: 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 )
}
}
-Toolkit::StyleManager::StyleChangeSignalType& StyleManager::StyleChangeSignal()
+Toolkit::StyleManager::StyleChangedSignalType& StyleManager::StyleChangedSignal()
{
- return mStyleChangeSignal;
+ return mStyleChangedSignal;
}
+Toolkit::StyleManager::StyleChangedSignalType& StyleManager::ControlStyleChangeSignal()
+{
+ return mControlStyleChangeSignal;
+}
-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)
{
mFeedbackStyle->StyleChanged( mThemeFile, StyleChange::THEME_CHANGE );
}
- mStyleChangeSignal.Emit( Toolkit::StyleManager::Get(), StyleChange::THEME_CHANGE );
+ EmitStyleChangeSignals(StyleChange::THEME_CHANGE);
}
else
{
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;
}
}
+ EmitStyleChangeSignals( styleChange );
+}
+
+void StyleManager::EmitStyleChangeSignals( StyleChange::Type styleChange )
+{
+ Toolkit::StyleManager styleManager = StyleManager::Get();
+
+ // Update Controls first
+ mControlStyleChangeSignal.Emit( styleManager, styleChange );
- mStyleChangeSignal.Emit( Toolkit::StyleManager::Get(), styleChange );
+ // Inform application last
+ mStyleChangedSignal.Emit( styleManager, styleChange );
}
+
} // namespace Internal
} // namespace Toolkit