Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
effect.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Authors:
4 * Ted Gould <ted@gould.cx>
5 *
6 * Copyright (C) 2002-2004 Authors
7 *
8 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
9 */
10
11
12#ifndef INKSCAPE_EXTENSION_EFFECT_H__
13#define INKSCAPE_EXTENSION_EFFECT_H__
14
15#include <glibmm/ustring.h>
16#include <list>
17
18#include <glibmm/i18n.h>
19#include <string>
20#include "extension.h"
22
23namespace Gtk {
24 class Box;
25}
26
27class SPDocument;
28
29namespace Inkscape {
30
31
32namespace Extension {
33class PrefDialog;
34
39class Effect : public Extension {
43
44 Inkscape::XML::Node *find_menu (Inkscape::XML::Node * menustruct, const gchar *name);
45 void get_menu(Inkscape::XML::Node * pattern, std::list<Glib::ustring>& sub_menu_list) const;
46
49
52
53public:
54 Effect(Inkscape::XML::Node *in_repr, ImplementationHolder implementation, std::string *base_directory, std::string* file_name);
55 ~Effect() override;
56
57 bool prefs(SPDesktop * desktop);
58 void effect(SPDesktop *desktop, SPDocument *document = nullptr);
59
61 bool _workingDialog = true;
62
64 bool ignore_stderr = false;
65
67 bool pipe_diffs = false;
68
70 static Effect * get_last_effect () { return _last_effect; };
71 static void set_last_effect (Effect * in_effect);
72
73 static void place_menus ();
75
76 Gtk::Box * get_info_widget();
77
78 bool no_doc; // if true, the effect does not process SVG document at all, so no need to save, read, and watch for errors
79 bool no_live_preview; // if true, the effect does not need "live preview" checkbox in its dialog
80
82 void set_pref_dialog (PrefDialog * prefdialog);
83
84 void deactivate() override;
85
86 // try to locate SVG thumbnail for this effect and return its path; empty string if not found;
87 // use "default_dir" for effects created from memory, as they don't know their location
88 std::string find_icon_file(const std::string& default_dir) const;
89
90 // returns true if this extension presents input dialog before taking effect
91 // or false for immediate action (no UI)
92 bool takes_input() const;
93
94 // returns true if this effect should not be presented in the UI main menu
95 bool hidden_from_menu() const;
96
97 // returns true if this extension is a filter effect
98 bool is_filter_effect() const;
99
100 // get effect's menu tip
101 const Glib::ustring& get_menu_tip() const;
102
103 // get effect's ID sanitized to alphanumeric ASCII charaters
104 std::string get_sanitized_id() const;
105
106 // get local effect menu
107 std::list<Glib::ustring> get_menu_list() const;
108
109 // apply filter effect to 'item'
110 bool apply_filter(SPItem* item);
111
112private:
113 std::string _file_name; // extension file name, if provided
114 bool _hidden_from_menu = false;
115 bool _filter_effect = false;
116 Glib::ustring _menu_tip;
118 std::string _icon_path;
119
120 static gchar * remove_ (gchar * instr);
121 static void _sanitizeId(std::string &id);
122};
123
124} } /* namespace Inkscape, Extension */
125#endif /* INKSCAPE_EXTENSION_EFFECT_H__ */
126
127/*
128 Local Variables:
129 mode:c++
130 c-file-style:"stroustrup"
131 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
132 indent-tabs-mode:nil
133 fill-column:99
134 End:
135*/
136// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
Effects are extensions that take a document and do something to it in place.
Definition effect.h:39
bool ignore_stderr
If stderr log should be shown, when process return code is 0.
Definition effect.h:64
void set_pref_dialog(PrefDialog *prefdialog)
Definition effect.cpp:310
Glib::ustring _menu_tip
Definition effect.h:116
PrefDialog * _prefDialog
The preference dialog if it is shown.
Definition effect.h:51
static gchar * remove_(gchar *instr)
static void set_last_effect(Effect *in_effect)
Sets which effect was called last.
Definition effect.cpp:267
void get_menu(Inkscape::XML::Node *pattern, std::list< Glib::ustring > &sub_menu_list) const
Definition effect.cpp:145
bool hidden_from_menu() const
Definition effect.cpp:353
void deactivate() override
This function diactivates the extension (which makes it unusable, but not deleted)
Definition effect.cpp:174
Inkscape::XML::Node * _menu_node
Menu node created for this effect.
Definition effect.h:48
Inkscape::XML::Node * find_menu(Inkscape::XML::Node *menustruct, const gchar *name)
Definition effect.cpp:276
Inkscape::XML::Node * _local_effects_menu
Definition effect.h:117
PrefDialog * get_pref_dialog()
Definition effect.cpp:304
std::string find_icon_file(const std::string &default_dir) const
Definition effect.cpp:320
const Glib::ustring & get_menu_tip() const
Definition effect.cpp:365
bool pipe_diffs
If changesets should be piped in via stdin.
Definition effect.h:67
void place_menu(Inkscape::XML::Node *menus)
static Effect * get_last_effect()
Static function to get the last effect used.
Definition effect.h:70
bool apply_filter(SPItem *item)
Definition effect.cpp:380
bool is_filter_effect() const
Definition effect.cpp:361
static Effect * _last_effect
This is the last effect that was used.
Definition effect.h:42
std::string get_sanitized_id() const
Sanitizes the id and returns.
Definition effect.cpp:114
std::list< Glib::ustring > get_menu_list() const
Definition effect.cpp:369
void effect(SPDesktop *desktop, SPDocument *document=nullptr)
The function that 'does' the effect itself.
Definition effect.cpp:233
Gtk::Box * get_info_widget()
Definition effect.cpp:298
bool _workingDialog
Whether a working dialog should be shown.
Definition effect.h:61
static void _sanitizeId(std::string &id)
The object that is the basis for the Extension system.
Definition extension.h:133
virtual bool prefs()
Create a dialog for preference for this extension.
A class to represent the preferences for an extension.
Definition prefdialog.h:31
Interface for refcounted XML nodes.
Definition node.h:80
To do: update description of desktop.
Definition desktop.h:149
Typed SVG document implementation.
Definition document.h:103
Base class for visual SVG elements.
Definition sp-item.h:109
Inkscape::Extension::Extension: Frontend to certain, possibly pluggable, actions.
SPItem * item
Definition desktop.h:50
Helper class to stream background task notifications as a series of messages.
SPDesktop * desktop
Glib::ustring name
Definition toolbars.cpp:55