gradient-toolbar.cpp revision ded1f8031114b632def0af23c46f48b7e1365c83
/*
* 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 "ui/widget/color-preview.h"
#include "verbs.h"
#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 "document-undo.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 "gradient-selector.h"
#include "selection.h"
#include "ui/icon-names.h"
#include "../ege-adjustment-action.h"
#include "../ege-output-action.h"
#include "../ege-select-one-action.h"
#include "../ink-action.h"
#include "../ink-comboboxentry-action.h"
#include "sp-stop.h"
#include "svg/css-ostringstream.h"
#include "svg/svg-color.h"
#include "desktop-style.h"
#include "gradient-context.h"
#include "toolbox.h"
using Inkscape::DocumentUndo;
void gr_apply_gradient_to_item( SPItem *item, SPGradient *gr, SPGradientType initialType, Inkscape::PaintTarget initialMode, Inkscape::PaintTarget mode );
gboolean gr_vector_list(GtkWidget *combo_box, SPDesktop *desktop, bool selection_empty, SPGradient *gr_selected, bool gr_multi);
void gr_read_selection( Inkscape::Selection *selection, GrDrag *drag, SPGradient *&gr_selected, bool &gr_multi, SPGradientSpread &spr_selected, bool &spr_multi );
static gboolean update_stop_list( GtkWidget *stop_combo, SPGradient *gradient, SPStop *new_stop, GtkWidget *widget, bool gr_multi);
static void select_stop_in_list( GtkWidget *combo_box, SPGradient *gradient, SPStop *new_stop, GtkWidget *data, gboolean block);
static void select_stop_by_drag( GtkWidget *combo_box, SPGradient *gradient, SPEventContext *ev, GtkWidget *data);
//########################
//## Gradient ##
//########################
void gr_apply_gradient_to_item( SPItem *item, SPGradient *gr, SPGradientType initialType, Inkscape::PaintTarget initialMode, Inkscape::PaintTarget mode )
{
if (style
if ( SP_IS_LINEARGRADIENT(server) ) {
} else if ( SP_IS_RADIALGRADIENT(server) ) {
}
}
else if (initialMode == mode)
{
}
}
/**
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 initialType = static_cast<SPGradientType>(prefs->getInt("/tools/gradient/newgradient", SP_GRADIENT_TYPE_LINEAR));
Inkscape::PaintTarget initialMode = (prefs->getInt("/tools/gradient/newfillorstroke", 1) != 0) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE;
// 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, initialType, initialMode, draggable->fill_or_stroke);
}
return;
}
// If no drag or no dragger selected, act on selection
}
}
gboolean gr_vector_list(GtkWidget *combo_box, SPDesktop *desktop, bool selection_empty, SPGradient *gr_selected, bool gr_multi)
{
if (blocked) {
return sensitive;
}
/* Clear old list, if there is any */
}
}
if (!gl) {
// The document has no gradients
} else if (selection_empty) {
// Document has gradients, but nothing is currently selected.
} else {
if (gr_selected == NULL) {
}
if (gr_multi) {
}
while (gl) {
if (gradient == gr_selected) {
}
idx ++;
}
}
}
else {
}
return sensitive;
}
/*
* Get the gradient of the selected desktop item
* This is gradient containing the repeat settings, not the underlying "getVector" href linked gradient.
*/
{
SPGradient *gradient = 0;
SPPaintServer *server = 0;
}
}
if ( SP_IS_GRADIENT(server) ) {
}
}
gradient = 0;
}
if (gradient) {
}
}
/*
* Get the current selection and dragger status from the desktop
*/
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 {
}
}
}
}
}
}
/*
* Core function, setup all the widgets whenever something changes on the desktop
*/
{
if (blocked)
return;
if (!desktop) {
return;
}
if (selection) {
if (ev) {
}
SPGradient *gr_selected = 0;
bool gr_multi = false;
bool spr_multi = false;
if ( gradient_combo ) {
gboolean sensitive = gr_vector_list(gradient_combo, desktop, selection->isEmpty(), gr_selected, gr_multi);
EgeSelectOneAction *gradient_action = (EgeSelectOneAction *) g_object_get_data(G_OBJECT(widget), "gradient_select_combo_action");
}
EgeSelectOneAction* spread = (EgeSelectOneAction *) g_object_get_data(G_OBJECT(widget), "gradient_select_repeat_action");
if (gr_selected) {
}
InkAction *reverse = (InkAction *) g_object_get_data(G_OBJECT(widget), "gradient_stops_reverse_action");
EgeSelectOneAction *stops_action = (EgeSelectOneAction *) g_object_get_data(G_OBJECT(widget), "gradient_stops_combo_action");
if ( stops_combo ) {
}
//sp_gradient_vector_widget_load_gradient(widget, gr_selected);
}
}
{
if (act1) {
if ( GTK_IS_COMBO_BOX(combodata) ) {
}
}
return combo_box;
}
static void gr_tb_selection_modified(Inkscape::Selection *selection, guint /*flags*/, gpointer data)
{
}
{
}
{
}
{
}
connection->disconnect();
delete connection;
}
{
if ( cb ) {
}
}
return stop;
}
{
}
static void sp_gradient_vector_gradient_modified(SPObject *object, guint /*flags*/, GtkWidget *widget)
{
if (!blocked) {
}
}
{
g_message("Load gradient");
release_connection = (sigc::connection *)g_object_get_data(G_OBJECT(widget), "gradient_release_connection");
modified_connection = (sigc::connection *)g_object_get_data(G_OBJECT(widget), "gradient_modified_connection");
if (old) {
}
if (gradient) {
if (!release_connection) {
}
if (!modified_connection) {
}
*release_connection = gradient->connectRelease(sigc::bind<1>(sigc::ptr_fun(&sp_gradient_vector_gradient_release), widget));
*modified_connection = gradient->connectModified(sigc::bind<2>(sigc::ptr_fun(&sp_gradient_vector_gradient_modified), widget));
} else {
if (release_connection) {
delete release_connection;
}
if (modified_connection) {
delete modified_connection;
}
}
}
if (gradient) {
gradient->ensureVector();
if (!stop) {
return;
}
// Once the user edits a gradient, it stops being auto-collectable
}
} else { // no gradient, disable everything
}
}
{
if (!desktop) {
return;
}
if (!selection) {
return;
}
if (rc) {
}
}
{
if (!desktop) {
return;
}
if (!selection) {
return;
}
if (ev) {
}
if (drag) {
drag->deleteSelected();
}
}
{
if ( active ) {
} else {
}
}
{
}
/*
* Change desktop drag selection to this stop
*/
{
return;
if (!drag) {
return;
}
}
static void select_stop_by_drag(GtkWidget *combo_box, SPGradient *gradient, SPEventContext *ev, GtkWidget *data)
{
return;
return;
}
gint n = 0;
// for all selected draggers
// for all draggables of dragger
n++;
}
if (n > 1) {
// Mulitple stops selected
if (!store) {
return;
}
EgeAdjustmentAction* act = (EgeAdjustmentAction *)g_object_get_data( G_OBJECT(data), "offset_action");
if (act) {
}
return;
}
if (!vector)
return;
switch (draggable->point_type) {
case POINT_LG_MID:
case POINT_RG_MID1:
case POINT_RG_MID2:
{
}
break;
case POINT_LG_END:
case POINT_RG_R1:
case POINT_RG_R2:
{
}
break;
default:
break;
}
}
}
}
static void select_stop_in_list( GtkWidget *combo_box, SPGradient *gradient, SPStop *new_stop, GtkWidget *data, gboolean block)
{
int i = 0;
if (SP_IS_STOP(ochild)) {
return;
}
i++;
}
}
}
static gboolean update_stop_list( GtkWidget *stop_combo, SPGradient *gradient, SPStop *new_stop, GtkWidget *widget, bool gr_multi)
{
if (!stop_combo) {
return sensitive;
}
if (!store) {
return sensitive;
}
/* Clear old list, if there is any */
if (!SP_IS_GRADIENT(gradient)) {
return sensitive;
}
/* Populate the combobox store */
if (SP_IS_STOP(ochild)) {
}
}
}
if (!sl) {
} else {
Inkscape::UI::Widget::ColorPreview *cpv = Gtk::manage(new Inkscape::UI::Widget::ColorPreview(sp_stop_get_rgba32(stop)));
}
}
}
if (gr_multi) {
}
} else {
}
return sensitive;
}
{
EgeSelectOneAction* act1 = (EgeSelectOneAction *)g_object_get_data( G_OBJECT(widget), "gradient_select_combo_action");
if (act1) {
return gr;
}
}
return gr;
}
/*
static void gr_edit(GtkWidget *button, GtkWidget *widget)
{
SPGradient *gr = gr_get_selected_gradient(widget);
if (gr) {
GtkWidget *dialog = sp_gradient_vector_editor_new(gr);
gtk_widget_show(dialog);
}
}
*/
{
if (!stop) {
return;
}
EgeAdjustmentAction* act = (EgeAdjustmentAction *)g_object_get_data( G_OBJECT(data), "offset_action");
if (!act) {
return;
}
bool isEndStop = false;
} else {
isEndStop = true;
}
} else {
isEndStop = true;
}
}
/*
* Callback functions for user actions
*/
{
gint typemode = ege_select_one_action_get_active( act ) == 0 ? SP_GRADIENT_TYPE_LINEAR : SP_GRADIENT_TYPE_RADIAL;
}
{
Inkscape::PaintTarget fsmode = (ege_select_one_action_get_active( act ) == 0) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE;
}
/*
* User selected a gradient from the combobox
*/
{
if (blocked) {
return;
}
}
if (gr) {
_("Assign gradient to object"));
}
}
{
if (blocked) {
return;
}
SPGradient *gradient = 0;
if (gradient) {
gradient->updateRepr();
_("Set gradient repeat"));
}
}
/*
* User selected a stop from the combobox
*/
{
if (blocked) {
return;
}
}
/*
* User changed the offset
*/
{
if (blocked) {
return;
}
if (stop) {
_("Change gradient stop offset"));
}
}
/*
*/
{
if (!rendered) {
}
}
/**
* Gradient auxiliary toolbar construction and setup.
*
*/
{
/* New gradient linear or radial */
{
0, _("radial"), 1, _("Create radial (elliptic or circular) gradient"), 2, INKSCAPE_ICON("paint-gradient-radial"), -1 );
EgeSelectOneAction* act = ege_select_one_action_new( "GradientNewTypeAction", (""), (""), NULL, GTK_TREE_MODEL(model) );
gint mode = prefs->getInt("/tools/gradient/newgradient", SP_GRADIENT_TYPE_LINEAR) != SP_GRADIENT_TYPE_LINEAR;
}
/* New gradient on fill or stroke*/
{
EgeSelectOneAction* act = ege_select_one_action_new( "GradientNewFillStrokeAction", (""), (""), NULL, GTK_TREE_MODEL(model) );
Inkscape::PaintTarget fsmode = (prefs->getInt("/tools/gradient/newfillorstroke", 1) != 0) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE;
}
/* Gradient Select list*/
{
EgeSelectOneAction* act1 = ege_select_one_action_new( "GradientSelectGradientAction", _("Select"), ("Choose a gradient"), NULL, GTK_TREE_MODEL(store) );
}
// Gradient Repeat type
{
(// TRANSLATORS: for info, see http://www.w3.org/TR/2000/CR-SVG-20000802/pservers.html#LinearGradientSpreadMethodAttribute
_("Whether to fill with flat color beyond the ends of the gradient vector "
"(spreadMethod=\"pad\"), or repeat the gradient in the same direction "
"(spreadMethod=\"repeat\"), or repeat the gradient in alternating opposite "
"directions (spreadMethod=\"reflect\")")),
}
/* Gradient Stop list */
{
EgeSelectOneAction* act1 = ege_select_one_action_new( "GradientEditStopsAction", _("Stops"), _("Select a stop for the current gradient"), NULL, GTK_TREE_MODEL(store) );
}
/* Offset */
{
EgeAdjustmentAction* eact = 0;
_("Offset"), _("Offset:"), _("Offset of selected stop"),
"/tools/gradient/stopoffset", 0,
0.0, 1.0, 0.01, 0.1,
0, 0, 0,
, 0.01, 2, 1.0);
}
/* Add stop */
{
_("Insert new stop"),
_("Insert new stop"),
INKSCAPE_ICON("node-add"),
}
/* Delete stop */
{
_("Delete stop"),
_("Delete stop"),
INKSCAPE_ICON("node-delete"),
}
/* Reverse */
{
_("Reverse"),
_("Reverse the direction of the gradient"),
INKSCAPE_ICON("object-flip-horizontal"),
}
// Gradients Linked toggle
{
_("Link gradients"),
_("Link gradients to change all related gradients"),
INKSCAPE_ICON("object-unlocked"),
}
// connect to selection modified and changed signals
selection->connectModified(sigc::bind(sigc::ptr_fun(&gr_tb_selection_modified), (gpointer) holder)));
desktop->connectToolSubselectionChanged( sigc::bind(sigc::ptr_fun(&gr_drag_selection_changed), (gpointer) holder)));
// when holder 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), GTK_WIDGET(holder)));
*modified_connection = document->getDefs()->connectModified(sigc::bind<2>(sigc::ptr_fun(&gr_defs_modified), GTK_WIDGET(holder)));
// when holder is destroyed, disconnect
}
/*
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 :