#include "style-manager-impl.h"
// EXTERNAL INCLUDES
-#include <fstream>
-#include <iostream>
-#include <sstream>
#include <dali/devel-api/adaptor-framework/singleton-service.h>
#include <dali/public-api/object/type-registry.h>
#include <dali/devel-api/object/type-registry-helper.h>
const char* PORTRAIT_QUALIFIER = "portrait";
const char* FONT_SIZE_QUALIFIER = "font-size-";
-const char* DEFAULT_THEME = DALI_STYLE_DIR "tizen-default-theme.json";
+const char* DEFAULT_THEME = DALI_STYLE_DIR "dali-toolkit-default-theme.json";
const char* PACKAGE_PATH_KEY = "PACKAGE_PATH";
const char* DEFAULT_PACKAGE_PATH = DALI_DATA_READ_ONLY_DIR "/toolkit/";
// Add theme builder constants
mThemeBuilderConstants[ PACKAGE_PATH_KEY ] = DEFAULT_PACKAGE_PATH;
- StyleMonitor styleMonitor( StyleMonitor::Get() );
- if( styleMonitor )
+ mStyleMonitor = StyleMonitor::Get();
+ if( mStyleMonitor )
{
- styleMonitor.StyleChangeSignal().Connect( this, &StyleManager::StyleMonitorChange );
+ mStyleMonitor.StyleChangeSignal().Connect( this, &StyleManager::StyleMonitorChange );
- mDefaultFontSize = styleMonitor.GetDefaultFontSize();
+ mDefaultFontSize = mStyleMonitor.GetDefaultFontSize();
}
}
{
DALI_ASSERT_DEBUG( 0 != filename.length());
- std::ifstream in( filename.c_str(), std::ios::in );
- if( in )
+ // as toolkit is platform agnostic, it cannot load files from filesystem
+ // ask style monitor to load the style sheet
+ if( mStyleMonitor )
{
- std::stringstream buffer;
- buffer << in.rdbuf();
-
- stringOut = buffer.str();
-
- in.close();
-
- return true;
+ return mStyleMonitor.LoadThemeFile( filename, stringOut );
}
return false;
mThemeBuilder = CreateBuilder( mThemeBuilderConstants );
if ( LoadJSON( mThemeBuilder, mThemeFile ) )
{
- StyleChange change;
- change.themeChange = true;
- mStyleChangeSignal.Emit( Toolkit::StyleManager::Get(), change );
+ mStyleChangeSignal.Emit( Toolkit::StyleManager::Get(), StyleChange::THEME_CHANGE );
}
else
{
mBuilderCache[ key ] = builder;
}
-void StyleManager::StyleMonitorChange( StyleMonitor styleMonitor, StyleChange styleChange )
+void StyleManager::StyleMonitorChange( StyleMonitor styleMonitor, StyleChange::Type styleChange )
{
- if( styleChange.defaultFontSizeChange )
- {
- mDefaultFontSize = styleMonitor.GetDefaultFontSize();
- }
-
- if( styleChange.themeChange )
+ switch ( styleChange )
{
- if( ! styleChange.themeFilePath.empty() )
+ case StyleChange::DEFAULT_FONT_CHANGE:
{
- mThemeFile = styleChange.themeFilePath;
+ break;
}
- else
+
+ case StyleChange::DEFAULT_FONT_SIZE_CHANGE:
{
- mThemeFile = DEFAULT_THEME;
+ mDefaultFontSize = styleMonitor.GetDefaultFontSize();
+ break;
}
- SetTheme();
+ case StyleChange::THEME_CHANGE:
+ {
+ const std::string& newTheme = styleMonitor.GetTheme();
+ if( ! newTheme.empty() )
+ {
+ mThemeFile = newTheme;
+ }
+ else
+ {
+ mThemeFile = DEFAULT_THEME;
+ }
+
+ SetTheme();
+ break;
+ }
}
mStyleChangeSignal.Emit( Toolkit::StyleManager::Get(), styleChange );