Code

Rework dialog management. Use singleton behavior for dialogs when
[inkscape.git] / src / dialogs / layers-panel.h
1 #ifndef SEEN_LAYERS_PANEL_H
2 #define SEEN_LAYERS_PANEL_H
3 /*
4  * A simple dialog for layer UI.
5  *
6  * Authors:
7  *   Jon A. Cruz
8  *
9  * Copyright (C) 2006 Jon A. Cruz
10  *
11  * Released under GNU GPL, read the file 'COPYING' for more information
12  */
14 #include <gtkmm/treeview.h>
15 #include <gtkmm/treestore.h>
16 #include <gtkmm/tooltips.h>
17 #include <gtkmm/scale.h>
18 #include <gtkmm/scrolledwindow.h>
19 #include <gtkmm/box.h>
20 #include <gtkmm/buttonbox.h>
21 #include <gtkmm/spinbutton.h>
23 //#include "ui/previewholder.h"
24 #include "ui/widget/panel.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 UI::Widget::Panel
40 {
41 public:
42     LayersPanel();
43     virtual ~LayersPanel();
45     //virtual void setOrientation( Gtk::AnchorType how );
46     
47     static LayersPanel& getInstance();
49     void setDesktop( SPDesktop* desktop );
51 protected:
52     //virtual void _handleAction( int setId, int itemId );
54 private:
55     class ModelColumns;
56     class InternalUIBounce;
58     LayersPanel(LayersPanel const &); // no copy
59     LayersPanel &operator=(LayersPanel const &); // no assign
61     void _styleButton( Gtk::Button& btn, SPDesktop *desktop, unsigned int code, char const* iconName, char const* fallback );
62     void _fireAction( unsigned int code );
63     Gtk::MenuItem& _addPopupItem( SPDesktop *desktop, unsigned int code, char const* iconName, char const* fallback, int id );
65     void _preToggle( GdkEvent const *event );
66     void _toggled( Glib::ustring const& str, int targetCol );
68     void _handleButtonEvent(GdkEventButton* evt);
69     void _handleRowChange( Gtk::TreeModel::Path const& path, Gtk::TreeModel::iterator const& iter );
71     void _pushTreeSelectionToCurrent();
72     void _checkTreeSelection();
74     void _takeAction( int val );
75     bool _executeAction();
77     bool _rowSelectFunction( Glib::RefPtr<Gtk::TreeModel> const & model, Gtk::TreeModel::Path const & path, bool b );
79     void _updateLayer(SPObject *layer);
80     bool _checkForUpdated(const Gtk::TreePath &path, const Gtk::TreeIter& iter, SPObject* layer);
82     void _selectLayer(SPObject *layer);
83     bool _checkForSelected(const Gtk::TreePath& path, const Gtk::TreeIter& iter, SPObject* layer);
85     void _layersChanged();
86     void _addLayer( SPDocument* doc, SPObject* layer, Gtk::TreeModel::Row* parentRow, SPObject* target, int level );
88     void _opacityChanged();
90     SPObject* _selectedLayer();
92     // Hooked to the layer manager:
93     sigc::connection _layerChangedConnection;
94     sigc::connection _layerUpdatedConnection;
95     sigc::connection _changedConnection;
96     sigc::connection _addedConnection;
97     sigc::connection _removedConnection;
98     sigc::connection _opacityConnection;
100     // Internal
101     sigc::connection _selectedConnection;
103     int _maxNestDepth;
104     Inkscape::LayerManager* _mgr;
105     SPDesktop* _desktop;
106     ModelColumns* _model;
107     InternalUIBounce* _pending;
108     GdkEvent* _toggleEvent;
109     Glib::RefPtr<Gtk::TreeStore> _store;
110     std::vector<Gtk::Widget*> _watching;
111     std::vector<Gtk::Widget*> _watchingNonTop;
112     std::vector<Gtk::Widget*> _watchingNonBottom;
114     Gtk::Tooltips _tips;
115     Gtk::TreeView _tree;
116     Gtk::HButtonBox _buttonsRow;
117     Gtk::ScrolledWindow _scroller;
118     Gtk::HBox _opacityBox;
119     Gtk::HScale _opacity;
120     Gtk::Menu _popupMenu;
121     Gtk::SpinButton _spinBtn;
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 :