utc-Dali-KeyboardFocusManager.cpp
utc-Dali-ScrollViewEffect.cpp
utc-Dali-TextInput.cpp
+ utc-Dali-StyleManager.cpp
)
# Append list of test harness files (Won't get parsed for test cases)
extern void dali_keyboard_focus_manager_cleanup(void);
extern void dali_scroll_view_effect_startup(void);
extern void dali_scroll_view_effect_cleanup(void);
+extern void dali_style_manager_startup(void);
+extern void dali_style_manager_cleanup(void);
extern int UtcDaliAlbumLayoutNew(void);
extern int UtcDaliAlbumSetAndGetItemSizeFunction(void);
extern int UtcDaliTextInputSetAndGetTextAlignment(void);
extern int UtcDaliTextInputSetAndGetMultilinePolicy(void);
extern int UtcDaliTextInputSetAndGetExceedEnabled(void);
+extern int UtcDaliStyleManagerGet(void);
+extern int UtcDaliStyleManagerSetOrientationValue(void);
+extern int UtcDaliStyleManagerSetOrientation(void);
+extern int UtcDaliStyleManagerSetStyleConstant(void);
testcase tc_array[] = {
{"UtcDaliAlbumLayoutNew", UtcDaliAlbumLayoutNew, album_layout_startup, album_layout_cleanup},
{"UtcDaliTextInputSetAndGetTextAlignment", UtcDaliTextInputSetAndGetTextAlignment, dali_scroll_view_effect_startup, dali_scroll_view_effect_cleanup},
{"UtcDaliTextInputSetAndGetMultilinePolicy", UtcDaliTextInputSetAndGetMultilinePolicy, dali_scroll_view_effect_startup, dali_scroll_view_effect_cleanup},
{"UtcDaliTextInputSetAndGetExceedEnabled", UtcDaliTextInputSetAndGetExceedEnabled, dali_scroll_view_effect_startup, dali_scroll_view_effect_cleanup},
+ {"UtcDaliStyleManagerGet", UtcDaliStyleManagerGet, dali_style_manager_startup, dali_style_manager_cleanup},
+ {"UtcDaliStyleManagerSetOrientationValue", UtcDaliStyleManagerSetOrientationValue, dali_style_manager_startup, dali_style_manager_cleanup},
+ {"UtcDaliStyleManagerSetOrientation", UtcDaliStyleManagerSetOrientation, dali_style_manager_startup, dali_style_manager_cleanup},
+ {"UtcDaliStyleManagerSetStyleConstant", UtcDaliStyleManagerSetStyleConstant, dali_style_manager_startup, dali_style_manager_cleanup},
{NULL, NULL}
};
--- /dev/null
+//
+// Copyright (c) 2014 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <iostream>
+#include <stdlib.h>
+#include <dali-toolkit-test-suite-utils.h>
+#include <dali-toolkit/dali-toolkit.h>
+#include <dali/integration-api/events/touch-event-integ.h>
+
+
+using namespace Dali;
+using namespace Dali::Toolkit;
+
+void dali_style_manager_startup(void)
+{
+ test_return_value = TET_UNDEF;
+}
+
+void dali_style_manager_cleanup(void)
+{
+ test_return_value = TET_PASS;
+}
+
+int UtcDaliStyleManagerGet(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);
+ END_TEST;
+}
+
+int UtcDaliStyleManagerSetOrientationValue(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline( " UtcDaliStyleManagerSetOrientationValue" );
+
+ 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 );
+
+ END_TEST;
+}
+
+int UtcDaliStyleManagerSetOrientation(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline( " UtcDaliStyleManagerSetOrientation" );
+
+ StyleManager manager = StyleManager::Get();
+
+ Orientation orientation;
+
+ manager.SetOrientation( orientation );
+
+ DALI_TEST_CHECK( manager.GetOrientation() == orientation );
+
+ END_TEST;
+}
+
+int UtcDaliStyleManagerSetStyleConstant(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline( " UtcDaliStyleManagerSetStyleConstant" );
+
+ 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>() );
+
+ std::string key2( "key2" );
+ Property::Value returnedValue2;
+ DALI_TEST_CHECK( !manager.GetStyleConstant( key2, returnedValue2 ) );
+
+ END_TEST;
+}
}
-void Builder::ApplyStyle( const std::string& styleName, Handle& handle )
+bool Builder::ApplyStyle( const std::string& styleName, Handle& handle )
{
Replacement replacer( mReplacementMap );
- ApplyStyle( styleName, handle, replacer );
+ return ApplyStyle( styleName, handle, replacer );
}
-void Builder::ApplyStyle( const std::string& styleName, Handle& handle, const Replacement& replacement )
+bool Builder::ApplyStyle( const std::string& styleName, Handle& handle, const Replacement& replacement )
{
DALI_ASSERT_ALWAYS(mParser.GetRoot() && "Builder script not loaded");
if( styles && style )
{
ApplyAllStyleProperties( *mParser.GetRoot(), *style, handle, replacement );
+ return true;
}
else
{
DALI_SCRIPT_WARNING("No styles section to create style '%s'\n", styleName.c_str());
+ return false;
}
-
}
BaseHandle Builder::Create( const std::string& templateName, const PropertyValueMap& map )
/**
* @copydoc Toolkit::Builder::ApplyStyle
*/
- void ApplyStyle( const std::string& styleName, Handle& handle );
+ bool ApplyStyle( const std::string& styleName, Handle& handle );
void AnimateTo( const std::string& styleName, Handle& handle );
void LoadIncludes( const std::string& data );
- void ApplyStyle( const std::string& styleName, Handle& handle, const Replacement& replacement);
+ bool ApplyStyle( const std::string& styleName, Handle& handle, const Replacement& replacement);
Animation CreateAnimation( const std::string& animationName, const Replacement& replacement, Dali::Actor sourceActor );
}
Alignment::Alignment( Toolkit::Alignment::Type horizontal, Toolkit::Alignment::Type vertical )
-: Control( false ), // doesn't require touch events
+: Control( CONTROL_BEHAVIOUR_NONE ),
mHorizontal( horizontal ),
mVertical( vertical ),
mScaling( Toolkit::Alignment::ScaleNone ),
} // unnamed namespace
Button::Button()
-: Control( true ),
+: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_THEME_CHANGE_SIGNALS ) ),
mState( ButtonUp ),
mDimmed( false ),
mPainter( NULL )
}
Popup::Popup(PopupStyle& style)
-: Control(true),
+: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_THEME_CHANGE_SIGNALS ) ),
mShowing(false),
mState(Toolkit::Popup::POPUP_NONE), // Initially, the popup state should not be set, it's set in OnInitialize
mAlterAddedChild(false),
///////////////////////////////////////////////////////////////////////////////////////////////////
Scrollable::Scrollable()
-: Control(true/*requires touch*/),
+: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_THEME_CHANGE_SIGNALS ) ),
mPropertyRelativePosition(Property::INVALID_INDEX),
mPropertyPositionMin(Property::INVALID_INDEX),
mPropertyPositionMax(Property::INVALID_INDEX),
}
TableView::TableView( unsigned int initialRows, unsigned int initialColumns )
-: Control( true ), // requires touch
+: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_THEME_CHANGE_SIGNALS ) ),
mCellData( initialRows, initialColumns ),
mLayoutingChild( false ),
mConstraintDuration( DEFAULT_CONSTRAINT_DURATION )
}
TextInput::TextInput()
-:Control( true ),
+:Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_THEME_CHANGE_SIGNALS ) ),
mState( StateEdit ),
mStyledText(),
mInputStyle(),
}
TextView::TextView()
-: Control( false ), // doesn't require touch events
+: Control( REQUIRES_THEME_CHANGE_SIGNALS ),
mCurrentStyledText(),
mTextViewProcessorOperations(),
mLayoutParameters( Toolkit::TextView::SplitByNewLineChar,
$(toolkit_base_src_dir)/controls/relayout-controller.cpp \
$(toolkit_base_src_dir)/controls/relayout-controller-impl.cpp \
$(toolkit_base_src_dir)/controls/relayout-helper.cpp \
- $(toolkit_base_src_dir)/controls/style-change-processor.cpp \
$(toolkit_base_src_dir)/controls/alignment/alignment-impl.cpp \
$(toolkit_base_src_dir)/controls/buttons/button-impl.cpp \
$(toolkit_base_src_dir)/controls/buttons/check-box-button-default-painter-impl.cpp \
$(toolkit_base_src_dir)/factory/localized-control-factory-impl.cpp \
$(toolkit_base_src_dir)/focus-manager/focus-manager-impl.cpp \
$(toolkit_base_src_dir)/focus-manager/keyboard-focus-manager-impl.cpp \
- $(toolkit_base_src_dir)/focus-manager/keyinput-focus-manager-impl.cpp
+ $(toolkit_base_src_dir)/focus-manager/keyinput-focus-manager-impl.cpp \
+ $(toolkit_base_src_dir)/styling/style-manager-impl.cpp \
+ $(toolkit_base_src_dir)/builder/builder-impl.cpp \
+ $(toolkit_base_src_dir)/builder/builder-animations.cpp \
+ $(toolkit_base_src_dir)/builder/builder-set-property.cpp \
+ $(toolkit_base_src_dir)/builder/builder-signals.cpp \
+ $(toolkit_base_src_dir)/builder/builder-actor.cpp \
+ $(toolkit_base_src_dir)/builder/json-parser-state.cpp \
+ $(toolkit_base_src_dir)/builder/json-parser-impl.cpp \
+ $(toolkit_base_src_dir)/builder/tree-node-manipulator.cpp \
+ $(toolkit_base_src_dir)/builder/replacement.cpp
--- /dev/null
+//
+// Copyright (c) 2014 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+// CLASS HEADER
+#include "style-manager-impl.h"
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/controls/control.h>
+#include <dali-toolkit/public-api/controls/control-impl.h>
+#include <dali-toolkit/public-api/styling/style-manager.h>
+#include <dali-toolkit/internal/styling/util.h>
+#include <dali/integration-api/debug.h>
+
+// EXTERNAL INCLUDES
+#include <fstream>
+#include <iostream>
+#include <sstream>
+
+
+namespace
+{
+
+const char* LANDSCAPE_QUALIFIER = "landscape";
+const char* PORTRAIT_QUALIFIER = "portrait";
+
+const char* DEFAULT_THEME = DALI_STYLE_DIR "tizen-default-theme.json";
+
+const char* PACKAGE_PATH_KEY = "PACKAGE_PATH";
+const char* DEFAULT_PACKAGE_PATH = DALI_DATA_READ_ONLY_DIR "/toolkit/";
+
+} // namespace
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+namespace
+{
+
+BaseHandle Create()
+{
+ BaseHandle handle = StyleManager::Get();
+
+ if ( !handle && Adaptor::IsAvailable() )
+ {
+ Toolkit::StyleManager manager = Toolkit::StyleManager( new Internal::StyleManager() );
+ Adaptor::Get().RegisterSingleton( typeid( manager ), manager );
+ handle = manager;
+ }
+
+ return handle;
+}
+TypeRegistration STYLE_MANAGER_TYPE( typeid(Dali::Toolkit::StyleManager), typeid(Dali::BaseHandle), Create, true /* Create instance at startup */ );
+
+/**
+ * Merge two maps into one
+ */
+void MergeMaps( const PropertyValueMap& a, const PropertyValueMap& b, PropertyValueMap& out )
+{
+ out = a;
+ for( PropertyValueMap::const_iterator it = b.begin(), itEnd = b.end(); it != itEnd; ++it )
+ {
+ out[ it->first ] = it->second;
+ }
+}
+
+} // namespace
+
+Toolkit::StyleManager StyleManager::Get()
+{
+ Toolkit::StyleManager manager;
+
+ if ( Adaptor::IsAvailable() )
+ {
+ // Check whether the style manager is already created
+ Dali::BaseHandle handle = Dali::Adaptor::Get().GetSingleton( typeid( Toolkit::StyleManager ) );
+ if( handle )
+ {
+ // If so, downcast the handle of singleton
+ manager = Toolkit::StyleManager( dynamic_cast< StyleManager* >( handle.GetObjectPtr() ) );
+ }
+ }
+
+ return manager;
+}
+
+StyleManager::StyleManager()
+ : mOrientationDegrees( 0 ), // Portrait
+ mSetThemeConnection( false )
+{
+ // Add theme builder constants
+ mThemeBuilderConstants[ PACKAGE_PATH_KEY ] = DEFAULT_PACKAGE_PATH;
+
+ RequestDefaultTheme();
+}
+
+StyleManager::~StyleManager()
+{
+ // Disconnect from signal
+ SetOrientation( Orientation() );
+}
+
+void StyleManager::SetOrientationValue( int orientation )
+{
+ mOrientationDegrees = orientation;
+
+ Util::ConnectEventProcessingFinishedSignal();
+ mSetThemeConnection = true;
+}
+
+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 );
+ }
+}
+
+Orientation StyleManager::GetOrientation()
+{
+ return mOrientation;
+}
+
+void StyleManager::SetStyleConstant( const std::string& key, const Property::Value& value )
+{
+ mStyleBuilderConstants[ key ] = value;
+}
+
+bool StyleManager::GetStyleConstant( const std::string& key, Property::Value& valueOut )
+{
+ Toolkit::PropertyValueMap::iterator valueIt = mStyleBuilderConstants.find( key );
+ if( valueIt != mStyleBuilderConstants.end() )
+ {
+ valueOut = valueIt->second;
+ return true;
+ }
+
+ return false;
+}
+
+void StyleManager::OnOrientationChanged( Orientation orientation )
+{
+ mOrientation = orientation;
+
+ if( mOrientation )
+ {
+ Util::ConnectEventProcessingFinishedSignal();
+ mSetThemeConnection = true;
+ }
+}
+
+Toolkit::Builder StyleManager::CreateBuilder( const PropertyValueMap& constants )
+{
+ Toolkit::Builder builder = Toolkit::Builder::New();
+ builder.AddConstants( constants );
+
+ return builder;
+}
+
+bool StyleManager::LoadJSON( Toolkit::Builder builder, const std::string& jsonFilePath )
+{
+ std::string fileString;
+ if( LoadFile( jsonFilePath, fileString ) )
+ {
+ builder.LoadFromString( fileString );
+ return true;
+ }
+ else
+ {
+ DALI_LOG_WARNING("Error loading file '%s'\n", jsonFilePath.c_str());
+ return false;
+ }
+}
+
+void StyleManager::CollectQualifiers( StringList& qualifiersOut )
+{
+ // Append the relevant qualifier for orientation
+ int orientation = mOrientationDegrees;
+
+ if( mOrientation )
+ {
+ orientation = mOrientation.GetDegrees();
+ }
+
+ switch( orientation )
+ {
+ case 90:
+ case 270:
+ {
+ qualifiersOut.push_back( std::string( LANDSCAPE_QUALIFIER ) );
+ break;
+ }
+ case 180:
+ case 0: // fall through
+ default:
+ {
+ qualifiersOut.push_back( std::string( PORTRAIT_QUALIFIER ) );
+ break;
+ }
+ }
+}
+
+void StyleManager::BuildQualifiedStyleName( const std::string& styleName, const StringList& qualifiers, std::string& qualifiedStyleOut )
+{
+ qualifiedStyleOut.append( styleName );
+
+ for( StringList::const_iterator it = qualifiers.begin(), itEnd = qualifiers.end(); it != itEnd; ++it )
+ {
+ const std::string& str = *it;
+
+ qualifiedStyleOut.append( "-" );
+ qualifiedStyleOut.append( str );
+ }
+}
+
+void StyleManager::ApplyStyle( Toolkit::Builder builder, Toolkit::Control control )
+{
+ // Convert control name to lower case
+ std::string styleName = control.GetTypeName();
+ std::transform( styleName.begin(), styleName.end(), styleName.begin(), ::tolower );
+
+ // Apply the style after choosing the correct actual style (e.g. landscape or portrait)
+ StringList qualifiers;
+ CollectQualifiers( qualifiers );
+
+ while( true )
+ {
+ std::string qualifiedStyleName;
+ BuildQualifiedStyleName( styleName, qualifiers, qualifiedStyleName );
+
+ // Break if style found or we have tried the root style name (qualifiers is empty)
+ if( builder.ApplyStyle( qualifiedStyleName, control ) || qualifiers.size() == 0 )
+ {
+ break;
+ }
+
+ // Remove the last qualifier in an attempt to find a style that is valid
+ qualifiers.pop_back();
+ }
+}
+
+void StyleManager::ApplyThemeStyle( Toolkit::Control control )
+{
+ if( mThemeBuilder )
+ {
+ ApplyStyle( mThemeBuilder, control );
+ }
+}
+
+void StyleManager::ApplyStyle( Toolkit::Control control, const std::string& jsonFileName, const std::string& styleName )
+{
+ bool builderReady = false;
+
+ // First look in the cache
+ Toolkit::Builder builder = FindCachedBuilder( jsonFileName );
+ if( builder )
+ {
+ builderReady = true;
+ }
+ else
+ {
+ // Merge theme and style constants
+ PropertyValueMap constants;
+ MergeMaps( mThemeBuilderConstants, mStyleBuilderConstants, constants );
+
+ // Create it
+ builder = CreateBuilder( constants );
+
+ if( LoadJSON( builder, jsonFileName ) )
+ {
+ CacheBuilder( builder, jsonFileName );
+ builderReady = true;
+ }
+ }
+
+ // Apply the style to the control
+ if( builderReady )
+ {
+ builder.ApplyStyle( styleName, control );
+ }
+}
+
+bool StyleManager::LoadFile( const std::string& filename, std::string& stringOut )
+{
+ DALI_ASSERT_DEBUG( 0 != filename.length());
+
+ std::ifstream in( filename.c_str(), std::ios::in );
+ if( in )
+ {
+ std::stringstream buffer;
+ buffer << in.rdbuf();
+
+ stringOut = buffer.str();
+
+ in.close();
+
+ return true;
+ }
+
+ return false;
+}
+
+Toolkit::StyleManager::ThemeChangeSignalType& StyleManager::ThemeChangeSignal()
+{
+ return mThemeChangeSignal;
+}
+
+void StyleManager::EmitThemeChangeSignal()
+{
+ if( !mThemeChangeSignal.Empty() )
+ {
+ mThemeChangeSignal.Emit( Toolkit::StyleManager::Get() );
+ }
+}
+
+void StyleManager::RequestThemeChange( const std::string& themeFile )
+{
+ mThemeFile = themeFile;
+
+ Util::ConnectEventProcessingFinishedSignal();
+ mSetThemeConnection = true;
+}
+
+void StyleManager::RequestDefaultTheme()
+{
+ RequestThemeChange( DEFAULT_THEME );
+}
+
+bool StyleManager::IsThemeRequestPending()
+{
+ return mSetThemeConnection;
+}
+
+void StyleManager::SetTheme()
+{
+ mThemeBuilder = CreateBuilder( mThemeBuilderConstants );
+ LoadJSON( mThemeBuilder, mThemeFile );
+
+ mSetThemeConnection = false;
+
+ EmitThemeChangeSignal();
+}
+
+Toolkit::Builder StyleManager::FindCachedBuilder( const std::string& key )
+{
+ BuilderMap::iterator builderIt = mBuilderCache.find( key );
+ if( builderIt != mBuilderCache.end() )
+ {
+ return builderIt->second;
+ }
+
+ return Toolkit::Builder();
+}
+
+void StyleManager::CacheBuilder( Toolkit::Builder builder, const std::string& key )
+{
+ mBuilderCache[ key ] = builder;
+}
+
+} // namespace Internal
+
+} // namespace Toolkit
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_TOOLKIT_INTERNAL_STYLE_MANAGER_H__
+#define __DALI_TOOLKIT_INTERNAL_STYLE_MANAGER_H__
+
+//
+// Copyright (c) 2014 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+// EXTERNAL INCLUDES
+#include <string>
+#include <list>
+
+// INTERNAL INCLUDES
+
+#include <dali/dali.h>
+#include <dali-toolkit/public-api/styling/style-manager.h>
+#include <dali-toolkit/public-api/builder/builder.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+/**
+ * @copydoc Toolkit::StyleManager
+ */
+class StyleManager : public Dali::BaseObject, public ConnectionTracker
+{
+public:
+
+ /**
+ * Singleton access
+ *
+ * @return The StyleManager object
+ */
+ static Toolkit::StyleManager Get();
+
+ /**
+ * Construct a new StyleManager.
+ */
+ StyleManager();
+
+ /**
+ * @copydoc Toolkit::StyleManager::SetOrientationValue
+ */
+ void SetOrientationValue( int orientation );
+
+ /**
+ * @copydoc Toolkit::StyleManager::GetOrientationValue
+ */
+ int GetOrientationValue();
+
+ /**
+ * @copydoc Toolkit::StyleManager::SetOrientation( Orientation orientation )
+ */
+ void SetOrientation( Orientation orientation );
+
+ /**
+ * @copydoc Toolkit::StyleManager::GetOrientation
+ */
+ Orientation GetOrientation();
+
+ /**
+ * @copydoc Toolkit::StyleManager::SetStyleConstant
+ */
+ void SetStyleConstant( const std::string& key, const Property::Value& value );
+
+ /**
+ * @copydoc Toolkit::StyleManager::GetStyleConstant
+ */
+ 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();
+
+ /**
+ * Determine if a theme change has been requested
+ * @return Whether a theme request is pending
+ */
+ bool IsThemeRequestPending();
+
+ /**
+ * @brief Apply the theme style to a control.
+ *
+ * @param[in] control The control to apply style.
+ */
+ void ApplyThemeStyle( Toolkit::Control control );
+
+ /**
+ * @copydoc Toolkit::StyleManager::ApplyStyle
+ */
+ void ApplyStyle( Toolkit::Control control, const std::string& jsonFileName, const std::string& styleName );
+
+public:
+ // SIGNALS
+
+ /**
+ * @copydoc Toolkit::StyleManager::ThemeChangeSignal
+ */
+ Toolkit::StyleManager::ThemeChangeSignalType& ThemeChangeSignal();
+
+protected:
+
+ /**
+ * @brief Destructor
+ */
+ virtual ~StyleManager();
+
+
+public:
+
+ /**
+ * @brief Set the current theme. Called only once per event processing cycle.
+ */
+ void SetTheme();
+
+private:
+
+ typedef std::list<std::string> StringList;
+
+ /**
+ * @brief Internal helper method to read a file from file system.
+ * @param filename The name of the file to read.
+ * @param[out] stringOut The string to return the file in
+ *
+ * @param Return true if file was found
+ */
+ bool LoadFile(const std::string& filename, std::string& stringOut);
+
+ /**
+ * @brief Create a new builder.
+ *
+ * @param[in] constants A map of constants to be used by the builder
+ *
+ * @return Return the newly created builder
+ */
+ Toolkit::Builder CreateBuilder( const PropertyValueMap& constants );
+
+ /**
+ * @brief Load a JSON file into given builder
+ *
+ * @param[in] builder The builder object to load the theme file
+ * @param[in] jsonFileName The name of the JSON file to load
+ * @return Return true if file was loaded
+ */
+ bool LoadJSON( Toolkit::Builder builder, const std::string& jsonFileName );
+
+ /**
+ * @brief Collect qualifiers (e.g. Landscape, portrait etc) for a given style
+ *
+ * @param[in,out] qualifiersOut The list to populate with qualifiers
+ */
+ void CollectQualifiers( StringList& qualifiersOut );
+
+ /**
+ * @brief Construct a qualified style name out of qualifiers
+ *
+ * A qualifed style name will be in the format: style-qualifier0-qualifier1-qualifierN
+ *
+ * @param[in] styleName The root name of the style
+ * @param[in] qualifiers List of qualifier names
+ * @param[out] qualifiedStyleOut The qualified style name
+ */
+ void BuildQualifiedStyleName( const std::string& styleName, const StringList& qualifiers, std::string& qualifiedStyleOut );
+
+ /**
+ * @brief Apply a style to the control using the given builder
+ *
+ * @param[in] builder The builder to apply the style from
+ * @param[in] control The control to apply the style to
+ */
+ void ApplyStyle( Toolkit::Builder builder, Toolkit::Control control );
+
+ /**
+ * @brief Emit theme changed signal
+ */
+ void EmitThemeChangeSignal();
+
+ /**
+ * @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
+ * @return Return the cached builder if found or an empty builder object if not found
+ */
+ Toolkit::Builder FindCachedBuilder( const std::string& key );
+
+ /**
+ * Store a given builder in the cache keyed to the given key
+ *
+ * @param[in] builder The builder object to store
+ * @param[in] key The key to store the builder under
+ */
+ void CacheBuilder( Toolkit::Builder builder, const std::string& key );
+
+ // Undefined
+ StyleManager(const StyleManager&);
+
+ StyleManager& operator=(const StyleManager& rhs);
+
+private:
+
+ // Map to store builders keyed by JSON file name
+ typedef std::map< std::string, Toolkit::Builder > BuilderMap;
+
+ Toolkit::Builder mThemeBuilder; ///< Builder for all default theme properties
+
+ Orientation mOrientation; ///< Handle to application orientation object
+ int mOrientationDegrees; ///< Directly set value of orientation
+
+ std::string mThemeFile; ///< The full path of the current theme file
+
+ Toolkit::PropertyValueMap mThemeBuilderConstants; ///< Contants to give the theme builder
+ Toolkit::PropertyValueMap mStyleBuilderConstants; ///< Constants specific to building styles
+
+ BuilderMap mBuilderCache; ///< Cache of builders keyed by JSON file name
+
+ bool mSetThemeConnection; ///< Has the callback to set the theme been set
+
+ // Signals
+ Toolkit::StyleManager::ThemeChangeSignalType mThemeChangeSignal; ///< Emitted when the theme changes
+};
+
+} // namespace Internal
+
+inline Internal::StyleManager& GetImpl( Dali::Toolkit::StyleManager& obj )
+{
+ DALI_ASSERT_ALWAYS( obj );
+
+ Dali::BaseObject& handle = obj.GetBaseObject();
+
+ return static_cast< Internal::StyleManager& >( handle );
+}
+
+inline const Internal::StyleManager& GetImpl( const Dali::Toolkit::StyleManager& obj )
+{
+ DALI_ASSERT_ALWAYS( obj );
+
+ const Dali::BaseObject& handle = obj.GetBaseObject();
+
+ return static_cast< const Internal::StyleManager& >( handle );
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // __DALI_TOOLKIT_INTERNAL_STYLE_MANAGER_H__
+
--- /dev/null
+#ifndef __DALI_TOOLKIT_INTERNAL_UTIL_H__
+#define __DALI_TOOLKIT_INTERNAL_UTIL_H__
+
+//
+// Copyright (c) 2014 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+// EXTERNAL INCLUDES
+
+// INTERNAL INCLUDES
+
+#include <dali/dali.h>
+#include <dali-toolkit/internal/styling/style-manager-impl.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+namespace Util
+{
+
+/**
+ * @brief Callback that the EventProcessingFinishedSignal signal calls
+ *
+ * Priorities calls to managers
+ */
+inline void EventProcessingFinishedSignalPrioritizer()
+{
+ // Priority 0: Set all styles
+ Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
+ if( GetImpl(styleManager).IsThemeRequestPending() )
+ {
+ GetImpl(styleManager).SetTheme();
+ }
+
+ // Todo: Priority 1: Do relayout after styles have been set
+}
+
+/**
+ * @brief Connect to the EventProcessingFinishedSignal
+ *
+ * Needs to be called only once, but will still operate successfully if called multiple times.
+ * Makes the assumption that this is the only thing connecting to the EventProcessingFinishedSignal.
+ */
+inline void ConnectEventProcessingFinishedSignal()
+{
+ Stage stage = Stage::GetCurrent();
+
+ // This is only intended for one purpose!
+ if( stage.EventProcessingFinishedSignal().GetConnectionCount() == 0 )
+ {
+ stage.EventProcessingFinishedSignal().Connect( &EventProcessingFinishedSignalPrioritizer );
+ }
+}
+
+} // namespace Util
+
+} // namespace Internal
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // __DALI_TOOLKIT_INTERNAL_STYLE_MANAGER_H__
+
return GetImpl(*this).Create( templateName, map );
}
-void Builder::ApplyStyle( const std::string& styleName, Handle& handle )
+bool Builder::ApplyStyle( const std::string& styleName, Handle& handle )
{
- GetImpl(*this).ApplyStyle( styleName, handle );
+ return GetImpl(*this).ApplyStyle( styleName, handle );
}
void Builder::AddActors( Actor toActor )
* @brief Adds or modifies a user defined constant to all future style template or animation expansions
*
* e.g.
- * builder.AddConstant( "IMAGE_DIRECTORY", "/usr/share/images" );
+ * @code
+ * builder.AddConstant( "IMAGE_DIRECTORY", "/usr/share/images" );
+ * @endcode
*
* @pre The Builder has been initialized.
* @param key The constant name to add or update
* @brief Gets all currently defined constants.
*
* e.g.
- * PropertyValueMap map = builder.GetConstants(); // get copy of current constants
- * map["IMAGE_DIRECTORY"] = "/usr/share/images"; // make modification
- * builder.AddConstants( map ); // write back changes
+ * @code
+ * PropertyValueMap map = builder.GetConstants(); // get copy of current constants
+ * map["IMAGE_DIRECTORY"] = "/usr/share/images"; // make modification
+ * builder.AddConstants( map ); // write back changes
+ * @endcode
*
* @pre The Builder has been initialized.
* @return A reference to the currently defined constants.
* @brief Gets a currently defined constant, or returns Property::INVALID
*
* e.g.
- * PropertyValueMap map = builder.GetConstants(); // get copy of current constants
- * map["IMAGE_DIRECTORY"] = "/usr/share/images"; // make modification
- * builder.AddConstants( map ); // write back changes
+ * @code
+ * PropertyValueMap map = builder.GetConstants(); // get copy of current constants
+ * map["IMAGE_DIRECTORY"] = "/usr/share/images"; // make modification
+ * builder.AddConstants( map ); // write back changes
+ * @endcode
*
* @pre The Builder has been initialized.
* @param key The constant name to search for.
* @pre Preconditions have been met for creating dali objects ie Images, Actors etc
* @param styleName The name of the set of style properties to set on the handle object.
* @param handle Then handle of the object on which to set the properties.
+ *
+ * @return Return true if the style was found
*/
- void ApplyStyle( const std::string& styleName, Handle& handle );
+ bool ApplyStyle( const std::string& styleName, Handle& handle );
/**
* Add the actor tree in the "stage" section to the actor toActor.
#include <dali/integration-api/debug.h>
-#include "dali-toolkit/internal/controls/style-change-processor.h"
#include "dali-toolkit/internal/controls/relayout-controller.h"
#include "dali-toolkit/internal/controls/relayout-helper.h"
#include "dali-toolkit/public-api/focus-manager/keyinput-focus-manager.h"
#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/internal/styling/style-manager-impl.h>
+
namespace Dali
{
mIsKeyboardNavigationSupported(false),
mIsKeyboardFocusGroup(false),
mKeyEventSignalV2(),
- mBackground( NULL )
+ mBackground( NULL ),
+ mFlags( Control::CONTROL_BEHAVIOUR_NONE )
{
}
// Background
Background* mBackground; ///< Only create the background if we use it
+ ControlBehaviour mFlags; ///< Flags passed in from constructor
+
// Properties - these need to be members of Internal::Control::Impl as they need to functions within this class.
static PropertyRegistration PROPERTY_1;
static PropertyRegistration PROPERTY_2;
Toolkit::Control Control::New()
{
// Create the implementation, temporarily owned on stack
- IntrusivePtr<Control> controlImpl = new Control( false );
+ IntrusivePtr<Control> controlImpl = new Control( CONTROL_BEHAVIOUR_NONE );
// Pass ownership to handle
Toolkit::Control handle( *controlImpl );
Control::~Control()
{
- if( mImpl->mInitialized )
- {
- // Unregister only if control has been initialized.
- Internal::StyleChangeProcessor::Unregister( this );
- }
delete mImpl;
}
void Control::Initialize()
{
- // Register with the style change processor so we are informed when the default style changes
- Internal::StyleChangeProcessor::Register( this );
// Calling deriving classes
OnInitialize();
+ if( mImpl->mFlags & REQUIRES_THEME_CHANGE_SIGNALS )
+ {
+ Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
+
+ // Register for font/theme changes
+ styleManager.ThemeChangeSignal().Connect( this, &ControlImpl::OnThemeChange );
+
+ // Set theme
+ GetImpl( styleManager ).ApplyThemeStyle( GetOwner() );
+ }
+
mImpl->mInitialized = true;
}
Relayout( size, container );
}
+void Control::OnThemeChange( Toolkit::StyleManager styleManager )
+{
+ GetImpl( styleManager ).ApplyThemeStyle( GetOwner() );
+}
+
bool Control::EmitKeyEventSignal( const KeyEvent& event )
{
// Guard against destruction during signal emission
{
}
+Control::Control( ControlBehaviour behaviourFlags )
+: CustomActorImpl( behaviourFlags & REQUIRES_TOUCH_EVENTS ),
+ mImpl(new Impl(*this))
+{
+ mImpl->mFlags = behaviourFlags;
+}
+
} // namespace Internal
} // namespace Toolkit
}
ScrollComponentImpl::ScrollComponentImpl()
-: Control(true/*requires touch*/)
+: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_THEME_CHANGE_SIGNALS ) )
{
}
$(public_api_base_src_dir)/focus-manager/keyinput-focus-manager.cpp \
$(public_api_base_src_dir)/markup-processor/markup-processor.cpp \
$(public_api_base_src_dir)/shader-effects/image-region-effect.cpp \
- $(public_api_base_src_dir)/shader-effects/bouncing-effect.cpp
+ $(public_api_base_src_dir)/shader-effects/bouncing-effect.cpp \
+ $(public_api_base_src_dir)/styling/style-manager.cpp \
+ $(public_api_base_src_dir)/builder/builder.cpp \
+ $(public_api_base_src_dir)/builder/json-parser.cpp \
+ $(public_api_base_src_dir)/builder/tree-node.cpp
# Add public header files here
public_api_base_shader_effects_header_files = \
$(public_api_base_src_dir)/shader-effects/bouncing-effect.h
+public_api_base_styling_header_files = \
+ $(public_api_base_src_dir)/styling/style-manager.h
+
+public_api_base_builder_header_files = \
+ $(public_api_base_src_dir)/builder/builder.h \
+ $(public_api_base_src_dir)/builder/json-parser.h \
+ $(public_api_base_src_dir)/builder/tree-node.h
+
+
--- /dev/null
+//
+// Copyright (c) 2014 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+// CLASS HEADER
+
+#include <dali-toolkit/public-api/styling/style-manager.h>
+
+// EXTERNAL INCLUDES
+
+// INTERNAL INCLUDES
+
+#include <dali-toolkit/internal/styling/style-manager-impl.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+StyleManager::StyleManager()
+{
+}
+
+StyleManager::~StyleManager()
+{
+}
+
+StyleManager StyleManager::Get()
+{
+ return Internal::StyleManager::Get();
+}
+
+void StyleManager::SetOrientationValue( int orientation )
+{
+ GetImpl(*this).SetOrientationValue( orientation );
+}
+
+int StyleManager::GetOrientationValue()
+{
+ return GetImpl(*this).GetOrientationValue();
+}
+
+void StyleManager::SetOrientation( Orientation orientation )
+{
+ GetImpl(*this).SetOrientation( orientation );
+}
+
+Orientation StyleManager::GetOrientation()
+{
+ return GetImpl(*this).GetOrientation();
+}
+
+void StyleManager::SetStyleConstant( const std::string& key, const Property::Value& value )
+{
+ GetImpl(*this).SetStyleConstant( key, value );
+}
+
+bool StyleManager::GetStyleConstant( const std::string& key, Property::Value& valueOut )
+{
+ return GetImpl(*this).GetStyleConstant( key, valueOut );
+}
+
+void StyleManager::ApplyStyle( Toolkit::Control control, const std::string& jsonFileName, const std::string& styleName )
+{
+ GetImpl(*this).ApplyStyle( control, jsonFileName, styleName );
+}
+
+StyleManager::StyleManager( Internal::StyleManager *impl )
+ : BaseHandle( impl )
+{
+}
+
+StyleManager::ThemeChangeSignalType& StyleManager::ThemeChangeSignal()
+{
+ return GetImpl( *this ).ThemeChangeSignal();
+}
+
+void StyleManager::RequestThemeChange( const std::string& themeFile )
+{
+ GetImpl(*this).RequestThemeChange( themeFile );
+}
+
+void StyleManager::RequestDefaultTheme()
+{
+ GetImpl(*this).RequestDefaultTheme();
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
+
--- /dev/null
+#ifndef __DALI_TOOLKIT_STYLE_MANAGER_H__
+#define __DALI_TOOLKIT_STYLE_MANAGER_H__
+
+//
+// Copyright (c) 2014 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+// EXTERNAL INCLUDES
+
+// INTERNAL INCLUDES
+#include <dali/dali.h>
+#include <dali-toolkit/public-api/controls/control.h>
+
+namespace Dali DALI_IMPORT_API
+{
+
+namespace Toolkit
+{
+
+namespace Internal DALI_INTERNAL
+{
+class StyleManager;
+}
+
+/**
+ * @brief StyleManager provides the following functionalities:
+ *
+ * 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.
+ *
+ * If the application wants to customize the theme, RequestThemeChange needs to be called.
+ * Also, the default orientation is Portrait, if the application wants to adapt to the orientation change, call SetOrientation or SetOrienationValue.
+ * @code
+ * const char* CUSTOM_THEME = DALI_SCRIPT_DIR "tizen-dark-theme.json";
+ *
+ * void OnInit(Application& app)
+ * {
+ * Toolkit::StyleManager::Get().RequestThemeChange( CUSTOM_THEME );
+ * Toolkit::StyleManager::Get().SetOrientation( app.GetOrientation() );
+ * ...
+ * }
+ * @endcode
+ *
+ * Internal::Control can be configured to register for the signals that are required from StyleManager,
+ * such as theme change.
+ */
+class StyleManager : public BaseHandle
+{
+public:
+
+ // Signals
+ typedef SignalV2< void ( StyleManager ) > ThemeChangeSignalType;
+
+ /**
+ * @brief Create a StyleManager handle; this can be initialised with StyleManager::Get()
+ * Calling member functions with an uninitialised handle is not allowed.
+ */
+ StyleManager();
+
+ /**
+ * @brief Virtual destructor.
+ */
+ virtual ~StyleManager();
+
+ /**
+ * @brief Get the singleton of StyleManager object.
+ *
+ * @return A handle to the StyleManager control.
+ */
+ static StyleManager Get();
+
+ /**
+ * @brief Specify the orientation value directly for the style manager
+ *
+ * @param[in] orientation The orientation in degrees
+ */
+ void SetOrientationValue( int orientation );
+
+ /**
+ * @brief Return the orientation value
+ *
+ * @return The orientation value
+ */
+ int GetOrientationValue();
+
+ /**
+ * @brief Set the orientation object. This will take precedence over setting the orientation value.
+ *
+ * @param[in] orientation Device orientation
+ */
+ void SetOrientation( Orientation orientation );
+
+ /**
+ * @brief Return the orientation object
+ *
+ * @return The orientation.
+ */
+ Orientation GetOrientation();
+
+ /**
+ * @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.
+ *
+ * @param[in] themeFile This is just the JSON theme file name and not the full path.
+ */
+ void RequestThemeChange( const std::string& themeFile );
+
+ /**
+ * @brief Request a change to the default theme
+ */
+ void RequestDefaultTheme();
+
+ /**
+ * @brief Set a constant for use when building styles
+ *
+ * A constant is used in JSON files e.g. "my-image":"{ROOT_PATH}/mypath/image.jpg"
+ * where the string "{ROOT_PATH}" is substituted with the value.
+ *
+ * @param[in] key The key of the constant
+ * @param[in] value The value of the constant
+ */
+ void SetStyleConstant( const std::string& key, const Property::Value& value );
+
+ /**
+ * @brief Return the style constant set for a specific key
+ *
+ * @param[in] key The key of the constant
+ * @param[out] valueOut The value of the constant if it exists
+ *
+ * @return If the constant for key exists then return the constant in valueOut and return true
+ */
+ bool GetStyleConstant( const std::string& key, Property::Value& valueOut );
+
+ /**
+ * @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.
+ * @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 );
+
+public: // Signals
+
+ /**
+ * @brief This signal is emitted whenever the theme is changed on device
+ * A callback of the following type may be connected:
+ * @code
+ * void YourCallbackName( StyleManager styleManager );
+ * @endcode
+ * @return The signal to connect to.
+ */
+ ThemeChangeSignalType& ThemeChangeSignal();
+
+public:
+
+ /**
+ * @brief Creates a new handle from the implementation.
+ *
+ * @param[in] impl A pointer to the object.
+ */
+ explicit DALI_INTERNAL StyleManager( Internal::StyleManager *impl );
+
+}; // class StyleManager
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+
+#endif /* __DALI_TOOLKIT_STYLE_MANAGER_H__ */
--- /dev/null
+# Files to install here
+
+dali_toolkit_style_files =\
+ $(toolkit_base_styles_dir)/*.json
--- /dev/null
+/*
+Copyright (c) 2000-2014 Samsung Electronics Co., Ltd All Rights Reserved
+
+This file is part of Dali Toolkit
+
+PROPRIETARY/CONFIDENTIAL
+
+This software is the confidential and proprietary information of
+SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
+disclose such Confidential Information and shall use it only in
+accordance with the terms of the license agreement you entered
+into with SAMSUNG ELECTRONICS.
+
+SAMSUNG make no representations or warranties about the suitability
+of the software, either express or implied, including but not limited
+to the implied warranties of merchantability, fitness for a particular
+purpose, or non-infringement. SAMSUNG shall not be liable for any
+damages suffered by licensee as a result of using, modifying or
+distributing this software or its derivatives.
+*/
+
+
+
+//******************************************************************************
+//
+// Default style theme for Tizen dark theme, The values should come from
+// UX design document.
+//
+//******************************************************************************
+
+{
+ "styles":
+ {
+ }
+}
\ No newline at end of file
--- /dev/null
+tizen-dark-theme.json
\ No newline at end of file
# Base files
toolkit_base_images_dir = ../../../base/dali-toolkit/images
toolkit_base_sounds_dir = ../../../base/dali-toolkit/sounds
+toolkit_base_styles_dir = ../../../base/dali-toolkit/styles
toolkit_base_src_dir = ../../../base/dali-toolkit/internal
public_api_base_src_dir = ../../../base/dali-toolkit/public-api
include ../../../base/dali-toolkit/images/file.list
include ../../../base/dali-toolkit/sounds/file.list
+include ../../../base/dali-toolkit/styles/file.list
include ../../../base/dali-toolkit/internal/file.list
include ../../../base/dali-toolkit/public-api/file.list
#dalisounddir = ${dataReadOnlyDir}/toolkit/sounds/
#dalisound_DATA = ${dali_toolkit_base_sound_files}
+#dalistyledir = ${dataReadOnlyDir}/toolkit/styles/
+#dalistyle_DATA = ${dali_toolkit_style_files}
+
# The Base library
lib_LTLIBRARIES = libdali-toolkit-base.la
libdali_toolkit_base_la_DEPENDENCIES =
libdali_toolkit_base_la_CXXFLAGS = -DDALI_COMPILATION \
+ -DDALI_TOOLKIT_BASE \
-DDALI_IMAGE_DIR="\"${daliimagedir}\"" \
-DDALI_SOUND_DIR="\"${dalisounddir}\"" \
+ -DDALI_STYLE_DIR="\"${dalistyledir}\"" \
+ -DDALI_DATA_READ_ONLY_DIR="\"${dataReadOnlyDir}\"" \
-Werror -Wall \
-I../../../base \
-I../../../capi \
# Base files
toolkit_base_images_dir = ../../../base/dali-toolkit/images
toolkit_base_sounds_dir = ../../../base/dali-toolkit/sounds
+toolkit_base_styles_dir = ../../../base/dali-toolkit/styles
toolkit_base_src_dir = ../../../base/dali-toolkit/internal
public_api_base_src_dir = ../../../base/dali-toolkit/public-api
include ../../../base/dali-toolkit/images/file.list
include ../../../base/dali-toolkit/sounds/file.list
+include ../../../base/dali-toolkit/styles/file.list
include ../../../base/dali-toolkit/internal/file.list
include ../../../base/dali-toolkit/public-api/file.list
$(toolkit_optional_src_files) \
$(public_api_optional_src_files)
+dalistyledir = ${dataReadOnlyDir}/toolkit/styles/
+dalistyle_DATA = ${dali_toolkit_style_files}
+
libdali_toolkit_la_DEPENDENCIES =
libdali_toolkit_la_CXXFLAGS = -DDALI_COMPILATION \
-DDALI_IMAGE_DIR="\"${daliimagedir}\"" \
-DDALI_SOUND_DIR="\"${dalisounddir}\"" \
+ -DDALI_STYLE_DIR="\"${dalistyledir}\"" \
+ -DDALI_DATA_READ_ONLY_DIR="\"${dataReadOnlyDir}\"" \
-Werror -Wall \
-I../../../base \
-I../../../optional \
publicapibasefocusmanagerdir = $(publicapibasedir)/focus-manager
publicapibasemarkupprocessordir = $(publicapibasedir)/markup-processor
publicapibaseshadereffectsdir = $(publicapibasedir)/shader-effects
+publicapibasestylingdir = $(publicapibasedir)/styling
+publicapibasebuilderdir = $(publicapibasedir)/builder
publicapibase_HEADERS = $(public_api_base_header_files)
publicapibasecontrols_HEADERS = $(public_api_base_controls_header_files)
publicapibasefocusmanager_HEADERS = $(public_api_base_focus_manager_header_files)
publicapibasemarkupprocessor_HEADERS = $(public_api_base_markup_processor_header_files)
publicapibaseshadereffects_HEADERS = $(public_api_base_shader_effects_header_files)
+publicapibasestyling_HEADERS = $(public_api_base_styling_header_files)
+publicapibasebuilder_HEADERS = $(public_api_base_builder_header_files)
# Install Optional headers
publicapioptionalnavigationframedir = $(publicapioptionaldir)/controls/navigation-frame
publicapioptionalshadereffectsdir = $(publicapioptionaldir)/shader-effects
publicapioptionalbubbleeffectdir = $(publicapioptionaldir)/shader-effects/bubble-effect
-publicapioptionalbuilderdir = $(publicapioptionaldir)/builder
publicapioptionaltransitioneffectsdir = $(publicapioptionaldir)/transition-effects
publicapioptional_HEADERS = $(public_api_optional_header_files)
publicapioptionalnavigationframe_HEADERS = $(public_api_optional_navigation_frame_header_files)
publicapioptionalshadereffects_HEADERS = $(public_api_optional_shader_effects_header_files)
publicapioptionalbubbleeffect_HEADERS = $(public_api_optional_bubble_effect_header_files)
-publicapioptionalbuilder_HEADERS = $(public_api_optional_builder_header_files)
publicapioptionaltransitioneffects_HEADERS = $(public_api_optional_transition_effects_header_files)
# Install CAPI headers
capidevelbuilderdir = $(capideveldir)/builder
capidevelutilitiesdir = $(capideveldir)/utilities
capideveltransitioneffectsdir = $(capideveldir)/transition-effects
+capidevelstylingdir = $(capideveldir)/styling
capidevel_HEADERS = $(capi_devel_header_files)
capidevelcontrols_HEADERS = $(capi_devel_controls_header_files)
capidevelbuilder_HEADERS = $(capi_devel_builder_header_files)
capidevelutilities_HEADERS = $(capi_devel_utilities_header_files)
capideveltransitioneffects_HEADERS = $(capi_devel_transition_effects_header_files)
+capidevelstyling_HEADERS = $(capi_devel_styling_header_files)
+
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/control.h>
+#include <dali-toolkit/public-api/styling/style-manager.h>
namespace Dali DALI_IMPORT_API
{
namespace Internal DALI_INTERNAL
{
-class StyleChangeProcessor;
class RelayoutControllerImpl;
class KeyInputFocusManager;
}
virtual void OnInitialize() { }
/**
- * @brief This method should be overridden by deriving classes when
- * they wish to be notified when the style changes.
- *
- * @param[in] change Information denoting what has changed.
+ * @brief Callback for when the theme changes.
*/
- virtual void OnStyleChange(StyleChange change) { }
+ virtual void OnThemeChange( Toolkit::StyleManager styleManager );
/**
* @brief Called whenever a pinch gesture is detected on this control.
protected: // Construction
+ // Flags for the constructor
+ enum ControlBehaviour
+ {
+ CONTROL_BEHAVIOUR_NONE = 0x0,
+ REQUIRES_TOUCH_EVENTS = 0x1, ///< True if the OnTouchEvent() callback is required.
+ REQUIRES_THEME_CHANGE_SIGNALS = 0x2 ///< True if this control should listen to theme change signals
+ };
+
/**
+ * @deprecated Use the constructor taking flags instead
* @brief Create a Control.
*
* @param[in] requiresTouchEvents True if the OnTouchEvent() callback is required.
*/
Control(bool requiresTouchEvents);
+ /**
+ * @brief Create a Control.
+ *
+ * @param[in] behaviourFlags Behavioural flags from ControlBehaviour enum
+ */
+ Control(ControlBehaviour behaviourFlags);
+
public:
// Size negotiation
class Impl;
Impl *mImpl;
- friend class Internal::StyleChangeProcessor;
friend class Internal::RelayoutControllerImpl; ///< Relayout controller needs to call Relayout() which is private.
friend class Internal::KeyInputFocusManager; ///< KeyInputFocusManager needs to call which is private.
};
#include <dali-toolkit/public-api/shader-effects/ripple2d-effect.h>
#include <dali-toolkit/public-api/shader-effects/swirl-effect.h>
-
#endif // __DALI_TOOLKIT_CAPI_INTERNAL_H__
$(capi_devel_src_dir)/shader-effects/ripple-effect.h \
$(capi_devel_src_dir)/shader-effects/ripple2d-effect.h \
$(capi_devel_src_dir)/shader-effects/swirl-effect.h
+
#include <dali-toolkit/public-api/dali-toolkit-capi-internal.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/builder/builder.h>
-#include <dali-toolkit/public-api/builder/tree-node.h>
#include <dali-toolkit/public-api/controls/bloom-view/bloom-view.h>
#include <dali-toolkit/public-api/controls/buttons/check-box-button.h>
#include <dali-toolkit/public-api/transition-effects/cube-transition-cross-effect.h>
#include <dali-toolkit/public-api/transition-effects/cube-transition-fold-effect.h>
+
#endif // __DALI_TOOLKIT_EXT_H__
BloomView::BloomView()
- : Control( false ) // doesn't require touch events
+ : Control( CONTROL_BEHAVIOUR_NONE )
, mBlurNumSamples(BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_NUM_SAMPLES)
, mBlurBellCurveWidth(BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_BLUR_BELL_CURVE_WIDTH)
, mPixelFormat(BLOOM_GAUSSIAN_BLUR_VIEW_DEFAULT_RENDER_TARGET_PIXEL_FORMAT)
BloomView::BloomView( const unsigned int blurNumSamples, const float blurBellCurveWidth, const Pixel::Format renderTargetPixelFormat,
const float downsampleWidthScale, const float downsampleHeightScale)
- : Control( false ) // doesn't require touch events
+ : Control( CONTROL_BEHAVIOUR_NONE )
, mBlurNumSamples(blurNumSamples)
, mBlurBellCurveWidth(blurBellCurveWidth)
, mPixelFormat(renderTargetPixelFormat)
Image shapeImage,
unsigned int maximumNumberOfBubble,
const Vector2& bubbleSizeRange )
-: Control( true ),
+: Control( REQUIRES_TOUCH_EVENTS ),
mMovementArea( movementArea ),
mShapeImage( shapeImage ),
mTotalNumOfBubble( maximumNumberOfBubble ),
}
Cluster::Cluster(Toolkit::ClusterStyle& style)
-: Control(true/*requires touch*/),
+: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_THEME_CHANGE_SIGNALS ) ),
mClusterStyle(style),
mExpandedCount(0)
{
}
EffectsView::EffectsView()
-: Control( false ),
+: Control( CONTROL_BEHAVIOUR_NONE ),
mEffectType( Toolkit::EffectsView::INVALID_TYPE ),
mPixelFormat( EFFECTS_VIEW_DEFAULT_PIXEL_FORMAT ),
mSpread(0.0f),
GaussianBlurView::GaussianBlurView()
- : Control( false ) // doesn't require touch events
+ : Control( CONTROL_BEHAVIOUR_NONE )
, mNumSamples(GAUSSIAN_BLUR_VIEW_DEFAULT_NUM_SAMPLES)
-
, mPixelFormat(GAUSSIAN_BLUR_VIEW_DEFAULT_RENDER_TARGET_PIXEL_FORMAT)
, mDownsampleWidthScale(GAUSSIAN_BLUR_VIEW_DEFAULT_DOWNSAMPLE_WIDTH_SCALE)
, mDownsampleHeightScale(GAUSSIAN_BLUR_VIEW_DEFAULT_DOWNSAMPLE_HEIGHT_SCALE)
GaussianBlurView::GaussianBlurView( const unsigned int numSamples, const float blurBellCurveWidth, const Pixel::Format renderTargetPixelFormat,
const float downsampleWidthScale, const float downsampleHeightScale,
bool blurUserImage)
- : Control( false ) // doesn't require touch events
+ : Control( CONTROL_BEHAVIOUR_NONE )
, mNumSamples(numSamples)
, mPixelFormat(renderTargetPixelFormat)
, mDownsampleWidthScale(downsampleWidthScale)
}
ImageView::ImageView()
-: Control(true)
+: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_THEME_CHANGE_SIGNALS ) )
{
}
}
MaskedImageView::MaskedImageView()
-: Control(true),
+: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_THEME_CHANGE_SIGNALS ) ),
mEditMode( Dali::Toolkit::MaskedImageView::EDIT_DISABLED ),
mSelfPropertySetting( false ),
mSourceRotation( Dali::Toolkit::MaskedImageView::ROTATE_0 ),
}
Magnifier::Magnifier()
-: Control(true),
+: Control( REQUIRES_TOUCH_EVENTS ),
mPropertySourcePosition(Property::INVALID_INDEX),
mActorSize(Vector3::ZERO),
mMagnificationFactor(1.0f)
}
NavigationControl::NavigationControl()
-: Control( true ),
+: Control( REQUIRES_TOUCH_EVENTS ),
mToolBar(NULL),
mTitleBar(NULL),
mOrientationAngle( 0 ),
} // unnamed namespace
Page::Page()
-: Control(false),
+: Control( CONTROL_BEHAVIOUR_NONE ),
mTitle(""),
mSubTitle("")
{
const float PageTurnView::STATIC_PAGE_INTERVAL_DISTANCE = 1.0f;
PageTurnView::PageTurnView( PageFactory& pageFactory, const Vector2& pageSize )
-: Control( true ),
+: Control( REQUIRES_TOUCH_EVENTS ),
mPageFactory( pageFactory ),
mPageSize( pageSize ),
mIsEditMode( false ),
}
RotatingSelector::RotatingSelector()
-: Control(true/*requires touch*/),
+: Control( REQUIRES_TOUCH_EVENTS ),
mSelected(false),
mSelectable(true),
mIsAnimating(false)
} // namespace
ShadowView::ShadowView( float downsampleWidthScale, float downsampleHeightScale )
-: Control( false ), // doesn't require touch events
+: Control( CONTROL_BEHAVIOUR_NONE ),
mChildrenRoot(Actor::New()),
mCachedShadowColor(DEFAULT_SHADOW_COLOR),
mCachedBackgroundColor(DEFAULT_SHADOW_COLOR.r, DEFAULT_SHADOW_COLOR.g, DEFAULT_SHADOW_COLOR.b, 0.0f),
}
Slider::Slider()
-: Control( true ),
+: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_THEME_CHANGE_SIGNALS ) ),
mState( NORMAL ),
mDisableColor( 0.0f, 0.0f, 0.0f, 0.0f ),
mPopupTextColor( 0.0f, 0.0f, 0.0f, 0.0f ),
} // unnamed namespace
SuperBlurView::SuperBlurView( unsigned int blurLevels )
-: Control( false ),
+: Control( CONTROL_BEHAVIOUR_NONE ),
mBlurLevels( blurLevels ),
mBlurStrengthPropertyIndex(Property::INVALID_INDEX),
mResourcesCleared( true ),
}
ToolBar::ToolBar()
-: Control( false ), // doesn't require touch events
+: Control( CONTROL_BEHAVIOUR_NONE ),
mLayout(),
mLeftOffset( 0 ),
mCenterBase( 1 ),
}
View::View(bool fullscreen)
-: Control( false ), // doesn't require touch events
+: Control( CONTROL_BEHAVIOUR_NONE ),
mOrientation( -1 ),
mFullScreen(fullscreen),
mContentLayers(),
# Add local source files here
toolkit_optional_src_files = \
- $(toolkit_optional_src_dir)/builder/builder-impl.cpp \
- $(toolkit_optional_src_dir)/builder/builder-animations.cpp \
- $(toolkit_optional_src_dir)/builder/builder-set-property.cpp \
- $(toolkit_optional_src_dir)/builder/builder-signals.cpp \
- $(toolkit_optional_src_dir)/builder/builder-actor.cpp \
- $(toolkit_optional_src_dir)/builder/json-parser-state.cpp \
- $(toolkit_optional_src_dir)/builder/json-parser-impl.cpp \
- $(toolkit_optional_src_dir)/builder/tree-node-manipulator.cpp \
- $(toolkit_optional_src_dir)/builder/replacement.cpp \
$(toolkit_optional_src_dir)/controls/bloom-view/bloom-view-impl.cpp \
$(toolkit_optional_src_dir)/controls/cluster/cluster-impl.cpp \
$(toolkit_optional_src_dir)/controls/cluster/cluster-style-impl.cpp \
$(public_api_optional_src_dir)/shader-effects/water-effect.cpp \
$(public_api_optional_src_dir)/shader-effects/bubble-effect/bubble-effect.cpp \
$(public_api_optional_src_dir)/shader-effects/bubble-effect/color-adjuster.cpp \
- $(public_api_optional_src_dir)/builder/builder.cpp \
- $(public_api_optional_src_dir)/builder/json-parser.cpp \
- $(public_api_optional_src_dir)/builder/tree-node.cpp \
$(public_api_optional_src_dir)/transition-effects/cube-transition-effect.cpp \
$(public_api_optional_src_dir)/transition-effects/cube-transition-wave-effect.cpp \
$(public_api_optional_src_dir)/transition-effects/cube-transition-cross-effect.cpp \
$(public_api_optional_src_dir)/transition-effects/cube-transition-fold-effect.cpp
-
+
# Add public header files here
public_api_optional_header_files =
public_api_optional_bubble_emitter_header_files =
-public_api_optional_builder_header_files = \
- $(public_api_optional_src_dir)/builder/builder.h \
- $(public_api_optional_src_dir)/builder/json-parser.h \
- $(public_api_optional_src_dir)/builder/tree-node.h
-
public_api_optional_transition_effects_header_files = \
$(public_api_optional_src_dir)/transition-effects/cube-transition-effect.h \
$(public_api_optional_src_dir)/transition-effects/cube-transition-wave-effect.h \
$(public_api_optional_src_dir)/transition-effects/cube-transition-cross-effect.h \
$(public_api_optional_src_dir)/transition-effects/cube-transition-fold-effect.h
+
%define dali_data_ro_dir /usr/share/dali/
%define dali_toolkit_image_files %{dali_data_ro_dir}/toolkit/images/
%define dali_toolkit_sound_files %{dali_data_ro_dir}/toolkit/sounds/
+%define dali_toolkit_style_files %{dali_data_ro_dir}/toolkit/styles/
%define dev_include_path %{_includedir}
##############################
%{_libdir}/lib%{name}.so*
%{dali_toolkit_image_files}/*
%{dali_toolkit_sound_files}/*
+%{dali_toolkit_style_files}/*
%{_datadir}/license/%{name}
%files devel