r19142 by craig - #12314: Add undo for drop shadow changes - GUI still needs updating for grouping items

scribus-commit scribus-commit at lists.scribus.net
Sat May 24 09:36:02 UTC 2014


Author: craig
Date: Sat May 24 09:36:02 2014
New Revision: 19142

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=19142
Log:
#12314: Add undo for drop shadow changes - GUI still needs updating for grouping items

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

Modified: trunk/Scribus/scribus/pageitem.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19142&path=/trunk/Scribus/scribus/pageitem.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem.cpp (original)
+++ trunk/Scribus/scribus/pageitem.cpp Sat May 24 09:36:02 2014
@@ -4491,6 +4491,134 @@
 	doOverprint = val;
 }
 
+void PageItem::setHasSoftShadow(bool val)
+{
+	if (m_hasSoftShadow == val)
+		return;
+
+	if (UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::SoftShadow, 0, Um::IGroup);
+		ss->set("SOFT_SHADOW", "SOFT_SHADOW");
+		ss->set("NEW_VALUE", val);
+		ss->set("OLD_VALUE", m_hasSoftShadow);
+		undoManager->action(this, ss);
+	}
+	m_hasSoftShadow = val;
+}
+
+void PageItem::setSoftShadowColor(const QString &val)
+{
+	if (m_softShadowColor == val)
+		return;
+
+	if (UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::SoftShadowColor, 0, Um::IGroup);
+		ss->set("SOFT_SHADOW_COLOR", "SOFT_SHADOW_COLOR");
+		ss->set("NEW_VALUE", val);
+		ss->set("OLD_VALUE", m_softShadowColor);
+		undoManager->action(this, ss);
+	}
+	m_softShadowColor = val;
+}
+
+void PageItem::setSoftShadowShade(int val)
+{
+	if (m_softShadowShade == val)
+		return;
+
+	if (UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::SoftShadowShade, 0, Um::IGroup);
+		ss->set("SOFT_SHADOW_SHADE", "SOFT_SHADOW_SHADE");
+		ss->set("NEW_VALUE", val);
+		ss->set("OLD_VALUE", m_softShadowShade);
+		undoManager->action(this, ss);
+	}
+	m_softShadowShade = val;
+}
+
+void PageItem::setSoftShadowBlurRadius(double val)
+{
+	if (m_softShadowBlurRadius == val)
+		return;
+
+	if (UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::SoftShadowBlurRadius, 0, Um::IGroup);
+		ss->set("SOFT_SHADOW_BLUR_RADIUS", "SOFT_SHADOW_BLUR_RADIUS");
+		ss->set("NEW_VALUE", val);
+		ss->set("OLD_VALUE", m_softShadowBlurRadius);
+		undoManager->action(this, ss);
+	}
+	m_softShadowBlurRadius = val;
+}
+
+void PageItem::setSoftShadowXOffset(double val)
+{
+	if (m_softShadowXOffset == val)
+		return;
+
+	if (UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::SoftShadowXOffset, 0, Um::IGroup);
+		ss->set("SOFT_SHADOW_XOFFSET", "SOFT_SHADOW_XOFFSET");
+		ss->set("NEW_VALUE", val);
+		ss->set("OLD_VALUE", m_softShadowXOffset);
+		undoManager->action(this, ss);
+	}
+	m_softShadowXOffset = val;
+}
+
+void PageItem::setSoftShadowYOffset(double val)
+{
+	if (m_softShadowYOffset == val)
+		return;
+
+	if (UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::SoftShadowYoffset, 0, Um::IGroup);
+		ss->set("SOFT_SHADOW_YOFFSET", "SOFT_SHADOW_YOFFSET");
+		ss->set("NEW_VALUE", val);
+		ss->set("OLD_VALUE", m_softShadowYOffset);
+		undoManager->action(this, ss);
+	}
+	m_softShadowYOffset = val;
+}
+
+void PageItem::setSoftShadowOpacity(double val)
+{
+	if (m_softShadowOpacity == val)
+		return;
+
+	if (UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::SoftShadowOpacity, 0, Um::IGroup);
+		ss->set("SOFT_SHADOW_OPACITY", "SOFT_SHADOW_OPACITY");
+		ss->set("NEW_VALUE", val);
+		ss->set("OLD_VALUE", m_softShadowOpacity);
+		undoManager->action(this, ss);
+	}
+	m_softShadowOpacity = val;
+}
+
+void PageItem::setSoftShadowBlendMode(int val)
+{
+	if (m_softShadowBlendMode == val)
+		return;
+
+	if (UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::SoftShadowBlendMode, 0, Um::IGroup);
+		ss->set("SOFT_SHADOW_BLEND_MODE", "SOFT_SHADOW_BLEND_MODE");
+		ss->set("NEW_VALUE", val);
+		ss->set("OLD_VALUE", m_softShadowBlendMode);
+		undoManager->action(this, ss);
+	}
+	m_softShadowBlendMode = val;
+}
+
 void PageItem::toggleLock()
 {
 	if (UndoManager::undoEnabled())
@@ -5166,6 +5294,22 @@
 			restoreUnWeldItem(ss, isUndo);
 		else if (ss->contains("CLEARMARKSTRING"))
 			restoreMarkString(ss, isUndo);
+		else if (ss->contains("SOFT_SHADOW"))
+			restoreSoftShadow(ss, isUndo);
+		else if (ss->contains("SOFT_SHADOW_COLOR"))
+			restoreSoftShadowColor(ss, isUndo);
+		else if (ss->contains("SOFT_SHADOW_SHADE"))
+			restoreSoftShadowShade(ss, isUndo);
+		else if (ss->contains("SOFT_SHADOW_BLUR_RADIUS"))
+			restoreSoftShadowBlurRadius(ss, isUndo);
+		else if (ss->contains("SOFT_SHADOW_XOFFSET"))
+			restoreSoftShadowXOffset(ss, isUndo);
+		else if (ss->contains("SOFT_SHADOW_YOFFSET"))
+			restoreSoftShadowYOffset(ss, isUndo);
+		else if (ss->contains("SOFT_SHADOW_OPACITY"))
+			restoreSoftShadowOpacity(ss, isUndo);
+		else if (ss->contains("SOFT_SHADOW_BLEND_MODE"))
+			restoreSoftShadowBlendMode(ss, isUndo);
 	}
 	if (!OnMasterPage.isEmpty())
 		m_Doc->setCurrentPage(oldCurrentPage);
