Updated demos to use DALi clang-format
[platform/core/uifw/dali-demo.git] / examples / text-editor / text-editor-example.cpp
index 35b8e60..d291bbb 100644 (file)
@@ -33,27 +33,26 @@ 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.
-const float   TOOLBAR_TITLE_PERCENTAGE = 0.7f;                      ///< The title's width as a percentage of the toolbar's width.
-const float   TOOLBAR_HEIGHT_PERCENTAGE = 0.05f;                    ///< The toolbar's height as a percentage of the window's height.
-const float   TOOLBAR_PADDING = 4.f;                                ///< The padding in pixels.
-const float   BUTTON_PERCENTAGE = 0.8f;                             ///< The button's height as a percentage of the space for the buttons in the toolbar.
-const Vector3 TEXT_EDITOR_RELATIVE_SIZE( 0.9f, 0.5f, 1.0f );        ///< The size of the text editor as a percentage of the window's size.
-const Vector4 TEXT_EDITOR_BACKGROUND_COLOR( 1.f, 1.f, 1.f, 0.15f ); ///< The background color of the text editor.
-
-const Vector4 COLORS[] = { Color::RED,
-                           Color::GREEN,
-                           Color::BLUE,
-                           Color::YELLOW,
-                           Color::CYAN,
-                           Color::MAGENTA,
-                           Color::WHITE,
-                           Color::BLACK };
-const unsigned int NUMBER_OF_COLORS = sizeof( COLORS ) / sizeof( Vector4 );
+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.
+const float       TOOLBAR_TITLE_PERCENTAGE  = 0.7f;                            ///< The title's width as a percentage of the toolbar's width.
+const float       TOOLBAR_HEIGHT_PERCENTAGE = 0.05f;                           ///< The toolbar's height as a percentage of the window's height.
+const float       TOOLBAR_PADDING           = 4.f;                             ///< The padding in pixels.
+const float       BUTTON_PERCENTAGE         = 0.8f;                            ///< The button's height as a percentage of the space for the buttons in the toolbar.
+const Vector3     TEXT_EDITOR_RELATIVE_SIZE(0.9f, 0.5f, 1.0f);                 ///< The size of the text editor as a percentage of the window's size.
+const Vector4     TEXT_EDITOR_BACKGROUND_COLOR(1.f, 1.f, 1.f, 0.15f);          ///< The background color of the text editor.
+
+const Vector4      COLORS[]         = {Color::RED,
+                          Color::GREEN,
+                          Color::BLUE,
+                          Color::YELLOW,
+                          Color::CYAN,
+                          Color::MAGENTA,
+                          Color::WHITE,
+                          Color::BLACK};
+const unsigned int NUMBER_OF_COLORS = sizeof(COLORS) / sizeof(Vector4);
 
 } // Unnamed namespace
 
