mController = Text::Controller::New( *this );
- mDecorator = Text::Decorator::New( *this, *mController );
+ mDecorator = Text::Decorator::New( *mController );
mController->GetLayoutEngine().SetLayout( LayoutEngine::SINGLE_LINE_BOX );
return mController->KeyEvent( event );
}
-ImfManager::ImfCallbackData TextField::OnImfEvent( Dali::ImfManager& imfManager, const ImfManager::ImfEventData& imfEvent )
+void TextField::AddDecoration( Actor& actor )
{
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnImfEvent %p eventName %d\n", mController.Get(), imfEvent.eventName );
- return mController->OnImfEvent( imfManager, imfEvent );
+ if( actor )
+ {
+ Self().Add( actor );
+ }
}
void TextField::RequestTextRelayout()
mMaxLengthReachedSignal.Emit( handle );
}
+ImfManager::ImfCallbackData TextField::OnImfEvent( Dali::ImfManager& imfManager, const ImfManager::ImfEventData& imfEvent )
+{
+ DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnImfEvent %p eventName %d\n", mController.Get(), imfEvent.eventName );
+ return mController->OnImfEvent( imfManager, imfEvent );
+}
+
void TextField::EnableClipping( bool clipping, const Vector2& size )
{
if( clipping )
virtual bool OnKeyEvent(const KeyEvent& event);
/**
- * @copydoc Dali::Toolkit::Text::Controller::(ImfManager& imfManager, const ImfManager::ImfEventData& imfEvent)
+ * @copydoc Text::ControlInterface::AddDecoration()
*/
- ImfManager::ImfCallbackData OnImfEvent( ImfManager& imfManager, const ImfManager::ImfEventData& imfEvent );
+ virtual void AddDecoration( Actor& actor );
/**
* @copydoc Text::ControlInterface::RequestTextRelayout()
*/
virtual void MaxLengthReached();
+ /**
+ * @copydoc Dali::Toolkit::Text::Controller::(ImfManager& imfManager, const ImfManager::ImfEventData& imfEvent)
+ */
+ ImfManager::ImfCallbackData OnImfEvent( ImfManager& imfManager, const ImfManager::ImfEventData& imfEvent );
+
private: // Implementation
/**
}
}
+void TextLabel::AddDecoration( Actor& actor )
+{
+ // TextLabel does not show decorations
+}
+
void TextLabel::RequestTextRelayout()
{
RelayoutRequest();
virtual float GetHeightForWidth( float width );
/**
+ * @copydoc Text::ControlInterface::AddDecoration()
+ */
+ virtual void AddDecoration( Actor& actor );
+
+ /**
* @copydoc Text::ControlInterface::RequestTextRelayout()
*/
virtual void RequestTextRelayout();
bool flipped : 1;
};
- Impl( Dali::Toolkit::Internal::Control& parent, Observer& observer )
- : mTextControlParent( parent ),
- mObserver( observer ),
+ Impl( ControllerInterface& controller )
+ : mController( controller ),
mBoundingBox( Rect<int>() ),
mHighlightColor( LIGHT_BLUE ),
mActiveCursor( ACTIVE_CURSOR_NONE ),
{
if( !mActiveLayer )
{
- Actor parent = mTextControlParent.Self();
-
mActiveLayer = Layer::New();
#ifdef DECORATOR_DEBUG
mActiveLayer.SetName ( "ActiveLayerActor" );
mActiveLayer.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
mActiveLayer.SetPositionInheritanceMode( USE_PARENT_POSITION );
- parent.Add( mActiveLayer );
+ mController.AddDecoration( mActiveLayer );
}
mActiveLayer.RaiseToTop();
mHighlightMeshActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
mHighlightMeshActor.SetPosition( 0.0f, 0.0f, DISPLAYED_HIGHLIGHT_Z_OFFSET );
- Actor parent = mTextControlParent.Self();
- parent.Add( mHighlightMeshActor );
+ mController.AddDecoration( mHighlightMeshActor );
}
}
if( Gesture::Started == gesture.state ||
Gesture::Continuing == gesture.state )
{
+ Vector2 targetSize;
+ mController.GetTargetSize( targetSize );
+
if( x < mScrollThreshold )
{
mScrollDirection = SCROLL_RIGHT;
mHandleScrolling = type;
StartScrollTimer();
}
- else if( x > mTextControlParent.Self().GetTargetSize().width - mScrollThreshold )
+ else if( x > targetSize.width - mScrollThreshold )
{
mScrollDirection = SCROLL_LEFT;
mHandleScrolling = type;
{
mHandleScrolling = HANDLE_TYPE_COUNT;
StopScrollTimer();
- mObserver.HandleEvent( type, HANDLE_PRESSED, x, y );
+ mController.DecorationEvent( type, HANDLE_PRESSED, x, y );
}
}
else if( Gesture::Finished == gesture.state ||
{
mHandleScrolling = HANDLE_TYPE_COUNT;
StopScrollTimer();
- mObserver.HandleEvent( type, HANDLE_STOP_SCROLLING, x, y );
+ mController.DecorationEvent( type, HANDLE_STOP_SCROLLING, x, y );
}
else
{
- mObserver.HandleEvent( type, HANDLE_RELEASED, x, y );
+ mController.DecorationEvent( type, HANDLE_RELEASED, x, y );
}
handle.actor.SetImage( mHandleImages[type][HANDLE_IMAGE_RELEASED] );
}
{
if( HANDLE_TYPE_COUNT != mHandleScrolling )
{
- mObserver.HandleEvent( mHandleScrolling,
- HANDLE_SCROLLING,
- mScrollDirection == SCROLL_RIGHT ? mScrollDistance : -mScrollDistance,
- 0.f );
+ mController.DecorationEvent( mHandleScrolling,
+ HANDLE_SCROLLING,
+ mScrollDirection == SCROLL_RIGHT ? mScrollDistance : -mScrollDistance,
+ 0.f );
}
return true;
}
- Internal::Control& mTextControlParent;
- Observer& mObserver;
+ ControllerInterface& mController;
TapGestureDetector mTapDetector;
PanGestureDetector mPanGestureDetector;
bool mSecondaryCursorVisible : 1; ///< Whether the secondary cursor is visible.
};
-DecoratorPtr Decorator::New( Internal::Control& parent, Observer& observer )
+DecoratorPtr Decorator::New( ControllerInterface& controller )
{
- return DecoratorPtr( new Decorator(parent, observer) );
+ return DecoratorPtr( new Decorator(controller) );
}
void Decorator::SetBoundingBox( const Rect<int>& boundingBox )
delete mImpl;
}
-Decorator::Decorator( Dali::Toolkit::Internal::Control& parent, Observer& observer )
+Decorator::Decorator( ControllerInterface& controller )
: mImpl( NULL )
{
- mImpl = new Decorator::Impl( parent, observer );
+ mImpl = new Decorator::Impl( controller );
}
} // namespace Text
namespace Dali
{
+class Actor;
class Image;
class Vector2;
class Vector4;
*
* Selection handles will be flipped around to ensure they do not exceed the Decoration Bounding Box. ( Stay visible ).
*
- * Decorator components forward input events to a controller class through an observer interface.
+ * Decorator components forward input events to a controller class through an interface.
* The controller is responsible for selecting which components are active.
*/
class Decorator : public RefObject
{
public:
- class Observer
+ class ControllerInterface
{
public:
/**
* @brief Constructor.
*/
- Observer() {};
+ ControllerInterface() {};
/**
* @brief Virtual destructor.
*/
- virtual ~Observer() {};
+ virtual ~ControllerInterface() {};
+
+ /**
+ * @brief An input event from one of the handles.
+ *
+ * @param[out] targetSize The Size of the UI control the decorator is adding it's decorations to.
+ */
+ virtual void GetTargetSize( Vector2& targetSize ) = 0;
+
+ /**
+ * @brief Add a decoration to the parent UI control.
+ *
+ * @param[in] decoration The actor displaying a decoration.
+ */
+ virtual void AddDecoration( Actor& actor ) = 0;
/**
* @brief An input event from one of the handles.
* @param[in] x The x position relative to the top-left of the parent control.
* @param[in] y The y position relative to the top-left of the parent control.
*/
- virtual void HandleEvent( HandleType handleType, HandleState state, float x, float y ) = 0;
+ virtual void DecorationEvent( HandleType handleType, HandleState state, float x, float y ) = 0;
};
/**
* @brief Create a new instance of a Decorator.
*
- * @param[in] parent Decorations will be added to this parent control.
- * @param[in] observer A class which receives input events from Decorator components.
+ * @param[in] controller The controller which receives input events from Decorator components.
* @return A pointer to a new Decorator.
*/
- static DecoratorPtr New( Dali::Toolkit::Internal::Control& parent, Observer& observer );
+ static DecoratorPtr New( ControllerInterface& controller );
/**
* @brief Set the bounding box which handles, popup and similar decorations will not exceed.
/**
* @brief Private constructor.
- * @param[in] parent Decorations will be added to this parent control.
- * @param[in] observer A class which receives input events from Decorator components.
+ * @param[in] controller The controller which receives input events from Decorator components.
*/
- Decorator(Dali::Toolkit::Internal::Control& parent, Observer& observer );
+ Decorator( ControllerInterface& controller );
// Undefined
Decorator( const Decorator& handle );
namespace Dali
{
+class Actor;
+
namespace Toolkit
{
virtual ~ControlInterface();
/**
+ * @brief Add a decoration.
+ *
+ * @param[in] decoration The actor displaying a decoration.
+ */
+ virtual void AddDecoration( Actor& actor ) = 0;
+
+ /**
* @brief Called to request a text relayout.
*/
virtual void RequestTextRelayout() = 0;
}
}
-void Controller::HandleEvent( HandleType handleType, HandleState state, float x, float y )
+void Controller::GetTargetSize( Vector2& targetSize )
{
- DALI_ASSERT_DEBUG( mImpl->mEventData && "Controller::HandleEvent. Unexpected HandleEvent" );
+ targetSize = mImpl->mControlSize;
+}
+
+void Controller::AddDecoration( Actor& actor )
+{
+ mImpl->mControlInterface.AddDecoration( actor );
+}
+
+void Controller::DecorationEvent( HandleType handleType, HandleState state, float x, float y )
+{
+ DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected DecorationEvent" );
if( mImpl->mEventData )
{
* 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 observer interface.
+ * and decorations (grab handles etc) via an interface.
*/
-class Controller : public RefObject, public Decorator::Observer
+class Controller : public RefObject, public Decorator::ControllerInterface
{
public:
void PanEvent( Gesture::State state, const Vector2& displacement );
/**
- * @copydoc Dali::Toolkit::Text::Decorator::Observer::HandleEvent()
- */
- virtual void HandleEvent( HandleType handle, HandleState state, float x, float y );
-
- /**
* @brief Event received from IMF manager
*
* @param[in] imfManager The IMF manager.
*/
ImfManager::ImfCallbackData OnImfEvent( ImfManager& imfManager, const ImfManager::ImfEventData& imfEvent );
+ /**
+ * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::GetTargetSize()
+ */
+ virtual void GetTargetSize( Vector2& targetSize );
+
+ /**
+ * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::AddDecoration()
+ */
+ virtual void AddDecoration( Actor& actor );
+
+ /**
+ * @copydoc Dali::Toolkit::Text::Decorator::ControllerInterface::DecorationEvent()
+ */
+ virtual void DecorationEvent( HandleType handle, HandleState state, float x, float y );
+
protected:
/**