mPopUpPanel.AddPopupOptions();
}
-void TextInput::SetPopupPosition(const Vector3& position)
+void TextInput::SetPopupPosition( const Vector3& position )
{
- mPopUpPanel.Self().SetPosition( position );
mPopUpPanel.SetTailPosition( position );
+ mPopUpPanel.Self().SetPosition( position );
}
void TextInput::HidePopup(bool animate, bool signalFinished )
if(mHighlightMeshActor && mState == StateEdit)
{
Vector3 topHandle;
+ Vector3 bottomHandle; // referring to the bottom most point of the handle or the bottom line of selection.
Size rowSize;
// When text is selected, show popup above top handle (and text), or below bottom handle.
// topHandle: referring to the top most point of the handle or the top line of selection.
if ( mSelectionHandleTwoActualPosition.y > mSelectionHandleOneActualPosition.y )
{
topHandle = mSelectionHandleOneActualPosition;
+ bottomHandle = mSelectionHandleTwoActualPosition;
rowSize= GetRowRectFromCharacterPosition( mSelectionHandleOnePosition );
}
else
{
topHandle = mSelectionHandleTwoActualPosition;
+ bottomHandle = mSelectionHandleOneActualPosition;
rowSize = GetRowRectFromCharacterPosition( mSelectionHandleTwoPosition );
}
topHandle.y += -mPopupOffsetFromText.y - rowSize.height;
position = Vector3(topHandle.x, topHandle.y, 0.0f);
- // bottomHandle: referring to the bottom most point of the handle or the bottom line of selection.
- Vector3 bottomHandle;
- bottomHandle.y = std::max ( mSelectionHandleTwoActualPosition.y , mSelectionHandleOneActualPosition.y );
bottomHandle.y += GetSelectionHandleSize().y + mPopupOffsetFromText.w;
mPopUpPanel.SetAlternativeOffset(Vector2( mBoundingRectangleWorldCoordinates.x, bottomHandle.y - topHandle.y));
// 2. For cursor: should be above top of cursor, or below bottom of cursor + grab handle.
const std::string POPUP_ALTERNATIVE_OFFSET("popup-alternative-offset"); ///< Alternative offset property for confinenment constraint.
+const std::string POPUP_REQUESTED_POSITION("popup-requested-position"); ///< Position the Popup was requested to be, for confinenment constraint.
/**
* Confine Actor to boundaries of reference actor (e.g. Parent)
const PropertyInput& parentOriginProperty,
const PropertyInput& anchorPointProperty,
const PropertyInput& referenceSizeProperty,
- const PropertyInput& alternativeOffsetProperty)
+ const PropertyInput& alternativeOffsetProperty,
+ const PropertyInput& requestedPositionProperty )
{
const Vector3& size = sizeProperty.GetVector3();
const Vector3& origin = parentOriginProperty.GetVector3();
const Vector3& anchor = anchorPointProperty.GetVector3();
const Vector3& referenceSize = referenceSizeProperty.GetVector3();
const Vector2& alternativeOffset = alternativeOffsetProperty.GetVector2();
+ const Vector3& requestedPosition = requestedPositionProperty.GetVector3();
- Vector3 newPosition(constPosition);
+ Vector3 newPosition( requestedPosition );
// Get actual position of Actor relative to parent's Top-Left.
Vector3 position(constPosition + origin * referenceSize);
Vector3 corner(position - size * anchor - mMinIndent);
- newPosition.x -= std::max(corner.x, 0.0f);
-
if ( mFlipHorizontal )
{
if( corner.x < mBoundingRect.x + POP_UP_SCREEN_EDGE_MARGIN )
{
// Snap PopUp to left hand boundary so stays visible
- corner.x = mBoundingRect.x + POP_UP_SCREEN_EDGE_MARGIN ;
+ corner.x = mBoundingRect.x + POP_UP_SCREEN_EDGE_MARGIN - ( origin.x * referenceSize.x ) + ( size.x * anchor.x );
+ newPosition.x = corner.x;
}
else if ( ( corner.x + size.x ) > ( ( mBoundingRect.x + mBoundingRect.width ) - POP_UP_SCREEN_EDGE_MARGIN ))
{
// Calculate offset from left boundary PopUp must be placed at so it does not exceed right side boundary.
float requiredOffSetFromLeftBoundaryToFit = mBoundingRect.width - POP_UP_SCREEN_EDGE_MARGIN - size.x;
corner.x = mBoundingRect.x + requiredOffSetFromLeftBoundaryToFit - ( origin.x * referenceSize.x ) + ( size.x * anchor.x );
+ newPosition.x = corner.x;
}
- newPosition.x = corner.x;
}
if(mFlipVertical && corner.y < 0.0f)
}
float operator()( const float constXPosition,
- const PropertyInput& localWidthProperty,
+ const PropertyInput& localSizeWidthProperty,
+ const PropertyInput& parentWidthProperty,
const PropertyInput& anchorPointXProperty )
{
- const float size = localWidthProperty.GetFloat();
- const float anchor = anchorPointXProperty.GetFloat();
-
- float newPosition = Clamp( mHandlesMidPoint, constXPosition - size * anchor , constXPosition + size * anchor);
+ const float localSizeProperty = localSizeWidthProperty.GetFloat();
+ const float size = parentWidthProperty.GetFloat();
+ float newPosition = std::max( mHandlesMidPoint, -size/2 + localSizeProperty );
+ newPosition = std::min( newPosition, size/2 - localSizeProperty );
return newPosition;
}
mShowFinishedSignal()
{
mAlternativeOffsetProperty = mRootActor.RegisterProperty( POPUP_ALTERNATIVE_OFFSET, Vector2::ZERO );
+ mRequestionPositionProperty = mRootActor.RegisterProperty( POPUP_REQUESTED_POSITION, Vector3::ZERO );
mRootActor.SetParentOrigin( ParentOrigin::CENTER );
mRootActor.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER );
// constrain popup to size of parent.
LocalSource( Actor::ANCHOR_POINT ),
ParentSource( Actor::SIZE ),
LocalSource( mAlternativeOffsetProperty ),
+ LocalSource( mRequestionPositionProperty),
ConfinementConstraint( DEFAULT_POPUP_INDICATOR_OFFSET,
Vector2::ZERO,
true,
mTail.RemoveConstraints();
Constraint constraint = Constraint::New<float>( Actor::POSITION_X,
LocalSource( Actor::SIZE_WIDTH ),
- LocalSource( Actor::ANCHOR_POINT_X ),
- ParentXAxisConstraint());
+ ParentSource( Actor::SIZE_WIDTH ),
+ LocalSource( Actor::PARENT_ORIGIN_X ),
+ ParentXAxisConstraint( mPopupTailXPosition ));
+ mTail.ApplyConstraint( constraint );
}
void TextInputPopup::CreateLayer( const Vector2& size )
mTail = ImageActor::New( tailImage );
mTail.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
mTail.SetAnchorPoint( AnchorPoint::TOP_CENTER );
+ mTail.SetPosition( 0.0f, TAIL_Y_POSITION );
// TODO: Make tail visible, and positioned in relation to original intended position of popup (i.e. before constrained effects)
mTail.SetVisible(true);
mTail.SetColor( mCutPasteButtonsColor );
{
mRootActor.SetSensitive( true );
- mTail.SetPosition(Vector3( mPopupTailXPosition, TAIL_Y_POSITION, 0.0f));
-
if(mAnimation)
{
mAnimation.Clear();
void TextInputPopup::SetTailPosition( const Vector3& position )
{
+ mRootActor.SetProperty( mRequestionPositionProperty, position );
mPopupTailXPosition = position.x;
+ ApplyConfinementConstraint();
ApplyTailConstraint();
}