r17097 by fschmid - Final fixes for editing items inside groups. Correct resizing inside flipped groups.

scribus-commit scribus-commit at lists.scribus.net
Sun Dec 18 11:03:18 UTC 2011


Author: fschmid
Date: Sun Dec 18 11:03:17 2011
New Revision: 17097

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17097
Log:
Final fixes for editing items inside groups. Correct resizing inside flipped groups.

Modified:
    trunk/Scribus/scribus/canvasgesture_resize.cpp
    trunk/Scribus/scribus/canvasmode.cpp
    trunk/Scribus/scribus/pageitem.cpp
    trunk/Scribus/scribus/ui/propertiespalette_group.cpp
    trunk/Scribus/scribus/ui/propertiespalette_shape.cpp
    trunk/Scribus/scribus/ui/propertiespalette_xyz.cpp

Modified: trunk/Scribus/scribus/canvasgesture_resize.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17097&path=/trunk/Scribus/scribus/canvasgesture_resize.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasgesture_resize.cpp (original)
+++ trunk/Scribus/scribus/canvasgesture_resize.cpp Sun Dec 18 11:03:17 2011
@@ -73,7 +73,17 @@
 		m.scale(m_scaleX, m_scaleY);
 		m_bounds = m.mapRect(m_bounds);
 		m_bounds.moveTopLeft(itPos);
-		m_rotation = -getRotationDFromMatrix(mm);
+		if (mm.m11() < 0)
+		{
+			m_rotation = -getRotationDFromMatrix(mm) - 180.0;
+			m_bounds.translate(-currItem->visualWidth() * m_scaleX, 0);
+		}
+		else
+			m_rotation = -getRotationDFromMatrix(mm);
+		if (mm.m22() < 0)
+		{
+			m_bounds.translate(0, -currItem->visualHeight() * m_scaleY);
+		}
 		currItem->OldB2 = currItem->width();
 		currItem->OldH2 = currItem->height();
 		m_extraWidth = currItem->visualWidth() - currItem->width();
@@ -126,19 +136,35 @@
 	drawColor.setAlpha(64);
 	p->setBrush(drawColor);
 	p->drawRect(localRect);
+
+	if (m_origBounds != m_bounds)
+	{
+		if (m_doc->m_Selection->count() > 0)
+		{
+			p->setBrush(Qt::NoBrush);
+			QPen out = QPen(Qt::gray, 1.0 , Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
+			out.setCosmetic(true);
+			p->setPen(out);
+			PageItem *currItem = m_doc->m_Selection->itemAt(0);
+			QTransform m;
+			m.translate(localRect.x(), localRect.y());
+			m.scale(localRect.width() / currItem->width(), localRect.height() / currItem->height());
+			QTransform mm = currItem->getTransform();
+			if (mm.m11() < 0)
+			{
+				m.translate(currItem->width(), 0);
+				m.scale(-1, 1);
+			}
+			if (mm.m22() < 0)
+			{
+				m.translate(0, currItem->height());
+				m.scale(1, -1);
+			}
+			QPolygon clip = m.map(currItem->Clip);
+			currItem->DrawPolyL(p, clip);
+		}
+	}
 	p->restore();
-
-	if (m_origBounds != m_bounds)
-	{
-		QRectF n_bounds = m_bounds.normalized();
-		QRectF n_origBounds = m_origBounds.normalized();
-		p->save();
-		drawOutline(p, qAbs(n_bounds.width()) / qMax(qAbs(n_origBounds.width()), static_cast<qreal>(1.0)), 
-					qAbs(n_bounds.height()) / qMax(qAbs(n_origBounds.height()), static_cast<qreal>(1.0)),
-					n_bounds.left() - n_origBounds.left(),
-					n_bounds.top() - n_origBounds.top());
-		p->restore();
-	}
 }
 
 
@@ -316,6 +342,10 @@
 		currItem->moveBy(-dx, -dy, true);
 		currItem->setWidth(newBounds.width() / m_scaleX - m_extraWidth);
 		currItem->setHeight(newBounds.height() / m_scaleY - m_extraHeight);
