*/
// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/text/decorator/text-decorator.h>
+#include <dali-toolkit/public-api/text/text-control-interface.h>
#include <dali-toolkit/public-api/text/text-view.h>
// EXTERNAL INCLUDES
class LayoutEngine;
typedef IntrusivePtr<Controller> ControllerPtr;
+typedef Dali::Toolkit::Text::ControlInterface ControlInterface;
/**
* @brief A Text Controller is used by UI Controls which display text.
*
* It manipulates the Logical & Visual text models on behalf of the UI Controls.
* 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.
*/
-class Controller : public RefObject
+class Controller : public RefObject, public Decorator::Observer
{
private:
/**
* @brief Create a new instance of a Controller.
*
+ * @param[in] controlInterface An interface used to request a text relayout.
* @return A pointer to a new Controller.
*/
- static ControllerPtr New();
+ static ControllerPtr New( ControlInterface& controlInterface );
/**
* @brief Replaces any text previously set.
void SetText( const std::string& text );
/**
+ * @brief Called to enable text input.
+ *
+ * @note Only selectable or editable controls should calls this.
+ * @param[in] decorator Used to create cursor, selection handle decorations etc.
+ */
+ void EnableTextInput( DecoratorPtr decorator );
+
+ /**
* @brief Triggers a relayout which updates View (if necessary).
*
* @note UI Controls are expected to minimize calls to this method e.g. call once after size negotiation.
* @param[in] size A the size of a bounding box to layout text within.
- * @return True if the View was updated.
+ * @return True if the text model or decorations were updated.
*/
bool Relayout( const Vector2& size );
*/
View& GetView();
+ /**
+ * @brief Caller by editable UI controls when keyboard focus is gained.
+ */
+ void KeyboardFocusGainEvent();
+
+ /**
+ * @brief Caller by editable UI controls when focus is lost.
+ */
+ void KeyboardFocusLostEvent();
+
+ /**
+ * @brief Caller by editable UI controls when a tap gesture occurs.
+ * @param[in] tapCount The number of taps.
+ * @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.
+ */
+ void TapEvent( unsigned int tapCount, float x, float y );
+
+ /**
+ * @copydoc Dali::Toolkit::Text::Decorator::Observer::GrabHandleEvent()
+ */
+ virtual void GrabHandleEvent( GrabHandleState state, float x, float y );
+
protected:
/**
private:
/**
- * @brief Private constructor.
+ * @brief Request a relayout using the ControlInterface.
*/
- Controller();
+ void RequestRelayout();
/**
- * @brief Populates the visual model.
+ * @brief Private constructor.
*/
- void UpdateVisualModel();
+ Controller( ControlInterface& controlInterface );
// Undefined
Controller( const Controller& handle );
struct Impl;
Impl* mImpl;
+
+ // Avoid allocating this for non-editable controls
+ struct TextInput;
};
} // namespace Text