build
build.log
tct*core.h
+CMakeLists.txt
results_xml.*
INCLUDE(FindPkgConfig)
SET(BIN_DIR "/opt/usr/bin")
+ADD_DEFINITIONS(-DDALI_STYLE_DIR="@dataReadOnlyDir@/toolkit/styles/")
+
INCLUDE_DIRECTORIES(
- src/common
+ src/common
)
ADD_SUBDIRECTORY(src)
#include <dali-toolkit-test-suite-utils.h>
#include <dali-toolkit/dali-toolkit.h>
#include <dali/integration-api/events/touch-event-integ.h>
-#include <dali-toolkit/devel-api/styling/style-manager.h>
#include <dali-toolkit/devel-api/builder/builder.h>
#include <test-button.h>
#include <test-animation-data.h>
test_return_value = TET_PASS;
}
-int UtcDaliStyleManagerGet(void)
+
+int UtcDaliStyleManagerConstructorP(void)
{
ToolkitTestApplication application;
- tet_infoline(" UtcDaliStyleManagerGet");
-
- // Register Type
- TypeInfo type;
- type = TypeRegistry::Get().GetTypeInfo( "StyleManager" );
- DALI_TEST_CHECK( type );
- BaseHandle handle = type.CreateInstance();
- DALI_TEST_CHECK( handle );
-
- StyleManager manager;
-
- manager = StyleManager::Get();
- DALI_TEST_CHECK(manager);
-
- StyleManager newManager = StyleManager::Get();
- DALI_TEST_CHECK(newManager);
-
- // Check that focus manager is a singleton
- DALI_TEST_CHECK(manager == newManager);
+ tet_infoline(" UtcDaliStyleManagerConstructorP");
+ StyleManager styleManager;
+ DALI_TEST_CHECK( !styleManager);
END_TEST;
}
-int UtcDaliStyleManagerSetOrientationValue(void)
+int UtcDaliStyleManagerCopyConstructorP(void)
{
- ToolkitTestApplication application;
-
- tet_infoline( " UtcDaliStyleManagerSetOrientationValue" );
+ TestApplication application;
- StyleManager manager = StyleManager::Get();
-
- int orientation1 = 0;
- manager.SetOrientationValue( orientation1 );
- DALI_TEST_CHECK( manager.GetOrientationValue() == orientation1 );
-
- int orientation2 = 180;
- manager.SetOrientationValue( orientation2 );
- DALI_TEST_CHECK( manager.GetOrientationValue() == orientation2 );
+ StyleManager styleManager = StyleManager::Get();
+ StyleManager copyOfStyleManager( styleManager );
+ DALI_TEST_CHECK( copyOfStyleManager );
END_TEST;
}
-int UtcDaliStyleManagerSetOrientation(void)
+int UtcDaliStyleManagerAssignmentOperatorP(void)
{
- ToolkitTestApplication application;
-
- tet_infoline( " UtcDaliStyleManagerSetOrientation" );
+ TestApplication application;
- StyleManager manager = StyleManager::Get();
-
- Orientation orientation;
-
- manager.SetOrientation( orientation );
-
- DALI_TEST_CHECK( manager.GetOrientation() == orientation );
+ StyleManager styleManager = StyleManager::Get();
+ StyleManager copyOfStyleManager = styleManager;
+ DALI_TEST_CHECK( copyOfStyleManager );
+ DALI_TEST_CHECK( copyOfStyleManager == styleManager );
END_TEST;
}
-int UtcDaliStyleManagerSetStyleConstant(void)
+int UtcDaliStyleManagerGet(void)
{
ToolkitTestApplication application;
- tet_infoline( " UtcDaliStyleManagerSetStyleConstant" );
-
- StyleManager manager = StyleManager::Get();
-
- std::string key( "key" );
- Property::Value value( 100 );
+ tet_infoline(" UtcDaliStyleManagerGet");
- manager.SetStyleConstant( key, value );
+ // Register Type
+ TypeInfo type;
+ type = TypeRegistry::Get().GetTypeInfo( "StyleManager" );
+ DALI_TEST_CHECK( type );
+ BaseHandle handle = type.CreateInstance();
+ DALI_TEST_CHECK( handle );
- Property::Value returnedValue;
- manager.GetStyleConstant( key, returnedValue );
+ StyleManager manager;
- DALI_TEST_CHECK( value.Get<int>() == returnedValue.Get<int>() );
+ manager = StyleManager::Get();
+ DALI_TEST_CHECK(manager);
- std::string key2( "key2" );
- Property::Value returnedValue2;
- DALI_TEST_CHECK( !manager.GetStyleConstant( key2, returnedValue2 ) );
+ StyleManager newManager = StyleManager::Get();
+ DALI_TEST_CHECK(newManager);
+ // Check that focus manager is a singleton
+ DALI_TEST_CHECK(manager == newManager);
END_TEST;
}
+
namespace
{
class StyleChangedSignalChecker : public ConnectionTracker
} // anonymous namespace
-int UtcDaliStyleManagerPropertyOverride(void)
+int UtcDaliStyleManagerApplyTheme(void)
{
ToolkitTestApplication application;
- tet_infoline( "Testing StyleManager property overrides" );
+ tet_infoline( "Testing StyleManager ApplyTheme" );
const char* json1 =
"{\n"
tet_infoline("Apply the style");
- Test::StyleMonitor::SetThemeFileOutput(json1);
std::string themeFile("ThemeOne");
- StyleManager::Get().RequestThemeChange(themeFile);
+ Test::StyleMonitor::SetThemeFileOutput(themeFile, json1);
+ StyleManager::Get().ApplyTheme(themeFile);
Property::Value bgColor( testButton.GetProperty(Test::TestButton::Property::BACKGROUND_COLOR) );
Property::Value fgColor( testButton.GetProperty(Test::TestButton::Property::FOREGROUND_COLOR) );
tet_infoline("Apply the style again");
styleChangedSignalHandler.signalCount = 0;
- StyleManager::Get().RequestThemeChange(themeFile);
+ StyleManager::Get().ApplyTheme(themeFile);
bgColor = testButton.GetProperty(Test::TestButton::Property::BACKGROUND_COLOR);
fgColor = testButton.GetProperty(Test::TestButton::Property::FOREGROUND_COLOR);
tet_infoline( "Load a different stylesheet");
tet_infoline("Apply the new style");
- Test::StyleMonitor::SetThemeFileOutput(json2);
+ std::string themeFile2("ThemeTwo");
+ Test::StyleMonitor::SetThemeFileOutput(themeFile2, json2);
styleChangedSignalHandler.signalCount = 0;
- std::string themeFile2("ThemeTwo");
- StyleManager::Get().RequestThemeChange(themeFile2);
+ StyleManager::Get().ApplyTheme(themeFile2);
bgColor = testButton.GetProperty(Test::TestButton::Property::BACKGROUND_COLOR);
fgColor = testButton.GetProperty(Test::TestButton::Property::FOREGROUND_COLOR);
END_TEST;
}
-int UtcDaliStyleManagerFontSizeChange(void)
+
+int UtcDaliStyleManagerApplyDefaultTheme(void)
+{
+ tet_infoline( "Testing StyleManager ApplyTheme" );
+
+ const char* defaultTheme =
+ "{\n"
+ " \"styles\":\n"
+ " {\n"
+ " \"testbutton\":\n"
+ " {\n"
+ " \"backgroundColor\":[1.0,1.0,0.0,1.0],\n"
+ " \"foregroundColor\":[0.0,0.0,1.0,1.0]\n"
+ " }\n"
+ " }\n"
+ "}\n";
+ // Bg: Yellow, Fg: Blue
+
+ const char* appTheme =
+ "{\n"
+ " \"styles\":\n"
+ " {\n"
+ " \"testbutton\":\n"
+ " {\n"
+ " \"backgroundColor\":[1.0,0.0,1.0,1.0],\n"
+ " \"foregroundColor\":[0.0,1.0,0.0,1.0]\n"
+ " }\n"
+ " }\n"
+ "}\n";
+ // Bg::Magenta, Fg:Green
+
+ std::string filepath(TEST_RESOURCE_DIR "");
+
+ Test::StyleMonitor::SetThemeFileOutput( DALI_STYLE_DIR "dali-toolkit-default-theme.json",
+ defaultTheme);
+ ToolkitTestApplication application;
+
+ Test::TestButton testButton = Test::TestButton::New();
+ Stage::GetCurrent().Add( testButton );
+ StyleChangedSignalChecker styleChangedSignalHandler;
+ StyleManager styleManager = StyleManager::Get();
+
+ styleManager.StyleChangedSignal().Connect(&styleChangedSignalHandler, &StyleChangedSignalChecker::OnStyleChanged);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Get the default:
+ Property::Value defaultBgColor( testButton.GetProperty(Test::TestButton::Property::BACKGROUND_COLOR) );
+ Property::Value defaultFgColor( testButton.GetProperty(Test::TestButton::Property::FOREGROUND_COLOR) );
+
+ tet_infoline("Apply the style");
+
+ std::string themeFile("ThemeOne");
+ Test::StyleMonitor::SetThemeFileOutput(themeFile, appTheme);
+ StyleManager::Get().ApplyTheme(themeFile);
+
+ Property::Value bgColor( testButton.GetProperty(Test::TestButton::Property::BACKGROUND_COLOR) );
+ Property::Value fgColor( testButton.GetProperty(Test::TestButton::Property::FOREGROUND_COLOR) );
+
+ DALI_TEST_EQUALS( bgColor, Property::Value(Color::MAGENTA), 0.001, TEST_LOCATION );
+ DALI_TEST_EQUALS( fgColor, Property::Value(Color::GREEN), 0.001, TEST_LOCATION );
+
+ tet_infoline("Testing that the signal handler is called only once");
+ DALI_TEST_EQUALS( styleChangedSignalHandler.signalCount, 1, TEST_LOCATION );
+ tet_infoline("Revert the style");
+
+ styleChangedSignalHandler.signalCount = 0;
+ StyleManager::Get().ApplyDefaultTheme();
+
+ bgColor = testButton.GetProperty(Test::TestButton::Property::BACKGROUND_COLOR);
+ fgColor = testButton.GetProperty(Test::TestButton::Property::FOREGROUND_COLOR);
+
+ tet_infoline("Check that the property is reverted");
+ DALI_TEST_EQUALS( bgColor, defaultBgColor, 0.001, TEST_LOCATION );
+ DALI_TEST_EQUALS( fgColor, defaultFgColor, 0.001, TEST_LOCATION );
+ DALI_TEST_EQUALS( bgColor, Property::Value(Color::YELLOW), 0.001, TEST_LOCATION );
+ DALI_TEST_EQUALS( fgColor, Property::Value(Color::BLUE), 0.001, TEST_LOCATION );
+ tet_infoline("Testing that the signal handler is called only once");
+ DALI_TEST_EQUALS( styleChangedSignalHandler.signalCount, 1, TEST_LOCATION );
+
+ END_TEST;
+}
+
+
+int UtcDaliStyleManagerSetStyleConstantP(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline( " UtcDaliStyleManagerSetStyleConstantP" );
+
+ StyleManager manager = StyleManager::Get();
+
+ std::string key( "key" );
+ Property::Value value( 100 );
+
+ manager.SetStyleConstant( key, value );
+
+ Property::Value returnedValue;
+ manager.GetStyleConstant( key, returnedValue );
+
+ DALI_TEST_CHECK( value.Get<int>() == returnedValue.Get<int>() );
+ END_TEST;
+}
+
+
+int UtcDaliStyleManagerGetStyleConstantP(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline( " UtcDaliStyleManagerGetStyleConstantP" );
+
+ StyleManager manager = StyleManager::Get();
+
+ std::string key( "key" );
+ Property::Value value( 100 );
+
+ manager.SetStyleConstant( key, value );
+
+ Property::Value returnedValue;
+ manager.GetStyleConstant( key, returnedValue );
+
+ DALI_TEST_CHECK( value.Get<int>() == returnedValue.Get<int>() );
+ END_TEST;
+}
+
+int UtcDaliStyleManagerGetStyleConstantN(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline( " UtcDaliStyleManagerGetStyleConstantN" );
+
+ StyleManager manager = StyleManager::Get();
+
+ std::string key2( "key2" );
+ Property::Value returnedValue2;
+ DALI_TEST_CHECK( !manager.GetStyleConstant( key2, returnedValue2 ) );
+
+ END_TEST;
+}
+
+int UtcDaliStyleManagerApplyStyle(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline( "UtcDaliStyleManagerApplyStyle - test that a style can be applied to a single button" );
+
+ const char* json1 =
+ "{\n"
+ " \"styles\":\n"
+ " {\n"
+ " \"testbutton\":\n"
+ " {\n"
+ " \"backgroundColor\":[1.0,1.0,0.0,1.0],\n"
+ " \"foregroundColor\":[0.0,0.0,1.0,1.0]\n"
+ " }\n"
+ " }\n"
+ "}\n";
+
+ const char* json2 =
+ "{\n"
+ " \"styles\":\n"
+ " {\n"
+ " \"testbutton\":\n"
+ " {\n"
+ " \"backgroundColor\":[1.0,0.0,0.0,1.0],\n"
+ " \"foregroundColor\":[0.0,1.0,1.0,1.0]\n"
+ " }\n"
+ " }\n"
+ "}\n";
+
+ // Add 2 buttons
+ Test::TestButton testButton = Test::TestButton::New();
+ Test::TestButton testButton2 = Test::TestButton::New();
+ Stage::GetCurrent().Add( testButton );
+ Stage::GetCurrent().Add( testButton2 );
+ StyleChangedSignalChecker styleChangedSignalHandler;
+ StyleManager styleManager = StyleManager::Get();
+
+ styleManager.StyleChangedSignal().Connect(&styleChangedSignalHandler, &StyleChangedSignalChecker::OnStyleChanged);
+
+ tet_infoline("Apply the style");
+
+ std::string themeFile("ThemeOne");
+ Test::StyleMonitor::SetThemeFileOutput(themeFile, json1);
+ styleManager.ApplyTheme(themeFile);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ Property::Value themedBgColor( testButton.GetProperty(Test::TestButton::Property::BACKGROUND_COLOR) );
+ Property::Value themedFgColor( testButton.GetProperty(Test::TestButton::Property::FOREGROUND_COLOR) );
+
+ // Apply the style to the test button:
+ std::string themeFile2("ThemeTwo");
+ Test::StyleMonitor::SetThemeFileOutput(themeFile2, json2);
+ styleManager.ApplyStyle( testButton, themeFile2, "testbutton" );
+
+ tet_infoline("Check that the properties change for the first button");
+ Property::Value bgColor = testButton.GetProperty(Test::TestButton::Property::BACKGROUND_COLOR);
+ Property::Value fgColor = testButton.GetProperty(Test::TestButton::Property::FOREGROUND_COLOR);
+ DALI_TEST_EQUALS( bgColor, Property::Value(Color::RED), 0.001, TEST_LOCATION );
+ DALI_TEST_EQUALS( fgColor, Property::Value(Color::CYAN), 0.001, TEST_LOCATION );
+
+ DALI_TEST_NOT_EQUALS( bgColor, themedBgColor, 0.001, TEST_LOCATION );
+ DALI_TEST_NOT_EQUALS( fgColor, themedFgColor, 0.001, TEST_LOCATION );
+
+ tet_infoline("Check that the properties remain the same for the second button");
+ bgColor = testButton2.GetProperty(Test::TestButton::Property::BACKGROUND_COLOR);
+ fgColor = testButton2.GetProperty(Test::TestButton::Property::FOREGROUND_COLOR);
+ DALI_TEST_EQUALS( bgColor, themedBgColor, 0.001, TEST_LOCATION );
+ DALI_TEST_EQUALS( fgColor, themedFgColor, 0.001, TEST_LOCATION );
+
+ END_TEST;
+}
+
+
+int UtcDaliStyleManagerStyleChangedSignal(void)
{
tet_infoline("Test that the StyleChange signal is fired when the font size is altered" );
- Test::StyleMonitor::SetThemeFileOutput(defaultTheme);
+ Test::StyleMonitor::SetThemeFileOutput( DALI_STYLE_DIR "dali-toolkit-default-theme.json",
+ defaultTheme );
ToolkitTestApplication application;
}
}
+template<typename Type>
+inline void DALI_TEST_NOT_EQUALS(Type value1, Type value2, float epsilon, const char* location)
+{
+ if( CompareType<Type>(value1, value2, epsilon) )
+ {
+ std::ostringstream o;
+ o << value1 << " != " << value2 << std::endl;
+ fprintf(stderr, "%s, checking %s", location, o.str().c_str());
+ tet_result(TET_FAIL);
+ }
+ else
+ {
+ tet_result(TET_PASS);
+ }
+}
+
+
/**
* Test whether two TimePeriods are within a certain distance of each other.
* @param[in] value1 The first value
#include "dummy-control.h"
-#include <dali-toolkit/devel-api/styling/style-manager.h>
+#include <dali-toolkit/dali-toolkit.h>
namespace Dali
{
" }\n"
"}\n";
+struct NamedTheme
+{
+ NamedTheme( const std::string& name, const std::string& theme )
+ : name(name), theme(theme)
+ {
+ }
+
+ std::string name;
+ std::string theme;
+};
+typedef std::vector< NamedTheme > NamedThemes;
+NamedThemes gThemes;
+
std::string gTheme;
std::string gFontFamily = Dali::StyleMonitor::DEFAULT_FONT_FAMILY;
std::string gFontStyle = Dali::StyleMonitor::DEFAULT_FONT_STYLE;
private:
Dali::StyleMonitor::StyleChangeSignalType mStyleChangeSignal;
static Dali::StyleMonitor mToolkitStyleMonitor;
- std::string mTheme;
- std::string mOutput; //<<< Test output. Use SetThemeFileOutput in a testharness to use it.
+ std::string mTheme; ///<< Current theme name
};
Dali::StyleMonitor StyleMonitor::mToolkitStyleMonitor;
bool StyleMonitor::LoadThemeFile( const std::string& filename, std::string& output )
{
+ for( NamedThemes::iterator iter = gThemes.begin(); iter != gThemes.end(); ++iter )
+ {
+ NamedTheme& theme = *iter;
+ if( theme.name == filename )
+ {
+ output = theme.theme;
+ return true;
+ }
+ }
+
if( !gTheme.empty() )
{
output = gTheme;
namespace StyleMonitor
{
-void SetThemeFileOutput( const std::string& output )
+void SetThemeFileOutput( const std::string& name, const std::string& output )
{
- gTheme = output;
+ for( NamedThemes::iterator iter = gThemes.begin(); iter != gThemes.end(); ++iter )
+ {
+ NamedTheme& theme = *iter;
+ if( theme.name == name )
+ {
+ theme.theme = output;
+ return;
+ }
+ }
+
+ gThemes.push_back( NamedTheme( name, output ) );
}
void SetDefaultFontFamily(const std::string& family)
{
namespace StyleMonitor
{
-void SetThemeFileOutput( const std::string& output );
+void SetThemeFileOutput( const std::string& name, const std::string& output );
void SetDefaultFontFamily(const std::string& family);
void SetDefaultFontStyle(const std::string& style);
void SetDefaultFontSize( float size );
#include <dali/integration-api/events/touch-event-integ.h>
#include <dali/integration-api/events/hover-event-integ.h>
-#include <dali-toolkit/devel-api/styling/style-manager.h>
#include "dummy-control.h"
END_TEST;
}
-
-
-
-
#include <dali-toolkit-test-suite-utils.h>
#include <dali-toolkit/dali-toolkit.h>
#include <dali-toolkit/devel-api/controls/text-controls/text-editor.h> ///< @todo to be removed when text-editor is added to the dali-toolkit.h
-#include <dali-toolkit/devel-api/styling/style-manager.h>
using namespace Dali;
using namespace Toolkit;
ToolkitTestApplication application;
tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
StyleManager styleManager = StyleManager::Get();
- styleManager.RequestDefaultTheme();
+ styleManager.ApplyDefaultTheme();
TextEditor editor = TextEditor::New();
DALI_TEST_CHECK( editor );
#include <dali/integration-api/events/tap-gesture-event.h>
#include <dali-toolkit-test-suite-utils.h>
#include <dali-toolkit/dali-toolkit.h>
-#include <dali-toolkit/devel-api/styling/style-manager.h>
using namespace Dali;
using namespace Toolkit;
ToolkitTestApplication application;
tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
StyleManager styleManager = StyleManager::Get();
- styleManager.RequestDefaultTheme();
+ styleManager.ApplyDefaultTheme();
TextField field = TextField::New();
DALI_TEST_CHECK( field );
dali-toolkit.pc
docs/Makefile
docs/dali.doxy
+ ../../automated-tests/CMakeLists.txt
])
AC_OUTPUT
develapiscriptingdir = $(develapidir)/scripting
develapishadereffectsdir = $(develapidir)/shader-effects
develapitransitioneffectsdir = $(develapidir)/transition-effects
-develapistylingdir = $(develapidir)/styling
develapitoolbardir = $(develapicontrolsdir)/tool-bar
develapitextselectionpopupdir = $(develapicontrolsdir)/text-controls
develapishadowview_HEADERS = $(devel_api_shadow_view_header_files)
develapishadereffects_HEADERS = $(devel_api_shader_effects_header_files)
develapislider_HEADERS = $(devel_api_slider_header_files)
-develapistyling_HEADERS = $(devel_api_styling_header_files)
develapisuperblurview_HEADERS = $(devel_api_super_blur_view_header_files)
develapitoolbar_HEADERS = $(devel_api_tool_bar_header_files)
develapitransitioneffects_HEADERS = $(devel_api_transition_effects_header_files)
publicapiscrollabledir = $(publicapicontrolsdir)/scrollable
publicapiscrollviewdir = $(publicapicontrolsdir)/scrollable/scroll-view
publicapiitemviewdir = $(publicapicontrolsdir)/scrollable/item-view
+publicapistylingdir = $(publicapidir)/styling
publicapitableviewdir = $(publicapicontrolsdir)/table-view
publicapitextcontrolsdir = $(publicapicontrolsdir)/text-controls
publicapifocusmanagerdir = $(publicapidir)/focus-manager
publicapiscrollbar_HEADERS = $(public_api_scroll_bar_header_files)
publicapiscrollable_HEADERS = $(public_api_scrollable_header_files)
publicapiscrollview_HEADERS = $(public_api_scroll_view_header_files)
+publicapistyling_HEADERS = $(public_api_styling_header_files)
publicapitableview_HEADERS = $(public_api_table_view_header_files)
publicapitextcontrols_HEADERS = $(public_api_text_controls_header_files)
publicapifocusmanager_HEADERS = $(public_api_focus_manager_header_files)
#include <dali-toolkit/public-api/controls/text-controls/text-label.h>
#include <dali-toolkit/public-api/accessibility-manager/accessibility-manager.h>
#include <dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h>
+#include <dali-toolkit/public-api/styling/style-manager.h>
#include <dali-toolkit/public-api/text/rendering-backend.h>
#include <dali-toolkit/public-api/dali-toolkit-version.h>
#include <dali-toolkit/public-api/enums.h>
$(devel_api_src_dir)/controls/tool-bar/tool-bar.cpp \
$(devel_api_src_dir)/focus-manager/keyinput-focus-manager.cpp \
$(devel_api_src_dir)/image-atlas/image-atlas.cpp \
- $(devel_api_src_dir)/styling/style-manager.cpp \
$(devel_api_src_dir)/scripting/script.cpp \
$(devel_api_src_dir)/transition-effects/cube-transition-cross-effect.cpp \
$(devel_api_src_dir)/transition-effects/cube-transition-effect.cpp \
devel_api_image_atlas_header_files = \
$(devel_api_src_dir)/image-atlas/image-atlas.h
-devel_api_styling_header_files = \
- $(devel_api_src_dir)/styling/style-manager.h
-
devel_api_scripting_header_files = \
$(devel_api_src_dir)/scripting/script.h \
$(devel_api_src_dir)/scripting/script-plugin.h
$(devel_api_src_dir)/transition-effects/cube-transition-cross-effect.h \
$(devel_api_src_dir)/transition-effects/cube-transition-fold-effect.h \
$(devel_api_src_dir)/transition-effects/cube-transition-wave-effect.h
-
case StyleChange::DEFAULT_FONT_CHANGE:
{
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor::OnStyleChange DEFAULT_FONT_CHANGE\n");
- std::string newFont = styleManager.GetDefaultFontFamily();
+ const std::string& newFont = GetImpl( styleManager ).GetDefaultFontFamily();
// Property system did not set the font so should update it.
mController->UpdateAfterFontChange( newFont );
break;
case StyleChange::DEFAULT_FONT_CHANGE:
{
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnStyleChange DEFAULT_FONT_CHANGE\n");
- std::string newFont = styleManager.GetDefaultFontFamily();
+ const std::string& newFont = GetImpl( styleManager ).GetDefaultFontFamily();
// Property system did not set the font so should update it.
mController->UpdateAfterFontChange( newFont );
break;
case StyleChange::DEFAULT_FONT_CHANGE:
{
// Property system did not set the font so should update it.
- std::string newFont = styleManager.GetDefaultFontFamily();
+ const std::string& newFont = GetImpl( styleManager ).GetDefaultFontFamily();
DALI_LOG_INFO( gLogFilter, Debug::General, "TextLabel::OnStyleChange StyleChange::DEFAULT_FONT_CHANGE newFont(%s)\n", newFont.c_str() );
mController->UpdateAfterFontChange( newFont );
break;
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/control.h>
#include <dali-toolkit/public-api/controls/control-impl.h>
-#include <dali-toolkit/devel-api/styling/style-manager.h>
+#include <dali-toolkit/public-api/styling/style-manager.h>
#include <dali-toolkit/internal/feedback/feedback-style.h>
namespace
}
StyleManager::StyleManager()
-: mOrientationDegrees( 0 ), // Portrait
- mDefaultFontSize( -1 ),
+: mDefaultFontSize( -1 ),
mDefaultFontFamily(""),
mFeedbackStyle( NULL )
{
delete mFeedbackStyle;
}
-void StyleManager::SetOrientationValue( int orientation )
+void StyleManager::ApplyTheme( const std::string& themeFile )
{
- if( orientation != mOrientationDegrees )
- {
- 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( mThemeFile );
- }
-}
-
-int StyleManager::GetOrientationValue()
-{
- return mOrientationDegrees;
-}
-
-void StyleManager::SetOrientation( Orientation orientation )
-{
- if( mOrientation )
- {
- mOrientation.ChangedSignal().Disconnect( this, &StyleManager::OnOrientationChanged );
- }
-
- OnOrientationChanged( orientation );
-
- if( mOrientation )
- {
- mOrientation.ChangedSignal().Connect( this, &StyleManager::OnOrientationChanged );
- }
+ SetTheme( themeFile );
}
-Orientation StyleManager::GetOrientation()
+void StyleManager::ApplyDefaultTheme()
{
- return mOrientation;
+ std::string empty;
+ SetTheme( empty );
}
-std::string StyleManager::GetDefaultFontFamily() const
+const std::string& StyleManager::GetDefaultFontFamily() const
{
return mDefaultFontFamily;
}
return false;
}
-void StyleManager::RequestThemeChange( const std::string& themeFile )
-{
- SetTheme( themeFile );
-}
-
-void StyleManager::RequestDefaultTheme()
-{
- std::string empty;
- SetTheme( empty );
-}
-
void StyleManager::ApplyThemeStyle( Toolkit::Control control )
{
if( !mThemeBuilder )
{
- RequestDefaultTheme();
+ ApplyDefaultTheme();
}
if( mThemeBuilder )
void StyleManager::CollectQualifiers( StringList& qualifiersOut )
{
// Append the relevant qualifier for orientation
- int orientation = mOrientationDegrees;
-
- if( mOrientation )
- {
- orientation = mOrientation.GetDegrees();
- }
-
+ int orientation = 0; // Get the orientation from the system
switch( orientation )
{
case 90:
}
}
-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( mThemeFile );
-}
-
-
Toolkit::Builder StyleManager::FindCachedBuilder( const std::string& key )
{
BuilderMap::iterator builderIt = mBuilderCache.find( key );
#include <dali/public-api/signals/connection-tracker.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/devel-api/styling/style-manager.h>
+#include <dali-toolkit/public-api/styling/style-manager.h>
#include <dali-toolkit/devel-api/builder/builder.h>
namespace Dali
public: // Public API
- /**
- * @copydoc Toolkit::StyleManager::SetOrientationValue
- */
- void SetOrientationValue( int orientation );
-
- /**
- * @copydoc Toolkit::StyleManager::GetOrientationValue
- */
- int GetOrientationValue();
-
- /**
- * @copydoc Toolkit::StyleManager::SetOrientation( Orientation orientation )
+/**
+ * @copydoc Toolkit::StyleManager::ApplyTheme
*/
- void SetOrientation( Orientation orientation );
+ void ApplyTheme( const std::string& themeFile );
/**
- * @copydoc Toolkit::StyleManager::GetOrientation
+ * @copydoc Toolkit::StyleManager::ApplyDefaultTheme
*/
- Orientation GetOrientation();
+ void ApplyDefaultTheme();
/**
* @copydoc Toolkit::StyleManager::GetDefaultFontFamily
*/
- std::string GetDefaultFontFamily() const;
+ const std::string& GetDefaultFontFamily() const;
/**
* @copydoc Toolkit::StyleManager::SetStyleConstant
bool GetStyleConstant( const std::string& key, Property::Value& valueOut );
/**
- * @copydoc Toolkit::StyleManager::RequestThemeChange
- */
- void RequestThemeChange( const std::string& themeFile );
-
- /**
- * @copydoc Toolkit::StyleManager::RequestDefaultTheme
- */
- void RequestDefaultTheme();
-
- /**
* @brief Apply the theme style to a control.
*
* @param[in] control The control to apply style.
void ApplyStyle( Toolkit::Builder builder, Toolkit::Control control );
/**
- * @brief Callback for orientation changes
- *
- * @param[in] orientation The orientation object
- */
- void OnOrientationChanged( Orientation orientation );
-
- /**
* Search for a builder in the cache
*
* @param[in] key The key the builder was cached under
Toolkit::Builder mThemeBuilder; ///< Builder for all default theme properties
StyleMonitor mStyleMonitor; ///< Style monitor handle
- Orientation mOrientation; ///< Handle to application orientation object
- int mOrientationDegrees; ///< Directly set value of orientation
-
int mDefaultFontSize; ///< Logical size, not a point-size
std::string mDefaultFontFamily;
std::string mThemeFile; ///< The full path of the current theme file
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h>
#include <dali-toolkit/public-api/controls/control.h>
+#include <dali-toolkit/public-api/styling/style-manager.h>
#include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
#include <dali-toolkit/devel-api/controls/renderer-factory/renderer-factory.h>
#include <dali-toolkit/devel-api/focus-manager/keyinput-focus-manager.h>
-#include <dali-toolkit/devel-api/styling/style-manager.h>
#include <dali-toolkit/internal/styling/style-manager-impl.h>
#include <dali-toolkit/internal/controls/renderers/color/color-renderer.h>
$(public_api_src_dir)/controls/text-controls/text-label.cpp \
$(public_api_src_dir)/controls/text-controls/text-field.cpp \
$(public_api_src_dir)/controls/gaussian-blur-view/gaussian-blur-view.cpp \
+ $(public_api_src_dir)/styling/style-manager.cpp \
$(public_api_src_dir)/accessibility-manager/accessibility-manager.cpp \
$(public_api_src_dir)/focus-manager/keyboard-focus-manager.cpp \
$(public_api_src_dir)/dali-toolkit-version.cpp \
$(public_api_src_dir)/controls/scrollable/scroll-view/scroll-view-page-path-effect.h \
$(public_api_src_dir)/controls/scrollable/scroll-view/scroll-view.h
+public_api_styling_header_files = \
+ $(public_api_src_dir)/styling/style-manager.h
+
public_api_table_view_header_files = \
$(public_api_src_dir)/controls/table-view/table-view.h
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
// CLASS HEADER
-#include <dali-toolkit/devel-api/styling/style-manager.h>
+#include <dali-toolkit/public-api/styling/style-manager.h>
// EXTERNAL INCLUDES
return Internal::StyleManager::Get();
}
-void StyleManager::SetOrientationValue( int orientation )
+void StyleManager::ApplyTheme( const std::string& themeFile )
{
- GetImpl(*this).SetOrientationValue( orientation );
+ GetImpl(*this).ApplyTheme( themeFile );
}
-int StyleManager::GetOrientationValue()
+void StyleManager::ApplyDefaultTheme()
{
- return GetImpl(*this).GetOrientationValue();
-}
-
-void StyleManager::SetOrientation( Orientation orientation )
-{
- GetImpl(*this).SetOrientation( orientation );
-}
-
-std::string StyleManager::GetDefaultFontFamily() const
-{
- return GetImpl(*this).GetDefaultFontFamily();
-}
-
-Orientation StyleManager::GetOrientation()
-{
- return GetImpl(*this).GetOrientation();
+ GetImpl(*this).ApplyDefaultTheme();
}
void StyleManager::SetStyleConstant( const std::string& key, const Property::Value& value )
GetImpl(*this).ApplyStyle( control, jsonFileName, styleName );
}
-StyleManager::StyleManager( Internal::StyleManager *impl )
- : BaseHandle( impl )
-{
-}
-
StyleManager::StyleChangedSignalType& StyleManager::StyleChangedSignal()
{
return GetImpl( *this ).StyleChangedSignal();
}
-void StyleManager::RequestThemeChange( const std::string& themeFile )
-{
- GetImpl(*this).RequestThemeChange( themeFile );
-}
-
-void StyleManager::RequestDefaultTheme()
+StyleManager::StyleManager( Internal::StyleManager *impl )
+ : BaseHandle( impl )
{
- GetImpl(*this).RequestDefaultTheme();
}
} // namespace Toolkit
#define __DALI_TOOLKIT_STYLE_MANAGER_H__
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
*/
// EXTERNAL INCLUDES
-#include <dali/devel-api/adaptor-framework/orientation.h>
#include <dali/public-api/adaptor-framework/style-change.h>
// INTERNAL INCLUDES
}
/**
- * @brief StyleManager provides the following functionalities:
+ * @addtogroup dali_toolkit_managers
+ * @{
+ */
+
+/**
+ * @brief StyleManager informs applications of system theme change,
+ * and supports application theme change at runtime.
*
* Applies various styles to Controls using the properties system.
- * On theme change a signal is raised that controls can be configured to listen to.
*
- * The default theme is automatically loaded and applied.
+ * On theme change, it automatically updates all controls, then raises
+ * a signal to inform the application.
+ *
+ * The default theme is automatically loaded and applied, followed by
+ * any application specific theme defined in Application::New().
*
* If the application wants to customize the theme, RequestThemeChange
- * needs to be called. Internal::Control can be configured to
- * register for the signals that are required from StyleManager, such
- * as theme change.
+ * needs to be called.
+ *
+ * Signals
+ * | %Signal Name | Method |
+ * |------------------------------------------------------------|
+ * | styleChanged | @ref StyleChangedSignal() |
+ * @SINCE_1_1.32
*/
class DALI_IMPORT_API StyleManager : public BaseHandle
{
public:
- // Signals
+ /// @brief Style Changed signal. Emitted after controls have been updated
typedef Signal< void ( StyleManager, StyleChange::Type ) > StyleChangedSignalType;
/**
* @brief Create a StyleManager handle; this can be initialised with StyleManager::Get()
+ *
* Calling member functions with an uninitialised handle is not allowed.
+ * @SINCE_1_1.32
*/
StyleManager();
* @brief Destructor
*
* This is non-virtual since derived Handle types must not contain data or virtual methods.
+ * @SINCE_1_1.32
*/
~StyleManager();
/**
* @brief Get the singleton of StyleManager object.
*
+ * @SINCE_1_1.32
* @return A handle to the StyleManager control.
*/
static StyleManager Get();
/**
- * @brief Specify the orientation value directly for the style manager
+ * @brief Apply a new theme to the application. This will be merged
+ * on top of the default Toolkit theme.
*
- * @param[in] orientation The orientation in degrees
- */
- void SetOrientationValue( int orientation );
-
- /**
- * @brief Return the orientation value
+ * If the application theme file doesn't style all controls that the
+ * application uses, then the default Toolkit theme will be used
+ * instead for those controls.
*
- * @return The orientation value
- */
- int GetOrientationValue();
-
- /**
- * @brief Set the orientation object. This will take precedence over setting the orientation value.
+ * On application startup, it is suggested that the theme file name is
+ * passed to Application::New instead of using this API to prevent
+ * controls being styled more than once.
+ * @sa Application::New()
*
- * @param[in] orientation Device orientation
+ * @SINCE_1_1.32
+ * @param[in] themeFile If a relative path is specified, then this is relative
+ * to the directory returned by app_get_resource_path().
*/
- void SetOrientation( Orientation orientation );
+ void ApplyTheme( const std::string& themeFile );
/**
- * @brief Return the orientation object
+ * @brief Apply the default Toolkit theme.
*
- * @return The orientation.
- */
- Orientation GetOrientation();
-
- /**
- * @brief Retrieves the default font family.
- * @return The default font family.
- */
- std::string GetDefaultFontFamily() const;
-
- /**
- * @brief Make a request to set the theme JSON file to one that exists in the Toolkit package.
- *
- * Multiple requests per event processing cycle can be made, but only the final one will be acted
- * on in the event processing finished callback.
+ * Request that any application specific styling is removed
+ * and that the default Toolkit theme is re-applied.
*
- * @param[in] themeFile This is just the JSON theme file name and not the full path.
+ * @SINCE_1_1.32
*/
- void RequestThemeChange( const std::string& themeFile );
-
- /**
- * @brief Request a change to the default theme
- */
- void RequestDefaultTheme();
+ void ApplyDefaultTheme();
/**
* @brief Set a constant for use when building styles
*
- * A constant is used in JSON files e.g. "myImage":"{ROOT_PATH}/mypath/image.jpg"
- * where the string "{ROOT_PATH}" is substituted with the value.
+ * A constant is used in JSON files e.g. "myImage":"{RELATIVE_PATH}/image.jpg"
+ * where the string "{RELATIVE_PATH}" is substituted with the value.
*
+ * @SINCE_1_1.32
* @param[in] key The key of the constant
* @param[in] value The value of the constant
*/
/**
* @brief Return the style constant set for a specific key
*
+ * @SINCE_1_1.32
* @param[in] key The key of the constant
* @param[out] valueOut The value of the constant if it exists
*
/**
* @brief Apply the specified style to the control.
*
- * The JSON file will be cached and subsequent calls using the same JSON file name will
- * use the already loaded cached values instead.
- *
- * @param[in] control The control to apply style.
- * @param[in] jsonFileName The name of the JSON style file to apply.
+ * @SINCE_1_1.32
+ * @param[in] control The control to which to apply the style.
+ * @param[in] jsonFileName The name of the JSON style file to apply. If a
+ * relative path is specified, then this is relative to the directory
+ * returned by app_get_resource_path().
* @param[in] styleName The name of the style within the JSON file to apply.
*/
void ApplyStyle( Toolkit::Control control, const std::string& jsonFileName, const std::string& styleName );
* @brief This signal is emitted after the style (e.g. theme/font change) has changed
* and the controls have been informed.
*
+ * @SINCE_1_1.32
* A callback of the following type may be connected:
* @code
* void YourCallbackName( StyleManager styleManager, StyleChange change );
public:
/**
- * @brief Creates a new handle from the implementation.
+ * @brief Allows the creation of a StyleManager handle from an internal pointer.
*
+ * @note Not intended for application developers
+ * @SINCE_1_1.32
* @param[in] impl A pointer to the object.
*/
explicit DALI_INTERNAL StyleManager( Internal::StyleManager *impl );
}; // class StyleManager
+/**
+ * @}
+ */
} // namespace Toolkit
} // namespace Dali