Fix bug related with maximum and minimum scrool value.

This commit is contained in:
Luis Lucas
2015-02-22 02:39:01 +00:00
parent 3bc693515b
commit b441e32009
+37 -22
View File
@@ -72,14 +72,29 @@ QSize SubWindowHandle::getScrollSize()
Void SubWindowHandle::adjustScrollBarByOffset( QPoint Offset )
{
QPoint cLastScroll = m_cCurrScroll;
m_cCurrScroll.setX(int( cLastScroll.x() + Offset.x() ));
m_cCurrScroll.setY(int( cLastScroll.y() + Offset.y() ));
QScrollBar *scrollBarH, *scrollBarV;
Int valueX, valueY;
valueX = int( cLastScroll.x() + Offset.x() );
valueY = int( cLastScroll.y() + Offset.y() );
scrollBarH = horizontalScrollBar();
if( valueX > scrollBarH->maximum() )
valueX = scrollBarH->maximum();
if( valueX < scrollBarH->minimum() )
valueX = scrollBarH->minimum();
m_cCurrScroll.setX(valueX);
scrollBarV = verticalScrollBar();
if( valueY > scrollBarV->maximum() )
valueY = scrollBarV->maximum();
if( valueY < scrollBarV->minimum() )
valueY = scrollBarV->minimum();
m_cCurrScroll.setY( valueY );
// Update window scroll
QScrollBar *scrollBar = horizontalScrollBar();
scrollBar->setValue( m_cCurrScroll.x() );
scrollBar = verticalScrollBar();
scrollBar->setValue( m_cCurrScroll.y() );
scrollBarH->setValue( m_cCurrScroll.x() );
scrollBarV->setValue( m_cCurrScroll.y() );
}
// This function was developed with help of the schematics presented in
@@ -87,43 +102,43 @@ Void SubWindowHandle::adjustScrollBarByOffset( QPoint Offset )
Void SubWindowHandle::adjustScrollBarByScale( Double scale, QPoint center )
{
QPoint cLastScroll = m_cCurrScroll;
QScrollBar *scrollBar = horizontalScrollBar();
QScrollBar *scrollBarH, *scrollBarV;
scrollBarH = horizontalScrollBar();
if( center.isNull() )
{
m_cCurrScroll.setX(int( scale * cLastScroll.x() + ( ( scale - 1 ) * scrollBar->pageStep() / 2 ) ));
m_cCurrScroll.setX(int( scale * cLastScroll.x() + ( ( scale - 1 ) * scrollBarH->pageStep() / 2 ) ));
}
else
{
Int x = center.x() - cLastScroll.x();
Int value = int( scale * cLastScroll.x() + ( ( scale - 1 ) * x ) );
if( value > scrollBar->maximum() )
value = scrollBar->maximum();
if( value < scrollBar->minimum() )
value = scrollBar->minimum();
if( value > scrollBarH->maximum() )
value = scrollBarH->maximum();
if( value < scrollBarH->minimum() )
value = scrollBarH->minimum();
m_cCurrScroll.setX(value);
}
scrollBar = verticalScrollBar();
scrollBarV = verticalScrollBar();
if( center.isNull() )
{
m_cCurrScroll.setY(int( scale * cLastScroll.y() + ( ( scale - 1 ) * scrollBar->pageStep() / 2 ) ));
m_cCurrScroll.setY(int( scale * cLastScroll.y() + ( ( scale - 1 ) * scrollBarV->pageStep() / 2 ) ));
}
else
{
Int y = center.y() - cLastScroll.y();
Int value = int( scale * cLastScroll.y() + ( ( scale - 1 ) * y ) );
if( value > scrollBar->maximum() )
value = scrollBar->maximum();
if( value < scrollBar->minimum() )
value = scrollBar->minimum();
if( value > scrollBarV->maximum() )
value = scrollBarV->maximum();
if( value < scrollBarV->minimum() )
value = scrollBarV->minimum();
m_cCurrScroll.setY(value);
}
// Update window scroll
scrollBar = horizontalScrollBar();
scrollBar->setValue( m_cCurrScroll.x() );
scrollBar = verticalScrollBar();
scrollBar->setValue( m_cCurrScroll.y() );
scrollBarH->setValue( m_cCurrScroll.x() );
scrollBarV->setValue( m_cCurrScroll.y() );
}