15#include <glibmm/i18n.h>
17#include <gdk/gdkkeysyms.h>
57 area->set_stroke(0x0000007f);
59 area->set_visible(
false);
63 if (prefs->getBool(
"/tools/dropper/selcue")) {
67 if (prefs->getBool(
"/tools/dropper/gradientdrag")) {
94 int pick = prefs->getInt(
"/tools/dropper/pick",
PICK_VISIBLE);
95 bool setalpha = prefs->getBool(
"/tools/dropper/setalpha",
true);
105 color->enableOpacity(
false);
113 int pick = prefs->getInt(
"/tools/dropper/pick",
PICK_VISIBLE);
116 auto modifiers =
event.modifiersAfter();
117 stroke = modifiers & GDK_SHIFT_MASK;
118 dropping = modifiers & GDK_CONTROL_MASK;
119 invert = modifiers & GDK_ALT_MASK;
128 std::optional<Inkscape::Colors::Color> apply_color;
129 for (
auto const &obj: selection->objects()) {
131 if (!
stroke && obj->style->fill.set) {
132 apply_color = obj->style->fill.getColor();
133 apply_color->addOpacity(obj->style->fill_opacity);
134 }
else if (
stroke && obj->style->stroke.set) {
135 apply_color = obj->style->stroke.getColor();
136 apply_color->addOpacity(obj->style->stroke_opacity);
151 bool self_destroyed =
false;
155 if (event.num_press != 1) {
159 if (event.button == 1) {
173 if (event.
modifiers & (GDK_BUTTON2_MASK | GDK_BUTTON3_MASK)) {
184 double rw = std::min((event.pos -
centre).length(), 400.0);
192 auto const scale = rw * w2dt.descrim();
198 area->set_bpath(std::move(path));
199 area->set_visible(
true);
204 if (!r.hasZeroArea()) {
205 pick_area = r.roundOutwards();
236 if (event.button != 1) {
240 area->set_visible(
false);
248 auto old_selection = std::vector<SPItem*>(selection->items().begin(), selection->items().end());
251 auto const button_w =
event.pos;
269 self_destroyed =
true;
282 selection->setList(old_selection);
293 case GDK_KEY_KP_Down:
310 if (self_destroyed) {
320 auto alphastr = g_strdup_printf(_(
" alpha %.3g"), color->getOpacity());
322 auto where =
dragging ? g_strdup_printf(_(
", averaged with radius %d"), (
int)
radius) : g_strdup_printf(
"%s", _(
" under cursor"));
324 auto message =
dragging ? _(
"<b>Release mouse</b> to set color.") : _(
"<b>Click</b> to set fill, <b>Shift+click</b> to set stroke; <b>drag</b> to average color in area; with <b>Alt</b> to pick inverse color; <b>Ctrl+C</b> to copy the color under mouse to clipboard");
328 "<b>%s%s</b>%s. %s", color->toString(
false).c_str(),
337 : (
stroke ?
"dropper-pick-stroke.svg" :
"dropper-pick-fill.svg");
Set of all points at a fixed distance from the center.
Axis aligned, non-empty, generic rectangle.
static CRect from_xywh(C x, C y, C w, C h)
Create rectangle from origin and dimensions.
Sequence of contiguous curves, aka spline.
Axis aligned, non-empty rectangle.
Inkscape::Drawing * get_drawing()
Color composed(Color const &other) const
Return the composition of this color, plus the other color on top.
static void done(SPDocument *document, Glib::ustring const &event_description, Glib::ustring const &undo_icon, unsigned int object_modified_tag=0)
Colors::Color averageColor(Geom::IntRect const &area) const
void setF(MessageType type, char const *format,...) G_GNUC_PRINTF(3
pushes a message on the stack using prinf-style formatting, and replacing our old message
void clear()
Unselects all selected objects.
bool isEmpty()
Returns true if no items are selected.
Colors::Color const & getDefaultBackgroundColor() const
static Preferences * get()
Access the singleton Preferences object.
To do: update description of desktop.
Inkscape::UI::Widget::Canvas * getCanvas() const
Inkscape::CanvasItemGroup * getCanvasControls() const
SPDocument * getDocument() const
Inkscape::CanvasItemDrawing * getCanvasDrawing() const
Inkscape::Selection * getSelection() const
Geom::Affine const & w2d() const
Transformation from window to desktop coordinates (zoom/rotate).
Inkscape::PageManager & getPageManager()
void sp_desktop_set_color(SPDesktop *desktop, Color const &color, bool is_relative, bool fill)
Set color on selection on desktop.
Editable view implementation.
TODO: insert short description here.
Macro for icon names used in Inkscape.
Interface for locally managing a current status message.
void inspect_event(E &&event, Fs... funcs)
Perform pattern-matching on a CanvasEvent.
bool mod_ctrl_only(unsigned modifiers)
void set_svg_cursor(Gtk::Widget &widget, std::string const &file_name, std::optional< Colors::Color > fill, std::optional< Colors::Color > stroke)
Loads an SVG cursor from the specified file name, and sets it as the cursor of the given widget.
Singleton class to access the preferences file in a convenient way.
void invert(const double v[16], double alpha[16])
Abstract base class for events.
unsigned modifiers
The modifiers mask immediately before the event.
Movement of the mouse pointer.
SPStyle - a style object for SPItem objects.