Revert "[3.0] Implement wayland clipboard & same behaviour as EFL clipboard" 39/97739/1
authordongsug.song <dongsug.song@samsung.com>
Tue, 15 Nov 2016 02:41:45 +0000 (11:41 +0900)
committerdongsug.song <dongsug.song@samsung.com>
Tue, 15 Nov 2016 02:41:48 +0000 (11:41 +0900)
This reverts commit 591c2d9d883a473c34784073e9a4559b5d4e775c.

Change-Id: I2503c9264181216eb71abda9bcfb1c99edd4737a

automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-clipboard.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-clipboard.h
automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp
automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp
dali-toolkit/internal/text/text-controller-impl.cpp
dali-toolkit/internal/text/text-controller-impl.h
dali-toolkit/internal/text/text-controller.cpp

index 1d06f25..956da8d 100644 (file)
@@ -19,7 +19,7 @@
 
 // EXTERNAL INCLUDES
 #include <dali/public-api/object/base-object.h>
-#include <dali/devel-api/adaptor-framework/clipboard-event-notifier.h>
+
 
 namespace Dali
 {
@@ -56,9 +56,9 @@ public:
   bool SetItem(const std::string &itemData);
 
   /**
-   * @copydoc Dali::Clipboard::RequestItem()
+   * @copydoc Dali::Clipboard::GetItem()
    */
-  void RequestItem();
+  std::string GetItem( unsigned int index );
 
   /**
    * @copydoc Dali::Clipboard::NumberOfClipboardItems()
@@ -75,29 +75,20 @@ public:
    */
   void HideClipboard();
 
-  /**
-  * @copydoc Dali::Clipboard::IsVisible()
-  */
-  bool IsVisible() const;
 
 private:
   Clipboard( const Clipboard& );
   Clipboard& operator=( Clipboard& );
 
   static Dali::Clipboard mToolkitClipboard;
-  bool mVisible;
-  std::string mItem;
-  int mCount;
 }; // class clipboard
 
 
 Dali::Clipboard Dali::Internal::Adaptor::Clipboard::mToolkitClipboard;
 
 
-Clipboard::Clipboard()
+Clipboard::Clipboard( /*Ecore_X_Window ecoreXwin*/)
 {
-  mVisible = false;
-  mCount = 0;
 }
 
 Clipboard::~Clipboard()
@@ -115,40 +106,27 @@ Dali::Clipboard Clipboard::Get()
 
 bool Clipboard::SetItem(const std::string &itemData )
 {
-  mItem = itemData;
-  mCount = 1;
   return true;
 }
 
-void Clipboard::RequestItem()
+std::string Clipboard::GetItem( unsigned int index )
 {
-  Dali::ClipboardEventNotifier clipboardEventNotifier(Dali::ClipboardEventNotifier::Get());
-  if ( clipboardEventNotifier )
-  {
-    clipboardEventNotifier.SetContent( mItem );
-    clipboardEventNotifier.EmitContentSelectedSignal();
-  }
+  return "";
 }
 
 unsigned int Clipboard::NumberOfItems()
 {
-  return mCount;
+  return 0;
 }
 
 void Clipboard::ShowClipboard()
 {
-  mVisible = true;
 }
 
 void Clipboard::HideClipboard()
 {
-  mVisible = false;
 }
 
-bool Clipboard::IsVisible() const
-{
-  return mVisible;
-}
 
 } // namespace Adaptor
 
@@ -192,9 +170,9 @@ bool Clipboard::SetItem( const std::string &itemData)
   return GetImplementation(*this).SetItem( itemData );
 }
 
-void Clipboard::RequestItem()
+std::string Clipboard::GetItem( unsigned int index )
 {
-  GetImplementation(*this).RequestItem();
+  return GetImplementation(*this).GetItem( index );
 }
 
 unsigned int Clipboard::NumberOfItems()
@@ -212,9 +190,4 @@ void Clipboard::HideClipboard()
   GetImplementation(*this).HideClipboard();
 }
 
-bool Clipboard::IsVisible() const
-{
-  return GetImplementation(*this).IsVisible();
-}
-
 } // namespace Dali
