Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
sp-namedview.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2#ifndef INKSCAPE_SP_NAMEDVIEW_H
3#define INKSCAPE_SP_NAMEDVIEW_H
4
5/*
6 * <sodipodi:namedview> implementation
7 *
8 * Authors:
9 * Lauris Kaplinski <lauris@kaplinski.com>
10 * Abhishek Sharma
11 *
12 * Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl>
13 * Copyright (C) Lauris Kaplinski 2000-2002
14 *
15 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
16 */
17
18#include <vector>
19
20#include "attributes.h"
21#include "snap.h"
22#include "sp-object-group.h"
23
24#include "colors/color.h"
25#include "svg/svg-bool.h"
26
27namespace Inkscape {
28 class CanvasPage;
29 namespace Util {
30 class Unit;
31 }
32 namespace Colors {
33 class Color;
34 }
35}
36
37using namespace Inkscape;
38
39class SPGrid;
40
41typedef unsigned int guint32;
43
44enum {
47};
48
49class SPNamedView final : public SPObjectGroup {
50public:
52 ~SPNamedView() override;
53 int tag() const override { return tag_of<decltype(*this)>; }
54
55 bool editable = true;
59 SVGBool clip_to_page{false}; // if true, clip rendered content to pages' boundaries
62 double zoom = 0;
63 double rotation = 0; // Document rotation in degrees (positive is clockwise)
64 double cx = 0;
65 double cy = 0;
66 int window_width = 0;
68 int window_x = 0;
69 int window_y = 0;
72 Inkscape::Util::Unit const *display_units = nullptr; // Units used for the UI (*not* the same as units of SVG coordinates)
73 // Inkscape::Util::Unit const *page_size_units; // Only used in "Custom size" part of Document Properties dialog
76 std::vector<SPGuide *> guides;
77 std::vector<SPGrid *> grids;
78 std::vector<SPDesktop *> views;
79 int viewcount = 0;
80
81 void show(SPDesktop *desktop);
82 void hide(SPDesktop const *desktop);
83 void setDefaultAttribute(std::string attribute, std::string preference, std::string fallback);
84 void activateGuides(void* desktop, bool active);
85 char const *getName() const;
86 std::vector<SPDesktop *> const getViewList() const;
88 void setDisplayUnit(std::string unit);
89 void setDisplayUnit(Inkscape::Util::Unit const *unit);
90
91 void translateGuides(Geom::Translate const &translation);
92 void translateGrids(Geom::Translate const &translation);
93 void scrollAllDesktops(double dx, double dy);
94
95 bool getShowGrids();
96 void setShowGrids(bool v);
97
98 void toggleShowGuides();
99 void toggleLockGuides();
100 void toggleShowGrids();
101
102 bool getLockGuides();
103 void setLockGuides(bool v);
104
105 void setShowGuides(bool v);
106 bool getShowGuides();
107
108 void updateViewPort();
109 void newGridCreated();
110
111 // page background, border, desk colors
112 void change_color(SPAttr color_key, SPAttr opacity_key,Colors::Color const &color);
113 // show border, border on top, anti-aliasing, ...
114 void change_bool_setting(SPAttr key, bool value);
115 // sync desk colors
117 // turn clip to page mode on/off
118 void set_clip_to_page(SPDesktop* desktop, bool enable);
119 // immediate show/hide guides request, not recorded in a named view
120 void temporarily_show_guides(bool show);
121 // coordinate system origin correction
123 void set_origin_follows_page(bool on);
124 // Y axis orientation
125 bool is_y_axis_down() const { return _y_axis_down; }
126 void set_y_axis_down(bool down);
127 // fix guidelines positions after Y axis flip
128 void fix_guidelines();
129
131
135private:
136 void updateGuides();
137 void updateGrids();
138
139 void setShowGuideSingle(SPGuide *guide);
140
141 friend class SPDocument;
142
143 std::unique_ptr<Inkscape::CanvasPage> _viewport;
144 bool _sync_grids = true;
145 std::optional<Colors::Color> _desk_color;
146 std::optional<Colors::Color> _guide_color;
147 std::optional<Colors::Color> _guide_hi_color;
148 double _guide_opacity = 0.6;
149 double _guide_hi_opacity = 0.5;
150 // if true, move coordinate system origin to the current page; if false - keep origin on front page
153
154protected:
156 void release() override;
157 void modified(unsigned int flags) override;
158 void update(SPCtx *ctx, unsigned int flags) override;
159 void set(SPAttr key, char const* value) override;
160
162 void remove_child(Inkscape::XML::Node* child) override;
164 Inkscape::XML::Node *new_repr) override;
165
166 Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags) override;
167};
168
169
174
175const Inkscape::Util::Unit* sp_parse_document_units(const char* unit);
176
177
178#endif /* !INKSCAPE_SP_NAMEDVIEW_H */
179
180/*
181 Local Variables:
182 mode:c++
183 c-file-style:"stroustrup"
184 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
185 indent-tabs-mode:nil
186 fill-column:99
187 End:
188*/
189// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
Lookup dictionary for attributes/properties.
SPAttr
Definition attributes.h:27
constexpr int tag_of
Convenience function to retrieve the tag (class id) of a given type.
Definition cast.h:26
Translation by a vector.
Definition transforms.h:115
Interface for refcounted XML nodes.
Definition node.h:80
To do: update description of desktop.
Definition desktop.h:149
Typed SVG document implementation.
Definition document.h:101
double _guide_opacity
char const * getName() const
void modified(unsigned int flags) override
~SPNamedView() override
void release() override
void set_y_axis_down(bool down)
SVGBool desk_checkerboard
bool getShowGrids()
bool getShowGuides()
void scrollAllDesktops(double dx, double dy)
int tag() const override
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
SVGBool lockguides
void newGridCreated()
void toggleLockGuides()
Inkscape::XML::Node * write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags) override
void setShowGuideSingle(SPGuide *guide)
SVGBool grids_visible
std::optional< Colors::Color > _desk_color
void show(SPDesktop *desktop)
void temporarily_show_guides(bool show)
void fix_guidelines()
std::vector< SPDesktop * > const getViewList() const
std::unique_ptr< Inkscape::CanvasPage > _viewport
std::optional< Colors::Color > _guide_hi_color
double rotation
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
SnapManager snap_manager
std::vector< SPGuide * > guides
SPGrid * getFirstEnabledGrid()
Returns the first grid it could find that isEnabled().
void toggleShowGuides()
void toggleShowGrids()
void child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) override
void setLockGuides(bool v)
Colors::Color getGuideHiColor() const
SVGBool _y_axis_down
void activateGuides(void *desktop, bool active)
bool get_origin_follows_page() const
Inkscape::Util::Unit const * display_units
void setShowGrids(bool v)
Colors::Color getGuideColor() const
std::vector< SPDesktop * > views
double _guide_hi_opacity
Colors::Color getDeskColor() const
GQuark default_layer_id
void updateGuides()
void set_origin_follows_page(bool on)
SVGBool antialias_rendering
SVGBool clip_to_page
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
bool is_y_axis_down() const
void set_desk_color(SPDesktop *desktop)
SVGBool showguides
bool getLockGuides()
int window_maximized
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)
double connector_spacing
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)
Inkscape::XML::Node * repr
Definition sp-object.h:193
SPDocument * document
Definition sp-object.h:188
Class to coordinate snapping operations.
Definition snap.h:80
unsigned int guint32
Miscellaneous supporting code.
Definition document.h:93
Helper class to stream background task notifications as a series of messages.
static cairo_user_data_key_t key
Ocnode * child[8]
Definition quantize.cpp:33
Ocnode ** ref
Definition quantize.cpp:32
void sp_namedview_zoom_and_view_from_document(SPDesktop *desktop)
unsigned int guint32
void sp_namedview_document_from_window(SPDesktop *desktop)
guint32 GQuark
@ SP_BORDER_LAYER_TOP
@ SP_BORDER_LAYER_BOTTOM
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 *unit)
Interface for XML documents.
Definition document.h:43
Unused.
Definition sp-object.h:94
SPDesktop * desktop