9e9a02f47bc1e000c61872386d1eaa3ca01ce0d7
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/colorbutton.h"
21 #include <gtkmm/comboboxtext.h>
22 #include <gtkmm/drawingarea.h>
23 #include <gtkmm/frame.h>
24 #include <gtkmm/liststore.h>
25 #include <gtkmm/menu.h>
26 #include <gtkmm/sizegroup.h>
27 #include <gtkmm/treeview.h>
29 #include "attributes.h"
30 #include "dialog.h"
31 #include "sp-filter.h"
32 #include "sp-feconvolvematrix.h"
33 #include "ui/widget/filter-effect-chooser.h"
34 #include "ui/widget/spin-slider.h"
36 using namespace Inkscape::UI::Widget;
38 namespace Inkscape {
39 namespace UI {
40 namespace Dialog {
42 class FilterEffectsDialog : public Dialog {
43 public:
44 ~FilterEffectsDialog();
46 void set_attrs_locked(const bool);
48 static FilterEffectsDialog *create() { return new FilterEffectsDialog(); }
49 private:
50 class FilterModifier : public Gtk::VBox, public FilterEffectChooser
51 {
52 public:
53 FilterModifier();
55 virtual SPFilter* get_selected_filter();
56 virtual void select_filter(const SPFilter*);
57 virtual Glib::SignalProxy0<void> signal_selection_changed();
58 private:
59 class CellRendererSel : public Gtk::CellRenderer
60 {
61 public:
62 CellRendererSel();
63 Glib::PropertyProxy<int> property_sel();
64 protected:
65 virtual void get_size_vfunc(Gtk::Widget&, const Gdk::Rectangle*,
66 int*, int*, int*, int*) const;
67 virtual void render_vfunc(const Glib::RefPtr<Gdk::Drawable>& win, Gtk::Widget& w,
68 const Gdk::Rectangle& bg_area, const Gdk::Rectangle& cell_area,
69 const Gdk::Rectangle& expose_area, Gtk::CellRendererState flags);
70 private:
71 const int _size;
72 Glib::Property<int> _sel;
73 };
75 static void on_inkscape_change_selection(Application *, Selection *, FilterModifier*);
76 void update_selection(Selection *);
78 void filter_list_button_press(GdkEventButton*);
79 void filter_list_button_release(GdkEventButton*);
80 void add_filter();
81 void remove_filter();
82 void duplicate_filter();
83 void filter_name_edited(const Glib::ustring& path, const Glib::ustring& text);
85 Gtk::TreeView _list;
86 CellRendererSel _cell_sel;
87 Gtk::Button _add;
88 Glib::RefPtr<Gtk::Menu> _menu;
89 };
91 class PrimitiveColumns : public Gtk::TreeModel::ColumnRecord
92 {
93 public:
94 PrimitiveColumns()
95 {
96 add(primitive);
97 add(type_id);
98 add(type);
99 add(id);
100 }
102 Gtk::TreeModelColumn<SPFilterPrimitive*> primitive;
103 Gtk::TreeModelColumn<NR::FilterPrimitiveType> type_id;
104 Gtk::TreeModelColumn<Glib::ustring> type;
105 Gtk::TreeModelColumn<Glib::ustring> id;
106 };
108 class CellRendererConnection : public Gtk::CellRenderer
109 {
110 public:
111 CellRendererConnection();
112 Glib::PropertyProxy<void*> property_primitive();
113 static int input_count(const SPFilterPrimitive* prim);
115 static const int size = 24;
117 void set_text_width(const int w);
118 int get_text_width() const;
119 protected:
120 virtual void get_size_vfunc(Gtk::Widget& widget, const Gdk::Rectangle* cell_area,
121 int* x_offset, int* y_offset, int* width, int* height) const;
122 private:
123 // void* should be SPFilterPrimitive*, some weirdness with properties prevents this
124 Glib::Property<void*> _primitive;
125 int _text_width;
126 };
128 class PrimitiveList : public Gtk::TreeView
129 {
130 public:
131 PrimitiveList(FilterEffectsDialog&);
133 Glib::SignalProxy0<void> signal_selection_changed();
135 void update();
136 void set_menu(Glib::RefPtr<Gtk::Menu>);
138 SPFilterPrimitive* get_selected();
139 void select(SPFilterPrimitive *prim);
141 int primitive_count() const;
142 protected:
143 bool on_expose_signal(GdkEventExpose*);
144 bool on_button_press_event(GdkEventButton*);
145 bool on_motion_notify_event(GdkEventMotion*);
146 bool on_button_release_event(GdkEventButton*);
147 void on_drag_end(const Glib::RefPtr<Gdk::DragContext>&);
148 private:
149 int init_text();
151 bool do_connection_node(const Gtk::TreeIter& row, const int input, std::vector<Gdk::Point>& points,
152 const int ix, const int iy);
153 const Gtk::TreeIter find_result(const Gtk::TreeIter& start, const SPAttributeEnum attr);
154 int find_index(const Gtk::TreeIter& target);
155 void draw_connection(const Gtk::TreeIter&, const SPAttributeEnum attr, const int text_start_x,
156 const int x1, const int y1, const int row_count);
157 void sanitize_connections(const Gtk::TreeIter& prim_iter);
159 FilterEffectsDialog& _dialog;
160 Glib::RefPtr<Gtk::ListStore> _model;
161 PrimitiveColumns _columns;
162 CellRendererConnection _connection_cell;
163 Glib::RefPtr<Gtk::Menu> _primitive_menu;
164 Glib::RefPtr<Pango::Layout> _vertical_layout;
165 int _in_drag;
166 SPFilterPrimitive* _drag_prim;
167 };
169 FilterEffectsDialog();
170 void init_settings_widgets();
172 // Handlers
173 void add_primitive();
174 void remove_primitive();
175 void duplicate_primitive();
176 void convolve_order_changed();
178 void set_attr_color(const SPAttributeEnum attr, const Gtk::ColorButton*);
179 void set_attr_direct(const SPAttributeEnum attr, const AttrWidget*);
180 void set_attr_special(const SPAttributeEnum);
181 void set_attr(const SPAttributeEnum, const gchar* val);
182 void update_settings_view();
183 void update_settings_sensitivity();
185 // Filter effect selection
186 FilterModifier _filter_modifier;
188 // View/add primitives
189 Gtk::VBox _primitive_box;
190 PrimitiveList _primitive_list;
191 UI::Widget::ComboBoxEnum<NR::FilterPrimitiveType> _add_primitive_type;
192 Gtk::Button _add_primitive;
194 // Bottom pane (filter effect primitive settings)
195 Gtk::VBox _settings_box;
196 Gtk::Label _empty_settings;
198 class Settings;
199 class ConvolveMatrix;
200 Settings* _settings;
202 // Convolve Matrix
203 ConvolveMatrix* _convolve_matrix;
204 DualSpinSlider* _convolve_order;
205 SpinSlider* _convolve_tx;
206 SpinSlider* _convolve_ty;
208 // For controlling setting sensitivity
209 Gtk::Widget* _k1, *_k2, *_k3, *_k4;
211 // To prevent unwanted signals
212 bool _locked;
214 FilterEffectsDialog(FilterEffectsDialog const &d);
215 FilterEffectsDialog& operator=(FilterEffectsDialog const &d);
216 };
218 } // namespace Dialog
219 } // namespace UI
220 } // namespace Inkscape
222 #endif // INKSCAPE_UI_DIALOG_FILTER_EFFECTS_H
224 /*
225 Local Variables:
226 mode:c++
227 c-file-style:"stroustrup"
228 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
229 indent-tabs-mode:nil
230 fill-column:99
231 End:
232 */
233 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :