DALI_TEST_CHECK( !textSelectionPopup );
- textSelectionPopup = TextSelectionPopup::New( TextSelectionPopup::COPY );
+ textSelectionPopup = TextSelectionPopup::New( TextSelectionPopup::COPY, NULL );
DALI_TEST_CHECK( textSelectionPopup );
END_TEST;
ToolkitTestApplication application;
TextSelectionPopup textSelectionPopup;
- textSelectionPopup = TextSelectionPopup::New( TextSelectionPopup::COPY );
+ textSelectionPopup = TextSelectionPopup::New( TextSelectionPopup::COPY, NULL );
TextSelectionPopup copy( textSelectionPopup );
DALI_TEST_CHECK( copy == textSelectionPopup );
{
ToolkitTestApplication application;
TextSelectionPopup textSelectionPopup;
- textSelectionPopup = TextSelectionPopup::New( TextSelectionPopup::COPY );
+ textSelectionPopup = TextSelectionPopup::New( TextSelectionPopup::COPY, NULL );
TextSelectionPopup copy;
copy = textSelectionPopup;
{
ToolkitTestApplication application;
TextSelectionPopup textSelectionPopup;
- textSelectionPopup = TextSelectionPopup::New( TextSelectionPopup::COPY );
+ textSelectionPopup = TextSelectionPopup::New( TextSelectionPopup::COPY, NULL );
TextSelectionPopup cast = TextSelectionPopup::DownCast( textSelectionPopup );
--- /dev/null
+#ifndef __DALI_TOOLKIT_TEXT_SELECTION_POPUP_CALLBACK_INTERFACE_H__
+#define __DALI_TOOLKIT_TEXT_SELECTION_POPUP_CALLBACK_INTERFACE_H__
+
+/*
+ * Copyright (c) 2015 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/controls/text-controls/text-selection-popup.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+/**
+ * @brief Interface used to receive the TextSelectionPopup's button callbacks.
+ */
+class TextSelectionPopupCallbackInterface
+{
+public:
+ /**
+ * @brief Virtual destructor.
+ */
+ virtual ~TextSelectionPopupCallbackInterface()
+ {}
+
+ /**
+ * @brief Called when a button is touched.
+ *
+ * @param[in] button The button identifier.
+ */
+ virtual void TextPopupButtonTouched( TextSelectionPopup::Buttons button ) = 0;
+};
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+
+#endif // __DALI_TOOLKIT_TEXT_SELECTION_POPUP_CALLBACK_INTERFACE_H__
namespace Toolkit
{
-TextSelectionPopup TextSelectionPopup::New( Buttons enabledButtons )
+TextSelectionPopup TextSelectionPopup::New( Buttons enabledButtons,
+ TextSelectionPopupCallbackInterface* callbackInterface )
{
- return Internal::TextSelectionPopup::New( enabledButtons );
+ return Internal::TextSelectionPopup::New( enabledButtons,
+ callbackInterface );
}
TextSelectionPopup::TextSelectionPopup()
namespace Toolkit
{
+class TextSelectionPopupCallbackInterface;
+
namespace Internal DALI_INTERNAL
{
class TextSelectionPopup;
/**
* Create the TextSelectionPopup control with the given set of buttons.
* @param[in] enabledButtons The given set of buttons to enable
+ * @param[in] callbackInterface The text popup callback interface which receives the button click callbacks.
* @return A handle to the TextSelectionPopup control.
*/
- static TextSelectionPopup New( Buttons enabledButtons );
+ static TextSelectionPopup New( Buttons enabledButtons,
+ TextSelectionPopupCallbackInterface* callbackInterface );
/**
* @brief Creates an empty handle.
mController = Text::Controller::New( *this );
- mDecorator = Text::Decorator::New( *mController );
+ mDecorator = Text::Decorator::New( *mController,
+ *mController );
mController->GetLayoutEngine().SetLayout( LayoutEngine::SINGLE_LINE_BOX );
#include <dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.h>
// INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/controls/text-controls/text-selection-popup-callback-interface.h>
#include <dali-toolkit/public-api/controls/default-controls/solid-color-actor.h>
#include <dali-toolkit/public-api/controls/text-controls/text-label.h>
BaseHandle Create()
{
- return Toolkit::TextSelectionPopup::New( Toolkit::TextSelectionPopup::NONE );
+ return Toolkit::TextSelectionPopup::New( Toolkit::TextSelectionPopup::NONE, NULL );
}
// Setup properties, signals and actions using the type-registry.
} // namespace
-Dali::Toolkit::TextSelectionPopup TextSelectionPopup::New( Toolkit::TextSelectionPopup::Buttons buttonsToEnable )
+Dali::Toolkit::TextSelectionPopup TextSelectionPopup::New( Toolkit::TextSelectionPopup::Buttons buttonsToEnable,
+ TextSelectionPopupCallbackInterface* callbackInterface )
{
// Create the implementation, temporarily owned by this handle on stack
- IntrusivePtr< TextSelectionPopup > impl = new TextSelectionPopup();
+ IntrusivePtr< TextSelectionPopup > impl = new TextSelectionPopup( callbackInterface );
// Pass ownership to CustomActor handle
Dali::Toolkit::TextSelectionPopup handle( *impl );
return handle;
}
+
void TextSelectionPopup::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
{
Toolkit::TextSelectionPopup selectionPopup = Toolkit::TextSelectionPopup::DownCast( Dali::BaseHandle( object ) );
CreatePopup();
}
-bool TextSelectionPopup::OnButtonPressed( Toolkit::Button button )
+bool TextSelectionPopup::OnCutButtonPressed( Toolkit::Button button )
{
+ if( mCallbackInterface )
+ {
+ mCallbackInterface->TextPopupButtonTouched( Toolkit::TextSelectionPopup::CUT );
+ }
+
+ return true;
+}
+
+bool TextSelectionPopup::OnCopyButtonPressed( Toolkit::Button button )
+{
+ if( mCallbackInterface )
+ {
+ mCallbackInterface->TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::COPY );
+ }
+
+ return true;
+}
+
+bool TextSelectionPopup::OnPasteButtonPressed( Toolkit::Button button )
+{
+ if( mCallbackInterface )
+ {
+ mCallbackInterface->TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::PASTE );
+ }
+
+ return true;
+}
+
+bool TextSelectionPopup::OnSelectButtonPressed( Toolkit::Button button )
+{
+ if( mCallbackInterface )
+ {
+ mCallbackInterface->TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::SELECT );
+ }
+
+ return true;
+}
+
+bool TextSelectionPopup::OnSelectAllButtonPressed( Toolkit::Button button )
+{
+ if( mCallbackInterface )
+ {
+ mCallbackInterface->TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::SELECT_ALL );
+ }
+
+ return true;
+}
+
+bool TextSelectionPopup::OnClipboardButtonPressed( Toolkit::Button button )
+{
+ if( mCallbackInterface )
+ {
+ mCallbackInterface->TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::CLIPBOARD );
+ }
+
return true;
}
std::sort( mOrderListOfButtons.begin(), mOrderListOfButtons.end(), TextSelectionPopup::ButtonPriorityCompare() );
}
- void TextSelectionPopup::AddOption( const std::string& name, const std::string& caption, const Image iconImage, bool showDivider, bool showIcons, bool showCaption )
+ void TextSelectionPopup::AddOption( const ButtonRequirement& button, bool showDivider, bool showIcons, bool showCaption )
{
+
+ const std::string& name = button.name;
+ const std::string& caption = button.caption;
+ Image iconImage = button.icon;
+
// 1. Create the backgrounds for the popup option both normal and pressed.
// Both containers will be added to a button.
option.SetName( name );
option.SetAnimationTime( 0.0f );
option.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS );
- option.ClickedSignal().Connect( this, &TextSelectionPopup::OnButtonPressed );
+
+ switch( button.id )
+ {
+ case Toolkit::TextSelectionPopup::CUT:
+ {
+ option.ClickedSignal().Connect( this, &TextSelectionPopup::OnCutButtonPressed );
+ break;
+ }
+ case Toolkit::TextSelectionPopup::COPY:
+ {
+ option.ClickedSignal().Connect( this, &TextSelectionPopup::OnCopyButtonPressed );
+ break;
+ }
+ case Toolkit::TextSelectionPopup::PASTE:
+ {
+ option.ClickedSignal().Connect( this, &TextSelectionPopup::OnPasteButtonPressed );
+ break;
+ }
+ case Toolkit::TextSelectionPopup::SELECT:
+ {
+ option.ClickedSignal().Connect( this, &TextSelectionPopup::OnSelectButtonPressed );
+ break;
+ }
+ case Toolkit::TextSelectionPopup::SELECT_ALL:
+ {
+ option.ClickedSignal().Connect( this, &TextSelectionPopup::OnSelectAllButtonPressed );
+ break;
+ }
+ case Toolkit::TextSelectionPopup::CLIPBOARD:
+ {
+ option.ClickedSignal().Connect( this, &TextSelectionPopup::OnClipboardButtonPressed );
+ break;
+ }
+ case Toolkit::TextSelectionPopup::NONE:
+ {
+ // Nothing to do:
+ break;
+ }
+ }
// 5. Set the normal option image.
option.SetButtonImage( optionContainer );
if ( button.enabled )
{
numberOfOptionsAdded++;
- AddOption( button.name, button.caption, button.icon, ( numberOfOptionsAdded < numberOfOptionsRequired ) , showIcons, showCaptions );
+ AddOption( button, ( numberOfOptionsAdded < numberOfOptionsRequired ) , showIcons, showCaptions );
}
}
}
}
}
-TextSelectionPopup::TextSelectionPopup()
+TextSelectionPopup::TextSelectionPopup( TextSelectionPopupCallbackInterface* callbackInterface )
: Control( ControlBehaviour( REQUIRES_STYLE_CHANGE_SIGNALS ) ),
mToolbar(),
mMaxSize(),
mMinSize(),
mOptionDividerSize( Size( 2.0f, 0.0f) ),
mEnabledButtons( Toolkit::TextSelectionPopup::NONE ),
+ mCallbackInterface( callbackInterface ),
mLineColor( DEFAULT_POPUP_LINE_COLOR ),
mIconColor( DEFAULT_OPTION_ICON ),
mPressedColor( DEFAULT_OPTION_ICON_PRESSED ),
/**
* @brief New constructor with provided buttons to enable.
* @param[in] buttonsToEnable bit mask of buttons to enable
+ * @param[in] callbackInterface The text popup callback interface which receives the button click callbacks.
* @return A handle to the TextSelectionPopup control.
*/
- static Toolkit::TextSelectionPopup New( Toolkit::TextSelectionPopup::Buttons buttonsToEnable );
+ static Toolkit::TextSelectionPopup New( Toolkit::TextSelectionPopup::Buttons buttonsToEnable,
+ TextSelectionPopupCallbackInterface* callbackInterface );
// Properties
private: // Implementation
/**
- * @brief When a popup button is pressed
+ * @brief When the cut button is pressed.
* @param[in] button the button pressed
- * @return bool
+ * @return @e true to consume the event.
*/
- bool OnButtonPressed( Toolkit::Button button );
+ bool OnCutButtonPressed( Toolkit::Button button );
+
+ /**
+ * @brief When the copy button is pressed.
+ * @param[in] button the button pressed
+ * @return @e true to consume the event.
+ */
+ bool OnCopyButtonPressed( Toolkit::Button button );
+
+ /**
+ * @brief When the paste button is pressed.
+ * @param[in] button the button pressed
+ * @return @e true to consume the event.
+ */
+ bool OnPasteButtonPressed( Toolkit::Button button );
+
+ /**
+ * @brief When the select button is pressed.
+ * @param[in] button the button pressed
+ * @return @e true to consume the event.
+ */
+ bool OnSelectButtonPressed( Toolkit::Button button );
+
+ /**
+ * @brief When the select all button is pressed.
+ * @param[in] button the button pressed
+ * @return @e true to consume the event.
+ */
+ bool OnSelectAllButtonPressed( Toolkit::Button button );
+
+ /**
+ * @brief When the clipboard button is pressed.
+ * @param[in] button the button pressed
+ * @return @e true to consume the event.
+ */
+ bool OnClipboardButtonPressed( Toolkit::Button button );
/**
* @brief Method to set the dimension or dimension constraint on certain aspects of the Popup.
void CreateOrderedListOfPopupOptions();
- void AddOption( const std::string& name, const std::string& caption, const Image iconImage, bool showDivider, bool showIcons, bool showCaption );
+ void AddOption( const ButtonRequirement& button, bool showDivider, bool showIcons, bool showCaption );
std::size_t GetNumberOfEnabledOptions();
/**
* Construct a new TextField.
*/
- TextSelectionPopup();
+ TextSelectionPopup( TextSelectionPopupCallbackInterface* callbackInterface );
/**
* A reference counted object may only be deleted by calling Unreference()
std::vector<ButtonRequirement> mOrderListOfButtons; // List of buttons in the order to be displayed and a flag to indicate if needed.
Toolkit::TextSelectionPopup::Buttons mEnabledButtons; // stores enabled buttons
+ Toolkit::TextSelectionPopupCallbackInterface* mCallbackInterface;
Vector4 mLineColor; // Color of the line around the text input popup
Vector4 mIconColor; // Color of the popup icon.
int offset;
};
- Impl( ControllerInterface& controller )
+ Impl( ControllerInterface& controller,
+ TextSelectionPopupCallbackInterface& callbackInterface )
: mController( controller ),
mEnabledPopupButtons( TextSelectionPopup::NONE ),
+ mTextSelectionPopupCallbackInterface( callbackInterface ),
mBoundingBox( Rect<int>() ),
mHighlightColor( LIGHT_BLUE ),
mActiveCursor( ACTIVE_CURSOR_NONE ),
UnparentAndReset( mCopyPastePopup.actor );
if ( !mCopyPastePopup.actor )
{
- mCopyPastePopup.actor = TextSelectionPopup::New( mEnabledPopupButtons );
+ mCopyPastePopup.actor = TextSelectionPopup::New( mEnabledPopupButtons, &mTextSelectionPopupCallbackInterface );
#ifdef DECORATOR_DEBUG
mCopyPastePopup.actor.SetName("mCopyPastePopup");
#endif
PopupImpl mCopyPastePopup;
TextSelectionPopup::Buttons mEnabledPopupButtons; /// Bit mask of currently enabled Popup buttons
+ TextSelectionPopupCallbackInterface& mTextSelectionPopupCallbackInterface;
Image mHandleImages[HANDLE_TYPE_COUNT][HANDLE_IMAGE_TYPE_COUNT];
Image mCursorImage;
bool mSwapSelectionHandles : 1; ///< Whether to swap the selection handle images.
};
-DecoratorPtr Decorator::New( ControllerInterface& controller )
+DecoratorPtr Decorator::New( ControllerInterface& controller,
+ TextSelectionPopupCallbackInterface& callbackInterface )
{
- return DecoratorPtr( new Decorator(controller) );
+ return DecoratorPtr( new Decorator( controller,
+ callbackInterface ) );
}
void Decorator::SetBoundingBox( const Rect<int>& boundingBox )
delete mImpl;
}
-Decorator::Decorator( ControllerInterface& controller )
+Decorator::Decorator( ControllerInterface& controller,
+ TextSelectionPopupCallbackInterface& callbackInterface )
: mImpl( NULL )
{
- mImpl = new Decorator::Impl( controller );
+ mImpl = new Decorator::Impl( controller, callbackInterface );
}
} // namespace Text
namespace Toolkit
{
+class TextSelectionPopupCallbackInterface;
+
namespace Internal
{
class Control;
* @brief Create a new instance of a Decorator.
*
* @param[in] controller The controller which receives input events from Decorator components.
+ * @param[in] callbackInterface The text popup callback interface which receives the button click callbacks.
+ *
* @return A pointer to a new Decorator.
*/
- static DecoratorPtr New( ControllerInterface& controller );
+ static DecoratorPtr New( ControllerInterface& controller,
+ TextSelectionPopupCallbackInterface& callbackInterface );
/**
* @brief Set the bounding box which handles, popup and similar decorations will not exceed.
/**
* @brief Private constructor.
* @param[in] controller The controller which receives input events from Decorator components.
+ * @param[in] callbackInterface The text popup callback interface which receives the button click callbacks.
*/
- Decorator( ControllerInterface& controller );
+ Decorator( ControllerInterface& controller,
+ TextSelectionPopupCallbackInterface& callbackInterface );
// Undefined
Decorator( const Decorator& handle );
}
}
+void Controller::TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::Buttons button )
+{
+}
+
ImfManager::ImfCallbackData Controller::OnImfEvent( ImfManager& imfManager, const ImfManager::ImfEventData& imfEvent )
{
bool update( false );
#include <dali/public-api/object/ref-object.h>
// INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/controls/text-controls/text-selection-popup-callback-interface.h>
#include <dali-toolkit/internal/text/decorator/text-decorator.h>
#include <dali-toolkit/internal/text/font-run.h>
#include <dali-toolkit/internal/text/layouts/layout-engine.h>
* It provides a view of the text that can be used by rendering back-ends.
*
* For selectable/editable UI controls, the controller handles input events from the UI control
- * and decorations (grab handles etc) via an interface.
+ * and decorations (grab handles etc) via the Decorator::ControllerInterface interface.
+ *
+ * The text selection popup button callbacks are as well handled via the TextSelectionPopupCallbackInterface interface.
*/
-class Controller : public RefObject, public Decorator::ControllerInterface
+class Controller : public RefObject, public Decorator::ControllerInterface, public TextSelectionPopupCallbackInterface
{
public:
*/
virtual void DecorationEvent( HandleType handle, HandleState state, float x, float y );
+ /**
+ * @copydoc Dali::Toolkit::TextSelectionPopup::TextPopupButtonCallbackInterface::TextPopupButtonTouched()
+ */
+ virtual void TextPopupButtonTouched( Dali::Toolkit::TextSelectionPopup::Buttons button );
+
protected:
/**