@@ -5241,6 +5385,78 @@
 	}
 	m_Doc->changed();
 	m_Doc->regionsChanged()->update(QRectF());
+}
+
+void PageItem::restoreSoftShadow(SimpleState *state, bool isUndo)
+{
+	if (isUndo)
+		m_hasSoftShadow = state->getBool("OLD_VALUE");
+	else
+		m_hasSoftShadow = state->getBool("NEW_VALUE");
+	update();
+}
+
+void PageItem::restoreSoftShadowColor(SimpleState *state, bool isUndo)
+{
+	if (isUndo)
+		m_softShadowColor = state->get("OLD_VALUE");
+	else
+		m_softShadowColor = state->get("NEW_VALUE");
+	update();
+}
+
+void PageItem::restoreSoftShadowShade(SimpleState *state, bool isUndo)
+{
+	if (isUndo)
+		m_softShadowShade = state->getInt("OLD_VALUE");
+	else
+		m_softShadowShade = state->getInt("NEW_VALUE");
+	update();
+}
+
+void PageItem::restoreSoftShadowBlurRadius(SimpleState *state, bool isUndo)
+{
+	if (isUndo)
+		m_softShadowBlurRadius = state->getDouble("OLD_VALUE");
+	else
+		m_softShadowBlurRadius = state->getDouble("NEW_VALUE");
+	update();
+}
+
+void PageItem::restoreSoftShadowXOffset(SimpleState *state, bool isUndo)
+{
+	if (isUndo)
+		m_softShadowXOffset = state->getDouble("OLD_VALUE");
+	else
+		m_softShadowXOffset = state->getDouble("NEW_VALUE");
+	update();
+}
+
+void PageItem::restoreSoftShadowYOffset(SimpleState *state, bool isUndo)
+{
+	if (isUndo)
+		m_softShadowYOffset = state->getDouble("OLD_VALUE");
+	else
+		m_softShadowYOffset = state->getDouble("NEW_VALUE");
+	update();
+}
+
+void PageItem::restoreSoftShadowOpacity(SimpleState *state, bool isUndo)
+{
+	if (isUndo)
+		m_softShadowOpacity = state->getDouble("OLD_VALUE");
+	else
+		m_softShadowOpacity = state->getDouble("NEW_VALUE");
+	update();
+}
+
+void PageItem::restoreSoftShadowBlendMode(SimpleState *state, bool isUndo)
+{
+	if (isUndo)
+		m_softShadowBlendMode = state->getInt("OLD_VALUE");
+	else
+		m_softShadowBlendMode = state->getInt("NEW_VALUE");
+	update();
 }
 
 void PageItem::restoreMarkString(SimpleState *state, bool isUndo)

Modified: trunk/Scribus/scribus/pageitem.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19142&path=/trunk/Scribus/scribus/pageitem.h
==============================================================================
--- trunk/Scribus/scribus/pageitem.h (original)
+++ trunk/Scribus/scribus/pageitem.h Sat May 24 09:36:02 2014
@@ -656,28 +656,28 @@
 	void setOverprint(bool val);
 
 	// soft shadow
-	void setHasSoftShadow(bool val) { m_hasSoftShadow = val; }
+	void setHasSoftShadow(bool val);
 	bool hasSoftShadow() { return m_hasSoftShadow; }
 
-	void setSoftShadowColor(const QString &newColor) { m_softShadowColor = newColor; }
+	void setSoftShadowColor(const QString &val);
 	QString softShadowColor() { return m_softShadowColor; }
 
-	void setSoftShadowShade(int val) { m_softShadowShade = val; }
+	void setSoftShadowShade(int val);
 	int softShadowShade() { return m_softShadowShade; }
 
-	void setSoftShadowBlurRadius(double val) { m_softShadowBlurRadius = val; }
+	void setSoftShadowBlurRadius(double val);
 	double softShadowBlurRadius() { return m_softShadowBlurRadius; }
 
-	void setSoftShadowXOffset(double val) { m_softShadowXOffset = val; }
+	void setSoftShadowXOffset(double val);
 	double softShadowXOffset() { return m_softShadowXOffset; }
 
-	void setSoftShadowYOffset(double val) { m_softShadowYOffset = val; }
+	void setSoftShadowYOffset(double val);
 	double softShadowYOffset() { return m_softShadowYOffset; }
 
-	void setSoftShadowOpacity(double val) { m_softShadowOpacity = val; }
+	void setSoftShadowOpacity(double val);
 	double softShadowOpacity() { return m_softShadowOpacity; }
 
-	void setSoftShadowBlendMode(int val) { m_softShadowBlendMode = val; }
+	void setSoftShadowBlendMode(int val);
 	double softShadowBlendMode() { return m_softShadowBlendMode; }
 
 	int frameType() const { return FrameType; } ///< rect / oval / round / other
@@ -1595,6 +1595,14 @@
 	void restoreUnlinkTextFrame(UndoState *state, bool isUndo);
 	void restoreVerticalAlign(SimpleState *state, bool isUndo);
 	void restoreWeldItems(SimpleState *state, bool isUndo);
+	void restoreSoftShadow(SimpleState *state, bool isUndo);
+	void restoreSoftShadowColor(SimpleState *state, bool isUndo);
+	void restoreSoftShadowShade(SimpleState *state, bool isUndo);
+	void restoreSoftShadowBlurRadius(SimpleState *state, bool isUndo);
+	void restoreSoftShadowXOffset(SimpleState *state, bool isUndo);
+	void restoreSoftShadowYOffset(SimpleState *state, bool isUndo);
+	void restoreSoftShadowOpacity(SimpleState *state, bool isUndo);
+	void restoreSoftShadowBlendMode(SimpleState *state, bool isUndo);
 
 
 	/*@}*/

Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19142&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp (original)
+++ trunk/Scribus/scribus/scribusdoc.cpp Sat May 24 09:36:02 2014
@@ -7800,6 +7800,12 @@
 	uint selectedItemCount = m_Selection->count();
 	if (selectedItemCount != 0)
 	{
+		UndoTransaction* activeTransaction = NULL;
+		m_updateManager.setUpdatesDisabled();
+		if (UndoManager::undoEnabled() && selectedItemCount > 1)
+			activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup,
+																				  Um::IGroup, Um::LineWidth, "", Um::ILineStyle));
+
 		for (uint a = 0; a < selectedItemCount; ++a)
 		{
 			PageItem *currItem = m_Selection->itemAt(a);
@@ -7814,6 +7820,12 @@
 			QRectF newRect = currItem->getVisualBoundingRect().adjusted(-dx, -dy, dx, dy);
 			currItem->invalidateLayout();
 			regionsChanged()->update(newRect);
+		}
+		if (activeTransaction)
+		{
+			activeTransaction->commit();
+			delete activeTransaction;
+			activeTransaction = NULL;
 		}
 	}
 	changed();

