r15599 by fschmid - Initial committ of the new "Paint Manager", it combines the former "Color Manager" and "Gradient Manager".
scribus-commit
scribus-commit at lists.scribus.net
Thu Oct 21 00:07:09 CEST 2010
Author: fschmid
Date: Wed Oct 20 22:07:09 2010
New Revision: 15599
URL: http://scribus.info/websvn/listing.php?repname=Scribus&sc=1&rev=15599
Log:
Initial committ of the new "Paint Manager", it combines the former "Color Manager" and "Gradient Manager".
This means we can have now gradients in the swatch files.
Added:
trunk/Scribus/scribus/ui/paintmanager.cpp
trunk/Scribus/scribus/ui/paintmanager.h
trunk/Scribus/scribus/ui/paintmanager.ui
Modified:
trunk/Scribus/scribus/CMakeLists.txt
trunk/Scribus/scribus/actionmanager.cpp
trunk/Scribus/scribus/scribus.cpp
trunk/Scribus/scribus/scribus.h
trunk/Scribus/scribus/util_color.cpp
trunk/Scribus/scribus/util_color.h
Modified: trunk/Scribus/scribus/CMakeLists.txt
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15599&path=/trunk/Scribus/scribus/CMakeLists.txt
==============================================================================
--- trunk/Scribus/scribus/CMakeLists.txt (original)
+++ trunk/Scribus/scribus/CMakeLists.txt Wed Oct 20 22:07:09 2010
@@ -89,6 +89,7 @@
ui/nftdialog.ui
ui/nftwidget.ui
ui/pageitemattributes.ui
+ ui/paintmanager.ui
ui/patterndialog.ui
ui/picsearch.ui
ui/picsearchoptions.ui
@@ -276,6 +277,7 @@
ui/pagelayout.h
ui/pagepalette.h
ui/pageselector.h
+ ui/paintmanager.h
ui/patterndialog.h
ui/patternpropsdialog.h
pdf_analyzer.h
@@ -599,6 +601,7 @@
ui/pagepalette.cpp
ui/pageselector.cpp
pagesize.cpp
+ ui/paintmanager.cpp
ui/patterndialog.cpp
ui/patternpropsdialog.cpp
pdf_analyzer.cpp
Modified: trunk/Scribus/scribus/actionmanager.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15599&path=/trunk/Scribus/scribus/actionmanager.cpp
==============================================================================
--- trunk/Scribus/scribus/actionmanager.cpp (original)
+++ trunk/Scribus/scribus/actionmanager.cpp Wed Oct 20 22:07:09 2010
@@ -234,6 +234,8 @@
scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow));
name="editGradients";
scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow));
+ name="editPaints";
+ scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow));
name="editStyles";
scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow));
name="editMasterPages";
@@ -262,6 +264,7 @@
connect( (*scrActions)["editReplaceColors"], SIGNAL(triggered()), mainWindow, SLOT(slotReplaceColors()) );
connect( (*scrActions)["editPatterns"], SIGNAL(triggered()), mainWindow, SLOT(managePatterns()) );
connect( (*scrActions)["editGradients"], SIGNAL(triggered()), mainWindow, SLOT(manageGradients()) );
+ connect( (*scrActions)["editPaints"], SIGNAL(triggered()), mainWindow, SLOT(managePaints()) );
connect( (*scrActions)["editMasterPages"], SIGNAL(triggered()), mainWindow, SLOT(manageMasterPages()) );
connect( (*scrActions)["editJavascripts"], SIGNAL(triggered()), mainWindow, SLOT(ManageJava()) );
}
@@ -1317,6 +1320,7 @@
(*scrActions)["editReplaceColors"]->setTexts( tr("Replace Colors..."));
(*scrActions)["editPatterns"]->setTexts( tr("Patterns..."));
(*scrActions)["editGradients"]->setTexts( tr("Gradients..."));
+ (*scrActions)["editPaints"]->setTexts( tr("Paints..."));
(*scrActions)["editStyles"]->setTexts( tr("S&tyles..."));
(*scrActions)["editMasterPages"]->setTexts( tr("&Master Pages..."));
(*scrActions)["editJavascripts"]->setTexts( tr("&JavaScripts..."));
@@ -1759,7 +1763,7 @@
itmenu->second << "fileDocSetup" << "fileDocSetup150" << "filePreferences" << "filePreferences150" << "filePrint" << "PrintPreview" << "fileQuit";
++itmenu;
//Edit
- itmenu->second << "editUndoAction" << "editRedoAction" << "editActionMode" << "editCut" << "editCopy" << "editPaste" << "editCopyContents" << "editPasteContents" << "editPasteContentsAbs" << "editClearContents" << "editSelectAll" << "editSelectAllOnLayer" << "editDeselectAll" << "editSearchReplace" << "toolsEditWithStoryEditor" << "editEditWithImageEditor" << "editEditRenderSource" << "editExtendedImageProperties" << "editColors" << "editReplaceColors" << "editPatterns" << "editGradients" << "editStyles" << "editMasterPages" << "editJavascripts";
+ itmenu->second << "editUndoAction" << "editRedoAction" << "editActionMode" << "editCut" << "editCopy" << "editPaste" << "editCopyContents" << "editPasteContents" << "editPasteContentsAbs" << "editClearContents" << "editSelectAll" << "editSelectAllOnLayer" << "editDeselectAll" << "editSearchReplace" << "toolsEditWithStoryEditor" << "editEditWithImageEditor" << "editEditRenderSource" << "editExtendedImageProperties" << "editColors" << "editReplaceColors" << "editPatterns" << "editGradients" << "editPaints" << "editStyles" << "editMasterPages" << "editJavascripts";
//Style
++itmenu;
int font_sizes[] = {7, 9, 10, 11, 12, 14, 18, 24, 36, 48, 60, 72};
Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15599&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp (original)
+++ trunk/Scribus/scribus/scribus.cpp Wed Oct 20 22:07:09 2010
@@ -152,6 +152,7 @@
#include "ui/pagepalette.h"
#include "ui/pageselector.h"
#include "pagesize.h"
+#include "ui/paintmanager.h"
#include "ui/patterndialog.h"
#include "pdflib.h"
#include "pdfoptions.h"
@@ -690,6 +691,7 @@
scrMenuMgr->addMenuItem(scrActions["editColors"], "Edit", true);
scrMenuMgr->addMenuItem(scrActions["editReplaceColors"], "Edit", false);
scrMenuMgr->addMenuItem(scrActions["editGradients"], "Edit", false);
+ scrMenuMgr->addMenuItem(scrActions["editPaints"], "Edit", true);
scrMenuMgr->addMenuItem(scrActions["editPatterns"], "Edit", false);
scrMenuMgr->addMenuItem(scrActions["editStyles"], "Edit", false);
scrMenuMgr->addMenuItem(scrActions["editMasterPages"], "Edit", false);
@@ -2341,7 +2343,7 @@
scrActions["editDeselectAll"]->setEnabled(false);
scrActions["editReplaceColors"]->setEnabled(true);
scrActions["editPatterns"]->setEnabled(true);
-// scrActions["editGradients"]->setEnabled(true);
+ scrActions["editGradients"]->setEnabled(true);
scrActions["editStyles"]->setEnabled(true);
scrActions["editMasterPages"]->setEnabled(true);
scrActions["editJavascripts"]->setEnabled(true);
@@ -4487,7 +4489,7 @@
scrActions["editDeselectAll"]->setEnabled(false);
scrActions["editReplaceColors"]->setEnabled(false);
scrActions["editPatterns"]->setEnabled(false);
-// scrActions["editGradients"]->setEnabled(false);
+ scrActions["editGradients"]->setEnabled(false);
scrActions["editStyles"]->setEnabled(false);
scrActions["editSearchReplace"]->setEnabled(false);
scrActions["editMasterPages"]->setEnabled(false);
@@ -9920,6 +9922,76 @@
}
}
+void ScribusMainWindow::managePaints()
+{
+ ColorList edc;
+ QMap<QString, VGradient> *Gradients;
+ if (HaveDoc)
+ {
+ Gradients = &doc->docGradients;
+ edc = doc->PageColors;
+ }
+ else
+ {
+ Gradients = &prefsManager->appPrefs.defaultGradients;
+ edc = prefsManager->colorSet();
+ }
+ undoManager->setUndoEnabled(false);
+ paintManagerDialog *dia = new paintManagerDialog(this, Gradients, edc, prefsManager->colorSetName(), prefsManager->appPrefs.colorPrefs.CustomColorSets, doc, this);
+ if (dia->exec())
+ {
+ if (HaveDoc)
+ {
+ QColor tmpc;
+ slotDocCh();
+ doc->PageColors = dia->m_colorList;
+ if (dia->replaceColorMap.isEmpty())
+ {
+ // invalidate all charstyles, as replaceNamedResources() wont do it if all maps are empty
+ const StyleSet<CharStyle> dummy;
+ doc->redefineCharStyles(dummy, false);
+ }
+ else
+ {
+ ResourceCollection colorrsc;
+ colorrsc.mapColors(dia->replaceColorMap);
+ // Update tools colors
+ PrefsManager::replaceToolColors(doc->itemToolPrefs(), colorrsc.colors());
+ // Update objects and styles colors
+ doc->replaceNamedResources(colorrsc);
+ // Temporary code until LineStyle is effectively used
+ doc->replaceLineStyleColors(dia->replaceColorMap);
+ }
+ doc->recalculateColors();
+ doc->recalcPicturesRes();
+ doc->setGradients(dia->dialogGradients);
+ if (!dia->replaceMap.isEmpty())
+ {
+ ResourceCollection gradrsc;
+ gradrsc.mapPatterns(dia->replaceMap);
+ doc->replaceNamedResources(gradrsc);
+ }
+ updateColorLists();
+ if (doc->m_Selection->count() != 0)
+ doc->m_Selection->itemAt(0)->emitAllToGUI();
+ view->DrawNew();
+ }
+ else
+ {
+ // Update tools colors if needed
+ prefsManager->replaceToolColors(dia->replaceColorMap);
+ prefsManager->setColorSet(dia->m_colorList);
+ prefsManager->setColorSetName(dia->getColorSetName());
+ propertiesPalette->Cpal->SetColors(prefsManager->colorSet());
+ prefsManager->appPrefs.defaultGradients = dia->dialogGradients;
+ }
+ }
+ if (!HaveDoc)
+ prefsManager->appPrefs.colorPrefs.CustomColorSets = dia->customColSet;
+ delete dia;
+ undoManager->setUndoEnabled(true);
+}
+
void ScribusMainWindow::manageGradients()
{
if (HaveDoc)
Modified: trunk/Scribus/scribus/scribus.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15599&path=/trunk/Scribus/scribus/scribus.h
==============================================================================
--- trunk/Scribus/scribus/scribus.h (original)
+++ trunk/Scribus/scribus/scribus.h Wed Oct 20 22:07:09 2010
@@ -555,6 +555,8 @@
void managePatterns();
//! \brief manages the documents gradients
void manageGradients();
+ //! \brief manages paints
+ void managePaints();
//! \brief enable or disable the unicode actions and their menus
void enableTextActions(QMap<QString, QPointer<ScrAction> > *actionMap, bool enabled, const QString& fontName=QString::null);
//! \brief allow SE to get the SM for edit stlyes
Modified: trunk/Scribus/scribus/util_color.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15599&path=/trunk/Scribus/scribus/util_color.cpp
==============================================================================
--- trunk/Scribus/scribus/util_color.cpp (original)
+++ trunk/Scribus/scribus/util_color.cpp Wed Oct 20 22:07:09 2010
@@ -184,8 +184,19 @@
static quint64 code64(const ScColor & col) {
int C, M, Y, K, R, G, B;
quint64 result=0;
- col.getRGB( &R, &G, &B );
- col.getCMYK( &C, &M, &Y, &K );
+ if (col.getColorModel() == colorModelRGB)
+ {
+ col.getRGB( &R, &G, &B );
+ QColor color = QColor(R, G, B);
+ color.getCmyk(&C, &M, &Y, &K);
+ }
+ else
+ {
+ col.getCMYK( &C, &M, &Y, &K );
+ R = 255-qMin(255, C + K);
+ G = 255-qMin(255, M + K);
+ B = 255-qMin(255, Y + K);
+ }
result |= col.getColorModel() == colorModelRGB ? 1 : 0;
result |= col.isSpotColor() ? 64 : 0;
result |= col.isRegistrationColor() ? 32 : 0;
@@ -230,7 +241,8 @@
return pxCache[res];
QPixmap *pa=new QPixmap(60, 15);
- QPixmap *pm=getSmallPixmap(col.getRawRGBColor());
+ QPixmap *pm=getSmallPixmap(ScColorEngine::getDisplayColor(col, doc));
+// QPixmap *pm=getSmallPixmap(col.getRawRGBColor());
pa->fill(Qt::white);
paintAlert(*pm, *pa, 0, 0);
if (ScColorEngine::isOutOfGamut(col, doc))
@@ -583,7 +595,7 @@
return CommonStrings::trUnknownCS;
}
-bool importColorsFromFile(QString fileName, ColorList &EditColors)
+bool importColorsFromFile(QString fileName, ColorList &EditColors, QMap<QString,VGradient> *dialogGradients)
{
int oldCount = EditColors.count();
if (!fileName.isEmpty())
@@ -768,6 +780,42 @@
if (!EditColors.contains(pg.attribute("NAME")))
EditColors.insert(pg.attribute("NAME"), lf);
}
+ else if (pg.tagName() == "Gradient")
+ {
+ if (dialogGradients != NULL)
+ {
+ VGradient gra = VGradient(VGradient::linear);
+ gra.clearStops();
+ QDomNode grad = pg.firstChild();
+ while(!grad.isNull())
+ {
+ QDomElement stop = grad.toElement();
+ QString name = stop.attribute("NAME");
+ double ramp = ScCLocale::toDoubleC(stop.attribute("RAMP"), 0.0);
+ int shade = stop.attribute("SHADE", "100").toInt();
+ double opa = ScCLocale::toDoubleC(stop.attribute("TRANS"), 1.0);
+ QColor color;
+ if (name == CommonStrings::None)
+ color = QColor(255, 255, 255, 0);
+ else
+ {
+ const ScColor& col = EditColors[name];
+ color = ScColorEngine::getShadeColorProof(col, NULL, shade);
+ }
+ gra.addStop(color, ramp, 0.5, opa, name, shade);
+ grad = grad.nextSibling();
+ }
+ if (!dialogGradients->contains(pg.attribute("Name")))
+ dialogGradients->insert(pg.attribute("Name"), gra);
+ else
+ {
+ QString tmp;
+ QString name = pg.attribute("Name");
+ name += "("+tmp.setNum(dialogGradients->count())+")";
+ dialogGradients->insert(name, gra);
+ }
+ }
+ }
else if (pg.tagName()=="draw:color" && pg.attribute("draw:name")!=CommonStrings::None)
{
if (pg.hasAttribute("draw:color"))
Modified: trunk/Scribus/scribus/util_color.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15599&path=/trunk/Scribus/scribus/util_color.h
==============================================================================
--- trunk/Scribus/scribus/util_color.h (original)
+++ trunk/Scribus/scribus/util_color.h Wed Oct 20 22:07:09 2010
@@ -13,6 +13,7 @@
#include <QString>
#include "fpointarray.h"
+#include "vgradient.h"
#include "sccolor.h"
#include "scribusapi.h"
@@ -110,6 +111,6 @@
* \param EditColors Color list to store the imported colors
* \return true if any colors have been found
*/
-bool SCRIBUS_API importColorsFromFile(QString fileName, ColorList &EditColors);
+bool SCRIBUS_API importColorsFromFile(QString fileName, ColorList &EditColors, QMap<QString,VGradient> *dialogGradients = NULL);
#endif
More information about the scribus-commit
mailing list