gradient-toolbar.cpp revision 21540d59a919b4404c3f298470257f8b33310351
/*
* Gradient aux toolbar
*
* Authors:
* bulia byak <bulia@dr.com>
* Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
* Abhishek Sharma
*
* Copyright (C) 2007 Johan Engelen
* 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 "preferences.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 "ui/icon-names.h"
#include "toolbox.h"
using Inkscape::DocumentUndo;
//########################
//## 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.
*/
{
SPGradientType new_type = static_cast<SPGradientType>(prefs->getInt("/tools/gradient/newgradient", SP_GRADIENT_TYPE_LINEAR));
// GRADIENTFIXME: make this work for multiple selected draggers.
// 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
}
}
{
_("Assign gradient to object"));
}
{
if (strlen(id) > 15 && (!strncmp (id, "#linearGradient", 15) || !strncmp (id, "#radialGradient", 15)))
}
GtkWidget *gr_vector_list(SPDesktop *desktop, bool selection_empty, SPGradient *gr_selected, bool gr_multi)
{
GtkWidget *m = gtk_menu_new ();
}
}
if (!gl) {
// The document has no gradients
GtkWidget *i = gtk_menu_item_new ();
gtk_container_add (GTK_CONTAINER (i), l);
gtk_widget_show (i);
gtk_menu_shell_append(GTK_MENU_SHELL (m), i);
} else if (selection_empty) {
// Document has gradients, but nothing is currently selected.
GtkWidget *i = gtk_menu_item_new ();
gtk_container_add (GTK_CONTAINER (i), l);
gtk_widget_show (i);
gtk_menu_shell_append(GTK_MENU_SHELL (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_shell_append(GTK_MENU_SHELL (m), i);
}
if (gr_multi) {
GtkWidget *i = gtk_menu_item_new ();
gtk_container_add (GTK_CONTAINER (i), l);
gtk_widget_show (i);
gtk_menu_shell_append(GTK_MENU_SHELL (m), i);
}
while (gl) {
GtkWidget *i = gtk_menu_item_new ();
gtk_widget_show_all (i);
gtk_menu_shell_append(GTK_MENU_SHELL (m), i);
if (gradient == gr_selected) {
}
idx ++;
}
}
else
return om;
}
bool &gr_multi,
bool &spr_multi )
{
// GRADIENTFIXME: make this work for more than one selected dragger?
gradient = 0;
}
if (gr_selected) {
gr_multi = true;
} else {
}
}
if (spread != spr_selected) {
if (spr_selected != INT_MAX) {
spr_multi = true;
} else {
}
}
}
return;
}
// If no selected dragger, read desktop selection
if ( SP_IS_GRADIENT(server) ) {
gradient = 0;
}
if (gr_selected) {
gr_multi = true;
} else {
}
}
if (spread != spr_selected) {
if (spr_selected != INT_MAX) {
spr_multi = true;
} else {
}
}
}
}
if ( SP_IS_GRADIENT(server) ) {
gradient = 0;
}
if (gr_selected) {
gr_multi = true;
} else {
}
}
if (spread != spr_selected) {
if (spr_selected != INT_MAX) {
spr_multi = true;
} else {
}
}
}
}
}
}
{
if (desktop) {
if (selection) {
if (om) {
om = 0;
}
SPGradient *gr_selected = 0;
bool gr_multi = false;
bool spr_multi = false;
gr_read_selection(selection, ev ? ev->get_drag() : 0, gr_selected, gr_multi, spr_selected, spr_multi);
}
}
}
static void
{
}
static void
{
}
static void
{
}
static void
{
}
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() : 0, gr_selected, gr_multi, spr_selected, spr_multi);
{
/* Edit... */
{
gtk_widget_set_tooltip_text(b, _("Edit the stops of the gradient"));
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)
*release_connection = document->getDefs()->connectRelease(sigc::bind<1>(sigc::ptr_fun(&gr_defs_release), widget));
*modified_connection = document->getDefs()->connectModified(sigc::bind<2>(sigc::ptr_fun(&gr_defs_modified), widget));
// when widget is destroyed, disconnect
return widget;
}
{
// TODO replace aux_toolbox_space(tbl, AUX_SPACING);
{
{
NULL,
INKSCAPE_ICON("paint-gradient-linear"),
_("Create linear gradient") );
}
{
NULL,
INKSCAPE_ICON("paint-gradient-radial"),
_("Create radial (elliptic or circular) gradient"));
}
}
// TODO replace aux_toolbox_space(tbl, AUX_SPACING);
// TODO replace aux_toolbox_space(tbl, AUX_SPACING);
{
{
NULL,
INKSCAPE_ICON("object-fill"),
_("Create gradient in the fill"));
}
{
NULL,
INKSCAPE_ICON("object-stroke"),
_("Create gradient in the stroke"));
}
}
// TODO replace aux_toolbox_space(tbl, AUX_SPACING);
{
}
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 :