index 1bdc49f7e96c6d117e65afb6dfe3a4c7287a2637..e1c30e7aebdf4a5fb21625fe4e48f1a28146fabe 100644 (file)
-#define __SP_FILL_STYLE_C__
-
-/**
- * \brief Fill style widget
- *
- * Authors:
+/** @file
+ * @brief Fill style widget
+ */
+/* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* Frank Felfe <innerspace@iname.com>
* bulia byak <buliabyak@users.sf.net>
#endif
-#include <widgets/sp-widget.h>
-#include <sp-linear-gradient.h>
-#include <sp-pattern.h>
-#include <sp-radial-gradient.h>
-#include <widgets/paint-selector.h>
-#include <style.h>
-#include <gradient-chemistry.h>
-#include <desktop-style.h>
-#include <desktop-handles.h>
-#include <selection.h>
-#include <inkscape.h>
-#include <document-private.h>
-#include <xml/repr.h>
+#include "widgets/sp-widget.h"
+#include "sp-linear-gradient.h"
+#include "sp-pattern.h"
+#include "sp-radial-gradient.h"
+#include "widgets/paint-selector.h"
+#include "style.h"
+#include "gradient-chemistry.h"
+#include "desktop-style.h"
+#include "desktop-handles.h"
+#include "selection.h"
+#include "inkscape.h"
+#include "document-private.h"
+#include "xml/repr.h"
+#include <glibmm/i18n.h>
+#include "display/sp-canvas.h"
// These can be deleted once we sort out the libart dependence.
static void
-sp_fill_style_widget_construct ( SPWidget *spw, SPPaintSelector *psel )
+sp_fill_style_widget_construct( SPWidget *spw, SPPaintSelector */*psel*/ )
{
-
#ifdef SP_FS_VERBOSE
g_print ( "Fill style widget constructed: inkscape %p repr %p\n",
spw->inkscape, spw->repr );
#endif
if (spw->inkscape) {
-
sp_fill_style_widget_update (spw);
-
}
} // end of sp_fill_style_widget_construct()
static void
-sp_fill_style_widget_modify_selection ( SPWidget *spw,
- Inkscape::Selection *selection,
- guint flags,
- SPPaintSelector *psel )
+sp_fill_style_widget_modify_selection( SPWidget *spw,
+ Inkscape::Selection */*selection*/,
+ guint flags,
+ SPPaintSelector */*psel*/ )
{
if (flags & ( SP_OBJECT_MODIFIED_FLAG |
SP_OBJECT_PARENT_MODIFIED_FLAG |
}
static void
-sp_fill_style_widget_change_subselection ( Inkscape::Application *inkscape,
- SPDesktop *desktop,
- SPWidget *spw )
+sp_fill_style_widget_change_subselection( Inkscape::Application */*inkscape*/,
+ SPDesktop */*desktop*/,
+ SPWidget *spw )
{
sp_fill_style_widget_update (spw);
}
static void
-sp_fill_style_widget_change_selection ( SPWidget *spw,
- Inkscape::Selection *selection,
- SPPaintSelector *psel )
+sp_fill_style_widget_change_selection( SPWidget *spw,
+ Inkscape::Selection */*selection*/,
+ SPPaintSelector */*psel*/ )
{
sp_fill_style_widget_update (spw);
}
SPPaintSelector *psel = SP_PAINT_SELECTOR (g_object_get_data (G_OBJECT (spw), "paint-selector"));
// create temporary style
- SPStyle *query = sp_style_new ();
+ SPStyle *query = sp_style_new (SP_ACTIVE_DOCUMENT);
// query style from desktop into it. This returns a result flag and fills query with the style of subselection, if any, or selection
int result = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FILL);
sp_paint_selector_set_fillrule (psel, query->fill_rule.computed == ART_WIND_RULE_NONZERO?
SP_PAINT_SELECTOR_FILLRULE_NONZERO : SP_PAINT_SELECTOR_FILLRULE_EVENODD);
- if (query->fill.set && query->fill.type == SP_PAINT_TYPE_COLOR) {
- gfloat d[3];
- sp_color_get_rgb_floatv (&query->fill.value.color, d);
- SPColor color;
- sp_color_set_rgb_float (&color, d[0], d[1], d[2]);
- sp_paint_selector_set_color_alpha (psel, &color, SP_SCALE24_TO_FLOAT (query->fill_opacity.value));
-
- } else if (query->fill.set && query->fill.type == SP_PAINT_TYPE_PAINTSERVER) {
+ 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));
+ } else if (query->fill.set && query->fill.isPaintserver()) {
SPPaintServer *server = SP_STYLE_FILL_SERVER (query);
}
}
- g_free (query);
+ sp_style_unref(query);
g_object_set_data (G_OBJECT (spw), "update", GINT_TO_POINTER (FALSE));
static void
sp_fill_style_widget_paint_mode_changed ( SPPaintSelector *psel,
- SPPaintSelectorMode mode,
+ SPPaintSelectorMode /*mode*/,
SPWidget *spw )
{
if (g_object_get_data (G_OBJECT (spw), "update"))
}
static void
-sp_fill_style_widget_fillrule_changed ( SPPaintSelector *psel,
+sp_fill_style_widget_fillrule_changed ( SPPaintSelector */*psel*/,
SPPaintSelectorFillRule mode,
SPWidget *spw )
{
sp_repr_css_attr_unref (css);
sp_document_done (SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_FILL_STROKE,
- /* TODO: annotate */ "fill-style.cpp:289");
+ _("Change fill rule"));
}
-static gchar *undo_label_1 = "fill:flatcolor:1";
-static gchar *undo_label_2 = "fill:flatcolor:2";
-static gchar *undo_label = undo_label_1;
+static gchar const *undo_label_1 = "fill:flatcolor:1";
+static gchar const *undo_label_2 = "fill:flatcolor:2";
+static gchar const *undo_label = undo_label_1;
/**
This is called repeatedly while you are dragging a color slider, only for flat color
{
sp_paint_selector_set_flat_color (psel, SP_ACTIVE_DESKTOP, "fill", "fill-opacity");
sp_document_maybe_done (sp_desktop_document(SP_ACTIVE_DESKTOP), undo_label, SP_VERB_DIALOG_FILL_STROKE,
- /* TODO: annotate */ "fill-style.cpp:329");
+ _("Set fill color"));
g_object_set_data (G_OBJECT (spw), "local", GINT_TO_POINTER (TRUE)); // local change, do not update from selection
break;
}
sp_repr_css_attr_unref (css);
sp_document_done (document, SP_VERB_DIALOG_FILL_STROKE,
- /* TODO: annotate */ "fill-style.cpp:391");
+ _("Remove fill"));
break;
}
case SP_PAINT_SELECTOR_MODE_COLOR_RGB:
case SP_PAINT_SELECTOR_MODE_COLOR_CMYK:
{
+ // 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");
sp_document_maybe_done (sp_desktop_document(desktop), undo_label, SP_VERB_DIALOG_FILL_STROKE,
- /* TODO: annotate */ "fill-style.cpp:400");
+ _("Set fill color"));
+ // resume interruptibility
+ sp_canvas_end_forced_full_redraws(sp_desktop_canvas(desktop));
// on release, toggle undo_label so that the next drag will not be lumped with this one
if (undo_label == undo_label_1)
if (!vector) {
/* No vector in paint selector should mean that we just changed mode */
- SPStyle *query = sp_style_new ();
- int result = objects_query_fillstroke ((GSList *) items, query, true);
+ SPStyle *query = sp_style_new (SP_ACTIVE_DOCUMENT);
+ int result = objects_query_fillstroke ((GSList *) items, query, true);
guint32 common_rgb = 0;
if (result == QUERY_STYLE_MULTIPLE_SAME) {
- if (query->fill.type != SP_PAINT_TYPE_COLOR) {
+ if (!query->fill.isColor()) {
common_rgb = sp_desktop_get_color(desktop, true);
} else {
- common_rgb = sp_color_get_rgba32_ualpha(&query->fill.value.color, 0xff);
+ common_rgb = query->fill.value.color.toRGBA32( 0xff );
}
vector = sp_document_default_gradient_vector(document, common_rgb);
}
- g_free (query);
+ sp_style_unref(query);
for (GSList const *i = items; i != NULL; i = i->next) {
//FIXME: see above
sp_repr_css_change_recursive(SP_OBJECT_REPR(i->data), css, "style");
if (!vector) {
- sp_item_set_gradient(SP_ITEM(i->data),
+ sp_item_set_gradient(SP_ITEM(i->data),
sp_gradient_vector_for_object(document, desktop, SP_OBJECT(i->data), true),
gradient_type, true);
} else {
sp_repr_css_attr_unref (css);
sp_document_done (document, SP_VERB_DIALOG_FILL_STROKE,
- /* TODO: annotate */ "fill-style.cpp:467");
+ _("Set gradient on fill"));
}
break;
SPObject *selobj = SP_OBJECT (i->data);
SPStyle *style = SP_OBJECT_STYLE (selobj);
- if (style && style->fill.type == SP_PAINT_TYPE_PAINTSERVER) {
+ if (style && style->fill.isPaintserver()) {
SPObject *server = SP_OBJECT_STYLE_FILL_SERVER (selobj);
if (SP_IS_PATTERN (server) && pattern_getroot (SP_PATTERN(server)) == pattern)
// only if this object's pattern is not rooted in our selected pattern, apply
} // end if
sp_document_done (document, SP_VERB_DIALOG_FILL_STROKE,
- /* TODO: annotate */ "fill-style.cpp:514");
+ _("Set pattern on fill"));
} // end if
sp_repr_css_attr_unref (css);
sp_document_done (document, SP_VERB_DIALOG_FILL_STROKE,
- /* TODO: annotate */ "fill-style.cpp:529");
+ _("Unset fill"));
}
break;