Modified: trunk/Scribus/scribus/undomanager.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19142&path=/trunk/Scribus/scribus/undomanager.cpp
==============================================================================
--- trunk/Scribus/scribus/undomanager.cpp (original)
+++ trunk/Scribus/scribus/undomanager.cpp Sat May 24 09:36:02 2014
@@ -1064,6 +1064,14 @@
 	UndoManager::ChangePageAttrs    = tr("Change Page Attributes");
 	UndoManager::Transform          = tr("Transform");
 	UndoManager::WeldItems          = tr("Weld Items");
+	UndoManager::SoftShadow         = tr("Soft Shadow");
+	UndoManager::SoftShadowColor    = tr("Soft Shadow Color");
+	UndoManager::SoftShadowShade    = tr("Soft Shadow Shade");
+	UndoManager::SoftShadowBlurRadius= tr("Soft Shadow Blue Radius");
+	UndoManager::SoftShadowXOffset  = tr("Soft Shadow X Offset");
+	UndoManager::SoftShadowYoffset  = tr("Soft Shadow Y Offset");
+	UndoManager::SoftShadowOpacity  = tr("Soft Shadow Opacity");
+	UndoManager::SoftShadowBlendMode= tr("Soft Shadow Blend Mode");
 }
 
 void UndoManager::initIcons()
@@ -1323,7 +1331,7 @@
 QString UndoManager::InsertFrame        = "";
 QString UndoManager::AdjustFrameToImage = "";
 QString UndoManager::RemoveAllGuides    = "";
-QString UndoManager::RemoveAllPageGuides = "";
+QString UndoManager::RemoveAllPageGuides= "";
 QString UndoManager::Copy               = "";
 QString UndoManager::CopyPage           = "";
 QString UndoManager::ImportPage         = "";
@@ -1336,6 +1344,14 @@
 QString UndoManager::ChangePageAttrs    = "";
 QString UndoManager::Transform          = "";
 QString UndoManager::WeldItems          = "";
+QString UndoManager::SoftShadow         = "";
+QString UndoManager::SoftShadowColor    = "";
+QString UndoManager::SoftShadowShade    = "";
+QString UndoManager::SoftShadowBlurRadius="";
+QString UndoManager::SoftShadowXOffset  = "";
+QString UndoManager::SoftShadowYoffset  = "";
+QString UndoManager::SoftShadowOpacity  = "";
+QString UndoManager::SoftShadowBlendMode= "";
 
 /*** Icons for UndoObjects *******************************************/
 QPixmap *UndoManager::IImageFrame      = 0;

Modified: trunk/Scribus/scribus/undomanager.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19142&path=/trunk/Scribus/scribus/undomanager.h
==============================================================================
--- trunk/Scribus/scribus/undomanager.h (original)
+++ trunk/Scribus/scribus/undomanager.h Sat May 24 09:36:02 2014
@@ -661,6 +661,14 @@
 	static QString ClearImage;
 	static QString PathOperation;
 	static QString WeldItems;
+	static QString SoftShadow;
+	static QString SoftShadowColor;
+	static QString SoftShadowShade;
+	static QString SoftShadowBlurRadius;
+	static QString SoftShadowXOffset;
+	static QString SoftShadowYoffset;
+	static QString SoftShadowOpacity;
+	static QString SoftShadowBlendMode;
 	/*@}*/
 
 	/**




More information about the scribus-commit mailing list