@@ -63,11 +62,11 @@ const unsigned int NUMBER_OF_COLORS = sizeof( COLORS ) / sizeof( Vector4 );
 class TextEditorExample : public ConnectionTracker
 {
 public:
-  TextEditorExample( Application& application )
-  : mApplication( application )
+  TextEditorExample(Application& application)
+  : mApplication(application)
   {
     // Connect to the Application's Init signal
-    mApplication.InitSignal().Connect( this, &TextEditorExample::Create );
+    mApplication.InitSignal().Connect(this, &TextEditorExample::Create);
   }
 
   ~TextEditorExample()
@@ -78,7 +77,7 @@ public:
   /**
    * One-time setup in response to Application InitSignal.
    */
-  void Create( Application& application )
+  void Create(Application& application)
   {
     Window window = application.GetWindow();
 
@@ -86,7 +85,7 @@ public:
     window.KeyEventSignal().Connect(this, &TextEditorExample::OnKeyEvent);
 
     // Set a background color.
-    window.SetBackgroundColor( BACKGROUND_COLOR );
+    window.SetBackgroundColor(BACKGROUND_COLOR);
 
     // The window size.
     const Vector2 windowSize = window.GetSize();
@@ -95,134 +94,134 @@ public:
     // The view is added to the window.
 
     // Set the toolbar style
-    const float toolBarHeight = TOOLBAR_HEIGHT_PERCENTAGE * windowSize.height;
-    const DemoHelper::ViewStyle viewStyle( TOOLBAR_BUTTON_PERCENTAGE,
-                                           TOOLBAR_TITLE_PERCENTAGE,
-                                           toolBarHeight,
-                                           TOOLBAR_PADDING );
-
-    Layer contents = DemoHelper::CreateView( mApplication,
-                                             mView,
-                                             mToolBar,
-                                             "",
-                                             TOOLBAR_IMAGE,
-                                             "",
-                                             viewStyle );
+    const float                 toolBarHeight = TOOLBAR_HEIGHT_PERCENTAGE * windowSize.height;
+    const DemoHelper::ViewStyle viewStyle(TOOLBAR_BUTTON_PERCENTAGE,
+                                          TOOLBAR_TITLE_PERCENTAGE,
+                                          toolBarHeight,
+                                          TOOLBAR_PADDING);
+
+    Layer contents = DemoHelper::CreateView(mApplication,
+                                            mView,
+                                            mToolBar,
+                                            "",
+                                            TOOLBAR_IMAGE,
+                                            "",
+                                            viewStyle);
 
     // Create a label for the color selection button.
     // The button will be a child of this, so as to be placed next to it.
-    TextLabel colorLabel = TextLabel::New( "Text Color: " );
-    colorLabel.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::WIDTH );
-    colorLabel.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT );
-    colorLabel.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
+    TextLabel colorLabel = TextLabel::New("Text Color: ");
+    colorLabel.SetResizePolicy(ResizePolicy::USE_NATURAL_SIZE, Dimension::WIDTH);
+    colorLabel.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT);
+    colorLabel.SetProperty(TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER");
 
     // Create a container for the color button, to layout the drop-down list below it.
     mColorContainer = Control::New();
-    mColorContainer.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::WIDTH );
-    mColorContainer.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::HEIGHT );
-    mColorContainer.SetProperty( Actor::Property::SIZE_MODE_FACTOR, Vector3( 0.0f, BUTTON_PERCENTAGE, 0.0f ) );
+    mColorContainer.SetResizePolicy(ResizePolicy::DIMENSION_DEPENDENCY, Dimension::WIDTH);
+    mColorContainer.SetResizePolicy(ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::HEIGHT);
+    mColorContainer.SetProperty(Actor::Property::SIZE_MODE_FACTOR, Vector3(0.0f, BUTTON_PERCENTAGE, 0.0f));
 
     // Place to right of parent.
-    mColorContainer.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_RIGHT );
-    mColorContainer.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT );
-    colorLabel.Add( mColorContainer );
+    mColorContainer.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_RIGHT);
+    mColorContainer.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT);
+    colorLabel.Add(mColorContainer);
 
     // 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( Toolkit::Visual::Property::TYPE, Visual::COLOR);
-    colorMap.Insert( ColorVisual::Property::MIX_COLOR, Color::BLACK );
-    mColorContainer.SetProperty( Control::Property::BACKGROUND, colorMap );
+    colorMap.Insert(Toolkit::Visual::Property::TYPE, Visual::COLOR);
+    colorMap.Insert(ColorVisual::Property::MIX_COLOR, Color::BLACK);
+    mColorContainer.SetProperty(Control::Property::BACKGROUND, colorMap);
 
     // Create a 'select color' button.
     mColorButtonOption = Toolkit::PushButton::New();
-    mColorButtonOption.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS );
-    mColorButtonOption.SetProperty( Actor::Property::SIZE_MODE_FACTOR, Vector3( 0.9f, 0.9f, 0.0f ) ); // Smaller than container to show border.
-    mColorButtonOption.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
-    mColorButtonOption.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
+    mColorButtonOption.SetResizePolicy(ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS);
+    mColorButtonOption.SetProperty(Actor::Property::SIZE_MODE_FACTOR, Vector3(0.9f, 0.9f, 0.0f)); // Smaller than container to show border.
+    mColorButtonOption.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
+    mColorButtonOption.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
 
-    SetButtonColor( mColorButtonOption, Color::BLACK );
+    SetButtonColor(mColorButtonOption, Color::BLACK);
 
-    mColorButtonOption.ClickedSignal().Connect( this, &TextEditorExample::OnChangeColorButtonClicked );
-    mColorContainer.Add( mColorButtonOption );
+    mColorButtonOption.ClickedSignal().Connect(this, &TextEditorExample::OnChangeColorButtonClicked);
+    mColorContainer.Add(mColorButtonOption);
 
     //Add label to toolbar, which will also add the color button next to it.
