r13926 by jghali - canvas gradient edit mode : remove weird use of right click to move gradient end point
scribus-commit
scribus-commit at lists.scribus.net
Thu Aug 27 00:55:18 CEST 2009
Revision: 13926
Author: jghali
Date: 2009-08-26T22:52:17.446695Z
Commit message: canvas gradient edit mode : remove weird use of right click to move gradient end point
Changeset:
M /branches/Version135/Scribus/scribus/canvasmode_editgradient.h
M /branches/Version135/Scribus/scribus/canvasmode_editgradient.cpp
Diffs:
Index: scribus/canvasmode_editgradient.cpp
===================================================================
--- scribus/canvasmode_editgradient.cpp (revision 13925)
+++ scribus/canvasmode_editgradient.cpp (revision 13926)
@@ -61,6 +61,7 @@
CanvasMode_EditGradient::CanvasMode_EditGradient(ScribusView* view) : CanvasMode(view), m_ScMW(view->m_ScMW)
{
Mxp = Myp = -1;
+ m_gradientPoint = noPointDefined;
}
inline bool CanvasMode_EditGradient::GetItem(PageItem** pi)
@@ -171,6 +172,9 @@
// emit MousePos(m->x()/m_canvas->scale(),// + m_doc->minCanvasCoordinate.x(),
// m->y()/m_canvas->scale()); // + m_doc->minCanvasCoordinate.y());
+ if (m_gradientPoint == noPointDefined)
+ return;
+
if (m_canvas->m_viewMode.m_MouseButtonPressed)
{
PageItem *currItem = m_doc->m_Selection->itemAt(0);
@@ -179,12 +183,12 @@
double dx = fabs(Mxp - newX) + 5.0 / m_canvas->scale();
double dy = fabs(Myp - newY) + 5.0 / m_canvas->scale();
FPoint np(Mxp - newX, Myp - newY, 0, 0, currItem->rotation(), 1, 1, true);
- if (m->buttons() & Qt::LeftButton)
+ if (m_gradientPoint == useGradientStart)
{
currItem->GrStartX -= np.x(); // (Mxp - newX); // / m_canvas->scale();
currItem->GrStartY -= np.y(); // (Myp - newY); // / m_canvas->scale();
}
- if (m->buttons() & Qt::RightButton)
+ if (m_gradientPoint == useGradientEnd)
{
currItem->GrEndX -= np.x(); // (Mxp - newX); // / m_canvas->scale();
currItem->GrEndY -= np.y(); // (Myp - newY); // / m_canvas->scale();
@@ -209,6 +213,7 @@
m_doc->leaveDrag = false;
m->accept();
m_view->registerMousePress(m->globalPos());
+ m_gradientPoint = noPointDefined;
Mxp = mousePointDoc.x(); //m->x();
Myp = mousePointDoc.y(); //m->y();
if (m->button() == Qt::MidButton)
@@ -218,6 +223,18 @@
m_view->DrawNew();
return;
}
+ QMatrix itemMatrix;
+ PageItem *currItem = m_doc->m_Selection->itemAt(0);
+ itemMatrix.translate(currItem->xPos(), currItem->yPos());
+ itemMatrix.rotate(currItem->rotation());
+ QPointF gradientStart(currItem->GrStartX, currItem->GrStartY);
+ gradientStart = itemMatrix.map(gradientStart);
+ QPointF gradientEnd(currItem->GrEndX, currItem->GrEndY);
+ gradientEnd = itemMatrix.map(gradientEnd);
+ if (m_canvas->hitsCanvasPoint(m->globalPos(), gradientStart))
+ m_gradientPoint = useGradientStart;
+ else if (m_canvas->hitsCanvasPoint(m->globalPos(), gradientEnd))
+ m_gradientPoint = useGradientEnd;
m_canvas->m_viewMode.m_MouseButtonPressed = true;
qApp->changeOverrideCursor(QCursor(Qt::CrossCursor));
}
@@ -231,5 +248,6 @@
m_canvas->m_viewMode.m_MouseButtonPressed = false;
m_canvas->resetRenderMode();
m->accept();
+ m_gradientPoint = noPointDefined;
// m_view->stopDragTimer();
}
Index: scribus/canvasmode_editgradient.h
===================================================================
--- scribus/canvasmode_editgradient.h (revision 13925)
+++ scribus/canvasmode_editgradient.h (revision 13926)
@@ -49,12 +49,21 @@
virtual void drawControls(QPainter* p);
private:
+
+ typedef enum
+ {
+ noPointDefined,
+ useGradientStart,
+ useGradientEnd
+ } eGradientPoint;
+
inline bool GetItem(PageItem** pi);
double Mxp, Myp;
ScribusMainWindow* m_ScMW;
bool m_cursorVisible;
bool m_lastPosWasOverGuide;
+ eGradientPoint m_gradientPoint;
};
More information about the scribus-commit
mailing list