fill-style.cpp revision 934b717f7d24a9c9492e7d8b983c8817d1c8aad3
/** @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 "fill-style.h"
#include "fill-n-stroke-factory.h"
// These can be deleted once we sort out the libart dependence.
#define ART_WIND_RULE_NONZERO 0
/* Fill */
static void fillnstroke_fillrule_changed(SPPaintSelector *psel, SPPaintSelector::FillRule mode, SPWidget *spw);
static void fillnstroke_selection_modified(SPWidget *spw, Inkscape::Selection *selection, guint flags, SPPaintSelector *psel);
static void fillnstroke_selection_changed(SPWidget *spw, Inkscape::Selection *selection, SPPaintSelector *psel);
static void fillnstroke_subselection_changed(Inkscape::Application *inkscape, SPDesktop *desktop, SPWidget *spw);
static void fillnstroke_paint_mode_changed(SPPaintSelector *psel, SPPaintSelector::Mode mode, SPWidget *spw);
static void fillnstroke_transientize_called(Inkscape::Application *inkscape, SPDesktop *desktop, SPWidget *spw);
{
}
/**
* Create the fill or stroke style widget, and hook up all the signals.
*/
{
// with or without fillrule selector
psel );
}
//FIXME: switch these from spw signals to global inkscape object signals; spw just retranslates
//those anyway; then eliminate spw
psel );
psel );
spw );
spw );
}
spw );
spw );
spw );
spw );
}
return spw;
}
{
#ifdef SP_FS_VERBOSE
g_print( "[%s] style widget constructed: inkscape %p\n",
#endif
}
}
/**
* On signal modified, invokes an update of the fill or stroke style paint object.
*/
SPPaintSelector * /*psel*/ )
{
if (flags & ( SP_OBJECT_MODIFIED_FLAG |
#ifdef SP_FS_VERBOSE
g_message("fillnstroke_selection_modified()");
#endif
}
}
/**
* On signal selection changed, invokes an update of the fill or stroke style paint object.
*/
SPPaintSelector * /*psel*/ )
{
}
/**
* On signal change subselection, invoke an update of the fill or stroke style widget.
*/
SPDesktop * /*desktop*/,
{
}
/**
* Gets the active fill or stroke style property, then sets the appropriate
* color, alpha, gradient, pattern, etc. for the paint-selector.
*
* @param sel Selection to use, or NULL.
*/
{
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
int result = sp_desktop_query_style(SP_ACTIVE_DESKTOP, query, (kind == FILL) ? QUERY_STYLE_PROPERTY_FILL : QUERY_STYLE_PROPERTY_STROKE);
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
{
}
SPPaintServer *server = (kind == FILL) ? query->getFillPaintServer() : query->getStrokePaintServer();
} 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;
}
}
}
/**
* When the mode is changed, invoke a regular changed handler.
*/
{
return;
}
#ifdef SP_FS_VERBOSE
#endif
/* TODO: Does this work?
* 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");
css = 0;
_("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.
*/
{
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:
{
psel->setFlatColor( SP_ACTIVE_DESKTOP, (kind == FILL) ? "fill" : "stroke", (kind == FILL) ? "fill-opacity" : "stroke-opacity" );
sp_document_maybe_done(sp_desktop_document(SP_ACTIVE_DESKTOP), (kind == FILL) ? undo_F_label : undo_S_label, SP_VERB_DIALOG_FILL_STROKE,
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.
*/
{
#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:
{
css = 0;
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
}
sp_document_maybe_done(sp_desktop_document(desktop), (kind == FILL) ? undo_F_label : undo_S_label, SP_VERB_DIALOG_FILL_STROKE,
// resume interruptibility
}
// on release, toggle undo_label so that the next drag will not be lumped with this one
if (undo_F_label == undo_F_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
css = sp_repr_css_attr_new();
}
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) {
} else {
}
}
} else {
// this gradient type.
//FIXME: see above
}
}
}
if (css) {
css = 0;
}
}
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
continue;
}
// only if this object's pattern is not rooted in our selected pattern, apply
continue;
}
} else {
}
}
css = 0;
} // end if
_("Set pattern on stroke"));
} // end if
break;
case SPPaintSelector::MODE_UNSET:
if (items) {
} else {
}
css = 0;
}
break;
default:
g_warning( "file %s: line %d: Paint selector should not be in "
"mode %d",
break;
}
}
SPDesktop * /*desktop*/,
SPWidget * /*spw*/ )
{
// TODO: Either of these will cause crashes sometimes
// sp_stroke_style_line_update( SP_WIDGET(spw), desktop ? sp_desktop_selection(desktop) : NULL);
// ink_markers_menu_update(spw);
}
/*
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 :