selected-style.cpp revision 9579e803693f47a266cc99cd239d183110078fe8
#ifdef HAVE_CONFIG_H
# include <config.h>
#include "selected-style.h"
#include "widgets/spw-utilities.h"
#include "ui/widget/color-preview.h"
#include "selection.h"
#include "desktop-handles.h"
#include "style.h"
#include "desktop-style.h"
#include "sp-linear-gradient-fns.h"
#include "sp-radial-gradient-fns.h"
#include "sp-pattern.h"
#include "ui/dialog/dialog-manager.h"
#include "ui/dialog/fill-and-stroke.h"
#include "ui/dialog/panel-dialog.h"
#include "document.h"
#include "document-undo.h"
#include "widgets/widget-sizes.h"
#include "widgets/spinbutton-events.h"
#include "widgets/gradient-image.h"
#include "sp-gradient.h"
#include "svg/svg-color.h"
#include "svg/css-ostringstream.h"
#include "event-context.h"
#include "message-context.h"
#include "verbs.h"
#include "color.h"
#include "pixmaps/cursor-adj-h.xpm"
#include "pixmaps/cursor-adj-s.xpm"
#include "pixmaps/cursor-adj-l.xpm"
#include "sp-cursor.h"
static gdouble const _sw_presets[] = { 32 , 16 , 10 , 8 , 6 , 4 , 3 , 2 , 1.5 , 1 , 0.75 , 0.5 , 0.25 , 0.1 };
static gchar const *const _sw_presets_str[] = {"32", "16", "10", "8", "6", "4", "3", "2", "1.5", "1", "0.75", "0.5", "0.25", "0.1"};
namespace Inkscape {
namespace UI {
namespace Widget {
int item;
} DropTracker;
#define ENTRIES_SIZE(n) sizeof(n)/sizeof(n[0])
_fill_flag_place (),
_opacity_place (),
#if WITH_GTKMM_3_0
_stroke (),
_stroke_width_place(this),
_opacity_blocked (false),
__none[i] = (i == SS_FILL)? (C_("Fill and stroke", "No fill")) : (C_("Fill and stroke", "No stroke"));
__averaged[i] = (i == SS_FILL)? (_("Fill is averaged over selected objects")) : (_("Stroke is averaged over selected objects"));
__multiple[i] = (i == SS_FILL)? (_("Multiple selected objects have the same fill")) : (_("Multiple selected objects have the same stroke"));
_popup_edit[i].add(*(new Gtk::Label((i == SS_FILL)? _("Edit fill...") : _("Edit stroke..."), 0.0, 0.5)));
_popup_opaque[i].add(*(new Gtk::Label((i == SS_FILL)? _("Make fill opaque") : _("Make stroke opaque"), 0.0, 0.5)));
_popup_unset[i].add(*(new Gtk::Label((i == SS_FILL)? _("Unset fill") : _("Unset stroke"), 0.0, 0.5)));
_popup_remove[i].add(*(new Gtk::Label((i == SS_FILL)? _("Remove fill") : _("Remove stroke"), 0.0, 0.5)));
mi->signal_activate().connect(sigc::bind<int>(sigc::mem_fun(*this, &SelectedStyle::on_popup_preset), i));
_fill_place.signal_button_release_event().connect(sigc::mem_fun(*this, &SelectedStyle::on_fill_click));
_stroke_place.signal_button_release_event().connect(sigc::mem_fun(*this, &SelectedStyle::on_stroke_click));
_opacity_place.signal_button_press_event().connect(sigc::mem_fun(*this, &SelectedStyle::on_opacity_click));
_stroke_width_place.signal_button_press_event().connect(sigc::mem_fun(*this, &SelectedStyle::on_sw_click));
_opacity_sb.signal_value_changed().connect(sigc::mem_fun(*this, &SelectedStyle::on_opacity_changed));
// Connect to key-press to ensure focus is consistent with other spin buttons when using the keys vs mouse-click
g_signal_connect (G_OBJECT (_opacity_sb.gobj()), "key-press-event", G_CALLBACK (spinbutton_keypress), _opacity_sb.gobj());
delete selection_changed_connection;
delete selection_modified_connection;
delete subselection_changed_connection;
delete _color_preview[i];
case SS_FILL:
case SS_STROKE:
sp_svg_write_color( c, sizeof(c),
sp_svg_write_color (c, sizeof(c),
sp_svg_write_color (c, sizeof(c),
text += c;
text += c;
guint32 color = sp_svg_read_color(text.c_str(), 0x000000ff); // impossible value, as SVG color cannot have opacity
guint32 color = sp_svg_read_color(text.c_str(), 0x000000ff); // impossible value, as SVG color cannot have opacity
case SS_NA:
case SS_MANY:
case SS_NONE:
case SS_UNSET:
case SS_COLOR:
case SS_LGRADIENT:
case SS_RGRADIENT:
case SS_PATTERN:
case SS_NA:
case SS_MANY:
case SS_NONE:
case SS_UNSET:
case SS_COLOR:
case SS_LGRADIENT:
case SS_RGRADIENT:
case SS_PATTERN:
const char* opacity = _opacity_sb.get_value() < 50? "0.5" : (_opacity_sb.get_value() == 100? "0" : "1");
update();
update();
update();
gdouble w;
if (_sw_unit) {
w = _sw_presets[i];
os << w;
// query style from desktop. This returns a result flag and fills query with the style of subselection, if any, or selection
switch (result) {
case QUERY_STYLE_NOTHING:
if ( _dropEnabled[i] ) {
_dropEnabled[i] = false;
case QUERY_STYLE_SINGLE:
if ( !_dropEnabled[i] ) {
_dropEnabled[i] = true;
if (i == SS_FILL) {
SPPaintServer *server = (i == SS_FILL)? SP_STYLE_FILL_SERVER (query) : SP_STYLE_STROKE_SERVER (query);
if ( server ) {
switch (result) {
case QUERY_STYLE_NOTHING:
case QUERY_STYLE_SINGLE:
if (_opacity_blocked) break;
_opacity_blocked = true;
#if WITH_GTKMM_3_0
_opacity_blocked = false;
switch (result_sw) {
case QUERY_STYLE_NOTHING:
current_stroke_width = 0;
case QUERY_STYLE_SINGLE:
if (_sw_unit) {
current_stroke_width = w;
for (Glib::ListHandle<Gtk::Widget *>::iterator iter = children.begin(); iter != children.end(); ++iter) {
if (_opacity_blocked)
_opacity_blocked = true;
#if WITH_GTKMM_3_0
DocumentUndo::maybeDone(sp_desktop_document(_desktop), "fillstroke:opacity", SP_VERB_DIALOG_FILL_STROKE,
_opacity_blocked = false;
startcolor(0),
startcolor_set(false),
cr(0),
cr_set(false)
double diff = 0;
if (by > 0) {
if (by > 0) {
while (hsl[0] < 0)
sp_svg_write_color (c, sizeof(c),
return diff;
cr_set = true;
if (!startcolor_set) {
startcolor_set = true;
double diff = 0;
parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting <b>saturation</b>: was %.3g, now <b>%.3g</b> (diff %.3g); with <b>Ctrl</b> to adjust lightness, without modifiers to adjust hue"), ch - diff, ch, diff);
parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting <b>lightness</b>: was %.3g, now <b>%.3g</b> (diff %.3g); with <b>Shift</b> to adjust saturation, without modifiers to adjust hue"), ch - diff, ch, diff);
parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting <b>hue</b>: was %.3g, now <b>%.3g</b> (diff %.3g); with <b>Shift</b> to adjust saturation, with <b>Ctrl</b> to adjust lightness"), ch - diff, ch, diff);
if (cr_set) {
if (cr) {
cr_set = false;
startcolor_set = false;
startvalue(0),
startvalue_set(false),
cr(0),
cr_set(false)
double newval;
if (by < 0) {
if (!startvalue_set) {
if (startvalue == 0)
startvalue_set = true;
parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting <b>stroke width</b>: was %.3g, now <b>%.3g</b> (diff %.3g)"), startvalue, startvalue + diff, diff);
startvalue_set = false;
return &fill_and_stroke;