summaryrefslogtreecommitdiffstats
path: root/src/extension/internal
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2013-02-06 08:19:53 +0000
committerJabiertxo Arraiza Cenoz <jtx@jtx.marker.es>2013-02-06 08:19:53 +0000
commit549a79b5367ffd259a23fbd18e93199d1c0149b7 (patch)
tree9c4ce4a0217afa63b59f32d02a60b848f43a9520 /src/extension/internal
parentMerge from branch (diff)
parentSupress Pango error message. (diff)
downloadinkscape-549a79b5367ffd259a23fbd18e93199d1c0149b7.tar.gz
inkscape-549a79b5367ffd259a23fbd18e93199d1c0149b7.zip
Merge from branch
(bzr r11950.1.19)
Diffstat (limited to 'src/extension/internal')
-rw-r--r--src/extension/internal/Makefile_insert6
-rw-r--r--src/extension/internal/cdr-input.cpp332
-rw-r--r--src/extension/internal/cdr-input.h54
-rw-r--r--src/extension/internal/filter/color.h197
-rwxr-xr-xsrc/extension/internal/filter/filter-all.cpp3
-rw-r--r--src/extension/internal/filter/filter.cpp2
-rw-r--r--src/extension/internal/filter/shadows.h13
-rw-r--r--src/extension/internal/vsd-input.cpp4
8 files changed, 547 insertions, 64 deletions
diff --git a/src/extension/internal/Makefile_insert b/src/extension/internal/Makefile_insert
index 1ea6caca9..9e55598df 100644
--- a/src/extension/internal/Makefile_insert
+++ b/src/extension/internal/Makefile_insert
@@ -12,6 +12,12 @@ ink_common_sources += \
extension/internal/vsd-input.h
endif
+if WITH_LIBCDR
+ink_common_sources += \
+ extension/internal/cdr-input.cpp \
+ extension/internal/cdr-input.h
+endif
+
if USE_IMAGE_MAGICK
ink_common_sources += \
extension/internal/bitmap/imagemagick.cpp \
diff --git a/src/extension/internal/cdr-input.cpp b/src/extension/internal/cdr-input.cpp
new file mode 100644
index 000000000..e6c400fb5
--- /dev/null
+++ b/src/extension/internal/cdr-input.cpp
@@ -0,0 +1,332 @@
+/*
+ * This file came from libwpg as a source, their utility wpg2svg
+ * specifically. It has been modified to work as an Inkscape extension.
+ * The Inkscape extension code is covered by this copyright, but the
+ * rest is covered by the one bellow.
+ *
+ * Authors:
+ * Fridrich Strba (fridrich.strba@bluewin.ch)
+ *
+ * Copyright (C) 2012 Authors
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ *
+ */
+
+#include <stdio.h>
+#include "config.h"
+
+#include "cdr-input.h"
+
+#ifdef WITH_LIBCDR
+
+#include <string>
+#include <cstring>
+
+#include <libcdr/libcdr.h>
+#include <libwpd-stream/libwpd-stream.h>
+
+#include <gtkmm/alignment.h>
+#include <gtkmm/comboboxtext.h>
+#include <gtkmm/drawingarea.h>
+#include <gtkmm/frame.h>
+#include <gtkmm/scale.h>
+
+#include "extension/system.h"
+#include "extension/input.h"
+#include "document.h"
+
+#include "document-private.h"
+#include "document-undo.h"
+#include "inkscape.h"
+
+#include "dialogs/dialog-events.h"
+#include <gtk/gtk.h>
+#include "ui/widget/spinbutton.h"
+#include "ui/widget/frame.h"
+#include <glibmm/i18n.h>
+
+#include <gdkmm/general.h>
+
+#include "svg-view.h"
+#include "svg-view-widget.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+
+
+class CdrImportDialog : public Gtk::Dialog {
+public:
+ CdrImportDialog(const std::vector<WPXString> &vec);
+ virtual ~CdrImportDialog();
+
+ bool showDialog();
+ unsigned getSelectedPage();
+ void getImportSettings(Inkscape::XML::Node *prefs);
+
+private:
+ void _setPreviewPage(unsigned page);
+
+ // Signal handlers
+#if !WITH_GTKMM_3_0
+ bool _onExposePreview(GdkEventExpose *event);
+#endif
+
+ void _onPageNumberChanged();
+
+ class Gtk::Button * cancelbutton;
+ class Gtk::Button * okbutton;
+ class Gtk::Label * _labelSelect;
+ class Inkscape::UI::Widget::SpinButton * _pageNumberSpin;
+ class Gtk::Label * _labelTotalPages;
+ class Gtk::VBox * vbox1;
+ class Gtk::VBox * vbox2;
+ class Gtk::Widget * _previewArea;
+
+ const std::vector<WPXString> &_vec; // Document to be imported
+ unsigned _current_page; // Current selected page
+ int _preview_width, _preview_height; // Size of the preview area
+};
+
+CdrImportDialog::CdrImportDialog(const std::vector<WPXString> &vec)
+ : _vec(vec), _current_page(1)
+{
+ int num_pages = _vec.size();
+ if ( num_pages <= 1 )
+ return;
+ cancelbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-cancel")));
+ okbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-ok")));
+ _labelSelect = Gtk::manage(new class Gtk::Label(_("Select page:")));
+
+ // Page number
+#if WITH_GTKMM_3_0
+ Glib::RefPtr<Gtk::Adjustment> _pageNumberSpin_adj = Gtk::Adjustment::create(1, 1, _vec.size(), 1, 10, 0);
+ _pageNumberSpin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(_pageNumberSpin_adj, 1, 1));
+#else
+ Gtk::Adjustment *_pageNumberSpin_adj = Gtk::manage(
+ new class Gtk::Adjustment(1, 1, _vec.size(), 1, 10, 0));
+ _pageNumberSpin = Gtk::manage(new class Inkscape::UI::Widget::SpinButton(*_pageNumberSpin_adj, 1, 1));
+#endif
+ _labelTotalPages = Gtk::manage(new class Gtk::Label());
+ gchar *label_text = g_strdup_printf(_("out of %i"), num_pages);
+ _labelTotalPages->set_label(label_text);
+ g_free(label_text);
+
+ vbox1 = Gtk::manage(new class Gtk::VBox(false, 4));
+ SPDocument *doc = SPDocument::createNewDocFromMem(_vec[0].cstr(), strlen(_vec[0].cstr()), 0);
+ _previewArea = Glib::wrap(sp_svg_view_widget_new(doc));
+
+ vbox2 = Gtk::manage(new class Gtk::VBox(false, 4));
+ cancelbutton->set_can_focus();
+ cancelbutton->set_can_default();
+ cancelbutton->set_relief(Gtk::RELIEF_NORMAL);
+ okbutton->set_can_focus();
+ okbutton->set_can_default();
+ okbutton->set_relief(Gtk::RELIEF_NORMAL);
+ this->get_action_area()->property_layout_style().set_value(Gtk::BUTTONBOX_END);
+ _labelSelect->set_line_wrap(false);
+ _labelSelect->set_use_markup(false);
+ _labelSelect->set_selectable(false);
+ _pageNumberSpin->set_can_focus();
+ _pageNumberSpin->set_update_policy(Gtk::UPDATE_ALWAYS);
+ _pageNumberSpin->set_numeric(true);
+ _pageNumberSpin->set_digits(0);
+ _pageNumberSpin->set_wrap(false);
+ _labelTotalPages->set_line_wrap(false);
+ _labelTotalPages->set_use_markup(false);
+ _labelTotalPages->set_selectable(false);
+ vbox2->pack_start(*_previewArea, Gtk::PACK_SHRINK, 0);
+ this->get_vbox()->set_homogeneous(false);
+ this->get_vbox()->set_spacing(0);
+ this->get_vbox()->pack_start(*vbox2);
+ this->set_title(_("Page Selector"));
+ this->set_modal(true);
+ sp_transientize(GTK_WIDGET(this->gobj())); //Make transient
+ this->property_window_position().set_value(Gtk::WIN_POS_NONE);
+ this->set_resizable(true);
+ this->property_destroy_with_parent().set_value(false);
+ this->get_action_area()->add(*_labelSelect);
+ this->add_action_widget(*_pageNumberSpin, -7);
+ this->get_action_area()->add(*_labelTotalPages);
+ this->add_action_widget(*cancelbutton, -6);
+ this->add_action_widget(*okbutton, -5);
+ cancelbutton->show();
+ okbutton->show();
+ _labelSelect->show();
+ _pageNumberSpin->show();
+ _labelTotalPages->show();
+ vbox1->show();
+ _previewArea->show();
+ vbox2->show();
+
+ // Connect signals
+ _pageNumberSpin_adj->signal_value_changed().connect(sigc::mem_fun(*this, &CdrImportDialog::_onPageNumberChanged));
+}
+
+CdrImportDialog::~CdrImportDialog() {}
+
+bool CdrImportDialog::showDialog()
+{
+ show();
+ gint b = run();
+ hide();
+ if ( b == Gtk::RESPONSE_OK ) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+}
+
+unsigned CdrImportDialog::getSelectedPage()
+{
+ return _current_page;
+}
+
+void CdrImportDialog::_onPageNumberChanged()
+{
+ unsigned page = static_cast<unsigned>(_pageNumberSpin->get_value_as_int());
+ _current_page = CLAMP(page, 1U, _vec.size());
+ _setPreviewPage(_current_page);
+}
+
+/**
+ * \brief Renders the given page's thumbnail
+ */
+void CdrImportDialog::_setPreviewPage(unsigned page)
+{
+ SPDocument *doc = SPDocument::createNewDocFromMem(_vec[page-1].cstr(), strlen(_vec[page-1].cstr()), 0);
+ Gtk::Widget * tmpPreviewArea = Glib::wrap(sp_svg_view_widget_new(doc));
+ std::swap(_previewArea, tmpPreviewArea);
+ if (tmpPreviewArea) {
+ _previewArea->set_size_request( tmpPreviewArea->get_width(), tmpPreviewArea->get_height() );
+ delete tmpPreviewArea;
+ }
+ vbox2->pack_start(*_previewArea, Gtk::PACK_SHRINK, 0);
+ _previewArea->show_now();
+}
+
+SPDocument *CdrInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * uri)
+{
+ WPXFileStream input(uri);
+
+ if (!libcdr::CDRDocument::isSupported(&input)) {
+ return NULL;
+ }
+
+ libcdr::CDRStringVector output;
+ if (!libcdr::CDRDocument::generateSVG(&input, output)) {
+ return NULL;
+ }
+
+ if (output.empty()) {
+ return NULL;
+ }
+
+ std::vector<WPXString> tmpSVGOutput;
+ for (unsigned i=0; i<output.size(); ++i) {
+ WPXString tmpString("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n");
+ tmpString.append(output[i]);
+ tmpSVGOutput.push_back(tmpString);
+ }
+
+ unsigned page_num = 1;
+
+ // If only one page is present, import that one without bothering user
+ if (tmpSVGOutput.size() > 1) {
+ CdrImportDialog *dlg = 0;
+ if (inkscape_use_gui()) {
+ dlg = new CdrImportDialog(tmpSVGOutput);
+ if (!dlg->showDialog()) {
+ delete dlg;
+ return NULL;
+ }
+ }
+
+ // Get needed page
+ if (dlg) {
+ page_num = dlg->getSelectedPage();
+ if (page_num < 1)
+ page_num = 1;
+ if (page_num > tmpSVGOutput.size())
+ page_num = tmpSVGOutput.size();
+ }
+ }
+
+ SPDocument * doc = SPDocument::createNewDocFromMem(tmpSVGOutput[page_num-1].cstr(), strlen(tmpSVGOutput[page_num-1].cstr()), TRUE);
+ return doc;
+}
+
+#include "clear-n_.h"
+
+void CdrInput::init(void)
+{
+ /* CDR */
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("Corel DRAW Input") "</name>\n"
+ "<id>org.inkscape.input.cdr</id>\n"
+ "<input>\n"
+ "<extension>.cdr</extension>\n"
+ "<mimetype>image/x-xcdr</mimetype>\n"
+ "<filetypename>" N_("Corel DRAW 7-X4 files (*.cdr)") "</filetypename>\n"
+ "<filetypetooltip>" N_("Open files saved in Corel DRAW 7-X4") "</filetypetooltip>\n"
+ "</input>\n"
+ "</inkscape-extension>", new CdrInput());
+
+ /* CDT */
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("Corel DRAW templates input") "</name>\n"
+ "<id>org.inkscape.input.cdt</id>\n"
+ "<input>\n"
+ "<extension>.cdt</extension>\n"
+ "<mimetype>application/x-xcdt</mimetype>\n"
+ "<filetypename>" N_("Corel DRAW 7-13 template files (*.cdt)") "</filetypename>\n"
+ "<filetypetooltip>" N_("Open files saved in Corel DRAW 7-13") "</filetypetooltip>\n"
+ "</input>\n"
+ "</inkscape-extension>", new CdrInput());
+
+ /* CCX */
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("Corel DRAW Compressed Exchange files input") "</name>\n"
+ "<id>org.inkscape.input.ccx</id>\n"
+ "<input>\n"
+ "<extension>.ccx</extension>\n"
+ "<mimetype>application/x-xccx</mimetype>\n"
+ "<filetypename>" N_("Corel DRAW Compressed Exchange files (*.ccx)") "</filetypename>\n"
+ "<filetypetooltip>" N_("Open compressed exchange files saved in Corel DRAW") "</filetypetooltip>\n"
+ "</input>\n"
+ "</inkscape-extension>", new CdrInput());
+
+ /* CMX */
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("Corel DRAW Presentation Exchange files input") "</name>\n"
+ "<id>org.inkscape.input.cmx</id>\n"
+ "<input>\n"
+ "<extension>.cmx</extension>\n"
+ "<mimetype>application/x-xcmx</mimetype>\n"
+ "<filetypename>" N_("Corel DRAW Presentation Exchange files (*.cmx)") "</filetypename>\n"
+ "<filetypetooltip>" N_("Open presentation exchange files saved in Corel DRAW") "</filetypetooltip>\n"
+ "</input>\n"
+ "</inkscape-extension>", new CdrInput());
+
+ return;
+
+} // init
+
+} } } /* namespace Inkscape, Extension, Implementation */
+#endif /* WITH_LIBCDR */
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/extension/internal/cdr-input.h b/src/extension/internal/cdr-input.h
new file mode 100644
index 000000000..10af41d5a
--- /dev/null
+++ b/src/extension/internal/cdr-input.h
@@ -0,0 +1,54 @@
+/*
+ * This code abstracts the libwpg interfaces into the Inkscape
+ * input extension interface.
+ *
+ * Authors:
+ * Fridrich Strba (fridrich.strba@bluewin.ch)
+ *
+ * Copyright (C) 2012 Authors
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#ifndef __EXTENSION_INTERNAL_CDROUTPUT_H__
+#define __EXTENSION_INTERNAL_CDROUTPUT_H__
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#ifdef WITH_LIBCDR
+
+#include <gtkmm/dialog.h>
+
+#include "../implementation/implementation.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+
+class CdrInput : public Inkscape::Extension::Implementation::Implementation {
+ CdrInput () { };
+public:
+ SPDocument *open( Inkscape::Extension::Input *mod,
+ const gchar *uri );
+ static void init( void );
+
+};
+
+} } } /* namespace Inkscape, Extension, Implementation */
+
+#endif /* WITH_LIBCDR */
+#endif /* __EXTENSION_INTERNAL_CDROUTPUT_H__ */
+
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h
index 785059cca..09079453f 100644
--- a/src/extension/internal/filter/color.h
+++ b/src/extension/internal/filter/color.h
@@ -3,7 +3,7 @@
/* Change the 'COLOR' above to be your file name */
/*
- * Copyright (C) 2011 Authors:
+ * Copyright (C) 2013 Authors:
* Ivan Louette (filters)
* Nicolas Dufour (UI) <nicoduf@yahoo.fr>
*
@@ -20,7 +20,8 @@
* Invert
* Lighting
* Lightness-contrast
- * Nudge
+ * Nudge RGB
+ * Nudge CMY
* Quadritone
* Solarize
* Tritone
@@ -211,7 +212,7 @@ ChannelPaint::get_filter_text (Inkscape::Extension::Extension * ext)
}
_filter = g_strdup_printf(
- "<filter inkscape:label=\"Channel Painting\" style=\"color-interpolation-filters:sRGB;\" >\n"
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Channel Painting\">\n"
"<feColorMatrix values=\"%s\" type=\"saturate\" result=\"colormatrix1\" />\n"
"<feColorMatrix values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 %s %s %s %s 0 \" in=\"SourceGraphic\" result=\"colormatrix2\" />\n"
"<feFlood flood-color=\"rgb(%s,%s,%s)\" flood-opacity=\"%s\" result=\"flood\" />\n"
@@ -1163,31 +1164,25 @@ LightnessContrast::get_filter_text (Inkscape::Extension::Extension * ext)
Filter's parameters:
Offsets
* Red
- * x (-100.->100., default -7) -> offset1 (dx)
- * y (-100.->100., default 5) -> offset1 (dy)
+ * x (-100.->100., default -6) -> offset1 (dx)
+ * y (-100.->100., default -6) -> offset1 (dy)
* Green
- * x (-100.->100., default 0) -> offset2 (dx)
- * y (-100.->100., default 10) -> offset2 (dy)
+ * x (-100.->100., default 6) -> offset2 (dx)
+ * y (-100.->100., default 7) -> offset2 (dy)
* Blue
- * x (-100.->100., default 3) -> offset3 (dx)
- * y (-100.->100., default -9) -> offset3 (dy)
+ * x (-100.->100., default 1) -> offset3 (dx)
+ * y (-100.->100., default -16) -> offset3 (dy)
Color
- * Background color (guint, default -1)-> flood (flood-color, flood-opacity)
- * Blend type (enum [normal,multiply and screen], default screen) -> blend1,2,3 (mode)
- * Blend source (enum, default color) ->
- * color: blend1 (in="flood")
- * image: blend1 (in="SourceGraphic")
- * background: blend1 (in="BackgroundImage")
- * Composite (enum [in,over], default over) -> composite (operator)
+ * Background color (guint, default 255)-> flood (flood-color, flood-opacity)
*/
-class Nudge : public Inkscape::Extension::Internal::Filter::Filter {
+class NudgeRGB : public Inkscape::Extension::Internal::Filter::Filter {
protected:
virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
public:
- Nudge ( ) : Filter() { };
- virtual ~Nudge ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
+ NudgeRGB ( ) : Filter() { };
+ virtual ~NudgeRGB ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
static void init (void) {
Inkscape::Extension::build_from_mem(
@@ -1197,31 +1192,17 @@ public:
"<param name=\"tab\" type=\"notebook\">\n"
"<page name=\"offsettab\" _gui-text=\"Offset\">\n"
"<_param name=\"redOffset\" type=\"description\" appearance=\"header\">" N_("Red offset") "</_param>\n"
- "<param name=\"rx\" gui-text=\"" N_("X:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">-7</param>\n"
- "<param name=\"ry\" gui-text=\"" N_("Y:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">5</param>\n"
+ "<param name=\"rx\" gui-text=\"" N_("X:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">-6</param>\n"
+ "<param name=\"ry\" gui-text=\"" N_("Y:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">-6</param>\n"
"<_param name=\"greenOffset\" type=\"description\" appearance=\"header\">" N_("Green offset") "</_param>\n"
- "<param name=\"gx\" gui-text=\"" N_("X:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">0</param>\n"
- "<param name=\"gy\" gui-text=\"" N_("Y:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">10</param>\n"
+ "<param name=\"gx\" gui-text=\"" N_("X:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">6</param>\n"
+ "<param name=\"gy\" gui-text=\"" N_("Y:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">7</param>\n"
"<_param name=\"redOffset\" type=\"description\" appearance=\"header\">" N_("Blue offset") "</_param>\n"
- "<param name=\"bx\" gui-text=\"" N_("X:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">3</param>\n"
- "<param name=\"by\" gui-text=\"" N_("Y:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">-9</param>\n"
+ "<param name=\"bx\" gui-text=\"" N_("X:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">1</param>\n"
+ "<param name=\"by\" gui-text=\"" N_("Y:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">-16</param>\n"
"</page>\n"
"<page name=\"coltab\" _gui-text=\"Color\">\n"
"<param name=\"color\" gui-text=\"" N_("Background color") "\" type=\"color\">255</param>\n"
- "<param name=\"blend\" gui-text=\"" N_("Blend type:") "\" type=\"enum\">\n"
- "<_item value=\"screen\">" N_("Screen") "</_item>\n"
- "<_item value=\"multiply\">" N_("Multiply") "</_item>\n"
- "<_item value=\"normal\">" N_("Normal") "</_item>\n"
- "</param>\n"
- "<param name=\"source\" gui-text=\"" N_("Blend source:") "\" type=\"enum\">\n"
- "<_item value=\"flood\">" N_("Color") "</_item>\n"
- "<_item value=\"SourceGraphic\">" N_("Image") "</_item>\n"
- "<_item value=\"BackgroundImage\">" N_("Background") "</_item>\n"
- "</param>\n"
- "<param name=\"composite\" gui-text=\"" N_("Composite:") "\" type=\"enum\">\n"
- "<_item value=\"over\">" N_("Over") "</_item>\n"
- "<_item value=\"in\">" N_("In") "</_item>\n"
- "</param>\n"
"</page>\n"
"</param>\n"
"<effect>\n"
@@ -1233,12 +1214,12 @@ public:
"</effects-menu>\n"
"<menu-tip>" N_("Nudge RGB channels separately and blend them to different types of backgrounds") "</menu-tip>\n"
"</effect>\n"
- "</inkscape-extension>\n", new Nudge());
+ "</inkscape-extension>\n", new NudgeRGB());
};
};
gchar const *
-Nudge::get_filter_text (Inkscape::Extension::Extension * ext)
+NudgeRGB::get_filter_text (Inkscape::Extension::Extension * ext)
{
if (_filter != NULL) g_free((void *)_filter);
@@ -1249,10 +1230,6 @@ Nudge::get_filter_text (Inkscape::Extension::Extension * ext)
std::ostringstream bx;
std::ostringstream by;
- std::ostringstream blend;
- std::ostringstream source;
- std::ostringstream composite;
-
std::ostringstream a;
std::ostringstream r;
std::ostringstream g;
@@ -1265,10 +1242,6 @@ Nudge::get_filter_text (Inkscape::Extension::Extension * ext)
bx << ext->get_param_float("bx");
by << ext->get_param_float("by");
- blend << ext->get_param_enum("blend");
- source << ext->get_param_enum("source");
- composite << ext->get_param_enum("composite");
-
guint32 color = ext->get_param_color("color");
r << ((color >> 24) & 0xff);
g << ((color >> 16) & 0xff);
@@ -1280,25 +1253,135 @@ Nudge::get_filter_text (Inkscape::Extension::Extension * ext)
"<feFlood flood-opacity=\"%s\" flood-color=\"rgb(%s,%s,%s)\" result=\"flood\" />\n"
"<feColorMatrix in=\"SourceGraphic\" values=\"0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 \" result=\"colormatrix1\" />\n"
"<feOffset dy=\"%s\" dx=\"%s\" result=\"offset1\" />\n"
- "<feBlend in2=\"%s\" mode=\"%s\" result=\"blend1\" />\n"
+ "<feBlend in2=\"flood\" mode=\"screen\" result=\"blend1\" />\n"
"<feColorMatrix in=\"SourceGraphic\" values=\"0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 \" result=\"colormatrix2\" />\n"
"<feOffset dy=\"%s\" dx=\"%s\" result=\"offset2\" />\n"
- "<feBlend in2=\"blend1\" mode=\"%s\" result=\"blend2\" />\n"
+ "<feBlend in2=\"blend1\" mode=\"screen\" result=\"blend2\" />\n"
"<feOffset dy=\"%s\" dx=\"%s\" result=\"offset3\" />\n"
"<feColorMatrix in=\"SourceGraphic\" values=\"0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 \" result=\"colormatrix3\" />\n"
- "<feBlend in2=\"offset3\" mode=\"%s\" result=\"blend3\" />\n"
- "<feComposite in2=\"SourceGraphic\" operator=\"%s\" />\n"
+ "<feBlend in2=\"offset3\" mode=\"screen\" result=\"blend3\" />\n"
"</filter>\n", a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(),
- rx.str().c_str(), ry.str().c_str(), source.str().c_str(), blend.str().c_str(),
- gx.str().c_str(), gy.str().c_str(), blend.str().c_str(),
- bx.str().c_str(), by.str().c_str(), blend.str().c_str(),
- composite.str().c_str() );
+ rx.str().c_str(), ry.str().c_str(),
+ gx.str().c_str(), gy.str().c_str(),
+ bx.str().c_str(), by.str().c_str() );
return _filter;
}; /* Nudge RGB filter */
/**
+ \brief Custom predefined Nudge CMY filter.
+
+ Nudge CMY channels separately and blend them to different types of backgrounds
+
+ Filter's parameters:
+ Offsets
+ * Cyan
+ * x (-100.->100., default -6) -> offset1 (dx)
+ * y (-100.->100., default -6) -> offset1 (dy)
+ * Magenta
+ * x (-100.->100., default 6) -> offset2 (dx)
+ * y (-100.->100., default 7) -> offset2 (dy)
+ * Yellow
+ * x (-100.->100., default 1) -> offset3 (dx)
+ * y (-100.->100., default -16) -> offset3 (dy)
+ Color
+ * Background color (guint, default -1)-> flood (flood-color, flood-opacity)
+*/
+class NudgeCMY : public Inkscape::Extension::Internal::Filter::Filter {
+protected:
+ virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
+
+public:
+ NudgeCMY ( ) : Filter() { };
+ virtual ~NudgeCMY ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
+
+ static void init (void) {
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("Nudge CMY") "</name>\n"
+ "<id>org.inkscape.effect.filter.NudgeCMY</id>\n"
+ "<param name=\"tab\" type=\"notebook\">\n"
+ "<page name=\"offsettab\" _gui-text=\"Offset\">\n"
+ "<_param name=\"cyanOffset\" type=\"description\" appearance=\"header\">" N_("Cyan offset") "</_param>\n"
+ "<param name=\"cx\" gui-text=\"" N_("X:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">-6</param>\n"
+ "<param name=\"cy\" gui-text=\"" N_("Y:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">-6</param>\n"
+ "<_param name=\"magentaOffset\" type=\"description\" appearance=\"header\">" N_("Magenta offset") "</_param>\n"
+ "<param name=\"mx\" gui-text=\"" N_("X:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">6</param>\n"
+ "<param name=\"my\" gui-text=\"" N_("Y:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">7</param>\n"
+ "<_param name=\"yellowOffset\" type=\"description\" appearance=\"header\">" N_("Yellow offset") "</_param>\n"
+ "<param name=\"yx\" gui-text=\"" N_("X:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">1</param>\n"
+ "<param name=\"yy\" gui-text=\"" N_("Y:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">-16</param>\n"
+ "</page>\n"
+ "<page name=\"coltab\" _gui-text=\"Color\">\n"
+ "<param name=\"color\" gui-text=\"" N_("Background color") "\" type=\"color\">-1</param>\n"
+ "</page>\n"
+ "</param>\n"
+ "<effect>\n"
+ "<object-type>all</object-type>\n"
+ "<effects-menu>\n"
+ "<submenu name=\"" N_("Filters") "\">\n"
+ "<submenu name=\"" N_("Color") "\"/>\n"
+ "</submenu>\n"
+ "</effects-menu>\n"
+ "<menu-tip>" N_("Nudge CMY channels separately and blend them to different types of backgrounds") "</menu-tip>\n"
+ "</effect>\n"
+ "</inkscape-extension>\n", new NudgeCMY());
+ };
+};
+
+gchar const *
+NudgeCMY::get_filter_text (Inkscape::Extension::Extension * ext)
+{
+ if (_filter != NULL) g_free((void *)_filter);
+
+ std::ostringstream cx;
+ std::ostringstream cy;
+ std::ostringstream mx;
+ std::ostringstream my;
+ std::ostringstream yx;
+ std::ostringstream yy;
+
+ std::ostringstream a;
+ std::ostringstream r;
+ std::ostringstream g;
+ std::ostringstream b;
+
+ cx << ext->get_param_float("cx");
+ cy << ext->get_param_float("cy");
+ mx << ext->get_param_float("mx");
+ my << ext->get_param_float("my");
+ yx << ext->get_param_float("yx");
+ yy << ext->get_param_float("yy");
+
+ guint32 color = ext->get_param_color("color");
+ r << ((color >> 24) & 0xff);
+ g << ((color >> 16) & 0xff);
+ b << ((color >> 8) & 0xff);
+ a << (color & 0xff) / 255.0F;
+
+ _filter = g_strdup_printf(
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Nudge CMY\">\n"
+ "<feFlood flood-opacity=\"%s\" flood-color=\"rgb(%s,%s,%s)\" result=\"flood\" />\n"
+ "<feColorMatrix in=\"SourceGraphic\" values=\"0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 -1 0 0 1 0 \" result=\"colormatrix1\" />\n"
+ "<feOffset dy=\"%s\" dx=\"%s\" result=\"offset1\" />\n"
+ "<feBlend in2=\"flood\" mode=\"multiply\" result=\"blend1\" />\n"
+ "<feColorMatrix in=\"SourceGraphic\" values=\"0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 -1 0 1 0 \" result=\"colormatrix2\" />\n"
+ "<feOffset dy=\"%s\" dx=\"%s\" result=\"offset2\" />\n"
+ "<feBlend in2=\"blend1\" mode=\"multiply\" result=\"blend2\" />\n"
+ "<feOffset dy=\"%s\" dx=\"%s\" result=\"offset3\" />\n"
+ "<feColorMatrix in=\"SourceGraphic\" values=\"0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 -1 1 0 \" result=\"colormatrix3\" />\n"
+ "<feBlend in2=\"offset3\" mode=\"multiply\" result=\"blend3\" />\n"
+ "</filter>\n", a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(),
+ cx.str().c_str(), cy.str().c_str(),
+ mx.str().c_str(), my.str().c_str(),
+ yx.str().c_str(), yy.str().c_str() );
+
+ return _filter;
+
+}; /* Nudge CMY filter */
+
+/**
\brief Custom predefined Quadritone filter.
Replace hue by two colors.
diff --git a/src/extension/internal/filter/filter-all.cpp b/src/extension/internal/filter/filter-all.cpp
index b5d47ae45..0273d1669 100755
--- a/src/extension/internal/filter/filter-all.cpp
+++ b/src/extension/internal/filter/filter-all.cpp
@@ -64,7 +64,8 @@ Filter::filters_all (void )
Invert::init();
Lighting::init();
LightnessContrast::init();
- Nudge::init();
+ NudgeRGB::init();
+ NudgeCMY::init();
Quadritone::init();
Solarize::init();
Tritone::init();
diff --git a/src/extension/internal/filter/filter.cpp b/src/extension/internal/filter/filter.cpp
index af597685b..9f7a45f7f 100644
--- a/src/extension/internal/filter/filter.cpp
+++ b/src/extension/internal/filter/filter.cpp
@@ -172,7 +172,7 @@ void Filter::effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::Vie
// no filter
if (filternode == NULL) {
- g_warning("no assoziating filter found!");
+ g_warning("no assigned filter found!");
continue;
}
diff --git a/src/extension/internal/filter/shadows.h b/src/extension/internal/filter/shadows.h
index d76358a96..415776607 100644
--- a/src/extension/internal/filter/shadows.h
+++ b/src/extension/internal/filter/shadows.h
@@ -3,7 +3,7 @@
/* Change the 'SHADOWS' above to be your file name */
/*
- * Copyright (C) 2011 Authors:
+ * Copyright (C) 2013 Authors:
* Ivan Louette (filters)
* Nicolas Dufour (UI) <nicoduf@yahoo.fr>
*
@@ -39,6 +39,7 @@ namespace Filter {
inner = composite1 (operator="out"), composite2 (operator="atop", in1="offset", in2="SourceGraphic")
innercut = composite1 (operator="in"), composite2 (operator="out", in1="offset", in2="SourceGraphic")
outercut = composite1 (operator="out"), composite2 (operator="in", in1="SourceGraphic", in2="offset")
+ shadow = composite1 (operator="out"), composite2 (operator="atop", in1="offset", in2="offset")
* Color (guint, default 0,0,0,127) -> flood (flood-opacity, flood-color)
* Use object's color (boolean, default false) -> composite1 (in1, in2)
*/
@@ -60,11 +61,12 @@ public:
"<param name=\"blur\" gui-text=\"" N_("Blur radius (px):") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"200.0\">3.0</param>\n"
"<param name=\"xoffset\" gui-text=\"" N_("Horizontal offset (px):") "\" type=\"float\" appearance=\"full\" min=\"-50.0\" max=\"50.0\">6.0</param>\n"
"<param name=\"yoffset\" gui-text=\"" N_("Vertical offset (px):") "\" type=\"float\" appearance=\"full\" min=\"-50.0\" max=\"50.0\">6.0</param>\n"
- "<param name=\"type\" gui-text=\"" N_("Blur type:") "\" type=\"enum\" >\n"
+ "<param name=\"type\" gui-text=\"" N_("Shadow type:") "\" type=\"enum\" >\n"
"<_item value=\"outer\">" N_("Outer") "</_item>\n"
"<_item value=\"inner\">" N_("Inner") "</_item>\n"
"<_item value=\"outercut\">" N_("Outer cutout") "</_item>\n"
"<_item value=\"innercut\">" N_("Inner cutout") "</_item>\n"
+ "<_item value=\"shadow\">" N_("Shadow only") "</_item>\n"
"</param>\n"
"</page>\n"
"<page name=\"coltab\" _gui-text=\"" N_("Blur color") "\">\n"
@@ -151,11 +153,16 @@ ColorizableDropShadow::get_filter_text (Inkscape::Extension::Extension * ext)
comp2op << "out";
comp2in1 << "offset";
comp2in2 << "SourceGraphic";
- } else { //innercut
+ } else if ((g_ascii_strcasecmp("innercut", type) == 0)){
comp1op << "out";
comp1in1 << "flood";
comp1in2 << "SourceGraphic";
comp2op << "in";
+ } else { //shadow
+ comp1op << "in";
+ comp2op << "atop";
+ comp2in1 << "offset";
+ comp2in2 << "offset";
}
_filter = g_strdup_printf(
diff --git a/src/extension/internal/vsd-input.cpp b/src/extension/internal/vsd-input.cpp
index 187318417..12e5150cb 100644
--- a/src/extension/internal/vsd-input.cpp
+++ b/src/extension/internal/vsd-input.cpp
@@ -185,8 +185,8 @@ unsigned VsdImportDialog::getSelectedPage()
void VsdImportDialog::_onPageNumberChanged()
{
- int page = _pageNumberSpin->get_value_as_int();
- _current_page = CLAMP(page, 1, _vec.size());
+ unsigned page = static_cast<unsigned>(_pageNumberSpin->get_value_as_int());
+ _current_page = CLAMP(page, 1U, _vec.size());
_setPreviewPage(_current_page);
}