Esempio n. 1
0
// ****************************************************************************
//
//  Function Name:	RSingleSelection::DrawResizeTrackingRect( )
//
//  Description:		Draws the selection tracking rect for resizing.
//
//  Returns:			Nothing
//
//  Exceptions:		Memory
//
// ****************************************************************************
//
void RSingleSelection::DrawResizeTrackingFeedback( RDrawingSurface& drawingSurface,
																	const R2dTransform& transform,
																	const RRealPoint& scalingCenter,
																	const RRealSize& scaleFactor,
																	BOOLEAN fMaintainAspectRatio ) const
	{
	if( m_pSelectedObject->GetComponentAttributes( ).IsResizable( ) )
		{
		// Setup the drawing surface
		drawingSurface.SetPenWidth( kSelectionOutlineWidth );
		drawingSurface.SetPenStyle( kSolidPen );

		// Get the components bounding rect
		YComponentBoundingRect boundingRect = m_pSelectedObject->GetBoundingRect( );

		// Constrain the scale factor
		RRealSize constrainedScaleFactor = m_pSelectedObject->ApplyResizeConstraint( scaleFactor );

		// Dont force to maintain aspect ratio if it really doesnt want to
		fMaintainAspectRatio = fMaintainAspectRatio && ::AreFloatsEqual( constrainedScaleFactor.m_dx, constrainedScaleFactor.m_dy );

		// Add the scale operation
		boundingRect.UnrotateAndScaleAboutPoint( scalingCenter, constrainedScaleFactor, m_pSelectedObject->GetMinimumSize( ), m_pSelectedObject->GetMaximumSize( ), fMaintainAspectRatio );

		// Tell the object to draw tracking feedback
		m_pSelectedObject->RenderTrackingFeedback( drawingSurface, boundingRect.GetTransform( ) * transform, *GetView( ) );
		}
	}
Esempio n. 2
0
// ****************************************************************************
//
//  Function Name:	RSingleSelection::GetDragTrackingFeedbackBoundingRect( )
//
//  Description:		Gets the bounding rect of drag tracking feedback
//
//  Returns:			Bounding rect
//
//  Exceptions:		Memory
//
// ****************************************************************************
//
RRealRect RSingleSelection::GetDragTrackingFeedbackBoundingRect( const R2dTransform& transform,
																					  const RRealSize& offset ) const
	{
	// Get the components bounding rect
	YComponentBoundingRect boundingRect = m_pSelectedObject->GetBoundingRect( );

	// Add the translate operation
	boundingRect.Offset( offset );

	// Get the objects feedback size
	return m_pSelectedObject->GetTrackingFeedbackBoundingRect( boundingRect.GetTransform( ) * transform );
	}
Esempio n. 3
0
// ****************************************************************************
//
//  Function Name:	RSingleSelection::SelectionRectFromDeviceObjectRect( )
//
//  Description:		Converts the given bounding rect to a selection rect
//							by inflating
//
//  Returns:			Nothing
//
//  Exceptions:		None
//
// ****************************************************************************
//
void RSingleSelection::SelectionRectFromDeviceObjectRect( YComponentBoundingRect& objectBoundingRect, BOOLEAN fOutset )
	{
	// Dont bother if the rect is too small
	if( objectBoundingRect.IsEmpty( ) )
		return;

	// If Outsetting, inflate the rect. Otherwise, deflate the rect
	if( fOutset == TRUE )
		objectBoundingRect.Inflate( RRealSize( (kSelectionOutlineWidth+kSelectionOutlineDistanceFromObject)/2.F, (kSelectionOutlineWidth+kSelectionOutlineDistanceFromObject)/2.F ) );
	else
		objectBoundingRect.Inflate( RRealSize( -( kSelectionOutlineWidth+kSelectionOutlineDistanceFromObject ), -( kSelectionOutlineWidth+kSelectionOutlineDistanceFromObject ) ) );
	}
