Inkscape
Vector Graphics Editor
preferences-widget.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
6/*
7 * Authors:
8 * Marco Scholten
9 * Bruno Dilly <bruno.dilly@gmail.com>
10 *
11 * Copyright (C) 2004, 2006, 2007 Authors
12 *
13 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
14 */
15
16#ifndef INKSCAPE_UI_WIDGET_INKSCAPE_PREFERENCES_H
17#define INKSCAPE_UI_WIDGET_INKSCAPE_PREFERENCES_H
18
19#include <cstdint>
20#include <span>
21#include <vector>
22#include <sigc++/signal.h>
23#include <glibmm/refptr.h>
24#include <gtkmm/checkbutton.h>
25#include <gtkmm/comboboxtext.h>
26#include <gtkmm/drawingarea.h>
27#include <gtkmm/grid.h>
28#include <gtkmm/scrolledwindow.h>
29#include <gtkmm/textview.h>
30
32#include "ui/widget/unit-menu.h"
35
36namespace Gtk {
37class Scale;
38} // namespace Gtk
39
40namespace Inkscape::UI::Widget {
41
42class PrefCheckButton : public Gtk::CheckButton
43{
44public:
45 void init(Glib::ustring const &label, Glib::ustring const &prefs_path,
46 bool default_value);
47 // Allow use with the GtkBuilder get_derived_widget
48 PrefCheckButton(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &refGlade, Glib::ustring pref, bool def)
49 : Gtk::CheckButton(cobject)
50 {
51 init("", pref, def);
52 }
53 PrefCheckButton() : Gtk::CheckButton() {};
54 sigc::signal<void (bool)> changed_signal;
55
56private:
57 Glib::ustring _prefs_path;
58 void on_toggled() override;
59};
60
61class PrefRadioButton : public Gtk::CheckButton
62{
63public:
64 void init(Glib::ustring const &label, Glib::ustring const &prefs_path,
65 int int_value, bool default_value, PrefRadioButton* group_member);
66 void init(Glib::ustring const &label, Glib::ustring const &prefs_path,
67 Glib::ustring const &string_value, bool default_value, PrefRadioButton* group_member);
68 sigc::signal<void (bool)> changed_signal;
69
70private:
71 Glib::ustring _prefs_path;
72 Glib::ustring _string_value;
74 enum
75 {
78 };
80 void on_toggled() override;
81};
82
83struct PrefItem { Glib::ustring label; int int_value; Glib::ustring tooltip; bool is_default = false; };
84
85class PrefRadioButtons : public Gtk::Box {
86public:
87 PrefRadioButtons(const std::vector<PrefItem>& buttons, const Glib::ustring& prefs_path);
88};
89
91{
92public:
93 void init(Glib::ustring const &prefs_path,
94 double lower, double upper, double step_increment, double page_increment,
95 double default_value, bool is_int, bool is_percent);
96 sigc::signal<void (double)> changed_signal;
97
98private:
99 Glib::ustring _prefs_path;
102
103 void on_value_changed();
104};
105
107{
108public:
109 PrefSpinUnit() : ScalarUnit("", "") {};
110
111 void init(Glib::ustring const &prefs_path,
112 double lower, double upper, double step_increment,
113 double default_value,
114 UnitType unit_type, Glib::ustring const &default_unit);
115
116private:
117 Glib::ustring _prefs_path;
119 void on_my_value_changed();
120};
121
122class ZoomCorrRuler : public Gtk::DrawingArea {
123public:
124 ZoomCorrRuler(int width = 100, int height = 20);
125 void set_size(int x, int y);
126 void set_unit_conversion(double conv) { _unitconv = conv; }
127
128 int width() { return _min_width + _border*2; }
129
130 static const double textsize;
131 static const double textpadding;
132
133private:
134 void on_draw(Cairo::RefPtr<Cairo::Context> const &cr, int width, int height);
135 void draw_marks(Cairo::RefPtr<Cairo::Context> const &cr, double dist, int major_interval);
136
137 double _unitconv;
142};
143
144class ZoomCorrRulerSlider : public Gtk::Box
145{
146public:
147 ZoomCorrRulerSlider() : Gtk::Box(Gtk::Orientation::VERTICAL) {}
148
149 void init(int ruler_width, int ruler_height, double lower, double upper,
150 double step_increment, double page_increment, double default_value);
151
152private:
155 void on_unit_changed();
156 bool on_mnemonic_activate( bool group_cycling ) override;
157
160 Gtk::Scale* _slider;
162 bool freeze; // used to block recursive updates of slider and spinbutton
163};
164
165class PrefSlider : public Gtk::Box
166{
167public:
168 PrefSlider(bool spin = true) : Gtk::Box(Gtk::Orientation::HORIZONTAL) { _spin = spin; }
169
170 void init(Glib::ustring const &prefs_path,
171 double lower, double upper, double step_increment, double page_increment, double default_value, int digits);
172
173 Gtk::Scale* getSlider() {return _slider;};
175
176private:
179 bool on_mnemonic_activate( bool group_cycling ) override;
180
181 Glib::ustring _prefs_path;
183 bool _spin;
184 Gtk::Scale* _slider = nullptr;
185
186 bool freeze; // used to block recursive updates of slider and spinbutton
187};
188
189class PrefCombo : public Gtk::ComboBoxText
190{
191public:
192 void init(Glib::ustring const &prefs_path,
193 std::span<Glib::ustring const> labels,
194 std::span<int const> values,
195 int default_value);
196
197 void init(Glib::ustring const &prefs_path,
198 std::span<Glib::ustring const> labels,
199 std::span<Glib::ustring const> values,
200 Glib::ustring const &default_value);
201
202private:
203 Glib::ustring _prefs_path;
204 std::vector<int> _values;
205 std::vector<Glib::ustring> _ustr_values;
206 void on_changed() override;
207};
208
209class PrefEntry : public Gtk::Entry
210{
211public:
212 void init(Glib::ustring const &prefs_path, bool mask);
213
214protected:
215 Glib::ustring _prefs_path;
216
217private:
218 void on_changed() override;
219};
220
222{
223 void on_changed() override;
224};
225
226class PrefMultiEntry : public Gtk::ScrolledWindow
227{
228public:
229 void init(Glib::ustring const &prefs_path, int height);
230
231private:
232 Glib::ustring _prefs_path;
233 Gtk::TextView _text;
234 void on_changed();
235};
236
237class PrefEntryButtonHBox : public Gtk::Box
238{
239public:
240 PrefEntryButtonHBox() : Gtk::Box(Gtk::Orientation::HORIZONTAL) {}
241
242 void init(Glib::ustring const &prefs_path,
243 bool mask, Glib::ustring const &default_string);
244
245private:
246 Glib::ustring _prefs_path;
247 Glib::ustring _default_string;
249 Gtk::Entry *relatedEntry;
252 bool on_mnemonic_activate( bool group_cycling ) override;
253};
254
255class PrefEntryFileButtonHBox : public Gtk::Box
256{
257public:
258 PrefEntryFileButtonHBox() : Gtk::Box(Gtk::Orientation::HORIZONTAL) {}
259
260 void init(Glib::ustring const &prefs_path,
261 bool mask);
262
263private:
264 Glib::ustring _prefs_path;
266 Gtk::Entry *relatedEntry;
269 bool on_mnemonic_activate( bool group_cycling ) override;
270};
271
272class PrefOpenFolder : public Gtk::Box {
273 public:
274 PrefOpenFolder() : Gtk::Box(Gtk::Orientation::HORIZONTAL) {}
275
276 void init(Glib::ustring const &entry_string, Glib::ustring const &tooltip);
277
278private:
280 Gtk::Entry *relatedEntry;
282};
283
285{
286public:
287 PrefColorPicker() : ColorPicker("", "", 0, false) {};
288 ~PrefColorPicker() override = default;;
289
290 void init(Glib::ustring const &abel, Glib::ustring const &prefs_path,
291 std::uint32_t default_rgba);
292
293private:
294 Glib::ustring _prefs_path;
295 void on_changed(std::uint32_t rgba) override;
296};
297
298class PrefUnit : public UnitMenu
299{
300public:
301 void init(Glib::ustring const &prefs_path);
302
303private:
304 Glib::ustring _prefs_path;
305 void on_changed() override;
306};
307
308class DialogPage : public Gtk::Grid
309{
310public:
311 DialogPage();
312 void add_line(bool indent, Glib::ustring const &label, Gtk::Widget& widget, Glib::ustring const &suffix, Glib::ustring const &tip, bool expand = true, Gtk::Widget *other_widget = nullptr);
313 void add_group_header(Glib::ustring name, int columns = 1);
314 void add_group_note(Glib::ustring name);
315 void set_tip(Gtk::Widget &widget, Glib::ustring const &tip);
316};
317
318} // namespace Inkscape::UI::Widget
319
320#endif //INKSCAPE_UI_WIDGET_INKSCAPE_PREFERENCES_H
321
322/*
323 Local Variables:
324 mode:c++
325 c-file-style:"stroustrup"
326 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
327 indent-tabs-mode:nil
328 fill-column:99
329 End:
330*/
331// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
void add_group_note(Glib::ustring name)
void add_group_header(Glib::ustring name, int columns=1)
void add_line(bool indent, Glib::ustring const &label, Gtk::Widget &widget, Glib::ustring const &suffix, Glib::ustring const &tip, bool expand=true, Gtk::Widget *other_widget=nullptr)
Add a widget to the bottom row of the dialog page.
void set_tip(Gtk::Widget &widget, Glib::ustring const &tip)
void init(Glib::ustring const &label, Glib::ustring const &prefs_path, bool default_value)
sigc::signal< void(bool)> changed_signal
PrefCheckButton(BaseObjectType *cobject, const Glib::RefPtr< Gtk::Builder > &refGlade, Glib::ustring pref, bool def)
void on_changed(std::uint32_t rgba) override
void init(Glib::ustring const &abel, Glib::ustring const &prefs_path, std::uint32_t default_rgba)
void init(Glib::ustring const &prefs_path, std::span< Glib::ustring const > labels, std::span< int const > values, int default_value)
std::vector< Glib::ustring > _ustr_values
string key values used optionally instead of numeric _values
bool on_mnemonic_activate(bool group_cycling) override
void init(Glib::ustring const &prefs_path, bool mask, Glib::ustring const &default_string)
bool on_mnemonic_activate(bool group_cycling) override
void init(Glib::ustring const &prefs_path, bool mask)
void init(Glib::ustring const &prefs_path, bool mask)
void init(Glib::ustring const &prefs_path, int height)
void init(Glib::ustring const &entry_string, Glib::ustring const &tooltip)
sigc::signal< void(bool)> changed_signal
void init(Glib::ustring const &label, Glib::ustring const &prefs_path, int int_value, bool default_value, PrefRadioButton *group_member)
PrefRadioButtons(const std::vector< PrefItem > &buttons, const Glib::ustring &prefs_path)
void init(Glib::ustring const &prefs_path, double lower, double upper, double step_increment, double page_increment, double default_value, int digits)
Inkscape::UI::Widget::SpinButton * getSpinButton()
bool on_mnemonic_activate(bool group_cycling) override
Inkscape::UI::Widget::SpinButton * _sb
sigc::signal< void(double)> changed_signal
void init(Glib::ustring const &prefs_path, double lower, double upper, double step_increment, double page_increment, double default_value, bool is_int, bool is_percent)
void init(Glib::ustring const &prefs_path, double lower, double upper, double step_increment, double default_value, UnitType unit_type, Glib::ustring const &default_unit)
void init(Glib::ustring const &prefs_path)
A labelled text box, with spin buttons and optional icon, for entering the values of various unit typ...
Definition: scalar-unit.h:35
SpinButton widget, that allows entry of simple math expressions (also units, when linked with UnitMen...
Definition: spinbutton.h:49
A drop down menu for choosing unit types.
Definition: unit-menu.h:31
bool on_mnemonic_activate(bool group_cycling) override
Inkscape::UI::Widget::SpinButton * _sb
void init(int ruler_width, int ruler_height, double lower, double upper, double step_increment, double page_increment, double default_value)
ZoomCorrRuler(int width=100, int height=20)
void draw_marks(Cairo::RefPtr< Cairo::Context > const &cr, double dist, int major_interval)
void on_draw(Cairo::RefPtr< Cairo::Context > const &cr, int width, int height)
Color picker button and window.
static Glib::ustring const prefs_path
double dist(const Point &a, const Point &b)
Definition: geometry.cpp:310
Definition: desktop.h:51
Button
helper to stop accidents on int vs gtkmm3's weak=typed enums, & looks nicer!
Definition: controller.h:70
Custom widgets.
Definition: desktop.h:127
static constexpr int height