-    mToolBar.AddControl( colorLabel, viewStyle.mToolBarButtonPercentage, Toolkit::Alignment::HORIZONTAL_LEFT, DemoHelper::DEFAULT_MODE_SWITCH_PADDING  );
+    mToolBar.AddControl(colorLabel, viewStyle.mToolBarButtonPercentage, Toolkit::Alignment::HORIZONTAL_LEFT, DemoHelper::DEFAULT_MODE_SWITCH_PADDING);
 
     // Create the text editor.
     mEditor = TextEditor::New();
-    mEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER );
-    mEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER );
-    mEditor.SetProperty( Actor::Property::POSITION, Vector3( 0.f, toolBarHeight * 2.0f, 0.f ));
-    mEditor.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS );
-    mEditor.SetProperty( Actor::Property::SIZE_MODE_FACTOR, TEXT_EDITOR_RELATIVE_SIZE );
-
-    mEditor.SetBackgroundColor( TEXT_EDITOR_BACKGROUND_COLOR );
-
-    const Size boundingBoxSize( windowSize * TEXT_EDITOR_RELATIVE_SIZE.GetVectorXY() );
-    Rect<int> boundingBox( 0,
-                           static_cast<int>( toolBarHeight ),
-                           static_cast<int>( boundingBoxSize.width ),
-                           static_cast<int>( boundingBoxSize.height - toolBarHeight ) );
-
-    mEditor.SetProperty( TextEditor::Property::DECORATION_BOUNDING_BOX, boundingBox );
-    mEditor.SetProperty( TextEditor::Property::TEXT_COLOR, Color::BLACK );
-    mEditor.SetProperty( TextEditor::Property::TEXT,
-                         "Lorem ipsum dolor sit amet, aeque definiebas ea mei, posse iracundia ne cum.\n"
-                         "Usu ne nisl maiorum iudicabit, veniam epicurei oporteat eos an.\n"
-                         "Ne nec nulla regione albucius, mea doctus delenit ad!\n"
-                         "Et everti blandit adversarium mei, eam porro neglegentur suscipiantur an.\n"
-                         "Quidam corpora at duo. An eos possim scripserit?\n\n"
-                         "Aťqui dicant sěnťenťíae aň vel!\n"
-                         "Vis viris médiocrem elaboraret ét, verear civibus moderatius ex duo!\n"
-                         "Án veri laborě iňtěgré quó, mei aď poššit lobortis, mei prompťa čonsťitůťó eů.\n"
-                         "Aliquip sanctůs delicáta quí ěá, et natum aliquam est?\n"
-                         "Asšúm sapěret usu ůť.\n"
-                         "Síť ut apeirián laboramúš percipitur, sůas hařum ín éos?\n" );
-
-    mEditor.InputStyleChangedSignal().Connect( this, &TextEditorExample::OnTextInputStyleChanged );
-
-    contents.Add( mEditor );
+    mEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER);
+    mEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER);
+    mEditor.SetProperty(Actor::Property::POSITION, Vector3(0.f, toolBarHeight * 2.0f, 0.f));
+    mEditor.SetResizePolicy(ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS);
+    mEditor.SetProperty(Actor::Property::SIZE_MODE_FACTOR, TEXT_EDITOR_RELATIVE_SIZE);
+
+    mEditor.SetBackgroundColor(TEXT_EDITOR_BACKGROUND_COLOR);
+
+    const Size boundingBoxSize(windowSize * TEXT_EDITOR_RELATIVE_SIZE.GetVectorXY());
+    Rect<int>  boundingBox(0,
+                          static_cast<int>(toolBarHeight),
+                          static_cast<int>(boundingBoxSize.width),
+                          static_cast<int>(boundingBoxSize.height - toolBarHeight));
+
+    mEditor.SetProperty(TextEditor::Property::DECORATION_BOUNDING_BOX, boundingBox);
+    mEditor.SetProperty(TextEditor::Property::TEXT_COLOR, Color::BLACK);
+    mEditor.SetProperty(TextEditor::Property::TEXT,
+                        "Lorem ipsum dolor sit amet, aeque definiebas ea mei, posse iracundia ne cum.\n"
+                        "Usu ne nisl maiorum iudicabit, veniam epicurei oporteat eos an.\n"
+                        "Ne nec nulla regione albucius, mea doctus delenit ad!\n"
+                        "Et everti blandit adversarium mei, eam porro neglegentur suscipiantur an.\n"
+                        "Quidam corpora at duo. An eos possim scripserit?\n\n"
+                        "Aťqui dicant sěnťenťíae aň vel!\n"
+                        "Vis viris médiocrem elaboraret ét, verear civibus moderatius ex duo!\n"
+                        "Án veri laborě iňtěgré quó, mei aď poššit lobortis, mei prompťa čonsťitůťó eů.\n"
+                        "Aliquip sanctůs delicáta quí ěá, et natum aliquam est?\n"
+                        "Asšúm sapěret usu ůť.\n"
+                        "Síť ut apeirián laboramúš percipitur, sůas hařum ín éos?\n");
+
+    mEditor.InputStyleChangedSignal().Connect(this, &TextEditorExample::OnTextInputStyleChanged);
+
+    contents.Add(mEditor);
     StyleManager styleManager = StyleManager::Get();
