fill-style.cpp revision 0c13cd8bc2121c9e2e1850899d4bda2cd85840ca
/** @file
* @brief Fill style widget
*/
/* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* Frank Felfe <innerspace@iname.com>
* bulia byak <buliabyak@users.sf.net>
*
* Copyright (C) 1999-2005 authors
* Copyright (C) 2001-2002 Ximian, Inc.
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#define noSP_FS_VERBOSE
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "desktop-handles.h"
#include "desktop-style.h"
#include "display/sp-canvas.h"
#include "document-private.h"
#include "gradient-chemistry.h"
#include "inkscape.h"
#include "selection.h"
#include "sp-linear-gradient.h"
#include "sp-pattern.h"
#include "sp-radial-gradient.h"
#include "style.h"
#include "widgets/paint-selector.h"
#include "widgets/sp-widget.h"
#include "widgets/fill-style.h"
// These can be deleted once we sort out the libart dependence.
#define ART_WIND_RULE_NONZERO 0
SPPaintSelector *psel );
SPPaintSelector *psel );
static void sp_fill_style_widget_change_subselection ( Inkscape::Application *inkscape, SPDesktop *desktop, SPWidget *spw );
SPPaintSelector *psel );
sp_fill_style_widget_new (void)
{
spw );
spw );
spw );
spw );
//FIXME: switch these from spw signals to global inkscape object signals; spw just retranslates
//those anyway; then eliminate spw
g_signal_connect (INKSCAPE, "change_subselection", G_CALLBACK (sp_fill_style_widget_change_subselection), spw);
return spw;
} // end of sp_fill_style_widget_new()
static void
{
#ifdef SP_FS_VERBOSE
g_print ( "Fill style widget constructed: inkscape %p\n",
#endif
}
} // end of sp_fill_style_widget_construct()
static void
SPPaintSelector */*psel*/ )
{
if (flags & ( SP_OBJECT_MODIFIED_FLAG |
{
#ifdef SP_FS_VERBOSE
g_message("sp_fill_style_widget_modify_selection()");
#endif
}
}
static void
SPDesktop */*desktop*/,
{
}
static void
SPPaintSelector */*psel*/ )
{
}
/**
* \param sel Selection to use, or NULL.
*/
static void
{
return;
g_object_set_data (G_OBJECT (spw), "local", GINT_TO_POINTER (FALSE)); // local change; do nothing, but reset the flag
return;
}
// create temporary style
// query style from desktop into it. This returns a result flag and fills query with the style of subselection, if any, or selection
switch (result) {
case QUERY_STYLE_NOTHING:
{
/* No paint at all */
break;
}
case QUERY_STYLE_SINGLE:
case QUERY_STYLE_MULTIPLE_AVERAGED: // TODO: treat this slightly differently, e.g. display "averaged" somewhere in paint selector
{
} else if (SP_IS_LINEARGRADIENT (server)) {
SP_GRADIENT_SPREAD(lg) );
} else if (SP_IS_RADIALGRADIENT (server)) {
SP_GRADIENT_SPREAD (rg) );
} else if (SP_IS_PATTERN (server)) {
}
}
break;
}
{
break;
}
}
}
static void
{
return;
#ifdef SP_FS_VERBOSE
#endif
/* TODO: Does this work? */
/* TODO: Not really, here we have to get old color back from object */
/* Instead of relying on paint widget having meaningful colors set */
}
{
return;
sp_repr_css_set_property(css, "fill-rule", mode == SPPaintSelector::FILLRULE_EVENODD? "evenodd":"nonzero");
_("Change fill rule"));
}
/**
This is called repeatedly while you are dragging a color slider, only for flat color
modes. Previously it set the color in style but did not update the repr for efficiency, however
this was flakey and didn't buy us almost anything. So now it does the same as _changed, except
lumps all its changes for undo.
*/
static void
{
return;
}
return;
}
// previous local flag not cleared yet;
// this means dragged events come too fast, so we better skip this one to speed up display
// (it's safe to do this in any case)
return;
}
case SPPaintSelector::MODE_COLOR_RGB:
case SPPaintSelector::MODE_COLOR_CMYK:
{
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
break;
}
default:
g_warning ( "file %s: line %d: Paint %d should not emit 'dragged'",
break;
}
}
/**
This is called (at least) when:
1 paint selector mode is switched (e.g. flat color -> gradient)
2 you finished dragging a gradient node and released mouse
3 you changed a gradient selector parameter (e.g. spread)
Must update repr.
*/
static void
{
#ifdef SP_FS_VERBOSE
#endif
return;
}
if (!desktop) {
return;
}
case SPPaintSelector::MODE_EMPTY:
// This should not happen.
g_warning ( "file %s: line %d: Paint %d should not emit 'changed'",
break;
case SPPaintSelector::MODE_MULTIPLE:
// This happens when you switch multiple objects with different gradients to flat color;
// nothing to do here.
break;
case SPPaintSelector::MODE_NONE:
{
_("Remove fill"));
break;
}
case SPPaintSelector::MODE_COLOR_RGB:
case SPPaintSelector::MODE_COLOR_CMYK:
{
// FIXME: fix for GTK breakage, see comment in SelectedStyle::on_opacity_changed; here it results in losing release events
_("Set fill color"));
// resume interruptibility
// on release, toggle undo_label so that the next drag will not be lumped with this one
if (undo_label == undo_label_1)
else
break;
}
case SPPaintSelector::MODE_SWATCH:
if (items) {
// HACK: reset fill-opacity - that 0.75 is annoying; BUT remove this when we have an opacity slider for all tabs
if (!vector) {
/* No vector in paint selector should mean that we just changed mode */
guint32 common_rgb = 0;
if (result == QUERY_STYLE_MULTIPLE_SAME) {
} else {
}
}
//FIXME: see above
if (!vector) {
gradient_type, true);
} else {
}
}
} else {
* this gradient type. */
//FIXME: see above
}
}
_("Set gradient on fill"));
}
break;
case SPPaintSelector::MODE_PATTERN:
if (items) {
if (!pattern) {
/* No Pattern in paint selector should mean that we just
* changed mode - dont do jack.
*/
} else {
// HACK: reset fill-opacity - that 0.75 is annoying; BUT remove this when we have an opacity slider for all tabs
// cannot just call sp_desktop_set_style, because we don't want to touch those
// objects who already have the same root pattern but through a different href
// chain. FIXME: move this to a sp_item_set_pattern
// only if this object's pattern is not rooted in our selected pattern, apply
continue;
}
}
} // end if
_("Set pattern on fill"));
} // end if
break;
case SPPaintSelector::MODE_UNSET:
if (items) {
_("Unset fill"));
}
break;
default:
g_warning ( "file %s: line %d: Paint selector should not be in "
"mode %d",
break;
}
}
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :