[3.0] Added bubble effect back in dali-demo (+visual changes)
[platform/core/uifw/dali-demo.git] / examples / text-editor / text-editor-example.cpp
index 5ec61b7..d2a05d7 100644 (file)
@@ -62,7 +62,6 @@ const unsigned int NUMBER_OF_COLORS = sizeof( COLORS ) / sizeof( Vector4 );
 class TextEditorExample : public ConnectionTracker
 {
 public:
-
   TextEditorExample( Application& application )
   : mApplication( application )
   {
@@ -131,6 +130,13 @@ public:
 
     mEditor.SetBackgroundColor( TEXT_EDITOR_BACKGROUND_COLOR );
 
+    const Size boundingBoxSize( stageSize * 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"
@@ -145,6 +151,8 @@ public:
                          "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 );
   }
 
@@ -215,18 +223,36 @@ public:
   {
     const std::string& name = button.GetName();
 
+    Vector4 color;
     if( "color" == name.substr( 0u, 5u ) )
     {
       const unsigned int index = strtoul( name.substr( 5u, 1u ).c_str(), NULL, 10u );
-      mEditor.SetProperty( TextEditor::Property::INPUT_COLOR, COLORS[index] );
+      color = COLORS[index];
+      mEditor.SetProperty( TextEditor::Property::INPUT_COLOR, color );
     }
 
+    mColorButtonOption.SetProperty( Button::Property::UNSELECTED_COLOR, color );
+    mColorButtonOption.SetProperty( Button::Property::SELECTED_COLOR, color );
+
     mButtonContainer.SetVisible( false );
     mButtonContainer.SetSensitive( false );
 
     return true;
   }
 
+  void OnTextInputStyleChanged( TextEditor editor, TextEditor::InputStyle::Mask mask )
+  {
+    if( TextEditor::InputStyle::NONE != static_cast<TextEditor::InputStyle::Mask>( mask & TextEditor::InputStyle::COLOR ) )
+    {
+      const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
+
+      mColorButtonOption.SetProperty( Button::Property::UNSELECTED_COLOR, color );
+      mColorButtonOption.SetProperty( Button::Property::SELECTED_COLOR, color );
+    }
+
+    editor.Reset();
+  }
+
 private:
 
   Application& mApplication;