index 0f9cb42..a67c0da 100644 (file)
@@ -74,9 +74,11 @@ public:
   bool SetItem( const std::string& itemData );
 
   /**
-   * Request clipboard service to retrieve an item
+   * Retreive the string at the given index in the clip board.
+   * @param[in] index item in clipboard list to retrieve
+   * @return string the text item at the current index.
    */
-  void RequestItem();
+  std::string GetItem( unsigned int index );
 
   /**
    * Returns the number of item currently in the clipboard
@@ -94,12 +96,6 @@ public:
    */
   void HideClipboard();
 
-  /**
-  * @brief Retrieves the clipboard's visibility
-  * @return bool true if the clipboard is visible.
-  */
-  bool IsVisible() const;
-
 };
 } // namespace Dali
 
index 83744f3..e9dd5e8 100644 (file)
@@ -20,7 +20,6 @@
 #include <unistd.h>
 
 #include <dali/public-api/rendering/renderer.h>
-#include <dali/devel-api/adaptor-framework/clipboard.h>
 #include <dali/integration-api/events/key-event-integ.h>
 #include <dali/integration-api/events/tap-gesture-event.h>
 #include <dali-toolkit-test-suite-utils.h>
@@ -1253,17 +1252,6 @@ int utcDaliTextEditorEvent03(void)
   application.SendNotification();
   application.Render();
 
-  // Send some taps and check text controller with clipboard window
-  Dali::Clipboard clipboard = Clipboard::Get();
-  clipboard.ShowClipboard();
-  application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
-  application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
-  clipboard.HideClipboard();
-
-  // Render and notify
-  application.SendNotification();
-  application.Render();
-
   // Tap first to get the focus.
   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
index 0335e4e..3cc605c 100644 (file)
@@ -27,7 +27,6 @@
 #include <dali/integration-api/events/long-press-gesture-event.h>
 #include <dali-toolkit-test-suite-utils.h>
 #include <dali-toolkit/dali-toolkit.h>
-#include "toolkit-clipboard.h"
 
 using namespace Dali;
 using namespace Toolkit;
@@ -214,22 +213,6 @@ static int Wait(ToolkitTestApplication& application, int duration = 0)
   return time;
 }
 
-Dali::Integration::Point GetPointDownInside( Vector2& pos )
-{
-  Dali::Integration::Point point;
-  point.SetState( PointState::DOWN );
-  point.SetScreenPosition( pos );
-  return point;
-}
-
-Dali::Integration::Point GetPointUpInside( Vector2& pos )
-{
-  Dali::Integration::Point point;
-  point.SetState( PointState::UP );
-  point.SetScreenPosition( pos );
-  return point;
-}
-
 struct CallbackFunctor
 {
   CallbackFunctor(bool* callbackFlag)
@@ -1741,9 +1724,6 @@ int utcDaliTextFieldEvent08(void)
   ToolkitTestApplication application;
   tet_infoline(" utcDaliTextFieldEvent08");
 
-  Dali::Clipboard clipboard = Clipboard::Get();
-  clipboard.SetItem("testTextFieldEvent");
-
   // Checks Longpress when only place holder text
 
   TextField field = TextField::New();
@@ -1774,28 +1754,6 @@ int utcDaliTextFieldEvent08(void)
   application.SendNotification();
   application.Render();
 
-  Wait(application, 500);
-
-  Stage stage = Stage::GetCurrent();
-  Layer layer = stage.GetRootLayer();
-  Actor actor = layer.FindChildByName("optionPaste");
-
-  if (actor)
-  {
-    Vector3 worldPosition = actor.GetCurrentWorldPosition();
-    Vector2 halfStageSize = stage.GetSize() / 2.0f;
-    Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
-
-    Dali::Integration::TouchEvent event;
-    event = Dali::Integration::TouchEvent();
-    event.AddPoint( GetPointDownInside( position ) );
-    application.ProcessEvent( event );
-
-    event = Dali::Integration::TouchEvent();
-    event.AddPoint( GetPointUpInside( position ) );
-    application.ProcessEvent( event );
-  }
-  DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
   END_TEST;
 }
 
