From: Agnelo Vaz Date: Tue, 3 Mar 2015 16:17:40 +0000 (+0000) Subject: Adding Decorator BoundingBox X-Git-Tag: new_text_0.1~28 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=9f1abc9d8b332a4a619173082cc2622f3c4c6125 Adding Decorator BoundingBox Change-Id: Iea3b56d5d9764a4ae124bb422b839a0b86cbe14d Signed-off-by: Agnelo Vaz --- 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 c4a636e..03dcf44 100644 --- a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp @@ -21,6 +21,7 @@ // EXTERNAL INCLUDES #include #include +#include #include // INTERNAL INCLUDES @@ -43,16 +44,17 @@ namespace Dali namespace Toolkit { -const Property::Index TextField::PROPERTY_RENDERING_BACKEND( Internal::TextField::TEXTFIELD_PROPERTY_START_INDEX ); -const Property::Index TextField::PROPERTY_PLACEHOLDER_TEXT( Internal::TextField::TEXTFIELD_PROPERTY_START_INDEX + 1 ); -const Property::Index TextField::PROPERTY_TEXT( Internal::TextField::TEXTFIELD_PROPERTY_START_INDEX + 2 ); -const Property::Index TextField::PROPERTY_CURSOR_IMAGE( Internal::TextField::TEXTFIELD_PROPERTY_START_INDEX + 3 ); -const Property::Index TextField::PROPERTY_PRIMARY_CURSOR_COLOR( Internal::TextField::TEXTFIELD_PROPERTY_START_INDEX + 4 ); -const Property::Index TextField::PROPERTY_SECONDARY_CURSOR_COLOR( Internal::TextField::TEXTFIELD_PROPERTY_START_INDEX + 5 ); -const Property::Index TextField::PROPERTY_ENABLE_CURSOR_BLINK( Internal::TextField::TEXTFIELD_PROPERTY_START_INDEX + 6 ); -const Property::Index TextField::PROPERTY_CURSOR_BLINK_INTERVAL( Internal::TextField::TEXTFIELD_PROPERTY_START_INDEX + 7 ); -const Property::Index TextField::PROPERTY_CURSOR_BLINK_DURATION( Internal::TextField::TEXTFIELD_PROPERTY_START_INDEX + 8 ); -const Property::Index TextField::PROPERTY_GRAB_HANDLE_IMAGE( Internal::TextField::TEXTFIELD_PROPERTY_START_INDEX + 9 ); +const Property::Index TextField::PROPERTY_RENDERING_BACKEND( Internal::TextField::TEXTFIELD_PROPERTY_START_INDEX ); +const Property::Index TextField::PROPERTY_PLACEHOLDER_TEXT( Internal::TextField::TEXTFIELD_PROPERTY_START_INDEX + 1 ); +const Property::Index TextField::PROPERTY_TEXT( Internal::TextField::TEXTFIELD_PROPERTY_START_INDEX + 2 ); +const Property::Index TextField::PROPERTY_CURSOR_IMAGE( Internal::TextField::TEXTFIELD_PROPERTY_START_INDEX + 3 ); +const Property::Index TextField::PROPERTY_PRIMARY_CURSOR_COLOR( Internal::TextField::TEXTFIELD_PROPERTY_START_INDEX + 4 ); +const Property::Index TextField::PROPERTY_SECONDARY_CURSOR_COLOR( Internal::TextField::TEXTFIELD_PROPERTY_START_INDEX + 5 ); +const Property::Index TextField::PROPERTY_ENABLE_CURSOR_BLINK( Internal::TextField::TEXTFIELD_PROPERTY_START_INDEX + 6 ); +const Property::Index TextField::PROPERTY_CURSOR_BLINK_INTERVAL( Internal::TextField::TEXTFIELD_PROPERTY_START_INDEX + 7 ); +const Property::Index TextField::PROPERTY_CURSOR_BLINK_DURATION( Internal::TextField::TEXTFIELD_PROPERTY_START_INDEX + 8 ); +const Property::Index TextField::PROPERTY_GRAB_HANDLE_IMAGE( Internal::TextField::TEXTFIELD_PROPERTY_START_INDEX + 9 ); +const Property::Index TextField::PROPERTY_DECORATION_BOUNDING_BOX( Internal::TextField::TEXTFIELD_PROPERTY_START_INDEX + 10 ); namespace Internal { @@ -68,17 +70,17 @@ BaseHandle Create() TypeRegistration mType( typeid(Toolkit::TextField), typeid(Toolkit::Control), Create ); -PropertyRegistration property01( mType, "rendering-backend", Toolkit::TextField::PROPERTY_RENDERING_BACKEND, Property::INTEGER, &TextField::SetProperty, &TextField::GetProperty ); -PropertyRegistration property02( mType, "placeholder-text", Toolkit::TextField::PROPERTY_PLACEHOLDER_TEXT, Property::STRING, &TextField::SetProperty, &TextField::GetProperty ); -PropertyRegistration property03( mType, "text", Toolkit::TextField::PROPERTY_TEXT, Property::STRING, &TextField::SetProperty, &TextField::GetProperty ); -PropertyRegistration property04( mType, "cursor-image", Toolkit::TextField::PROPERTY_CURSOR_IMAGE, Property::STRING, &TextField::SetProperty, &TextField::GetProperty ); -PropertyRegistration property05( mType, "primary-cursor-color", Toolkit::TextField::PROPERTY_PRIMARY_CURSOR_COLOR, Property::VECTOR4, &TextField::SetProperty, &TextField::GetProperty ); -PropertyRegistration property06( mType, "secondary-cursor-color", Toolkit::TextField::PROPERTY_SECONDARY_CURSOR_COLOR, Property::VECTOR4, &TextField::SetProperty, &TextField::GetProperty ); -PropertyRegistration property07( mType, "enable-cursor-blink", Toolkit::TextField::PROPERTY_ENABLE_CURSOR_BLINK, Property::BOOLEAN, &TextField::SetProperty, &TextField::GetProperty ); -PropertyRegistration property08( mType, "cursor-blink-interval", Toolkit::TextField::PROPERTY_CURSOR_BLINK_INTERVAL, Property::FLOAT, &TextField::SetProperty, &TextField::GetProperty ); -PropertyRegistration property09( mType, "cursor-blink-duration", Toolkit::TextField::PROPERTY_CURSOR_BLINK_DURATION, Property::FLOAT, &TextField::SetProperty, &TextField::GetProperty ); -PropertyRegistration property10( mType, "grab-handle-image", Toolkit::TextField::PROPERTY_GRAB_HANDLE_IMAGE, Property::STRING, &TextField::SetProperty, &TextField::GetProperty ); - +PropertyRegistration property01( mType, "rendering-backend", Toolkit::TextField::PROPERTY_RENDERING_BACKEND, Property::INTEGER, &TextField::SetProperty, &TextField::GetProperty ); +PropertyRegistration property02( mType, "placeholder-text", Toolkit::TextField::PROPERTY_PLACEHOLDER_TEXT, Property::STRING, &TextField::SetProperty, &TextField::GetProperty ); +PropertyRegistration property03( mType, "text", Toolkit::TextField::PROPERTY_TEXT, Property::STRING, &TextField::SetProperty, &TextField::GetProperty ); +PropertyRegistration property04( mType, "cursor-image", Toolkit::TextField::PROPERTY_CURSOR_IMAGE, Property::STRING, &TextField::SetProperty, &TextField::GetProperty ); +PropertyRegistration property05( mType, "primary-cursor-color", Toolkit::TextField::PROPERTY_PRIMARY_CURSOR_COLOR, Property::VECTOR4, &TextField::SetProperty, &TextField::GetProperty ); +PropertyRegistration property06( mType, "secondary-cursor-color", Toolkit::TextField::PROPERTY_SECONDARY_CURSOR_COLOR, Property::VECTOR4, &TextField::SetProperty, &TextField::GetProperty ); +PropertyRegistration property07( mType, "enable-cursor-blink", Toolkit::TextField::PROPERTY_ENABLE_CURSOR_BLINK, Property::BOOLEAN, &TextField::SetProperty, &TextField::GetProperty ); +PropertyRegistration property08( mType, "cursor-blink-interval", Toolkit::TextField::PROPERTY_CURSOR_BLINK_INTERVAL, Property::FLOAT, &TextField::SetProperty, &TextField::GetProperty ); +PropertyRegistration property09( mType, "cursor-blink-duration", Toolkit::TextField::PROPERTY_CURSOR_BLINK_DURATION, Property::FLOAT, &TextField::SetProperty, &TextField::GetProperty ); +PropertyRegistration property10( mType, "grab-handle-image", Toolkit::TextField::PROPERTY_GRAB_HANDLE_IMAGE, Property::STRING, &TextField::SetProperty, &TextField::GetProperty ); +PropertyRegistration property11( mType, "decoration bounding-box", Toolkit::TextField::PROPERTY_DECORATION_BOUNDING_BOX, Property::RECTANGLE, &TextField::SetProperty, &TextField::GetProperty ); } // namespace Toolkit::TextField TextField::New() @@ -193,6 +195,14 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr } break; } + case Toolkit::TextField::PROPERTY_DECORATION_BOUNDING_BOX: + { + if( impl.mDecorator ) + { + impl.mDecorator->SetBoundingBox( value.Get< Rect >() ); + } + break; + } } } } @@ -285,6 +295,14 @@ Property::Value TextField::GetProperty( BaseObject* object, Property::Index inde } break; } + case Toolkit::TextField::PROPERTY_DECORATION_BOUNDING_BOX: + { + if( impl.mDecorator ) + { + value = impl.mDecorator->GetBoundingBox(); + } + break; + } } } @@ -309,6 +327,13 @@ void TextField::OnInitialize() mDoubleTapDetector.SetTapsRequired( 2 ); mDoubleTapDetector.DetectedSignal().Connect( this, &TextField::OnDoubleTap ); mDoubleTapDetector.Attach(Self()); + + // Set BoundingBox to stage size if not already set. + if ( mDecorator->GetBoundingBox().IsEmpty() ) + { + Vector2 stageSize = Dali::Stage::GetCurrent().GetSize(); + mDecorator->SetBoundingBox( Rect( 0.0f, 0.0f, stageSize.width, stageSize.height ) ); + } } void TextField::OnRelayout( const Vector2& size, ActorSizeContainer& container ) diff --git a/dali-toolkit/public-api/controls/text-controls/text-field.cpp b/dali-toolkit/public-api/controls/text-controls/text-field.cpp index bbe9d1f..397f6a5 100644 --- a/dali-toolkit/public-api/controls/text-controls/text-field.cpp +++ b/dali-toolkit/public-api/controls/text-controls/text-field.cpp @@ -37,6 +37,7 @@ const std::string TextField::ENABLE_CURSOR_BLINK_PROPERTY_NAME("enable-cursor-bl const std::string TextField::CURSOR_BLINK_INTERVAL_PROPERTY_NAME("cursor-blink-interval"); const std::string TextField::CURSOR_BLINK_DURATION_PROPERTY_NAME("cursor-blink-duration"); const std::string TextField::GRAB_HANDLE_IMAGE_PROPERTY_NAME("grab-handle-image"); +const std::string TextField::DECORATION_BOUNDING_BOX("decoration-bounding-box"); TextField TextField::New() { diff --git a/dali-toolkit/public-api/controls/text-controls/text-field.h b/dali-toolkit/public-api/controls/text-controls/text-field.h index 293e293..4d97b03 100644 --- a/dali-toolkit/public-api/controls/text-controls/text-field.h +++ b/dali-toolkit/public-api/controls/text-controls/text-field.h @@ -41,28 +41,30 @@ class DALI_IMPORT_API TextField : public Control public: // Property indices - static const Property::Index PROPERTY_RENDERING_BACKEND; ///< name "rendering-backend", type INT - static const Property::Index PROPERTY_PLACEHOLDER_TEXT; ///< name "placeholder-text", type STRING - static const Property::Index PROPERTY_TEXT; ///< name "text", type STRING - static const Property::Index PROPERTY_CURSOR_IMAGE; ///< name "cursor-image", type STRING - static const Property::Index PROPERTY_PRIMARY_CURSOR_COLOR; ///< name "primary-cursor-color", type VECTOR4 - static const Property::Index PROPERTY_SECONDARY_CURSOR_COLOR; ///< name "secondary-cursor-color", type VECTOR4 - static const Property::Index PROPERTY_ENABLE_CURSOR_BLINK; ///< name "enable-cursor-blink", type BOOLEAN - static const Property::Index PROPERTY_CURSOR_BLINK_INTERVAL; ///< name "cursor-blink-interval", type FLOAT - static const Property::Index PROPERTY_CURSOR_BLINK_DURATION; ///< name "cursor-blink-duration", type FLOAT - static const Property::Index PROPERTY_GRAB_HANDLE_IMAGE; ///< name "grab-handle-image", type STRING + static const Property::Index PROPERTY_RENDERING_BACKEND; ///< name "rendering-backend", type INT + static const Property::Index PROPERTY_PLACEHOLDER_TEXT; ///< name "placeholder-text", type STRING + static const Property::Index PROPERTY_TEXT; ///< name "text", type STRING + static const Property::Index PROPERTY_CURSOR_IMAGE; ///< name "cursor-image", type STRING + static const Property::Index PROPERTY_PRIMARY_CURSOR_COLOR; ///< name "primary-cursor-color", type VECTOR4 + static const Property::Index PROPERTY_SECONDARY_CURSOR_COLOR; ///< name "secondary-cursor-color", type VECTOR4 + static const Property::Index PROPERTY_ENABLE_CURSOR_BLINK; ///< name "enable-cursor-blink", type BOOLEAN + static const Property::Index PROPERTY_CURSOR_BLINK_INTERVAL; ///< name "cursor-blink-interval", type FLOAT + static const Property::Index PROPERTY_CURSOR_BLINK_DURATION; ///< name "cursor-blink-duration", type FLOAT + static const Property::Index PROPERTY_GRAB_HANDLE_IMAGE; ///< name "grab-handle-image", type STRING + static const Property::Index PROPERTY_DECORATION_BOUNDING_BOX; ///< name "decoration-bounding-box", type RECTANGLE // Property names - static const std::string RENDERING_BACKEND_PROPERTY_NAME; ///< Property, name "rendering-backend", type INT - static const std::string PLACEHOLDER_TEXT_PROPERTY_NAME; ///< Property, name "placeholder-text", type STRING - static const std::string TEXT_PROPERTY_NAME; ///< Property, name "text", type STRING - static const std::string CURSOR_IMAGE_PROPERTY_NAME; ///< Property, name "cursor-image", type STRING - static const std::string PRIMARY_CURSOR_COLOR_PROPERTY_NAME; ///< Property, name "primary-cursor-color", type VECTOR4 - static const std::string SECONDARY_CURSOR_COLOR_PROPERTY_NAME; ///< Property, name "secondary-cursor-color", type VECTOR4 - static const std::string ENABLE_CURSOR_BLINK_PROPERTY_NAME; ///< Property, name "enable-cursor-blink", type BOOLEAN - static const std::string CURSOR_BLINK_INTERVAL_PROPERTY_NAME; ///< Property, name "cursor-blink-interval", type FLOAT - static const std::string CURSOR_BLINK_DURATION_PROPERTY_NAME; ///< Property, name "cursor-blink-duration", type FLOAT - static const std::string GRAB_HANDLE_IMAGE_PROPERTY_NAME; ///< Property, name "grab-handle-image", type STRING + static const std::string RENDERING_BACKEND_PROPERTY_NAME; ///< Property, name "rendering-backend", type INT + static const std::string PLACEHOLDER_TEXT_PROPERTY_NAME; ///< Property, name "placeholder-text", type STRING + static const std::string TEXT_PROPERTY_NAME; ///< Property, name "text", type STRING + static const std::string CURSOR_IMAGE_PROPERTY_NAME; ///< Property, name "cursor-image", type STRING + static const std::string PRIMARY_CURSOR_COLOR_PROPERTY_NAME; ///< Property, name "primary-cursor-color", type VECTOR4 + static const std::string SECONDARY_CURSOR_COLOR_PROPERTY_NAME; ///< Property, name "secondary-cursor-color", type VECTOR4 + static const std::string ENABLE_CURSOR_BLINK_PROPERTY_NAME; ///< Property, name "enable-cursor-blink", type BOOLEAN + static const std::string CURSOR_BLINK_INTERVAL_PROPERTY_NAME; ///< Property, name "cursor-blink-interval", type FLOAT + static const std::string CURSOR_BLINK_DURATION_PROPERTY_NAME; ///< Property, name "cursor-blink-duration", type FLOAT + static const std::string GRAB_HANDLE_IMAGE_PROPERTY_NAME; ///< Property, name "grab-handle-image", type STRING + static const std::string DECORATION_BOUNDING_BOX; ///< Property, name "decoration-bounding-box", type RECTANGLE /** * Create the TextField control. diff --git a/dali-toolkit/public-api/text/decorator/text-decorator.cpp b/dali-toolkit/public-api/text/decorator/text-decorator.cpp index 148fbc8..0b15b49 100644 --- a/dali-toolkit/public-api/text/decorator/text-decorator.cpp +++ b/dali-toolkit/public-api/text/decorator/text-decorator.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -56,6 +57,7 @@ const Dali::Vector3 DEFAULT_GRAB_HANDLE_RELATIVE_SIZE( 1.5f, 2.0f, 1.0f ); const Dali::Vector3 DEFAULT_SELECTION_HANDLE_RELATIVE_SIZE( 1.5f, 1.5f, 1.0f ); const std::size_t CURSOR_BLINK_INTERVAL = 500; // Cursor blink interval +const std::size_t MILLISECONDS = 1000; } // end of namespace @@ -116,10 +118,11 @@ struct Decorator::Impl : public ConnectionTracker mActiveGrabHandle(false), mActiveSelection( false ), mCursorBlinkInterval( CURSOR_BLINK_INTERVAL ), - mCursorBlinkDuration(0.0f), + mCursorBlinkDuration( 0.0f ), mCursorBlinkStatus( true ), - mGrabDisplacementX(0.0f), - mGrabDisplacementY(0.0f) + mGrabDisplacementX( 0.0f ), + mGrabDisplacementY( 0.0f ), + mBoundingBox( Rect() ) { } @@ -467,7 +470,7 @@ struct Decorator::Impl : public ConnectionTracker TapGestureDetector mTapDetector; PanGestureDetector mPanGestureDetector; - + Rect mBoundingBox; }; DecoratorPtr Decorator::New( Internal::Control& parent, Observer& observer ) @@ -475,6 +478,16 @@ DecoratorPtr Decorator::New( Internal::Control& parent, Observer& observer ) return DecoratorPtr( new Decorator(parent, observer) ); } +void Decorator::SetBoundingBox( const Rect& boundingBox ) +{ + mImpl->mBoundingBox = boundingBox; +} + +const Rect& Decorator::GetBoundingBox() const +{ + return mImpl->mBoundingBox; +} + void Decorator::Relayout( const Vector2& size ) { mImpl->Relayout( size ); @@ -554,7 +567,7 @@ void Decorator::StopCursorBlink() void Decorator::SetCursorBlinkInterval( float seconds ) { - mImpl->mCursorBlinkInterval = seconds*1000; // Convert to milliseconds + mImpl->mCursorBlinkInterval = seconds*MILLISECONDS; // Convert to milliseconds } float Decorator::GetCursorBlinkInterval() const diff --git a/dali-toolkit/public-api/text/decorator/text-decorator.h b/dali-toolkit/public-api/text/decorator/text-decorator.h index 144f0ef..4038d3f 100644 --- a/dali-toolkit/public-api/text/decorator/text-decorator.h +++ b/dali-toolkit/public-api/text/decorator/text-decorator.h @@ -21,6 +21,7 @@ // EXTERNAL INCLUDES #include #include +#include namespace Dali { @@ -128,6 +129,36 @@ public: static DecoratorPtr New( Dali::Toolkit::Internal::Control& parent, Observer& observer ); /** + * @brief Set the bounding box which handles, popup and similar decorations will not exceed. + * + * The default value is the width and height of the stage from the top left origin. + * If a title bar for example is on the top of the screen then the y should be the title's height and + * the boundary height the stage height minus the title's height. + * Restrictions - The boundary box should be set up with a fixed z position for the text-input and the default camera. + * + * ------------------------------------------ + * |(x,y) | + * |o---------------------------------------| + * || || + * || Bounding Box || boundary height + * || || + * |----------------------------------------| + * ------------------------------------------ + * boundary width + * + * @param[in] boundingBox Vector( x coordinate, y coordinate, width, height ) + */ + void SetBoundingBox( const Rect& boundingBox ); + + /** + * @brief Retrieve the bounding box origin and dimensions. + * + * default is set once control is added to stage, before this the return vector will be Vector4:ZERO + * @return Rect the bounding box origin, width and height + */ + const Rect& GetBoundingBox() const; + + /** * @brief The decorator waits until a relayout before creating actors etc. * * @param[in] size The size of the parent control after size-negotiation.