-    styleManager.ApplyTheme( THEME_PATH );
+    styleManager.ApplyTheme(THEME_PATH);
   }
 
   void CreateButtonContainer()
   {
-    mButtonContainer = Toolkit::TableView::New( NUMBER_OF_COLORS, 1u );
-    mButtonContainer.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS );
-    mButtonContainer.SetProperty( Actor::Property::SIZE_MODE_FACTOR, Vector3( 1.0f, NUMBER_OF_COLORS, 1.0f ) );
+    mButtonContainer = Toolkit::TableView::New(NUMBER_OF_COLORS, 1u);
+    mButtonContainer.SetResizePolicy(ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS);
+    mButtonContainer.SetProperty(Actor::Property::SIZE_MODE_FACTOR, Vector3(1.0f, NUMBER_OF_COLORS, 1.0f));
 
     // Place below color selection button.
-    mButtonContainer.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_CENTER  );
-    mButtonContainer.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER );
-    mButtonContainer.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 2.f * TOOLBAR_PADDING, 0.f ));
-    mColorContainer.Add( mButtonContainer );
+    mButtonContainer.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_CENTER);
+    mButtonContainer.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER);
+    mButtonContainer.SetProperty(Actor::Property::POSITION, Vector3(0.0f, 2.f * TOOLBAR_PADDING, 0.f));
+    mColorContainer.Add(mButtonContainer);
 
-    const Vector3 buttonPercentage( 1.f, 0.8f / static_cast<float>( NUMBER_OF_COLORS ), 1.f );
-    for( unsigned int index = 0u; index < NUMBER_OF_COLORS; ++index )
+    const Vector3 buttonPercentage(1.f, 0.8f / static_cast<float>(NUMBER_OF_COLORS), 1.f);
+    for(unsigned int index = 0u; index < NUMBER_OF_COLORS; ++index)
     {
       Toolkit::PushButton button = Toolkit::PushButton::New();
-      button.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS );
-      button.SetProperty( Actor::Property::SIZE_MODE_FACTOR, buttonPercentage );
+      button.SetResizePolicy(ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS);
+      button.SetProperty(Actor::Property::SIZE_MODE_FACTOR, buttonPercentage);
 
       std::ostringstream s;
       s << "color" << index;
-      button.SetProperty( Dali::Actor::Property::NAME, s.str() );
+      button.SetProperty(Dali::Actor::Property::NAME, s.str());
 
-      SetButtonColor( button, COLORS[index] );
+      SetButtonColor(button, COLORS[index]);
 
-      button.ClickedSignal().Connect( this, &TextEditorExample::OnColorButtonClicked );
+      button.ClickedSignal().Connect(this, &TextEditorExample::OnColorButtonClicked);
 
-      mButtonContainer.Add( button );
+      mButtonContainer.Add(button);
     }
   }
 
