r23327 by jghali - Enable use of custom selection with itemSelection_FlipH() and itemSelection_FlipV()

scribus-commit scribus-commit at lists.scribus.net
Mon Nov 4 15:58:34 UTC 2019


Author: jghali
Date: Mon Nov  4 15:58:33 2019
New Revision: 23327

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23327
Log:
Enable use of custom selection with itemSelection_FlipH() and itemSelection_FlipV()

Modified:
    trunk/Scribus/scribus/scribusdoc.cpp
    trunk/Scribus/scribus/scribusdoc.h

Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23327&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp	(original)
+++ trunk/Scribus/scribus/scribusdoc.cpp	Mon Nov  4 15:58:33 2019
@@ -10851,21 +10851,23 @@
 }
 
 
-void ScribusDoc::itemSelection_FlipH()
-{
-	int docSelectionCount=m_Selection->count();
-	if (docSelectionCount == 0)
+void ScribusDoc::itemSelection_FlipH(Selection* customSelection)
+{
+	Selection* itemSelection = (customSelection != nullptr) ? customSelection : m_Selection;
+	if (itemSelection->isEmpty())
 		return;
+	int docSelectionCount = itemSelection->count();
+
 	UndoTransaction trans;
 	if (UndoManager::undoEnabled())
 		trans = m_undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::FlipH, nullptr, Um::IFlipH);
 	if (docSelectionCount > 1)
 	{
 		double gx, gy, gh, gw, ix, iy, iw, ih;
-		m_Selection->getGroupRect(&gx, &gy, &gw, &gh);
+		itemSelection->getGroupRect(&gx, &gy, &gw, &gh);
 		for (int i = 0; i < docSelectionCount; ++i)
 		{
-			PageItem* currItem=m_Selection->itemAt(i);
+			PageItem* currItem = itemSelection->itemAt(i);
 			currItem->getBoundingRect(&ix, &iy, &iw, &ih);
 			double dx =  ((gw / 2.0) -  ((ix - gx) + (iw - ix) / 2.0)) * 2.0;
 			if (currItem->rotation() != 0.0)
@@ -10881,7 +10883,7 @@
 				currItem->setRotation(newRotation);
 				currItem->setRedrawBounding();
 				currItem->getBoundingRect(&ix2, &iy2, &iw2, &ih2);
-				currItem->moveBy(ix-ix2, iy-iy2, false);
+				currItem->moveBy(ix - ix2, iy - iy2, false);
 				currItem->setRedrawBounding();
 			}
 			if (currItem->isImageFrame() || currItem->isTextFrame() || currItem->isLatexFrame() || currItem->isOSGFrame() || currItem->isSymbol() || currItem->isGroup() || currItem->isSpiral())
@@ -10918,7 +10920,7 @@
 	}
 	else
 	{
-		PageItem* currItem=m_Selection->itemAt(0);
+		PageItem* currItem = itemSelection->itemAt(0);
 		if (currItem->isImageFrame() || currItem->isTextFrame() || currItem->isLatexFrame() || currItem->isOSGFrame() || currItem->isSymbol() || currItem->isGroup() || currItem->isSpiral())
 			currItem->flipImageH();
 		if (currItem->itemType() != PageItem::Line)
@@ -10935,7 +10937,7 @@
 			currItem->setRotation(newRotation);
 			currItem->setRedrawBounding();
 			currItem->getBoundingRect(&ix2, &iy2, &iw2, &ih2);
-			currItem->moveBy(ix-ix2, iy-iy2, false);
+			currItem->moveBy(ix - ix2, iy - iy2, false);
 			currItem->setRedrawBounding();
 		}
 		currItem->GrStartX = currItem->width() - currItem->GrStartX;
@@ -10967,25 +10969,27 @@
 		trans.commit();
 	regionsChanged()->update(QRectF());
 	changed();
-	emit firstSelectedItemType(m_Selection->itemAt(0)->itemType());
-}
-
-
-void ScribusDoc::itemSelection_FlipV()
-{
-	int docSelectionCount=m_Selection->count();
-	if (docSelectionCount == 0)
+	emit firstSelectedItemType(itemSelection->itemAt(0)->itemType());
+}
+
+
+void ScribusDoc::itemSelection_FlipV(Selection* customSelection)
+{
+	Selection* itemSelection = (customSelection != nullptr) ? customSelection : m_Selection;
+	if (itemSelection->isEmpty())
 		return;
+	int docSelectionCount = itemSelection->count();
+
 	UndoTransaction trans;
 	if (UndoManager::undoEnabled())
 		trans = m_undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::FlipV, nullptr, Um::IFlipV);
 	if (docSelectionCount > 1)
 	{
 		double gx, gy, gh, gw, ix, iy, iw, ih;
-		m_Selection->getGroupRect(&gx, &gy, &gw, &gh);
+		itemSelection->getGroupRect(&gx, &gy, &gw, &gh);
 		for (int i = 0; i < docSelectionCount; ++i)
 		{
-			PageItem* currItem=m_Selection->itemAt(i);
+			PageItem* currItem = itemSelection->itemAt(i);
 			currItem->getBoundingRect(&ix, &iy, &iw, &ih);
 			double dx =  ((gh / 2.0) -  ((iy - gy) + (ih - iy) / 2.0)) * 2.0;
 			if (currItem->rotation() != 0.0)
@@ -11034,7 +11038,7 @@
 	}
 	else
 	{
-		PageItem* currItem=m_Selection->itemAt(0);
+		PageItem* currItem = itemSelection->itemAt(0);
 		if (currItem->isImageFrame() || currItem->isTextFrame() || currItem->isLatexFrame() || currItem->isOSGFrame() || currItem->isSymbol() || currItem->isGroup() || currItem->isSpiral())
 			currItem->flipImageV();
 		if (currItem->itemType() != PageItem::Line)

Modified: trunk/Scribus/scribus/scribusdoc.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23327&path=/trunk/Scribus/scribus/scribusdoc.h
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.h	(original)
+++ trunk/Scribus/scribus/scribusdoc.h	Mon Nov  4 15:58:33 2019
@@ -1494,8 +1494,8 @@
 	void itemSelection_SetMaskGradient(VGradient& newGradient, Selection* customSelection = nullptr);
 	void itemSelection_SetOverprint(bool overprint, Selection* customSelection = nullptr);
 	void itemSelection_ApplyImageEffects(ScImageEffectList& newEffectList, Selection* customSelection = nullptr);
-	void itemSelection_FlipH();
-	void itemSelection_FlipV();
+	void itemSelection_FlipH(Selection* customSelection = nullptr);
+	void itemSelection_FlipV(Selection* customSelection = nullptr);
 	void itemSelection_Rotate(double angle, Selection* customSelection = nullptr);
 	void itemSelection_DoHyphenate();
 	void itemSelection_DoDeHyphenate();




More information about the scribus-commit mailing list