Esempio n. 4
0
// ****************************************************************************
//
//  Function Name:	RSingleSelection::GetRotateTrackingFeedbackBoundingRect( )
//
//  Description:		Gets the bounding rect of resize tracking feedback
//
//  Returns:			Bounding rect
//
//  Exceptions:		Memory
//
// ****************************************************************************
//
RRealRect RSingleSelection::GetRotateTrackingFeedbackBoundingRect( const R2dTransform& transform,
																						 const RRealPoint& rotationCenter,
																						 YAngle rotationAngle ) const
	{
	// Get the components bounding rect
	YComponentBoundingRect boundingRect = m_pSelectedObject->GetBoundingRect( );

	// Add the rotate operation
	boundingRect.RotateAboutPoint( rotationCenter, rotationAngle );

	// Get the objects feedback size
	return m_pSelectedObject->GetTrackingFeedbackBoundingRect( boundingRect.GetTransform( ) * transform );
	}
Esempio n. 5
0
// ****************************************************************************
//
//  Function Name:	RSingleSelection::GetResizeTrackingFeedbackBoundingRect( )
//
//  Description:		Gets the bounding rect of resize tracking feedback
//
//  Returns:			Bounding rect
//
//  Exceptions:		Memory
//
// ****************************************************************************
//
RRealRect RSingleSelection::GetResizeTrackingFeedbackBoundingRect( const R2dTransform& transform,
																						 const RRealPoint& scalingCenter,
																						 const RRealSize& scaleFactor,
																						 BOOLEAN fMaintainAspectRatio ) const
	{	
	// Get the components bounding rect
	YComponentBoundingRect boundingRect = m_pSelectedObject->GetBoundingRect( );

	// Constrain the scale factor
	RRealSize constrainedScaleFactor = m_pSelectedObject->ApplyResizeConstraint( scaleFactor );

	// Dont force to maintain aspect ratio if it really doesnt want to
	fMaintainAspectRatio = fMaintainAspectRatio && ::AreFloatsEqual( constrainedScaleFactor.m_dx, constrainedScaleFactor.m_dy );

	// Add the scale operation
	boundingRect.UnrotateAndScaleAboutPoint( scalingCenter, constrainedScaleFactor, m_pSelectedObject->GetMinimumSize( ), m_pSelectedObject->GetMaximumSize( ), fMaintainAspectRatio );

	// Get the objects feedback size
	return m_pSelectedObject->GetTrackingFeedbackBoundingRect( boundingRect.GetTransform( ) * transform );
	}
Esempio n. 6
0
// ****************************************************************************
//
//  Function Name:	RSingleSelection::DrawDragTrackingRect( )
//
//  Description:		Draws the selection tracking rect for dragging
//
//  Returns:			Nothing
//
//  Exceptions:		None
//
// ****************************************************************************
//
void RSingleSelection::DrawDragTrackingFeedback( RDrawingSurface& drawingSurface,
																 const R2dTransform& transform,
																 const RRealSize& offset ) const
	{
	if( m_pSelectedObject->GetComponentAttributes( ).IsMovable( ) )
		{
		// Setup the drawing surface
		drawingSurface.SetPenWidth( kSelectionOutlineWidth );
		drawingSurface.SetPenStyle( kSolidPen );

		// Get the components bounding rect
		YComponentBoundingRect boundingRect = m_pSelectedObject->GetBoundingRect( );

		// Add the translate operation
		boundingRect.Offset( offset );

		// Tell the object to draw tracking feedback
		m_pSelectedObject->RenderTrackingFeedback( drawingSurface, boundingRect.GetTransform( ) * transform, *GetView( ) );
		}
	}
