21#include <gtkmm/combobox.h>
22#include <gtkmm/frame.h>
23#include <gtkmm/spinbutton.h>
24#include <gtkmm/togglebutton.h>
25#include <gtkmm/treemodelfilter.h>
62 set_name(
"AlignAndDistribute");
70 std::string align_to = prefs->
getString(
"/dialogs/align/objects-align-to",
"selection");
74 filtered_store->set_visible_func([=,
this](
const Gtk::TreeModel::const_iterator &it) {
77 it->get_value(1,
name);
84 if (
auto desktop = win->get_desktop()) {
90 filtered_store->refilter();
102 bool sel_as_group = prefs->
getBool(
"/dialogs/align/sel-as-groups");
107 std::vector<std::pair<const char*, const char*>> align_buttons = {
108 {
"align-horizontal-right-to-anchor",
"right anchor" },
109 {
"align-horizontal-left",
"left" },
110 {
"align-horizontal-center",
"hcenter" },
111 {
"align-horizontal-right",
"right" },
112 {
"align-horizontal-left-to-anchor",
"left anchor" },
113 {
"align-horizontal-baseline",
"horizontal" },
114 {
"align-vertical-bottom-to-anchor",
"bottom anchor" },
115 {
"align-vertical-top",
"top" },
116 {
"align-vertical-center",
"vcenter" },
117 {
"align-vertical-bottom",
"bottom" },
118 {
"align-vertical-top-to-anchor",
"top anchor" },
119 {
"align-vertical-baseline",
"vertical" }
123 for (
auto align_button : align_buttons) {
124 auto &button = get_widget<Gtk::Button>(
builder, align_button.first);
125 button.signal_clicked().connect(
136 std::string align_nodes_to = prefs->
getString(
"/dialogs/align/nodes-align-to",
"first");
140 std::vector<std::pair<const char*, const char*>> align_node_buttons = {
141 {
"align-node-horizontal",
"horizontal"},
142 {
"align-node-vertical",
"vertical" }
145 for (
auto align_button: align_node_buttons) {
146 auto &button = get_widget<Gtk::Button>(
builder, align_button.first);
147 button.signal_clicked().connect(
159 auto set_icon_size_prefs = [prefs,
this]() {
167 set_icon_size_prefs();
202 prefs->
setBool(
"/dialogs/align/sel-as-groups", state);
210 prefs->
setString(
"/dialogs/align/objects-align-to", align_to);
213 if (
auto desktop = win->get_desktop()) {
215 if (selection->singleItem()) {
235 Glib::ustring argument = align_to;
240 argument +=
" group";
243 auto variant = Glib::Variant<Glib::ustring>::create(argument);
244 auto app = Gio::Application::get_default();
246 if (align_to.find(
"vertical") != Glib::ustring::npos or align_to.find(
"horizontal") != Glib::ustring::npos) {
247 app->activate_action(
"object-align-text", variant);
249 app->activate_action(
"object-align", variant);
259 auto variant = Glib::Variant<std::tuple<double, double>>
::create(std::tuple<double, double>(hgap, vgap));
260 auto app = Gio::Application::get_default();
261 app->activate_action(
"object-remove-overlaps", variant);
269 auto variant = Glib::Variant<Glib::ustring>::create(argument);
277 win->activate_action(
"win.node-align-horizontal", variant);
279 win->activate_action(
"win.node-align-vertical", variant);
Align and Distribute widget.
InkscapeWindow * get_active_window()
static InkscapeApplication * instance()
Singleton instance.
SPItem * singleItem()
Returns a single selected item.
Preference storage class.
bool getBool(Glib::ustring const &pref_path, bool def=false)
Retrieve a Boolean value.
Glib::ustring getString(Glib::ustring const &pref_path, Glib::ustring const &def="")
Retrieve an UTF-8 string.
static Preferences * get()
Access the singleton Preferences object.
std::unique_ptr< PreferencesObserver > createObserver(Glib::ustring path, std::function< void(const Preferences::Entry &new_value)> callback)
Create an observer watching preference 'path' and calling provided function when preference changes.
void setString(Glib::ustring const &pref_path, Glib::ustring const &value)
Set an UTF-8 string value.
int getIntLimited(Glib::ustring const &pref_path, int def=0, int min=INT_MIN, int max=INT_MAX)
Retrieve a limited integer.
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.
Gtk::ComboBox & align_relative_node
sigc::scoped_connection sel_changed
Gtk::SpinButton & remove_overlap_vgap
void on_remove_overlap_clicked()
void on_align_relative_object_changed()
void on_align_as_group_clicked()
Gtk::Button & remove_overlap_button
AlignAndDistribute(Inkscape::UI::Dialog::DialogBase *dlg)
void on_align_relative_node_changed()
Gtk::SpinButton & remove_overlap_hgap
Gtk::ToggleButton & align_move_as_group
Gtk::Frame & remove_overlap_frame
Gtk::ComboBox & align_relative_object
void tool_changed(SPDesktop *desktop)
void desktop_changed(SPDesktop *desktop)
Inkscape::PrefObserver _icon_sizes_changed
Gtk::Box & align_and_distribute_box
void on_align_clicked(std::string const &align_to)
Glib::ustring multi_selection_align_to
void on_align_node_clicked(std::string const &align_to)
sigc::connection tool_connection
Glib::RefPtr< Gtk::Builder > builder
std::set< Glib::ustring > single_selection_relative_categories
Gtk::Box & align_and_distribute_node
Glib::ustring single_selection_align_to
void tool_changed_callback(SPDesktop *desktop, Inkscape::UI::Tools::ToolBase *tool)
Gtk::Box & align_and_distribute_object
DialogBase is the base class for the dialog system.
SPDesktop * getDesktop() const
To do: update description of desktop.
Inkscape::Selection * getSelection() const
sigc::connection connectEventContextChanged(F &&slot)
Editable view implementation.
A base class for all dialogs.
Inkscape - An SVG editor.
std::string get_filename(Type type, char const *filename, bool localized, bool silent)
void set_icon_sizes(Gtk::Widget *parent, int pixel_size)
Recursively set all the icon sizes inside this parent widget.
W & get_widget(const Glib::RefPtr< Gtk::Builder > &builder, const char *id)
static Geom::Point direction(Geom::Point const &first, Geom::Point const &second)
Computes an unit vector of the direction from first to second control point.
Glib::RefPtr< Gtk::Builder > create_builder(const char *filename)
static void append(std::vector< T > &target, std::vector< T > &&source)
Inkscape::IO::Resource - simple resource API.
Glib::RefPtr< Gtk::Builder > builder