25#include <gtkmm/window.h>
114 if (
auto guide = cast<SPGuide>(&
child)) {
123 if (
auto grid = cast<SPGrid>(&
child)) {
124 grids.emplace_back(grid);
179 if (flags & SP_OBJECT_MODIFIED_FLAG) {
183 for (
auto &
page : page_manager.getPages()) {
184 page->setDefaultAttributes();
188 if (
auto saction = std::dynamic_pointer_cast<Gio::SimpleAction>(action)) {
189 Glib::VariantType String(Glib::VARIANT_TYPE_STRING);
205 if (flags || (
child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) {
206 child->emitModified(flags & SP_OBJECT_MODIFIED_CASCADE);
216 if (flags & SP_OBJECT_MODIFIED_FLAG) {
217 flags |= SP_OBJECT_PARENT_MODIFIED_FLAG;
220 flags &= SP_OBJECT_MODIFIED_CASCADE;
223 if (flags || (
child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) {
224 child->updateDisplay(ctx, flags);
239 auto new_unit = unit_table.getUnit(
"px");
243 if ( !unit_table.hasUnit(value) ) {
244 g_warning(
"Unrecognized unit `%s'", value);
252 g_warning(
"Document units must be absolute like `mm', `pt' or `px', but found `%s'", value);
267 auto update_guides = [
this]() {
268 for(
auto guide :
guides) {
321 _desk_color = Inkscape::Colors::Color::parse(value);
327 zoom = value ? g_ascii_strtod(value,
nullptr) : 0;
330 rotation = value ? g_ascii_strtod(value,
nullptr) : 0;
333 cx = value ? g_ascii_strtod(value,
nullptr) : HUGE_VAL;
336 cy = value ? g_ascii_strtod(value,
nullptr) : HUGE_VAL;
417 if (
page->isViewportPage()) {
418 page->setDesktopRect(*box);
434 if (
auto grid = cast<SPGrid>(no)) {
435 grids.emplace_back(grid);
436 for (
auto view :
views) {
439 }
else if (!strcmp(
child->name(),
"inkscape:page")) {
440 if (
auto page = cast<SPPage>(no)) {
442 for (
auto view :
views) {
443 page->showPage(view->getCanvasPagesBg(), view->getCanvasPagesFg());
447 if (
auto g = cast<SPGuide>(no)) {
456 for(
auto view :
views) {
457 g->SPGuide::showSPGuide(view->getCanvasGuides());
459 if (view->guides_active) {
460 g->sensitize(view->getCanvas(), TRUE);
471 if (!strcmp(
child->name(),
"inkscape:page")) {
473 }
else if (!strcmp(
child->name(),
"inkscape:grid")) {
474 for (
auto it =
grids.begin(); it !=
grids.end(); ++it) {
476 if (grid->getRepr() ==
child) {
477 for (
auto view :
views) {
485 for (
auto it =
guides.begin(); it !=
guides.end(); ++it) {
486 if ((*it)->getRepr() ==
child) {
500 if (!strcmp(
child->name(),
"inkscape:page")) {
506 if ( ( flags & SP_OBJECT_WRITE_EXT ) &&
521 for (
auto guide :
guides) {
530 for (
auto grid :
grids) {
562 gint pw = prefs->
getInt(
"/desktop/geometry/width", -1);
563 gint ph = prefs->
getInt(
"/desktop/geometry/height", -1);
564 gint px = prefs->
getInt(
"/desktop/geometry/x", -1);
565 gint py = prefs->
getInt(
"/desktop/geometry/y", -1);
566 gint full = prefs->
getBool(
"/desktop/geometry/fullscreen");
567 gint maxed = prefs->
getBool(
"/desktop/geometry/maximized");
571 pw = std::min(pw, monitor_geometry.get_width());
572 ph = std::min(ph, monitor_geometry.get_height());
586 const int MIN_WINDOW_SIZE = 600;
588 int w = prefs->
getInt(
"/template/base/inkscape:window-width", 0);
589 int h = prefs->
getInt(
"/template/base/inkscape:window-height", 0);
590 bool move_to_screen =
false;
595 move_to_screen =
true;
598 w =
MAX(0.75 * monitor_geometry.get_width(), MIN_WINDOW_SIZE);
599 h =
MAX(0.75 * monitor_geometry.get_height(), MIN_WINDOW_SIZE);
601 w = h = MIN_WINDOW_SIZE;
607 int monitor_width = monitor_geometry.get_width();
608 int monitor_height = monitor_geometry.get_height();
609 int window_width = win->get_width();
610 int window_height = win->get_height();
611 if (window_width > monitor_width || window_height > monitor_height) {
612 w = std::min(monitor_width, window_width);
613 h = std::min(monitor_height, window_height);
616 if (
w > 0 && h > 0) {
631 if (nv->
zoom != 0 && nv->
zoom != HUGE_VAL && !std::isnan(nv->
zoom)
632 && nv->
cx != HUGE_VAL && !std::isnan(nv->
cx)
633 && nv->
cy != HUGE_VAL && !std::isnan(nv->
cy)) {
637 document->getPageManager().zoomToSelectedPage(
desktop);
641 if (nv->
cx != HUGE_VAL && !std::isnan(nv->
cx) && nv->
cy != HUGE_VAL && !std::isnan(nv->
cy)) {
659 if ( !layer || !is<SPGroup>(layer) ) {
683 bool save_viewport_in_file = prefs->
getBool(
"/options/savedocviewport/value",
true);
689 if (save_viewport_in_file) {
698 if (save_geometry_in_file) {
712 for (
auto guide :
guides) {
715 for (
auto grid :
grids) {
735 std::string value =
"";
736 if (!preference.empty()) {
737 value = Preferences::get()->getString(preference);
739 if (value.empty() && !fallback.empty()) {
742 if (!value.empty()) {
754 for(
auto & guide :
guides) {
755 guide->sensitize(dt->
getCanvas(), active);
789 if (v &&
grids.empty())
861 if (
auto saction = std::dynamic_pointer_cast<Gio::SimpleAction>(
868 for (
auto grid :
grids) {
879 if (
auto saction = std::dynamic_pointer_cast<Gio::SimpleAction>(
882 saction->set_state(Glib::Variant<bool>::create(shown));
885 if (
auto saction = std::dynamic_pointer_cast<Gio::SimpleAction>(
888 saction->set_state(Glib::Variant<bool>::create(locked));
891 for (
auto guide :
guides) {
893 guide->set_locked(locked,
true);
919 unit ? unit->
abbr.c_str() :
nullptr);
927 for (
auto grid :
grids) {
928 if (grid->isEnabled())
940 guide.
moveto(point_on_line,
true);
946 for (
auto grid :
grids) {
947 grid->setOrigin( grid->getOrigin() *
scale * tr *
scale.inverse());
952 for(
auto & view :
views) {
953 view->scroll_relative_in_svg_coords(dx, dy);
964 const char* str_value =
nullptr;
966 str_value = value ?
"auto" :
"crispEdges";
968 str_value = value ?
"below" :
"default";
970 str_value = value ?
"true" :
"false";
978 for (
auto guide :
guides) {
979 show ? guide->showSPGuide() : guide->hideSPGuide();
1003 for (
auto guide :
guides) {
1004 guide->fix_orientation();
SnapPreferences & get_snapping_preferences()
gchar const * sp_attribute_name(SPAttr id)
Get attribute name by id.
Lookup dictionary for attributes/properties.
@ INKSCAPE_DOCUMENT_UNITS
@ INKSCAPE_CONNECTOR_SPACING
@ INKSCAPE_ANTIALIAS_RENDERING
@ INKSCAPE_DESK_CHECKERBOARD
@ INKSCAPE_CLIP_TO_PAGE_RENDERING
@ INKSCAPE_WINDOW_MAXIMIZED
@ INKSCAPE_ORIGIN_CORRECTION
Rewrite of code originally in desktop-widget.cpp.
Two-dimensional point that doubles as a vector.
constexpr Coord y() const noexcept
constexpr Coord x() const noexcept
std::string toString(bool opacity=true) const
Format the color as a css string and return it.
bool hasOpacity() const
Returns true if there is an opacity channel in this color.
double getOpacity() const
Get the opacity in this color, if it's stored.
RAII-style mechanism for creating a temporary undo-insensitive context.
void setCurrentLayer(SPObject *object, bool clear=false)
Sets the current layer of the desktop.
SPGroup * currentLayer() const
Returns current top layer.
bool isLayer(SPObject *object) const
True if object is a layer.
bool setDefaultAttributes(CanvasPage *item)
Update the canvas item with the default display attributes.
void reorderPage(Inkscape::XML::Node *child)
Reorder page within the internal list to keep it up to date.
void addPage(SPPage *page)
Add a page to this manager, called from namedview parent.
bool subset(SPAttr key, const gchar *value)
Manage the page subset of attributes from sp-namedview and store them.
const std::vector< SPPage * > & getPages() const
SPPage * getPageAt(Geom::Point pos) const
Get a page at a specific starting location.
void removePage(Inkscape::XML::Node *child)
Remove a page from this manager, called from namedview parent.
Preference storage class.
bool getBool(Glib::ustring const &pref_path, bool def=false)
Retrieve a Boolean value.
static Preferences * get()
Access the singleton Preferences object.
int getInt(Glib::ustring const &pref_path, int def=0)
Retrieve an integer.
void setGridTolerance(double val)
void setObjectTolerance(double val)
void setGuideTolerance(double val)
void setAlignementTolerance(double val)
void setDistributionTolerance(double val)
Interface for refcounted XML nodes.
void setAttributeOrRemoveIfEmpty(Inkscape::Util::const_char_ptr key, Inkscape::Util::const_char_ptr value)
Change an attribute of this node.
void setAttribute(Util::const_char_ptr key, Util::const_char_ptr value)
Change an attribute of this node.
bool setAttributeInt(Util::const_char_ptr key, int val)
virtual Node * duplicate(Document *doc) const =0
Create a duplicate of this node.
bool setAttributeSvgNonDefaultDouble(Util::const_char_ptr key, double val, double default_value)
virtual void mergeFrom(Node const *src, char const *key, bool extension=false, bool clean=false)=0
Merge all children of another node with the current.
bool setAttributeCssDouble(Util::const_char_ptr key, double val)
Set a property attribute to val [slightly rounded], in the format required for CSS properties: in par...
bool setAttributeBoolean(Util::const_char_ptr key, bool val)
bool setAttributeSvgDouble(Util::const_char_ptr key, double val)
For attributes where an exponent is allowed.
bool getAttributeBoolean(Util::const_char_ptr key, bool default_value=false) const
Parses the boolean value of an attribute "key" in repr and sets val accordingly, or to false if the a...
To do: update description of desktop.
Inkscape::UI::Widget::Canvas * getCanvas() const
double current_zoom() const
Inkscape::CanvasItemGroup * getCanvasGuides() const
Geom::Point current_center() const
SPDocument * getDocument() const
InkscapeWindow const * getInkscapeWindow() const
SPNamedView * getNamedView() const
void setWindowSize(Geom::IntPoint const &size)
Geom::Rotate const & current_rotation() const
void rotate_absolute_keep_point(Geom::Point const &c, double rotate)
Set new rotation, keeping the point 'c' fixed in the desktop window.
Geom::IntPoint getWindowSize() const
Inkscape::CanvasItemGroup * getCanvasPagesFg() const
bool is_maximized() const
Inkscape::CanvasItemGroup * getCanvasPagesBg() const
void clear_transform_history()
Clear transform lists.
Inkscape::LayerManager & layerManager()
void zoom_absolute(Geom::Point const &c, double zoom, bool keep_point=true)
Zoom to the given absolute zoom level.
Typed SVG document implementation.
Glib::RefPtr< Gio::SimpleActionGroup > getActionGroup()
SPRoot * getRoot()
Returns our SPRoot.
SPObject * getObjectById(std::string const &id) const
Inkscape::EventLog * get_event_log()
Geom::OptRect preferredBounds() const
Inkscape::PageManager & getPageManager()
bool is_yaxisdown() const
True if the desktop Y-axis points down, false if it points up.
SPObject * getObjectByRepr(Inkscape::XML::Node *repr) const
Geom::Scale getDocumentScale(bool computed=true) const
Returns document scale as defined by width/height (in pixels) and viewBox (real world to user-units).
static void create_new(SPDocument *doc, Inkscape::XML::Node *parent, GridType type)
void showSPGuide(Inkscape::CanvasItemGroup *group)
void moveto(Geom::Point const point_on_line, bool const commit)
Geom::Point getPoint() const
void hideSPGuide(Inkscape::UI::Widget::Canvas *canvas)
char const * getName() const
void modified(unsigned int flags) override
void set_y_axis_down(bool down)
SVGBool desk_checkerboard
void scrollAllDesktops(double dx, double dy)
void setDefaultAttribute(std::string attribute, std::string preference, std::string fallback)
Set an attribute in the named view to the value in this preference, or use the fallback.
std::optional< Colors::Color > _guide_color
Inkscape::XML::Node * write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags) override
void set(SPAttr key, char const *value) override
void setShowGuideSingle(SPGuide *guide)
std::optional< Colors::Color > _desk_color
void show(SPDesktop *desktop)
void temporarily_show_guides(bool show)
std::vector< SPDesktop * > const getViewList() const
std::unique_ptr< Inkscape::CanvasPage > _viewport
std::optional< Colors::Color > _guide_hi_color
void translateGrids(Geom::Translate const &translation)
void order_changed(Inkscape::XML::Node *child, Inkscape::XML::Node *old_repr, Inkscape::XML::Node *new_repr) override
void remove_child(Inkscape::XML::Node *child) override
void set_clip_to_page(SPDesktop *desktop, bool enable)
SVGBool _origin_correction
std::vector< SPGuide * > guides
SPGrid * getFirstEnabledGrid()
Returns the first grid it could find that isEnabled().
void child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) override
void setLockGuides(bool v)
Colors::Color getGuideHiColor() const
void activateGuides(void *desktop, bool active)
Inkscape::Util::Unit const * display_units
void setShowGrids(bool v)
Colors::Color getGuideColor() const
std::vector< SPDesktop * > views
Colors::Color getDeskColor() const
void set_origin_follows_page(bool on)
SVGBool antialias_rendering
void change_bool_setting(SPAttr key, bool value)
Inkscape::Util::Unit const * getDisplayUnit() const
Returns namedview's default unit.
void build(SPDocument *document, Inkscape::XML::Node *repr) override
void set_desk_color(SPDesktop *desktop)
void change_color(SPAttr color_key, SPAttr opacity_key, Colors::Color const &color)
void setDisplayUnit(std::string unit)
Set the display unit to the given value.
void setShowGuides(bool v)
std::vector< SPGrid * > grids
void hide(SPDesktop const *desktop)
void updateViewPort()
Update the visibility of the viewport space.
void update(SPCtx *ctx, unsigned int flags) override
Propergate the update to the child nodes so they can be updated correctly.
void translateGuides(Geom::Translate const &translation)
void order_changed(Inkscape::XML::Node *child, Inkscape::XML::Node *old, Inkscape::XML::Node *new_repr) override
void remove_child(Inkscape::XML::Node *child) override
void child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) override
SPObject is an abstract base class of all of the document nodes at the SVG document level.
Inkscape::XML::Node * repr
void setAttribute(Inkscape::Util::const_char_ptr key, Inkscape::Util::const_char_ptr value)
void requestModified(unsigned int flags)
Requests that a modification notification signal be emitted later (e.g.
std::vector< SPObject * > childList(bool add_ref, Action action=ActionGeneral)
Retrieves the children as a std vector object, optionally ref'ing the children in the process,...
virtual void set(SPAttr key, const char *value)
char const * getId() const
Returns the objects current ID string.
void readAttr(char const *key)
Read value of key attribute from XML node into object.
Inkscape::XML::Node * getRepr()
Returns the XML representation of tree.
char const * getAttribute(char const *name) const
virtual void build(SPDocument *doc, Inkscape::XML::Node *repr)
void readOrUnset(gchar const *str)
Inkscape::SnapPreferences & snapprefs
A class for handling shape interaction with libavoid.
static const double defaultConnSpacing
Editable view implementation.
TODO: insert short description here.
@ PREFS_WINDOW_GEOMETRY_NONE
@ PREFS_WINDOW_GEOMETRY_LAST
@ PREFS_WINDOW_GEOMETRY_FILE
@ PREFS_WINDOW_SIZE_SMALL
@ PREFS_WINDOW_SIZE_NATURAL
@ PREFS_WINDOW_SIZE_MAXIMIZED
@ PREFS_WINDOW_SIZE_LARGE
Inkscape - An SVG editor.
helper functions for retrieving monitor geometry, etc.
Gdk::Rectangle get_monitor_geometry_at_surface(Glib::RefPtr< Gdk::Surface > const &surface)
get monitor geometry of monitor containing largest part of surface
Gdk::Rectangle get_monitor_geometry_at_point(int x, int y)
get monitor geometry of monitor at (or closest to) point on combined screen area
Helper class to stream background task notifications as a series of messages.
static cairo_user_data_key_t key
Singleton class to access the preferences file in a convenient way.
void sp_namedview_zoom_and_view_from_document(SPDesktop *desktop)
static auto const default_guide_hi_color
void sp_namedview_document_from_window(SPDesktop *desktop)
static auto const default_guide_color
void sp_namedview_window_from_document(SPDesktop *desktop)
void sp_namedview_update_layers_from_document(SPDesktop *desktop)
const Inkscape::Util::Unit * sp_parse_document_units(const char *value)
static auto const default_desk_color
const Inkscape::Util::Unit * sp_parse_document_units(const char *unit)
SPRoot: SVG <svg> implementation.
Interface for XML documents.