summaryrefslogtreecommitdiffstats
path: root/src/ui
diff options
context:
space:
mode:
authorTavmjong Bah <tavmjong@free.fr>2013-11-19 12:10:04 +0000
committertavmjong-free <tavmjong@free.fr>2013-11-19 12:10:04 +0000
commit9318c9c232cf73aa806c366381f144dc6df4d218 (patch)
tree62ca4883e4ba7604ddbd7417b84699a44902485a /src/ui
parentfix initialization bug, that leads to non-continuous path (diff)
downloadinkscape-9318c9c232cf73aa806c366381f144dc6df4d218.tar.gz
inkscape-9318c9c232cf73aa806c366381f144dc6df4d218.zip
Add GUI for 'image-rendering'. Completes fix for blocker bug #1163449.
Removed two unused preference options for bitmaps. (bzr r12823)
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/dialog/inkscape-preferences.cpp37
-rw-r--r--src/ui/dialog/inkscape-preferences.h6
-rw-r--r--src/ui/dialog/object-attributes.cpp1
-rw-r--r--src/ui/dialog/object-properties.cpp82
-rw-r--r--src/ui/dialog/object-properties.h8
5 files changed, 117 insertions, 17 deletions
diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp
index e9cf2e753..03108b403 100644
--- a/src/ui/dialog/inkscape-preferences.cpp
+++ b/src/ui/dialog/inkscape-preferences.cpp
@@ -1419,34 +1419,43 @@ void InkscapePreferences::initPageRendering()
void InkscapePreferences::initPageBitmaps()
{
- {
- Glib::ustring labels[] = {_("None"), _("2x2"), _("4x4"), _("8x8"), _("16x16")};
- int values[] = {0, 1, 2, 3, 4};
- _misc_overs_bitmap.set_size_request(_sb_width);
- _misc_overs_bitmap.init("/options/bitmapoversample/value", labels, values, G_N_ELEMENTS(values), 1);
- _page_bitmaps.add_line( false, _("Oversample bitmaps:"), _misc_overs_bitmap, "", "", false);
- }
-
+ /* Note: /options/bitmapoversample removed with Cairo renderer */
+ _page_bitmaps.add_group_header( _("Edit"));
_misc_bitmap_autoreload.init(_("Automatically reload bitmaps"), "/options/bitmapautoreload/value", true);
_page_bitmaps.add_line( false, "", _misc_bitmap_autoreload, "",
_("Automatically reload linked images when file is changed on disk"));
_misc_bitmap_editor.init("/options/bitmapeditor/value", true);
_page_bitmaps.add_line( false, _("_Bitmap editor:"), _misc_bitmap_editor, "", "", true);
+
+ _page_bitmaps.add_group_header( _("Export"));
_importexport_export_res.init("/dialogs/export/defaultxdpi/value", 0.0, 6000.0, 1.0, 1.0, Inkscape::Util::Quantity::convert(1, "in", "px"), true, false);
_page_bitmaps.add_line( false, _("Default export _resolution:"), _importexport_export_res, _("dpi"),
_("Default bitmap resolution (in dots per inch) in the Export dialog"), false);
+ _page_bitmaps.add_group_header( _("Create"));
_bitmap_copy_res.init("/options/createbitmap/resolution", 1.0, 6000.0, 1.0, 1.0, Inkscape::Util::Quantity::convert(1, "in", "px"), true, false);
_page_bitmaps.add_line( false, _("Resolution for Create Bitmap _Copy:"), _bitmap_copy_res, _("dpi"),
_("Resolution used by the Create Bitmap Copy command"), false);
+
+ _page_bitmaps.add_group_header( _("Import"));
+ _bitmap_ask.init(_("Ask about linking and scaling when importing"), "/dialogs/import/ask", true);
+ _page_bitmaps.add_line( true, "", _bitmap_ask, "",
+ _("Pop-up linking and scaling dialog when importing bitmap image."));
+
{
- Glib::ustring labels[] = {_("Always embed"), _("Always link"), _("Ask")};
- Glib::ustring values[] = {"embed", "link", "ask"};
- _bitmap_import.init("/dialogs/import/link", labels, values, G_N_ELEMENTS(values), "ask");
- _page_bitmaps.add_line( false, _("Bitmap import:"), _bitmap_import, "", "", false);
+ Glib::ustring labels[] = {_("Embed"), _("Link")};
+ Glib::ustring values[] = {"embed", "link"};
+ _bitmap_link.init("/dialogs/import/link", labels, values, G_N_ELEMENTS(values), "link");
+ _page_bitmaps.add_line( false, _("Bitmap link:"), _bitmap_link, "", "", false);
+ }
- _bitmap_import_quality.init("/dialogs/import/quality", 1, 100, 1, 1, 100, true, false);
- _page_bitmaps.add_line( false, _("Bitmap import quality:"), _bitmap_import_quality, "%", "Bitmap import quality (jpeg only). 100 is best quality", false);
+ {
+ Glib::ustring labels[] = {_("None (auto)"), _("Smooth (optimizeQuality)"), _("Blocky (optimizeSpeed)") };
+ Glib::ustring values[] = {"auto", "optimizeQuality", "optimizeSpeed"};
+ _bitmap_scale.init("/dialogs/import/scale", labels, values, G_N_ELEMENTS(values), "scale");
+ _page_bitmaps.add_line( false, _("Bitmap scale (image-rendering):"), _bitmap_scale, "", "", false);
}
+
+ /* Note: /dialogs/import/quality removed use of in r12542 */
_importexport_import_res.init("/dialogs/import/defaultxdpi/value", 0.0, 6000.0, 1.0, 1.0, Inkscape::Util::Quantity::convert(1, "in", "px"), true, false);
_page_bitmaps.add_line( false, _("Default _import resolution:"), _importexport_import_res, _("dpi"),
_("Default bitmap resolution (in dots per inch) for bitmap import"), false);
diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h
index 56222fb22..da85b805d 100644
--- a/src/ui/dialog/inkscape-preferences.h
+++ b/src/ui/dialog/inkscape-preferences.h
@@ -365,12 +365,14 @@ protected:
UI::Widget::PrefCheckButton _spell_ignorenumbers;
UI::Widget::PrefCheckButton _spell_ignoreallcaps;
-
+ // Bitmaps
UI::Widget::PrefCombo _misc_overs_bitmap;
UI::Widget::PrefEntryFileButtonHBox _misc_bitmap_editor;
UI::Widget::PrefCheckButton _misc_bitmap_autoreload;
UI::Widget::PrefSpinButton _bitmap_copy_res;
- UI::Widget::PrefCombo _bitmap_import;
+ UI::Widget::PrefCheckButton _bitmap_ask;
+ UI::Widget::PrefCombo _bitmap_link;
+ UI::Widget::PrefCombo _bitmap_scale;
UI::Widget::PrefSpinButton _bitmap_import_quality;
UI::Widget::PrefEntry _kb_search;
diff --git a/src/ui/dialog/object-attributes.cpp b/src/ui/dialog/object-attributes.cpp
index 9a7b91c57..cfa5c6182 100644
--- a/src/ui/dialog/object-attributes.cpp
+++ b/src/ui/dialog/object-attributes.cpp
@@ -67,6 +67,7 @@ static const SPAttrDesc image_desc[] = {
{ N_("Y:"), "y"},
{ N_("Width:"), "width"},
{ N_("Height:"), "height"},
+ { N_("Image Rendering:"), "image-rendering"},
{ NULL, NULL}
};
diff --git a/src/ui/dialog/object-properties.cpp b/src/ui/dialog/object-properties.cpp
index 8a2b0299a..82b2cf6b1 100644
--- a/src/ui/dialog/object-properties.cpp
+++ b/src/ui/dialog/object-properties.cpp
@@ -36,6 +36,8 @@
#include "selection.h"
#include "desktop.h"
#include "sp-item.h"
+#include "sp-image.h"
+#include "xml/repr.h"
#include <glibmm/i18n.h>
#if WITH_GTKMM_3_0
@@ -56,11 +58,12 @@ ObjectProperties::ObjectProperties (void) :
#if WITH_GTKMM_3_0
TopTable(Gtk::manage(new Gtk::Grid())),
#else
- TopTable(Gtk::manage(new Gtk::Table(3, 4))),
+ TopTable(Gtk::manage(new Gtk::Table(4, 4))),
#endif
LabelID(_("_ID:"), 1),
LabelLabel(_("_Label:"), 1),
LabelTitle(_("_Title:"),1),
+ LabelImageRendering(_("_Image Rendering:"),1),
LabelDescription(_("_Description:"),1),
FrameDescription("", FALSE),
HBoxCheck(FALSE, 0),
@@ -248,6 +251,39 @@ void ObjectProperties::MakeWidget(void)
FrameTextDescription.add (TextViewDescription);
TextViewDescription.add_mnemonic_label(LabelDescription);
+ /* Image rendering */
+ /* Create the label for the object ImageRendering */
+ LabelImageRendering.set_label (LabelImageRendering.get_label() + " ");
+ LabelImageRendering.set_alignment (1, 0.5);
+
+#if WITH_GTKMM_3_0
+ LabelImageRendering.set_valign(Gtk::ALIGN_CENTER);
+ TopTable->attach(LabelImageRendering, 0, 3, 1, 1);
+#else
+ TopTable->attach(LabelImageRendering, 0, 1, 3, 4,
+ Gtk::SHRINK | Gtk::FILL,
+ Gtk::AttachOptions(), 0, 0 );
+#endif
+
+ /* Create the combo box text for the 'image-rendering' property */
+ ComboBoxTextImageRendering.append( "auto" );
+ ComboBoxTextImageRendering.append( "optimizeQuality" );
+ ComboBoxTextImageRendering.append( "optimizeSpeed" );
+ ComboBoxTextImageRendering.set_tooltip_text (_("The 'image-rendering' property can influence how a bitmap is up-scaled:\n\t'auto' no preference;\n\t'optimizeQuality' smooth;\n\t'optimizeSpeed' blocky.\nNote that this behaviour is not defined in the SVG 1.1 specification and not all browsers follow this interpretation."));
+
+#if WITH_GTKMM_3_0
+ ComboBoxTextImageRendering.set_valign(Gtk::ALIGN_CENTER);
+ TopTable->attach(ComboBoxTextImageRendering, 1, 3, 1, 1);
+#else
+ TopTable->attach(ComboBoxTextImageRendering, 1, 2, 3, 4,
+ Gtk::EXPAND | Gtk::FILL,
+ Gtk::AttachOptions(), 0, 0 );
+#endif
+
+ LabelImageRendering.set_mnemonic_widget (ComboBoxTextImageRendering);
+
+ ComboBoxTextImageRendering.signal_changed().connect(sigc::mem_fun(this, &ObjectProperties::image_rendering_changed));
+
/* Check boxes */
contents->pack_start (HBoxCheck, FALSE, FALSE, 0);
CheckTable->set_border_width(4);
@@ -376,6 +412,24 @@ void ObjectProperties::widget_setup(void)
}
EntryTitle.set_sensitive(TRUE);
+ /* Image Rendering */
+ if( SP_IS_IMAGE( item ) ) {
+ ComboBoxTextImageRendering.show();
+ LabelImageRendering.show();
+ char const *str = obj->getStyleProperty( "image-rendering", "auto" );
+ if( strcmp( str, "auto" ) == 0 ) {
+ ComboBoxTextImageRendering.set_active(0);
+ } else if( strcmp( str, "optimizeQuality" ) == 0 ) {
+ ComboBoxTextImageRendering.set_active(1);
+ } else {
+ ComboBoxTextImageRendering.set_active(2);
+ }
+ } else {
+ ComboBoxTextImageRendering.hide();
+ ComboBoxTextImageRendering.unset_active();
+ LabelImageRendering.hide();
+ }
+
/* Description */
gchar *desc = obj->desc();
if (desc) {
@@ -459,6 +513,32 @@ void ObjectProperties::label_changed(void)
blocked = false;
}
+void ObjectProperties::image_rendering_changed(void)
+{
+ if (blocked)
+ {
+ return;
+ }
+
+ SPItem *item = sp_desktop_selection(SP_ACTIVE_DESKTOP)->singleItem();
+ g_return_if_fail (item != NULL);
+
+ blocked = true;
+
+ Glib::ustring scale = ComboBoxTextImageRendering.get_active_text();
+
+ // We should unset if the parent computed value is auto and the desired value is auto.
+ SPCSSAttr *css = sp_repr_css_attr_new();
+ sp_repr_css_set_property(css, "image-rendering", scale.c_str());
+ Inkscape::XML::Node *image_node = item->getRepr();
+ if( image_node ) {
+ sp_repr_css_change(image_node, css, "style");
+ }
+ sp_repr_css_attr_unref( css );
+
+ blocked = false;
+}
+
void ObjectProperties::sensitivity_toggled (void)
{
if (blocked)
diff --git a/src/ui/dialog/object-properties.h b/src/ui/dialog/object-properties.h
index 624a18246..721c12c56 100644
--- a/src/ui/dialog/object-properties.h
+++ b/src/ui/dialog/object-properties.h
@@ -41,6 +41,7 @@
#include <gtkmm/expander.h>
#include <gtkmm/frame.h>
#include <gtkmm/textview.h>
+#include <gtkmm/comboboxtext.h>
#include "ui/dialog/desktop-tracker.h"
@@ -96,6 +97,8 @@ private:
Gtk::Entry EntryLabel; //the entry for the object label
Gtk::Label LabelTitle; //the label for the object title
Gtk::Entry EntryTitle; //the entry for the object title
+ Gtk::Label LabelImageRendering; // the label for 'image-rendering'
+ Gtk::ComboBoxText ComboBoxTextImageRendering; // the combo box text for 'image-rendering'
Gtk::Label LabelDescription; //the label for the object description
UI::Widget::Frame FrameDescription; //the frame for the object description
@@ -134,6 +137,11 @@ private:
*/
void label_changed(void);
+ /**
+ * Callback for 'image-rendering'.
+ */
+ void image_rendering_changed(void);
+
/**
* Callback for checkbox Lock.
*/