32#include <glibmm/i18n.h>
33#include <gtkmm/adjustment.h>
35#include <gtkmm/enums.h>
36#include <gtkmm/expander.h>
37#include <gtkmm/grid.h>
38#include <gtkmm/label.h>
39#include <gtkmm/object.h>
40#include <gtkmm/separator.h>
41#include <gtkmm/version.h>
60 :
DialogBase(
"/dialogs/object-properties-widget/",
"ObjectPropertiesWidget")
62 , _current_item(nullptr)
63 , _label_id(_(
"_ID:"), true)
64 , _label_label(_(
"_Label:"), true)
65 , _label_title(_(
"_Title:"), true)
66 , _label_dpi(_(
"_DPI SVG:"), true)
67 , _label_color(_(
"Highlight Color:"), true)
68 , _highlight_color(_(
"Highlight Color"),
"",
Colors::
Color(0xff0000ff), true)
69 , _cb_hide(_(
"_Hide"), true)
70 , _cb_lock(_(
"L_ock"), true)
71 , _cb_aspect_ratio(_(
"Preserve Ratio"), true)
72 , _exp_interactivity(_(
"_Interactivity"), true)
101 const int spacing = 4;
102 set_spacing(spacing);
108 _exp_properties.property_expanded().signal_changed().connect([exp_path,
this]{
113 auto exp_path =
_prefs_path +
"expand-interactive";
121 auto const grid_top = Gtk::make_managed<Gtk::Grid>();
122 grid_top->set_row_spacing(spacing);
123 grid_top->set_column_spacing(spacing);
132 _label_id.set_valign(Gtk::Align::CENTER);
135 _entry_id.set_tooltip_text(_(
"The id= attribute (only letters, digits, and the characters .-_: allowed)"));
138 _entry_id.set_valign(Gtk::Align::CENTER);
153 _entry_label.set_tooltip_text(_(
"A freeform label for the object"));
185 auto const label_desc = Gtk::make_managed<Gtk::Label>(_(
"_Description:"),
true);
186 auto const frame_desc = Gtk::make_managed<UI::Widget::Frame>(
"", FALSE);
187 frame_desc->set_label_widget(*label_desc);
188 label_desc->set_margin_bottom(spacing);
189 frame_desc->set_padding(0, 0, 0, 0);
190 frame_desc->set_size_request(-1, 80);
209 auto adj = Gtk::Adjustment::create(96, 1, 2400);
210 adj->set_step_increment(10);
211 adj->set_page_increment(100);
213 _spin_dpi.set_tooltip_text(_(
"Set resolution for vector images (press Enter to see change in rendering quality)"));
217#if GTKMM_CHECK_VERSION(4, 14, 0)
222 auto const hb_checkboxes = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::HORIZONTAL);
224 auto const grid_cb = Gtk::make_managed<Gtk::Grid>();
225 grid_cb->set_row_homogeneous();
226 grid_cb->set_column_homogeneous(
true);
227 grid_cb->set_row_spacing(spacing);
228 grid_cb->set_column_spacing(spacing);
229 grid_cb->set_margin(0);
233 _cb_hide.set_tooltip_text (_(
"Check to make the object invisible"));
235 _cb_hide.set_valign(Gtk::Align::CENTER);
236 grid_cb->attach(
_cb_hide, 0, 0, 1, 1);
242 _cb_lock.set_tooltip_text(_(
"Check to make the object insensitive (not selectable by mouse)"));
244 _cb_lock.set_valign(Gtk::Align::CENTER);
245 grid_cb->attach(
_cb_lock, 1, 0, 1, 1);
250 _cb_aspect_ratio.set_tooltip_text(_(
"Check to preserve aspect ratio on images"));
258 auto const btn_set = Gtk::make_managed<Gtk::Button>(_(
"_Set"),
true);
259 btn_set->set_hexpand();
260 btn_set->set_valign(Gtk::Align::CENTER);
261 grid_cb->attach(*btn_set, 1, 1, 1, 1);
275 grid_top->attach(*frame_desc, 0, 5, 2, 1);
276 grid_top->attach(*hb_checkboxes, 0, 6, 2, 1);
279 auto vbox = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::VERTICAL);
280 auto js = Gtk::make_managed<Gtk::Label>();
281 js->set_markup(_(
"<small><i>Enter JavaScript code for interactive behavior in a browser.</i></small>"));
282 js->set_ellipsize(Pango::EllipsizeMode::END);
284 vbox->set_spacing(spacing);
289 auto sep = Gtk::make_managed<Gtk::Separator>(Gtk::Orientation::HORIZONTAL);
307 auto set_sens = [](Gtk::Expander& exp,
bool sensitive) {
308 if (
auto w = exp.get_child()) {
309 w->set_sensitive(sensitive);
345 bool show_dpi = is<SPImage>(
item);
369 _entry_id.set_text(obj && obj->getId() ? obj->getId() :
"");
371 _label_id.set_markup_with_mnemonic(_(
"_ID:") + Glib::ustring(
" "));
374 auto currentlabel = obj ? obj->
label() :
nullptr;
375 auto placeholder =
"";
378 placeholder = obj ? obj->defaultLabel() :
"";
385 auto title = obj ? obj->title() :
nullptr;
396 auto desc = obj ? obj->desc() :
nullptr;
418 g_return_if_fail (
item !=
nullptr);
423 gchar *
id = g_strdup(
_entry_id.get_text().c_str());
424 g_strcanon(
id,
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.:",
'_');
426 _label_id.set_markup_with_mnemonic(_(
"_ID:") + Glib::ustring(
" "));
427 }
else if (!*
id || !isalnum (*
id)) {
429 }
else if (
getDocument()->getObjectById(
id) !=
nullptr) {
432 _label_id.set_markup_with_mnemonic(_(
"_ID:") + Glib::ustring(
" "));
445 char const *currentlabel = obj->
label();
446 if (
label.compare(currentlabel ? currentlabel :
"")) {
457 if (is<SPImage>(obj)) {
464 Gtk::TextBuffer::iterator
start,
end;
467 if (obj->
setDesc(desc.c_str())) {
492 g_return_if_fail(
item !=
nullptr);
507 g_return_if_fail(
item !=
nullptr);
519 if (is<SPImage>(
item)) {
534 g_return_if_fail(
item !=
nullptr);
static void done(SPDocument *document, Glib::ustring const &event_description, Glib::ustring const &undo_icon, unsigned int object_modified_tag=0)
SPItem * singleItem()
Returns a single selected item.
bool getBool(Glib::ustring const &pref_path, bool def=false)
Retrieve a Boolean value.
static Preferences * get()
Access the singleton Preferences object.
void setBool(Glib::ustring const &pref_path, bool value)
Set a Boolean value.
The set of selected SPObjects for a given document and layer model.
DialogBase is the base class for the dialog system.
Selection * getSelection() const
SPDocument * getDocument() const
Glib::ustring const _prefs_path
SPDesktop * getDesktop() const
Gtk::CheckButton _cb_lock
Gtk::TextView _tv_description
Gtk::Expander _exp_interactivity
Gtk::Frame _ft_description
std::vector< Glib::ustring > _int_labels
Gtk::SpinButton _spin_dpi
SPAttributeTable * _attr_table
Gtk::Expander _exp_properties
Inkscape::UI::Widget::ColorPicker _highlight_color
void _highlightChanged(Colors::Color const &color)
void _hiddenToggled()
Callback for checkbox Hide.
Gtk::CheckButton _cb_aspect_ratio
void _aspectRatioToggled()
Callback for checkbox Preserve Aspect Ratio.
void _init()
Constructor auxiliary function creating the child widgets.
void update_entries()
Updates entries and other child widgets on selection change, object modification, etc.
std::vector< Glib::ustring > _int_attrs
Gtk::CheckButton _cb_hide
void _labelChanged()
Sets object properties (ID, label, title, description) on user input.
void desktopReplaced() override
Called when the desktop has certainly changed.
void selectionChanged(Selection *selection) override
void _sensitivityToggled()
Callback for checkbox Lock.
double getAttributeDouble(Util::const_char_ptr key, double default_value=0.0) const
A base class for dialogs to enter the value of several properties.
void change_object(SPObject *object)
Update values in entry boxes on change of object.
void create(const std::vector< Glib::ustring > &labels, const std::vector< Glib::ustring > &attributes)
Base class for visual SVG elements.
void setHighlight(Inkscape::Colors::Color color)
virtual Inkscape::Colors::Color highlight_color() const
void setLocked(bool lock, bool recursive=false)
bool isExplicitlyHidden() const
Returns something suitable for the ‘Hide’ checkbox in the Object Properties dialog box.
void setExplicitlyHidden(bool val)
Sets the display CSS property to ‘hidden’ if val is true, otherwise makes it unset.
SPObject is an abstract base class of all of the document nodes at the SVG document level.
char const * label() const
Gets the author-visible label property for the object or a default if no label is defined.
void setAttribute(Inkscape::Util::const_char_ptr key, Inkscape::Util::const_char_ptr value)
bool setDesc(char const *desc, bool verbatim=false)
Sets the description of this object.
char const * getId() const
Returns the objects current ID string.
bool setTitle(char const *title, bool verbatim=false)
Sets the title of this object.
void setLabel(char const *label)
Sets the author-visible label for this object.
Inkscape::XML::Node * getRepr()
Returns the XML representation of tree.
char const * getAttribute(char const *name) const
TODO: insert short description here.
Macro for icon names used in Inkscape.
void pack_start(Gtk::Box &box, Gtk::Widget &child, bool const expand, bool const fill, unsigned const padding)
Adds child to box, packed with reference to the start of box.
Glib::ustring format_classic(T const &... args)
Helpers for using Gtk::Boxes, encapsulating large changes between GTK3 & GTK4.
Singleton class to access the preferences file in a convenient way.
SVG <image> implementation.
Some things pertinent to all visible shapes: SPItem, SPItemView, SPItemCtx.