summaryrefslogtreecommitdiffstats
path: root/src/ui/dialog/object-properties.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/dialog/object-properties.cpp')
-rw-r--r--src/ui/dialog/object-properties.cpp73
1 files changed, 68 insertions, 5 deletions
diff --git a/src/ui/dialog/object-properties.cpp b/src/ui/dialog/object-properties.cpp
index 8daa83e9c..849ffae0a 100644
--- a/src/ui/dialog/object-properties.cpp
+++ b/src/ui/dialog/object-properties.cpp
@@ -48,14 +48,16 @@ namespace Dialog {
ObjectProperties::ObjectProperties()
: UI::Widget::Panel("/dialogs/object/", SP_VERB_DIALOG_ITEM)
- , _blocked (false)
+ , _blocked(false)
, _current_item(nullptr)
, _label_id(_("_ID:"), true)
, _label_label(_("_Label:"), true)
, _label_title(_("_Title:"), true)
+ , _label_dpi(_("_DPI SVG:"), true)
, _label_image_rendering(_("_Image Rendering:"), true)
, _cb_hide(_("_Hide"), true)
, _cb_lock(_("L_ock"), true)
+ , _cb_aspect_ratio(_("Pereserve Ratio"), true)
, _attr_table(Gtk::manage(new SPAttributeTable()))
, _desktop(nullptr)
{
@@ -185,12 +187,28 @@ void ObjectProperties::_init()
_ft_description.add(_tv_description);
_tv_description.add_mnemonic_label(*label_desc);
+ /* Create the label for the object title */
+ _label_dpi.set_label(_label_dpi.get_label() + " ");
+ _label_dpi.set_halign(Gtk::ALIGN_END);
+ _label_dpi.set_valign(Gtk::ALIGN_CENTER);
+ grid_top->attach(_label_dpi, 0, 3, 1, 1);
+
+ /* Create the entry box for the SVG DPI */
+ _spin_dpi.set_digits(2);
+ _spin_dpi.set_range(1, 1200);
+ grid_top->attach(_spin_dpi, 1, 3, 1, 1);
+
+ _label_dpi.set_mnemonic_widget(_spin_dpi);
+ // pressing enter in the label field is the same as clicking Set:
+ _spin_dpi.signal_activate().connect(sigc::mem_fun(this, &ObjectProperties::_labelChanged));
+
+
/* Image rendering */
/* Create the label for the object ImageRendering */
_label_image_rendering.set_label(_label_image_rendering.get_label() + " ");
_label_image_rendering.set_halign(Gtk::ALIGN_END);
_label_image_rendering.set_valign(Gtk::ALIGN_CENTER);
- grid_top->attach(_label_image_rendering, 0, 3, 1, 1);
+ grid_top->attach(_label_image_rendering, 0, 4, 1, 1);
/* Create the combo box text for the 'image-rendering' property */
_combo_image_rendering.append( "auto" );
@@ -199,7 +217,7 @@ void ObjectProperties::_init()
_combo_image_rendering.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."));
_combo_image_rendering.set_valign(Gtk::ALIGN_CENTER);
- grid_top->attach(_combo_image_rendering, 1, 3, 1, 1);
+ grid_top->attach(_combo_image_rendering, 1, 4, 1, 1);
_label_image_rendering.set_mnemonic_widget(_combo_image_rendering);
@@ -207,6 +225,8 @@ void ObjectProperties::_init()
sigc::mem_fun(this, &ObjectProperties::_imageRenderingChanged)
);
+
+
/* Check boxes */
Gtk::HBox *hb_checkboxes = Gtk::manage(new Gtk::HBox());
contents->pack_start(*hb_checkboxes, FALSE, FALSE, 0);
@@ -235,12 +255,20 @@ void ObjectProperties::_init()
_cb_lock.signal_toggled().connect(sigc::mem_fun(this, &ObjectProperties::_sensitivityToggled));
+ /* Preserve aspect ratio */
+ _cb_aspect_ratio.set_tooltip_text(_("Check to preserve aspect ratio on images"));
+ _cb_aspect_ratio.set_hexpand();
+ _cb_aspect_ratio.set_valign(Gtk::ALIGN_CENTER);
+ grid_cb->attach(_cb_aspect_ratio, 0, 1, 1, 1);
+
+ _cb_aspect_ratio.signal_toggled().connect(sigc::mem_fun(this, &ObjectProperties::_aspectRatioToggled));
+
/* Button for setting the object's id, label, title and description. */
Gtk::Button *btn_set = Gtk::manage(new Gtk::Button(_("_Set"), true));
btn_set->set_hexpand();
btn_set->set_valign(Gtk::ALIGN_CENTER);
- grid_cb->attach(*btn_set, 2, 0, 1, 1);
+ grid_cb->attach(*btn_set, 1, 1, 1, 1);
btn_set->signal_clicked().connect(sigc::mem_fun(this, &ObjectProperties::_labelChanged));
@@ -284,7 +312,7 @@ void ObjectProperties::update()
return;
}
_blocked = true;
-
+ _cb_aspect_ratio.set_active(item->getAttribute("preserveAspectRatio") == "true");
_cb_lock.set_active(item->isLocked()); /* Sensitive */
_cb_hide.set_active(item->isExplicitlyHidden()); /* Hidden */
@@ -409,6 +437,13 @@ void ObjectProperties::_labelChanged()
_("Set object title"));
}
+ /* Retrieve the DPI */
+ if (SP_IS_IMAGE(obj)) {
+ Glib::ustring dpi_value = Glib::ustring::format(_spin_dpi.get_value());
+ obj->setAttribute("inkscape:svg-dpi", dpi_value);
+ DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM, _("Set image DPI"));
+ }
+
/* Retrieve the description */
Gtk::TextBuffer::iterator start, end;
_tv_description.get_buffer()->get_bounds(start, end);
@@ -464,6 +499,34 @@ void ObjectProperties::_sensitivityToggled()
_blocked = false;
}
+void ObjectProperties::_aspectRatioToggled()
+{
+ if (_blocked) {
+ return;
+ }
+
+ SPItem *item = SP_ACTIVE_DESKTOP->getSelection()->singleItem();
+ g_return_if_fail(item != nullptr);
+
+ _blocked = true;
+
+ item->setLocked(_cb_aspect_ratio.get_active());
+ const char *active;
+ if (_cb_aspect_ratio.get_active()) {
+ active = "true";
+ }
+ else {
+ active = "none";
+ }
+ /* Retrieve the DPI */
+ if (SP_IS_IMAGE(item)) {
+ Glib::ustring dpi_value = Glib::ustring::format(_spin_dpi.get_value());
+ item->setAttribute("preserveAspectRatio", active);
+ DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_ITEM, _("Set preserve ratio"));
+ }
+ _blocked = false;
+}
+
void ObjectProperties::_hiddenToggled()
{
if (_blocked) {