+		if (mm.m11() < 0)
+			currItem->moveBy(-currItem->width(), 0);
+		if (mm.m22() < 0)
+			currItem->moveBy(0, -currItem->height());
 		currItem->updateClip();
 		if (currItem->isArc())
 		{
@@ -589,6 +619,60 @@
 	else
 	{
 		m_handle = m_canvas->frameHitTest(QPointF(point.x(), point.y()), m_doc->m_Selection->itemAt(0));
+		PageItem* currItem = m_doc->m_Selection->itemAt(0);
+		QTransform mm = currItem->getTransform();
+		if (mm.m11() < 0)
+		{
+			switch (m_handle)
+			{
+				case Canvas::NORTHEAST:
+					m_handle = Canvas::NORTHWEST;
+					break;
+				case Canvas::NORTHWEST:
+					m_handle = Canvas::NORTHEAST;
+					break;
+				case Canvas::EAST:
+					m_handle = Canvas::WEST;
+					break;
+				case Canvas::WEST:
+					m_handle = Canvas::EAST;
+					break;
+				case Canvas::SOUTHEAST:
+					m_handle = Canvas::SOUTHWEST;
+					break;
+				case Canvas::SOUTHWEST:
+					m_handle = Canvas::SOUTHEAST;
+					break;
+				default:
+					break;
+			}
+		}
+		if (mm.m22() < 0)
+		{
+			switch (m_handle)
+			{
+				case Canvas::NORTHEAST:
+					m_handle = Canvas::SOUTHEAST;
+					break;
+				case Canvas::NORTHWEST:
+					m_handle = Canvas::SOUTHWEST;
+					break;
+				case Canvas::SOUTH:
+					m_handle = Canvas::NORTH;
+					break;
+				case Canvas::NORTH:
+					m_handle = Canvas::SOUTH;
+					break;
+				case Canvas::SOUTHEAST:
+					m_handle = Canvas::SOUTHWEST;
+					break;
+				case Canvas::SOUTHWEST:
+					m_handle = Canvas::NORTHWEST;
+					break;
+				default:
+					break;
+			}
+		}
 	}
 	if (m_handle > 0)
 	{

Modified: trunk/Scribus/scribus/canvasmode.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17097&path=/trunk/Scribus/scribus/canvasmode.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode.cpp (original)
+++ trunk/Scribus/scribus/canvasmode.cpp Sun Dec 18 11:03:17 2011
@@ -454,8 +454,16 @@
 			QPointF itPos = itemTrans.map(QPointF(0, 0));
 			double gRot = getRotationDFromMatrix(itemTrans);
 			double m_scaleX, m_scaleY;
+			double addTransX = 0.0;
 			getScaleFromMatrix(itemTrans, m_scaleX, m_scaleY);
 			p->translate(itPos);
+			if (itemTrans.m11() < 0)
+			{
+				gRot -= 180.0;
+		//		p->translate(-currItem->visualWidth(), 0);
+		//		addTransX = -currItem->visualWidth() * (scalex * m_scaleX);
+		//		m_scaleX *= -1;
+			}
 			p->translate(deltax, deltay);
 			if (gRot != 0)
 			{
@@ -463,6 +471,7 @@
 				p->rotate(-gRot);
 			}
 			p->scale(scalex * m_scaleX, scaley * m_scaleY);
+			p->translate(addTransX, 0);
 			currItem->DrawPolyL(p, currItem->Clip);
 		}
 		else // moving page item

Modified: trunk/Scribus/scribus/pageitem.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17097&path=/trunk/Scribus/scribus/pageitem.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem.cpp (original)
+++ trunk/Scribus/scribus/pageitem.cpp Sun Dec 18 11:03:17 2011
@@ -5576,21 +5576,21 @@
 		}
 		result.translate(ite->xPos(), ite->yPos());
 		result.rotate(ite->rotation());
