1cb88e1f9f2f5386ee259694bd9f206d023254cc
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 static FilterEffectsDialog *create() { return new FilterEffectsDialog(); }
47 private:
48 class FilterModifier : public Gtk::VBox, public FilterEffectChooser
49 {
50 public:
51 FilterModifier();
53 virtual SPFilter* get_selected_filter();
54 virtual void select_filter(const SPFilter*);
55 virtual Glib::SignalProxy0<void> signal_selection_changed();
56 private:
57 void filter_list_button_release(GdkEventButton*);
58 void add_filter();
59 void remove_filter();
60 void duplicate_filter();
61 void filter_name_edited(const Glib::ustring& path, const Glib::ustring& text);
63 Gtk::TreeView _list;
64 Gtk::Button _add;
65 Glib::RefPtr<Gtk::Menu> _menu;
66 };
68 class PrimitiveColumns : public Gtk::TreeModel::ColumnRecord
69 {
70 public:
71 PrimitiveColumns()
72 {
73 add(primitive);
74 add(type_id);
75 add(type);
76 add(id);
77 }
79 Gtk::TreeModelColumn<SPFilterPrimitive*> primitive;
80 Gtk::TreeModelColumn<NR::FilterPrimitiveType> type_id;
81 Gtk::TreeModelColumn<Glib::ustring> type;
82 Gtk::TreeModelColumn<Glib::ustring> id;
83 };
85 class CellRendererConnection : public Gtk::CellRenderer
86 {
87 public:
88 CellRendererConnection();
89 Glib::PropertyProxy<void*> property_primitive();
90 static int input_count(const SPFilterPrimitive* prim);
92 static const int size = 24;
94 void set_text_width(const int w);
95 int get_text_width() const;
96 protected:
97 virtual void get_size_vfunc(Gtk::Widget& widget, const Gdk::Rectangle* cell_area,
98 int* x_offset, int* y_offset, int* width, int* height) const;
99 private:
100 // void* should be SPFilterPrimitive*, some weirdness with properties prevents this
101 Glib::Property<void*> _primitive;
102 int _text_width;
103 };
105 class PrimitiveList : public Gtk::TreeView
106 {
107 public:
108 PrimitiveList(FilterEffectsDialog&);
110 Glib::SignalProxy0<void> signal_selection_changed();
112 void update();
113 void set_menu(Glib::RefPtr<Gtk::Menu>);
115 SPFilterPrimitive* get_selected();
116 void select(SPFilterPrimitive *prim);
118 int primitive_count() const;
119 protected:
120 bool on_expose_signal(GdkEventExpose*);
121 bool on_button_press_event(GdkEventButton*);
122 bool on_motion_notify_event(GdkEventMotion*);
123 bool on_button_release_event(GdkEventButton*);
124 void on_drag_end(const Glib::RefPtr<Gdk::DragContext>&);
125 private:
126 int init_text();
128 bool do_connection_node(const Gtk::TreeIter& row, const int input, std::vector<Gdk::Point>& points,
129 const int ix, const int iy);
130 const Gtk::TreeIter find_result(const Gtk::TreeIter& start, const SPAttributeEnum attr);
131 int find_index(const Gtk::TreeIter& target);
132 void draw_connection(const Gtk::TreeIter&, const SPAttributeEnum attr, const int text_start_x,
133 const int x1, const int y1, const int row_count);
134 void sanitize_connections(const Gtk::TreeIter& prim_iter);
136 FilterEffectsDialog& _dialog;
137 Glib::RefPtr<Gtk::ListStore> _model;
138 PrimitiveColumns _columns;
139 CellRendererConnection _connection_cell;
140 Glib::RefPtr<Gtk::Menu> _primitive_menu;
141 Glib::RefPtr<Pango::Layout> _vertical_layout;
142 int _in_drag;
143 SPFilterPrimitive* _drag_prim;
144 };
146 FilterEffectsDialog();
147 void init_settings_widgets();
149 // Handlers
150 void add_primitive();
151 void remove_primitive();
152 void duplicate_primitive();
154 void set_attr_color(const SPAttributeEnum attr, const Gtk::ColorButton*);
155 void set_attr_direct(const SPAttributeEnum attr, const AttrWidget*);
156 void set_attr_special(const SPAttributeEnum);
157 void set_attr(const SPAttributeEnum, const gchar* val);
158 void update_settings_view();
159 void update_settings_sensitivity();
161 // Filter effect selection
162 FilterModifier _filter_modifier;
164 // View/add primitives
165 Gtk::VBox _primitive_box;
166 PrimitiveList _primitive_list;
167 UI::Widget::ComboBoxEnum<NR::FilterPrimitiveType> _add_primitive_type;
168 Gtk::Button _add_primitive;
170 // Bottom pane (filter effect primitive settings)
171 Gtk::VBox _settings_box;
172 Gtk::Label _empty_settings;
174 class Settings;
175 class ConvolveMatrix;
176 Settings* _settings;
178 // For controlling setting sensitivity
179 Gtk::Widget* _k1, *_k2, *_k3, *_k4;
181 FilterEffectsDialog(FilterEffectsDialog const &d);
182 FilterEffectsDialog& operator=(FilterEffectsDialog const &d);
183 };
185 } // namespace Dialog
186 } // namespace UI
187 } // namespace Inkscape
189 #endif // INKSCAPE_UI_DIALOG_FILTER_EFFECTS_H
191 /*
192 Local Variables:
193 mode:c++
194 c-file-style:"stroustrup"
195 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
196 indent-tabs-mode:nil
197 fill-column:99
198 End:
199 */
200 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :