summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 342e520)
raw | patch | inline | side by side (parent: 342e520)
author | johanengelen <johanengelen@users.sourceforge.net> | |
Sun, 7 Jan 2007 21:51:23 +0000 (21:51 +0000) | ||
committer | johanengelen <johanengelen@users.sourceforge.net> | |
Sun, 7 Jan 2007 21:51:23 +0000 (21:51 +0000) |
diff --git a/src/desktop.cpp b/src/desktop.cpp
index 903a6bd7c90c46e3ea7980fc54b6d4e2f7f43b54..bf4b0ba6524e1d928e1d085ae8e6fcacafcdf66d 100644 (file)
--- a/src/desktop.cpp
+++ b/src/desktop.cpp
is_fullscreen = false;
gr_item = NULL;
- gr_point_type = 0;
- gr_point_i = 0;
+ gr_point_num = 0;
gr_fill_or_stroke = true;
_layer_hierarchy = NULL;
diff --git a/src/desktop.h b/src/desktop.h
index 8f2fac1e8d00758086aae87e9897db179a875237..e9e2f638e764d5388ba433ea12bf6fdae8a55e29 100644 (file)
--- a/src/desktop.h
+++ b/src/desktop.h
// storage for selected dragger used by GrDrag as it's
// created and deleted by tools
SPItem *gr_item;
- guint gr_point_type;
- guint gr_point_i;
+ guint gr_point_num;
bool gr_fill_or_stroke;
-
Inkscape::ObjectHierarchy *_layer_hierarchy;
gchar * _reconstruction_old_layer_id;
index 0f57ed901691cfcb2a903fa32e9a1b9d1dcf9cb9..6a485e573d392f57840579e733e85f10de9b3eda 100644 (file)
#include "desktop-style.h"
#include "sp-gradient-reference.h"
-#include "sp-gradient-vector.h"
#include "sp-linear-gradient.h"
#include "sp-radial-gradient.h"
#include "sp-stop.h"
return stop;
}
return NULL;
-}
-
-SPStop*
-sp_get_stop_i(SPGradient *gradient, guint stop_i)
-{
- SPStop *stop = sp_first_stop (gradient);
-
- for (guint i=0; i < stop_i; i++) {
- if (!stop) return NULL;
- stop = sp_next_stop (stop);
- }
-
- return stop;
}
void
-sp_item_gradient_edit_stop (SPItem *item, guint point_type, guint point_i, bool fill_or_stroke)
+sp_item_gradient_edit_stop (SPItem *item, guint point_num, bool fill_or_stroke)
{
SPGradient *gradient = sp_item_gradient (item, fill_or_stroke);
return;
SPGradient *vector = sp_gradient_get_vector (gradient, false);
- switch (point_type) {
- case POINT_LG_BEGIN:
+ switch (point_num) {
+ case POINT_LG_P1:
case POINT_RG_CENTER:
case POINT_RG_FOCUS:
{
}
break;
- case POINT_LG_END:
+ case POINT_LG_P2:
case POINT_RG_R1:
case POINT_RG_R2:
{
@@ -542,20 +528,13 @@ sp_item_gradient_edit_stop (SPItem *item, guint point_type, guint point_i, bool
gtk_widget_show (dialog);
}
break;
-
- case POINT_LG_MID:
- {
- GtkWidget *dialog = sp_gradient_vector_editor_new (vector, sp_get_stop_i (vector, point_i));
- gtk_widget_show (dialog);
- }
- break;
default:
break;
}
}
guint32
-sp_item_gradient_stop_query_style (SPItem *item, guint point_type, guint point_i, bool fill_or_stroke)
+sp_item_gradient_stop_query_style (SPItem *item, guint point_num, bool fill_or_stroke)
{
SPGradient *gradient = sp_item_gradient (item, fill_or_stroke);
@@ -567,8 +546,8 @@ sp_item_gradient_stop_query_style (SPItem *item, guint point_type, guint point_i
if (!vector) // orphan!
return 0; // what else to do?
- switch (point_type) {
- case POINT_LG_BEGIN:
+ switch (point_num) {
+ case POINT_LG_P1:
case POINT_RG_CENTER:
case POINT_RG_FOCUS:
{
@@ -579,7 +558,7 @@ sp_item_gradient_stop_query_style (SPItem *item, guint point_type, guint point_i
}
break;
- case POINT_LG_END:
+ case POINT_LG_P2:
case POINT_RG_R1:
case POINT_RG_R2:
{
@@ -589,16 +568,6 @@ sp_item_gradient_stop_query_style (SPItem *item, guint point_type, guint point_i
}
}
break;
-
- case POINT_LG_MID:
- {
- SPStop *stopi = sp_get_stop_i (vector, point_i);
- if (stopi) {
- return sp_stop_get_rgba32(stopi);
- }
- }
- break;
-
default:
break;
}
@@ -606,7 +575,7 @@ sp_item_gradient_stop_query_style (SPItem *item, guint point_type, guint point_i
}
void
-sp_item_gradient_stop_set_style (SPItem *item, guint point_type, guint point_i, bool fill_or_stroke, SPCSSAttr *stop)
+sp_item_gradient_stop_set_style (SPItem *item, guint point_num, bool fill_or_stroke, SPCSSAttr *stop)
{
SPGradient *gradient = sp_item_gradient (item, fill_or_stroke);
sp_gradient_repr_set_link(SP_OBJECT_REPR(gradient), vector);
}
- switch (point_type) {
- case POINT_LG_BEGIN:
+ switch (point_num) {
+ case POINT_LG_P1:
case POINT_RG_CENTER:
case POINT_RG_FOCUS:
{
}
break;
- case POINT_LG_END:
+ case POINT_LG_P2:
case POINT_RG_R1:
case POINT_RG_R2:
{
@@ -645,16 +614,6 @@ sp_item_gradient_stop_set_style (SPItem *item, guint point_type, guint point_i,
}
}
break;
-
- case POINT_LG_MID:
- {
- SPStop *stopi = sp_get_stop_i (vector, point_i);
- if (stopi) {
- sp_repr_css_change (SP_OBJECT_REPR (stopi), stop, "style");
- }
- }
- break;
-
default:
break;
}
/**
-Set the position of point point_type of the gradient applied to item (either fill_or_stroke) to
+Set the position of point point_num of the gradient applied to item (either fill_or_stroke) to
p_w (in desktop coordinates). Write_repr if you want the change to become permanent.
*/
void
-sp_item_gradient_set_coords (SPItem *item, guint point_type, guint point_i, NR::Point p_w, bool fill_or_stroke, bool write_repr, bool scale)
+sp_item_gradient_set_coords (SPItem *item, guint point_num, NR::Point p_w, bool fill_or_stroke, bool write_repr, bool scale)
{
SPGradient *gradient = sp_item_gradient (item, fill_or_stroke);
@@ -737,8 +696,8 @@ sp_item_gradient_set_coords (SPItem *item, guint point_type, guint point_i, NR::
if (SP_IS_LINEARGRADIENT(gradient)) {
SPLinearGradient *lg = SP_LINEARGRADIENT(gradient);
- switch (point_type) {
- case POINT_LG_BEGIN:
+ switch (point_num) {
+ case POINT_LG_P1:
if (scale) {
lg->x2.computed += (lg->x1.computed - p[NR::X]);
lg->y2.computed += (lg->y1.computed - p[NR::Y]);
@@ -756,7 +715,7 @@ sp_item_gradient_set_coords (SPItem *item, guint point_type, guint point_i, NR::
SP_OBJECT (gradient)->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
- case POINT_LG_END:
+ case POINT_LG_P2:
if (scale) {
lg->x1.computed += (lg->x2.computed - p[NR::X]);
lg->y1.computed += (lg->y2.computed - p[NR::Y]);
@@ -774,11 +733,6 @@ sp_item_gradient_set_coords (SPItem *item, guint point_type, guint point_i, NR::
SP_OBJECT (gradient)->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
- case POINT_LG_MID:
- {
- //do stuff!
- }
- break;
default:
break;
}
@@ -787,14 +741,14 @@ sp_item_gradient_set_coords (SPItem *item, guint point_type, guint point_i, NR::
SPRadialGradient *rg = SP_RADIALGRADIENT(gradient);
NR::Point c (rg->cx.computed, rg->cy.computed);
NR::Point c_w = c * gradient->gradientTransform * i2d; // now in desktop coords
- if ((point_type == POINT_RG_R1 || point_type == POINT_RG_R2) && NR::L2 (p_w - c_w) < 1e-3) {
+ if ((point_num == POINT_RG_R1 || point_num == POINT_RG_R2) && NR::L2 (p_w - c_w) < 1e-3) {
// prevent setting a radius too close to the center
return;
}
NR::Matrix new_transform;
bool transform_set = false;
- switch (point_type) {
+ switch (point_num) {
case POINT_RG_CENTER:
rg->fx.computed = p[NR::X] + (rg->fx.computed - rg->cx.computed);
rg->fy.computed = p[NR::Y] + (rg->fy.computed - rg->cy.computed);
/**
-Returns the position of point point_type of the gradient applied to item (either fill_or_stroke),
+Returns the position of point point_num of the gradient applied to item (either fill_or_stroke),
in desktop coordinates.
*/
NR::Point
-sp_item_gradient_get_coords (SPItem *item, guint point_type, guint point_i, bool fill_or_stroke)
+sp_item_gradient_get_coords (SPItem *item, guint point_num, bool fill_or_stroke)
{
SPGradient *gradient = sp_item_gradient (item, fill_or_stroke);
@@ -914,22 +868,17 @@ sp_item_gradient_get_coords (SPItem *item, guint point_type, guint point_i, bool
if (SP_IS_LINEARGRADIENT(gradient)) {
SPLinearGradient *lg = SP_LINEARGRADIENT(gradient);
- switch (point_type) {
- case POINT_LG_BEGIN:
+ switch (point_num) {
+ case POINT_LG_P1:
p = NR::Point (lg->x1.computed, lg->y1.computed);
break;
- case POINT_LG_END:
+ case POINT_LG_P2:
p = NR::Point (lg->x2.computed, lg->y2.computed);
break;
- case POINT_LG_MID:
- //p = somewhere in between (x1,y1)-(x2,y2) defined by percentage of point[point_i];
- gdouble offset = lg->vector.stops.at(point_i).offset;
- p = (1-offset) * NR::Point(lg->x1.computed, lg->y1.computed) + offset * NR::Point(lg->x2.computed, lg->y2.computed);
- break;
}
} else if (SP_IS_RADIALGRADIENT(gradient)) {
SPRadialGradient *rg = SP_RADIALGRADIENT(gradient);
- switch (point_type) {
+ switch (point_num) {
case POINT_RG_CENTER:
p = NR::Point (rg->cx.computed, rg->cy.computed);
break;
index b95c5025e57c0b1f388336ee022b8aa3bc33e90e..b649a22ec78f76e1e265ccc0e9bf217ccb85d496 100644 (file)
--- a/src/gradient-chemistry.h
+++ b/src/gradient-chemistry.h
SPStop* sp_last_stop(SPGradient *gradient);
SPStop* sp_prev_stop(SPStop *stop, SPGradient *gradient);
SPStop* sp_next_stop(SPStop *stop);
-SPStop* sp_get_stop_i(SPGradient *gradient, guint i);
void sp_gradient_transform_multiply (SPGradient *gradient, NR::Matrix postmul, bool set);
-void sp_item_gradient_set_coords (SPItem *item, guint point_type, guint point_i, NR::Point p_desk, bool fill_or_stroke, bool write_repr, bool scale);
-NR::Point sp_item_gradient_get_coords (SPItem *item, guint point_type, guint point_i, bool fill_or_stroke);
+void sp_item_gradient_set_coords (SPItem *item, guint point_num, NR::Point p_desk, bool fill_or_stroke, bool write_repr, bool scale);
+NR::Point sp_item_gradient_get_coords (SPItem *item, guint point_num, bool fill_or_stroke);
SPGradient *sp_item_gradient_get_vector (SPItem *item, bool fill_or_stroke);
SPGradientSpread sp_item_gradient_get_spread (SPItem *item, bool fill_or_stroke);
struct SPCSSAttr;
-void sp_item_gradient_stop_set_style (SPItem *item, guint point_type, guint point_i, bool fill_or_stroke, SPCSSAttr *stop);
-guint32 sp_item_gradient_stop_query_style (SPItem *item, guint point_type, guint point_i, bool fill_or_stroke);
-void sp_item_gradient_edit_stop (SPItem *item, guint point_type, guint point_i, bool fill_or_stroke);
+void sp_item_gradient_stop_set_style (SPItem *item, guint point_num, bool fill_or_stroke, SPCSSAttr *stop);
+guint32 sp_item_gradient_stop_query_style (SPItem *item, guint point_num, bool fill_or_stroke);
+void sp_item_gradient_edit_stop (SPItem *item, guint point_num, bool fill_or_stroke);
void sp_item_gradient_reverse_vector (SPItem *item, bool fill_or_stroke);
#endif
index c54041a8222c6fb2f9165dbbbc168b1a3f71bae3..ad1dd873066873f5e58d2ee198837464c1f5b9c5 100644 (file)
--- a/src/gradient-context.cpp
+++ b/src/gradient-context.cpp
@@ -433,15 +433,11 @@ static void sp_gradient_drag(SPGradientContext &rc, NR::Point const pt, guint st
sp_item_set_gradient(SP_ITEM(i->data), vector, (SPGradientType) type, fill_or_stroke);
if (type == SP_GRADIENT_TYPE_LINEAR) {
- sp_item_gradient_set_coords (SP_ITEM(i->data), POINT_LG_BEGIN, 0, rc.origin, fill_or_stroke, true, false);
-/* FIXGRADIENT
- Add sensible code to handle the midpoints, or maybe not necessary?
- not necessary i think because this only creates default gradient?
-*/
- sp_item_gradient_set_coords (SP_ITEM(i->data), POINT_LG_END, 0, pt, fill_or_stroke, true, false);
+ sp_item_gradient_set_coords (SP_ITEM(i->data), POINT_LG_P1, rc.origin, fill_or_stroke, true, false);
+ sp_item_gradient_set_coords (SP_ITEM(i->data), POINT_LG_P2, pt, fill_or_stroke, true, false);
} else if (type == SP_GRADIENT_TYPE_RADIAL) {
- sp_item_gradient_set_coords (SP_ITEM(i->data), POINT_RG_CENTER, 0, rc.origin, fill_or_stroke, true, false);
- sp_item_gradient_set_coords (SP_ITEM(i->data), POINT_RG_R1, 0, pt, fill_or_stroke, true, false);
+ sp_item_gradient_set_coords (SP_ITEM(i->data), POINT_RG_CENTER, rc.origin, fill_or_stroke, true, false);
+ sp_item_gradient_set_coords (SP_ITEM(i->data), POINT_RG_R1, pt, fill_or_stroke, true, false);
}
SP_OBJECT (i->data)->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
@@ -453,8 +449,7 @@ static void sp_gradient_drag(SPGradientContext &rc, NR::Point const pt, guint st
// give the grab out-of-bounds values of xp/yp because we're already dragging
// and therefore are already out of tolerance
ec->_grdrag->grabKnot (SP_ITEM(selection->itemList()->data),
- type == SP_GRADIENT_TYPE_LINEAR? POINT_LG_END : POINT_RG_R1,
- 0, //point_i
+ type == SP_GRADIENT_TYPE_LINEAR? POINT_LG_P2 : POINT_RG_R1,
fill_or_stroke, 99999, 99999, etime);
}
// We did an undoable action, but sp_document_done will be called by the knot when released
diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp
index 763e5bdb4c8064aa5aa0edd9625e54959b9c3c76..465f57b86e373407db3b9da53945aa842eedb636 100644 (file)
--- a/src/gradient-drag.cpp
+++ b/src/gradient-drag.cpp
// 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
+// knot shapes corresponding to GrPoint 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_LG_P1
+ SP_KNOT_SHAPE_SQUARE,
SP_KNOT_SHAPE_DIAMOND,
SP_KNOT_SHAPE_CIRCLE,
SP_KNOT_SHAPE_CIRCLE,
};
const gchar *gr_knot_descr [] = {
- N_("Linear gradient <b>start</b>"), //POINT_LG_BEGIN
+ N_("Linear gradient <b>start</b>"), //POINT_LG_P1
N_("Linear gradient <b>end</b>"),
- N_("Linear gradient <b>mid</b>"),
N_("Radial gradient <b>center</b>"),
N_("Radial gradient <b>radius</b>"),
N_("Radial gradient <b>radius</b>"),
ret = QUERY_STYLE_MULTIPLE_AVERAGED;
}
- guint32 c = sp_item_gradient_stop_query_style (draggable->item, draggable->point_type, draggable->point_i, draggable->fill_or_stroke);
+ guint32 c = sp_item_gradient_stop_query_style (draggable->item, draggable->point_num, draggable->fill_or_stroke);
cf[0] += SP_RGBA32_R_F (c);
cf[1] += SP_RGBA32_G_F (c);
cf[2] += SP_RGBA32_B_F (c);
GrDraggable *draggable = (GrDraggable *) i->data;
drag->local_change = true;
- sp_item_gradient_stop_set_style (draggable->item, draggable->point_type, draggable->point_i, draggable->fill_or_stroke, stop);
+ sp_item_gradient_stop_set_style (draggable->item, draggable->point_num, draggable->fill_or_stroke, stop);
}
//sp_repr_css_print(stop);
this->updateLevels ();
if (desktop->gr_item) {
- this->setSelected (getDraggerFor (desktop->gr_item, desktop->gr_point_type, desktop->gr_point_i, desktop->gr_fill_or_stroke));
+ this->setSelected (getDraggerFor (desktop->gr_item, desktop->gr_point_num, desktop->gr_fill_or_stroke));
}
}
if (this->selected) {
GrDraggable *draggable = (GrDraggable *) this->selected->draggables->data;
desktop->gr_item = draggable->item;
- desktop->gr_point_type = draggable->point_type;
- desktop->gr_point_i = draggable->point_i;
+ desktop->gr_point_num = draggable->point_num;
desktop->gr_fill_or_stroke = draggable->fill_or_stroke;
} else {
desktop->gr_item = NULL;
- desktop->gr_point_type = 0;
- desktop->gr_point_i = 0;
+ desktop->gr_point_num = 0;
desktop->gr_fill_or_stroke = true;
}
this->lines = NULL;
}
-GrDraggable::GrDraggable (SPItem *item, guint point_type, guint point_i, bool fill_or_stroke)
+GrDraggable::GrDraggable (SPItem *item, guint point_num, bool fill_or_stroke)
{
this->item = item;
- this->point_type = point_type;
- this->point_i = point_i;
+ this->point_num = point_num;
this->fill_or_stroke = fill_or_stroke;
g_object_ref (G_OBJECT (this->item));
@@ -372,7 +367,7 @@ gr_knot_moved_handler(SPKnot *knot, NR::Point const *ppointer, guint state, gpoi
for (GSList const* i = dragger->draggables; i != NULL; i = i->next) { // for all draggables of dragger
GrDraggable *draggable = (GrDraggable *) i->data;
// copy draggable to d_new:
- GrDraggable *da_new = new GrDraggable (draggable->item, draggable->point_type, draggable->point_i, draggable->fill_or_stroke);
+ GrDraggable *da_new = new GrDraggable (draggable->item, draggable->point_num, draggable->fill_or_stroke);
d_new->addDraggable (da_new);
}
@@ -422,14 +417,13 @@ gr_knot_moved_handler(SPKnot *knot, NR::Point const *ppointer, guint state, gpoi
NR::Point *dr_snap = NULL;
- if (draggable->point_type == POINT_LG_BEGIN || draggable->point_type == POINT_LG_END) {
+ if (draggable->point_num == POINT_LG_P1 || draggable->point_num == POINT_LG_P2) {
for (GList *di = dragger->parent->draggers; di != NULL; di = di->next) {
GrDragger *d_new = (GrDragger *) di->data;
if (d_new == dragger)
continue;
if (d_new->isA (draggable->item,
- draggable->point_type == POINT_LG_BEGIN? POINT_LG_END : POINT_LG_BEGIN,
- draggable->point_i,
+ draggable->point_num == POINT_LG_P1? POINT_LG_P2 : POINT_LG_P1,
draggable->fill_or_stroke)) {
// found the other end of the linear gradient;
if (state & GDK_SHIFT_MASK) {
@@ -442,20 +436,19 @@ gr_knot_moved_handler(SPKnot *knot, NR::Point const *ppointer, guint state, gpoi
}
}
}
- } else if (draggable->point_type == POINT_RG_R1 || draggable->point_type == POINT_RG_R2 || draggable->point_type == POINT_RG_FOCUS) {
+ } else if (draggable->point_num == POINT_RG_R1 || draggable->point_num == POINT_RG_R2 || draggable->point_num == POINT_RG_FOCUS) {
for (GList *di = dragger->parent->draggers; di != NULL; di = di->next) {
GrDragger *d_new = (GrDragger *) di->data;
if (d_new == dragger)
continue;
if (d_new->isA (draggable->item,
POINT_RG_CENTER,
- draggable->point_i,
draggable->fill_or_stroke)) {
// found the center of the radial gradient;
dr_snap = &(d_new->point);
}
}
- } else if (draggable->point_type == POINT_RG_CENTER) {
+ } else if (draggable->point_num == POINT_RG_CENTER) {
// radial center snaps to hor/vert relative to its original position
dr_snap = &(dragger->point_original);
}
return;
GrDraggable *draggable = (GrDraggable *) dragger->draggables->data;
- sp_item_gradient_edit_stop (draggable->item, draggable->point_type, draggable->point_i, draggable->fill_or_stroke);
+ sp_item_gradient_edit_stop (draggable->item, draggable->point_num, draggable->fill_or_stroke);
}
/**
@@ -570,20 +563,20 @@ GrDragger::fireDraggables (bool write_repr, bool scale_radial, bool merging_focu
// 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);
+ !(draggable->point_num == POINT_RG_FOCUS && this->isA(draggable->item, POINT_RG_CENTER, draggable->fill_or_stroke)))
+ sp_item_gradient_set_coords (draggable->item, draggable->point_num, this->point, draggable->fill_or_stroke, write_repr, scale_radial);
}
}
/**
-Checks if the dragger has a draggable with this point_type
+Checks if the dragger has a draggable with this point_num
*/
bool
-GrDragger::isA (guint point_type)
+GrDragger::isA (guint point_num)
{
for (GSList const* i = this->draggables; i != NULL; i = i->next) {
GrDraggable *draggable = (GrDraggable *) i->data;
- if (draggable->point_type == point_type) {
+ if (draggable->point_num == point_num) {
return true;
}
}
}
/**
-Checks if the dragger has a draggable with this item, point_type, fill_or_stroke
+Checks if the dragger has a draggable with this item, point_num, fill_or_stroke
*/
bool
-GrDragger::isA (SPItem *item, guint point_type, guint point_i, bool fill_or_stroke)
+GrDragger::isA (SPItem *item, guint point_num, bool fill_or_stroke)
{
for (GSList const* i = this->draggables; i != NULL; i = i->next) {
GrDraggable *draggable = (GrDraggable *) i->data;
- if ( (draggable->point_type == point_type) && (draggable->point_i == point_i) && (draggable->item == item) && (draggable->fill_or_stroke == fill_or_stroke) ) {
+ if (draggable->point_num == point_num && draggable->item == item && draggable->fill_or_stroke == fill_or_stroke) {
return true;
}
}
{
if ((this->item == da2->item) && (this->fill_or_stroke == da2->fill_or_stroke)) {
// we must not merge the points of the same gradient!
- if (!((this->point_type == POINT_RG_FOCUS && da2->point_type == POINT_RG_CENTER) ||
- (this->point_type == POINT_RG_CENTER && da2->point_type == POINT_RG_FOCUS))) {
+ if (!((this->point_num == POINT_RG_FOCUS && da2->point_num == POINT_RG_CENTER) ||
+ (this->point_num == POINT_RG_CENTER && da2->point_num == POINT_RG_FOCUS))) {
// except that we can snap center and focus together
return false;
}
GrDraggable *draggable = (GrDraggable *) this->draggables->data;
char *item_desc = sp_item_description(draggable->item);
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"),
- _(gr_knot_descr[draggable->point_type]),
+ _(gr_knot_descr[draggable->point_num]),
item_desc,
draggable->fill_or_stroke == false ? _(" (stroke)") : "");
g_free(item_desc);
if (!draggables)
return;
GrDraggable *last = (GrDraggable *) g_slist_last(draggables)->data;
- g_object_set (G_OBJECT (this->knot->item), "shape", gr_knot_shapes[last->point_type], NULL);
+ g_object_set (G_OBJECT (this->knot->item), "shape", gr_knot_shapes[last->point_num], NULL);
}
/**
Moves this dragger to the point of the given draggable, acting upon all other draggables
*/
void
-GrDragger::moveThisToDraggable (SPItem *item, guint point_type, guint point_i, bool fill_or_stroke, bool write_repr)
+GrDragger::moveThisToDraggable (SPItem *item, guint point_num, bool fill_or_stroke, bool write_repr)
{
- this->point = sp_item_gradient_get_coords (item, point_type, point_i, fill_or_stroke);
+ this->point = sp_item_gradient_get_coords (item, point_num, fill_or_stroke);
this->point_original = this->point;
sp_knot_moveto (this->knot, &(this->point));
for (GSList const* i = this->draggables; i != NULL; i = i->next) {
GrDraggable *da = (GrDraggable *) i->data;
- if ( (da->item == item) && (da->point_type == point_type) && (da->point_i == point_i) && (da->fill_or_stroke == fill_or_stroke) ) {
+ if (da->item == item && da->point_num == point_num && da->fill_or_stroke == fill_or_stroke) {
continue;
}
- sp_item_gradient_set_coords (da->item, da->point_type, da->point_i, this->point, da->fill_or_stroke, write_repr, false);
+ sp_item_gradient_set_coords (da->item, da->point_num, 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?
}
{
for (GSList const* i = this->draggables; i != NULL; i = i->next) {
GrDraggable *draggable = (GrDraggable *) i->data;
- 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, 0, draggable->fill_or_stroke, write_repr);
-
- // update all midpoints.
- SPObject *server = SP_OBJECT_STYLE_FILL_SERVER (draggable->item);
- guint num = SP_GRADIENT(server)->vector.stops.size();
- if (num > 2) {
- for ( guint i = 1; i < num - 1; i++ ) {
- this->moveOtherToDraggable (draggable->item, POINT_LG_MID, i, draggable->fill_or_stroke, write_repr);
- }
- }
- }
+ switch (draggable->point_num) {
+ case POINT_LG_P1:
+ // the other point is dependent only when dragging with ctrl+shift
+ this->moveOtherToDraggable (draggable->item, POINT_LG_P2, 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);
-
- // update all midpoints.
- SPObject *server = SP_OBJECT_STYLE_FILL_SERVER (draggable->item);
- guint num = SP_GRADIENT(server)->vector.stops.size();
- if (num > 2) {
- for ( guint i = 1; i < num - 1; i++ ) {
- this->moveOtherToDraggable (draggable->item, POINT_LG_MID, i, draggable->fill_or_stroke, write_repr);
- }
- }
- }
- break;
- case POINT_LG_MID:
- // no other nodes depend on mid points.
+ case POINT_LG_P2:
+ this->moveOtherToDraggable (draggable->item, POINT_LG_P1, draggable->fill_or_stroke, write_repr);
break;
case POINT_RG_R2:
- this->moveOtherToDraggable (draggable->item, POINT_RG_R1, 0, draggable->fill_or_stroke, write_repr);
- this->moveOtherToDraggable (draggable->item, POINT_RG_FOCUS, 0, draggable->fill_or_stroke, write_repr);
+ this->moveOtherToDraggable (draggable->item, POINT_RG_R1, draggable->fill_or_stroke, write_repr);
+ this->moveOtherToDraggable (draggable->item, POINT_RG_FOCUS, draggable->fill_or_stroke, write_repr);
break;
case POINT_RG_R1:
- this->moveOtherToDraggable (draggable->item, POINT_RG_R2, 0, draggable->fill_or_stroke, write_repr);
- this->moveOtherToDraggable (draggable->item, POINT_RG_FOCUS, 0, draggable->fill_or_stroke, write_repr);
+ this->moveOtherToDraggable (draggable->item, POINT_RG_R2, draggable->fill_or_stroke, write_repr);
+ this->moveOtherToDraggable (draggable->item, POINT_RG_FOCUS, draggable->fill_or_stroke, write_repr);
break;
case POINT_RG_CENTER:
- this->moveOtherToDraggable (draggable->item, POINT_RG_R1, 0, draggable->fill_or_stroke, write_repr);
- this->moveOtherToDraggable (draggable->item, POINT_RG_R2, 0, draggable->fill_or_stroke, write_repr);
- this->moveOtherToDraggable (draggable->item, POINT_RG_FOCUS, 0, draggable->fill_or_stroke, write_repr);
+ this->moveOtherToDraggable (draggable->item, POINT_RG_R1, draggable->fill_or_stroke, write_repr);
+ this->moveOtherToDraggable (draggable->item, POINT_RG_R2, draggable->fill_or_stroke, write_repr);
+ this->moveOtherToDraggable (draggable->item, POINT_RG_FOCUS, draggable->fill_or_stroke, write_repr);
break;
case POINT_RG_FOCUS:
// nothing can depend on that
Select the dragger which has the given draggable.
*/
GrDragger *
-GrDrag::getDraggerFor (SPItem *item, guint point_type, guint point_i, bool fill_or_stroke)
+GrDrag::getDraggerFor (SPItem *item, guint point_num, bool fill_or_stroke)
{
for (GList const* i = this->draggers; i != NULL; i = i->next) {
GrDragger *dragger = (GrDragger *) i->data;
for (GSList const* j = dragger->draggables; j != NULL; j = j->next) {
GrDraggable *da2 = (GrDraggable *) j->data;
- if ( (da2->item == item) && (da2->point_type == point_type) && (da2->point_i == point_i) && (da2->fill_or_stroke == fill_or_stroke)) {
+ if (da2->item == item && da2->point_num == point_num && da2->fill_or_stroke == fill_or_stroke) {
return (dragger);
}
}
@@ -858,11 +825,11 @@ GrDrag::getDraggerFor (SPItem *item, guint point_type, guint point_i, bool fill_
void
-GrDragger::moveOtherToDraggable (SPItem *item, guint point_type, guint point_i, bool fill_or_stroke, bool write_repr)
+GrDragger::moveOtherToDraggable (SPItem *item, guint point_num, bool fill_or_stroke, bool write_repr)
{
- GrDragger *d = this->parent->getDraggerFor (item, point_type, point_i, fill_or_stroke);
+ GrDragger *d = this->parent->getDraggerFor (item, point_num, fill_or_stroke);
if (d && d != this) {
- d->moveThisToDraggable (item, point_type, point_i, fill_or_stroke, write_repr);
+ d->moveThisToDraggable (item, point_num, fill_or_stroke, write_repr);
}
}
void
GrDrag::addDragger (GrDraggable *draggable)
{
- NR::Point p = sp_item_gradient_get_coords (draggable->item, draggable->point_type, draggable->point_i, draggable->fill_or_stroke);
+ NR::Point p = sp_item_gradient_get_coords (draggable->item, draggable->point_num, draggable->fill_or_stroke);
for (GList *i = this->draggers; i != NULL; i = i->next) {
GrDragger *dragger = (GrDragger *) i->data;
void
GrDrag::addDraggersRadial (SPRadialGradient *rg, SPItem *item, bool fill_or_stroke)
{
- addDragger (new GrDraggable (item, POINT_RG_CENTER, 0, fill_or_stroke));
- addDragger (new GrDraggable (item, POINT_RG_FOCUS, 0, fill_or_stroke));
- addDragger (new GrDraggable (item, POINT_RG_R1, 0, fill_or_stroke));
- addDragger (new GrDraggable (item, POINT_RG_R2, 0, fill_or_stroke));
+ addDragger (new GrDraggable (item, POINT_RG_CENTER, fill_or_stroke));
+ addDragger (new GrDraggable (item, POINT_RG_FOCUS, fill_or_stroke));
+ addDragger (new GrDraggable (item, POINT_RG_R1, fill_or_stroke));
+ addDragger (new GrDraggable (item, POINT_RG_R2, fill_or_stroke));
}
/**
void
GrDrag::addDraggersLinear (SPLinearGradient *lg, SPItem *item, bool fill_or_stroke)
{
- addDragger (new GrDraggable (item, POINT_LG_BEGIN, 0, fill_or_stroke));
-
- // add midstops if any:
- guint num = lg->vector.stops.size();
- if (num > 2) {
- for ( guint i = 1; i < num - 1; i++ ) {
- addDragger (new GrDraggable (item, POINT_LG_MID, i, fill_or_stroke));
- }
- }
-
- addDragger (new GrDraggable (item, POINT_LG_END, 0, fill_or_stroke));
+ addDragger (new GrDraggable (item, POINT_LG_P1, fill_or_stroke));
+ addDragger (new GrDraggable (item, POINT_LG_P2, fill_or_stroke));
}
/**
Artificially grab the knot of the dragger with this draggable; used by the gradient context
*/
void
-GrDrag::grabKnot (SPItem *item, guint point_type, guint point_i, bool fill_or_stroke, gint x, gint y, guint32 etime)
+GrDrag::grabKnot (SPItem *item, guint point_num, bool fill_or_stroke, gint x, gint y, guint32 etime)
{
- GrDragger *dragger = getDraggerFor (item, point_type, point_i, fill_or_stroke);
+ GrDragger *dragger = getDraggerFor (item, point_num, fill_or_stroke);
if (dragger) {
sp_knot_start_dragging (dragger->knot, dragger->point, x, y, etime);
}
if (style && (style->fill.type == SP_PAINT_TYPE_PAINTSERVER)) {
SPObject *server = SP_OBJECT_STYLE_FILL_SERVER (item);
if (SP_IS_LINEARGRADIENT (server)) {
- this->addLine (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);
+ this->addLine (sp_item_gradient_get_coords (item, POINT_LG_P1, true), sp_item_gradient_get_coords (item, POINT_LG_P2, true), GR_LINE_COLOR_FILL);
} else if (SP_IS_RADIALGRADIENT (server)) {
- NR::Point center = sp_item_gradient_get_coords (item, POINT_RG_CENTER, 0, true);
- this->addLine (center, sp_item_gradient_get_coords (item, POINT_RG_R1, 0, true), GR_LINE_COLOR_FILL);
- this->addLine (center, sp_item_gradient_get_coords (item, POINT_RG_R2, 0, true), GR_LINE_COLOR_FILL);
+ NR::Point center = sp_item_gradient_get_coords (item, POINT_RG_CENTER, true);
+ this->addLine (center, sp_item_gradient_get_coords (item, POINT_RG_R1, true), GR_LINE_COLOR_FILL);
+ this->addLine (center, sp_item_gradient_get_coords (item, POINT_RG_R2, true), GR_LINE_COLOR_FILL);
}
}
if (style && (style->stroke.type == SP_PAINT_TYPE_PAINTSERVER)) {
SPObject *server = SP_OBJECT_STYLE_STROKE_SERVER (item);
if (SP_IS_LINEARGRADIENT (server)) {
- this->addLine (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);
+ this->addLine (sp_item_gradient_get_coords (item, POINT_LG_P1, false), sp_item_gradient_get_coords (item, POINT_LG_P2, false), GR_LINE_COLOR_STROKE);
} else if (SP_IS_RADIALGRADIENT (server)) {
- NR::Point center = sp_item_gradient_get_coords (item, POINT_RG_CENTER, 0, false);
- this->addLine (center, sp_item_gradient_get_coords (item, POINT_RG_R1, 0, false), GR_LINE_COLOR_STROKE);
- this->addLine (center, sp_item_gradient_get_coords (item, POINT_RG_R2, 0, false), GR_LINE_COLOR_STROKE);
+ NR::Point center = sp_item_gradient_get_coords (item, POINT_RG_CENTER, false);
+ this->addLine (center, sp_item_gradient_get_coords (item, POINT_RG_R1, false), GR_LINE_COLOR_STROKE);
+ this->addLine (center, sp_item_gradient_get_coords (item, POINT_RG_R2, false), GR_LINE_COLOR_STROKE);
}
}
}
diff --git a/src/gradient-drag.h b/src/gradient-drag.h
index 72e9ce0dd5a31d30d6b87f4ad8becf0306edaf03..365da9b9253beb43b7a6221aa23daca0f2c94754 100644 (file)
--- a/src/gradient-drag.h
+++ b/src/gradient-drag.h
/**
This class represents a single draggable point of a gradient. It remembers the item
-which has the gradient, whether it's fill or stroke, the point type (from the
-GrPointType enum), and the point number (needed if more than 2 stops are present).
+which has the gradient, whether it's fill or stroke, and the point number (from the
+GrPoint enum).
*/
struct GrDraggable {
- GrDraggable(SPItem *item, guint point_type, guint point_i, bool fill_or_stroke);
+ GrDraggable(SPItem *item, guint point_num, bool fill_or_stroke);
~GrDraggable();
SPItem *item;
- guint point_type;
- guint point_i; // the stop number of this point ( = 0 for all types except POINT_LG_MID)
+ guint point_num;
bool fill_or_stroke;
bool mayMerge (GrDraggable *da2);
inline int equals (GrDraggable *other) {
- return ((item == other->item) && (point_type == other->point_type) && (point_i == other->point_i) && (fill_or_stroke == other->fill_or_stroke));
+ return ((item == other->item) && (point_num == other->point_num) && (fill_or_stroke == other->fill_or_stroke));
}
};
void updateKnotShape();
void updateTip();
- void moveThisToDraggable (SPItem *item, guint point_type, guint point_i, bool fill_or_stroke, bool write_repr);
- void moveOtherToDraggable (SPItem *item, guint point_type, guint point_i, bool fill_or_stroke, bool write_repr);
+ void moveThisToDraggable (SPItem *item, guint point_num, bool fill_or_stroke, bool write_repr);
+ void moveOtherToDraggable (SPItem *item, guint point_num, bool fill_or_stroke, bool write_repr);
void updateDependencies (bool write_repr);
bool mayMerge (GrDragger *other);
bool mayMerge (GrDraggable *da2);
- bool isA (guint point_type);
- bool isA (SPItem *item, guint point_type, guint point_i, bool fill_or_stroke);
+ bool isA (guint point_num);
+ bool isA (SPItem *item, guint point_num, bool fill_or_stroke);
void fireDraggables (bool write_repr, bool scale_radial = false, bool merging_focus = false);
};
GrDragger *selected;
void setSelected (GrDragger *dragger);
- GrDragger *getDraggerFor (SPItem *item, guint point_type, guint point_i, bool fill_or_stroke);
+ GrDragger *getDraggerFor (SPItem *item, guint point_num, bool fill_or_stroke);
- void grabKnot (SPItem *item, guint point_type, guint point_i, bool fill_or_stroke, gint x, gint y, guint32 etime);
+ void grabKnot (SPItem *item, guint point_num, bool fill_or_stroke, gint x, gint y, guint32 etime);
bool local_change;
diff --git a/src/sp-gradient.h b/src/sp-gradient.h
index de5247c1c57fc2499a1353a05d8772c708b13fcb..b0ed49c0023d8205c8c6202da7870899eda718cb 100644 (file)
--- a/src/sp-gradient.h
+++ b/src/sp-gradient.h
} SPGradientState;
typedef enum {
- POINT_LG_BEGIN,
- POINT_LG_END,
- POINT_LG_MID,
+ POINT_LG_P1,
+ POINT_LG_P2,
POINT_RG_CENTER,
POINT_RG_R1,
POINT_RG_R2,
POINT_RG_FOCUS
-} GrPointType;
+} GrPoint;
/**
* Gradient