+		if (ite->isGroup() || ite->isSymbol())
+		{
+			if (ite->imageFlippedH())
+			{
+				result.translate(ite->width(), 0);
+				result.scale(-1, 1);
+			}
+			if (ite->imageFlippedV())
+			{
+				result.translate(0, ite->height());
+				result.scale(1, -1);
+			}
+		}
 		if (ite == this)
 			return result;
-		if (ite->isGroup() || ite->isSymbol())
-		{
-			if (ite->imageFlippedH())
-			{
-				result.translate(ite->width(), 0);
-				result.scale(-1, 1);
-			}
-			if (ite->imageFlippedV())
-			{
-				result.translate(0, ite->height());
-				result.scale(1, -1);
-			}
-		}
 		if (ite->isGroup())
 			result.scale(ite->width() / ite->groupWidth, ite->height() / ite->groupHeight);
 		for (int aa = 0; aa < itList.count(); aa++)
@@ -5598,8 +5598,6 @@
 			ite = itList.at(aa);
 			result.translate(ite->gXpos, ite->gYpos);
 			result.rotate(ite->rotation());
-			if (ite == this)
-				return result;
 			if (ite->isGroup() || ite->isSymbol())
 			{
 				if (ite->imageFlippedH())
@@ -5613,6 +5611,8 @@
 					result.scale(1, -1);
 				}
 			}
+			if (ite == this)
+				return result;
 			if (ite->isGroup())
 				result.scale(ite->width() / ite->groupWidth, ite->height() / ite->groupHeight);
 		}

Modified: trunk/Scribus/scribus/ui/propertiespalette_group.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17097&path=/trunk/Scribus/scribus/ui/propertiespalette_group.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/propertiespalette_group.cpp (original)
+++ trunk/Scribus/scribus/ui/propertiespalette_group.cpp Sun Dec 18 11:03:17 2011
@@ -468,6 +468,8 @@
 			return;
 
 		m_doc->item_setFrameShape(m_item, frameType, count, points);
+		m_doc->invalidateAll();
+		m_doc->regionsChanged()->update(QRect());
 
 		//ScribusDoc::changed() is called in item_setFrameShape()
 		//Hope this is enough

Modified: trunk/Scribus/scribus/ui/propertiespalette_shape.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17097&path=/trunk/Scribus/scribus/ui/propertiespalette_shape.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/propertiespalette_shape.cpp (original)
+++ trunk/Scribus/scribus/ui/propertiespalette_shape.cpp Sun Dec 18 11:03:17 2011
@@ -507,6 +507,8 @@
 //		m_item->convertTo(PageItem::Polygon);
 //		newSelection(6);
 		roundRect->setEnabled(f == 0);
+		m_doc->invalidateAll();
+		m_doc->regionsChanged()->update(QRect());
 	}
 }
 

Modified: trunk/Scribus/scribus/ui/propertiespalette_xyz.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17097&path=/trunk/Scribus/scribus/ui/propertiespalette_xyz.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/propertiespalette_xyz.cpp (original)
+++ trunk/Scribus/scribus/ui/propertiespalette_xyz.cpp Sun Dec 18 11:03:17 2011
@@ -417,7 +417,9 @@
 
 void PropertiesPalette_XYZ::handleAppModeChanged(int oldMode, int mode)
 {
-	doUnGroup->setEnabled(mode != modeEdit && mode != modeEditClip);
+	if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning())
+		return;
+	doUnGroup->setEnabled(mode != modeEdit && mode != modeEditClip && m_item->isGroup());
 }
 
 void PropertiesPalette_XYZ::handleSelectionChanged()
@@ -1502,4 +1504,6 @@
 void PropertiesPalette_XYZ::handleUngrouping()
 {
 	m_ScMW->UnGroupObj();
-}
+	m_doc->invalidateAll();
+	m_doc->regionsChanged()->update(QRect());
+}




More information about the scribus-commit mailing list