summaryrefslogtreecommitdiffstats
path: root/src/layer-model.h
blob: 8e7153875a96147de07fb9b2de8bdf7aaf6c0790 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// SPDX-License-Identifier: GPL-2.0-or-later
#ifndef SEEN_INKSCAPE_LAYER_MODEL_H
#define SEEN_INKSCAPE_LAYER_MODEL_H

/*
 * Authors:
 *   Lauris Kaplinski <lauris@kaplinski.com>
 *   Frank Felfe <innerspace@iname.com>
 *   bulia byak <buliabyak@users.sf.net>
 *   Ralf Stephan <ralf@ark.in-berlin.de>
 *   John Bintz <jcoswell@coswellproductions.org>
 *   Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
 *   Jon A. Cruz <jon@joncruz.org>get
 *   Abhishek Sharma
 *   Eric Greveson <eric@greveson.co.uk>
 *
 * Copyright (C) 2007 Johan Engelen
 * Copyright (C) 2006 John Bintz
 * Copyright (C) 1999-2013 authors
 * Copyright (C) 2000-2001 Ximian, Inc.
 *
 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
 *
 */

#include <sigc++/sigc++.h>
#include <cstddef>

class SPDocument;
class SPObject;

namespace Inkscape {
  
class ObjectHierarchy;

namespace XML {
    class Node;
}

/**
 * The layer model for a document.
 *
 * This class represents the layer model for a document, typically (but
 * not necessarily) displayed in an SPDesktop.
 *
 * It also implements its own asynchronous notification signals that
 * UI elements can listen to.
 */
class LayerModel
{
    SPDocument *_doc;
    Inkscape::ObjectHierarchy *_layer_hierarchy;
    unsigned int _display_key;

public:
    /** Construct a layer model */
    LayerModel();

    /** Destructor */
    ~LayerModel();

    // Set document
    void setDocument(SPDocument *doc);

    // Set display key. For GUI apps.
    void setDisplayKey(unsigned int display_key);

    // Get the document that this layer model refers to. May be NULL.
    SPDocument *getDocument();

    // TODO look into making these return a more specific subclass:
    SPObject *currentRoot() const;
    SPObject *currentLayer() const;

    void reset();
    void setCurrentLayer(SPObject *object);
    void toggleLayerSolo(SPObject *object);
    void toggleHideAllLayers(bool hide);
    void toggleLockAllLayers(bool lock);
    void toggleLockOtherLayers(SPObject *object);
    SPObject *layerForObject(SPObject *object);
    bool isLayer(SPObject *object) const;
    
    sigc::signal<void, SPObject *> _layer_activated_signal;
    sigc::signal<void, SPObject *> _layer_deactivated_signal;
    sigc::signal<void, SPObject *, SPObject *> _layer_changed_signal;
};

} // namespace Inkscape

#endif
/*
  Local Variables:
  mode:c++
  c-file-style:"stroustrup"
  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
  indent-tabs-mode:nil
  fill-column:99
  End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :