Fix buggy painting of selected area in view area. Improve limits of selected area during selection procedure.
This commit is contained in:
1 parent
dc27998192
commit
f14c5c09b7
1 file changed
+10
-9
+10
-9
@@ -436,7 +436,7 @@ void ViewArea::paintEvent( QPaintEvent *event )
|
|||||||
QRect imgr = viewToWindow( QRect( 0, 0, m_pixmap.width(), m_pixmap.height() ) );
|
QRect imgr = viewToWindow( QRect( 0, 0, m_pixmap.width(), m_pixmap.height() ) );
|
||||||
|
|
||||||
myPath.addRect( imgr );
|
myPath.addRect( imgr );
|
||||||
myPath.addRect( sr/*m_selectedArea*/);
|
myPath.addRect( sr); //m_selectedArea
|
||||||
painter.drawPath( myPath );
|
painter.drawPath( myPath );
|
||||||
|
|
||||||
// 2) Draw the selection rectangle
|
// 2) Draw the selection rectangle
|
||||||
@@ -641,7 +641,7 @@ void ViewArea::mouseMoveEvent( QMouseEvent *event )
|
|||||||
{
|
{
|
||||||
// If the selection is only vertical or horizontal then we have one
|
// If the selection is only vertical or horizontal then we have one
|
||||||
// of the dimentions null.
|
// of the dimentions null.
|
||||||
if( actualPos.x() == m_lastPos.x() || actualPos.y() == m_lastPos.y() )
|
if( actualPos.x() == m_lastPos.x() && actualPos.y() == m_lastPos.y() )
|
||||||
{
|
{
|
||||||
m_selectedArea = QRect();
|
m_selectedArea = QRect();
|
||||||
}
|
}
|
||||||
@@ -651,14 +651,14 @@ void ViewArea::mouseMoveEvent( QMouseEvent *event )
|
|||||||
// From left to right
|
// From left to right
|
||||||
if( m_lastPos.x() < actualPos.x() )
|
if( m_lastPos.x() < actualPos.x() )
|
||||||
{
|
{
|
||||||
QPoint bottomR = actualPos - QPoint( 1, 1 );
|
QPoint bottomR = actualPos;// - QPoint( 1, 1 );
|
||||||
m_selectedArea = QRect( m_lastPos, bottomR );
|
m_selectedArea = QRect( m_lastPos, bottomR );
|
||||||
}
|
}
|
||||||
// From right to left
|
// From right to left
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QPoint topL( actualPos.x(), m_lastPos.y() );
|
QPoint topL( actualPos.x(), m_lastPos.y() );
|
||||||
QPoint bottomR( m_lastPos.x() - 1, actualPos.y() - 1 );
|
QPoint bottomR( m_lastPos.x(), actualPos.y() );
|
||||||
|
|
||||||
m_selectedArea = QRect( topL, bottomR );
|
m_selectedArea = QRect( topL, bottomR );
|
||||||
}
|
}
|
||||||
@@ -670,13 +670,13 @@ void ViewArea::mouseMoveEvent( QMouseEvent *event )
|
|||||||
if( m_lastPos.x() < actualPos.x() )
|
if( m_lastPos.x() < actualPos.x() )
|
||||||
{
|
{
|
||||||
QPoint topL( m_lastPos.x(), actualPos.y() );
|
QPoint topL( m_lastPos.x(), actualPos.y() );
|
||||||
QPoint bottomR( actualPos.x() - 1, m_lastPos.y() - 1 );
|
QPoint bottomR( actualPos.x(), m_lastPos.y() );
|
||||||
m_selectedArea = QRect( topL, bottomR );
|
m_selectedArea = QRect( topL, bottomR );
|
||||||
}
|
}
|
||||||
// From right to left
|
// From right to left
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QPoint bottomR = m_lastPos - QPoint( 1, 1 );
|
QPoint bottomR = m_lastPos;// - QPoint( 1, 1 );
|
||||||
m_selectedArea = QRect( actualPos, bottomR );
|
m_selectedArea = QRect( actualPos, bottomR );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -702,15 +702,16 @@ void ViewArea::mouseMoveEvent( QMouseEvent *event )
|
|||||||
m_selectedArea &= QRect( 0, 0, m_pixmap.width(), m_pixmap.height() );
|
m_selectedArea &= QRect( 0, 0, m_pixmap.width(), m_pixmap.height() );
|
||||||
|
|
||||||
// Update only the united area
|
// Update only the united area
|
||||||
updateRect = updateRect.united( viewToWindow( m_selectedArea ) );
|
// updateRect = updateRect.united( viewToWindow( m_selectedArea ) );
|
||||||
|
|
||||||
// "When rendering with a one pixel wide pen the QRect's
|
// "When rendering with a one pixel wide pen the QRect's
|
||||||
// boundary line will be rendered to the right and below the
|
// boundary line will be rendered to the right and below the
|
||||||
// mathematical rectangle's boundary line.", in QT4 doc.
|
// mathematical rectangle's boundary line.", in QT4 doc.
|
||||||
// Our selection pen width is 1, let's adjust the rendering area.
|
// Our selection pen width is 1, let's adjust the rendering area.
|
||||||
updateRect.adjust( 0, 0, 1, 1 );
|
// updateRect.adjust( 0, 0, 1, 1 );
|
||||||
|
|
||||||
update( updateRect.normalized() );
|
// update( updateRect.normalized() );
|
||||||
|
update();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user