X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Fpublic-api%2Ftext%2Ftext-controller.h;h=8133451c54fd7a7df68702605416e2b530eb1ee1;hp=3155015d2227e6a64b908c299aacb8a5ac16b66d;hb=09e2475439f1d40c576df0fdc0bc9e26a9661758;hpb=2dd044328238768ae8b27a223cb7d0f5cda53513 diff --git a/dali-toolkit/public-api/text/text-controller.h b/dali-toolkit/public-api/text/text-controller.h index 3155015..8133451 100644 --- a/dali-toolkit/public-api/text/text-controller.h +++ b/dali-toolkit/public-api/text/text-controller.h @@ -19,11 +19,15 @@ */ // INTERNAL INCLUDES -#include -#include +#include +#include #include // EXTERNAL INCLUDES +#include +#include +#include +#include #include namespace Dali @@ -39,23 +43,50 @@ class Controller; class LayoutEngine; typedef IntrusivePtr 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 Text related operations to be done in the relayout process. + */ + enum OperationsMask + { + NO_OPERATION = 0x0, + CONVERT_TO_UTF32 = 0x1, + GET_SCRIPTS = 0x2, + VALIDATE_FONTS = 0x4, + GET_LINE_BREAKS = 0x8, + GET_WORD_BREAKS = 0x10, + SHAPE_TEXT = 0x20, + GET_GLYPH_METRICS = 0x40, + LAYOUT = 0x80, + REORDER = 0x100, + ALIGNMENT = 0x200, + RENDER = 0x400, + ALL_OPERATIONS = 0xFFF + }; + public: /** * @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. @@ -66,15 +97,38 @@ public: 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 ); /** + * + */ + bool DoRelayout( const Vector2& size, OperationsMask operations ); + + /** + * @copydoc Control::GetNaturalSize() + */ + Vector3 GetNaturalSize(); + + /** + * @copydoc Control::GetHeightForWidth() + */ + float GetHeightForWidth( float width ); + + /** * @brief Return the layout engine. * * @return A reference to the layout engine. @@ -88,6 +142,29 @@ public: */ 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: /** @@ -98,14 +175,14 @@ 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 ); @@ -117,7 +194,11 @@ private: struct Impl; Impl* mImpl; + + // Avoid allocating this for non-editable controls + struct TextInput; }; + } // namespace Text } // namespace Toolkit