Code

marked forgotten translatable message
[inkscape.git] / src / ui / dialog / filter-effects-dialog.h
1 /** @file
2  * @brief Filter Effects dialog
3  */
4 /* Authors:
5  *   Nicholas Bishop <nicholasbishop@gmail.com>
6  *   Rodrigo Kumpera <kumpera@gmail.com>
7  *
8  * Copyright (C) 2007 Authors
9  *
10  * Released under GNU GPL.  Read the file 'COPYING' for more information.
11  */
13 #ifndef INKSCAPE_UI_DIALOG_FILTER_EFFECTS_H
14 #define INKSCAPE_UI_DIALOG_FILTER_EFFECTS_H
16 #include <memory>
18 #include <gtkmm/adjustment.h>
19 #include <gtkmm/alignment.h>
20 #include <gtkmm/box.h>
21 #include <gtkmm/buttonbox.h>
22 #include <gtkmm/comboboxtext.h>
23 #include <gtkmm/drawingarea.h>
24 #include <gtkmm/frame.h>
25 #include <gtkmm/liststore.h>
26 #include <gtkmm/menu.h>
27 #include <gtkmm/notebook.h>
28 #include <gtkmm/sizegroup.h>
29 #include <gtkmm/treeview.h>
31 #include "attributes.h"
32 #include "ui/widget/panel.h"
33 #include "sp-filter.h"
34 #include "ui/widget/combo-enums.h"
35 #include "ui/widget/spin-slider.h"
37 using namespace Inkscape::UI::Widget;
39 namespace Inkscape {
40 namespace UI {
41 namespace Dialog {
43 class DualSpinButton;
44 class MultiSpinButton;
45 class FilterEffectsDialog : public UI::Widget::Panel {
46 public:
48     FilterEffectsDialog();
49     ~FilterEffectsDialog();
51     static FilterEffectsDialog &getInstance()
52     { return *new FilterEffectsDialog(); }
54     void set_attrs_locked(const bool);
55 protected:
56     virtual void show_all_vfunc();
57 private:
58     class SignalObserver;
60     class FilterModifier : public Gtk::VBox
61     {
62     public:
63         FilterModifier(FilterEffectsDialog&);
64         ~FilterModifier();
66         SPFilter* get_selected_filter();
67         void select_filter(const SPFilter*);
69         sigc::signal<void>& signal_filter_changed()
70         {
71             return _signal_filter_changed;
72         }
73     private:
74         class Columns : public Gtk::TreeModel::ColumnRecord
75         {
76         public:
77             Columns()
78             {
79                 add(filter);
80                 add(label);
81                 add(sel);
82             }
84             Gtk::TreeModelColumn<SPFilter*> filter;
85             Gtk::TreeModelColumn<Glib::ustring> label;
86             Gtk::TreeModelColumn<int> sel;
87         };
89         static void on_activate_desktop(Application*, SPDesktop*, FilterModifier*);
90         static void on_deactivate_desktop(Application*, SPDesktop*, FilterModifier*);
91         void on_document_replaced(SPDesktop*, SPDocument*)
92         {
93             update_filters();
94         }
95        
96         static void on_inkscape_change_selection(Application *, Selection *, FilterModifier*);
97         
98         void update_selection(Selection *);
99         void on_filter_selection_changed();
101         void on_name_edited(const Glib::ustring&, const Glib::ustring&);
102         void on_selection_toggled(const Glib::ustring&);
104         void update_filters();
105         void filter_list_button_release(GdkEventButton*);
106         void add_filter();
107         void remove_filter();
108         void duplicate_filter();
109         void rename_filter();
111         sigc::connection _doc_replaced;
112         sigc::connection _resource_changed;
114         FilterEffectsDialog& _dialog;
115         Gtk::TreeView _list;
116         Glib::RefPtr<Gtk::ListStore> _model;
117         Columns _columns;
118         Gtk::CellRendererToggle _cell_toggle;
119         Gtk::Button _add;
120         Glib::RefPtr<Gtk::Menu> _menu;
121         sigc::signal<void> _signal_filter_changed;
122         std::auto_ptr<SignalObserver> _observer;
123     };
125     class PrimitiveColumns : public Gtk::TreeModel::ColumnRecord
126     {
127     public:
128         PrimitiveColumns()
129         {
130             add(primitive);
131             add(type_id);
132             add(type);
133             add(id);
134         }
136         Gtk::TreeModelColumn<SPFilterPrimitive*> primitive;
137         Gtk::TreeModelColumn<NR::FilterPrimitiveType> type_id;
138         Gtk::TreeModelColumn<Glib::ustring> type;
139         Gtk::TreeModelColumn<Glib::ustring> id;
140     };
142     class CellRendererConnection : public Gtk::CellRenderer
143     {
144     public:
145         CellRendererConnection();
146         Glib::PropertyProxy<void*> property_primitive();
148         static const int size = 24;
149         
150         void set_text_width(const int w);
151         int get_text_width() const;
152     protected:
153         virtual void get_size_vfunc(Gtk::Widget& widget, const Gdk::Rectangle* cell_area,
154                                     int* x_offset, int* y_offset, int* width, int* height) const;
155     private:
156         // void* should be SPFilterPrimitive*, some weirdness with properties prevents this
157         Glib::Property<void*> _primitive;
158         int _text_width;
159     };
161     class PrimitiveList : public Gtk::TreeView
162     {
163     public:
164         PrimitiveList(FilterEffectsDialog&);
166         sigc::signal<void>& signal_primitive_changed();
168         void update();
169         void set_menu(Glib::RefPtr<Gtk::Menu>);
171         SPFilterPrimitive* get_selected();
172         void select(SPFilterPrimitive *prim);
173         void remove_selected();
175         int primitive_count() const;
176     protected:
177         bool on_expose_signal(GdkEventExpose*);
178         bool on_button_press_event(GdkEventButton*);
179         bool on_motion_notify_event(GdkEventMotion*);
180         bool on_button_release_event(GdkEventButton*);
181         void on_drag_end(const Glib::RefPtr<Gdk::DragContext>&);
182     private:
183         int init_text();
185         bool do_connection_node(const Gtk::TreeIter& row, const int input, std::vector<Gdk::Point>& points,
186                                 const int ix, const int iy);
187         const Gtk::TreeIter find_result(const Gtk::TreeIter& start, const int attr, int& src_id);
188         int find_index(const Gtk::TreeIter& target);
189         void draw_connection(const Gtk::TreeIter&, const int attr, const int text_start_x,
190                              const int x1, const int y1, const int row_count);
191         void sanitize_connections(const Gtk::TreeIter& prim_iter);
192         void on_primitive_selection_changed();
193         bool on_scroll_timeout();
195         FilterEffectsDialog& _dialog;
196         Glib::RefPtr<Gtk::ListStore> _model;
197         PrimitiveColumns _columns;
198         CellRendererConnection _connection_cell;
199         Glib::RefPtr<Gtk::Menu> _primitive_menu;
200         Glib::RefPtr<Pango::Layout> _vertical_layout;
201         int _in_drag;
202         SPFilterPrimitive* _drag_prim;
203         sigc::signal<void> _signal_primitive_changed;
204         sigc::connection _scroll_connection;
205         int _autoscroll;
206         std::auto_ptr<SignalObserver> _observer;
207     };
209     void init_settings_widgets();
211     // Handlers
212     void add_primitive();
213     void remove_primitive();
214     void duplicate_primitive();
215     void convolve_order_changed();
217     void set_attr_direct(const AttrWidget*);
218     void set_child_attr_direct(const AttrWidget*);
219     void set_filternode_attr(const AttrWidget*);
220     void set_attr(SPObject*, const SPAttributeEnum, const gchar* val);
221     void update_settings_view();
222     void update_filter_general_settings_view();
223     void update_settings_sensitivity();
224     void update_color_matrix();
225     void update_primitive_infobox();
227     // Primitives Info Box  
228     Gtk::Label _infobox_desc;
229     Gtk::Image _infobox_icon;
231     // View/add primitives
232     Gtk::VBox _primitive_box;
233     UI::Widget::ComboBoxEnum<NR::FilterPrimitiveType> _add_primitive_type;
234     Gtk::Button _add_primitive;
236     // Bottom pane (filter effect primitive settings)
237     Gtk::Notebook _settings_tabs;
238     Gtk::VBox _settings_tab2;
239     Gtk::VBox _settings_tab1;
240     Gtk::Label _empty_settings;
241     Gtk::Label _no_filter_selected;
242     bool _settings_initialized;
244     class Settings;
245     class MatrixAttr;
246     class ColorMatrixValues;
247     class LightSourceControl;
248     Settings* _settings;
249     Settings* _filter_general_settings;
250     Glib::RefPtr<Gtk::SizeGroup> _sizegroup;
252     // Color Matrix
253     ColorMatrixValues* _color_matrix_values;
255     // Convolve Matrix
256     MatrixAttr* _convolve_matrix;
257     DualSpinButton* _convolve_order;
258     MultiSpinButton* _convolve_target;
260     // For controlling setting sensitivity
261     Gtk::Widget* _k1, *_k2, *_k3, *_k4;
262     Gtk::Widget* _ct_table, *_ct_slope, *_ct_intercept, *_ct_amplitude, *_ct_exponent, *_ct_offset;
264     // To prevent unwanted signals
265     bool _locked;
266     bool _attr_lock;
268     // These go last since they depend on the prior initialization of
269     // other FilterEffectsDialog members
270     FilterModifier _filter_modifier;
271     PrimitiveList _primitive_list;
273     FilterEffectsDialog(FilterEffectsDialog const &d);
274     FilterEffectsDialog& operator=(FilterEffectsDialog const &d);
275 };
277 } // namespace Dialog
278 } // namespace UI
279 } // namespace Inkscape
281 #endif // INKSCAPE_UI_DIALOG_FILTER_EFFECTS_H
283 /*
284   Local Variables:
285   mode:c++
286   c-file-style:"stroustrup"
287   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
288   indent-tabs-mode:nil
289   fill-column:99
290   End:
291 */
292 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :