1 /*
2 * A simple dialog for layer UI.
3 *
4 * Authors:
5 * Jon A. Cruz
6 *
7 * Copyright (C) 2006,2010 Jon A. Cruz
8 *
9 * Released under GNU GPL, read the file 'COPYING' for more information
10 */
12 #ifndef SEEN_LAYERS_PANEL_H
13 #define SEEN_LAYERS_PANEL_H
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>
22 #include <gtkmm/spinbutton.h>
23 #include <gtkmm/notebook.h>
25 //#include "ui/previewholder.h"
26 #include "ui/widget/panel.h"
27 #include "ui/widget/object-composite-settings.h"
28 #include "desktop-tracker.h"
30 class SPObject;
32 namespace Inkscape {
34 class LayerManager;
36 namespace UI {
37 namespace Dialog {
40 /**
41 * A panel that displays layers.
42 */
43 class LayersPanel : public UI::Widget::Panel
44 {
45 public:
46 LayersPanel();
47 virtual ~LayersPanel();
49 //virtual void setOrientation( Gtk::AnchorType how );
51 static LayersPanel& getInstance();
53 void setDesktop( SPDesktop* desktop );
55 protected:
56 //virtual void _handleAction( int setId, int itemId );
58 private:
59 class ModelColumns;
60 class InternalUIBounce;
62 LayersPanel(LayersPanel const &); // no copy
63 LayersPanel &operator=(LayersPanel const &); // no assign
65 void _styleButton( Gtk::Button& btn, SPDesktop *desktop, unsigned int code, char const* iconName, char const* fallback );
66 void _fireAction( unsigned int code );
67 Gtk::MenuItem& _addPopupItem( SPDesktop *desktop, unsigned int code, char const* iconName, char const* fallback, int id );
69 void _preToggle( GdkEvent const *event );
70 void _toggled( Glib::ustring const& str, int targetCol );
72 void _handleButtonEvent(GdkEventButton* evt);
73 void _handleRowChange( Gtk::TreeModel::Path const& path, Gtk::TreeModel::iterator const& iter );
75 void _pushTreeSelectionToCurrent();
76 void _checkTreeSelection();
78 void _takeAction( int val );
79 bool _executeAction();
81 bool _rowSelectFunction( Glib::RefPtr<Gtk::TreeModel> const & model, Gtk::TreeModel::Path const & path, bool b );
83 void _updateLayer(SPObject *layer);
84 bool _checkForUpdated(const Gtk::TreePath &path, const Gtk::TreeIter& iter, SPObject* layer);
86 void _selectLayer(SPObject *layer);
87 bool _checkForSelected(const Gtk::TreePath& path, const Gtk::TreeIter& iter, SPObject* layer);
89 void _layersChanged();
90 void _addLayer( SPDocument* doc, SPObject* layer, Gtk::TreeModel::Row* parentRow, SPObject* target, int level );
92 SPObject* _selectedLayer();
94 // Hooked to the layer manager:
95 sigc::connection _layerChangedConnection;
96 sigc::connection _layerUpdatedConnection;
97 sigc::connection _changedConnection;
98 sigc::connection _addedConnection;
99 sigc::connection _removedConnection;
101 // Internal
102 sigc::connection _selectedConnection;
104 DesktopTracker deskTrack;
105 int _maxNestDepth;
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::Menu _popupMenu;
120 Gtk::SpinButton _spinBtn;
121 Gtk::VBox _layersPage;
123 UI::Widget::StyleSubject::CurrentLayer _subject;
124 UI::Widget::ObjectCompositeSettings _compositeSettings;
125 sigc::connection desktopChangeConn;
126 };
130 } //namespace Dialogs
131 } //namespace UI
132 } //namespace Inkscape
136 #endif // SEEN_LAYERS_PANEL_H
138 /*
139 Local Variables:
140 mode:c++
141 c-file-style:"stroustrup"
142 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
143 indent-tabs-mode:nil
144 fill-column:99
145 End:
146 */
147 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :