gradient-vector.cpp revision ef9d155a8149d4793471047b3836db719b9e0292
#define __SP_GRADIENT_VECTOR_C__
/*
* Gradient vector selection widget
*
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* bulia byak <buliabyak@users.sf.net>
* MenTaLguY <mental@rydia.net>
*
* 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
*
* Released under GNU GPL, read the file 'COPYING' for more information
*
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_STRING_H
#endif
#include "macros.h"
#include "../widgets/gradient-image.h"
#include "../inkscape.h"
#include "../document-private.h"
#include "../gradient-chemistry.h"
#include "gradient-vector.h"
#include "../dialogs/dialog-events.h"
#include "../prefs-utils.h"
#include "svg/css-ostringstream.h"
#include "sp-stop.h"
enum {
};
static GtkVBoxClass *parent_class;
static gint x = -1000, y = -1000, w = 0, h = 0; // impossible original values to make sure they are read from prefs
{
if (!type) {
GtkTypeInfo info = {
"SPGradientVectorSelector",
sizeof (SPGradientVectorSelector),
sizeof (SPGradientVectorSelectorClass),
};
}
return type;
}
static void
{
GTK_TYPE_NONE, 1,
}
static void
{
}
static void
{
}
}
}
{
if (doc) {
} else {
}
return gvs;
}
void
sp_gradient_vector_selector_set_gradient (SPGradientVectorSelector *gvs, SPDocument *doc, SPGradient *gr)
{
/* Disconnect signals */
}
}
/* Connect signals */
if (doc) {
gvs->defs_release_connection = SP_DOCUMENT_DEFS(doc)->connectRelease(sigc::bind<1>(sigc::ptr_fun(&sp_gvs_defs_release), gvs));
gvs->defs_modified_connection = SP_DOCUMENT_DEFS(doc)->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 menus and stuff */
/* fixme: (Lauris) */
}
/* The case of setting NULL -> NULL is not very interesting */
}
{
}
{
}
static void
{
/* Clear old menu, if there is any */
}
/* Create new menu widget */
GtkWidget *m = gtk_menu_new ();
gtk_widget_show (m);
/* Pick up all gradients with vectors */
if (SP_GRADIENT_HAS_STOPS (l->data)) {
}
}
}
GtkWidget *i;
i = gtk_menu_item_new_with_label (_("No document selected"));
gtk_widget_show (i);
gtk_menu_append (GTK_MENU (m), i);
} else if (!gl) {
GtkWidget *i;
i = gtk_menu_item_new_with_label (_("No gradients in document"));
gtk_widget_show (i);
gtk_menu_append (GTK_MENU (m), i);
GtkWidget *i;
i = gtk_menu_item_new_with_label (_("No gradient selected"));
gtk_widget_show (i);
gtk_menu_append (GTK_MENU (m), i);
} else {
while (gl) {
SPGradient *gr;
GtkWidget *i, *w;
/* We have to know: */
/* Gradient destroy */
/* Gradient name change */
i = gtk_menu_item_new ();
gtk_widget_show (i);
w = sp_gradient_image_new (gr);
gtk_widget_show (w);
gtk_widget_show (l);
w = hb;
}
gtk_container_add (GTK_CONTAINER (i), w);
gtk_menu_append (GTK_MENU (m), i);
idx += 1;
}
}
/* Set history */
}
static void
{
/* Hmmm... bad things may happen here, if actual gradient is something new */
/* Namely - menuitems etc. will be fucked up */
/* Hmmm - probably we can just re-set it as menuitem data (Lauris) */
//g_print ("SPGradientVectorSelector: gradient %s activated\n", SP_OBJECT_ID (gr));
//g_print ("SPGradientVectorSelector: become %s after normalization\n", SP_OBJECT_ID (norm));
/* But be careful that we do not have gradient saved anywhere else */
}
/* fixme: Really we would want to use _set_vector */
/* Detach old */
}
/* Attach new */
if (norm) {
gvs->gradient_release_connection = norm->connectRelease(sigc::bind<1>(sigc::ptr_fun(&sp_gvs_gradient_release), gvs));
}
/* We do extra undo push here */
/* If handler has already done it, it is just NOP */
// FIXME: looks like this is never a valid undo step, consider removing this
/* TODO: annotate */ "gradient-vector.cpp:350");
}
}
static void
{
/* Disconnect gradient */
}
/* Rebuild GUI */
}
static void
{
/* Disconnect gradient as well */
}
/* Rebuild GUI */
}
static void
{
/* fixme: We probably have to check some flags here (Lauris) */
}
/*##################################################################
### Vector Editing Widget
##################################################################*/
#include "../widgets/sp-color-notebook.h"
#include "../widgets/sp-color-preview.h"
#include "../widgets/widget-sizes.h"
#include "../xml/node-event-vector.h"
#include "../svg/svg-color.h"
#define PAD 4
static gint sp_gradient_vector_dialog_delete (GtkWidget *widget, GdkEvent *event, GtkWidget *dialog);
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 */
};
static void
{
int i = 0;
/* count stops */
for ( SPObject *ochild = sp_object_first_child(SP_OBJECT(gradient)) ; ochild != NULL ; ochild = SP_OBJECT_NEXT(ochild) ) {
if (SP_IS_STOP (ochild)) {
i++;
}
}
if (i < 1) {
gchar c[64];
}
if (i < 2) {
}
}
static void
{
int i = 0;
for ( SPObject *ochild = sp_object_first_child(SP_OBJECT(gradient)) ; ochild != NULL ; ochild = SP_OBJECT_NEXT(ochild) ) {
if (SP_IS_STOP (ochild)) {
break;
}
i++;
}
}
}
static void
{
if (!SP_IS_GRADIENT (gradient))
return;
/* Clear old menu, if there is any */
}
/* Create new menu widget */
GtkWidget *m = gtk_menu_new ();
gtk_widget_show (m);
for ( SPObject *ochild = sp_object_first_child (SP_OBJECT(gradient)) ; ochild != NULL ; ochild = SP_OBJECT_NEXT(ochild) ) {
if (SP_IS_STOP (ochild)) {
}
}
}
if (!sl) {
gtk_widget_show (i);
gtk_menu_append (GTK_MENU (m), i);
} else {
GtkWidget *i;
i = gtk_menu_item_new ();
gtk_widget_show (i);
gtk_widget_show (l);
gtk_menu_append (GTK_MENU (m), i);
}
}
}
/* Set history */
} else {
}
}
/*user selected existing stop from list*/
static void
{
if (!stop) return;
// set its color, from the stored array
bool isEndStop = false;
} else {
isEndStop = true;
}
} else {
isEndStop = true;
}
//fixme: does this work on all possible input gradients?
if (!isEndStop) {
} else {
}
}
static void
{
if (blocked)
return;
if (!g_object_get_data (G_OBJECT(gtk_menu_get_active (GTK_MENU(gtk_option_menu_get_menu (mnu)))), "stop")) return;
SPStop *stop = SP_STOP(g_object_get_data (G_OBJECT(gtk_menu_get_active (GTK_MENU(gtk_option_menu_get_menu (mnu)))), "stop"));
_("Change gradient stop offset"));
}
{
return SP_RGBA32_U_COMPOSE (r, g, b, a);
}
static void
{
SPStop *stop = (SPStop *) g_object_get_data (G_OBJECT(gtk_menu_get_active (GTK_MENU(gtk_option_menu_get_menu (mnu)))), "stop");
return;
}
}
} else {
}
gchar c[64];
_("Add gradient stop"));
}
static void
{
if (!g_object_get_data (G_OBJECT(gtk_menu_get_active (GTK_MENU(gtk_option_menu_get_menu (mnu)))), "stop")) return;
SPStop *stop = SP_STOP(g_object_get_data (G_OBJECT(gtk_menu_get_active (GTK_MENU(gtk_option_menu_get_menu (mnu)))), "stop"));
if (next) {
}
if (prev) {
}
}
_("Delete gradient stop"));
}
}
static GtkWidget *
{
w = sp_gradient_image_new (gradient);
gtk_widget_show (w);
/* Stop list */
/* Create new menu widget */
/* Add and Remove buttons */
// TRANSLATORS: "Stop" means: a "phase" of a gradient
gtk_widget_show (b);
b = gtk_button_new_with_label (_("Delete stop"));
gtk_widget_show (b);
/* Offset Slider and stuff */
/* Label */
gtk_widget_show (l);
/* Adjustment */
/* Slider */
/* Spinbutton */
} else {
}
/* Signals */
// gtk_signal_connect (GTK_OBJECT (slider), "changed", GTK_SIGNAL_FUNC (offsliderChanged), vb);
// TRANSLATORS: "Stop" means: a "phase" of a gradient
f = gtk_frame_new (_("Stop Color"));
gtk_widget_show (f);
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
g_signal_connect (G_OBJECT (INKSCAPE), "activate_desktop", G_CALLBACK (sp_transientize_callback), &wd);
gtk_signal_connect (GTK_OBJECT (dlg), "destroy", G_CALLBACK (sp_gradient_vector_dialog_destroy), dlg);
gtk_signal_connect (GTK_OBJECT (dlg), "delete_event", G_CALLBACK (sp_gradient_vector_dialog_delete), dlg);
g_signal_connect (G_OBJECT (INKSCAPE), "shut_down", G_CALLBACK (sp_gradient_vector_dialog_delete), 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;
}
static void
{
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) {
SPStop *stop = SP_STOP(g_object_get_data (G_OBJECT(gtk_menu_get_active (GTK_MENU(gtk_option_menu_get_menu (mnu)))), "stop"));
/// get the color selector
// set alpha
// set color
}
/* Fill preview */
// Once the user edits a gradient, it stops being auto-collectable
sp_document_set_undo_sensitive (document, false);
}
}
static void
{
}
static gboolean
{
if (x<0) x=0;
if (y<0) y=0;
return FALSE; // which means, go ahead and destroy it
}
/* Widget destroy handler */
static void
{
/* Remove signals connected to us */
/* fixme: may use _connect_while_alive as well */
}
}
static void
{
}
static void
{
if (!blocked) {
}
}
{
if (blocked) return;
if (!gradient) return;
/* Our master gradient has changed */
}
SPStop *stop = SP_STOP(g_object_get_data (G_OBJECT(gtk_menu_get_active (GTK_MENU(gtk_option_menu_get_menu (mnu)))), "stop"));
stop->currentColor = false;
SPColorPreview *cpv = (SPColorPreview *)g_object_get_data (G_OBJECT(gtk_menu_get_active (GTK_MENU(gtk_option_menu_get_menu (mnu)))), "preview");
}
static void
{
float alpha;
if (blocked) return;
if (!gradient) return;
/* Our master gradient has changed */
}
/* Set start parameters */
/* We rely on normalized vector, i.e. stops HAVE to exist */
SPStop *stop = SP_STOP(g_object_get_data (G_OBJECT(gtk_menu_get_active (GTK_MENU(gtk_option_menu_get_menu (mnu)))), "stop"));
gchar c[64];
// g_snprintf (c, 256, "stop-color:#%06x;stop-opacity:%g;", rgb >> 8, (gdouble) alpha);
//SP_OBJECT_REPR (stop)->setAttribute("style", c);
_("Change gradient stop color"));
}