Code

Fixing crash on layer delete undo
[inkscape.git] / src / dialogs / layers-panel.h
2 #ifndef SEEN_LAYERS_PANEL_H
3 #define SEEN_LAYERS_PANEL_H
4 /*
5  * A simple dialog for layer UI.
6  *
7  * Authors:
8  *   Jon A. Cruz
9  *
10  * Copyright (C) 2006 Jon A. Cruz
11  *
12  * Released under GNU GPL, read the file 'COPYING' for more information
13  */
15 #include <gtkmm/treeview.h>
16 #include <gtkmm/treestore.h>
17 #include <gtkmm/tooltips.h>
18 #include <gtkmm/scale.h>
19 #include <gtkmm/scrolledwindow.h>
20 #include <gtkmm/box.h>
21 #include <gtkmm/buttonbox.h>
23 #include "ui/widget/panel.h"
24 //#include "ui/previewholder.h"
26 class SPObject;
28 namespace Inkscape {
30 class LayerManager;
32 namespace UI {
33 namespace Dialogs {
36 /**
37  * A panel that displays layers.
38  */
39 class LayersPanel : public Inkscape::UI::Widget::Panel
40 {
41 public:
42     LayersPanel();
43     virtual ~LayersPanel();
45     static LayersPanel& getInstance();
46     //virtual void setOrientation( Gtk::AnchorType how );
48     void setDesktop( SPDesktop* desktop );
50 protected:
51     //virtual void _handleAction( int setId, int itemId );
53 private:
54     class ModelColumns;
55     class InternalUIBounce;
57     LayersPanel(LayersPanel const &); // no copy
58     LayersPanel &operator=(LayersPanel const &); // no assign
60     static LayersPanel* instance;
62     void _styleButton( Gtk::Button& btn, SPDesktop *desktop, unsigned int code, char const* iconName, char const* fallback );
63     void _fireAction( unsigned int code );
64     Gtk::MenuItem& _addPopupItem( SPDesktop *desktop, unsigned int code, char const* iconName, char const* fallback, int id );
66     void _preToggle( GdkEvent const *event );
67     void _toggled( Glib::ustring const& str, int targetCol );
69     void _handleButtonEvent(GdkEventButton* evt);
70     void _handleRowChange( Gtk::TreeModel::Path const& path, Gtk::TreeModel::iterator const& iter );
72     void _pushTreeSelectionToCurrent();
73     void _checkTreeSelection();
75     void _takeAction( int val );
76     bool _executeAction();
78     bool _rowSelectFunction( Glib::RefPtr<Gtk::TreeModel> const & model, Gtk::TreeModel::Path const & path, bool b );
80     void _updateLayer(SPObject *layer);
81     bool _checkForUpdated(const Gtk::TreePath &path, const Gtk::TreeIter& iter, SPObject* layer);
83     void _selectLayer(SPObject *layer);
84     bool _checkForSelected(const Gtk::TreePath& path, const Gtk::TreeIter& iter, SPObject* layer);
86     void _layersChanged();
87     void _addLayer( SPDocument* doc, SPObject* layer, Gtk::TreeModel::Row* parentRow, SPObject* target, int level );
89     void _opacityChanged();
91     SPObject* _selectedLayer();
93     // Hooked to the layer manager:
94     sigc::connection _layerChangedConnection;
95     sigc::connection _layerUpdatedConnection;
96     sigc::connection _changedConnection;
97     sigc::connection _addedConnection;
98     sigc::connection _removedConnection;
99     sigc::connection _opacityConnection;
101     // Internal
102     sigc::connection _selectedConnection;
104     int _maxNestDepth;
105     Inkscape::LayerManager* _mgr;
106     SPDesktop* _desktop;
107     ModelColumns* _model;
108     InternalUIBounce* _pending;
109     GdkEvent* _toggleEvent;
110     Glib::RefPtr<Gtk::TreeStore> _store;
111     std::vector<Gtk::Widget*> _watching;
112     std::vector<Gtk::Widget*> _watchingNonTop;
113     std::vector<Gtk::Widget*> _watchingNonBottom;
115     Gtk::Tooltips _tips;
116     Gtk::TreeView _tree;
117     Gtk::HButtonBox _buttonsRow;
118     Gtk::ScrolledWindow _scroller;
119     Gtk::HBox _opacityBox;
120     Gtk::HScale _opacity;
121     Gtk::Menu _popupMenu;
122 };
126 } //namespace Dialogs
127 } //namespace UI
128 } //namespace Inkscape
132 #endif // SEEN_LAYERS_PANEL_H
134 /*
135   Local Variables:
136   mode:c++
137   c-file-style:"stroustrup"
138   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
139   indent-tabs-mode:nil
140   fill-column:99
141   End:
142 */
143 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :