From koffice-devel Thu Oct 09 04:13:12 2003 From: Thorsten Zachmann Date: Thu, 09 Oct 2003 04:13:12 +0000 To: koffice-devel Subject: Re: [PATCH] Fix for kpresenter bug #63032 X-MARC-Message: https://marc.info/?l=koffice-devel&m=106567274419479 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--Boundary-00=_YBOh//+KwlDB3wl" --Boundary-00=_YBOh//+KwlDB3wl Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Hello Peter and all, > > I do not know how to fix this. > > > > I think there are two possibilities to solve this problem as the new > > behavior is not realy much better than the old one. > > > > 1. fix remaining problems (no idea at the moment how it could be done) > > 2. revert the patch > > > > What do you thing should be done. > > Ok here's a new patch that should (hopefully ;)) fix your last problems... > (it contains your patch too) > > Ok, to commit? ( and please test before answering ;)) As I came home yesterday I also looked for a solution and found one (patch is attached). So now we have two patches. My patch moves the deciding of the "Snap to Grid" into the moveObject function, in calculating the dx,dy so that it will snap to the grid. I thing that way it is easy to understand what is done. What do you think? I haven't tested your patch yet so I can't say if it works now. But I will do so today. Can you also please test my patch, than we can decide which patch is better and apply that one. Lets test. Thorsten --Boundary-00=_YBOh//+KwlDB3wl Content-Type: text/x-diff; charset="iso-8859-1"; name="patch50" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="patch50" Index: kprcanvas.cc =================================================================== RCS file: /home/kde/koffice/kpresenter/kprcanvas.cc,v retrieving revision 1.373 diff -u -3 -p -r1.373 kprcanvas.cc --- kprcanvas.cc 5 Oct 2003 18:19:29 -0000 1.373 +++ kprcanvas.cc 9 Oct 2003 03:50:31 -0000 @@ -1619,22 +1619,9 @@ void KPrCanvas::mouseMoveEvent( QMouseEv else return; } else if ( mousePressed ) { - int mx = e->x()+diffx(); - int my = e->y()+diffy(); - if ( m_view->kPresenterDoc()->snapToGrid() ) - { - mx = applyGridOnPosX( mx ); - my = applyGridOnPosY( my ); - } switch ( toolEditMode ) { case TEM_MOUSE: { drawContour = TRUE; - if ( m_view->kPresenterDoc()->snapToGrid() ) - { - oldMx = applyGridOnPosX( oldMx ); - oldMy = applyGridOnPosY( oldMy ); - } - if ( modType == MT_NONE ) { if ( m_tmpVertHelpline !=-1 || m_tmpHorizHelpline !=-1) { @@ -1661,11 +1648,22 @@ void KPrCanvas::mouseMoveEvent( QMouseEv int y = e->y() + diffy(); moveObject( x - m_origPos.x(), y - m_origPos.y(), false ); } else if ( modType != MT_NONE && resizeObjNum ) { - resizeObject( modType, mx - m_origPos.x(), my - m_origPos.y() ); - } + int mx = e->x()+diffx(); + int my = e->y()+diffy(); + + if ( m_view->kPresenterDoc()->snapToGrid() ) + { + mx = applyGridOnPosX( mx ); + my = applyGridOnPosY( my ); + oldMx = applyGridOnPosX( oldMx ); + oldMy = applyGridOnPosY( oldMy ); + } - oldMx = e->x()+diffx(); - oldMy = e->y()+diffy(); + resizeObject( modType, mx - oldMx, my - oldMy ); + + oldMx = e->x()+diffx(); + oldMy = e->y()+diffy(); + } } break; case TEM_ZOOM : { if ( drawRubber ) { @@ -5472,80 +5470,93 @@ void KPrCanvas::resizeObject( ModifyType dx=0; if( (point.y()+dy) <(pageRect.top()-1)) dy=0; + dx = applyGrid( KoPoint(objRect.left() + dx, 0) ).x() - objRect.left(); + dy = applyGrid( KoPoint(0, objRect.top() + dy) ).y() - objRect.top(); if ( keepRatio && ratio != 0.0 ) calcRatio( dx, dy, _modType, ratio ); - kpobject->setSize(m_origBRect.width() + dx, m_origBRect.height() + dy); + kpobject->resizeBy( -dx, -dy ); if ( objSize.width() != (kpobject->getSize()).width() ) - kpobject->setOrig(m_origBRect.x() - dx, kpobject->getOrig().y()); + kpobject->moveBy( KoPoint( dx, 0 ) ); if ( objSize.height() != (kpobject->getSize()).height() ) - kpobject->setOrig(kpobject->getOrig().x(), m_origBRect.y() - dy); + kpobject->moveBy( KoPoint( 0, dy ) ); } break; case MT_RESIZE_LF: { dy = 0; if( (point.x()+dx) <(pageRect.left()-1)) dx=0; + dx = applyGrid( KoPoint(objRect.left() + dx, 0) ).x() - objRect.left(); if ( keepRatio && ratio != 0.0 ) calcRatio( dx, dy, _modType, ratio ); - kpobject->setSize(m_origBRect.width() + dx, m_origBRect.height() + dy); + kpobject->resizeBy( -dx, -dy ); if ( objSize != kpobject->getSize() ) - kpobject->setOrig(m_origBRect.x() - dx, kpobject->getOrig().y()); + kpobject->moveBy( KoPoint( dx, 0 ) ); } break; case MT_RESIZE_LD: { if( (point.y()+objRect.height()+dy) > pageRect.height()) dy=0; if( (point.x()+dx) <(pageRect.left()-1)) dx=0; + dx = applyGrid( KoPoint(objRect.left() + dx, 0) ).x() - objRect.left(); + dy = applyGrid( KoPoint(0, objRect.bottom() + dy) ).y() - objRect.bottom(); if ( keepRatio && ratio != 0.0 ) calcRatio( dx, dy, _modType, ratio ); - kpobject->setSize(m_origBRect.width() + dx, m_origBRect.height() + dy); + kpobject->resizeBy( -dx, dy ); if ( objSize.width() != (kpobject->getSize()).width() ) - kpobject->setOrig(m_origBRect.x() - dx, kpobject->getOrig().y()); + kpobject->moveBy( KoPoint( dx, 0 ) ); } break; case MT_RESIZE_RU: { if( (point.x()+objRect.width()+dx) > pageRect.width()) dx=0; if( (point.y()+dy) <(pageRect.top()-1)) dy=0; + dx = applyGrid( KoPoint(objRect.right() + dx, 0) ).x() - objRect.right(); + dy = applyGrid( KoPoint(0, objRect.top() + dy) ).y() - objRect.top(); if ( keepRatio && ratio != 0.0 ) calcRatio( dx, dy, _modType, ratio ); - kpobject->setSize(m_origBRect.width() + dx, m_origBRect.height() + dy); + kpobject->resizeBy( dx, -dy ); if ( objSize.height() != (kpobject->getSize()).height() ) - kpobject->setOrig(kpobject->getOrig().x(), m_origBRect.y() - dy); + kpobject->moveBy( KoPoint( 0, dy ) ); } break; case MT_RESIZE_RT: { dy = 0; if( (point.x()+objRect.width()+dx) > pageRect.width()) dx=0; + dx = applyGrid( KoPoint(objRect.right() + dx, 0) ).x() - objRect.right(); if ( keepRatio && ratio != 0.0 ) calcRatio( dx, dy, _modType, ratio ); - kpobject->setSize(m_origBRect.width() + dx, m_origBRect.height() + dy); + kpobject->resizeBy( dx, dy ); } break; case MT_RESIZE_RD: { if( (point.y()+objRect.height()+dy) > pageRect.height()) dy=0; if( (point.x()+objRect.width()+dx) > pageRect.width()) dx=0; + dx = applyGrid( KoPoint(objRect.right() + dx, 0) ).x() - objRect.right(); + dy = applyGrid( KoPoint(0, objRect.bottom() + dy) ).y() - objRect.bottom(); if ( keepRatio && ratio != 0.0 ) calcRatio( dx, dy, _modType, ratio ); - kpobject->setSize(m_origBRect.width() + dx, m_origBRect.height() + dy); + kpobject->resizeBy( dx, dy ); } break; case MT_RESIZE_UP: { dx = 0; if( (point.y()+dy) <(pageRect.top()-1)) dy=0; + dy = applyGrid( KoPoint(0, objRect.top() + dy) ).y() - objRect.top(); if ( keepRatio && ratio != 0.0 ) calcRatio( dx, dy, _modType, ratio ); - kpobject->setSize(m_origBRect.width() + dx, m_origBRect.height() + dy); + kpobject->resizeBy( -dx, -dy ); if ( objSize != kpobject->getSize() ) - kpobject->setOrig(kpobject->getOrig().x(), m_origBRect.y() - dy); + kpobject->moveBy( KoPoint( 0, dy ) ); + } break; case MT_RESIZE_DN: { dx = 0; if( (point.y()+objRect.height()+dy) > pageRect.height()) dy=0; + dy = applyGrid( KoPoint(0, objRect.bottom() + dy) ).y() - objRect.bottom(); if ( keepRatio && ratio != 0.0 ) calcRatio( dx, dy, _modType, ratio ); - kpobject->setSize(m_origBRect.width() + dx, m_origBRect.height() + dy); + kpobject->resizeBy( dx, dy ); } break; default: break; } --Boundary-00=_YBOh//+KwlDB3wl Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ koffice-devel mailing list koffice-devel@mail.kde.org http://mail.kde.org/mailman/listinfo/koffice-devel --Boundary-00=_YBOh//+KwlDB3wl--