// **************************************************************************** // // 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( ) ); } }
// **************************************************************************** // // 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( ) ); } }
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( ) ); } }
// **************************************************************************** // // Function Name: RSingleSelection::Render( ) // // Description: Draws the selection rect and handles // // Returns: Nothing // // Exceptions: Memory // // **************************************************************************** // void RSingleSelection::Render( RDrawingSurface& drawingSurface, const R2dTransform& transform, const RIntRect& rcRender, BOOLEAN fRenderIfLocked ) const { // Get the component attributes const RComponentAttributes& componentAttributes = m_pSelectedObject->GetComponentAttributes( ); BOOLEAN fIsLocked = componentAttributes.IsLocked( ); if( fRenderIfLocked || !fIsLocked ) { // Set surface attributes drawingSurface.SetPenWidth( kSelectionOutlineWidth ); drawingSurface.SetPenStyle( kSolidPen ); RRealRect resizeHandleRect; // Draw the resize handles if( componentAttributes.IsResizable( FALSE ) ) { RArray<RRealRect> rectList; RRealSize scaleFactor( kDummyScale, kDummyScale ); scaleFactor = m_pSelectedObject->ApplyResizeConstraint( scaleFactor ); GetResizeSelectionHandle( resizeHandleRect, transform, kTopLeftResizeHandle, TRUE ); rectList.InsertAtEnd( resizeHandleRect ); GetResizeSelectionHandle( resizeHandleRect, transform, kTopRightResizeHandle, TRUE ); rectList.InsertAtEnd( resizeHandleRect ); GetResizeSelectionHandle( resizeHandleRect, transform, kBottomRightResizeHandle, TRUE ); rectList.InsertAtEnd( resizeHandleRect ); GetResizeSelectionHandle( resizeHandleRect, transform, kBottomLeftResizeHandle, TRUE ); rectList.InsertAtEnd( resizeHandleRect ); if ( !AreFloatsEqual( scaleFactor.m_dy, kConstrainedScale ) ) { GetResizeSelectionHandle( resizeHandleRect, transform, kBottomResizeHandle, TRUE ); rectList.InsertAtEnd( resizeHandleRect ); GetResizeSelectionHandle( resizeHandleRect, transform, kTopResizeHandle, TRUE ); rectList.InsertAtEnd( resizeHandleRect ); } if ( !AreFloatsEqual( scaleFactor.m_dx, kConstrainedScale ) ) { GetResizeSelectionHandle( resizeHandleRect, transform, kRightResizeHandle, TRUE ); rectList.InsertAtEnd( resizeHandleRect ); GetResizeSelectionHandle( resizeHandleRect, transform, kLeftResizeHandle, TRUE ); rectList.InsertAtEnd( resizeHandleRect ); } RArray<RRealRect>::YIterator iterator = rectList.Start( ); RArray<RRealRect>::YIterator iteratorEnd = rectList.End( ); if( fIsLocked ) { while ( iterator != iteratorEnd ) drawingSurface.FrameRectangle( *iterator++ ); } else { while ( iterator != iteratorEnd ) drawingSurface.FillRectangle( *iterator++ ); } } // Draw the rotate line and handle if( componentAttributes.IsRotatable( ) ) DrawRotateHandle( drawingSurface, transform, rcRender ); // Draw the selection frame m_pSelectedObject->DrawSelectionFrame( drawingSurface, transform ); } }