12#include <glibmm/i18n.h>
39 return prefs->
getBool(
"/tools/pages/move_objects",
true);
72 if (
auto next =
page->getNextPage()) {
74 auto it = std::find(
pages.begin(),
pages.end(), next);
75 if (it !=
pages.end()) {
92 for (
auto it =
pages.begin(); it !=
pages.end(); ++it) {
103 if (
auto next =
page->getNextPage()) {
105 }
else if (
auto prev =
page->getPreviousPage()) {
125 for (
auto &
child : nv->children) {
153 auto new_page =
newPage(rect.width(), rect.height());
176 auto rect =
page->getRect();
177 if (rect.right() > left) {
178 left = rect.right() + 10;
198 repr->setAttributeSvgDouble(
"y", rect.
top());
199 repr->setAttributeSvgDouble(
"width", rect.
width());
200 repr->setAttributeSvgDouble(
"height", rect.
height());
202 if (
auto page = cast<SPPage>(nv->appendChildRepr(repr))) {
237 for (
auto &
item :
page->getExclusiveItems()) {
240 for (
auto &
item :
page->getOverlappingItems()) {
251 page->deleteObject();
262 auto rect =
page->getDesktopRect();
264 if (
page->isBarePage())
299 if (it !=
pages.end()) {
300 return it -
pages.begin();
302 g_warning(
"Can't get page index for %s",
page->getId());
398 if (index < 0 || index >=
pages.size()) {
427 std::vector<SPPage *> ret;
429 bool contains = page_pos.find(
page->getPagePosition()) != page_pos.end();
430 if (contains != inverse) {
442 std::vector<SPPage *> ret;
444 if (
page->itemOnPage(
item, contains)) {
457 if (
page->itemOnPage(
item, contains))
469 if (
page->getDesktopRect().corner(0) == pos) {
487 if (rect.contains(pos)) {
504 if (
page->isViewportPage()) {
521 total_area =
page->getDesktopRect();
558 for (
int side = 0; side < 4; side++) {
559 page->setMarginSide(side,
page->getMarginSide(side) *
scale.vector()[0]);
560 page->setBleedSide(side,
page->getBleedSide(side) *
scale.vector()[0]);
599 contents.applyAffine(tr);
622 if (!selection || selection->
isEmpty()) {
631 if (contents.isEmpty()) {
648 bool viewport =
true;
650 viewport =
page->isViewportPage();
651 page->setDocumentRect(*rect, add_margins);
652 rect =
page->getDocumentRect();
656 if (
page && !
page->isViewportPage()) {
670 return page->getOverlappingItems(hidden, in_bleed, in_layers);
728 bdcolor.setOpacity(0.0);
736 bgcolor.setOpacity(0.0);
738 bgcolor.setOpacity(1.0);
758 box =
page->getDesktopRect();
761 return _(
label.c_str());
777 return _(preset->get_name().c_str());
782 return format_number(Quantity::convert(
width, px, unit), 2)
784 format_number(Quantity::convert(
height, px, unit), 2)
795 page->movePage(tr,
false);
Lookup dictionary for attributes/properties.
@ INKSCAPE_DESK_CHECKERBOARD
3x3 matrix representing an affine transformation.
void unionWith(CRect const &b)
Enlarge the rectangle to contain the argument.
static CRect from_xywh(Coord x, Coord y, Coord w, Coord h)
Create rectangle from origin and dimensions.
bool contains(GenericRect< C > const &r) const
Check whether the rectangle includes all points in the given rectangle.
C top() const
Return top coordinate of the rectangle (+Y is downwards).
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 minExtent() const
Get the smaller extent (width or height) 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.
CPoint max() const
Get the corner of the rectangle with largest coordinate values.
Axis-aligned rectangle that can be empty.
Two-dimensional point that doubles as a vector.
Axis aligned, non-empty rectangle.
Rotation around the origin.
static Rotate from_degrees(Coord deg)
Construct a rotation from its angle in degrees.
Translate inverse() const
Get the inverse translation.
bool setOpacity(double opacity)
Set the opacity of this color object.
double getOpacity() const
Get the opacity in this color, if it's stored.
static std::shared_ptr< TemplatePreset > get_any_preset(const std::string &key)
Return the template preset based on the key from any template class (static method).
SPDesktop * desktop()
Returns the desktop the selection is bound to.
Geom::OptRect documentPreferredBounds() const
Returns either the visual or geometric bounding rectangle of selection in document coordinates based ...
bool isEmpty()
Returns true if no items are selected.
Colors::Color const & getMarginColor() const
bool setDefaultAttributes(CanvasPage *item)
Update the canvas item with the default display attributes.
void disablePages()
Disables multi page supply by removing all the page objects.
void changeOrientation()
Change page orientation, landscape to portrait and back.
Geom::Affine getSelectedPageAffine() const
sigc::signal< void(SPPage *)> _page_selected_signal
void centerToPage(SPDesktop *desktop, SPPage *page)
Center without zooming on the given page.
Colors::Color const & getBorderColor() const
SPPage * getFirstPage() const
void scalePages(Geom::Scale const &scale)
Change page size, margins and bleeds by a set amount.
std::vector< SPPage * > getPagesFor(SPItem *item, bool contains) const
Return a list of pages this item is on.
sigc::signal< void()> _pages_changed_signal
void enablePages()
Enables multi page support by turning the document viewBox into the first page.
Colors::Color border_color
void zoomToPage(SPDesktop *desktop, SPPage *page, bool width_only=false)
Center/zoom on the given page.
SPPage * getLastPage() const
void fitToSelection(ObjectSet *selection, bool add_margins=true)
Resize the page to the given selection.
SPPage * findPageAt(Geom::Point pos) const
This provides a simple way of selecting a page based on their layering Pages which are entirely conta...
SPPage * getPageFor(SPItem *item, bool contains) const
Return the first page that contains the given item.
SPPage * newPage()
Add a new page of the default size, this will be either the size of the viewBox if no pages exist,...
void reorderPage(Inkscape::XML::Node *child)
Reorder page within the internal list to keep it up to date.
Colors::Color background_color
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.
std::string getSizeLabel(SPPage *page=nullptr)
Return a page's size label, or match via width and height.
sigc::signal< void(SPPage *)> _page_modified_signal
const std::vector< SPPage * > & getPages() const
Colors::Color const & getBleedColor() const
bool selectPage(SPPage *page)
Set the given page as the selected page.
PageManager(SPDocument *document)
SPPage * getPage(int index) const
Get the page at the given position or return nullptr if out of range.
Geom::Rect getSelectedPageRect() const
Returns the selected page rect, OR the viewbox rect.
SPPage * getPageAt(Geom::Point pos) const
Get a page at a specific starting location.
Geom::Point nextPageLocation() const
Return the location of the next created page.
int getSelectedPageIndex() const
Return the index of the page in the index.
void movePages(Geom::Affine tr)
Called when the viewbox is resized.
void deletePage(SPPage *page, bool contents=false)
Delete the given page.
Colors::Color const & getBackgroundColor() const
SPPage * newDesktopPage(Geom::Rect rect, bool first_page=false)
Create a new page, resizing the rectangle from desktop coordinates.
SPPage * getViewportPage() const
Returns the page attached to the viewport, or nullptr if no pages or none of the pages are the viewpo...
void fitToRect(Geom::OptRect box, SPPage *page, bool add_margins=false)
Fit the selected page to the given rectangle.
void rotatePage(int turns)
Rotate the selected page by the given number of 90 degree rotations.
std::vector< SPItem * > getOverlappingItems(SPDesktop *desktop, SPPage *page, bool hidden=true, bool in_bleed=false, bool in_layers=true)
Return a list of objects touching this page, or viewbox (of single page document)
sigc::connection _page_modified_connection
static bool move_objects()
void removePage(Inkscape::XML::Node *child)
Remove a page from this manager, called from namedview parent.
void pagesChanged()
Called when the pages vector is updated, either page deleted or page created (but not if the page is ...
int getPageIndex(const SPPage *page) const
Get page index, returns -1 if the page is not found in this document.
void resizePage(double width, double height)
std::vector< SPPage * > pages
Geom::OptRect getDesktopRect() const
Returns the total area of all the pages in desktop units.
SPPage * newDocumentPage(Geom::Rect rect, bool first_page=false)
Create a new page, using document coordinates.
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.
Unit const * getUnit(Glib::ustring const &name) const
Retrieve a given unit based on its string identifier.
Interface for refcounted XML nodes.
bool setAttributeSvgDouble(Util::const_char_ptr key, double val)
For attributes where an exponent is allowed.
To do: update description of desktop.
void set_display_area(bool log=true)
Does all the dirty work in setting the display area.
void set_display_center(Geom::Rect const &a)
Centre Rect, without zooming.
void set_display_width(Geom::Rect const &a, Geom::Coord border)
Set display area in only the width dimension.
Typed SVG document implementation.
Glib::RefPtr< Gio::SimpleActionGroup > getActionGroup()
SPRoot * getRoot()
Returns our SPRoot.
const Geom::Affine & dt2doc() const
Desktop to document coordinate transformation.
void fitToRect(Geom::Rect const &rect, bool with_margins=false)
Given a Geom::Rect that may, for example, correspond to the bbox of an object, this function fits the...
std::vector< SPItem * > getItemsPartiallyInBox(unsigned int dkey, Geom::Rect const &box, bool take_hidden=false, bool take_insensitive=false, bool take_groups=true, bool enter_groups=false, bool enter_layers=true) const
Get items whose bounding box overlaps with given area.
Geom::OptRect preferredBounds() const
Inkscape::XML::Document * getReprDoc()
Our Inkscape::XML::Document.
SPNamedView * getNamedView()
Get the namedview for this document, creates it if it's not found.
Geom::Scale getDocumentScale(bool computed=true) const
Returns document scale as defined by width/height (in pixels) and viewBox (real world to user-units).
Inkscape::Util::Unit const * getDisplayUnit()
guaranteed not to return nullptr
std::vector< SPItem * > item_list()
Base class for visual SVG elements.
Geom::OptRect documentPreferredBounds() const
Colors::Color getDeskColor() const
SPObject is an abstract base class of all of the document nodes at the SVG document level.
void deleteObject(bool propagate, bool propagate_descendants)
Deletes an object, unparenting it from its parent.
sigc::connection connectModified(sigc::slot< void(SPObject *, unsigned int)> slot)
Connects to the modification notification signal.
Geom::Translate getDesktopAffine() const
Gets the page's position as a translation in desktop units.
Geom::Rect getDesktopRect() const
Get the rectangle of the page, in desktop units.
bool itemOnPage(SPItem const *item, bool contains=false, bool groups=true) const
Return true if this item is contained within the page boundary.
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.
Geom::Rect getRect() const
Gets the rectangle in document units.
Geom::Rect getSensitiveRect() const
Like getDesktopRect but returns a slightly shrunken rectangle so interactions don't confuse the borde...
void readOrUnset(gchar const *str)
Utility functions to convert ascii representations to numbers.
Editable view implementation.
Affine identity()
Create an identity matrix.
static R & release(R &r)
Decrements the reference count of a anchored object.
Miscellaneous supporting code.
Helper class to stream background task notifications as a series of messages.
static auto const default_background_color
static auto const default_bleed_color
static auto const default_margin_color
std::set< unsigned > parseIntRange(std::string const &input, unsigned start, unsigned end)
Parse integer ranges out of a string.
static auto const default_border_color
static cairo_user_data_key_t key
Singleton class to access the preferences file in a convenient way.
Some things pertinent to all visible shapes: SPItem, SPItemView, SPItemCtx.
SPRoot: SVG <svg> implementation.
virtual Node * createElement(char const *name)=0