gradient-drag.cpp revision c3d71eeb981927093e5a6284277181d1d6b83985
#define __GRADIENT_DRAG_C__
/*
* On-canvas gradient dragging
*
* Authors:
* bulia byak <buliabyak@users.sf.net>
* Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
*
* 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 <cstring>
#include <string>
#include "desktop-handles.h"
#include "selection.h"
#include "desktop.h"
#include "desktop-style.h"
#include "document.h"
#include "display/sp-ctrlline.h"
#include "svg/css-ostringstream.h"
#include "libnr/nr-point-fns.h"
#include "prefs-utils.h"
#include "sp-item.h"
#include "style.h"
#include "knot.h"
#include "sp-linear-gradient.h"
#include "sp-radial-gradient.h"
#include "gradient-chemistry.h"
#include "gradient-drag.h"
#include "sp-stop.h"
#include "snap.h"
#include "sp-namedview.h"
#include "selection-chemistry.h"
#define GR_KNOT_COLOR_NORMAL 0xffffff00
#define GR_KNOT_COLOR_MOUSEOVER 0xff000000
#define GR_KNOT_COLOR_SELECTED 0x0000ff00
#define GR_LINE_COLOR_FILL 0x0000ff7f
#define GR_LINE_COLOR_STROKE 0x9999007f
// screen pixels between knots when they snap:
#define SNAP_DIST 5
// absolute distance between gradient points for them to become a single dragger when the drag is created:
#define MERGE_DIST 0.1
// knot shapes corresponding to GrPointType enum
SPKnotShapeType gr_knot_shapes [] = {
SP_KNOT_SHAPE_SQUARE, //POINT_LG_BEGIN
SP_KNOT_SHAPE_CIRCLE, //POINT_LG_END
SP_KNOT_SHAPE_DIAMOND, //POINT_LG_MID
SP_KNOT_SHAPE_SQUARE, // POINT_RG_CENTER
SP_KNOT_SHAPE_CIRCLE, // POINT_RG_R1
SP_KNOT_SHAPE_CIRCLE, // POINT_RG_R2
SP_KNOT_SHAPE_CROSS, // POINT_RG_FOCUS
SP_KNOT_SHAPE_DIAMOND, //POINT_RG_MID1
SP_KNOT_SHAPE_DIAMOND //POINT_RG_MID2
};
const gchar *gr_knot_descr [] = {
N_("Linear gradient <b>end</b>"),
N_("Linear gradient <b>mid stop</b>"),
N_("Radial gradient <b>center</b>"),
N_("Radial gradient <b>radius</b>"),
N_("Radial gradient <b>radius</b>"),
N_("Radial gradient <b>mid stop</b>"),
N_("Radial gradient <b>mid stop</b>")
};
static void
{
drag->updateDraggers ();
drag->updateLines ();
drag->updateLevels ();
}
static void
{
if (drag->local_change) {
drag->local_change = false;
} else {
drag->updateDraggers ();
}
drag->updateLines ();
drag->updateLevels ();
}
/**
When a _query_style_signal is received, check that \a property requests fill/stroke/opacity (otherwise
skip), and fill the \a style with the averaged color of all draggables of the selected dragger, if
any.
*/
int
{
if (property != QUERY_STYLE_PROPERTY_FILL && property != QUERY_STYLE_PROPERTY_STROKE && property != QUERY_STYLE_PROPERTY_MASTEROPACITY) {
return QUERY_STYLE_NOTHING;
}
return QUERY_STYLE_NOTHING;
} else {
int ret = QUERY_STYLE_NOTHING;
float cf[4];
int count = 0;
if (ret == QUERY_STYLE_NOTHING) {
} else if (ret == QUERY_STYLE_SINGLE) {
}
guint32 c = sp_item_gradient_stop_query_style (draggable->item, draggable->point_type, draggable->point_i, draggable->fill_or_stroke);
cf[0] += SP_RGBA32_R_F (c);
count ++;
}
}
if (count) {
// set both fill and stroke with our stop-color and stop-opacity
}
return ret;
}
}
bool
{
return false;
// See if the css contains interesting properties, and if so, translate them into the format
// acceptable for gradient stops
// any of color properties, in order of increasing priority:
} else { // multiply all opacity properties:
os << accumulated;
if ((css->attribute("fill") && !css->attribute("stroke") && !strcmp(css->attribute("fill"), "none")) ||
sp_repr_css_set_property (stop, "stop-opacity", "0"); // if a single fill/stroke property is set to none, don't change color, set opacity to 0
}
return false;
}
for (GList const* sel = drag->selected; sel != NULL; sel = sel->next) { // for all selected draggers
for (GSList const* i = dragger->draggables; i != NULL; i = i->next) { // for all draggables of dragger
drag->local_change = true;
sp_item_gradient_stop_set_style (draggable->item, draggable->point_type, draggable->point_i, draggable->fill_or_stroke, stop);
}
}
//sp_repr_css_print(stop);
return true;
}
{
if (!selected) return 0;
float cf[4];
int count = 0;
guint32 c = sp_item_gradient_stop_query_style (draggable->item, draggable->point_type, draggable->point_i, draggable->fill_or_stroke);
cf[0] += SP_RGBA32_R_F (c);
count ++;
}
}
if (count) {
}
}
SPStop *
{
bool fill_or_stroke = true;
bool r1_knot = false;
bool addknot = false;
do {
if (SP_IS_LINEARGRADIENT(gradient)) {
if ( dist_screen < tolerance ) {
// add the knot
addknot = true;
break; // break out of the while loop: add only one knot
}
} else if (SP_IS_RADIALGRADIENT(gradient)) {
if ( dist_screen < tolerance ) {
addknot = true;
r1_knot = true;
break; // break out of the while loop: add only one knot
}
if ( dist_screen < tolerance ) {
addknot = true;
r1_knot = false;
break; // break out of the while loop: add only one knot
}
}
} while (!fill_or_stroke && !addknot) ;
if (addknot) {
guint i = 1;
i++;
}
if (!next_stop) {
// logical error: the endstop should have offset 1 and should always be more than this offset here
return NULL;
}
return newstop;
}
return NULL;
}
bool
{
// first, see if we can drop onto one of the existing draggers
local_change = true;
sp_item_gradient_stop_set_style (draggable->item, draggable->point_type, draggable->point_i, draggable->fill_or_stroke, stop);
}
return true;
}
}
// now see if we're over line and create a new stop
bool over_line = false;
if (lines) {
if (stop) {
return true;
}
}
}
}
return false;
}
this->hor_levels.clear();
this->vert_levels.clear();
this->local_change = false;
(gpointer)this )
);
(gpointer)this )
);
(gpointer)this )
);
(gpointer)this )
);
this->updateDraggers ();
this->updateLines ();
this->updateLevels ();
this->setSelected (getDraggerFor (desktop->gr_item, desktop->gr_point_type, desktop->gr_point_i, desktop->gr_fill_or_stroke));
}
}
{
this->sel_changed_connection.disconnect();
this->sel_modified_connection.disconnect();
this->style_set_connection.disconnect();
this->style_query_connection.disconnect();
if (this->selected) {
} else {
desktop->gr_point_type = 0;
desktop->gr_point_i = 0;
desktop->gr_fill_or_stroke = true;
}
deselect_all();
}
g_list_free (this->draggers);
}
g_slist_free (this->lines);
}
{
this->point_type = point_type;
this->fill_or_stroke = fill_or_stroke;
}
GrDraggable::~GrDraggable ()
{
}
SPObject *
GrDraggable::getServer ()
{
if (!item)
return NULL;
if (fill_or_stroke)
else
return server;
}
static void
{
// FIXME: take from prefs
if (state & GDK_SHIFT_MASK) {
// with Shift; unsnap if we carry more than one draggable
// create a new dragger
// relink to it all but the first draggable in the list
}
}
} else if (!(state & GDK_CONTROL_MASK)) {
// without Shift or Ctrl; see if we need to snap to another dragger
// Merge draggers:
for (GSList const* i = dragger->draggables; i != NULL; i = i->next) { // for all draggables of dragger
// copy draggable to d_new:
GrDraggable *da_new = new GrDraggable (draggable->item, draggable->point_type, draggable->point_i, draggable->fill_or_stroke);
}
// unlink and delete this dragger
delete dragger;
// update the new merged dragger
d_new->fireDraggables(true, false, true);
d_new->updateKnotShape ();
d_new->updateDependencies(true);
_("Merge gradient handles"));
return;
}
}
}
// Try snapping to the grid or guides
if (s.getSnapped()) {
p = s.getPoint();
sp_knot_moveto (knot, &p);
} else {
bool was_snapped = false;
// No snapping so far, let's see if we need to snap to any of the levels
was_snapped = true;
sp_knot_moveto (knot, &p);
}
}
was_snapped = true;
sp_knot_moveto (knot, &p);
}
}
if (was_snapped) {
}
}
}
if (state & GDK_CONTROL_MASK) {
/* 0 means no snapping. */
// This list will store snap vectors from all draggables of dragger
continue;
draggable->fill_or_stroke)) {
// found the other end of the linear gradient;
if (state & GDK_SHIFT_MASK) {
// moving linear around center
} else {
// moving linear around the other end
}
}
}
} else if (draggable->point_type == POINT_RG_R1 || draggable->point_type == POINT_RG_R2 || draggable->point_type == POINT_RG_FOCUS) {
continue;
draggable->fill_or_stroke)) {
// found the center of the radial gradient;
}
}
}
if (dr_snap) {
if (state & GDK_MOD1_MASK) {
// with Alt, snap to the original angle and its perpendiculars
snap_vector = get_snap_vector (p, *dr_snap, M_PI/2, NR::atan2 (dragger->point_original - *dr_snap));
} else {
}
}
if (snap_vector) {
}
}
// Move by the smallest of snap vectors:
move = *snap_vector;
}
p += move;
sp_knot_moveto (knot, &p);
}
}
if (drag->keep_selection) {
} else {
dragger->updateDependencies(false);
}
}
static void
gr_midpoint_limits(GrDragger *dragger, SPObject *server, NR::Point *begin, NR::Point *end, NR::Point *low_lim, NR::Point *high_lim, GSList **moving)
{
// a midpoint dragger can (logically) only contain one GrDraggable
// get begin and end points between which dragging is allowed:
// the draglimits are between knot(lowest_i - 1) and knot(highest_i + 1)
if (dragger->isSelected()) {
while ( true )
{
d_add = drag->getDraggerFor(draggable->item, draggable->point_type, lowest_i - 1, draggable->fill_or_stroke);
} else {
break;
}
}
while ( true )
{
d_add = drag->getDraggerFor(draggable->item, draggable->point_type, highest_i + 1, draggable->fill_or_stroke);
} else {
break;
}
}
}
if ( SP_IS_LINEARGRADIENT(server) ) {
if (lowest_i == 1) {
} else {
d_temp = drag->getDraggerFor (draggable->item, POINT_LG_MID, lowest_i - 1, draggable->fill_or_stroke);
}
if (d_temp)
d_temp = drag->getDraggerFor (draggable->item, POINT_LG_MID, highest_i + 1, draggable->fill_or_stroke);
}
if (d_temp)
} else if ( SP_IS_RADIALGRADIENT(server) ) {
if (lowest_i == 1) {
} else {
d_temp = drag->getDraggerFor (draggable->item, draggable->point_type, lowest_i - 1, draggable->fill_or_stroke);
}
if (d_temp)
d_temp = drag->getDraggerFor (draggable->item, draggable->point_type, highest_i + 1, draggable->fill_or_stroke);
d_temp = drag->getDraggerFor (draggable->item, (draggable->point_type==POINT_RG_MID1) ? POINT_RG_R1 : POINT_RG_R2, num-1, draggable->fill_or_stroke);
}
if (d_temp)
}
}
/**
Called when a midpoint knot is dragged.
*/
static void
gr_knot_moved_midpoint_handler(SPKnot */*knot*/, NR::Point const *ppointer, guint state, gpointer data)
{
// a midpoint dragger can (logically) only contain one GrDraggable
// FIXME: take from prefs
double snap_fraction = 0.1;
if (state & GDK_CONTROL_MASK) {
} else {
}
if (state & GDK_MOD1_MASK) {
// FIXME: unify all these profiles (here, in nodepath, in tweak) in one place
double alpha = 1.0;
if (NR::L2(drg->point - dragger->point) + NR::L2(drg->point - begin) - 1e-3 > NR::L2(dragger->point - begin)) { // drg is on the end side from dragger
} else { // drg is on the begin side from dragger
}
}
drg->fireDraggables (false);
drg->updateDependencies(false);
}
}
static void
{
}
/**
Called when the mouse releases a dragger knot; changes gradient writing to repr, updates other draggers if needed
*/
static void
{
dragger->fireDraggables (true, true);
} else {
dragger->fireDraggables (true);
}
if (d == dragger)
continue;
d->fireDraggables (true);
}
// make this dragger selected
}
dragger->updateDependencies(true);
// we did an undoable action
_("Move gradient handle"));
}
/**
Called when a dragger knot is clicked; selects the dragger or deletes it depending on the
state of the keyboard keys
*/
static void
{
if (!draggable) return;
// delete this knot from vector
switch (draggable->point_type) { // if we delete first or last stop, move the next/previous to the edge
case POINT_LG_BEGIN:
case POINT_RG_CENTER:
{
if (next) {
}
}
break;
case POINT_LG_END:
case POINT_RG_R1:
case POINT_RG_R2:
{
if (prev) {
}
}
break;
case POINT_LG_MID:
case POINT_RG_MID1:
case POINT_RG_MID2:
break;
}
_("Delete gradient stop"));
}
} else {
// select the dragger
if ( state & GDK_SHIFT_MASK ) {
} else {
}
}
}
/**
Called when a dragger knot is doubleclicked; opens gradient editor with the stop from the first draggable
*/
static void
{
return;
sp_item_gradient_edit_stop (draggable->item, draggable->point_type, draggable->point_i, draggable->fill_or_stroke);
}
/**
Act upon all draggables of the dragger, setting them to the dragger's point
*/
void
{
// set local_change flag so that selection_changed callback does not regenerate draggers
this->parent->local_change = true;
// change gradient, optionally writing to repr; prevent focus from moving if it's snapped
// to the center, unless it's the first update upon merge when we must snap it to the point
if (merging_focus ||
!(draggable->point_type == POINT_RG_FOCUS && this->isA(draggable->item, POINT_RG_CENTER, draggable->point_i, draggable->fill_or_stroke)))
{
sp_item_gradient_set_coords (draggable->item, draggable->point_type, draggable->point_i, this->point, draggable->fill_or_stroke, write_repr, scale_radial);
}
}
}
/**
Checks if the dragger has a draggable with this point_type
*/
bool
{
return true;
}
}
return false;
}
/**
Checks if the dragger has a draggable with this item, point_type + point_i (number), fill_or_stroke
*/
bool
{
if ( (draggable->point_type == point_type) && (draggable->point_i == point_i) && (draggable->item == item) && (draggable->fill_or_stroke == fill_or_stroke) ) {
return true;
}
}
return false;
}
/**
Checks if the dragger has a draggable with this item, point_type, fill_or_stroke
*/
bool
{
if ( (draggable->point_type == point_type) && (draggable->item == item) && (draggable->fill_or_stroke == fill_or_stroke) ) {
return true;
}
}
return false;
}
bool
{
// we must not merge the points of the same gradient!
// except that we can snap center and focus together
return false;
}
}
// disable merging of midpoints.
return false;
return true;
}
bool
{
if (this == other)
return false;
return false;
}
}
return true;
}
bool
{
return false;
}
return true;
}
/**
Updates the statusbar tip of the dragger knot, based on its draggables
*/
void
{
}
switch (draggable->point_type) {
case POINT_LG_MID:
case POINT_RG_MID1:
case POINT_RG_MID2:
this->knot->tip = g_strdup_printf (_("%s %d for: %s%s; drag with <b>Ctrl</b> to snap offset; click with <b>Ctrl+Alt</b> to delete stop"),
break;
default:
this->knot->tip = g_strdup_printf (_("%s for: %s%s; drag with <b>Ctrl</b> to snap angle, with <b>Ctrl+Alt</b> to preserve angle, with <b>Ctrl+Shift</b> to scale around center"),
break;
}
this->knot->tip = g_strdup_printf (_("Radial gradient <b>center</b> and <b>focus</b>; drag with <b>Shift</b> to separate focus"));
} else {
this->knot->tip = g_strdup_printf (ngettext("Gradient point shared by <b>%d</b> gradient; drag with <b>Shift</b> to separate",
"Gradient point shared by <b>%d</b> gradients; drag with <b>Shift</b> to separate",
length),
length);
}
}
/**
Adds a draggable to the dragger
*/
void
{
if (!draggables)
return;
}
/**
Adds a draggable to the dragger
*/
void
{
this->updateTip();
}
/**
Moves this dragger to the point of the given draggable, acting upon all other draggables
*/
void
GrDragger::moveThisToDraggable (SPItem *item, gint point_type, gint point_i, bool fill_or_stroke, bool write_repr)
{
this->point_original = this->point;
continue;
}
sp_item_gradient_set_coords (da->item, da->point_type, da->point_i, this->point, da->fill_or_stroke, write_repr, false);
}
// FIXME: here we should also call this->updateDependencies(write_repr); to propagate updating, but how to prevent loops?
}
/**
Moves all midstop draggables that depend on this one
*/
void
if (!server)
return;
if (num <= 2) return;
if ( SP_IS_LINEARGRADIENT(server) ) {
this->moveOtherToDraggable (draggable->item, POINT_LG_MID, i, draggable->fill_or_stroke, write_repr);
}
} else if ( SP_IS_RADIALGRADIENT(server) ) {
this->moveOtherToDraggable (draggable->item, POINT_RG_MID1, i, draggable->fill_or_stroke, write_repr);
this->moveOtherToDraggable (draggable->item, POINT_RG_MID2, i, draggable->fill_or_stroke, write_repr);
}
}
}
/**
Moves all draggables that depend on this one
*/
void
{
switch (draggable->point_type) {
case POINT_LG_BEGIN:
{
// the end point is dependent only when dragging with ctrl+shift
this->moveOtherToDraggable (draggable->item, POINT_LG_END, -1, draggable->fill_or_stroke, write_repr);
}
break;
case POINT_LG_END:
{
// the begin point is dependent only when dragging with ctrl+shift
this->moveOtherToDraggable (draggable->item, POINT_LG_BEGIN, 0, draggable->fill_or_stroke, write_repr);
}
break;
case POINT_LG_MID:
// no other nodes depend on mid points.
break;
case POINT_RG_R2:
this->moveOtherToDraggable (draggable->item, POINT_RG_R1, -1, draggable->fill_or_stroke, write_repr);
this->moveOtherToDraggable (draggable->item, POINT_RG_FOCUS, -1, draggable->fill_or_stroke, write_repr);
break;
case POINT_RG_R1:
this->moveOtherToDraggable (draggable->item, POINT_RG_R2, -1, draggable->fill_or_stroke, write_repr);
this->moveOtherToDraggable (draggable->item, POINT_RG_FOCUS, -1, draggable->fill_or_stroke, write_repr);
break;
case POINT_RG_CENTER:
this->moveOtherToDraggable (draggable->item, POINT_RG_R1, -1, draggable->fill_or_stroke, write_repr);
this->moveOtherToDraggable (draggable->item, POINT_RG_R2, -1, draggable->fill_or_stroke, write_repr);
this->moveOtherToDraggable (draggable->item, POINT_RG_FOCUS, -1, draggable->fill_or_stroke, write_repr);
break;
case POINT_RG_FOCUS:
// nothing can depend on that
break;
case POINT_RG_MID1:
this->moveOtherToDraggable (draggable->item, POINT_RG_MID2, draggable->point_i, draggable->fill_or_stroke, write_repr);
break;
case POINT_RG_MID2:
this->moveOtherToDraggable (draggable->item, POINT_RG_MID1, draggable->point_i, draggable->fill_or_stroke, write_repr);
break;
default:
break;
}
}
}
{
this->draggables = NULL;
this->point = p;
this->point_original = p;
// create the knot
sp_knot_update_ctrl(this->knot);
// move knot to the given point
sp_knot_show (this->knot);
// connect knot's signals
if ( (draggable) // it can be NULL if a node in unsnapped (eg. focus point unsnapped from center)
// luckily, midstops never snap to other nodes so are never unsnapped...
{
this->handler_id = g_signal_connect (G_OBJECT (this->knot), "moved", G_CALLBACK (gr_knot_moved_midpoint_handler), this);
} else {
this->handler_id = g_signal_connect (G_OBJECT (this->knot), "moved", G_CALLBACK (gr_knot_moved_handler), this);
}
g_signal_connect (G_OBJECT (this->knot), "doubleclicked", G_CALLBACK (gr_knot_doubleclicked_handler), this);
g_signal_connect (G_OBJECT (this->knot), "ungrabbed", G_CALLBACK (gr_knot_ungrabbed_handler), this);
// add the initial draggable
if (draggable)
this->addDraggable (draggable);
}
{
// unselect if it was selected
this->parent->setDeselected(this);
// disconnect signals
g_signal_handlers_disconnect_by_func(G_OBJECT(this->knot), (gpointer) G_CALLBACK (gr_knot_moved_handler), this);
g_signal_handlers_disconnect_by_func(G_OBJECT(this->knot), (gpointer) G_CALLBACK (gr_knot_clicked_handler), this);
g_signal_handlers_disconnect_by_func(G_OBJECT(this->knot), (gpointer) G_CALLBACK (gr_knot_doubleclicked_handler), this);
g_signal_handlers_disconnect_by_func(G_OBJECT(this->knot), (gpointer) G_CALLBACK (gr_knot_grabbed_handler), this);
g_signal_handlers_disconnect_by_func(G_OBJECT(this->knot), (gpointer) G_CALLBACK (gr_knot_ungrabbed_handler), this);
/* unref should call destroy */
// delete all draggables
delete ((GrDraggable *) i->data);
}
g_slist_free (this->draggables);
this->draggables = NULL;
}
/**
Select the dragger which has the given draggable.
*/
{
return (dragger);
}
}
}
return NULL;
}
void
GrDragger::moveOtherToDraggable (SPItem *item, gint point_type, gint point_i, bool fill_or_stroke, bool write_repr)
{
if (d && d != this) {
}
}
/**
Draw this dragger as selected
*/
void
{
}
/**
Draw this dragger as normal (deselected)
*/
void
{
}
bool
{
}
/**
*/
void
{
while (selected) {
}
}
/**
*/
void
{
deselect_all();
}
/**
*/
void
{
setSelected (d, true, true);
}
}
/**
*/
void
{
setSelected (d, true, true);
}
}
}
}
/**
*/
void
{
setSelected (d, true, true);
}
}
}
/**
\brief Select a dragger
\param dragger The dragger to select
\param add_to_selection If true, add to selection, otherwise deselect others
\param override If true, always select this node, otherwise toggle selected status
*/
void
{
if (add_to_selection) {
if (!dragger) return;
if (override) {
}
} else { // toggle
if (selected) {
}
} else {
}
}
} else {
deselect_all();
if (dragger) {
}
}
if (seldragger) {
}
}
/**
\brief Deselect a dragger
\param dragger The dragger to deselect
*/
void
{
}
}
/**
Create a line from p1 to p2 and add it to the lines list
*/
void
{
if (rgba != GR_LINE_COLOR_FILL) // fill is the default, so don't set color for it to speed up redraw
}
/**
If there already exists a dragger within MERGE_DIST of p, add the draggable to it; otherwise create
new dragger and add it to draggers list
*/
void
{
NR::Point p = sp_item_gradient_get_coords (draggable->item, draggable->point_type, draggable->point_i, draggable->fill_or_stroke);
// distance is small, merge this draggable into dragger, no need to create new dragger
return;
}
}
// fixme: draggers should be added AFTER the last one: this way tabbing through them will be from begin to end.
}
/**
Add draggers for the radial gradient rg on item
*/
void
{
if (num > 2) {
}
}
if (num > 2) {
}
}
}
/**
Add draggers for the linear gradient lg on item
*/
void
{
if (num > 2) {
}
}
}
/**
Artificially grab the knot of this dragger; used by the gradient context
*/
void
{
if (dragger) {
}
}
/**
Artificially grab the knot of the dragger with this draggable; used by the gradient context
*/
void
GrDrag::grabKnot (SPItem *item, gint point_type, gint point_i, bool fill_or_stroke, gint x, gint y, guint32 etime)
{
if (dragger) {
}
}
/**
Regenerates the draggers list from the current selection; is called when selection is changed or
modified, also when a radial dragger needs to update positions of other draggers in the gradient
*/
void
GrDrag::updateDraggers ()
{
while (selected) {
}
// delete old draggers
}
g_list_free (this->draggers);
if (SP_IS_LINEARGRADIENT (server)) {
} else if (SP_IS_RADIALGRADIENT (server)) {
}
}
if (SP_IS_LINEARGRADIENT (server)) {
} else if (SP_IS_RADIALGRADIENT (server)) {
}
}
}
}
/**
Regenerates the lines list from the current selection; is called on each move of a dragger, so that
lines are always in sync with the actual gradient
*/
void
GrDrag::updateLines ()
{
// delete old lines
}
g_slist_free (this->lines);
if (SP_IS_LINEARGRADIENT (server)) {
this->addLine (item, sp_item_gradient_get_coords (item, POINT_LG_BEGIN, 0, true), sp_item_gradient_get_coords (item, POINT_LG_END, 0, true), GR_LINE_COLOR_FILL);
} else if (SP_IS_RADIALGRADIENT (server)) {
this->addLine (item, center, sp_item_gradient_get_coords (item, POINT_RG_R1, 0, true), GR_LINE_COLOR_FILL);
this->addLine (item, center, sp_item_gradient_get_coords (item, POINT_RG_R2, 0, true), GR_LINE_COLOR_FILL);
}
}
if (SP_IS_LINEARGRADIENT (server)) {
this->addLine (item, sp_item_gradient_get_coords (item, POINT_LG_BEGIN, 0, false), sp_item_gradient_get_coords (item, POINT_LG_END, 0, false), GR_LINE_COLOR_STROKE);
} else if (SP_IS_RADIALGRADIENT (server)) {
this->addLine (item, center, sp_item_gradient_get_coords (item, POINT_RG_R1, 0, false), GR_LINE_COLOR_STROKE);
this->addLine (item, center, sp_item_gradient_get_coords (item, POINT_RG_R2, 0, false), GR_LINE_COLOR_STROKE);
}
}
}
}
/**
Regenerates the levels list from the current selection
*/
void
GrDrag::updateLevels ()
{
hor_levels.clear();
vert_levels.clear();
if (rect) {
// Remember the edges of the bbox and the center axis
}
}
}
void
{
return;
}
}
void
{
selected_move (x, y, false, scale_radial);
}
void
{
return;
bool did = false;
// if this is an endpoint,
// Moving an rg center moves its focus and radii as well.
// therefore, if this is a focus or radius and if selection
// contains the center as well, do not move this one
bool skip_radius_with_center = false;
0,
// FIXME: here we take into account only the first draggable!
skip_radius_with_center = true;
}
}
continue;
}
did = true;
d->point_original = d->point;
}
}
if (write_repr && did) {
// we did an undoable action
_("Move gradient handle(s)"));
return;
}
if (!did) { // none of the end draggers are selected, so let's try to move the mids
// a midpoint dragger can (logically) only contain one GrDraggable
drg->fireDraggables (true);
drg->updateDependencies(true);
did = true;
}
if (write_repr && did) {
// we did an undoable action
_("Move gradient mid stop(s)"));
}
}
}
void
GrDrag::selected_move_screen (double x, double y)
{
}
/**
Select the knot next to the last selected one and deselect all other selected.
*/
GrDrag::select_next ()
{
if (draggers)
} else {
}
if (d)
setSelected (d);
return d;
}
/**
Select the knot previous from the last selected one and deselect all other selected.
*/
GrDrag::select_prev ()
{
if (draggers)
} else {
}
if (d)
setSelected (d);
return d;
}
// FIXME: i.m.o. an ugly function that I just made to work, but... aargh! (Johan)
void
{
if (!selected) return;
SPDocument *document = false;
struct StructStopInfo {
SPGradient * vector;
};
while (selected) {
switch (draggable->point_type) {
case POINT_LG_MID:
case POINT_RG_MID1:
case POINT_RG_MID2:
{
// check if already present in list. (e.g. when both RG_MID1 and RG_MID2 were selected)
bool present = false;
present = true;
break; // no need to search further.
}
}
if (!present)
}
break;
case POINT_LG_BEGIN:
case POINT_LG_END:
case POINT_RG_CENTER:
case POINT_RG_R1:
case POINT_RG_R2:
{
} else {
}
if (stop) {
// check if already present in list. (e.g. when both R1 and R2 were selected)
bool present = false;
present = true;
break; // no need to search further.
}
}
if (!present)
}
}
break;
default:
break;
}
}
if ( just_one ) break; // iterate once if just_one is set.
}
while (midstoplist) {
}
while (endstoplist) {
// 2 is the minimum, cannot delete more than that without deleting the whole vector
// cannot use vector->vector.stops.size() because the vector might be invalidated by deletion of a midstop
// manually count the children, don't know if there already exists a function for this...
int len = 0;
{
}
if (len > 2)
{
case POINT_LG_BEGIN:
{
// iterate through midstops to set new offset values such that they won't move on canvas.
}
}
break;
case POINT_LG_END:
{
// iterate through midstops to set new offset values such that they won't move on canvas.
}
}
break;
case POINT_RG_CENTER:
{
if (newfirst) {
}
}
break;
case POINT_RG_R1:
case POINT_RG_R2:
// iterate through midstops to set new offset values such that they won't move on canvas.
}
break;
}
}
else
{ // delete the gradient from the object. set fill to unset FIXME: set to fill of unselected node?
// stopinfo->spstop is the selected stop
}
if (unselectedrepr == NULL) {
} else {
}
} else {
sp_repr_css_set_property(css, "fill", sp_repr_css_property(stopcss, "stop-color", "inkscape:unset"));
} else {
sp_repr_css_set_property(css, "stroke", sp_repr_css_property(stopcss, "stop-color", "inkscape:unset"));
sp_repr_css_set_property(css, "stroke-opacity", sp_repr_css_property(stopcss, "stop-opacity", "1"));
}
}
}
delete stopinfo;
}
if (document) {
}
}
/*
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 :