diff options
| author | Felipe Corr??a da Silva Sanches <juca@members.fsf.org> | 2008-01-24 02:31:30 +0000 |
|---|---|---|
| committer | jucablues <jucablues@users.sourceforge.net> | 2008-01-24 02:31:30 +0000 |
| commit | f193b3fec2a7fc4ad52a3f5b947d9aadbd0b027b (patch) | |
| tree | c2571b18ff3efd4a24475e60d495db7ed1fe9c96 | |
| parent | Fixed crash with lighting effects and missing source image (diff) | |
| download | inkscape-f193b3fec2a7fc4ad52a3f5b947d9aadbd0b027b.tar.gz inkscape-f193b3fec2a7fc4ad52a3f5b947d9aadbd0b027b.zip | |
* implemented feImage Settings UI
* created feImage icon
* added CC licensing info on feConvolveMatrix-icon
(bzr r4586)
| -rw-r--r-- | share/icons/Makefile.am | 2 | ||||
| -rw-r--r-- | share/icons/feConvolveMatrix-icon.svg | 43 | ||||
| -rw-r--r-- | share/icons/feImage-icon.png | bin | 0 -> 20560 bytes | |||
| -rw-r--r-- | share/icons/feImage-icon.svg | 194 | ||||
| -rw-r--r-- | src/ui/dialog/filter-effects-dialog.cpp | 143 |
5 files changed, 368 insertions, 14 deletions
diff --git a/share/icons/Makefile.am b/share/icons/Makefile.am index ec8c3d383..0c666d212 100644 --- a/share/icons/Makefile.am +++ b/share/icons/Makefile.am @@ -19,6 +19,8 @@ pixmaps = \ feFlood-icon.svg \ feGaussianBlur-icon.png \ feGaussianBlur-icon.svg \ + feImage-icon.png \ + feImage-icon.svg \ feMerge-icon.png \ feMerge-icon.svg \ feMorphology-icon.png \ diff --git a/share/icons/feConvolveMatrix-icon.svg b/share/icons/feConvolveMatrix-icon.svg index c4bbd2666..4bfeb5ad4 100644 --- a/share/icons/feConvolveMatrix-icon.svg +++ b/share/icons/feConvolveMatrix-icon.svg @@ -18,7 +18,7 @@ sodipodi:docbase="/home/tsoots/ohj/translations/po" version="1.0" inkscape:output_extension="org.inkscape.output.svg.inkscape" - inkscape:export-filename="/home/felipe/devel/inkscape/inkscape/share/icons/feConvolveMatrix.png" + inkscape:export-filename="/home/felipe/devel/inkscape/inkscape/share/icons/feConvolveMatrix-icon.png" inkscape:export-xdpi="90" inkscape:export-ydpi="90"> <defs @@ -29,6 +29,27 @@ inkscape:vp_y="0 : 1000 : 0" inkscape:vp_z="700 : 600 : 1" inkscape:persp3d-origin="300 : 400 : 1" + id="perspective2405" /> + <inkscape:perspective + sodipodi:type="inkscape:persp3d" + inkscape:vp_x="-50 : 600 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_z="700 : 600 : 1" + inkscape:persp3d-origin="300 : 400 : 1" + id="perspective2495" /> + <inkscape:perspective + sodipodi:type="inkscape:persp3d" + inkscape:vp_x="-50 : 600 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_z="700 : 600 : 1" + inkscape:persp3d-origin="300 : 400 : 1" + id="perspective2661" /> + <inkscape:perspective + sodipodi:type="inkscape:persp3d" + inkscape:vp_x="-50 : 600 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_z="700 : 600 : 1" + inkscape:persp3d-origin="300 : 400 : 1" id="perspective2475" /> <inkscape:perspective sodipodi:type="inkscape:persp3d" @@ -87,8 +108,8 @@ inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="3.4766083" - inkscape:cx="45.053791" - inkscape:cy="49.982894" + inkscape:cx="33.938552" + inkscape:cy="28.549012" inkscape:document-units="px" inkscape:current-layer="layer1" gridtolerance="10000" @@ -132,14 +153,16 @@ <dc:title>Felipe Corrêa da Silva Sanches</dc:title> </cc:Agent> </dc:publisher> - <dc:identifier></dc:identifier> - <dc:source></dc:source> - <dc:relation></dc:relation> - <dc:language></dc:language> - <dc:coverage></dc:coverage> + <dc:identifier /> + <dc:source>http://www.flickr.com/photos/dariosanches</dc:source> + <dc:relation /> + <dc:language /> + <dc:coverage /> <dc:contributor> <cc:Agent> - <dc:title></dc:title> + <dc:title>This file is derived from ticotico.jpg which is: +(C) 2007 Dario Sanches under the CC by-sa license +</dc:title> </cc:Agent> </dc:contributor> </cc:Work> @@ -172,7 +195,7 @@ height="124.7063" width="168.06779" sodipodi:absref="ticotico.jpg" - xlink:href="/home/felipe/Desktop/ticotico.jpg" + xlink:href="./ticotico.jpg" style="filter:url(#filter2688)" /> <rect style="opacity:0.43324938;fill:none;fill-opacity:0.3678161;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.97574574;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:0.97574573, 1.95149145;stroke-dashoffset:0;stroke-opacity:1" diff --git a/share/icons/feImage-icon.png b/share/icons/feImage-icon.png Binary files differnew file mode 100644 index 000000000..22a21fbc1 --- /dev/null +++ b/share/icons/feImage-icon.png diff --git a/share/icons/feImage-icon.svg b/share/icons/feImage-icon.svg new file mode 100644 index 000000000..e8a6a47ec --- /dev/null +++ b/share/icons/feImage-icon.svg @@ -0,0 +1,194 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="96" + height="96" + id="svg1901" + sodipodi:version="0.32" + inkscape:version="0.45+devel" + sodipodi:docname="feImage-icon.svg" + sodipodi:docbase="/home/tsoots/ohj/translations/po" + version="1.0" + inkscape:output_extension="org.inkscape.output.svg.inkscape" + inkscape:export-filename="/home/felipe/devel/inkscape/inkscape/share/icons/feImage-icon.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90"> + <defs + id="defs1903"> + <inkscape:perspective + sodipodi:type="inkscape:persp3d" + inkscape:vp_x="-50 : 600 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_z="700 : 600 : 1" + inkscape:persp3d-origin="300 : 400 : 1" + id="perspective2403" /> + <inkscape:perspective + sodipodi:type="inkscape:persp3d" + inkscape:vp_x="-50 : 600 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_z="700 : 600 : 1" + inkscape:persp3d-origin="300 : 400 : 1" + id="perspective2402" /> + <inkscape:perspective + sodipodi:type="inkscape:persp3d" + inkscape:vp_x="-50 : 600 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_z="700 : 600 : 1" + inkscape:persp3d-origin="300 : 400 : 1" + id="perspective2661" /> + <inkscape:perspective + sodipodi:type="inkscape:persp3d" + inkscape:vp_x="-50 : 600 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_z="700 : 600 : 1" + inkscape:persp3d-origin="300 : 400 : 1" + id="perspective2475" /> + <inkscape:perspective + sodipodi:type="inkscape:persp3d" + inkscape:vp_x="-50 : 600 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_z="700 : 600 : 1" + inkscape:persp3d-origin="300 : 400 : 1" + id="perspective2592" /> + <inkscape:perspective + sodipodi:type="inkscape:persp3d" + inkscape:vp_x="-50 : 600 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_z="700 : 600 : 1" + inkscape:persp3d-origin="300 : 400 : 1" + id="perspective2483" /> + <inkscape:perspective + sodipodi:type="inkscape:persp3d" + inkscape:vp_x="-50 : 600 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_z="700 : 600 : 1" + inkscape:persp3d-origin="300 : 400 : 1" + id="perspective3325" /> + <inkscape:perspective + sodipodi:type="inkscape:persp3d" + inkscape:vp_x="-50 : 600 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_z="700 : 600 : 1" + inkscape:persp3d-origin="300 : 400 : 1" + id="perspective4826" /> + <inkscape:perspective + id="perspective2680" + inkscape:persp3d-origin="300 : 400 : 1" + inkscape:vp_z="700 : 600 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_x="-50 : 600 : 1" + sodipodi:type="inkscape:persp3d" /> + </defs> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="3.0729167" + inkscape:cx="148.55593" + inkscape:cy="48" + inkscape:document-units="px" + inkscape:current-layer="layer1" + gridtolerance="10000" + inkscape:window-width="1014" + inkscape:window-height="717" + inkscape:window-x="5" + inkscape:window-y="24" + width="768px" + height="256px" + showgrid="false" /> + <metadata + id="metadata1906"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <cc:license + rdf:resource="http://creativecommons.org/licenses/by-sa/3.0/" /> + <dc:title>feImage filter primitive example</dc:title> + <dc:date>23 Jan 2008</dc:date> + <dc:creator> + <cc:Agent> + <dc:title>Felipe Corrêa da Silva Sanches</dc:title> + </cc:Agent> + </dc:creator> + <dc:rights> + <cc:Agent> + <dc:title>Felipe Corrêa da Silva Sanches</dc:title> + </cc:Agent> + </dc:rights> + <dc:subject> + <rdf:Bag> + <rdf:li>Image filter primitive example</rdf:li> + </rdf:Bag> + </dc:subject> + <dc:description>this is an image originaly intended to be used in Inkscape</dc:description> + <dc:publisher> + <cc:Agent> + <dc:title>Felipe Corrêa da Silva Sanches</dc:title> + </cc:Agent> + </dc:publisher> + <dc:identifier /> + <dc:source>http://www.flickr.com/photos/dariosanches</dc:source> + <dc:relation /> + <dc:language /> + <dc:coverage /> + <dc:contributor> + <cc:Agent> + <dc:title>This file is derived from ticotico.jpg which is: +(C) 2007 Dario Sanches under the CC by-sa license +</dc:title> + </cc:Agent> + </dc:contributor> + </cc:Work> + <cc:License + rdf:about="http://creativecommons.org/licenses/by-sa/3.0/"> + <cc:permits + rdf:resource="http://creativecommons.org/ns#Reproduction" /> + <cc:permits + rdf:resource="http://creativecommons.org/ns#Distribution" /> + <cc:requires + rdf:resource="http://creativecommons.org/ns#Notice" /> + <cc:requires + rdf:resource="http://creativecommons.org/ns#Attribution" /> + <cc:permits + rdf:resource="http://creativecommons.org/ns#DerivativeWorks" /> + <cc:requires + rdf:resource="http://creativecommons.org/ns#ShareAlike" /> + </cc:License> + </rdf:RDF> + </metadata> + <g + inkscape:label="Taso 1" + inkscape:groupmode="layer" + id="layer1" + style="opacity:1"> + <image + y="-3.336705" + x="-45.587234" + id="image2682" + height="124.7063" + width="168.06779" + sodipodi:absref="ticotico.jpg" + xlink:href="./ticotico.jpg" /> + <rect + style="opacity:0.43324938;fill:none;fill-opacity:0.3678161;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.97574574;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:0.97574573, 1.95149145;stroke-dashoffset:0;stroke-opacity:1" + id="rect2686" + width="93.740524" + height="95.985802" + x="1.7403355" + y="1.1223228" /> + </g> +</svg> diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index a120b6a40..b3dd1a7d0 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -29,12 +29,14 @@ #include "desktop.h" #include "desktop-handles.h" #include "dialog-manager.h" +#include "dir-util.h" #include "document.h" #include "filter-chemistry.h" #include "filter-effects-dialog.h" #include "filter-enums.h" #include "inkscape.h" #include "path-prefix.h" +#include "prefs-utils.h" #include "selection.h" #include "sp-feblend.h" #include "sp-fecolormatrix.h" @@ -53,12 +55,14 @@ #include "style.h" #include "svg/svg-color.h" +#include "ui/dialog/filedialog.h" #include "verbs.h" #include "xml/node.h" #include "xml/node-observer.h" #include "xml/repr.h" #include <sstream> +#include "io/sys.h" #include <iostream> using namespace NR; @@ -545,6 +549,126 @@ private: double _angle_store; }; +static Inkscape::UI::Dialog::FileOpenDialog * selectFeImageFileInstance = NULL; + +//Displays a chooser for feImage input +//It may be a filename or the id for an SVG Element +//described in xlink:href syntax +class FileOrElementChooser : public Gtk::HBox, public AttrWidget +{ +public: + FileOrElementChooser(const SPAttributeEnum a) + : AttrWidget(a) + { + pack_start(_entry, false, false); + pack_start(_fromFile, false, false); + //pack_start(_fromSVGElement, false, false); + + _fromFile.set_label(_("Image File")); + _fromFile.signal_clicked().connect(sigc::mem_fun(*this, &FileOrElementChooser::select_file)); + + _fromSVGElement.set_label(_("Selected SVG Element")); + _fromSVGElement.signal_clicked().connect(sigc::mem_fun(*this, &FileOrElementChooser::select_svg_element)); + + _entry.signal_changed().connect(signal_attr_changed().make_slot()); + + show_all(); + + } + + // Returns the element in xlink:href form. + Glib::ustring get_as_attribute() const + { + return _entry.get_text(); + } + + + void set_from_attribute(SPObject* o) + { + const gchar* val = attribute_value(o); + if(val) { + _entry.set_text(val); + } + } + + void set_desktop(SPDesktop* d){ + _desktop = d; + } + +private: + void select_svg_element(){ + Inkscape::Selection* sel = sp_desktop_selection(_desktop); + if (sel->isEmpty()) return; + Inkscape::XML::Node* node = (Inkscape::XML::Node*) g_slist_nth_data((GSList *)sel->reprList(), 0); + if (!node || !node->matchAttributeName("id")) return; + + std::ostringstream xlikhref; + xlikhref << "#(" << node->attribute("id") << ")"; + _entry.set_text(xlikhref.str()); + } + + void select_file(){ + + //# Get the current directory for finding files + Glib::ustring open_path; + char *attr = (char *)prefs_get_string_attribute("dialogs.open", "path"); + if (attr) + open_path = attr; + + //# Test if the open_path directory exists + if (!Inkscape::IO::file_test(open_path.c_str(), + (GFileTest)(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) + open_path = ""; + + //# If no open path, default to our home directory + if (open_path.size() < 1) + { + open_path = g_get_home_dir(); + open_path.append(G_DIR_SEPARATOR_S); + } + + //# Create a dialog if we don't already have one + if (!selectFeImageFileInstance) { + selectFeImageFileInstance = + Inkscape::UI::Dialog::FileOpenDialog::create( + *_desktop->getToplevel(), + open_path, + Inkscape::UI::Dialog::SVG_TYPES,/*TODO: any image, not justy svg*/ + (char const *)_("Select an image to be used as feImage input")); + } + + //# Show the dialog + bool const success = selectFeImageFileInstance->show(); + if (!success) + return; + + //# User selected something. Get name and type + Glib::ustring fileName = selectFeImageFileInstance->getFilename(); + + if (fileName.size() > 0) { + + Glib::ustring newFileName = Glib::filename_to_utf8(fileName); + + if ( newFileName.size() > 0) + fileName = newFileName; + else + g_warning( "ERROR CONVERTING OPEN FILENAME TO UTF-8" ); + + open_path = fileName; + open_path.append(G_DIR_SEPARATOR_S); + prefs_set_string_attribute("dialogs.open", "path", open_path.c_str()); + + _entry.set_text(fileName); + } + return; + } + + Gtk::Entry _entry; + Gtk::Button _fromFile; + Gtk::Button _fromSVGElement; + SPDesktop* _desktop; +}; + class FilterEffectsDialog::Settings { public: @@ -676,7 +800,7 @@ public: add_attr_widget(dsb); return dsb; } - + // MultiSpinButton MultiSpinButton* add_multispinbutton(const SPAttributeEnum attr1, const SPAttributeEnum attr2, const Glib::ustring& label, const double lo, const double hi, @@ -705,6 +829,16 @@ public: add_attr_widget(msb->get_spinbuttons()[i]); return msb; } + + // FileOrElementChooser + FileOrElementChooser* add_fileorelement(const SPAttributeEnum attr, const Glib::ustring& label) + { + FileOrElementChooser* foech = new FileOrElementChooser(attr); + foech->set_desktop(_dialog.getDesktop()); + add_widget(foech, label); + add_attr_widget(foech); + return foech; + } // ComboBoxEnum template<typename T> ComboBoxEnum<T>* add_combo(const SPAttributeEnum attr, @@ -1883,7 +2017,6 @@ FilterEffectsDialog::FilterEffectsDialog() _sizegroup = Gtk::SizeGroup::create(Gtk::SIZE_GROUP_HORIZONTAL); _sizegroup->set_ignore_hidden(); - _add_primitive_type.remove_row(NR_FILTER_IMAGE); _add_primitive_type.remove_row(NR_FILTER_TILE); _add_primitive_type.remove_row(NR_FILTER_COMPONENTTRANSFER); @@ -2017,8 +2150,10 @@ void FilterEffectsDialog::init_settings_widgets() _settings->add_dualspinslider(SP_ATTR_RADIUS, _("Radius"), 0, 100, 1, 0.01, 1); _settings->type(NR_FILTER_IMAGE); - _settings->add_notimplemented(); - + _settings->add_fileorelement(SP_ATTR_XLINK_HREF, _("Source of Image")); + _settings->add_multispinbutton(SP_ATTR_X, SP_ATTR_Y, _("Coordinates"), -10000, 10000, 1, 1, 0); + _settings->add_multispinbutton(SP_ATTR_WIDTH, SP_ATTR_HEIGHT, _("Dimensions"), 0, 10000, 1, 1, 0); + _settings->type(NR_FILTER_OFFSET); _settings->add_spinslider(SP_ATTR_DX, _("Delta X"), -100, 100, 1, 0.01, 1); _settings->add_spinslider(SP_ATTR_DY, _("Delta Y"), -100, 100, 1, 0.01, 1); |
