54
55
#include "widgets/spw-utilities.h"
55
56
#include "xml/repr.h"
57
#include "widgets/stroke-style.h"
58
#include "stroke-style.h"
59
#include "fill-n-stroke-factory.h"
63
GtkWidget *createStyleWidgetS( FillOrStroke kind );
68
// These can be deleted once we sort out the libart dependence.
70
#define ART_WIND_RULE_NONZERO 0
62
static void sp_stroke_style_paint_selection_modified (SPWidget *spw, Inkscape::Selection *selection, guint flags, SPPaintSelector *psel);
63
static void sp_stroke_style_paint_selection_changed (SPWidget *spw, Inkscape::Selection *selection, SPPaintSelector *psel);
64
static void sp_stroke_style_paint_update(SPWidget *spw);
66
static void sp_stroke_style_paint_mode_changed(SPPaintSelector *psel, SPPaintSelector::Mode mode, SPWidget *spw);
67
static void sp_stroke_style_paint_dragged(SPPaintSelector *psel, SPWidget *spw);
68
static void sp_stroke_style_paint_changed(SPPaintSelector *psel, SPWidget *spw);
70
static void sp_stroke_style_widget_change_subselection ( Inkscape::Application *inkscape, SPDesktop *desktop, SPWidget *spw );
71
static void sp_stroke_style_widget_transientize_callback(Inkscape::Application *inkscape,
74
static void fillnstroke_constructed(SPWidget *spw, SPPaintSelector *psel);
75
static void fillnstroke_fillrule_changed(SPPaintSelector *psel, SPPaintSelector::FillRule mode, SPWidget *spw);
77
static void fillnstroke_selection_modified(SPWidget *spw, Inkscape::Selection *selection, guint flags, SPPaintSelector *psel);
78
static void fillnstroke_selection_changed(SPWidget *spw, Inkscape::Selection *selection, SPPaintSelector *psel);
79
static void fillnstroke_subselection_changed(Inkscape::Application *inkscape, SPDesktop *desktop, SPWidget *spw);
81
static void fillnstroke_paint_mode_changed(SPPaintSelector *psel, SPPaintSelector::Mode mode, SPWidget *spw);
82
static void fillnstroke_paint_dragged(SPPaintSelector *psel, SPWidget *spw);
83
static void fillnstroke_paint_changed(SPPaintSelector *psel, SPWidget *spw);
85
static void fillnstroke_transientize_called(Inkscape::Application *inkscape, SPDesktop *desktop, SPWidget *spw);
87
static void fillnstroke_performUpdate(SPWidget *spw);
75
89
/** Marker selection option menus */
76
90
static Gtk::OptionMenu * marker_start_menu = NULL;
87
101
static Inkscape::UI::Cache::SvgPreview svg_preview_cache;
103
GtkWidget *sp_stroke_style_paint_widget_new(void)
105
return Inkscape::Widgets::createStyleWidgetS( STROKE );
90
* Create the stroke style widget, and hook up all the signals.
109
* Create the fill or stroke style widget, and hook up all the signals.
93
sp_stroke_style_paint_widget_new(void)
111
GtkWidget *Inkscape::Widgets::createStyleWidgetS( FillOrStroke kind )
95
GtkWidget *spw, *psel;
97
spw = sp_widget_new_global(INKSCAPE);
99
psel = sp_paint_selector_new(false); // without fillrule selector
113
GtkWidget *spw = sp_widget_new_global(INKSCAPE);
115
// with or without fillrule selector
116
GtkWidget *psel = sp_paint_selector_new(kind == FILL);
100
117
gtk_widget_show(psel);
101
118
gtk_container_add(GTK_CONTAINER(spw), psel);
102
gtk_object_set_data(GTK_OBJECT(spw), "paint-selector", psel);
104
gtk_signal_connect(GTK_OBJECT(spw), "modify_selection",
105
GTK_SIGNAL_FUNC(sp_stroke_style_paint_selection_modified),
107
gtk_signal_connect(GTK_OBJECT(spw), "change_selection",
108
GTK_SIGNAL_FUNC(sp_stroke_style_paint_selection_changed),
111
g_signal_connect (INKSCAPE, "change_subselection", G_CALLBACK (sp_stroke_style_widget_change_subselection), spw);
113
g_signal_connect (G_OBJECT(INKSCAPE), "activate_desktop", G_CALLBACK (sp_stroke_style_widget_transientize_callback), spw );
115
gtk_signal_connect(GTK_OBJECT(psel), "mode_changed",
116
GTK_SIGNAL_FUNC(sp_stroke_style_paint_mode_changed),
118
gtk_signal_connect(GTK_OBJECT(psel), "dragged",
119
GTK_SIGNAL_FUNC(sp_stroke_style_paint_dragged),
121
gtk_signal_connect(GTK_OBJECT(psel), "changed",
122
GTK_SIGNAL_FUNC(sp_stroke_style_paint_changed),
125
sp_stroke_style_paint_update (SP_WIDGET(spw));
119
g_object_set_data(G_OBJECT(spw), "paint-selector", psel);
120
g_object_set_data(G_OBJECT(spw), "kind", GINT_TO_POINTER(kind));
123
g_signal_connect( G_OBJECT(spw), "construct",
124
G_CALLBACK(fillnstroke_constructed),
128
//FIXME: switch these from spw signals to global inkscape object signals; spw just retranslates
129
//those anyway; then eliminate spw
130
g_signal_connect( G_OBJECT(spw), "modify_selection",
131
G_CALLBACK(fillnstroke_selection_modified),
134
g_signal_connect( G_OBJECT(spw), "change_selection",
135
G_CALLBACK(fillnstroke_selection_changed),
138
g_signal_connect( INKSCAPE, "change_subselection",
139
G_CALLBACK(fillnstroke_subselection_changed),
142
if (kind == STROKE) {
143
g_signal_connect( G_OBJECT(INKSCAPE), "activate_desktop",
144
G_CALLBACK(fillnstroke_transientize_called),
148
g_signal_connect( G_OBJECT(psel), "mode_changed",
149
G_CALLBACK(fillnstroke_paint_mode_changed),
152
g_signal_connect( G_OBJECT(psel), "dragged",
153
G_CALLBACK(fillnstroke_paint_dragged),
156
g_signal_connect( G_OBJECT(psel), "changed",
157
G_CALLBACK(fillnstroke_paint_changed),
161
g_signal_connect( G_OBJECT(psel), "fillrule_changed",
162
G_CALLBACK(fillnstroke_fillrule_changed),
166
fillnstroke_performUpdate(SP_WIDGET(spw));
171
static void fillnstroke_constructed( SPWidget *spw, SPPaintSelector * /*psel*/ )
174
FillOrStroke kind = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(spw), "kind")) ? FILL : STROKE;
175
g_print( "[%s] style widget constructed: inkscape %p\n",
176
(kind == FILL) ? "fill" : "style",
180
fillnstroke_performUpdate(spw);
130
* On signal modified, invokes an update of the stroke style paint object.
186
* On signal modified, invokes an update of the fill or stroke style paint object.
133
sp_stroke_style_paint_selection_modified( SPWidget *spw,
134
Inkscape::Selection */*selection*/,
136
SPPaintSelector */*psel*/ )
188
static void fillnstroke_selection_modified( SPWidget *spw,
189
Inkscape::Selection * /*selection*/,
191
SPPaintSelector * /*psel*/ )
138
if (flags & ( SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_PARENT_MODIFIED_FLAG |
193
if (flags & ( SP_OBJECT_MODIFIED_FLAG |
194
SP_OBJECT_PARENT_MODIFIED_FLAG |
139
195
SP_OBJECT_STYLE_MODIFIED_FLAG) ) {
140
sp_stroke_style_paint_update(spw);
197
g_message("fillnstroke_selection_modified()");
199
fillnstroke_performUpdate(spw);
146
* On signal selection changed, invokes an update of the stroke style paint object.
149
sp_stroke_style_paint_selection_changed( SPWidget *spw,
150
Inkscape::Selection */*selection*/,
151
SPPaintSelector */*psel*/ )
153
sp_stroke_style_paint_update (spw);
158
* On signal change subselection, invoke an update of the stroke style widget.
161
sp_stroke_style_widget_change_subselection( Inkscape::Application */*inkscape*/,
162
SPDesktop */*desktop*/,
165
sp_stroke_style_paint_update (spw);
169
* Gets the active stroke style property, then sets the appropriate color, alpha, gradient,
170
* pattern, etc. for the paint-selector.
173
sp_stroke_style_paint_update (SPWidget *spw)
175
if (gtk_object_get_data(GTK_OBJECT(spw), "update")) {
204
* On signal selection changed, invokes an update of the fill or stroke style paint object.
206
static void fillnstroke_selection_changed( SPWidget *spw,
207
Inkscape::Selection * /*selection*/,
208
SPPaintSelector * /*psel*/ )
210
fillnstroke_performUpdate(spw);
214
* On signal change subselection, invoke an update of the fill or stroke style widget.
216
static void fillnstroke_subselection_changed( Inkscape::Application * /*inkscape*/,
217
SPDesktop * /*desktop*/,
220
fillnstroke_performUpdate(spw);
224
* Gets the active fill or stroke style property, then sets the appropriate
225
* color, alpha, gradient, pattern, etc. for the paint-selector.
227
* @param sel Selection to use, or NULL.
229
static void fillnstroke_performUpdate( SPWidget *spw )
231
if ( g_object_get_data(G_OBJECT(spw), "update") ) {
179
gtk_object_set_data(GTK_OBJECT(spw), "update", GINT_TO_POINTER(TRUE));
181
SPPaintSelector *psel = SP_PAINT_SELECTOR(gtk_object_get_data(GTK_OBJECT(spw), "paint-selector"));
235
FillOrStroke kind = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(spw), "kind")) ? FILL : STROKE;
238
if ( g_object_get_data(G_OBJECT(spw), "local") ) {
239
g_object_set_data(G_OBJECT(spw), "local", GINT_TO_POINTER(FALSE)); // local change; do nothing, but reset the flag
244
g_object_set_data(G_OBJECT(spw), "update", GINT_TO_POINTER(TRUE));
246
SPPaintSelector *psel = SP_PAINT_SELECTOR(g_object_get_data(G_OBJECT(spw), "paint-selector"));
183
248
// create temporary style
184
SPStyle *query = sp_style_new (SP_ACTIVE_DOCUMENT);
186
int result = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_STROKE);
249
SPStyle *query = sp_style_new(SP_ACTIVE_DOCUMENT);
251
// query style from desktop into it. This returns a result flag and fills query with the style of subselection, if any, or selection
252
int result = sp_desktop_query_style(SP_ACTIVE_DESKTOP, query, (kind == FILL) ? QUERY_STYLE_PROPERTY_FILL : QUERY_STYLE_PROPERTY_STROKE);
254
SPIPaint &targPaint = (kind == FILL) ? query->fill : query->stroke;
255
SPIScale24 &targOpacity = (kind == FILL) ? query->fill_opacity : query->stroke_opacity;
188
257
switch (result) {
189
258
case QUERY_STYLE_NOTHING:
197
266
case QUERY_STYLE_MULTIPLE_AVERAGED: // TODO: treat this slightly differently, e.g. display "averaged" somewhere in paint selector
198
267
case QUERY_STYLE_MULTIPLE_SAME:
200
SPPaintSelector::Mode pselmode = SPPaintSelector::getModeForStyle(*query, false);
269
SPPaintSelector::Mode pselmode = SPPaintSelector::getModeForStyle(*query, kind == FILL);
201
270
psel->setMode(pselmode);
203
if (query->stroke.set && query->stroke.isPaintserver()) {
205
SPPaintServer *server = SP_STYLE_STROKE_SERVER (query);
207
if (server && server->isSwatch()) {
273
psel->setFillrule(query->fill_rule.computed == ART_WIND_RULE_NONZERO?
274
SPPaintSelector::FILLRULE_NONZERO : SPPaintSelector::FILLRULE_EVENODD);
277
if (targPaint.set && targPaint.isColor()) {
278
psel->setColorAlpha(targPaint.value.color, SP_SCALE24_TO_FLOAT(targOpacity.value));
279
} else if (targPaint.set && targPaint.isPaintserver()) {
281
SPPaintServer *server = (kind == FILL) ? query->getFillPaintServer() : query->getStrokePaintServer();
283
if (server && SP_IS_GRADIENT(server) && SP_GRADIENT(server)->getVector()->isSwatch()) {
208
284
SPGradient *vector = SP_GRADIENT(server)->getVector();
209
285
psel->setSwatch( vector );
210
} else if (SP_IS_LINEARGRADIENT (server)) {
286
} else if (SP_IS_LINEARGRADIENT(server)) {
211
287
SPGradient *vector = SP_GRADIENT(server)->getVector();
212
288
psel->setGradientLinear( vector );
214
SPLinearGradient *lg = SP_LINEARGRADIENT (server);
290
SPLinearGradient *lg = SP_LINEARGRADIENT(server);
215
291
psel->setGradientProperties( SP_GRADIENT_UNITS(lg),
216
292
SP_GRADIENT_SPREAD(lg) );
217
} else if (SP_IS_RADIALGRADIENT (server)) {
293
} else if (SP_IS_RADIALGRADIENT(server)) {
218
294
SPGradient *vector = SP_GRADIENT(server)->getVector();
219
295
psel->setGradientRadial( vector );
221
SPRadialGradient *rg = SP_RADIALGRADIENT (server);
297
SPRadialGradient *rg = SP_RADIALGRADIENT(server);
222
298
psel->setGradientProperties( SP_GRADIENT_UNITS(rg),
223
299
SP_GRADIENT_SPREAD(rg) );
224
} else if (SP_IS_PATTERN (server)) {
225
SPPattern *pat = pattern_getroot (SP_PATTERN (server));
300
} else if (SP_IS_PATTERN(server)) {
301
SPPattern *pat = pattern_getroot(SP_PATTERN(server));
226
302
psel->updatePatternList( pat );
228
} else if (query->stroke.set && query->stroke.isColor()) {
229
psel->setColorAlpha(query->stroke.value.color, SP_SCALE24_TO_FLOAT(query->stroke_opacity.value));
241
315
sp_style_unref(query);
243
gtk_object_set_data(GTK_OBJECT(spw), "update", GINT_TO_POINTER(FALSE));
317
g_object_set_data(G_OBJECT(spw), "update", GINT_TO_POINTER(FALSE));
247
321
* When the mode is changed, invoke a regular changed handler.
250
sp_stroke_style_paint_mode_changed( SPPaintSelector *psel,
323
static void fillnstroke_paint_mode_changed( SPPaintSelector *psel,
251
324
SPPaintSelector::Mode /*mode*/,
254
if (gtk_object_get_data(GTK_OBJECT(spw), "update")) {
327
if (g_object_get_data(G_OBJECT(spw), "update")) {
332
g_message("fillnstroke_paint_mode_changed(psel:%p, mode, spw:%p)", psel, spw);
258
335
/* TODO: Does this work?
259
336
* Not really, here we have to get old color back from object
260
337
* Instead of relying on paint widget having meaningful colors set
262
sp_stroke_style_paint_changed(psel, spw);
265
static gchar const *const undo_label_1 = "stroke:flatcolor:1";
266
static gchar const *const undo_label_2 = "stroke:flatcolor:2";
267
static gchar const *undo_label = undo_label_1;
339
fillnstroke_paint_changed(psel, spw);
342
static void fillnstroke_fillrule_changed( SPPaintSelector * /*psel*/,
343
SPPaintSelector::FillRule mode,
346
if (g_object_get_data(G_OBJECT(spw), "update")) {
350
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
352
SPCSSAttr *css = sp_repr_css_attr_new();
353
sp_repr_css_set_property(css, "fill-rule", mode == SPPaintSelector::FILLRULE_EVENODD? "evenodd":"nonzero");
355
sp_desktop_set_style(desktop, css);
357
sp_repr_css_attr_unref(css);
360
sp_document_done(SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_FILL_STROKE,
361
_("Change fill rule"));
364
static gchar const *undo_F_label_1 = "fill:flatcolor:1";
365
static gchar const *undo_F_label_2 = "fill:flatcolor:2";
367
static gchar const *undo_S_label_1 = "stroke:flatcolor:1";
368
static gchar const *undo_S_label_2 = "stroke:flatcolor:2";
370
static gchar const *undo_F_label = undo_F_label_1;
371
static gchar const *undo_S_label = undo_S_label_1;
270
* When a drag callback occurs on a paint selector object, if it is a RGB or CMYK
271
* color mode, then set the stroke opacity to psel's flat color.
374
* This is called repeatedly while you are dragging a color slider, only for flat color
375
* modes. Previously it set the color in style but did not update the repr for efficiency, however
376
* this was flakey and didn't buy us almost anything. So now it does the same as _changed, except
377
* lumps all its changes for undo.
274
sp_stroke_style_paint_dragged(SPPaintSelector *psel, SPWidget *spw)
379
static void fillnstroke_paint_dragged(SPPaintSelector *psel, SPWidget *spw)
276
if (gtk_object_get_data(GTK_OBJECT(spw), "update")) {
381
if (!spw->inkscape) {
385
if (g_object_get_data(G_OBJECT(spw), "update")) {
389
FillOrStroke kind = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(spw), "kind")) ? FILL : STROKE;
392
if (g_object_get_data(G_OBJECT(spw), "local")) {
393
// previous local flag not cleared yet;
394
// this means dragged events come too fast, so we better skip this one to speed up display
395
// (it's safe to do this in any case)
400
g_object_set_data(G_OBJECT(spw), "update", GINT_TO_POINTER(TRUE));
280
402
switch (psel->mode) {
281
403
case SPPaintSelector::MODE_COLOR_RGB:
282
404
case SPPaintSelector::MODE_COLOR_CMYK:
284
psel->setFlatColor( SP_ACTIVE_DESKTOP, "stroke", "stroke-opacity" );
285
sp_document_maybe_done (sp_desktop_document(SP_ACTIVE_DESKTOP), undo_label, SP_VERB_DIALOG_FILL_STROKE,
286
_("Set stroke color"));
406
psel->setFlatColor( SP_ACTIVE_DESKTOP, (kind == FILL) ? "fill" : "stroke", (kind == FILL) ? "fill-opacity" : "stroke-opacity" );
407
sp_document_maybe_done(sp_desktop_document(SP_ACTIVE_DESKTOP), (kind == FILL) ? undo_F_label : undo_S_label, SP_VERB_DIALOG_FILL_STROKE,
408
(kind == FILL) ? _("Set fill color") : _("Set stroke color"));
410
g_object_set_data(G_OBJECT(spw), "local", GINT_TO_POINTER(TRUE)); // local change, do not update from selection
291
416
g_warning( "file %s: line %d: Paint %d should not emit 'dragged'",
292
__FILE__, __LINE__, psel->mode);
417
__FILE__, __LINE__, psel->mode );
420
g_object_set_data(G_OBJECT(spw), "update", GINT_TO_POINTER(FALSE));
298
* When the stroke style's paint settings change, this handler updates the
299
* repr's stroke css style and applies the style to relevant drawing items.
424
This is called (at least) when:
425
1 paint selector mode is switched (e.g. flat color -> gradient)
426
2 you finished dragging a gradient node and released mouse
427
3 you changed a gradient selector parameter (e.g. spread)
302
sp_stroke_style_paint_changed(SPPaintSelector *psel, SPWidget *spw)
430
static void fillnstroke_paint_changed( SPPaintSelector *psel, SPWidget *spw )
304
if (gtk_object_get_data(GTK_OBJECT(spw), "update")) {
433
g_message("fillnstroke_paint_changed(psel:%p, spw:%p)", psel, spw);
435
if (g_object_get_data(G_OBJECT(spw), "update")) {
307
g_object_set_data (G_OBJECT (spw), "update", GINT_TO_POINTER (TRUE));
438
g_object_set_data(G_OBJECT(spw), "update", GINT_TO_POINTER(TRUE));
440
FillOrStroke kind = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(spw), "kind")) ? FILL : STROKE;
309
442
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
310
SPDocument *document = sp_desktop_document (desktop);
311
Inkscape::Selection *selection = sp_desktop_selection (desktop);
446
SPDocument *document = sp_desktop_document(desktop);
447
Inkscape::Selection *selection = sp_desktop_selection(desktop);
313
449
GSList const *items = selection->itemList();
315
451
switch (psel->mode) {
316
452
case SPPaintSelector::MODE_EMPTY:
317
453
// This should not happen.
318
g_warning ( "file %s: line %d: Paint %d should not emit 'changed'",
319
__FILE__, __LINE__, psel->mode);
454
g_warning( "file %s: line %d: Paint %d should not emit 'changed'",
455
__FILE__, __LINE__, psel->mode);
321
457
case SPPaintSelector::MODE_MULTIPLE:
322
458
// This happens when you switch multiple objects with different gradients to flat color;
326
462
case SPPaintSelector::MODE_NONE:
328
464
SPCSSAttr *css = sp_repr_css_attr_new();
329
sp_repr_css_set_property(css, "stroke", "none");
465
sp_repr_css_set_property(css, (kind == FILL) ? "fill" : "stroke", "none");
331
sp_desktop_set_style (desktop, css);
467
sp_desktop_set_style(desktop, css);
333
469
sp_repr_css_attr_unref(css);
335
472
sp_document_done(document, SP_VERB_DIALOG_FILL_STROKE,
473
(kind == FILL) ? _("Remove fill") : _("Remove stroke"));
340
477
case SPPaintSelector::MODE_COLOR_RGB:
341
478
case SPPaintSelector::MODE_COLOR_CMYK:
343
psel->setFlatColor(desktop, "stroke", "stroke-opacity");
344
sp_document_maybe_done (sp_desktop_document(desktop), undo_label, SP_VERB_DIALOG_FILL_STROKE,
345
_("Set stroke color"));
481
// FIXME: fix for GTK breakage, see comment in SelectedStyle::on_opacity_changed; here it results in losing release events
482
sp_canvas_force_full_redraw_after_interruptions(sp_desktop_canvas(desktop), 0);
485
psel->setFlatColor( desktop,
486
(kind == FILL) ? "fill" : "stroke",
487
(kind == FILL) ? "fill-opacity" : "stroke-opacity" );
488
sp_document_maybe_done(sp_desktop_document(desktop), (kind == FILL) ? undo_F_label : undo_S_label, SP_VERB_DIALOG_FILL_STROKE,
489
(kind == FILL) ? _("Set fill color") : _("Set stroke color"));
492
// resume interruptibility
493
sp_canvas_end_forced_full_redraws(sp_desktop_canvas(desktop));
347
496
// on release, toggle undo_label so that the next drag will not be lumped with this one
348
if (undo_label == undo_label_1)
349
undo_label = undo_label_2;
351
undo_label = undo_label_1;
497
if (undo_F_label == undo_F_label_1) {
498
undo_F_label = undo_F_label_2;
499
undo_S_label = undo_S_label_2;
501
undo_F_label = undo_F_label_1;
502
undo_S_label = undo_S_label_1;
356
508
case SPPaintSelector::MODE_GRADIENT_LINEAR:
357
509
case SPPaintSelector::MODE_GRADIENT_RADIAL:
510
case SPPaintSelector::MODE_SWATCH:
359
SPGradientType const gradient_type = ( psel->mode == SPPaintSelector::MODE_GRADIENT_LINEAR
512
SPGradientType const gradient_type = ( psel->mode != SPPaintSelector::MODE_GRADIENT_RADIAL
360
513
? SP_GRADIENT_TYPE_LINEAR
361
514
: SP_GRADIENT_TYPE_RADIAL );
518
// HACK: reset fill-opacity - that 0.75 is annoying; BUT remove this when we have an opacity slider for all tabs
519
css = sp_repr_css_attr_new();
520
sp_repr_css_set_property(css, "fill-opacity", "1.0");
362
523
SPGradient *vector = psel->getGradientVector();
364
525
/* No vector in paint selector should mean that we just changed mode */
366
SPStyle *query = sp_style_new (SP_ACTIVE_DOCUMENT);
367
int result = objects_query_fillstroke ((GSList *) items, query, false);
527
SPStyle *query = sp_style_new(SP_ACTIVE_DOCUMENT);
528
int result = objects_query_fillstroke(const_cast<GSList *>(items), query, kind == FILL);
529
SPIPaint &targPaint = (kind == FILL) ? query->fill : query->stroke;
368
530
guint32 common_rgb = 0;
369
531
if (result == QUERY_STYLE_MULTIPLE_SAME) {
370
if (!query->fill.isColor()) {
371
common_rgb = sp_desktop_get_color(desktop, false);
532
if (!targPaint.isColor()) {
533
common_rgb = sp_desktop_get_color(desktop, kind == FILL);
373
common_rgb = query->stroke.value.color.toRGBA32( 0xff );
535
common_rgb = targPaint.value.color.toRGBA32( 0xff );
375
537
vector = sp_document_default_gradient_vector(document, common_rgb);
377
539
sp_style_unref(query);
379
541
for (GSList const *i = items; i != NULL; i = i->next) {
544
sp_repr_css_change_recursive(SP_OBJECT_REPR(i->data), css, "style");
381
548
sp_item_set_gradient(SP_ITEM(i->data),
382
sp_gradient_vector_for_object(document, desktop, SP_OBJECT(i->data), false),
383
gradient_type, false);
549
sp_gradient_vector_for_object(document, desktop, SP_OBJECT(i->data), kind == FILL),
550
gradient_type, kind == FILL);
385
sp_item_set_gradient(SP_ITEM(i->data), vector, gradient_type, false);
552
sp_item_set_gradient(SP_ITEM(i->data), vector, gradient_type, kind == FILL);
556
// We have changed from another gradient type, or modified spread/units within
557
// this gradient type.
389
558
vector = sp_gradient_ensure_vector_normalized(vector);
390
559
for (GSList const *i = items; i != NULL; i = i->next) {
391
SPGradient *gr = sp_item_set_gradient(SP_ITEM(i->data), vector, gradient_type, false);
562
sp_repr_css_change_recursive(SP_OBJECT_REPR(i->data), css, "style");
565
SPGradient *gr = sp_item_set_gradient(SP_ITEM(i->data), vector, gradient_type, kind == FILL);
392
566
psel->pushAttrsToGradient( gr );
571
sp_repr_css_attr_unref(css);
396
575
sp_document_done(document, SP_VERB_DIALOG_FILL_STROKE,
397
_("Set gradient on stroke"));
576
(kind == FILL) ? _("Set gradient on fill") : _("Set gradient on stroke"));
413
592
Inkscape::XML::Node *patrepr = SP_OBJECT_REPR(pattern);
414
SPCSSAttr *css = sp_repr_css_attr_new ();
415
gchar *urltext = g_strdup_printf ("url(#%s)", patrepr->attribute("id"));
416
sp_repr_css_set_property (css, "stroke", urltext);
593
SPCSSAttr *css = sp_repr_css_attr_new();
594
gchar *urltext = g_strdup_printf("url(#%s)", patrepr->attribute("id"));
595
sp_repr_css_set_property(css, (kind == FILL) ? "fill" : "stroke", urltext);
597
// HACK: reset fill-opacity - that 0.75 is annoying; BUT remove this when we have an opacity slider for all tabs
599
sp_repr_css_set_property(css, "fill-opacity", "1.0");
602
// cannot just call sp_desktop_set_style, because we don't want to touch those
603
// objects who already have the same root pattern but through a different href
604
// chain. FIXME: move this to a sp_item_set_pattern
418
605
for (GSList const *i = items; i != NULL; i = i->next) {
419
Inkscape::XML::Node *selrepr = SP_OBJECT_REPR (i->data);
420
SPObject *selobj = SP_OBJECT (i->data);
424
SPStyle *style = SP_OBJECT_STYLE (selobj);
425
if (style && style->stroke.isPaintserver()) {
426
SPObject *server = SP_OBJECT_STYLE_STROKE_SERVER (selobj);
427
if (SP_IS_PATTERN (server) && pattern_getroot (SP_PATTERN(server)) == pattern)
428
// only if this object's pattern is not rooted in our selected pattern, apply
432
sp_repr_css_change_recursive (selrepr, css, "style");
435
sp_repr_css_attr_unref (css);
606
Inkscape::XML::Node *selrepr = SP_OBJECT_REPR(i->data);
607
if ( (kind == STROKE) && !selrepr) {
610
SPObject *selobj = SP_OBJECT(i->data);
612
SPStyle *style = SP_OBJECT_STYLE(selobj);
613
if (style && ((kind == FILL) ? style->fill : style->stroke).isPaintserver()) {
614
SPObject *server = (kind == FILL) ?
615
SP_OBJECT_STYLE_FILL_SERVER(selobj) :
616
SP_OBJECT_STYLE_STROKE_SERVER(selobj);
617
if (SP_IS_PATTERN(server) && pattern_getroot(SP_PATTERN(server)) == pattern)
618
// only if this object's pattern is not rooted in our selected pattern, apply
623
sp_desktop_apply_css_recursive(selobj, css, true);
625
sp_repr_css_change_recursive(selrepr, css, "style");
629
sp_repr_css_attr_unref(css);
440
sp_document_done (document, SP_VERB_DIALOG_FILL_STROKE,
441
_("Set pattern on stroke"));
635
sp_document_done(document, SP_VERB_DIALOG_FILL_STROKE,
636
(kind == FILL) ? _("Set pattern on fill") :
637
_("Set pattern on stroke"));
446
case SPPaintSelector::MODE_SWATCH:
450
642
case SPPaintSelector::MODE_UNSET:
452
SPCSSAttr *css = sp_repr_css_attr_new ();
453
sp_repr_css_unset_property (css, "stroke");
454
sp_repr_css_unset_property (css, "stroke-opacity");
455
sp_repr_css_unset_property (css, "stroke-width");
456
sp_repr_css_unset_property (css, "stroke-miterlimit");
457
sp_repr_css_unset_property (css, "stroke-linejoin");
458
sp_repr_css_unset_property (css, "stroke-linecap");
459
sp_repr_css_unset_property (css, "stroke-dashoffset");
460
sp_repr_css_unset_property (css, "stroke-dasharray");
462
sp_desktop_set_style (desktop, css);
463
sp_repr_css_attr_unref (css);
465
sp_document_done (document, SP_VERB_DIALOG_FILL_STROKE,
644
SPCSSAttr *css = sp_repr_css_attr_new();
646
sp_repr_css_unset_property(css, "fill");
648
sp_repr_css_unset_property(css, "stroke");
649
sp_repr_css_unset_property(css, "stroke-opacity");
650
sp_repr_css_unset_property(css, "stroke-width");
651
sp_repr_css_unset_property(css, "stroke-miterlimit");
652
sp_repr_css_unset_property(css, "stroke-linejoin");
653
sp_repr_css_unset_property(css, "stroke-linecap");
654
sp_repr_css_unset_property(css, "stroke-dashoffset");
655
sp_repr_css_unset_property(css, "stroke-dasharray");
658
sp_desktop_set_style(desktop, css);
659
sp_repr_css_attr_unref(css);
662
sp_document_done(document, SP_VERB_DIALOG_FILL_STROKE,
663
(kind == FILL) ? _("Unset fill") : _("Unset stroke"));