Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
selected-style.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Authors:
4 * buliabyak@gmail.com
5 * scislac@users.sf.net
6 *
7 * Copyright (C) 2005 authors
8 *
9 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
10 */
11
12#ifndef SEEN_INKSCAPE_UI_SELECTED_STYLE_H
13#define SEEN_INKSCAPE_UI_SELECTED_STYLE_H
14
15#include <memory>
16#include <vector>
17#include <glibmm/refptr.h>
18#include <gtkmm/box.h>
19#include <gtkmm/enums.h>
20#include <gtkmm/gesture.h> // Gtk::EventSequenceState
21#include <gtkmm/grid.h>
22#include <gtkmm/label.h>
23
24#include "colors/color.h"
25#include <sigc++/scoped_connection.h>
26#include "rotateable.h"
27#include "ui/defocus-target.h"
28#include "ui/popup-menu.h"
31
32namespace Gtk {
33class Adjustment;
34class GestureClick;
35class CheckButton;
36} // namespace Gtk
37
38class SPDesktop;
39
40namespace Inkscape {
41
42namespace Util {
43class Unit;
44} // namespace Util
45
46namespace UI::Widget {
47
48class PopoverMenu;
49class PopoverMenuItem;
50
63
68
69class ColorPreview;
70class GradientImage;
71class SelectedStyle;
72class SelectedStyleDropTracker;
73
75 public:
78
79 std::pair<double, double> color_adjust(Colors::Color const &cc, double by, guint state);
80
81 void do_motion (double by, guint state) override;
82 void do_release (double by, guint state) override;
83 void do_scroll (double by, guint state) override;
84
85private:
87
89
90 std::optional<Colors::Color> startcolor;
91
92 gchar const *undokey = "ssrot1";
93
94 int cursor_state = -1;
95};
96
98 public:
101
102 double value_adjust(double current, double by, guint modifier, bool final);
103 void do_motion (double by, guint state) override;
104 void do_release (double by, guint state) override;
105 void do_scroll (double by, guint state) override;
106
107private:
109
112
113 gchar const *undokey;
114};
115
121 , private DefocusTarget
122{
123public:
124 bool dragging = false;
126
129 void update();
130
131 std::optional<Colors::Color> _lastselected[2];
132 std::optional<Colors::Color> _thisselected[2];
133
134 guint _mode[2];
135
137 Inkscape::Util::Unit const *_sw_unit = nullptr; // points to object in UnitTable, do not delete
138
139protected:
140 SPDesktop *_desktop = nullptr;
141
142 // Widgets
143 Gtk::Grid *grid;
144
145 Gtk::Label *label[2]; // 'Fill' and 'Stroke'
146 Gtk::Label *tag[2]; // 'a', 'm', or empty.
147
148 std::unique_ptr<Gtk::Label> type_label[2]; // 'L', 'R', 'M', or empty.
149 std::unique_ptr<GradientImage> gradient_preview[2];
150 std::unique_ptr<ColorPreview> color_preview[2];
151 RotateableSwatch *swatch[2]; // // Wraps one or two of: "type_label", "gradient_preview", "color_preview"
152
153 Gtk::Label *stroke_width; // Stroke width
155
156 Gtk::Label *opacity_label;
157 Glib::RefPtr<Gtk::Adjustment> opacity_adjustment;
159
160 Glib::ustring _paintserver_id[2];
161
162 // Signals
163 sigc::scoped_connection selection_changed_connection;
164 sigc::scoped_connection selection_modified_connection;
165
166 Gtk::EventSequenceState on_fill_click (Gtk::GestureClick const &click,
167 int n_press, double x, double y);
168 Gtk::EventSequenceState on_stroke_click (Gtk::GestureClick const &click,
169 int n_press, double x, double y);
170 Gtk::EventSequenceState on_opacity_click(Gtk::GestureClick const &click,
171 int n_press, double x, double y);
172 Gtk::EventSequenceState on_sw_click (Gtk::GestureClick const &click,
173 int n_press, double x, double y);
174
175 bool _opacity_blocked = false;
176
177 std::unique_ptr<UI::Widget::PopoverMenu> _popup_opacity;
178 void make_popup_opacity();
179 void on_opacity_changed();
181 void opacity_0();
182 void opacity_025();
183 void opacity_05();
184 void opacity_075();
185 void opacity_1();
186
187 void on_fill_remove();
188 void on_stroke_remove();
189 void on_fill_lastused();
190 void on_stroke_lastused();
193 void on_fill_unset();
194 void on_stroke_unset();
195 void on_fill_edit();
196 void on_stroke_edit();
197 void on_fillstroke_swap();
198 void on_fill_invert();
199 void on_stroke_invert();
200 void on_fill_white();
201 void on_stroke_white();
202 void on_fill_black();
203 void on_stroke_black();
204 void on_fill_copy();
205 void on_stroke_copy();
206 void on_fill_paste();
207 void on_stroke_paste();
208 void on_fill_opaque();
209 void on_stroke_opaque();
210 void _on_paste_callback(Glib::RefPtr<Gio::AsyncResult> &result, Glib::ustring typepaste);
211
212 std::unique_ptr<UI::Widget::PopoverMenu> _popup[2];
214 void make_popup(FillOrStroke i);
215
216 std::unique_ptr<UI::Widget::PopoverMenu> _popup_sw;
217 std::vector<Gtk::CheckButton *> _unit_mis;
218 void make_popup_units();
220 void on_popup_preset(int i);
221
222 std::unique_ptr<SelectedStyleDropTracker> drop[2];
223 bool dropEnabled[2] = {false, false};
224
225private:
226 void onDefocus() override;
227};
228
229} // namespace UI::Widget
230
231} // namespace Inkscape
232
233#endif // SEEN_INKSCAPE_UI_SELECTED_STYLE_H
234
235/*
236 Local Variables:
237 mode:c++
238 c-file-style:"stroustrup"
239 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
240 indent-tabs-mode:nil
241 fill-column:99
242 End:
243*/
244// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
Interface for objects that would like to be informed when another widget loses focus.
Holds a single child widget while allowing a single popover to be displayed over it.
Definition popover-bin.h:19
A replacement for GTK3ʼs Gtk::MenuItem, as removed in GTK4.
void do_motion(double by, guint state) override
double value_adjust(double current, double by, guint modifier, bool final)
void do_scroll(double by, guint state) override
void do_release(double by, guint state) override
std::optional< Colors::Color > startcolor
void do_motion(double by, guint state) override
void do_release(double by, guint state) override
std::pair< double, double > color_adjust(Colors::Color const &cc, double by, guint state)
void do_scroll(double by, guint state) override
Widget adjustable by dragging it to rotate away from a zero-change axis.
Definition rotateable.h:30
Selected style indicator (fill, stroke, opacity).
UI::Widget::PopoverMenuItem * _popup_copy[2]
void on_popup_units(Inkscape::Util::Unit const *u)
sigc::scoped_connection selection_changed_connection
std::unique_ptr< Gtk::Label > type_label[2]
void setDesktop(SPDesktop *desktop)
Glib::RefPtr< Gtk::Adjustment > opacity_adjustment
std::unique_ptr< ColorPreview > color_preview[2]
Gtk::EventSequenceState on_fill_click(Gtk::GestureClick const &click, int n_press, double x, double y)
std::optional< Colors::Color > _thisselected[2]
RotateableStrokeWidth * stroke_width_rotateable
std::unique_ptr< GradientImage > gradient_preview[2]
bool on_opacity_popup(PopupMenuOptionalClick)
std::optional< Colors::Color > _lastselected[2]
Gtk::EventSequenceState on_stroke_click(Gtk::GestureClick const &click, int n_press, double x, double y)
Gtk::EventSequenceState on_sw_click(Gtk::GestureClick const &click, int n_press, double x, double y)
Inkscape::Util::Unit const * _sw_unit
std::unique_ptr< UI::Widget::PopoverMenu > _popup_sw
std::unique_ptr< UI::Widget::PopoverMenu > _popup[2]
std::unique_ptr< SelectedStyleDropTracker > drop[2]
std::vector< Gtk::CheckButton * > _unit_mis
Inkscape::UI::Widget::SpinButton * opacity_sb
sigc::scoped_connection selection_modified_connection
Gtk::EventSequenceState on_opacity_click(Gtk::GestureClick const &click, int n_press, double x, double y)
std::unique_ptr< UI::Widget::PopoverMenu > _popup_opacity
void _on_paste_callback(Glib::RefPtr< Gio::AsyncResult > &result, Glib::ustring typepaste)
SpinButton widget, that allows entry of simple math expressions (also units, when linked with UnitMen...
Definition spinbutton.h:52
To do: update description of desktop.
Definition desktop.h:149
Css & result
static char const *const current
Definition dir-util.cpp:71
Definition desktop.h:50
std::optional< PopupMenuClick > PopupMenuOptionalClick
Optional: not present if popup wasnʼt triggered by click.
Definition popup-menu.h:41
Miscellaneous supporting code.
Definition document.h:93
Helper class to stream background task notifications as a series of messages.
int mode
Helpers to connect signals to events that popup a menu in both GTK3 and GTK4.
SPDesktop * desktop