paint-selector.cpp revision 3673604002997562b7c0b941072c1bd6057c3788
402N/A#define noSP_PS_VERBOSE
#ifdef HAVE_CONFIG_H
# include "config.h"
#include <cstring>
#include <string>
#include "widgets/swatch-selector.h"
#include "../sp-pattern.h"
#include "widgets/widget-sizes.h"
#include "sp-color-notebook.h"
#include "sp-linear-gradient-fns.h"
#include "sp-radial-gradient-fns.h"
#include "gradient-selector.h"
#include <inkscape.h>
#include <document-private.h>
#include <desktop-style.h>
#include <style.h>
#include "svg/svg-color.h"
#include "svg/css-ostringstream.h"
#include "path-prefix.h"
#include "helper/stock-items.h"
#include "ui/icon-names.h"
#include "paint-selector.h"
#ifdef SP_PS_VERBOSE
#include "svg/svg-icc-color.h"
static GtkWidget *sp_paint_selector_style_button_add(SPPaintSelector *psel, gchar const *px, SPPaintSelector::Mode mode, gchar const *tip);
#ifdef SP_PS_VERBOSE
return isGrad;
SwatchSelector *swatchsel = static_cast<SwatchSelector*>(g_object_get_data(G_OBJECT(psel->selector), "swatch-selector"));
if (swatchsel) {
grad = reinterpret_cast<SPGradientSelector*>(g_object_get_data(G_OBJECT(psel->selector), "gradient-selector"));
return grad;
if (!type) {
sizeof(SPPaintSelectorClass),
sizeof(SPPaintSelector),
return type;
G_TYPE_NONE, 0);
G_TYPE_NONE, 0);
G_TYPE_NONE, 0);
G_TYPE_NONE, 0);
psel->mode = static_cast<SPPaintSelector::Mode>(-1); // huh? do you mean 0xff? -- I think this means "not in the enum"
GtkWidget *w;
// TRANSLATORS: for info, see http://www.w3.org/TR/2000/CR-SVG-20000802/painting.html#FillRuleProperty
gtk_widget_set_tooltip_text(psel->evenodd, _("Any path self-intersections or subpaths create holes in the fill (fill-rule: evenodd)"));
g_object_set_data(G_OBJECT(psel->evenodd), "mode", GUINT_TO_POINTER(SPPaintSelector::FILLRULE_EVENODD));
g_signal_connect(G_OBJECT(psel->evenodd), "toggled", G_CALLBACK(sp_paint_selector_fillrule_toggled), psel);
// TRANSLATORS: for info, see http://www.w3.org/TR/2000/CR-SVG-20000802/painting.html#FillRuleProperty
gtk_widget_set_tooltip_text(psel->nonzero, _("Fill is solid unless a subpath is counterdirectional (fill-rule: nonzero)"));
g_object_set_data(G_OBJECT(psel->nonzero), "mode", GUINT_TO_POINTER(SPPaintSelector::FILLRULE_NONZERO));
g_signal_connect(G_OBJECT(psel->nonzero), "toggled", G_CALLBACK(sp_paint_selector_fillrule_toggled), psel);
GtkWidget *b, *w;
b = gtk_toggle_button_new();
gtk_widget_show(b);
gtk_widget_show(w);
psel->setMode(static_cast<SPPaintSelector::Mode>(GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(tb), "mode"))));
SPPaintSelector::FillRule fr = static_cast<SPPaintSelector::FillRule>(GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(tb), "mode")));
if (is_fill) {
return psel;
#ifdef SP_PS_VERBOSE
g_print("Mode change %d -> %d %s -> %s\n", this->mode, mode, modeStrings[this->mode], modeStrings[mode]);
switch (mode) {
case MODE_EMPTY:
case MODE_MULTIPLE:
case MODE_NONE:
case MODE_COLOR_RGB:
case MODE_COLOR_CMYK:
case MODE_GRADIENT_LINEAR:
case MODE_GRADIENT_RADIAL:
case MODE_PATTERN:
case MODE_SWATCH:
case MODE_UNSET:
if (fillrulebox) {
#ifdef SP_PS_VERBOSE
#ifdef SP_PS_VERBOSE
SwatchSelector *swatchsel = static_cast<SwatchSelector*>(g_object_get_data(G_OBJECT(selector), "swatch-selector"));
if (swatchsel) {
#ifdef SP_PS_VERBOSE
#ifdef SP_PS_VERBOSE
void SPPaintSelector::getGradientProperties( SPGradientUnits &units, SPGradientSpread &spread) const
return vect;
if ((psel->mode == SPPaintSelector::MODE_COLOR_RGB) || (psel->mode == SPPaintSelector::MODE_COLOR_CMYK)) {
#ifdef SP_PS_VERBOSE
if ((psel->mode == SPPaintSelector::MODE_GRADIENT_LINEAR) || (psel->mode == SPPaintSelector::MODE_GRADIENT_RADIAL)) {
g_signal_connect(G_OBJECT(gsel), "released", G_CALLBACK(sp_paint_selector_gradient_released), psel);
#ifdef SP_PS_VERBOSE
GSList *
return NULL;
if (SP_PATTERN(l->data) == pattern_getroot(SP_PATTERN(l->data))) { // only if this is a root pattern
return pl;
* Adds menu items for pattern list - derived from marker code, left hb etc in to make addition of previews easier at some point.
gtk_widget_show(i);
GtkWidget *l;
gtk_widget_show(l);
static void sp_pattern_list_from_doc(GtkWidget *m, SPDocument * /*current_doc*/, SPDocument *source, SPDocument * /*pattern_doc*/)
// find and load patterns.svg
gtk_widget_show(i);
// suck in from patterns.svg
if (patterns_doc) {
static GtkWidget*
gtk_widget_show(m);
if (!doc) {
GtkWidget *i;
gtk_widget_show(i);
return mnu;
if (update) {
int patpos = 0;
patpos = i;
gtk_label_set_markup(GTK_LABEL(l), _("Use the <b>Node tool</b> to adjust position, scale, and rotation of the pattern on canvas. Use <b>Object > Pattern > Objects to Pattern</b> to create a new pattern from selection."));
#ifdef SP_PS_VERBOSE
return NULL;
if (pat_obj) {
pat = 0;
return pat;
swatchsel = static_cast<SwatchSelector*>(g_object_get_data(G_OBJECT(psel->selector), "swatch-selector"));
#ifdef SP_PS_VERBOSE
// TODO this seems very bad to be taking in a desktop pointer to muck with. Logic probably belongs elsewhere
void SPPaintSelector::setFlatColor( SPDesktop *desktop, gchar const *color_property, gchar const *opacity_property )
#ifdef SP_PS_VERBOSE
rgba,
SPPaintServer const *server = (kind == FILL) ? style.getFillPaintServer() : style.getStrokePaintServer();
#ifdef SP_PS_VERBOSE
g_message("==== server:%p %s grad:%s swatch:%s", server, server->getId(), (SP_IS_GRADIENT(server)?"Y":"n"), (SP_IS_GRADIENT(server) && SP_GRADIENT(server)->getVector()->isSwatch()?"Y":"n"));
return mode;