From: Paul Wisbey
Date: Mon, 8 Jun 2015 18:10:39 +0000 (-0700)
Subject: Merge "Control to call Init derived classes before applying style" into devel/master
X-Git-Tag: dali_1.0.44~5
X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=64184de859e515190adf28466fa9f9dd8f8437e9;hp=e232ff307eaa76bb80c7027e9943cf5f76682236
Merge "Control to call Init derived classes before applying style" into devel/master
---
diff --git a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp
index 753d347..43de0d9 100644
--- a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp
+++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp
@@ -859,7 +859,7 @@ void TextField::OnInitialize()
mController = Text::Controller::New( *this );
- mDecorator = Text::Decorator::New( *this, *mController );
+ mDecorator = Text::Decorator::New( *mController );
mController->GetLayoutEngine().SetLayout( LayoutEngine::SINGLE_LINE_BOX );
@@ -1031,10 +1031,12 @@ bool TextField::OnKeyEvent( const KeyEvent& event )
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()
@@ -1054,6 +1056,12 @@ void TextField::MaxLengthReached()
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 )
diff --git a/dali-toolkit/internal/controls/text-controls/text-field-impl.h b/dali-toolkit/internal/controls/text-controls/text-field-impl.h
index 85b88e2..0e53053 100644
--- a/dali-toolkit/internal/controls/text-controls/text-field-impl.h
+++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.h
@@ -142,9 +142,9 @@ private: // From Control
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()
@@ -161,6 +161,11 @@ private: // From Control
*/
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
/**
diff --git a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp
index 004609f..854ddbf 100644
--- a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp
+++ b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp
@@ -489,6 +489,11 @@ void TextLabel::OnRelayout( const Vector2& size, RelayoutContainer& container )
}
}
+void TextLabel::AddDecoration( Actor& actor )
+{
+ // TextLabel does not show decorations
+}
+
void TextLabel::RequestTextRelayout()
{
RelayoutRequest();
diff --git a/dali-toolkit/internal/controls/text-controls/text-label-impl.h b/dali-toolkit/internal/controls/text-controls/text-label-impl.h
index 54b30dd..12dc56e 100644
--- a/dali-toolkit/internal/controls/text-controls/text-label-impl.h
+++ b/dali-toolkit/internal/controls/text-controls/text-label-impl.h
@@ -93,6 +93,11 @@ private: // From Control
virtual float GetHeightForWidth( float width );
/**
+ * @copydoc Text::ControlInterface::AddDecoration()
+ */
+ virtual void AddDecoration( Actor& actor );
+
+ /**
* @copydoc Text::ControlInterface::RequestTextRelayout()
*/
virtual void RequestTextRelayout();
diff --git a/dali-toolkit/internal/text/decorator/text-decorator.cpp b/dali-toolkit/internal/text/decorator/text-decorator.cpp
index e92866b..2961c52 100644
--- a/dali-toolkit/internal/text/decorator/text-decorator.cpp
+++ b/dali-toolkit/internal/text/decorator/text-decorator.cpp
@@ -209,9 +209,8 @@ struct Decorator::Impl : public ConnectionTracker
bool flipped : 1;
};
- Impl( Dali::Toolkit::Internal::Control& parent, Observer& observer )
- : mTextControlParent( parent ),
- mObserver( observer ),
+ Impl( ControllerInterface& controller )
+ : mController( controller ),
mBoundingBox( Rect() ),
mHighlightColor( LIGHT_BLUE ),
mActiveCursor( ACTIVE_CURSOR_NONE ),
@@ -474,8 +473,6 @@ struct Decorator::Impl : public ConnectionTracker
{
if( !mActiveLayer )
{
- Actor parent = mTextControlParent.Self();
-
mActiveLayer = Layer::New();
#ifdef DECORATOR_DEBUG
mActiveLayer.SetName ( "ActiveLayerActor" );
@@ -485,7 +482,7 @@ struct Decorator::Impl : public ConnectionTracker
mActiveLayer.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
mActiveLayer.SetPositionInheritanceMode( USE_PARENT_POSITION );
- parent.Add( mActiveLayer );
+ mController.AddDecoration( mActiveLayer );
}
mActiveLayer.RaiseToTop();
@@ -625,8 +622,7 @@ struct Decorator::Impl : public ConnectionTracker
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 );
}
}
@@ -746,13 +742,16 @@ struct Decorator::Impl : public ConnectionTracker
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;
@@ -762,7 +761,7 @@ struct Decorator::Impl : public ConnectionTracker
{
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 ||
@@ -772,11 +771,11 @@ struct Decorator::Impl : public ConnectionTracker
{
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] );
}
@@ -992,17 +991,16 @@ struct Decorator::Impl : public ConnectionTracker
{
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;
@@ -1044,9 +1042,9 @@ struct Decorator::Impl : public ConnectionTracker
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& boundingBox )
@@ -1255,10 +1253,10 @@ Decorator::~Decorator()
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
diff --git a/dali-toolkit/internal/text/decorator/text-decorator.h b/dali-toolkit/internal/text/decorator/text-decorator.h
index e341e2b..b271b7b 100644
--- a/dali-toolkit/internal/text/decorator/text-decorator.h
+++ b/dali-toolkit/internal/text/decorator/text-decorator.h
@@ -27,6 +27,7 @@
namespace Dali
{
+class Actor;
class Image;
class Vector2;
class Vector4;
@@ -98,26 +99,40 @@ enum HandleType
*
* 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.
@@ -127,17 +142,16 @@ public:
* @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.
@@ -440,10 +454,9 @@ private:
/**
* @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 );
diff --git a/dali-toolkit/internal/text/text-control-interface.h b/dali-toolkit/internal/text/text-control-interface.h
index e485be9..4d74def 100644
--- a/dali-toolkit/internal/text/text-control-interface.h
+++ b/dali-toolkit/internal/text/text-control-interface.h
@@ -21,6 +21,8 @@
namespace Dali
{
+class Actor;
+
namespace Toolkit
{
@@ -45,6 +47,13 @@ public:
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;
diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp
index 889ca68..49bca2e 100644
--- a/dali-toolkit/internal/text/text-controller.cpp
+++ b/dali-toolkit/internal/text/text-controller.cpp
@@ -1342,9 +1342,19 @@ void Controller::PanEvent( Gesture::State state, const Vector2& displacement )
}
}
-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 )
{
diff --git a/dali-toolkit/internal/text/text-controller.h b/dali-toolkit/internal/text/text-controller.h
index 8a780a9..6c12dd3 100644
--- a/dali-toolkit/internal/text/text-controller.h
+++ b/dali-toolkit/internal/text/text-controller.h
@@ -67,9 +67,9 @@ enum PlaceholderType
* 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:
@@ -504,11 +504,6 @@ 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.
@@ -517,6 +512,21 @@ public:
*/
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:
/**