summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6b6133b)
raw | patch | inline | side by side (parent: 6b6133b)
author | Jon A. Cruz <jon@joncruz.org> | |
Mon, 22 Mar 2010 00:44:33 +0000 (17:44 -0700) | ||
committer | Jon A. Cruz <jon@joncruz.org> | |
Mon, 22 Mar 2010 00:44:33 +0000 (17:44 -0700) |
index d6ae50ae36998f8198720bcc1f5250f044c6b9cf..34cf1d5e35f72718ae2a6f12da676a1063f3c908 100644 (file)
void
sp_color_picker_color_mod(SPColorSelector *csel, GObject *cp)
{
- if (_in_use) return;
- else _in_use = true;
+ if (_in_use) {
+ return;
+ } else {
+ _in_use = true;
+ }
SPColor color;
- float alpha;
- csel->base->getColorAlpha(color, &alpha);
+ float alpha = 0;
+ csel->base->getColorAlpha(color, alpha);
guint32 rgba = color.toRGBA32( alpha );
ColorPicker *ptr = (ColorPicker *)(cp);
index 87cd238a7fc45d20112102bcdf80ebc9522f5650..c84a3a07e7eb3da172deb2e8c220624295e59a2a 100644 (file)
case QUERY_STYLE_NOTHING:
{
/* No paint at all */
- sp_paint_selector_set_mode (psel, SP_PAINT_SELECTOR_MODE_EMPTY);
+ psel->setMode(SP_PAINT_SELECTOR_MODE_EMPTY);
break;
}
case QUERY_STYLE_MULTIPLE_SAME:
{
SPPaintSelectorMode pselmode = sp_style_determine_paint_selector_mode (query, true);
- sp_paint_selector_set_mode (psel, pselmode);
+ psel->setMode(pselmode);
- sp_paint_selector_set_fillrule (psel, query->fill_rule.computed == ART_WIND_RULE_NONZERO?
- SP_PAINT_SELECTOR_FILLRULE_NONZERO : SP_PAINT_SELECTOR_FILLRULE_EVENODD);
+ psel->setFillrule(query->fill_rule.computed == ART_WIND_RULE_NONZERO?
+ SP_PAINT_SELECTOR_FILLRULE_NONZERO : SP_PAINT_SELECTOR_FILLRULE_EVENODD);
if (query->fill.set && query->fill.isColor()) {
- sp_paint_selector_set_color_alpha (psel, &query->fill.value.color, SP_SCALE24_TO_FLOAT (query->fill_opacity.value));
+ psel->setColorAlpha(query->fill.value.color, SP_SCALE24_TO_FLOAT(query->fill_opacity.value));
} else if (query->fill.set && query->fill.isPaintserver()) {
SPPaintServer *server = SP_STYLE_FILL_SERVER (query);
if (server && SP_IS_GRADIENT(server) && SP_GRADIENT(server)->getVector()->isSwatch()) {
SPGradient *vector = SP_GRADIENT(server)->getVector();
- sp_paint_selector_set_swatch( psel, vector );
+ psel->setSwatch( vector );
} else if (SP_IS_LINEARGRADIENT (server)) {
SPGradient *vector = SP_GRADIENT(server)->getVector();
- sp_paint_selector_set_gradient_linear (psel, vector);
+ psel->setGradientLinear( vector );
SPLinearGradient *lg = SP_LINEARGRADIENT (server);
- sp_paint_selector_set_gradient_properties (psel,
- SP_GRADIENT_UNITS (lg),
- SP_GRADIENT_SPREAD (lg));
+ psel->setGradientProperties( SP_GRADIENT_UNITS(lg),
+ SP_GRADIENT_SPREAD(lg) );
} else if (SP_IS_RADIALGRADIENT (server)) {
SPGradient *vector = SP_GRADIENT(server)->getVector();
- sp_paint_selector_set_gradient_radial (psel, vector);
+ psel->setGradientRadial( vector );
SPRadialGradient *rg = SP_RADIALGRADIENT (server);
- sp_paint_selector_set_gradient_properties (psel,
- SP_GRADIENT_UNITS (rg),
- SP_GRADIENT_SPREAD (rg));
+ psel->setGradientProperties( SP_GRADIENT_UNITS (rg),
+ SP_GRADIENT_SPREAD (rg) );
} else if (SP_IS_PATTERN (server)) {
SPPattern *pat = pattern_getroot (SP_PATTERN (server));
- sp_update_pattern_list (psel, pat);
+ psel->updatePatternList( pat );
}
}
break;
case QUERY_STYLE_MULTIPLE_DIFFERENT:
{
- sp_paint_selector_set_mode (psel, SP_PAINT_SELECTOR_MODE_MULTIPLE);
+ psel->setMode(SP_PAINT_SELECTOR_MODE_MULTIPLE);
break;
}
}
case SP_PAINT_SELECTOR_MODE_COLOR_RGB:
case SP_PAINT_SELECTOR_MODE_COLOR_CMYK:
{
- sp_paint_selector_set_flat_color (psel, SP_ACTIVE_DESKTOP, "fill", "fill-opacity");
+ psel->setFlatColor( SP_ACTIVE_DESKTOP, "fill", "fill-opacity" );
sp_document_maybe_done (sp_desktop_document(SP_ACTIVE_DESKTOP), undo_label, SP_VERB_DIALOG_FILL_STROKE,
_("Set fill color"));
g_object_set_data (G_OBJECT (spw), "local", GINT_TO_POINTER (TRUE)); // local change, do not update from selection
// FIXME: fix for GTK breakage, see comment in SelectedStyle::on_opacity_changed; here it results in losing release events
sp_canvas_force_full_redraw_after_interruptions(sp_desktop_canvas(desktop), 0);
- sp_paint_selector_set_flat_color (psel, desktop, "fill", "fill-opacity");
+ psel->setFlatColor( desktop, "fill", "fill-opacity" );
sp_document_maybe_done (sp_desktop_document(desktop), undo_label, SP_VERB_DIALOG_FILL_STROKE,
_("Set fill color"));
// resume interruptibility
SPCSSAttr *css = sp_repr_css_attr_new();
sp_repr_css_set_property(css, "fill-opacity", "1.0");
- SPGradient *vector = sp_paint_selector_get_gradient_vector(psel);
+ SPGradient *vector = psel->getGradientVector();
if (!vector) {
/* No vector in paint selector should mean that we just changed mode */
sp_repr_css_change_recursive (SP_OBJECT_REPR (i->data), css, "style");
SPGradient *gr = sp_item_set_gradient(SP_ITEM(i->data), vector, gradient_type, true);
- sp_gradient_selector_attrs_to_gradient (gr, psel);
+ psel->pushAttrsToGradient( gr );
}
}
if (items) {
- SPPattern *pattern = sp_paint_selector_get_pattern (psel);
+ SPPattern *pattern = psel->getPattern();
if (!pattern) {
/* No Pattern in paint selector should mean that we just
index 147077f44a0285ee0aa179a9911a9a75c53e3811..7bfe27310ddc74e008898718ca94f7d696065d7c 100644 (file)
@@ -1146,7 +1146,7 @@ static void sp_gradient_vector_color_dragged(SPColorSelector *csel, GtkObject *o
SPStop *stop = SP_STOP(g_object_get_data(G_OBJECT(gtk_menu_get_active(GTK_MENU(gtk_option_menu_get_menu(mnu)))), "stop"));
- csel->base->getColorAlpha(stop->specified_color, &stop->opacity);
+ csel->base->getColorAlpha(stop->specified_color, stop->opacity);
stop->currentColor = false;
blocked = FALSE;
@@ -1185,7 +1185,7 @@ static void sp_gradient_vector_color_changed(SPColorSelector *csel, GtkObject *o
SPStop *stop = SP_STOP(g_object_get_data(G_OBJECT(gtk_menu_get_active(GTK_MENU(gtk_option_menu_get_menu(mnu)))), "stop"));
csel = static_cast<SPColorSelector*>(g_object_get_data(G_OBJECT(object), "cselector"));
- csel->base->getColorAlpha( color, &alpha );
+ csel->base->getColorAlpha( color, alpha );
rgb = color.toRGBA32( 0x00 );
sp_repr_set_css_double(SP_OBJECT_REPR(stop), "offset", stop->offset);
index 3eaec1c231904f1435586e2e3bfc330f13665ef2..3609942415efa7d0776500639eb75d3bf361f58e 100644 (file)
return isGrad;
}
-static SPGradientSelector *getGradientFromData(SPPaintSelector *psel)
+static SPGradientSelector *getGradientFromData(SPPaintSelector const *psel)
{
SPGradientSelector *grad = 0;
if (psel->mode == SP_PAINT_SELECTOR_MODE_SWATCH) {
sp_paint_selector_style_button_toggled(GtkToggleButton *tb, SPPaintSelector *psel)
{
if (!psel->update && gtk_toggle_button_get_active(tb)) {
- sp_paint_selector_set_mode(psel, (SPPaintSelectorMode)GPOINTER_TO_UINT(gtk_object_get_data(GTK_OBJECT(tb), "mode")));
+ psel->setMode(static_cast<SPPaintSelectorMode>(GPOINTER_TO_UINT(gtk_object_get_data(GTK_OBJECT(tb), "mode"))));
}
}
GtkWidget *
sp_paint_selector_new(bool is_fill)
{
- SPPaintSelector *psel;
+ SPPaintSelector *psel = static_cast<SPPaintSelector*>(gtk_type_new(SP_TYPE_PAINT_SELECTOR));
- psel = (SPPaintSelector*)gtk_type_new(SP_TYPE_PAINT_SELECTOR);
-
- sp_paint_selector_set_mode(psel, SP_PAINT_SELECTOR_MODE_MULTIPLE);
+ psel->setMode(SP_PAINT_SELECTOR_MODE_MULTIPLE);
// This silliness is here because I don't know how to pass a parameter to the
// GtkObject "constructor" (sp_paint_selector_init). Remove it when paint_selector
return GTK_WIDGET(psel);
}
-void
-sp_paint_selector_set_mode(SPPaintSelector *psel, SPPaintSelectorMode mode)
+void SPPaintSelector::setMode(SPPaintSelectorMode mode)
{
- if (psel->mode != mode) {
- psel->update = TRUE;
+ if (this->mode != mode) {
+ update = TRUE;
#ifdef SP_PS_VERBOSE
- g_print("Mode change %d -> %d %s -> %s\n", psel->mode, mode, modeStrings[psel->mode], modeStrings[mode]);
+ g_print("Mode change %d -> %d %s -> %s\n", this->mode, mode, modeStrings[this->mode], modeStrings[mode]);
#endif
switch (mode) {
case SP_PAINT_SELECTOR_MODE_EMPTY:
- sp_paint_selector_set_mode_empty(psel);
+ sp_paint_selector_set_mode_empty(this);
break;
case SP_PAINT_SELECTOR_MODE_MULTIPLE:
- sp_paint_selector_set_mode_multiple(psel);
+ sp_paint_selector_set_mode_multiple(this);
break;
case SP_PAINT_SELECTOR_MODE_NONE:
- sp_paint_selector_set_mode_none(psel);
+ sp_paint_selector_set_mode_none(this);
break;
case SP_PAINT_SELECTOR_MODE_COLOR_RGB:
case SP_PAINT_SELECTOR_MODE_COLOR_CMYK:
- sp_paint_selector_set_mode_color(psel, mode);
+ sp_paint_selector_set_mode_color(this, mode);
break;
case SP_PAINT_SELECTOR_MODE_GRADIENT_LINEAR:
case SP_PAINT_SELECTOR_MODE_GRADIENT_RADIAL:
- sp_paint_selector_set_mode_gradient(psel, mode);
+ sp_paint_selector_set_mode_gradient(this, mode);
break;
case SP_PAINT_SELECTOR_MODE_PATTERN:
- sp_paint_selector_set_mode_pattern(psel, mode);
+ sp_paint_selector_set_mode_pattern(this, mode);
break;
case SP_PAINT_SELECTOR_MODE_SWATCH:
- sp_paint_selector_set_mode_swatch(psel, mode);
+ sp_paint_selector_set_mode_swatch(this, mode);
break;
case SP_PAINT_SELECTOR_MODE_UNSET:
- sp_paint_selector_set_mode_unset(psel);
+ sp_paint_selector_set_mode_unset(this);
break;
default:
g_warning("file %s: line %d: Unknown paint mode %d", __FILE__, __LINE__, mode);
break;
}
- psel->mode = mode;
- gtk_signal_emit(GTK_OBJECT(psel), psel_signals[MODE_CHANGED], psel->mode);
- psel->update = FALSE;
+ this->mode = mode;
+ gtk_signal_emit(GTK_OBJECT(this), psel_signals[MODE_CHANGED], this->mode);
+ update = FALSE;
}
}
-void
-sp_paint_selector_set_fillrule(SPPaintSelector *psel, SPPaintSelectorFillRule fillrule)
+void SPPaintSelector::setFillrule(SPPaintSelectorFillRule fillrule)
{
- if (psel->fillrulebox) {
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(psel->evenodd), (fillrule == SP_PAINT_SELECTOR_FILLRULE_EVENODD));
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(psel->nonzero), (fillrule == SP_PAINT_SELECTOR_FILLRULE_NONZERO));
+ if (fillrulebox) {
+ // TODO this flips widgets but does not use a member to store state. Revisit
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(evenodd), (fillrule == SP_PAINT_SELECTOR_FILLRULE_EVENODD));
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(nonzero), (fillrule == SP_PAINT_SELECTOR_FILLRULE_NONZERO));
}
}
-void
-sp_paint_selector_set_color_alpha(SPPaintSelector *psel, SPColor const *color, float alpha)
+void SPPaintSelector::setColorAlpha(SPColor const &color, float alpha)
{
g_return_if_fail( ( 0.0 <= alpha ) && ( alpha <= 1.0 ) );
- SPColorSelector *csel;
- guint32 rgba;
+ SPColorSelector *csel = 0;
+ guint32 rgba = 0;
/*
if ( sp_color_get_colorspace_type(color) == SP_COLORSPACE_TYPE_CMYK )
@@ -444,115 +440,105 @@ sp_paint_selector_set_color_alpha(SPPaintSelector *psel, SPColor const *color, f
#ifdef SP_PS_VERBOSE
g_print("PaintSelector set RGBA\n");
#endif
- sp_paint_selector_set_mode(psel, SP_PAINT_SELECTOR_MODE_COLOR_RGB);
+ setMode(SP_PAINT_SELECTOR_MODE_COLOR_RGB);
}
- csel = (SPColorSelector*)gtk_object_get_data(GTK_OBJECT(psel->selector), "color-selector");
- rgba = color->toRGBA32( alpha );
- csel->base->setColorAlpha( *color, alpha );
+ csel = reinterpret_cast<SPColorSelector*>(gtk_object_get_data(GTK_OBJECT(selector), "color-selector"));
+ rgba = color.toRGBA32( alpha );
+ csel->base->setColorAlpha( color, alpha );
}
-void sp_paint_selector_set_swatch(SPPaintSelector *psel, SPGradient *vector )
+void SPPaintSelector::setSwatch(SPGradient *vector )
{
#ifdef SP_PS_VERBOSE
g_print("PaintSelector set SWATCH\n");
#endif
- sp_paint_selector_set_mode(psel, SP_PAINT_SELECTOR_MODE_SWATCH);
+ setMode(SP_PAINT_SELECTOR_MODE_SWATCH);
- SwatchSelector *swatchsel = static_cast<SwatchSelector*>(gtk_object_get_data(GTK_OBJECT(psel->selector), "swatch-selector"));
+ SwatchSelector *swatchsel = static_cast<SwatchSelector*>(g_object_get_data(G_OBJECT(selector), "swatch-selector"));
if (swatchsel) {
swatchsel->setVector( (vector) ? SP_OBJECT_DOCUMENT(vector) : 0, vector );
}
}
-void
-sp_paint_selector_set_gradient_linear(SPPaintSelector *psel, SPGradient *vector)
+void SPPaintSelector::setGradientLinear(SPGradient *vector)
{
#ifdef SP_PS_VERBOSE
g_print("PaintSelector set GRADIENT LINEAR\n");
#endif
- sp_paint_selector_set_mode(psel, SP_PAINT_SELECTOR_MODE_GRADIENT_LINEAR);
+ setMode(SP_PAINT_SELECTOR_MODE_GRADIENT_LINEAR);
- SPGradientSelector *gsel = getGradientFromData(psel);
+ SPGradientSelector *gsel = getGradientFromData(this);
gsel->setMode(SPGradientSelector::MODE_LINEAR);
gsel->setVector((vector) ? SP_OBJECT_DOCUMENT(vector) : 0, vector);
}
-void
-sp_paint_selector_set_gradient_radial(SPPaintSelector *psel, SPGradient *vector)
+void SPPaintSelector::setGradientRadial(SPGradient *vector)
{
#ifdef SP_PS_VERBOSE
g_print("PaintSelector set GRADIENT RADIAL\n");
#endif
- sp_paint_selector_set_mode(psel, SP_PAINT_SELECTOR_MODE_GRADIENT_RADIAL);
+ setMode(SP_PAINT_SELECTOR_MODE_GRADIENT_RADIAL);
- SPGradientSelector *gsel = getGradientFromData(psel);
+ SPGradientSelector *gsel = getGradientFromData(this);
gsel->setMode(SPGradientSelector::MODE_RADIAL);
gsel->setVector((vector) ? SP_OBJECT_DOCUMENT(vector) : 0, vector);
}
-void sp_paint_selector_set_gradient_properties(SPPaintSelector *psel, SPGradientUnits units, SPGradientSpread spread)
+void SPPaintSelector::setGradientProperties( SPGradientUnits units, SPGradientSpread spread )
{
- g_return_if_fail(SP_IS_PAINT_SELECTOR(psel));
- g_return_if_fail(isPaintModeGradient(psel->mode));
+ g_return_if_fail(isPaintModeGradient(mode));
- SPGradientSelector *gsel = getGradientFromData(psel);
+ SPGradientSelector *gsel = getGradientFromData(this);
gsel->setUnits(units);
gsel->setSpread(spread);
}
-void sp_paint_selector_get_gradient_properties(SPPaintSelector *psel, SPGradientUnits *units, SPGradientSpread *spread)
+void SPPaintSelector::getGradientProperties( SPGradientUnits &units, SPGradientSpread &spread) const
{
- g_return_if_fail(SP_IS_PAINT_SELECTOR(psel));
- g_return_if_fail(isPaintModeGradient(psel->mode));
+ g_return_if_fail(isPaintModeGradient(mode));
- SPGradientSelector *gsel = getGradientFromData(psel);
- if (units) {
- *units = gsel->getUnits();
- }
- if (spread) {
- *spread = gsel->getSpread();
- }
+ SPGradientSelector *gsel = getGradientFromData(this);
+ units = gsel->getUnits();
+ spread = gsel->getSpread();
}
/**
* \post (alpha == NULL) || (*alpha in [0.0, 1.0]).
*/
-void
-sp_paint_selector_get_color_alpha(SPPaintSelector *psel, SPColor *color, gfloat *alpha)
+void SPPaintSelector::getColorAlpha(SPColor &color, gfloat &alpha) const
{
SPColorSelector *csel;
- csel = (SPColorSelector*)gtk_object_get_data(GTK_OBJECT(psel->selector), "color-selector");
+ csel = reinterpret_cast<SPColorSelector*>(g_object_get_data(G_OBJECT(selector), "color-selector"));
- csel->base->getColorAlpha( *color, alpha );
+ csel->base->getColorAlpha( color, alpha );
- g_assert( !alpha
- || ( ( 0.0 <= *alpha )
- && ( *alpha <= 1.0 ) ) );
+ g_assert( ( 0.0 <= alpha )
+ && ( alpha <= 1.0 ) );
}
-SPGradient *sp_paint_selector_get_gradient_vector(SPPaintSelector *psel)
+SPGradient *SPPaintSelector::getGradientVector()
{
SPGradient* vect = 0;
- if (isPaintModeGradient(psel->mode)) {
- SPGradientSelector *gsel = getGradientFromData(psel);
+ if (isPaintModeGradient(mode)) {
+ SPGradientSelector *gsel = getGradientFromData(this);
vect = gsel->getVector();
}
return vect;
}
-void
-sp_gradient_selector_attrs_to_gradient(SPGradient *gr, SPPaintSelector *psel)
+
+void SPPaintSelector::pushAttrsToGradient( SPGradient *gr ) const
{
SPGradientUnits units = SP_GRADIENT_UNITS_OBJECTBOUNDINGBOX;
SPGradientSpread spread = SP_GRADIENT_SPREAD_PAD;
- sp_paint_selector_get_gradient_properties(psel, &units, &spread);
+ getGradientProperties( units, spread );
sp_gradient_set_units(gr, units);
sp_gradient_set_spread(gr, spread);
SP_OBJECT(gr)->updateRepr();
static void
sp_paint_selector_color_changed(SPColorSelector *csel, SPPaintSelector *psel)
{
- csel->base->getColorAlpha( psel->color, &psel->alpha );
+ csel->base->getColorAlpha( psel->color, psel->alpha );
gtk_signal_emit(GTK_OBJECT(psel), psel_signals[CHANGED]);
}
/*update pattern list*/
-void
-sp_update_pattern_list( SPPaintSelector *psel, SPPattern *pattern)
+void SPPaintSelector::updatePatternList( SPPattern *pattern )
{
- if (psel->update) return;
- GtkWidget *mnu = (GtkWidget *)g_object_get_data(G_OBJECT(psel), "patternmenu");
+ if (update) {
+ return;
+ }
+ GtkWidget *mnu = GTK_WIDGET(g_object_get_data(G_OBJECT(this), "patternmenu"));
g_assert( mnu != NULL );
/* Clear existing menu if any */
@@ -1068,13 +1055,12 @@ sp_paint_selector_set_mode_pattern(SPPaintSelector *psel, SPPaintSelectorMode mo
#endif
}
-SPPattern *
-sp_paint_selector_get_pattern(SPPaintSelector *psel)
+SPPattern *SPPaintSelector::getPattern()
{
- SPPattern *pat;
- g_return_val_if_fail((psel->mode == SP_PAINT_SELECTOR_MODE_PATTERN) , NULL);
+ SPPattern *pat = 0;
+ g_return_val_if_fail((mode == SP_PAINT_SELECTOR_MODE_PATTERN) , NULL);
- GtkWidget *patmnu = (GtkWidget *) g_object_get_data(G_OBJECT(psel), "patternmenu");
+ GtkWidget *patmnu = (GtkWidget *) g_object_get_data(G_OBJECT(this), "patternmenu");
/* no pattern menu if we were just selected */
if ( patmnu == NULL ) return NULL;
return NULL;
}
gchar *patid = (gchar *) g_object_get_data(G_OBJECT(gtk_menu_get_active(m)),
- "pattern");
+ "pattern");
//gchar *pattern = "";
if (strcmp(patid, "none")){
- gchar *stockid = (gchar *) g_object_get_data(G_OBJECT(gtk_menu_get_active(m)),
- "stockid");
- gchar *paturn = patid;
- if (!strcmp(stockid,"true")) paturn = g_strconcat("urn:inkscape:pattern:",patid,NULL);
- SPObject *pat_obj = get_stock_item(paturn);
- if (pat_obj) {
+ gchar *stockid = (gchar *) g_object_get_data(G_OBJECT(gtk_menu_get_active(m)),
+ "stockid");
+ gchar *paturn = patid;
+ if (!strcmp(stockid,"true")) paturn = g_strconcat("urn:inkscape:pattern:",patid,NULL);
+ SPObject *pat_obj = get_stock_item(paturn);
+ if (pat_obj) {
pat = SP_PATTERN(pat_obj);
}
} else {
- pat = pattern_getroot(SP_PATTERN(g_object_get_data(G_OBJECT(gtk_menu_get_active(m)), "pattern")));
+ pat = pattern_getroot(SP_PATTERN(g_object_get_data(G_OBJECT(gtk_menu_get_active(m)), "pattern")));
+ }
+
+ if (pat && !SP_IS_PATTERN(pat)) {
+ pat = 0;
}
- if SP_IS_PATTERN(pat) return pat;
- return NULL;
+ return pat;
}
static void sp_paint_selector_set_mode_swatch(SPPaintSelector *psel, SPPaintSelectorMode mode)
@@ -1142,14 +1131,14 @@ static void sp_paint_selector_set_mode_swatch(SPPaintSelector *psel, SPPaintSele
#endif
}
-void
-sp_paint_selector_set_flat_color(SPPaintSelector *psel, SPDesktop *desktop, gchar const *color_property, gchar const *opacity_property)
+// 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 )
{
SPCSSAttr *css = sp_repr_css_attr_new();
SPColor color;
- gfloat alpha;
- sp_paint_selector_get_color_alpha(psel, &color, &alpha);
+ gfloat alpha = 0;
+ getColorAlpha( color, alpha );
std::string colorStr = color.toString();
@@ -1158,7 +1147,7 @@ sp_paint_selector_set_flat_color(SPPaintSelector *psel, SPDesktop *desktop, gcha
g_message("sp_paint_selector_set_flat_color() to '%s' from 0x%08x::%s",
colorStr.c_str(),
rgba,
- (color.icc?color.icc->colorProfile.c_str():"<null>") );
+ (color.icc ? color.icc->colorProfile.c_str():"<null>") );
#endif // SP_PS_VERBOSE
sp_repr_css_set_property(css, color_property, colorStr.c_str());
index 2d7ac301180822755523bee838b6c308ebf1373b..9d0c5e76cdb2bf42a126895e0c82ae4b2e43b17a 100644 (file)
SPColor color;
float alpha;
+
+
+ void setMode( SPPaintSelectorMode mode );
+ void setFillrule( SPPaintSelectorFillRule fillrule );
+
+ void setColorAlpha( SPColor const &color, float alpha );
+ void getColorAlpha( SPColor &color, gfloat &alpha ) const;
+
+ void setGradientLinear( SPGradient *vector );
+ void setGradientRadial( SPGradient *vector );
+ void setSwatch( SPGradient *vector );
+
+ void setGradientProperties( SPGradientUnits units, SPGradientSpread spread );
+ void getGradientProperties( SPGradientUnits &units, SPGradientSpread &spread ) const;
+
+ void pushAttrsToGradient( SPGradient *gr ) const;
+ SPGradient *getGradientVector();
+ SPPattern * getPattern();
+ void updatePatternList( SPPattern *pat );
+
+ // TODO move this elsewhere:
+ void setFlatColor( SPDesktop *desktop, const gchar *color_property, const gchar *opacity_property );
};
/// The SPPaintSelector vtable
GtkWidget *sp_paint_selector_new (bool is_fill);
-void sp_paint_selector_set_mode (SPPaintSelector *psel, SPPaintSelectorMode mode);
-void sp_paint_selector_set_fillrule (SPPaintSelector *psel, SPPaintSelectorFillRule fillrule);
-
-void sp_paint_selector_set_color_alpha (SPPaintSelector *psel, const SPColor *color, float alpha);
-
-void sp_paint_selector_set_gradient_linear (SPPaintSelector *psel, SPGradient *vector);
-
-void sp_paint_selector_set_gradient_radial (SPPaintSelector *psel, SPGradient *vector);
-
-void sp_paint_selector_set_swatch(SPPaintSelector *psel, SPGradient *vector );
-
-void sp_paint_selector_set_gradient_properties (SPPaintSelector *psel, SPGradientUnits units, SPGradientSpread spread);
-void sp_paint_selector_get_gradient_properties (SPPaintSelector *psel, SPGradientUnits *units, SPGradientSpread *spread);
-
-void sp_gradient_selector_attrs_to_gradient (SPGradient *gr, SPPaintSelector *psel);
-
-void sp_paint_selector_get_color_alpha (SPPaintSelector *psel, SPColor *color, gfloat *alpha);
-
-SPGradient *sp_paint_selector_get_gradient_vector (SPPaintSelector *psel);
-
-void sp_paint_selector_system_color_set (SPPaintSelector *psel, const SPColor *color, float opacity);
-
-SPPattern * sp_paint_selector_get_pattern (SPPaintSelector *psel);
-
-void sp_update_pattern_list ( SPPaintSelector *psel, SPPattern *pat);
-void sp_paint_selector_set_flat_color (SPPaintSelector *psel, SPDesktop *desktop, const gchar *color_property, const gchar *opacity_property);
SPPaintSelectorMode sp_style_determine_paint_selector_mode (SPStyle *style, bool isfill);
index b2df8d2a54580e760f3a25f32792cdc9046d297a..a249786fff2769bd6f0d0004fac869eb3fbc1a43 100644 (file)
if ( gtk_notebook_get_current_page (GTK_NOTEBOOK (_book)) >= 0 )
{
csel = getCurrentSelector();
- csel->base->getColorAlpha(_color, &_alpha);
+ csel->base->getColorAlpha(_color, _alpha);
}
widget = gtk_notebook_get_nth_page (GTK_NOTEBOOK (_book), page_num);
if ( widget && SP_IS_COLOR_SELECTOR (widget) )
@@ -625,7 +625,7 @@ void ColorNotebook::_entryModified (SPColorSelector *csel, SPColorNotebook *colo
SPColor color;
gfloat alpha = 1.0;
- csel->base->getColorAlpha( color, &alpha );
+ csel->base->getColorAlpha( color, alpha );
nb->_updateRgbaEntry( color, alpha );
nb->_updateInternals( color, alpha, nb->_dragging );
}
index 312128781765b18059cb21fa52ea51b2dbd7d0db..203bc3c2a8dc3d2c490f32cd979f8dd10fad7d26 100644 (file)
{
}
-void ColorSelector::getColorAlpha( SPColor& color, gfloat* alpha ) const
+void ColorSelector::getColorAlpha( SPColor &color, gfloat &alpha ) const
{
gint i = 0;
color = _color;
- if ( alpha )
- {
- *alpha = _alpha;
- }
+ alpha = _alpha;
// Try to catch uninitialized value usage
if ( color.v.c[0] )
{
i++;
}
- if ( alpha && *alpha )
+ if ( alpha )
{
i++;
}
index 40446fe0ad9b4998c69ce4b63c3281bf7804fe5e..a2ad87dd55ddc3332aadf24407776724233f380a 100644 (file)
gfloat getAlpha() const;
void setColorAlpha( const SPColor& color, gfloat alpha, bool emit = false );
- void getColorAlpha( SPColor& color, gfloat* alpha ) const;
+ void getColorAlpha( SPColor &color, gfloat &alpha ) const;
virtual void setSubmode( guint submode );
virtual guint getSubmode() const;
index a981934dd8c81a80012949c1505f4db58ad08c43..57dce6fff6d8d3871c131354a7f6482e40f87c30 100644 (file)
case QUERY_STYLE_NOTHING:
{
/* No paint at all */
- sp_paint_selector_set_mode (psel, SP_PAINT_SELECTOR_MODE_EMPTY);
+ psel->setMode(SP_PAINT_SELECTOR_MODE_EMPTY);
break;
}
case QUERY_STYLE_MULTIPLE_SAME:
{
SPPaintSelectorMode pselmode = sp_style_determine_paint_selector_mode (query, false);
- sp_paint_selector_set_mode (psel, pselmode);
+ psel->setMode(pselmode);
if (query->stroke.set && query->stroke.isPaintserver()) {
if (server && server->isSwatch()) {
SPGradient *vector = SP_GRADIENT(server)->getVector();
- sp_paint_selector_set_swatch( psel, vector );
+ psel->setSwatch( vector );
} else if (SP_IS_LINEARGRADIENT (server)) {
SPGradient *vector = SP_GRADIENT(server)->getVector();
- sp_paint_selector_set_gradient_linear (psel, vector);
+ psel->setGradientLinear( vector );
SPLinearGradient *lg = SP_LINEARGRADIENT (server);
- sp_paint_selector_set_gradient_properties (psel,
- SP_GRADIENT_UNITS (lg),
- SP_GRADIENT_SPREAD (lg));
+ psel->setGradientProperties( SP_GRADIENT_UNITS(lg),
+ SP_GRADIENT_SPREAD(lg) );
} else if (SP_IS_RADIALGRADIENT (server)) {
SPGradient *vector = SP_GRADIENT(server)->getVector();
- sp_paint_selector_set_gradient_radial (psel, vector);
+ psel->setGradientRadial( vector );
SPRadialGradient *rg = SP_RADIALGRADIENT (server);
- sp_paint_selector_set_gradient_properties (psel,
- SP_GRADIENT_UNITS (rg),
- SP_GRADIENT_SPREAD (rg));
+ psel->setGradientProperties( SP_GRADIENT_UNITS(rg),
+ SP_GRADIENT_SPREAD(rg) );
} else if (SP_IS_PATTERN (server)) {
SPPattern *pat = pattern_getroot (SP_PATTERN (server));
- sp_update_pattern_list (psel, pat);
+ psel->updatePatternList( pat );
}
} else if (query->stroke.set && query->stroke.isColor()) {
- sp_paint_selector_set_color_alpha (psel, &query->stroke.value.color, SP_SCALE24_TO_FLOAT (query->stroke_opacity.value));
-
+ psel->setColorAlpha(query->stroke.value.color, SP_SCALE24_TO_FLOAT(query->stroke_opacity.value));
}
break;
}
case QUERY_STYLE_MULTIPLE_DIFFERENT:
{
- sp_paint_selector_set_mode (psel, SP_PAINT_SELECTOR_MODE_MULTIPLE);
+ psel->setMode(SP_PAINT_SELECTOR_MODE_MULTIPLE);
break;
}
}
case SP_PAINT_SELECTOR_MODE_COLOR_RGB:
case SP_PAINT_SELECTOR_MODE_COLOR_CMYK:
{
- sp_paint_selector_set_flat_color (psel, SP_ACTIVE_DESKTOP, "stroke", "stroke-opacity");
+ psel->setFlatColor( SP_ACTIVE_DESKTOP, "stroke", "stroke-opacity" );
sp_document_maybe_done (sp_desktop_document(SP_ACTIVE_DESKTOP), undo_label, SP_VERB_DIALOG_FILL_STROKE,
_("Set stroke color"));
break;
case SP_PAINT_SELECTOR_MODE_COLOR_RGB:
case SP_PAINT_SELECTOR_MODE_COLOR_CMYK:
{
- sp_paint_selector_set_flat_color (psel, desktop, "stroke", "stroke-opacity");
+ psel->setFlatColor(desktop, "stroke", "stroke-opacity");
sp_document_maybe_done (sp_desktop_document(desktop), undo_label, SP_VERB_DIALOG_FILL_STROKE,
_("Set stroke color"));
SPGradientType const gradient_type = ( psel->mode == SP_PAINT_SELECTOR_MODE_GRADIENT_LINEAR
? SP_GRADIENT_TYPE_LINEAR
: SP_GRADIENT_TYPE_RADIAL );
- SPGradient *vector = sp_paint_selector_get_gradient_vector(psel);
+ SPGradient *vector = psel->getGradientVector();
if (!vector) {
/* No vector in paint selector should mean that we just changed mode */
vector = sp_gradient_ensure_vector_normalized(vector);
for (GSList const *i = items; i != NULL; i = i->next) {
SPGradient *gr = sp_item_set_gradient(SP_ITEM(i->data), vector, gradient_type, false);
- sp_gradient_selector_attrs_to_gradient(gr, psel);
+ psel->pushAttrsToGradient( gr );
}
}
if (items) {
- SPPattern *pattern = sp_paint_selector_get_pattern (psel);
+ SPPattern *pattern = psel->getPattern();
if (!pattern) {
/* No Pattern in paint selector should mean that we just
index 50ee632cd1e5af7b5fd695397d5a86db608cb934..602adec4fd4c47f004321da1078b0384b70359fd 100644 (file)
float alpha = 0;
guint32 rgb = 0;
- swsel->_csel->base->getColorAlpha( color, &alpha );
+ swsel->_csel->base->getColorAlpha( color, alpha );
rgb = color.toRGBA32( 0x00 );
// TODO replace with generic shared code that also handles icc-color