*/
// Popup: Tails
-const char* DEFAULT_POPUP_TAIL_BOTTOM( DALI_IMAGE_DIR "00_popup_bubble_tail_bottom.png" );
+const char* DEFAULT_POPUP_TAIL_BOTTOM( DALI_IMAGE_DIR "popup_bubble_tail_bottom.png" );
+const char* DEFAULT_POPUP_TAIL_BOTTOM_OUTLINE( DALI_IMAGE_DIR "popup_bubble_tail_bottom_line.png" );
// Popup: Vertical Constraint
// TODO: Remove - this should come from application - it is not possible to get the
const float SHOW_POPUP_ANIMATION_DURATION(0.2f); ///< Duration of popup show animation in seconds.
const Vector2 DEFAULT_ICON_SIZE( 45.0f, 45.0f ); ///< Default icon size for image in options
-const float TEXT_POSITION_OFFSET( -19.0f ); ///< Default offset for text label
+const float TEXT_POSITION_OFFSET( -19.0f ); ///< Default offset for text label
const float ICON_POSITION_OFFSET( 19.0f ); ///< Default offset for icon
const char* DEFAULT_ICON_CLIPBOARD( DALI_IMAGE_DIR "copy_paste_icon_clipboard.png" );
Rect<float> mBoundingRect; ///< Bounding Rect Popup must stay within
};
+/**
+ * Confine actor to the x axis boundaries of reference actor (e.g. Parent)
+ */
+struct ParentXAxisConstraint
+{
+ /**
+ * Confinement constraint constructor.
+ */
+ ParentXAxisConstraint( float handlesMidPoint = 0.0f )
+ : mHandlesMidPoint( handlesMidPoint )
+ {
+ }
+
+ float operator()( const float constXPosition,
+ const PropertyInput& localWidthProperty,
+ const PropertyInput& anchorPointXProperty )
+ {
+ const float size = localWidthProperty.GetFloat();
+ const float anchor = anchorPointXProperty.GetFloat();
+
+ float newPosition = Clamp( mHandlesMidPoint, constXPosition - size * anchor , constXPosition + size * anchor);
+
+ return newPosition;
+ }
+
+ float mHandlesMidPoint;
+};
+
+
} // unnamed namespace
namespace Dali
TextInputPopup::TextInputPopup()
: mState(StateHidden),
mRootActor(Layer::New()),
+ mPopupTailXPosition( 0.0f ),
mContentSize( Vector3::ZERO ),
mCutPasteButtonsColor( DEFAULT_POPUP_BACKGROUND ),
mCutPasteButtonsPressedColor( DEFAULT_POPUP_BUTTON_PRESSED ),
mRootActor.ApplyConstraint(constraint);
}
+void TextInputPopup::ApplyTailConstraint()
+{
+ mTail.RemoveConstraints();
+ Constraint constraint = Constraint::New<float>( Actor::POSITION_X,
+ LocalSource( Actor::SIZE_WIDTH ),
+ LocalSource( Actor::ANCHOR_POINT_X ),
+ ParentXAxisConstraint());
+}
+
void TextInputPopup::CreateLayer( const Vector2& size )
{
mLayer = Layer::New();
{
if ( mBackground )
{
+ UnparentAndReset( mTail );
UnparentAndReset( mStencil );
UnparentAndReset( mBackground );
UnparentAndReset( mScrollView );
// Add Tail too.
Image tailImage = Image::New( DEFAULT_POPUP_TAIL_BOTTOM );
+ Image tailImageOutline = Image::New( DEFAULT_POPUP_TAIL_BOTTOM_OUTLINE );
+
+ mTailOutline = ImageActor::New ( tailImageOutline );
+ mTailOutline.SetParentOrigin( ParentOrigin::CENTER );
+ mTailOutline.SetAnchorPoint( AnchorPoint::CENTER );
+ mTailOutline.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
mTail = ImageActor::New( tailImage );
mTail.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
mTail.SetAnchorPoint( AnchorPoint::TOP_CENTER );
- mBackground.Add( mTail );
// TODO: Make tail visible, and positioned in relation to original intended position of popup (i.e. before constrained effects)
- mTail.SetVisible(false);
+ mTail.SetVisible(true);
+ mTail.SetColor( mCutPasteButtonsColor );
+ mTailOutline.SetColor( mBorderColor );
+ mTail.Add( mTailOutline);
}
}
{
i->SetSize( DIVIDER_WIDTH, dividerHeight );
}
-
- mTail.SetPosition(Vector3(0.0f, -20.0f, 0.0f));
-
button.ClickedSignal().Connect( this, &TextInputPopup::OnButtonPressed );
}
void TextInputPopup::Hide(bool animate)
{
- if(mBackground)
+ if( mRootActor )
{
if(mAnimation)
{
if(animate)
{
mAnimation = Animation::New( HIDE_POPUP_ANIMATION_DURATION );
- mAnimation.AnimateTo( Property(mBackground, Actor::SCALE), Vector3::ZERO, AlphaFunctions::EaseOut );
- mAnimation.AnimateTo( Property(mBackground, Actor::COLOR_ALPHA), 0.0f, AlphaFunctions::EaseOut );
+ mAnimation.AnimateTo( Property(mRootActor, Actor::SCALE), Vector3::ZERO, AlphaFunctions::EaseOut );
+ mAnimation.AnimateTo( Property(mRootActor, Actor::COLOR_ALPHA), 0.0f, AlphaFunctions::EaseOut );
mAnimation.Play();
mAnimation.FinishedSignal().Connect( this, &TextInputPopup::OnHideFinished );
}
else
{
- mBackground.SetProperty(Actor::SCALE, Vector3::ZERO);
- mBackground.SetProperty(Actor::COLOR_ALPHA, 0.0f);
+ mRootActor.SetProperty(Actor::SCALE, Vector3::ZERO);
+ mRootActor.SetProperty(Actor::COLOR_ALPHA, 0.0f);
mState = StateHidden;
}
}
void TextInputPopup::Show(bool animate)
{
- if(mBackground)
+ if( mRootActor )
{
- mBackground.SetSensitive( true );
+ mRootActor.SetSensitive( true );
+
+ mTail.SetPosition(Vector3( mPopupTailXPosition, 0.0f, 0.0f));
if(mAnimation)
{
if(animate)
{
mAnimation = Animation::New( SHOW_POPUP_ANIMATION_DURATION );
- mAnimation.AnimateTo( Property(mBackground, Actor::SCALE), Vector3::ONE, AlphaFunctions::EaseOut );
- mAnimation.AnimateTo( Property(mBackground, Actor::COLOR_ALPHA), 1.0f, AlphaFunctions::EaseOut );
+ mAnimation.AnimateTo( Property(mRootActor, Actor::SCALE), Vector3::ONE, AlphaFunctions::EaseOut );
+ mAnimation.AnimateTo( Property(mRootActor, Actor::COLOR_ALPHA), 1.0f, AlphaFunctions::EaseOut );
mAnimation.Play();
mAnimation.FinishedSignal().Connect( this, &TextInputPopup::OnShowFinished );
}
else
{
- mBackground.SetProperty(Actor::SCALE, Vector3::ONE);
- mBackground.SetProperty(Actor::COLOR_ALPHA, 1.0f);
+ mRootActor.SetProperty(Actor::SCALE, Vector3::ONE);
+ mRootActor.SetProperty(Actor::COLOR_ALPHA, 1.0f);
mState = StateShown;
}
}
mLayer.Add( mStencil );
mLayer.Add( mScrollView );
mScrollView.Add( mBackground );
+ mRootActor.Add( mTail );
Self().Add(mLayer);
}
mBoundingRect = boundingRectangle;
}
+void TextInputPopup::SetTailPosition( const Vector3& position )
+{
+ mPopupTailXPosition = position.x;
+ ApplyTailConstraint();
+}
+
bool TextInputPopup::OnButtonPressed( Toolkit::Button button )
{
mPressedSignal.Emit( button );
} // namespace Toolkit
} // namespace Dali
+