summaryrefslogtreecommitdiffstats
path: root/src/ui/dialog
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-03-26 04:34:25 +0000
committerTed Gould <ted@gould.cx>2010-03-26 04:34:25 +0000
commit9e023a3aa964a0d3fa1e31e46d33657367ba68aa (patch)
tree33f1392a340737e4eeefca6fd031f96c29befd2b /src/ui/dialog
parentInstalling the pkgconfig file (diff)
parentAdding in shape-record.h (diff)
downloadinkscape-9e023a3aa964a0d3fa1e31e46d33657367ba68aa.tar.gz
inkscape-9e023a3aa964a0d3fa1e31e46d33657367ba68aa.zip
Merge from trunk
(bzr r8254.1.53)
Diffstat (limited to 'src/ui/dialog')
-rw-r--r--src/ui/dialog/CMakeLists.txt1
-rw-r--r--src/ui/dialog/Makefile_insert4
-rw-r--r--src/ui/dialog/aboutbox.cpp4
-rw-r--r--src/ui/dialog/align-and-distribute.cpp15
-rw-r--r--src/ui/dialog/color-item.cpp837
-rw-r--r--src/ui/dialog/color-item.h128
-rw-r--r--src/ui/dialog/dialog-manager.cpp3
-rw-r--r--src/ui/dialog/document-properties.cpp2
-rw-r--r--src/ui/dialog/filedialogimpl-gtkmm.cpp2
-rw-r--r--src/ui/dialog/filedialogimpl-win32.cpp12
-rw-r--r--src/ui/dialog/filter-effects-dialog.cpp4
-rw-r--r--src/ui/dialog/icon-preview.cpp6
-rw-r--r--src/ui/dialog/inkscape-preferences.cpp57
-rw-r--r--src/ui/dialog/inkscape-preferences.h11
-rw-r--r--src/ui/dialog/layers.cpp4
-rw-r--r--src/ui/dialog/spray-option.cpp397
-rw-r--r--src/ui/dialog/spray-option.h145
-rw-r--r--src/ui/dialog/svg-fonts-dialog.cpp4
-rw-r--r--src/ui/dialog/swatches.cpp1168
-rw-r--r--src/ui/dialog/swatches.h18
20 files changed, 1331 insertions, 1491 deletions
diff --git a/src/ui/dialog/CMakeLists.txt b/src/ui/dialog/CMakeLists.txt
index ea63d6023..98c4a47bb 100644
--- a/src/ui/dialog/CMakeLists.txt
+++ b/src/ui/dialog/CMakeLists.txt
@@ -9,6 +9,7 @@ ENDIF(WIN32)
SET(ui_dialog_SRC
aboutbox.cpp
align-and-distribute.cpp
+color-item.cpp
debug.cpp
dialog.cpp
dialog-manager.cpp
diff --git a/src/ui/dialog/Makefile_insert b/src/ui/dialog/Makefile_insert
index fac5bad80..033bec875 100644
--- a/src/ui/dialog/Makefile_insert
+++ b/src/ui/dialog/Makefile_insert
@@ -18,6 +18,8 @@ ink_common_sources += \
ui/dialog/behavior.h \
ui/dialog/calligraphic-profile-rename.h \
ui/dialog/calligraphic-profile-rename.cpp \
+ ui/dialog/color-item.cpp \
+ ui/dialog/color-item.h \
ui/dialog/debug.cpp \
ui/dialog/debug.h \
ui/dialog/dialog.cpp \
@@ -75,8 +77,6 @@ ink_common_sources += \
ui/dialog/print-colors-preview-dialog.h \
ui/dialog/scriptdialog.cpp \
ui/dialog/scriptdialog.h \
- ui/dialog/spray-option.cpp \
- ui/dialog/spray-option.h \
ui/dialog/svg-fonts-dialog.cpp \
ui/dialog/svg-fonts-dialog.h \
ui/dialog/swatches.cpp \
diff --git a/src/ui/dialog/aboutbox.cpp b/src/ui/dialog/aboutbox.cpp
index 025bec37a..bbd02fa5d 100644
--- a/src/ui/dialog/aboutbox.cpp
+++ b/src/ui/dialog/aboutbox.cpp
@@ -103,8 +103,8 @@ AboutBox::AboutBox() : Gtk::Dialog(_("About Inkscape")) {
Gtk::Label *label=new Gtk::Label();
gchar *label_text =
- g_strdup_printf("<small><i>Inkscape %s, built %s</i></small>",
- Inkscape::version_string, __DATE__);
+ g_strdup_printf("<small><i>Inkscape %s</i></small>",
+ Inkscape::version_string);
label->set_markup(label_text);
label->set_alignment(Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER);
g_free(label_text);
diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp
index 2bba0a0f8..a75a8d68d 100644
--- a/src/ui/dialog/align-and-distribute.cpp
+++ b/src/ui/dialog/align-and-distribute.cpp
@@ -24,20 +24,20 @@
#include "unclump.h"
#include "document.h"
#include "enums.h"
-#include "graphlayout/graphlayout.h"
+#include "graphlayout.h"
#include "inkscape.h"
#include "macros.h"
-#include "node-context.h" //For access to ShapeEditor
#include "preferences.h"
-#include "removeoverlap/removeoverlap.h"
+#include "removeoverlap.h"
#include "selection.h"
-#include "shape-editor.h" //For node align/distribute methods
#include "sp-flowtext.h"
#include "sp-item-transform.h"
#include "sp-text.h"
#include "text-editing.h"
#include "tools-switch.h"
#include "ui/icon-names.h"
+#include "ui/tool/node-tool.h"
+#include "ui/tool/multi-path-manipulator.h"
#include "util/glib-list-iterators.h"
#include "verbs.h"
#include "widgets/icon.h"
@@ -429,12 +429,13 @@ private :
if (!_dialog.getDesktop()) return;
SPEventContext *event_context = sp_desktop_event_context(_dialog.getDesktop());
- if (!SP_IS_NODE_CONTEXT (event_context)) return ;
+ if (!INK_IS_NODE_TOOL (event_context)) return;
+ InkNodeTool *nt = INK_NODE_TOOL(event_context);
if (_distribute)
- event_context->shape_editor->distribute((Geom::Dim2)_orientation);
+ nt->_multipath->distributeNodes(_orientation);
else
- event_context->shape_editor->align((Geom::Dim2)_orientation);
+ nt->_multipath->alignNodes(_orientation);
}
};
diff --git a/src/ui/dialog/color-item.cpp b/src/ui/dialog/color-item.cpp
new file mode 100644
index 000000000..cb6cfbbbe
--- /dev/null
+++ b/src/ui/dialog/color-item.cpp
@@ -0,0 +1,837 @@
+/** @file
+ * @brief Inkscape color swatch UI item.
+ */
+/* Authors:
+ * Jon A. Cruz
+ *
+ * Copyright (C) 2010 Jon A. Cruz
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include <errno.h>
+#include <glibmm/i18n.h>
+#include <gtkmm/label.h>
+#include <gtk/gtkdnd.h>
+
+#include "color-item.h"
+
+#include "desktop.h"
+#include "desktop-handles.h"
+#include "desktop-style.h"
+#include "display/nr-plain-stuff.h"
+#include "document.h"
+#include "inkscape.h" // for SP_ACTIVE_DESKTOP
+#include "io/resource.h"
+#include "io/sys.h"
+#include "message-context.h"
+#include "sp-gradient.h"
+#include "sp-item.h"
+#include "svg/svg-color.h"
+#include "xml/node.h"
+#include "xml/repr.h"
+
+#include "color.h" // for SP_RGBA32_U_COMPOSE
+
+
+namespace Inkscape {
+namespace UI {
+namespace Dialogs {
+
+static std::vector<std::string> mimeStrings;
+static std::map<std::string, guint> mimeToInt;
+
+
+#if ENABLE_MAGIC_COLORS
+// TODO remove this soon:
+extern std::vector<SwatchPage*> possible;
+#endif // ENABLE_MAGIC_COLORS
+
+
+#if ENABLE_MAGIC_COLORS
+static bool bruteForce( SPDocument* document, Inkscape::XML::Node* node, Glib::ustring const& match, int r, int g, int b )
+{
+ bool changed = false;
+
+ if ( node ) {
+ gchar const * val = node->attribute("inkscape:x-fill-tag");
+ if ( val && (match == val) ) {
+ SPObject *obj = document->getObjectByRepr( node );
+
+ gchar c[64] = {0};
+ sp_svg_write_color( c, sizeof(c), SP_RGBA32_U_COMPOSE( r, g, b, 0xff ) );
+ SPCSSAttr *css = sp_repr_css_attr_new();
+ sp_repr_css_set_property( css, "fill", c );
+
+ sp_desktop_apply_css_recursive( obj, css, true );
+ static_cast<SPItem*>(obj)->updateRepr();
+
+ changed = true;
+ }
+
+ val = node->attribute("inkscape:x-stroke-tag");
+ if ( val && (match == val) ) {
+ SPObject *obj = document->getObjectByRepr( node );
+
+ gchar c[64] = {0};
+ sp_svg_write_color( c, sizeof(c), SP_RGBA32_U_COMPOSE( r, g, b, 0xff ) );
+ SPCSSAttr *css = sp_repr_css_attr_new();
+ sp_repr_css_set_property( css, "stroke", c );
+
+ sp_desktop_apply_css_recursive( (SPItem*)obj, css, true );
+ ((SPItem*)obj)->updateRepr();
+
+ changed = true;
+ }
+
+ Inkscape::XML::Node* first = node->firstChild();
+ changed |= bruteForce( document, first, match, r, g, b );
+
+ changed |= bruteForce( document, node->next(), match, r, g, b );
+ }
+
+ return changed;
+}
+#endif // ENABLE_MAGIC_COLORS
+
+static void handleClick( GtkWidget* /*widget*/, gpointer callback_data ) {
+ ColorItem* item = reinterpret_cast<ColorItem*>(callback_data);
+ if ( item ) {
+ item->buttonClicked(false);
+ }
+}
+
+static void handleSecondaryClick( GtkWidget* /*widget*/, gint /*arg1*/, gpointer callback_data ) {
+ ColorItem* item = reinterpret_cast<ColorItem*>(callback_data);
+ if ( item ) {
+ item->buttonClicked(true);
+ }
+}
+
+static gboolean handleEnterNotify( GtkWidget* /*widget*/, GdkEventCrossing* /*event*/, gpointer callback_data ) {
+ ColorItem* item = reinterpret_cast<ColorItem*>(callback_data);
+ if ( item ) {
+ SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+ if ( desktop ) {
+ gchar* msg = g_strdup_printf(_("Color: <b>%s</b>; <b>Click</b> to set fill, <b>Shift+click</b> to set stroke"),
+ item->def.descr.c_str());
+ desktop->tipsMessageContext()->set(Inkscape::INFORMATION_MESSAGE, msg);
+ g_free(msg);
+ }
+ }
+ return FALSE;
+}
+
+static gboolean handleLeaveNotify( GtkWidget* /*widget*/, GdkEventCrossing* /*event*/, gpointer callback_data ) {
+ ColorItem* item = reinterpret_cast<ColorItem*>(callback_data);
+ if ( item ) {
+ SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+ if ( desktop ) {
+ desktop->tipsMessageContext()->clear();
+ }
+ }
+ return FALSE;
+}
+
+static void dieDieDie( GtkObject *obj, gpointer user_data )
+{
+ g_message("die die die %p %p", obj, user_data );
+}
+
+static bool getBlock( std::string& dst, guchar ch, std::string const str )
+{
+ bool good = false;
+ std::string::size_type pos = str.find(ch);
+ if ( pos != std::string::npos )
+ {
+ std::string::size_type pos2 = str.find( '(', pos );
+ if ( pos2 != std::string::npos ) {
+ std::string::size_type endPos = str.find( ')', pos2 );
+ if ( endPos != std::string::npos ) {
+ dst = str.substr( pos2 + 1, (endPos - pos2 - 1) );
+ good = true;
+ }
+ }
+ }
+ return good;
+}
+
+static bool popVal( guint64& numVal, std::string& str )
+{
+ bool good = false;
+ std::string::size_type endPos = str.find(',');
+ if ( endPos == std::string::npos ) {
+ endPos = str.length();
+ }
+
+ if ( endPos != std::string::npos && endPos > 0 ) {
+ std::string xxx = str.substr( 0, endPos );
+ const gchar* ptr = xxx.c_str();
+ gchar* endPtr = 0;
+ numVal = g_ascii_strtoull( ptr, &endPtr, 10 );
+ if ( (numVal == G_MAXUINT64) && (ERANGE == errno) ) {
+ // overflow
+ } else if ( (numVal == 0) && (endPtr == ptr) ) {
+ // failed conversion
+ } else {
+ good = true;
+ str.erase( 0, endPos + 1 );
+ }
+ }
+
+ return good;
+}
+
+// TODO resolve this more cleanly:
+extern gboolean colorItemHandleButtonPress( GtkWidget* /*widget*/, GdkEventButton* event, gpointer user_data);
+
+static void colorItemDragBegin( GtkWidget */*widget*/, GdkDragContext* dc, gpointer data )
+{
+ ColorItem* item = reinterpret_cast<ColorItem*>(data);
+ if ( item )
+ {
+ using Inkscape::IO::Resource::get_path;
+ using Inkscape::IO::Resource::ICONS;
+ using Inkscape::IO::Resource::SYSTEM;
+ int width = 32;
+ int height = 24;
+
+ if (item->def.getType() != ege::PaintDef::RGB){
+ GError *error = NULL;
+ gsize bytesRead = 0;
+ gsize bytesWritten = 0;
+ gchar *localFilename = g_filename_from_utf8( get_path(SYSTEM, ICONS, "remove-color.png"),
+ -1,
+ &bytesRead,
+ &bytesWritten,
+ &error);
+ GdkPixbuf* pixbuf = gdk_pixbuf_new_from_file_at_scale(localFilename, width, height, FALSE, &error);
+ g_free(localFilename);
+ gtk_drag_set_icon_pixbuf( dc, pixbuf, 0, 0 );
+ } else {
+ GdkPixbuf* pixbuf = 0;
+ if ( item->getGradient() ){
+ guchar* px = g_new( guchar, 3 * height * width );
+ nr_render_checkerboard_rgb( px, width, height, 3 * width, 0, 0 );
+
+ sp_gradient_render_vector_block_rgb( item->getGradient(),
+ px, width, height, 3 * width,
+ 0, width, TRUE );
+
+ pixbuf = gdk_pixbuf_new_from_data( px, GDK_COLORSPACE_RGB, FALSE, 8,
+ width, height, width * 3,
+ 0, // add delete function
+ 0 );
+ } else {
+ Glib::RefPtr<Gdk::Pixbuf> thumb = Gdk::Pixbuf::create( Gdk::COLORSPACE_RGB, false, 8, width, height );
+ guint32 fillWith = (0xff000000 & (item->def.getR() << 24))
+ | (0x00ff0000 & (item->def.getG() << 16))
+ | (0x0000ff00 & (item->def.getB() << 8));
+ thumb->fill( fillWith );
+ pixbuf = thumb->gobj();
+ g_object_ref(G_OBJECT(pixbuf));
+ }
+ gtk_drag_set_icon_pixbuf( dc, pixbuf, 0, 0 );
+ }
+ }
+
+}
+
+//"drag-drop"
+// gboolean dragDropColorData( GtkWidget *widget,
+// GdkDragContext *drag_context,
+// gint x,
+// gint y,
+// guint time,
+// gpointer user_data)
+// {
+// // TODO finish
+
+// return TRUE;
+// }
+
+
+SwatchPage::SwatchPage() :
+ _name(),
+ _prefWidth(0),
+ _colors()
+{
+}
+
+SwatchPage::~SwatchPage()
+{
+}
+
+
+ColorItem::ColorItem(ege::PaintDef::ColorType type) :
+ Previewable(),
+ def(type),
+ tips(),
+ _previews(),
+ _isFill(false),
+ _isStroke(false),
+ _isLive(false),
+ _linkIsTone(false),
+ _linkPercent(0),
+ _linkGray(0),
+ _linkSrc(0),
+ _grad(0),
+ _pixData(0),
+ _pixWidth(0),
+ _pixHeight(0),
+ _listeners()
+{
+}
+
+ColorItem::ColorItem( unsigned int r, unsigned int g, unsigned int b, Glib::ustring& name ) :
+ Previewable(),
+ def( r, g, b, name ),
+ tips(),
+ _previews(),
+ _isFill(false),
+ _isStroke(false),
+ _isLive(false),
+ _linkIsTone(false),
+ _linkPercent(0),
+ _linkGray(0),
+ _linkSrc(0),
+ _grad(0),
+ _pixData(0),
+ _pixWidth(0),
+ _pixHeight(0),
+ _listeners()
+{
+}
+
+ColorItem::~ColorItem()
+{
+}
+
+ColorItem::ColorItem(ColorItem const &other) :
+ Inkscape::UI::Previewable()
+{
+ if ( this != &other ) {
+ *this = other;
+ }
+}
+
+ColorItem &ColorItem::operator=(ColorItem const &other)
+{
+ if ( this != &other ) {
+ def = other.def;
+
+ // TODO - correct linkage
+ _linkSrc = other._linkSrc;
+ g_message("Erk!");
+ }
+ return *this;
+}
+
+void ColorItem::setState( bool fill, bool stroke )
+{
+ if ( (_isFill != fill) || (_isStroke != stroke) ) {
+ _isFill = fill;
+ _isStroke = stroke;
+
+ for ( std::vector<Gtk::Widget*>::iterator it = _previews.begin(); it != _previews.end(); ++it ) {
+ Gtk::Widget* widget = *it;
+ if ( IS_EEK_PREVIEW(widget->gobj()) ) {
+ EekPreview * preview = EEK_PREVIEW(widget->gobj());
+
+ int val = eek_preview_get_linked( preview );
+ val &= ~(PREVIEW_FILL | PREVIEW_STROKE);
+ if ( _isFill ) {
+ val |= PREVIEW_FILL;
+ }
+ if ( _isStroke ) {
+ val |= PREVIEW_STROKE;
+ }
+ eek_preview_set_linked( preview, static_cast<LinkType>(val) );
+ }
+ }
+ }
+}
+
+void ColorItem::setGradient(SPGradient *grad)
+{
+ if (_grad != grad) {
+ _grad = grad;
+ // TODO regen and push to listeners
+ }
+}
+
+void ColorItem::setPixData(guchar* px, int width, int height)
+{
+ if (px != _pixData) {
+ if (_pixData) {
+ g_free(_pixData);
+ }
+ _pixData = px;
+ _pixWidth = width;
+ _pixHeight = height;
+
+ _updatePreviews();
+ }
+}
+
+void ColorItem::_dragGetColorData( GtkWidget */*widget*/,
+ GdkDragContext */*drag_context*/,
+ GtkSelectionData *data,
+ guint info,
+ guint /*time*/,
+ gpointer user_data)
+{
+ ColorItem* item = reinterpret_cast<ColorItem*>(user_data);
+ std::string key;
+ if ( info < mimeStrings.size() ) {
+ key = mimeStrings[info];
+ } else {
+ g_warning("ERROR: unknown value (%d)", info);
+ }
+
+ if ( !key.empty() ) {
+ char* tmp = 0;
+ int len = 0;
+ int format = 0;
+ item->def.getMIMEData(key, tmp, len, format);
+ if ( tmp ) {
+ GdkAtom dataAtom = gdk_atom_intern( key.c_str(), FALSE );
+ gtk_selection_data_set( data, dataAtom, format, (guchar*)tmp, len );
+ delete[] tmp;
+ }
+ }
+}
+
+void ColorItem::_dropDataIn( GtkWidget */*widget*/,
+ GdkDragContext */*drag_context*/,
+ gint /*x*/, gint /*y*/,
+ GtkSelectionData */*data*/,
+ guint /*info*/,
+ guint /*event_time*/,
+ gpointer /*user_data*/)
+{
+}
+
+void ColorItem::_colorDefChanged(void* data)
+{
+ ColorItem* item = reinterpret_cast<ColorItem*>(data);
+ if ( item ) {
+ item->_updatePreviews();
+ }
+}
+
+void ColorItem::_updatePreviews()
+{
+ for ( std::vector<Gtk::Widget*>::iterator it = _previews.begin(); it != _previews.end(); ++it ) {
+ Gtk::Widget* widget = *it;
+ if ( IS_EEK_PREVIEW(widget->gobj()) ) {
+ EekPreview * preview = EEK_PREVIEW(widget->gobj());
+
+ _regenPreview(preview);
+
+ widget->queue_draw();
+ }
+ }
+
+ for ( std::vector<ColorItem*>::iterator it = _listeners.begin(); it != _listeners.end(); ++it ) {
+ guint r = def.getR();
+ guint g = def.getG();
+ guint b = def.getB();
+
+ if ( (*it)->_linkIsTone ) {
+ r = ( ((*it)->_linkPercent * (*it)->_linkGray) + ((100 - (*it)->_linkPercent) * r) ) / 100;
+ g = ( ((*it)->_linkPercent * (*it)->_linkGray) + ((100 - (*it)->_linkPercent) * g) ) / 100;
+ b = ( ((*it)->_linkPercent * (*it)->_linkGray) + ((100 - (*it)->_linkPercent) * b) ) / 100;
+ } else {
+ r = ( ((*it)->_linkPercent * 255) + ((100 - (*it)->_linkPercent) * r) ) / 100;
+ g = ( ((*it)->_linkPercent * 255) + ((100 - (*it)->_linkPercent) * g) ) / 100;
+ b = ( ((*it)->_linkPercent * 255) + ((100 - (*it)->_linkPercent) * b) ) / 100;
+ }
+
+ (*it)->def.setRGB( r, g, b );
+ }
+
+
+#if ENABLE_MAGIC_COLORS
+ // Look for objects using this color
+ {
+ SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+ if ( desktop ) {
+ SPDocument* document = sp_desktop_document( desktop );
+ Inkscape::XML::Node *rroot = sp_document_repr_root( document );
+ if ( rroot ) {
+
+ // Find where this thing came from
+ Glib::ustring paletteName;
+ bool found = false;
+ int index = 0;
+ for ( std::vector<SwatchPage*>::iterator it2 = possible.begin(); it2 != possible.end() && !found; ++it2 ) {
+ SwatchPage* curr = *it2;
+ index = 0;
+ for ( std::vector<ColorItem*>::iterator zz = curr->_colors.begin(); zz != curr->_colors.end(); ++zz ) {
+ if ( this == *zz ) {
+ found = true;
+ paletteName = curr->_name;
+ break;
+ } else {
+ index++;
+ }
+ }
+ }
+
+ if ( !paletteName.empty() ) {
+ gchar* str = g_strdup_printf("%d|", index);
+ paletteName.insert( 0, str );
+ g_free(str);
+ str = 0;
+
+ if ( bruteForce( document, rroot, paletteName, def.getR(), def.getG(), def.getB() ) ) {
+ sp_document_done( document , SP_VERB_DIALOG_SWATCHES,
+ _("Change color definition"));
+ }
+ }
+ }
+ }
+ }
+#endif // ENABLE_MAGIC_COLORS
+
+}
+
+void ColorItem::_regenPreview(EekPreview * preview)
+{
+ if ( def.getType() != ege::PaintDef::RGB ) {
+ using Inkscape::IO::Resource::get_path;
+ using Inkscape::IO::Resource::ICONS;
+ using Inkscape::IO::Resource::SYSTEM;
+ GError *error = NULL;
+ gsize bytesRead = 0;
+ gsize bytesWritten = 0;
+ gchar *localFilename = g_filename_from_utf8( get_path(SYSTEM, ICONS, "remove-color.png"),
+ -1,
+ &bytesRead,
+ &bytesWritten,
+ &error);
+ GdkPixbuf* pixbuf = gdk_pixbuf_new_from_file(localFilename, &error);
+ if (!pixbuf) {
+ g_warning("Null pixbuf for %p [%s]", localFilename, localFilename );
+ }
+ g_free(localFilename);
+
+ eek_preview_set_pixbuf( preview, pixbuf );
+ }
+ else if ( !_pixData ){
+ eek_preview_set_color( preview,
+ (def.getR() << 8) | def.getR(),
+ (def.getG() << 8) | def.getG(),
+ (def.getB() << 8) | def.getB() );
+ } else {
+ GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data( _pixData, GDK_COLORSPACE_RGB, FALSE, 8,
+ _pixWidth, _pixHeight, _pixWidth * 3,
+ 0, // add delete function
+ 0 );
+ eek_preview_set_pixbuf( preview, pixbuf );
+ }
+
+ eek_preview_set_linked( preview, (LinkType)((_linkSrc ? PREVIEW_LINK_IN:0)
+ | (_listeners.empty() ? 0:PREVIEW_LINK_OUT)
+ | (_isLive ? PREVIEW_LINK_OTHER:0)) );
+}
+
+Gtk::Widget* ColorItem::getPreview(PreviewStyle style, ViewType view, ::PreviewSize size, guint ratio)
+{
+ Gtk::Widget* widget = 0;
+ if ( style == PREVIEW_STYLE_BLURB) {
+ Gtk::Label *lbl = new Gtk::Label(def.descr);
+ lbl->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
+ widget = lbl;
+ } else {
+// Glib::ustring blank(" ");
+// if ( size == Inkscape::ICON_SIZE_MENU || size == Inkscape::ICON_SIZE_DECORATION ) {
+// blank = " ";
+// }
+
+ GtkWidget* eekWidget = eek_preview_new();
+ EekPreview * preview = EEK_PREVIEW(eekWidget);
+ Gtk::Widget* newBlot = Glib::wrap(eekWidget);
+
+ _regenPreview(preview);
+
+ eek_preview_set_details( preview, (::PreviewStyle)style, (::ViewType)view, (::PreviewSize)size, ratio );
+
+ def.addCallback( _colorDefChanged, this );
+
+ GValue val = {0, {{0}, {0}}};
+ g_value_init( &val, G_TYPE_BOOLEAN );
+ g_value_set_boolean( &val, FALSE );
+ g_object_set_property( G_OBJECT(preview), "focus-on-click", &val );
+
+/*
+ Gtk::Button *btn = new Gtk::Button(blank);
+ Gdk::Color color;
+ color.set_rgb((_r << 8)|_r, (_g << 8)|_g, (_b << 8)|_b);
+ btn->modify_bg(Gtk::STATE_NORMAL, color);
+ btn->modify_bg(Gtk::STATE_ACTIVE, color);
+ btn->modify_bg(Gtk::STATE_PRELIGHT, color);
+ btn->modify_bg(Gtk::STATE_SELECTED, color);
+
+ Gtk::Widget* newBlot = btn;
+*/
+
+ tips.set_tip((*newBlot), def.descr);
+
+/*
+ newBlot->signal_clicked().connect( sigc::mem_fun(*this, &ColorItem::buttonClicked) );
+
+ sigc::signal<void> type_signal_something;
+*/
+
+ g_signal_connect( G_OBJECT(newBlot->gobj()),
+ "clicked",
+ G_CALLBACK(handleClick),
+ this);
+
+ g_signal_connect( G_OBJECT(newBlot->gobj()),
+ "alt-clicked",
+ G_CALLBACK(handleSecondaryClick),
+ this);
+
+ g_signal_connect( G_OBJECT(newBlot->gobj()),
+ "button-press-event",
+ G_CALLBACK(colorItemHandleButtonPress),
+ this);
+
+ {
+ std::vector<std::string> listing = def.getMIMETypes();
+ int entryCount = listing.size();
+ GtkTargetEntry* entries = new GtkTargetEntry[entryCount];
+ GtkTargetEntry* curr = entries;
+ for ( std::vector<std::string>::iterator it = listing.begin(); it != listing.end(); ++it ) {
+ curr->target = g_strdup(it->c_str());
+ curr->flags = 0;
+ if ( mimeToInt.find(*it) == mimeToInt.end() ){
+ // these next lines are order-dependent:
+ mimeToInt[*it] = mimeStrings.size();
+ mimeStrings.push_back(*it);
+ }
+ curr->info = mimeToInt[curr->target];
+ curr++;
+ }
+ gtk_drag_source_set( GTK_WIDGET(newBlot->gobj()),
+ GDK_BUTTON1_MASK,
+ entries, entryCount,
+ GdkDragAction(GDK_ACTION_MOVE | GDK_ACTION_COPY) );
+ for ( int i = 0; i < entryCount; i++ ) {
+ g_free(entries[i].target);
+ }
+ delete[] entries;
+ }
+
+ g_signal_connect( G_OBJECT(newBlot->gobj()),
+ "drag-data-get",
+ G_CALLBACK(ColorItem::_dragGetColorData),
+ this);
+
+ g_signal_connect( G_OBJECT(newBlot->gobj()),
+ "drag-begin",
+ G_CALLBACK(colorItemDragBegin),
+ this );
+
+ g_signal_connect( G_OBJECT(newBlot->gobj()),
+ "enter-notify-event",
+ G_CALLBACK(handleEnterNotify),
+ this);
+
+ g_signal_connect( G_OBJECT(newBlot->gobj()),
+ "leave-notify-event",
+ G_CALLBACK(handleLeaveNotify),
+ this);
+
+// g_signal_connect( G_OBJECT(newBlot->gobj()),
+// "drag-drop",
+// G_CALLBACK(dragDropColorData),
+// this);
+
+ if ( def.isEditable() )
+ {
+// gtk_drag_dest_set( GTK_WIDGET(newBlot->gobj()),
+// GTK_DEST_DEFAULT_ALL,
+// destColorTargets,
+// G_N_ELEMENTS(destColorTargets),
+// GdkDragAction(GDK_ACTION_COPY | GDK_ACTION_MOVE) );
+
+
+// g_signal_connect( G_OBJECT(newBlot->gobj()),
+// "drag-data-received",
+// G_CALLBACK(_dropDataIn),
+// this );
+ }
+
+ g_signal_connect( G_OBJECT(newBlot->gobj()),
+ "destroy",
+ G_CALLBACK(dieDieDie),
+ this);
+
+
+ widget = newBlot;
+ }
+
+ _previews.push_back( widget );
+
+ return widget;
+}
+
+void ColorItem::buttonClicked(bool secondary)
+{
+ SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+ if (desktop) {
+ char const * attrName = secondary ? "stroke" : "fill";
+
+ SPCSSAttr *css = sp_repr_css_attr_new();
+ Glib::ustring descr;
+ switch (def.getType()) {
+ case ege::PaintDef::CLEAR: {
+ // TODO actually make this clear
+ sp_repr_css_set_property( css, attrName, "none" );
+ descr = secondary? _("Remove stroke color") : _("Remove fill color");
+ break;
+ }
+ case ege::PaintDef::NONE: {
+ sp_repr_css_set_property( css, attrName, "none" );
+ descr = secondary? _("Set stroke color to none") : _("Set fill color to none");
+ break;
+ }
+ case ege::PaintDef::RGB: {
+ Glib::ustring colorspec;
+ if ( _grad ){
+ colorspec = "url(#";
+ colorspec += _grad->getId();
+ colorspec += ")";
+ } else {
+ gchar c[64];
+ guint32 rgba = (def.getR() << 24) | (def.getG() << 16) | (def.getB() << 8) | 0xff;
+ sp_svg_write_color(c, sizeof(c), rgba);
+ colorspec = c;
+ }
+ sp_repr_css_set_property( css, attrName, colorspec.c_str() );
+ descr = secondary? _("Set stroke color from swatch") : _("Set fill color from swatch");
+ break;
+ }
+ }
+ sp_desktop_set_style(desktop, css);
+ sp_repr_css_attr_unref(css);
+
+ sp_document_done( sp_desktop_document(desktop), SP_VERB_DIALOG_SWATCHES, descr.c_str() );
+ }
+}
+
+void ColorItem::_wireMagicColors( SwatchPage *colorSet )
+{
+ if ( colorSet )
+ {
+ for ( std::vector<ColorItem*>::iterator it = colorSet->_colors.begin(); it != colorSet->_colors.end(); ++it )
+ {
+ std::string::size_type pos = (*it)->def.descr.find("*{");
+ if ( pos != std::string::npos )
+ {
+ std::string subby = (*it)->def.descr.substr( pos + 2 );
+ std::string::size_type endPos = subby.find("}*");
+ if ( endPos != std::string::npos )
+ {
+ subby.erase( endPos );
+ //g_message("FOUND MAGIC at '%s'", (*it)->def.descr.c_str());
+ //g_message(" '%s'", subby.c_str());
+
+ if ( subby.find('E') != std::string::npos )
+ {
+ (*it)->def.setEditable( true );
+ }
+
+ if ( subby.find('L') != std::string::npos )
+ {
+ (*it)->_isLive = true;
+ }
+
+ std::string part;
+ // Tint. index + 1 more val.
+ if ( getBlock( part, 'T', subby ) ) {
+ guint64 colorIndex = 0;
+ if ( popVal( colorIndex, part ) ) {
+ guint64 percent = 0;
+ if ( popVal( percent, part ) ) {
+ (*it)->_linkTint( *(colorSet->_colors[colorIndex]), percent );
+ }
+ }
+ }
+
+ // Shade/tone. index + 1 or 2 more val.
+ if ( getBlock( part, 'S', subby ) ) {
+ guint64 colorIndex = 0;
+ if ( popVal( colorIndex, part ) ) {
+ guint64 percent = 0;
+ if ( popVal( percent, part ) ) {
+ guint64 grayLevel = 0;
+ if ( !popVal( grayLevel, part ) ) {
+ grayLevel = 0;
+ }
+ (*it)->_linkTone( *(colorSet->_colors[colorIndex]), percent, grayLevel );
+ }
+ }
+ }
+
+ }
+ }
+ }
+ }
+}
+
+
+void ColorItem::_linkTint( ColorItem& other, int percent )
+{
+ if ( !_linkSrc )
+ {
+ other._listeners.push_back(this);
+ _linkIsTone = false;
+ _linkPercent = percent;
+ if ( _linkPercent > 100 )
+ _linkPercent = 100;
+ if ( _linkPercent < 0 )
+ _linkPercent = 0;
+ _linkGray = 0;
+ _linkSrc = &other;
+
+ ColorItem::_colorDefChanged(&other);
+ }
+}
+
+void ColorItem::_linkTone( ColorItem& other, int percent, int grayLevel )
+{
+ if ( !_linkSrc )
+ {
+ other._listeners.push_back(this);
+ _linkIsTone = true;
+ _linkPercent = percent;
+ if ( _linkPercent > 100 )
+ _linkPercent = 100;
+ if ( _linkPercent < 0 )
+ _linkPercent = 0;
+ _linkGray = grayLevel;
+ _linkSrc = &other;
+
+ ColorItem::_colorDefChanged(&other);
+ }
+}
+
+} // namespace Dialogs
+} // namespace UI
+} // namespace Inkscape
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
diff --git a/src/ui/dialog/color-item.h b/src/ui/dialog/color-item.h
new file mode 100644
index 000000000..4aac86a30
--- /dev/null
+++ b/src/ui/dialog/color-item.h
@@ -0,0 +1,128 @@
+/** @file
+ * @brief Inkscape color swatch UI item.
+ */
+/* Authors:
+ * Jon A. Cruz
+ *
+ * Copyright (C) 2010 Jon A. Cruz
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#ifndef SEEN_DIALOGS_COLOR_ITEM_H
+#define SEEN_DIALOGS_COLOR_ITEM_H
+
+#include <gtkmm/tooltips.h>
+
+#include "widgets/ege-paint-def.h"
+#include "ui/previewable.h"
+
+class SPGradient;
+
+namespace Inkscape {
+namespace UI {
+namespace Dialogs {
+
+class ColorItem;
+
+class SwatchPage
+{
+public:
+ SwatchPage();
+ ~SwatchPage();
+
+ Glib::ustring _name;
+ int _prefWidth;
+ std::vector<ColorItem*> _colors;
+};
+
+
+/**
+ * The color swatch you see on screen as a clickable box.
+ */
+class ColorItem : public Inkscape::UI::Previewable
+{
+ friend void _loadPaletteFile( gchar const *filename );
+public:
+ ColorItem( ege::PaintDef::ColorType type );
+ ColorItem( unsigned int r, unsigned int g, unsigned int b,
+ Glib::ustring& name );
+ virtual ~ColorItem();
+ ColorItem(ColorItem const &other);
+ virtual ColorItem &operator=(ColorItem const &other);
+ virtual Gtk::Widget* getPreview(PreviewStyle style,
+ ViewType view,
+ ::PreviewSize size,
+ guint ratio);
+ void buttonClicked(bool secondary = false);
+
+ void setGradient(SPGradient *grad);
+ SPGradient * getGradient() const { return _grad; }
+
+ void setPixData(guchar* px, int width, int height);
+
+ void setState( bool fill, bool stroke );
+ bool isFill() { return _isFill; }
+ bool isStroke() { return _isStroke; }
+
+ ege::PaintDef def;
+
+private:
+
+ static void _dropDataIn( GtkWidget *widget,
+ GdkDragContext *drag_context,
+ gint x, gint y,
+ GtkSelectionData *data,
+ guint info,
+ guint event_time,
+ gpointer user_data);
+
+ static void _dragGetColorData( GtkWidget *widget,
+ GdkDragContext *drag_context,
+ GtkSelectionData *data,
+ guint info,
+ guint time,
+ gpointer user_data);
+
+ static void _wireMagicColors( SwatchPage *colorSet );
+ static void _colorDefChanged(void* data);
+
+ void _updatePreviews();
+ void _regenPreview(EekPreview * preview);
+
+ void _linkTint( ColorItem& other, int percent );
+ void _linkTone( ColorItem& other, int percent, int grayLevel );
+
+ Gtk::Tooltips tips;
+ std::vector<Gtk::Widget*> _previews;
+
+ bool _isFill;
+ bool _isStroke;
+ bool _isLive;
+ bool _linkIsTone;
+ int _linkPercent;
+ int _linkGray;
+ ColorItem* _linkSrc;
+ SPGradient* _grad;
+ guchar *_pixData;
+ int _pixWidth;
+ int _pixHeight;
+ std::vector<ColorItem*> _listeners;
+};
+
+} // namespace Dialogs
+} // namespace UI
+} // namespace Inkscape
+
+#endif // SEEN_DIALOGS_COLOR_ITEM_H
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
diff --git a/src/ui/dialog/dialog-manager.cpp b/src/ui/dialog/dialog-manager.cpp
index 2116d46c3..30cbed649 100644
--- a/src/ui/dialog/dialog-manager.cpp
+++ b/src/ui/dialog/dialog-manager.cpp
@@ -40,7 +40,6 @@
#include "ui/dialog/icon-preview.h"
#include "ui/dialog/floating-behavior.h"
#include "ui/dialog/dock-behavior.h"
-#include "ui/dialog/spray-option.h"
#include "ui/dialog/print-colors-preview-dialog.h"
#include "preferences.h"
@@ -114,7 +113,6 @@ DialogManager::DialogManager() {
registerFactory("Transformation", &create<Transformation, FloatingBehavior>);
registerFactory("UndoHistory", &create<UndoHistory, FloatingBehavior>);
registerFactory("InputDevices", &create<InputDialog, FloatingBehavior>);
- registerFactory("SprayOptionClass", &create<SprayOptionClass, FloatingBehavior>);
} else {
@@ -142,7 +140,6 @@ DialogManager::DialogManager() {
registerFactory("Transformation", &create<Transformation, DockBehavior>);
registerFactory("UndoHistory", &create<UndoHistory, DockBehavior>);
registerFactory("InputDevices", &create<InputDialog, DockBehavior>);
- registerFactory("SprayOptionClass", &create<SprayOptionClass, DockBehavior>);
}
}
diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp
index a7241ea40..86baa85cd 100644
--- a/src/ui/dialog/document-properties.cpp
+++ b/src/ui/dialog/document-properties.cpp
@@ -222,7 +222,7 @@ DocumentProperties::build_page()
Gtk::Label* label_bor = manage (new Gtk::Label);
label_bor->set_markup (_("<b>Border</b>"));
Gtk::Label *label_for = manage (new Gtk::Label);
- label_for->set_markup (_("<b>Format</b>"));
+ label_for->set_markup (_("<b>Page Size</b>"));
_page_sizer.init();
Gtk::Widget *const widget_array[] =
diff --git a/src/ui/dialog/filedialogimpl-gtkmm.cpp b/src/ui/dialog/filedialogimpl-gtkmm.cpp
index e650cf842..916e3ec97 100644
--- a/src/ui/dialog/filedialogimpl-gtkmm.cpp
+++ b/src/ui/dialog/filedialogimpl-gtkmm.cpp
@@ -521,7 +521,7 @@ bool SVGPreview::set(Glib::ustring &fileName, int dialogType)
return FALSE;
}
long fileLen = info.st_size;
- if (fileLen > 0x150000L)
+ if (fileLen > 0xA00000L)
{
showingNoPreview = false;
showTooLarge(fileLen);
diff --git a/src/ui/dialog/filedialogimpl-win32.cpp b/src/ui/dialog/filedialogimpl-win32.cpp
index d22a368f2..0f3672f25 100644
--- a/src/ui/dialog/filedialogimpl-win32.cpp
+++ b/src/ui/dialog/filedialogimpl-win32.cpp
@@ -61,7 +61,7 @@ namespace Dialog
const int PreviewWidening = 150;
const char PreviewWindowClassName[] = "PreviewWnd";
-const unsigned long MaxPreviewFileSize = 1344; // kB
+const unsigned long MaxPreviewFileSize = 10240; // kB
#define IDC_SHOW_PREVIEW 1000
@@ -454,15 +454,15 @@ UINT_PTR CALLBACK FileOpenDialogImplWin32::GetOpenFileName_hookproc(
pImpl = (FileOpenDialogImplWin32*)ofn->lCustData;
// Subclass the parent
- pImpl->_base_window_proc = (WNDPROC)GetWindowLongPtr(hParentWnd, GWL_WNDPROC);
- SetWindowLongPtr(hParentWnd, GWL_WNDPROC, (LONG_PTR)file_dialog_subclass_proc);
+ pImpl->_base_window_proc = (WNDPROC)GetWindowLongPtr(hParentWnd, GWLP_WNDPROC);
+ SetWindowLongPtr(hParentWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(file_dialog_subclass_proc));
// Add a button to the toolbar
pImpl->_toolbar_wnd = FindWindowEx(hParentWnd, NULL, "ToolbarWindow32", NULL);
pImpl->_show_preview_button_bitmap = LoadBitmap(
hInstance, MAKEINTRESOURCE(IDC_SHOW_PREVIEW));
- TBADDBITMAP tbAddBitmap = {NULL, (UINT)pImpl->_show_preview_button_bitmap};
+ TBADDBITMAP tbAddBitmap = {NULL, reinterpret_cast<UINT_PTR>(pImpl->_show_preview_button_bitmap)};
const int iBitmapIndex = SendMessage(pImpl->_toolbar_wnd,
TB_ADDBITMAP, 1, (LPARAM)&tbAddBitmap);
@@ -1373,10 +1373,10 @@ void FileOpenDialogImplWin32::render_preview()
if(_preview_bitmap_image) // Is the image a pixbuf?
{
// Set the transformation
- const Matrix matrix = {
+ const Cairo::Matrix matrix(
scaleFactor, 0,
0, scaleFactor,
- svgX, svgY };
+ svgX, svgY);
context->set_matrix (matrix);
// Render the image
diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp
index 1345ffe55..132e5fd4e 100644
--- a/src/ui/dialog/filter-effects-dialog.cpp
+++ b/src/ui/dialog/filter-effects-dialog.cpp
@@ -1265,7 +1265,7 @@ void FilterEffectsDialog::FilterModifier::update_filters()
SPFilter* f = (SPFilter*)l->data;
row[_columns.filter] = f;
const gchar* lbl = f->label();
- const gchar* id = SP_OBJECT_ID(f);
+ const gchar* id = f->getId();
row[_columns.label] = lbl ? lbl : (id ? id : "filter");
}
@@ -1485,7 +1485,7 @@ void FilterEffectsDialog::PrimitiveList::update()
row[_columns.primitive] = prim;
row[_columns.type_id] = FPConverter.get_id_from_key(prim->repr->name());
row[_columns.type] = _(FPConverter.get_label(row[_columns.type_id]).c_str());
- row[_columns.id] = SP_OBJECT_ID(prim);
+ row[_columns.id] = prim->getId();
if(prim == active_prim) {
get_selection()->select(row);
diff --git a/src/ui/dialog/icon-preview.cpp b/src/ui/dialog/icon-preview.cpp
index 336afc3c5..088f63031 100644
--- a/src/ui/dialog/icon-preview.cpp
+++ b/src/ui/dialog/icon-preview.cpp
@@ -90,7 +90,7 @@ IconPreviewPanel::IconPreviewPanel() :
std::vector<Glib::ustring> pref_sizes = prefs->getAllDirs("/iconpreview/sizes/default");
std::vector<int> rawSizes;
-
+
for (std::vector<Glib::ustring>::iterator i = pref_sizes.begin(); i != pref_sizes.end(); ++i) {
if (prefs->getBool(*i + "/show", true)) {
int sizeVal = prefs->getInt(*i + "/value", -1);
@@ -215,7 +215,7 @@ void IconPreviewPanel::refreshPreview()
while ( items && !target ) {
SPItem* item = SP_ITEM( items->data );
SPObject * obj = SP_OBJECT(item);
- gchar const *id = SP_OBJECT_ID( obj );
+ gchar const *id = obj->getId();
if ( id ) {
target = obj;
}
@@ -248,7 +248,7 @@ void IconPreviewPanel::modeToggled()
void IconPreviewPanel::renderPreview( SPObject* obj )
{
SPDocument * doc = SP_OBJECT_DOCUMENT(obj);
- gchar * id = SP_OBJECT_ID(obj);
+ gchar const * id = obj->getId();
// g_message(" setting up to render '%s' as the icon", id );
diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp
index 90516063c..40efc8282 100644
--- a/src/ui/dialog/inkscape-preferences.cpp
+++ b/src/ui/dialog/inkscape-preferences.cpp
@@ -433,15 +433,28 @@ void InkscapePreferences::initPageTools()
this->AddPage(_page_node, _("Node"), iter_tools, PREFS_PAGE_TOOLS_NODE);
AddSelcueCheckbox(_page_node, "/tools/nodes", true);
AddGradientCheckbox(_page_node, "/tools/nodes", true);
- _page_node.add_group_header( _("Path outline:"));
+ _page_node.add_group_header( _("Path outline"));
_t_node_pathoutline_color.init(_("Path outline color"), "/tools/nodes/highlight_color", 0xff0000ff);
- _page_node.add_line( false, _("Path outline color"), _t_node_pathoutline_color, "", _("Selects the color used for showing the path outline."), false);
- _t_node_pathflash_enabled.init ( _("Path outline flash on mouse-over"), "/tools/nodes/pathflash_enabled", false);
+ _page_node.add_line( false, "", _t_node_pathoutline_color, "", _("Selects the color used for showing the path outline."), false);
+ _t_node_show_outline.init(_("Always show outline"), "/tools/nodes/show_outline", false);
+ _page_node.add_line( true, "", _t_node_show_outline, "", _("Show outlines for all paths, not only invisible paths"));
+ _t_node_live_outline.init(_("Update outline when dragging nodes"), "/tools/nodes/live_outline", false);
+ _page_node.add_line( true, "", _t_node_live_outline, "", _("Update the outline when dragging or transforming nodes. If this is off, the outline will only update when completing a drag."));
+ _t_node_live_objects.init(_("Update paths when dragging nodes"), "/tools/nodes/live_objects", false);
+ _page_node.add_line( true, "", _t_node_live_objects, "", _("Update paths when dragging or transforming nodes. If this is off, paths will only be updated when completing a drag."));
+ _t_node_show_path_direction.init(_("Show path direction on outlines"), "/tools/nodes/show_path_direction", false);
+ _page_node.add_line( true, "", _t_node_show_path_direction, "", _("Visualize the direction of selected paths by drawing small arrows in the middle of each outline segment"));
+ _t_node_pathflash_enabled.init ( _("Show temporary path outline"), "/tools/nodes/pathflash_enabled", false);
_page_node.add_line( true, "", _t_node_pathflash_enabled, "", _("When hovering over a path, briefly flash its outline."));
- _t_node_pathflash_unselected.init ( _("Suppress path outline flash when one path selected"), "/tools/nodes/pathflash_unselected", false);
- _page_node.add_line( true, "", _t_node_pathflash_unselected, "", _("If a path is selected, do not continue flashing path outlines."));
+ _t_node_pathflash_selected.init ( _("Show temporary outline for selected paths"), "/tools/nodes/pathflash_selected", false);
+ _page_node.add_line( true, "", _t_node_pathflash_selected, "", _("Show temporary outline even when a path is selected for editing"));
_t_node_pathflash_timeout.init("/tools/nodes/pathflash_timeout", 0, 10000.0, 100.0, 100.0, 1000.0, true, false);
_page_node.add_line( false, _("Flash time"), _t_node_pathflash_timeout, "ms", _("Specifies how long the path outline will be visible after a mouse-over (in milliseconds). Specify 0 to have the outline shown until mouse leaves the path."), false);
+ _page_node.add_group_header(_("Editing preferences"));
+ _t_node_single_node_transform_handles.init(_("Show transform handles for single nodes"), "/tools/nodes/single_node_transform_handles", false);
+ _page_node.add_line( true, "", _t_node_single_node_transform_handles, "", _("Show transform handles even when only a single node is selected."));
+ _t_node_delete_preserves_shape.init(_("Deleting nodes preserves shape"), "/tools/nodes/delete_preserves_shape", true);
+ _page_node.add_line( true, "", _t_node_delete_preserves_shape, "", _("Move handles next to deleted nodes to resemble original shape. Hold Ctrl to get the other behavior."));
//Tweak
this->AddPage(_page_tweak, _("Tweak"), iter_tools, PREFS_PAGE_TOOLS_TWEAK);
@@ -657,6 +670,28 @@ void InkscapePreferences::initPageMasks()
_mask_mask_remove.init ( _("Remove clippath/mask object after applying"), "/options/maskobject/remove", true);
_page_mask.add_line(true, "", _mask_mask_remove, "",
_("After applying, remove the object used as the clipping path or mask from the drawing"));
+
+ _page_mask.add_group_header( _("Before applying clippath/mask:"));
+
+ _mask_grouping_none.init( _("Do not group clipped/masked objects"), "/options/maskobject/grouping", PREFS_MASKOBJECT_GROUPING_NONE, true, 0);
+ _mask_grouping_separate.init( _("Enclose every clipped/masked object in its own group"), "/options/maskobject/grouping", PREFS_MASKOBJECT_GROUPING_SEPARATE, false, &_mask_grouping_none);
+ _mask_grouping_all.init( _("Put all clipped/masked objects into one group"), "/options/maskobject/grouping", PREFS_MASKOBJECT_GROUPING_ALL, false, &_mask_grouping_none);
+
+ _page_mask.add_line(true, "", _mask_grouping_none, "",
+ _("Apply clippath/mask to every object"));
+
+ _page_mask.add_line(true, "", _mask_grouping_separate, "",
+ _("Apply clippath/mask to groups containing single object"));
+
+ _page_mask.add_line(true, "", _mask_grouping_all, "",
+ _("Apply clippath/mask to group containing all objects"));
+
+ _page_mask.add_group_header( _("After releasing clippath/mask:"));
+
+ _mask_ungrouping.init ( _("Ungroup automatically created groups"), "/options/maskobject/ungrouping", true);
+ _page_mask.add_line(true, "", _mask_ungrouping, "",
+ _("Ungroup groups created when setting clip/mask"));
+
this->AddPage(_page_mask, _("Clippaths and masks"), PREFS_PAGE_MASKS);
}
@@ -987,7 +1022,7 @@ void InkscapePreferences::initPageGrids()
_page_grids.add_line( false, "", _grids_notebook, "", "", false);
_grids_notebook.append_page(_grids_xy, CanvasGrid::getName( GRID_RECTANGULAR ));
_grids_notebook.append_page(_grids_axonom, CanvasGrid::getName( GRID_AXONOMETRIC ));
- _grids_xy_units.init("/options/grids/units");
+ _grids_xy_units.init("/options/grids/xy/units");
_grids_xy.add_line( false, _("Grid units:"), _grids_xy_units, "", "", false);
_grids_xy_origin_x.init("/options/grids/xy/origin_x", -10000.0, 10000.0, 0.1, 1.0, 0.0, false, false);
_grids_xy_origin_y.init("/options/grids/xy/origin_y", -10000.0, 10000.0, 0.1, 1.0, 0.0, false, false);
@@ -1069,7 +1104,7 @@ void InkscapePreferences::initPageUI()
_("Chinese/Taiwan (zh_TW)"), _("Croatian (hr)"), _("Czech (cs)"),
_("Danish (da)"), _("Dutch (nl)"), _("Dzongkha (dz)"), _("German (de)"), _("Greek (el)"), _("English (en)"), _("English/Australia (en_AU)"),
_("English/Canada (en_CA)"), _("English/Great Britain (en_GB)"), _("Pig Latin (en_US@piglatin)"),
- _("Esperanto (eo)"), _("Estonian (et)"), _("Finnish (fi)"),
+ _("Esperanto (eo)"), _("Estonian (et)"), _("Farsi (fa)"), _("Finnish (fi)"),
_("French (fr)"), _("Irish (ga)"), _("Galician (gl)"), _("Hebrew (he)"), _("Hungarian (hu)"),
_("Indonesian (id)"), _("Italian (it)"), _("Japanese (ja)"), _("Khmer (km)"), _("Kinyarwanda (rw)"), _("Korean (ko)"), _("Lithuanian (lt)"), _("Macedonian (mk)"),
_("Mongolian (mn)"), _("Nepali (ne)"), _("Norwegian Bokmål (nb)"), _("Norwegian Nynorsk (nn)"), _("Panjabi (pa)"),
@@ -1077,7 +1112,7 @@ void InkscapePreferences::initPageUI()
_("Serbian (sr)"), _("Serbian in Latin script (sr@latin)"), _("Slovak (sk)"), _("Slovenian (sl)"), _("Spanish (es)"), _("Spanish/Mexico (es_MX)"),
_("Swedish (sv)"), _("Thai (th)"), _("Turkish (tr)"), _("Ukrainian (uk)"), _("Vietnamese (vi)")};
Glib::ustring langValues[] = {"", "sq", "am", "ar", "hy", "az", "eu", "be", "bg", "bn", "br", "ca", "ca@valencia", "zh_CN", "zh_TW", "hr", "cs", "da", "nl",
- "dz", "de", "el", "en", "en_AU", "en_CA", "en_GB", "en_US@piglatin", "eo", "et", "fi", "fr", "ga",
+ "dz", "de", "el", "en", "en_AU", "en_CA", "en_GB", "en_US@piglatin", "eo", "et", "fa", "fi", "fr", "ga",
"gl", "he", "hu", "id", "it", "ja", "km", "rw", "ko", "lt", "mk", "mn", "ne", "nb", "nn", "pa",
"pl", "pt", "pt_BR", "ro", "ru", "sr", "sr@latin", "sk", "sl", "es", "es_MX", "sv", "th", "tr", "uk", "vi" };
@@ -1121,6 +1156,12 @@ void InkscapePreferences::initPageUI()
_page_ui.add_line( false, _("Zoom correction factor (in %):"), _ui_zoom_correction, "",
_("Adjust the slider until the length of the ruler on your screen matches its real length. This information is used when zooming to 1:1, 1:2, etc., to display objects in their true sizes"), true);
+
+ _ui_partialdynamic.init( _("Enable dynamic relayout for incomplete sections."), "/options/workarounds/dynamicnotdone", false);
+ _page_ui.add_line( false, "", _ui_partialdynamic, "",
+ _("When on, will allow dynamic layout of components that are not completely finished being refactored."), true);
+
+
this->AddPage(_page_ui, _("Interface"), PREFS_PAGE_UI);
}
diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h
index 16e62df59..0ba8c965d 100644
--- a/src/ui/dialog/inkscape-preferences.h
+++ b/src/ui/dialog/inkscape-preferences.h
@@ -141,9 +141,15 @@ protected:
PrefRadioButton _t_sel_trans_obj, _t_sel_trans_outl, _t_sel_cue_none, _t_sel_cue_mark,
_t_sel_cue_box, _t_bbox_visual, _t_bbox_geometric;
PrefCheckButton _t_cvg_keep_objects, _t_cvg_convert_whole_groups;
+ PrefCheckButton _t_node_show_outline;
+ PrefCheckButton _t_node_live_outline;
+ PrefCheckButton _t_node_live_objects;
PrefCheckButton _t_node_pathflash_enabled;
- PrefCheckButton _t_node_pathflash_unselected;
+ PrefCheckButton _t_node_pathflash_selected;
PrefSpinButton _t_node_pathflash_timeout;
+ PrefCheckButton _t_node_show_path_direction;
+ PrefCheckButton _t_node_single_node_transform_handles;
+ PrefCheckButton _t_node_delete_preserves_shape;
PrefColorPicker _t_node_pathoutline_color;
PrefRadioButton _win_dockable, _win_floating;
@@ -167,6 +173,8 @@ protected:
PrefCheckButton _mask_mask_on_top;
PrefCheckButton _mask_mask_remove;
+ PrefRadioButton _mask_grouping_none, _mask_grouping_separate, _mask_grouping_all;
+ PrefCheckButton _mask_ungrouping;
PrefRadioButton _blur_quality_best, _blur_quality_better, _blur_quality_normal, _blur_quality_worse, _blur_quality_worst;
PrefRadioButton _filter_quality_best, _filter_quality_better, _filter_quality_normal, _filter_quality_worse, _filter_quality_worst;
@@ -197,6 +205,7 @@ protected:
PrefCombo _misc_small_tools;
PrefCheckButton _ui_colorsliders_top;
PrefSpinButton _misc_recent;
+ PrefCheckButton _ui_partialdynamic;
ZoomCorrRulerSlider _ui_zoom_correction;
//Spellcheck
diff --git a/src/ui/dialog/layers.cpp b/src/ui/dialog/layers.cpp
index a06b6c9b6..98bf236fc 100644
--- a/src/ui/dialog/layers.cpp
+++ b/src/ui/dialog/layers.cpp
@@ -304,7 +304,7 @@ bool LayersPanel::_checkForUpdated(const Gtk::TreePath &/*path*/, const Gtk::Tre
Glib::ustring tmp = row[_model->_colLabel];
if ( layer == row[_model->_colObject] )
{
- row[_model->_colLabel] = layer->label() ? layer->label() : SP_OBJECT_ID(layer);
+ row[_model->_colLabel] = layer->label() ? layer->label() : layer->getId();
row[_model->_colVisible] = SP_IS_ITEM(layer) ? !SP_ITEM(layer)->isHidden() : false;
row[_model->_colLocked] = SP_IS_ITEM(layer) ? SP_ITEM(layer)->isLocked() : false;
@@ -381,7 +381,7 @@ void LayersPanel::_addLayer( SPDocument* doc, SPObject* layer, Gtk::TreeModel::R
Gtk::TreeModel::iterator iter = parentRow ? _store->prepend(parentRow->children()) : _store->prepend();
Gtk::TreeModel::Row row = *iter;
row[_model->_colObject] = child;
- row[_model->_colLabel] = child->label() ? child->label() : SP_OBJECT_ID(child);
+ row[_model->_colLabel] = child->label() ? child->label() : child->getId();
row[_model->_colVisible] = SP_IS_ITEM(child) ? !SP_ITEM(child)->isHidden() : false;
row[_model->_colLocked] = SP_IS_ITEM(child) ? SP_ITEM(child)->isLocked() : false;
diff --git a/src/ui/dialog/spray-option.cpp b/src/ui/dialog/spray-option.cpp
deleted file mode 100644
index a9e037381..000000000
--- a/src/ui/dialog/spray-option.cpp
+++ /dev/null
@@ -1,397 +0,0 @@
-/*Julien LERAY (julien.leray@ecl2010.ec-lyon.fr), interface for the spray tool*/
-
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <gtkmm/spinbutton.h>
-
-#include "desktop-handles.h"
-#include "unclump.h"
-#include "document.h"
-#include "enums.h"
-#include "graphlayout/graphlayout.h"
-#include "inkscape.h"
-#include "macros.h"
-#include "node-context.h"
-#include "preferences.h"
-#include "removeoverlap/removeoverlap.h"
-#include "selection.h"
-#include "shape-editor.h"
-#include "sp-flowtext.h"
-#include "sp-item-transform.h"
-#include "sp-text.h"
-#include "text-editing.h"
-#include "tools-switch.h"
-#include "ui/icon-names.h"
-#include "util/glib-list-iterators.h"
-#include "verbs.h"
-#include "widgets/icon.h"
-
-#include "spray-option.h"
-
-namespace Inkscape {
-namespace UI {
-namespace Dialog {
-
-
-//Classes qui permettent de créer les environnements Gaussienne, Witdh...
-
-
-
-class Action {
-public:
- Action(const Glib::ustring &id,
- const Glib::ustring &/*tiptext*/,
- guint /*row*/,
- guint /*column*/,
- Gtk::Table &parent,
- Gtk::Tooltips &/*tooltips*/,
- SprayOptionClass &dialog):
- _dialog(dialog),
- _id(id),
- _parent(parent) {}
-
- virtual ~Action(){}
- virtual void on_button_click(){}
- SprayOptionClass &_dialog;
-
-private :
-
- Glib::ustring _id;
- Gtk::Table &_parent;
-};
-
-class ActionE : public Action {
-private:
- Gtk::Label _Label;
- Gtk::SpinButton _Gap;
- guint _min, _max;
- Glib::ustring _pref_path;
-
-public:
- ActionE(const Glib::ustring &id,
- const Glib::ustring &tiptext,
- guint row, guint column,
- SprayOptionClass &dialog,
- guint min, guint max,
- Glib::ustring const &pref_path ):
- Action(id, tiptext, row, column,
- dialog._Table(), dialog.tooltips(), dialog),
- _min(min),
- _max(max),
- _pref_path(pref_path)
- {
- dialog._Table().set_col_spacings(3);
-
- double increm = ((double)_max - (double)_min)/10;
- double val_ini = ((double)_max + (double)_min)/2;
- _Gap.set_digits(1);
- _Gap.set_size_request(60, -1);
- _Gap.set_increments(increm , 0);
- _Gap.set_range(_min, _max);
- _Gap.set_value(val_ini);
- dialog.tooltips().set_tip(_Gap,
- tiptext);
- _Gap.signal_changed().connect(sigc::mem_fun(*this, &ActionE::on_button_click)); //rajout douteux
- _Label.set_label(id);
-
- dialog._Table().attach(_Label, column, column+1, row, row+1, Gtk::FILL, Gtk::FILL);
- dialog._Table().attach(_Gap, column+1, column+2, row, row+1, Gtk::EXPAND, Gtk::EXPAND);
- }
-
- virtual void on_button_click(){
- if (!_dialog.getDesktop()) return;
-
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
-
- prefs->setDouble(_pref_path, SP_VERB_CONTEXT_SPRAY);
-
- double const Gap = _Gap.get_value();
-
-
- prefs->setDouble(_pref_path, Gap);
-
- sp_document_done(sp_desktop_document(_dialog.getDesktop()), SP_VERB_CONTEXT_SPRAY,
- _("Remove overlaps"));
- }
-
-
-};
-
-class ActionF : public Action {
-private:
- Gtk::Label _Label;
- Gtk::Label _Label1;
- Gtk::Label _Label2;
- Gtk::SpinButton _Gap1;
- Gtk::SpinButton _Gap2;
- Glib::ustring _pref1_path;
- Glib::ustring _pref2_path;
-
-public:
- ActionF(const Glib::ustring &id,
- const Glib::ustring &tiptext,
- guint row, guint column,
- SprayOptionClass &dialog,
- Glib::ustring const &pref1_path,
- Glib::ustring const &pref2_path ):
- Action(id, tiptext, row, column,
- dialog._Table(), dialog.tooltips(), dialog),
- _pref1_path(pref1_path),
- _pref2_path(pref2_path)
- {
- dialog.F_Table().set_col_spacings(3);
-
- _Label.set_label(id);
-
- _Gap1.set_digits(1);
- _Gap1.set_size_request(60, -1);
- _Gap1.set_increments(0.1, 0);
- _Gap1.set_range(0, 10);
- _Gap1.set_value(1);
- dialog.tooltips().set_tip(_Gap1,
- _("Minimum"));
-
- _Label1.set_label(Q_("Min"));
-
- _Gap2.set_digits(1);
- _Gap2.set_size_request(60, -1);
- _Gap2.set_increments(0.1, 0);
- _Gap2.set_range(0, 10);
- _Gap2.set_value(1);
- dialog.tooltips().set_tip(_Gap2,
- _("Maximum"));
-
- _Label2.set_label(_("Max:"));
-
- _Gap1.signal_changed().connect(sigc::mem_fun(*this, &ActionF::on_button_click));
- _Gap2.signal_changed().connect(sigc::mem_fun(*this, &ActionF::on_button_click));
-
- dialog.F_Table().attach(_Label, column, column+1, row, row+1, Gtk::FILL, Gtk::FILL);
- dialog.F_Table().attach(_Label1, column+1, column+2, row, row+1, Gtk::FILL, Gtk::FILL);
- dialog.F_Table().attach(_Gap1, column+2, column+3, row, row+1, Gtk::EXPAND, Gtk::EXPAND);
- dialog.F_Table().attach(_Label2, column+3, column+4, row, row+1, Gtk::FILL, Gtk::FILL);
- dialog.F_Table().attach(_Gap2, column+4, column+5, row, row+1, Gtk::EXPAND, Gtk::EXPAND);
-
- }
-
- virtual void on_button_click(){
- if (!_dialog.getDesktop()) return;
-
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
-
- prefs->setDouble(_pref1_path, SP_VERB_CONTEXT_SPRAY);
- prefs->setDouble(_pref2_path, SP_VERB_CONTEXT_SPRAY);
-
- double const Gap1 = _Gap1.get_value();
- double const Gap2 = _Gap2.get_value();
-
- prefs->setDouble(_pref1_path, Gap1);
- prefs->setDouble(_pref2_path, Gap2);
-
- sp_document_done(sp_desktop_document(_dialog.getDesktop()), SP_VERB_CONTEXT_SPRAY,
- _("Remove overlaps"));
- }
-
-
-};
-
-
-
-void SprayOptionClass::combo_action() {
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- cout<<"combo.get_active_row_number = "<<_combo.get_active_row_number()<<endl;
-
- int const distrib = _combo.get_active_row_number();
-
- prefs->setInt("/tools/spray/distribution", distrib);
-
-
- sp_document_done(sp_desktop_document(this->getDesktop()), SP_VERB_CONTEXT_SPRAY,
- _("Remove overlaps"));
-
-}
-
-
-
-
-void SprayOptionClass::action() {
- for (list<Action *>::iterator it = _actionList.begin(); it != _actionList.end(); ++it) {
- (*it)->on_button_click();
- }
- combo_action();
-}
-
-
-
-
-
-
-void on_selection_changed(Inkscape::Application */*inkscape*/, Inkscape::Selection */*selection*/, SprayOptionClass *daad)
-{
- daad->randomize_bbox = Geom::OptRect();
-}
-
-/////////////////////////////////////////////////////////
-//Construction de l'interface
-/////////////////////////////////////////////////////////
-
-
-SprayOptionClass::SprayOptionClass()
- : UI::Widget::Panel ("", "/dialogs/spray", SP_VERB_DIALOG_SPRAY_OPTION),
- _actionList(),
- _distributionFrame(Q_("sprayOptions|Distribution")),
- _Frame(Q_("sprayOptions|Cursor Options")),
- _FFrame(Q_("sprayOptions|Random Options")),
- _distributionTable(),
- _gaussianTable(1, 5, false),
- _ETable(3,2,false),
- _FTable(2,5,false),
- _anchorBox(),
- _unifBox(),
- _gaussianBox(),
- _HBox(),
- _FHBox(),
- _BoutonBox(),
- _distributionBox(),
- _VBox(),
- _FVBox(),
- _ActionBox(),
- _anchorLabel(Q_("sprayOptions|Distribution:")),
- _unifLabel(Q_("sprayOptions|Uniform")),
- _gaussLabel(Q_("sprayOptions|Gaussian")),
- _Label(),
- _FLabel(),
- _unif(),
- _gauss(),
- _combo(),
- _tooltips()
-{
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
-
- //ComboBoxText
-
- _combo.append_text(Q_("sprayOptions|Uniform"));
- _combo.append_text(Q_("sprayOptions|Gaussian"));
-
- _combo.set_active(prefs->getInt("/tools/spray/distribution", 1));
- _combo.signal_changed().connect(sigc::mem_fun(*this, &SprayOptionClass::combo_action));
-
- _anchorBox.pack_start(_anchorLabel);
- _anchorBox.pack_start(_combo);
-
- _gaussianBox.pack_start(_anchorBox);
-
-
- _distributionBox.pack_start(_gaussianBox);
- _distributionFrame.add(_distributionBox);
-
-
- //Hbox Random
- addFButton(Q_("sprayOptions|Scale:") ,_("Apply a scale factor"), 0, 0, "/tools/spray/scale_min","/tools/spray/scale_max");
- addFButton(Q_("sprayOptions|Rotation:") ,_("Apply rotation"), 1, 0, "/tools/spray/rot_min","/tools/spray/rot_max");
- _FHBox.pack_start(_FLabel);
- _FHBox.pack_start(_FTable);
-
- //Implementation dans la Vbox Cursor
- _FVBox.pack_start(_FHBox);
- _FFrame.add(_FVBox);
-
- //Hbox Cursor
- addEButton(Q_("sprayOptions|Ratio:") ,_("Eccentricity of the ellipse"), 0, 0, 0, 1,"/tools/spray/ratio");
- addEButton(Q_("sprayOptions|Angle:") ,_("Angle of the ellipse"), 1, 0, 0, 5,"/tools/spray/tilt");
- addEButton(Q_("sprayOptions|Width:") ,_("Size of the ellipse"), 2, 0, 0, 1,"/tools/spray/width");
- _HBox.pack_start(_Label);
- _HBox.pack_start(_ETable);
-
- //Implementation dans la Vbox Cursor
- _VBox.pack_start(_HBox);
- _Frame.add(_VBox);
-
- Gtk::Box *contents = _getContents();
- contents->set_spacing(4);
-
-
-
-
-
-
- // Crée dans l'ordre suivant les différentes Frames (cadres de réglages)
-
- contents->pack_start(_distributionFrame, true, true);
- contents->pack_start(_FFrame, true, true);
- contents->pack_start(_Frame, true, true);
-
-
-
- // Connect to the global selection change, to invalidate cached randomize_bbox
- g_signal_connect (G_OBJECT (INKSCAPE), "change_selection", G_CALLBACK (on_selection_changed), this);
- randomize_bbox = Geom::OptRect();
-
- show_all_children();
-
-
-
-}
-
-SprayOptionClass::~SprayOptionClass()
-{
- sp_signal_disconnect_by_data (G_OBJECT (INKSCAPE), this);
-
- for (std::list<Action *>::iterator it = _actionList.begin();
- it != _actionList.end();
- it ++)
- delete *it;
-}
-
-
-
-
-
-
-
-//Fonctions qui lient la demande d'ajout d'une interface graphique à l'action correspondante
-
-void SprayOptionClass::addEButton(const Glib::ustring &id,
- const Glib::ustring &tiptext,
- guint row, guint column,
- guint min, guint max,
- Glib::ustring const &pref_path)
-{
- _actionList.push_back( new ActionE(id, tiptext,row, column,*this,min ,max, pref_path ));
-}
-
-void SprayOptionClass::addFButton(const Glib::ustring &id,
- const Glib::ustring &tiptext,
- guint row, guint column,
- Glib::ustring const &pref1_path,
- Glib::ustring const &pref2_path)
-{
- _actionList.push_back( new ActionF(id, tiptext,row, column,*this,pref1_path, pref2_path ));
-}
-
-
-
-
-
-SprayOptionClass &SprayOptionClass::get_SprayOptionClass()
-{
- return *this;
-}
-
-} // namespace Dialog
-} // namespace UI
-} // namespace Inkscape
-
-/*
- Local Variables:
- mode:c++
- c-file-style:"stroustrup"
- c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
- indent-tabs-mode:nil
- fill-column:99
- End:
-*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
diff --git a/src/ui/dialog/spray-option.h b/src/ui/dialog/spray-option.h
deleted file mode 100644
index 42090a120..000000000
--- a/src/ui/dialog/spray-option.h
+++ /dev/null
@@ -1,145 +0,0 @@
-
-/*Julien LERAY (julien.leray@ecl2010.ec-lyon.fr), interface for the spray tool*/
-
-#ifndef INKSCAPE_UI_DIALOG_SPRAY_OPTION_H
-#define INKSCAPE_UI_DIALOG_SPRAY_OPTION_H
-
-#include <gtkmm/notebook.h>
-#include <glibmm/i18n.h>
-
-#include <list>
-#include <gtkmm/frame.h>
-#include <gtkmm/tooltips.h>
-#include <gtkmm/comboboxtext.h>
-#include <gtkmm/table.h>
-#include <gtkmm/buttonbox.h>
-#include <gtkmm/label.h>
-#include "libnr/nr-dim2.h"
-#include "libnr/nr-rect.h"
-
-
-#include "ui/widget/panel.h"
-#include "ui/widget/notebook-page.h"
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <gtkmm/spinbutton.h>
-#include "desktop-handles.h"
-#include "unclump.h"
-#include "document.h"
-#include "enums.h"
-#include "graphlayout/graphlayout.h"
-#include "inkscape.h"
-#include "macros.h"
-#include "node-context.h"
-#include "preferences.h"
-#include "removeoverlap/removeoverlap.h"
-#include "selection.h"
-#include "shape-editor.h"
-#include "sp-flowtext.h"
-#include "sp-item-transform.h"
-#include "sp-text.h"
-#include "text-editing.h"
-#include "tools-switch.h"
-#include "ui/icon-names.h"
-#include "util/glib-list-iterators.h"
-#include "verbs.h"
-#include "widgets/icon.h"
-
-#include "spray-context.h"
-#include "verbs.h"
-
-#include <iostream>
-using namespace std;
-
-using namespace Inkscape::UI::Widget;
-
-class SPItem;
-
-
-namespace Inkscape {
-namespace UI {
-namespace Dialog {
-
-class Action;
-
-class SprayOptionClass : public Widget::Panel {
-
-private:
-
- SprayOptionClass(SprayOptionClass const &d);
- SprayOptionClass& operator=(SprayOptionClass const &d);
-
-public:
- SprayOptionClass();
- virtual ~SprayOptionClass();
- void test() { cout<<"appel de test !!"<<endl; }
- static SprayOptionClass &getInstance() { return *new SprayOptionClass(); }
-
-
- Gtk::Table &_Table(){return _ETable;}
- Gtk::Table &F_Table(){return _FTable;}
- Gtk::Tooltips &tooltips(){return _tooltips;}
- void action();
- void combo_action();
- Geom::OptRect randomize_bbox;
-
- SprayOptionClass &get_SprayOptionClass();
-
-protected:
-
- void addGaussianButton(guint row, guint col);
- void addEButton(const Glib::ustring &id, const Glib::ustring &tiptext, guint row, guint column,
- guint min, guint max, const Glib::ustring &pref_path);
- void addFButton(const Glib::ustring &id, const Glib::ustring &tiptext, guint row, guint column,
- const Glib::ustring &pref1_path, const Glib::ustring &pref2_path);
-
- std::list<Action *> _actionList;
- Gtk::Frame _distributionFrame;
- Gtk::Frame _Frame;
- Gtk::Frame _FFrame;
- Gtk::Table _distributionTable;
- Gtk::Table _gaussianTable;
- Gtk::Table _ETable;
- Gtk::Table _FTable;
- Gtk::HBox _anchorBox;
- Gtk::HBox _unifBox;
- Gtk::HBox _gaussianBox;
- Gtk::HBox _HBox;
- Gtk::HBox _FHBox;
- Gtk::HBox _BoutonBox;
- Gtk::VBox _distributionBox;
- Gtk::VBox _VBox;
- Gtk::VBox _FVBox;
- Gtk::VBox _ActionBox;
- Gtk::Label _anchorLabel;
- Gtk::Label _unifLabel;
- Gtk::Label _gaussLabel;
- Gtk::Label _Label;
- Gtk::Label _FLabel;
- Gtk::CheckButton _unif;
- Gtk::CheckButton _gauss;
- Gtk::ComboBoxText _combo;
- Gtk::Tooltips _tooltips;
-};
-
-
-} // namespace Dialog
-} // namespace UI
-} // namespace Inkscape
-
-#endif // INKSCAPE_UI_DIALOG_ALIGN_AND_DISTRIBUTE_H
-
-/*
- Local Variables:
- mode:c++
- c-file-style:"stroustrup"
- c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
- indent-tabs-mode:nil
- fill-column:99
- End:
-*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
-
diff --git a/src/ui/dialog/svg-fonts-dialog.cpp b/src/ui/dialog/svg-fonts-dialog.cpp
index cb22e029b..998f4e1e1 100644
--- a/src/ui/dialog/svg-fonts-dialog.cpp
+++ b/src/ui/dialog/svg-fonts-dialog.cpp
@@ -252,7 +252,7 @@ void SvgFontsDialog::update_fonts()
row[_columns.spfont] = f;
row[_columns.svgfont] = new SvgFont(f);
const gchar* lbl = f->label();
- const gchar* id = SP_OBJECT_ID(f);
+ const gchar* id = f->getId();
row[_columns.label] = lbl ? lbl : (id ? id : "font");
}
@@ -653,7 +653,7 @@ Gtk::VBox* SvgFontsDialog::glyphs_tab(){
missing_glyph_button.signal_clicked().connect(sigc::mem_fun(*this, &SvgFontsDialog::missing_glyph_description_from_selected_path));
missing_glyph_reset_button.set_label(_("Reset"));
missing_glyph_reset_button.signal_clicked().connect(sigc::mem_fun(*this, &SvgFontsDialog::reset_missing_glyph_description));
-
+
glyphs_vbox.pack_start(*missing_glyph_hbox, false,false);
glyphs_vbox.add(_GlyphsListScroller);
diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp
index 450d4202d..6f013f4f3 100644
--- a/src/ui/dialog/swatches.cpp
+++ b/src/ui/dialog/swatches.cpp
@@ -1,3 +1,4 @@
+
/** @file
* @brief Color swatches dialog
*/
@@ -22,6 +23,7 @@
#include <glibmm/i18n.h>
#include <gdkmm/pixbuf.h>
+#include "color-item.h"
#include "desktop.h"
#include "desktop-handles.h"
#include "desktop-style.h"
@@ -36,278 +38,36 @@
#include "path-prefix.h"
#include "preferences.h"
#include "sp-item.h"
-#include "svg/svg-color.h"
#include "sp-gradient-fns.h"
#include "sp-gradient.h"
#include "sp-gradient-vector.h"
#include "swatches.h"
#include "style.h"
+#include "ui/previewholder.h"
#include "widgets/gradient-vector.h"
#include "widgets/eek-preview.h"
#include "display/nr-plain-stuff.h"
#include "sp-gradient-reference.h"
-#define USE_DOCUMENT_PALETTE 1
namespace Inkscape {
namespace UI {
namespace Dialogs {
#define VBLOCK 16
+#define PREVIEW_PIXBUF_WIDTH 128
void _loadPaletteFile( gchar const *filename );
-/**
- * The color swatch you see on screen as a clickable box.
- */
-class ColorItem : public Inkscape::UI::Previewable
-{
- friend void _loadPaletteFile( gchar const *filename );
-public:
- ColorItem( ege::PaintDef::ColorType type );
- ColorItem( unsigned int r, unsigned int g, unsigned int b,
- Glib::ustring& name );
- virtual ~ColorItem();
- ColorItem(ColorItem const &other);
- virtual ColorItem &operator=(ColorItem const &other);
- virtual Gtk::Widget* getPreview(PreviewStyle style,
- ViewType view,
- ::PreviewSize size,
- guint ratio);
- void buttonClicked(bool secondary = false);
-
- void setState( bool fill, bool stroke );
- bool isFill() { return _isFill; }
- bool isStroke() { return _isStroke; }
-
- ege::PaintDef def;
- void* ptr;
-
-private:
- static void _dropDataIn( GtkWidget *widget,
- GdkDragContext *drag_context,
- gint x, gint y,
- GtkSelectionData *data,
- guint info,
- guint event_time,
- gpointer user_data);
-
- static void _dragGetColorData( GtkWidget *widget,
- GdkDragContext *drag_context,
- GtkSelectionData *data,
- guint info,
- guint time,
- gpointer user_data);
-
- static void _wireMagicColors( void* p );
- static void _colorDefChanged(void* data);
-
- void _linkTint( ColorItem& other, int percent );
- void _linkTone( ColorItem& other, int percent, int grayLevel );
-
- Gtk::Tooltips tips;
- std::vector<Gtk::Widget*> _previews;
-
- bool _isFill;
- bool _isStroke;
- bool _isLive;
- bool _linkIsTone;
- int _linkPercent;
- int _linkGray;
- ColorItem* _linkSrc;
- std::vector<ColorItem*> _listeners;
-};
-
-
-
-ColorItem::ColorItem(ege::PaintDef::ColorType type) :
- def(type),
- ptr(0),
- _isFill(false),
- _isStroke(false),
- _isLive(false),
- _linkIsTone(false),
- _linkPercent(0),
- _linkGray(0),
- _linkSrc(0)
-{
-}
-
-ColorItem::ColorItem( unsigned int r, unsigned int g, unsigned int b, Glib::ustring& name ) :
- def( r, g, b, name ),
- ptr(0),
- _isFill(false),
- _isStroke(false),
- _isLive(false),
- _linkIsTone(false),
- _linkPercent(0),
- _linkGray(0),
- _linkSrc(0)
-{
-}
-
-ColorItem::~ColorItem()
-{
-}
-
-ColorItem::ColorItem(ColorItem const &other) :
- Inkscape::UI::Previewable()
-{
- if ( this != &other ) {
- *this = other;
- }
-}
-
-ColorItem &ColorItem::operator=(ColorItem const &other)
-{
- if ( this != &other ) {
- def = other.def;
-
- // TODO - correct linkage
- _linkSrc = other._linkSrc;
- g_message("Erk!");
- }
- return *this;
-}
-
-void ColorItem::setState( bool fill, bool stroke )
-{
- if ( (_isFill != fill) || (_isStroke != stroke) ) {
- _isFill = fill;
- _isStroke = stroke;
-
- for ( std::vector<Gtk::Widget*>::iterator it = _previews.begin(); it != _previews.end(); ++it ) {
- Gtk::Widget* widget = *it;
- if ( IS_EEK_PREVIEW(widget->gobj()) ) {
- EekPreview * preview = EEK_PREVIEW(widget->gobj());
-
- int val = eek_preview_get_linked( preview );
- val &= ~(PREVIEW_FILL | PREVIEW_STROKE);
- if ( _isFill ) {
- val |= PREVIEW_FILL;
- }
- if ( _isStroke ) {
- val |= PREVIEW_STROKE;
- }
- eek_preview_set_linked( preview, static_cast<LinkType>(val) );
- }
- }
- }
-}
-
-
-class JustForNow
-{
-public:
- JustForNow() : _prefWidth(0) {}
-
- Glib::ustring _name;
- int _prefWidth;
- std::vector<ColorItem*> _colors;
-};
-
-static std::vector<JustForNow*> possible;
+class DocTrack;
-static std::vector<std::string> mimeStrings;
-static std::map<std::string, guint> mimeToInt;
+std::vector<SwatchPage*> possible;
+static std::map<SPDocument*, SwatchPage*> docPalettes;
+static std::vector<DocTrack*> docTrackings;
+static std::map<SwatchesPanel*, SPDocument*> docPerPanel;
-static std::map<ColorItem*, guchar*> previewMap;
-static std::map<ColorItem*, SPGradient*> gradMap; // very temporary workaround.
-void ColorItem::_dragGetColorData( GtkWidget */*widget*/,
- GdkDragContext */*drag_context*/,
- GtkSelectionData *data,
- guint info,
- guint /*time*/,
- gpointer user_data)
-{
- ColorItem* item = reinterpret_cast<ColorItem*>(user_data);
- std::string key;
- if ( info < mimeStrings.size() ) {
- key = mimeStrings[info];
- } else {
- g_warning("ERROR: unknown value (%d)", info);
- }
-
- if ( !key.empty() ) {
- char* tmp = 0;
- int len = 0;
- int format = 0;
- item->def.getMIMEData(key, tmp, len, format);
- if ( tmp ) {
- GdkAtom dataAtom = gdk_atom_intern( key.c_str(), FALSE );
- gtk_selection_data_set( data, dataAtom, format, (guchar*)tmp, len );
- delete[] tmp;
- }
- }
-}
-
-static void dragBegin( GtkWidget */*widget*/, GdkDragContext* dc, gpointer data )
-{
- ColorItem* item = reinterpret_cast<ColorItem*>(data);
- if ( item )
- {
- using Inkscape::IO::Resource::get_path;
- using Inkscape::IO::Resource::ICONS;
- using Inkscape::IO::Resource::SYSTEM;
- int width = 32;
- int height = 24;
-
- if (item->def.getType() != ege::PaintDef::RGB){
- GError *error = NULL;
- gsize bytesRead = 0;
- gsize bytesWritten = 0;
- gchar *localFilename = g_filename_from_utf8( get_path(SYSTEM, ICONS, "remove-color.png"),
- -1,
- &bytesRead,
- &bytesWritten,
- &error);
- GdkPixbuf* pixbuf = gdk_pixbuf_new_from_file_at_scale(localFilename, width, height, FALSE, &error);
- g_free(localFilename);
- gtk_drag_set_icon_pixbuf( dc, pixbuf, 0, 0 );
- } else {
- GdkPixbuf* pixbuf = 0;
- if ( gradMap.find(item) == gradMap.end() ){
- Glib::RefPtr<Gdk::Pixbuf> thumb = Gdk::Pixbuf::create( Gdk::COLORSPACE_RGB, false, 8, width, height );
- guint32 fillWith = (0xff000000 & (item->def.getR() << 24))
- | (0x00ff0000 & (item->def.getG() << 16))
- | (0x0000ff00 & (item->def.getB() << 8));
- thumb->fill( fillWith );
- pixbuf = thumb->gobj();
- } else {
- SPGradient* grad = gradMap[item];
-
- guchar* px = g_new( guchar, 3 * height * width );
- nr_render_checkerboard_rgb( px, width, height, 3 * width, 0, 0 );
-
- sp_gradient_render_vector_block_rgb( grad,
- px, width, height, 3 * width,
- 0, width, TRUE );
-
- pixbuf = gdk_pixbuf_new_from_data( px, GDK_COLORSPACE_RGB, FALSE, 8,
- width, height, width * 3,
- 0, // add delete function
- 0 );
- }
- gtk_drag_set_icon_pixbuf( dc, pixbuf, 0, 0 );
- }
- }
-
-}
-
-//"drag-drop"
-// gboolean dragDropColorData( GtkWidget *widget,
-// GdkDragContext *drag_context,
-// gint x,
-// gint y,
-// guint time,
-// gpointer user_data)
-// {
-// // TODO finish
-
-// return TRUE;
-// }
static void handleClick( GtkWidget* /*widget*/, gpointer callback_data ) {
ColorItem* item = reinterpret_cast<ColorItem*>(callback_data);
@@ -323,34 +83,10 @@ static void handleSecondaryClick( GtkWidget* /*widget*/, gint /*arg1*/, gpointer
}
}
-static gboolean handleEnterNotify( GtkWidget* /*widget*/, GdkEventCrossing* /*event*/, gpointer callback_data ) {
- ColorItem* item = reinterpret_cast<ColorItem*>(callback_data);
- if ( item ) {
- SPDesktop *desktop = SP_ACTIVE_DESKTOP;
- if ( desktop ) {
- gchar* msg = g_strdup_printf(_("Color: <b>%s</b>; <b>Click</b> to set fill, <b>Shift+click</b> to set stroke"),
- item->def.descr.c_str());
- desktop->tipsMessageContext()->set(Inkscape::INFORMATION_MESSAGE, msg);
- g_free(msg);
- }
- }
- return FALSE;
-}
-
-static gboolean handleLeaveNotify( GtkWidget* /*widget*/, GdkEventCrossing* /*event*/, gpointer callback_data ) {
- ColorItem* item = reinterpret_cast<ColorItem*>(callback_data);
- if ( item ) {
- SPDesktop *desktop = SP_ACTIVE_DESKTOP;
- if ( desktop ) {
- desktop->tipsMessageContext()->clear();
- }
- }
- return FALSE;
-}
-
static GtkWidget* popupMenu = 0;
static std::vector<GtkWidget*> popupExtras;
static ColorItem* bounceTarget = 0;
+static SwatchesPanel* bouncePanel = 0;
static void redirClick( GtkMenuItem *menuitem, gpointer /*user_data*/ )
{
@@ -366,7 +102,6 @@ static void redirSecondaryClick( GtkMenuItem *menuitem, gpointer /*user_data*/ )
}
}
-#if USE_DOCUMENT_PALETTE
static void editGradientImpl( SPGradient* gr )
{
if ( gr ) {
@@ -378,7 +113,7 @@ static void editGradientImpl( SPGradient* gr )
static void editGradient( GtkMenuItem */*menuitem*/, gpointer /*user_data*/ )
{
if ( bounceTarget ) {
- SwatchesPanel* swp = bounceTarget->ptr ? reinterpret_cast<SwatchesPanel*>(bounceTarget->ptr) : 0;
+ SwatchesPanel* swp = bouncePanel;
SPDesktop* desktop = swp ? swp->getDesktop() : 0;
SPDocument *doc = desktop ? desktop->doc() : 0;
if (doc) {
@@ -386,7 +121,7 @@ static void editGradient( GtkMenuItem */*menuitem*/, gpointer /*user_data*/ )
const GSList *gradients = sp_document_get_resource_list(doc, "gradient");
for (const GSList *item = gradients; item; item = item->next) {
SPGradient* grad = SP_GRADIENT(item->data);
- if ( targetName == grad->id ) {
+ if ( targetName == grad->getId() ) {
editGradientImpl( grad );
break;
}
@@ -398,7 +133,7 @@ static void editGradient( GtkMenuItem */*menuitem*/, gpointer /*user_data*/ )
static void addNewGradient( GtkMenuItem */*menuitem*/, gpointer /*user_data*/ )
{
if ( bounceTarget ) {
- SwatchesPanel* swp = bounceTarget->ptr ? reinterpret_cast<SwatchesPanel*>(bounceTarget->ptr) : 0;
+ SwatchesPanel* swp = bouncePanel;
SPDesktop* desktop = swp ? swp->getDesktop() : 0;
SPDocument *doc = desktop ? desktop->doc() : 0;
if (doc) {
@@ -420,20 +155,35 @@ static void addNewGradient( GtkMenuItem */*menuitem*/, gpointer /*user_data*/ )
editGradientImpl( gr );
- // Work-around for timing of gradient addition change. Must follow edit.
- if ( swp ) {
- swp->handleGradientsChange();
- }
}
}
}
-#endif // USE_DOCUMENT_PALETTE
-static gboolean handleButtonPress( GtkWidget* /*widget*/, GdkEventButton* event, gpointer user_data)
+static SwatchesPanel* findContainingPanel( GtkWidget *widget )
+{
+ SwatchesPanel *swp = 0;
+
+ std::map<GtkWidget*, SwatchesPanel*> rawObjects;
+ for (std::map<SwatchesPanel*, SPDocument*>::iterator it = docPerPanel.begin(); it != docPerPanel.end(); ++it) {
+ rawObjects[GTK_WIDGET(it->first->gobj())] = it->first;
+ }
+
+ for (GtkWidget* curr = widget; curr && !swp; curr = gtk_widget_get_parent(curr)) {
+ if (rawObjects.find(curr) != rawObjects.end()) {
+ swp = rawObjects[curr];
+ }
+ }
+
+ return swp;
+}
+
+gboolean colorItemHandleButtonPress( GtkWidget* widget, GdkEventButton* event, gpointer user_data)
{
gboolean handled = FALSE;
if ( (event->button == 3) && (event->type == GDK_BUTTON_PRESS) ) {
+ SwatchesPanel* swp = findContainingPanel( widget );
+
if ( !popupMenu ) {
popupMenu = gtk_menu_new();
GtkWidget* child = 0;
@@ -455,7 +205,6 @@ static gboolean handleButtonPress( GtkWidget* /*widget*/, GdkEventButton* event,
user_data);
gtk_menu_shell_append(GTK_MENU_SHELL(popupMenu), child);
-#if USE_DOCUMENT_PALETTE
child = gtk_separator_menu_item_new();
gtk_menu_shell_append(GTK_MENU_SHELL(popupMenu), child);
popupExtras.push_back(child);
@@ -489,20 +238,19 @@ static gboolean handleButtonPress( GtkWidget* /*widget*/, GdkEventButton* event,
gtk_menu_shell_append(GTK_MENU_SHELL(popupMenu), child);
//popupExtras.push_back(child);
gtk_widget_set_sensitive( child, FALSE );
-#endif // USE_DOCUMENT_PALETTE
gtk_widget_show_all(popupMenu);
}
ColorItem* item = reinterpret_cast<ColorItem*>(user_data);
if ( item ) {
- SwatchesPanel* swp = item->ptr ? reinterpret_cast<SwatchesPanel*>(item->ptr) : 0;
bool show = swp && (swp->getSelectedIndex() == 0);
for ( std::vector<GtkWidget*>::iterator it = popupExtras.begin(); it != popupExtras.end(); ++ it) {
gtk_widget_set_sensitive(*it, show);
}
bounceTarget = item;
+ bouncePanel = swp;
if ( popupMenu ) {
gtk_menu_popup(GTK_MENU(popupMenu), NULL, NULL, NULL, NULL, event->button, event->time);
handled = TRUE;
@@ -513,374 +261,6 @@ static gboolean handleButtonPress( GtkWidget* /*widget*/, GdkEventButton* event,
return handled;
}
-static void dieDieDie( GtkObject *obj, gpointer user_data )
-{
- g_message("die die die %p %p", obj, user_data );
-}
-
-#include "color.h" // for SP_RGBA32_U_COMPOSE
-
-void ColorItem::_dropDataIn( GtkWidget */*widget*/,
- GdkDragContext */*drag_context*/,
- gint /*x*/, gint /*y*/,
- GtkSelectionData */*data*/,
- guint /*info*/,
- guint /*event_time*/,
- gpointer /*user_data*/)
-{
-}
-
-static bool bruteForce( SPDocument* document, Inkscape::XML::Node* node, Glib::ustring const& match, int r, int g, int b )
-{
- bool changed = false;
-
- if ( node ) {
- gchar const * val = node->attribute("inkscape:x-fill-tag");
- if ( val && (match == val) ) {
- SPObject *obj = document->getObjectByRepr( node );
-
- gchar c[64] = {0};
- sp_svg_write_color( c, sizeof(c), SP_RGBA32_U_COMPOSE( r, g, b, 0xff ) );
- SPCSSAttr *css = sp_repr_css_attr_new();
- sp_repr_css_set_property( css, "fill", c );
-
- sp_desktop_apply_css_recursive( (SPItem*)obj, css, true );
- ((SPItem*)obj)->updateRepr();
-
- changed = true;
- }
-
- val = node->attribute("inkscape:x-stroke-tag");
- if ( val && (match == val) ) {
- SPObject *obj = document->getObjectByRepr( node );
-
- gchar c[64] = {0};
- sp_svg_write_color( c, sizeof(c), SP_RGBA32_U_COMPOSE( r, g, b, 0xff ) );
- SPCSSAttr *css = sp_repr_css_attr_new();
- sp_repr_css_set_property( css, "stroke", c );
-
- sp_desktop_apply_css_recursive( (SPItem*)obj, css, true );
- ((SPItem*)obj)->updateRepr();
-
- changed = true;
- }
-
- Inkscape::XML::Node* first = node->firstChild();
- changed |= bruteForce( document, first, match, r, g, b );
-
- changed |= bruteForce( document, node->next(), match, r, g, b );
- }
-
- return changed;
-}
-
-void ColorItem::_colorDefChanged(void* data)
-{
- ColorItem* item = reinterpret_cast<ColorItem*>(data);
- if ( item ) {
- for ( std::vector<Gtk::Widget*>::iterator it = item->_previews.begin(); it != item->_previews.end(); ++it ) {
- Gtk::Widget* widget = *it;
- if ( IS_EEK_PREVIEW(widget->gobj()) ) {
- EekPreview * preview = EEK_PREVIEW(widget->gobj());
- eek_preview_set_color( preview,
- (item->def.getR() << 8) | item->def.getR(),
- (item->def.getG() << 8) | item->def.getG(),
- (item->def.getB() << 8) | item->def.getB() );
-
- eek_preview_set_linked( preview, (LinkType)((item->_linkSrc ? PREVIEW_LINK_IN:0)
- | (item->_listeners.empty() ? 0:PREVIEW_LINK_OUT)
- | (item->_isLive ? PREVIEW_LINK_OTHER:0)) );
-
- widget->queue_draw();
- }
- }
-
- for ( std::vector<ColorItem*>::iterator it = item->_listeners.begin(); it != item->_listeners.end(); ++it ) {
- guint r = item->def.getR();
- guint g = item->def.getG();
- guint b = item->def.getB();
-
- if ( (*it)->_linkIsTone ) {
- r = ( ((*it)->_linkPercent * (*it)->_linkGray) + ((100 - (*it)->_linkPercent) * r) ) / 100;
- g = ( ((*it)->_linkPercent * (*it)->_linkGray) + ((100 - (*it)->_linkPercent) * g) ) / 100;
- b = ( ((*it)->_linkPercent * (*it)->_linkGray) + ((100 - (*it)->_linkPercent) * b) ) / 100;
- } else {
- r = ( ((*it)->_linkPercent * 255) + ((100 - (*it)->_linkPercent) * r) ) / 100;
- g = ( ((*it)->_linkPercent * 255) + ((100 - (*it)->_linkPercent) * g) ) / 100;
- b = ( ((*it)->_linkPercent * 255) + ((100 - (*it)->_linkPercent) * b) ) / 100;
- }
-
- (*it)->def.setRGB( r, g, b );
- }
-
-
- // Look for objects using this color
- {
- SPDesktop *desktop = SP_ACTIVE_DESKTOP;
- if ( desktop ) {
- SPDocument* document = sp_desktop_document( desktop );
- Inkscape::XML::Node *rroot = sp_document_repr_root( document );
- if ( rroot ) {
-
- // Find where this thing came from
- Glib::ustring paletteName;
- bool found = false;
- int index = 0;
- for ( std::vector<JustForNow*>::iterator it2 = possible.begin(); it2 != possible.end() && !found; ++it2 ) {
- JustForNow* curr = *it2;
- index = 0;
- for ( std::vector<ColorItem*>::iterator zz = curr->_colors.begin(); zz != curr->_colors.end(); ++zz ) {
- if ( item == *zz ) {
- found = true;
- paletteName = curr->_name;
- break;
- } else {
- index++;
- }
- }
- }
-
- if ( !paletteName.empty() ) {
- gchar* str = g_strdup_printf("%d|", index);
- paletteName.insert( 0, str );
- g_free(str);
- str = 0;
-
- if ( bruteForce( document, rroot, paletteName, item->def.getR(), item->def.getG(), item->def.getB() ) ) {
- sp_document_done( document , SP_VERB_DIALOG_SWATCHES,
- _("Change color definition"));
- }
- }
- }
- }
- }
- }
-}
-
-
-Gtk::Widget* ColorItem::getPreview(PreviewStyle style, ViewType view, ::PreviewSize size, guint ratio)
-{
- Gtk::Widget* widget = 0;
- if ( style == PREVIEW_STYLE_BLURB) {
- Gtk::Label *lbl = new Gtk::Label(def.descr);
- lbl->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
- widget = lbl;
- } else {
-// Glib::ustring blank(" ");
-// if ( size == Inkscape::ICON_SIZE_MENU || size == Inkscape::ICON_SIZE_DECORATION ) {
-// blank = " ";
-// }
-
- GtkWidget* eekWidget = eek_preview_new();
- EekPreview * preview = EEK_PREVIEW(eekWidget);
- Gtk::Widget* newBlot = Glib::wrap(eekWidget);
-
- if ( previewMap.find(this) == previewMap.end() ){
- eek_preview_set_color( preview, (def.getR() << 8) | def.getR(),
- (def.getG() << 8) | def.getG(),
- (def.getB() << 8) | def.getB());
- } else {
- guchar* px = previewMap[this];
- int width = 128;
- int height = 16;
- GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data( px, GDK_COLORSPACE_RGB, FALSE, 8,
- width, height, width * 3,
- 0, // add delete function
- 0 );
- eek_preview_set_pixbuf( preview, pixbuf );
- }
- if ( def.getType() != ege::PaintDef::RGB ) {
- using Inkscape::IO::Resource::get_path;
- using Inkscape::IO::Resource::ICONS;
- using Inkscape::IO::Resource::SYSTEM;
- GError *error = NULL;
- gsize bytesRead = 0;
- gsize bytesWritten = 0;
- gchar *localFilename = g_filename_from_utf8( get_path(SYSTEM, ICONS, "remove-color.png"),
- -1,
- &bytesRead,
- &bytesWritten,
- &error);
- GdkPixbuf* pixbuf = gdk_pixbuf_new_from_file(localFilename, &error);
- if (!pixbuf) {
- g_warning("Null pixbuf for %p [%s]", localFilename, localFilename );
- }
- g_free(localFilename);
-
- eek_preview_set_pixbuf( preview, pixbuf );
- }
-
- eek_preview_set_details( preview, (::PreviewStyle)style, (::ViewType)view, (::PreviewSize)size, ratio );
- eek_preview_set_linked( preview, (LinkType)((_linkSrc ? PREVIEW_LINK_IN:0)
- | (_listeners.empty() ? 0:PREVIEW_LINK_OUT)
- | (_isLive ? PREVIEW_LINK_OTHER:0)) );
-
- def.addCallback( _colorDefChanged, this );
-
- GValue val = {0, {{0}, {0}}};
- g_value_init( &val, G_TYPE_BOOLEAN );
- g_value_set_boolean( &val, FALSE );
- g_object_set_property( G_OBJECT(preview), "focus-on-click", &val );
-
-/*
- Gtk::Button *btn = new Gtk::Button(blank);
- Gdk::Color color;
- color.set_rgb((_r << 8)|_r, (_g << 8)|_g, (_b << 8)|_b);
- btn->modify_bg(Gtk::STATE_NORMAL, color);
- btn->modify_bg(Gtk::STATE_ACTIVE, color);
- btn->modify_bg(Gtk::STATE_PRELIGHT, color);
- btn->modify_bg(Gtk::STATE_SELECTED, color);
-
- Gtk::Widget* newBlot = btn;
-*/
-
- tips.set_tip((*newBlot), def.descr);
-
-/*
- newBlot->signal_clicked().connect( sigc::mem_fun(*this, &ColorItem::buttonClicked) );
-
- sigc::signal<void> type_signal_something;
-*/
-
- g_signal_connect( G_OBJECT(newBlot->gobj()),
- "clicked",
- G_CALLBACK(handleClick),
- this);
-
- g_signal_connect( G_OBJECT(newBlot->gobj()),
- "alt-clicked",
- G_CALLBACK(handleSecondaryClick),
- this);
-
- g_signal_connect( G_OBJECT(newBlot->gobj()),
- "button-press-event",
- G_CALLBACK(handleButtonPress),
- this);
-
- {
- std::vector<std::string> listing = def.getMIMETypes();
- int entryCount = listing.size();
- GtkTargetEntry* entries = new GtkTargetEntry[entryCount];
- GtkTargetEntry* curr = entries;
- for ( std::vector<std::string>::iterator it = listing.begin(); it != listing.end(); ++it ) {
- curr->target = g_strdup(it->c_str());
- curr->flags = 0;
- if ( mimeToInt.find(*it) == mimeToInt.end() ){
- // these next lines are order-dependent:
- mimeToInt[*it] = mimeStrings.size();
- mimeStrings.push_back(*it);
- }
- curr->info = mimeToInt[curr->target];
- curr++;
- }
- gtk_drag_source_set( GTK_WIDGET(newBlot->gobj()),
- GDK_BUTTON1_MASK,
- entries, entryCount,
- GdkDragAction(GDK_ACTION_MOVE | GDK_ACTION_COPY) );
- for ( int i = 0; i < entryCount; i++ ) {
- g_free(entries[i].target);
- }
- delete[] entries;
- }
-
- g_signal_connect( G_OBJECT(newBlot->gobj()),
- "drag-data-get",
- G_CALLBACK(ColorItem::_dragGetColorData),
- this);
-
- g_signal_connect( G_OBJECT(newBlot->gobj()),
- "drag-begin",
- G_CALLBACK(dragBegin),
- this );
-
- g_signal_connect( G_OBJECT(newBlot->gobj()),
- "enter-notify-event",
- G_CALLBACK(handleEnterNotify),
- this);
-
- g_signal_connect( G_OBJECT(newBlot->gobj()),
- "leave-notify-event",
- G_CALLBACK(handleLeaveNotify),
- this);
-
-// g_signal_connect( G_OBJECT(newBlot->gobj()),
-// "drag-drop",
-// G_CALLBACK(dragDropColorData),
-// this);
-
- if ( def.isEditable() )
- {
-// gtk_drag_dest_set( GTK_WIDGET(newBlot->gobj()),
-// GTK_DEST_DEFAULT_ALL,
-// destColorTargets,
-// G_N_ELEMENTS(destColorTargets),
-// GdkDragAction(GDK_ACTION_COPY | GDK_ACTION_MOVE) );
-
-
-// g_signal_connect( G_OBJECT(newBlot->gobj()),
-// "drag-data-received",
-// G_CALLBACK(_dropDataIn),
-// this );
- }
-
- g_signal_connect( G_OBJECT(newBlot->gobj()),
- "destroy",
- G_CALLBACK(dieDieDie),
- this);
-
-
- widget = newBlot;
- }
-
- _previews.push_back( widget );
-
- return widget;
-}
-
-void ColorItem::buttonClicked(bool secondary)
-{
- SPDesktop *desktop = SP_ACTIVE_DESKTOP;
- if (desktop) {
- char const * attrName = secondary ? "stroke" : "fill";
-
- SPCSSAttr *css = sp_repr_css_attr_new();
- Glib::ustring descr;
- switch (def.getType()) {
- case ege::PaintDef::CLEAR: {
- // TODO actually make this clear
- sp_repr_css_set_property( css, attrName, "none" );
- descr = secondary? _("Remove stroke color") : _("Remove fill color");
- break;
- }
- case ege::PaintDef::NONE: {
- sp_repr_css_set_property( css, attrName, "none" );
- descr = secondary? _("Set stroke color to none") : _("Set fill color to none");
- break;
- }
- case ege::PaintDef::RGB: {
- Glib::ustring colorspec;
- if ( gradMap.find(this) == gradMap.end() ){
- gchar c[64];
- guint32 rgba = (def.getR() << 24) | (def.getG() << 16) | (def.getB() << 8) | 0xff;
- sp_svg_write_color(c, sizeof(c), rgba);
- colorspec = c;
- } else {
- SPGradient* grad = gradMap[this];
- colorspec = "url(#";
- colorspec += grad->id;
- colorspec += ")";
- }
- sp_repr_css_set_property( css, attrName, colorspec.c_str() );
- descr = secondary? _("Set stroke color from swatch") : _("Set fill color from swatch");
- break;
- }
- }
- sp_desktop_set_style(desktop, css);
- sp_repr_css_attr_unref(css);
-
- sp_document_done( sp_desktop_document(desktop), SP_VERB_DIALOG_SWATCHES, descr.c_str() );
- }
-}
static char* trim( char* str ) {
char* ret = str;
@@ -915,149 +295,6 @@ bool parseNum( char*& str, int& val ) {
}
-static bool getBlock( std::string& dst, guchar ch, std::string const str )
-{
- bool good = false;
- std::string::size_type pos = str.find(ch);
- if ( pos != std::string::npos )
- {
- std::string::size_type pos2 = str.find( '(', pos );
- if ( pos2 != std::string::npos ) {
- std::string::size_type endPos = str.find( ')', pos2 );
- if ( endPos != std::string::npos ) {
- dst = str.substr( pos2 + 1, (endPos - pos2 - 1) );
- good = true;
- }
- }
- }
- return good;
-}
-
-static bool popVal( guint64& numVal, std::string& str )
-{
- bool good = false;
- std::string::size_type endPos = str.find(',');
- if ( endPos == std::string::npos ) {
- endPos = str.length();
- }
-
- if ( endPos != std::string::npos && endPos > 0 ) {
- std::string xxx = str.substr( 0, endPos );
- const gchar* ptr = xxx.c_str();
- gchar* endPtr = 0;
- numVal = g_ascii_strtoull( ptr, &endPtr, 10 );
- if ( (numVal == G_MAXUINT64) && (ERANGE == errno) ) {
- // overflow
- } else if ( (numVal == 0) && (endPtr == ptr) ) {
- // failed conversion
- } else {
- good = true;
- str.erase( 0, endPos + 1 );
- }
- }
-
- return good;
-}
-
-void ColorItem::_wireMagicColors( void* p )
-{
- JustForNow* onceMore = reinterpret_cast<JustForNow*>(p);
- if ( onceMore )
- {
- for ( std::vector<ColorItem*>::iterator it = onceMore->_colors.begin(); it != onceMore->_colors.end(); ++it )
- {
- std::string::size_type pos = (*it)->def.descr.find("*{");
- if ( pos != std::string::npos )
- {
- std::string subby = (*it)->def.descr.substr( pos + 2 );
- std::string::size_type endPos = subby.find("}*");
- if ( endPos != std::string::npos )
- {
- subby.erase( endPos );
- //g_message("FOUND MAGIC at '%s'", (*it)->def.descr.c_str());
- //g_message(" '%s'", subby.c_str());
-
- if ( subby.find('E') != std::string::npos )
- {
- (*it)->def.setEditable( true );
- }
-
- if ( subby.find('L') != std::string::npos )
- {
- (*it)->_isLive = true;
- }
-
- std::string part;
- // Tint. index + 1 more val.
- if ( getBlock( part, 'T', subby ) ) {
- guint64 colorIndex = 0;
- if ( popVal( colorIndex, part ) ) {
- guint64 percent = 0;
- if ( popVal( percent, part ) ) {
- (*it)->_linkTint( *(onceMore->_colors[colorIndex]), percent );
- }
- }
- }
-
- // Shade/tone. index + 1 or 2 more val.
- if ( getBlock( part, 'S', subby ) ) {
- guint64 colorIndex = 0;
- if ( popVal( colorIndex, part ) ) {
- guint64 percent = 0;
- if ( popVal( percent, part ) ) {
- guint64 grayLevel = 0;
- if ( !popVal( grayLevel, part ) ) {
- grayLevel = 0;
- }
- (*it)->_linkTone( *(onceMore->_colors[colorIndex]), percent, grayLevel );
- }
- }
- }
-
- }
- }
- }
- }
-}
-
-
-void ColorItem::_linkTint( ColorItem& other, int percent )
-{
- if ( !_linkSrc )
- {
- other._listeners.push_back(this);
- _linkIsTone = false;
- _linkPercent = percent;
- if ( _linkPercent > 100 )
- _linkPercent = 100;
- if ( _linkPercent < 0 )
- _linkPercent = 0;
- _linkGray = 0;
- _linkSrc = &other;
-
- ColorItem::_colorDefChanged(&other);
- }
-}
-
-void ColorItem::_linkTone( ColorItem& other, int percent, int grayLevel )
-{
- if ( !_linkSrc )
- {
- other._listeners.push_back(this);
- _linkIsTone = true;
- _linkPercent = percent;
- if ( _linkPercent > 100 )
- _linkPercent = 100;
- if ( _linkPercent < 0 )
- _linkPercent = 0;
- _linkGray = grayLevel;
- _linkSrc = &other;
-
- ColorItem::_colorDefChanged(&other);
- }
-}
-
-
void _loadPaletteFile( gchar const *filename )
{
char block[1024];
@@ -1069,7 +306,7 @@ void _loadPaletteFile( gchar const *filename )
bool inHeader = true;
bool hasErr = false;
- JustForNow *onceMore = new JustForNow();
+ SwatchPage *onceMore = new SwatchPage();
do {
result = fgets( block, sizeof(block), f );
@@ -1245,46 +482,45 @@ SwatchesPanel::SwatchesPanel(gchar const* prefsPath) :
_remove(0),
_currentIndex(0),
_currentDesktop(0),
- _currentDocument(0),
- _ptr(0)
+ _currentDocument(0)
{
Gtk::RadioMenuItem* hotItem = 0;
_holder = new PreviewHolder();
_clear = new ColorItem( ege::PaintDef::CLEAR );
- _clear->ptr = this;
_remove = new ColorItem( ege::PaintDef::NONE );
- _remove->ptr = this;
-#if USE_DOCUMENT_PALETTE
- {
- JustForNow *docPalette = new JustForNow();
+ if (docPalettes.empty()) {
+ SwatchPage *docPalette = new SwatchPage();
docPalette->_name = "Auto";
- possible.push_back(docPalette);
-
- _ptr = docPalette;
+ docPalettes[0] = docPalette;
}
-#endif // USE_DOCUMENT_PALETTE
+
loadEmUp();
if ( !possible.empty() ) {
- JustForNow* first = 0;
+ SwatchPage* first = 0;
int index = 0;
Glib::ustring targetName;
if ( !_prefs_path.empty() ) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
targetName = prefs->getString(_prefs_path + "/palette");
if (!targetName.empty()) {
- for ( std::vector<JustForNow*>::iterator iter = possible.begin(); iter != possible.end(); ++iter ) {
- if ( (*iter)->_name == targetName ) {
- first = *iter;
- break;
- }
+ if (targetName == "Auto") {
+ first = docPalettes[0];
+ } else {
index++;
+ for ( std::vector<SwatchPage*>::iterator iter = possible.begin(); iter != possible.end(); ++iter ) {
+ if ( (*iter)->_name == targetName ) {
+ first = *iter;
+ break;
+ }
+ index++;
+ }
}
}
}
if ( !first ) {
- first = possible.front();
+ first = docPalettes[0];
_currentIndex = 0;
} else {
_currentIndex = index;
@@ -1295,8 +531,9 @@ SwatchesPanel::SwatchesPanel(gchar const* prefsPath) :
Gtk::RadioMenuItem::Group groupOne;
int i = 0;
- for ( std::vector<JustForNow*>::iterator it = possible.begin(); it != possible.end(); it++ ) {
- JustForNow* curr = *it;
+ std::vector<SwatchPage*> swatchSets = _getSwatchSets();
+ for ( std::vector<SwatchPage*>::iterator it = swatchSets.begin(); it != swatchSets.end(); it++ ) {
+ SwatchPage* curr = *it;
Gtk::RadioMenuItem* single = manage(new Gtk::RadioMenuItem(groupOne, curr->_name));
if ( curr == first ) {
hotItem = single;
@@ -1320,11 +557,10 @@ SwatchesPanel::SwatchesPanel(gchar const* prefsPath) :
SwatchesPanel::~SwatchesPanel()
{
+ _trackDocument( this, 0 );
+
_documentConnection.disconnect();
- _resourceConnection.disconnect();
_selChanged.disconnect();
- _setModified.disconnect();
- _subselChanged.disconnect();
if ( _clear ) {
delete _clear;
@@ -1354,8 +590,6 @@ void SwatchesPanel::setDesktop( SPDesktop* desktop )
if ( _currentDesktop ) {
_documentConnection.disconnect();
_selChanged.disconnect();
- _setModified.disconnect();
- _subselChanged.disconnect();
}
_currentDesktop = desktop;
@@ -1382,104 +616,235 @@ void SwatchesPanel::setDesktop( SPDesktop* desktop )
}
}
-void SwatchesPanel::_setDocument( SPDocument *document )
+
+class DocTrack
{
- if ( document != _currentDocument ) {
- if ( _currentDocument ) {
- _resourceConnection.disconnect();
+public:
+ DocTrack(SPDocument *doc, sigc::connection &gradientRsrcChanged, sigc::connection &defsChanged, sigc::connection &defsModified) :
+ doc(doc),
+ gradientRsrcChanged(gradientRsrcChanged),
+ defsChanged(defsChanged),
+ defsModified(defsModified)
+ {
+ }
+
+ ~DocTrack()
+ {
+ if (doc) {
+ gradientRsrcChanged.disconnect();
+ defsChanged.disconnect();
+ defsModified.disconnect();
}
- _currentDocument = document;
- if ( _currentDocument ) {
- _resourceConnection = sp_document_resources_changed_connect(document,
- "gradient",
- sigc::mem_fun(*this, &SwatchesPanel::handleGradientsChange));
+ }
+
+ SPDocument *doc;
+ sigc::connection gradientRsrcChanged;
+ sigc::connection defsChanged;
+ sigc::connection defsModified;
+
+private:
+ DocTrack(DocTrack const &); // no copy
+ DocTrack &operator=(DocTrack const &); // no assign
+};
+
+void SwatchesPanel::_trackDocument( SwatchesPanel *panel, SPDocument *document )
+{
+ SPDocument *oldDoc = 0;
+ if (docPerPanel.find(panel) != docPerPanel.end()) {
+ oldDoc = docPerPanel[panel];
+ if (!oldDoc) {
+ docPerPanel.erase(panel); // Should not be needed, but clean up just in case.
+ }
+ }
+ if (oldDoc != document) {
+ if (oldDoc) {
+ docPerPanel[panel] = 0;
+ bool found = false;
+ for (std::map<SwatchesPanel*, SPDocument*>::iterator it = docPerPanel.begin(); (it != docPerPanel.end()) && !found; ++it) {
+ found = (it->second == document);
+ }
+ if (!found) {
+ for (std::vector<DocTrack*>::iterator it = docTrackings.begin(); it != docTrackings.end(); ++it){
+ if ((*it)->doc == oldDoc) {
+ delete *it;
+ docTrackings.erase(it);
+ break;
+ }
+ }
+ }
+ }
+
+ if (document) {
+ bool found = false;
+ for (std::map<SwatchesPanel*, SPDocument*>::iterator it = docPerPanel.begin(); (it != docPerPanel.end()) && !found; ++it) {
+ found = (it->second == document);
+ }
+ docPerPanel[panel] = document;
+ if (!found) {
+ sigc::connection conn1 = sp_document_resources_changed_connect( document, "gradient", sigc::bind(sigc::ptr_fun(&SwatchesPanel::handleGradientsChange), document) );
+ sigc::connection conn2 = SP_DOCUMENT_DEFS(document)->connectRelease( sigc::hide(sigc::bind(sigc::ptr_fun(&SwatchesPanel::handleDefsModified), document)) );
+ sigc::connection conn3 = SP_DOCUMENT_DEFS(document)->connectModified( sigc::hide(sigc::hide(sigc::bind(sigc::ptr_fun(&SwatchesPanel::handleDefsModified), document))) );
+
+ DocTrack *dt = new DocTrack(document, conn1, conn2, conn3);
+ docTrackings.push_back(dt);
+
+ if (docPalettes.find(document) == docPalettes.end()) {
+ SwatchPage *docPalette = new SwatchPage();
+ docPalette->_name = "Auto";
+ docPalettes[document] = docPalette;
+ }
+ }
}
+ }
- handleGradientsChange();
+ std::set<SPDocument*> docs;
+ for (std::map<SwatchesPanel*, SPDocument*>::iterator it = docPerPanel.begin(); it != docPerPanel.end(); ++it) {
+ docs.insert(it->second);
}
}
-void SwatchesPanel::handleGradientsChange()
+void SwatchesPanel::_setDocument( SPDocument *document )
+{
+ if ( document != _currentDocument ) {
+ _trackDocument(this, document);
+ _currentDocument = document;
+ handleGradientsChange( document );
+ }
+}
+
+static void recalcSwatchContents(SPDocument* doc,
+ std::vector<ColorItem*> &tmpColors,
+ std::map<ColorItem*, guchar*> &previewMappings,
+ std::map<ColorItem*, SPGradient*> &gradMappings)
{
std::vector<SPGradient*> newList;
- const GSList *gradients = sp_document_get_resource_list(_currentDocument, "gradient");
+ const GSList *gradients = sp_document_get_resource_list(doc, "gradient");
for (const GSList *item = gradients; item; item = item->next) {
SPGradient* grad = SP_GRADIENT(item->data);
- if ( grad->has_stops ) {
+ if ( grad->isSwatch() ) {
newList.push_back(SP_GRADIENT(item->data));
}
}
-#if USE_DOCUMENT_PALETTE
- if ( _ptr ) {
- JustForNow *docPalette = reinterpret_cast<JustForNow *>(_ptr);
- // TODO delete pointed to objects
- docPalette->_colors.clear();
- if ( !newList.empty() ) {
- for ( std::vector<SPGradient*>::iterator it = newList.begin(); it != newList.end(); ++it )
- {
- SPGradient* grad = *it;
- if ( grad->repr->attribute("osb:paint") ) {
- sp_gradient_ensure_vector( grad );
- SPGradientStop first = grad->vector.stops[0];
- SPColor color = first.color;
- guint32 together = color.toRGBA32(first.opacity);
-
- // At the moment we can't trust the count of 1 vs 2 stops.
- SPGradientStop second = (*it)->vector.stops[1];
- SPColor color2 = second.color;
- guint32 together2 = color2.toRGBA32(second.opacity);
-
- if ( (grad->vector.stops.size() <= 2) && (together == together2) ) {
- // Treat as solid-color
- Glib::ustring name( grad->id );
- unsigned int r = SP_RGBA32_R_U(together);
- unsigned int g = SP_RGBA32_G_U(together);
- unsigned int b = SP_RGBA32_B_U(together);
- ColorItem* item = new ColorItem( r, g, b, name );
- item->ptr = this;
- docPalette->_colors.push_back(item);
- gradMap[item] = grad;
- } else {
- // Treat as gradient
- Glib::ustring name( grad->id );
- unsigned int r = SP_RGBA32_R_U(together);
- unsigned int g = SP_RGBA32_G_U(together);
- unsigned int b = SP_RGBA32_B_U(together);
- ColorItem* item = new ColorItem( r, g, b, name );
- item->ptr = this;
- docPalette->_colors.push_back(item);
-
- gint width = 128;
- gint height = VBLOCK;
- guchar* px = g_new( guchar, 3 * height * width );
- nr_render_checkerboard_rgb( px, width, VBLOCK, 3 * width, 0, 0 );
-
- sp_gradient_render_vector_block_rgb( grad,
- px, width, height, 3 * width,
- 0, width, TRUE );
-
- previewMap[item] = px;
- gradMap[item] = grad;
- }
+ if ( !newList.empty() ) {
+ for ( std::vector<SPGradient*>::iterator it = newList.begin(); it != newList.end(); ++it )
+ {
+ SPGradient* grad = *it;
+ sp_gradient_ensure_vector( grad );
+ SPGradientStop first = grad->vector.stops[0];
+ SPColor color = first.color;
+ guint32 together = color.toRGBA32(first.opacity);
+
+ SPGradientStop second = (*it)->vector.stops[1];
+ SPColor color2 = second.color;
+
+ Glib::ustring name( grad->getId() );
+ unsigned int r = SP_RGBA32_R_U(together);
+ unsigned int g = SP_RGBA32_G_U(together);
+ unsigned int b = SP_RGBA32_B_U(together);
+ ColorItem* item = new ColorItem( r, g, b, name );
+
+ gint width = PREVIEW_PIXBUF_WIDTH;
+ gint height = VBLOCK;
+ guchar* px = g_new( guchar, 3 * height * width );
+ nr_render_checkerboard_rgb( px, width, height, 3 * width, 0, 0 );
+
+ sp_gradient_render_vector_block_rgb( grad,
+ px, width, height, 3 * width,
+ 0, width, TRUE );
+
+ previewMappings[item] = px;
+
+ tmpColors.push_back(item);
+ gradMappings[item] = grad;
+ }
+ }
+}
+
+void SwatchesPanel::handleGradientsChange(SPDocument *document)
+{
+ SwatchPage *docPalette = (docPalettes.find(document) != docPalettes.end()) ? docPalettes[document] : 0;
+ if (docPalette) {
+ std::vector<ColorItem*> tmpColors;
+ std::map<ColorItem*, guchar*> tmpPrevs;
+ std::map<ColorItem*, SPGradient*> tmpGrads;
+ recalcSwatchContents(document, tmpColors, tmpPrevs, tmpGrads);
+
+ for (std::map<ColorItem*, guchar*>::iterator it = tmpPrevs.begin(); it != tmpPrevs.end(); ++it) {
+ it->first->setPixData(it->second, PREVIEW_PIXBUF_WIDTH, VBLOCK);
+ }
+
+ for (std::map<ColorItem*, SPGradient*>::iterator it = tmpGrads.begin(); it != tmpGrads.end(); ++it) {
+ it->first->setGradient(it->second);
+ }
+
+ docPalette->_colors.swap(tmpColors);
+ for (std::vector<ColorItem*>::iterator it = tmpColors.begin(); it != tmpColors.end(); ++it) {
+ delete *it;
+ }
+
+
+ // Figure out which SwatchesPanel instances are affected and update them.
+
+ for (std::map<SwatchesPanel*, SPDocument*>::iterator it = docPerPanel.begin(); it != docPerPanel.end(); ++it) {
+ if (it->second == document) {
+ SwatchesPanel* swp = it->first;
+ std::vector<SwatchPage*> pages = swp->_getSwatchSets();
+ SwatchPage* curr = pages[swp->_currentIndex];
+ if (curr == docPalette) {
+ swp->_rebuild();
}
}
}
- JustForNow* curr = possible[_currentIndex];
- if (curr == docPalette) {
- _rebuild();
+ }
+}
+
+void SwatchesPanel::handleDefsModified(SPDocument *document)
+{
+ SwatchPage *docPalette = (docPalettes.find(document) != docPalettes.end()) ? docPalettes[document] : 0;
+ if (docPalette) {
+ std::vector<ColorItem*> tmpColors;
+ std::map<ColorItem*, guchar*> tmpPrevs;
+ std::map<ColorItem*, SPGradient*> tmpGrads;
+ recalcSwatchContents(document, tmpColors, tmpPrevs, tmpGrads);
+
+ int cap = std::min(docPalette->_colors.size(), tmpColors.size());
+ for (int i = 0; i < cap; i++) {
+ ColorItem* newColor = tmpColors[i];
+ ColorItem* oldColor = docPalette->_colors[i];
+ if ( (newColor->def.getType() != oldColor->def.getType()) ||
+ (newColor->def.getR() != oldColor->def.getR()) ||
+ (newColor->def.getG() != oldColor->def.getG()) ||
+ (newColor->def.getB() != oldColor->def.getB()) ) {
+ oldColor->def.setRGB(newColor->def.getR(), newColor->def.getG(), newColor->def.getB());
+ }
+ if (tmpGrads.find(newColor) != tmpGrads.end()) {
+ oldColor->setGradient(tmpGrads[newColor]);
+ }
+ if ( tmpPrevs.find(newColor) != tmpPrevs.end() ) {
+ oldColor->setPixData(tmpPrevs[newColor], PREVIEW_PIXBUF_WIDTH, VBLOCK);
+ }
}
}
-#endif // USE_DOCUMENT_PALETTE
}
-void SwatchesPanel::_updateFromSelection()
+std::vector<SwatchPage*> SwatchesPanel::_getSwatchSets() const
{
-#if USE_DOCUMENT_PALETTE
- if ( _ptr ) {
- JustForNow *docPalette = reinterpret_cast<JustForNow *>(_ptr);
+ std::vector<SwatchPage*> tmp;
+ if (docPalettes.find(_currentDocument) != docPalettes.end()) {
+ tmp.push_back(docPalettes[_currentDocument]);
+ }
+ tmp.insert(tmp.end(), possible.begin(), possible.end());
+
+ return tmp;
+}
+
+void SwatchesPanel::_updateFromSelection()
+{
+ SwatchPage *docPalette = (docPalettes.find(_currentDocument) != docPalettes.end()) ? docPalettes[_currentDocument] : 0;
+ if ( docPalette ) {
Glib::ustring fillId;
Glib::ustring strokeId;
@@ -1554,7 +919,6 @@ void SwatchesPanel::_updateFromSelection()
item->setState( isFill, isStroke );
}
}
-#endif // USE_DOCUMENT_PALETTE
}
void SwatchesPanel::_handleAction( int setId, int itemId )
@@ -1562,12 +926,13 @@ void SwatchesPanel::_handleAction( int setId, int itemId )
switch( setId ) {
case 3:
{
- if ( itemId >= 0 && itemId < static_cast<int>(possible.size()) ) {
+ std::vector<SwatchPage*> pages = _getSwatchSets();
+ if ( itemId >= 0 && itemId < static_cast<int>(pages.size()) ) {
_currentIndex = itemId;
if ( !_prefs_path.empty() ) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setString(_prefs_path + "/palette", possible[_currentIndex]->_name);
+ prefs->setString(_prefs_path + "/palette", pages[_currentIndex]->_name);
}
_rebuild();
@@ -1579,7 +944,8 @@ void SwatchesPanel::_handleAction( int setId, int itemId )
void SwatchesPanel::_rebuild()
{
- JustForNow* curr = possible[_currentIndex];
+ std::vector<SwatchPage*> pages = _getSwatchSets();
+ SwatchPage* curr = pages[_currentIndex];
_holder->clear();
if ( curr->_prefWidth > 0 ) {
diff --git a/src/ui/dialog/swatches.h b/src/ui/dialog/swatches.h
index 35bcd8c78..b18fd6cad 100644
--- a/src/ui/dialog/swatches.h
+++ b/src/ui/dialog/swatches.h
@@ -11,17 +11,18 @@
#define SEEN_DIALOGS_SWATCHES_H
#include <gtkmm/textview.h>
-#include <gtkmm/tooltips.h>
#include "ui/widget/panel.h"
-#include "ui/previewholder.h"
-#include "widgets/ege-paint-def.h"
namespace Inkscape {
namespace UI {
+
+class PreviewHolder;
+
namespace Dialogs {
class ColorItem;
+class SwatchPage;
/**
* A panel that displays paint swatches.
@@ -40,7 +41,6 @@ public:
virtual SPDesktop* getDesktop() {return _currentDesktop;}
virtual int getSelectedIndex() {return _currentIndex;} // temporary
- virtual void handleGradientsChange(); // temporary
protected:
virtual void _updateFromSelection();
@@ -48,23 +48,25 @@ protected:
virtual void _setDocument( SPDocument *document );
virtual void _rebuild();
+ virtual std::vector<SwatchPage*> _getSwatchSets() const;
+
private:
SwatchesPanel(SwatchesPanel const &); // no copy
SwatchesPanel &operator=(SwatchesPanel const &); // no assign
+ static void _trackDocument( SwatchesPanel *panel, SPDocument *document );
+ static void handleGradientsChange(SPDocument *document);
+ static void handleDefsModified(SPDocument *document);
+
PreviewHolder* _holder;
ColorItem* _clear;
ColorItem* _remove;
int _currentIndex;
SPDesktop* _currentDesktop;
SPDocument* _currentDocument;
- void* _ptr;
sigc::connection _documentConnection;
- sigc::connection _resourceConnection;
sigc::connection _selChanged;
- sigc::connection _setModified;
- sigc::connection _subselChanged;
};
} //namespace Dialogs