Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
filter-effects-dialog.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
5/* Authors:
6 * Nicholas Bishop <nicholasbishop@gmail.org>
7 * Rodrigo Kumpera <kumpera@gmail.com>
8 * Felipe C. da S. Sanches <juca@members.fsf.org>
9 * Jon A. Cruz <jon@joncruz.org>
10 * Abhishek Sharma
11 * insaner
12 *
13 * Copyright (C) 2007 Authors
14 *
15 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
16 */
17
18#ifndef INKSCAPE_UI_DIALOG_FILTER_EFFECTS_H
19#define INKSCAPE_UI_DIALOG_FILTER_EFFECTS_H
20
21#include <glibmm/property.h>
22#include <gtkmm/gesture.h> // Gtk::EventSequenceState
23#include <gtkmm/label.h>
24#include <gtkmm/treeview.h>
25
28#include "ui/widget/bin.h"
33#include "xml/helper-observer.h"
34
35namespace Gdk {
36class Drag;
37} // namespace Gdk
38
39namespace Gtk {
40class Button;
41class CheckButton;
42class DragSource;
43class GestureClick;
44class Grid;
45class Label;
46class ListStore;
47class Paned;
48class ScrolledWindow;
49class ToggleButton;
50} // namespace Gtk
51
52class SPFilter;
54
55namespace Inkscape::UI {
56
57namespace Widget {
58class PopoverMenu;
59} // namespace Widget
60
61namespace Dialog {
62
63class EntryAttr;
64class FileOrElementChooser;
65class DualSpinButton;
66class MultiSpinButton;
67
69{
71
72public:
75
76 void set_attrs_locked(const bool);
77
78private:
79 void documentReplaced() override;
81 void selectionModified(Inkscape::Selection *selection, guint flags) override;
82
83 sigc::scoped_connection _resource_changed;
84
86
87 class FilterModifier : public Gtk::Box
88 {
89 public:
90 FilterModifier(FilterEffectsDialog& d, Glib::RefPtr<Gtk::Builder> builder);
91
92 void update_filters();
94
96 void select_filter(const SPFilter*);
97 void add_filter();
100 bool filters_present() const;
101
102 sigc::signal<void ()>& signal_filter_changed()
103 {
105 }
106 sigc::signal<void ()>& signal_filters_updated() {
108 }
109
110 private:
111 class Columns : public Gtk::TreeModel::ColumnRecord
112 {
113 public:
115 {
116 add(filter);
117 add(label);
118 add(sel);
119 add(count);
120 }
121
122 Gtk::TreeModelColumn<SPFilter*> filter;
123 Gtk::TreeModelColumn<Glib::ustring> label;
124 Gtk::TreeModelColumn<int> sel;
125 Gtk::TreeModelColumn<int> count;
126 };
127
128 std::unique_ptr<UI::Widget::PopoverMenu> create_menu();
130 void on_name_edited(const Glib::ustring&, const Glib::ustring&);
131 void on_selection_toggled(const Glib::ustring&);
132 void selection_toggled(Gtk::TreeModel::iterator iter, bool toggle);
133
134 void update_counts();
135 Gtk::EventSequenceState filter_list_click_released(Gtk::GestureClick const &click,
136 int n_press, double x, double y);
137 void remove_filter();
138 void duplicate_filter();
139 void rename_filter();
141
142 Glib::RefPtr<Gtk::Builder> _builder;
144 Gtk::TreeView& _list;
145 Glib::RefPtr<Gtk::ListStore> _filters_model;
147 Gtk::CellRendererToggle _cell_toggle;
148 Gtk::Button& _add;
149 Gtk::Button& _dup;
150 Gtk::Button& _del;
151 Gtk::Button& _select;
152 std::unique_ptr<UI::Widget::PopoverMenu> _menu;
153 sigc::signal<void ()> _signal_filter_changed;
154 std::unique_ptr<Inkscape::XML::SignalObserver> _observer;
155 sigc::signal<void ()> _signal_filters_updated;
156 };
157
158 class PrimitiveColumns : public Gtk::TreeModel::ColumnRecord
159 {
160 public:
162 {
163 add(primitive);
164 add(type_id);
165 add(type);
166 add(id);
167 }
168
169 Gtk::TreeModelColumn<SPFilterPrimitive*> primitive;
170 Gtk::TreeModelColumn<Inkscape::Filters::FilterPrimitiveType> type_id;
171 Gtk::TreeModelColumn<Glib::ustring> type;
172 Gtk::TreeModelColumn<Glib::ustring> id;
173 };
174
175 class CellRendererConnection : public Gtk::CellRenderer
176 {
177 public:
179 Glib::PropertyProxy<void*> property_primitive();
180
181 static constexpr int size_w = 16;
182 static constexpr int size_h = 21;
183
184 private:
185 void get_preferred_width_vfunc(Gtk::Widget& widget,
186 int& minimum_width,
187 int& natural_width) const override;
188
189 void get_preferred_width_for_height_vfunc(Gtk::Widget& widget,
190 int height,
191 int& minimum_width,
192 int& natural_width) const override;
193
194 void get_preferred_height_vfunc(Gtk::Widget& widget,
195 int& minimum_height,
196 int& natural_height) const override;
197
198 void get_preferred_height_for_width_vfunc(Gtk::Widget& widget,
199 int width,
200 int& minimum_height,
201 int& natural_height) const override;
202
203 // void* should be SPFilterPrimitive*, some weirdness with properties prevents this
204 Glib::Property<void*> _primitive;
205 };
206
209 , public Gtk::TreeView
210 {
211 using parent_type = Gtk::TreeView;
212
213 public:
215
216 sigc::signal<void ()>& signal_primitive_changed();
217
218 void update();
219 void set_menu(sigc::slot<void ()> dup, sigc::slot<void ()> rem);
220
222 void select(SPFilterPrimitive *prim);
223 void remove_selected();
224 int primitive_count() const;
225 int get_input_type_width() const;
226 void set_inputs_count(int count);
227 int get_inputs_count() const;
228
229 private:
230 void snapshot_vfunc(Glib::RefPtr<Gtk::Snapshot> const &snapshot) override;
231 void css_changed(GtkCssStyleChange *change) override;
232
233 void on_drag_end(Glib::RefPtr<Gdk::Drag> const &drag, bool delete_data);
234
235 Gtk::EventSequenceState on_click_pressed (Gtk::GestureClick const &click,
236 int n_press, double x, double y);
237 Gtk::EventSequenceState on_click_released(Gtk::GestureClick const &click,
238 int n_press, double x, double y);
239 void on_motion_motion(double x, double y);
240
241 void init_text();
242
243 bool do_connection_node(const Gtk::TreeModel::iterator& row, const int input,
244 std::vector<Geom::Point> &points,
245 const int ix, const int iy);
246
247 const Gtk::TreeModel::iterator find_result(const Gtk::TreeModel::iterator& start, const SPAttr attr, int& src_id, const int pos);
248 int find_index(const Gtk::TreeModel::iterator& target);
249 void draw_connection(const Cairo::RefPtr<Cairo::Context>& cr,
250 const Gtk::TreeModel::iterator&, const SPAttr attr, const int text_start_x,
251 const int x1, const int y1, const int row_count, const int pos,
252 const Gdk::RGBA fg_color, const Gdk::RGBA mid_color);
253 void sanitize_connections(const Gtk::TreeModel::iterator& prim_iter);
255 bool on_scroll_timeout();
256
258 Glib::RefPtr<Gtk::ListStore> _model;
261 std::unique_ptr<UI::Widget::PopoverMenu> _primitive_menu;
262 Glib::RefPtr<Pango::Layout> _vertical_layout;
263 int _in_drag = 0;
265 sigc::signal<void ()> _signal_primitive_changed;
266 sigc::connection _scroll_connection;
269 std::unique_ptr<Inkscape::XML::SignalObserver> _observer;
273 Gdk::RGBA bg_color{};
274 };
275
277
278 // Handlers
279 void add_primitive();
281 void duplicate_primitive();
283 void image_x_changed();
284 void image_y_changed();
286
290 void set_attr(SPObject*, const SPAttr, const gchar* val);
294 void update_color_matrix();
295 void update_automatic_region(Gtk::CheckButton *btn);
296 void add_effects(Inkscape::UI::Widget::CompletionPopup& popup, bool symbolic);
297
298 Glib::RefPtr<Gtk::Builder> _builder;
301 Gtk::Paned& _paned;
302 Gtk::Grid& _main_grid;
303 Gtk::Box& _params_box;
304 Gtk::Box& _search_box;
306 Gtk::ScrolledWindow& _filter_wnd;
307 bool _narrow_dialog = true;
308 Gtk::ToggleButton *_show_sources = nullptr;
309 Gtk::CheckButton& _cur_filter_btn;
310 sigc::connection _cur_filter_toggle;
311 // View/add primitives
312 Gtk::ScrolledWindow* _primitive_box;
313
315 Gtk::Button _add_primitive;
316
317 // Bottom pane (filter effect primitive settings)
320 Gtk::Label _empty_settings;
322 Gtk::Label* _cur_effect_name;
324
325 class Settings;
326 class MatrixAttr;
327 class ColorMatrixValues;
328 class ComponentTransferValues;
329 class LightSourceControl;
330
331 std::unique_ptr<Settings> _settings;
332 std::unique_ptr<Settings> _filter_general_settings;
333
334 // General settings
335 MultiSpinButton *_region_pos, *_region_size;
336
337 // Color Matrix
338 ColorMatrixValues* _color_matrix_values;
339
340 // Component Transfer
341 ComponentTransferValues* _component_transfer_values;
342
343 // Convolve Matrix
344 MatrixAttr* _convolve_matrix;
345 DualSpinButton* _convolve_order;
346 MultiSpinButton* _convolve_target;
347
348 // Image
349 EntryAttr* _image_x;
350 EntryAttr* _image_y;
351
352 // For controlling setting sensitivity
353 Gtk::Widget* _k1, *_k2, *_k3, *_k4;
354
355 // To prevent unwanted signals
358
359 // These go last since they depend on the prior initialization of
360 // other FilterEffectsDialog members
364};
365
366} // namespace Dialog
367
368} // namespace Inkscape::UI
369
370#endif // INKSCAPE_UI_DIALOG_FILTER_EFFECTS_H
371
372/*
373 Local Variables:
374 mode:c++
375 c-file-style:"stroustrup"
376 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
377 indent-tabs-mode:nil
378 fill-column:99
379 End:
380*/
381// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
SPAttr
Definition attributes.h:27
Bin: widget that can hold one child, useful as a base class of custom widgets.
The set of selected SPObjects for a given document and layer model.
Definition selection.h:80
DialogBase is the base class for the dialog system.
Definition dialog-base.h:40
void get_preferred_width_vfunc(Gtk::Widget &widget, int &minimum_width, int &natural_width) const override
void get_preferred_height_for_width_vfunc(Gtk::Widget &widget, int width, int &minimum_height, int &natural_height) const override
void get_preferred_width_for_height_vfunc(Gtk::Widget &widget, int height, int &minimum_width, int &natural_width) const override
void get_preferred_height_vfunc(Gtk::Widget &widget, int &minimum_height, int &natural_height) const override
void on_name_edited(const Glib::ustring &, const Glib::ustring &)
std::unique_ptr< Inkscape::XML::SignalObserver > _observer
void selection_toggled(Gtk::TreeModel::iterator iter, bool toggle)
Gtk::EventSequenceState filter_list_click_released(Gtk::GestureClick const &click, int n_press, double x, double y)
std::unique_ptr< UI::Widget::PopoverMenu > create_menu()
Gtk::TreeModelColumn< Inkscape::Filters::FilterPrimitiveType > type_id
void css_changed(GtkCssStyleChange *change) override
Called after gtk_widget_css_changed(): when a CSS widget node is validated & style changed.
void set_menu(sigc::slot< void()> dup, sigc::slot< void()> rem)
bool do_connection_node(const Gtk::TreeModel::iterator &row, const int input, std::vector< Geom::Point > &points, const int ix, const int iy)
void on_drag_end(Glib::RefPtr< Gdk::Drag > const &drag, bool delete_data)
void sanitize_connections(const Gtk::TreeModel::iterator &prim_iter)
std::unique_ptr< Inkscape::XML::SignalObserver > _observer
Gtk::EventSequenceState on_click_released(Gtk::GestureClick const &click, int n_press, double x, double y)
Gtk::EventSequenceState on_click_pressed(Gtk::GestureClick const &click, int n_press, double x, double y)
const Gtk::TreeModel::iterator find_result(const Gtk::TreeModel::iterator &start, const SPAttr attr, int &src_id, const int pos)
void draw_connection(const Cairo::RefPtr< Cairo::Context > &cr, const Gtk::TreeModel::iterator &, const SPAttr attr, const int text_start_x, const int x1, const int y1, const int row_count, const int pos, const Gdk::RGBA fg_color, const Gdk::RGBA mid_color)
std::unique_ptr< UI::Widget::PopoverMenu > _primitive_menu
void snapshot_vfunc(Glib::RefPtr< Gtk::Snapshot > const &snapshot) override
void set_attr(SPObject *, const SPAttr, const gchar *val)
std::unique_ptr< Settings > _filter_general_settings
void selectionModified(Inkscape::Selection *selection, guint flags) override
void set_filternode_attr(const UI::Widget::AttrWidget *)
void set_attr_direct(const UI::Widget::AttrWidget *)
void add_filter_primitive(Filters::FilterPrimitiveType type)
void set_child_attr_direct(const UI::Widget::AttrWidget *)
UI::Widget::ComboBoxEnum< Inkscape::Filters::FilterPrimitiveType > _add_primitive_type
void selectionChanged(Inkscape::Selection *selection) override
void add_effects(Inkscape::UI::Widget::CompletionPopup &popup, bool symbolic)
Inkscape::UI::Widget::CompletionPopup _effects_popup
The Bin is a widget that can hold a single child.
Definition bin.h:31
Simplified management of enumerations in the UI as combobox.
Definition combo-enums.h:37
Holds a single child widget while allowing a single popover to be displayed over it.
Definition popover-bin.h:19
A class you can inherit to access GTK4ʼs Widget.css_changed & .focus vfuncs, missing in gtkmm4.
SPObject is an abstract base class of all of the document nodes at the SVG document level.
Definition sp-object.h:160
A base class for all dialogs.
TODO: insert short description here.
Definition desktop.h:50
static constexpr int height
User interface code.
Definition desktop.h:113
TODO: insert short description here.
double width
Glib::RefPtr< Gtk::Builder > builder
A class that can be inherited to access GTK4ʼs Widget.css_changed & .focus vfuncs,...