r16496 by craig - #4930: Allow undo/redo for layer transparency and blend mode

scribus-commit scribus-commit at lists.scribus.net
Thu Mar 24 23:53:56 CET 2011


Author: craig
Date: Thu Mar 24 22:53:56 2011
New Revision: 16496

URL: http://scribus.info/websvn/listing.php?repname=Scribus&sc=1&rev=16496
Log:
#4930: Allow undo/redo for layer transparency and blend mode

Modified:
    branches/Version135/Scribus/scribus/scribusdoc.cpp
    branches/Version135/Scribus/scribus/undomanager.cpp
    branches/Version135/Scribus/scribus/undomanager.h

Modified: branches/Version135/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16496&path=/branches/Version135/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- branches/Version135/Scribus/scribus/scribusdoc.cpp (original)
+++ branches/Version135/Scribus/scribus/scribusdoc.cpp Thu Mar 24 22:53:56 2011
@@ -1294,10 +1294,24 @@
 			setLayerPrintable(ss->getInt("ACTIVE"), isUndo ? !print : print);
 			layersUndo=true;
 		}
-		else if (ss->contains("FLOW_LAYER"))
+		else if (ss->contains("LAYER_FLOW"))
 		{
 			bool flow = ss->getBool("FLOW");
 			setLayerFlow(ss->getInt("ACTIVE"), isUndo ? !flow : flow);
+			layersUndo=true;
+		}
+		else if (ss->contains("LAYER_TRANSPARENCY"))
+		{
+			double old_trans = ss->getDouble("OLD_TRANS");
+			double new_trans = ss->getDouble("NEW_TRANS");
+			setLayerTransparency(ss->getInt("ACTIVE"), isUndo ? old_trans : new_trans);
+			layersUndo=true;
+		}
+		else if (ss->contains("LAYER_BLENDMODE"))
+		{
+			int old_blend = ss->getInt("OLD_BLENDMODE");
+			int new_blend = ss->getInt("NEW_BLENDMODE");
+			setLayerBlendMode(ss->getInt("ACTIVE"), isUndo ? old_blend : new_blend);
 			layersUndo=true;
 		}
 		else if (ss->contains("ADD_LAYER"))
@@ -1350,6 +1364,7 @@
 			{
 				m_ScMW->changeLayer(ss->getInt("ACTIVE"));
 				m_ScMW->layerPalette->rebuildList();
+				m_ScMW->layerPalette->markActiveLayer(activeLayer());
 			}
 		}
 	}