index 5769fac..b6efd59 100644 (file)
@@ -1747,11 +1747,11 @@ void Controller::Impl::SendSelectionToClipboard( bool deleteAfterSending )
   ChangeState( EventData::EDITING );
 }
 
-void Controller::Impl::RequestGetTextFromClipboard()
+void Controller::Impl::GetTextFromClipboard( unsigned int itemIndex, std::string& retrievedString )
 {
   if ( mClipboard )
   {
-    mClipboard.RequestItem();
+    retrievedString =  mClipboard.GetItem( itemIndex );
   }
 }
 
@@ -2289,6 +2289,7 @@ void Controller::Impl::ChangeState( EventData::State newState )
         mEventData->mDecorator->SetHighlightActive( false );
         mEventData->mDecorator->SetPopupActive( false );
         mEventData->mDecoratorUpdated = true;
+        HideClipboard();
         break;
       }
       case EventData::INTERRUPTED:
@@ -2299,6 +2300,7 @@ void Controller::Impl::ChangeState( EventData::State newState )
         mEventData->mDecorator->SetHighlightActive( false );
         mEventData->mDecorator->SetPopupActive( false );
         mEventData->mDecoratorUpdated = true;
+        HideClipboard();
         break;
       }
       case EventData::SELECTING:
@@ -2334,6 +2336,7 @@ void Controller::Impl::ChangeState( EventData::State newState )
           mEventData->mDecorator->SetPopupActive( false );
         }
         mEventData->mDecoratorUpdated = true;
+        HideClipboard();
         break;
       }
       case EventData::EDITING_WITH_POPUP:
@@ -2360,6 +2363,7 @@ void Controller::Impl::ChangeState( EventData::State newState )
           SetPopupButtons();
           mEventData->mDecorator->SetPopupActive( true );
         }
+        HideClipboard();
         mEventData->mDecoratorUpdated = true;
         break;
       }
@@ -2382,6 +2386,7 @@ void Controller::Impl::ChangeState( EventData::State newState )
           mEventData->mDecorator->SetPopupActive( false );
         }
         mEventData->mDecoratorUpdated = true;
+        HideClipboard();
         break;
       }
       case EventData::SELECTION_HANDLE_PANNING:
@@ -2439,6 +2444,7 @@ void Controller::Impl::ChangeState( EventData::State newState )
           SetPopupButtons();
           mEventData->mDecorator->SetPopupActive( true );
         }
+        HideClipboard();
         mEventData->mDecoratorUpdated = true;
         break;
       }
index 9b17fa7..af3c7c6 100644 (file)
@@ -477,12 +477,6 @@ struct Controller::Impl
     return !result; // If NumberOfItems greater than 0, return false
   }
 
-  bool IsClipboardVisible()
-  {
-    bool result( mClipboard && mClipboard.IsVisible() );
-    return result;
-  }
-
   /**
    * @brief Calculates the start character index of the first paragraph to be updated and
    * the end character index of the last paragraph to be updated.
@@ -590,7 +584,7 @@ struct Controller::Impl
 
   void SendSelectionToClipboard( bool deleteAfterSending );
 
-  void RequestGetTextFromClipboard();
+  void GetTextFromClipboard( unsigned int itemIndex, std::string& retrievedString );
 
   void RepositionSelectionHandles();
   void RepositionSelectionHandles( float visualX, float visualY );
index e10556c..07eb23b 100644 (file)
@@ -2418,27 +2418,31 @@ void Controller::TapEvent( unsigned int tapCount, float x, float y )
   if( NULL != mImpl->mEventData )
   {
     DALI_LOG_INFO( gLogFilter, Debug::Concise, "TapEvent state:%d \n", mImpl->mEventData->mState );
-    EventData::State state( mImpl->mEventData->mState );
-    bool relayoutNeeded( false );   // to avoid unnecessary relayouts when tapping an empty text-field
 
-    if( mImpl->IsClipboardVisible() )
+    if( 1u == tapCount )
     {
-      if( EventData::INACTIVE == state || EventData::EDITING == state)
-      {
-        mImpl->ChangeState( EventData::EDITING_WITH_GRAB_HANDLE );
-      }
-      relayoutNeeded = true;
-    }
-    else if( 1u == tapCount )
-    {
-      if( EventData::EDITING_WITH_POPUP == state || EventData::EDITING_WITH_PASTE_POPUP == state )
+      // This is to avoid unnecessary relayouts when tapping an empty text-field
+      bool relayoutNeeded( false );
+
+      if( ( EventData::EDITING_WITH_POPUP == mImpl->mEventData->mState ) ||
+          ( EventData::EDITING_WITH_PASTE_POPUP == mImpl->mEventData->mState ) )
       {
         mImpl->ChangeState( EventData::EDITING_WITH_GRAB_HANDLE );  // If Popup shown hide it here so can be shown again if required.
       }
 
-      if( mImpl->IsShowingRealText() && ( EventData::INACTIVE != state ) )
+      if( mImpl->IsShowingRealText() && ( EventData::INACTIVE != mImpl->mEventData->mState ) )
       {
-        mImpl->ChangeState( EventData::EDITING_WITH_GRAB_HANDLE );
+        // Already in an active state so show a popup
+        if( !mImpl->IsClipboardEmpty() )
+        {
+          // Shows Paste popup but could show full popup with Selection options. ( EDITING_WITH_POPUP )
+          mImpl->ChangeState( EventData::EDITING_WITH_PASTE_POPUP );
+        }
+        else
+        {
+          // Show cursor and grabhandle on first tap, this matches the behaviour of tapping when already editing
+          mImpl->ChangeState( EventData::EDITING_WITH_GRAB_HANDLE );
+        }
         relayoutNeeded = true;
       }
       else
@@ -2449,7 +2453,7 @@ void Controller::TapEvent( unsigned int tapCount, float x, float y )
           ResetText();
         }
 
-        if( EventData::INACTIVE == state )
+        if( EventData::INACTIVE == mImpl->mEventData->mState )
         {
           mImpl->ChangeState( EventData::EDITING );
         }
@@ -2459,6 +2463,18 @@ void Controller::TapEvent( unsigned int tapCount, float x, float y )
         }
         relayoutNeeded = true;
       }
+
+      // Handles & cursors must be repositioned after Relayout() i.e. after the Model has been updated
+      if( relayoutNeeded )
+      {
+        Event event( Event::TAP_EVENT );
+        event.p1.mUint = tapCount;
+        event.p2.mFloat = x;
+        event.p3.mFloat = y;
+        mImpl->mEventData->mEventQueue.push_back( event );
+
+        mImpl->RequestRelayout();
+      }
     }
     else if( 2u == tapCount )
     {
@@ -2468,17 +2484,6 @@ void Controller::TapEvent( unsigned int tapCount, float x, float y )
         SelectEvent( x, y, false );
       }
     }
-    // Handles & cursors must be repositioned after Relayout() i.e. after the Model has been updated
-    if( relayoutNeeded )
-    {
-      Event event( Event::TAP_EVENT );
-      event.p1.mUint = tapCount;
-      event.p2.mFloat = x;
-      event.p3.mFloat = y;
-      mImpl->mEventData->mEventQueue.push_back( event );
-
-      mImpl->RequestRelayout();
-    }
   }
 
   // Reset keyboard as tap event has occurred.
@@ -2530,7 +2535,7 @@ void Controller::LongPressEvent( Gesture::State state, float x, float y  )
 
         mImpl->RequestRelayout();
       }
-      else if( !mImpl->IsClipboardVisible() )
+      else
       {
         // Reset the imf manger to commit the pre-edit before selecting the text.
         mImpl->ResetImfManager();
@@ -2698,7 +2703,9 @@ void Controller::TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::Butt
     }
     case Toolkit::TextSelectionPopup::PASTE:
     {
-      mImpl->RequestGetTextFromClipboard(); // Request clipboard service to retrieve an item
+      std::string stringToPaste("");
+      mImpl->GetTextFromClipboard( 0, stringToPaste ); // Paste latest item from system clipboard
+      PasteText( stringToPaste );
       break;
     }
     case Toolkit::TextSelectionPopup::SELECT: