19#include <glibmm/i18n.h>
20#include <glibmm/main.h>
21#include <gtkmm/adjustment.h>
23#include <gtkmm/enums.h>
24#include <gtkmm/image.h>
25#include <gtkmm/togglebutton.h>
58 , _action_prefix{
"selector:toolbar:"}
77 auto unit_menu =
_tracker->create_tool_item(_(
"Units"), (
""));
78 get_widget<Gtk::Box>(
builder,
"unit_menu_box").append(*unit_menu);
87 for (
auto const child : children) {
88 if (
child->has_css_class(
"context_item")) {
106 _lock_btn.set_active(prefs->getBool(
"/tools/select/lock_aspect_ratio",
false));
149 auto const path =
"/tools/select/" +
name;
151 auto const adj = btn.get_adjustment();
154 _tracker->addAdjustment(adj->gobj());
166 bool const sensitive = selection && !selection->
isEmpty();
168 item->set_sensitive(sensitive);
187 auto page_correction = document->get_origin_follows_page();
189 document->ensureUpToDate();
199 auto const unit =
_tracker->getActiveUnit();
201 double old_w = bbox_user->width();
202 double old_h = bbox_user->height();
203 double new_w, new_h, new_x, new_y = 0;
205 auto _adj_x =
_x_item.get_adjustment();
206 auto _adj_y =
_y_item.get_adjustment();
207 auto _adj_w =
_w_item.get_adjustment();
208 auto _adj_h =
_h_item.get_adjustment();
211 new_w = Quantity::convert(_adj_w->get_value(), unit,
"px");
212 new_h = Quantity::convert(_adj_h->get_value(), unit,
"px");
213 new_x = Quantity::convert(_adj_x->get_value(), unit,
"px");
214 new_y = Quantity::convert(_adj_y->get_value(), unit,
"px");
217 double old_x = bbox_user->min()[
Geom::X] + (old_w * selection->anchor.x());
218 double old_y = bbox_user->min()[
Geom::Y] + (old_h * selection->anchor.y());
221 if (page_correction) {
222 old_x -=
page.left();
226 new_x = old_x * (_adj_x->get_value() / 100 / unit->factor);
227 new_y = old_y * (_adj_y->get_value() / 100 / unit->factor);
228 new_w = old_w * (_adj_w->get_value() / 100 / unit->factor);
229 new_h = old_h * (_adj_h->get_value() / 100 / unit->factor);
233 double x0 = (new_x - (old_w * selection->anchor.x())) - ((new_w - old_w) * selection->anchor.x());
234 double y0 = (new_y - (old_h * selection->anchor.y())) - ((new_h - old_h) * selection->anchor.y());
237 if (page_correction) {
242 double x1 = x0 + new_w;
243 double xrel = new_w / old_w;
244 double y1 = y0 + new_h;
245 double yrel = new_h / old_h;
250 x1 = x0 + yrel * bbox_user->dimensions()[
Geom::X];
251 }
else if (adj == _adj_w) {
252 y1 = y0 + xrel * bbox_user->dimensions()[
Geom::Y];
257 double mh = fabs(x0 - bbox_user->min()[
Geom::X]);
258 double sh = fabs(x1 - bbox_user->max()[
Geom::X]);
259 double mv = fabs(y0 - bbox_user->min()[
Geom::Y]);
260 double sv = fabs(y1 - bbox_user->max()[
Geom::Y]);
264 mh = Quantity::convert(mh,
"px", unit);
265 sh = Quantity::convert(sh,
"px", unit);
266 mv = Quantity::convert(mv,
"px", unit);
267 sv = Quantity::convert(sv,
"px", unit);
274 bool transform_stroke = prefs->getBool(
"/options/transform/stroke",
true);
275 bool preserve = prefs->getBool(
"/options/preservetransform/value",
false);
278 if (prefs->getInt(
"/tools/bounding_box") == 0) {
288 selection->applyAffine(scaler);
303 auto const unit =
_tracker->getActiveUnit();
305 auto width = bbox->width();
306 auto height = bbox->height();
317 auto _adj_x =
_x_item.get_adjustment();
318 auto _adj_y =
_y_item.get_adjustment();
319 auto _adj_w =
_w_item.get_adjustment();
320 auto _adj_h =
_h_item.get_adjustment();
323 double const val = unit->factor * 100;
324 _adj_x->set_value(val);
325 _adj_y->set_value(val);
326 _adj_w->set_value(val);
327 _adj_h->set_value(val);
328 _tracker->setFullVal(_adj_x->gobj(), x);
329 _tracker->setFullVal(_adj_y->gobj(), y);
333 _adj_x->set_value(Quantity::convert(x,
"px", unit));
334 _adj_y->set_value(Quantity::convert(y,
"px", unit));
335 _adj_w->set_value(Quantity::convert(
width,
"px", unit));
336 _adj_h->set_value(Quantity::convert(
height,
"px", unit));
352 if (flags & (SP_OBJECT_MODIFIED_FLAG |
353 SP_OBJECT_PARENT_MODIFIED_FLAG |
354 SP_OBJECT_CHILD_MODIFIED_FLAG ))
367 double const threshold = 5e-4;
368 char const *
const action = mh > threshold ?
"move:horizontal:" :
369 sh > threshold ?
"scale:horizontal:" :
370 mv > threshold ?
"move:vertical:" :
371 sv > threshold ?
"scale:vertical:" :
nullptr;
383 _lock_btn.set_image_from_icon_name(
_lock_btn.get_active() ?
"object-locked" :
"object-unlocked");
3x3 matrix representing an affine transformation.
C left() const
Return leftmost coordinate of the rectangle (+X is to the right).
Axis-aligned rectangle that can be empty.
constexpr Coord y() const noexcept
constexpr Coord x() const noexcept
static void maybeDone(SPDocument *document, const gchar *keyconst, Glib::ustring const &event_description, Glib::ustring const &undo_icon, unsigned int object_modified_tag=0)
MessageId flash(MessageType type, char const *message)
Temporarily pushes a message onto the stack.
Geom::OptRect preferredBounds() const
Returns either the visual or geometric bounding rectangle of the selection, based on the preferences ...
bool isEmpty()
Returns true if no items are selected.
Geom::Rect getSelectedPageRect() const
Returns the selected page rect, OR the viewbox rect.
Data type representing a typeless value of a preference.
double getDouble(Glib::ustring const &pref_path, double def=0.0, Glib::ustring const &unit="")
Retrieve a floating point value.
static Preferences * get()
Access the singleton Preferences object.
void setInt(Glib::ustring const &pref_path, int value)
Set an integer value.
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.
sigc::connection connectChanged(sigc::slot< void(Selection *)> slot)
Connects a slot to be notified of selection changes.
To do: update description of desktop.
SPDocument * getDocument() const
Inkscape::MessageStack * messageStack() const
Inkscape::Selection * getSelection() const
bool get_origin_follows_page()
Inkscape::PageManager & getPageManager()
Editable view implementation.
TODO: insert short description here.
Macro for icon names used in Inkscape.
Raw stack of active status messages.
std::vector< Gtk::Widget * > get_children(Gtk::Widget &widget)
Get a vector of the widgetʼs children, from get_first_child() through each get_next_sibling().
W & get_widget(const Glib::RefPtr< Gtk::Builder > &builder, const char *id)
W & get_derived_widget(const Glib::RefPtr< Gtk::Builder > &builder, const char *id, Args &&... args)
Glib::RefPtr< Gtk::Builder > create_builder(const char *filename)
Miscellaneous supporting code.
@ UNIT_TYPE_DIMENSIONLESS
Glib::RefPtr< Gtk::Builder > builder