Esempio n. 7
0
void RSingleSelection::DrawRotateTrackingFeedback( RDrawingSurface& drawingSurface,
																	const R2dTransform& transform,
																	const RRealPoint& rotationCenter,
																	YAngle rotationAngle ) const
	{
	if( m_pSelectedObject->GetComponentAttributes( ).IsRotatable( ) )
		{
		// Setup the drawing surface
		drawingSurface.SetPenWidth( kSelectionOutlineWidth );
		drawingSurface.SetPenStyle( kSolidPen );

		// Get the components bounding rect
		YComponentBoundingRect boundingRect = m_pSelectedObject->GetBoundingRect( );

		// Add the rotate operation
		boundingRect.RotateAboutPoint( rotationCenter, rotationAngle );

		// Tell the object to draw tracking feedback
		m_pSelectedObject->RenderTrackingFeedback( drawingSurface, boundingRect.GetTransform( ) * transform, *GetView( ) );
		}
	}
Esempio n. 8
0
// ****************************************************************************
//
//  Function Name:	RCompositeSelection::SetResizeCursor( )
//
//  Description:		Calculates which resize cursor to use, and sets it
//
//  Returns:			Nothing
//
//  Exceptions:		None
//
// ****************************************************************************
//
void RCompositeSelection::SetResizeCursor( RSingleSelection* pHitObject, EHitLocation eHitLocation ) const
{
    // Get the center point of the object
    YComponentBoundingRect boundingRect;
    pHitObject->GetObjectBoundingRect( boundingRect );
    RRealPoint centerPoint = boundingRect.GetCenterPoint( );

    // Create a new bounding rect that is a square.
    YComponentBoundingRect squareRect = boundingRect;
    RRealSize size = squareRect.WidthHeight( );
    if( size.m_dx > size.m_dy )
        squareRect.UnrotateAndScaleAboutPoint( centerPoint, RRealSize( size.m_dy / size.m_dx, 1.0 ) );
    else
        squareRect.UnrotateAndScaleAboutPoint( centerPoint, RRealSize( 1.0, size.m_dx / size.m_dy ) );

    // Select a point from this square based on the hit location
    RRealPoint point;
    switch( eHitLocation )
    {
    case kLeftResizeHandle :
        ::midpoint( point, squareRect.m_TopLeft,squareRect.m_BottomLeft);
        break;

    case kTopResizeHandle :
        ::midpoint( point, squareRect.m_TopLeft,squareRect.m_TopRight);
        break;

    case kRightResizeHandle :
        ::midpoint( point, squareRect.m_TopRight,squareRect.m_BottomRight);
        break;

    case kBottomResizeHandle :
        ::midpoint( point, squareRect.m_BottomLeft,squareRect.m_BottomRight);
        break;

    case kTopLeftResizeHandle :
        point = squareRect.m_TopLeft;
        break;

    case kTopRightResizeHandle :
        point = squareRect.m_TopRight;
        break;

    case kBottomLeftResizeHandle :
        point = squareRect.m_BottomLeft;
        break;

    case kBottomRightResizeHandle :
        point = squareRect.m_BottomRight;
        break;

    default :
        TpsAssertAlways( "Invalid hit location in RCompositeSelection::SetResizeCursor( )." );
    }

    // Calculate the angle between a vertical line through the square center and
    // a line connecting the calculatated point and the square center.
    YAngle angle = ::atan2( (YFloatType)( point.m_x - centerPoint.m_x ), (YFloatType)( centerPoint.m_y - point.m_y ) );

    // atan2 returns an angle between PI and -PI. Convert this to an angle between 0 and 2PI
    if( angle < 0 )
        angle += ( 2 * kPI );

    // Select a cursor. We have 4 cursors to choose from, rotated in 45 degree
    // increments. Divide the angle by 45 deg. and use the resulting octant
    // number mod 4 to index into an array of cursor ids.
    int nOctant = ::Round( angle / ( kPI / 4 ) );

    TpsAssert( nOctant >= 0 && nOctant <= 8, "Invalid octant." );

#ifdef _WINDOWS
    static LPCTSTR cursorArray[ 4 ] = { IDC_SIZENS, IDC_SIZENESW, IDC_SIZEWE, IDC_SIZENWSE };
#else
    // REVIEW: define cursors for Mac
#endif

    // Set the cursor
    ::GetCursorManager( ).SetCursor( cursorArray[ nOctant % 4 ] );
}