r17122 by fschmid - Fixed editing of images inside groups.
scribus-commit
scribus-commit at lists.scribus.net
Fri Dec 23 20:42:25 UTC 2011
Author: fschmid
Date: Fri Dec 23 20:42:25 2011
New Revision: 17122
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17122
Log:
Fixed editing of images inside groups.
Modified:
trunk/Scribus/scribus/canvasgesture_resize.cpp
trunk/Scribus/scribus/canvasmode.cpp
trunk/Scribus/scribus/canvasmode.h
trunk/Scribus/scribus/canvasmode_edit.cpp
Modified: trunk/Scribus/scribus/canvasgesture_resize.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17122&path=/trunk/Scribus/scribus/canvasgesture_resize.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasgesture_resize.cpp (original)
+++ trunk/Scribus/scribus/canvasgesture_resize.cpp Fri Dec 23 20:42:25 2011
@@ -271,8 +271,17 @@
}
else if (currItem->itemType() == PageItem::ImageFrame && currItem->PictureIsAvailable)
{
- double dx = ((newBounds.x() + m_extraX) - currItem->xPos());
- double dy = ((newBounds.y() + m_extraY) - currItem->yPos());
+ QTransform mm = currItem->getTransform();
+ QPointF itPos = mm.map(QPointF(0, 0));
+ double dx = ((newBounds.x() + m_extraX) - itPos.x());
+ double dy = ((newBounds.y() + m_extraY) - itPos.y());
+ if (currItem->Parent != 0)
+ {
+ double sx, sy;
+ getScaleFromMatrix(mm, sx, sy);
+ dx /= sx;
+ dy /= sy;
+ }
double cosa = cos(currItem->rotation() * M_PI / 180.0);
double sina = sin(currItem->rotation() * M_PI / 180.0);
double xoff = -(cosa*dx + sina*dy);
Modified: trunk/Scribus/scribus/canvasmode.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17122&path=/trunk/Scribus/scribus/canvasmode.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode.cpp (original)
+++ trunk/Scribus/scribus/canvasmode.cpp Fri Dec 23 20:42:25 2011
@@ -215,7 +215,7 @@
viewmode->drawFramelinksWithContents = false;
}
-void CanvasMode::drawSelectionHandles(QPainter *psx, QRectF selectionRect, bool background, bool insideGroup)
+void CanvasMode::drawSelectionHandles(QPainter *psx, QRectF selectionRect, bool background, bool insideGroup, double sx, double sy)
{
m_pen["handle"] = QPen(PrefsManager::instance()->appPrefs.displayPrefs.frameColor, 1.0, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
m_pen["handle"].setCosmetic(true);
@@ -223,7 +223,9 @@
m_pen["selection-group-inside"].setCosmetic(true);
QPen ba = QPen(Qt::white, 3.0, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
ba.setCosmetic(true);
- const double markWidth = 4.0 / m_canvas->scale();
+ double markWidth = 4.0 / m_canvas->scale();
+ if (insideGroup)
+ markWidth /= qMax(sx, sy);
QRectF handleRect = QRectF(0, 0, markWidth, markWidth);
double x = selectionRect.x();
double y = selectionRect.y();
@@ -356,6 +358,8 @@
if (currItem->Parent != NULL)
{
QTransform t = currItem->getCombinedTransform();
+ double sx, sy;
+ getScaleFromMatrix(t, sx, sy);
psx->setTransform(t, true);
w = currItem->visualWidth();
h = currItem->visualHeight();
@@ -366,12 +370,12 @@
QRectF drRect = QRectF(x, y, w, h).normalized();
psx->drawRect(drRect);
if (drawHandles)
- drawSelectionHandles(psx, QRectF(x, y, w, h), true, true);
+ drawSelectionHandles(psx, QRectF(x, y, w, h), true, true, sx, sy);
psx->setPen(m_pen["selection-group-inside"]);
psx->setBrush(m_brush["selection-group-inside"]);
psx->drawRect(drRect);
if (drawHandles)
- drawSelectionHandles(psx, QRectF(x, y, w, h), false, true);
+ drawSelectionHandles(psx, QRectF(x, y, w, h), false, true, sx, sy);
}
else
{
Modified: trunk/Scribus/scribus/canvasmode.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17122&path=/trunk/Scribus/scribus/canvasmode.h
==============================================================================
--- trunk/Scribus/scribus/canvasmode.h (original)
+++ trunk/Scribus/scribus/canvasmode.h Fri Dec 23 20:42:25 2011
@@ -118,7 +118,7 @@
/** Draws the handles for the selection marker */
- void drawSelectionHandles(QPainter *psx, QRectF selectionRect, bool background, bool insideGroup = false);
+ void drawSelectionHandles(QPainter *psx, QRectF selectionRect, bool background, bool insideGroup = false, double sx = 1.0, double sy = 1.0);
/** Draws the regular selection marker */
void drawSelection(QPainter* psx, bool drawHandles);
/** Draws an outline of selected items */
Modified: trunk/Scribus/scribus/canvasmode_edit.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17122&path=/trunk/Scribus/scribus/canvasmode_edit.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_edit.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_edit.cpp Fri Dec 23 20:42:25 2011
@@ -145,6 +145,8 @@
PageItem* currItem;
if (GetItem(&currItem))
{
+ QPen pp = QPen(Qt::blue, 1.0 / m_canvas->scale(), Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
+ pp.setCosmetic(true);
PageItem_TextFrame* textframe = currItem->asTextFrame();
if (textframe)
{
@@ -165,10 +167,11 @@
}
else if (currItem->asImageFrame())
{
+ QTransform mm = currItem->getTransform();
p->save();
- p->setTransform(currItem->getTransform(), true);
- p->setPen(QPen(Qt::blue, 1.0 / m_canvas->scale(), Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
+ p->setTransform(mm, true);
p->setClipRect(QRectF(0.0, 0.0, currItem->width(), currItem->height()));
+ p->setPen(pp);
p->setBrush(QColor(0,0,255,10));
p->setRenderHint(QPainter::Antialiasing);
p->translate(currItem->imageXOffset()*currItem->imageXScale(), currItem->imageYOffset()*currItem->imageYScale());
@@ -176,7 +179,9 @@
p->drawRect(0, 0, currItem->OrigW*currItem->imageXScale(), currItem->OrigH*currItem->imageYScale());
p->translate(currItem->OrigW*currItem->imageXScale() / 2, currItem->OrigH*currItem->imageYScale() / 2);
p->scale(1.0 / m_canvas->scale(), 1.0 / m_canvas->scale());
- p->setPen(QPen(Qt::blue, 1.0, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
+ QPen pps = QPen(Qt::blue, 1.0, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
+ pps.setCosmetic(true);
+ p->setPen(pps);
p->drawLine(-10, 0, 10, 0);
p->drawLine(0, -10, 0, 10);
p->setBrush(QColor(0,0,255,70));
@@ -365,10 +370,14 @@
QTransform ro;
ro.rotate(-currItem->rotation());
QPointF rota = ro.map(QPointF(newX-Mxp,newY-Myp));
- currItem->moveImageInFrame(rota.x()/currItem->imageXScale(), rota.y()/currItem->imageYScale());
+ QTransform mm = currItem->getTransform();
+ double sx, sy;
+ getScaleFromMatrix(mm, sx, sy);
+ currItem->moveImageInFrame((rota.x() / sx) / currItem->imageXScale(), (rota.y() / sy) / currItem->imageYScale());
m_canvas->displayXYHUD(m->globalPos(), currItem->imageXOffset() * currItem->imageXScale(), currItem->imageYOffset() * currItem->imageYScale());
}
currItem->update();
+ m_view->DrawNew();
Mxp = newX;
Myp = newY;
}
More information about the scribus-commit
mailing list