Code

1) Changes to snapping preferences dialog
[inkscape.git] / src / ui / dialog / filter-effects-dialog.h
1 /**
2  * \brief Filter Effects dialog
3  *
4  * Authors:
5  *   Nicholas Bishop <nicholasbishop@gmail.com>
6  *
7  * Copyright (C) 2007 Authors
8  *
9  * Released under GNU GPL.  Read the file 'COPYING' for more information.
10  */
12 #ifndef INKSCAPE_UI_DIALOG_FILTER_EFFECTS_H
13 #define INKSCAPE_UI_DIALOG_FILTER_EFFECTS_H
15 #include <gtkmm/adjustment.h>
16 #include <gtkmm/alignment.h>
17 #include <gtkmm/box.h>
18 #include <gtkmm/buttonbox.h>
19 #include <gtkmm/cellrendererspin.h>
20 #include <gtkmm/comboboxtext.h>
21 #include <gtkmm/drawingarea.h>
22 #include <gtkmm/frame.h>
23 #include <gtkmm/liststore.h>
24 #include <gtkmm/menu.h>
25 #include <gtkmm/sizegroup.h>
26 #include <gtkmm/treeview.h>
28 #include "attributes.h"
29 #include "dialog.h"
30 #include "sp-filter.h"
31 #include "sp-feconvolvematrix.h"
32 #include "ui/widget/filter-effect-chooser.h"
33 #include "ui/widget/spin-slider.h"
35 using namespace Inkscape::UI::Widget;
37 namespace Inkscape {
38 namespace UI {
39 namespace Dialog {
41 class FilterEffectsDialog : public Dialog {
42 public:
43     ~FilterEffectsDialog();
45     void set_attrs_locked(const bool);
47     static FilterEffectsDialog *create() { return new FilterEffectsDialog(); }
48 private:
49     class FilterModifier : public Gtk::VBox, public FilterEffectChooser
50     {
51     public:
52         FilterModifier();
54         virtual SPFilter* get_selected_filter();
55         virtual void select_filter(const SPFilter*);
56         virtual Glib::SignalProxy0<void> signal_selection_changed();
57     private:
58         class CellRendererSel : public Gtk::CellRenderer
59         {
60         public:
61             CellRendererSel();
62             Glib::PropertyProxy<int> property_sel();
63         protected:
64             virtual void get_size_vfunc(Gtk::Widget&, const Gdk::Rectangle*,
65                                     int*, int*, int*, int*) const;
66             virtual void render_vfunc(const Glib::RefPtr<Gdk::Drawable>& win, Gtk::Widget& w,
67                                       const Gdk::Rectangle& bg_area, const Gdk::Rectangle& cell_area,
68                                       const Gdk::Rectangle& expose_area, Gtk::CellRendererState flags);
69         private:
70             const int _size;
71             Glib::Property<int> _sel;
72         };
73         
74         static void on_inkscape_change_selection(Application *, Selection *, FilterModifier*);
75         void update_selection(Selection *);
77         void filter_list_button_press(GdkEventButton*);
78         void filter_list_button_release(GdkEventButton*);
79         void add_filter();
80         void remove_filter();
81         void duplicate_filter();
82         void filter_name_edited(const Glib::ustring& path, const Glib::ustring& text);
84         Gtk::TreeView _list;
85         CellRendererSel _cell_sel;
86         Gtk::Button _add;
87         Glib::RefPtr<Gtk::Menu> _menu;
88     };
90     class PrimitiveColumns : public Gtk::TreeModel::ColumnRecord
91     {
92     public:
93         PrimitiveColumns()
94         {
95             add(primitive);
96             add(type_id);
97             add(type);
98             add(id);
99         }
101         Gtk::TreeModelColumn<SPFilterPrimitive*> primitive;
102         Gtk::TreeModelColumn<NR::FilterPrimitiveType> type_id;
103         Gtk::TreeModelColumn<Glib::ustring> type;
104         Gtk::TreeModelColumn<Glib::ustring> id;
105     };
107     class CellRendererConnection : public Gtk::CellRenderer
108     {
109     public:
110         CellRendererConnection();
111         Glib::PropertyProxy<void*> property_primitive();
112         static int input_count(const SPFilterPrimitive* prim);
114         static const int size = 24;
115         
116         void set_text_width(const int w);
117         int get_text_width() const;
118     protected:
119         virtual void get_size_vfunc(Gtk::Widget& widget, const Gdk::Rectangle* cell_area,
120                                     int* x_offset, int* y_offset, int* width, int* height) const;
121     private:
122         // void* should be SPFilterPrimitive*, some weirdness with properties prevents this
123         Glib::Property<void*> _primitive;
124         int _text_width;
125     };
127     class PrimitiveList : public Gtk::TreeView
128     {
129     public:
130         PrimitiveList(FilterEffectsDialog&);
132         Glib::SignalProxy0<void> signal_selection_changed();
134         void update();
135         void set_menu(Glib::RefPtr<Gtk::Menu>);
137         SPFilterPrimitive* get_selected();
138         void select(SPFilterPrimitive *prim);
140         int primitive_count() const;
141     protected:
142         bool on_expose_signal(GdkEventExpose*);
143         bool on_button_press_event(GdkEventButton*);
144         bool on_motion_notify_event(GdkEventMotion*);
145         bool on_button_release_event(GdkEventButton*);
146         void on_drag_end(const Glib::RefPtr<Gdk::DragContext>&);
147     private:
148         int init_text();
150         bool do_connection_node(const Gtk::TreeIter& row, const int input, std::vector<Gdk::Point>& points,
151                                 const int ix, const int iy);
152         const Gtk::TreeIter find_result(const Gtk::TreeIter& start, const SPAttributeEnum attr);
153         int find_index(const Gtk::TreeIter& target);
154         void draw_connection(const Gtk::TreeIter&, const SPAttributeEnum attr, const int text_start_x,
155                              const int x1, const int y1, const int row_count);
156         void sanitize_connections(const Gtk::TreeIter& prim_iter);
158         FilterEffectsDialog& _dialog;
159         Glib::RefPtr<Gtk::ListStore> _model;
160         PrimitiveColumns _columns;
161         CellRendererConnection _connection_cell;
162         Glib::RefPtr<Gtk::Menu> _primitive_menu;
163         Glib::RefPtr<Pango::Layout> _vertical_layout;
164         int _in_drag;
165         SPFilterPrimitive* _drag_prim;
166     };
168     FilterEffectsDialog();
169     void init_settings_widgets();
171     // Handlers
172     void add_primitive();
173     void remove_primitive();
174     void duplicate_primitive();
175     void convolve_order_changed();
177     void set_attr_direct(const SPAttributeEnum attr, const AttrWidget*);
178     void set_attr_special(const SPAttributeEnum);
179     void set_attr(const SPAttributeEnum, const gchar* val);
180     void update_settings_view();
181     void update_settings_sensitivity();
183     // Filter effect selection
184     FilterModifier _filter_modifier;
186     // View/add primitives
187     Gtk::VBox _primitive_box;
188     PrimitiveList _primitive_list;
189     UI::Widget::ComboBoxEnum<NR::FilterPrimitiveType> _add_primitive_type;
190     Gtk::Button _add_primitive;
192     // Bottom pane (filter effect primitive settings)
193     Gtk::VBox _settings_box;
194     Gtk::Label _empty_settings;
196     class Settings;
197     class ConvolveMatrix;
198     Settings* _settings;
200     // Convolve Matrix
201     ConvolveMatrix* _convolve_matrix;
202     DualSpinSlider* _convolve_order;
203     SpinSlider* _convolve_tx;
204     SpinSlider* _convolve_ty;
206     // For controlling setting sensitivity
207     Gtk::Widget* _k1, *_k2, *_k3, *_k4;
209     // To prevent unwanted signals
210     bool _locked;
212     FilterEffectsDialog(FilterEffectsDialog const &d);
213     FilterEffectsDialog& operator=(FilterEffectsDialog const &d);
214 };
216 } // namespace Dialog
217 } // namespace UI
218 } // namespace Inkscape
220 #endif // INKSCAPE_UI_DIALOG_FILTER_EFFECTS_H
222 /*
223   Local Variables:
224   mode:c++
225   c-file-style:"stroustrup"
226   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
227   indent-tabs-mode:nil
228   fill-column:99
229   End:
230 */
231 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :