From: Agnelo Vaz Date: Fri, 19 Jun 2015 10:28:24 +0000 (+0100) Subject: TextSelectionPopup to show Paste in data in Clipboard X-Git-Tag: dali_1.0.46~14^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=771ece63d9ad24a6835cbe46c8137db2ced47356 TextSelectionPopup to show Paste in data in Clipboard Requires Adaptor fix "Fix Clipboard to return 0 when has no items" Change-Id: I37213b3cc024d434d164136c509c2c9d6c7d0ccb Signed-off-by: Agnelo Vaz --- diff --git a/dali-toolkit/internal/text/text-controller-impl.cpp b/dali-toolkit/internal/text/text-controller-impl.cpp index 24e38c2..621d50e 100644 --- a/dali-toolkit/internal/text/text-controller-impl.cpp +++ b/dali-toolkit/internal/text/text-controller-impl.cpp @@ -847,8 +847,13 @@ void Controller::Impl::ChangeState( EventData::State newState ) mEventData->mDecorator->SetHandleActive( RIGHT_SELECTION_HANDLE, true ); if( mEventData->mGrabHandlePopupEnabled ) { - TextSelectionPopup::Buttons selectedButtons = TextSelectionPopup::Buttons( TextSelectionPopup::CUT | TextSelectionPopup::COPY ); - mEventData->mDecorator->SetEnabledPopupButtons( selectedButtons ); + TextSelectionPopup::Buttons buttonsToShow = TextSelectionPopup::Buttons( TextSelectionPopup::CUT | TextSelectionPopup::COPY ); + if ( !IsClipboardEmpty() ) + { + buttonsToShow = TextSelectionPopup::Buttons ( ( buttonsToShow | TextSelectionPopup::PASTE ) ); + } + + mEventData->mDecorator->SetEnabledPopupButtons( buttonsToShow ); mEventData->mDecorator->SetPopupActive( true ); } mEventData->mDecoratorUpdated = true; @@ -857,8 +862,12 @@ void Controller::Impl::ChangeState( EventData::State newState ) { if( mEventData->mGrabHandlePopupEnabled ) { - TextSelectionPopup::Buttons selectedButtons = TextSelectionPopup::Buttons( TextSelectionPopup::CUT | TextSelectionPopup::COPY ); - mEventData->mDecorator->SetEnabledPopupButtons( selectedButtons ); + TextSelectionPopup::Buttons buttonsToShow = TextSelectionPopup::Buttons( TextSelectionPopup::CUT | TextSelectionPopup::COPY ); + if ( !IsClipboardEmpty() ) + { + buttonsToShow = TextSelectionPopup::Buttons ( ( buttonsToShow | TextSelectionPopup::PASTE ) ); + } + mEventData->mDecorator->SetEnabledPopupButtons( buttonsToShow ); mEventData->mDecorator->SetPopupActive( true ); } mEventData->mDecoratorUpdated = true; @@ -898,8 +907,14 @@ void Controller::Impl::ChangeState( EventData::State newState ) } if( mEventData->mGrabHandlePopupEnabled ) { - TextSelectionPopup::Buttons selectionButtons = TextSelectionPopup::Buttons( TextSelectionPopup::SELECT | TextSelectionPopup::SELECT_ALL ); - mEventData->mDecorator->SetEnabledPopupButtons( selectionButtons ); + TextSelectionPopup::Buttons buttonsToShow = TextSelectionPopup::Buttons( TextSelectionPopup::SELECT | TextSelectionPopup::SELECT_ALL ); + + if ( !IsClipboardEmpty() ) + { + buttonsToShow = TextSelectionPopup::Buttons ( ( buttonsToShow | TextSelectionPopup::PASTE ) ); + } + + mEventData->mDecorator->SetEnabledPopupButtons( buttonsToShow ); mEventData->mDecorator->SetPopupActive( true ); } mEventData->mDecoratorUpdated = true; diff --git a/dali-toolkit/internal/text/text-controller-impl.h b/dali-toolkit/internal/text/text-controller-impl.h index 326770d..422bcdc 100644 --- a/dali-toolkit/internal/text/text-controller-impl.h +++ b/dali-toolkit/internal/text/text-controller-impl.h @@ -19,8 +19,9 @@ */ // EXTERNAL INCLUDES -#include +#include #include +#include // INTERNAL INCLUDES #include @@ -198,6 +199,7 @@ struct Controller::Impl mFontDefaults( NULL ), mEventData( NULL ), mFontClient(), + mClipboard(), mView(), mLayoutEngine(), mModifyEvents(), @@ -212,6 +214,7 @@ struct Controller::Impl mVisualModel = VisualModel::New(); mFontClient = TextAbstraction::FontClient::Get(); + mClipboard = Clipboard::Get(); mView.SetVisualModel( mVisualModel ); @@ -306,6 +309,12 @@ struct Controller::Impl ClearPreEditFlag(); } + bool IsClipboardEmpty() + { + bool result( mClipboard && mClipboard.NumberOfItems() ); + return !result; // // If NumberOfItems greater than 0, return false + } + void UpdateModel( OperationsMask operationsRequired ); /** @@ -423,6 +432,7 @@ struct Controller::Impl FontDefaults* mFontDefaults; ///< Avoid allocating this when the user does not specify a font. EventData* mEventData; ///< Avoid allocating everything for text input until EnableTextInput(). TextAbstraction::FontClient mFontClient; ///< Handle to the font client. + Clipboard mClipboard; ///< Handle to the system clipboard View mView; ///< The view interface to the rendering back-end. LayoutEngine mLayoutEngine; ///< The layout engine. std::vector mModifyEvents; ///< Temporary stores the text set until the next relayout.