Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
desktop.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
5/*
6 * Authors:
7 * Lauris Kaplinski <lauris@kaplinski.com>
8 * Frank Felfe <innerspace@iname.com>
9 * MenTaLguY <mental@rydia.net>
10 * bulia byak <buliabyak@users.sf.net>
11 * Ralf Stephan <ralf@ark.in-berlin.de>
12 * John Bintz <jcoswell@coswellproductions.org>
13 * Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
14 * Jon A. Cruz <jon@joncruz.org>
15 * Abhishek Sharma
16 *
17 * Copyright (C) 2007 Jon A. Cruz
18 * Copyright (C) 2006-2008 Johan Engelen
19 * Copyright (C) 2006 John Bintz
20 * Copyright (C) 2004 MenTaLguY
21 * Copyright (C) 1999-2002 Lauris Kaplinski
22 * Copyright (C) 2000-2001 Ximian, Inc.
23 *
24 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
25 */
26
27#include <glibmm/i18n.h>
28#include <gtkmm/gesturezoom.h>
29#include <sigc++/adaptors/bind.h>
30#include <2geom/transforms.h>
31#include <2geom/rect.h>
32
33#include "desktop.h"
34#include "desktop-events.h"
35#include "desktop-style.h"
36#include "document-undo.h"
37#include "inkscape-window.h"
38#include "layer-manager.h"
39#include "message-context.h"
40#include "message-stack.h"
43#include "actions/actions-view-mode.h" // To update View menu
44#include "actions/actions-tools.h" // To change tools
45#include "display/drawing.h"
52#include "io/fix-broken-links.h"
53#include "object/sp-namedview.h"
54#include "object/sp-root.h"
56#include "ui/interface.h" // Only for getLayoutPrefPath
57#include "ui/tool-factory.h"
58#include "ui/tools/tool-base.h"
59#include "ui/tools/box3d-tool.h"
61#include "ui/widget/canvas.h"
64// TODO those includes are only for node tool quick zoom. Remove them after fixing it.
65#include "ui/tools/node-tool.h"
67#include "util/enums.h"
68
69namespace Inkscape::XML { class Node; }
70
71template <typename T>
72static void delete_then_null(std::unique_ptr<T> &uptr)
73{
74 // reset() would null the ptr before calling delete. But a Tool dtor may call getTool(), so
75 // do it this way so that until dtor is done, our getTool() will still return the valid ptr
76 delete uptr.get();
77 uptr.release();
78}
79
81 : namedview(namedview_)
82{
83 // Moving this into the list initializer breaks the application because this->_document_replaced_signal
84 // is accessed before it is initialized
85 _layer_manager = std::make_unique<Inkscape::LayerManager>(this);
86 _selection = std::make_unique<Inkscape::Selection>(this);
87
88 _message_stack = std::make_unique<Inkscape::MessageStack>();
89 _tips_message_context = std::make_unique<Inkscape::MessageContext>(*_message_stack);
90 _guides_message_context = std::make_unique<Inkscape::MessageContext>(*_message_stack);
91
92 _message_changed_connection = _message_stack->connectChanged([this] (auto type, auto message) {
93 _message_idle_connection = Glib::signal_idle().connect([=, this] {
94 onStatusMessage(type, message);
95 return false;
96 }, Glib::PRIORITY_HIGH);
97 });
98
99 auto const prefs = Inkscape::Preferences::get();
100
101 current = prefs->getStyle("/desktop/style");
102
103 auto const document = namedview->document;
105
106 canvas = std::make_unique<Inkscape::UI::Widget::Canvas>();
107 canvas->set_desktop(this);
108
110
111 _temporary_item_list = std::make_unique<Inkscape::Display::TemporaryItemList>();
112 _translucency_group = std::make_unique<Inkscape::Display::TranslucencyGroup>(dkey);
113 _snapindicator = std::make_unique<Inkscape::Display::SnapIndicator>(this);
114
115 // display rect and zoom are now handled in sp_desktop_widget_realize()
116
117 // pinch zoom
118 auto const zoom = Gtk::GestureZoom::create();
119 zoom->set_propagation_phase(Gtk::PropagationPhase::CAPTURE);
120 zoom->signal_begin().connect(sigc::mem_fun(*this, &SPDesktop::on_zoom_begin));
121 zoom->signal_scale_changed().connect(sigc::mem_fun(*this, &SPDesktop::on_zoom_scale));
122 zoom->signal_end().connect(sigc::mem_fun(*this, &SPDesktop::on_zoom_end));
123 canvas->add_controller(zoom);
124
125 /* Connect document */
127
128 // Set the select tool as the active tool.
129 setTool("/tools/select");
130
132
135}
136
138{
139 /* CanvasItems: Controls/Grids/etc. Canvas items are owned by the canvas through
140 * canvas_item_root. Canvas items are automatically added and removed from the tree when
141 * created and deleted (as long as a canvas item group is passed in the constructor).
142 */
143
144 auto const canvas_item_root = canvas->get_canvas_item_root();
145
146 // The order in which these canvas items are added determines the z-order. It's therefore
147 // important to add the tempgroup (which will contain the snapindicator) before adding the
148 // controls. Only this way one will be able to quickly (before the snap indicator has
149 // disappeared) reselect a node after snapping it. If the z-order is wrong however, this
150 // will not work (the snap indicator is on top of the node handler; is the snapindicator
151 // being selected? or does it intercept some of the events that should have gone to the
152 // node handler? see bug https://bugs.launchpad.net/inkscape/+bug/414142)
153
154 _canvas_catchall = new Inkscape::CanvasItemCatchall{canvas_item_root}; // Lowest item!
155 _canvas_group_pages_bg = new Inkscape::CanvasItemGroup {canvas_item_root};
156 _canvas_group_drawing = new Inkscape::CanvasItemGroup {canvas_item_root};
157 _canvas_group_pages_fg = new Inkscape::CanvasItemGroup {canvas_item_root};
158 _canvas_group_grids = new Inkscape::CanvasItemGroup {canvas_item_root};
159 _canvas_group_guides = new Inkscape::CanvasItemGroup {canvas_item_root};
160 _canvas_group_sketch = new Inkscape::CanvasItemGroup {canvas_item_root};
161 _canvas_group_temp = new Inkscape::CanvasItemGroup {canvas_item_root};
162 _canvas_group_controls = new Inkscape::CanvasItemGroup {canvas_item_root};
164
165 _canvas_group_pages_bg->set_name("CanvasItemGroup:PagesBg" ); // Page backgrounds
166 _canvas_group_drawing ->set_name("CanvasItemGroup:Drawing" ); // The actual SVG drawing.
167 _canvas_group_pages_fg->set_name("CanvasItemGroup:PagesFg" ); // Page borders, when on top.
168 _canvas_group_grids ->set_name("CanvasItemGroup:Grids" ); // Grids.
169 _canvas_group_guides ->set_name("CanvasItemGroup:Guides" ); // Guides.
170 _canvas_group_sketch ->set_name("CanvasItemGroup:Sketch" ); // Temporary items before becoming permanent.
171 _canvas_group_temp ->set_name("CanvasItemGroup:Temp" ); // Temporary items that disappear by themselves.
172 _canvas_group_controls->set_name("CanvasItemGroup:Controls"); // Controls (handles, knots, rectangles, etc.).
173
174 _canvas_group_sketch->set_pickable(false); // Temporary items are not pickable!
175 _canvas_group_temp ->set_pickable(false); // Temporary items are not pickable!
176
177 // The root should never emit events. The "catchall" should get it!
178 // But somehow there are still exceptions, e.g. Ctrl+scroll to zoom.
179 canvas_item_root->connect_event(sigc::bind(&sp_desktop_root_handler, this));
181
183
184 canvas->set_drawing(_canvas_drawing->get_drawing());
185}
186
188{
189 _destroy_signal.emit(this);
190
192
193 // Canvas
194 canvas->set_drawing(nullptr); // Ensures deactivation
195 canvas->set_desktop(nullptr); // Todo: Remove desktop dependency.
196
197 if (document) {
199 }
200
201 _snapindicator.reset();
202 _temporary_item_list.reset();
203 _selection.reset();
204
205 _guides_message_context = nullptr;
206}
207
212
213//--------------------------------------------------------------------
214/* Public methods */
215
216/* These methods help for temporarily showing things on-canvas.
217 * The *only* valid use of the TemporaryItem* that you get from add_temporary_canvasitem
218 * is when you want to prematurely remove the item from the canvas, by calling
219 * desktop->remove_temporary_canvasitem(tempitem).
220 */
230{
231 if (move_to_bottom) {
232 item->lower_to_bottom();
233 }
234
235 return _temporary_item_list->add_item(item, lifetime_msecs);
236}
237
240// Note: This function may free the wrong temporary item if it is called on a freed pointer that
241// has had another TemporaryItem reallocated in its place.
243{
244 // check for non-null temporary_item_list, because during destruction of desktop, some destructor might try to access this list!
245 if (tempitem && _temporary_item_list) {
246 _temporary_item_list->delete_item(tempitem);
247 }
248}
249
254{
255 auto const bbox = item->desktopVisualBounds();
256 if (!bbox) {
257 return false;
258 }
259 auto const viewport = get_display_area();
260 return viewport.intersects(*bbox);
261}
262
265 return item->isHidden(dkey);
266}
267
271void
277
282{
283 g_return_if_fail(theDocument);
284
285 /* unselect everything before switching documents */
286 _selection->clear();
287
288 // Reset any tool actions currently in progress.
289 setTool(std::string{_tool->getPrefsPath()}); // Copy so not passing ref to member of reset tool
290
291 setDocument(theDocument);
292
293 /* update the rulers, connect the desktop widget's signal to the new namedview etc.
294 (this can probably be done in a better way) */
295 getInkscapeWindow()->change_document(theDocument);
297
299}
300
308void SPDesktop::setTool(std::string const &toolName)
309{
310 // Tool should be able to be replaced with itself. See commit 29df5ca05d
311 if (_tool) {
312 _tool->switching_away(toolName);
314 }
315
316 if (!toolName.empty()) {
317 _tool.reset(ToolFactory::createObject(this, toolName));
318 // Switch back, though we don't know what the tool was
319 if (!_tool->is_ready()) {
320 set_active_tool(this, "Select");
321 return;
322 }
323 }
324
325 _event_context_changed_signal.emit(this, _tool.get());
326}
327
334
339
343SPItem *SPDesktop::getItemFromListAtPointBottom(const std::vector<SPItem*> &list, Geom::Point const &p) const
344{
345 g_return_val_if_fail (doc() != nullptr, NULL);
346 return SPDocument::getItemFromListAtPointBottom(dkey, doc()->getRoot(), list, p);
347}
348
352SPItem *SPDesktop::getItemAtPoint(Geom::Point const &p, bool into_groups, SPItem *upto) const
353{
354 g_return_val_if_fail (doc() != nullptr, NULL);
355 return doc()->getItemAtPoint( dkey, p, into_groups, upto);
356}
357
358std::vector<SPItem*> SPDesktop::getItemsAtPoints(std::vector<Geom::Point> points, bool all_layers, bool topmost_only, size_t limit, bool active_only) const
359{
360 if (!doc())
361 return {};
362 return doc()->getItemsAtPoints(dkey, points, all_layers, topmost_only, limit, active_only);
363}
364
369{
370 g_return_val_if_fail (doc() != nullptr, NULL);
371 return doc()->getGroupAtPoint(dkey, p);
372}
373
379{
380 auto ret = canvas->get_last_mouse();
381 auto pt = ret ? *ret : Geom::Point(canvas->get_dimensions()) / 2.0;
382 return w2d(canvas->canvas_to_world(pt));
383}
384
389void
391{
392 if (transforms_past.empty()) {
393 std::cerr << "SPDesktop::prev_transform: current transform missing!" << std::endl;
394 return;
395 }
396
397 if (transforms_past.size() == 1) {
398 messageStack()->flash(Inkscape::WARNING_MESSAGE, _("No previous transform."));
399 return;
400 }
401
402 // Push current transform into future transforms list.
404
405 // Remove the current transform from the past transforms list.
406 transforms_past.pop_front();
407
408 // restore previous transform
410 set_display_area (false);
411}
412
417{
418 if (transforms_future.empty()) {
419 this->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("No next transform."));
420 return;
421 }
422
423 // restore next transform
425 set_display_area (false);
426
427 // remove the just-used transform from the future transforms list
428 transforms_future.pop_front();
429
430 // push current transform into past transforms list
431 transforms_past.push_front( _current_affine );
432}
433
442
449{
450 // Save the transform
451 if (log) {
453 // if we do a logged transform, our transform-forward list is invalidated, so delete it
454 transforms_future.clear();
455 }
456
457 // Scroll
458 canvas->set_pos(_current_affine.getOffset());
459 canvas->set_affine(_current_affine.d2w()); // For CanvasItems.
460
461 // Update perspective lines if we are in the 3D box tool (so that infinite ones are shown correctly).
462 if (auto const boxtool = dynamic_cast<Inkscape::UI::Tools::Box3dTool*>(_tool.get())) {
463 boxtool->_vpdrag->updateLines();
464 }
465
466 // Update GUI (TODO: should be handled by CanvasGrid).
471
472 signal_zoom_changed.emit(_current_affine.getZoom()); // Observed by path-manipulator to update arrows.
473}
474
480{
481 // The relative offset needed to keep c at w.
482 Geom::Point offset = d2w(c) - w;
485}
486
494{
495 // Create a rectangle the size of the window aligned with origin.
496 Geom::Rect w( Geom::Point(), canvas->get_dimensions() );
497
498 // Shrink window to account for border padding.
499 w.expandBy(-border);
500
501 double zoom = 1.0;
502 // Determine which direction limits scale:
503 // if (r.width/w.width > r.height/w.height) then zoom using width.
504 // Avoiding division in test:
505 if ( r.width()*w.height() > r.height()*w.width() ) {
506 zoom = w.width() / r.width();
507 } else {
508 zoom = w.height() / r.height();
509 }
510 zoom = std::clamp(zoom, SP_DESKTOP_ZOOM_MIN, SP_DESKTOP_ZOOM_MAX);
511 _current_affine.setScale( Geom::Scale(zoom, yaxisdir() * zoom) );
512 // Zero offset, actual offset calculated later.
514
515 set_display_area( r.midpoint(), w.midpoint(), log );
516}
517
522{
523 // viewbox in world coordinates
524 Geom::Rect const viewbox = canvas->get_area_world();
525
526 // display area in desktop coordinates
527 return Geom::Parallelogram(viewbox) * w2d();
528}
529
537void
538SPDesktop::zoom_absolute(Geom::Point const &center, double zoom, bool keep_point)
539{
540 Geom::Point w = d2w(center); // Must be before zoom changed.
541 if(!keep_point) {
542 w = Geom::Rect(canvas->get_area_world()).midpoint();
543 }
544 zoom = CLAMP (zoom, SP_DESKTOP_ZOOM_MIN, SP_DESKTOP_ZOOM_MAX);
545 _current_affine.setScale( Geom::Scale(zoom, yaxisdir() * zoom) );
546 set_display_area( center, w );
547}
548
556void
557SPDesktop::zoom_relative(Geom::Point const &center, double zoom, bool keep_point)
558{
559 double new_zoom = _current_affine.getZoom() * zoom;
560 this->zoom_absolute(center, new_zoom, keep_point);
561}
562
569void
570SPDesktop::zoom_realworld(Geom::Point const &center, double ratio)
571{
573 double correction = prefs->getDouble("/options/zoomcorrection/value", 1.0);
574 this->zoom_absolute(center, ratio * correction, false);
575}
576
581{
582 if (rect.width() < 1.0)
583 return;
584 auto const center_y = current_center().y();
586 Geom::Point(rect.left(), center_y),
587 Geom::Point(rect.width(), center_y)), border);
588}
589
594{
595 zoom_absolute(rect.midpoint(), this->current_zoom(), false);
596}
597
601void
603{
604 g_return_if_fail (doc() != nullptr);
605 SPItem *docitem = doc()->getRoot();
606 g_return_if_fail (docitem != nullptr);
607
608 docitem->bbox_valid = FALSE;
609 Geom::OptRect d = docitem->desktopVisualBounds();
610
611 /* Note that the second condition here indicates that
612 ** there are no items in the drawing.
613 */
614 if ( !d || d->minExtent() < 0.1 ) {
615 return;
616 }
617
618 set_display_area(*d, 10);
619}
620
624void
626{
627 Geom::OptRect const d = _selection->visualBounds();
628
629 if ( !d || d->minExtent() < 0.1 ) {
630 return;
631 }
632
633 set_display_area(*d, 10);
634}
635
659
661 return Geom::Rect(canvas->get_area_world()).midpoint() * _current_affine.w2d();
662}
663
669void SPDesktop::zoom_quick(bool enable)
670{
671 if (enable == _quick_zoom_enabled) {
672 return;
673 }
674
675 if (enable) {
677 bool zoomed = false;
678
679 // TODO This needs to migrate into the node tool, but currently the design
680 // of this method is sufficiently wrong to prevent this.
681 if (!zoomed) {
682 if (auto const nt = dynamic_cast<Inkscape::UI::Tools::NodeTool*>(_tool.get())) {
683 if (!nt->_selected_nodes->empty()) {
684 Geom::Rect nodes = *nt->_selected_nodes->bounds();
685 double area = nodes.area();
686 // do not zoom if a single cusp node is selected aand the bounds
687 // have zero area.
688 if (!Geom::are_near(area, 0)) {
689 set_display_area(nodes, true);
690 zoomed = true;
691 }
692 }
693 }
694 }
695
696 if (!zoomed) {
697 Geom::OptRect const d = _selection->visualBounds();
698 if (d) {
699 set_display_area(*d, true);
700 zoomed = true;
701 }
702 }
703
704 if (!zoomed) {
705 Geom::Rect const d_canvas = canvas->get_area_world();
706 Geom::Point midpoint = w2d(d_canvas.midpoint()); // Midpoint of drawing on canvas.
707 zoom_relative(midpoint, 2.0, false);
708 }
709 } else {
711 set_display_area( false );
712 }
713
714 _quick_zoom_enabled = enable;
715 return;
716}
717
721void
726
730void
735
743{
744 auto const w = d2w(c); // Must be before rotate changed.
747}
748
756{
757 auto const w = d2w(c); // Must be before rotate changed.
760}
761
769{
771 auto const viewbox = canvas->get_area_world();
772 set_display_area(c, viewbox.midpoint());
773}
774
782{
784 auto const viewbox = canvas->get_area_world();
785 set_display_area(c, viewbox.midpoint());
786}
787
794void
796{
797 Geom::Point w = d2w(c); // Must be before flip.
800}
801
808void
810{
811 Geom::Point w = d2w(c); // Must be before flip.
814}
815
822void
824{
826 Geom::Rect viewbox = canvas->get_area_world();
827 set_display_area(c, viewbox.midpoint());
828}
829
836void
838{
840 Geom::Rect viewbox = canvas->get_area_world();
841 set_display_area(c, viewbox.midpoint());
842}
843
844bool
849
853void
855{
856 canvas->set_pos(point);
858
859 /* update perspective lines if we are in the 3D box tool (so that infinite ones are shown correctly) */
860 if (auto const boxtool = dynamic_cast<Inkscape::UI::Tools::Box3dTool*>(_tool.get())) {
861 boxtool->_vpdrag->updateLines();
862 }
863
866}
867
871void
873{
874 Geom::Rect const viewbox = canvas->get_area_world();
875 scroll_absolute( viewbox.min() - delta );
876}
877
881void
887
893// Todo: Eliminate second argument and return value.
895{
896 auto prefs = Inkscape::Preferences::get();
897
898 // autoscrolldistance is in screen pixels.
899 double const autoscrolldistance = prefs->getIntLimited("/options/autoscrolldistance/value", 0, -1000, 10000);
900
901 auto w = Geom::Rect(canvas->get_area_world()); // Window in screen coordinates.
902 w.expandBy(-autoscrolldistance); // Shrink window
903
904 auto const c = d2w(p); // Point 'p' in screen coordinates.
905 if (!w.contains(c)) {
906 auto const c2 = w.clamp(c); // Constrain c to window.
907 scroll_relative(c2 - c);
908 return true;
909 }
910
911 return false;
912}
913
915{
916 return getInkscapeWindow()->isMinimised();
917}
918
920{
921 return getInkscapeWindow()->has_css_class("dark");
922}
923
925{
926 return getInkscapeWindow()->isMaximised();
927}
928
930{
932}
933
940{
941 return _focusMode;
942}
943
950{
951 if (mode == _focusMode) {
952 return;
953 }
954
956
957 layoutWidget();
958}
959
964
969
970void SPDesktop::setWindowTransient(Gtk::Window &window, int transient_policy)
971{
972 _widget->setWindowTransient(window, transient_policy);
973}
974
976{
977 return _widget->get_window();
978}
979
984
985void
990
991void SPDesktop::showInfoDialog(Glib::ustring const &message)
992{
993 _widget->showInfoDialog(message);
994}
995
996bool
997SPDesktop::warnDialog (Glib::ustring const &text)
998{
999 return _widget->warnDialog (text);
1000}
1001
1003{
1004 canvas->set_render_mode(mode);
1005 if (_widget) {
1007 }
1008}
1009
1011{
1012 canvas->set_color_mode(mode);
1013 if (_widget) {
1015 }
1016}
1017
1018void
1022void
1027
1028void
1033
1040{
1041 if (_overlays_visible != hide) {
1042 return; // Nothing to do
1043 }
1044
1045 if (hide) {
1051 }
1052 if (canvas && !canvas->has_focus()) {
1053 canvas->grab_focus(); // Ensure we receive the key up event
1054 }
1055 _overlays_visible = false;
1056 } else {
1060 }
1062 _overlays_visible = true;
1063 }
1064}
1065
1066// (De)Activate preview mode: hide overlays (grid, guides, etc) and crop content to page areas
1069 if (canvas) {
1070 canvas->set_clip_to_page_mode(activate ? true : static_cast<bool>(namedview->clip_to_page));
1071 }
1072}
1073
1074void SPDesktop::toggleToolbar(char const * const toolbar_name)
1075{
1076 Glib::ustring pref_path = getLayoutPrefPath(this) + toolbar_name + "/state";
1077
1079 gboolean visible = prefs->getBool(pref_path, true);
1080 prefs->setBool(pref_path, !visible);
1081
1082 layoutWidget();
1083}
1084
1085void
1090
1096void
1097SPDesktop::onWindowStateChanged(Gdk::Toplevel::State const changed,
1098 Gdk::Toplevel::State const new_state)
1099{
1100 // Layout may differ depending on full-screen mode or not
1101 if (Inkscape::Util::has_flag(changed, Gdk::Toplevel::State::FULLSCREEN | Gdk::Toplevel::State::MAXIMIZED)) {
1102 layoutWidget();
1103 view_set_gui(getInkscapeWindow()); // Updates View menu
1104 }
1105}
1106
1110void SPDesktop::applyCurrentOrToolStyle(SPObject *obj, Glib::ustring const &tool_path, bool with_text)
1111{
1112 SPCSSAttr *css_current = sp_desktop_get_style(this, with_text);
1114
1115 if (prefs->getBool(tool_path + "/usecurrent") && css_current) {
1116 obj->setCSS(css_current,"style");
1117 } else {
1118 SPCSSAttr *css = prefs->getInheritedStyle(tool_path + "/style");
1119 obj->setCSS(css,"style");
1121 }
1122 if (css_current) {
1123 sp_repr_css_attr_unref(css_current);
1124 }
1125}
1126
1127void
1129{
1131}
1132
1133void
1134SPDesktop::setToolboxAdjustmentValue(char const * const id, double const val)
1135{
1137}
1138
1139Gtk::Widget *SPDesktop::get_toolbar_by_name(const Glib::ustring &name)
1140{
1142}
1143
1144bool
1145SPDesktop::isToolboxButtonActive(char const * const id) const
1146{
1147 return _widget->isToolboxButtonActive(id);
1148}
1149
1154
1156{
1157 canvas->set_cursor("wait");
1158
1159 // GDK needs the flush for the cursor change to take effect
1160 // TODO: GTK4: Is that still the case?
1161 // display->flush();
1162
1163 waiting_cursor = true;
1164}
1165
1167 if (waiting_cursor && _tool) {
1168 _tool->use_tool_cursor();
1169 }
1170}
1171
1176
1177//----------------------------------------------------------------------
1178// Callback implementations. The virtual ones are connected by the view.
1179
1184{
1185 if (document) {
1187 }
1188
1189 _selection->setDocument(doc);
1190 document = doc;
1191
1192 if (document) {
1194 }
1195}
1196
1198{
1199 /* XXX:
1200 * ensureUpToDate() sends a 'modified' signal to the root element.
1201 * This is required to prevent flickering after the document
1202 * loads. However, many SPObjects write to their repr in response
1203 * to this signal. This is apparently done to support live path effects,
1204 * which rewrite their result paths after each modification of the base object.
1205 * This causes the generation of an incomplete undo transaction,
1206 * which causes problems down the line, including crashes in the
1207 * Undo History dialog.
1208 *
1209 * For now, this is handled by disabling undo tracking during this call.
1210 * A proper fix would involve modifying the way ensureUpToDate() works,
1211 * so that the LPE results are not rewritten.
1212 */
1213 {
1216 }
1217
1218 /* Set up notification of rebuilding the document, this allows
1219 for saving object related settings in the document. */
1223
1224 _y_axis_flipped = document->get_y_axis_flipped().connect([this](double yshift){ handle_y_axis_flip(yshift); });
1225
1226 auto const drawing = _canvas_drawing->get_drawing();
1227
1228 if (auto const drawing_item = document->getRoot()->invoke_show(*drawing, dkey, SP_ITEM_SHOW_DISPLAY)) {
1229 drawing->root()->prependChild(drawing_item);
1230 }
1231
1234 namedview->show(this);
1236 namedview->set_desk_color(this); // Background page sits on.
1237
1239
1240 /* Ugly hack */
1241 activate_guides(true);
1242
1245 });
1248 });
1249
1250 // set new document before firing signal, so handlers can see new value if they query desktop
1252
1254}
1255
1257{
1258 namedview->hide(this);
1260
1261 _document_uri_set_connection.disconnect();
1262 _saved_or_modified_conn.disconnect();
1266}
1267
1268void SPDesktop::showNotice(Glib::ustring const &msg, int timeout)
1269{
1271}
1272
1274{
1275 if (_widget && _widget->get_desktop() == this) {
1276 _widget->setMessage(type, message);
1277 }
1278}
1279
1284{
1285 auto const tool = getTool();
1286 if (!tool) return false;
1287
1288 if (event.type() == Inkscape::EventType::KEY_PRESS &&
1289 Inkscape::UI::Tools::get_latin_keyval(static_cast<Inkscape::KeyPressEvent const &>(event)) == GDK_KEY_space &&
1290 tool->is_space_panning())
1291 {
1292 return true;
1293 }
1294
1295 if (drawing_item) {
1296 return tool->start_item_handler(drawing_item->getItem(), event);
1297 }
1298
1299 return tool->start_root_handler(event);
1300}
1301
1304{
1305 auto layer = layerManager().currentLayer();
1306 _reconstruction_old_layer_id = layer->getId() ? layer->getId() : "";
1307 layerManager().reset();
1308
1309 getSelection()->clear();
1310}
1311
1314{
1315 g_debug("Desktop, finishing reconstruction\n");
1316 if (!_reconstruction_old_layer_id.empty()) {
1317 if (auto const newLayer = getNamedView()->document->getObjectById(_reconstruction_old_layer_id)) {
1318 layerManager().setCurrentLayer(newLayer);
1319 }
1320
1322 }
1323 g_debug("Desktop, finishing reconstruction end\n");
1324}
1325
1327 // selection is repainted in a wrong location, so clearing it for now
1328 _selection->clear();
1329
1331 auto zoom = _current_affine.getZoom();
1333 _current_affine.setOffset(Geom::Point(offset.x(), offset.y() + zoom * yshift));
1334 set_display_area(false);
1335}
1336
1338{
1339 assert(document);
1340 return document->doc2dt();
1341}
1342
1344{
1345 assert(document);
1346 return document->dt2doc();
1347}
1348
1349sigc::connection SPDesktop::connect_gradient_stop_selected(sigc::slot<void (SPStop *)> const &slot) {
1350 return _gradient_stop_selected.connect(slot);
1351}
1352
1353sigc::connection SPDesktop::connect_control_point_selected(sigc::slot<void (Inkscape::UI::ControlPointSelection *)> const &slot) {
1354 return _control_point_selected.connect(slot);
1355}
1356
1357sigc::connection SPDesktop::connect_text_cursor_moved(sigc::slot<void (Inkscape::UI::Tools::TextTool*)> const &slot) {
1358 return _text_cursor_moved.connect(slot);
1359}
1360
1364
1368
1372
1373/*
1374 * pinch zoom
1375 */
1376
1377void SPDesktop::on_zoom_begin(Gdk::EventSequence * /*sequence*/)
1378{
1380}
1381
1382void SPDesktop::on_zoom_scale(double const scale)
1383{
1384 if (!_begin_zoom) {
1385 std::cerr << "on_zoom_scale: Missed on_zoom_begin event" << std::endl;
1386 return;
1387 }
1388 auto const widget_point = canvas->get_last_mouse().value_or(canvas->get_dimensions() / 2);
1389 auto const world_point = canvas->canvas_to_world(widget_point);
1390 zoom_absolute(w2d(world_point), *_begin_zoom * scale);
1391}
1392
1393void SPDesktop::on_zoom_end(Gdk::EventSequence * /*sequence*/)
1394{
1395 _begin_zoom.reset();
1396}
1397
1398/*
1399 Local Variables:
1400 mode:c++
1401 c-file-style:"stroustrup"
1402 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
1403 indent-tabs-mode:nil
1404 fill-column:99
1405 End:
1406*/
1407// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
double scale
Definition aa.cpp:228
void apply_preferences_canvas_mode(SPDesktop *dt)
void apply_preferences_canvas_transform(SPDesktop *dt)
void set_active_tool(InkscapeWindow *win, Glib::ustring const &tool)
void view_set_gui(InkscapeWindow *win)
Authors: Sushant A A sushant.co19@gmail.com
Rewrite of code originally in desktop-widget.cpp.
Geom::IntRect visible
Definition canvas.cpp:154
Inkscape canvas widget.
3x3 matrix representing an affine transformation.
Definition affine.h:70
C area() const
Compute the rectangle's area.
CPoint midpoint() const
Get the point in the geometric center of the rectangle.
C left() const
Return leftmost coordinate of the rectangle (+X is to the right).
C height() const
Get the vertical extent of the rectangle.
C width() const
Get the horizontal extent of the rectangle.
CPoint min() const
Get the corner of the rectangle with smallest coordinate values.
Two-dimensional point with integer coordinates.
Definition int-point.h:57
Axis-aligned rectangle that can be empty.
Definition rect.h:203
Paralellogram, representing a linear transformation of a rectangle.
Two-dimensional point that doubles as a vector.
Definition point.h:66
constexpr Coord y() const noexcept
Definition point.h:106
Axis aligned, non-empty rectangle.
Definition rect.h:92
Scaling from the origin.
Definition transforms.h:150
bool isMinimised() const
bool isMaximised() const
bool isFullscreen() const
void change_document(SPDocument *document)
Inkscape::Drawing * get_drawing()
sigc::connection connect_drawing_event(sigc::slot< bool(CanvasEvent const &, Inkscape::DrawingItem *)> slot)
virtual void set_visible(bool visible)
void set_name(std::string &&name)
Definition canvas-item.h:97
sigc::connection connect_event(sigc::slot< bool(CanvasEvent const &)> const &slot)
void set_pickable(bool pickable)
Provides a class to put a canvasitem temporarily on-canvas.
RAII-style mechanism for creating a temporary undo-insensitive context.
SVG drawing item for display.
SPItem * getItem() const
void prependChild(DrawingItem *item)
DrawingItem * root()
Definition drawing.h:46
void setCurrentLayer(SPObject *object, bool clear=false)
Sets the current layer of the desktop.
SPGroup * currentLayer() const
Returns current top layer.
void reset()
Resets the bottom layer to the current root.
MessageId flash(MessageType type, char const *message)
Temporarily pushes a message onto the stack.
void clear()
Unselects all selected objects.
Preference storage class.
Definition preferences.h:66
bool getBool(Glib::ustring const &pref_path, bool def=false)
Retrieve a Boolean value.
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.
SPCSSAttr * getInheritedStyle(Glib::ustring const &pref_path)
Retrieve an inherited CSS style.
void setBool(Glib::ustring const &pref_path, bool value)
Set a Boolean value.
Group of selected control points.
A widget that manages DialogNotebook's and other widgets inside a horizontal DialogMultipaned contain...
void set_inkscape_window(InkscapeWindow *inkscape_window)
void updateScrollbars(double scale)
A GtkBox on an SPDesktop.
bool warnDialog(Glib::ustring const &text)
Gtk::Widget * get_toolbar_by_name(const Glib::ustring &name)
InkscapeWindow const * get_window() const
void setToolboxAdjustmentValue(char const *id, double value)
bool isToolboxButtonActive(char const *id) const
void setWindowTransient(Gtk::Window &window, int transient_policy)
void desktopChangedDocument(SPDesktop *desktop)
void showNotice(Glib::ustring const &msg, int timeout=0)
void layoutWidgets()
Hide whatever the user does not want to see in the window.
Inkscape::UI::Dialog::DialogContainer * getDialogContainer()
void setCoordinateStatus(Geom::Point p)
Inkscape::UI::Widget::CanvasGrid * get_canvas_grid()
void showInfoDialog(Glib::ustring const &message)
void setWindowSize(Geom::IntPoint const &size)
void setMessage(Inkscape::MessageType type, char const *message)
void setToolboxFocusTo(char const *)
Geom::IntPoint getWindowSize() const
void desktopChangedTitle(SPDesktop *desktop)
SPDesktop * get_desktop()
double getZoom() const
Definition desktop.h:500
void setRotate(Geom::Rotate rotate)
Definition desktop.h:460
Geom::Affine const & w2d() const
Definition desktop.h:448
bool isFlipped(CanvasFlip flip)
Definition desktop.h:480
void addFlip(CanvasFlip flip)
Definition desktop.h:490
void setOffset(Geom::Point offset)
Definition desktop.h:508
void setScale(Geom::Scale scale)
Definition desktop.h:451
void addRotate(Geom::Rotate rotate)
Definition desktop.h:467
Geom::Point const & getOffset()
Definition desktop.h:514
void addOffset(Geom::Point offset)
Definition desktop.h:511
void setFlip(CanvasFlip flip)
Definition desktop.h:475
Geom::Affine const & d2w() const
Definition desktop.h:449
Inkscape::CanvasItemGroup * _canvas_group_grids
Grids.
Definition desktop.h:213
double current_zoom() const
Definition desktop.h:335
void toggleLockGuides()
Definition desktop.cpp:1172
sigc::signal< void(SPDesktop *)> _destroy_signal
Definition desktop.h:542
Geom::Point current_center() const
Definition desktop.cpp:660
void setTool(std::string const &toolName)
Replaces the currently active tool with a new one.
Definition desktop.cpp:308
void _attachDocument()
Definition desktop.cpp:1197
Geom::Parallelogram get_display_area() const
Return canvas viewbox in desktop coordinates.
Definition desktop.cpp:521
std::unique_ptr< Inkscape::Display::TemporaryItemList > _temporary_item_list
Definition desktop.h:177
void toggleToolbar(char const *toolbar_name)
Definition desktop.cpp:1074
void emit_control_point_selected(Inkscape::UI::ControlPointSelection *selection)
Definition desktop.cpp:1365
void focusMode(bool mode=true)
Changes whether the user is in focus mode or not.
Definition desktop.cpp:949
std::vector< SPItem * > getItemsAtPoints(std::vector< Geom::Point > ps, bool all_layers=true, bool topmost_only=true, size_t limit=0, bool active_only=true) const
Definition desktop.cpp:358
void emit_text_cursor_moved(Inkscape::UI::Tools::TextTool *tool)
Definition desktop.cpp:1369
Inkscape::Display::TemporaryItem * add_temporary_canvasitem(Inkscape::CanvasItem *item, int lifetime_msecs, bool move_to_bottom=true)
One should not keep a reference to the SPCanvasItem, the temporary item code will delete the object f...
Definition desktop.cpp:229
void setRenderMode(Inkscape::RenderMode mode)
Definition desktop.cpp:1002
bool _focusMode
Whether we're focused working or general working.
Definition desktop.h:227
bool itemIsHidden(SPItem const *item) const
Definition desktop.cpp:264
void zoom_grab_focus()
Tell widget to let zoom widget grab keyboard focus.
Definition desktop.cpp:722
Inkscape::CanvasItemGroup * _canvas_group_drawing
SVG Drawing.
Definition desktop.h:212
void rotate_relative_center_point(Geom::Point const &c, double rotate)
Rotate aligning the point 'c' to the center of desktop window.
Definition desktop.cpp:781
void setToolboxFocusTo(char const *label)
Definition desktop.cpp:1128
std::list< DesktopAffine > transforms_past
Definition desktop.h:532
unsigned dkey
Definition desktop.h:229
std::optional< double > _begin_zoom
Definition desktop.h:560
InkscapeWindow const * getInkscapeWindow() const
Definition desktop.cpp:975
void flip_relative_center_point(Geom::Point const &c, CanvasFlip flip)
Flip direction, aligning the point 'c' to the center of desktop window.
Definition desktop.cpp:837
void set_display_area(bool log=true)
Does all the dirty work in setting the display area.
Definition desktop.cpp:448
bool is_darktheme() const
Definition desktop.cpp:919
Inkscape::MessageStack * messageStack() const
Definition desktop.h:160
DesktopAffine _quick_zoom_affine
The transform of the screen before quick zoom.
Definition desktop.h:535
Inkscape::CanvasItemCatchall * _canvas_catchall
The bottom item for unclaimed events.
Definition desktop.h:220
SPCSSAttr * current
Current style.
Definition desktop.h:226
bool waiting_cursor
Definition desktop.h:231
void _detachDocument()
Definition desktop.cpp:1256
void handle_y_axis_flip(double yshift)
Definition desktop.cpp:1326
Geom::Affine const & dt2doc() const
Definition desktop.cpp:1343
void updateDialogs()
Definition desktop.cpp:1150
Geom::Affine const & d2w() const
Transformation from desktop to window coordinates.
Definition desktop.h:419
sigc::scoped_connection _message_changed_connection
Definition desktop.h:171
void rotate_relative_keep_point(Geom::Point const &c, double rotate)
Rotate keeping the point 'c' fixed in the desktop window.
Definition desktop.cpp:755
void on_zoom_scale(double scale)
Definition desktop.cpp:1382
Geom::Point point() const
Returns the mouse point in desktop coordinates; if mouse is outside the canvas, returns the center of...
Definition desktop.cpp:378
bool isWithinViewport(SPItem const *item) const
True if desktop viewport intersects item's bbox.
Definition desktop.cpp:253
void zoom_quick(bool enable=true)
Performs a quick zoom into what the user is working on.
Definition desktop.cpp:669
bool drawing_handler(Inkscape::CanvasEvent const &event, Inkscape::DrawingItem *item)
Calls event handler of current event context.
Definition desktop.cpp:1283
Inkscape::CanvasItemGroup * _canvas_group_guides
Guide lines.
Definition desktop.h:214
void scroll_relative_in_svg_coords(double dx, double dy)
Scroll canvas by specific coordinate amount in svg coordinates.
Definition desktop.cpp:882
SPItem * getItemAtPoint(Geom::Point const &p, bool into_groups, SPItem *upto=nullptr) const
Definition desktop.cpp:352
Gtk::Widget * get_toolbar_by_name(Glib::ustring const &name)
Definition desktop.cpp:1139
void scroll_relative(Geom::Point const &delta)
Scroll canvas by specific coordinate amount (window coordinates).
Definition desktop.cpp:872
void rotate_grab_focus()
Tell widget to let rotate widget grab keyboard focus.
Definition desktop.cpp:731
int _view_number
Definition desktop.h:182
SPItem * getItemFromListAtPointBottom(std::vector< SPItem * > const &list, Geom::Point const &p) const
Definition desktop.cpp:343
std::unique_ptr< Inkscape::MessageStack > _message_stack
Definition desktop.h:167
void flip_absolute_keep_point(Geom::Point const &c, CanvasFlip flip)
Set new flip direction, keeping the point 'c' fixed in the desktop window.
Definition desktop.cpp:795
void layoutWidget()
Definition desktop.cpp:1086
std::unique_ptr< Inkscape::Selection > _selection
current selection; will never generally be NULL
Definition desktop.h:208
void rotate_absolute_center_point(Geom::Point const &c, double rotate)
Set new rotation, aligning the point 'c' to the center of desktop window.
Definition desktop.cpp:768
std::unique_ptr< Inkscape::UI::Tools::ToolBase > _tool
Definition desktop.h:176
sigc::scoped_connection _reconstruction_finish_connection
Definition desktop.h:550
void showInfoDialog(Glib::ustring const &message)
Definition desktop.cpp:991
void flip_relative_keep_point(Geom::Point const &c, CanvasFlip flip)
Flip direction, keeping the point 'c' fixed in the desktop window.
Definition desktop.cpp:809
sigc::signal< void(SPDesktop *, Inkscape::UI::Tools::ToolBase *)> _event_context_changed_signal
Definition desktop.h:544
SPNamedView * namedview
Definition desktop.h:181
bool isToolboxButtonActive(char const *id) const
Definition desktop.cpp:1145
bool is_fullscreen() const
Definition desktop.cpp:929
void prev_transform()
Revert back to previous transform if possible.
Definition desktop.cpp:390
std::unique_ptr< Inkscape::Display::SnapIndicator > _snapindicator
Definition desktop.h:179
SPNamedView * getNamedView() const
Definition desktop.h:191
void zoom_realworld(Geom::Point const &c, double ratio)
Zoom in to an absolute realworld ratio, e.g.
Definition desktop.cpp:570
bool _overlays_visible
Whether the overlays are temporarily hidden.
Definition desktop.h:537
void quick_preview(bool activate)
Definition desktop.cpp:1067
sigc::connection connect_gradient_stop_selected(sigc::slot< void(SPStop *)> const &slot)
Definition desktop.cpp:1349
void setWindowSize(Geom::IntPoint const &size)
Definition desktop.cpp:965
void set_display_center(Geom::Rect const &a)
Centre Rect, without zooming.
Definition desktop.cpp:593
std::unique_ptr< Inkscape::MessageContext > _tips_message_context
Definition desktop.h:168
Inkscape::UI::Dialog::DialogContainer * getContainer()
Definition desktop.cpp:335
SPDocument * document
Definition desktop.h:166
void change_document(SPDocument *document)
Make desktop switch documents.
Definition desktop.cpp:281
SPItem * getGroupAtPoint(Geom::Point const &p) const
Definition desktop.cpp:368
Inkscape::Selection * getSelection() const
Definition desktop.h:188
sigc::scoped_connection _reconstruction_start_connection
Definition desktop.h:549
Inkscape::CanvasItemGroup * _canvas_group_pages_bg
Page background.
Definition desktop.h:217
SPDesktopWidget * _widget
Definition desktop.h:436
void remove_temporary_canvasitem(Inkscape::Display::TemporaryItem *tempitem)
It is perfectly safe to call this function while the object has already been deleted due to a timeout...
Definition desktop.cpp:242
void on_zoom_end(Gdk::EventSequence *sequence)
Definition desktop.cpp:1393
DesktopAffine _current_affine
Definition desktop.h:531
sigc::connection connect_text_cursor_moved(sigc::slot< void(Inkscape::UI::Tools::TextTool *)> const &slot)
Definition desktop.cpp:1357
sigc::signal< void(SPDesktop *, SPDocument *)> _document_replaced_signal
Definition desktop.h:543
bool guides_active
Definition desktop.h:235
sigc::signal< void(double)> signal_zoom_changed
Emitted when the zoom factor changes (not emitted when scrolling).
Definition desktop.h:251
Inkscape::UI::Tools::ToolBase * getTool() const
Definition desktop.h:187
double yaxisdir() const
Definition desktop.h:426
std::unique_ptr< Inkscape::LayerManager > _layer_manager
Definition desktop.h:540
void rotate_absolute_keep_point(Geom::Point const &c, double rotate)
Set new rotation, keeping the point 'c' fixed in the desktop window.
Definition desktop.cpp:742
sigc::scoped_connection _schedule_zoom_from_document_connection
Definition desktop.h:551
void toggleRulers()
Definition desktop.cpp:1023
sigc::connection connect_control_point_selected(sigc::slot< void(Inkscape::UI::ControlPointSelection *)> const &slot)
Definition desktop.cpp:1353
void set_coordinate_status(Geom::Point const &p)
Sets the coordinate status to a given point.
Definition desktop.cpp:331
Inkscape::CanvasItemGroup * _canvas_group_pages_fg
Page border + shadow.
Definition desktop.h:218
bool isMinimised() const
Definition desktop.cpp:914
SPDocument * doc() const
Definition desktop.h:159
void clearWaitingCursor()
Definition desktop.cpp:1166
void applyCurrentOrToolStyle(SPObject *obj, Glib::ustring const &tool_path, bool with_text)
Apply the desktop's current style or the tool style to the object.
Definition desktop.cpp:1110
void zoom_selection()
Zoom to selection.
Definition desktop.cpp:625
bool scroll_to_point(Geom::Point const &s_dt, double autoscrollspeed=0)
Scroll screen so as to keep point 'p' visible in window.
Definition desktop.cpp:894
void setWindowTransient(Gtk::Window &window, int transient_policy=1)
Definition desktop.cpp:970
sigc::signal< void(Inkscape::UI::ControlPointSelection *)> _control_point_selected
Definition desktop.h:546
void _setupCanvasItems()
Definition desktop.cpp:137
void emit_gradient_stop_selected(SPStop *stop)
Definition desktop.cpp:1361
Geom::IntPoint getWindowSize() const
Definition desktop.cpp:960
Glib::ustring _reconstruction_old_layer_id
Definition desktop.h:244
SPDesktop(SPNamedView *nv)
Definition desktop.cpp:80
bool _saved_guides_visible
Remembers guides' visibility when hiding overlays.
Definition desktop.h:538
bool is_maximized() const
Definition desktop.cpp:924
sigc::connection _saved_or_modified_conn
Definition desktop.h:174
bool is_flipped(CanvasFlip flip)
Definition desktop.cpp:845
void toggleScrollbars()
Definition desktop.cpp:1029
sigc::signal< void(Inkscape::UI::Tools::TextTool *)> _text_cursor_moved
Definition desktop.h:547
std::unique_ptr< Inkscape::UI::Widget::Canvas > canvas
Definition desktop.h:184
std::unique_ptr< Inkscape::Display::TranslucencyGroup > _translucency_group
Definition desktop.h:178
std::unique_ptr< Inkscape::MessageContext > _guides_message_context
Definition desktop.h:169
Inkscape::CanvasItemDrawing * _canvas_drawing
The actual SVG drawing (a.k.a. arena).
Definition desktop.h:221
Inkscape::CanvasItemGroup * _canvas_group_controls
Handles, knots, nodes, etc.
Definition desktop.h:211
void setDesktopWidget(SPDesktopWidget *dtw)
Definition desktop.cpp:208
sigc::scoped_connection _message_idle_connection
Definition desktop.h:172
void schedule_zoom_from_document()
Schedule the zoom/view settings from the document to be applied to the desktop just after the canvas ...
Definition desktop.cpp:648
bool _quick_zoom_enabled
Signifies that currently we're in quick zoom mode.
Definition desktop.h:534
void clear_transform_history()
Clear transform lists.
Definition desktop.cpp:437
void presentWindow()
Definition desktop.cpp:986
void showNotice(Glib::ustring const &msg, int timeout=0)
Definition desktop.cpp:1268
sigc::scoped_connection _y_axis_flipped
Definition desktop.h:552
void reconstruction_finish()
Called when document rebuild is finished.
Definition desktop.cpp:1313
void reconstruction_start()
Called when document is starting to be rebuilt.
Definition desktop.cpp:1303
void setToolboxAdjustmentValue(char const *id, double val)
Definition desktop.cpp:1134
void flip_absolute_center_point(Geom::Point const &c, CanvasFlip flip)
Set new flip direction, aligning the point 'c' to the center of desktop window.
Definition desktop.cpp:823
sigc::signal< void(SPStop *)> _gradient_stop_selected
Definition desktop.h:545
bool is_focusMode() const
Checks to see if the user is working in focused mode.
Definition desktop.cpp:939
void zoom_relative(Geom::Point const &c, double zoom, bool keep_point=true)
Zoom in or out relatively to the current zoom.
Definition desktop.cpp:557
Inkscape::LayerManager & layerManager()
Definition desktop.h:287
void scroll_absolute(Geom::Point const &point)
Scroll canvas by to a particular point (window coordinates).
Definition desktop.cpp:854
void set_display_width(Geom::Rect const &a, Geom::Coord border)
Set display area in only the width dimension.
Definition desktop.cpp:580
void setDocument(SPDocument *doc)
Associate document with desktop.
Definition desktop.cpp:1183
void zoom_absolute(Geom::Point const &c, double zoom, bool keep_point=true)
Zoom to the given absolute zoom level.
Definition desktop.cpp:538
void setColorMode(Inkscape::ColorMode mode)
Definition desktop.cpp:1010
Inkscape::CanvasItemGroup * _canvas_group_sketch
Temporary items before becoming permanent.
Definition desktop.h:215
Geom::Affine const & doc2dt() const
Definition desktop.cpp:1337
std::list< DesktopAffine > transforms_future
Definition desktop.h:533
void next_transform()
Set transform to next in list.
Definition desktop.cpp:416
void setWaitingCursor()
Definition desktop.cpp:1155
void setTempHideOverlays(bool hide)
Shows or hides the on-canvas overlays and controls, such as grids, guides, manipulation handles,...
Definition desktop.cpp:1039
bool warnDialog(Glib::ustring const &text)
Definition desktop.cpp:997
void toggleCommandPalette()
Definition desktop.cpp:1019
void onStatusMessage(Inkscape::MessageType type, char const *message)
Definition desktop.cpp:1273
Inkscape::CanvasItemGroup * _canvas_group_temp
Temporary items that self-destruct.
Definition desktop.h:216
void zoom_drawing()
Zoom to whole drawing.
Definition desktop.cpp:602
sigc::connection _document_uri_set_connection
Definition desktop.h:173
void onWindowStateChanged(Gdk::Toplevel::State changed, Gdk::Toplevel::State new_toplevel_state)
onWindowStateChanged
Definition desktop.cpp:1097
void on_zoom_begin(Gdk::EventSequence *sequence)
Definition desktop.cpp:1377
Geom::Affine const & w2d() const
Transformation from window to desktop coordinates (zoom/rotate).
Definition desktop.h:416
void activate_guides(bool activate)
Set activate status of current desktop's named view.
Definition desktop.cpp:272
Typed SVG document implementation.
Definition document.h:103
const Geom::Affine & doc2dt() const
Document to desktop coordinate transformation.
Definition document.cpp:935
std::vector< SPItem * > getItemsAtPoints(unsigned const key, std::vector< Geom::Point > points, bool all_layers=true, bool topmost_only=true, size_t limit=0, bool active_only=true) const
SPRoot * getRoot()
Returns our SPRoot.
Definition document.h:202
static SPItem * getItemFromListAtPointBottom(unsigned int dkey, SPGroup *group, const std::vector< SPItem * > &list, Geom::Point const &p, bool take_insensitive=false)
Returns the bottommost item from the list which is at the point, or NULL if none.
const Geom::Affine & dt2doc() const
Desktop to document coordinate transformation.
Definition document.h:270
SPObject * getObjectById(std::string const &id) const
sigc::connection connectSavedOrModified(sigc::slot< void()> &&slot)
sigc::signal< void(double)> get_y_axis_flipped()
Definition document.h:283
sigc::connection connectReconstructionFinish(ReconstructionFinish::slot_type slot)
sigc::connection connectFilenameSet(FilenameSetSignal::slot_type slot)
int ensureUpToDate(unsigned int object_modified_tag=0)
Repeatedly works on getting the document updated, since sometimes it takes more than one pass to get ...
sigc::connection connectReconstructionStart(ReconstructionStart::slot_type slot, bool first=false)
SPNamedView * getNamedView()
Get the namedview for this document, creates it if it's not found.
Definition document.cpp:233
SPItem * getGroupAtPoint(unsigned int key, Geom::Point const &p) const
SPItem * getItemAtPoint(unsigned int key, Geom::Point const &p, bool into_groups, SPItem *upto=nullptr) const
Base class for visual SVG elements.
Definition sp-item.h:109
Inkscape::DrawingItem * invoke_show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags)
Definition sp-item.cpp:1269
bool isHidden() const
Definition sp-item.cpp:235
void invoke_hide(unsigned int key)
Definition sp-item.cpp:1320
unsigned bbox_valid
Definition sp-item.h:129
Geom::OptRect desktopVisualBounds() const
Get item's visual bbox in desktop coordinate system.
Definition sp-item.cpp:1049
static unsigned int display_key_new(unsigned numkeys)
Allocates unique integer keys.
Definition sp-item.cpp:1246
bool getShowGrids()
bool getShowGuides()
void toggleLockGuides()
void show(SPDesktop *desktop)
void temporarily_show_guides(bool show)
void activateGuides(void *desktop, bool active)
void setShowGrids(bool v)
SVGBool clip_to_page
void set_desk_color(SPDesktop *desktop)
void hide(SPDesktop const *desktop)
SPObject is an abstract base class of all of the document nodes at the SVG document level.
Definition sp-object.h:160
SPDocument * document
Definition sp-object.h:188
char const * getId() const
Returns the objects current ID string.
void setCSS(SPCSSAttr *css, char const *attr)
Gradient stop.
Definition sp-stop.h:31
const double w
Definition conic-4.cpp:19
Control point selection - stores a set of control points and applies transformations to them.
std::shared_ptr< Css const > css
sigc::scoped_connection timeout
Glib::ustring msg
double c[8][4]
bool sp_desktop_root_handler(Inkscape::CanvasEvent const &event, SPDesktop *desktop)
SPCSSAttr * sp_desktop_get_style(SPDesktop *desktop, bool with_text)
Return the desktop's current style.
A class to hold:
static void delete_then_null(std::unique_ptr< T > &uptr)
Definition desktop.cpp:72
Editable view implementation.
constexpr double SP_DESKTOP_ZOOM_MIN
Definition desktop.h:143
constexpr double SP_DESKTOP_ZOOM_MAX
Definition desktop.h:142
A widget that manages DialogNotebook's and other widgets inside a horizontal DialogMultipaned.
TODO: insert short description here.
SVG drawing for display.
double Coord
Floating point type used to store coordinates.
Definition coord.h:76
SPItem * item
Inkscape - An SVG editor.
Glib::ustring getLayoutPrefPath(SPDesktop *desktop)
Definition interface.cpp:45
double offset
Glib::ustring label
Interface for locally managing a current status message.
Raw stack of active status messages.
bool are_near(Affine const &a1, Affine const &a2, Coord eps=EPSILON)
unsigned get_latin_keyval(GtkEventControllerKey const *const controller, unsigned const keyval, unsigned const keycode, GdkModifierType const state, unsigned *consumed_modifiers)
Return the keyval corresponding to the event controller key in Latin group.
constexpr bool has_flag(T test, T flag)
Definition enums.h:128
@Inkscape XML tree.
MessageType
A hint about the meaning of a message; is it an ordinary message, a message advising the user of some...
Definition message.h:25
@ WARNING_MESSAGE
Definition message.h:28
New node tool with support for multiple path editing.
int mode
int size
Piecewise< SBasis > log(Interval in)
Definition pw-funcs.cpp:37
Axis-aligned rectangle.
void sp_repr_css_attr_unref(SPCSSAttr *css)
Unreferences an SPCSSAttr (will be garbage collected if no references remain).
Definition repr-css.cpp:76
Provides a class that shows a temporary indicator on the canvas of where the snap was,...
void sp_namedview_zoom_and_view_from_document(SPDesktop *desktop)
void sp_namedview_update_layers_from_document(SPDesktop *desktop)
SPRoot: SVG <svg> implementation.
Abstract base class for events.
virtual EventType type() const =0
Return the dynamic type of the CanvasEvent.
A key has been pressed.
static Inkscape::UI::Tools::ToolBase * createObject(SPDesktop *desktop, std::string const &id)
int delta
double border
Glib::ustring name
Definition toolbars.cpp:55
static void activate(GApplication *app, gpointer)
Affine transformation classes.
Render some items as translucent in a document rendering stack.