Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
layer-manager.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Inkscape::LayerManager - a view of a document's layers, relative
4 * to a particular desktop
5 *
6 * Copyright 2006 MenTaLguY <mental@rydia.net>
7 *
8 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
9 */
10
11#ifndef SEEN_INKSCAPE_LAYER_MANAGER_H
12#define SEEN_INKSCAPE_LAYER_MANAGER_H
13
14#include <memory>
15#include <glibmm/ustring.h>
16
17#include "document-subset.h"
19
20class SPDesktop;
21class SPDocument;
22
23namespace Inkscape {
24
25class ObjectHierarchy;
26
28{
29public:
32
33 void renameLayer( SPObject* obj, char const *label, bool uniquify );
34 Glib::ustring getNextLayerName( SPObject* obj, char const *label);
35
36 sigc::connection connectCurrentLayerChanged(const sigc::slot<void (SPGroup *)> & slot) {
37 return _layer_changed_signal.connect(slot);
38 }
39
40 SPGroup *currentRoot() const;
41 SPGroup *currentLayer() const;
42
43 unsigned getLayerCount() const { return childCount(currentRoot()); }
44
45 void reset();
46 void setCurrentLayer(SPObject *object, bool clear=false);
47 void toggleLayerSolo(SPObject *object, bool force_hide = false);
48 void toggleHideAllLayers(bool hide);
49 void toggleLockAllLayers(bool lock);
50 void toggleLockOtherLayers(SPObject *object, bool force_lock = false);
52 std::list<SPItem *> getAllLayers();
53 bool isLayer(SPObject *object) const;
54 static SPGroup *asLayer(SPObject *object);
55
56 bool isRoot() const { return currentLayer() == currentRoot(); }
57
58private:
59 void _objectModified( SPObject* obj, unsigned int flags );
60 void _setDocument(SPDesktop *, SPDocument *document);
61 void _rebuild();
62
63 void _selectedLayerChanged(SPObject *top, SPObject *bottom);
64 void _layer_activated(SPObject *layer);
65 void _layer_deactivated(SPObject *layer);
66
67 sigc::connection _layer_connection;
68 sigc::connection _activate_connection;
69 sigc::connection _deactivate_connection;
70 sigc::connection _document_connection;
71 sigc::connection _resource_connection;
72
75
76 std::unique_ptr<Inkscape::ObjectHierarchy> _layer_hierarchy;
77 sigc::signal<void (SPGroup *)> _layer_changed_signal;
78};
79
85
89
90} // namespace Inkscape
91
92#endif // SEEN_INKSCAPE_LAYER_MANAGER_H
93
94/*
95 Local Variables:
96 mode:c++
97 c-file-style:"stroustrup"
98 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
99 indent-tabs-mode:nil
100 fill-column:99
101 End:
102*/
103// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
unsigned childCount(SPObject *obj) const
void toggleLayerSolo(SPObject *object, bool force_hide=false)
Toggle the visibility of every layer except the given layer.
void renameLayer(SPObject *obj, char const *label, bool uniquify)
SPObject * layerForObject(SPObject *object)
Return layer that contains object.
void _selectedLayerChanged(SPObject *top, SPObject *bottom)
sigc::signal< void(SPGroup *)> _layer_changed_signal
void setCurrentLayer(SPObject *object, bool clear=false)
Sets the current layer of the desktop.
sigc::connection _activate_connection
static SPGroup * asLayer(SPObject *object)
Return the SPGroup if we have a layer object.
void toggleHideAllLayers(bool hide)
SPGroup * currentLayer() const
Returns current top layer.
void toggleLockOtherLayers(SPObject *object, bool force_lock=false)
Toggle the sensitivity of every layer except the given layer.
SPGroup * currentRoot() const
Returns current root (=bottom) layer.
void toggleLockAllLayers(bool lock)
void _objectModified(SPObject *obj, unsigned int flags)
unsigned getLayerCount() const
std::list< SPItem * > getAllLayers()
sigc::connection _document_connection
std::unique_ptr< Inkscape::ObjectHierarchy > _layer_hierarchy
sigc::connection _deactivate_connection
Glib::ustring getNextLayerName(SPObject *obj, char const *label)
void _setDocument(SPDesktop *, SPDocument *document)
bool isLayer(SPObject *object) const
True if object is a layer.
void _layer_deactivated(SPObject *layer)
void reset()
Resets the bottom layer to the current root.
sigc::connection connectCurrentLayerChanged(const sigc::slot< void(SPGroup *)> &slot)
void _layer_activated(SPObject *layer)
sigc::connection _layer_connection
sigc::connection _resource_connection
To do: update description of desktop.
Definition desktop.h:149
Typed SVG document implementation.
Definition document.h:101
SPObject is an abstract base class of all of the document nodes at the SVG document level.
Definition sp-object.h:160
RootCluster root
Glib::ustring label
Helper class to stream background task notifications as a series of messages.
SPObject * create_layer(SPObject *root, SPObject *layer, LayerRelativePosition position)
Creates a new layer.
SPObject * next_layer(SPObject *root, SPObject *layer)
Finds the next layer under root, relative to layer in depth-first order.
SPObject * previous_layer(SPObject *root, SPObject *layer)
Finds the previous layer under root, relative to layer in depth-first order.
SPDesktop * desktop