/*
* Gradient vector selection widget
*
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* bulia byak <buliabyak@users.sf.net>
* MenTaLguY <mental@rydia.net>
* Jon A. Cruz <jon@joncruz.org>
* Abhishek Sharma
*
* Copyright (C) 2001-2002 Lauris Kaplinski
* Copyright (C) 2001 Ximian, Inc.
* Copyright (C) 2004 Monash University
* Copyright (C) 2004 David Turner
* Copyright (C) 2006 MenTaLguY
* Copyright (C) 2010 Jon A. Cruz
*
* Released under GNU GPL, read the file 'COPYING' for more information
*
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <glibmm.h>
#include "gradient-vector.h"
#include "ui/widget/color-preview.h"
#include "verbs.h"
#include "macros.h"
#include <set>
#include "../widgets/gradient-image.h"
#include "../inkscape.h"
#include "../document-private.h"
#include "../gradient-chemistry.h"
#include "io/resource.h"
#include "../preferences.h"
#include "svg/css-ostringstream.h"
#include "sp-stop.h"
#include "selection-chemistry.h"
#include "style.h"
#include "sp-linear-gradient.h"
#include "sp-radial-gradient.h"
#include "desktop.h"
#include "layer-manager.h"
#include "document-undo.h"
#include "ui/dialog-events.h"
#include "ui/selected-color.h"
#include "ui/widget/color-notebook.h"
using Inkscape::DocumentUndo;
enum {
};
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
// TODO FIXME kill these globals!!!
static gint x = -1000, y = -1000, w = 0, h = 0; // impossible original values to make sure they are read from prefs
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
{
G_TYPE_NONE, 1,
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
}
{
#if GTK_CHECK_VERSION(3,0,0)
#endif
}
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
{
}
}
#if GTK_CHECK_VERSION(3,0,0)
}
#else
}
#endif
}
{
if (doc) {
} else {
}
return gvs;
}
void sp_gradient_vector_selector_set_gradient(SPGradientVectorSelector *gvs, SPDocument *doc, SPGradient *gr)
{
// g_message("sp_gradient_vector_selector_set_gradient(%p, %p, %p) [%s] %d %d", gvs, doc, gr,
// (gr ? gr->getId():"N/A"),
// (gr ? gr->isSwatch() : -1),
// (gr ? gr->isSolid() : -1));
/* Disconnect signals */
}
}
// Connect signals
if (doc) {
gvs->defs_release_connection = doc->getDefs()->connectRelease(sigc::bind<1>(sigc::ptr_fun(&sp_gvs_defs_release), gvs));
gvs->defs_modified_connection = doc->getDefs()->connectModified(sigc::bind<2>(sigc::ptr_fun(&sp_gvs_defs_modified), gvs));
}
if (gr) {
gvs->gradient_release_connection = gr->connectRelease(sigc::bind<1>(sigc::ptr_fun(&sp_gvs_gradient_release), gvs));
}
// Harder case - keep document, rebuild list and stuff
// fixme: (Lauris)
}
/* The case of setting NULL -> NULL is not very interesting */
}
{
}
{
}
{
if (!id) {
}
if (strlen(id) > 14 && (!strncmp (id, "linearGradient", 14) || !strncmp (id, "radialGradient", 14)))
}
/*
* Ellipse text if longer than maxlen, "50% start text + ... + ~50% end text"
* Text should be > length 8 or just return the original text
*/
{
}
return src;
}
{
/* Clear old list, if there is any */
/* Pick up all gradients with vectors */
}
}
}
/* Get usage count of all the gradients */
} else if (!gl) {
} else {
while (gl) {
}
}
}
/*
* Return a "HHSSLL" version of the first stop color so we can sort by it
*/
{
}
static GSList *get_all_doc_items(GSList *list, SPObject *from, bool onlyvisible, bool onlysensitive, bool ingroups, GSList const *exclude)
{
if (SP_IS_ITEM(child)) {
}
}
}
return list;
}
/*
* Return a SPItem's gradient
*/
{
if (item_paint->isPaintserver()) {
}
}
return NULL;
}
/*
* Map each gradient to its usage count for both fill and stroke styles
*/
{
if (!doc)
return;
GSList *all_list = get_all_doc_items(NULL, doc->getRoot(), onlyvisible, onlysensitive, ingroups, NULL);
continue;
if (gr) {
}
if (gr) {
}
}
}
{
/* Disconnect gradient */
}
/* Rebuild GUI */
}
{
/* Disconnect gradient as well */
}
/* Rebuild GUI */
}
static void sp_gvs_defs_modified(SPObject */*defs*/, guint /*flags*/, SPGradientVectorSelector *gvs)
{
/* fixme: We probably have to check some flags here (Lauris) */
}
{
swatched = true;
sp_gvs_rebuild_gui_full(this);
}
/*##################################################################
### Vector Editing Widget
##################################################################*/
#include "widgets/widget-sizes.h"
#include "xml/node-event-vector.h"
#include "svg/svg-color.h"
#include "ui/widget/color-notebook.h"
static gint sp_gradient_vector_dialog_delete(GtkWidget *widget, GdkEvent *event, GtkWidget *dialog);
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
static void sp_gradient_vector_color_dragged(Inkscape::UI::SelectedColor *selected_color, GObject *object);
static void sp_gradient_vector_color_changed(Inkscape::UI::SelectedColor *selected_color, GObject *object);
static void grad_edit_dia_stop_added_or_removed(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node */*child*/, Inkscape::XML::Node */*ref*/, gpointer data)
{
}
//FIXME!!! We must also listen to attr changes on all children (i.e. stops) too,
//otherwise the dialog does not reflect undoing color or offset change. This is a major
//hassle, unless we have a "one of the descendants changed in some way" signal.
{
grad_edit_dia_stop_added_or_removed, /* child_added */
grad_edit_dia_stop_added_or_removed, /* child_removed */
NULL, /* attr_changed*/
NULL, /* content_changed */
NULL /* order_changed */
};
{
int i = 0;
/* count stops */
if (SP_IS_STOP(ochild)) {
i++;
}
}
if (i < 1) {
return;
}
if (i < 2) {
}
}
{
int i = 0;
if (SP_IS_STOP(ochild)) {
break;
}
i++;
}
}
}
{
if (!SP_IS_GRADIENT(gradient)) {
return;
}
/* Clear old list, if there is any */
if (!combo_box) {
return;
}
if (!store) {
return;
}
/* Populate the combobox store */
if (SP_IS_STOP(ochild)) {
}
}
}
if (!sl) {
} else {
Inkscape::UI::Widget::ColorPreview *cpv = Gtk::manage(new Inkscape::UI::Widget::ColorPreview(stop->get_rgba32()));
}
}
}
/* Set history */
} else {
}
}
// user selected existing stop from list
{
if (!stop) {
return;
}
// set its color, from the stored array
bool isEndStop = false;
} else {
isEndStop = true;
gtk_adjustment_set_lower (adj, 0);
}
} else {
isEndStop = true;
}
//fixme: does this work on all possible input gradients?
if (!isEndStop) {
} else {
}
}
{
if (combo_box) {
}
}
return stop;
}
{
if (!blocked) {
if (stop) {
_("Change gradient stop offset"));
}
}
}
{
return SP_RGBA32_U_COMPOSE(r, g, b, a);
}
{
if (!stop) {
return;
}
}
}
} else {
}
gchar c[64];
sp_svg_write_color(c, sizeof(c), cnew);
_("Add gradient stop"));
}
{
if (!stop) {
return;
}
if (next) {
}
if (prev) {
}
}
_("Delete gradient stop"));
}
}
{
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
gtk_widget_show(w);
/* ComboBox of stops with 3 columns,
* The color preview, the label and a pointer to the SPStop
*/
/* Add and Remove buttons */
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
// TRANSLATORS: "Stop" means: a "phase" of a gradient
gtk_widget_show(b);
gtk_widget_set_tooltip_text(b, _("Add another control stop to gradient"));
b = gtk_button_new_with_label(_("Delete stop"));
gtk_widget_show(b);
gtk_widget_set_tooltip_text(b, _("Delete current control stop from gradient"));
/* Offset Slider and stuff */
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
/* Label */
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
gtk_widget_show(l);
/* Adjustment */
if (!stop) {
return NULL;
}
/* Slider */
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
/* Spinbutton */
} else {
}
/* Signals */
// g_signal_connect(G_OBJECT(slider), "changed", G_CALLBACK(offsliderChanged), vb);
// TRANSLATORS: "Stop" means: a "phase" of a gradient
f = gtk_frame_new(_("Stop Color"));
gtk_widget_show(f);
selected_color->signal_dragged.connect(sigc::bind(sigc::ptr_fun(&sp_gradient_vector_color_dragged), selected_color, G_OBJECT(vb)));
selected_color->signal_dragged.connect(sigc::bind(sigc::ptr_fun(&sp_gradient_vector_color_changed), selected_color, G_OBJECT(vb)));
color_selector->show();
/*
gtk_widget_show(csel);
gtk_container_add(GTK_CONTAINER(f), csel);
g_signal_connect(G_OBJECT(csel), "dragged", G_CALLBACK(sp_gradient_vector_color_dragged), vb);
g_signal_connect(G_OBJECT(csel), "changed", G_CALLBACK(sp_gradient_vector_color_changed), vb);
*/
if (select_stop) {
}
return vb;
}
{
if (x == -1000 || y == -1000) {
}
if (w ==0 || h == 0) {
}
if (x<0) {
x=0;
}
if (y<0) {
y=0;
}
if (x != 0 || y != 0) {
} else {
}
if (w && h) {
}
conn = new sigc::connection(INKSCAPE.signal_activate_desktop.connect(sigc::bind(sigc::ptr_fun(&sp_transientize_callback), &wd)));
sigc::bind(sigc::ptr_fun(&sp_gradient_vector_dialog_delete), (GtkWidget *) NULL, (GdkEvent *) NULL, (GtkWidget *) NULL)
)));
conn = new sigc::connection(INKSCAPE.signal_dialogs_hide.connect(sigc::bind(sigc::ptr_fun(>k_widget_hide), dlg)));
conn = new sigc::connection(INKSCAPE.signal_dialogs_unhide.connect(sigc::bind(sigc::ptr_fun(>k_widget_show), dlg)));
/* Connect signals */
} else {
// FIXME: temp fix for 0.38
// Simply load_gradient into the editor does not work for multi-stop gradients,
// as the stop list and other widgets are in a wrong state and crash readily.
// Instead we just delete the window (by sending the delete signal)
// and call sp_gradient_vector_editor_new again, so it creates the window anew.
}
return dlg;
}
{
release_connection = static_cast<sigc::connection *>(g_object_get_data(G_OBJECT(widget), "gradient_release_connection"));
modified_connection = static_cast<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;
}
// get the color selector
SelectedColor *csel = static_cast<SelectedColor*>(g_object_get_data(G_OBJECT(widget), "cselector"));
/* Fill preview */
// Once the user edits a gradient, it stops being auto-collectable
}
} else { // no gradient, disable everything
}
}
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
{
sigc::connection *conn = static_cast<sigc::connection *>(g_object_get_data(obj, "desktop-activate-connection"));
conn->disconnect();
delete conn;
conn->disconnect();
delete conn;
conn->disconnect();
delete conn;
conn->disconnect();
delete conn;
}
static gboolean sp_gradient_vector_dialog_delete(GtkWidget */*widget*/, GdkEvent */*event*/, GtkWidget */*dialog*/)
{
if (x<0) {
x=0;
}
if (y<0) {
y=0;
}
return FALSE; // which means, go ahead and destroy it
}
/* Widget destroy handler */
#if GTK_CHECK_VERSION(3,0,0)
#else
#endif
{
sigc::connection *release_connection = static_cast<sigc::connection *>(g_object_get_data(G_OBJECT(object), "gradient_release_connection"));
sigc::connection *modified_connection = static_cast<sigc::connection *>(g_object_get_data(G_OBJECT(object), "gradient_modified_connection"));
if (gradient) {
}
}
SelectedColor *selected_color = static_cast<SelectedColor *>(g_object_get_data(G_OBJECT(object), "cselector"));
if (selected_color) {
delete selected_color;
}
}
{
}
static void sp_gradient_vector_gradient_modified(SPObject *object, guint /*flags*/, GtkWidget *widget)
{
if (!blocked) {
}
}
static void sp_gradient_vector_color_dragged(Inkscape::UI::SelectedColor *selected_color, GObject *object)
{
if (blocked) {
return;
}
if (!gradient) {
return;
}
/* Our master gradient has changed */
}
ngr->ensureVector();
if (!stop) {
return;
}
stop->currentColor = false;
}
static void sp_gradient_vector_color_changed(Inkscape::UI::SelectedColor *selected_color, GObject *object)
{
(void)selected_color;
if (updating_color) {
return;
}
if (blocked) {
return;
}
if (!gradient) {
return;
}
/* Our master gradient has changed */
}
ngr->ensureVector();
/* Set start parameters */
/* We rely on normalized vector, i.e. stops HAVE to exist */
if (!stop) {
return;
}
SelectedColor *csel = static_cast<SelectedColor *>(g_object_get_data(G_OBJECT(object), "cselector"));
float alpha = 0;
// g_snprintf(c, 256, "stop-color:#%06x;stop-opacity:%g;", rgb >> 8, static_cast<gdouble>(alpha));
//stop->getRepr()->setAttribute("style", c);
_("Change gradient stop color"));
// Set the color in the selected stop after change
if (combo_box) {
Inkscape::UI::Widget::ColorPreview *cp = Gtk::manage(new Inkscape::UI::Widget::ColorPreview(stop->get_rgba32()));
}
}
}
/*
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:fileencoding=utf-8:textwidth=99 :