X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=examples%2Ftext-editor%2Ftext-editor-example.cpp;h=866bdeddbf67f19fdf6a3dbcd5fa9912f0acbf2a;hb=a832af2813558a32f0a18747f3e6134ff6f6f301;hp=209c2800209b4546e4c35e75d6db45749dfb3b58;hpb=03175ecc2e82d4845f84c9033e00d09636576538;p=platform%2Fcore%2Fuifw%2Fdali-demo.git diff --git a/examples/text-editor/text-editor-example.cpp b/examples/text-editor/text-editor-example.cpp index 209c280..866bded 100644 --- a/examples/text-editor/text-editor-example.cpp +++ b/examples/text-editor/text-editor-example.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 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. @@ -22,7 +22,7 @@ // EXTERNAL INCLUDES #include -#include +#include #include // INTERNAL INCLUDES @@ -34,6 +34,7 @@ using namespace Dali::Toolkit; namespace { +const char * const THEME_PATH( DEMO_STYLE_DIR "text-editor-example-theme.json" ); ///< The theme used for this example const Vector4 BACKGROUND_COLOR( 0.04f, 0.345f, 0.392f, 1.0f ); ///< The background color. const char* TOOLBAR_IMAGE = DEMO_IMAGE_DIR "top-bar.png"; ///< The tool-bar image. const float TOOLBAR_BUTTON_PERCENTAGE = 0.1f; ///< The button's space width as a percentage of the toolbar's width. @@ -129,7 +130,7 @@ public: // Add border to highlight harder-to-see colors. // We use a color rather than border visual as the container will always be behind the button. Property::Map colorMap; - colorMap.Insert( Visual::Property::TYPE, Visual::COLOR); + colorMap.Insert( Toolkit::Visual::Property::TYPE, Visual::COLOR); colorMap.Insert( ColorVisual::Property::MIX_COLOR, Color::BLACK ); mColorContainer.SetProperty( Control::Property::BACKGROUND, colorMap ); @@ -140,8 +141,7 @@ public: mColorButtonOption.SetParentOrigin( ParentOrigin::CENTER ); mColorButtonOption.SetAnchorPoint( AnchorPoint::CENTER ); - mColorButtonOption.SetProperty( Button::Property::UNSELECTED_COLOR, Color::BLACK ); - mColorButtonOption.SetProperty( Button::Property::SELECTED_COLOR, Color::BLACK ); + SetButtonColor( mColorButtonOption, Color::BLACK ); mColorButtonOption.ClickedSignal().Connect( this, &TextEditorExample::OnChangeColorButtonClicked ); mColorContainer.Add( mColorButtonOption ); @@ -183,6 +183,8 @@ public: mEditor.InputStyleChangedSignal().Connect( this, &TextEditorExample::OnTextInputStyleChanged ); contents.Add( mEditor ); + StyleManager styleManager = StyleManager::Get(); + styleManager.ApplyTheme( THEME_PATH ); } void CreateButtonContainer() @@ -208,8 +210,7 @@ public: s << "color" << index; button.SetName( s.str() ); - button.SetProperty( Button::Property::UNSELECTED_COLOR, COLORS[index] ); - button.SetProperty( Button::Property::SELECTED_COLOR, COLORS[index] ); + SetButtonColor( button, COLORS[index] ); button.ClickedSignal().Connect( this, &TextEditorExample::OnColorButtonClicked ); @@ -253,8 +254,7 @@ public: mEditor.SetProperty( TextEditor::Property::INPUT_COLOR, color ); } - mColorButtonOption.SetProperty( Button::Property::UNSELECTED_COLOR, color ); - mColorButtonOption.SetProperty( Button::Property::SELECTED_COLOR, color ); + SetButtonColor( mColorButtonOption, color ); mButtonContainer.SetVisible( false ); mButtonContainer.SetSensitive( false ); @@ -267,14 +267,22 @@ public: if( TextEditor::InputStyle::NONE != static_cast( mask & TextEditor::InputStyle::COLOR ) ) { const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get(); - - mColorButtonOption.SetProperty( Button::Property::UNSELECTED_COLOR, color ); - mColorButtonOption.SetProperty( Button::Property::SELECTED_COLOR, color ); + SetButtonColor( mColorButtonOption, color ); } editor.Reset(); } + void SetButtonColor( Button& button, const Vector4& color ) + { + Property::Map colorVisualMap; + colorVisualMap.Add( Toolkit::Visual::Property::TYPE, Visual::COLOR ) + .Add( ColorVisual::Property::MIX_COLOR, color ); + + button.SetProperty( DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, colorVisualMap ); + button.SetProperty( DevelButton::Property::SELECTED_BACKGROUND_VISUAL, colorVisualMap ); + } + private: Application& mApplication;