Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
sp-page.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
/*
5 * Authors:
6 * Martin Owens 2021
7 *
8 * Copyright (C) 2021 Martin Owens
9 *
10 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
11 */
12#ifndef SEEN_SP_PAGE_H
13#define SEEN_SP_PAGE_H
14
15#include <2geom/rect.h>
16#include <vector>
17
19#include "page-manager.h"
20#include "sp-object.h"
21#include "svg/svg-length.h"
22#include "svg/svg-box.h"
23
24class SPDesktop;
25class SPItem;
26namespace Inkscape {
27 class ObjectSet;
28}
29
30class SPPage final : public SPObject
31{
32public:
33 SPPage();
34 ~SPPage() override;
35 int tag() const override { return tag_of<decltype(*this)>; }
36
37 void movePage(Geom::Affine translate, bool with_objects);
38 void swapPage(SPPage *other, bool with_objects);
39 static void moveItems(Geom::Affine translate, std::vector<SPItem *> const &objects);
40
41 // Canvas visualisation
44 void showPage() { _canvas_item->show(); }
45 void hidePage() { _canvas_item->hide(); }
46 void set_guides_visible(bool show);
47
48 double getMarginSide(int side);
49 const SVGBox &getMarginBox() const { return margin; }
50 void setMargin(const std::string &value);
51 void setMarginSide(int pos, double value, bool confine = false);
52 void setMarginSide(int side, const std::string &value, bool confine = false);
53 std::string getMarginLabel() const;
54
55 double getBleedSide(int side);
56 void setBleedSide(int side, double value);
57 const SVGBox &getBleedBox() const { return bleed; }
58 void setBleed(const std::string &value);
59 std::string getBleedLabel() const;
60
61 void copyFrom(SPPage *page);
62 void setSelected(bool selected);
64 void setSizeLabel(std::string label);
65 int getPageIndex() const;
66 int getPagePosition() const { return getPageIndex() + 1; }
67 bool setPageIndex(int index, bool swap_page);
68 bool setPagePosition(int position, bool swap_page) { return setPageIndex(position - 1, swap_page); }
69 bool isBarePage() const;
70
71 // To sort the pages in the set by index/page number
73 {
74 bool operator()(const SPPage* Page1, const SPPage* Page2) const
75 {
76 return (Page1->getPageIndex() < Page2->getPageIndex());
77 }
78 };
79
82
83 Geom::Rect getRect() const;
86
89
90 Geom::Rect getBleed() const;
93
95
96 void setRect(Geom::Rect rect);
97 void setDesktopRect(Geom::Rect rect);
98 void setDocumentRect(Geom::Rect rect, bool add_margins = false);
99
100 void setSize(double width, double height);
101 std::vector<SPItem *> getExclusiveItems(bool hidden = true, bool in_bleed = false, bool in_layers = true) const;
102 std::vector<SPItem *> getOverlappingItems(bool hidden = true, bool in_bleed = false, bool in_layers = true) const;
103 bool itemOnPage(SPItem const *item, bool contains = false, bool groups = true) const;
104 bool isViewportPage() const;
105 std::string getDefaultLabel() const;
106 std::string getLabel() const;
107 std::string getSizeLabel() const;
108
110
111protected:
112 void build(SPDocument *doc, Inkscape::XML::Node *repr) override;
113 void release() override;
114 void update(SPCtx *ctx, unsigned int flags) override;
115 void set(SPAttr key, const char *value) override;
117
118 void update_relatives();
119private:
121
128 std::string _size_label;
129};
130
131#endif // SEEN_SP_PAGE_H
132
133/*
134 Local Variables:
135 mode:c++
136 c-file-style:"stroustrup"
137 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
138 indent-tabs-mode:nil
139 fill-column:99
140 End:
141*/
142// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
SPAttr
Definition attributes.h:27
uint64_t page
Definition canvas.cpp:171
constexpr int tag_of
Convenience function to retrieve the tag (class id) of a given type.
Definition cast.h:26
3x3 matrix representing an affine transformation.
Definition affine.h:70
Axis aligned, non-empty rectangle.
Definition rect.h:92
Translation by a vector.
Definition transforms.h:115
void remove(UI::Widget::Canvas *canvas)
Hide the page in the given canvas widget.
A widget for Inkscape's canvas.
Definition canvas.h:62
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:103
Base class for visual SVG elements.
Definition sp-item.h:109
SPObject is an abstract base class of all of the document nodes at the SVG document level.
Definition sp-object.h:160
char const * label() const
Gets the author-visible label property for the object or a default if no label is defined.
Inkscape::XML::Node * repr
Definition sp-object.h:193
int tag() const override
Definition sp-page.h:35
void setDesktopRect(Geom::Rect rect)
Set the page rectangle in desktop coordinates.
Definition sp-page.cpp:254
SVGLength x
Definition sp-page.h:122
Geom::Rect getDesktopMargin() const
Definition sp-page.cpp:161
int getPageIndex() const
Returns the page number (order of pages) starting at 1.
Definition sp-page.cpp:455
void setRect(Geom::Rect rect)
Set the page rectangle in its native units.
Definition sp-page.cpp:218
~SPPage() override
Definition sp-page.cpp:32
bool setPageIndex(int index, bool swap_page)
Set this page to a new order in the page stack.
Definition sp-page.cpp:468
SVGLength height
Definition sp-page.h:125
Geom::Translate getDesktopAffine() const
Gets the page's position as a translation in desktop units.
Definition sp-page.cpp:140
void setBleedSide(int side, double value)
Definition sp-page.cpp:350
std::string getLabel() const
Definition sp-page.cpp:648
void setSizeLabel(std::string label)
Definition sp-page.cpp:633
Geom::Rect getDesktopRect() const
Get the rectangle of the page, in desktop units.
Definition sp-page.cpp:132
std::string getDefaultLabel() const
Definition sp-page.cpp:640
void copyFrom(SPPage *page)
Copy non-size attributes from the given page.
Definition sp-page.cpp:665
SPPage()
Definition sp-page.cpp:26
const SVGBox & getBleedBox() const
Definition sp-page.h:57
std::string getMarginLabel() const
Definition sp-page.cpp:327
SPPage * getNextPage()
Returns the sibling page next to this one in the stack order.
Definition sp-page.cpp:513
SVGBox margin
Definition sp-page.h:126
void hidePage(Inkscape::UI::Widget::Canvas *canvas)
Definition sp-page.h:43
void swapPage(SPPage *other, bool with_objects)
Swap the locations of this page with another page (see movePage)
Definition sp-page.cpp:582
Geom::Rect getDesktopBleed() const
Definition sp-page.cpp:191
SVGLength width
Definition sp-page.h:124
void showPage()
Definition sp-page.h:44
bool setPagePosition(int position, bool swap_page)
Definition sp-page.h:68
std::string getSizeLabel() const
Definition sp-page.cpp:657
bool itemOnPage(SPItem const *item, bool contains=false, bool groups=true) const
Return true if this item is contained within the page boundary.
Definition sp-page.cpp:393
Geom::Rect getDocumentMargin() const
Get document rect, minus the margin amounts.
Definition sp-page.cpp:149
void set_guides_visible(bool show)
Definition sp-page.cpp:677
Geom::Rect getBleed() const
Get page rect enlarged by bleed amounts.
Definition sp-page.cpp:169
static void moveItems(Geom::Affine translate, std::vector< SPItem * > const &objects)
Move the given items by the given translation in document units.
Definition sp-page.cpp:561
bool setDefaultAttributes()
Sets the default attributes from the namedview.
Definition sp-page.cpp:434
void hidePage()
Definition sp-page.h:45
Geom::Rect getDocumentBleed() const
Get document rect, plus the bleed amounts.
Definition sp-page.cpp:186
std::vector< SPItem * > getOverlappingItems(bool hidden=true, bool in_bleed=false, bool in_layers=true) const
Like ExcludiveItems above but get all the items which are inside or overlapping.
Definition sp-page.cpp:379
SVGBox bleed
Definition sp-page.h:127
void setSelected(bool selected)
Set the selected high-light for this page.
Definition sp-page.cpp:446
std::string getBleedLabel() const
Definition sp-page.cpp:336
void update(SPCtx *ctx, unsigned int flags) override
Definition sp-page.cpp:601
SPPage * getPreviousPage()
Returns the sibling page previous to this one in the stack order.
Definition sp-page.cpp:527
Geom::Rect getRect() const
Gets the rectangle in document units.
Definition sp-page.cpp:124
std::string _size_label
Definition sp-page.h:128
bool isBarePage() const
Returns true if the only aspect to this page is its size.
Definition sp-page.cpp:113
Inkscape::CanvasPage * _canvas_item
Definition sp-page.h:120
Geom::Rect getDocumentRect() const
Get the rectangle of the page, scaled to the document.
Definition sp-page.cpp:199
double getMarginSide(int side)
Get the margin side of the box.
Definition sp-page.cpp:295
double getBleedSide(int side)
Definition sp-page.cpp:345
const SVGBox & getMarginBox() const
Definition sp-page.h:49
void setBleed(const std::string &value)
Set the page's bleed.
Definition sp-page.cpp:286
void setMargin(const std::string &value)
Set the page's margin.
Definition sp-page.cpp:277
std::vector< SPItem * > getExclusiveItems(bool hidden=true, bool in_bleed=false, bool in_layers=true) const
Get the items which are ONLY on this page and don't overlap.
Definition sp-page.cpp:367
void update_relatives()
Update the percentage values of the svg boxes.
Definition sp-page.cpp:100
Geom::Rect getSensitiveRect() const
Like getDesktopRect but returns a slightly shrunken rectangle so interactions don't confuse the borde...
Definition sp-page.cpp:208
bool isViewportPage() const
Returns true if this page is the same as the viewport.
Definition sp-page.cpp:415
void movePage(Geom::Affine translate, bool with_objects)
Move the page by the given affine, in desktop units.
Definition sp-page.cpp:544
void release() override
Definition sp-page.cpp:55
void build(SPDocument *doc, Inkscape::XML::Node *repr) override
Definition sp-page.cpp:38
void setDocumentRect(Geom::Rect rect, bool add_margins=false)
Set the page rectangle in document coordinates.
Definition sp-page.cpp:238
int getPagePosition() const
Definition sp-page.h:66
SVGLength y
Definition sp-page.h:123
void setSize(double width, double height)
Set just the height and width from a predefined size.
Definition sp-page.cpp:267
void setMarginSide(int pos, double value, bool confine=false)
Set the margin at this side of the box in user units.
Definition sp-page.cpp:303
Inkscape::XML::Node * write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) override
Write out the page's data into its xml structure.
Definition sp-page.cpp:616
SVG length type.
Definition svg-length.h:22
SPItem * item
Helper class to stream background task notifications as a series of messages.
static cairo_user_data_key_t key
Axis-aligned rectangle.
Interface for XML documents.
Definition document.h:43
Unused.
Definition sp-object.h:94
bool operator()(const SPPage *Page1, const SPPage *Page2) const
Definition sp-page.h:74
int index