@@ -2074,18 +2089,15 @@
 	{
 		if (it->LNr == layerNumber)
 		{
-			bool oldPrintable = it->isPrintable;
-			it->isPrintable = isPrintable;
-
-			if (oldPrintable!=isPrintable && UndoManager::undoEnabled())
-			{
-				SimpleState *ss = new SimpleState(isPrintable ? Um::PrintLayer : Um::DoNotPrintLayer,
-						                          "", Um::IPrint);
+			if (it->isPrintable!=isPrintable && UndoManager::undoEnabled())
+			{
+				SimpleState *ss = new SimpleState(isPrintable ? Um::PrintLayer : Um::DoNotPrintLayer, "", Um::IPrint);
 				ss->set("PRINT_LAYER", "print_layer");
-				ss->set("ACTIVE", (*it).LNr);
+				ss->set("ACTIVE", it->LNr);
 				ss->set("PRINT", isPrintable);
 				undoManager->action(this, ss, it->Name, Um::ILayer);
 			}
+			it->isPrintable = isPrintable;
 			found=true;
 			break;
 		}
@@ -2184,18 +2196,15 @@
 	{
 		if (it->LNr == layerNumber)
 		{
-			bool oldFlow = it->flowControl;
-			it->flowControl = flow;
-			
-			if (oldFlow!=flow && UndoManager::undoEnabled())
+			if (it->flowControl!=flow && UndoManager::undoEnabled())
 			{
 				SimpleState *ss = new SimpleState(flow ? Um::FlowLayer : Um::DisableFlowLayer, "", Um::ITextFrame);
-				ss->set("FLOW_LAYER", "flow_layer");
-				ss->set("ACTIVE", (*it).LNr);
+				ss->set("LAYER_FLOW", "layer_flow");
+				ss->set("ACTIVE", it->LNr);
 				ss->set("FLOW", flow);
 				undoManager->action(this, ss, it->Name, Um::ILayer);
 			}
-			
+			it->flowControl = flow;			
 			found=true;
 			break;
 		}
@@ -2237,6 +2246,15 @@
 	{
 		if (it->LNr == layerNumber)
 		{
+			if (it->transparency!=trans && UndoManager::undoEnabled())
+			{
+				SimpleState *ss = new SimpleState(Um::SetLayerTransparency, "", Um::ILayer);
+				ss->set("LAYER_TRANSPARENCY", "layer_transparency");
+				ss->set("ACTIVE", it->LNr);
+				ss->set("OLD_TRANS", it->transparency);
+				ss->set("NEW_TRANS", trans);
+				undoManager->action(this, ss, it->Name, Um::ILayer);
+			}
 			it->transparency = trans;
 			found=true;
 			break;
@@ -2270,6 +2288,15 @@
 	{
 		if (it->LNr == layerNumber)
 		{
+			if (it->blendMode!=blend && UndoManager::undoEnabled())
+			{
+				SimpleState *ss = new SimpleState(Um::SetLayerBlendMode, "", Um::ILayer);
+				ss->set("LAYER_BLENDMODE", "layer_blendmode");
+				ss->set("ACTIVE", it->LNr);
+				ss->set("OLD_BLENDMODE", it->blendMode);
+				ss->set("NEW_BLENDMODE", blend);
+				undoManager->action(this, ss, it->Name, Um::ILayer);
+			}
 			it->blendMode = blend;
 			found=true;
 			break;
@@ -4834,7 +4861,6 @@
 void ScribusDoc::removePageFromSection(const uint pageIndex)
 {
 	//Get the section of the new page index.
-	bool found = false;
 	uint fromIndex, toIndex;
 	DocumentSectionMap::Iterator it = sections.begin();
 	for (; it!= sections.end(); ++it)
@@ -10303,9 +10329,9 @@
 		QMap<int, QList<PageItem*> >::iterator groupIt;
 		for (it = toDelete.begin(); it != toDelete.end(); ++it)
 		{
-			PageItem* groupItem = it.key();
-			int groupId = it.value();
-			groupIt = groupObjects.find(groupId);
+			//PageItem* groupItem = it.key();
+			//int groupId = it.value();
+			groupIt = groupObjects.find(it.value());
 			if (groupIt == groupObjects.end()) 
 				continue;
 			QList<PageItem*> groupItems = groupIt.value();

Modified: branches/Version135/Scribus/scribus/undomanager.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16496&path=/branches/Version135/Scribus/scribus/undomanager.cpp
==============================================================================
--- branches/Version135/Scribus/scribus/undomanager.cpp (original)
+++ branches/Version135/Scribus/scribus/undomanager.cpp Thu Mar 24 22:53:56 2011
@@ -947,6 +947,8 @@
 	UndoManager::SetLayerName       = tr("Change name of the layer");
 	UndoManager::FlowLayer			= tr("Enable text flow around for lower layers");
 	UndoManager::DisableFlowLayer	= tr("Disable text flow around for lower layers");
+	UndoManager::SetLayerBlendMode	= tr("Set layer blend mode");
+	UndoManager::SetLayerTransparency=tr("Set layer opacity");
 	UndoManager::GetImage           = tr("Get image");
 	UndoManager::ChangeFormula      = tr("Change formula");
 	UndoManager::MultipleDuplicate  = tr("Multiple duplicate");
@@ -1143,7 +1145,7 @@
 QString UndoManager::DeletePage         = "";
 QString UndoManager::DeletePages        = "";
 QString UndoManager::AddLayer           = "";
-QString UndoManager::DuplicateLayer	= "";
+QString UndoManager::DuplicateLayer     = "";
 QString UndoManager::DeleteLayer        = "";
 QString UndoManager::RenameLayer        = "";
 QString UndoManager::RaiseLayer         = "";
@@ -1154,6 +1156,8 @@
 QString UndoManager::SetLayerName       = "";
 QString UndoManager::FlowLayer			= "";
 QString UndoManager::DisableFlowLayer	= "";
+QString UndoManager::SetLayerBlendMode  = "";
+QString UndoManager::SetLayerTransparency="";
 QString UndoManager::GetImage           = "";
 QString UndoManager::ChangeFormula      = "";
 QString UndoManager::MultipleDuplicate  = "";
@@ -1169,7 +1173,7 @@
 QString UndoManager::InsertFrame        = "";
 QString UndoManager::AdjustFrameToImage = "";
 QString UndoManager::RemoveAllGuides    = "";
-QString UndoManager::RemoveAllPageGuides = "";
+QString UndoManager::RemoveAllPageGuides= "";
 QString UndoManager::Copy               = "";
 QString UndoManager::CopyPage           = "";
 QString UndoManager::ToOutlines         = "";
@@ -1178,6 +1182,7 @@
 QString UndoManager::ClearContent		= "";
 QString UndoManager::LinkTextFrame		= "";
 QString UndoManager::UnlinkTextFrame	= "";
+
 
 /*** Icons for UndoObjects *******************************************/
 QPixmap *UndoManager::IImageFrame      = 0;

Modified: branches/Version135/Scribus/scribus/undomanager.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16496&path=/branches/Version135/Scribus/scribus/undomanager.h
==============================================================================
--- branches/Version135/Scribus/scribus/undomanager.h (original)
+++ branches/Version135/Scribus/scribus/undomanager.h Thu Mar 24 22:53:56 2011
@@ -573,6 +573,8 @@
 	static QString SetLayerName;
 	static QString FlowLayer;
 	static QString DisableFlowLayer;
+	static QString SetLayerBlendMode;
+	static QString SetLayerTransparency;
 	static QString GetImage;
 	static QString ChangeFormula;
 	static QString MultipleDuplicate;




More information about the scribus-commit mailing list