gradient-toolbar.cpp revision e42e6130e1aca183d24c4e696c9fae555c49beaa
/*
* Gradient aux toolbar
*
* Authors:
* bulia byak <bulia@dr.com>
*
* Copyright (C) 2005 authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "macros.h"
#include "widgets/widget-sizes.h"
#include "widgets/spw-utilities.h"
#include "widgets/spinbutton-events.h"
#include "widgets/gradient-vector.h"
#include "widgets/gradient-image.h"
#include "style.h"
#include "prefs-utils.h"
#include "document-private.h"
#include "desktop.h"
#include "desktop-handles.h"
#include "gradient-context.h"
#include "gradient-drag.h"
#include "sp-linear-gradient.h"
#include "sp-radial-gradient.h"
#include "gradient-chemistry.h"
#include "selection.h"
#include "toolbox.h"
//########################
//## Gradient ##
//########################
}
}
}
}
void
gr_apply_gradient_to_item (SPItem *item, SPGradient *gr, SPGradientType new_type, guint new_fill, bool do_fill, bool do_stroke)
{
if (do_fill) {
if (SP_IS_LINEARGRADIENT (server)) {
} else if (SP_IS_RADIALGRADIENT (server)) {
}
} else if (new_fill) {
}
}
if (do_stroke) {
if (SP_IS_LINEARGRADIENT (server)) {
} else if (SP_IS_RADIALGRADIENT (server)) {
}
} else if (!new_fill) {
}
}
}
/**
Applies gradient vector gr to the gradients attached to the selected dragger of drag, or if none,
to all objects in selection. If there was no previous gradient on an item, uses gradient type and
gradient.
*/
void
{
SPGradientType new_type = (SPGradientType) prefs_get_int_attribute ("tools.gradient", "newgradient", SP_GRADIENT_TYPE_LINEAR);
// First try selected dragger
for (GSList const* i = dragger->draggables; i != NULL; i = i->next) { // for all draggables of dragger
gr_apply_gradient_to_item (draggable->item, gr, new_type, new_fill, draggable->fill_or_stroke, !draggable->fill_or_stroke);
}
return;
}
// If no drag or no dragger selected, act on selection
}
}
void
{
}
gchar *
{
if (strlen(id) > 15 && (!strncmp (id, "#linearGradient", 15) || !strncmp (id, "#radialGradient", 15)))
}
{
GtkWidget *m = gtk_menu_new ();
if (SP_GRADIENT_HAS_STOPS (i->data)) {
}
}
if (!gl) {
GtkWidget *i = gtk_menu_item_new ();
gtk_container_add (GTK_CONTAINER (i), l);
gtk_widget_show (i);
gtk_menu_append (GTK_MENU (m), i);
} else if (selection_empty) {
GtkWidget *i = gtk_menu_item_new ();
gtk_container_add (GTK_CONTAINER (i), l);
gtk_widget_show (i);
gtk_menu_append (GTK_MENU (m), i);
} else {
if (gr_selected == NULL) {
GtkWidget *i = gtk_menu_item_new ();
gtk_container_add (GTK_CONTAINER (i), l);
gtk_widget_show (i);
gtk_menu_append (GTK_MENU (m), i);
}
if (gr_multi) {
GtkWidget *i = gtk_menu_item_new ();
gtk_container_add (GTK_CONTAINER (i), l);
gtk_widget_show (i);
gtk_menu_append (GTK_MENU (m), i);
}
while (gl) {
GtkWidget *i = gtk_menu_item_new ();
gtk_widget_show_all (i);
gtk_menu_append (GTK_MENU (m), i);
if (gradient == gr_selected) {
}
idx ++;
}
}
else
return om;
}
void
gr_read_selection (Inkscape::Selection *selection, GrDrag *drag, SPGradient **gr_selected, bool *gr_multi, SPGradientSpread *spr_selected, bool *spr_multi)
{
for (GSList const* i = dragger->draggables; i != NULL; i = i->next) { // for all draggables of dragger
if (gradient != *gr_selected) {
if (*gr_selected != NULL) {
*gr_multi = true;
} else {
*gr_selected = gradient;
}
}
if (spread != *spr_selected) {
if (*spr_selected != INT_MAX) {
*spr_multi = true;
} else {
*spr_selected = spread;
}
}
}
return;
}
// If no selected dragger, read desktop selection
if (SP_IS_GRADIENT (server)) {
if (gradient != *gr_selected) {
if (*gr_selected != NULL) {
*gr_multi = true;
} else {
*gr_selected = gradient;
}
}
if (spread != *spr_selected) {
if (*spr_selected != INT_MAX) {
*spr_multi = true;
} else {
*spr_selected = spread;
}
}
}
}
if (SP_IS_GRADIENT (server)) {
if (gradient != *gr_selected) {
if (*gr_selected != NULL) {
*gr_multi = true;
} else {
*gr_selected = gradient;
}
}
if (spread != *spr_selected) {
if (*spr_selected != INT_MAX) {
*spr_multi = true;
} else {
*spr_selected = spread;
}
}
}
}
}
}
static void
{
if (!desktop)
return;
if (!selection)
return;
bool gr_multi = false;
bool spr_multi = false;
gr_read_selection (selection, ev? ev->get_drag() : NULL, &gr_selected, &gr_multi, &spr_selected, &spr_multi);
}
static void
{
}
static void
{
}
static void
{
}
static void
{
}
static void
{
if (gr) {
}
}
}
}
connection->disconnect();
delete connection;
}
}
static void
{
if (om) {
if (gr) {
}
}
}
{
bool gr_multi = false;
bool spr_multi = false;
gr_read_selection (selection, ev? ev->get_drag() : NULL, &gr_selected, &gr_multi, &spr_selected, &spr_multi);
{
/* Fork */
{
gtk_tooltips_set_tip(tt, b, _("If the gradient is used by more than one object, create a copy of it for the selected object(s)"), NULL);
gtk_widget_show(b);
}
/* Edit... */
{
gtk_widget_show(b);
}
}
// connect to selection modified and changed signals
));
));
));
// when widget is destroyed, disconnect
// connect to release and modified signals of the defs (i.e. when someone changes gradient)
g_signal_connect (G_OBJECT (SP_DOCUMENT_DEFS (document)), "release", G_CALLBACK (gr_defs_release), widget);
g_signal_connect (G_OBJECT (SP_DOCUMENT_DEFS (document)), "modified", G_CALLBACK (gr_defs_modified), widget);
// when widget is destroyed, disconnect
g_signal_connect(G_OBJECT(widget), "destroy", G_CALLBACK(gr_disconnect_gsignal), G_OBJECT (SP_DOCUMENT_DEFS (document)));
g_signal_connect(G_OBJECT(widget), "destroy", G_CALLBACK(gr_disconnect_gsignal), G_OBJECT (SP_DOCUMENT_DEFS (document)));
return widget;
}
{
{
{
NULL,
"fill_gradient",
_("Create linear gradient"),
tt);
prefs_get_int_attribute ("tools.gradient", "newgradient", SP_GRADIENT_TYPE_LINEAR) == SP_GRADIENT_TYPE_LINEAR);
}
{
NULL,
"fill_radial",
_("Create radial (elliptic or circular) gradient"),
tt);
prefs_get_int_attribute ("tools.gradient", "newgradient", SP_GRADIENT_TYPE_LINEAR) == SP_GRADIENT_TYPE_RADIAL);
}
}
{
{
NULL,
"controls_fill",
_("Create gradient in the fill"),
tt);
}
{
NULL,
"controls_stroke",
_("Create gradient in the stroke"),
tt);
}
}
{
}
return tbl;
}
/*
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 :