18#include <gtkmm/applicationwindow.h>
19#include <gtkmm/grid.h>
20#include <gtkmm/label.h>
21#include <gtkmm/popover.h>
22#include <gtkmm/popovermenu.h>
43 auto &statusbar = UI::get_widget<Gtk::Box>(
builder,
"statusbar");
55 zoom = &UI::get_widget<Gtk::Box>(
builder,
"statusbar-zoom");
56 zoom_value = &UI::get_derived_widget<UI::Widget::SpinButton>(
builder,
"statusbar-zoom-value");
59 const std::vector<std::pair<std::string, std::string>> zoom_entries =
61 {
"10%",
"win.canvas-zoom-absolute(0.1)" },
62 {
"20%",
"win.canvas-zoom-absolute(0.2)" },
63 {
"50%",
"win.canvas-zoom-absolute(0.5)" },
64 {
"100%",
"win.canvas-zoom-absolute(1.0)" },
65 {
"200%",
"win.canvas-zoom-absolute(2.0)" },
66 {
"500%",
"win.canvas-zoom-absolute(5.0)" },
67 {
"1000%",
"win.canvas-zoom-absolute(10.0)"},
70 auto zoom_menu = UI::get_object<Gio::Menu>(
builder,
"statusbar-zoom-menu");
71 for (
auto entry : zoom_entries) {
72 auto menu_item = Gio::MenuItem::create(entry.first, entry.second);
73 zoom_menu->prepend_item(menu_item);
76 zoom_popover = std::make_unique<Gtk::PopoverMenu>(zoom_menu, Gtk::PopoverMenu::Flags::NESTED);
85 auto zoom_adjustment =
zoom_value->get_adjustment();
91 rotate = &UI::get_widget<Gtk::Box>(
builder,
"statusbar-rotate");
92 rotate_value = &UI::get_derived_widget<UI::Widget::SpinButton>(
builder,
"statusbar-rotate-value");
96 const std::vector<std::pair<std::string, std::string>> rotate_entries =
98 {
"180°",
"win.canvas-rotate-absolute-degrees( 180.0)" },
99 {
"135°",
"win.canvas-rotate-absolute-degrees( 135.0)" },
100 {
"90°",
"win.canvas-rotate-absolute-degrees( 90.0)" },
101 {
"45°",
"win.canvas-rotate-absolute-degrees( 45.0)" },
102 {
"0°",
"win.canvas-rotate-absolute-degrees( 0.0)" },
103 {
"-45°",
"win.canvas-rotate-absolute-degrees( -45.0)" },
104 {
"-90°",
"win.canvas-rotate-absolute-degrees( -90.0)" },
105 {
"-135°",
"win.canvas-rotate-absolute-degrees(-135.0)" },
108 auto rotate_menu = UI::get_object<Gio::Menu>(
builder,
"statusbar-rotate-menu");
109 for (
auto entry : rotate_entries) {
110 auto menu_item = Gio::MenuItem::create(entry.first, entry.second);
111 rotate_menu->prepend_item(menu_item);
114 rotate_popover = std::make_unique<Gtk::PopoverMenu>(rotate_menu, Gtk::PopoverMenu::Flags::NESTED);
125 selected_style = Gtk::make_managed<Inkscape::UI::Widget::SelectedStyle>();
129 layer_selector = Gtk::make_managed<Inkscape::UI::Widget::LayerSelector>();
167 Glib::ustring pattern =
"%1";
169#if PANGO_VERSION_CHECK(1,50,0)
171 pattern =
"<span line_height='0.8'>%1</span>";
175 auto const msg = Glib::ustring::compose(pattern, message ? message :
"");
185 char * str_total = g_strdup_printf(
"(%7.2f, %7.2f)", p.
x(), p.
y());
212 double value = g_strtod(
zoom_value->get_text().c_str(),
nullptr);
213 new_value =
log(value / 100.0) /
log(2);
220 double value =
floor (10 * (pow (2,
zoom_value->get_value()) * 100.0 + 0.05)) / 10;
224 g_snprintf(b, 64,
"%4.1f%%", value);
226 g_snprintf(b, 64,
"%4.0f%%", value);
240 double const zoom_factor = std::pow(2,
zoom_value->get_value());
242 if (
auto const window =
dynamic_cast<Gtk::ApplicationWindow *
>(get_root())) {
243 auto variant = Glib::Variant<double>::create(zoom_factor);
244 window->activate_action(
"win.canvas-zoom-absolute", variant);
246 std::cerr <<
"StatusBar::zoom_value_changed(): failed to get window!" << std::endl;
265 double correction = 1.0;
266 if (prefs->getDouble(
"/options/zoomcorrection/shown",
true)) {
267 correction = prefs->getDouble(
"/options/zoomcorrection/value", 1.0);
279 if (val < -180) val += 360;
280 if (val > 180) val -= 360;
283 g_snprintf(b, 64,
"%7.2f°", val);
296 if (
auto const window =
dynamic_cast<Gtk::ApplicationWindow *
>(get_root())) {
297 auto variant = Glib::Variant<double>::create(
rotate_value->get_value());
298 window->activate_action(
"win.canvas-rotate-absolute-degrees", variant);
300 std::cerr <<
"StatusBar::rotate_value_changed(): failed to get window!" << std::endl;
324 Glib::ustring path(
"/statusbar/visibility/");
326 layer_selector->set_visible(prefs->getBool(path +
"layer",
true));
327 selected_style->set_visible(prefs->getBool(path +
"style",
true));
328 coordinates->set_visible( prefs->getBool(path +
"coordinates",
true));
329 rotate->set_visible( prefs->getBool(path +
"rotation",
true));
Cartesian point / 2D vector and related operations.
Various trigoniometric helper functions.
Two-dimensional point that doubles as a vector.
constexpr Coord y() const noexcept
constexpr Coord x() const noexcept
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 setDesktop(SPDesktop *desktop)
To do: update description of desktop.
double current_zoom() const
SPDesktopWidget * getDesktopWidget() const
Geom::Rotate const & current_rotation() const
Editable view implementation.
constexpr double SP_DESKTOP_ZOOM_MIN
constexpr double SP_DESKTOP_ZOOM_MAX
auto floor(Geom::Rect const &rect)
void popup_at_center(Gtk::Popover &popover, Gtk::Widget &widget)
As popup_at() but point to center of widget.
void on_popup_menu(Gtk::Widget &widget, PopupMenuSlot slot)
Connect slot to a widgetʼs key and button events that traditionally trigger a popup menu,...
Glib::RefPtr< Gtk::Builder > create_builder(const char *filename)
std::optional< PopupMenuClick > PopupMenuOptionalClick
Optional: not present if popup wasnʼt triggered by click.
static void append(std::vector< T > &target, std::vector< T > &&source)
MessageType
A hint about the meaning of a message; is it an ordinary message, a message advising the user of some...
Piecewise< SBasis > log(Interval in)
Glib::RefPtr< Gtk::Builder > builder