-  void OnKeyEvent( const KeyEvent& event )
+  void OnKeyEvent(const KeyEvent& event)
   {
-    if( event.GetState() == KeyEvent::DOWN )
+    if(event.GetState() == KeyEvent::DOWN)
     {
-      if( IsKey( event, Dali::DALI_KEY_ESCAPE ) || IsKey( event, Dali::DALI_KEY_BACK ) )
+      if(IsKey(event, Dali::DALI_KEY_ESCAPE) || IsKey(event, Dali::DALI_KEY_BACK))
       {
         // Exit application when click back or escape.
         mApplication.Quit();
@@ -230,61 +229,60 @@ public:
     }
   }
 
-  bool OnChangeColorButtonClicked( Button button )
+  bool OnChangeColorButtonClicked(Button button)
   {
-    if( !mButtonContainer )
+    if(!mButtonContainer)
     {
       CreateButtonContainer();
     }
 
-    mButtonContainer.SetProperty( Actor::Property::VISIBLE, true );
-    mButtonContainer.SetProperty( Actor::Property::SENSITIVE, true );
+    mButtonContainer.SetProperty(Actor::Property::VISIBLE, true);
+    mButtonContainer.SetProperty(Actor::Property::SENSITIVE, true);
     return true;
   }
 
-  bool OnColorButtonClicked( Button button )
+  bool OnColorButtonClicked(Button button)
   {
-    const std::string& name = button.GetProperty< std::string >( Dali::Actor::Property::NAME );
+    const std::string& name = button.GetProperty<std::string>(Dali::Actor::Property::NAME);
 
     Vector4 color;
-    if( "color" == name.substr( 0u, 5u ) )
+    if("color" == name.substr(0u, 5u))
     {
-      const unsigned int index = strtoul( name.substr( 5u, 1u ).c_str(), NULL, 10u );
-      color = COLORS[index];
-      mEditor.SetProperty( TextEditor::Property::INPUT_COLOR, color );
+      const unsigned int index = strtoul(name.substr(5u, 1u).c_str(), NULL, 10u);
+      color                    = COLORS[index];
+      mEditor.SetProperty(TextEditor::Property::INPUT_COLOR, color);
     }
 
-    SetButtonColor( mColorButtonOption, color  );
+    SetButtonColor(mColorButtonOption, color);
 
-    mButtonContainer.SetProperty( Actor::Property::VISIBLE, false );
-    mButtonContainer.SetProperty( Actor::Property::SENSITIVE, false );
+    mButtonContainer.SetProperty(Actor::Property::VISIBLE, false);
+    mButtonContainer.SetProperty(Actor::Property::SENSITIVE, false);
 
     return true;
   }
 
-  void OnTextInputStyleChanged( TextEditor editor, TextEditor::InputStyle::Mask mask )
+  void OnTextInputStyleChanged(TextEditor editor, TextEditor::InputStyle::Mask mask)
   {
-    if( TextEditor::InputStyle::NONE != static_cast<TextEditor::InputStyle::Mask>( mask & TextEditor::InputStyle::COLOR ) )
+    if(TextEditor::InputStyle::NONE != static_cast<TextEditor::InputStyle::Mask>(mask & TextEditor::InputStyle::COLOR))
     {
-      const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
-      SetButtonColor( mColorButtonOption, color  );
+      const Vector4 color = editor.GetProperty(TextEditor::Property::INPUT_COLOR).Get<Vector4>();
+      SetButtonColor(mColorButtonOption, color);
     }
 
     editor.Reset();
   }
 
-  void SetButtonColor( Button& button, const Vector4& color )
+  void SetButtonColor(Button& button, const Vector4& color)
   {
     Property::Map colorVisualMap;
-    colorVisualMap.Add( Toolkit::Visual::Property::TYPE, Visual::COLOR )
-                  .Add( ColorVisual::Property::MIX_COLOR, color );
+    colorVisualMap.Add(Toolkit::Visual::Property::TYPE, Visual::COLOR)
+      .Add(ColorVisual::Property::MIX_COLOR, color);
 
-    button.SetProperty( Button::Property::UNSELECTED_BACKGROUND_VISUAL, colorVisualMap );
-    button.SetProperty( Button::Property::SELECTED_BACKGROUND_VISUAL, colorVisualMap );
+    button.SetProperty(Button::Property::UNSELECTED_BACKGROUND_VISUAL, colorVisualMap);
+    button.SetProperty(Button::Property::SELECTED_BACKGROUND_VISUAL, colorVisualMap);
   }
 
 private:
-
   Application& mApplication;
 
   Toolkit::Control    mView;
@@ -295,11 +293,11 @@ private:
   Toolkit::TableView  mButtonContainer;
 };
 
-int DALI_EXPORT_API main( int argc, char **argv )
+int DALI_EXPORT_API main(int argc, char** argv)
 {
   // DALI_DEMO_THEME_PATH not passed to Application so TextEditor example uses default Toolkit style sheet.
-  Application application = Application::New( &argc, &argv );
-  TextEditorExample test( application );
+  Application       application = Application::New(&argc, &argv);
+  TextEditorExample test(application);
   application.MainLoop();
   return 0;
 }